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, call proper function. */
2845 ret
= str2sockunion(peer_str
, &su
);
2847 /* Check for peer by interface */
2848 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2851 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2854 "%% Create the peer-group or interface first or specify \"interface\" keyword\n");
2855 vty_out(vty
, "%% if using an unnumbered interface neighbor\n");
2856 return CMD_WARNING_CONFIG_FAILED
;
2861 if (peer_address_self_check(bgp
, &su
)) {
2863 "%% Can not configure the local system as neighbor\n");
2864 return CMD_WARNING_CONFIG_FAILED
;
2866 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2869 /* This peer belongs to peer group. */
2871 case BGP_ERR_PEER_GROUP_MEMBER
:
2873 "%% Peer-group member cannot override remote-as of peer-group\n");
2874 return CMD_WARNING_CONFIG_FAILED
;
2875 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2877 "%% Peer-group members must be all internal or all external\n");
2878 return CMD_WARNING_CONFIG_FAILED
;
2880 return bgp_vty_return(vty
, ret
);
2883 DEFUN (bgp_default_shutdown
,
2884 bgp_default_shutdown_cmd
,
2885 "[no] bgp default shutdown",
2888 "Configure BGP defaults\n"
2889 "Apply administrative shutdown to newly configured peers\n")
2891 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2892 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2896 DEFUN (neighbor_remote_as
,
2897 neighbor_remote_as_cmd
,
2898 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2901 "Specify a BGP neighbor\n"
2903 "Internal BGP peer\n"
2904 "External BGP peer\n")
2907 int idx_remote_as
= 3;
2908 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2909 argv
[idx_remote_as
]->arg
, AFI_IP
,
2913 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2914 afi_t afi
, safi_t safi
, int v6only
,
2915 const char *peer_group_name
,
2918 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2920 int as_type
= AS_UNSPECIFIED
;
2922 struct peer_group
*group
;
2926 group
= peer_group_lookup(bgp
, conf_if
);
2929 vty_out(vty
, "%% Name conflict with peer-group \n");
2930 return CMD_WARNING_CONFIG_FAILED
;
2934 if (as_str
[0] == 'i') {
2935 as_type
= AS_INTERNAL
;
2936 } else if (as_str
[0] == 'e') {
2937 as_type
= AS_EXTERNAL
;
2939 /* Get AS number. */
2940 as
= strtoul(as_str
, NULL
, 10);
2941 as_type
= AS_SPECIFIED
;
2945 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2948 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
2951 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2952 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2953 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2954 as_type
, 0, 0, NULL
);
2956 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2957 as_type
, afi
, safi
, NULL
);
2960 vty_out(vty
, "%% BGP failed to create peer\n");
2961 return CMD_WARNING_CONFIG_FAILED
;
2965 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2967 /* Request zebra to initiate IPv6 RAs on this interface. We do
2969 * any unnumbered peer in order to not worry about run-time
2971 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2973 * gets deleted later etc.)
2976 bgp_zebra_initiate_radv(bgp
, peer
);
2979 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2980 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2982 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2984 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2986 /* v6only flag changed. Reset bgp seesion */
2987 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2988 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2989 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2990 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2992 bgp_session_reset(peer
);
2995 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
2996 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
2997 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
2998 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
3001 if (peer_group_name
) {
3002 group
= peer_group_lookup(bgp
, peer_group_name
);
3004 vty_out(vty
, "%% Configure the peer-group first\n");
3005 return CMD_WARNING_CONFIG_FAILED
;
3008 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3011 return bgp_vty_return(vty
, ret
);
3014 DEFUN (neighbor_interface_config
,
3015 neighbor_interface_config_cmd
,
3016 "neighbor WORD interface [peer-group WORD]",
3018 "Interface name or neighbor tag\n"
3019 "Enable BGP on interface\n"
3020 "Member of the peer-group\n"
3021 "Peer-group name\n")
3024 int idx_peer_group_word
= 4;
3026 if (argc
> idx_peer_group_word
)
3027 return peer_conf_interface_get(
3028 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
3029 argv
[idx_peer_group_word
]->arg
, NULL
);
3031 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3032 SAFI_UNICAST
, 0, NULL
, NULL
);
3035 DEFUN (neighbor_interface_config_v6only
,
3036 neighbor_interface_config_v6only_cmd
,
3037 "neighbor WORD interface v6only [peer-group WORD]",
3039 "Interface name or neighbor tag\n"
3040 "Enable BGP on interface\n"
3041 "Enable BGP with v6 link-local only\n"
3042 "Member of the peer-group\n"
3043 "Peer-group name\n")
3046 int idx_peer_group_word
= 5;
3048 if (argc
> idx_peer_group_word
)
3049 return peer_conf_interface_get(
3050 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
3051 argv
[idx_peer_group_word
]->arg
, NULL
);
3053 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3054 SAFI_UNICAST
, 1, NULL
, NULL
);
3058 DEFUN (neighbor_interface_config_remote_as
,
3059 neighbor_interface_config_remote_as_cmd
,
3060 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
3062 "Interface name or neighbor tag\n"
3063 "Enable BGP on interface\n"
3064 "Specify a BGP neighbor\n"
3066 "Internal BGP peer\n"
3067 "External BGP peer\n")
3070 int idx_remote_as
= 4;
3071 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3072 SAFI_UNICAST
, 0, NULL
,
3073 argv
[idx_remote_as
]->arg
);
3076 DEFUN (neighbor_interface_v6only_config_remote_as
,
3077 neighbor_interface_v6only_config_remote_as_cmd
,
3078 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
3080 "Interface name or neighbor tag\n"
3081 "Enable BGP with v6 link-local only\n"
3082 "Enable BGP on interface\n"
3083 "Specify a BGP neighbor\n"
3085 "Internal BGP peer\n"
3086 "External BGP peer\n")
3089 int idx_remote_as
= 5;
3090 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3091 SAFI_UNICAST
, 1, NULL
,
3092 argv
[idx_remote_as
]->arg
);
3095 DEFUN (neighbor_peer_group
,
3096 neighbor_peer_group_cmd
,
3097 "neighbor WORD peer-group",
3099 "Interface name or neighbor tag\n"
3100 "Configure peer-group\n")
3102 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3105 struct peer_group
*group
;
3107 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3109 vty_out(vty
, "%% Name conflict with interface: \n");
3110 return CMD_WARNING_CONFIG_FAILED
;
3113 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
3115 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
3116 return CMD_WARNING_CONFIG_FAILED
;
3124 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3128 "Specify a BGP neighbor\n"
3130 "Internal BGP peer\n"
3131 "External BGP peer\n")
3133 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3137 struct peer_group
*group
;
3141 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3143 /* look up for neighbor by interface name config. */
3144 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3146 /* Request zebra to terminate IPv6 RAs on this
3149 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3154 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3156 peer_group_delete(group
);
3158 vty_out(vty
, "%% Create the peer-group first\n");
3159 return CMD_WARNING_CONFIG_FAILED
;
3162 peer
= peer_lookup(bgp
, &su
);
3164 if (peer_dynamic_neighbor(peer
)) {
3166 "%% Operation not allowed on a dynamic neighbor\n");
3167 return CMD_WARNING_CONFIG_FAILED
;
3170 other
= peer
->doppelganger
;
3172 if (other
&& other
->status
!= Deleted
)
3180 DEFUN (no_neighbor_interface_config
,
3181 no_neighbor_interface_config_cmd
,
3182 "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]",
3186 "Configure BGP on interface\n"
3187 "Enable BGP with v6 link-local only\n"
3188 "Member of the peer-group\n"
3190 "Specify a BGP neighbor\n"
3192 "Internal BGP peer\n"
3193 "External BGP peer\n")
3195 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3199 /* look up for neighbor by interface name config. */
3200 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3202 /* Request zebra to terminate IPv6 RAs on this interface. */
3204 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3207 vty_out(vty
, "%% Create the bgp interface first\n");
3208 return CMD_WARNING_CONFIG_FAILED
;
3213 DEFUN (no_neighbor_peer_group
,
3214 no_neighbor_peer_group_cmd
,
3215 "no neighbor WORD peer-group",
3219 "Configure peer-group\n")
3221 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3223 struct peer_group
*group
;
3225 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3227 peer_group_delete(group
);
3229 vty_out(vty
, "%% Create the peer-group first\n");
3230 return CMD_WARNING_CONFIG_FAILED
;
3235 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3236 no_neighbor_interface_peer_group_remote_as_cmd
,
3237 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3240 "Interface name or neighbor tag\n"
3241 "Specify a BGP neighbor\n"
3243 "Internal BGP peer\n"
3244 "External BGP peer\n")
3246 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3248 struct peer_group
*group
;
3251 /* look up for neighbor by interface name config. */
3252 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3254 peer_as_change(peer
, 0, AS_SPECIFIED
);
3258 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3260 peer_group_remote_as_delete(group
);
3262 vty_out(vty
, "%% Create the peer-group or interface first\n");
3263 return CMD_WARNING_CONFIG_FAILED
;
3268 DEFUN (neighbor_local_as
,
3269 neighbor_local_as_cmd
,
3270 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3273 "Specify a local-as number\n"
3274 "AS number used as local AS\n")
3282 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3284 return CMD_WARNING_CONFIG_FAILED
;
3286 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3287 ret
= peer_local_as_set(peer
, as
, 0, 0);
3288 return bgp_vty_return(vty
, ret
);
3291 DEFUN (neighbor_local_as_no_prepend
,
3292 neighbor_local_as_no_prepend_cmd
,
3293 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3296 "Specify a local-as number\n"
3297 "AS number used as local AS\n"
3298 "Do not prepend local-as to updates from ebgp peers\n")
3306 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3308 return CMD_WARNING_CONFIG_FAILED
;
3310 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3311 ret
= peer_local_as_set(peer
, as
, 1, 0);
3312 return bgp_vty_return(vty
, ret
);
3315 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3316 neighbor_local_as_no_prepend_replace_as_cmd
,
3317 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3320 "Specify a local-as number\n"
3321 "AS number used as local AS\n"
3322 "Do not prepend local-as to updates from ebgp peers\n"
3323 "Do not prepend local-as to updates from ibgp peers\n")
3331 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3333 return CMD_WARNING_CONFIG_FAILED
;
3335 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3336 ret
= peer_local_as_set(peer
, as
, 1, 1);
3337 return bgp_vty_return(vty
, ret
);
3340 DEFUN (no_neighbor_local_as
,
3341 no_neighbor_local_as_cmd
,
3342 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3346 "Specify a local-as number\n"
3347 "AS number used as local AS\n"
3348 "Do not prepend local-as to updates from ebgp peers\n"
3349 "Do not prepend local-as to updates from ibgp peers\n")
3355 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3357 return CMD_WARNING_CONFIG_FAILED
;
3359 ret
= peer_local_as_unset(peer
);
3360 return bgp_vty_return(vty
, ret
);
3364 DEFUN (neighbor_solo
,
3366 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3369 "Solo peer - part of its own update group\n")
3375 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3377 return CMD_WARNING_CONFIG_FAILED
;
3379 ret
= update_group_adjust_soloness(peer
, 1);
3380 return bgp_vty_return(vty
, ret
);
3383 DEFUN (no_neighbor_solo
,
3384 no_neighbor_solo_cmd
,
3385 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3389 "Solo peer - part of its own update group\n")
3395 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3397 return CMD_WARNING_CONFIG_FAILED
;
3399 ret
= update_group_adjust_soloness(peer
, 0);
3400 return bgp_vty_return(vty
, ret
);
3403 DEFUN (neighbor_password
,
3404 neighbor_password_cmd
,
3405 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3416 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3418 return CMD_WARNING_CONFIG_FAILED
;
3420 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3421 return bgp_vty_return(vty
, ret
);
3424 DEFUN (no_neighbor_password
,
3425 no_neighbor_password_cmd
,
3426 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3437 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3439 return CMD_WARNING_CONFIG_FAILED
;
3441 ret
= peer_password_unset(peer
);
3442 return bgp_vty_return(vty
, ret
);
3445 DEFUN (neighbor_activate
,
3446 neighbor_activate_cmd
,
3447 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3450 "Enable the Address Family for this Neighbor\n")
3456 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3458 return CMD_WARNING_CONFIG_FAILED
;
3460 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3461 return bgp_vty_return(vty
, ret
);
3464 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3465 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3466 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3467 "Enable the Address Family for this Neighbor\n")
3469 DEFUN (no_neighbor_activate
,
3470 no_neighbor_activate_cmd
,
3471 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3475 "Enable the Address Family for this Neighbor\n")
3482 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3484 return CMD_WARNING_CONFIG_FAILED
;
3486 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3487 return bgp_vty_return(vty
, ret
);
3490 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3491 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3492 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3493 "Enable the Address Family for this Neighbor\n")
3495 DEFUN (neighbor_set_peer_group
,
3496 neighbor_set_peer_group_cmd
,
3497 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3500 "Member of the peer-group\n"
3501 "Peer-group name\n")
3503 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3510 struct peer_group
*group
;
3512 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3514 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3516 vty_out(vty
, "%% Malformed address or name: %s\n",
3517 argv
[idx_peer
]->arg
);
3518 return CMD_WARNING_CONFIG_FAILED
;
3521 if (peer_address_self_check(bgp
, &su
)) {
3523 "%% Can not configure the local system as neighbor\n");
3524 return CMD_WARNING_CONFIG_FAILED
;
3527 /* Disallow for dynamic neighbor. */
3528 peer
= peer_lookup(bgp
, &su
);
3529 if (peer
&& peer_dynamic_neighbor(peer
)) {
3531 "%% Operation not allowed on a dynamic neighbor\n");
3532 return CMD_WARNING_CONFIG_FAILED
;
3536 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3538 vty_out(vty
, "%% Configure the peer-group first\n");
3539 return CMD_WARNING_CONFIG_FAILED
;
3542 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3544 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3546 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3548 return CMD_WARNING_CONFIG_FAILED
;
3551 return bgp_vty_return(vty
, ret
);
3554 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3555 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3556 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3557 "Member of the peer-group\n"
3558 "Peer-group name\n")
3560 DEFUN (no_neighbor_set_peer_group
,
3561 no_neighbor_set_peer_group_cmd
,
3562 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3566 "Member of the peer-group\n"
3567 "Peer-group name\n")
3569 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3574 struct peer_group
*group
;
3576 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3578 return CMD_WARNING_CONFIG_FAILED
;
3580 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3582 vty_out(vty
, "%% Configure the peer-group first\n");
3583 return CMD_WARNING_CONFIG_FAILED
;
3586 ret
= peer_delete(peer
);
3588 return bgp_vty_return(vty
, ret
);
3591 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3592 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3593 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3594 "Member of the peer-group\n"
3595 "Peer-group name\n")
3597 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3598 uint32_t flag
, int set
)
3603 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3605 return CMD_WARNING_CONFIG_FAILED
;
3608 * If 'neighbor <interface>', then this is for directly connected peers,
3609 * we should not accept disable-connected-check.
3611 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3613 "%s is directly connected peer, cannot accept disable-"
3614 "connected-check\n",
3616 return CMD_WARNING_CONFIG_FAILED
;
3619 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3620 peer_tx_shutdown_message_unset(peer
);
3623 ret
= peer_flag_set(peer
, flag
);
3625 ret
= peer_flag_unset(peer
, flag
);
3627 return bgp_vty_return(vty
, ret
);
3630 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3632 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3635 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3638 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3641 /* neighbor passive. */
3642 DEFUN (neighbor_passive
,
3643 neighbor_passive_cmd
,
3644 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3647 "Don't send open messages to this neighbor\n")
3650 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3653 DEFUN (no_neighbor_passive
,
3654 no_neighbor_passive_cmd
,
3655 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3659 "Don't send open messages to this neighbor\n")
3662 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3665 /* neighbor shutdown. */
3666 DEFUN (neighbor_shutdown_msg
,
3667 neighbor_shutdown_msg_cmd
,
3668 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3671 "Administratively shut down this neighbor\n"
3672 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3673 "Shutdown message\n")
3679 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3683 return CMD_WARNING_CONFIG_FAILED
;
3684 message
= argv_concat(argv
, argc
, 4);
3685 peer_tx_shutdown_message_set(peer
, message
);
3686 XFREE(MTYPE_TMP
, message
);
3689 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3692 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3693 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3694 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3695 "Administratively shut down this neighbor\n")
3697 DEFUN (no_neighbor_shutdown_msg
,
3698 no_neighbor_shutdown_msg_cmd
,
3699 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3703 "Administratively shut down this neighbor\n"
3704 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3705 "Shutdown message\n")
3709 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3710 PEER_FLAG_SHUTDOWN
);
3713 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3714 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3715 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3716 "Administratively shut down this neighbor\n")
3718 /* neighbor capability dynamic. */
3719 DEFUN (neighbor_capability_dynamic
,
3720 neighbor_capability_dynamic_cmd
,
3721 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3724 "Advertise capability to the peer\n"
3725 "Advertise dynamic capability to this neighbor\n")
3728 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3729 PEER_FLAG_DYNAMIC_CAPABILITY
);
3732 DEFUN (no_neighbor_capability_dynamic
,
3733 no_neighbor_capability_dynamic_cmd
,
3734 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3738 "Advertise capability to the peer\n"
3739 "Advertise dynamic capability to this neighbor\n")
3742 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3743 PEER_FLAG_DYNAMIC_CAPABILITY
);
3746 /* neighbor dont-capability-negotiate */
3747 DEFUN (neighbor_dont_capability_negotiate
,
3748 neighbor_dont_capability_negotiate_cmd
,
3749 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3752 "Do not perform capability negotiation\n")
3755 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3756 PEER_FLAG_DONT_CAPABILITY
);
3759 DEFUN (no_neighbor_dont_capability_negotiate
,
3760 no_neighbor_dont_capability_negotiate_cmd
,
3761 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3765 "Do not perform capability negotiation\n")
3768 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3769 PEER_FLAG_DONT_CAPABILITY
);
3772 /* neighbor capability extended next hop encoding */
3773 DEFUN (neighbor_capability_enhe
,
3774 neighbor_capability_enhe_cmd
,
3775 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3778 "Advertise capability to the peer\n"
3779 "Advertise extended next-hop capability to the peer\n")
3782 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3783 PEER_FLAG_CAPABILITY_ENHE
);
3786 DEFUN (no_neighbor_capability_enhe
,
3787 no_neighbor_capability_enhe_cmd
,
3788 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3792 "Advertise capability to the peer\n"
3793 "Advertise extended next-hop capability to the peer\n")
3796 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3797 PEER_FLAG_CAPABILITY_ENHE
);
3800 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3801 afi_t afi
, safi_t safi
, uint32_t flag
,
3807 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3809 return CMD_WARNING_CONFIG_FAILED
;
3812 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3814 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3816 return bgp_vty_return(vty
, ret
);
3819 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3820 afi_t afi
, safi_t safi
, uint32_t flag
)
3822 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3825 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3826 afi_t afi
, safi_t safi
, uint32_t flag
)
3828 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3831 /* neighbor capability orf prefix-list. */
3832 DEFUN (neighbor_capability_orf_prefix
,
3833 neighbor_capability_orf_prefix_cmd
,
3834 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3837 "Advertise capability to the peer\n"
3838 "Advertise ORF capability to the peer\n"
3839 "Advertise prefixlist ORF capability to this neighbor\n"
3840 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3841 "Capability to RECEIVE the ORF from this neighbor\n"
3842 "Capability to SEND the ORF to this neighbor\n")
3845 int idx_send_recv
= 5;
3848 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3849 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3850 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3851 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3852 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3853 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3855 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3856 return CMD_WARNING_CONFIG_FAILED
;
3859 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3860 bgp_node_safi(vty
), flag
);
3864 neighbor_capability_orf_prefix
,
3865 neighbor_capability_orf_prefix_hidden_cmd
,
3866 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3867 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3868 "Advertise capability to the peer\n"
3869 "Advertise ORF capability to the peer\n"
3870 "Advertise prefixlist ORF capability to this neighbor\n"
3871 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3872 "Capability to RECEIVE the ORF from this neighbor\n"
3873 "Capability to SEND the ORF to this neighbor\n")
3875 DEFUN (no_neighbor_capability_orf_prefix
,
3876 no_neighbor_capability_orf_prefix_cmd
,
3877 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3881 "Advertise capability to the peer\n"
3882 "Advertise ORF capability to the peer\n"
3883 "Advertise prefixlist ORF capability to this neighbor\n"
3884 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3885 "Capability to RECEIVE the ORF from this neighbor\n"
3886 "Capability to SEND the ORF to this neighbor\n")
3889 int idx_send_recv
= 6;
3892 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3893 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3894 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3895 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3896 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3897 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3899 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3900 return CMD_WARNING_CONFIG_FAILED
;
3903 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3904 bgp_node_afi(vty
), bgp_node_safi(vty
),
3909 no_neighbor_capability_orf_prefix
,
3910 no_neighbor_capability_orf_prefix_hidden_cmd
,
3911 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3912 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3913 "Advertise capability to the peer\n"
3914 "Advertise ORF capability to the peer\n"
3915 "Advertise prefixlist ORF capability to this neighbor\n"
3916 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3917 "Capability to RECEIVE the ORF from this neighbor\n"
3918 "Capability to SEND the ORF to this neighbor\n")
3920 /* neighbor next-hop-self. */
3921 DEFUN (neighbor_nexthop_self
,
3922 neighbor_nexthop_self_cmd
,
3923 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3926 "Disable the next hop calculation for this neighbor\n")
3929 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3930 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3933 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3934 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3935 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3936 "Disable the next hop calculation for this neighbor\n")
3938 /* neighbor next-hop-self. */
3939 DEFUN (neighbor_nexthop_self_force
,
3940 neighbor_nexthop_self_force_cmd
,
3941 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3944 "Disable the next hop calculation for this neighbor\n"
3945 "Set the next hop to self for reflected routes\n")
3948 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3950 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3953 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3954 neighbor_nexthop_self_force_hidden_cmd
,
3955 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3956 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3957 "Disable the next hop calculation for this neighbor\n"
3958 "Set the next hop to self for reflected routes\n")
3960 DEFUN (no_neighbor_nexthop_self
,
3961 no_neighbor_nexthop_self_cmd
,
3962 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3966 "Disable the next hop calculation for this neighbor\n")
3969 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3970 bgp_node_afi(vty
), bgp_node_safi(vty
),
3971 PEER_FLAG_NEXTHOP_SELF
);
3974 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3975 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3976 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3977 "Disable the next hop calculation for this neighbor\n")
3979 DEFUN (no_neighbor_nexthop_self_force
,
3980 no_neighbor_nexthop_self_force_cmd
,
3981 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3985 "Disable the next hop calculation for this neighbor\n"
3986 "Set the next hop to self for reflected routes\n")
3989 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3990 bgp_node_afi(vty
), bgp_node_safi(vty
),
3991 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3994 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3995 no_neighbor_nexthop_self_force_hidden_cmd
,
3996 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3997 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3998 "Disable the next hop calculation for this neighbor\n"
3999 "Set the next hop to self for reflected routes\n")
4001 /* neighbor as-override */
4002 DEFUN (neighbor_as_override
,
4003 neighbor_as_override_cmd
,
4004 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4007 "Override ASNs in outbound updates if aspath equals remote-as\n")
4010 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4011 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
4014 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
4015 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4016 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4017 "Override ASNs in outbound updates if aspath equals remote-as\n")
4019 DEFUN (no_neighbor_as_override
,
4020 no_neighbor_as_override_cmd
,
4021 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4025 "Override ASNs in outbound updates if aspath equals remote-as\n")
4028 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4029 bgp_node_afi(vty
), bgp_node_safi(vty
),
4030 PEER_FLAG_AS_OVERRIDE
);
4033 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
4034 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4035 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4036 "Override ASNs in outbound updates if aspath equals remote-as\n")
4038 /* neighbor remove-private-AS. */
4039 DEFUN (neighbor_remove_private_as
,
4040 neighbor_remove_private_as_cmd
,
4041 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4044 "Remove private ASNs in outbound updates\n")
4047 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4049 PEER_FLAG_REMOVE_PRIVATE_AS
);
4052 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
4053 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4054 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4055 "Remove private ASNs in outbound updates\n")
4057 DEFUN (neighbor_remove_private_as_all
,
4058 neighbor_remove_private_as_all_cmd
,
4059 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4062 "Remove private ASNs in outbound updates\n"
4063 "Apply to all AS numbers\n")
4066 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4068 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4071 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
4072 neighbor_remove_private_as_all_hidden_cmd
,
4073 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4074 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4075 "Remove private ASNs in outbound updates\n"
4076 "Apply to all AS numbers")
4078 DEFUN (neighbor_remove_private_as_replace_as
,
4079 neighbor_remove_private_as_replace_as_cmd
,
4080 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4083 "Remove private ASNs in outbound updates\n"
4084 "Replace private ASNs with our ASN in outbound updates\n")
4087 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4089 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4092 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
4093 neighbor_remove_private_as_replace_as_hidden_cmd
,
4094 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4095 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4096 "Remove private ASNs in outbound updates\n"
4097 "Replace private ASNs with our ASN in outbound updates\n")
4099 DEFUN (neighbor_remove_private_as_all_replace_as
,
4100 neighbor_remove_private_as_all_replace_as_cmd
,
4101 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4104 "Remove private ASNs in outbound updates\n"
4105 "Apply to all AS numbers\n"
4106 "Replace private ASNs with our ASN in outbound updates\n")
4109 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4111 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4115 neighbor_remove_private_as_all_replace_as
,
4116 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4117 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4118 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4119 "Remove private ASNs in outbound updates\n"
4120 "Apply to all AS numbers\n"
4121 "Replace private ASNs with our ASN in outbound updates\n")
4123 DEFUN (no_neighbor_remove_private_as
,
4124 no_neighbor_remove_private_as_cmd
,
4125 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4129 "Remove private ASNs in outbound updates\n")
4132 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4133 bgp_node_afi(vty
), bgp_node_safi(vty
),
4134 PEER_FLAG_REMOVE_PRIVATE_AS
);
4137 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4138 no_neighbor_remove_private_as_hidden_cmd
,
4139 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4140 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4141 "Remove private ASNs in outbound updates\n")
4143 DEFUN (no_neighbor_remove_private_as_all
,
4144 no_neighbor_remove_private_as_all_cmd
,
4145 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4149 "Remove private ASNs in outbound updates\n"
4150 "Apply to all AS numbers\n")
4153 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4154 bgp_node_afi(vty
), bgp_node_safi(vty
),
4155 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4158 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4159 no_neighbor_remove_private_as_all_hidden_cmd
,
4160 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4161 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4162 "Remove private ASNs in outbound updates\n"
4163 "Apply to all AS numbers\n")
4165 DEFUN (no_neighbor_remove_private_as_replace_as
,
4166 no_neighbor_remove_private_as_replace_as_cmd
,
4167 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4171 "Remove private ASNs in outbound updates\n"
4172 "Replace private ASNs with our ASN in outbound updates\n")
4175 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4176 bgp_node_afi(vty
), bgp_node_safi(vty
),
4177 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4180 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4181 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4182 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4183 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4184 "Remove private ASNs in outbound updates\n"
4185 "Replace private ASNs with our ASN in outbound updates\n")
4187 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4188 no_neighbor_remove_private_as_all_replace_as_cmd
,
4189 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4193 "Remove private ASNs in outbound updates\n"
4194 "Apply to all AS numbers\n"
4195 "Replace private ASNs with our ASN in outbound updates\n")
4198 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4199 bgp_node_afi(vty
), bgp_node_safi(vty
),
4200 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4204 no_neighbor_remove_private_as_all_replace_as
,
4205 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4206 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4207 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4208 "Remove private ASNs in outbound updates\n"
4209 "Apply to all AS numbers\n"
4210 "Replace private ASNs with our ASN in outbound updates\n")
4213 /* neighbor send-community. */
4214 DEFUN (neighbor_send_community
,
4215 neighbor_send_community_cmd
,
4216 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4219 "Send Community attribute to this neighbor\n")
4223 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4225 PEER_FLAG_SEND_COMMUNITY
);
4228 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4229 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4230 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4231 "Send Community attribute to this neighbor\n")
4233 DEFUN (no_neighbor_send_community
,
4234 no_neighbor_send_community_cmd
,
4235 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4239 "Send Community attribute to this neighbor\n")
4243 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4244 bgp_node_afi(vty
), bgp_node_safi(vty
),
4245 PEER_FLAG_SEND_COMMUNITY
);
4248 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4249 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4250 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4251 "Send Community attribute to this neighbor\n")
4253 /* neighbor send-community extended. */
4254 DEFUN (neighbor_send_community_type
,
4255 neighbor_send_community_type_cmd
,
4256 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4259 "Send Community attribute to this neighbor\n"
4260 "Send Standard and Extended Community attributes\n"
4261 "Send Standard, Large and Extended Community attributes\n"
4262 "Send Extended Community attributes\n"
4263 "Send Standard Community attributes\n"
4264 "Send Large Community attributes\n")
4268 const char *type
= argv
[argc
- 1]->text
;
4270 if (strmatch(type
, "standard")) {
4271 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4272 } else if (strmatch(type
, "extended")) {
4273 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4274 } else if (strmatch(type
, "large")) {
4275 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4276 } else if (strmatch(type
, "both")) {
4277 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4278 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4279 } else { /* if (strmatch(type, "all")) */
4280 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4281 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4282 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4285 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4286 bgp_node_safi(vty
), flag
);
4290 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4291 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4292 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4293 "Send Community attribute to this neighbor\n"
4294 "Send Standard and Extended Community attributes\n"
4295 "Send Standard, Large and Extended Community attributes\n"
4296 "Send Extended Community attributes\n"
4297 "Send Standard Community attributes\n"
4298 "Send Large Community attributes\n")
4300 DEFUN (no_neighbor_send_community_type
,
4301 no_neighbor_send_community_type_cmd
,
4302 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4306 "Send Community attribute to this neighbor\n"
4307 "Send Standard and Extended Community attributes\n"
4308 "Send Standard, Large and Extended Community attributes\n"
4309 "Send Extended Community attributes\n"
4310 "Send Standard Community attributes\n"
4311 "Send Large Community attributes\n")
4315 const char *type
= argv
[argc
- 1]->text
;
4317 if (strmatch(type
, "standard")) {
4318 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4319 } else if (strmatch(type
, "extended")) {
4320 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4321 } else if (strmatch(type
, "large")) {
4322 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4323 } else if (strmatch(type
, "both")) {
4324 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4325 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4326 } else { /* if (strmatch(type, "all")) */
4327 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4328 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4329 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4332 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4333 bgp_node_afi(vty
), bgp_node_safi(vty
),
4338 no_neighbor_send_community_type
,
4339 no_neighbor_send_community_type_hidden_cmd
,
4340 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4341 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4342 "Send Community attribute to this neighbor\n"
4343 "Send Standard and Extended Community attributes\n"
4344 "Send Standard, Large and Extended Community attributes\n"
4345 "Send Extended Community attributes\n"
4346 "Send Standard Community attributes\n"
4347 "Send Large Community attributes\n")
4349 /* neighbor soft-reconfig. */
4350 DEFUN (neighbor_soft_reconfiguration
,
4351 neighbor_soft_reconfiguration_cmd
,
4352 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4355 "Per neighbor soft reconfiguration\n"
4356 "Allow inbound soft reconfiguration for this neighbor\n")
4359 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4361 PEER_FLAG_SOFT_RECONFIG
);
4364 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4365 neighbor_soft_reconfiguration_hidden_cmd
,
4366 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4367 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4368 "Per neighbor soft reconfiguration\n"
4369 "Allow inbound soft reconfiguration for this neighbor\n")
4371 DEFUN (no_neighbor_soft_reconfiguration
,
4372 no_neighbor_soft_reconfiguration_cmd
,
4373 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4377 "Per neighbor soft reconfiguration\n"
4378 "Allow inbound soft reconfiguration for this neighbor\n")
4381 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4382 bgp_node_afi(vty
), bgp_node_safi(vty
),
4383 PEER_FLAG_SOFT_RECONFIG
);
4386 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4387 no_neighbor_soft_reconfiguration_hidden_cmd
,
4388 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4389 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4390 "Per neighbor soft reconfiguration\n"
4391 "Allow inbound soft reconfiguration for this neighbor\n")
4393 DEFUN (neighbor_route_reflector_client
,
4394 neighbor_route_reflector_client_cmd
,
4395 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4398 "Configure a neighbor as Route Reflector client\n")
4404 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4406 return CMD_WARNING_CONFIG_FAILED
;
4408 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4410 PEER_FLAG_REFLECTOR_CLIENT
);
4413 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4414 neighbor_route_reflector_client_hidden_cmd
,
4415 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4416 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4417 "Configure a neighbor as Route Reflector client\n")
4419 DEFUN (no_neighbor_route_reflector_client
,
4420 no_neighbor_route_reflector_client_cmd
,
4421 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4425 "Configure a neighbor as Route Reflector client\n")
4428 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4429 bgp_node_afi(vty
), bgp_node_safi(vty
),
4430 PEER_FLAG_REFLECTOR_CLIENT
);
4433 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4434 no_neighbor_route_reflector_client_hidden_cmd
,
4435 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4436 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4437 "Configure a neighbor as Route Reflector client\n")
4439 /* neighbor route-server-client. */
4440 DEFUN (neighbor_route_server_client
,
4441 neighbor_route_server_client_cmd
,
4442 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4445 "Configure a neighbor as Route Server client\n")
4450 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4452 return CMD_WARNING_CONFIG_FAILED
;
4453 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4455 PEER_FLAG_RSERVER_CLIENT
);
4458 ALIAS_HIDDEN(neighbor_route_server_client
,
4459 neighbor_route_server_client_hidden_cmd
,
4460 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4461 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4462 "Configure a neighbor as Route Server client\n")
4464 DEFUN (no_neighbor_route_server_client
,
4465 no_neighbor_route_server_client_cmd
,
4466 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4470 "Configure a neighbor as Route Server client\n")
4473 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4474 bgp_node_afi(vty
), bgp_node_safi(vty
),
4475 PEER_FLAG_RSERVER_CLIENT
);
4478 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4479 no_neighbor_route_server_client_hidden_cmd
,
4480 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4481 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4482 "Configure a neighbor as Route Server client\n")
4484 DEFUN (neighbor_nexthop_local_unchanged
,
4485 neighbor_nexthop_local_unchanged_cmd
,
4486 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4489 "Configure treatment of outgoing link-local nexthop attribute\n"
4490 "Leave link-local nexthop unchanged for this peer\n")
4493 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4495 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4498 DEFUN (no_neighbor_nexthop_local_unchanged
,
4499 no_neighbor_nexthop_local_unchanged_cmd
,
4500 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4504 "Configure treatment of outgoing link-local-nexthop attribute\n"
4505 "Leave link-local nexthop unchanged for this peer\n")
4508 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4509 bgp_node_afi(vty
), bgp_node_safi(vty
),
4510 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4513 DEFUN (neighbor_attr_unchanged
,
4514 neighbor_attr_unchanged_cmd
,
4515 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4518 "BGP attribute is propagated unchanged to this neighbor\n"
4519 "As-path attribute\n"
4520 "Nexthop attribute\n"
4524 char *peer_str
= argv
[1]->arg
;
4527 afi_t afi
= bgp_node_afi(vty
);
4528 safi_t safi
= bgp_node_safi(vty
);
4530 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4532 return CMD_WARNING_CONFIG_FAILED
;
4534 if (argv_find(argv
, argc
, "as-path", &idx
))
4535 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4537 if (argv_find(argv
, argc
, "next-hop", &idx
))
4538 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4540 if (argv_find(argv
, argc
, "med", &idx
))
4541 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4543 /* no flags means all of them! */
4545 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4546 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4547 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4549 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4550 && peer_af_flag_check(peer
, afi
, safi
,
4551 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4552 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4553 PEER_FLAG_AS_PATH_UNCHANGED
);
4556 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4557 && peer_af_flag_check(peer
, afi
, safi
,
4558 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4559 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4560 PEER_FLAG_NEXTHOP_UNCHANGED
);
4563 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4564 && peer_af_flag_check(peer
, afi
, safi
,
4565 PEER_FLAG_MED_UNCHANGED
)) {
4566 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4567 PEER_FLAG_MED_UNCHANGED
);
4571 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4575 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4576 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4577 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4578 "BGP attribute is propagated unchanged to this neighbor\n"
4579 "As-path attribute\n"
4580 "Nexthop attribute\n"
4583 DEFUN (no_neighbor_attr_unchanged
,
4584 no_neighbor_attr_unchanged_cmd
,
4585 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4589 "BGP attribute is propagated unchanged to this neighbor\n"
4590 "As-path attribute\n"
4591 "Nexthop attribute\n"
4595 char *peer
= argv
[2]->arg
;
4598 if (argv_find(argv
, argc
, "as-path", &idx
))
4599 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4601 if (argv_find(argv
, argc
, "next-hop", &idx
))
4602 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4604 if (argv_find(argv
, argc
, "med", &idx
))
4605 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4607 if (!flags
) // no flags means all of them!
4609 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4610 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4611 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4614 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4615 bgp_node_safi(vty
), flags
);
4619 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4620 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4621 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4622 "BGP attribute is propagated unchanged to this neighbor\n"
4623 "As-path attribute\n"
4624 "Nexthop attribute\n"
4627 /* EBGP multihop configuration. */
4628 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4629 const char *ttl_str
)
4634 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4636 return CMD_WARNING_CONFIG_FAILED
;
4639 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4644 ttl
= strtoul(ttl_str
, NULL
, 10);
4646 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4649 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4653 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4655 return CMD_WARNING_CONFIG_FAILED
;
4657 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4660 /* neighbor ebgp-multihop. */
4661 DEFUN (neighbor_ebgp_multihop
,
4662 neighbor_ebgp_multihop_cmd
,
4663 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4666 "Allow EBGP neighbors not on directly connected networks\n")
4669 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4672 DEFUN (neighbor_ebgp_multihop_ttl
,
4673 neighbor_ebgp_multihop_ttl_cmd
,
4674 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4677 "Allow EBGP neighbors not on directly connected networks\n"
4678 "maximum hop count\n")
4682 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4683 argv
[idx_number
]->arg
);
4686 DEFUN (no_neighbor_ebgp_multihop
,
4687 no_neighbor_ebgp_multihop_cmd
,
4688 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4692 "Allow EBGP neighbors not on directly connected networks\n"
4693 "maximum hop count\n")
4696 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4700 /* disable-connected-check */
4701 DEFUN (neighbor_disable_connected_check
,
4702 neighbor_disable_connected_check_cmd
,
4703 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4706 "one-hop away EBGP peer using loopback address\n"
4707 "Enforce EBGP neighbors perform multihop\n")
4710 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4711 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4714 DEFUN (no_neighbor_disable_connected_check
,
4715 no_neighbor_disable_connected_check_cmd
,
4716 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4720 "one-hop away EBGP peer using loopback address\n"
4721 "Enforce EBGP neighbors perform multihop\n")
4724 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4725 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4729 /* enforce-first-as */
4730 DEFUN (neighbor_enforce_first_as
,
4731 neighbor_enforce_first_as_cmd
,
4732 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4735 "Enforce the first AS for EBGP routes\n")
4739 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4740 PEER_FLAG_ENFORCE_FIRST_AS
);
4743 DEFUN (no_neighbor_enforce_first_as
,
4744 no_neighbor_enforce_first_as_cmd
,
4745 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4749 "Enforce the first AS for EBGP routes\n")
4753 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4754 PEER_FLAG_ENFORCE_FIRST_AS
);
4758 DEFUN (neighbor_description
,
4759 neighbor_description_cmd
,
4760 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4763 "Neighbor specific description\n"
4764 "Up to 80 characters describing this neighbor\n")
4771 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4773 return CMD_WARNING_CONFIG_FAILED
;
4775 str
= argv_concat(argv
, argc
, idx_line
);
4777 peer_description_set(peer
, str
);
4779 XFREE(MTYPE_TMP
, str
);
4784 DEFUN (no_neighbor_description
,
4785 no_neighbor_description_cmd
,
4786 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4790 "Neighbor specific description\n")
4795 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4797 return CMD_WARNING_CONFIG_FAILED
;
4799 peer_description_unset(peer
);
4804 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4805 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4806 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4807 "Neighbor specific description\n"
4808 "Up to 80 characters describing this neighbor\n")
4810 /* Neighbor update-source. */
4811 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4812 const char *source_str
)
4818 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4820 return CMD_WARNING_CONFIG_FAILED
;
4826 if (str2sockunion(source_str
, &su
) == 0)
4827 peer_update_source_addr_set(peer
, &su
);
4829 if (str2prefix(source_str
, &p
)) {
4831 "%% Invalid update-source, remove prefix length \n");
4832 return CMD_WARNING_CONFIG_FAILED
;
4834 peer_update_source_if_set(peer
, source_str
);
4837 peer_update_source_unset(peer
);
4842 #define BGP_UPDATE_SOURCE_HELP_STR \
4845 "Interface name (requires zebra to be running)\n"
4847 DEFUN (neighbor_update_source
,
4848 neighbor_update_source_cmd
,
4849 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4852 "Source of routing updates\n"
4853 BGP_UPDATE_SOURCE_HELP_STR
)
4857 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4858 argv
[idx_peer_2
]->arg
);
4861 DEFUN (no_neighbor_update_source
,
4862 no_neighbor_update_source_cmd
,
4863 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4867 "Source of routing updates\n"
4868 BGP_UPDATE_SOURCE_HELP_STR
)
4871 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4874 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4875 afi_t afi
, safi_t safi
,
4876 const char *rmap
, int set
)
4880 struct route_map
*route_map
;
4882 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4884 return CMD_WARNING_CONFIG_FAILED
;
4887 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
4888 ret
= peer_default_originate_set(peer
, afi
, safi
,
4891 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4893 return bgp_vty_return(vty
, ret
);
4896 /* neighbor default-originate. */
4897 DEFUN (neighbor_default_originate
,
4898 neighbor_default_originate_cmd
,
4899 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4902 "Originate default route to this neighbor\n")
4905 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4907 bgp_node_safi(vty
), NULL
, 1);
4910 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4911 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4912 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4913 "Originate default route to this neighbor\n")
4915 DEFUN (neighbor_default_originate_rmap
,
4916 neighbor_default_originate_rmap_cmd
,
4917 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4920 "Originate default route to this neighbor\n"
4921 "Route-map to specify criteria to originate default\n"
4926 return peer_default_originate_set_vty(
4927 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4928 argv
[idx_word
]->arg
, 1);
4932 neighbor_default_originate_rmap
,
4933 neighbor_default_originate_rmap_hidden_cmd
,
4934 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4935 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4936 "Originate default route to this neighbor\n"
4937 "Route-map to specify criteria to originate default\n"
4940 DEFUN (no_neighbor_default_originate
,
4941 no_neighbor_default_originate_cmd
,
4942 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4946 "Originate default route to this neighbor\n"
4947 "Route-map to specify criteria to originate default\n"
4951 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4953 bgp_node_safi(vty
), NULL
, 0);
4957 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4958 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4959 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4960 "Originate default route to this neighbor\n"
4961 "Route-map to specify criteria to originate default\n"
4965 /* Set neighbor's BGP port. */
4966 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4967 const char *port_str
)
4973 peer
= peer_lookup_vty(vty
, ip_str
);
4975 return CMD_WARNING_CONFIG_FAILED
;
4978 sp
= getservbyname("bgp", "tcp");
4979 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
4981 port
= strtoul(port_str
, NULL
, 10);
4984 peer_port_set(peer
, port
);
4989 /* Set specified peer's BGP port. */
4990 DEFUN (neighbor_port
,
4992 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
4995 "Neighbor's BGP port\n"
4996 "TCP port number\n")
5000 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
5001 argv
[idx_number
]->arg
);
5004 DEFUN (no_neighbor_port
,
5005 no_neighbor_port_cmd
,
5006 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
5010 "Neighbor's BGP port\n"
5011 "TCP port number\n")
5014 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
5018 /* neighbor weight. */
5019 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5020 safi_t safi
, const char *weight_str
)
5024 unsigned long weight
;
5026 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5028 return CMD_WARNING_CONFIG_FAILED
;
5030 weight
= strtoul(weight_str
, NULL
, 10);
5032 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
5033 return bgp_vty_return(vty
, ret
);
5036 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5042 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5044 return CMD_WARNING_CONFIG_FAILED
;
5046 ret
= peer_weight_unset(peer
, afi
, safi
);
5047 return bgp_vty_return(vty
, ret
);
5050 DEFUN (neighbor_weight
,
5051 neighbor_weight_cmd
,
5052 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5055 "Set default weight for routes from this neighbor\n"
5060 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5061 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
5064 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
5065 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5066 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5067 "Set default weight for routes from this neighbor\n"
5070 DEFUN (no_neighbor_weight
,
5071 no_neighbor_weight_cmd
,
5072 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5076 "Set default weight for routes from this neighbor\n"
5080 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
5081 bgp_node_afi(vty
), bgp_node_safi(vty
));
5084 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
5085 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5086 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5087 "Set default weight for routes from this neighbor\n"
5091 /* Override capability negotiation. */
5092 DEFUN (neighbor_override_capability
,
5093 neighbor_override_capability_cmd
,
5094 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5097 "Override capability negotiation result\n")
5100 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5101 PEER_FLAG_OVERRIDE_CAPABILITY
);
5104 DEFUN (no_neighbor_override_capability
,
5105 no_neighbor_override_capability_cmd
,
5106 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5110 "Override capability negotiation result\n")
5113 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5114 PEER_FLAG_OVERRIDE_CAPABILITY
);
5117 DEFUN (neighbor_strict_capability
,
5118 neighbor_strict_capability_cmd
,
5119 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5122 "Strict capability negotiation match\n")
5126 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5127 PEER_FLAG_STRICT_CAP_MATCH
);
5130 DEFUN (no_neighbor_strict_capability
,
5131 no_neighbor_strict_capability_cmd
,
5132 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5136 "Strict capability negotiation match\n")
5140 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5141 PEER_FLAG_STRICT_CAP_MATCH
);
5144 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5145 const char *keep_str
, const char *hold_str
)
5152 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5154 return CMD_WARNING_CONFIG_FAILED
;
5156 keepalive
= strtoul(keep_str
, NULL
, 10);
5157 holdtime
= strtoul(hold_str
, NULL
, 10);
5159 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5161 return bgp_vty_return(vty
, ret
);
5164 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5169 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5171 return CMD_WARNING_CONFIG_FAILED
;
5173 ret
= peer_timers_unset(peer
);
5175 return bgp_vty_return(vty
, ret
);
5178 DEFUN (neighbor_timers
,
5179 neighbor_timers_cmd
,
5180 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5183 "BGP per neighbor timers\n"
5184 "Keepalive interval\n"
5189 int idx_number_2
= 4;
5190 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5191 argv
[idx_number
]->arg
,
5192 argv
[idx_number_2
]->arg
);
5195 DEFUN (no_neighbor_timers
,
5196 no_neighbor_timers_cmd
,
5197 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5201 "BGP per neighbor timers\n"
5202 "Keepalive interval\n"
5206 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5210 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5211 const char *time_str
)
5217 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5219 return CMD_WARNING_CONFIG_FAILED
;
5221 connect
= strtoul(time_str
, NULL
, 10);
5223 ret
= peer_timers_connect_set(peer
, connect
);
5225 return bgp_vty_return(vty
, ret
);
5228 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5233 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5235 return CMD_WARNING_CONFIG_FAILED
;
5237 ret
= peer_timers_connect_unset(peer
);
5239 return bgp_vty_return(vty
, ret
);
5242 DEFUN (neighbor_timers_connect
,
5243 neighbor_timers_connect_cmd
,
5244 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5247 "BGP per neighbor timers\n"
5248 "BGP connect timer\n"
5253 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5254 argv
[idx_number
]->arg
);
5257 DEFUN (no_neighbor_timers_connect
,
5258 no_neighbor_timers_connect_cmd
,
5259 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5263 "BGP per neighbor timers\n"
5264 "BGP connect timer\n"
5268 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5272 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5273 const char *time_str
, int set
)
5277 uint32_t routeadv
= 0;
5279 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5281 return CMD_WARNING_CONFIG_FAILED
;
5284 routeadv
= strtoul(time_str
, NULL
, 10);
5287 ret
= peer_advertise_interval_set(peer
, routeadv
);
5289 ret
= peer_advertise_interval_unset(peer
);
5291 return bgp_vty_return(vty
, ret
);
5294 DEFUN (neighbor_advertise_interval
,
5295 neighbor_advertise_interval_cmd
,
5296 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5299 "Minimum interval between sending BGP routing updates\n"
5300 "time in seconds\n")
5304 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5305 argv
[idx_number
]->arg
, 1);
5308 DEFUN (no_neighbor_advertise_interval
,
5309 no_neighbor_advertise_interval_cmd
,
5310 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5314 "Minimum interval between sending BGP routing updates\n"
5315 "time in seconds\n")
5318 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5322 /* Time to wait before processing route-map updates */
5323 DEFUN (bgp_set_route_map_delay_timer
,
5324 bgp_set_route_map_delay_timer_cmd
,
5325 "bgp route-map delay-timer (0-600)",
5327 "BGP route-map delay timer\n"
5328 "Time in secs to wait before processing route-map changes\n"
5329 "0 disables the timer, no route updates happen when route-maps change\n")
5332 uint32_t rmap_delay_timer
;
5334 if (argv
[idx_number
]->arg
) {
5335 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5336 bm
->rmap_update_timer
= rmap_delay_timer
;
5338 /* if the dynamic update handling is being disabled, and a timer
5340 * running, stop the timer and act as if the timer has already
5343 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5344 BGP_TIMER_OFF(bm
->t_rmap_update
);
5345 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5350 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5351 return CMD_WARNING_CONFIG_FAILED
;
5355 DEFUN (no_bgp_set_route_map_delay_timer
,
5356 no_bgp_set_route_map_delay_timer_cmd
,
5357 "no bgp route-map delay-timer [(0-600)]",
5360 "Default BGP route-map delay timer\n"
5361 "Reset to default time to wait for processing route-map changes\n"
5362 "0 disables the timer, no route updates happen when route-maps change\n")
5365 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5371 /* neighbor interface */
5372 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5377 peer
= peer_lookup_vty(vty
, ip_str
);
5378 if (!peer
|| peer
->conf_if
) {
5379 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5380 return CMD_WARNING_CONFIG_FAILED
;
5384 peer_interface_set(peer
, str
);
5386 peer_interface_unset(peer
);
5391 DEFUN (neighbor_interface
,
5392 neighbor_interface_cmd
,
5393 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5401 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5404 DEFUN (no_neighbor_interface
,
5405 no_neighbor_interface_cmd
,
5406 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5414 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5417 DEFUN (neighbor_distribute_list
,
5418 neighbor_distribute_list_cmd
,
5419 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5422 "Filter updates to/from this neighbor\n"
5423 "IP access-list number\n"
5424 "IP access-list number (expanded range)\n"
5425 "IP Access-list name\n"
5426 "Filter incoming updates\n"
5427 "Filter outgoing updates\n")
5434 const char *pstr
= argv
[idx_peer
]->arg
;
5435 const char *acl
= argv
[idx_acl
]->arg
;
5436 const char *inout
= argv
[argc
- 1]->text
;
5438 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5440 return CMD_WARNING_CONFIG_FAILED
;
5442 /* Check filter direction. */
5443 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5444 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5447 return bgp_vty_return(vty
, ret
);
5451 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5452 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5453 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5454 "Filter updates to/from this neighbor\n"
5455 "IP access-list number\n"
5456 "IP access-list number (expanded range)\n"
5457 "IP Access-list name\n"
5458 "Filter incoming updates\n"
5459 "Filter outgoing updates\n")
5461 DEFUN (no_neighbor_distribute_list
,
5462 no_neighbor_distribute_list_cmd
,
5463 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5467 "Filter updates to/from this neighbor\n"
5468 "IP access-list number\n"
5469 "IP access-list number (expanded range)\n"
5470 "IP Access-list name\n"
5471 "Filter incoming updates\n"
5472 "Filter outgoing updates\n")
5478 const char *pstr
= argv
[idx_peer
]->arg
;
5479 const char *inout
= argv
[argc
- 1]->text
;
5481 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5483 return CMD_WARNING_CONFIG_FAILED
;
5485 /* Check filter direction. */
5486 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5487 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5490 return bgp_vty_return(vty
, ret
);
5494 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5495 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5496 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5497 "Filter updates to/from this neighbor\n"
5498 "IP access-list number\n"
5499 "IP access-list number (expanded range)\n"
5500 "IP Access-list name\n"
5501 "Filter incoming updates\n"
5502 "Filter outgoing updates\n")
5504 /* Set prefix list to the peer. */
5505 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5506 afi_t afi
, safi_t safi
,
5507 const char *name_str
,
5508 const char *direct_str
)
5511 int direct
= FILTER_IN
;
5514 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5516 return CMD_WARNING_CONFIG_FAILED
;
5518 /* Check filter direction. */
5519 if (strncmp(direct_str
, "i", 1) == 0)
5521 else if (strncmp(direct_str
, "o", 1) == 0)
5522 direct
= FILTER_OUT
;
5524 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5526 return bgp_vty_return(vty
, ret
);
5529 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5530 afi_t afi
, safi_t safi
,
5531 const char *direct_str
)
5535 int direct
= FILTER_IN
;
5537 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5539 return CMD_WARNING_CONFIG_FAILED
;
5541 /* Check filter direction. */
5542 if (strncmp(direct_str
, "i", 1) == 0)
5544 else if (strncmp(direct_str
, "o", 1) == 0)
5545 direct
= FILTER_OUT
;
5547 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5549 return bgp_vty_return(vty
, ret
);
5552 DEFUN (neighbor_prefix_list
,
5553 neighbor_prefix_list_cmd
,
5554 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5557 "Filter updates to/from this neighbor\n"
5558 "Name of a prefix list\n"
5559 "Filter incoming updates\n"
5560 "Filter outgoing updates\n")
5565 return peer_prefix_list_set_vty(
5566 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5567 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5570 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5571 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5572 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5573 "Filter updates to/from this neighbor\n"
5574 "Name of a prefix list\n"
5575 "Filter incoming updates\n"
5576 "Filter outgoing updates\n")
5578 DEFUN (no_neighbor_prefix_list
,
5579 no_neighbor_prefix_list_cmd
,
5580 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5584 "Filter updates to/from this neighbor\n"
5585 "Name of a prefix list\n"
5586 "Filter incoming updates\n"
5587 "Filter outgoing updates\n")
5591 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5592 bgp_node_afi(vty
), bgp_node_safi(vty
),
5593 argv
[idx_in_out
]->arg
);
5596 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5597 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5598 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5599 "Filter updates to/from this neighbor\n"
5600 "Name of a prefix list\n"
5601 "Filter incoming updates\n"
5602 "Filter outgoing updates\n")
5604 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5605 safi_t safi
, const char *name_str
,
5606 const char *direct_str
)
5610 int direct
= FILTER_IN
;
5612 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5614 return CMD_WARNING_CONFIG_FAILED
;
5616 /* Check filter direction. */
5617 if (strncmp(direct_str
, "i", 1) == 0)
5619 else if (strncmp(direct_str
, "o", 1) == 0)
5620 direct
= FILTER_OUT
;
5622 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5624 return bgp_vty_return(vty
, ret
);
5627 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5628 safi_t safi
, const char *direct_str
)
5632 int direct
= FILTER_IN
;
5634 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5636 return CMD_WARNING_CONFIG_FAILED
;
5638 /* Check filter direction. */
5639 if (strncmp(direct_str
, "i", 1) == 0)
5641 else if (strncmp(direct_str
, "o", 1) == 0)
5642 direct
= FILTER_OUT
;
5644 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5646 return bgp_vty_return(vty
, ret
);
5649 DEFUN (neighbor_filter_list
,
5650 neighbor_filter_list_cmd
,
5651 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5654 "Establish BGP filters\n"
5655 "AS path access-list name\n"
5656 "Filter incoming routes\n"
5657 "Filter outgoing routes\n")
5662 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5663 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5664 argv
[idx_in_out
]->arg
);
5667 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5668 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5669 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5670 "Establish BGP filters\n"
5671 "AS path access-list name\n"
5672 "Filter incoming routes\n"
5673 "Filter outgoing routes\n")
5675 DEFUN (no_neighbor_filter_list
,
5676 no_neighbor_filter_list_cmd
,
5677 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5681 "Establish BGP filters\n"
5682 "AS path access-list name\n"
5683 "Filter incoming routes\n"
5684 "Filter outgoing routes\n")
5688 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5689 bgp_node_afi(vty
), bgp_node_safi(vty
),
5690 argv
[idx_in_out
]->arg
);
5693 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5694 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5695 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5696 "Establish BGP filters\n"
5697 "AS path access-list name\n"
5698 "Filter incoming routes\n"
5699 "Filter outgoing routes\n")
5701 /* Set route-map to the peer. */
5702 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5703 afi_t afi
, safi_t safi
, const char *name_str
,
5704 const char *direct_str
)
5708 int direct
= RMAP_IN
;
5709 struct route_map
*route_map
;
5711 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5713 return CMD_WARNING_CONFIG_FAILED
;
5715 /* Check filter direction. */
5716 if (strncmp(direct_str
, "in", 2) == 0)
5718 else if (strncmp(direct_str
, "o", 1) == 0)
5721 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5722 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
5724 return bgp_vty_return(vty
, ret
);
5727 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5728 afi_t afi
, safi_t safi
,
5729 const char *direct_str
)
5733 int direct
= RMAP_IN
;
5735 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5737 return CMD_WARNING_CONFIG_FAILED
;
5739 /* Check filter direction. */
5740 if (strncmp(direct_str
, "in", 2) == 0)
5742 else if (strncmp(direct_str
, "o", 1) == 0)
5745 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5747 return bgp_vty_return(vty
, ret
);
5750 DEFUN (neighbor_route_map
,
5751 neighbor_route_map_cmd
,
5752 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5755 "Apply route map to neighbor\n"
5756 "Name of route map\n"
5757 "Apply map to incoming routes\n"
5758 "Apply map to outbound routes\n")
5763 return peer_route_map_set_vty(
5764 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5765 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5768 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5769 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5770 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5771 "Apply route map to neighbor\n"
5772 "Name of route map\n"
5773 "Apply map to incoming routes\n"
5774 "Apply map to outbound routes\n")
5776 DEFUN (no_neighbor_route_map
,
5777 no_neighbor_route_map_cmd
,
5778 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5782 "Apply route map to neighbor\n"
5783 "Name of route map\n"
5784 "Apply map to incoming routes\n"
5785 "Apply map to outbound routes\n")
5789 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5790 bgp_node_afi(vty
), bgp_node_safi(vty
),
5791 argv
[idx_in_out
]->arg
);
5794 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5795 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5796 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5797 "Apply route map to neighbor\n"
5798 "Name of route map\n"
5799 "Apply map to incoming routes\n"
5800 "Apply map to outbound routes\n")
5802 /* Set unsuppress-map to the peer. */
5803 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5804 afi_t afi
, safi_t safi
,
5805 const char *name_str
)
5809 struct route_map
*route_map
;
5811 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5813 return CMD_WARNING_CONFIG_FAILED
;
5815 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5816 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
5818 return bgp_vty_return(vty
, ret
);
5821 /* Unset route-map from the peer. */
5822 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5823 afi_t afi
, safi_t safi
)
5828 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5830 return CMD_WARNING_CONFIG_FAILED
;
5832 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5834 return bgp_vty_return(vty
, ret
);
5837 DEFUN (neighbor_unsuppress_map
,
5838 neighbor_unsuppress_map_cmd
,
5839 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5842 "Route-map to selectively unsuppress suppressed routes\n"
5843 "Name of route map\n")
5847 return peer_unsuppress_map_set_vty(
5848 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5849 argv
[idx_word
]->arg
);
5852 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5853 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5854 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5855 "Route-map to selectively unsuppress suppressed routes\n"
5856 "Name of route map\n")
5858 DEFUN (no_neighbor_unsuppress_map
,
5859 no_neighbor_unsuppress_map_cmd
,
5860 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5864 "Route-map to selectively unsuppress suppressed routes\n"
5865 "Name of route map\n")
5868 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5870 bgp_node_safi(vty
));
5873 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5874 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5875 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5876 "Route-map to selectively unsuppress suppressed routes\n"
5877 "Name of route map\n")
5879 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5880 afi_t afi
, safi_t safi
,
5881 const char *num_str
,
5882 const char *threshold_str
, int warning
,
5883 const char *restart_str
)
5891 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5893 return CMD_WARNING_CONFIG_FAILED
;
5895 max
= strtoul(num_str
, NULL
, 10);
5897 threshold
= atoi(threshold_str
);
5899 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5902 restart
= atoi(restart_str
);
5906 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5909 return bgp_vty_return(vty
, ret
);
5912 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5913 afi_t afi
, safi_t safi
)
5918 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5920 return CMD_WARNING_CONFIG_FAILED
;
5922 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5924 return bgp_vty_return(vty
, ret
);
5927 /* Maximum number of prefix configuration. prefix count is different
5928 for each peer configuration. So this configuration can be set for
5929 each peer configuration. */
5930 DEFUN (neighbor_maximum_prefix
,
5931 neighbor_maximum_prefix_cmd
,
5932 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5935 "Maximum number of prefix accept from this peer\n"
5936 "maximum no. of prefix limit\n")
5940 return peer_maximum_prefix_set_vty(
5941 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5942 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5945 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5946 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5947 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5948 "Maximum number of prefix accept from this peer\n"
5949 "maximum no. of prefix limit\n")
5951 DEFUN (neighbor_maximum_prefix_threshold
,
5952 neighbor_maximum_prefix_threshold_cmd
,
5953 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5956 "Maximum number of prefix accept from this peer\n"
5957 "maximum no. of prefix limit\n"
5958 "Threshold value (%) at which to generate a warning msg\n")
5962 int idx_number_2
= 4;
5963 return peer_maximum_prefix_set_vty(
5964 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5965 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5969 neighbor_maximum_prefix_threshold
,
5970 neighbor_maximum_prefix_threshold_hidden_cmd
,
5971 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5972 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5973 "Maximum number of prefix accept from this peer\n"
5974 "maximum no. of prefix limit\n"
5975 "Threshold value (%) at which to generate a warning msg\n")
5977 DEFUN (neighbor_maximum_prefix_warning
,
5978 neighbor_maximum_prefix_warning_cmd
,
5979 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5982 "Maximum number of prefix accept from this peer\n"
5983 "maximum no. of prefix limit\n"
5984 "Only give warning message when limit is exceeded\n")
5988 return peer_maximum_prefix_set_vty(
5989 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5990 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
5994 neighbor_maximum_prefix_warning
,
5995 neighbor_maximum_prefix_warning_hidden_cmd
,
5996 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5997 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5998 "Maximum number of prefix accept from this peer\n"
5999 "maximum no. of prefix limit\n"
6000 "Only give warning message when limit is exceeded\n")
6002 DEFUN (neighbor_maximum_prefix_threshold_warning
,
6003 neighbor_maximum_prefix_threshold_warning_cmd
,
6004 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6007 "Maximum number of prefix accept from this peer\n"
6008 "maximum no. of prefix limit\n"
6009 "Threshold value (%) at which to generate a warning msg\n"
6010 "Only give warning message when limit is exceeded\n")
6014 int idx_number_2
= 4;
6015 return peer_maximum_prefix_set_vty(
6016 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6017 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
6021 neighbor_maximum_prefix_threshold_warning
,
6022 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
6023 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6024 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6025 "Maximum number of prefix accept from this peer\n"
6026 "maximum no. of prefix limit\n"
6027 "Threshold value (%) at which to generate a warning msg\n"
6028 "Only give warning message when limit is exceeded\n")
6030 DEFUN (neighbor_maximum_prefix_restart
,
6031 neighbor_maximum_prefix_restart_cmd
,
6032 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6035 "Maximum number of prefix accept from this peer\n"
6036 "maximum no. of prefix limit\n"
6037 "Restart bgp connection after limit is exceeded\n"
6038 "Restart interval in minutes\n")
6042 int idx_number_2
= 5;
6043 return peer_maximum_prefix_set_vty(
6044 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6045 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
6049 neighbor_maximum_prefix_restart
,
6050 neighbor_maximum_prefix_restart_hidden_cmd
,
6051 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6052 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6053 "Maximum number of prefix accept from this peer\n"
6054 "maximum no. of prefix limit\n"
6055 "Restart bgp connection after limit is exceeded\n"
6056 "Restart interval in minutes\n")
6058 DEFUN (neighbor_maximum_prefix_threshold_restart
,
6059 neighbor_maximum_prefix_threshold_restart_cmd
,
6060 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6063 "Maximum number of prefixes to accept from this peer\n"
6064 "maximum no. of prefix limit\n"
6065 "Threshold value (%) at which to generate a warning msg\n"
6066 "Restart bgp connection after limit is exceeded\n"
6067 "Restart interval in minutes\n")
6071 int idx_number_2
= 4;
6072 int idx_number_3
= 6;
6073 return peer_maximum_prefix_set_vty(
6074 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6075 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
6076 argv
[idx_number_3
]->arg
);
6080 neighbor_maximum_prefix_threshold_restart
,
6081 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
6082 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6083 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6084 "Maximum number of prefixes to accept from this peer\n"
6085 "maximum no. of prefix limit\n"
6086 "Threshold value (%) at which to generate a warning msg\n"
6087 "Restart bgp connection after limit is exceeded\n"
6088 "Restart interval in minutes\n")
6090 DEFUN (no_neighbor_maximum_prefix
,
6091 no_neighbor_maximum_prefix_cmd
,
6092 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6096 "Maximum number of prefixes to accept from this peer\n"
6097 "maximum no. of prefix limit\n"
6098 "Threshold value (%) at which to generate a warning msg\n"
6099 "Restart bgp connection after limit is exceeded\n"
6100 "Restart interval in minutes\n"
6101 "Only give warning message when limit is exceeded\n")
6104 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
6106 bgp_node_safi(vty
));
6110 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
6111 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6112 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6113 "Maximum number of prefixes to accept from this peer\n"
6114 "maximum no. of prefix limit\n"
6115 "Threshold value (%) at which to generate a warning msg\n"
6116 "Restart bgp connection after limit is exceeded\n"
6117 "Restart interval in minutes\n"
6118 "Only give warning message when limit is exceeded\n")
6121 /* "neighbor allowas-in" */
6122 DEFUN (neighbor_allowas_in
,
6123 neighbor_allowas_in_cmd
,
6124 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6127 "Accept as-path with my AS present in it\n"
6128 "Number of occurences of AS number\n"
6129 "Only accept my AS in the as-path if the route was originated in my AS\n")
6132 int idx_number_origin
= 3;
6138 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6140 return CMD_WARNING_CONFIG_FAILED
;
6142 if (argc
<= idx_number_origin
)
6145 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6148 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6151 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6154 return bgp_vty_return(vty
, ret
);
6158 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6159 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6160 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6161 "Accept as-path with my AS present in it\n"
6162 "Number of occurences of AS number\n"
6163 "Only accept my AS in the as-path if the route was originated in my AS\n")
6165 DEFUN (no_neighbor_allowas_in
,
6166 no_neighbor_allowas_in_cmd
,
6167 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6171 "allow local ASN appears in aspath attribute\n"
6172 "Number of occurences of AS number\n"
6173 "Only accept my AS in the as-path if the route was originated in my AS\n")
6179 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6181 return CMD_WARNING_CONFIG_FAILED
;
6183 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6184 bgp_node_safi(vty
));
6186 return bgp_vty_return(vty
, ret
);
6190 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6191 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6192 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6193 "allow local ASN appears in aspath attribute\n"
6194 "Number of occurences of AS number\n"
6195 "Only accept my AS in the as-path if the route was originated in my AS\n")
6197 DEFUN (neighbor_ttl_security
,
6198 neighbor_ttl_security_cmd
,
6199 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6202 "BGP ttl-security parameters\n"
6203 "Specify the maximum number of hops to the BGP peer\n"
6204 "Number of hops to BGP peer\n")
6211 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6213 return CMD_WARNING_CONFIG_FAILED
;
6215 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6218 * If 'neighbor swpX', then this is for directly connected peers,
6219 * we should not accept a ttl-security hops value greater than 1.
6221 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6223 "%s is directly connected peer, hops cannot exceed 1\n",
6224 argv
[idx_peer
]->arg
);
6225 return CMD_WARNING_CONFIG_FAILED
;
6228 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6231 DEFUN (no_neighbor_ttl_security
,
6232 no_neighbor_ttl_security_cmd
,
6233 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6237 "BGP ttl-security parameters\n"
6238 "Specify the maximum number of hops to the BGP peer\n"
6239 "Number of hops to BGP peer\n")
6244 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6246 return CMD_WARNING_CONFIG_FAILED
;
6248 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6251 DEFUN (neighbor_addpath_tx_all_paths
,
6252 neighbor_addpath_tx_all_paths_cmd
,
6253 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6256 "Use addpath to advertise all paths to a neighbor\n")
6261 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6263 return CMD_WARNING_CONFIG_FAILED
;
6265 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6270 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6271 neighbor_addpath_tx_all_paths_hidden_cmd
,
6272 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6273 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6274 "Use addpath to advertise all paths to a neighbor\n")
6276 DEFUN (no_neighbor_addpath_tx_all_paths
,
6277 no_neighbor_addpath_tx_all_paths_cmd
,
6278 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6282 "Use addpath to advertise all paths to a neighbor\n")
6287 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6289 return CMD_WARNING_CONFIG_FAILED
;
6291 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6292 != BGP_ADDPATH_ALL
) {
6294 "%% Peer not currently configured to transmit all paths.");
6295 return CMD_WARNING_CONFIG_FAILED
;
6298 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6304 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6305 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6306 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6307 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6308 "Use addpath to advertise all paths to a neighbor\n")
6310 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6311 neighbor_addpath_tx_bestpath_per_as_cmd
,
6312 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6315 "Use addpath to advertise the bestpath per each neighboring AS\n")
6320 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6322 return CMD_WARNING_CONFIG_FAILED
;
6324 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6325 BGP_ADDPATH_BEST_PER_AS
);
6330 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6331 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6332 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6333 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6334 "Use addpath to advertise the bestpath per each neighboring AS\n")
6336 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6337 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6338 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6342 "Use addpath to advertise the bestpath per each neighboring AS\n")
6347 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6349 return CMD_WARNING_CONFIG_FAILED
;
6351 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6352 != BGP_ADDPATH_BEST_PER_AS
) {
6354 "%% Peer not currently configured to transmit all best path per as.");
6355 return CMD_WARNING_CONFIG_FAILED
;
6358 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6364 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6365 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6366 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6367 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6368 "Use addpath to advertise the bestpath per each neighboring AS\n")
6370 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6371 struct ecommunity
**list
)
6373 struct ecommunity
*ecom
= NULL
;
6374 struct ecommunity
*ecomadd
;
6376 for (; argc
; --argc
, ++argv
) {
6378 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6379 ECOMMUNITY_ROUTE_TARGET
, 0);
6381 vty_out(vty
, "Malformed community-list value\n");
6383 ecommunity_free(&ecom
);
6384 return CMD_WARNING_CONFIG_FAILED
;
6388 ecommunity_merge(ecom
, ecomadd
);
6389 ecommunity_free(&ecomadd
);
6396 ecommunity_free(&*list
);
6404 * v2vimport is true if we are handling a `import vrf ...` command
6406 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6410 switch (vty
->node
) {
6419 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6424 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6425 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6426 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6427 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6429 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6433 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6434 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6435 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6436 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6438 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6445 DEFPY (af_rd_vpn_export
,
6446 af_rd_vpn_export_cmd
,
6447 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6449 "Specify route distinguisher\n"
6450 "Between current address-family and vpn\n"
6451 "For routes leaked from current address-family to vpn\n"
6452 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6454 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6455 struct prefix_rd prd
;
6461 if (argv_find(argv
, argc
, "no", &idx
))
6465 ret
= str2prefix_rd(rd_str
, &prd
);
6467 vty_out(vty
, "%% Malformed rd\n");
6468 return CMD_WARNING_CONFIG_FAILED
;
6472 afi
= vpn_policy_getafi(vty
, bgp
, false);
6474 return CMD_WARNING_CONFIG_FAILED
;
6477 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6479 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6480 bgp_get_default(), bgp
);
6483 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6484 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6485 BGP_VPN_POLICY_TOVPN_RD_SET
);
6487 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6488 BGP_VPN_POLICY_TOVPN_RD_SET
);
6491 /* post-change: re-export vpn routes */
6492 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6493 bgp_get_default(), bgp
);
6498 ALIAS (af_rd_vpn_export
,
6499 af_no_rd_vpn_export_cmd
,
6502 "Specify route distinguisher\n"
6503 "Between current address-family and vpn\n"
6504 "For routes leaked from current address-family to vpn\n")
6506 DEFPY (af_label_vpn_export
,
6507 af_label_vpn_export_cmd
,
6508 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6510 "label value for VRF\n"
6511 "Between current address-family and vpn\n"
6512 "For routes leaked from current address-family to vpn\n"
6513 "Label Value <0-1048575>\n"
6514 "Automatically assign a label\n")
6516 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6517 mpls_label_t label
= MPLS_LABEL_NONE
;
6522 if (argv_find(argv
, argc
, "no", &idx
))
6525 /* If "no ...", squash trailing parameter */
6531 label
= label_val
; /* parser should force unsigned */
6534 afi
= vpn_policy_getafi(vty
, bgp
, false);
6536 return CMD_WARNING_CONFIG_FAILED
;
6539 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6540 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6545 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6547 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6548 bgp_get_default(), bgp
);
6550 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6551 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6553 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6556 * label has previously been automatically
6557 * assigned by labelpool: release it
6559 * NB if tovpn_label == MPLS_LABEL_NONE it
6560 * means the automatic assignment is in flight
6561 * and therefore the labelpool callback must
6562 * detect that the auto label is not needed.
6565 bgp_lp_release(LP_TYPE_VRF
,
6566 &bgp
->vpn_policy
[afi
],
6567 bgp
->vpn_policy
[afi
].tovpn_label
);
6569 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6570 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6573 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6575 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6576 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6577 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6578 vpn_leak_label_callback
);
6581 /* post-change: re-export vpn routes */
6582 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6583 bgp_get_default(), bgp
);
6588 ALIAS (af_label_vpn_export
,
6589 af_no_label_vpn_export_cmd
,
6590 "no label vpn export",
6592 "label value for VRF\n"
6593 "Between current address-family and vpn\n"
6594 "For routes leaked from current address-family to vpn\n")
6596 DEFPY (af_nexthop_vpn_export
,
6597 af_nexthop_vpn_export_cmd
,
6598 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6600 "Specify next hop to use for VRF advertised prefixes\n"
6601 "Between current address-family and vpn\n"
6602 "For routes leaked from current address-family to vpn\n"
6606 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6612 if (argv_find(argv
, argc
, "no", &idx
))
6616 if (!sockunion2hostprefix(nexthop_str
, &p
))
6617 return CMD_WARNING_CONFIG_FAILED
;
6620 afi
= vpn_policy_getafi(vty
, bgp
, false);
6622 return CMD_WARNING_CONFIG_FAILED
;
6625 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6627 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6628 bgp_get_default(), bgp
);
6631 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6632 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6633 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6635 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6636 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6639 /* post-change: re-export vpn routes */
6640 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6641 bgp_get_default(), bgp
);
6646 ALIAS (af_nexthop_vpn_export
,
6647 af_no_nexthop_vpn_export_cmd
,
6648 "no nexthop vpn export",
6650 "Specify next hop to use for VRF advertised prefixes\n"
6651 "Between current address-family and vpn\n"
6652 "For routes leaked from current address-family to vpn\n")
6654 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6656 if (!strcmp(dstr
, "import")) {
6657 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6658 } else if (!strcmp(dstr
, "export")) {
6659 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6660 } else if (!strcmp(dstr
, "both")) {
6661 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6662 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6664 vty_out(vty
, "%% direction parse error\n");
6665 return CMD_WARNING_CONFIG_FAILED
;
6670 DEFPY (af_rt_vpn_imexport
,
6671 af_rt_vpn_imexport_cmd
,
6672 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6674 "Specify route target list\n"
6675 "Specify route target list\n"
6676 "Between current address-family and vpn\n"
6677 "For routes leaked from vpn to current address-family: match any\n"
6678 "For routes leaked from current address-family to vpn: set\n"
6679 "both import: match any and export: set\n"
6680 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6682 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6684 struct ecommunity
*ecom
= NULL
;
6685 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6686 vpn_policy_direction_t dir
;
6691 if (argv_find(argv
, argc
, "no", &idx
))
6694 afi
= vpn_policy_getafi(vty
, bgp
, false);
6696 return CMD_WARNING_CONFIG_FAILED
;
6698 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6699 if (ret
!= CMD_SUCCESS
)
6703 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6704 vty_out(vty
, "%% Missing RTLIST\n");
6705 return CMD_WARNING_CONFIG_FAILED
;
6707 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6708 if (ret
!= CMD_SUCCESS
) {
6713 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6717 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6720 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6722 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6723 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6724 ecommunity_dup(ecom
);
6726 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6728 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6729 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6732 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6736 ecommunity_free(&ecom
);
6741 ALIAS (af_rt_vpn_imexport
,
6742 af_no_rt_vpn_imexport_cmd
,
6743 "no <rt|route-target> vpn <import|export|both>$direction_str",
6745 "Specify route target list\n"
6746 "Specify route target list\n"
6747 "Between current address-family and vpn\n"
6748 "For routes leaked from vpn to current address-family\n"
6749 "For routes leaked from current address-family to vpn\n"
6750 "both import and export\n")
6752 DEFPY (af_route_map_vpn_imexport
,
6753 af_route_map_vpn_imexport_cmd
,
6754 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6755 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6757 "Specify route map\n"
6758 "Between current address-family and vpn\n"
6759 "For routes leaked from vpn to current address-family\n"
6760 "For routes leaked from current address-family to vpn\n"
6761 "name of route-map\n")
6763 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6765 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6766 vpn_policy_direction_t dir
;
6771 if (argv_find(argv
, argc
, "no", &idx
))
6774 afi
= vpn_policy_getafi(vty
, bgp
, false);
6776 return CMD_WARNING_CONFIG_FAILED
;
6778 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6779 if (ret
!= CMD_SUCCESS
)
6782 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6786 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6789 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6790 XFREE(MTYPE_ROUTE_MAP_NAME
,
6791 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6792 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6793 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6794 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6795 route_map_lookup_warn_noexist(vty
, rmap_str
);
6796 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6799 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6800 XFREE(MTYPE_ROUTE_MAP_NAME
,
6801 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6802 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6803 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6806 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6812 ALIAS (af_route_map_vpn_imexport
,
6813 af_no_route_map_vpn_imexport_cmd
,
6814 "no route-map vpn <import|export>$direction_str",
6816 "Specify route map\n"
6817 "Between current address-family and vpn\n"
6818 "For routes leaked from vpn to current address-family\n"
6819 "For routes leaked from current address-family to vpn\n")
6821 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6822 "[no] import vrf route-map RMAP$rmap_str",
6824 "Import routes from another VRF\n"
6825 "Vrf routes being filtered\n"
6826 "Specify route map\n"
6827 "name of route-map\n")
6829 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6830 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6834 struct bgp
*bgp_default
;
6836 if (argv_find(argv
, argc
, "no", &idx
))
6839 afi
= vpn_policy_getafi(vty
, bgp
, true);
6841 return CMD_WARNING_CONFIG_FAILED
;
6843 bgp_default
= bgp_get_default();
6848 /* Auto-create assuming the same AS */
6849 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6850 BGP_INSTANCE_TYPE_DEFAULT
);
6854 "VRF default is not configured as a bgp instance\n");
6859 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6862 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6863 XFREE(MTYPE_ROUTE_MAP_NAME
,
6864 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6865 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6866 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6867 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6868 route_map_lookup_warn_noexist(vty
, rmap_str
);
6869 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6872 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6873 XFREE(MTYPE_ROUTE_MAP_NAME
,
6874 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6875 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6876 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6879 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6884 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6885 "no import vrf route-map",
6887 "Import routes from another VRF\n"
6888 "Vrf routes being filtered\n"
6889 "Specify route map\n")
6891 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
6892 "[no] import vrf VIEWVRFNAME$import_name",
6894 "Import routes from another VRF\n"
6895 "VRF to import from\n"
6896 "The name of the VRF\n")
6898 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6899 struct listnode
*node
;
6900 struct bgp
*vrf_bgp
, *bgp_default
;
6903 bool remove
= false;
6906 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
6910 if (import_name
== NULL
) {
6911 vty_out(vty
, "%% Missing import name\n");
6915 if (argv_find(argv
, argc
, "no", &idx
))
6918 afi
= vpn_policy_getafi(vty
, bgp
, true);
6920 return CMD_WARNING_CONFIG_FAILED
;
6922 safi
= bgp_node_safi(vty
);
6924 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
6925 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
6926 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
6927 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
6928 remove
? "unimport" : "import", import_name
);
6932 bgp_default
= bgp_get_default();
6934 /* Auto-create assuming the same AS */
6935 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6936 BGP_INSTANCE_TYPE_DEFAULT
);
6940 "VRF default is not configured as a bgp instance\n");
6945 vrf_bgp
= bgp_lookup_by_name(import_name
);
6947 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
6948 vrf_bgp
= bgp_default
;
6950 /* Auto-create assuming the same AS */
6951 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
6955 "VRF %s is not configured as a bgp instance\n",
6962 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6964 /* Already importing from "import_vrf"? */
6965 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
6967 if (strcmp(vname
, import_name
) == 0)
6971 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6977 /* This command is valid only in a bgp vrf instance or the default instance */
6978 DEFPY (bgp_imexport_vpn
,
6979 bgp_imexport_vpn_cmd
,
6980 "[no] <import|export>$direction_str vpn",
6982 "Import routes to this address-family\n"
6983 "Export routes from this address-family\n"
6984 "to/from default instance VPN RIB\n")
6986 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6993 vpn_policy_direction_t dir
;
6995 if (argv_find(argv
, argc
, "no", &idx
))
6998 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
6999 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
7001 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
7002 return CMD_WARNING_CONFIG_FAILED
;
7005 afi
= bgp_node_afi(vty
);
7006 safi
= bgp_node_safi(vty
);
7007 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
7008 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
7009 return CMD_WARNING_CONFIG_FAILED
;
7012 if (!strcmp(direction_str
, "import")) {
7013 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
7014 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
7015 } else if (!strcmp(direction_str
, "export")) {
7016 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
7017 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
7019 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
7020 return CMD_WARNING_CONFIG_FAILED
;
7023 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7026 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7027 if (!previous_state
) {
7028 /* trigger export current vrf */
7029 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7032 if (previous_state
) {
7033 /* trigger un-export current vrf */
7034 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7036 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7042 DEFPY (af_routetarget_import
,
7043 af_routetarget_import_cmd
,
7044 "[no] <rt|route-target> redirect import RTLIST...",
7046 "Specify route target list\n"
7047 "Specify route target list\n"
7048 "Flow-spec redirect type route target\n"
7049 "Import routes to this address-family\n"
7050 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
7052 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7054 struct ecommunity
*ecom
= NULL
;
7059 if (argv_find(argv
, argc
, "no", &idx
))
7062 afi
= vpn_policy_getafi(vty
, bgp
, false);
7064 return CMD_WARNING_CONFIG_FAILED
;
7067 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7068 vty_out(vty
, "%% Missing RTLIST\n");
7069 return CMD_WARNING_CONFIG_FAILED
;
7071 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7072 if (ret
!= CMD_SUCCESS
)
7077 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7078 ecommunity_free(&bgp
->vpn_policy
[afi
]
7079 .import_redirect_rtlist
);
7080 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
7081 ecommunity_dup(ecom
);
7083 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7084 ecommunity_free(&bgp
->vpn_policy
[afi
]
7085 .import_redirect_rtlist
);
7086 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
7090 ecommunity_free(&ecom
);
7095 DEFUN_NOSH (address_family_ipv4_safi
,
7096 address_family_ipv4_safi_cmd
,
7097 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7098 "Enter Address Family command mode\n"
7100 BGP_SAFI_WITH_LABEL_HELP_STR
)
7104 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7105 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7106 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7107 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7108 && safi
!= SAFI_EVPN
) {
7110 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7111 return CMD_WARNING_CONFIG_FAILED
;
7113 vty
->node
= bgp_node_type(AFI_IP
, safi
);
7115 vty
->node
= BGP_IPV4_NODE
;
7120 DEFUN_NOSH (address_family_ipv6_safi
,
7121 address_family_ipv6_safi_cmd
,
7122 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7123 "Enter Address Family command mode\n"
7125 BGP_SAFI_WITH_LABEL_HELP_STR
)
7128 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7129 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7130 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7131 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7132 && safi
!= SAFI_EVPN
) {
7134 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7135 return CMD_WARNING_CONFIG_FAILED
;
7137 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
7139 vty
->node
= BGP_IPV6_NODE
;
7144 #ifdef KEEP_OLD_VPN_COMMANDS
7145 DEFUN_NOSH (address_family_vpnv4
,
7146 address_family_vpnv4_cmd
,
7147 "address-family vpnv4 [unicast]",
7148 "Enter Address Family command mode\n"
7150 "Address Family modifier\n")
7152 vty
->node
= BGP_VPNV4_NODE
;
7156 DEFUN_NOSH (address_family_vpnv6
,
7157 address_family_vpnv6_cmd
,
7158 "address-family vpnv6 [unicast]",
7159 "Enter Address Family command mode\n"
7161 "Address Family modifier\n")
7163 vty
->node
= BGP_VPNV6_NODE
;
7166 #endif /* KEEP_OLD_VPN_COMMANDS */
7168 DEFUN_NOSH (address_family_evpn
,
7169 address_family_evpn_cmd
,
7170 "address-family l2vpn evpn",
7171 "Enter Address Family command mode\n"
7173 "Address Family modifier\n")
7175 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7176 vty
->node
= BGP_EVPN_NODE
;
7180 DEFUN_NOSH (exit_address_family
,
7181 exit_address_family_cmd
,
7182 "exit-address-family",
7183 "Exit from Address Family configuration mode\n")
7185 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7186 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7187 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7188 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7189 || vty
->node
== BGP_EVPN_NODE
7190 || vty
->node
== BGP_FLOWSPECV4_NODE
7191 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7192 vty
->node
= BGP_NODE
;
7196 /* Recalculate bestpath and re-advertise a prefix */
7197 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7198 const char *ip_str
, afi_t afi
, safi_t safi
,
7199 struct prefix_rd
*prd
)
7202 struct prefix match
;
7203 struct bgp_node
*rn
;
7204 struct bgp_node
*rm
;
7206 struct bgp_table
*table
;
7207 struct bgp_table
*rib
;
7209 /* BGP structure lookup. */
7211 bgp
= bgp_lookup_by_name(view_name
);
7213 vty_out(vty
, "%% Can't find BGP instance %s\n",
7218 bgp
= bgp_get_default();
7220 vty_out(vty
, "%% No BGP process is configured\n");
7225 /* Check IP address argument. */
7226 ret
= str2prefix(ip_str
, &match
);
7228 vty_out(vty
, "%% address is malformed\n");
7232 match
.family
= afi2family(afi
);
7233 rib
= bgp
->rib
[afi
][safi
];
7235 if (safi
== SAFI_MPLS_VPN
) {
7236 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7237 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7240 table
= bgp_node_get_bgp_table_info(rn
);
7241 if (table
!= NULL
) {
7243 if ((rm
= bgp_node_match(table
, &match
))
7246 == match
.prefixlen
) {
7248 BGP_NODE_USER_CLEAR
);
7249 bgp_process(bgp
, rm
, afi
, safi
);
7251 bgp_unlock_node(rm
);
7256 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7257 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7258 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7259 bgp_process(bgp
, rn
, afi
, safi
);
7261 bgp_unlock_node(rn
);
7268 /* one clear bgp command to rule them all */
7269 DEFUN (clear_ip_bgp_all
,
7270 clear_ip_bgp_all_cmd
,
7271 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> [<soft [<in|out>]|in [prefix-filter]|out>]",
7275 BGP_INSTANCE_HELP_STR
7278 BGP_SAFI_WITH_LABEL_HELP_STR
7279 "Address Family modifier\n"
7281 "BGP neighbor address to clear\n"
7282 "BGP IPv6 neighbor to clear\n"
7283 "BGP neighbor on interface to clear\n"
7284 "Clear peers with the AS number\n"
7285 "Clear all external peers\n"
7286 "Clear all members of peer-group\n"
7287 "BGP peer-group name\n"
7292 "Push out prefix-list ORF and do inbound soft reconfig\n"
7297 afi_t afi
= AFI_IP6
;
7298 safi_t safi
= SAFI_UNICAST
;
7299 enum clear_sort clr_sort
= clear_peer
;
7300 enum bgp_clear_type clr_type
;
7301 char *clr_arg
= NULL
;
7305 /* clear [ip] bgp */
7306 if (argv_find(argv
, argc
, "ip", &idx
))
7309 /* [<vrf> VIEWVRFNAME] */
7310 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7311 vrf
= argv
[idx
+ 1]->arg
;
7313 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7315 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7316 /* [<view> VIEWVRFNAME] */
7317 vrf
= argv
[idx
+ 1]->arg
;
7320 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7321 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7322 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7324 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */
7325 if (argv_find(argv
, argc
, "*", &idx
)) {
7326 clr_sort
= clear_all
;
7327 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7328 clr_sort
= clear_peer
;
7329 clr_arg
= argv
[idx
]->arg
;
7330 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7331 clr_sort
= clear_peer
;
7332 clr_arg
= argv
[idx
]->arg
;
7333 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7334 clr_sort
= clear_group
;
7336 clr_arg
= argv
[idx
]->arg
;
7337 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7338 clr_sort
= clear_peer
;
7339 clr_arg
= argv
[idx
]->arg
;
7340 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7341 clr_sort
= clear_as
;
7342 clr_arg
= argv
[idx
]->arg
;
7343 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7344 clr_sort
= clear_external
;
7347 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7348 if (argv_find(argv
, argc
, "soft", &idx
)) {
7349 if (argv_find(argv
, argc
, "in", &idx
)
7350 || argv_find(argv
, argc
, "out", &idx
))
7351 clr_type
= strmatch(argv
[idx
]->text
, "in")
7353 : BGP_CLEAR_SOFT_OUT
;
7355 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7356 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7357 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7358 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7359 : BGP_CLEAR_SOFT_IN
;
7360 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7361 clr_type
= BGP_CLEAR_SOFT_OUT
;
7363 clr_type
= BGP_CLEAR_SOFT_NONE
;
7365 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7368 DEFUN (clear_ip_bgp_prefix
,
7369 clear_ip_bgp_prefix_cmd
,
7370 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7374 BGP_INSTANCE_HELP_STR
7375 "Clear bestpath and re-advertise\n"
7379 char *prefix
= NULL
;
7383 /* [<view|vrf> VIEWVRFNAME] */
7384 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7385 vrf
= argv
[idx
+ 1]->arg
;
7387 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7389 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7390 /* [<view> VIEWVRFNAME] */
7391 vrf
= argv
[idx
+ 1]->arg
;
7395 prefix
= argv
[argc
- 1]->arg
;
7397 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7400 DEFUN (clear_bgp_ipv6_safi_prefix
,
7401 clear_bgp_ipv6_safi_prefix_cmd
,
7402 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7408 "Clear bestpath and re-advertise\n"
7412 int idx_ipv6_prefix
= 0;
7413 safi_t safi
= SAFI_UNICAST
;
7414 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7415 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7417 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7418 return bgp_clear_prefix(
7419 vty
, NULL
, prefix
, AFI_IP6
,
7423 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7424 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7425 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7429 BGP_INSTANCE_HELP_STR
7432 "Clear bestpath and re-advertise\n"
7436 int idx_vrfview
= 0;
7437 int idx_ipv6_prefix
= 0;
7438 safi_t safi
= SAFI_UNICAST
;
7439 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7440 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7441 char *vrfview
= NULL
;
7443 /* [<view|vrf> VIEWVRFNAME] */
7444 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
7445 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7446 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
7448 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
7449 /* [<view> VIEWVRFNAME] */
7450 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7452 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7454 return bgp_clear_prefix(
7455 vty
, vrfview
, prefix
,
7456 AFI_IP6
, safi
, NULL
);
7459 DEFUN (show_bgp_views
,
7461 "show [ip] bgp views",
7465 "Show the defined BGP views\n")
7467 struct list
*inst
= bm
->bgp
;
7468 struct listnode
*node
;
7471 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7472 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7476 vty_out(vty
, "Defined BGP views:\n");
7477 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7479 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7481 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7488 DEFUN (show_bgp_vrfs
,
7490 "show [ip] bgp vrfs [json]",
7497 char buf
[ETHER_ADDR_STRLEN
];
7498 struct list
*inst
= bm
->bgp
;
7499 struct listnode
*node
;
7501 bool uj
= use_json(argc
, argv
);
7502 json_object
*json
= NULL
;
7503 json_object
*json_vrfs
= NULL
;
7506 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7507 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7512 json
= json_object_new_object();
7513 json_vrfs
= json_object_new_object();
7516 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7517 const char *name
, *type
;
7519 struct listnode
*node2
, *nnode2
;
7520 int peers_cfg
, peers_estb
;
7521 json_object
*json_vrf
= NULL
;
7524 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7528 if (!uj
&& count
== 1)
7530 "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n",
7531 "Type", "Id", "routerId", "#PeersVfg",
7532 "#PeersEstb", "Name", "L3-VNI", "Rmac");
7534 peers_cfg
= peers_estb
= 0;
7536 json_vrf
= json_object_new_object();
7539 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
7540 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7543 if (peer
->status
== Established
)
7547 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7548 name
= VRF_DEFAULT_NAME
;
7557 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7559 : (int64_t)bgp
->vrf_id
;
7560 json_object_string_add(json_vrf
, "type", type
);
7561 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7562 json_object_string_add(json_vrf
, "routerId",
7563 inet_ntoa(bgp
->router_id
));
7564 json_object_int_add(json_vrf
, "numConfiguredPeers",
7566 json_object_int_add(json_vrf
, "numEstablishedPeers",
7569 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7570 json_object_string_add(
7572 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7573 json_object_object_add(json_vrfs
, name
, json_vrf
);
7576 "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n",
7578 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7580 inet_ntoa(bgp
->router_id
), peers_cfg
,
7581 peers_estb
, name
, bgp
->l3vni
,
7582 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7586 json_object_object_add(json
, "vrfs", json_vrfs
);
7588 json_object_int_add(json
, "totalVrfs", count
);
7590 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7591 json
, JSON_C_TO_STRING_PRETTY
));
7592 json_object_free(json
);
7596 "\nTotal number of VRFs (including default): %d\n",
7603 DEFUN (show_bgp_mac_hash
,
7604 show_bgp_mac_hash_cmd
,
7605 "show bgp mac hash",
7609 "Mac Address database\n")
7611 bgp_mac_dump_table(vty
);
7616 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
7618 struct vty
*vty
= (struct vty
*)args
;
7619 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
7621 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7625 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7627 vty_out(vty
, "self nexthop database:\n");
7628 bgp_nexthop_show_address_hash(vty
, bgp
);
7630 vty_out(vty
, "Tunnel-ip database:\n");
7631 hash_iterate(bgp
->tip_hash
,
7632 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
7636 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7637 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7638 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7639 "martian next-hops\n"
7640 "martian next-hop database\n")
7642 struct bgp
*bgp
= NULL
;
7646 /* [<vrf> VIEWVRFNAME] */
7647 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7648 name
= argv
[idx
+ 1]->arg
;
7649 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7651 } else if (argv_find(argv
, argc
, "view", &idx
))
7652 /* [<view> VIEWVRFNAME] */
7653 name
= argv
[idx
+ 1]->arg
;
7655 bgp
= bgp_lookup_by_name(name
);
7657 bgp
= bgp_get_default();
7660 vty_out(vty
, "%% No BGP process is configured\n");
7663 bgp_show_martian_nexthops(vty
, bgp
);
7668 DEFUN (show_bgp_memory
,
7669 show_bgp_memory_cmd
,
7670 "show [ip] bgp memory",
7674 "Global BGP memory statistics\n")
7676 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7677 unsigned long count
;
7679 /* RIB related usage stats */
7680 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7681 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7682 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7683 count
* sizeof(struct bgp_node
)));
7685 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7686 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7687 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7688 count
* sizeof(struct bgp_path_info
)));
7689 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7690 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7693 memstrbuf
, sizeof(memstrbuf
),
7694 count
* sizeof(struct bgp_path_info_extra
)));
7696 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7697 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7698 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7699 count
* sizeof(struct bgp_static
)));
7701 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7702 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7703 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7704 count
* sizeof(struct bpacket
)));
7707 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7708 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7709 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7710 count
* sizeof(struct bgp_adj_in
)));
7711 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7712 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7713 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7714 count
* sizeof(struct bgp_adj_out
)));
7716 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7717 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7719 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7720 count
* sizeof(struct bgp_nexthop_cache
)));
7722 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7723 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7725 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7726 count
* sizeof(struct bgp_damp_info
)));
7729 count
= attr_count();
7730 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7731 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7732 count
* sizeof(struct attr
)));
7734 if ((count
= attr_unknown_count()))
7735 vty_out(vty
, "%ld unknown attributes\n", count
);
7737 /* AS_PATH attributes */
7738 count
= aspath_count();
7739 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7740 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7741 count
* sizeof(struct aspath
)));
7743 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7744 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7745 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7746 count
* sizeof(struct assegment
)));
7748 /* Other attributes */
7749 if ((count
= community_count()))
7750 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7751 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7752 count
* sizeof(struct community
)));
7753 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7754 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7755 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7756 count
* sizeof(struct ecommunity
)));
7757 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7759 "%ld BGP large-community entries, using %s of memory\n",
7760 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7761 count
* sizeof(struct lcommunity
)));
7763 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7764 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7765 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7766 count
* sizeof(struct cluster_list
)));
7768 /* Peer related usage */
7769 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7770 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7771 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7772 count
* sizeof(struct peer
)));
7774 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7775 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7776 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7777 count
* sizeof(struct peer_group
)));
7780 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
7781 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
7782 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7783 count
* sizeof(struct hash
)));
7784 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
7785 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
7786 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7787 count
* sizeof(struct hash_bucket
)));
7788 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7789 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7790 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7791 count
* sizeof(regex_t
)));
7795 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7797 json_object
*bestpath
= json_object_new_object();
7799 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7800 json_object_string_add(bestpath
, "asPath", "ignore");
7802 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7803 json_object_string_add(bestpath
, "asPath", "confed");
7805 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7806 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7807 json_object_string_add(bestpath
, "multiPathRelax",
7810 json_object_string_add(bestpath
, "multiPathRelax",
7813 json_object_string_add(bestpath
, "multiPathRelax", "false");
7815 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7816 json_object_string_add(bestpath
, "compareRouterId", "true");
7817 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7818 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7819 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7820 json_object_string_add(bestpath
, "med", "confed");
7821 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7822 json_object_string_add(bestpath
, "med",
7823 "missing-as-worst");
7825 json_object_string_add(bestpath
, "med", "true");
7828 json_object_object_add(json
, "bestPath", bestpath
);
7831 /* Show BGP peer's summary information. */
7832 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7833 bool use_json
, json_object
*json
)
7836 struct listnode
*node
, *nnode
;
7837 unsigned int count
= 0, dn_count
= 0;
7838 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7839 char neighbor_buf
[VTY_BUFSIZ
];
7840 int neighbor_col_default_width
= 16;
7842 int max_neighbor_width
= 0;
7844 json_object
*json_peer
= NULL
;
7845 json_object
*json_peers
= NULL
;
7846 struct peer_af
*paf
;
7848 /* labeled-unicast routes are installed in the unicast table so in order
7850 * display the correct PfxRcd value we must look at SAFI_UNICAST
7852 if (safi
== SAFI_LABELED_UNICAST
)
7853 pfx_rcd_safi
= SAFI_UNICAST
;
7855 pfx_rcd_safi
= safi
;
7859 json
= json_object_new_object();
7861 json_peers
= json_object_new_object();
7863 /* Loop over all neighbors that will be displayed to determine
7865 * characters are needed for the Neighbor column
7867 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7868 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7871 if (peer
->afc
[afi
][safi
]) {
7872 memset(dn_flag
, '\0', sizeof(dn_flag
));
7873 if (peer_dynamic_neighbor(peer
))
7877 && bgp_flag_check(bgp
,
7878 BGP_FLAG_SHOW_HOSTNAME
))
7879 sprintf(neighbor_buf
, "%s%s(%s) ",
7880 dn_flag
, peer
->hostname
,
7883 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7886 len
= strlen(neighbor_buf
);
7888 if (len
> max_neighbor_width
)
7889 max_neighbor_width
= len
;
7893 /* Originally we displayed the Neighbor column as 16
7894 * characters wide so make that the default
7896 if (max_neighbor_width
< neighbor_col_default_width
)
7897 max_neighbor_width
= neighbor_col_default_width
;
7900 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7901 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7904 if (!peer
->afc
[afi
][safi
])
7909 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7912 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7914 : (int64_t)bgp
->vrf_id
;
7916 /* Usage summary and header */
7918 json_object_string_add(
7920 inet_ntoa(bgp
->router_id
));
7921 json_object_int_add(json
, "as", bgp
->as
);
7922 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7923 json_object_string_add(
7926 == BGP_INSTANCE_TYPE_DEFAULT
)
7931 "BGP router identifier %s, local AS number %u vrf-id %d",
7932 inet_ntoa(bgp
->router_id
), bgp
->as
,
7933 bgp
->vrf_id
== VRF_UNKNOWN
7935 : (int)bgp
->vrf_id
);
7939 if (bgp_update_delay_configured(bgp
)) {
7941 json_object_int_add(
7942 json
, "updateDelayLimit",
7943 bgp
->v_update_delay
);
7945 if (bgp
->v_update_delay
7946 != bgp
->v_establish_wait
)
7947 json_object_int_add(
7949 "updateDelayEstablishWait",
7950 bgp
->v_establish_wait
);
7952 if (bgp_update_delay_active(bgp
)) {
7953 json_object_string_add(
7955 "updateDelayFirstNeighbor",
7956 bgp
->update_delay_begin_time
);
7957 json_object_boolean_true_add(
7959 "updateDelayInProgress");
7961 if (bgp
->update_delay_over
) {
7962 json_object_string_add(
7964 "updateDelayFirstNeighbor",
7965 bgp
->update_delay_begin_time
);
7966 json_object_string_add(
7968 "updateDelayBestpathResumed",
7969 bgp
->update_delay_end_time
);
7970 json_object_string_add(
7972 "updateDelayZebraUpdateResume",
7973 bgp
->update_delay_zebra_resume_time
);
7974 json_object_string_add(
7976 "updateDelayPeerUpdateResume",
7977 bgp
->update_delay_peers_resume_time
);
7982 "Read-only mode update-delay limit: %d seconds\n",
7983 bgp
->v_update_delay
);
7984 if (bgp
->v_update_delay
7985 != bgp
->v_establish_wait
)
7987 " Establish wait: %d seconds\n",
7988 bgp
->v_establish_wait
);
7990 if (bgp_update_delay_active(bgp
)) {
7992 " First neighbor established: %s\n",
7993 bgp
->update_delay_begin_time
);
7995 " Delay in progress\n");
7997 if (bgp
->update_delay_over
) {
7999 " First neighbor established: %s\n",
8000 bgp
->update_delay_begin_time
);
8002 " Best-paths resumed: %s\n",
8003 bgp
->update_delay_end_time
);
8005 " zebra update resumed: %s\n",
8006 bgp
->update_delay_zebra_resume_time
);
8008 " peers update resumed: %s\n",
8009 bgp
->update_delay_peers_resume_time
);
8016 if (bgp_maxmed_onstartup_configured(bgp
)
8017 && bgp
->maxmed_active
)
8018 json_object_boolean_true_add(
8019 json
, "maxMedOnStartup");
8020 if (bgp
->v_maxmed_admin
)
8021 json_object_boolean_true_add(
8022 json
, "maxMedAdministrative");
8024 json_object_int_add(
8025 json
, "tableVersion",
8026 bgp_table_version(bgp
->rib
[afi
][safi
]));
8028 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8029 json_object_int_add(json
, "ribCount", ents
);
8030 json_object_int_add(
8032 ents
* sizeof(struct bgp_node
));
8034 ents
= listcount(bgp
->peer
);
8035 json_object_int_add(json
, "peerCount", ents
);
8036 json_object_int_add(json
, "peerMemory",
8037 ents
* sizeof(struct peer
));
8039 if ((ents
= listcount(bgp
->group
))) {
8040 json_object_int_add(
8041 json
, "peerGroupCount", ents
);
8042 json_object_int_add(
8043 json
, "peerGroupMemory",
8044 ents
* sizeof(struct
8048 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8049 BGP_CONFIG_DAMPENING
))
8050 json_object_boolean_true_add(
8051 json
, "dampeningEnabled");
8053 if (bgp_maxmed_onstartup_configured(bgp
)
8054 && bgp
->maxmed_active
)
8056 "Max-med on-startup active\n");
8057 if (bgp
->v_maxmed_admin
)
8059 "Max-med administrative active\n");
8061 vty_out(vty
, "BGP table version %" PRIu64
"\n",
8062 bgp_table_version(bgp
->rib
[afi
][safi
]));
8064 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8066 "RIB entries %ld, using %s of memory\n",
8068 mtype_memstr(memstrbuf
,
8070 ents
* sizeof(struct
8073 /* Peer related usage */
8074 ents
= listcount(bgp
->peer
);
8075 vty_out(vty
, "Peers %ld, using %s of memory\n",
8078 memstrbuf
, sizeof(memstrbuf
),
8079 ents
* sizeof(struct peer
)));
8081 if ((ents
= listcount(bgp
->group
)))
8083 "Peer groups %ld, using %s of memory\n",
8088 ents
* sizeof(struct
8091 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8092 BGP_CONFIG_DAMPENING
))
8093 vty_out(vty
, "Dampening enabled.\n");
8096 /* Subtract 8 here because 'Neighbor' is
8098 vty_out(vty
, "Neighbor");
8099 vty_out(vty
, "%*s", max_neighbor_width
- 8,
8102 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
8109 json_peer
= json_object_new_object();
8111 if (peer_dynamic_neighbor(peer
)) {
8113 json_object_boolean_true_add(json_peer
,
8118 json_object_string_add(json_peer
, "hostname",
8121 if (peer
->domainname
)
8122 json_object_string_add(json_peer
, "domainname",
8125 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
8126 json_object_int_add(json_peer
, "version", 4);
8127 json_object_int_add(json_peer
, "msgRcvd",
8128 PEER_TOTAL_RX(peer
));
8129 json_object_int_add(json_peer
, "msgSent",
8130 PEER_TOTAL_TX(peer
));
8132 json_object_int_add(json_peer
, "tableVersion",
8133 peer
->version
[afi
][safi
]);
8134 json_object_int_add(json_peer
, "outq",
8136 json_object_int_add(json_peer
, "inq", 0);
8137 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8138 use_json
, json_peer
);
8141 * Adding "pfxRcd" field to match with the corresponding
8142 * CLI. "prefixReceivedCount" will be deprecated in
8145 json_object_int_add(json_peer
, "prefixReceivedCount",
8146 peer
->pcount
[afi
][pfx_rcd_safi
]);
8147 json_object_int_add(json_peer
, "pfxRcd",
8148 peer
->pcount
[afi
][pfx_rcd_safi
]);
8150 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
8151 if (paf
&& PAF_SUBGRP(paf
))
8152 json_object_int_add(json_peer
,
8154 (PAF_SUBGRP(paf
))->scount
);
8156 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8157 json_object_string_add(json_peer
, "state",
8159 else if (peer
->afc_recv
[afi
][safi
])
8160 json_object_string_add(
8162 lookup_msg(bgp_status_msg
, peer
->status
,
8164 else if (CHECK_FLAG(peer
->sflags
,
8165 PEER_STATUS_PREFIX_OVERFLOW
))
8166 json_object_string_add(json_peer
, "state",
8169 json_object_string_add(
8171 lookup_msg(bgp_status_msg
, peer
->status
,
8175 json_object_string_add(json_peer
, "idType",
8177 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8178 json_object_string_add(json_peer
, "idType",
8180 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8181 json_object_string_add(json_peer
, "idType",
8184 json_object_object_add(json_peers
, peer
->host
,
8187 memset(dn_flag
, '\0', sizeof(dn_flag
));
8188 if (peer_dynamic_neighbor(peer
)) {
8194 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8195 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8196 peer
->hostname
, peer
->host
);
8198 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8200 /* pad the neighbor column with spaces */
8201 if (len
< max_neighbor_width
)
8202 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8205 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8206 peer
->as
, PEER_TOTAL_RX(peer
),
8207 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8208 0, peer
->obuf
->count
,
8209 peer_uptime(peer
->uptime
, timebuf
,
8210 BGP_UPTIME_LEN
, 0, NULL
));
8212 if (peer
->status
== Established
)
8213 if (peer
->afc_recv
[afi
][safi
])
8214 vty_out(vty
, " %12ld",
8218 vty_out(vty
, " NoNeg");
8220 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8221 vty_out(vty
, " Idle (Admin)");
8222 else if (CHECK_FLAG(
8224 PEER_STATUS_PREFIX_OVERFLOW
))
8225 vty_out(vty
, " Idle (PfxCt)");
8227 vty_out(vty
, " %12s",
8228 lookup_msg(bgp_status_msg
,
8229 peer
->status
, NULL
));
8236 json_object_object_add(json
, "peers", json_peers
);
8238 json_object_int_add(json
, "totalPeers", count
);
8239 json_object_int_add(json
, "dynamicPeers", dn_count
);
8241 bgp_show_bestpath_json(bgp
, json
);
8243 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8244 json
, JSON_C_TO_STRING_PRETTY
));
8245 json_object_free(json
);
8248 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8250 vty_out(vty
, "No %s neighbor is configured\n",
8251 afi_safi_print(afi
, safi
));
8255 vty_out(vty
, "* - dynamic neighbor\n");
8256 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8257 dn_count
, bgp
->dynamic_neighbors_limit
);
8264 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8265 int safi
, bool use_json
,
8269 int afi_wildcard
= (afi
== AFI_MAX
);
8270 int safi_wildcard
= (safi
== SAFI_MAX
);
8271 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8272 bool nbr_output
= false;
8274 if (use_json
&& is_wildcard
)
8275 vty_out(vty
, "{\n");
8277 afi
= 1; /* AFI_IP */
8278 while (afi
< AFI_MAX
) {
8280 safi
= 1; /* SAFI_UNICAST */
8281 while (safi
< SAFI_MAX
) {
8282 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8286 * So limit output to those afi/safi
8288 * actualy have something interesting in
8292 json
= json_object_new_object();
8295 vty_out(vty
, ",\n");
8299 vty_out(vty
, "\"%s\":",
8303 vty_out(vty
, "\n%s Summary:\n",
8308 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
8320 if (use_json
&& is_wildcard
)
8321 vty_out(vty
, "}\n");
8322 else if (!nbr_output
) {
8324 vty_out(vty
, "{}\n");
8326 vty_out(vty
, "%% No BGP neighbors found\n");
8330 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8331 safi_t safi
, bool use_json
)
8333 struct listnode
*node
, *nnode
;
8335 json_object
*json
= NULL
;
8337 bool nbr_output
= false;
8340 vty_out(vty
, "{\n");
8342 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8345 json
= json_object_new_object();
8348 vty_out(vty
, ",\n");
8352 vty_out(vty
, "\"%s\":",
8353 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8357 vty_out(vty
, "\nInstance %s:\n",
8358 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8362 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
8366 vty_out(vty
, "}\n");
8367 else if (!nbr_output
)
8368 vty_out(vty
, "%% BGP instance not found\n");
8371 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8372 safi_t safi
, bool use_json
)
8377 if (strmatch(name
, "all")) {
8378 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8382 bgp
= bgp_lookup_by_name(name
);
8386 vty_out(vty
, "{}\n");
8389 "%% BGP instance not found\n");
8393 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
8399 bgp
= bgp_get_default();
8402 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
8405 vty_out(vty
, "{}\n");
8407 vty_out(vty
, "%% BGP instance not found\n");
8414 /* `show [ip] bgp summary' commands. */
8415 DEFUN (show_ip_bgp_summary
,
8416 show_ip_bgp_summary_cmd
,
8417 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8421 BGP_INSTANCE_HELP_STR
8423 BGP_SAFI_WITH_LABEL_HELP_STR
8424 "Summary of BGP neighbor status\n"
8428 afi_t afi
= AFI_MAX
;
8429 safi_t safi
= SAFI_MAX
;
8434 if (argv_find(argv
, argc
, "ip", &idx
))
8436 /* [<vrf> VIEWVRFNAME] */
8437 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8438 vrf
= argv
[idx
+ 1]->arg
;
8439 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8441 } else if (argv_find(argv
, argc
, "view", &idx
))
8442 /* [<view> VIEWVRFNAME] */
8443 vrf
= argv
[idx
+ 1]->arg
;
8444 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8445 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8446 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8449 bool uj
= use_json(argc
, argv
);
8451 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8454 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8456 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8457 return "IPv4 Unicast";
8458 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8459 return "IPv4 Multicast";
8460 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8461 return "IPv4 Labeled Unicast";
8462 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8464 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8465 return "IPv4 Encap";
8466 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8467 return "IPv4 Flowspec";
8468 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8469 return "IPv6 Unicast";
8470 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8471 return "IPv6 Multicast";
8472 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8473 return "IPv6 Labeled Unicast";
8474 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8476 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8477 return "IPv6 Encap";
8478 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8479 return "IPv6 Flowspec";
8480 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8481 return "L2VPN EVPN";
8487 * Please note that we have intentionally camelCased
8488 * the return strings here. So if you want
8489 * to use this function, please ensure you
8490 * are doing this within json output
8492 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8494 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8495 return "ipv4Unicast";
8496 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8497 return "ipv4Multicast";
8498 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8499 return "ipv4LabeledUnicast";
8500 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8502 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8504 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8505 return "ipv4Flowspec";
8506 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8507 return "ipv6Unicast";
8508 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8509 return "ipv6Multicast";
8510 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8511 return "ipv6LabeledUnicast";
8512 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8514 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8516 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8517 return "ipv6Flowspec";
8518 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8524 /* Show BGP peer's information. */
8525 enum show_type
{ show_all
, show_peer
};
8527 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8528 afi_t afi
, safi_t safi
,
8529 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8530 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8531 bool use_json
, json_object
*json_pref
)
8534 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8535 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8537 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8538 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8539 json_object_string_add(json_pref
, "sendMode",
8540 "advertisedAndReceived");
8541 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8542 json_object_string_add(json_pref
, "sendMode",
8544 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8545 json_object_string_add(json_pref
, "sendMode",
8548 vty_out(vty
, " Send-mode: ");
8549 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8550 vty_out(vty
, "advertised");
8551 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8552 vty_out(vty
, "%sreceived",
8553 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8562 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8563 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8565 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8566 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8567 json_object_string_add(json_pref
, "recvMode",
8568 "advertisedAndReceived");
8569 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8570 json_object_string_add(json_pref
, "recvMode",
8572 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8573 json_object_string_add(json_pref
, "recvMode",
8576 vty_out(vty
, " Receive-mode: ");
8577 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8578 vty_out(vty
, "advertised");
8579 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8580 vty_out(vty
, "%sreceived",
8581 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8590 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8591 safi_t safi
, bool use_json
,
8592 json_object
*json_neigh
)
8594 struct bgp_filter
*filter
;
8595 struct peer_af
*paf
;
8596 char orf_pfx_name
[BUFSIZ
];
8598 json_object
*json_af
= NULL
;
8599 json_object
*json_prefA
= NULL
;
8600 json_object
*json_prefB
= NULL
;
8601 json_object
*json_addr
= NULL
;
8604 json_addr
= json_object_new_object();
8605 json_af
= json_object_new_object();
8606 filter
= &p
->filter
[afi
][safi
];
8608 if (peer_group_active(p
))
8609 json_object_string_add(json_addr
, "peerGroupMember",
8612 paf
= peer_af_find(p
, afi
, safi
);
8613 if (paf
&& PAF_SUBGRP(paf
)) {
8614 json_object_int_add(json_addr
, "updateGroupId",
8615 PAF_UPDGRP(paf
)->id
);
8616 json_object_int_add(json_addr
, "subGroupId",
8617 PAF_SUBGRP(paf
)->id
);
8618 json_object_int_add(json_addr
, "packetQueueLength",
8619 bpacket_queue_virtual_length(paf
));
8622 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8623 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8624 PEER_CAP_ORF_PREFIX_SM_RCV
)
8625 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8626 PEER_CAP_ORF_PREFIX_RM_ADV
)
8627 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8628 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8629 json_object_int_add(json_af
, "orfType",
8631 json_prefA
= json_object_new_object();
8632 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8633 PEER_CAP_ORF_PREFIX_SM_ADV
,
8634 PEER_CAP_ORF_PREFIX_RM_ADV
,
8635 PEER_CAP_ORF_PREFIX_SM_RCV
,
8636 PEER_CAP_ORF_PREFIX_RM_RCV
,
8637 use_json
, json_prefA
);
8638 json_object_object_add(json_af
, "orfPrefixList",
8642 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8643 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8644 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8645 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8646 PEER_CAP_ORF_PREFIX_RM_ADV
)
8647 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8648 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8649 json_object_int_add(json_af
, "orfOldType",
8650 ORF_TYPE_PREFIX_OLD
);
8651 json_prefB
= json_object_new_object();
8652 bgp_show_peer_afi_orf_cap(
8653 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8654 PEER_CAP_ORF_PREFIX_RM_ADV
,
8655 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8656 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8658 json_object_object_add(json_af
, "orfOldPrefixList",
8662 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8663 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8664 PEER_CAP_ORF_PREFIX_SM_RCV
)
8665 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8666 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8667 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8668 PEER_CAP_ORF_PREFIX_RM_ADV
)
8669 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8670 PEER_CAP_ORF_PREFIX_RM_RCV
)
8671 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8672 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8673 json_object_object_add(json_addr
, "afDependentCap",
8676 json_object_free(json_af
);
8678 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8679 orf_pfx_count
= prefix_bgp_show_prefix_list(
8680 NULL
, afi
, orf_pfx_name
, use_json
);
8682 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8683 PEER_STATUS_ORF_PREFIX_SEND
)
8685 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8686 PEER_STATUS_ORF_PREFIX_SEND
))
8687 json_object_boolean_true_add(json_neigh
,
8690 json_object_int_add(json_addr
, "orfRecvCounter",
8693 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8694 PEER_STATUS_ORF_WAIT_REFRESH
))
8695 json_object_string_add(
8696 json_addr
, "orfFirstUpdate",
8697 "deferredUntilORFOrRouteRefreshRecvd");
8699 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8700 PEER_FLAG_REFLECTOR_CLIENT
))
8701 json_object_boolean_true_add(json_addr
,
8702 "routeReflectorClient");
8703 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8704 PEER_FLAG_RSERVER_CLIENT
))
8705 json_object_boolean_true_add(json_addr
,
8706 "routeServerClient");
8707 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8708 json_object_boolean_true_add(json_addr
,
8709 "inboundSoftConfigPermit");
8711 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8712 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8713 json_object_boolean_true_add(
8715 "privateAsNumsAllReplacedInUpdatesToNbr");
8716 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8717 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8718 json_object_boolean_true_add(
8720 "privateAsNumsReplacedInUpdatesToNbr");
8721 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8722 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8723 json_object_boolean_true_add(
8725 "privateAsNumsAllRemovedInUpdatesToNbr");
8726 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8727 PEER_FLAG_REMOVE_PRIVATE_AS
))
8728 json_object_boolean_true_add(
8730 "privateAsNumsRemovedInUpdatesToNbr");
8732 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8733 json_object_boolean_true_add(
8735 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8738 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8739 json_object_string_add(json_addr
,
8740 "overrideASNsInOutboundUpdates",
8741 "ifAspathEqualRemoteAs");
8743 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8744 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8745 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8746 json_object_boolean_true_add(json_addr
,
8747 "routerAlwaysNextHop");
8748 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8749 PEER_FLAG_AS_PATH_UNCHANGED
))
8750 json_object_boolean_true_add(
8751 json_addr
, "unchangedAsPathPropogatedToNbr");
8752 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8753 PEER_FLAG_NEXTHOP_UNCHANGED
))
8754 json_object_boolean_true_add(
8755 json_addr
, "unchangedNextHopPropogatedToNbr");
8756 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8757 json_object_boolean_true_add(
8758 json_addr
, "unchangedMedPropogatedToNbr");
8759 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8760 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8761 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8762 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8763 PEER_FLAG_SEND_COMMUNITY
)
8764 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8765 PEER_FLAG_SEND_EXT_COMMUNITY
))
8766 json_object_string_add(json_addr
,
8767 "commAttriSentToNbr",
8768 "extendedAndStandard");
8769 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8770 PEER_FLAG_SEND_EXT_COMMUNITY
))
8771 json_object_string_add(json_addr
,
8772 "commAttriSentToNbr",
8775 json_object_string_add(json_addr
,
8776 "commAttriSentToNbr",
8779 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8780 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8781 if (p
->default_rmap
[afi
][safi
].name
)
8782 json_object_string_add(
8783 json_addr
, "defaultRouteMap",
8784 p
->default_rmap
[afi
][safi
].name
);
8786 if (paf
&& PAF_SUBGRP(paf
)
8787 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8788 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8789 json_object_boolean_true_add(json_addr
,
8792 json_object_boolean_true_add(json_addr
,
8796 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8797 if (is_evpn_enabled())
8798 json_object_boolean_true_add(
8799 json_addr
, "advertiseAllVnis");
8802 if (filter
->plist
[FILTER_IN
].name
8803 || filter
->dlist
[FILTER_IN
].name
8804 || filter
->aslist
[FILTER_IN
].name
8805 || filter
->map
[RMAP_IN
].name
)
8806 json_object_boolean_true_add(json_addr
,
8807 "inboundPathPolicyConfig");
8808 if (filter
->plist
[FILTER_OUT
].name
8809 || filter
->dlist
[FILTER_OUT
].name
8810 || filter
->aslist
[FILTER_OUT
].name
8811 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8812 json_object_boolean_true_add(
8813 json_addr
, "outboundPathPolicyConfig");
8816 if (filter
->plist
[FILTER_IN
].name
)
8817 json_object_string_add(json_addr
,
8818 "incomingUpdatePrefixFilterList",
8819 filter
->plist
[FILTER_IN
].name
);
8820 if (filter
->plist
[FILTER_OUT
].name
)
8821 json_object_string_add(json_addr
,
8822 "outgoingUpdatePrefixFilterList",
8823 filter
->plist
[FILTER_OUT
].name
);
8825 /* distribute-list */
8826 if (filter
->dlist
[FILTER_IN
].name
)
8827 json_object_string_add(
8828 json_addr
, "incomingUpdateNetworkFilterList",
8829 filter
->dlist
[FILTER_IN
].name
);
8830 if (filter
->dlist
[FILTER_OUT
].name
)
8831 json_object_string_add(
8832 json_addr
, "outgoingUpdateNetworkFilterList",
8833 filter
->dlist
[FILTER_OUT
].name
);
8836 if (filter
->aslist
[FILTER_IN
].name
)
8837 json_object_string_add(json_addr
,
8838 "incomingUpdateAsPathFilterList",
8839 filter
->aslist
[FILTER_IN
].name
);
8840 if (filter
->aslist
[FILTER_OUT
].name
)
8841 json_object_string_add(json_addr
,
8842 "outgoingUpdateAsPathFilterList",
8843 filter
->aslist
[FILTER_OUT
].name
);
8846 if (filter
->map
[RMAP_IN
].name
)
8847 json_object_string_add(
8848 json_addr
, "routeMapForIncomingAdvertisements",
8849 filter
->map
[RMAP_IN
].name
);
8850 if (filter
->map
[RMAP_OUT
].name
)
8851 json_object_string_add(
8852 json_addr
, "routeMapForOutgoingAdvertisements",
8853 filter
->map
[RMAP_OUT
].name
);
8855 /* ebgp-requires-policy (inbound) */
8856 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8857 && !bgp_inbound_policy_exists(p
, filter
))
8858 json_object_string_add(
8859 json_addr
, "inboundEbgpRequiresPolicy",
8860 "Inbound updates discarded due to missing policy");
8862 /* ebgp-requires-policy (outbound) */
8863 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8864 && (!bgp_outbound_policy_exists(p
, filter
)))
8865 json_object_string_add(
8866 json_addr
, "outboundEbgpRequiresPolicy",
8867 "Outbound updates discarded due to missing policy");
8869 /* unsuppress-map */
8870 if (filter
->usmap
.name
)
8871 json_object_string_add(json_addr
,
8872 "selectiveUnsuppressRouteMap",
8873 filter
->usmap
.name
);
8875 /* Receive prefix count */
8876 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8877 p
->pcount
[afi
][safi
]);
8878 if (paf
&& PAF_SUBGRP(paf
))
8879 json_object_int_add(json_addr
, "sentPrefixCounter",
8880 (PAF_SUBGRP(paf
))->scount
);
8882 /* Maximum prefix */
8883 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8884 json_object_int_add(json_addr
, "prefixAllowedMax",
8885 p
->pmax
[afi
][safi
]);
8886 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8887 PEER_FLAG_MAX_PREFIX_WARNING
))
8888 json_object_boolean_true_add(
8889 json_addr
, "prefixAllowedMaxWarning");
8890 json_object_int_add(json_addr
,
8891 "prefixAllowedWarningThresh",
8892 p
->pmax_threshold
[afi
][safi
]);
8893 if (p
->pmax_restart
[afi
][safi
])
8894 json_object_int_add(
8896 "prefixAllowedRestartIntervalMsecs",
8897 p
->pmax_restart
[afi
][safi
] * 60000);
8899 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8903 filter
= &p
->filter
[afi
][safi
];
8905 vty_out(vty
, " For address family: %s\n",
8906 afi_safi_print(afi
, safi
));
8908 if (peer_group_active(p
))
8909 vty_out(vty
, " %s peer-group member\n",
8912 paf
= peer_af_find(p
, afi
, safi
);
8913 if (paf
&& PAF_SUBGRP(paf
)) {
8914 vty_out(vty
, " Update group %" PRIu64
8915 ", subgroup %" PRIu64
"\n",
8916 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8917 vty_out(vty
, " Packet Queue length %d\n",
8918 bpacket_queue_virtual_length(paf
));
8920 vty_out(vty
, " Not part of any update group\n");
8922 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8923 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8924 PEER_CAP_ORF_PREFIX_SM_RCV
)
8925 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8926 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8927 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8928 PEER_CAP_ORF_PREFIX_RM_ADV
)
8929 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8930 PEER_CAP_ORF_PREFIX_RM_RCV
)
8931 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8932 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8933 vty_out(vty
, " AF-dependant capabilities:\n");
8935 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8936 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8937 PEER_CAP_ORF_PREFIX_SM_RCV
)
8938 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8939 PEER_CAP_ORF_PREFIX_RM_ADV
)
8940 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8941 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8943 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8945 bgp_show_peer_afi_orf_cap(
8946 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8947 PEER_CAP_ORF_PREFIX_RM_ADV
,
8948 PEER_CAP_ORF_PREFIX_SM_RCV
,
8949 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8951 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8952 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8953 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8954 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8955 PEER_CAP_ORF_PREFIX_RM_ADV
)
8956 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8957 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8959 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8960 ORF_TYPE_PREFIX_OLD
);
8961 bgp_show_peer_afi_orf_cap(
8962 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8963 PEER_CAP_ORF_PREFIX_RM_ADV
,
8964 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8965 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8968 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8969 orf_pfx_count
= prefix_bgp_show_prefix_list(
8970 NULL
, afi
, orf_pfx_name
, use_json
);
8972 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8973 PEER_STATUS_ORF_PREFIX_SEND
)
8975 vty_out(vty
, " Outbound Route Filter (ORF):");
8976 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8977 PEER_STATUS_ORF_PREFIX_SEND
))
8978 vty_out(vty
, " sent;");
8980 vty_out(vty
, " received (%d entries)",
8984 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8985 PEER_STATUS_ORF_WAIT_REFRESH
))
8987 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
8989 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8990 PEER_FLAG_REFLECTOR_CLIENT
))
8991 vty_out(vty
, " Route-Reflector Client\n");
8992 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8993 PEER_FLAG_RSERVER_CLIENT
))
8994 vty_out(vty
, " Route-Server Client\n");
8995 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8997 " Inbound soft reconfiguration allowed\n");
8999 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9000 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
9002 " Private AS numbers (all) replaced in updates to this neighbor\n");
9003 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9004 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
9006 " Private AS numbers replaced in updates to this neighbor\n");
9007 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9008 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
9010 " Private AS numbers (all) removed in updates to this neighbor\n");
9011 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9012 PEER_FLAG_REMOVE_PRIVATE_AS
))
9014 " Private AS numbers removed in updates to this neighbor\n");
9016 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
9017 vty_out(vty
, " %s\n",
9018 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
9019 ->human_description
);
9021 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
9023 " Override ASNs in outbound updates if aspath equals remote-as\n");
9025 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
9026 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9027 PEER_FLAG_FORCE_NEXTHOP_SELF
))
9028 vty_out(vty
, " NEXT_HOP is always this router\n");
9029 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9030 PEER_FLAG_AS_PATH_UNCHANGED
))
9032 " AS_PATH is propagated unchanged to this neighbor\n");
9033 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9034 PEER_FLAG_NEXTHOP_UNCHANGED
))
9036 " NEXT_HOP is propagated unchanged to this neighbor\n");
9037 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
9039 " MED is propagated unchanged to this neighbor\n");
9040 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
9041 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9042 PEER_FLAG_SEND_EXT_COMMUNITY
)
9043 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9044 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
9046 " Community attribute sent to this neighbor");
9047 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9048 PEER_FLAG_SEND_COMMUNITY
)
9049 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9050 PEER_FLAG_SEND_EXT_COMMUNITY
)
9051 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9052 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9053 vty_out(vty
, "(all)\n");
9054 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9055 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9056 vty_out(vty
, "(large)\n");
9057 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9058 PEER_FLAG_SEND_EXT_COMMUNITY
))
9059 vty_out(vty
, "(extended)\n");
9061 vty_out(vty
, "(standard)\n");
9063 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9064 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9065 vty_out(vty
, " Default information originate,");
9067 if (p
->default_rmap
[afi
][safi
].name
)
9068 vty_out(vty
, " default route-map %s%s,",
9069 p
->default_rmap
[afi
][safi
].map
? "*"
9071 p
->default_rmap
[afi
][safi
].name
);
9072 if (paf
&& PAF_SUBGRP(paf
)
9073 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9074 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9075 vty_out(vty
, " default sent\n");
9077 vty_out(vty
, " default not sent\n");
9080 /* advertise-vni-all */
9081 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9082 if (is_evpn_enabled())
9083 vty_out(vty
, " advertise-all-vni\n");
9086 if (filter
->plist
[FILTER_IN
].name
9087 || filter
->dlist
[FILTER_IN
].name
9088 || filter
->aslist
[FILTER_IN
].name
9089 || filter
->map
[RMAP_IN
].name
)
9090 vty_out(vty
, " Inbound path policy configured\n");
9091 if (filter
->plist
[FILTER_OUT
].name
9092 || filter
->dlist
[FILTER_OUT
].name
9093 || filter
->aslist
[FILTER_OUT
].name
9094 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9095 vty_out(vty
, " Outbound path policy configured\n");
9098 if (filter
->plist
[FILTER_IN
].name
)
9100 " Incoming update prefix filter list is %s%s\n",
9101 filter
->plist
[FILTER_IN
].plist
? "*" : "",
9102 filter
->plist
[FILTER_IN
].name
);
9103 if (filter
->plist
[FILTER_OUT
].name
)
9105 " Outgoing update prefix filter list is %s%s\n",
9106 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
9107 filter
->plist
[FILTER_OUT
].name
);
9109 /* distribute-list */
9110 if (filter
->dlist
[FILTER_IN
].name
)
9112 " Incoming update network filter list is %s%s\n",
9113 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
9114 filter
->dlist
[FILTER_IN
].name
);
9115 if (filter
->dlist
[FILTER_OUT
].name
)
9117 " Outgoing update network filter list is %s%s\n",
9118 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
9119 filter
->dlist
[FILTER_OUT
].name
);
9122 if (filter
->aslist
[FILTER_IN
].name
)
9124 " Incoming update AS path filter list is %s%s\n",
9125 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
9126 filter
->aslist
[FILTER_IN
].name
);
9127 if (filter
->aslist
[FILTER_OUT
].name
)
9129 " Outgoing update AS path filter list is %s%s\n",
9130 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
9131 filter
->aslist
[FILTER_OUT
].name
);
9134 if (filter
->map
[RMAP_IN
].name
)
9136 " Route map for incoming advertisements is %s%s\n",
9137 filter
->map
[RMAP_IN
].map
? "*" : "",
9138 filter
->map
[RMAP_IN
].name
);
9139 if (filter
->map
[RMAP_OUT
].name
)
9141 " Route map for outgoing advertisements is %s%s\n",
9142 filter
->map
[RMAP_OUT
].map
? "*" : "",
9143 filter
->map
[RMAP_OUT
].name
);
9145 /* ebgp-requires-policy (inbound) */
9146 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9147 && !bgp_inbound_policy_exists(p
, filter
))
9149 " Inbound updates discarded due to missing policy\n");
9151 /* ebgp-requires-policy (outbound) */
9152 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9153 && !bgp_outbound_policy_exists(p
, filter
))
9155 " Outbound updates discarded due to missing policy\n");
9157 /* unsuppress-map */
9158 if (filter
->usmap
.name
)
9160 " Route map for selective unsuppress is %s%s\n",
9161 filter
->usmap
.map
? "*" : "",
9162 filter
->usmap
.name
);
9164 /* Receive prefix count */
9165 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
9167 /* Maximum prefix */
9168 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9169 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
9171 CHECK_FLAG(p
->af_flags
[afi
][safi
],
9172 PEER_FLAG_MAX_PREFIX_WARNING
)
9175 vty_out(vty
, " Threshold for warning message %d%%",
9176 p
->pmax_threshold
[afi
][safi
]);
9177 if (p
->pmax_restart
[afi
][safi
])
9178 vty_out(vty
, ", restart interval %d min",
9179 p
->pmax_restart
[afi
][safi
]);
9187 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
9191 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
9192 char timebuf
[BGP_UPTIME_LEN
];
9194 const char *subcode_str
;
9195 const char *code_str
;
9200 json_object
*json_neigh
= NULL
;
9206 json_neigh
= json_object_new_object();
9208 memset(dn_flag
, '\0', sizeof(dn_flag
));
9209 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9213 if (p
->conf_if
) /* Configured interface name. */
9214 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9215 BGP_PEER_SU_UNSPEC(p
)
9217 : sockunion2str(&p
->su
, buf
,
9219 else /* Configured IP address. */
9220 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9225 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9226 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9228 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9229 json_object_string_add(
9230 json_neigh
, "bgpNeighborAddr",
9231 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9233 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9235 if (p
->change_local_as
)
9236 json_object_int_add(json_neigh
, "localAs",
9237 p
->change_local_as
);
9239 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9241 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9242 json_object_boolean_true_add(json_neigh
,
9243 "localAsNoPrepend");
9245 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9246 json_object_boolean_true_add(json_neigh
,
9247 "localAsReplaceAs");
9249 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9250 || (p
->as_type
== AS_INTERNAL
))
9251 vty_out(vty
, "remote AS %u, ", p
->as
);
9253 vty_out(vty
, "remote AS Unspecified, ");
9254 vty_out(vty
, "local AS %u%s%s, ",
9255 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9256 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9259 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9263 /* peer type internal or confed-internal */
9264 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
9266 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9267 json_object_boolean_true_add(
9268 json_neigh
, "nbrConfedInternalLink");
9270 json_object_boolean_true_add(json_neigh
,
9273 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9274 vty_out(vty
, "confed-internal link\n");
9276 vty_out(vty
, "internal link\n");
9278 /* peer type external or confed-external */
9279 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
9281 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9282 json_object_boolean_true_add(
9283 json_neigh
, "nbrConfedExternalLink");
9285 json_object_boolean_true_add(json_neigh
,
9288 if (bgp_confederation_peers_check(bgp
, p
->as
))
9289 vty_out(vty
, "confed-external link\n");
9291 vty_out(vty
, "external link\n");
9295 json_object_boolean_true_add(json_neigh
,
9296 "nbrUnspecifiedLink");
9298 vty_out(vty
, "unspecified link\n");
9304 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9306 vty_out(vty
, " Description: %s\n", p
->desc
);
9312 json_object_string_add(json_neigh
, "hostname",
9316 json_object_string_add(json_neigh
, "domainname",
9319 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9320 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9323 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9330 json_object_string_add(json_neigh
, "peerGroup",
9334 struct prefix prefix
, *range
= NULL
;
9336 sockunion2hostprefix(&(p
->su
), &prefix
);
9337 range
= peer_group_lookup_dynamic_neighbor_range(
9341 prefix2str(range
, buf1
, sizeof(buf1
));
9342 json_object_string_add(
9344 "peerSubnetRangeGroup", buf1
);
9349 " Member of peer-group %s for session parameters\n",
9353 struct prefix prefix
, *range
= NULL
;
9355 sockunion2hostprefix(&(p
->su
), &prefix
);
9356 range
= peer_group_lookup_dynamic_neighbor_range(
9360 prefix2str(range
, buf1
, sizeof(buf1
));
9362 " Belongs to the subnet range group: %s\n",
9370 /* Administrative shutdown. */
9371 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9372 json_object_boolean_true_add(json_neigh
,
9376 json_object_int_add(json_neigh
, "bgpVersion", 4);
9377 json_object_string_add(
9378 json_neigh
, "remoteRouterId",
9379 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9380 json_object_string_add(
9381 json_neigh
, "localRouterId",
9382 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9386 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9387 && bgp_confederation_peers_check(bgp
, p
->as
))
9388 json_object_boolean_true_add(json_neigh
,
9392 json_object_string_add(
9393 json_neigh
, "bgpState",
9394 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9396 if (p
->status
== Established
) {
9399 uptime
= bgp_clock();
9400 uptime
-= p
->uptime
;
9401 epoch_tbuf
= time(NULL
) - uptime
;
9403 #if CONFDATE > 20200101
9405 "bgpTimerUp should be deprecated and can be removed now");
9408 * bgpTimerUp was miliseconds that was accurate
9409 * up to 1 day, then the value returned
9410 * became garbage. So in order to provide
9411 * some level of backwards compatability,
9412 * we still provde the data, but now
9413 * we are returning the correct value
9414 * and also adding a new bgpTimerUpMsec
9415 * which will allow us to deprecate
9418 json_object_int_add(json_neigh
, "bgpTimerUp",
9420 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9422 json_object_string_add(json_neigh
, "bgpTimerUpString",
9423 peer_uptime(p
->uptime
, timebuf
,
9426 json_object_int_add(json_neigh
,
9427 "bgpTimerUpEstablishedEpoch",
9431 else if (p
->status
== Active
) {
9432 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9433 json_object_string_add(json_neigh
, "bgpStateIs",
9435 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9436 json_object_string_add(json_neigh
, "bgpStateIs",
9444 uptime
= bgp_clock();
9445 uptime
-= p
->readtime
;
9446 tm
= gmtime(&uptime
);
9447 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9448 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9449 + (tm
->tm_hour
* 3600000));
9451 uptime
= bgp_clock();
9452 uptime
-= p
->last_write
;
9453 tm
= gmtime(&uptime
);
9454 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9455 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9456 + (tm
->tm_hour
* 3600000));
9458 uptime
= bgp_clock();
9459 uptime
-= p
->update_time
;
9460 tm
= gmtime(&uptime
);
9461 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9462 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9463 + (tm
->tm_hour
* 3600000));
9465 /* Configured timer values. */
9466 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9467 p
->v_holdtime
* 1000);
9468 json_object_int_add(json_neigh
,
9469 "bgpTimerKeepAliveIntervalMsecs",
9470 p
->v_keepalive
* 1000);
9471 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9472 json_object_int_add(json_neigh
,
9473 "bgpTimerConfiguredHoldTimeMsecs",
9474 p
->holdtime
* 1000);
9475 json_object_int_add(
9477 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9478 p
->keepalive
* 1000);
9479 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9480 || (bgp
->default_keepalive
9481 != BGP_DEFAULT_KEEPALIVE
)) {
9482 json_object_int_add(json_neigh
,
9483 "bgpTimerConfiguredHoldTimeMsecs",
9484 bgp
->default_holdtime
);
9485 json_object_int_add(
9487 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9488 bgp
->default_keepalive
);
9491 /* Administrative shutdown. */
9492 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9493 vty_out(vty
, " Administratively shut down\n");
9496 vty_out(vty
, " BGP version 4");
9497 vty_out(vty
, ", remote router ID %s",
9498 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9499 vty_out(vty
, ", local router ID %s\n",
9500 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9504 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9505 && bgp_confederation_peers_check(bgp
, p
->as
))
9507 " Neighbor under common administration\n");
9510 vty_out(vty
, " BGP state = %s",
9511 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9513 if (p
->status
== Established
)
9514 vty_out(vty
, ", up for %8s",
9515 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9518 else if (p
->status
== Active
) {
9519 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9520 vty_out(vty
, " (passive)");
9521 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9522 vty_out(vty
, " (NSF passive)");
9527 vty_out(vty
, " Last read %s",
9528 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9530 vty_out(vty
, ", Last write %s\n",
9531 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9534 /* Configured timer values. */
9536 " Hold time is %d, keepalive interval is %d seconds\n",
9537 p
->v_holdtime
, p
->v_keepalive
);
9538 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9539 vty_out(vty
, " Configured hold time is %d",
9541 vty_out(vty
, ", keepalive interval is %d seconds\n",
9543 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9544 || (bgp
->default_keepalive
9545 != BGP_DEFAULT_KEEPALIVE
)) {
9546 vty_out(vty
, " Configured hold time is %d",
9547 bgp
->default_holdtime
);
9548 vty_out(vty
, ", keepalive interval is %d seconds\n",
9549 bgp
->default_keepalive
);
9553 if (p
->status
== Established
) {
9554 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9555 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9556 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9557 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9558 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9559 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9560 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9561 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9562 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9563 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9564 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9565 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9566 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9567 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9568 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9569 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9570 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9571 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9572 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9573 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9575 json_object
*json_cap
= NULL
;
9577 json_cap
= json_object_new_object();
9580 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9581 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9582 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9583 && CHECK_FLAG(p
->cap
,
9585 json_object_string_add(
9586 json_cap
, "4byteAs",
9587 "advertisedAndReceived");
9588 else if (CHECK_FLAG(p
->cap
,
9590 json_object_string_add(
9591 json_cap
, "4byteAs",
9593 else if (CHECK_FLAG(p
->cap
,
9595 json_object_string_add(
9596 json_cap
, "4byteAs",
9601 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9602 || CHECK_FLAG(p
->cap
,
9603 PEER_CAP_ADDPATH_ADV
)) {
9604 json_object
*json_add
= NULL
;
9605 const char *print_store
;
9607 json_add
= json_object_new_object();
9609 FOREACH_AFI_SAFI (afi
, safi
) {
9610 json_object
*json_sub
= NULL
;
9612 json_object_new_object();
9613 print_store
= afi_safi_print(
9619 PEER_CAP_ADDPATH_AF_TX_ADV
)
9623 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9628 PEER_CAP_ADDPATH_AF_TX_ADV
)
9633 PEER_CAP_ADDPATH_AF_TX_RCV
))
9634 json_object_boolean_true_add(
9636 "txAdvertisedAndReceived");
9642 PEER_CAP_ADDPATH_AF_TX_ADV
))
9643 json_object_boolean_true_add(
9651 PEER_CAP_ADDPATH_AF_TX_RCV
))
9652 json_object_boolean_true_add(
9660 PEER_CAP_ADDPATH_AF_RX_ADV
)
9664 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9669 PEER_CAP_ADDPATH_AF_RX_ADV
)
9674 PEER_CAP_ADDPATH_AF_RX_RCV
))
9675 json_object_boolean_true_add(
9677 "rxAdvertisedAndReceived");
9683 PEER_CAP_ADDPATH_AF_RX_ADV
))
9684 json_object_boolean_true_add(
9692 PEER_CAP_ADDPATH_AF_RX_RCV
))
9693 json_object_boolean_true_add(
9701 PEER_CAP_ADDPATH_AF_TX_ADV
)
9705 PEER_CAP_ADDPATH_AF_TX_RCV
)
9709 PEER_CAP_ADDPATH_AF_RX_ADV
)
9713 PEER_CAP_ADDPATH_AF_RX_RCV
))
9714 json_object_object_add(
9723 json_object_object_add(
9724 json_cap
, "addPath", json_add
);
9728 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9729 || CHECK_FLAG(p
->cap
,
9730 PEER_CAP_DYNAMIC_ADV
)) {
9731 if (CHECK_FLAG(p
->cap
,
9732 PEER_CAP_DYNAMIC_ADV
)
9733 && CHECK_FLAG(p
->cap
,
9734 PEER_CAP_DYNAMIC_RCV
))
9735 json_object_string_add(
9736 json_cap
, "dynamic",
9737 "advertisedAndReceived");
9738 else if (CHECK_FLAG(
9740 PEER_CAP_DYNAMIC_ADV
))
9741 json_object_string_add(
9742 json_cap
, "dynamic",
9744 else if (CHECK_FLAG(
9746 PEER_CAP_DYNAMIC_RCV
))
9747 json_object_string_add(
9748 json_cap
, "dynamic",
9752 /* Extended nexthop */
9753 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9754 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9755 json_object
*json_nxt
= NULL
;
9756 const char *print_store
;
9759 if (CHECK_FLAG(p
->cap
,
9761 && CHECK_FLAG(p
->cap
,
9763 json_object_string_add(
9766 "advertisedAndReceived");
9767 else if (CHECK_FLAG(p
->cap
,
9769 json_object_string_add(
9773 else if (CHECK_FLAG(p
->cap
,
9775 json_object_string_add(
9780 if (CHECK_FLAG(p
->cap
,
9781 PEER_CAP_ENHE_RCV
)) {
9783 json_object_new_object();
9785 for (safi
= SAFI_UNICAST
;
9786 safi
< SAFI_MAX
; safi
++) {
9791 PEER_CAP_ENHE_AF_RCV
)) {
9792 print_store
= afi_safi_print(
9795 json_object_string_add(
9798 "recieved"); /* misspelled for compatibility */
9801 json_object_object_add(
9803 "extendedNexthopFamililesByPeer",
9809 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9810 || CHECK_FLAG(p
->cap
,
9811 PEER_CAP_REFRESH_NEW_RCV
)
9812 || CHECK_FLAG(p
->cap
,
9813 PEER_CAP_REFRESH_OLD_RCV
)) {
9814 if (CHECK_FLAG(p
->cap
,
9815 PEER_CAP_REFRESH_ADV
)
9818 PEER_CAP_REFRESH_NEW_RCV
)
9821 PEER_CAP_REFRESH_OLD_RCV
))) {
9824 PEER_CAP_REFRESH_OLD_RCV
)
9827 PEER_CAP_REFRESH_NEW_RCV
))
9828 json_object_string_add(
9831 "advertisedAndReceivedOldNew");
9835 PEER_CAP_REFRESH_OLD_RCV
))
9836 json_object_string_add(
9839 "advertisedAndReceivedOld");
9841 json_object_string_add(
9844 "advertisedAndReceivedNew");
9849 PEER_CAP_REFRESH_ADV
))
9850 json_object_string_add(
9857 PEER_CAP_REFRESH_NEW_RCV
)
9860 PEER_CAP_REFRESH_OLD_RCV
))
9861 json_object_string_add(
9867 /* Multiprotocol Extensions */
9868 json_object
*json_multi
= NULL
;
9869 json_multi
= json_object_new_object();
9871 FOREACH_AFI_SAFI (afi
, safi
) {
9872 if (p
->afc_adv
[afi
][safi
]
9873 || p
->afc_recv
[afi
][safi
]) {
9874 json_object
*json_exten
= NULL
;
9876 json_object_new_object();
9878 if (p
->afc_adv
[afi
][safi
]
9879 && p
->afc_recv
[afi
][safi
])
9880 json_object_boolean_true_add(
9882 "advertisedAndReceived");
9883 else if (p
->afc_adv
[afi
][safi
])
9884 json_object_boolean_true_add(
9887 else if (p
->afc_recv
[afi
][safi
])
9888 json_object_boolean_true_add(
9892 json_object_object_add(
9899 json_object_object_add(
9900 json_cap
, "multiprotocolExtensions",
9903 /* Hostname capabilities */
9904 json_object
*json_hname
= NULL
;
9906 json_hname
= json_object_new_object();
9908 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9909 json_object_string_add(
9910 json_hname
, "advHostName",
9911 bgp
->peer_self
->hostname
9915 json_object_string_add(
9916 json_hname
, "advDomainName",
9917 bgp
->peer_self
->domainname
9924 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9925 json_object_string_add(
9926 json_hname
, "rcvHostName",
9927 p
->hostname
? p
->hostname
9929 json_object_string_add(
9930 json_hname
, "rcvDomainName",
9931 p
->domainname
? p
->domainname
9935 json_object_object_add(json_cap
, "hostName",
9938 /* Gracefull Restart */
9939 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9940 || CHECK_FLAG(p
->cap
,
9941 PEER_CAP_RESTART_ADV
)) {
9942 if (CHECK_FLAG(p
->cap
,
9943 PEER_CAP_RESTART_ADV
)
9944 && CHECK_FLAG(p
->cap
,
9945 PEER_CAP_RESTART_RCV
))
9946 json_object_string_add(
9949 "advertisedAndReceived");
9950 else if (CHECK_FLAG(
9952 PEER_CAP_RESTART_ADV
))
9953 json_object_string_add(
9955 "gracefulRestartCapability",
9957 else if (CHECK_FLAG(
9959 PEER_CAP_RESTART_RCV
))
9960 json_object_string_add(
9962 "gracefulRestartCapability",
9965 if (CHECK_FLAG(p
->cap
,
9966 PEER_CAP_RESTART_RCV
)) {
9967 int restart_af_count
= 0;
9968 json_object
*json_restart
=
9971 json_object_new_object();
9973 json_object_int_add(
9975 "gracefulRestartRemoteTimerMsecs",
9976 p
->v_gr_restart
* 1000);
9978 FOREACH_AFI_SAFI (afi
, safi
) {
9983 PEER_CAP_RESTART_AF_RCV
)) {
9988 json_object_new_object();
9994 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
9995 json_object_boolean_true_add(
9999 json_object_object_add(
10007 if (!restart_af_count
) {
10008 json_object_string_add(
10010 "addressFamiliesByPeer",
10015 json_object_object_add(
10017 "addressFamiliesByPeer",
10021 json_object_object_add(json_neigh
,
10022 "neighborCapabilities",
10025 vty_out(vty
, " Neighbor capabilities:\n");
10028 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
10029 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
10030 vty_out(vty
, " 4 Byte AS:");
10031 if (CHECK_FLAG(p
->cap
,
10033 vty_out(vty
, " advertised");
10034 if (CHECK_FLAG(p
->cap
,
10036 vty_out(vty
, " %sreceived",
10042 vty_out(vty
, "\n");
10046 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
10047 || CHECK_FLAG(p
->cap
,
10048 PEER_CAP_ADDPATH_ADV
)) {
10049 vty_out(vty
, " AddPath:\n");
10051 FOREACH_AFI_SAFI (afi
, safi
) {
10055 PEER_CAP_ADDPATH_AF_TX_ADV
)
10059 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
10070 PEER_CAP_ADDPATH_AF_TX_ADV
))
10081 PEER_CAP_ADDPATH_AF_TX_RCV
))
10088 PEER_CAP_ADDPATH_AF_TX_ADV
)
10092 vty_out(vty
, "\n");
10098 PEER_CAP_ADDPATH_AF_RX_ADV
)
10102 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
10113 PEER_CAP_ADDPATH_AF_RX_ADV
))
10124 PEER_CAP_ADDPATH_AF_RX_RCV
))
10131 PEER_CAP_ADDPATH_AF_RX_ADV
)
10135 vty_out(vty
, "\n");
10141 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10142 || CHECK_FLAG(p
->cap
,
10143 PEER_CAP_DYNAMIC_ADV
)) {
10144 vty_out(vty
, " Dynamic:");
10145 if (CHECK_FLAG(p
->cap
,
10146 PEER_CAP_DYNAMIC_ADV
))
10147 vty_out(vty
, " advertised");
10148 if (CHECK_FLAG(p
->cap
,
10149 PEER_CAP_DYNAMIC_RCV
))
10150 vty_out(vty
, " %sreceived",
10153 PEER_CAP_DYNAMIC_ADV
)
10156 vty_out(vty
, "\n");
10159 /* Extended nexthop */
10160 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10161 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10162 vty_out(vty
, " Extended nexthop:");
10163 if (CHECK_FLAG(p
->cap
,
10164 PEER_CAP_ENHE_ADV
))
10165 vty_out(vty
, " advertised");
10166 if (CHECK_FLAG(p
->cap
,
10167 PEER_CAP_ENHE_RCV
))
10168 vty_out(vty
, " %sreceived",
10174 vty_out(vty
, "\n");
10176 if (CHECK_FLAG(p
->cap
,
10177 PEER_CAP_ENHE_RCV
)) {
10179 " Address families by peer:\n ");
10180 for (safi
= SAFI_UNICAST
;
10181 safi
< SAFI_MAX
; safi
++)
10186 PEER_CAP_ENHE_AF_RCV
))
10195 /* Route Refresh */
10196 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10197 || CHECK_FLAG(p
->cap
,
10198 PEER_CAP_REFRESH_NEW_RCV
)
10199 || CHECK_FLAG(p
->cap
,
10200 PEER_CAP_REFRESH_OLD_RCV
)) {
10201 vty_out(vty
, " Route refresh:");
10202 if (CHECK_FLAG(p
->cap
,
10203 PEER_CAP_REFRESH_ADV
))
10204 vty_out(vty
, " advertised");
10205 if (CHECK_FLAG(p
->cap
,
10206 PEER_CAP_REFRESH_NEW_RCV
)
10209 PEER_CAP_REFRESH_OLD_RCV
))
10210 vty_out(vty
, " %sreceived(%s)",
10213 PEER_CAP_REFRESH_ADV
)
10218 PEER_CAP_REFRESH_OLD_RCV
)
10221 PEER_CAP_REFRESH_NEW_RCV
))
10225 PEER_CAP_REFRESH_OLD_RCV
)
10229 vty_out(vty
, "\n");
10232 /* Multiprotocol Extensions */
10233 FOREACH_AFI_SAFI (afi
, safi
)
10234 if (p
->afc_adv
[afi
][safi
]
10235 || p
->afc_recv
[afi
][safi
]) {
10237 " Address Family %s:",
10238 afi_safi_print(afi
,
10240 if (p
->afc_adv
[afi
][safi
])
10243 if (p
->afc_recv
[afi
][safi
])
10250 vty_out(vty
, "\n");
10253 /* Hostname capability */
10254 vty_out(vty
, " Hostname Capability:");
10256 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10258 " advertised (name: %s,domain name: %s)",
10259 bgp
->peer_self
->hostname
10263 bgp
->peer_self
->domainname
10268 vty_out(vty
, " not advertised");
10271 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10273 " received (name: %s,domain name: %s)",
10274 p
->hostname
? p
->hostname
10276 p
->domainname
? p
->domainname
10279 vty_out(vty
, " not received");
10282 vty_out(vty
, "\n");
10284 /* Gracefull Restart */
10285 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10286 || CHECK_FLAG(p
->cap
,
10287 PEER_CAP_RESTART_ADV
)) {
10289 " Graceful Restart Capabilty:");
10290 if (CHECK_FLAG(p
->cap
,
10291 PEER_CAP_RESTART_ADV
))
10292 vty_out(vty
, " advertised");
10293 if (CHECK_FLAG(p
->cap
,
10294 PEER_CAP_RESTART_RCV
))
10295 vty_out(vty
, " %sreceived",
10298 PEER_CAP_RESTART_ADV
)
10301 vty_out(vty
, "\n");
10303 if (CHECK_FLAG(p
->cap
,
10304 PEER_CAP_RESTART_RCV
)) {
10305 int restart_af_count
= 0;
10308 " Remote Restart timer is %d seconds\n",
10311 " Address families by peer:\n ");
10313 FOREACH_AFI_SAFI (afi
, safi
)
10318 PEER_CAP_RESTART_AF_RCV
)) {
10331 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10333 : "not preserved");
10334 restart_af_count
++;
10336 if (!restart_af_count
)
10337 vty_out(vty
, "none");
10338 vty_out(vty
, "\n");
10345 /* graceful restart information */
10346 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10347 || p
->t_gr_stale
) {
10348 json_object
*json_grace
= NULL
;
10349 json_object
*json_grace_send
= NULL
;
10350 json_object
*json_grace_recv
= NULL
;
10351 int eor_send_af_count
= 0;
10352 int eor_receive_af_count
= 0;
10355 json_grace
= json_object_new_object();
10356 json_grace_send
= json_object_new_object();
10357 json_grace_recv
= json_object_new_object();
10359 if (p
->status
== Established
) {
10360 FOREACH_AFI_SAFI (afi
, safi
) {
10361 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10362 PEER_STATUS_EOR_SEND
)) {
10363 json_object_boolean_true_add(
10365 afi_safi_print(afi
,
10367 eor_send_af_count
++;
10370 FOREACH_AFI_SAFI (afi
, safi
) {
10372 p
->af_sflags
[afi
][safi
],
10373 PEER_STATUS_EOR_RECEIVED
)) {
10374 json_object_boolean_true_add(
10376 afi_safi_print(afi
,
10378 eor_receive_af_count
++;
10383 json_object_object_add(json_grace
, "endOfRibSend",
10385 json_object_object_add(json_grace
, "endOfRibRecv",
10388 if (p
->t_gr_restart
)
10389 json_object_int_add(json_grace
,
10390 "gracefulRestartTimerMsecs",
10391 thread_timer_remain_second(
10396 json_object_int_add(
10398 "gracefulStalepathTimerMsecs",
10399 thread_timer_remain_second(
10403 json_object_object_add(
10404 json_neigh
, "gracefulRestartInfo", json_grace
);
10406 vty_out(vty
, " Graceful restart information:\n");
10407 if (p
->status
== Established
) {
10408 vty_out(vty
, " End-of-RIB send: ");
10409 FOREACH_AFI_SAFI (afi
, safi
) {
10410 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10411 PEER_STATUS_EOR_SEND
)) {
10412 vty_out(vty
, "%s%s",
10413 eor_send_af_count
? ", "
10415 afi_safi_print(afi
,
10417 eor_send_af_count
++;
10420 vty_out(vty
, "\n");
10421 vty_out(vty
, " End-of-RIB received: ");
10422 FOREACH_AFI_SAFI (afi
, safi
) {
10424 p
->af_sflags
[afi
][safi
],
10425 PEER_STATUS_EOR_RECEIVED
)) {
10426 vty_out(vty
, "%s%s",
10427 eor_receive_af_count
10430 afi_safi_print(afi
,
10432 eor_receive_af_count
++;
10435 vty_out(vty
, "\n");
10438 if (p
->t_gr_restart
)
10440 " The remaining time of restart timer is %ld\n",
10441 thread_timer_remain_second(
10446 " The remaining time of stalepath timer is %ld\n",
10447 thread_timer_remain_second(
10452 json_object
*json_stat
= NULL
;
10453 json_stat
= json_object_new_object();
10454 /* Packet counts. */
10455 json_object_int_add(json_stat
, "depthInq", 0);
10456 json_object_int_add(json_stat
, "depthOutq",
10457 (unsigned long)p
->obuf
->count
);
10458 json_object_int_add(json_stat
, "opensSent",
10459 atomic_load_explicit(&p
->open_out
,
10460 memory_order_relaxed
));
10461 json_object_int_add(json_stat
, "opensRecv",
10462 atomic_load_explicit(&p
->open_in
,
10463 memory_order_relaxed
));
10464 json_object_int_add(json_stat
, "notificationsSent",
10465 atomic_load_explicit(&p
->notify_out
,
10466 memory_order_relaxed
));
10467 json_object_int_add(json_stat
, "notificationsRecv",
10468 atomic_load_explicit(&p
->notify_in
,
10469 memory_order_relaxed
));
10470 json_object_int_add(json_stat
, "updatesSent",
10471 atomic_load_explicit(&p
->update_out
,
10472 memory_order_relaxed
));
10473 json_object_int_add(json_stat
, "updatesRecv",
10474 atomic_load_explicit(&p
->update_in
,
10475 memory_order_relaxed
));
10476 json_object_int_add(json_stat
, "keepalivesSent",
10477 atomic_load_explicit(&p
->keepalive_out
,
10478 memory_order_relaxed
));
10479 json_object_int_add(json_stat
, "keepalivesRecv",
10480 atomic_load_explicit(&p
->keepalive_in
,
10481 memory_order_relaxed
));
10482 json_object_int_add(json_stat
, "routeRefreshSent",
10483 atomic_load_explicit(&p
->refresh_out
,
10484 memory_order_relaxed
));
10485 json_object_int_add(json_stat
, "routeRefreshRecv",
10486 atomic_load_explicit(&p
->refresh_in
,
10487 memory_order_relaxed
));
10488 json_object_int_add(json_stat
, "capabilitySent",
10489 atomic_load_explicit(&p
->dynamic_cap_out
,
10490 memory_order_relaxed
));
10491 json_object_int_add(json_stat
, "capabilityRecv",
10492 atomic_load_explicit(&p
->dynamic_cap_in
,
10493 memory_order_relaxed
));
10494 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10495 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10496 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10498 /* Packet counts. */
10499 vty_out(vty
, " Message statistics:\n");
10500 vty_out(vty
, " Inq depth is 0\n");
10501 vty_out(vty
, " Outq depth is %lu\n",
10502 (unsigned long)p
->obuf
->count
);
10503 vty_out(vty
, " Sent Rcvd\n");
10504 vty_out(vty
, " Opens: %10d %10d\n",
10505 atomic_load_explicit(&p
->open_out
,
10506 memory_order_relaxed
),
10507 atomic_load_explicit(&p
->open_in
,
10508 memory_order_relaxed
));
10509 vty_out(vty
, " Notifications: %10d %10d\n",
10510 atomic_load_explicit(&p
->notify_out
,
10511 memory_order_relaxed
),
10512 atomic_load_explicit(&p
->notify_in
,
10513 memory_order_relaxed
));
10514 vty_out(vty
, " Updates: %10d %10d\n",
10515 atomic_load_explicit(&p
->update_out
,
10516 memory_order_relaxed
),
10517 atomic_load_explicit(&p
->update_in
,
10518 memory_order_relaxed
));
10519 vty_out(vty
, " Keepalives: %10d %10d\n",
10520 atomic_load_explicit(&p
->keepalive_out
,
10521 memory_order_relaxed
),
10522 atomic_load_explicit(&p
->keepalive_in
,
10523 memory_order_relaxed
));
10524 vty_out(vty
, " Route Refresh: %10d %10d\n",
10525 atomic_load_explicit(&p
->refresh_out
,
10526 memory_order_relaxed
),
10527 atomic_load_explicit(&p
->refresh_in
,
10528 memory_order_relaxed
));
10529 vty_out(vty
, " Capability: %10d %10d\n",
10530 atomic_load_explicit(&p
->dynamic_cap_out
,
10531 memory_order_relaxed
),
10532 atomic_load_explicit(&p
->dynamic_cap_in
,
10533 memory_order_relaxed
));
10534 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10539 /* advertisement-interval */
10540 json_object_int_add(json_neigh
,
10541 "minBtwnAdvertisementRunsTimerMsecs",
10542 p
->v_routeadv
* 1000);
10544 /* Update-source. */
10545 if (p
->update_if
|| p
->update_source
) {
10547 json_object_string_add(json_neigh
,
10550 else if (p
->update_source
)
10551 json_object_string_add(
10552 json_neigh
, "updateSource",
10553 sockunion2str(p
->update_source
, buf1
,
10557 /* advertisement-interval */
10559 " Minimum time between advertisement runs is %d seconds\n",
10562 /* Update-source. */
10563 if (p
->update_if
|| p
->update_source
) {
10564 vty_out(vty
, " Update source is ");
10566 vty_out(vty
, "%s", p
->update_if
);
10567 else if (p
->update_source
)
10569 sockunion2str(p
->update_source
, buf1
,
10571 vty_out(vty
, "\n");
10574 vty_out(vty
, "\n");
10577 /* Address Family Information */
10578 json_object
*json_hold
= NULL
;
10581 json_hold
= json_object_new_object();
10583 FOREACH_AFI_SAFI (afi
, safi
)
10584 if (p
->afc
[afi
][safi
])
10585 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10589 json_object_object_add(json_neigh
, "addressFamilyInfo",
10591 json_object_int_add(json_neigh
, "connectionsEstablished",
10593 json_object_int_add(json_neigh
, "connectionsDropped",
10596 vty_out(vty
, " Connections established %d; dropped %d\n",
10597 p
->established
, p
->dropped
);
10599 if (!p
->last_reset
) {
10601 json_object_string_add(json_neigh
, "lastReset",
10604 vty_out(vty
, " Last reset never\n");
10610 uptime
= bgp_clock();
10611 uptime
-= p
->resettime
;
10612 tm
= gmtime(&uptime
);
10613 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10614 (tm
->tm_sec
* 1000)
10615 + (tm
->tm_min
* 60000)
10616 + (tm
->tm_hour
* 3600000));
10617 json_object_string_add(
10618 json_neigh
, "lastResetDueTo",
10619 peer_down_str
[(int)p
->last_reset
]);
10620 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10621 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10622 char errorcodesubcode_hexstr
[5];
10623 char errorcodesubcode_str
[256];
10625 code_str
= bgp_notify_code_str(p
->notify
.code
);
10626 subcode_str
= bgp_notify_subcode_str(
10627 p
->notify
.code
, p
->notify
.subcode
);
10629 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10630 p
->notify
.code
, p
->notify
.subcode
);
10631 json_object_string_add(json_neigh
,
10632 "lastErrorCodeSubcode",
10633 errorcodesubcode_hexstr
);
10634 snprintf(errorcodesubcode_str
, 255, "%s%s",
10635 code_str
, subcode_str
);
10636 json_object_string_add(json_neigh
,
10637 "lastNotificationReason",
10638 errorcodesubcode_str
);
10639 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10640 && p
->notify
.code
== BGP_NOTIFY_CEASE
10641 && (p
->notify
.subcode
10642 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10643 || p
->notify
.subcode
10644 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10645 && p
->notify
.length
) {
10647 const char *msg_str
;
10649 msg_str
= bgp_notify_admin_message(
10650 msgbuf
, sizeof(msgbuf
),
10651 (uint8_t *)p
->notify
.data
,
10654 json_object_string_add(
10656 "lastShutdownDescription",
10661 vty_out(vty
, " Last reset %s, ",
10662 peer_uptime(p
->resettime
, timebuf
,
10663 BGP_UPTIME_LEN
, 0, NULL
));
10665 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10666 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10667 code_str
= bgp_notify_code_str(p
->notify
.code
);
10668 subcode_str
= bgp_notify_subcode_str(
10669 p
->notify
.code
, p
->notify
.subcode
);
10670 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10671 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10674 code_str
, subcode_str
);
10675 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10676 && p
->notify
.code
== BGP_NOTIFY_CEASE
10677 && (p
->notify
.subcode
10678 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10679 || p
->notify
.subcode
10680 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10681 && p
->notify
.length
) {
10683 const char *msg_str
;
10685 msg_str
= bgp_notify_admin_message(
10686 msgbuf
, sizeof(msgbuf
),
10687 (uint8_t *)p
->notify
.data
,
10691 " Message: \"%s\"\n",
10695 vty_out(vty
, "due to %s\n",
10696 peer_down_str
[(int)p
->last_reset
]);
10699 if (p
->last_reset_cause_size
) {
10700 msg
= p
->last_reset_cause
;
10702 " Message received that caused BGP to send a NOTIFICATION:\n ");
10703 for (i
= 1; i
<= p
->last_reset_cause_size
;
10705 vty_out(vty
, "%02X", *msg
++);
10707 if (i
!= p
->last_reset_cause_size
) {
10709 vty_out(vty
, "\n ");
10710 } else if (i
% 4 == 0) {
10715 vty_out(vty
, "\n");
10720 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10722 json_object_boolean_true_add(json_neigh
,
10723 "prefixesConfigExceedMax");
10726 " Peer had exceeded the max. no. of prefixes configured.\n");
10728 if (p
->t_pmax_restart
) {
10730 json_object_boolean_true_add(
10731 json_neigh
, "reducePrefixNumFrom");
10732 json_object_int_add(json_neigh
,
10733 "restartInTimerMsec",
10734 thread_timer_remain_second(
10739 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10740 p
->host
, thread_timer_remain_second(
10741 p
->t_pmax_restart
));
10744 json_object_boolean_true_add(
10746 "reducePrefixNumAndClearIpBgp");
10749 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10754 /* EBGP Multihop and GTSM */
10755 if (p
->sort
!= BGP_PEER_IBGP
) {
10757 if (p
->gtsm_hops
> 0)
10758 json_object_int_add(json_neigh
,
10759 "externalBgpNbrMaxHopsAway",
10761 else if (p
->ttl
> 1)
10762 json_object_int_add(json_neigh
,
10763 "externalBgpNbrMaxHopsAway",
10766 if (p
->gtsm_hops
> 0)
10768 " External BGP neighbor may be up to %d hops away.\n",
10770 else if (p
->ttl
> 1)
10772 " External BGP neighbor may be up to %d hops away.\n",
10776 if (p
->gtsm_hops
> 0) {
10778 json_object_int_add(json_neigh
,
10779 "internalBgpNbrMaxHopsAway",
10783 " Internal BGP neighbor may be up to %d hops away.\n",
10788 /* Local address. */
10791 json_object_string_add(json_neigh
, "hostLocal",
10792 sockunion2str(p
->su_local
, buf1
,
10794 json_object_int_add(json_neigh
, "portLocal",
10795 ntohs(p
->su_local
->sin
.sin_port
));
10797 vty_out(vty
, "Local host: %s, Local port: %d\n",
10798 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10799 ntohs(p
->su_local
->sin
.sin_port
));
10802 /* Remote address. */
10803 if (p
->su_remote
) {
10805 json_object_string_add(json_neigh
, "hostForeign",
10806 sockunion2str(p
->su_remote
, buf1
,
10808 json_object_int_add(json_neigh
, "portForeign",
10809 ntohs(p
->su_remote
->sin
.sin_port
));
10811 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10812 sockunion2str(p
->su_remote
, buf1
,
10814 ntohs(p
->su_remote
->sin
.sin_port
));
10817 /* Nexthop display. */
10820 json_object_string_add(json_neigh
, "nexthop",
10822 &p
->nexthop
.v4
, buf1
,
10824 json_object_string_add(json_neigh
, "nexthopGlobal",
10825 inet_ntop(AF_INET6
,
10826 &p
->nexthop
.v6_global
,
10827 buf1
, sizeof(buf1
)));
10828 json_object_string_add(json_neigh
, "nexthopLocal",
10829 inet_ntop(AF_INET6
,
10830 &p
->nexthop
.v6_local
,
10831 buf1
, sizeof(buf1
)));
10832 if (p
->shared_network
)
10833 json_object_string_add(json_neigh
,
10837 json_object_string_add(json_neigh
,
10839 "nonSharedNetwork");
10841 vty_out(vty
, "Nexthop: %s\n",
10842 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10844 vty_out(vty
, "Nexthop global: %s\n",
10845 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10847 vty_out(vty
, "Nexthop local: %s\n",
10848 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10850 vty_out(vty
, "BGP connection: %s\n",
10851 p
->shared_network
? "shared network"
10852 : "non shared network");
10856 /* Timer information. */
10858 json_object_int_add(json_neigh
, "connectRetryTimer",
10860 if (p
->status
== Established
&& p
->rtt
)
10861 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10864 json_object_int_add(
10865 json_neigh
, "nextStartTimerDueInMsecs",
10866 thread_timer_remain_second(p
->t_start
) * 1000);
10868 json_object_int_add(
10869 json_neigh
, "nextConnectTimerDueInMsecs",
10870 thread_timer_remain_second(p
->t_connect
)
10872 if (p
->t_routeadv
) {
10873 json_object_int_add(json_neigh
, "mraiInterval",
10875 json_object_int_add(
10876 json_neigh
, "mraiTimerExpireInMsecs",
10877 thread_timer_remain_second(p
->t_routeadv
)
10881 json_object_int_add(json_neigh
, "authenticationEnabled",
10885 json_object_string_add(json_neigh
, "readThread", "on");
10887 json_object_string_add(json_neigh
, "readThread", "off");
10889 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10890 json_object_string_add(json_neigh
, "writeThread", "on");
10892 json_object_string_add(json_neigh
, "writeThread",
10895 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10897 if (p
->status
== Established
&& p
->rtt
)
10898 vty_out(vty
, "Estimated round trip time: %d ms\n",
10901 vty_out(vty
, "Next start timer due in %ld seconds\n",
10902 thread_timer_remain_second(p
->t_start
));
10904 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10905 thread_timer_remain_second(p
->t_connect
));
10908 "MRAI (interval %u) timer expires in %ld seconds\n",
10910 thread_timer_remain_second(p
->t_routeadv
));
10912 vty_out(vty
, "Peer Authentication Enabled\n");
10914 vty_out(vty
, "Read thread: %s Write thread: %s\n",
10915 p
->t_read
? "on" : "off",
10916 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10921 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10922 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10923 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10926 vty_out(vty
, "\n");
10928 /* BFD information. */
10929 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10932 if (p
->conf_if
) /* Configured interface name. */
10933 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10934 else /* Configured IP address. */
10935 json_object_object_add(json
, p
->host
, json_neigh
);
10939 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10940 enum show_type type
, union sockunion
*su
,
10941 const char *conf_if
, bool use_json
,
10944 struct listnode
*node
, *nnode
;
10947 bool nbr_output
= false;
10949 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10950 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10955 bgp_show_peer(vty
, peer
, use_json
, json
);
10961 && !strcmp(peer
->conf_if
, conf_if
))
10963 && !strcmp(peer
->hostname
, conf_if
))) {
10965 bgp_show_peer(vty
, peer
, use_json
,
10969 if (sockunion_same(&peer
->su
, su
)) {
10971 bgp_show_peer(vty
, peer
, use_json
,
10979 if (type
== show_peer
&& !find
) {
10981 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
10983 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
10986 if (type
!= show_peer
&& !nbr_output
&& !use_json
)
10987 vty_out(vty
, "%% No BGP neighbors found\n");
10990 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10991 json
, JSON_C_TO_STRING_PRETTY
));
10993 vty_out(vty
, "\n");
10996 return CMD_SUCCESS
;
10999 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
11000 enum show_type type
,
11001 const char *ip_str
,
11004 struct listnode
*node
, *nnode
;
11006 union sockunion su
;
11007 json_object
*json
= NULL
;
11008 int ret
, is_first
= 1;
11009 bool nbr_output
= false;
11012 vty_out(vty
, "{\n");
11014 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11017 if (!(json
= json_object_new_object())) {
11019 EC_BGP_JSON_MEM_ERROR
,
11020 "Unable to allocate memory for JSON object");
11022 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
11026 json_object_int_add(json
, "vrfId",
11027 (bgp
->vrf_id
== VRF_UNKNOWN
)
11029 : (int64_t)bgp
->vrf_id
);
11030 json_object_string_add(
11032 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11037 vty_out(vty
, ",\n");
11041 vty_out(vty
, "\"%s\":",
11042 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11046 vty_out(vty
, "\nInstance %s:\n",
11047 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11052 if (type
== show_peer
) {
11053 ret
= str2sockunion(ip_str
, &su
);
11055 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11058 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11061 bgp_show_neighbor(vty
, bgp
, show_all
, NULL
, NULL
,
11064 json_object_free(json
);
11068 vty_out(vty
, "}\n");
11069 json_object_free(json
);
11071 else if (!nbr_output
)
11072 vty_out(vty
, "%% BGP instance not found\n");
11075 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
11076 enum show_type type
, const char *ip_str
,
11081 union sockunion su
;
11082 json_object
*json
= NULL
;
11085 if (strmatch(name
, "all")) {
11086 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
11088 return CMD_SUCCESS
;
11090 bgp
= bgp_lookup_by_name(name
);
11093 json
= json_object_new_object();
11094 vty_out(vty
, "%s\n",
11095 json_object_to_json_string_ext(
11097 JSON_C_TO_STRING_PRETTY
));
11098 json_object_free(json
);
11101 "%% BGP instance not found\n");
11103 return CMD_WARNING
;
11107 bgp
= bgp_get_default();
11111 json
= json_object_new_object();
11113 ret
= str2sockunion(ip_str
, &su
);
11115 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11118 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11121 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
11124 json_object_free(json
);
11127 vty_out(vty
, "{}\n");
11129 vty_out(vty
, "%% BGP instance not found\n");
11132 return CMD_SUCCESS
;
11135 /* "show [ip] bgp neighbors" commands. */
11136 DEFUN (show_ip_bgp_neighbors
,
11137 show_ip_bgp_neighbors_cmd
,
11138 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
11142 BGP_INSTANCE_HELP_STR
11145 "Detailed information on TCP and BGP neighbor connections\n"
11146 "Neighbor to display information about\n"
11147 "Neighbor to display information about\n"
11148 "Neighbor on BGP configured interface\n"
11152 char *sh_arg
= NULL
;
11153 enum show_type sh_type
;
11155 bool uj
= use_json(argc
, argv
);
11159 /* [<vrf> VIEWVRFNAME] */
11160 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11161 vrf
= argv
[idx
+ 1]->arg
;
11162 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11164 } else if (argv_find(argv
, argc
, "view", &idx
))
11165 /* [<view> VIEWVRFNAME] */
11166 vrf
= argv
[idx
+ 1]->arg
;
11169 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
11170 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
11171 || argv_find(argv
, argc
, "WORD", &idx
)) {
11172 sh_type
= show_peer
;
11173 sh_arg
= argv
[idx
]->arg
;
11175 sh_type
= show_all
;
11177 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
11180 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
11181 paths' and `show ip mbgp paths'. Those functions results are the
11183 DEFUN (show_ip_bgp_paths
,
11184 show_ip_bgp_paths_cmd
,
11185 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
11190 "Path information\n")
11192 vty_out(vty
, "Address Refcnt Path\n");
11193 aspath_print_all_vty(vty
);
11194 return CMD_SUCCESS
;
11199 static void community_show_all_iterator(struct hash_bucket
*bucket
,
11202 struct community
*com
;
11204 com
= (struct community
*)bucket
->data
;
11205 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
11206 community_str(com
, false));
11209 /* Show BGP's community internal data. */
11210 DEFUN (show_ip_bgp_community_info
,
11211 show_ip_bgp_community_info_cmd
,
11212 "show [ip] bgp community-info",
11216 "List all bgp community information\n")
11218 vty_out(vty
, "Address Refcnt Community\n");
11220 hash_iterate(community_hash(),
11221 (void (*)(struct hash_bucket
*,
11222 void *))community_show_all_iterator
,
11225 return CMD_SUCCESS
;
11228 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
11231 struct lcommunity
*lcom
;
11233 lcom
= (struct lcommunity
*)bucket
->data
;
11234 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11235 lcommunity_str(lcom
, false));
11238 /* Show BGP's community internal data. */
11239 DEFUN (show_ip_bgp_lcommunity_info
,
11240 show_ip_bgp_lcommunity_info_cmd
,
11241 "show ip bgp large-community-info",
11245 "List all bgp large-community information\n")
11247 vty_out(vty
, "Address Refcnt Large-community\n");
11249 hash_iterate(lcommunity_hash(),
11250 (void (*)(struct hash_bucket
*,
11251 void *))lcommunity_show_all_iterator
,
11254 return CMD_SUCCESS
;
11258 DEFUN (show_ip_bgp_attr_info
,
11259 show_ip_bgp_attr_info_cmd
,
11260 "show [ip] bgp attribute-info",
11264 "List all bgp attribute information\n")
11266 attr_show_all(vty
);
11267 return CMD_SUCCESS
;
11270 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11271 safi_t safi
, bool use_json
)
11274 struct listnode
*node
;
11276 char buf1
[INET6_ADDRSTRLEN
];
11278 vpn_policy_direction_t dir
;
11281 json_object
*json
= NULL
;
11282 json_object
*json_import_vrfs
= NULL
;
11283 json_object
*json_export_vrfs
= NULL
;
11285 json
= json_object_new_object();
11287 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11290 vty_out(vty
, "%s\n",
11291 json_object_to_json_string_ext(
11293 JSON_C_TO_STRING_PRETTY
));
11294 json_object_free(json
);
11296 return CMD_WARNING
;
11299 /* Provide context for the block */
11300 json_object_string_add(json
, "vrf", name
? name
: "default");
11301 json_object_string_add(json
, "afiSafi",
11302 afi_safi_print(afi
, safi
));
11304 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11305 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11306 json_object_string_add(json
, "importFromVrfs", "none");
11307 json_object_string_add(json
, "importRts", "none");
11309 json_import_vrfs
= json_object_new_array();
11311 for (ALL_LIST_ELEMENTS_RO(
11312 bgp
->vpn_policy
[afi
].import_vrf
,
11314 json_object_array_add(json_import_vrfs
,
11315 json_object_new_string(vname
));
11317 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11318 ecom_str
= ecommunity_ecom2str(
11319 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11320 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11321 json_object_object_add(json
, "importFromVrfs",
11323 json_object_string_add(json
, "importRts", ecom_str
);
11325 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11328 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11329 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11330 json_object_string_add(json
, "exportToVrfs", "none");
11331 json_object_string_add(json
, "routeDistinguisher",
11333 json_object_string_add(json
, "exportRts", "none");
11335 json_export_vrfs
= json_object_new_array();
11337 for (ALL_LIST_ELEMENTS_RO(
11338 bgp
->vpn_policy
[afi
].export_vrf
,
11340 json_object_array_add(json_export_vrfs
,
11341 json_object_new_string(vname
));
11342 json_object_object_add(json
, "exportToVrfs",
11344 json_object_string_add(json
, "routeDistinguisher",
11345 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11346 buf1
, RD_ADDRSTRLEN
));
11348 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11349 ecom_str
= ecommunity_ecom2str(
11350 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11351 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11352 json_object_string_add(json
, "exportRts", ecom_str
);
11354 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11357 vty_out(vty
, "%s\n",
11358 json_object_to_json_string_ext(json
,
11359 JSON_C_TO_STRING_PRETTY
));
11360 json_object_free(json
);
11363 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11366 vty_out(vty
, "%% No such BGP instance exist\n");
11367 return CMD_WARNING
;
11370 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11371 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11373 "This VRF is not importing %s routes from any other VRF\n",
11374 afi_safi_print(afi
, safi
));
11377 "This VRF is importing %s routes from the following VRFs:\n",
11378 afi_safi_print(afi
, safi
));
11380 for (ALL_LIST_ELEMENTS_RO(
11381 bgp
->vpn_policy
[afi
].import_vrf
,
11383 vty_out(vty
, " %s\n", vname
);
11385 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11386 ecom_str
= ecommunity_ecom2str(
11387 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11388 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11389 vty_out(vty
, "Import RT(s): %s\n", 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
))
11397 "This VRF is not exporting %s routes to any other VRF\n",
11398 afi_safi_print(afi
, safi
));
11401 "This VRF is exporting %s routes to the following VRFs:\n",
11402 afi_safi_print(afi
, safi
));
11404 for (ALL_LIST_ELEMENTS_RO(
11405 bgp
->vpn_policy
[afi
].export_vrf
,
11407 vty_out(vty
, " %s\n", vname
);
11409 vty_out(vty
, "RD: %s\n",
11410 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11411 buf1
, RD_ADDRSTRLEN
));
11413 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11414 ecom_str
= ecommunity_ecom2str(
11415 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11416 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11417 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11418 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11422 return CMD_SUCCESS
;
11425 /* "show [ip] bgp route-leak" command. */
11426 DEFUN (show_ip_bgp_route_leak
,
11427 show_ip_bgp_route_leak_cmd
,
11428 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11432 BGP_INSTANCE_HELP_STR
11435 "Route leaking information\n"
11439 afi_t afi
= AFI_MAX
;
11440 safi_t safi
= SAFI_MAX
;
11442 bool uj
= use_json(argc
, argv
);
11445 /* show [ip] bgp */
11446 if (argv_find(argv
, argc
, "ip", &idx
)) {
11448 safi
= SAFI_UNICAST
;
11450 /* [vrf VIEWVRFNAME] */
11451 if (argv_find(argv
, argc
, "view", &idx
)) {
11453 "%% This command is not applicable to BGP views\n");
11454 return CMD_WARNING
;
11457 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11458 vrf
= argv
[idx
+ 1]->arg
;
11459 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11462 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11463 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11464 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11467 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11469 "%% This command is applicable only for unicast ipv4|ipv6\n");
11470 return CMD_WARNING
;
11473 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
);
11476 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11479 struct listnode
*node
, *nnode
;
11482 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11483 vty_out(vty
, "\nInstance %s:\n",
11484 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11487 update_group_show(bgp
, afi
, safi
, vty
, 0);
11491 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11492 int safi
, uint64_t subgrp_id
)
11497 if (strmatch(name
, "all")) {
11498 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11499 return CMD_SUCCESS
;
11501 bgp
= bgp_lookup_by_name(name
);
11504 bgp
= bgp_get_default();
11508 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11509 return CMD_SUCCESS
;
11512 DEFUN (show_ip_bgp_updgrps
,
11513 show_ip_bgp_updgrps_cmd
,
11514 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11518 BGP_INSTANCE_HELP_STR
11520 BGP_SAFI_WITH_LABEL_HELP_STR
11521 "Detailed info about dynamic update groups\n"
11522 "Specific subgroup to display detailed info for\n")
11525 afi_t afi
= AFI_IP6
;
11526 safi_t safi
= SAFI_UNICAST
;
11527 uint64_t subgrp_id
= 0;
11531 /* show [ip] bgp */
11532 if (argv_find(argv
, argc
, "ip", &idx
))
11534 /* [<vrf> VIEWVRFNAME] */
11535 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11536 vrf
= argv
[idx
+ 1]->arg
;
11537 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11539 } else if (argv_find(argv
, argc
, "view", &idx
))
11540 /* [<view> VIEWVRFNAME] */
11541 vrf
= argv
[idx
+ 1]->arg
;
11542 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11543 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11544 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11547 /* get subgroup id, if provided */
11549 if (argv
[idx
]->type
== VARIABLE_TKN
)
11550 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11552 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11555 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11556 show_bgp_instance_all_ipv6_updgrps_cmd
,
11557 "show [ip] bgp <view|vrf> all update-groups",
11561 BGP_INSTANCE_ALL_HELP_STR
11562 "Detailed info about dynamic update groups\n")
11564 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11565 return CMD_SUCCESS
;
11568 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
11569 show_bgp_l2vpn_evpn_updgrps_cmd
,
11570 "show [ip] bgp l2vpn evpn update-groups",
11574 "l2vpn address family\n"
11575 "evpn sub-address family\n"
11576 "Detailed info about dynamic update groups\n")
11579 uint64_t subgrp_id
= 0;
11581 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
11582 return CMD_SUCCESS
;
11585 DEFUN (show_bgp_updgrps_stats
,
11586 show_bgp_updgrps_stats_cmd
,
11587 "show [ip] bgp update-groups statistics",
11591 "Detailed info about dynamic update groups\n"
11596 bgp
= bgp_get_default();
11598 update_group_show_stats(bgp
, vty
);
11600 return CMD_SUCCESS
;
11603 DEFUN (show_bgp_instance_updgrps_stats
,
11604 show_bgp_instance_updgrps_stats_cmd
,
11605 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11609 BGP_INSTANCE_HELP_STR
11610 "Detailed info about dynamic update groups\n"
11616 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11618 update_group_show_stats(bgp
, vty
);
11620 return CMD_SUCCESS
;
11623 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11624 afi_t afi
, safi_t safi
,
11625 const char *what
, uint64_t subgrp_id
)
11630 bgp
= bgp_lookup_by_name(name
);
11632 bgp
= bgp_get_default();
11635 if (!strcmp(what
, "advertise-queue"))
11636 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11638 else if (!strcmp(what
, "advertised-routes"))
11639 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11641 else if (!strcmp(what
, "packet-queue"))
11642 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11647 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11648 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11649 "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",
11650 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11652 "Detailed info about dynamic update groups\n"
11653 "Specific subgroup to display info for\n"
11654 "Advertisement queue\n"
11655 "Announced routes\n"
11658 uint64_t subgrp_id
= 0;
11662 subgrp_id
= strtoull(sgid
, NULL
, 10);
11667 afiz
= bgp_vty_afi_from_str(afi
);
11671 afiz
= bgp_vty_afi_from_str(afi
);
11672 if (afiz
!= AFI_IP
)
11674 "%% Cannot specify both 'ip' and 'ipv6'\n");
11675 return CMD_WARNING
;
11678 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11680 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11681 return CMD_SUCCESS
;
11684 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11686 struct listnode
*node
, *nnode
;
11687 struct prefix
*range
;
11690 char buf
[PREFIX2STR_BUFFER
];
11693 const char *peer_status
;
11694 const char *af_str
;
11699 conf
= group
->conf
;
11701 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11702 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11703 group
->name
, conf
->as
);
11704 } else if (conf
->as_type
== AS_INTERNAL
) {
11705 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11706 group
->name
, group
->bgp
->as
);
11708 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11711 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11712 vty_out(vty
, " Peer-group type is internal\n");
11714 vty_out(vty
, " Peer-group type is external\n");
11716 /* Display AFs configured. */
11717 vty_out(vty
, " Configured address-families:");
11718 FOREACH_AFI_SAFI (afi
, safi
) {
11719 if (conf
->afc
[afi
][safi
]) {
11721 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11725 vty_out(vty
, " none\n");
11727 vty_out(vty
, "\n");
11729 /* Display listen ranges (for dynamic neighbors), if any */
11730 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11733 else if (afi
== AFI_IP6
)
11737 lr_count
= listcount(group
->listen_range
[afi
]);
11739 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11743 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11745 prefix2str(range
, buf
, sizeof(buf
));
11746 vty_out(vty
, " %s\n", buf
);
11751 /* Display group members and their status */
11752 if (listcount(group
->peer
)) {
11753 vty_out(vty
, " Peer-group members:\n");
11754 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11755 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11756 peer_status
= "Idle (Admin)";
11757 else if (CHECK_FLAG(peer
->sflags
,
11758 PEER_STATUS_PREFIX_OVERFLOW
))
11759 peer_status
= "Idle (PfxCt)";
11761 peer_status
= lookup_msg(bgp_status_msg
,
11762 peer
->status
, NULL
);
11764 dynamic
= peer_dynamic_neighbor(peer
);
11765 vty_out(vty
, " %s %s %s \n", peer
->host
,
11766 dynamic
? "(dynamic)" : "", peer_status
);
11770 return CMD_SUCCESS
;
11773 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11774 const char *group_name
)
11777 struct listnode
*node
, *nnode
;
11778 struct peer_group
*group
;
11779 bool found
= false;
11781 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11784 vty_out(vty
, "%% BGP instance not found\n");
11785 return CMD_WARNING
;
11788 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11790 if (strmatch(group
->name
, group_name
)) {
11791 bgp_show_one_peer_group(vty
, group
);
11796 bgp_show_one_peer_group(vty
, group
);
11800 if (group_name
&& !found
)
11801 vty_out(vty
, "%% No such peer-group\n");
11803 return CMD_SUCCESS
;
11806 DEFUN (show_ip_bgp_peer_groups
,
11807 show_ip_bgp_peer_groups_cmd
,
11808 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11812 BGP_INSTANCE_HELP_STR
11813 "Detailed information on BGP peer groups\n"
11814 "Peer group name\n")
11819 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11821 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11823 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11827 /* Redistribute VTY commands. */
11829 DEFUN (bgp_redistribute_ipv4
,
11830 bgp_redistribute_ipv4_cmd
,
11831 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11832 "Redistribute information from another routing protocol\n"
11833 FRR_IP_REDIST_HELP_STR_BGPD
)
11835 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11836 int idx_protocol
= 1;
11839 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11841 vty_out(vty
, "%% Invalid route type\n");
11842 return CMD_WARNING_CONFIG_FAILED
;
11845 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11846 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
11850 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11851 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11852 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11854 DEFUN (bgp_redistribute_ipv4_rmap
,
11855 bgp_redistribute_ipv4_rmap_cmd
,
11856 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11857 "Redistribute information from another routing protocol\n"
11858 FRR_IP_REDIST_HELP_STR_BGPD
11859 "Route map reference\n"
11860 "Pointer to route-map entries\n")
11862 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11863 int idx_protocol
= 1;
11866 struct bgp_redist
*red
;
11868 struct route_map
*route_map
= route_map_lookup_warn_noexist(
11869 vty
, argv
[idx_word
]->arg
);
11871 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11873 vty_out(vty
, "%% Invalid route type\n");
11874 return CMD_WARNING_CONFIG_FAILED
;
11877 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11879 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
11880 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11884 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
11885 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11886 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11887 "Route map reference\n"
11888 "Pointer to route-map entries\n")
11890 DEFUN (bgp_redistribute_ipv4_metric
,
11891 bgp_redistribute_ipv4_metric_cmd
,
11892 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11893 "Redistribute information from another routing protocol\n"
11894 FRR_IP_REDIST_HELP_STR_BGPD
11895 "Metric for redistributed routes\n"
11896 "Default metric\n")
11898 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11899 int idx_protocol
= 1;
11900 int idx_number
= 3;
11903 struct bgp_redist
*red
;
11906 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11908 vty_out(vty
, "%% Invalid route type\n");
11909 return CMD_WARNING_CONFIG_FAILED
;
11911 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11913 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11914 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11915 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11919 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
11920 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11921 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11922 "Metric for redistributed routes\n"
11923 "Default metric\n")
11925 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
11926 bgp_redistribute_ipv4_rmap_metric_cmd
,
11927 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11928 "Redistribute information from another routing protocol\n"
11929 FRR_IP_REDIST_HELP_STR_BGPD
11930 "Route map reference\n"
11931 "Pointer to route-map entries\n"
11932 "Metric for redistributed routes\n"
11933 "Default metric\n")
11935 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11936 int idx_protocol
= 1;
11938 int idx_number
= 5;
11941 struct bgp_redist
*red
;
11943 struct route_map
*route_map
=
11944 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
11946 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11948 vty_out(vty
, "%% Invalid route type\n");
11949 return CMD_WARNING_CONFIG_FAILED
;
11951 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11953 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11955 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
11956 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11957 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11961 bgp_redistribute_ipv4_rmap_metric
,
11962 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
11963 "redistribute " FRR_IP_REDIST_STR_BGPD
11964 " route-map WORD metric (0-4294967295)",
11965 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11966 "Route map reference\n"
11967 "Pointer to route-map entries\n"
11968 "Metric for redistributed routes\n"
11969 "Default metric\n")
11971 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
11972 bgp_redistribute_ipv4_metric_rmap_cmd
,
11973 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
11974 "Redistribute information from another routing protocol\n"
11975 FRR_IP_REDIST_HELP_STR_BGPD
11976 "Metric for redistributed routes\n"
11978 "Route map reference\n"
11979 "Pointer to route-map entries\n")
11981 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11982 int idx_protocol
= 1;
11983 int idx_number
= 3;
11987 struct bgp_redist
*red
;
11989 struct route_map
*route_map
=
11990 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
11992 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11994 vty_out(vty
, "%% Invalid route type\n");
11995 return CMD_WARNING_CONFIG_FAILED
;
11997 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11999 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12000 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12002 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12003 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12007 bgp_redistribute_ipv4_metric_rmap
,
12008 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
12009 "redistribute " FRR_IP_REDIST_STR_BGPD
12010 " metric (0-4294967295) route-map WORD",
12011 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12012 "Metric for redistributed routes\n"
12014 "Route map reference\n"
12015 "Pointer to route-map entries\n")
12017 DEFUN (bgp_redistribute_ipv4_ospf
,
12018 bgp_redistribute_ipv4_ospf_cmd
,
12019 "redistribute <ospf|table> (1-65535)",
12020 "Redistribute information from another routing protocol\n"
12021 "Open Shortest Path First (OSPFv2)\n"
12022 "Non-main Kernel Routing Table\n"
12023 "Instance ID/Table ID\n")
12025 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12026 int idx_ospf_table
= 1;
12027 int idx_number
= 2;
12028 unsigned short instance
;
12029 unsigned short protocol
;
12031 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12033 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12034 protocol
= ZEBRA_ROUTE_OSPF
;
12036 protocol
= ZEBRA_ROUTE_TABLE
;
12038 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12039 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
12042 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
12043 "redistribute <ospf|table> (1-65535)",
12044 "Redistribute information from another routing protocol\n"
12045 "Open Shortest Path First (OSPFv2)\n"
12046 "Non-main Kernel Routing Table\n"
12047 "Instance ID/Table ID\n")
12049 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
12050 bgp_redistribute_ipv4_ospf_rmap_cmd
,
12051 "redistribute <ospf|table> (1-65535) route-map WORD",
12052 "Redistribute information from another routing protocol\n"
12053 "Open Shortest Path First (OSPFv2)\n"
12054 "Non-main Kernel Routing Table\n"
12055 "Instance ID/Table ID\n"
12056 "Route map reference\n"
12057 "Pointer to route-map entries\n")
12059 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12060 int idx_ospf_table
= 1;
12061 int idx_number
= 2;
12063 struct bgp_redist
*red
;
12064 unsigned short instance
;
12067 struct route_map
*route_map
=
12068 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12070 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12071 protocol
= ZEBRA_ROUTE_OSPF
;
12073 protocol
= ZEBRA_ROUTE_TABLE
;
12075 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12076 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12078 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12079 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12082 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
12083 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
12084 "redistribute <ospf|table> (1-65535) route-map WORD",
12085 "Redistribute information from another routing protocol\n"
12086 "Open Shortest Path First (OSPFv2)\n"
12087 "Non-main Kernel Routing Table\n"
12088 "Instance ID/Table ID\n"
12089 "Route map reference\n"
12090 "Pointer to route-map entries\n")
12092 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
12093 bgp_redistribute_ipv4_ospf_metric_cmd
,
12094 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12095 "Redistribute information from another routing protocol\n"
12096 "Open Shortest Path First (OSPFv2)\n"
12097 "Non-main Kernel Routing Table\n"
12098 "Instance ID/Table ID\n"
12099 "Metric for redistributed routes\n"
12100 "Default metric\n")
12102 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12103 int idx_ospf_table
= 1;
12104 int idx_number
= 2;
12105 int idx_number_2
= 4;
12107 struct bgp_redist
*red
;
12108 unsigned short instance
;
12112 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12113 protocol
= ZEBRA_ROUTE_OSPF
;
12115 protocol
= ZEBRA_ROUTE_TABLE
;
12117 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12118 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12120 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12121 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12123 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12126 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
12127 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
12128 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12129 "Redistribute information from another routing protocol\n"
12130 "Open Shortest Path First (OSPFv2)\n"
12131 "Non-main Kernel Routing Table\n"
12132 "Instance ID/Table ID\n"
12133 "Metric for redistributed routes\n"
12134 "Default metric\n")
12136 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
12137 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
12138 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12139 "Redistribute information from another routing protocol\n"
12140 "Open Shortest Path First (OSPFv2)\n"
12141 "Non-main Kernel Routing Table\n"
12142 "Instance ID/Table ID\n"
12143 "Route map reference\n"
12144 "Pointer to route-map entries\n"
12145 "Metric for redistributed routes\n"
12146 "Default metric\n")
12148 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12149 int idx_ospf_table
= 1;
12150 int idx_number
= 2;
12152 int idx_number_2
= 6;
12154 struct bgp_redist
*red
;
12155 unsigned short instance
;
12158 struct route_map
*route_map
=
12159 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12161 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12162 protocol
= ZEBRA_ROUTE_OSPF
;
12164 protocol
= ZEBRA_ROUTE_TABLE
;
12166 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12167 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12169 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12171 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12172 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12174 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12178 bgp_redistribute_ipv4_ospf_rmap_metric
,
12179 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
12180 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12181 "Redistribute information from another routing protocol\n"
12182 "Open Shortest Path First (OSPFv2)\n"
12183 "Non-main Kernel Routing Table\n"
12184 "Instance ID/Table ID\n"
12185 "Route map reference\n"
12186 "Pointer to route-map entries\n"
12187 "Metric for redistributed routes\n"
12188 "Default metric\n")
12190 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
12191 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
12192 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12193 "Redistribute information from another routing protocol\n"
12194 "Open Shortest Path First (OSPFv2)\n"
12195 "Non-main Kernel Routing Table\n"
12196 "Instance ID/Table ID\n"
12197 "Metric for redistributed routes\n"
12199 "Route map reference\n"
12200 "Pointer to route-map entries\n")
12202 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12203 int idx_ospf_table
= 1;
12204 int idx_number
= 2;
12205 int idx_number_2
= 4;
12208 struct bgp_redist
*red
;
12209 unsigned short instance
;
12212 struct route_map
*route_map
=
12213 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12215 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12216 protocol
= ZEBRA_ROUTE_OSPF
;
12218 protocol
= ZEBRA_ROUTE_TABLE
;
12220 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12221 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12223 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12224 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12227 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12228 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12232 bgp_redistribute_ipv4_ospf_metric_rmap
,
12233 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
12234 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12235 "Redistribute information from another routing protocol\n"
12236 "Open Shortest Path First (OSPFv2)\n"
12237 "Non-main Kernel Routing Table\n"
12238 "Instance ID/Table ID\n"
12239 "Metric for redistributed routes\n"
12241 "Route map reference\n"
12242 "Pointer to route-map entries\n")
12244 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12245 no_bgp_redistribute_ipv4_ospf_cmd
,
12246 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12248 "Redistribute information from another routing protocol\n"
12249 "Open Shortest Path First (OSPFv2)\n"
12250 "Non-main Kernel Routing Table\n"
12251 "Instance ID/Table ID\n"
12252 "Metric for redistributed routes\n"
12254 "Route map reference\n"
12255 "Pointer to route-map entries\n")
12257 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12258 int idx_ospf_table
= 2;
12259 int idx_number
= 3;
12260 unsigned short instance
;
12263 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12264 protocol
= ZEBRA_ROUTE_OSPF
;
12266 protocol
= ZEBRA_ROUTE_TABLE
;
12268 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12269 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12273 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12274 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12276 "Redistribute information from another routing protocol\n"
12277 "Open Shortest Path First (OSPFv2)\n"
12278 "Non-main Kernel Routing Table\n"
12279 "Instance ID/Table ID\n"
12280 "Metric for redistributed routes\n"
12282 "Route map reference\n"
12283 "Pointer to route-map entries\n")
12285 DEFUN (no_bgp_redistribute_ipv4
,
12286 no_bgp_redistribute_ipv4_cmd
,
12287 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12289 "Redistribute information from another routing protocol\n"
12290 FRR_IP_REDIST_HELP_STR_BGPD
12291 "Metric for redistributed routes\n"
12293 "Route map reference\n"
12294 "Pointer to route-map entries\n")
12296 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12297 int idx_protocol
= 2;
12300 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12302 vty_out(vty
, "%% Invalid route type\n");
12303 return CMD_WARNING_CONFIG_FAILED
;
12305 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12309 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12310 "no redistribute " FRR_IP_REDIST_STR_BGPD
12311 " [metric (0-4294967295)] [route-map WORD]",
12313 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12314 "Metric for redistributed routes\n"
12316 "Route map reference\n"
12317 "Pointer to route-map entries\n")
12319 DEFUN (bgp_redistribute_ipv6
,
12320 bgp_redistribute_ipv6_cmd
,
12321 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12322 "Redistribute information from another routing protocol\n"
12323 FRR_IP6_REDIST_HELP_STR_BGPD
)
12325 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12326 int idx_protocol
= 1;
12329 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12331 vty_out(vty
, "%% Invalid route type\n");
12332 return CMD_WARNING_CONFIG_FAILED
;
12335 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12336 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12339 DEFUN (bgp_redistribute_ipv6_rmap
,
12340 bgp_redistribute_ipv6_rmap_cmd
,
12341 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12342 "Redistribute information from another routing protocol\n"
12343 FRR_IP6_REDIST_HELP_STR_BGPD
12344 "Route map reference\n"
12345 "Pointer to route-map entries\n")
12347 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12348 int idx_protocol
= 1;
12351 struct bgp_redist
*red
;
12353 struct route_map
*route_map
=
12354 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12356 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12358 vty_out(vty
, "%% Invalid route type\n");
12359 return CMD_WARNING_CONFIG_FAILED
;
12362 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12364 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12365 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12368 DEFUN (bgp_redistribute_ipv6_metric
,
12369 bgp_redistribute_ipv6_metric_cmd
,
12370 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12371 "Redistribute information from another routing protocol\n"
12372 FRR_IP6_REDIST_HELP_STR_BGPD
12373 "Metric for redistributed routes\n"
12374 "Default metric\n")
12376 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12377 int idx_protocol
= 1;
12378 int idx_number
= 3;
12381 struct bgp_redist
*red
;
12384 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12386 vty_out(vty
, "%% Invalid route type\n");
12387 return CMD_WARNING_CONFIG_FAILED
;
12389 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12391 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12392 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12393 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12396 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12397 bgp_redistribute_ipv6_rmap_metric_cmd
,
12398 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12399 "Redistribute information from another routing protocol\n"
12400 FRR_IP6_REDIST_HELP_STR_BGPD
12401 "Route map reference\n"
12402 "Pointer to route-map entries\n"
12403 "Metric for redistributed routes\n"
12404 "Default metric\n")
12406 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12407 int idx_protocol
= 1;
12409 int idx_number
= 5;
12412 struct bgp_redist
*red
;
12414 struct route_map
*route_map
=
12415 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12417 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12419 vty_out(vty
, "%% Invalid route type\n");
12420 return CMD_WARNING_CONFIG_FAILED
;
12422 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12424 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12426 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12427 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12429 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12432 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12433 bgp_redistribute_ipv6_metric_rmap_cmd
,
12434 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12435 "Redistribute information from another routing protocol\n"
12436 FRR_IP6_REDIST_HELP_STR_BGPD
12437 "Metric for redistributed routes\n"
12439 "Route map reference\n"
12440 "Pointer to route-map entries\n")
12442 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12443 int idx_protocol
= 1;
12444 int idx_number
= 3;
12448 struct bgp_redist
*red
;
12450 struct route_map
*route_map
=
12451 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12453 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12455 vty_out(vty
, "%% Invalid route type\n");
12456 return CMD_WARNING_CONFIG_FAILED
;
12458 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12460 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12461 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12464 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12465 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12468 DEFUN (no_bgp_redistribute_ipv6
,
12469 no_bgp_redistribute_ipv6_cmd
,
12470 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12472 "Redistribute information from another routing protocol\n"
12473 FRR_IP6_REDIST_HELP_STR_BGPD
12474 "Metric for redistributed routes\n"
12476 "Route map reference\n"
12477 "Pointer to route-map entries\n")
12479 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12480 int idx_protocol
= 2;
12483 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12485 vty_out(vty
, "%% Invalid route type\n");
12486 return CMD_WARNING_CONFIG_FAILED
;
12489 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12492 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12497 /* Unicast redistribution only. */
12498 if (safi
!= SAFI_UNICAST
)
12501 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12502 /* Redistribute BGP does not make sense. */
12503 if (i
!= ZEBRA_ROUTE_BGP
) {
12504 struct list
*red_list
;
12505 struct listnode
*node
;
12506 struct bgp_redist
*red
;
12508 red_list
= bgp
->redist
[afi
][i
];
12512 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12513 /* "redistribute" configuration. */
12514 vty_out(vty
, " redistribute %s",
12515 zebra_route_string(i
));
12517 vty_out(vty
, " %d", red
->instance
);
12518 if (red
->redist_metric_flag
)
12519 vty_out(vty
, " metric %u",
12520 red
->redist_metric
);
12521 if (red
->rmap
.name
)
12522 vty_out(vty
, " route-map %s",
12524 vty_out(vty
, "\n");
12530 /* This is part of the address-family block (unicast only) */
12531 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12536 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12537 if (listcount(bgp
->vpn_policy
[afi
].import_vrf
))
12538 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12539 bgp
->vpn_policy
[afi
]
12540 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12542 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
12543 bgp
->vpn_policy
[afi
]
12544 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12546 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12547 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12548 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12549 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12552 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12553 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12555 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12558 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12559 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12560 bgp
->vpn_policy
[afi
].tovpn_label
);
12563 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12564 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12565 char buf
[RD_ADDRSTRLEN
];
12566 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12567 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12570 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12571 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12573 char buf
[PREFIX_STRLEN
];
12574 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12575 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12578 vty_out(vty
, "%*snexthop vpn export %s\n",
12582 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12583 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12585 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12586 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12588 char *b
= ecommunity_ecom2str(
12589 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12590 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12591 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12592 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12594 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12595 char *b
= ecommunity_ecom2str(
12596 bgp
->vpn_policy
[afi
]
12597 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12598 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12599 ECOMMUNITY_ROUTE_TARGET
);
12600 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12601 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12603 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12604 char *b
= ecommunity_ecom2str(
12605 bgp
->vpn_policy
[afi
]
12606 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12607 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12608 ECOMMUNITY_ROUTE_TARGET
);
12609 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12610 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12614 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12615 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12616 bgp
->vpn_policy
[afi
]
12617 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12619 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12620 char *b
= ecommunity_ecom2str(
12621 bgp
->vpn_policy
[afi
]
12622 .import_redirect_rtlist
,
12623 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12624 ECOMMUNITY_ROUTE_TARGET
);
12626 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12627 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12632 /* BGP node structure. */
12633 static struct cmd_node bgp_node
= {
12634 BGP_NODE
, "%s(config-router)# ", 1,
12637 static struct cmd_node bgp_ipv4_unicast_node
= {
12638 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12641 static struct cmd_node bgp_ipv4_multicast_node
= {
12642 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12645 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12646 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12649 static struct cmd_node bgp_ipv6_unicast_node
= {
12650 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12653 static struct cmd_node bgp_ipv6_multicast_node
= {
12654 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12657 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12658 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12661 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12662 "%s(config-router-af)# ", 1};
12664 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12665 "%s(config-router-af-vpnv6)# ", 1};
12667 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12668 "%s(config-router-evpn)# ", 1};
12670 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12671 "%s(config-router-af-vni)# ", 1};
12673 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12674 "%s(config-router-af)# ", 1};
12676 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12677 "%s(config-router-af-vpnv6)# ", 1};
12679 static void community_list_vty(void);
12681 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12685 struct listnode
*lnbgp
, *lnpeer
;
12687 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12688 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12689 /* only provide suggestions on the appropriate input
12691 * they'll otherwise show up multiple times */
12692 enum cmd_token_type match_type
;
12693 char *name
= peer
->host
;
12695 if (peer
->conf_if
) {
12696 match_type
= VARIABLE_TKN
;
12697 name
= peer
->conf_if
;
12698 } else if (strchr(peer
->host
, ':'))
12699 match_type
= IPV6_TKN
;
12701 match_type
= IPV4_TKN
;
12703 if (token
->type
!= match_type
)
12706 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12711 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12712 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12713 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12714 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12715 {.completions
= NULL
}};
12717 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12720 struct peer_group
*group
;
12721 struct listnode
*lnbgp
, *lnpeer
;
12723 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12724 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12725 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12730 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12731 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12732 {.completions
= NULL
} };
12734 void bgp_vty_init(void)
12736 cmd_variable_handler_register(bgp_var_neighbor
);
12737 cmd_variable_handler_register(bgp_var_peergroup
);
12739 /* Install bgp top node. */
12740 install_node(&bgp_node
, bgp_config_write
);
12741 install_node(&bgp_ipv4_unicast_node
, NULL
);
12742 install_node(&bgp_ipv4_multicast_node
, NULL
);
12743 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12744 install_node(&bgp_ipv6_unicast_node
, NULL
);
12745 install_node(&bgp_ipv6_multicast_node
, NULL
);
12746 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12747 install_node(&bgp_vpnv4_node
, NULL
);
12748 install_node(&bgp_vpnv6_node
, NULL
);
12749 install_node(&bgp_evpn_node
, NULL
);
12750 install_node(&bgp_evpn_vni_node
, NULL
);
12751 install_node(&bgp_flowspecv4_node
, NULL
);
12752 install_node(&bgp_flowspecv6_node
, NULL
);
12754 /* Install default VTY commands to new nodes. */
12755 install_default(BGP_NODE
);
12756 install_default(BGP_IPV4_NODE
);
12757 install_default(BGP_IPV4M_NODE
);
12758 install_default(BGP_IPV4L_NODE
);
12759 install_default(BGP_IPV6_NODE
);
12760 install_default(BGP_IPV6M_NODE
);
12761 install_default(BGP_IPV6L_NODE
);
12762 install_default(BGP_VPNV4_NODE
);
12763 install_default(BGP_VPNV6_NODE
);
12764 install_default(BGP_FLOWSPECV4_NODE
);
12765 install_default(BGP_FLOWSPECV6_NODE
);
12766 install_default(BGP_EVPN_NODE
);
12767 install_default(BGP_EVPN_VNI_NODE
);
12769 /* "bgp multiple-instance" commands. */
12770 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
12771 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
12773 /* "bgp config-type" commands. */
12774 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
12775 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
12777 /* "bgp local-mac" hidden commands. */
12778 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
12779 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
12781 /* bgp route-map delay-timer commands. */
12782 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12783 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12785 /* Dummy commands (Currently not supported) */
12786 install_element(BGP_NODE
, &no_synchronization_cmd
);
12787 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12789 /* "router bgp" commands. */
12790 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12792 /* "no router bgp" commands. */
12793 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12795 /* "bgp router-id" commands. */
12796 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12797 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12799 /* "bgp cluster-id" commands. */
12800 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12801 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12803 /* "bgp confederation" commands. */
12804 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12805 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12807 /* "bgp confederation peers" commands. */
12808 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12809 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12811 /* bgp max-med command */
12812 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12813 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12814 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12815 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12816 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12818 /* bgp disable-ebgp-connected-nh-check */
12819 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12820 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12822 /* bgp update-delay command */
12823 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12824 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12825 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12827 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12828 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12829 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12830 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12832 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12833 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12835 /* "maximum-paths" commands. */
12836 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12837 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12838 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12839 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12840 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12841 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12842 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12843 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12844 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12845 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12846 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12847 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12848 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12849 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12850 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12852 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12853 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12854 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12855 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12856 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12858 /* "timers bgp" commands. */
12859 install_element(BGP_NODE
, &bgp_timers_cmd
);
12860 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12862 /* route-map delay-timer commands - per instance for backwards compat.
12864 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12865 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12867 /* "bgp client-to-client reflection" commands */
12868 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
12869 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
12871 /* "bgp always-compare-med" commands */
12872 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
12873 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
12875 /* bgp ebgp-requires-policy */
12876 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
12877 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
12879 /* "bgp deterministic-med" commands */
12880 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
12881 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
12883 /* "bgp graceful-restart" commands */
12884 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
12885 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
12886 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
12887 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
12888 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
12889 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
12891 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
12892 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
12894 /* "bgp graceful-shutdown" commands */
12895 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
12896 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
12898 /* "bgp fast-external-failover" commands */
12899 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
12900 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
12902 /* "bgp enforce-first-as" commands */
12903 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
12905 /* "bgp bestpath compare-routerid" commands */
12906 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
12907 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
12909 /* "bgp bestpath as-path ignore" commands */
12910 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
12911 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
12913 /* "bgp bestpath as-path confed" commands */
12914 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
12915 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
12917 /* "bgp bestpath as-path multipath-relax" commands */
12918 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
12919 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
12921 /* "bgp log-neighbor-changes" commands */
12922 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
12923 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
12925 /* "bgp bestpath med" commands */
12926 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
12927 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
12929 /* "no bgp default ipv4-unicast" commands. */
12930 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
12931 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
12933 /* "bgp network import-check" commands. */
12934 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
12935 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
12936 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
12938 /* "bgp default local-preference" commands. */
12939 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
12940 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
12942 /* bgp default show-hostname */
12943 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
12944 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
12946 /* "bgp default subgroup-pkt-queue-max" commands. */
12947 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
12948 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
12950 /* bgp ibgp-allow-policy-mods command */
12951 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
12952 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
12954 /* "bgp listen limit" commands. */
12955 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
12956 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
12958 /* "bgp listen range" commands. */
12959 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
12960 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
12962 /* "bgp default shutdown" command */
12963 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
12965 /* "neighbor remote-as" commands. */
12966 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
12967 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
12968 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
12969 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
12970 install_element(BGP_NODE
,
12971 &neighbor_interface_v6only_config_remote_as_cmd
);
12972 install_element(BGP_NODE
, &no_neighbor_cmd
);
12973 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
12975 /* "neighbor peer-group" commands. */
12976 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
12977 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
12978 install_element(BGP_NODE
,
12979 &no_neighbor_interface_peer_group_remote_as_cmd
);
12981 /* "neighbor local-as" commands. */
12982 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
12983 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
12984 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
12985 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
12987 /* "neighbor solo" commands. */
12988 install_element(BGP_NODE
, &neighbor_solo_cmd
);
12989 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
12991 /* "neighbor password" commands. */
12992 install_element(BGP_NODE
, &neighbor_password_cmd
);
12993 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
12995 /* "neighbor activate" commands. */
12996 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
12997 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
12998 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
12999 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
13000 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
13001 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
13002 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
13003 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
13004 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
13005 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
13006 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
13007 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
13009 /* "no neighbor activate" commands. */
13010 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
13011 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
13012 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
13013 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
13014 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
13015 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
13016 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
13017 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
13018 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
13019 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
13020 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
13021 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
13023 /* "neighbor peer-group" set commands. */
13024 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
13025 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13026 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13027 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13028 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13029 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13030 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13031 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13032 install_element(BGP_FLOWSPECV4_NODE
,
13033 &neighbor_set_peer_group_hidden_cmd
);
13034 install_element(BGP_FLOWSPECV6_NODE
,
13035 &neighbor_set_peer_group_hidden_cmd
);
13037 /* "no neighbor peer-group unset" commands. */
13038 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
13039 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13040 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13041 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13042 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13043 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13044 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13045 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13046 install_element(BGP_FLOWSPECV4_NODE
,
13047 &no_neighbor_set_peer_group_hidden_cmd
);
13048 install_element(BGP_FLOWSPECV6_NODE
,
13049 &no_neighbor_set_peer_group_hidden_cmd
);
13051 /* "neighbor softreconfiguration inbound" commands.*/
13052 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
13053 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
13054 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13055 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13056 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13057 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13058 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13059 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13060 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13061 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13062 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13063 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13064 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13065 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13066 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13067 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13068 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13069 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13070 install_element(BGP_FLOWSPECV4_NODE
,
13071 &neighbor_soft_reconfiguration_cmd
);
13072 install_element(BGP_FLOWSPECV4_NODE
,
13073 &no_neighbor_soft_reconfiguration_cmd
);
13074 install_element(BGP_FLOWSPECV6_NODE
,
13075 &neighbor_soft_reconfiguration_cmd
);
13076 install_element(BGP_FLOWSPECV6_NODE
,
13077 &no_neighbor_soft_reconfiguration_cmd
);
13078 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
13079 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13081 /* "neighbor attribute-unchanged" commands. */
13082 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
13083 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
13084 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
13085 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13086 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
13087 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13088 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
13089 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13090 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
13091 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13092 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
13093 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13094 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
13095 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13096 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
13097 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13098 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
13099 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13101 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
13102 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
13104 /* "nexthop-local unchanged" commands */
13105 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
13106 install_element(BGP_IPV6_NODE
,
13107 &no_neighbor_nexthop_local_unchanged_cmd
);
13109 /* "neighbor next-hop-self" commands. */
13110 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
13111 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
13112 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
13113 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13114 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
13115 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
13116 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
13117 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
13118 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
13119 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13120 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
13121 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
13122 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
13123 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
13124 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
13125 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13126 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
13127 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13128 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
13129 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
13131 /* "neighbor next-hop-self force" commands. */
13132 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
13133 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
13134 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13135 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13136 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
13137 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13138 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
13139 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13140 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13141 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13142 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
13143 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13144 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
13145 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13146 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13147 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13148 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13149 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13151 /* "neighbor as-override" commands. */
13152 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
13153 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
13154 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
13155 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
13156 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
13157 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
13158 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
13159 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
13160 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
13161 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
13162 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
13163 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
13164 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
13165 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
13166 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
13167 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
13168 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
13169 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
13171 /* "neighbor remove-private-AS" commands. */
13172 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
13173 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
13174 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
13175 install_element(BGP_NODE
,
13176 &no_neighbor_remove_private_as_all_hidden_cmd
);
13177 install_element(BGP_NODE
,
13178 &neighbor_remove_private_as_replace_as_hidden_cmd
);
13179 install_element(BGP_NODE
,
13180 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
13181 install_element(BGP_NODE
,
13182 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13185 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13186 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
13187 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13188 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13189 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13190 install_element(BGP_IPV4_NODE
,
13191 &neighbor_remove_private_as_replace_as_cmd
);
13192 install_element(BGP_IPV4_NODE
,
13193 &no_neighbor_remove_private_as_replace_as_cmd
);
13194 install_element(BGP_IPV4_NODE
,
13195 &neighbor_remove_private_as_all_replace_as_cmd
);
13196 install_element(BGP_IPV4_NODE
,
13197 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13198 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
13199 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
13200 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
13201 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13202 install_element(BGP_IPV4M_NODE
,
13203 &neighbor_remove_private_as_replace_as_cmd
);
13204 install_element(BGP_IPV4M_NODE
,
13205 &no_neighbor_remove_private_as_replace_as_cmd
);
13206 install_element(BGP_IPV4M_NODE
,
13207 &neighbor_remove_private_as_all_replace_as_cmd
);
13208 install_element(BGP_IPV4M_NODE
,
13209 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13210 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
13211 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
13212 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
13213 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13214 install_element(BGP_IPV4L_NODE
,
13215 &neighbor_remove_private_as_replace_as_cmd
);
13216 install_element(BGP_IPV4L_NODE
,
13217 &no_neighbor_remove_private_as_replace_as_cmd
);
13218 install_element(BGP_IPV4L_NODE
,
13219 &neighbor_remove_private_as_all_replace_as_cmd
);
13220 install_element(BGP_IPV4L_NODE
,
13221 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13222 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
13223 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13224 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13225 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13226 install_element(BGP_IPV6_NODE
,
13227 &neighbor_remove_private_as_replace_as_cmd
);
13228 install_element(BGP_IPV6_NODE
,
13229 &no_neighbor_remove_private_as_replace_as_cmd
);
13230 install_element(BGP_IPV6_NODE
,
13231 &neighbor_remove_private_as_all_replace_as_cmd
);
13232 install_element(BGP_IPV6_NODE
,
13233 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13234 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
13235 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
13236 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
13237 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13238 install_element(BGP_IPV6M_NODE
,
13239 &neighbor_remove_private_as_replace_as_cmd
);
13240 install_element(BGP_IPV6M_NODE
,
13241 &no_neighbor_remove_private_as_replace_as_cmd
);
13242 install_element(BGP_IPV6M_NODE
,
13243 &neighbor_remove_private_as_all_replace_as_cmd
);
13244 install_element(BGP_IPV6M_NODE
,
13245 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13246 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
13247 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
13248 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
13249 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13250 install_element(BGP_IPV6L_NODE
,
13251 &neighbor_remove_private_as_replace_as_cmd
);
13252 install_element(BGP_IPV6L_NODE
,
13253 &no_neighbor_remove_private_as_replace_as_cmd
);
13254 install_element(BGP_IPV6L_NODE
,
13255 &neighbor_remove_private_as_all_replace_as_cmd
);
13256 install_element(BGP_IPV6L_NODE
,
13257 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13258 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
13259 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13260 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13261 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13262 install_element(BGP_VPNV4_NODE
,
13263 &neighbor_remove_private_as_replace_as_cmd
);
13264 install_element(BGP_VPNV4_NODE
,
13265 &no_neighbor_remove_private_as_replace_as_cmd
);
13266 install_element(BGP_VPNV4_NODE
,
13267 &neighbor_remove_private_as_all_replace_as_cmd
);
13268 install_element(BGP_VPNV4_NODE
,
13269 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13270 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
13271 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13272 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13273 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13274 install_element(BGP_VPNV6_NODE
,
13275 &neighbor_remove_private_as_replace_as_cmd
);
13276 install_element(BGP_VPNV6_NODE
,
13277 &no_neighbor_remove_private_as_replace_as_cmd
);
13278 install_element(BGP_VPNV6_NODE
,
13279 &neighbor_remove_private_as_all_replace_as_cmd
);
13280 install_element(BGP_VPNV6_NODE
,
13281 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13283 /* "neighbor send-community" commands.*/
13284 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
13285 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
13286 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
13287 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
13288 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
13289 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
13290 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
13291 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
13292 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
13293 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
13294 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
13295 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
13296 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
13297 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
13298 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
13299 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
13300 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
13301 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
13302 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
13303 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
13304 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
13305 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
13306 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
13307 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
13308 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
13309 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
13310 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
13311 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
13312 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
13313 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
13314 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
13315 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
13316 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
13317 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
13318 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
13319 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
13321 /* "neighbor route-reflector" commands.*/
13322 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
13323 install_element(BGP_NODE
,
13324 &no_neighbor_route_reflector_client_hidden_cmd
);
13325 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
13326 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
13327 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
13328 install_element(BGP_IPV4M_NODE
,
13329 &no_neighbor_route_reflector_client_cmd
);
13330 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
13331 install_element(BGP_IPV4L_NODE
,
13332 &no_neighbor_route_reflector_client_cmd
);
13333 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
13334 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
13335 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
13336 install_element(BGP_IPV6M_NODE
,
13337 &no_neighbor_route_reflector_client_cmd
);
13338 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
13339 install_element(BGP_IPV6L_NODE
,
13340 &no_neighbor_route_reflector_client_cmd
);
13341 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
13342 install_element(BGP_VPNV4_NODE
,
13343 &no_neighbor_route_reflector_client_cmd
);
13344 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
13345 install_element(BGP_VPNV6_NODE
,
13346 &no_neighbor_route_reflector_client_cmd
);
13347 install_element(BGP_FLOWSPECV4_NODE
,
13348 &neighbor_route_reflector_client_cmd
);
13349 install_element(BGP_FLOWSPECV4_NODE
,
13350 &no_neighbor_route_reflector_client_cmd
);
13351 install_element(BGP_FLOWSPECV6_NODE
,
13352 &neighbor_route_reflector_client_cmd
);
13353 install_element(BGP_FLOWSPECV6_NODE
,
13354 &no_neighbor_route_reflector_client_cmd
);
13355 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
13356 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
13358 /* "neighbor route-server" commands.*/
13359 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
13360 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
13361 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
13362 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
13363 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
13364 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
13365 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
13366 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
13367 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
13368 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
13369 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
13370 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
13371 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
13372 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
13373 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
13374 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
13375 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
13376 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
13377 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
13378 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
13379 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
13380 install_element(BGP_FLOWSPECV4_NODE
,
13381 &no_neighbor_route_server_client_cmd
);
13382 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
13383 install_element(BGP_FLOWSPECV6_NODE
,
13384 &no_neighbor_route_server_client_cmd
);
13386 /* "neighbor addpath-tx-all-paths" commands.*/
13387 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
13388 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
13389 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13390 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13391 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13392 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13393 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13394 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13395 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13396 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13397 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13398 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13399 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13400 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13401 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13402 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13403 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13404 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13406 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
13407 install_element(BGP_NODE
,
13408 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13409 install_element(BGP_NODE
,
13410 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13411 install_element(BGP_IPV4_NODE
,
13412 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13413 install_element(BGP_IPV4_NODE
,
13414 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13415 install_element(BGP_IPV4M_NODE
,
13416 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13417 install_element(BGP_IPV4M_NODE
,
13418 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13419 install_element(BGP_IPV4L_NODE
,
13420 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13421 install_element(BGP_IPV4L_NODE
,
13422 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13423 install_element(BGP_IPV6_NODE
,
13424 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13425 install_element(BGP_IPV6_NODE
,
13426 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13427 install_element(BGP_IPV6M_NODE
,
13428 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13429 install_element(BGP_IPV6M_NODE
,
13430 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13431 install_element(BGP_IPV6L_NODE
,
13432 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13433 install_element(BGP_IPV6L_NODE
,
13434 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13435 install_element(BGP_VPNV4_NODE
,
13436 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13437 install_element(BGP_VPNV4_NODE
,
13438 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13439 install_element(BGP_VPNV6_NODE
,
13440 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13441 install_element(BGP_VPNV6_NODE
,
13442 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13444 /* "neighbor passive" commands. */
13445 install_element(BGP_NODE
, &neighbor_passive_cmd
);
13446 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13449 /* "neighbor shutdown" commands. */
13450 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13451 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13452 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13453 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13455 /* "neighbor capability extended-nexthop" commands.*/
13456 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13457 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13459 /* "neighbor capability orf prefix-list" commands.*/
13460 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13461 install_element(BGP_NODE
,
13462 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13463 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13464 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13465 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13466 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13467 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13468 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13469 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13470 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13471 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13472 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13473 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13474 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13476 /* "neighbor capability dynamic" commands.*/
13477 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13478 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13480 /* "neighbor dont-capability-negotiate" commands. */
13481 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13482 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13484 /* "neighbor ebgp-multihop" commands. */
13485 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13486 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13487 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13489 /* "neighbor disable-connected-check" commands. */
13490 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13491 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13493 /* "neighbor enforce-first-as" commands. */
13494 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13495 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13497 /* "neighbor description" commands. */
13498 install_element(BGP_NODE
, &neighbor_description_cmd
);
13499 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13500 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13502 /* "neighbor update-source" commands. "*/
13503 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13504 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13506 /* "neighbor default-originate" commands. */
13507 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13508 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13509 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13510 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13511 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13512 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13513 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13514 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13515 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13516 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13517 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13518 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13519 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13520 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13521 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13522 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13523 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13524 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13525 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13526 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13527 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13529 /* "neighbor port" commands. */
13530 install_element(BGP_NODE
, &neighbor_port_cmd
);
13531 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13533 /* "neighbor weight" commands. */
13534 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13535 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13537 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13538 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13539 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13540 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13541 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13542 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13543 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13544 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13545 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13546 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13547 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13548 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13549 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13550 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13551 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13552 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13554 /* "neighbor override-capability" commands. */
13555 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13556 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13558 /* "neighbor strict-capability-match" commands. */
13559 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13560 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13562 /* "neighbor timers" commands. */
13563 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13564 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13566 /* "neighbor timers connect" commands. */
13567 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13568 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13570 /* "neighbor advertisement-interval" commands. */
13571 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13572 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13574 /* "neighbor interface" commands. */
13575 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13576 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13578 /* "neighbor distribute" commands. */
13579 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13580 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13581 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13582 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13583 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13584 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13585 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13586 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13587 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13588 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13589 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13590 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13591 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13592 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13593 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13594 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13595 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13596 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13598 /* "neighbor prefix-list" commands. */
13599 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13600 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13601 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13602 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13603 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13604 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13605 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13606 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13607 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13608 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13609 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13610 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13611 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13612 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13613 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13614 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13615 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13616 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13617 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13618 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13619 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13620 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13622 /* "neighbor filter-list" commands. */
13623 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13624 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13625 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13626 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13627 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13628 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13629 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13630 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13631 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13632 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13633 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13634 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13635 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13636 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13637 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13638 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13639 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13640 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13641 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13642 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13643 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13644 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13646 /* "neighbor route-map" commands. */
13647 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13648 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13649 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13650 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13651 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13652 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13653 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13654 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13655 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13656 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13657 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13658 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13659 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13660 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13661 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13662 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13663 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13664 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13665 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13666 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13667 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13668 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13669 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13670 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13672 /* "neighbor unsuppress-map" commands. */
13673 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13674 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13675 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13676 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13677 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13678 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13679 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13680 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13681 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13682 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13683 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13684 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13685 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13686 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13687 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13688 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13689 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13690 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13692 /* "neighbor maximum-prefix" commands. */
13693 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13694 install_element(BGP_NODE
,
13695 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13696 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13697 install_element(BGP_NODE
,
13698 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13699 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13700 install_element(BGP_NODE
,
13701 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13702 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13703 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13704 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13705 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13706 install_element(BGP_IPV4_NODE
,
13707 &neighbor_maximum_prefix_threshold_warning_cmd
);
13708 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13709 install_element(BGP_IPV4_NODE
,
13710 &neighbor_maximum_prefix_threshold_restart_cmd
);
13711 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13712 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13713 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13714 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13715 install_element(BGP_IPV4M_NODE
,
13716 &neighbor_maximum_prefix_threshold_warning_cmd
);
13717 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13718 install_element(BGP_IPV4M_NODE
,
13719 &neighbor_maximum_prefix_threshold_restart_cmd
);
13720 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13721 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13722 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13723 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13724 install_element(BGP_IPV4L_NODE
,
13725 &neighbor_maximum_prefix_threshold_warning_cmd
);
13726 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13727 install_element(BGP_IPV4L_NODE
,
13728 &neighbor_maximum_prefix_threshold_restart_cmd
);
13729 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13730 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13731 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13732 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13733 install_element(BGP_IPV6_NODE
,
13734 &neighbor_maximum_prefix_threshold_warning_cmd
);
13735 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13736 install_element(BGP_IPV6_NODE
,
13737 &neighbor_maximum_prefix_threshold_restart_cmd
);
13738 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13739 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13740 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13741 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13742 install_element(BGP_IPV6M_NODE
,
13743 &neighbor_maximum_prefix_threshold_warning_cmd
);
13744 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13745 install_element(BGP_IPV6M_NODE
,
13746 &neighbor_maximum_prefix_threshold_restart_cmd
);
13747 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13748 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13749 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13750 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13751 install_element(BGP_IPV6L_NODE
,
13752 &neighbor_maximum_prefix_threshold_warning_cmd
);
13753 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13754 install_element(BGP_IPV6L_NODE
,
13755 &neighbor_maximum_prefix_threshold_restart_cmd
);
13756 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13757 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13758 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13759 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13760 install_element(BGP_VPNV4_NODE
,
13761 &neighbor_maximum_prefix_threshold_warning_cmd
);
13762 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13763 install_element(BGP_VPNV4_NODE
,
13764 &neighbor_maximum_prefix_threshold_restart_cmd
);
13765 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13766 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13767 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13768 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13769 install_element(BGP_VPNV6_NODE
,
13770 &neighbor_maximum_prefix_threshold_warning_cmd
);
13771 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13772 install_element(BGP_VPNV6_NODE
,
13773 &neighbor_maximum_prefix_threshold_restart_cmd
);
13774 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13776 /* "neighbor allowas-in" */
13777 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13778 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13779 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13780 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13781 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13782 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13783 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13784 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13785 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13786 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13787 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13788 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13789 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13790 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13791 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13792 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13793 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13794 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13795 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13796 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13798 /* address-family commands. */
13799 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13800 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13801 #ifdef KEEP_OLD_VPN_COMMANDS
13802 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13803 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13804 #endif /* KEEP_OLD_VPN_COMMANDS */
13806 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13808 /* "exit-address-family" command. */
13809 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13810 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13811 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13812 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13813 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13814 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13815 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13816 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13817 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13818 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13819 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13821 /* "clear ip bgp commands" */
13822 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13824 /* clear ip bgp prefix */
13825 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13826 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13827 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13829 /* "show [ip] bgp summary" commands. */
13830 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13831 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
13832 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13833 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13834 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13835 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13836 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
13838 /* "show [ip] bgp neighbors" commands. */
13839 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
13841 /* "show [ip] bgp peer-group" commands. */
13842 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
13844 /* "show [ip] bgp paths" commands. */
13845 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
13847 /* "show [ip] bgp community" commands. */
13848 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
13850 /* "show ip bgp large-community" commands. */
13851 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
13852 /* "show [ip] bgp attribute-info" commands. */
13853 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
13854 /* "show [ip] bgp route-leak" command */
13855 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
13857 /* "redistribute" commands. */
13858 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
13859 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
13860 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
13861 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
13862 install_element(BGP_NODE
,
13863 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
13864 install_element(BGP_NODE
,
13865 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
13866 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
13867 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
13868 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
13869 install_element(BGP_NODE
,
13870 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
13871 install_element(BGP_NODE
,
13872 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
13873 install_element(BGP_NODE
,
13874 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
13875 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
13876 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
13877 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
13878 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
13879 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
13880 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
13881 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
13882 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
13883 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
13884 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
13885 install_element(BGP_IPV4_NODE
,
13886 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
13887 install_element(BGP_IPV4_NODE
,
13888 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
13889 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
13890 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
13891 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
13892 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
13893 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
13894 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
13896 /* import|export vpn [route-map WORD] */
13897 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
13898 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
13900 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
13901 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
13903 /* ttl_security commands */
13904 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
13905 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
13907 /* "show [ip] bgp memory" commands. */
13908 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
13910 /* "show bgp martian next-hop" */
13911 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
13913 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
13915 /* "show [ip] bgp views" commands. */
13916 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
13918 /* "show [ip] bgp vrfs" commands. */
13919 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
13921 /* Community-list. */
13922 community_list_vty();
13924 /* vpn-policy commands */
13925 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
13926 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
13927 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
13928 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
13929 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
13930 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
13931 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
13932 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
13933 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
13934 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
13935 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
13936 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
13938 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
13939 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
13941 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
13942 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
13943 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
13944 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
13945 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
13946 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
13947 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
13948 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
13949 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13950 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13951 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
13952 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
13955 #include "memory.h"
13956 #include "bgp_regex.h"
13957 #include "bgp_clist.h"
13958 #include "bgp_ecommunity.h"
13960 /* VTY functions. */
13962 /* Direction value to string conversion. */
13963 static const char *community_direct_str(int direct
)
13966 case COMMUNITY_DENY
:
13968 case COMMUNITY_PERMIT
:
13975 /* Display error string. */
13976 static void community_list_perror(struct vty
*vty
, int ret
)
13979 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
13980 vty_out(vty
, "%% Can't find community-list\n");
13982 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
13983 vty_out(vty
, "%% Malformed community-list value\n");
13985 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
13987 "%% Community name conflict, previously defined as standard community\n");
13989 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
13991 "%% Community name conflict, previously defined as expanded community\n");
13996 /* "community-list" keyword help string. */
13997 #define COMMUNITY_LIST_STR "Add a community list entry\n"
13999 /*community-list standard */
14000 DEFUN (community_list_standard
,
14001 bgp_community_list_standard_cmd
,
14002 "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14005 "Community list number (standard)\n"
14006 "Add an standard community-list entry\n"
14007 "Community list name\n"
14008 "Specify community to reject\n"
14009 "Specify community to accept\n"
14012 char *cl_name_or_number
= NULL
;
14014 int style
= COMMUNITY_LIST_STANDARD
;
14018 if (argv_find(argv
, argc
, "ip", &idx
)) {
14019 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14020 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14021 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14022 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14025 argv_find(argv
, argc
, "(1-99)", &idx
);
14026 argv_find(argv
, argc
, "WORD", &idx
);
14027 cl_name_or_number
= argv
[idx
]->arg
;
14028 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14030 argv_find(argv
, argc
, "AA:NN", &idx
);
14031 char *str
= argv_concat(argv
, argc
, idx
);
14033 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14036 XFREE(MTYPE_TMP
, str
);
14039 /* Display error string. */
14040 community_list_perror(vty
, ret
);
14041 return CMD_WARNING_CONFIG_FAILED
;
14044 return CMD_SUCCESS
;
14047 #if CONFDATE > 20191005
14048 CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command")
14050 ALIAS (community_list_standard
,
14051 ip_community_list_standard_cmd
,
14052 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14055 "Community list number (standard)\n"
14056 "Add an standard community-list entry\n"
14057 "Community list name\n"
14058 "Specify community to reject\n"
14059 "Specify community to accept\n"
14062 DEFUN (no_community_list_standard_all
,
14063 no_bgp_community_list_standard_all_cmd
,
14064 "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14068 "Community list number (standard)\n"
14069 "Add an standard community-list entry\n"
14070 "Community list name\n"
14071 "Specify community to reject\n"
14072 "Specify community to accept\n"
14075 char *cl_name_or_number
= NULL
;
14078 int style
= COMMUNITY_LIST_STANDARD
;
14082 if (argv_find(argv
, argc
, "ip", &idx
)) {
14083 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
14084 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14085 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14086 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used");
14089 argv_find(argv
, argc
, "permit", &idx
);
14090 argv_find(argv
, argc
, "deny", &idx
);
14093 direct
= argv_find(argv
, argc
, "permit", &idx
)
14098 argv_find(argv
, argc
, "AA:NN", &idx
);
14099 str
= argv_concat(argv
, argc
, idx
);
14103 argv_find(argv
, argc
, "(1-99)", &idx
);
14104 argv_find(argv
, argc
, "WORD", &idx
);
14105 cl_name_or_number
= argv
[idx
]->arg
;
14107 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14110 XFREE(MTYPE_TMP
, str
);
14113 community_list_perror(vty
, ret
);
14114 return CMD_WARNING_CONFIG_FAILED
;
14117 return CMD_SUCCESS
;
14119 ALIAS (no_community_list_standard_all
,
14120 no_ip_community_list_standard_all_cmd
,
14121 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14125 "Community list number (standard)\n"
14126 "Add an standard community-list entry\n"
14127 "Community list name\n"
14128 "Specify community to reject\n"
14129 "Specify community to accept\n"
14132 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
14133 "no bgp community-list <(1-99)|standard WORD>",
14134 NO_STR BGP_STR COMMUNITY_LIST_STR
14135 "Community list number (standard)\n"
14136 "Add an standard community-list entry\n"
14137 "Community list name\n")
14139 ALIAS(no_community_list_standard_all
, no_ip_community_list_standard_all_list_cmd
,
14140 "no ip community-list <(1-99)|standard WORD>",
14141 NO_STR BGP_STR COMMUNITY_LIST_STR
14142 "Community list number (standard)\n"
14143 "Add an standard community-list entry\n"
14144 "Community list name\n")
14146 /*community-list expanded */
14147 DEFUN (community_list_expanded_all
,
14148 bgp_community_list_expanded_all_cmd
,
14149 "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14152 "Community list number (expanded)\n"
14153 "Add an expanded community-list entry\n"
14154 "Community list name\n"
14155 "Specify community to reject\n"
14156 "Specify community to accept\n"
14159 char *cl_name_or_number
= NULL
;
14161 int style
= COMMUNITY_LIST_EXPANDED
;
14164 if (argv_find(argv
, argc
, "ip", &idx
)) {
14165 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14166 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14167 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14168 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14170 argv_find(argv
, argc
, "(100-500)", &idx
);
14171 argv_find(argv
, argc
, "WORD", &idx
);
14172 cl_name_or_number
= argv
[idx
]->arg
;
14173 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14175 argv_find(argv
, argc
, "AA:NN", &idx
);
14176 char *str
= argv_concat(argv
, argc
, idx
);
14178 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14181 XFREE(MTYPE_TMP
, str
);
14184 /* Display error string. */
14185 community_list_perror(vty
, ret
);
14186 return CMD_WARNING_CONFIG_FAILED
;
14189 return CMD_SUCCESS
;
14192 ALIAS (community_list_expanded_all
,
14193 ip_community_list_expanded_all_cmd
,
14194 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14197 "Community list number (expanded)\n"
14198 "Add an expanded community-list entry\n"
14199 "Community list name\n"
14200 "Specify community to reject\n"
14201 "Specify community to accept\n"
14204 DEFUN (no_community_list_expanded_all
,
14205 no_bgp_community_list_expanded_all_cmd
,
14206 "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14210 "Community list number (expanded)\n"
14211 "Add an expanded community-list entry\n"
14212 "Community list name\n"
14213 "Specify community to reject\n"
14214 "Specify community to accept\n"
14217 char *cl_name_or_number
= NULL
;
14220 int style
= COMMUNITY_LIST_EXPANDED
;
14223 if (argv_find(argv
, argc
, "ip", &idx
)) {
14224 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14225 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14226 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14227 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14231 argv_find(argv
, argc
, "permit", &idx
);
14232 argv_find(argv
, argc
, "deny", &idx
);
14235 direct
= argv_find(argv
, argc
, "permit", &idx
)
14240 argv_find(argv
, argc
, "AA:NN", &idx
);
14241 str
= argv_concat(argv
, argc
, idx
);
14245 argv_find(argv
, argc
, "(100-500)", &idx
);
14246 argv_find(argv
, argc
, "WORD", &idx
);
14247 cl_name_or_number
= argv
[idx
]->arg
;
14249 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14252 XFREE(MTYPE_TMP
, str
);
14255 community_list_perror(vty
, ret
);
14256 return CMD_WARNING_CONFIG_FAILED
;
14259 return CMD_SUCCESS
;
14262 ALIAS (no_community_list_expanded_all
,
14263 no_ip_community_list_expanded_all_cmd
,
14264 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14268 "Community list number (expanded)\n"
14269 "Add an expanded community-list entry\n"
14270 "Community list name\n"
14271 "Specify community to reject\n"
14272 "Specify community to accept\n"
14275 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
14276 "no bgp community-list <(100-500)|expanded WORD>",
14277 NO_STR IP_STR COMMUNITY_LIST_STR
14278 "Community list number (expanded)\n"
14279 "Add an expanded community-list entry\n"
14280 "Community list name\n")
14282 ALIAS(no_community_list_expanded_all
, no_ip_community_list_expanded_all_list_cmd
,
14283 "no ip community-list <(100-500)|expanded WORD>",
14284 NO_STR IP_STR COMMUNITY_LIST_STR
14285 "Community list number (expanded)\n"
14286 "Add an expanded community-list entry\n"
14287 "Community list name\n")
14289 /* Return configuration string of community-list entry. */
14290 static const char *community_list_config_str(struct community_entry
*entry
)
14297 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
14298 str
= community_str(entry
->u
.com
, false);
14299 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
14300 str
= lcommunity_str(entry
->u
.lcom
, false);
14302 str
= entry
->config
;
14307 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
14309 struct community_entry
*entry
;
14311 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14312 if (entry
== list
->head
) {
14313 if (all_digit(list
->name
))
14314 vty_out(vty
, "Community %s list %s\n",
14315 entry
->style
== COMMUNITY_LIST_STANDARD
14317 : "(expanded) access",
14320 vty_out(vty
, "Named Community %s list %s\n",
14321 entry
->style
== COMMUNITY_LIST_STANDARD
14327 vty_out(vty
, " %s\n",
14328 community_direct_str(entry
->direct
));
14330 vty_out(vty
, " %s %s\n",
14331 community_direct_str(entry
->direct
),
14332 community_list_config_str(entry
));
14336 DEFUN (show_community_list
,
14337 show_bgp_community_list_cmd
,
14338 "show bgp community-list",
14341 "List community-list\n")
14343 struct community_list
*list
;
14344 struct community_list_master
*cm
;
14347 if (argv_find(argv
, argc
, "ip", &idx
)) {
14348 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14349 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14350 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14351 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14353 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14355 return CMD_SUCCESS
;
14357 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14358 community_list_show(vty
, list
);
14360 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14361 community_list_show(vty
, list
);
14363 return CMD_SUCCESS
;
14366 ALIAS (show_community_list
,
14367 show_ip_community_list_cmd
,
14368 "show ip community-list",
14371 "List community-list\n")
14373 DEFUN (show_community_list_arg
,
14374 show_bgp_community_list_arg_cmd
,
14375 "show bgp community-list <(1-500)|WORD>",
14378 "List community-list\n"
14379 "Community-list number\n"
14380 "Community-list name\n")
14382 int idx_comm_list
= 3;
14383 struct community_list
*list
;
14386 if (argv_find(argv
, argc
, "ip", &idx
)) {
14387 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14388 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14389 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14390 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14392 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
14393 COMMUNITY_LIST_MASTER
);
14395 vty_out(vty
, "%% Can't find community-list\n");
14396 return CMD_WARNING
;
14399 community_list_show(vty
, list
);
14401 return CMD_SUCCESS
;
14404 ALIAS (show_community_list_arg
,
14405 show_ip_community_list_arg_cmd
,
14406 "show ip community-list <(1-500)|WORD>",
14409 "List community-list\n"
14410 "Community-list number\n"
14411 "Community-list name\n")
14414 * Large Community code.
14416 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
14417 struct cmd_token
**argv
, int style
,
14418 int reject_all_digit_name
)
14426 if (argv_find(argv
, argc
, "ip", &idx
)) {
14427 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14428 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14429 vty_out(vty
, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14430 zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14432 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14435 /* All digit name check. */
14437 argv_find(argv
, argc
, "WORD", &idx
);
14438 argv_find(argv
, argc
, "(1-99)", &idx
);
14439 argv_find(argv
, argc
, "(100-500)", &idx
);
14440 cl_name
= argv
[idx
]->arg
;
14441 if (reject_all_digit_name
&& all_digit(cl_name
)) {
14442 vty_out(vty
, "%% Community name cannot have all digits\n");
14443 return CMD_WARNING_CONFIG_FAILED
;
14447 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
14448 argv_find(argv
, argc
, "LINE", &idx
);
14449 /* Concat community string argument. */
14451 str
= argv_concat(argv
, argc
, idx
);
14455 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
14457 /* Free temporary community list string allocated by
14459 XFREE(MTYPE_TMP
, str
);
14462 community_list_perror(vty
, ret
);
14463 return CMD_WARNING_CONFIG_FAILED
;
14465 return CMD_SUCCESS
;
14468 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
14469 struct cmd_token
**argv
, int style
)
14476 if (argv_find(argv
, argc
, "ip", &idx
)) {
14477 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14478 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14479 vty_out(vty
, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14480 zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14482 argv_find(argv
, argc
, "permit", &idx
);
14483 argv_find(argv
, argc
, "deny", &idx
);
14486 /* Check the list direct. */
14487 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
14488 direct
= COMMUNITY_PERMIT
;
14490 direct
= COMMUNITY_DENY
;
14493 argv_find(argv
, argc
, "LINE", &idx
);
14494 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
14495 /* Concat community string argument. */
14496 str
= argv_concat(argv
, argc
, idx
);
14500 argv_find(argv
, argc
, "(1-99)", &idx
);
14501 argv_find(argv
, argc
, "(100-500)", &idx
);
14502 argv_find(argv
, argc
, "WORD", &idx
);
14504 /* Unset community list. */
14505 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
14508 /* Free temporary community list string allocated by
14510 XFREE(MTYPE_TMP
, str
);
14513 community_list_perror(vty
, ret
);
14514 return CMD_WARNING_CONFIG_FAILED
;
14517 return CMD_SUCCESS
;
14520 /* "large-community-list" keyword help string. */
14521 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
14522 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
14524 #if CONFDATE > 20191005
14525 CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command")
14527 DEFUN (lcommunity_list_standard
,
14528 bgp_lcommunity_list_standard_cmd
,
14529 "bgp large-community-list (1-99) <deny|permit>",
14531 LCOMMUNITY_LIST_STR
14532 "Large Community list number (standard)\n"
14533 "Specify large community to reject\n"
14534 "Specify large community to accept\n")
14536 return lcommunity_list_set_vty(vty
, argc
, argv
,
14537 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14540 ALIAS (lcommunity_list_standard
,
14541 ip_lcommunity_list_standard_cmd
,
14542 "ip large-community-list (1-99) <deny|permit>",
14544 LCOMMUNITY_LIST_STR
14545 "Large Community list number (standard)\n"
14546 "Specify large community to reject\n"
14547 "Specify large community to accept\n")
14549 DEFUN (lcommunity_list_standard1
,
14550 bgp_lcommunity_list_standard1_cmd
,
14551 "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...",
14553 LCOMMUNITY_LIST_STR
14554 "Large Community list number (standard)\n"
14555 "Specify large community to reject\n"
14556 "Specify large community to accept\n"
14557 LCOMMUNITY_VAL_STR
)
14559 return lcommunity_list_set_vty(vty
, argc
, argv
,
14560 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14563 ALIAS (lcommunity_list_standard1
,
14564 ip_lcommunity_list_standard1_cmd
,
14565 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
14567 LCOMMUNITY_LIST_STR
14568 "Large Community list number (standard)\n"
14569 "Specify large community to reject\n"
14570 "Specify large community to accept\n"
14571 LCOMMUNITY_VAL_STR
)
14573 DEFUN (lcommunity_list_expanded
,
14574 bgp_lcommunity_list_expanded_cmd
,
14575 "bgp large-community-list (100-500) <deny|permit> LINE...",
14577 LCOMMUNITY_LIST_STR
14578 "Large Community list number (expanded)\n"
14579 "Specify large community to reject\n"
14580 "Specify large community to accept\n"
14581 "An ordered list as a regular-expression\n")
14583 return lcommunity_list_set_vty(vty
, argc
, argv
,
14584 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
14587 ALIAS (lcommunity_list_expanded
,
14588 ip_lcommunity_list_expanded_cmd
,
14589 "ip large-community-list (100-500) <deny|permit> LINE...",
14591 LCOMMUNITY_LIST_STR
14592 "Large Community list number (expanded)\n"
14593 "Specify large community to reject\n"
14594 "Specify large community to accept\n"
14595 "An ordered list as a regular-expression\n")
14597 DEFUN (lcommunity_list_name_standard
,
14598 bgp_lcommunity_list_name_standard_cmd
,
14599 "bgp large-community-list standard WORD <deny|permit>",
14601 LCOMMUNITY_LIST_STR
14602 "Specify standard large-community-list\n"
14603 "Large Community list name\n"
14604 "Specify large community to reject\n"
14605 "Specify large community to accept\n")
14607 return lcommunity_list_set_vty(vty
, argc
, argv
,
14608 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14611 ALIAS (lcommunity_list_name_standard
,
14612 ip_lcommunity_list_name_standard_cmd
,
14613 "ip large-community-list standard WORD <deny|permit>",
14615 LCOMMUNITY_LIST_STR
14616 "Specify standard large-community-list\n"
14617 "Large Community list name\n"
14618 "Specify large community to reject\n"
14619 "Specify large community to accept\n")
14621 DEFUN (lcommunity_list_name_standard1
,
14622 bgp_lcommunity_list_name_standard1_cmd
,
14623 "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
14625 LCOMMUNITY_LIST_STR
14626 "Specify standard large-community-list\n"
14627 "Large Community list name\n"
14628 "Specify large community to reject\n"
14629 "Specify large community to accept\n"
14630 LCOMMUNITY_VAL_STR
)
14632 return lcommunity_list_set_vty(vty
, argc
, argv
,
14633 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14636 ALIAS (lcommunity_list_name_standard1
,
14637 ip_lcommunity_list_name_standard1_cmd
,
14638 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
14640 LCOMMUNITY_LIST_STR
14641 "Specify standard large-community-list\n"
14642 "Large Community list name\n"
14643 "Specify large community to reject\n"
14644 "Specify large community to accept\n"
14645 LCOMMUNITY_VAL_STR
)
14647 DEFUN (lcommunity_list_name_expanded
,
14648 bgp_lcommunity_list_name_expanded_cmd
,
14649 "bgp large-community-list expanded WORD <deny|permit> LINE...",
14651 LCOMMUNITY_LIST_STR
14652 "Specify expanded large-community-list\n"
14653 "Large Community list name\n"
14654 "Specify large community to reject\n"
14655 "Specify large community to accept\n"
14656 "An ordered list as a regular-expression\n")
14658 return lcommunity_list_set_vty(vty
, argc
, argv
,
14659 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
14662 ALIAS (lcommunity_list_name_expanded
,
14663 ip_lcommunity_list_name_expanded_cmd
,
14664 "ip large-community-list expanded WORD <deny|permit> LINE...",
14666 LCOMMUNITY_LIST_STR
14667 "Specify expanded large-community-list\n"
14668 "Large Community list name\n"
14669 "Specify large community to reject\n"
14670 "Specify large community to accept\n"
14671 "An ordered list as a regular-expression\n")
14673 DEFUN (no_lcommunity_list_standard_all
,
14674 no_bgp_lcommunity_list_standard_all_cmd
,
14675 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
14678 LCOMMUNITY_LIST_STR
14679 "Large Community list number (standard)\n"
14680 "Large Community list number (expanded)\n"
14681 "Large Community list name\n")
14683 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14684 LARGE_COMMUNITY_LIST_STANDARD
);
14687 ALIAS (no_lcommunity_list_standard_all
,
14688 no_ip_lcommunity_list_standard_all_cmd
,
14689 "no ip large-community-list <(1-99)|(100-500)|WORD>",
14692 LCOMMUNITY_LIST_STR
14693 "Large Community list number (standard)\n"
14694 "Large Community list number (expanded)\n"
14695 "Large Community list name\n")
14697 DEFUN (no_lcommunity_list_name_expanded_all
,
14698 no_bgp_lcommunity_list_name_expanded_all_cmd
,
14699 "no bgp large-community-list expanded WORD",
14702 LCOMMUNITY_LIST_STR
14703 "Specify expanded large-community-list\n"
14704 "Large Community list name\n")
14706 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14707 LARGE_COMMUNITY_LIST_EXPANDED
);
14710 ALIAS (no_lcommunity_list_name_expanded_all
,
14711 no_ip_lcommunity_list_name_expanded_all_cmd
,
14712 "no ip large-community-list expanded WORD",
14715 LCOMMUNITY_LIST_STR
14716 "Specify expanded large-community-list\n"
14717 "Large Community list name\n")
14719 DEFUN (no_lcommunity_list_standard
,
14720 no_bgp_lcommunity_list_standard_cmd
,
14721 "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
14724 LCOMMUNITY_LIST_STR
14725 "Large Community list number (standard)\n"
14726 "Specify large community to reject\n"
14727 "Specify large community to accept\n"
14728 LCOMMUNITY_VAL_STR
)
14730 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14731 LARGE_COMMUNITY_LIST_STANDARD
);
14734 ALIAS (no_lcommunity_list_standard
,
14735 no_ip_lcommunity_list_standard_cmd
,
14736 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
14739 LCOMMUNITY_LIST_STR
14740 "Large Community list number (standard)\n"
14741 "Specify large community to reject\n"
14742 "Specify large community to accept\n"
14743 LCOMMUNITY_VAL_STR
)
14745 DEFUN (no_lcommunity_list_expanded
,
14746 no_bgp_lcommunity_list_expanded_cmd
,
14747 "no bgp large-community-list (100-500) <deny|permit> LINE...",
14750 LCOMMUNITY_LIST_STR
14751 "Large Community list number (expanded)\n"
14752 "Specify large community to reject\n"
14753 "Specify large community to accept\n"
14754 "An ordered list as a regular-expression\n")
14756 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14757 LARGE_COMMUNITY_LIST_EXPANDED
);
14760 ALIAS (no_lcommunity_list_expanded
,
14761 no_ip_lcommunity_list_expanded_cmd
,
14762 "no ip large-community-list (100-500) <deny|permit> LINE...",
14765 LCOMMUNITY_LIST_STR
14766 "Large Community list number (expanded)\n"
14767 "Specify large community to reject\n"
14768 "Specify large community to accept\n"
14769 "An ordered list as a regular-expression\n")
14771 DEFUN (no_lcommunity_list_name_standard
,
14772 no_bgp_lcommunity_list_name_standard_cmd
,
14773 "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
14776 LCOMMUNITY_LIST_STR
14777 "Specify standard large-community-list\n"
14778 "Large Community list name\n"
14779 "Specify large community to reject\n"
14780 "Specify large community to accept\n"
14781 LCOMMUNITY_VAL_STR
)
14783 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14784 LARGE_COMMUNITY_LIST_STANDARD
);
14787 ALIAS (no_lcommunity_list_name_standard
,
14788 no_ip_lcommunity_list_name_standard_cmd
,
14789 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
14792 LCOMMUNITY_LIST_STR
14793 "Specify standard large-community-list\n"
14794 "Large Community list name\n"
14795 "Specify large community to reject\n"
14796 "Specify large community to accept\n"
14797 LCOMMUNITY_VAL_STR
)
14799 DEFUN (no_lcommunity_list_name_expanded
,
14800 no_bgp_lcommunity_list_name_expanded_cmd
,
14801 "no bgp large-community-list expanded WORD <deny|permit> LINE...",
14804 LCOMMUNITY_LIST_STR
14805 "Specify expanded large-community-list\n"
14806 "Large community list name\n"
14807 "Specify large community to reject\n"
14808 "Specify large community to accept\n"
14809 "An ordered list as a regular-expression\n")
14811 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14812 LARGE_COMMUNITY_LIST_EXPANDED
);
14815 ALIAS (no_lcommunity_list_name_expanded
,
14816 no_ip_lcommunity_list_name_expanded_cmd
,
14817 "no ip large-community-list expanded WORD <deny|permit> LINE...",
14820 LCOMMUNITY_LIST_STR
14821 "Specify expanded large-community-list\n"
14822 "Large community list name\n"
14823 "Specify large community to reject\n"
14824 "Specify large community to accept\n"
14825 "An ordered list as a regular-expression\n")
14827 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14829 struct community_entry
*entry
;
14831 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14832 if (entry
== list
->head
) {
14833 if (all_digit(list
->name
))
14834 vty_out(vty
, "Large community %s list %s\n",
14835 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14837 : "(expanded) access",
14841 "Named large community %s list %s\n",
14842 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14848 vty_out(vty
, " %s\n",
14849 community_direct_str(entry
->direct
));
14851 vty_out(vty
, " %s %s\n",
14852 community_direct_str(entry
->direct
),
14853 community_list_config_str(entry
));
14857 DEFUN (show_lcommunity_list
,
14858 show_bgp_lcommunity_list_cmd
,
14859 "show bgp large-community-list",
14862 "List large-community list\n")
14864 struct community_list
*list
;
14865 struct community_list_master
*cm
;
14868 if (argv_find(argv
, argc
, "ip", &idx
)) {
14869 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14870 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14871 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
14872 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
14875 cm
= community_list_master_lookup(bgp_clist
,
14876 LARGE_COMMUNITY_LIST_MASTER
);
14878 return CMD_SUCCESS
;
14880 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14881 lcommunity_list_show(vty
, list
);
14883 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14884 lcommunity_list_show(vty
, list
);
14886 return CMD_SUCCESS
;
14889 ALIAS (show_lcommunity_list
,
14890 show_ip_lcommunity_list_cmd
,
14891 "show ip large-community-list",
14894 "List large-community list\n")
14896 DEFUN (show_lcommunity_list_arg
,
14897 show_bgp_lcommunity_list_arg_cmd
,
14898 "show bgp large-community-list <(1-500)|WORD>",
14901 "List large-community list\n"
14902 "large-community-list number\n"
14903 "large-community-list name\n")
14905 struct community_list
*list
;
14908 if (argv_find(argv
, argc
, "ip", &idx
)) {
14909 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14910 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14911 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
14912 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
14915 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
14916 LARGE_COMMUNITY_LIST_MASTER
);
14918 vty_out(vty
, "%% Can't find extcommunity-list\n");
14919 return CMD_WARNING
;
14922 lcommunity_list_show(vty
, list
);
14924 return CMD_SUCCESS
;
14927 ALIAS (show_lcommunity_list_arg
,
14928 show_ip_lcommunity_list_arg_cmd
,
14929 "show ip large-community-list <(1-500)|WORD>",
14932 "List large-community list\n"
14933 "large-community-list number\n"
14934 "large-community-list name\n")
14936 /* "extcommunity-list" keyword help string. */
14937 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
14938 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
14940 DEFUN (extcommunity_list_standard
,
14941 bgp_extcommunity_list_standard_cmd
,
14942 "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14944 EXTCOMMUNITY_LIST_STR
14945 "Extended Community list number (standard)\n"
14946 "Specify standard extcommunity-list\n"
14947 "Community list name\n"
14948 "Specify community to reject\n"
14949 "Specify community to accept\n"
14950 EXTCOMMUNITY_VAL_STR
)
14952 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14954 char *cl_number_or_name
= NULL
;
14957 if (argv_find(argv
, argc
, "ip", &idx
)) {
14958 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14959 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14960 vty_out(vty
, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
14961 zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
14963 argv_find(argv
, argc
, "(1-99)", &idx
);
14964 argv_find(argv
, argc
, "WORD", &idx
);
14965 cl_number_or_name
= argv
[idx
]->arg
;
14966 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14968 argv_find(argv
, argc
, "AA:NN", &idx
);
14969 char *str
= argv_concat(argv
, argc
, idx
);
14971 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14974 XFREE(MTYPE_TMP
, str
);
14977 community_list_perror(vty
, ret
);
14978 return CMD_WARNING_CONFIG_FAILED
;
14981 return CMD_SUCCESS
;
14984 #if CONFDATE > 20191005
14985 CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command")
14987 ALIAS (extcommunity_list_standard
,
14988 ip_extcommunity_list_standard_cmd
,
14989 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14991 EXTCOMMUNITY_LIST_STR
14992 "Extended Community list number (standard)\n"
14993 "Specify standard extcommunity-list\n"
14994 "Community list name\n"
14995 "Specify community to reject\n"
14996 "Specify community to accept\n"
14997 EXTCOMMUNITY_VAL_STR
)
14999 DEFUN (extcommunity_list_name_expanded
,
15000 bgp_extcommunity_list_name_expanded_cmd
,
15001 "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15003 EXTCOMMUNITY_LIST_STR
15004 "Extended Community list number (expanded)\n"
15005 "Specify expanded extcommunity-list\n"
15006 "Extended Community list name\n"
15007 "Specify community to reject\n"
15008 "Specify community to accept\n"
15009 "An ordered list as a regular-expression\n")
15011 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15013 char *cl_number_or_name
= NULL
;
15016 if (argv_find(argv
, argc
, "ip", &idx
)) {
15017 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15018 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15019 vty_out(vty
, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15020 zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15023 argv_find(argv
, argc
, "(100-500)", &idx
);
15024 argv_find(argv
, argc
, "WORD", &idx
);
15025 cl_number_or_name
= argv
[idx
]->arg
;
15026 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15028 argv_find(argv
, argc
, "LINE", &idx
);
15029 char *str
= argv_concat(argv
, argc
, idx
);
15031 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15034 XFREE(MTYPE_TMP
, str
);
15037 community_list_perror(vty
, ret
);
15038 return CMD_WARNING_CONFIG_FAILED
;
15041 return CMD_SUCCESS
;
15044 ALIAS (extcommunity_list_name_expanded
,
15045 ip_extcommunity_list_name_expanded_cmd
,
15046 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15048 EXTCOMMUNITY_LIST_STR
15049 "Extended Community list number (expanded)\n"
15050 "Specify expanded extcommunity-list\n"
15051 "Extended Community list name\n"
15052 "Specify community to reject\n"
15053 "Specify community to accept\n"
15054 "An ordered list as a regular-expression\n")
15056 DEFUN (no_extcommunity_list_standard_all
,
15057 no_bgp_extcommunity_list_standard_all_cmd
,
15058 "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15061 EXTCOMMUNITY_LIST_STR
15062 "Extended Community list number (standard)\n"
15063 "Specify standard extcommunity-list\n"
15064 "Community list name\n"
15065 "Specify community to reject\n"
15066 "Specify community to accept\n"
15067 EXTCOMMUNITY_VAL_STR
)
15069 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15071 char *cl_number_or_name
= NULL
;
15075 if (argv_find(argv
, argc
, "ip", &idx
)) {
15076 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15077 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15078 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15079 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15083 argv_find(argv
, argc
, "permit", &idx
);
15084 argv_find(argv
, argc
, "deny", &idx
);
15087 direct
= argv_find(argv
, argc
, "permit", &idx
)
15092 argv_find(argv
, argc
, "AA:NN", &idx
);
15093 str
= argv_concat(argv
, argc
, idx
);
15097 argv_find(argv
, argc
, "(1-99)", &idx
);
15098 argv_find(argv
, argc
, "WORD", &idx
);
15099 cl_number_or_name
= argv
[idx
]->arg
;
15101 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15104 XFREE(MTYPE_TMP
, str
);
15107 community_list_perror(vty
, ret
);
15108 return CMD_WARNING_CONFIG_FAILED
;
15111 return CMD_SUCCESS
;
15114 ALIAS (no_extcommunity_list_standard_all
,
15115 no_ip_extcommunity_list_standard_all_cmd
,
15116 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15119 EXTCOMMUNITY_LIST_STR
15120 "Extended Community list number (standard)\n"
15121 "Specify standard extcommunity-list\n"
15122 "Community list name\n"
15123 "Specify community to reject\n"
15124 "Specify community to accept\n"
15125 EXTCOMMUNITY_VAL_STR
)
15127 ALIAS(no_extcommunity_list_standard_all
,
15128 no_bgp_extcommunity_list_standard_all_list_cmd
,
15129 "no bgp extcommunity-list <(1-99)|standard WORD>",
15130 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15131 "Extended Community list number (standard)\n"
15132 "Specify standard extcommunity-list\n"
15133 "Community list name\n")
15135 ALIAS(no_extcommunity_list_standard_all
,
15136 no_ip_extcommunity_list_standard_all_list_cmd
,
15137 "no ip extcommunity-list <(1-99)|standard WORD>",
15138 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15139 "Extended Community list number (standard)\n"
15140 "Specify standard extcommunity-list\n"
15141 "Community list name\n")
15143 DEFUN (no_extcommunity_list_expanded_all
,
15144 no_bgp_extcommunity_list_expanded_all_cmd
,
15145 "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15148 EXTCOMMUNITY_LIST_STR
15149 "Extended Community list number (expanded)\n"
15150 "Specify expanded extcommunity-list\n"
15151 "Extended Community list name\n"
15152 "Specify community to reject\n"
15153 "Specify community to accept\n"
15154 "An ordered list as a regular-expression\n")
15156 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15158 char *cl_number_or_name
= NULL
;
15162 if (argv_find(argv
, argc
, "ip", &idx
)) {
15163 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15164 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15165 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15166 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15170 argv_find(argv
, argc
, "permit", &idx
);
15171 argv_find(argv
, argc
, "deny", &idx
);
15174 direct
= argv_find(argv
, argc
, "permit", &idx
)
15179 argv_find(argv
, argc
, "LINE", &idx
);
15180 str
= argv_concat(argv
, argc
, idx
);
15184 argv_find(argv
, argc
, "(100-500)", &idx
);
15185 argv_find(argv
, argc
, "WORD", &idx
);
15186 cl_number_or_name
= argv
[idx
]->arg
;
15188 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15191 XFREE(MTYPE_TMP
, str
);
15194 community_list_perror(vty
, ret
);
15195 return CMD_WARNING_CONFIG_FAILED
;
15198 return CMD_SUCCESS
;
15201 ALIAS (no_extcommunity_list_expanded_all
,
15202 no_ip_extcommunity_list_expanded_all_cmd
,
15203 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15206 EXTCOMMUNITY_LIST_STR
15207 "Extended Community list number (expanded)\n"
15208 "Specify expanded extcommunity-list\n"
15209 "Extended Community list name\n"
15210 "Specify community to reject\n"
15211 "Specify community to accept\n"
15212 "An ordered list as a regular-expression\n")
15214 ALIAS(no_extcommunity_list_expanded_all
,
15215 no_ip_extcommunity_list_expanded_all_list_cmd
,
15216 "no ip extcommunity-list <(100-500)|expanded WORD>",
15217 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15218 "Extended Community list number (expanded)\n"
15219 "Specify expanded extcommunity-list\n"
15220 "Extended Community list name\n")
15222 ALIAS(no_extcommunity_list_expanded_all
,
15223 no_bgp_extcommunity_list_expanded_all_list_cmd
,
15224 "no bgp extcommunity-list <(100-500)|expanded WORD>",
15225 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15226 "Extended Community list number (expanded)\n"
15227 "Specify expanded extcommunity-list\n"
15228 "Extended Community list name\n")
15230 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
15232 struct community_entry
*entry
;
15234 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15235 if (entry
== list
->head
) {
15236 if (all_digit(list
->name
))
15237 vty_out(vty
, "Extended community %s list %s\n",
15238 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15240 : "(expanded) access",
15244 "Named extended community %s list %s\n",
15245 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15251 vty_out(vty
, " %s\n",
15252 community_direct_str(entry
->direct
));
15254 vty_out(vty
, " %s %s\n",
15255 community_direct_str(entry
->direct
),
15256 community_list_config_str(entry
));
15260 DEFUN (show_extcommunity_list
,
15261 show_bgp_extcommunity_list_cmd
,
15262 "show bgp extcommunity-list",
15265 "List extended-community list\n")
15267 struct community_list
*list
;
15268 struct community_list_master
*cm
;
15271 if (argv_find(argv
, argc
, "ip", &idx
)) {
15272 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15273 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15274 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15275 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15277 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15279 return CMD_SUCCESS
;
15281 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15282 extcommunity_list_show(vty
, list
);
15284 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15285 extcommunity_list_show(vty
, list
);
15287 return CMD_SUCCESS
;
15290 ALIAS (show_extcommunity_list
,
15291 show_ip_extcommunity_list_cmd
,
15292 "show ip extcommunity-list",
15295 "List extended-community list\n")
15297 DEFUN (show_extcommunity_list_arg
,
15298 show_bgp_extcommunity_list_arg_cmd
,
15299 "show bgp extcommunity-list <(1-500)|WORD>",
15302 "List extended-community list\n"
15303 "Extcommunity-list number\n"
15304 "Extcommunity-list name\n")
15306 int idx_comm_list
= 3;
15307 struct community_list
*list
;
15310 if (argv_find(argv
, argc
, "ip", &idx
)) {
15311 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15312 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15313 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15314 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15316 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
15317 EXTCOMMUNITY_LIST_MASTER
);
15319 vty_out(vty
, "%% Can't find extcommunity-list\n");
15320 return CMD_WARNING
;
15323 extcommunity_list_show(vty
, list
);
15325 return CMD_SUCCESS
;
15328 ALIAS (show_extcommunity_list_arg
,
15329 show_ip_extcommunity_list_arg_cmd
,
15330 "show ip extcommunity-list <(1-500)|WORD>",
15333 "List extended-community list\n"
15334 "Extcommunity-list number\n"
15335 "Extcommunity-list name\n")
15337 /* Display community-list and extcommunity-list configuration. */
15338 static int community_list_config_write(struct vty
*vty
)
15340 struct community_list
*list
;
15341 struct community_entry
*entry
;
15342 struct community_list_master
*cm
;
15345 /* Community-list. */
15346 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
15348 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15349 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15350 vty_out(vty
, "bgp community-list %s %s %s\n", list
->name
,
15351 community_direct_str(entry
->direct
),
15352 community_list_config_str(entry
));
15355 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15356 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15357 vty_out(vty
, "bgp community-list %s %s %s %s\n",
15358 entry
->style
== COMMUNITY_LIST_STANDARD
15361 list
->name
, community_direct_str(entry
->direct
),
15362 community_list_config_str(entry
));
15366 /* Extcommunity-list. */
15367 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15369 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15370 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15371 vty_out(vty
, "bgp extcommunity-list %s %s %s\n",
15372 list
->name
, community_direct_str(entry
->direct
),
15373 community_list_config_str(entry
));
15376 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15377 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15378 vty_out(vty
, "bgp extcommunity-list %s %s %s %s\n",
15379 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15382 list
->name
, community_direct_str(entry
->direct
),
15383 community_list_config_str(entry
));
15388 /* lcommunity-list. */
15389 cm
= community_list_master_lookup(bgp_clist
,
15390 LARGE_COMMUNITY_LIST_MASTER
);
15392 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15393 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15394 vty_out(vty
, "bgp large-community-list %s %s %s\n",
15395 list
->name
, community_direct_str(entry
->direct
),
15396 community_list_config_str(entry
));
15399 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15400 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15401 vty_out(vty
, "bgp large-community-list %s %s %s %s\n",
15402 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
15405 list
->name
, community_direct_str(entry
->direct
),
15406 community_list_config_str(entry
));
15413 static struct cmd_node community_list_node
= {
15414 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
15417 static void community_list_vty(void)
15419 install_node(&community_list_node
, community_list_config_write
);
15421 /* Community-list. */
15422 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
15423 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
15424 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
15425 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
15426 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
15427 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
15428 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
15429 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
15430 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
15431 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
15432 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
15433 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_list_cmd
);
15434 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
15435 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_list_cmd
);
15436 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
15437 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
15439 /* Extcommunity-list. */
15440 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
15441 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
15442 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
15443 install_element(CONFIG_NODE
,
15444 &no_bgp_extcommunity_list_standard_all_list_cmd
);
15445 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
15446 install_element(CONFIG_NODE
,
15447 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
15448 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
15449 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
15450 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
15451 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
15452 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
15453 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_list_cmd
);
15454 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
15455 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_list_cmd
);
15456 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
15457 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
15459 /* Large Community List */
15460 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
15461 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard1_cmd
);
15462 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
15463 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
15464 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard1_cmd
);
15465 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
15466 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_all_cmd
);
15467 install_element(CONFIG_NODE
,
15468 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
15469 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
15470 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
15471 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
15472 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
15473 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
15474 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
15475 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
15476 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
15477 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
15478 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
15479 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
15480 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
15481 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
15482 install_element(CONFIG_NODE
,
15483 &no_ip_lcommunity_list_name_expanded_all_cmd
);
15484 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
15485 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
15486 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
15487 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
15488 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
15489 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);