2 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "lib/zclient.h"
34 #include "memory_vty.h"
40 #include "bgpd/bgpd.h"
41 #include "bgpd/bgp_attr_evpn.h"
42 #include "bgpd/bgp_advertise.h"
43 #include "bgpd/bgp_attr.h"
44 #include "bgpd/bgp_aspath.h"
45 #include "bgpd/bgp_community.h"
46 #include "bgpd/bgp_ecommunity.h"
47 #include "bgpd/bgp_lcommunity.h"
48 #include "bgpd/bgp_damp.h"
49 #include "bgpd/bgp_debug.h"
50 #include "bgpd/bgp_errors.h"
51 #include "bgpd/bgp_fsm.h"
52 #include "bgpd/bgp_nexthop.h"
53 #include "bgpd/bgp_open.h"
54 #include "bgpd/bgp_regex.h"
55 #include "bgpd/bgp_route.h"
56 #include "bgpd/bgp_mplsvpn.h"
57 #include "bgpd/bgp_zebra.h"
58 #include "bgpd/bgp_table.h"
59 #include "bgpd/bgp_vty.h"
60 #include "bgpd/bgp_mpath.h"
61 #include "bgpd/bgp_packet.h"
62 #include "bgpd/bgp_updgrp.h"
63 #include "bgpd/bgp_bfd.h"
64 #include "bgpd/bgp_io.h"
65 #include "bgpd/bgp_evpn.h"
66 #include "bgpd/bgp_addpath.h"
67 #include "bgpd/bgp_mac.h"
69 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
70 struct prefix
*range
, int exact
);
72 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
81 return BGP_IPV4M_NODE
;
83 case SAFI_LABELED_UNICAST
:
84 return BGP_IPV4L_NODE
;
87 return BGP_VPNV4_NODE
;
90 return BGP_FLOWSPECV4_NODE
;
100 return BGP_IPV6_NODE
;
103 return BGP_IPV6M_NODE
;
105 case SAFI_LABELED_UNICAST
:
106 return BGP_IPV6L_NODE
;
109 return BGP_VPNV6_NODE
;
112 return BGP_FLOWSPECV6_NODE
;
115 return BGP_IPV4_NODE
;
120 return BGP_EVPN_NODE
;
123 // We should never be here but to clarify the switch statement..
124 return BGP_IPV4_NODE
;
128 // Impossible to happen
129 return BGP_IPV4_NODE
;
132 /* Utility function to get address family from current node. */
133 afi_t
bgp_node_afi(struct vty
*vty
)
141 case BGP_FLOWSPECV6_NODE
:
154 /* Utility function to get subsequent address family from current
156 safi_t
bgp_node_safi(struct vty
*vty
)
162 safi
= SAFI_MPLS_VPN
;
166 safi
= SAFI_MULTICAST
;
173 safi
= SAFI_LABELED_UNICAST
;
175 case BGP_FLOWSPECV4_NODE
:
176 case BGP_FLOWSPECV6_NODE
:
177 safi
= SAFI_FLOWSPEC
;
187 * Converts an AFI in string form to afi_t
189 * @param afi string, one of
193 * @return the corresponding afi_t
195 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
197 afi_t afi
= AFI_MAX
; /* unknown */
198 if (strmatch(afi_str
, "ipv4"))
200 else if (strmatch(afi_str
, "ipv6"))
202 else if (strmatch(afi_str
, "l2vpn"))
207 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
211 if (argv_find(argv
, argc
, "ipv4", index
)) {
215 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
223 /* supports <unicast|multicast|vpn|labeled-unicast> */
224 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
226 safi_t safi
= SAFI_MAX
; /* unknown */
227 if (strmatch(safi_str
, "multicast"))
228 safi
= SAFI_MULTICAST
;
229 else if (strmatch(safi_str
, "unicast"))
231 else if (strmatch(safi_str
, "vpn"))
232 safi
= SAFI_MPLS_VPN
;
233 else if (strmatch(safi_str
, "evpn"))
235 else if (strmatch(safi_str
, "labeled-unicast"))
236 safi
= SAFI_LABELED_UNICAST
;
237 else if (strmatch(safi_str
, "flowspec"))
238 safi
= SAFI_FLOWSPEC
;
242 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
246 if (argv_find(argv
, argc
, "unicast", index
)) {
249 *safi
= SAFI_UNICAST
;
250 } else if (argv_find(argv
, argc
, "multicast", index
)) {
253 *safi
= SAFI_MULTICAST
;
254 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
257 *safi
= SAFI_LABELED_UNICAST
;
258 } else if (argv_find(argv
, argc
, "vpn", index
)) {
261 *safi
= SAFI_MPLS_VPN
;
262 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
265 *safi
= SAFI_FLOWSPEC
;
271 * bgp_vty_find_and_parse_afi_safi_bgp
273 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
274 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
275 * to appropriate values for the calling function. This is to allow the
276 * calling function to make decisions appropriate for the show command
277 * that is being parsed.
279 * The show commands are generally of the form:
280 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
281 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
283 * Since we use argv_find if the show command in particular doesn't have:
285 * [<view|vrf> VIEWVRFNAME]
286 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
287 * The command parsing should still be ok.
289 * vty -> The vty for the command so we can output some useful data in
290 * the event of a parse error in the vrf.
291 * argv -> The command tokens
292 * argc -> How many command tokens we have
293 * idx -> The current place in the command, generally should be 0 for this
295 * afi -> The parsed afi if it was included in the show command, returned here
296 * safi -> The parsed safi if it was included in the show command, returned here
297 * bgp -> Pointer to the bgp data structure we need to fill in.
299 * The function returns the correct location in the parse tree for the
302 * Returns 0 for failure to parse correctly, else the idx position of where
303 * it found the last token.
305 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
306 struct cmd_token
**argv
, int argc
,
307 int *idx
, afi_t
*afi
, safi_t
*safi
,
308 struct bgp
**bgp
, bool use_json
)
310 char *vrf_name
= NULL
;
316 if (argv_find(argv
, argc
, "ip", idx
))
319 if (argv_find(argv
, argc
, "view", idx
))
320 vrf_name
= argv
[*idx
+ 1]->arg
;
321 else if (argv_find(argv
, argc
, "vrf", idx
)) {
322 vrf_name
= argv
[*idx
+ 1]->arg
;
323 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
327 if (strmatch(vrf_name
, "all"))
330 *bgp
= bgp_lookup_by_name(vrf_name
);
333 vty_out(vty
, "{}\n");
335 vty_out(vty
, "View/Vrf %s is unknown\n",
342 *bgp
= bgp_get_default();
345 vty_out(vty
, "{}\n");
348 "Default BGP instance not found\n");
354 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
355 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
361 static int peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
363 struct interface
*ifp
= NULL
;
365 if (su
->sa
.sa_family
== AF_INET
)
366 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
367 else if (su
->sa
.sa_family
== AF_INET6
)
368 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
369 su
->sin6
.sin6_scope_id
,
378 /* Utility function for looking up peer from VTY. */
379 /* This is used only for configuration, so disallow if attempted on
380 * a dynamic neighbor.
382 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
384 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
393 ret
= str2sockunion(ip_str
, &su
);
395 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
397 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
400 "%% Malformed address or name: %s\n",
406 peer
= peer_lookup(bgp
, &su
);
409 "%% Specify remote-as or peer-group commands first\n");
412 if (peer_dynamic_neighbor(peer
)) {
414 "%% Operation not allowed on a dynamic neighbor\n");
421 /* Utility function for looking up peer or peer group. */
422 /* This is used only for configuration, so disallow if attempted on
423 * a dynamic neighbor.
425 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
427 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
430 struct peer
*peer
= NULL
;
431 struct peer_group
*group
= NULL
;
437 ret
= str2sockunion(peer_str
, &su
);
439 /* IP address, locate peer. */
440 peer
= peer_lookup(bgp
, &su
);
442 /* Not IP, could match either peer configured on interface or a
444 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
446 group
= peer_group_lookup(bgp
, peer_str
);
450 if (peer_dynamic_neighbor(peer
)) {
452 "%% Operation not allowed on a dynamic neighbor\n");
462 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
467 int bgp_vty_return(struct vty
*vty
, int ret
)
469 const char *str
= NULL
;
472 case BGP_ERR_INVALID_VALUE
:
473 str
= "Invalid value";
475 case BGP_ERR_INVALID_FLAG
:
476 str
= "Invalid flag";
478 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
479 str
= "Peer-group has been shutdown. Activate the peer-group first";
481 case BGP_ERR_PEER_FLAG_CONFLICT
:
482 str
= "Can't set override-capability and strict-capability-match at the same time";
484 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
485 str
= "Specify remote-as or peer-group remote AS first";
487 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
488 str
= "Cannot change the peer-group. Deconfigure first";
490 case BGP_ERR_PEER_GROUP_MISMATCH
:
491 str
= "Peer is not a member of this peer-group";
493 case BGP_ERR_PEER_FILTER_CONFLICT
:
494 str
= "Prefix/distribute list can not co-exist";
496 case BGP_ERR_NOT_INTERNAL_PEER
:
497 str
= "Invalid command. Not an internal neighbor";
499 case BGP_ERR_REMOVE_PRIVATE_AS
:
500 str
= "remove-private-AS cannot be configured for IBGP peers";
502 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
503 str
= "Local-AS allowed only for EBGP peers";
505 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
506 str
= "Cannot have local-as same as BGP AS number";
508 case BGP_ERR_TCPSIG_FAILED
:
509 str
= "Error while applying TCP-Sig to session(s)";
511 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
512 str
= "ebgp-multihop and ttl-security cannot be configured together";
514 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
515 str
= "ttl-security only allowed for EBGP peers";
517 case BGP_ERR_AS_OVERRIDE
:
518 str
= "as-override cannot be configured for IBGP peers";
520 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
521 str
= "Invalid limit for number of dynamic neighbors";
523 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
524 str
= "Dynamic neighbor listen range already exists";
526 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
527 str
= "Operation not allowed on a dynamic neighbor";
529 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
530 str
= "Operation not allowed on a directly connected neighbor";
532 case BGP_ERR_PEER_SAFI_CONFLICT
:
533 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
537 vty_out(vty
, "%% %s\n", str
);
538 return CMD_WARNING_CONFIG_FAILED
;
543 /* BGP clear sort. */
552 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
553 safi_t safi
, int error
)
556 case BGP_ERR_AF_UNCONFIGURED
:
558 "%%BGP: Enable %s address family for the neighbor %s\n",
559 afi_safi_print(afi
, safi
), peer
->host
);
561 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
563 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
571 /* `clear ip bgp' functions. */
572 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
573 enum clear_sort sort
, enum bgp_clear_type stype
,
579 struct listnode
*node
, *nnode
;
581 /* Clear all neighbors. */
583 * Pass along pointer to next node to peer_clear() when walking all
584 * nodes on the BGP instance as that may get freed if it is a
587 if (sort
== clear_all
) {
588 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
589 if (!peer
->afc
[afi
][safi
])
592 if (stype
== BGP_CLEAR_SOFT_NONE
)
593 ret
= peer_clear(peer
, &nnode
);
595 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
598 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
603 /* This is to apply read-only mode on this clear. */
604 if (stype
== BGP_CLEAR_SOFT_NONE
)
605 bgp
->update_delay_over
= 0;
608 vty_out(vty
, "%%BGP: No %s peer configured\n",
609 afi_safi_print(afi
, safi
));
614 /* Clear specified neighbor. */
615 if (sort
== clear_peer
) {
618 /* Make sockunion for lookup. */
619 ret
= str2sockunion(arg
, &su
);
621 peer
= peer_lookup_by_conf_if(bgp
, arg
);
623 peer
= peer_lookup_by_hostname(bgp
, arg
);
626 "Malformed address or name: %s\n",
632 peer
= peer_lookup(bgp
, &su
);
635 "%%BGP: Unknown neighbor - \"%s\"\n",
641 if (!peer
->afc
[afi
][safi
])
642 ret
= BGP_ERR_AF_UNCONFIGURED
;
643 else if (stype
== BGP_CLEAR_SOFT_NONE
)
644 ret
= peer_clear(peer
, NULL
);
646 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
649 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
654 /* Clear all neighbors belonging to a specific peer-group. */
655 if (sort
== clear_group
) {
656 struct peer_group
*group
;
658 group
= peer_group_lookup(bgp
, arg
);
660 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
664 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
665 if (!peer
->afc
[afi
][safi
])
668 if (stype
== BGP_CLEAR_SOFT_NONE
)
669 ret
= peer_clear(peer
, NULL
);
671 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
674 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
681 "%%BGP: No %s peer belonging to peer-group %s is configured\n",
682 afi_safi_print(afi
, safi
), arg
);
687 /* Clear all external (eBGP) neighbors. */
688 if (sort
== clear_external
) {
689 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
690 if (peer
->sort
== BGP_PEER_IBGP
)
693 if (!peer
->afc
[afi
][safi
])
696 if (stype
== BGP_CLEAR_SOFT_NONE
)
697 ret
= peer_clear(peer
, &nnode
);
699 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
702 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
709 "%%BGP: No external %s peer is configured\n",
710 afi_safi_print(afi
, safi
));
715 /* Clear all neighbors belonging to a specific AS. */
716 if (sort
== clear_as
) {
717 as_t as
= strtoul(arg
, NULL
, 10);
719 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
723 if (!peer
->afc
[afi
][safi
])
724 ret
= BGP_ERR_AF_UNCONFIGURED
;
725 else if (stype
== BGP_CLEAR_SOFT_NONE
)
726 ret
= peer_clear(peer
, &nnode
);
728 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
731 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
738 "%%BGP: No %s peer is configured with AS %s\n",
739 afi_safi_print(afi
, safi
), arg
);
747 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
748 safi_t safi
, enum clear_sort sort
,
749 enum bgp_clear_type stype
, const char *arg
)
753 /* BGP structure lookup. */
755 bgp
= bgp_lookup_by_name(name
);
757 vty_out(vty
, "Can't find BGP instance %s\n", name
);
761 bgp
= bgp_get_default();
763 vty_out(vty
, "No BGP process is configured\n");
768 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
771 /* clear soft inbound */
772 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
774 bgp_clear_vty(vty
, name
, AFI_IP
, SAFI_UNICAST
, clear_all
,
775 BGP_CLEAR_SOFT_IN
, NULL
);
776 bgp_clear_vty(vty
, name
, AFI_IP6
, SAFI_UNICAST
, clear_all
,
777 BGP_CLEAR_SOFT_IN
, NULL
);
780 /* clear soft outbound */
781 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
783 bgp_clear_vty(vty
, name
, AFI_IP
, SAFI_UNICAST
, clear_all
,
784 BGP_CLEAR_SOFT_OUT
, NULL
);
785 bgp_clear_vty(vty
, name
, AFI_IP6
, SAFI_UNICAST
, clear_all
,
786 BGP_CLEAR_SOFT_OUT
, NULL
);
790 #ifndef VTYSH_EXTRACT_PL
791 #include "bgpd/bgp_vty_clippy.c"
794 /* BGP global configuration. */
795 #if (CONFDATE > 20190601)
796 CPP_NOTICE("bgpd: time to remove deprecated bgp multiple-instance")
797 CPP_NOTICE("This includes BGP_OPT_MULTIPLE_INSTANCE")
799 DEFUN_HIDDEN (bgp_multiple_instance_func
,
800 bgp_multiple_instance_cmd
,
801 "bgp multiple-instance",
803 "Enable bgp multiple instance\n")
805 bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE
);
809 DEFUN_HIDDEN (no_bgp_multiple_instance
,
810 no_bgp_multiple_instance_cmd
,
811 "no bgp multiple-instance",
814 "BGP multiple instance\n")
818 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
819 vty_out(vty
, "if you are using this please let the developers know\n");
820 zlog_info("Deprecated option: `bgp multiple-instance` being used");
821 ret
= bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE
);
823 vty_out(vty
, "%% There are more than two BGP instances\n");
824 return CMD_WARNING_CONFIG_FAILED
;
829 DEFUN_HIDDEN (bgp_local_mac
,
831 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
834 "VxLAN Network Identifier\n"
838 "mac-mobility sequence\n"
848 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
849 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
850 vty_out(vty
, "%% Malformed MAC address\n");
853 memset(&ip
, 0, sizeof(ip
));
854 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
856 bgp
= bgp_get_default();
858 vty_out(vty
, "Default BGP instance is not there\n");
862 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
);
864 vty_out(vty
, "Internal error\n");
871 DEFUN_HIDDEN (no_bgp_local_mac
,
872 no_bgp_local_mac_cmd
,
873 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
877 "VxLAN Network Identifier\n"
888 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
889 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
890 vty_out(vty
, "%% Malformed MAC address\n");
893 memset(&ip
, 0, sizeof(ip
));
895 bgp
= bgp_get_default();
897 vty_out(vty
, "Default BGP instance is not there\n");
901 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
903 vty_out(vty
, "Internal error\n");
910 #if (CONFDATE > 20190601)
911 CPP_NOTICE("bgpd: time to remove deprecated cli bgp config-type cisco")
912 CPP_NOTICE("This includes BGP_OPT_CISCO_CONFIG")
914 DEFUN_HIDDEN (bgp_config_type
,
916 "bgp config-type <cisco|zebra>",
918 "Configuration type\n"
923 if (argv_find(argv
, argc
, "cisco", &idx
)) {
924 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
925 vty_out(vty
, "if you are using this please let the developers know!\n");
926 zlog_info("Deprecated option: `bgp config-type cisco` being used");
927 bgp_option_set(BGP_OPT_CONFIG_CISCO
);
929 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
934 DEFUN_HIDDEN (no_bgp_config_type
,
935 no_bgp_config_type_cmd
,
936 "no bgp config-type [<cisco|zebra>]",
939 "Display configuration type\n"
943 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
948 DEFUN (no_synchronization
,
949 no_synchronization_cmd
,
950 "no synchronization",
952 "Perform IGP synchronization\n")
957 DEFUN (no_auto_summary
,
961 "Enable automatic network number summarization\n")
966 /* "router bgp" commands. */
967 DEFUN_NOSH (router_bgp
,
969 "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
973 BGP_INSTANCE_HELP_STR
)
976 int idx_view_vrf
= 3;
982 const char *name
= NULL
;
983 enum bgp_instance_type inst_type
;
985 // "router bgp" without an ASN
987 // Pending: Make VRF option available for ASN less config
988 bgp
= bgp_get_default();
991 vty_out(vty
, "%% No BGP process is configured\n");
992 return CMD_WARNING_CONFIG_FAILED
;
995 if (listcount(bm
->bgp
) > 1) {
996 vty_out(vty
, "%% Please specify ASN and VRF\n");
997 return CMD_WARNING_CONFIG_FAILED
;
1003 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1005 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1007 name
= argv
[idx_vrf
]->arg
;
1009 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1010 if (strmatch(name
, VRF_DEFAULT_NAME
))
1013 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1014 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1015 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1018 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1019 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1021 ret
= bgp_get(&bgp
, &as
, name
, inst_type
);
1023 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET
:
1025 "Please specify 'bgp multiple-instance' first\n");
1026 return CMD_WARNING_CONFIG_FAILED
;
1027 case BGP_ERR_AS_MISMATCH
:
1028 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1029 return CMD_WARNING_CONFIG_FAILED
;
1030 case BGP_ERR_INSTANCE_MISMATCH
:
1032 "BGP instance name and AS number mismatch\n");
1034 "BGP instance is already running; AS is %u\n",
1036 return CMD_WARNING_CONFIG_FAILED
;
1040 * If we just instantiated the default instance, complete
1041 * any pending VRF-VPN leaking that was configured via
1042 * earlier "router bgp X vrf FOO" blocks.
1044 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1045 vpn_leak_postchange_all();
1047 /* Pending: handle when user tries to change a view to vrf n vv.
1051 /* unset the auto created flag as the user config is now present */
1052 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1053 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1058 /* "no router bgp" commands. */
1059 DEFUN (no_router_bgp
,
1061 "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
1066 BGP_INSTANCE_HELP_STR
)
1072 const char *name
= NULL
;
1074 // "no router bgp" without an ASN
1076 // Pending: Make VRF option available for ASN less config
1077 bgp
= bgp_get_default();
1080 vty_out(vty
, "%% No BGP process is configured\n");
1081 return CMD_WARNING_CONFIG_FAILED
;
1084 if (listcount(bm
->bgp
) > 1) {
1085 vty_out(vty
, "%% Please specify ASN and VRF\n");
1086 return CMD_WARNING_CONFIG_FAILED
;
1090 vty_out(vty
, "%% Please unconfigure l3vni %u",
1092 return CMD_WARNING_CONFIG_FAILED
;
1095 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1098 name
= argv
[idx_vrf
]->arg
;
1100 /* Lookup bgp structure. */
1101 bgp
= bgp_lookup(as
, name
);
1103 vty_out(vty
, "%% Can't find BGP instance\n");
1104 return CMD_WARNING_CONFIG_FAILED
;
1108 vty_out(vty
, "%% Please unconfigure l3vni %u",
1110 return CMD_WARNING_CONFIG_FAILED
;
1120 /* BGP router-id. */
1122 DEFPY (bgp_router_id
,
1124 "bgp router-id A.B.C.D",
1126 "Override configured router identifier\n"
1127 "Manually configured router identifier\n")
1129 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1130 bgp_router_id_static_set(bgp
, router_id
);
1134 DEFPY (no_bgp_router_id
,
1135 no_bgp_router_id_cmd
,
1136 "no bgp router-id [A.B.C.D]",
1139 "Override configured router identifier\n"
1140 "Manually configured router identifier\n")
1142 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1144 if (router_id_str
) {
1145 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1146 vty_out(vty
, "%% BGP router-id doesn't match\n");
1147 return CMD_WARNING_CONFIG_FAILED
;
1151 router_id
.s_addr
= 0;
1152 bgp_router_id_static_set(bgp
, router_id
);
1158 /* BGP Cluster ID. */
1159 DEFUN (bgp_cluster_id
,
1161 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1163 "Configure Route-Reflector Cluster-id\n"
1164 "Route-Reflector Cluster-id in IP address format\n"
1165 "Route-Reflector Cluster-id as 32 bit quantity\n")
1167 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1170 struct in_addr cluster
;
1172 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1174 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1175 return CMD_WARNING_CONFIG_FAILED
;
1178 bgp_cluster_id_set(bgp
, &cluster
);
1179 bgp_clear_star_soft_out(vty
, bgp
->name
);
1184 DEFUN (no_bgp_cluster_id
,
1185 no_bgp_cluster_id_cmd
,
1186 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1189 "Configure Route-Reflector Cluster-id\n"
1190 "Route-Reflector Cluster-id in IP address format\n"
1191 "Route-Reflector Cluster-id as 32 bit quantity\n")
1193 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1194 bgp_cluster_id_unset(bgp
);
1195 bgp_clear_star_soft_out(vty
, bgp
->name
);
1200 DEFUN (bgp_confederation_identifier
,
1201 bgp_confederation_identifier_cmd
,
1202 "bgp confederation identifier (1-4294967295)",
1203 "BGP specific commands\n"
1204 "AS confederation parameters\n"
1206 "Set routing domain confederation AS\n")
1208 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1212 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1214 bgp_confederation_id_set(bgp
, as
);
1219 DEFUN (no_bgp_confederation_identifier
,
1220 no_bgp_confederation_identifier_cmd
,
1221 "no bgp confederation identifier [(1-4294967295)]",
1223 "BGP specific commands\n"
1224 "AS confederation parameters\n"
1226 "Set routing domain confederation AS\n")
1228 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1229 bgp_confederation_id_unset(bgp
);
1234 DEFUN (bgp_confederation_peers
,
1235 bgp_confederation_peers_cmd
,
1236 "bgp confederation peers (1-4294967295)...",
1237 "BGP specific commands\n"
1238 "AS confederation parameters\n"
1239 "Peer ASs in BGP confederation\n"
1242 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1247 for (i
= idx_asn
; i
< argc
; i
++) {
1248 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1250 if (bgp
->as
== as
) {
1252 "%% Local member-AS not allowed in confed peer list\n");
1256 bgp_confederation_peers_add(bgp
, as
);
1261 DEFUN (no_bgp_confederation_peers
,
1262 no_bgp_confederation_peers_cmd
,
1263 "no bgp confederation peers (1-4294967295)...",
1265 "BGP specific commands\n"
1266 "AS confederation parameters\n"
1267 "Peer ASs in BGP confederation\n"
1270 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1275 for (i
= idx_asn
; i
< argc
; i
++) {
1276 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1278 bgp_confederation_peers_remove(bgp
, as
);
1284 * Central routine for maximum-paths configuration.
1285 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1286 * @set: 1 for setting values, 0 for removing the max-paths config.
1288 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1289 const char *mpaths
, uint16_t options
,
1292 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1293 uint16_t maxpaths
= 0;
1298 afi
= bgp_node_afi(vty
);
1299 safi
= bgp_node_safi(vty
);
1302 maxpaths
= strtol(mpaths
, NULL
, 10);
1303 if (maxpaths
> multipath_num
) {
1305 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1306 maxpaths
, multipath_num
);
1307 return CMD_WARNING_CONFIG_FAILED
;
1309 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1312 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1316 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1317 (set
== 1) ? "" : "un",
1318 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1319 maxpaths
, afi
, safi
);
1320 return CMD_WARNING_CONFIG_FAILED
;
1323 bgp_recalculate_all_bestpaths(bgp
);
1328 DEFUN (bgp_maxmed_admin
,
1329 bgp_maxmed_admin_cmd
,
1330 "bgp max-med administrative ",
1332 "Advertise routes with max-med\n"
1333 "Administratively applied, for an indefinite period\n")
1335 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1337 bgp
->v_maxmed_admin
= 1;
1338 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1340 bgp_maxmed_update(bgp
);
1345 DEFUN (bgp_maxmed_admin_medv
,
1346 bgp_maxmed_admin_medv_cmd
,
1347 "bgp max-med administrative (0-4294967295)",
1349 "Advertise routes with max-med\n"
1350 "Administratively applied, for an indefinite period\n"
1351 "Max MED value to be used\n")
1353 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1356 bgp
->v_maxmed_admin
= 1;
1357 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1359 bgp_maxmed_update(bgp
);
1364 DEFUN (no_bgp_maxmed_admin
,
1365 no_bgp_maxmed_admin_cmd
,
1366 "no bgp max-med administrative [(0-4294967295)]",
1369 "Advertise routes with max-med\n"
1370 "Administratively applied, for an indefinite period\n"
1371 "Max MED value to be used\n")
1373 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1374 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1375 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1376 bgp_maxmed_update(bgp
);
1381 DEFUN (bgp_maxmed_onstartup
,
1382 bgp_maxmed_onstartup_cmd
,
1383 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1385 "Advertise routes with max-med\n"
1386 "Effective on a startup\n"
1387 "Time (seconds) period for max-med\n"
1388 "Max MED value to be used\n")
1390 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1393 argv_find(argv
, argc
, "(5-86400)", &idx
);
1394 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1395 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1396 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1398 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1400 bgp_maxmed_update(bgp
);
1405 DEFUN (no_bgp_maxmed_onstartup
,
1406 no_bgp_maxmed_onstartup_cmd
,
1407 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1410 "Advertise routes with max-med\n"
1411 "Effective on a startup\n"
1412 "Time (seconds) period for max-med\n"
1413 "Max MED value to be used\n")
1415 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1417 /* Cancel max-med onstartup if its on */
1418 if (bgp
->t_maxmed_onstartup
) {
1419 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1420 bgp
->maxmed_onstartup_over
= 1;
1423 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1424 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1426 bgp_maxmed_update(bgp
);
1431 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1434 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1435 uint16_t update_delay
;
1436 uint16_t establish_wait
;
1438 update_delay
= strtoul(delay
, NULL
, 10);
1440 if (!wait
) /* update-delay <delay> */
1442 bgp
->v_update_delay
= update_delay
;
1443 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1447 /* update-delay <delay> <establish-wait> */
1448 establish_wait
= atoi(wait
);
1449 if (update_delay
< establish_wait
) {
1451 "%%Failed: update-delay less than the establish-wait!\n");
1452 return CMD_WARNING_CONFIG_FAILED
;
1455 bgp
->v_update_delay
= update_delay
;
1456 bgp
->v_establish_wait
= establish_wait
;
1461 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1463 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1465 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1466 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1471 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1473 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1474 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1475 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1476 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1482 /* Update-delay configuration */
1483 DEFUN (bgp_update_delay
,
1484 bgp_update_delay_cmd
,
1485 "update-delay (0-3600)",
1486 "Force initial delay for best-path and updates\n"
1490 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1493 DEFUN (bgp_update_delay_establish_wait
,
1494 bgp_update_delay_establish_wait_cmd
,
1495 "update-delay (0-3600) (1-3600)",
1496 "Force initial delay for best-path and updates\n"
1501 int idx_number_2
= 2;
1502 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1503 argv
[idx_number_2
]->arg
);
1506 /* Update-delay deconfiguration */
1507 DEFUN (no_bgp_update_delay
,
1508 no_bgp_update_delay_cmd
,
1509 "no update-delay [(0-3600) [(1-3600)]]",
1511 "Force initial delay for best-path and updates\n"
1515 return bgp_update_delay_deconfig_vty(vty
);
1519 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1522 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1525 uint32_t quanta
= strtoul(num
, NULL
, 10);
1526 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
,
1527 memory_order_relaxed
);
1529 atomic_store_explicit(&bgp
->wpkt_quanta
, BGP_WRITE_PACKET_MAX
,
1530 memory_order_relaxed
);
1536 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1539 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1542 uint32_t quanta
= strtoul(num
, NULL
, 10);
1543 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
,
1544 memory_order_relaxed
);
1546 atomic_store_explicit(&bgp
->rpkt_quanta
, BGP_READ_PACKET_MAX
,
1547 memory_order_relaxed
);
1553 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1556 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1557 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1558 vty_out(vty
, " write-quanta %d\n", quanta
);
1561 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1564 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1565 if (quanta
!= BGP_READ_PACKET_MAX
)
1566 vty_out(vty
, " read-quanta %d\n", quanta
);
1569 /* Packet quanta configuration */
1570 DEFUN (bgp_wpkt_quanta
,
1571 bgp_wpkt_quanta_cmd
,
1572 "write-quanta (1-10)",
1573 "How many packets to write to peer socket per run\n"
1574 "Number of packets\n")
1577 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1580 DEFUN (no_bgp_wpkt_quanta
,
1581 no_bgp_wpkt_quanta_cmd
,
1582 "no write-quanta (1-10)",
1584 "How many packets to write to peer socket per I/O cycle\n"
1585 "Number of packets\n")
1588 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1591 DEFUN (bgp_rpkt_quanta
,
1592 bgp_rpkt_quanta_cmd
,
1593 "read-quanta (1-10)",
1594 "How many packets to read from peer socket per I/O cycle\n"
1595 "Number of packets\n")
1598 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1601 DEFUN (no_bgp_rpkt_quanta
,
1602 no_bgp_rpkt_quanta_cmd
,
1603 "no read-quanta (1-10)",
1605 "How many packets to read from peer socket per I/O cycle\n"
1606 "Number of packets\n")
1609 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1612 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1614 if (!bgp
->heuristic_coalesce
)
1615 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1619 DEFUN (bgp_coalesce_time
,
1620 bgp_coalesce_time_cmd
,
1621 "coalesce-time (0-4294967295)",
1622 "Subgroup coalesce timer\n"
1623 "Subgroup coalesce timer value (in ms)\n")
1625 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1628 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1629 bgp
->heuristic_coalesce
= false;
1630 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1634 DEFUN (no_bgp_coalesce_time
,
1635 no_bgp_coalesce_time_cmd
,
1636 "no coalesce-time (0-4294967295)",
1638 "Subgroup coalesce timer\n"
1639 "Subgroup coalesce timer value (in ms)\n")
1641 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1643 bgp
->heuristic_coalesce
= true;
1644 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1648 /* Maximum-paths configuration */
1649 DEFUN (bgp_maxpaths
,
1651 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1652 "Forward packets over multiple paths\n"
1653 "Number of paths\n")
1656 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1657 argv
[idx_number
]->arg
, 0, 1);
1660 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1661 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1662 "Forward packets over multiple paths\n"
1663 "Number of paths\n")
1665 DEFUN (bgp_maxpaths_ibgp
,
1666 bgp_maxpaths_ibgp_cmd
,
1667 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1668 "Forward packets over multiple paths\n"
1670 "Number of paths\n")
1673 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1674 argv
[idx_number
]->arg
, 0, 1);
1677 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1678 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1679 "Forward packets over multiple paths\n"
1681 "Number of paths\n")
1683 DEFUN (bgp_maxpaths_ibgp_cluster
,
1684 bgp_maxpaths_ibgp_cluster_cmd
,
1685 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1686 "Forward packets over multiple paths\n"
1689 "Match the cluster length\n")
1692 return bgp_maxpaths_config_vty(
1693 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1694 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1697 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1698 "maximum-paths ibgp " CMD_RANGE_STR(
1699 1, MULTIPATH_NUM
) " equal-cluster-length",
1700 "Forward packets over multiple paths\n"
1703 "Match the cluster length\n")
1705 DEFUN (no_bgp_maxpaths
,
1706 no_bgp_maxpaths_cmd
,
1707 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1709 "Forward packets over multiple paths\n"
1710 "Number of paths\n")
1712 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1715 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1716 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1717 "Forward packets over multiple paths\n"
1718 "Number of paths\n")
1720 DEFUN (no_bgp_maxpaths_ibgp
,
1721 no_bgp_maxpaths_ibgp_cmd
,
1722 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1724 "Forward packets over multiple paths\n"
1727 "Match the cluster length\n")
1729 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1732 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1733 "no maximum-paths ibgp [" CMD_RANGE_STR(
1734 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1736 "Forward packets over multiple paths\n"
1739 "Match the cluster length\n")
1741 void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1744 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1745 vty_out(vty
, " maximum-paths %d\n",
1746 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1749 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1750 vty_out(vty
, " maximum-paths ibgp %d",
1751 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1752 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1753 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1754 vty_out(vty
, " equal-cluster-length");
1763 "timers bgp (0-65535) (0-65535)",
1764 "Adjust routing timers\n"
1766 "Keepalive interval\n"
1769 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1771 int idx_number_2
= 3;
1772 unsigned long keepalive
= 0;
1773 unsigned long holdtime
= 0;
1775 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1776 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1778 /* Holdtime value check. */
1779 if (holdtime
< 3 && holdtime
!= 0) {
1781 "%% hold time value must be either 0 or greater than 3\n");
1782 return CMD_WARNING_CONFIG_FAILED
;
1785 bgp_timers_set(bgp
, keepalive
, holdtime
);
1790 DEFUN (no_bgp_timers
,
1792 "no timers bgp [(0-65535) (0-65535)]",
1794 "Adjust routing timers\n"
1796 "Keepalive interval\n"
1799 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1800 bgp_timers_unset(bgp
);
1806 DEFUN (bgp_client_to_client_reflection
,
1807 bgp_client_to_client_reflection_cmd
,
1808 "bgp client-to-client reflection",
1809 "BGP specific commands\n"
1810 "Configure client to client route reflection\n"
1811 "reflection of routes allowed\n")
1813 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1814 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1815 bgp_clear_star_soft_out(vty
, bgp
->name
);
1820 DEFUN (no_bgp_client_to_client_reflection
,
1821 no_bgp_client_to_client_reflection_cmd
,
1822 "no bgp client-to-client reflection",
1824 "BGP specific commands\n"
1825 "Configure client to client route reflection\n"
1826 "reflection of routes allowed\n")
1828 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1829 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1830 bgp_clear_star_soft_out(vty
, bgp
->name
);
1835 /* "bgp always-compare-med" configuration. */
1836 DEFUN (bgp_always_compare_med
,
1837 bgp_always_compare_med_cmd
,
1838 "bgp always-compare-med",
1839 "BGP specific commands\n"
1840 "Allow comparing MED from different neighbors\n")
1842 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1843 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1844 bgp_recalculate_all_bestpaths(bgp
);
1849 DEFUN (no_bgp_always_compare_med
,
1850 no_bgp_always_compare_med_cmd
,
1851 "no bgp always-compare-med",
1853 "BGP specific commands\n"
1854 "Allow comparing MED from different neighbors\n")
1856 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1857 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1858 bgp_recalculate_all_bestpaths(bgp
);
1864 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
1865 "bgp ebgp-requires-policy",
1866 "BGP specific commands\n"
1867 "Require in and out policy for eBGP peers (RFC8212)\n")
1869 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1870 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_ENABLED
;
1874 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
1875 "no bgp ebgp-requires-policy",
1877 "BGP specific commands\n"
1878 "Require in and out policy for eBGP peers (RFC8212)\n")
1880 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1881 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_DISABLED
;
1886 /* "bgp deterministic-med" configuration. */
1887 DEFUN (bgp_deterministic_med
,
1888 bgp_deterministic_med_cmd
,
1889 "bgp deterministic-med",
1890 "BGP specific commands\n"
1891 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1893 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1895 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1896 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1897 bgp_recalculate_all_bestpaths(bgp
);
1903 DEFUN (no_bgp_deterministic_med
,
1904 no_bgp_deterministic_med_cmd
,
1905 "no bgp deterministic-med",
1907 "BGP specific commands\n"
1908 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1910 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1911 int bestpath_per_as_used
;
1915 struct listnode
*node
, *nnode
;
1917 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1918 bestpath_per_as_used
= 0;
1920 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1921 FOREACH_AFI_SAFI (afi
, safi
)
1922 if (bgp_addpath_dmed_required(
1923 peer
->addpath_type
[afi
][safi
])) {
1924 bestpath_per_as_used
= 1;
1928 if (bestpath_per_as_used
)
1932 if (bestpath_per_as_used
) {
1934 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
1935 return CMD_WARNING_CONFIG_FAILED
;
1937 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1938 bgp_recalculate_all_bestpaths(bgp
);
1945 /* "bgp graceful-restart" configuration. */
1946 DEFUN (bgp_graceful_restart
,
1947 bgp_graceful_restart_cmd
,
1948 "bgp graceful-restart",
1949 "BGP specific commands\n"
1950 "Graceful restart capability parameters\n")
1952 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1953 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1957 DEFUN (no_bgp_graceful_restart
,
1958 no_bgp_graceful_restart_cmd
,
1959 "no bgp graceful-restart",
1961 "BGP specific commands\n"
1962 "Graceful restart capability parameters\n")
1964 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1965 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1969 DEFUN (bgp_graceful_restart_stalepath_time
,
1970 bgp_graceful_restart_stalepath_time_cmd
,
1971 "bgp graceful-restart stalepath-time (1-4095)",
1972 "BGP specific commands\n"
1973 "Graceful restart capability parameters\n"
1974 "Set the max time to hold onto restarting peer's stale paths\n"
1975 "Delay value (seconds)\n")
1977 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1981 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1982 bgp
->stalepath_time
= stalepath
;
1986 DEFUN (bgp_graceful_restart_restart_time
,
1987 bgp_graceful_restart_restart_time_cmd
,
1988 "bgp graceful-restart restart-time (1-4095)",
1989 "BGP specific commands\n"
1990 "Graceful restart capability parameters\n"
1991 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1992 "Delay value (seconds)\n")
1994 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1998 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1999 bgp
->restart_time
= restart
;
2003 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2004 no_bgp_graceful_restart_stalepath_time_cmd
,
2005 "no bgp graceful-restart stalepath-time [(1-4095)]",
2007 "BGP specific commands\n"
2008 "Graceful restart capability parameters\n"
2009 "Set the max time to hold onto restarting peer's stale paths\n"
2010 "Delay value (seconds)\n")
2012 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2014 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2018 DEFUN (no_bgp_graceful_restart_restart_time
,
2019 no_bgp_graceful_restart_restart_time_cmd
,
2020 "no bgp graceful-restart restart-time [(1-4095)]",
2022 "BGP specific commands\n"
2023 "Graceful restart capability parameters\n"
2024 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2025 "Delay value (seconds)\n")
2027 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2029 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2033 DEFUN (bgp_graceful_restart_preserve_fw
,
2034 bgp_graceful_restart_preserve_fw_cmd
,
2035 "bgp graceful-restart preserve-fw-state",
2036 "BGP specific commands\n"
2037 "Graceful restart capability parameters\n"
2038 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2040 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2041 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2045 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2046 no_bgp_graceful_restart_preserve_fw_cmd
,
2047 "no bgp graceful-restart preserve-fw-state",
2049 "BGP specific commands\n"
2050 "Graceful restart capability parameters\n"
2051 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2053 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2054 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2058 static void bgp_redistribute_redo(struct bgp
*bgp
)
2062 struct list
*red_list
;
2063 struct listnode
*node
;
2064 struct bgp_redist
*red
;
2066 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2067 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
2069 red_list
= bgp
->redist
[afi
][i
];
2073 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
2074 bgp_redistribute_resend(bgp
, afi
, i
,
2081 /* "bgp graceful-shutdown" configuration */
2082 DEFUN (bgp_graceful_shutdown
,
2083 bgp_graceful_shutdown_cmd
,
2084 "bgp graceful-shutdown",
2086 "Graceful shutdown parameters\n")
2088 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2090 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2091 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2092 bgp_static_redo_import_check(bgp
);
2093 bgp_redistribute_redo(bgp
);
2094 bgp_clear_star_soft_out(vty
, bgp
->name
);
2095 bgp_clear_star_soft_in(vty
, bgp
->name
);
2101 DEFUN (no_bgp_graceful_shutdown
,
2102 no_bgp_graceful_shutdown_cmd
,
2103 "no bgp graceful-shutdown",
2106 "Graceful shutdown parameters\n")
2108 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2110 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2111 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2112 bgp_static_redo_import_check(bgp
);
2113 bgp_redistribute_redo(bgp
);
2114 bgp_clear_star_soft_out(vty
, bgp
->name
);
2115 bgp_clear_star_soft_in(vty
, bgp
->name
);
2121 /* "bgp fast-external-failover" configuration. */
2122 DEFUN (bgp_fast_external_failover
,
2123 bgp_fast_external_failover_cmd
,
2124 "bgp fast-external-failover",
2126 "Immediately reset session if a link to a directly connected external peer goes down\n")
2128 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2129 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2133 DEFUN (no_bgp_fast_external_failover
,
2134 no_bgp_fast_external_failover_cmd
,
2135 "no bgp fast-external-failover",
2138 "Immediately reset session if a link to a directly connected external peer goes down\n")
2140 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2141 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2145 /* "bgp enforce-first-as" configuration. */
2146 #if CONFDATE > 20190517
2147 CPP_NOTICE("bgpd: remove deprecated '[no] bgp enforce-first-as' commands")
2150 DEFUN_HIDDEN (bgp_enforce_first_as
,
2151 bgp_enforce_first_as_cmd
,
2152 "[no] bgp enforce-first-as",
2155 "Enforce the first AS for EBGP routes\n")
2157 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2159 if (strmatch(argv
[0]->text
, "no"))
2160 bgp_flag_unset(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2162 bgp_flag_set(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2167 /* "bgp bestpath compare-routerid" configuration. */
2168 DEFUN (bgp_bestpath_compare_router_id
,
2169 bgp_bestpath_compare_router_id_cmd
,
2170 "bgp bestpath compare-routerid",
2171 "BGP specific commands\n"
2172 "Change the default bestpath selection\n"
2173 "Compare router-id for identical EBGP paths\n")
2175 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2176 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2177 bgp_recalculate_all_bestpaths(bgp
);
2182 DEFUN (no_bgp_bestpath_compare_router_id
,
2183 no_bgp_bestpath_compare_router_id_cmd
,
2184 "no bgp bestpath compare-routerid",
2186 "BGP specific commands\n"
2187 "Change the default bestpath selection\n"
2188 "Compare router-id for identical EBGP paths\n")
2190 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2191 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2192 bgp_recalculate_all_bestpaths(bgp
);
2197 /* "bgp bestpath as-path ignore" configuration. */
2198 DEFUN (bgp_bestpath_aspath_ignore
,
2199 bgp_bestpath_aspath_ignore_cmd
,
2200 "bgp bestpath as-path ignore",
2201 "BGP specific commands\n"
2202 "Change the default bestpath selection\n"
2203 "AS-path attribute\n"
2204 "Ignore as-path length in selecting a route\n")
2206 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2207 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2208 bgp_recalculate_all_bestpaths(bgp
);
2213 DEFUN (no_bgp_bestpath_aspath_ignore
,
2214 no_bgp_bestpath_aspath_ignore_cmd
,
2215 "no bgp bestpath as-path ignore",
2217 "BGP specific commands\n"
2218 "Change the default bestpath selection\n"
2219 "AS-path attribute\n"
2220 "Ignore as-path length in selecting a route\n")
2222 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2223 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2224 bgp_recalculate_all_bestpaths(bgp
);
2229 /* "bgp bestpath as-path confed" configuration. */
2230 DEFUN (bgp_bestpath_aspath_confed
,
2231 bgp_bestpath_aspath_confed_cmd
,
2232 "bgp bestpath as-path confed",
2233 "BGP specific commands\n"
2234 "Change the default bestpath selection\n"
2235 "AS-path attribute\n"
2236 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2238 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2239 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2240 bgp_recalculate_all_bestpaths(bgp
);
2245 DEFUN (no_bgp_bestpath_aspath_confed
,
2246 no_bgp_bestpath_aspath_confed_cmd
,
2247 "no bgp bestpath as-path confed",
2249 "BGP specific commands\n"
2250 "Change the default bestpath selection\n"
2251 "AS-path attribute\n"
2252 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2254 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2255 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2256 bgp_recalculate_all_bestpaths(bgp
);
2261 /* "bgp bestpath as-path multipath-relax" configuration. */
2262 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2263 bgp_bestpath_aspath_multipath_relax_cmd
,
2264 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2265 "BGP specific commands\n"
2266 "Change the default bestpath selection\n"
2267 "AS-path attribute\n"
2268 "Allow load sharing across routes that have different AS paths (but same length)\n"
2269 "Generate an AS_SET\n"
2270 "Do not generate an AS_SET\n")
2272 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2274 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2276 /* no-as-set is now the default behavior so we can silently
2278 if (argv_find(argv
, argc
, "as-set", &idx
))
2279 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2281 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2283 bgp_recalculate_all_bestpaths(bgp
);
2288 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2289 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2290 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2292 "BGP specific commands\n"
2293 "Change the default bestpath selection\n"
2294 "AS-path attribute\n"
2295 "Allow load sharing across routes that have different AS paths (but same length)\n"
2296 "Generate an AS_SET\n"
2297 "Do not generate an AS_SET\n")
2299 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2300 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2301 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2302 bgp_recalculate_all_bestpaths(bgp
);
2307 /* "bgp log-neighbor-changes" configuration. */
2308 DEFUN (bgp_log_neighbor_changes
,
2309 bgp_log_neighbor_changes_cmd
,
2310 "bgp log-neighbor-changes",
2311 "BGP specific commands\n"
2312 "Log neighbor up/down and reset reason\n")
2314 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2315 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2319 DEFUN (no_bgp_log_neighbor_changes
,
2320 no_bgp_log_neighbor_changes_cmd
,
2321 "no bgp log-neighbor-changes",
2323 "BGP specific commands\n"
2324 "Log neighbor up/down and reset reason\n")
2326 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2327 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2331 /* "bgp bestpath med" configuration. */
2332 DEFUN (bgp_bestpath_med
,
2333 bgp_bestpath_med_cmd
,
2334 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2335 "BGP specific commands\n"
2336 "Change the default bestpath selection\n"
2338 "Compare MED among confederation paths\n"
2339 "Treat missing MED as the least preferred one\n"
2340 "Treat missing MED as the least preferred one\n"
2341 "Compare MED among confederation paths\n")
2343 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2346 if (argv_find(argv
, argc
, "confed", &idx
))
2347 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2349 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2350 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2352 bgp_recalculate_all_bestpaths(bgp
);
2357 DEFUN (no_bgp_bestpath_med
,
2358 no_bgp_bestpath_med_cmd
,
2359 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2361 "BGP specific commands\n"
2362 "Change the default bestpath selection\n"
2364 "Compare MED among confederation paths\n"
2365 "Treat missing MED as the least preferred one\n"
2366 "Treat missing MED as the least preferred one\n"
2367 "Compare MED among confederation paths\n")
2369 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2372 if (argv_find(argv
, argc
, "confed", &idx
))
2373 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2375 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2376 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2378 bgp_recalculate_all_bestpaths(bgp
);
2383 /* "no bgp default ipv4-unicast". */
2384 DEFUN (no_bgp_default_ipv4_unicast
,
2385 no_bgp_default_ipv4_unicast_cmd
,
2386 "no bgp default ipv4-unicast",
2388 "BGP specific commands\n"
2389 "Configure BGP defaults\n"
2390 "Activate ipv4-unicast for a peer by default\n")
2392 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2393 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2397 DEFUN (bgp_default_ipv4_unicast
,
2398 bgp_default_ipv4_unicast_cmd
,
2399 "bgp default ipv4-unicast",
2400 "BGP specific commands\n"
2401 "Configure BGP defaults\n"
2402 "Activate ipv4-unicast for a peer by default\n")
2404 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2405 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2409 /* Display hostname in certain command outputs */
2410 DEFUN (bgp_default_show_hostname
,
2411 bgp_default_show_hostname_cmd
,
2412 "bgp default show-hostname",
2413 "BGP specific commands\n"
2414 "Configure BGP defaults\n"
2415 "Show hostname in certain command outputs\n")
2417 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2418 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2422 DEFUN (no_bgp_default_show_hostname
,
2423 no_bgp_default_show_hostname_cmd
,
2424 "no bgp default show-hostname",
2426 "BGP specific commands\n"
2427 "Configure BGP defaults\n"
2428 "Show hostname in certain command outputs\n")
2430 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2431 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2435 /* "bgp network import-check" configuration. */
2436 DEFUN (bgp_network_import_check
,
2437 bgp_network_import_check_cmd
,
2438 "bgp network import-check",
2439 "BGP specific commands\n"
2440 "BGP network command\n"
2441 "Check BGP network route exists in IGP\n")
2443 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2444 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2445 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2446 bgp_static_redo_import_check(bgp
);
2452 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2453 "bgp network import-check exact",
2454 "BGP specific commands\n"
2455 "BGP network command\n"
2456 "Check BGP network route exists in IGP\n"
2457 "Match route precisely\n")
2459 DEFUN (no_bgp_network_import_check
,
2460 no_bgp_network_import_check_cmd
,
2461 "no bgp network import-check",
2463 "BGP specific commands\n"
2464 "BGP network command\n"
2465 "Check BGP network route exists in IGP\n")
2467 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2468 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2469 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2470 bgp_static_redo_import_check(bgp
);
2476 DEFUN (bgp_default_local_preference
,
2477 bgp_default_local_preference_cmd
,
2478 "bgp default local-preference (0-4294967295)",
2479 "BGP specific commands\n"
2480 "Configure BGP defaults\n"
2481 "local preference (higher=more preferred)\n"
2482 "Configure default local preference value\n")
2484 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2486 uint32_t local_pref
;
2488 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2490 bgp_default_local_preference_set(bgp
, local_pref
);
2491 bgp_clear_star_soft_in(vty
, bgp
->name
);
2496 DEFUN (no_bgp_default_local_preference
,
2497 no_bgp_default_local_preference_cmd
,
2498 "no bgp default local-preference [(0-4294967295)]",
2500 "BGP specific commands\n"
2501 "Configure BGP defaults\n"
2502 "local preference (higher=more preferred)\n"
2503 "Configure default local preference value\n")
2505 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2506 bgp_default_local_preference_unset(bgp
);
2507 bgp_clear_star_soft_in(vty
, bgp
->name
);
2513 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2514 bgp_default_subgroup_pkt_queue_max_cmd
,
2515 "bgp default subgroup-pkt-queue-max (20-100)",
2516 "BGP specific commands\n"
2517 "Configure BGP defaults\n"
2518 "subgroup-pkt-queue-max\n"
2519 "Configure subgroup packet queue max\n")
2521 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2525 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2527 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2532 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2533 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2534 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2536 "BGP specific commands\n"
2537 "Configure BGP defaults\n"
2538 "subgroup-pkt-queue-max\n"
2539 "Configure subgroup packet queue max\n")
2541 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2542 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2547 DEFUN (bgp_rr_allow_outbound_policy
,
2548 bgp_rr_allow_outbound_policy_cmd
,
2549 "bgp route-reflector allow-outbound-policy",
2550 "BGP specific commands\n"
2551 "Allow modifications made by out route-map\n"
2552 "on ibgp neighbors\n")
2554 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2556 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2557 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2558 update_group_announce_rrclients(bgp
);
2559 bgp_clear_star_soft_out(vty
, bgp
->name
);
2565 DEFUN (no_bgp_rr_allow_outbound_policy
,
2566 no_bgp_rr_allow_outbound_policy_cmd
,
2567 "no bgp route-reflector allow-outbound-policy",
2569 "BGP specific commands\n"
2570 "Allow modifications made by out route-map\n"
2571 "on ibgp neighbors\n")
2573 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2575 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2576 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2577 update_group_announce_rrclients(bgp
);
2578 bgp_clear_star_soft_out(vty
, bgp
->name
);
2584 DEFUN (bgp_listen_limit
,
2585 bgp_listen_limit_cmd
,
2586 "bgp listen limit (1-5000)",
2587 "BGP specific commands\n"
2588 "Configure BGP defaults\n"
2589 "maximum number of BGP Dynamic Neighbors that can be created\n"
2590 "Configure Dynamic Neighbors listen limit value\n")
2592 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2596 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2598 bgp_listen_limit_set(bgp
, listen_limit
);
2603 DEFUN (no_bgp_listen_limit
,
2604 no_bgp_listen_limit_cmd
,
2605 "no bgp listen limit [(1-5000)]",
2606 "BGP specific commands\n"
2607 "Configure BGP defaults\n"
2608 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2609 "Configure Dynamic Neighbors listen limit value to default\n"
2610 "Configure Dynamic Neighbors listen limit value\n")
2612 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2613 bgp_listen_limit_unset(bgp
);
2619 * Check if this listen range is already configured. Check for exact
2620 * match or overlap based on input.
2622 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2623 struct prefix
*range
, int exact
)
2625 struct listnode
*node
, *nnode
;
2626 struct listnode
*node1
, *nnode1
;
2627 struct peer_group
*group
;
2632 afi
= family2afi(range
->family
);
2633 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2634 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2637 match
= prefix_same(range
, lr
);
2639 match
= (prefix_match(range
, lr
)
2640 || prefix_match(lr
, range
));
2649 DEFUN (bgp_listen_range
,
2650 bgp_listen_range_cmd
,
2651 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2652 "BGP specific commands\n"
2653 "Configure BGP dynamic neighbors listen range\n"
2654 "Configure BGP dynamic neighbors listen range\n"
2656 "Member of the peer-group\n"
2657 "Peer-group name\n")
2659 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2660 struct prefix range
;
2661 struct peer_group
*group
, *existing_group
;
2666 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2667 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2668 char *prefix
= argv
[idx
]->arg
;
2669 argv_find(argv
, argc
, "WORD", &idx
);
2670 char *peergroup
= argv
[idx
]->arg
;
2672 /* Convert IP prefix string to struct prefix. */
2673 ret
= str2prefix(prefix
, &range
);
2675 vty_out(vty
, "%% Malformed listen range\n");
2676 return CMD_WARNING_CONFIG_FAILED
;
2679 afi
= family2afi(range
.family
);
2681 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2683 "%% Malformed listen range (link-local address)\n");
2684 return CMD_WARNING_CONFIG_FAILED
;
2689 /* Check if same listen range is already configured. */
2690 existing_group
= listen_range_exists(bgp
, &range
, 1);
2691 if (existing_group
) {
2692 if (strcmp(existing_group
->name
, peergroup
) == 0)
2696 "%% Same listen range is attached to peer-group %s\n",
2697 existing_group
->name
);
2698 return CMD_WARNING_CONFIG_FAILED
;
2702 /* Check if an overlapping listen range exists. */
2703 if (listen_range_exists(bgp
, &range
, 0)) {
2705 "%% Listen range overlaps with existing listen range\n");
2706 return CMD_WARNING_CONFIG_FAILED
;
2709 group
= peer_group_lookup(bgp
, peergroup
);
2711 vty_out(vty
, "%% Configure the peer-group first\n");
2712 return CMD_WARNING_CONFIG_FAILED
;
2715 ret
= peer_group_listen_range_add(group
, &range
);
2716 return bgp_vty_return(vty
, ret
);
2719 DEFUN (no_bgp_listen_range
,
2720 no_bgp_listen_range_cmd
,
2721 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2723 "BGP specific commands\n"
2724 "Unconfigure BGP dynamic neighbors listen range\n"
2725 "Unconfigure BGP dynamic neighbors listen range\n"
2727 "Member of the peer-group\n"
2728 "Peer-group name\n")
2730 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2731 struct prefix range
;
2732 struct peer_group
*group
;
2737 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2738 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2739 char *prefix
= argv
[idx
]->arg
;
2740 argv_find(argv
, argc
, "WORD", &idx
);
2741 char *peergroup
= argv
[idx
]->arg
;
2743 /* Convert IP prefix string to struct prefix. */
2744 ret
= str2prefix(prefix
, &range
);
2746 vty_out(vty
, "%% Malformed listen range\n");
2747 return CMD_WARNING_CONFIG_FAILED
;
2750 afi
= family2afi(range
.family
);
2752 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2754 "%% Malformed listen range (link-local address)\n");
2755 return CMD_WARNING_CONFIG_FAILED
;
2760 group
= peer_group_lookup(bgp
, peergroup
);
2762 vty_out(vty
, "%% Peer-group does not exist\n");
2763 return CMD_WARNING_CONFIG_FAILED
;
2766 ret
= peer_group_listen_range_del(group
, &range
);
2767 return bgp_vty_return(vty
, ret
);
2770 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2772 struct peer_group
*group
;
2773 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2774 struct prefix
*range
;
2776 char buf
[PREFIX2STR_BUFFER
];
2778 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2779 vty_out(vty
, " bgp listen limit %d\n",
2780 bgp
->dynamic_neighbors_limit
);
2782 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2783 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2784 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2786 prefix2str(range
, buf
, sizeof(buf
));
2788 " bgp listen range %s peer-group %s\n",
2796 DEFUN (bgp_disable_connected_route_check
,
2797 bgp_disable_connected_route_check_cmd
,
2798 "bgp disable-ebgp-connected-route-check",
2799 "BGP specific commands\n"
2800 "Disable checking if nexthop is connected on ebgp sessions\n")
2802 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2803 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2804 bgp_clear_star_soft_in(vty
, bgp
->name
);
2809 DEFUN (no_bgp_disable_connected_route_check
,
2810 no_bgp_disable_connected_route_check_cmd
,
2811 "no bgp disable-ebgp-connected-route-check",
2813 "BGP specific commands\n"
2814 "Disable checking if nexthop is connected on ebgp sessions\n")
2816 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2817 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2818 bgp_clear_star_soft_in(vty
, bgp
->name
);
2824 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2825 const char *as_str
, afi_t afi
, safi_t safi
)
2827 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2830 int as_type
= AS_SPECIFIED
;
2833 if (as_str
[0] == 'i') {
2835 as_type
= AS_INTERNAL
;
2836 } else if (as_str
[0] == 'e') {
2838 as_type
= AS_EXTERNAL
;
2840 /* Get AS number. */
2841 as
= strtoul(as_str
, NULL
, 10);
2844 /* If peer is peer group or interface peer, call proper function. */
2845 ret
= str2sockunion(peer_str
, &su
);
2849 /* Check if existing interface peer */
2850 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
2852 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2855 /* if not interface peer, check peer-group settings */
2856 if (ret
< 0 && !peer
) {
2857 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2860 "%% Create the peer-group or interface first\n");
2861 return CMD_WARNING_CONFIG_FAILED
;
2866 if (peer_address_self_check(bgp
, &su
)) {
2868 "%% Can not configure the local system as neighbor\n");
2869 return CMD_WARNING_CONFIG_FAILED
;
2871 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2874 /* This peer belongs to peer group. */
2876 case BGP_ERR_PEER_GROUP_MEMBER
:
2878 "%% Peer-group member cannot override remote-as of peer-group\n");
2879 return CMD_WARNING_CONFIG_FAILED
;
2880 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2882 "%% Peer-group members must be all internal or all external\n");
2883 return CMD_WARNING_CONFIG_FAILED
;
2885 return bgp_vty_return(vty
, ret
);
2888 DEFUN (bgp_default_shutdown
,
2889 bgp_default_shutdown_cmd
,
2890 "[no] bgp default shutdown",
2893 "Configure BGP defaults\n"
2894 "Apply administrative shutdown to newly configured peers\n")
2896 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2897 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2901 DEFUN (neighbor_remote_as
,
2902 neighbor_remote_as_cmd
,
2903 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2906 "Specify a BGP neighbor\n"
2908 "Internal BGP peer\n"
2909 "External BGP peer\n")
2912 int idx_remote_as
= 3;
2913 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2914 argv
[idx_remote_as
]->arg
, AFI_IP
,
2918 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2919 afi_t afi
, safi_t safi
, int v6only
,
2920 const char *peer_group_name
,
2923 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2925 int as_type
= AS_UNSPECIFIED
;
2927 struct peer_group
*group
;
2931 group
= peer_group_lookup(bgp
, conf_if
);
2934 vty_out(vty
, "%% Name conflict with peer-group \n");
2935 return CMD_WARNING_CONFIG_FAILED
;
2939 if (as_str
[0] == 'i') {
2940 as_type
= AS_INTERNAL
;
2941 } else if (as_str
[0] == 'e') {
2942 as_type
= AS_EXTERNAL
;
2944 /* Get AS number. */
2945 as
= strtoul(as_str
, NULL
, 10);
2946 as_type
= AS_SPECIFIED
;
2950 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2953 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
2956 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2957 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2958 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2959 as_type
, 0, 0, NULL
);
2961 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2962 as_type
, afi
, safi
, NULL
);
2965 vty_out(vty
, "%% BGP failed to create peer\n");
2966 return CMD_WARNING_CONFIG_FAILED
;
2970 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2972 /* Request zebra to initiate IPv6 RAs on this interface. We do
2974 * any unnumbered peer in order to not worry about run-time
2976 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2978 * gets deleted later etc.)
2981 bgp_zebra_initiate_radv(bgp
, peer
);
2984 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2985 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2987 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2989 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2991 /* v6only flag changed. Reset bgp seesion */
2992 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2993 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2994 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2995 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2997 bgp_session_reset(peer
);
3000 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
3001 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
3002 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
3003 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
3006 if (peer_group_name
) {
3007 group
= peer_group_lookup(bgp
, peer_group_name
);
3009 vty_out(vty
, "%% Configure the peer-group first\n");
3010 return CMD_WARNING_CONFIG_FAILED
;
3013 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3016 return bgp_vty_return(vty
, ret
);
3019 DEFUN (neighbor_interface_config
,
3020 neighbor_interface_config_cmd
,
3021 "neighbor WORD interface [peer-group WORD]",
3023 "Interface name or neighbor tag\n"
3024 "Enable BGP on interface\n"
3025 "Member of the peer-group\n"
3026 "Peer-group name\n")
3029 int idx_peer_group_word
= 4;
3031 if (argc
> idx_peer_group_word
)
3032 return peer_conf_interface_get(
3033 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
3034 argv
[idx_peer_group_word
]->arg
, NULL
);
3036 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3037 SAFI_UNICAST
, 0, NULL
, NULL
);
3040 DEFUN (neighbor_interface_config_v6only
,
3041 neighbor_interface_config_v6only_cmd
,
3042 "neighbor WORD interface v6only [peer-group WORD]",
3044 "Interface name or neighbor tag\n"
3045 "Enable BGP on interface\n"
3046 "Enable BGP with v6 link-local only\n"
3047 "Member of the peer-group\n"
3048 "Peer-group name\n")
3051 int idx_peer_group_word
= 5;
3053 if (argc
> idx_peer_group_word
)
3054 return peer_conf_interface_get(
3055 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
3056 argv
[idx_peer_group_word
]->arg
, NULL
);
3058 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3059 SAFI_UNICAST
, 1, NULL
, NULL
);
3063 DEFUN (neighbor_interface_config_remote_as
,
3064 neighbor_interface_config_remote_as_cmd
,
3065 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
3067 "Interface name or neighbor tag\n"
3068 "Enable BGP on interface\n"
3069 "Specify a BGP neighbor\n"
3071 "Internal BGP peer\n"
3072 "External BGP peer\n")
3075 int idx_remote_as
= 4;
3076 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3077 SAFI_UNICAST
, 0, NULL
,
3078 argv
[idx_remote_as
]->arg
);
3081 DEFUN (neighbor_interface_v6only_config_remote_as
,
3082 neighbor_interface_v6only_config_remote_as_cmd
,
3083 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
3085 "Interface name or neighbor tag\n"
3086 "Enable BGP with v6 link-local only\n"
3087 "Enable BGP on interface\n"
3088 "Specify a BGP neighbor\n"
3090 "Internal BGP peer\n"
3091 "External BGP peer\n")
3094 int idx_remote_as
= 5;
3095 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3096 SAFI_UNICAST
, 1, NULL
,
3097 argv
[idx_remote_as
]->arg
);
3100 DEFUN (neighbor_peer_group
,
3101 neighbor_peer_group_cmd
,
3102 "neighbor WORD peer-group",
3104 "Interface name or neighbor tag\n"
3105 "Configure peer-group\n")
3107 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3110 struct peer_group
*group
;
3112 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3114 vty_out(vty
, "%% Name conflict with interface: \n");
3115 return CMD_WARNING_CONFIG_FAILED
;
3118 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
3120 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
3121 return CMD_WARNING_CONFIG_FAILED
;
3129 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3133 "Specify a BGP neighbor\n"
3135 "Internal BGP peer\n"
3136 "External BGP peer\n")
3138 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3142 struct peer_group
*group
;
3146 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3148 /* look up for neighbor by interface name config. */
3149 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3151 /* Request zebra to terminate IPv6 RAs on this
3154 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3159 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3161 peer_group_delete(group
);
3163 vty_out(vty
, "%% Create the peer-group first\n");
3164 return CMD_WARNING_CONFIG_FAILED
;
3167 peer
= peer_lookup(bgp
, &su
);
3169 if (peer_dynamic_neighbor(peer
)) {
3171 "%% Operation not allowed on a dynamic neighbor\n");
3172 return CMD_WARNING_CONFIG_FAILED
;
3175 other
= peer
->doppelganger
;
3177 if (other
&& other
->status
!= Deleted
)
3185 DEFUN (no_neighbor_interface_config
,
3186 no_neighbor_interface_config_cmd
,
3187 "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]",
3191 "Configure BGP on interface\n"
3192 "Enable BGP with v6 link-local only\n"
3193 "Member of the peer-group\n"
3195 "Specify a BGP neighbor\n"
3197 "Internal BGP peer\n"
3198 "External BGP peer\n")
3200 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3204 /* look up for neighbor by interface name config. */
3205 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3207 /* Request zebra to terminate IPv6 RAs on this interface. */
3209 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3212 vty_out(vty
, "%% Create the bgp interface first\n");
3213 return CMD_WARNING_CONFIG_FAILED
;
3218 DEFUN (no_neighbor_peer_group
,
3219 no_neighbor_peer_group_cmd
,
3220 "no neighbor WORD peer-group",
3224 "Configure peer-group\n")
3226 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3228 struct peer_group
*group
;
3230 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3232 peer_group_delete(group
);
3234 vty_out(vty
, "%% Create the peer-group first\n");
3235 return CMD_WARNING_CONFIG_FAILED
;
3240 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3241 no_neighbor_interface_peer_group_remote_as_cmd
,
3242 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3245 "Interface name or neighbor tag\n"
3246 "Specify a BGP neighbor\n"
3248 "Internal BGP peer\n"
3249 "External BGP peer\n")
3251 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3253 struct peer_group
*group
;
3256 /* look up for neighbor by interface name config. */
3257 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3259 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
3263 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3265 peer_group_remote_as_delete(group
);
3267 vty_out(vty
, "%% Create the peer-group or interface first\n");
3268 return CMD_WARNING_CONFIG_FAILED
;
3273 DEFUN (neighbor_local_as
,
3274 neighbor_local_as_cmd
,
3275 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3278 "Specify a local-as number\n"
3279 "AS number used as local AS\n")
3287 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3289 return CMD_WARNING_CONFIG_FAILED
;
3291 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3292 ret
= peer_local_as_set(peer
, as
, 0, 0);
3293 return bgp_vty_return(vty
, ret
);
3296 DEFUN (neighbor_local_as_no_prepend
,
3297 neighbor_local_as_no_prepend_cmd
,
3298 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3301 "Specify a local-as number\n"
3302 "AS number used as local AS\n"
3303 "Do not prepend local-as to updates from ebgp peers\n")
3311 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3313 return CMD_WARNING_CONFIG_FAILED
;
3315 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3316 ret
= peer_local_as_set(peer
, as
, 1, 0);
3317 return bgp_vty_return(vty
, ret
);
3320 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3321 neighbor_local_as_no_prepend_replace_as_cmd
,
3322 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3325 "Specify a local-as number\n"
3326 "AS number used as local AS\n"
3327 "Do not prepend local-as to updates from ebgp peers\n"
3328 "Do not prepend local-as to updates from ibgp peers\n")
3336 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3338 return CMD_WARNING_CONFIG_FAILED
;
3340 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3341 ret
= peer_local_as_set(peer
, as
, 1, 1);
3342 return bgp_vty_return(vty
, ret
);
3345 DEFUN (no_neighbor_local_as
,
3346 no_neighbor_local_as_cmd
,
3347 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3351 "Specify a local-as number\n"
3352 "AS number used as local AS\n"
3353 "Do not prepend local-as to updates from ebgp peers\n"
3354 "Do not prepend local-as to updates from ibgp peers\n")
3360 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3362 return CMD_WARNING_CONFIG_FAILED
;
3364 ret
= peer_local_as_unset(peer
);
3365 return bgp_vty_return(vty
, ret
);
3369 DEFUN (neighbor_solo
,
3371 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3374 "Solo peer - part of its own update group\n")
3380 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3382 return CMD_WARNING_CONFIG_FAILED
;
3384 ret
= update_group_adjust_soloness(peer
, 1);
3385 return bgp_vty_return(vty
, ret
);
3388 DEFUN (no_neighbor_solo
,
3389 no_neighbor_solo_cmd
,
3390 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3394 "Solo peer - part of its own update group\n")
3400 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3402 return CMD_WARNING_CONFIG_FAILED
;
3404 ret
= update_group_adjust_soloness(peer
, 0);
3405 return bgp_vty_return(vty
, ret
);
3408 DEFUN (neighbor_password
,
3409 neighbor_password_cmd
,
3410 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3421 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3423 return CMD_WARNING_CONFIG_FAILED
;
3425 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3426 return bgp_vty_return(vty
, ret
);
3429 DEFUN (no_neighbor_password
,
3430 no_neighbor_password_cmd
,
3431 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3442 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3444 return CMD_WARNING_CONFIG_FAILED
;
3446 ret
= peer_password_unset(peer
);
3447 return bgp_vty_return(vty
, ret
);
3450 DEFUN (neighbor_activate
,
3451 neighbor_activate_cmd
,
3452 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3455 "Enable the Address Family for this Neighbor\n")
3461 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3463 return CMD_WARNING_CONFIG_FAILED
;
3465 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3466 return bgp_vty_return(vty
, ret
);
3469 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3470 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3471 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3472 "Enable the Address Family for this Neighbor\n")
3474 DEFUN (no_neighbor_activate
,
3475 no_neighbor_activate_cmd
,
3476 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3480 "Enable the Address Family for this Neighbor\n")
3487 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3489 return CMD_WARNING_CONFIG_FAILED
;
3491 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3492 return bgp_vty_return(vty
, ret
);
3495 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3496 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3497 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3498 "Enable the Address Family for this Neighbor\n")
3500 DEFUN (neighbor_set_peer_group
,
3501 neighbor_set_peer_group_cmd
,
3502 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3505 "Member of the peer-group\n"
3506 "Peer-group name\n")
3508 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3515 struct peer_group
*group
;
3517 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3519 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3521 vty_out(vty
, "%% Malformed address or name: %s\n",
3522 argv
[idx_peer
]->arg
);
3523 return CMD_WARNING_CONFIG_FAILED
;
3526 if (peer_address_self_check(bgp
, &su
)) {
3528 "%% Can not configure the local system as neighbor\n");
3529 return CMD_WARNING_CONFIG_FAILED
;
3532 /* Disallow for dynamic neighbor. */
3533 peer
= peer_lookup(bgp
, &su
);
3534 if (peer
&& peer_dynamic_neighbor(peer
)) {
3536 "%% Operation not allowed on a dynamic neighbor\n");
3537 return CMD_WARNING_CONFIG_FAILED
;
3541 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3543 vty_out(vty
, "%% Configure the peer-group first\n");
3544 return CMD_WARNING_CONFIG_FAILED
;
3547 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3549 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3551 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3553 return CMD_WARNING_CONFIG_FAILED
;
3556 return bgp_vty_return(vty
, ret
);
3559 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3560 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3561 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3562 "Member of the peer-group\n"
3563 "Peer-group name\n")
3565 DEFUN (no_neighbor_set_peer_group
,
3566 no_neighbor_set_peer_group_cmd
,
3567 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3571 "Member of the peer-group\n"
3572 "Peer-group name\n")
3574 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3579 struct peer_group
*group
;
3581 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3583 return CMD_WARNING_CONFIG_FAILED
;
3585 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3587 vty_out(vty
, "%% Configure the peer-group first\n");
3588 return CMD_WARNING_CONFIG_FAILED
;
3591 ret
= peer_delete(peer
);
3593 return bgp_vty_return(vty
, ret
);
3596 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3597 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3598 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3599 "Member of the peer-group\n"
3600 "Peer-group name\n")
3602 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3603 uint32_t flag
, int set
)
3608 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3610 return CMD_WARNING_CONFIG_FAILED
;
3613 * If 'neighbor <interface>', then this is for directly connected peers,
3614 * we should not accept disable-connected-check.
3616 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3618 "%s is directly connected peer, cannot accept disable-"
3619 "connected-check\n",
3621 return CMD_WARNING_CONFIG_FAILED
;
3624 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3625 peer_tx_shutdown_message_unset(peer
);
3628 ret
= peer_flag_set(peer
, flag
);
3630 ret
= peer_flag_unset(peer
, flag
);
3632 return bgp_vty_return(vty
, ret
);
3635 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3637 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3640 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3643 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3646 /* neighbor passive. */
3647 DEFUN (neighbor_passive
,
3648 neighbor_passive_cmd
,
3649 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3652 "Don't send open messages to this neighbor\n")
3655 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3658 DEFUN (no_neighbor_passive
,
3659 no_neighbor_passive_cmd
,
3660 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3664 "Don't send open messages to this neighbor\n")
3667 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3670 /* neighbor shutdown. */
3671 DEFUN (neighbor_shutdown_msg
,
3672 neighbor_shutdown_msg_cmd
,
3673 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3676 "Administratively shut down this neighbor\n"
3677 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3678 "Shutdown message\n")
3684 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3688 return CMD_WARNING_CONFIG_FAILED
;
3689 message
= argv_concat(argv
, argc
, 4);
3690 peer_tx_shutdown_message_set(peer
, message
);
3691 XFREE(MTYPE_TMP
, message
);
3694 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3697 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3698 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3699 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3700 "Administratively shut down this neighbor\n")
3702 DEFUN (no_neighbor_shutdown_msg
,
3703 no_neighbor_shutdown_msg_cmd
,
3704 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3708 "Administratively shut down this neighbor\n"
3709 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3710 "Shutdown message\n")
3714 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3715 PEER_FLAG_SHUTDOWN
);
3718 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3719 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3720 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3721 "Administratively shut down this neighbor\n")
3723 /* neighbor capability dynamic. */
3724 DEFUN (neighbor_capability_dynamic
,
3725 neighbor_capability_dynamic_cmd
,
3726 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3729 "Advertise capability to the peer\n"
3730 "Advertise dynamic capability to this neighbor\n")
3733 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3734 PEER_FLAG_DYNAMIC_CAPABILITY
);
3737 DEFUN (no_neighbor_capability_dynamic
,
3738 no_neighbor_capability_dynamic_cmd
,
3739 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3743 "Advertise capability to the peer\n"
3744 "Advertise dynamic capability to this neighbor\n")
3747 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3748 PEER_FLAG_DYNAMIC_CAPABILITY
);
3751 /* neighbor dont-capability-negotiate */
3752 DEFUN (neighbor_dont_capability_negotiate
,
3753 neighbor_dont_capability_negotiate_cmd
,
3754 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3757 "Do not perform capability negotiation\n")
3760 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3761 PEER_FLAG_DONT_CAPABILITY
);
3764 DEFUN (no_neighbor_dont_capability_negotiate
,
3765 no_neighbor_dont_capability_negotiate_cmd
,
3766 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3770 "Do not perform capability negotiation\n")
3773 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3774 PEER_FLAG_DONT_CAPABILITY
);
3777 /* neighbor capability extended next hop encoding */
3778 DEFUN (neighbor_capability_enhe
,
3779 neighbor_capability_enhe_cmd
,
3780 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3783 "Advertise capability to the peer\n"
3784 "Advertise extended next-hop capability to the peer\n")
3787 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3788 PEER_FLAG_CAPABILITY_ENHE
);
3791 DEFUN (no_neighbor_capability_enhe
,
3792 no_neighbor_capability_enhe_cmd
,
3793 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3797 "Advertise capability to the peer\n"
3798 "Advertise extended next-hop capability to the peer\n")
3801 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3802 PEER_FLAG_CAPABILITY_ENHE
);
3805 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3806 afi_t afi
, safi_t safi
, uint32_t flag
,
3812 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3814 return CMD_WARNING_CONFIG_FAILED
;
3817 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3819 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3821 return bgp_vty_return(vty
, ret
);
3824 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3825 afi_t afi
, safi_t safi
, uint32_t flag
)
3827 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3830 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3831 afi_t afi
, safi_t safi
, uint32_t flag
)
3833 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3836 /* neighbor capability orf prefix-list. */
3837 DEFUN (neighbor_capability_orf_prefix
,
3838 neighbor_capability_orf_prefix_cmd
,
3839 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3842 "Advertise capability to the peer\n"
3843 "Advertise ORF capability to the peer\n"
3844 "Advertise prefixlist ORF capability to this neighbor\n"
3845 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3846 "Capability to RECEIVE the ORF from this neighbor\n"
3847 "Capability to SEND the ORF to this neighbor\n")
3850 int idx_send_recv
= 5;
3853 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3854 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3855 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3856 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3857 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3858 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3860 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3861 return CMD_WARNING_CONFIG_FAILED
;
3864 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3865 bgp_node_safi(vty
), flag
);
3869 neighbor_capability_orf_prefix
,
3870 neighbor_capability_orf_prefix_hidden_cmd
,
3871 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3872 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3873 "Advertise capability to the peer\n"
3874 "Advertise ORF capability to the peer\n"
3875 "Advertise prefixlist ORF capability to this neighbor\n"
3876 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3877 "Capability to RECEIVE the ORF from this neighbor\n"
3878 "Capability to SEND the ORF to this neighbor\n")
3880 DEFUN (no_neighbor_capability_orf_prefix
,
3881 no_neighbor_capability_orf_prefix_cmd
,
3882 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3886 "Advertise capability to the peer\n"
3887 "Advertise ORF capability to the peer\n"
3888 "Advertise prefixlist ORF capability to this neighbor\n"
3889 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3890 "Capability to RECEIVE the ORF from this neighbor\n"
3891 "Capability to SEND the ORF to this neighbor\n")
3894 int idx_send_recv
= 6;
3897 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3898 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3899 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3900 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3901 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3902 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3904 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3905 return CMD_WARNING_CONFIG_FAILED
;
3908 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3909 bgp_node_afi(vty
), bgp_node_safi(vty
),
3914 no_neighbor_capability_orf_prefix
,
3915 no_neighbor_capability_orf_prefix_hidden_cmd
,
3916 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3917 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3918 "Advertise capability to the peer\n"
3919 "Advertise ORF capability to the peer\n"
3920 "Advertise prefixlist ORF capability to this neighbor\n"
3921 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3922 "Capability to RECEIVE the ORF from this neighbor\n"
3923 "Capability to SEND the ORF to this neighbor\n")
3925 /* neighbor next-hop-self. */
3926 DEFUN (neighbor_nexthop_self
,
3927 neighbor_nexthop_self_cmd
,
3928 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3931 "Disable the next hop calculation for this neighbor\n")
3934 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3935 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3938 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3939 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3940 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3941 "Disable the next hop calculation for this neighbor\n")
3943 /* neighbor next-hop-self. */
3944 DEFUN (neighbor_nexthop_self_force
,
3945 neighbor_nexthop_self_force_cmd
,
3946 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3949 "Disable the next hop calculation for this neighbor\n"
3950 "Set the next hop to self for reflected routes\n")
3953 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3955 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3958 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3959 neighbor_nexthop_self_force_hidden_cmd
,
3960 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3961 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3962 "Disable the next hop calculation for this neighbor\n"
3963 "Set the next hop to self for reflected routes\n")
3965 DEFUN (no_neighbor_nexthop_self
,
3966 no_neighbor_nexthop_self_cmd
,
3967 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3971 "Disable the next hop calculation for this neighbor\n")
3974 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3975 bgp_node_afi(vty
), bgp_node_safi(vty
),
3976 PEER_FLAG_NEXTHOP_SELF
);
3979 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3980 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3981 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3982 "Disable the next hop calculation for this neighbor\n")
3984 DEFUN (no_neighbor_nexthop_self_force
,
3985 no_neighbor_nexthop_self_force_cmd
,
3986 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3990 "Disable the next hop calculation for this neighbor\n"
3991 "Set the next hop to self for reflected routes\n")
3994 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3995 bgp_node_afi(vty
), bgp_node_safi(vty
),
3996 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3999 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4000 no_neighbor_nexthop_self_force_hidden_cmd
,
4001 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4002 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4003 "Disable the next hop calculation for this neighbor\n"
4004 "Set the next hop to self for reflected routes\n")
4006 /* neighbor as-override */
4007 DEFUN (neighbor_as_override
,
4008 neighbor_as_override_cmd
,
4009 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4012 "Override ASNs in outbound updates if aspath equals remote-as\n")
4015 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4016 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
4019 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
4020 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4021 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4022 "Override ASNs in outbound updates if aspath equals remote-as\n")
4024 DEFUN (no_neighbor_as_override
,
4025 no_neighbor_as_override_cmd
,
4026 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4030 "Override ASNs in outbound updates if aspath equals remote-as\n")
4033 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4034 bgp_node_afi(vty
), bgp_node_safi(vty
),
4035 PEER_FLAG_AS_OVERRIDE
);
4038 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
4039 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4040 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4041 "Override ASNs in outbound updates if aspath equals remote-as\n")
4043 /* neighbor remove-private-AS. */
4044 DEFUN (neighbor_remove_private_as
,
4045 neighbor_remove_private_as_cmd
,
4046 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4049 "Remove private ASNs in outbound updates\n")
4052 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4054 PEER_FLAG_REMOVE_PRIVATE_AS
);
4057 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
4058 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4059 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4060 "Remove private ASNs in outbound updates\n")
4062 DEFUN (neighbor_remove_private_as_all
,
4063 neighbor_remove_private_as_all_cmd
,
4064 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4067 "Remove private ASNs in outbound updates\n"
4068 "Apply to all AS numbers\n")
4071 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4073 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4076 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
4077 neighbor_remove_private_as_all_hidden_cmd
,
4078 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4079 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4080 "Remove private ASNs in outbound updates\n"
4081 "Apply to all AS numbers")
4083 DEFUN (neighbor_remove_private_as_replace_as
,
4084 neighbor_remove_private_as_replace_as_cmd
,
4085 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4088 "Remove private ASNs in outbound updates\n"
4089 "Replace private ASNs with our ASN in outbound updates\n")
4092 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4094 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4097 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
4098 neighbor_remove_private_as_replace_as_hidden_cmd
,
4099 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4100 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4101 "Remove private ASNs in outbound updates\n"
4102 "Replace private ASNs with our ASN in outbound updates\n")
4104 DEFUN (neighbor_remove_private_as_all_replace_as
,
4105 neighbor_remove_private_as_all_replace_as_cmd
,
4106 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4109 "Remove private ASNs in outbound updates\n"
4110 "Apply to all AS numbers\n"
4111 "Replace private ASNs with our ASN in outbound updates\n")
4114 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4116 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4120 neighbor_remove_private_as_all_replace_as
,
4121 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4122 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4123 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4124 "Remove private ASNs in outbound updates\n"
4125 "Apply to all AS numbers\n"
4126 "Replace private ASNs with our ASN in outbound updates\n")
4128 DEFUN (no_neighbor_remove_private_as
,
4129 no_neighbor_remove_private_as_cmd
,
4130 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4134 "Remove private ASNs in outbound updates\n")
4137 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4138 bgp_node_afi(vty
), bgp_node_safi(vty
),
4139 PEER_FLAG_REMOVE_PRIVATE_AS
);
4142 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4143 no_neighbor_remove_private_as_hidden_cmd
,
4144 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4145 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4146 "Remove private ASNs in outbound updates\n")
4148 DEFUN (no_neighbor_remove_private_as_all
,
4149 no_neighbor_remove_private_as_all_cmd
,
4150 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4154 "Remove private ASNs in outbound updates\n"
4155 "Apply to all AS numbers\n")
4158 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4159 bgp_node_afi(vty
), bgp_node_safi(vty
),
4160 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4163 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4164 no_neighbor_remove_private_as_all_hidden_cmd
,
4165 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4166 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4167 "Remove private ASNs in outbound updates\n"
4168 "Apply to all AS numbers\n")
4170 DEFUN (no_neighbor_remove_private_as_replace_as
,
4171 no_neighbor_remove_private_as_replace_as_cmd
,
4172 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4176 "Remove private ASNs in outbound updates\n"
4177 "Replace private ASNs with our ASN in outbound updates\n")
4180 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4181 bgp_node_afi(vty
), bgp_node_safi(vty
),
4182 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4185 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4186 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4187 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4188 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4189 "Remove private ASNs in outbound updates\n"
4190 "Replace private ASNs with our ASN in outbound updates\n")
4192 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4193 no_neighbor_remove_private_as_all_replace_as_cmd
,
4194 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4198 "Remove private ASNs in outbound updates\n"
4199 "Apply to all AS numbers\n"
4200 "Replace private ASNs with our ASN in outbound updates\n")
4203 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4204 bgp_node_afi(vty
), bgp_node_safi(vty
),
4205 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4209 no_neighbor_remove_private_as_all_replace_as
,
4210 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4211 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4212 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4213 "Remove private ASNs in outbound updates\n"
4214 "Apply to all AS numbers\n"
4215 "Replace private ASNs with our ASN in outbound updates\n")
4218 /* neighbor send-community. */
4219 DEFUN (neighbor_send_community
,
4220 neighbor_send_community_cmd
,
4221 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4224 "Send Community attribute to this neighbor\n")
4228 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4230 PEER_FLAG_SEND_COMMUNITY
);
4233 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4234 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4235 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4236 "Send Community attribute to this neighbor\n")
4238 DEFUN (no_neighbor_send_community
,
4239 no_neighbor_send_community_cmd
,
4240 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4244 "Send Community attribute to this neighbor\n")
4248 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4249 bgp_node_afi(vty
), bgp_node_safi(vty
),
4250 PEER_FLAG_SEND_COMMUNITY
);
4253 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4254 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4255 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4256 "Send Community attribute to this neighbor\n")
4258 /* neighbor send-community extended. */
4259 DEFUN (neighbor_send_community_type
,
4260 neighbor_send_community_type_cmd
,
4261 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4264 "Send Community attribute to this neighbor\n"
4265 "Send Standard and Extended Community attributes\n"
4266 "Send Standard, Large and Extended Community attributes\n"
4267 "Send Extended Community attributes\n"
4268 "Send Standard Community attributes\n"
4269 "Send Large Community attributes\n")
4273 const char *type
= argv
[argc
- 1]->text
;
4275 if (strmatch(type
, "standard")) {
4276 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4277 } else if (strmatch(type
, "extended")) {
4278 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4279 } else if (strmatch(type
, "large")) {
4280 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4281 } else if (strmatch(type
, "both")) {
4282 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4283 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4284 } else { /* if (strmatch(type, "all")) */
4285 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4286 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4287 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4290 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4291 bgp_node_safi(vty
), flag
);
4295 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4296 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4297 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4298 "Send Community attribute to this neighbor\n"
4299 "Send Standard and Extended Community attributes\n"
4300 "Send Standard, Large and Extended Community attributes\n"
4301 "Send Extended Community attributes\n"
4302 "Send Standard Community attributes\n"
4303 "Send Large Community attributes\n")
4305 DEFUN (no_neighbor_send_community_type
,
4306 no_neighbor_send_community_type_cmd
,
4307 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4311 "Send Community attribute to this neighbor\n"
4312 "Send Standard and Extended Community attributes\n"
4313 "Send Standard, Large and Extended Community attributes\n"
4314 "Send Extended Community attributes\n"
4315 "Send Standard Community attributes\n"
4316 "Send Large Community attributes\n")
4320 const char *type
= argv
[argc
- 1]->text
;
4322 if (strmatch(type
, "standard")) {
4323 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4324 } else if (strmatch(type
, "extended")) {
4325 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4326 } else if (strmatch(type
, "large")) {
4327 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4328 } else if (strmatch(type
, "both")) {
4329 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4330 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4331 } else { /* if (strmatch(type, "all")) */
4332 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4333 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4334 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4337 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4338 bgp_node_afi(vty
), bgp_node_safi(vty
),
4343 no_neighbor_send_community_type
,
4344 no_neighbor_send_community_type_hidden_cmd
,
4345 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4346 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4347 "Send Community attribute to this neighbor\n"
4348 "Send Standard and Extended Community attributes\n"
4349 "Send Standard, Large and Extended Community attributes\n"
4350 "Send Extended Community attributes\n"
4351 "Send Standard Community attributes\n"
4352 "Send Large Community attributes\n")
4354 /* neighbor soft-reconfig. */
4355 DEFUN (neighbor_soft_reconfiguration
,
4356 neighbor_soft_reconfiguration_cmd
,
4357 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4360 "Per neighbor soft reconfiguration\n"
4361 "Allow inbound soft reconfiguration for this neighbor\n")
4364 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4366 PEER_FLAG_SOFT_RECONFIG
);
4369 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4370 neighbor_soft_reconfiguration_hidden_cmd
,
4371 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4372 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4373 "Per neighbor soft reconfiguration\n"
4374 "Allow inbound soft reconfiguration for this neighbor\n")
4376 DEFUN (no_neighbor_soft_reconfiguration
,
4377 no_neighbor_soft_reconfiguration_cmd
,
4378 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4382 "Per neighbor soft reconfiguration\n"
4383 "Allow inbound soft reconfiguration for this neighbor\n")
4386 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4387 bgp_node_afi(vty
), bgp_node_safi(vty
),
4388 PEER_FLAG_SOFT_RECONFIG
);
4391 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4392 no_neighbor_soft_reconfiguration_hidden_cmd
,
4393 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4394 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4395 "Per neighbor soft reconfiguration\n"
4396 "Allow inbound soft reconfiguration for this neighbor\n")
4398 DEFUN (neighbor_route_reflector_client
,
4399 neighbor_route_reflector_client_cmd
,
4400 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4403 "Configure a neighbor as Route Reflector client\n")
4409 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4411 return CMD_WARNING_CONFIG_FAILED
;
4413 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4415 PEER_FLAG_REFLECTOR_CLIENT
);
4418 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4419 neighbor_route_reflector_client_hidden_cmd
,
4420 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4421 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4422 "Configure a neighbor as Route Reflector client\n")
4424 DEFUN (no_neighbor_route_reflector_client
,
4425 no_neighbor_route_reflector_client_cmd
,
4426 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4430 "Configure a neighbor as Route Reflector client\n")
4433 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4434 bgp_node_afi(vty
), bgp_node_safi(vty
),
4435 PEER_FLAG_REFLECTOR_CLIENT
);
4438 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4439 no_neighbor_route_reflector_client_hidden_cmd
,
4440 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4441 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4442 "Configure a neighbor as Route Reflector client\n")
4444 /* neighbor route-server-client. */
4445 DEFUN (neighbor_route_server_client
,
4446 neighbor_route_server_client_cmd
,
4447 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4450 "Configure a neighbor as Route Server client\n")
4455 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4457 return CMD_WARNING_CONFIG_FAILED
;
4458 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4460 PEER_FLAG_RSERVER_CLIENT
);
4463 ALIAS_HIDDEN(neighbor_route_server_client
,
4464 neighbor_route_server_client_hidden_cmd
,
4465 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4466 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4467 "Configure a neighbor as Route Server client\n")
4469 DEFUN (no_neighbor_route_server_client
,
4470 no_neighbor_route_server_client_cmd
,
4471 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4475 "Configure a neighbor as Route Server client\n")
4478 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4479 bgp_node_afi(vty
), bgp_node_safi(vty
),
4480 PEER_FLAG_RSERVER_CLIENT
);
4483 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4484 no_neighbor_route_server_client_hidden_cmd
,
4485 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4486 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4487 "Configure a neighbor as Route Server client\n")
4489 DEFUN (neighbor_nexthop_local_unchanged
,
4490 neighbor_nexthop_local_unchanged_cmd
,
4491 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4494 "Configure treatment of outgoing link-local nexthop attribute\n"
4495 "Leave link-local nexthop unchanged for this peer\n")
4498 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4500 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4503 DEFUN (no_neighbor_nexthop_local_unchanged
,
4504 no_neighbor_nexthop_local_unchanged_cmd
,
4505 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4509 "Configure treatment of outgoing link-local-nexthop attribute\n"
4510 "Leave link-local nexthop unchanged for this peer\n")
4513 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4514 bgp_node_afi(vty
), bgp_node_safi(vty
),
4515 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4518 DEFUN (neighbor_attr_unchanged
,
4519 neighbor_attr_unchanged_cmd
,
4520 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4523 "BGP attribute is propagated unchanged to this neighbor\n"
4524 "As-path attribute\n"
4525 "Nexthop attribute\n"
4529 char *peer_str
= argv
[1]->arg
;
4532 afi_t afi
= bgp_node_afi(vty
);
4533 safi_t safi
= bgp_node_safi(vty
);
4535 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4537 return CMD_WARNING_CONFIG_FAILED
;
4539 if (argv_find(argv
, argc
, "as-path", &idx
))
4540 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4542 if (argv_find(argv
, argc
, "next-hop", &idx
))
4543 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4545 if (argv_find(argv
, argc
, "med", &idx
))
4546 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4548 /* no flags means all of them! */
4550 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4551 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4552 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4554 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4555 && peer_af_flag_check(peer
, afi
, safi
,
4556 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4557 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4558 PEER_FLAG_AS_PATH_UNCHANGED
);
4561 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4562 && peer_af_flag_check(peer
, afi
, safi
,
4563 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4564 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4565 PEER_FLAG_NEXTHOP_UNCHANGED
);
4568 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4569 && peer_af_flag_check(peer
, afi
, safi
,
4570 PEER_FLAG_MED_UNCHANGED
)) {
4571 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4572 PEER_FLAG_MED_UNCHANGED
);
4576 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4580 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4581 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4582 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4583 "BGP attribute is propagated unchanged to this neighbor\n"
4584 "As-path attribute\n"
4585 "Nexthop attribute\n"
4588 DEFUN (no_neighbor_attr_unchanged
,
4589 no_neighbor_attr_unchanged_cmd
,
4590 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4594 "BGP attribute is propagated unchanged to this neighbor\n"
4595 "As-path attribute\n"
4596 "Nexthop attribute\n"
4600 char *peer
= argv
[2]->arg
;
4603 if (argv_find(argv
, argc
, "as-path", &idx
))
4604 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4606 if (argv_find(argv
, argc
, "next-hop", &idx
))
4607 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4609 if (argv_find(argv
, argc
, "med", &idx
))
4610 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4612 if (!flags
) // no flags means all of them!
4614 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4615 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4616 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4619 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4620 bgp_node_safi(vty
), flags
);
4624 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4625 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4626 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4627 "BGP attribute is propagated unchanged to this neighbor\n"
4628 "As-path attribute\n"
4629 "Nexthop attribute\n"
4632 /* EBGP multihop configuration. */
4633 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4634 const char *ttl_str
)
4639 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4641 return CMD_WARNING_CONFIG_FAILED
;
4644 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4649 ttl
= strtoul(ttl_str
, NULL
, 10);
4651 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4654 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4658 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4660 return CMD_WARNING_CONFIG_FAILED
;
4662 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4665 /* neighbor ebgp-multihop. */
4666 DEFUN (neighbor_ebgp_multihop
,
4667 neighbor_ebgp_multihop_cmd
,
4668 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4671 "Allow EBGP neighbors not on directly connected networks\n")
4674 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4677 DEFUN (neighbor_ebgp_multihop_ttl
,
4678 neighbor_ebgp_multihop_ttl_cmd
,
4679 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4682 "Allow EBGP neighbors not on directly connected networks\n"
4683 "maximum hop count\n")
4687 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4688 argv
[idx_number
]->arg
);
4691 DEFUN (no_neighbor_ebgp_multihop
,
4692 no_neighbor_ebgp_multihop_cmd
,
4693 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4697 "Allow EBGP neighbors not on directly connected networks\n"
4698 "maximum hop count\n")
4701 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4705 /* disable-connected-check */
4706 DEFUN (neighbor_disable_connected_check
,
4707 neighbor_disable_connected_check_cmd
,
4708 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4711 "one-hop away EBGP peer using loopback address\n"
4712 "Enforce EBGP neighbors perform multihop\n")
4715 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4716 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4719 DEFUN (no_neighbor_disable_connected_check
,
4720 no_neighbor_disable_connected_check_cmd
,
4721 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4725 "one-hop away EBGP peer using loopback address\n"
4726 "Enforce EBGP neighbors perform multihop\n")
4729 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4730 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4734 /* enforce-first-as */
4735 DEFUN (neighbor_enforce_first_as
,
4736 neighbor_enforce_first_as_cmd
,
4737 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4740 "Enforce the first AS for EBGP routes\n")
4744 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4745 PEER_FLAG_ENFORCE_FIRST_AS
);
4748 DEFUN (no_neighbor_enforce_first_as
,
4749 no_neighbor_enforce_first_as_cmd
,
4750 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4754 "Enforce the first AS for EBGP routes\n")
4758 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4759 PEER_FLAG_ENFORCE_FIRST_AS
);
4763 DEFUN (neighbor_description
,
4764 neighbor_description_cmd
,
4765 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4768 "Neighbor specific description\n"
4769 "Up to 80 characters describing this neighbor\n")
4776 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4778 return CMD_WARNING_CONFIG_FAILED
;
4780 str
= argv_concat(argv
, argc
, idx_line
);
4782 peer_description_set(peer
, str
);
4784 XFREE(MTYPE_TMP
, str
);
4789 DEFUN (no_neighbor_description
,
4790 no_neighbor_description_cmd
,
4791 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4795 "Neighbor specific description\n")
4800 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4802 return CMD_WARNING_CONFIG_FAILED
;
4804 peer_description_unset(peer
);
4809 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4810 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4811 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4812 "Neighbor specific description\n"
4813 "Up to 80 characters describing this neighbor\n")
4815 /* Neighbor update-source. */
4816 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4817 const char *source_str
)
4823 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4825 return CMD_WARNING_CONFIG_FAILED
;
4831 if (str2sockunion(source_str
, &su
) == 0)
4832 peer_update_source_addr_set(peer
, &su
);
4834 if (str2prefix(source_str
, &p
)) {
4836 "%% Invalid update-source, remove prefix length \n");
4837 return CMD_WARNING_CONFIG_FAILED
;
4839 peer_update_source_if_set(peer
, source_str
);
4842 peer_update_source_unset(peer
);
4847 #define BGP_UPDATE_SOURCE_HELP_STR \
4850 "Interface name (requires zebra to be running)\n"
4852 DEFUN (neighbor_update_source
,
4853 neighbor_update_source_cmd
,
4854 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4857 "Source of routing updates\n"
4858 BGP_UPDATE_SOURCE_HELP_STR
)
4862 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4863 argv
[idx_peer_2
]->arg
);
4866 DEFUN (no_neighbor_update_source
,
4867 no_neighbor_update_source_cmd
,
4868 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4872 "Source of routing updates\n"
4873 BGP_UPDATE_SOURCE_HELP_STR
)
4876 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4879 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4880 afi_t afi
, safi_t safi
,
4881 const char *rmap
, int set
)
4885 struct route_map
*route_map
;
4887 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4889 return CMD_WARNING_CONFIG_FAILED
;
4892 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
4893 ret
= peer_default_originate_set(peer
, afi
, safi
,
4896 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4898 return bgp_vty_return(vty
, ret
);
4901 /* neighbor default-originate. */
4902 DEFUN (neighbor_default_originate
,
4903 neighbor_default_originate_cmd
,
4904 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4907 "Originate default route to this neighbor\n")
4910 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4912 bgp_node_safi(vty
), NULL
, 1);
4915 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4916 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4917 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4918 "Originate default route to this neighbor\n")
4920 DEFUN (neighbor_default_originate_rmap
,
4921 neighbor_default_originate_rmap_cmd
,
4922 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4925 "Originate default route to this neighbor\n"
4926 "Route-map to specify criteria to originate default\n"
4931 return peer_default_originate_set_vty(
4932 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4933 argv
[idx_word
]->arg
, 1);
4937 neighbor_default_originate_rmap
,
4938 neighbor_default_originate_rmap_hidden_cmd
,
4939 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4940 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4941 "Originate default route to this neighbor\n"
4942 "Route-map to specify criteria to originate default\n"
4945 DEFUN (no_neighbor_default_originate
,
4946 no_neighbor_default_originate_cmd
,
4947 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4951 "Originate default route to this neighbor\n"
4952 "Route-map to specify criteria to originate default\n"
4956 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4958 bgp_node_safi(vty
), NULL
, 0);
4962 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4963 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4964 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4965 "Originate default route to this neighbor\n"
4966 "Route-map to specify criteria to originate default\n"
4970 /* Set neighbor's BGP port. */
4971 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4972 const char *port_str
)
4978 peer
= peer_lookup_vty(vty
, ip_str
);
4980 return CMD_WARNING_CONFIG_FAILED
;
4983 sp
= getservbyname("bgp", "tcp");
4984 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
4986 port
= strtoul(port_str
, NULL
, 10);
4989 peer_port_set(peer
, port
);
4994 /* Set specified peer's BGP port. */
4995 DEFUN (neighbor_port
,
4997 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
5000 "Neighbor's BGP port\n"
5001 "TCP port number\n")
5005 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
5006 argv
[idx_number
]->arg
);
5009 DEFUN (no_neighbor_port
,
5010 no_neighbor_port_cmd
,
5011 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
5015 "Neighbor's BGP port\n"
5016 "TCP port number\n")
5019 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
5023 /* neighbor weight. */
5024 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5025 safi_t safi
, const char *weight_str
)
5029 unsigned long weight
;
5031 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5033 return CMD_WARNING_CONFIG_FAILED
;
5035 weight
= strtoul(weight_str
, NULL
, 10);
5037 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
5038 return bgp_vty_return(vty
, ret
);
5041 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5047 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5049 return CMD_WARNING_CONFIG_FAILED
;
5051 ret
= peer_weight_unset(peer
, afi
, safi
);
5052 return bgp_vty_return(vty
, ret
);
5055 DEFUN (neighbor_weight
,
5056 neighbor_weight_cmd
,
5057 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5060 "Set default weight for routes from this neighbor\n"
5065 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5066 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
5069 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
5070 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5071 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5072 "Set default weight for routes from this neighbor\n"
5075 DEFUN (no_neighbor_weight
,
5076 no_neighbor_weight_cmd
,
5077 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5081 "Set default weight for routes from this neighbor\n"
5085 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
5086 bgp_node_afi(vty
), bgp_node_safi(vty
));
5089 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
5090 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5091 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5092 "Set default weight for routes from this neighbor\n"
5096 /* Override capability negotiation. */
5097 DEFUN (neighbor_override_capability
,
5098 neighbor_override_capability_cmd
,
5099 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5102 "Override capability negotiation result\n")
5105 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5106 PEER_FLAG_OVERRIDE_CAPABILITY
);
5109 DEFUN (no_neighbor_override_capability
,
5110 no_neighbor_override_capability_cmd
,
5111 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5115 "Override capability negotiation result\n")
5118 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5119 PEER_FLAG_OVERRIDE_CAPABILITY
);
5122 DEFUN (neighbor_strict_capability
,
5123 neighbor_strict_capability_cmd
,
5124 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5127 "Strict capability negotiation match\n")
5131 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5132 PEER_FLAG_STRICT_CAP_MATCH
);
5135 DEFUN (no_neighbor_strict_capability
,
5136 no_neighbor_strict_capability_cmd
,
5137 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5141 "Strict capability negotiation match\n")
5145 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5146 PEER_FLAG_STRICT_CAP_MATCH
);
5149 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5150 const char *keep_str
, const char *hold_str
)
5157 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5159 return CMD_WARNING_CONFIG_FAILED
;
5161 keepalive
= strtoul(keep_str
, NULL
, 10);
5162 holdtime
= strtoul(hold_str
, NULL
, 10);
5164 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5166 return bgp_vty_return(vty
, ret
);
5169 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5174 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5176 return CMD_WARNING_CONFIG_FAILED
;
5178 ret
= peer_timers_unset(peer
);
5180 return bgp_vty_return(vty
, ret
);
5183 DEFUN (neighbor_timers
,
5184 neighbor_timers_cmd
,
5185 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5188 "BGP per neighbor timers\n"
5189 "Keepalive interval\n"
5194 int idx_number_2
= 4;
5195 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5196 argv
[idx_number
]->arg
,
5197 argv
[idx_number_2
]->arg
);
5200 DEFUN (no_neighbor_timers
,
5201 no_neighbor_timers_cmd
,
5202 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5206 "BGP per neighbor timers\n"
5207 "Keepalive interval\n"
5211 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5215 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5216 const char *time_str
)
5222 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5224 return CMD_WARNING_CONFIG_FAILED
;
5226 connect
= strtoul(time_str
, NULL
, 10);
5228 ret
= peer_timers_connect_set(peer
, connect
);
5230 return bgp_vty_return(vty
, ret
);
5233 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5238 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5240 return CMD_WARNING_CONFIG_FAILED
;
5242 ret
= peer_timers_connect_unset(peer
);
5244 return bgp_vty_return(vty
, ret
);
5247 DEFUN (neighbor_timers_connect
,
5248 neighbor_timers_connect_cmd
,
5249 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5252 "BGP per neighbor timers\n"
5253 "BGP connect timer\n"
5258 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5259 argv
[idx_number
]->arg
);
5262 DEFUN (no_neighbor_timers_connect
,
5263 no_neighbor_timers_connect_cmd
,
5264 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5268 "BGP per neighbor timers\n"
5269 "BGP connect timer\n"
5273 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5277 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5278 const char *time_str
, int set
)
5282 uint32_t routeadv
= 0;
5284 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5286 return CMD_WARNING_CONFIG_FAILED
;
5289 routeadv
= strtoul(time_str
, NULL
, 10);
5292 ret
= peer_advertise_interval_set(peer
, routeadv
);
5294 ret
= peer_advertise_interval_unset(peer
);
5296 return bgp_vty_return(vty
, ret
);
5299 DEFUN (neighbor_advertise_interval
,
5300 neighbor_advertise_interval_cmd
,
5301 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5304 "Minimum interval between sending BGP routing updates\n"
5305 "time in seconds\n")
5309 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5310 argv
[idx_number
]->arg
, 1);
5313 DEFUN (no_neighbor_advertise_interval
,
5314 no_neighbor_advertise_interval_cmd
,
5315 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5319 "Minimum interval between sending BGP routing updates\n"
5320 "time in seconds\n")
5323 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5327 /* Time to wait before processing route-map updates */
5328 DEFUN (bgp_set_route_map_delay_timer
,
5329 bgp_set_route_map_delay_timer_cmd
,
5330 "bgp route-map delay-timer (0-600)",
5332 "BGP route-map delay timer\n"
5333 "Time in secs to wait before processing route-map changes\n"
5334 "0 disables the timer, no route updates happen when route-maps change\n")
5337 uint32_t rmap_delay_timer
;
5339 if (argv
[idx_number
]->arg
) {
5340 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5341 bm
->rmap_update_timer
= rmap_delay_timer
;
5343 /* if the dynamic update handling is being disabled, and a timer
5345 * running, stop the timer and act as if the timer has already
5348 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5349 BGP_TIMER_OFF(bm
->t_rmap_update
);
5350 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5355 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5356 return CMD_WARNING_CONFIG_FAILED
;
5360 DEFUN (no_bgp_set_route_map_delay_timer
,
5361 no_bgp_set_route_map_delay_timer_cmd
,
5362 "no bgp route-map delay-timer [(0-600)]",
5365 "Default BGP route-map delay timer\n"
5366 "Reset to default time to wait for processing route-map changes\n"
5367 "0 disables the timer, no route updates happen when route-maps change\n")
5370 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5376 /* neighbor interface */
5377 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5382 peer
= peer_lookup_vty(vty
, ip_str
);
5383 if (!peer
|| peer
->conf_if
) {
5384 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5385 return CMD_WARNING_CONFIG_FAILED
;
5389 peer_interface_set(peer
, str
);
5391 peer_interface_unset(peer
);
5396 DEFUN (neighbor_interface
,
5397 neighbor_interface_cmd
,
5398 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5406 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5409 DEFUN (no_neighbor_interface
,
5410 no_neighbor_interface_cmd
,
5411 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5419 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5422 DEFUN (neighbor_distribute_list
,
5423 neighbor_distribute_list_cmd
,
5424 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5427 "Filter updates to/from this neighbor\n"
5428 "IP access-list number\n"
5429 "IP access-list number (expanded range)\n"
5430 "IP Access-list name\n"
5431 "Filter incoming updates\n"
5432 "Filter outgoing updates\n")
5439 const char *pstr
= argv
[idx_peer
]->arg
;
5440 const char *acl
= argv
[idx_acl
]->arg
;
5441 const char *inout
= argv
[argc
- 1]->text
;
5443 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5445 return CMD_WARNING_CONFIG_FAILED
;
5447 /* Check filter direction. */
5448 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5449 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5452 return bgp_vty_return(vty
, ret
);
5456 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5457 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5458 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5459 "Filter updates to/from this neighbor\n"
5460 "IP access-list number\n"
5461 "IP access-list number (expanded range)\n"
5462 "IP Access-list name\n"
5463 "Filter incoming updates\n"
5464 "Filter outgoing updates\n")
5466 DEFUN (no_neighbor_distribute_list
,
5467 no_neighbor_distribute_list_cmd
,
5468 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5472 "Filter updates to/from this neighbor\n"
5473 "IP access-list number\n"
5474 "IP access-list number (expanded range)\n"
5475 "IP Access-list name\n"
5476 "Filter incoming updates\n"
5477 "Filter outgoing updates\n")
5483 const char *pstr
= argv
[idx_peer
]->arg
;
5484 const char *inout
= argv
[argc
- 1]->text
;
5486 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5488 return CMD_WARNING_CONFIG_FAILED
;
5490 /* Check filter direction. */
5491 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5492 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5495 return bgp_vty_return(vty
, ret
);
5499 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5500 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5501 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5502 "Filter updates to/from this neighbor\n"
5503 "IP access-list number\n"
5504 "IP access-list number (expanded range)\n"
5505 "IP Access-list name\n"
5506 "Filter incoming updates\n"
5507 "Filter outgoing updates\n")
5509 /* Set prefix list to the peer. */
5510 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5511 afi_t afi
, safi_t safi
,
5512 const char *name_str
,
5513 const char *direct_str
)
5516 int direct
= FILTER_IN
;
5519 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5521 return CMD_WARNING_CONFIG_FAILED
;
5523 /* Check filter direction. */
5524 if (strncmp(direct_str
, "i", 1) == 0)
5526 else if (strncmp(direct_str
, "o", 1) == 0)
5527 direct
= FILTER_OUT
;
5529 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5531 return bgp_vty_return(vty
, ret
);
5534 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5535 afi_t afi
, safi_t safi
,
5536 const char *direct_str
)
5540 int direct
= FILTER_IN
;
5542 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5544 return CMD_WARNING_CONFIG_FAILED
;
5546 /* Check filter direction. */
5547 if (strncmp(direct_str
, "i", 1) == 0)
5549 else if (strncmp(direct_str
, "o", 1) == 0)
5550 direct
= FILTER_OUT
;
5552 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5554 return bgp_vty_return(vty
, ret
);
5557 DEFUN (neighbor_prefix_list
,
5558 neighbor_prefix_list_cmd
,
5559 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5562 "Filter updates to/from this neighbor\n"
5563 "Name of a prefix list\n"
5564 "Filter incoming updates\n"
5565 "Filter outgoing updates\n")
5570 return peer_prefix_list_set_vty(
5571 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5572 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5575 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5576 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5577 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5578 "Filter updates to/from this neighbor\n"
5579 "Name of a prefix list\n"
5580 "Filter incoming updates\n"
5581 "Filter outgoing updates\n")
5583 DEFUN (no_neighbor_prefix_list
,
5584 no_neighbor_prefix_list_cmd
,
5585 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5589 "Filter updates to/from this neighbor\n"
5590 "Name of a prefix list\n"
5591 "Filter incoming updates\n"
5592 "Filter outgoing updates\n")
5596 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5597 bgp_node_afi(vty
), bgp_node_safi(vty
),
5598 argv
[idx_in_out
]->arg
);
5601 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5602 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5603 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5604 "Filter updates to/from this neighbor\n"
5605 "Name of a prefix list\n"
5606 "Filter incoming updates\n"
5607 "Filter outgoing updates\n")
5609 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5610 safi_t safi
, const char *name_str
,
5611 const char *direct_str
)
5615 int direct
= FILTER_IN
;
5617 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5619 return CMD_WARNING_CONFIG_FAILED
;
5621 /* Check filter direction. */
5622 if (strncmp(direct_str
, "i", 1) == 0)
5624 else if (strncmp(direct_str
, "o", 1) == 0)
5625 direct
= FILTER_OUT
;
5627 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5629 return bgp_vty_return(vty
, ret
);
5632 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5633 safi_t safi
, const char *direct_str
)
5637 int direct
= FILTER_IN
;
5639 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5641 return CMD_WARNING_CONFIG_FAILED
;
5643 /* Check filter direction. */
5644 if (strncmp(direct_str
, "i", 1) == 0)
5646 else if (strncmp(direct_str
, "o", 1) == 0)
5647 direct
= FILTER_OUT
;
5649 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5651 return bgp_vty_return(vty
, ret
);
5654 DEFUN (neighbor_filter_list
,
5655 neighbor_filter_list_cmd
,
5656 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5659 "Establish BGP filters\n"
5660 "AS path access-list name\n"
5661 "Filter incoming routes\n"
5662 "Filter outgoing routes\n")
5667 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5668 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5669 argv
[idx_in_out
]->arg
);
5672 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5673 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5674 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5675 "Establish BGP filters\n"
5676 "AS path access-list name\n"
5677 "Filter incoming routes\n"
5678 "Filter outgoing routes\n")
5680 DEFUN (no_neighbor_filter_list
,
5681 no_neighbor_filter_list_cmd
,
5682 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5686 "Establish BGP filters\n"
5687 "AS path access-list name\n"
5688 "Filter incoming routes\n"
5689 "Filter outgoing routes\n")
5693 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5694 bgp_node_afi(vty
), bgp_node_safi(vty
),
5695 argv
[idx_in_out
]->arg
);
5698 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5699 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5700 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5701 "Establish BGP filters\n"
5702 "AS path access-list name\n"
5703 "Filter incoming routes\n"
5704 "Filter outgoing routes\n")
5706 /* Set route-map to the peer. */
5707 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5708 afi_t afi
, safi_t safi
, const char *name_str
,
5709 const char *direct_str
)
5713 int direct
= RMAP_IN
;
5714 struct route_map
*route_map
;
5716 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5718 return CMD_WARNING_CONFIG_FAILED
;
5720 /* Check filter direction. */
5721 if (strncmp(direct_str
, "in", 2) == 0)
5723 else if (strncmp(direct_str
, "o", 1) == 0)
5726 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5727 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
5729 return bgp_vty_return(vty
, ret
);
5732 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5733 afi_t afi
, safi_t safi
,
5734 const char *direct_str
)
5738 int direct
= RMAP_IN
;
5740 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5742 return CMD_WARNING_CONFIG_FAILED
;
5744 /* Check filter direction. */
5745 if (strncmp(direct_str
, "in", 2) == 0)
5747 else if (strncmp(direct_str
, "o", 1) == 0)
5750 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5752 return bgp_vty_return(vty
, ret
);
5755 DEFUN (neighbor_route_map
,
5756 neighbor_route_map_cmd
,
5757 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5760 "Apply route map to neighbor\n"
5761 "Name of route map\n"
5762 "Apply map to incoming routes\n"
5763 "Apply map to outbound routes\n")
5768 return peer_route_map_set_vty(
5769 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5770 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5773 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5774 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5775 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5776 "Apply route map to neighbor\n"
5777 "Name of route map\n"
5778 "Apply map to incoming routes\n"
5779 "Apply map to outbound routes\n")
5781 DEFUN (no_neighbor_route_map
,
5782 no_neighbor_route_map_cmd
,
5783 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5787 "Apply route map to neighbor\n"
5788 "Name of route map\n"
5789 "Apply map to incoming routes\n"
5790 "Apply map to outbound routes\n")
5794 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5795 bgp_node_afi(vty
), bgp_node_safi(vty
),
5796 argv
[idx_in_out
]->arg
);
5799 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5800 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5801 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5802 "Apply route map to neighbor\n"
5803 "Name of route map\n"
5804 "Apply map to incoming routes\n"
5805 "Apply map to outbound routes\n")
5807 /* Set unsuppress-map to the peer. */
5808 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5809 afi_t afi
, safi_t safi
,
5810 const char *name_str
)
5814 struct route_map
*route_map
;
5816 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5818 return CMD_WARNING_CONFIG_FAILED
;
5820 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5821 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
5823 return bgp_vty_return(vty
, ret
);
5826 /* Unset route-map from the peer. */
5827 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5828 afi_t afi
, safi_t safi
)
5833 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5835 return CMD_WARNING_CONFIG_FAILED
;
5837 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5839 return bgp_vty_return(vty
, ret
);
5842 DEFUN (neighbor_unsuppress_map
,
5843 neighbor_unsuppress_map_cmd
,
5844 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5847 "Route-map to selectively unsuppress suppressed routes\n"
5848 "Name of route map\n")
5852 return peer_unsuppress_map_set_vty(
5853 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5854 argv
[idx_word
]->arg
);
5857 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5858 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5859 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5860 "Route-map to selectively unsuppress suppressed routes\n"
5861 "Name of route map\n")
5863 DEFUN (no_neighbor_unsuppress_map
,
5864 no_neighbor_unsuppress_map_cmd
,
5865 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5869 "Route-map to selectively unsuppress suppressed routes\n"
5870 "Name of route map\n")
5873 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5875 bgp_node_safi(vty
));
5878 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5879 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5880 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5881 "Route-map to selectively unsuppress suppressed routes\n"
5882 "Name of route map\n")
5884 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5885 afi_t afi
, safi_t safi
,
5886 const char *num_str
,
5887 const char *threshold_str
, int warning
,
5888 const char *restart_str
)
5896 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5898 return CMD_WARNING_CONFIG_FAILED
;
5900 max
= strtoul(num_str
, NULL
, 10);
5902 threshold
= atoi(threshold_str
);
5904 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5907 restart
= atoi(restart_str
);
5911 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5914 return bgp_vty_return(vty
, ret
);
5917 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5918 afi_t afi
, safi_t safi
)
5923 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5925 return CMD_WARNING_CONFIG_FAILED
;
5927 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5929 return bgp_vty_return(vty
, ret
);
5932 /* Maximum number of prefix configuration. prefix count is different
5933 for each peer configuration. So this configuration can be set for
5934 each peer configuration. */
5935 DEFUN (neighbor_maximum_prefix
,
5936 neighbor_maximum_prefix_cmd
,
5937 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5940 "Maximum number of prefix accept from this peer\n"
5941 "maximum no. of prefix limit\n")
5945 return peer_maximum_prefix_set_vty(
5946 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5947 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5950 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5951 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5952 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5953 "Maximum number of prefix accept from this peer\n"
5954 "maximum no. of prefix limit\n")
5956 DEFUN (neighbor_maximum_prefix_threshold
,
5957 neighbor_maximum_prefix_threshold_cmd
,
5958 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5961 "Maximum number of prefix accept from this peer\n"
5962 "maximum no. of prefix limit\n"
5963 "Threshold value (%) at which to generate a warning msg\n")
5967 int idx_number_2
= 4;
5968 return peer_maximum_prefix_set_vty(
5969 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5970 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5974 neighbor_maximum_prefix_threshold
,
5975 neighbor_maximum_prefix_threshold_hidden_cmd
,
5976 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5977 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5978 "Maximum number of prefix accept from this peer\n"
5979 "maximum no. of prefix limit\n"
5980 "Threshold value (%) at which to generate a warning msg\n")
5982 DEFUN (neighbor_maximum_prefix_warning
,
5983 neighbor_maximum_prefix_warning_cmd
,
5984 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5987 "Maximum number of prefix accept from this peer\n"
5988 "maximum no. of prefix limit\n"
5989 "Only give warning message when limit is exceeded\n")
5993 return peer_maximum_prefix_set_vty(
5994 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5995 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
5999 neighbor_maximum_prefix_warning
,
6000 neighbor_maximum_prefix_warning_hidden_cmd
,
6001 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6002 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6003 "Maximum number of prefix accept from this peer\n"
6004 "maximum no. of prefix limit\n"
6005 "Only give warning message when limit is exceeded\n")
6007 DEFUN (neighbor_maximum_prefix_threshold_warning
,
6008 neighbor_maximum_prefix_threshold_warning_cmd
,
6009 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6012 "Maximum number of prefix accept from this peer\n"
6013 "maximum no. of prefix limit\n"
6014 "Threshold value (%) at which to generate a warning msg\n"
6015 "Only give warning message when limit is exceeded\n")
6019 int idx_number_2
= 4;
6020 return peer_maximum_prefix_set_vty(
6021 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6022 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
6026 neighbor_maximum_prefix_threshold_warning
,
6027 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
6028 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6029 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6030 "Maximum number of prefix accept from this peer\n"
6031 "maximum no. of prefix limit\n"
6032 "Threshold value (%) at which to generate a warning msg\n"
6033 "Only give warning message when limit is exceeded\n")
6035 DEFUN (neighbor_maximum_prefix_restart
,
6036 neighbor_maximum_prefix_restart_cmd
,
6037 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6040 "Maximum number of prefix accept from this peer\n"
6041 "maximum no. of prefix limit\n"
6042 "Restart bgp connection after limit is exceeded\n"
6043 "Restart interval in minutes\n")
6047 int idx_number_2
= 5;
6048 return peer_maximum_prefix_set_vty(
6049 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6050 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
6054 neighbor_maximum_prefix_restart
,
6055 neighbor_maximum_prefix_restart_hidden_cmd
,
6056 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6057 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6058 "Maximum number of prefix accept from this peer\n"
6059 "maximum no. of prefix limit\n"
6060 "Restart bgp connection after limit is exceeded\n"
6061 "Restart interval in minutes\n")
6063 DEFUN (neighbor_maximum_prefix_threshold_restart
,
6064 neighbor_maximum_prefix_threshold_restart_cmd
,
6065 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6068 "Maximum number of prefixes to accept from this peer\n"
6069 "maximum no. of prefix limit\n"
6070 "Threshold value (%) at which to generate a warning msg\n"
6071 "Restart bgp connection after limit is exceeded\n"
6072 "Restart interval in minutes\n")
6076 int idx_number_2
= 4;
6077 int idx_number_3
= 6;
6078 return peer_maximum_prefix_set_vty(
6079 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6080 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
6081 argv
[idx_number_3
]->arg
);
6085 neighbor_maximum_prefix_threshold_restart
,
6086 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
6087 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6088 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6089 "Maximum number of prefixes to accept from this peer\n"
6090 "maximum no. of prefix limit\n"
6091 "Threshold value (%) at which to generate a warning msg\n"
6092 "Restart bgp connection after limit is exceeded\n"
6093 "Restart interval in minutes\n")
6095 DEFUN (no_neighbor_maximum_prefix
,
6096 no_neighbor_maximum_prefix_cmd
,
6097 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6101 "Maximum number of prefixes to accept from this peer\n"
6102 "maximum no. of prefix limit\n"
6103 "Threshold value (%) at which to generate a warning msg\n"
6104 "Restart bgp connection after limit is exceeded\n"
6105 "Restart interval in minutes\n"
6106 "Only give warning message when limit is exceeded\n")
6109 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
6111 bgp_node_safi(vty
));
6115 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
6116 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6117 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6118 "Maximum number of prefixes to accept from this peer\n"
6119 "maximum no. of prefix limit\n"
6120 "Threshold value (%) at which to generate a warning msg\n"
6121 "Restart bgp connection after limit is exceeded\n"
6122 "Restart interval in minutes\n"
6123 "Only give warning message when limit is exceeded\n")
6126 /* "neighbor allowas-in" */
6127 DEFUN (neighbor_allowas_in
,
6128 neighbor_allowas_in_cmd
,
6129 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6132 "Accept as-path with my AS present in it\n"
6133 "Number of occurences of AS number\n"
6134 "Only accept my AS in the as-path if the route was originated in my AS\n")
6137 int idx_number_origin
= 3;
6143 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6145 return CMD_WARNING_CONFIG_FAILED
;
6147 if (argc
<= idx_number_origin
)
6150 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6153 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6156 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6159 return bgp_vty_return(vty
, ret
);
6163 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6164 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6165 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6166 "Accept as-path with my AS present in it\n"
6167 "Number of occurences of AS number\n"
6168 "Only accept my AS in the as-path if the route was originated in my AS\n")
6170 DEFUN (no_neighbor_allowas_in
,
6171 no_neighbor_allowas_in_cmd
,
6172 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6176 "allow local ASN appears in aspath attribute\n"
6177 "Number of occurences of AS number\n"
6178 "Only accept my AS in the as-path if the route was originated in my AS\n")
6184 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6186 return CMD_WARNING_CONFIG_FAILED
;
6188 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6189 bgp_node_safi(vty
));
6191 return bgp_vty_return(vty
, ret
);
6195 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6196 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6197 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6198 "allow local ASN appears in aspath attribute\n"
6199 "Number of occurences of AS number\n"
6200 "Only accept my AS in the as-path if the route was originated in my AS\n")
6202 DEFUN (neighbor_ttl_security
,
6203 neighbor_ttl_security_cmd
,
6204 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6207 "BGP ttl-security parameters\n"
6208 "Specify the maximum number of hops to the BGP peer\n"
6209 "Number of hops to BGP peer\n")
6216 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6218 return CMD_WARNING_CONFIG_FAILED
;
6220 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6223 * If 'neighbor swpX', then this is for directly connected peers,
6224 * we should not accept a ttl-security hops value greater than 1.
6226 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6228 "%s is directly connected peer, hops cannot exceed 1\n",
6229 argv
[idx_peer
]->arg
);
6230 return CMD_WARNING_CONFIG_FAILED
;
6233 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6236 DEFUN (no_neighbor_ttl_security
,
6237 no_neighbor_ttl_security_cmd
,
6238 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6242 "BGP ttl-security parameters\n"
6243 "Specify the maximum number of hops to the BGP peer\n"
6244 "Number of hops to BGP peer\n")
6249 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6251 return CMD_WARNING_CONFIG_FAILED
;
6253 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6256 DEFUN (neighbor_addpath_tx_all_paths
,
6257 neighbor_addpath_tx_all_paths_cmd
,
6258 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6261 "Use addpath to advertise all paths to a neighbor\n")
6266 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6268 return CMD_WARNING_CONFIG_FAILED
;
6270 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6275 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6276 neighbor_addpath_tx_all_paths_hidden_cmd
,
6277 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6278 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6279 "Use addpath to advertise all paths to a neighbor\n")
6281 DEFUN (no_neighbor_addpath_tx_all_paths
,
6282 no_neighbor_addpath_tx_all_paths_cmd
,
6283 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6287 "Use addpath to advertise all paths to a neighbor\n")
6292 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6294 return CMD_WARNING_CONFIG_FAILED
;
6296 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6297 != BGP_ADDPATH_ALL
) {
6299 "%% Peer not currently configured to transmit all paths.");
6300 return CMD_WARNING_CONFIG_FAILED
;
6303 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6309 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6310 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6311 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6312 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6313 "Use addpath to advertise all paths to a neighbor\n")
6315 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6316 neighbor_addpath_tx_bestpath_per_as_cmd
,
6317 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6320 "Use addpath to advertise the bestpath per each neighboring AS\n")
6325 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6327 return CMD_WARNING_CONFIG_FAILED
;
6329 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6330 BGP_ADDPATH_BEST_PER_AS
);
6335 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6336 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6337 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6338 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6339 "Use addpath to advertise the bestpath per each neighboring AS\n")
6341 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6342 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6343 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6347 "Use addpath to advertise the bestpath per each neighboring AS\n")
6352 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6354 return CMD_WARNING_CONFIG_FAILED
;
6356 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6357 != BGP_ADDPATH_BEST_PER_AS
) {
6359 "%% Peer not currently configured to transmit all best path per as.");
6360 return CMD_WARNING_CONFIG_FAILED
;
6363 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6369 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6370 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6371 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6372 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6373 "Use addpath to advertise the bestpath per each neighboring AS\n")
6375 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6376 struct ecommunity
**list
)
6378 struct ecommunity
*ecom
= NULL
;
6379 struct ecommunity
*ecomadd
;
6381 for (; argc
; --argc
, ++argv
) {
6383 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6384 ECOMMUNITY_ROUTE_TARGET
, 0);
6386 vty_out(vty
, "Malformed community-list value\n");
6388 ecommunity_free(&ecom
);
6389 return CMD_WARNING_CONFIG_FAILED
;
6393 ecommunity_merge(ecom
, ecomadd
);
6394 ecommunity_free(&ecomadd
);
6401 ecommunity_free(&*list
);
6409 * v2vimport is true if we are handling a `import vrf ...` command
6411 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6415 switch (vty
->node
) {
6424 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6429 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6430 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6431 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6432 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6434 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6438 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6439 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6440 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6441 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6443 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6450 DEFPY (af_rd_vpn_export
,
6451 af_rd_vpn_export_cmd
,
6452 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6454 "Specify route distinguisher\n"
6455 "Between current address-family and vpn\n"
6456 "For routes leaked from current address-family to vpn\n"
6457 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6459 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6460 struct prefix_rd prd
;
6466 if (argv_find(argv
, argc
, "no", &idx
))
6470 ret
= str2prefix_rd(rd_str
, &prd
);
6472 vty_out(vty
, "%% Malformed rd\n");
6473 return CMD_WARNING_CONFIG_FAILED
;
6477 afi
= vpn_policy_getafi(vty
, bgp
, false);
6479 return CMD_WARNING_CONFIG_FAILED
;
6482 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6484 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6485 bgp_get_default(), bgp
);
6488 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6489 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6490 BGP_VPN_POLICY_TOVPN_RD_SET
);
6492 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6493 BGP_VPN_POLICY_TOVPN_RD_SET
);
6496 /* post-change: re-export vpn routes */
6497 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6498 bgp_get_default(), bgp
);
6503 ALIAS (af_rd_vpn_export
,
6504 af_no_rd_vpn_export_cmd
,
6507 "Specify route distinguisher\n"
6508 "Between current address-family and vpn\n"
6509 "For routes leaked from current address-family to vpn\n")
6511 DEFPY (af_label_vpn_export
,
6512 af_label_vpn_export_cmd
,
6513 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6515 "label value for VRF\n"
6516 "Between current address-family and vpn\n"
6517 "For routes leaked from current address-family to vpn\n"
6518 "Label Value <0-1048575>\n"
6519 "Automatically assign a label\n")
6521 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6522 mpls_label_t label
= MPLS_LABEL_NONE
;
6527 if (argv_find(argv
, argc
, "no", &idx
))
6530 /* If "no ...", squash trailing parameter */
6536 label
= label_val
; /* parser should force unsigned */
6539 afi
= vpn_policy_getafi(vty
, bgp
, false);
6541 return CMD_WARNING_CONFIG_FAILED
;
6544 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6545 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6550 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6552 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6553 bgp_get_default(), bgp
);
6555 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6556 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6558 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6561 * label has previously been automatically
6562 * assigned by labelpool: release it
6564 * NB if tovpn_label == MPLS_LABEL_NONE it
6565 * means the automatic assignment is in flight
6566 * and therefore the labelpool callback must
6567 * detect that the auto label is not needed.
6570 bgp_lp_release(LP_TYPE_VRF
,
6571 &bgp
->vpn_policy
[afi
],
6572 bgp
->vpn_policy
[afi
].tovpn_label
);
6574 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6575 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6578 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6580 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6581 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6582 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6583 vpn_leak_label_callback
);
6586 /* post-change: re-export vpn routes */
6587 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6588 bgp_get_default(), bgp
);
6593 ALIAS (af_label_vpn_export
,
6594 af_no_label_vpn_export_cmd
,
6595 "no label vpn export",
6597 "label value for VRF\n"
6598 "Between current address-family and vpn\n"
6599 "For routes leaked from current address-family to vpn\n")
6601 DEFPY (af_nexthop_vpn_export
,
6602 af_nexthop_vpn_export_cmd
,
6603 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6605 "Specify next hop to use for VRF advertised prefixes\n"
6606 "Between current address-family and vpn\n"
6607 "For routes leaked from current address-family to vpn\n"
6611 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6617 if (argv_find(argv
, argc
, "no", &idx
))
6621 if (!sockunion2hostprefix(nexthop_str
, &p
))
6622 return CMD_WARNING_CONFIG_FAILED
;
6625 afi
= vpn_policy_getafi(vty
, bgp
, false);
6627 return CMD_WARNING_CONFIG_FAILED
;
6630 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6632 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6633 bgp_get_default(), bgp
);
6636 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6637 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6638 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6640 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6641 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6644 /* post-change: re-export vpn routes */
6645 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6646 bgp_get_default(), bgp
);
6651 ALIAS (af_nexthop_vpn_export
,
6652 af_no_nexthop_vpn_export_cmd
,
6653 "no nexthop vpn export",
6655 "Specify next hop to use for VRF advertised prefixes\n"
6656 "Between current address-family and vpn\n"
6657 "For routes leaked from current address-family to vpn\n")
6659 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6661 if (!strcmp(dstr
, "import")) {
6662 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6663 } else if (!strcmp(dstr
, "export")) {
6664 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6665 } else if (!strcmp(dstr
, "both")) {
6666 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6667 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6669 vty_out(vty
, "%% direction parse error\n");
6670 return CMD_WARNING_CONFIG_FAILED
;
6675 DEFPY (af_rt_vpn_imexport
,
6676 af_rt_vpn_imexport_cmd
,
6677 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6679 "Specify route target list\n"
6680 "Specify route target list\n"
6681 "Between current address-family and vpn\n"
6682 "For routes leaked from vpn to current address-family: match any\n"
6683 "For routes leaked from current address-family to vpn: set\n"
6684 "both import: match any and export: set\n"
6685 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6687 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6689 struct ecommunity
*ecom
= NULL
;
6690 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6691 vpn_policy_direction_t dir
;
6696 if (argv_find(argv
, argc
, "no", &idx
))
6699 afi
= vpn_policy_getafi(vty
, bgp
, false);
6701 return CMD_WARNING_CONFIG_FAILED
;
6703 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6704 if (ret
!= CMD_SUCCESS
)
6708 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6709 vty_out(vty
, "%% Missing RTLIST\n");
6710 return CMD_WARNING_CONFIG_FAILED
;
6712 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6713 if (ret
!= CMD_SUCCESS
) {
6718 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6722 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6725 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6727 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6728 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6729 ecommunity_dup(ecom
);
6731 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6733 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6734 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6737 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6741 ecommunity_free(&ecom
);
6746 ALIAS (af_rt_vpn_imexport
,
6747 af_no_rt_vpn_imexport_cmd
,
6748 "no <rt|route-target> vpn <import|export|both>$direction_str",
6750 "Specify route target list\n"
6751 "Specify route target list\n"
6752 "Between current address-family and vpn\n"
6753 "For routes leaked from vpn to current address-family\n"
6754 "For routes leaked from current address-family to vpn\n"
6755 "both import and export\n")
6757 DEFPY (af_route_map_vpn_imexport
,
6758 af_route_map_vpn_imexport_cmd
,
6759 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6760 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6762 "Specify route map\n"
6763 "Between current address-family and vpn\n"
6764 "For routes leaked from vpn to current address-family\n"
6765 "For routes leaked from current address-family to vpn\n"
6766 "name of route-map\n")
6768 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6770 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6771 vpn_policy_direction_t dir
;
6776 if (argv_find(argv
, argc
, "no", &idx
))
6779 afi
= vpn_policy_getafi(vty
, bgp
, false);
6781 return CMD_WARNING_CONFIG_FAILED
;
6783 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6784 if (ret
!= CMD_SUCCESS
)
6787 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6791 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6794 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6795 XFREE(MTYPE_ROUTE_MAP_NAME
,
6796 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6797 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6798 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6799 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6800 route_map_lookup_warn_noexist(vty
, rmap_str
);
6801 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6804 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6805 XFREE(MTYPE_ROUTE_MAP_NAME
,
6806 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6807 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6808 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6811 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6817 ALIAS (af_route_map_vpn_imexport
,
6818 af_no_route_map_vpn_imexport_cmd
,
6819 "no route-map vpn <import|export>$direction_str",
6821 "Specify route map\n"
6822 "Between current address-family and vpn\n"
6823 "For routes leaked from vpn to current address-family\n"
6824 "For routes leaked from current address-family to vpn\n")
6826 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6827 "[no] import vrf route-map RMAP$rmap_str",
6829 "Import routes from another VRF\n"
6830 "Vrf routes being filtered\n"
6831 "Specify route map\n"
6832 "name of route-map\n")
6834 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6835 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6839 struct bgp
*bgp_default
;
6841 if (argv_find(argv
, argc
, "no", &idx
))
6844 afi
= vpn_policy_getafi(vty
, bgp
, true);
6846 return CMD_WARNING_CONFIG_FAILED
;
6848 bgp_default
= bgp_get_default();
6853 /* Auto-create assuming the same AS */
6854 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6855 BGP_INSTANCE_TYPE_DEFAULT
);
6859 "VRF default is not configured as a bgp instance\n");
6864 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6867 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6868 XFREE(MTYPE_ROUTE_MAP_NAME
,
6869 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6870 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6871 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6872 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6873 route_map_lookup_warn_noexist(vty
, rmap_str
);
6874 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6877 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6878 XFREE(MTYPE_ROUTE_MAP_NAME
,
6879 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6880 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6881 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6884 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6889 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6890 "no import vrf route-map",
6892 "Import routes from another VRF\n"
6893 "Vrf routes being filtered\n"
6894 "Specify route map\n")
6896 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
6897 "[no] import vrf VIEWVRFNAME$import_name",
6899 "Import routes from another VRF\n"
6900 "VRF to import from\n"
6901 "The name of the VRF\n")
6903 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6904 struct listnode
*node
;
6905 struct bgp
*vrf_bgp
, *bgp_default
;
6908 bool remove
= false;
6911 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
6915 if (import_name
== NULL
) {
6916 vty_out(vty
, "%% Missing import name\n");
6920 if (argv_find(argv
, argc
, "no", &idx
))
6923 afi
= vpn_policy_getafi(vty
, bgp
, true);
6925 return CMD_WARNING_CONFIG_FAILED
;
6927 safi
= bgp_node_safi(vty
);
6929 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
6930 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
6931 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
6932 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
6933 remove
? "unimport" : "import", import_name
);
6937 bgp_default
= bgp_get_default();
6939 /* Auto-create assuming the same AS */
6940 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6941 BGP_INSTANCE_TYPE_DEFAULT
);
6945 "VRF default is not configured as a bgp instance\n");
6950 vrf_bgp
= bgp_lookup_by_name(import_name
);
6952 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
6953 vrf_bgp
= bgp_default
;
6955 /* Auto-create assuming the same AS */
6956 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
6960 "VRF %s is not configured as a bgp instance\n",
6967 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6969 /* Already importing from "import_vrf"? */
6970 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
6972 if (strcmp(vname
, import_name
) == 0)
6976 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6982 /* This command is valid only in a bgp vrf instance or the default instance */
6983 DEFPY (bgp_imexport_vpn
,
6984 bgp_imexport_vpn_cmd
,
6985 "[no] <import|export>$direction_str vpn",
6987 "Import routes to this address-family\n"
6988 "Export routes from this address-family\n"
6989 "to/from default instance VPN RIB\n")
6991 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6998 vpn_policy_direction_t dir
;
7000 if (argv_find(argv
, argc
, "no", &idx
))
7003 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
7004 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
7006 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
7007 return CMD_WARNING_CONFIG_FAILED
;
7010 afi
= bgp_node_afi(vty
);
7011 safi
= bgp_node_safi(vty
);
7012 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
7013 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
7014 return CMD_WARNING_CONFIG_FAILED
;
7017 if (!strcmp(direction_str
, "import")) {
7018 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
7019 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
7020 } else if (!strcmp(direction_str
, "export")) {
7021 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
7022 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
7024 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
7025 return CMD_WARNING_CONFIG_FAILED
;
7028 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7031 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7032 if (!previous_state
) {
7033 /* trigger export current vrf */
7034 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7037 if (previous_state
) {
7038 /* trigger un-export current vrf */
7039 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7041 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7047 DEFPY (af_routetarget_import
,
7048 af_routetarget_import_cmd
,
7049 "[no] <rt|route-target> redirect import RTLIST...",
7051 "Specify route target list\n"
7052 "Specify route target list\n"
7053 "Flow-spec redirect type route target\n"
7054 "Import routes to this address-family\n"
7055 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
7057 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7059 struct ecommunity
*ecom
= NULL
;
7064 if (argv_find(argv
, argc
, "no", &idx
))
7067 afi
= vpn_policy_getafi(vty
, bgp
, false);
7069 return CMD_WARNING_CONFIG_FAILED
;
7072 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7073 vty_out(vty
, "%% Missing RTLIST\n");
7074 return CMD_WARNING_CONFIG_FAILED
;
7076 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7077 if (ret
!= CMD_SUCCESS
)
7082 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7083 ecommunity_free(&bgp
->vpn_policy
[afi
]
7084 .import_redirect_rtlist
);
7085 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
7086 ecommunity_dup(ecom
);
7088 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7089 ecommunity_free(&bgp
->vpn_policy
[afi
]
7090 .import_redirect_rtlist
);
7091 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
7095 ecommunity_free(&ecom
);
7100 DEFUN_NOSH (address_family_ipv4_safi
,
7101 address_family_ipv4_safi_cmd
,
7102 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7103 "Enter Address Family command mode\n"
7105 BGP_SAFI_WITH_LABEL_HELP_STR
)
7109 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7110 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7111 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7112 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7113 && safi
!= SAFI_EVPN
) {
7115 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7116 return CMD_WARNING_CONFIG_FAILED
;
7118 vty
->node
= bgp_node_type(AFI_IP
, safi
);
7120 vty
->node
= BGP_IPV4_NODE
;
7125 DEFUN_NOSH (address_family_ipv6_safi
,
7126 address_family_ipv6_safi_cmd
,
7127 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7128 "Enter Address Family command mode\n"
7130 BGP_SAFI_WITH_LABEL_HELP_STR
)
7133 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7134 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7135 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7136 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7137 && safi
!= SAFI_EVPN
) {
7139 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7140 return CMD_WARNING_CONFIG_FAILED
;
7142 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
7144 vty
->node
= BGP_IPV6_NODE
;
7149 #ifdef KEEP_OLD_VPN_COMMANDS
7150 DEFUN_NOSH (address_family_vpnv4
,
7151 address_family_vpnv4_cmd
,
7152 "address-family vpnv4 [unicast]",
7153 "Enter Address Family command mode\n"
7155 "Address Family modifier\n")
7157 vty
->node
= BGP_VPNV4_NODE
;
7161 DEFUN_NOSH (address_family_vpnv6
,
7162 address_family_vpnv6_cmd
,
7163 "address-family vpnv6 [unicast]",
7164 "Enter Address Family command mode\n"
7166 "Address Family modifier\n")
7168 vty
->node
= BGP_VPNV6_NODE
;
7171 #endif /* KEEP_OLD_VPN_COMMANDS */
7173 DEFUN_NOSH (address_family_evpn
,
7174 address_family_evpn_cmd
,
7175 "address-family l2vpn evpn",
7176 "Enter Address Family command mode\n"
7178 "Address Family modifier\n")
7180 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7181 vty
->node
= BGP_EVPN_NODE
;
7185 DEFUN_NOSH (exit_address_family
,
7186 exit_address_family_cmd
,
7187 "exit-address-family",
7188 "Exit from Address Family configuration mode\n")
7190 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7191 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7192 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7193 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7194 || vty
->node
== BGP_EVPN_NODE
7195 || vty
->node
== BGP_FLOWSPECV4_NODE
7196 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7197 vty
->node
= BGP_NODE
;
7201 /* Recalculate bestpath and re-advertise a prefix */
7202 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7203 const char *ip_str
, afi_t afi
, safi_t safi
,
7204 struct prefix_rd
*prd
)
7207 struct prefix match
;
7208 struct bgp_node
*rn
;
7209 struct bgp_node
*rm
;
7211 struct bgp_table
*table
;
7212 struct bgp_table
*rib
;
7214 /* BGP structure lookup. */
7216 bgp
= bgp_lookup_by_name(view_name
);
7218 vty_out(vty
, "%% Can't find BGP instance %s\n",
7223 bgp
= bgp_get_default();
7225 vty_out(vty
, "%% No BGP process is configured\n");
7230 /* Check IP address argument. */
7231 ret
= str2prefix(ip_str
, &match
);
7233 vty_out(vty
, "%% address is malformed\n");
7237 match
.family
= afi2family(afi
);
7238 rib
= bgp
->rib
[afi
][safi
];
7240 if (safi
== SAFI_MPLS_VPN
) {
7241 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7242 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7245 table
= bgp_node_get_bgp_table_info(rn
);
7246 if (table
!= NULL
) {
7248 if ((rm
= bgp_node_match(table
, &match
))
7251 == match
.prefixlen
) {
7253 BGP_NODE_USER_CLEAR
);
7254 bgp_process(bgp
, rm
, afi
, safi
);
7256 bgp_unlock_node(rm
);
7261 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7262 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7263 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7264 bgp_process(bgp
, rn
, afi
, safi
);
7266 bgp_unlock_node(rn
);
7273 /* one clear bgp command to rule them all */
7274 DEFUN (clear_ip_bgp_all
,
7275 clear_ip_bgp_all_cmd
,
7276 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> [<soft [<in|out>]|in [prefix-filter]|out>]",
7280 BGP_INSTANCE_HELP_STR
7283 BGP_SAFI_WITH_LABEL_HELP_STR
7284 "Address Family modifier\n"
7286 "BGP neighbor address to clear\n"
7287 "BGP IPv6 neighbor to clear\n"
7288 "BGP neighbor on interface to clear\n"
7289 "Clear peers with the AS number\n"
7290 "Clear all external peers\n"
7291 "Clear all members of peer-group\n"
7292 "BGP peer-group name\n"
7297 "Push out prefix-list ORF and do inbound soft reconfig\n"
7302 afi_t afi
= AFI_IP6
;
7303 safi_t safi
= SAFI_UNICAST
;
7304 enum clear_sort clr_sort
= clear_peer
;
7305 enum bgp_clear_type clr_type
;
7306 char *clr_arg
= NULL
;
7310 /* clear [ip] bgp */
7311 if (argv_find(argv
, argc
, "ip", &idx
))
7314 /* [<vrf> VIEWVRFNAME] */
7315 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7316 vrf
= argv
[idx
+ 1]->arg
;
7318 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7320 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7321 /* [<view> VIEWVRFNAME] */
7322 vrf
= argv
[idx
+ 1]->arg
;
7325 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7326 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7327 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7329 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */
7330 if (argv_find(argv
, argc
, "*", &idx
)) {
7331 clr_sort
= clear_all
;
7332 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7333 clr_sort
= clear_peer
;
7334 clr_arg
= argv
[idx
]->arg
;
7335 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7336 clr_sort
= clear_peer
;
7337 clr_arg
= argv
[idx
]->arg
;
7338 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7339 clr_sort
= clear_group
;
7341 clr_arg
= argv
[idx
]->arg
;
7342 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7343 clr_sort
= clear_peer
;
7344 clr_arg
= argv
[idx
]->arg
;
7345 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7346 clr_sort
= clear_as
;
7347 clr_arg
= argv
[idx
]->arg
;
7348 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7349 clr_sort
= clear_external
;
7352 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7353 if (argv_find(argv
, argc
, "soft", &idx
)) {
7354 if (argv_find(argv
, argc
, "in", &idx
)
7355 || argv_find(argv
, argc
, "out", &idx
))
7356 clr_type
= strmatch(argv
[idx
]->text
, "in")
7358 : BGP_CLEAR_SOFT_OUT
;
7360 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7361 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7362 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7363 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7364 : BGP_CLEAR_SOFT_IN
;
7365 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7366 clr_type
= BGP_CLEAR_SOFT_OUT
;
7368 clr_type
= BGP_CLEAR_SOFT_NONE
;
7370 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7373 DEFUN (clear_ip_bgp_prefix
,
7374 clear_ip_bgp_prefix_cmd
,
7375 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7379 BGP_INSTANCE_HELP_STR
7380 "Clear bestpath and re-advertise\n"
7384 char *prefix
= NULL
;
7388 /* [<view|vrf> VIEWVRFNAME] */
7389 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7390 vrf
= argv
[idx
+ 1]->arg
;
7392 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7394 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7395 /* [<view> VIEWVRFNAME] */
7396 vrf
= argv
[idx
+ 1]->arg
;
7400 prefix
= argv
[argc
- 1]->arg
;
7402 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7405 DEFUN (clear_bgp_ipv6_safi_prefix
,
7406 clear_bgp_ipv6_safi_prefix_cmd
,
7407 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7413 "Clear bestpath and re-advertise\n"
7417 int idx_ipv6_prefix
= 0;
7418 safi_t safi
= SAFI_UNICAST
;
7419 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7420 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7422 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7423 return bgp_clear_prefix(
7424 vty
, NULL
, prefix
, AFI_IP6
,
7428 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7429 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7430 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7434 BGP_INSTANCE_HELP_STR
7437 "Clear bestpath and re-advertise\n"
7441 int idx_vrfview
= 0;
7442 int idx_ipv6_prefix
= 0;
7443 safi_t safi
= SAFI_UNICAST
;
7444 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7445 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7446 char *vrfview
= NULL
;
7448 /* [<view|vrf> VIEWVRFNAME] */
7449 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
7450 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7451 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
7453 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
7454 /* [<view> VIEWVRFNAME] */
7455 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7457 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7459 return bgp_clear_prefix(
7460 vty
, vrfview
, prefix
,
7461 AFI_IP6
, safi
, NULL
);
7464 DEFUN (show_bgp_views
,
7466 "show [ip] bgp views",
7470 "Show the defined BGP views\n")
7472 struct list
*inst
= bm
->bgp
;
7473 struct listnode
*node
;
7476 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7477 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7481 vty_out(vty
, "Defined BGP views:\n");
7482 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7484 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7486 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7493 DEFUN (show_bgp_vrfs
,
7495 "show [ip] bgp vrfs [json]",
7502 char buf
[ETHER_ADDR_STRLEN
];
7503 struct list
*inst
= bm
->bgp
;
7504 struct listnode
*node
;
7506 bool uj
= use_json(argc
, argv
);
7507 json_object
*json
= NULL
;
7508 json_object
*json_vrfs
= NULL
;
7511 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7512 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7517 json
= json_object_new_object();
7518 json_vrfs
= json_object_new_object();
7521 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7522 const char *name
, *type
;
7524 struct listnode
*node2
, *nnode2
;
7525 int peers_cfg
, peers_estb
;
7526 json_object
*json_vrf
= NULL
;
7529 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7533 if (!uj
&& count
== 1)
7535 "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n",
7536 "Type", "Id", "routerId", "#PeersVfg",
7537 "#PeersEstb", "Name", "L3-VNI", "Rmac");
7539 peers_cfg
= peers_estb
= 0;
7541 json_vrf
= json_object_new_object();
7544 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
7545 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7548 if (peer
->status
== Established
)
7552 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7553 name
= VRF_DEFAULT_NAME
;
7562 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7564 : (int64_t)bgp
->vrf_id
;
7565 json_object_string_add(json_vrf
, "type", type
);
7566 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7567 json_object_string_add(json_vrf
, "routerId",
7568 inet_ntoa(bgp
->router_id
));
7569 json_object_int_add(json_vrf
, "numConfiguredPeers",
7571 json_object_int_add(json_vrf
, "numEstablishedPeers",
7574 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7575 json_object_string_add(
7577 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7578 json_object_object_add(json_vrfs
, name
, json_vrf
);
7581 "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n",
7583 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7585 inet_ntoa(bgp
->router_id
), peers_cfg
,
7586 peers_estb
, name
, bgp
->l3vni
,
7587 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7591 json_object_object_add(json
, "vrfs", json_vrfs
);
7593 json_object_int_add(json
, "totalVrfs", count
);
7595 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7596 json
, JSON_C_TO_STRING_PRETTY
));
7597 json_object_free(json
);
7601 "\nTotal number of VRFs (including default): %d\n",
7608 DEFUN (show_bgp_mac_hash
,
7609 show_bgp_mac_hash_cmd
,
7610 "show bgp mac hash",
7614 "Mac Address database\n")
7616 bgp_mac_dump_table(vty
);
7621 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
7623 struct vty
*vty
= (struct vty
*)args
;
7624 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
7626 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7630 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7632 vty_out(vty
, "self nexthop database:\n");
7633 bgp_nexthop_show_address_hash(vty
, bgp
);
7635 vty_out(vty
, "Tunnel-ip database:\n");
7636 hash_iterate(bgp
->tip_hash
,
7637 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
7641 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7642 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7643 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7644 "martian next-hops\n"
7645 "martian next-hop database\n")
7647 struct bgp
*bgp
= NULL
;
7651 /* [<vrf> VIEWVRFNAME] */
7652 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7653 name
= argv
[idx
+ 1]->arg
;
7654 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7656 } else if (argv_find(argv
, argc
, "view", &idx
))
7657 /* [<view> VIEWVRFNAME] */
7658 name
= argv
[idx
+ 1]->arg
;
7660 bgp
= bgp_lookup_by_name(name
);
7662 bgp
= bgp_get_default();
7665 vty_out(vty
, "%% No BGP process is configured\n");
7668 bgp_show_martian_nexthops(vty
, bgp
);
7673 DEFUN (show_bgp_memory
,
7674 show_bgp_memory_cmd
,
7675 "show [ip] bgp memory",
7679 "Global BGP memory statistics\n")
7681 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7682 unsigned long count
;
7684 /* RIB related usage stats */
7685 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7686 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7687 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7688 count
* sizeof(struct bgp_node
)));
7690 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7691 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7692 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7693 count
* sizeof(struct bgp_path_info
)));
7694 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7695 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7698 memstrbuf
, sizeof(memstrbuf
),
7699 count
* sizeof(struct bgp_path_info_extra
)));
7701 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7702 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7703 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7704 count
* sizeof(struct bgp_static
)));
7706 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7707 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7708 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7709 count
* sizeof(struct bpacket
)));
7712 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7713 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7714 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7715 count
* sizeof(struct bgp_adj_in
)));
7716 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7717 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7718 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7719 count
* sizeof(struct bgp_adj_out
)));
7721 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7722 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7724 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7725 count
* sizeof(struct bgp_nexthop_cache
)));
7727 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7728 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7730 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7731 count
* sizeof(struct bgp_damp_info
)));
7734 count
= attr_count();
7735 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7736 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7737 count
* sizeof(struct attr
)));
7739 if ((count
= attr_unknown_count()))
7740 vty_out(vty
, "%ld unknown attributes\n", count
);
7742 /* AS_PATH attributes */
7743 count
= aspath_count();
7744 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7745 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7746 count
* sizeof(struct aspath
)));
7748 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7749 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7750 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7751 count
* sizeof(struct assegment
)));
7753 /* Other attributes */
7754 if ((count
= community_count()))
7755 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7756 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7757 count
* sizeof(struct community
)));
7758 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7759 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7760 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7761 count
* sizeof(struct ecommunity
)));
7762 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7764 "%ld BGP large-community entries, using %s of memory\n",
7765 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7766 count
* sizeof(struct lcommunity
)));
7768 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7769 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7770 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7771 count
* sizeof(struct cluster_list
)));
7773 /* Peer related usage */
7774 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7775 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7776 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7777 count
* sizeof(struct peer
)));
7779 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7780 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7781 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7782 count
* sizeof(struct peer_group
)));
7785 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
7786 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
7787 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7788 count
* sizeof(struct hash
)));
7789 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
7790 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
7791 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7792 count
* sizeof(struct hash_bucket
)));
7793 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7794 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7795 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7796 count
* sizeof(regex_t
)));
7800 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7802 json_object
*bestpath
= json_object_new_object();
7804 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7805 json_object_string_add(bestpath
, "asPath", "ignore");
7807 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7808 json_object_string_add(bestpath
, "asPath", "confed");
7810 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7811 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7812 json_object_string_add(bestpath
, "multiPathRelax",
7815 json_object_string_add(bestpath
, "multiPathRelax",
7818 json_object_string_add(bestpath
, "multiPathRelax", "false");
7820 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7821 json_object_string_add(bestpath
, "compareRouterId", "true");
7822 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7823 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7824 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7825 json_object_string_add(bestpath
, "med", "confed");
7826 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7827 json_object_string_add(bestpath
, "med",
7828 "missing-as-worst");
7830 json_object_string_add(bestpath
, "med", "true");
7833 json_object_object_add(json
, "bestPath", bestpath
);
7836 /* Show BGP peer's summary information. */
7837 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7838 bool use_json
, json_object
*json
)
7841 struct listnode
*node
, *nnode
;
7842 unsigned int count
= 0, dn_count
= 0;
7843 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7844 char neighbor_buf
[VTY_BUFSIZ
];
7845 int neighbor_col_default_width
= 16;
7847 int max_neighbor_width
= 0;
7849 json_object
*json_peer
= NULL
;
7850 json_object
*json_peers
= NULL
;
7851 struct peer_af
*paf
;
7853 /* labeled-unicast routes are installed in the unicast table so in order
7855 * display the correct PfxRcd value we must look at SAFI_UNICAST
7857 if (safi
== SAFI_LABELED_UNICAST
)
7858 pfx_rcd_safi
= SAFI_UNICAST
;
7860 pfx_rcd_safi
= safi
;
7864 json
= json_object_new_object();
7866 json_peers
= json_object_new_object();
7868 /* Loop over all neighbors that will be displayed to determine
7870 * characters are needed for the Neighbor column
7872 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7873 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7876 if (peer
->afc
[afi
][safi
]) {
7877 memset(dn_flag
, '\0', sizeof(dn_flag
));
7878 if (peer_dynamic_neighbor(peer
))
7882 && bgp_flag_check(bgp
,
7883 BGP_FLAG_SHOW_HOSTNAME
))
7884 sprintf(neighbor_buf
, "%s%s(%s) ",
7885 dn_flag
, peer
->hostname
,
7888 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7891 len
= strlen(neighbor_buf
);
7893 if (len
> max_neighbor_width
)
7894 max_neighbor_width
= len
;
7898 /* Originally we displayed the Neighbor column as 16
7899 * characters wide so make that the default
7901 if (max_neighbor_width
< neighbor_col_default_width
)
7902 max_neighbor_width
= neighbor_col_default_width
;
7905 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7906 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7909 if (!peer
->afc
[afi
][safi
])
7914 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7917 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7919 : (int64_t)bgp
->vrf_id
;
7921 /* Usage summary and header */
7923 json_object_string_add(
7925 inet_ntoa(bgp
->router_id
));
7926 json_object_int_add(json
, "as", bgp
->as
);
7927 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7928 json_object_string_add(
7931 == BGP_INSTANCE_TYPE_DEFAULT
)
7936 "BGP router identifier %s, local AS number %u vrf-id %d",
7937 inet_ntoa(bgp
->router_id
), bgp
->as
,
7938 bgp
->vrf_id
== VRF_UNKNOWN
7940 : (int)bgp
->vrf_id
);
7944 if (bgp_update_delay_configured(bgp
)) {
7946 json_object_int_add(
7947 json
, "updateDelayLimit",
7948 bgp
->v_update_delay
);
7950 if (bgp
->v_update_delay
7951 != bgp
->v_establish_wait
)
7952 json_object_int_add(
7954 "updateDelayEstablishWait",
7955 bgp
->v_establish_wait
);
7957 if (bgp_update_delay_active(bgp
)) {
7958 json_object_string_add(
7960 "updateDelayFirstNeighbor",
7961 bgp
->update_delay_begin_time
);
7962 json_object_boolean_true_add(
7964 "updateDelayInProgress");
7966 if (bgp
->update_delay_over
) {
7967 json_object_string_add(
7969 "updateDelayFirstNeighbor",
7970 bgp
->update_delay_begin_time
);
7971 json_object_string_add(
7973 "updateDelayBestpathResumed",
7974 bgp
->update_delay_end_time
);
7975 json_object_string_add(
7977 "updateDelayZebraUpdateResume",
7978 bgp
->update_delay_zebra_resume_time
);
7979 json_object_string_add(
7981 "updateDelayPeerUpdateResume",
7982 bgp
->update_delay_peers_resume_time
);
7987 "Read-only mode update-delay limit: %d seconds\n",
7988 bgp
->v_update_delay
);
7989 if (bgp
->v_update_delay
7990 != bgp
->v_establish_wait
)
7992 " Establish wait: %d seconds\n",
7993 bgp
->v_establish_wait
);
7995 if (bgp_update_delay_active(bgp
)) {
7997 " First neighbor established: %s\n",
7998 bgp
->update_delay_begin_time
);
8000 " Delay in progress\n");
8002 if (bgp
->update_delay_over
) {
8004 " First neighbor established: %s\n",
8005 bgp
->update_delay_begin_time
);
8007 " Best-paths resumed: %s\n",
8008 bgp
->update_delay_end_time
);
8010 " zebra update resumed: %s\n",
8011 bgp
->update_delay_zebra_resume_time
);
8013 " peers update resumed: %s\n",
8014 bgp
->update_delay_peers_resume_time
);
8021 if (bgp_maxmed_onstartup_configured(bgp
)
8022 && bgp
->maxmed_active
)
8023 json_object_boolean_true_add(
8024 json
, "maxMedOnStartup");
8025 if (bgp
->v_maxmed_admin
)
8026 json_object_boolean_true_add(
8027 json
, "maxMedAdministrative");
8029 json_object_int_add(
8030 json
, "tableVersion",
8031 bgp_table_version(bgp
->rib
[afi
][safi
]));
8033 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8034 json_object_int_add(json
, "ribCount", ents
);
8035 json_object_int_add(
8037 ents
* sizeof(struct bgp_node
));
8039 ents
= listcount(bgp
->peer
);
8040 json_object_int_add(json
, "peerCount", ents
);
8041 json_object_int_add(json
, "peerMemory",
8042 ents
* sizeof(struct peer
));
8044 if ((ents
= listcount(bgp
->group
))) {
8045 json_object_int_add(
8046 json
, "peerGroupCount", ents
);
8047 json_object_int_add(
8048 json
, "peerGroupMemory",
8049 ents
* sizeof(struct
8053 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8054 BGP_CONFIG_DAMPENING
))
8055 json_object_boolean_true_add(
8056 json
, "dampeningEnabled");
8058 if (bgp_maxmed_onstartup_configured(bgp
)
8059 && bgp
->maxmed_active
)
8061 "Max-med on-startup active\n");
8062 if (bgp
->v_maxmed_admin
)
8064 "Max-med administrative active\n");
8066 vty_out(vty
, "BGP table version %" PRIu64
"\n",
8067 bgp_table_version(bgp
->rib
[afi
][safi
]));
8069 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8071 "RIB entries %ld, using %s of memory\n",
8073 mtype_memstr(memstrbuf
,
8075 ents
* sizeof(struct
8078 /* Peer related usage */
8079 ents
= listcount(bgp
->peer
);
8080 vty_out(vty
, "Peers %ld, using %s of memory\n",
8083 memstrbuf
, sizeof(memstrbuf
),
8084 ents
* sizeof(struct peer
)));
8086 if ((ents
= listcount(bgp
->group
)))
8088 "Peer groups %ld, using %s of memory\n",
8093 ents
* sizeof(struct
8096 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8097 BGP_CONFIG_DAMPENING
))
8098 vty_out(vty
, "Dampening enabled.\n");
8101 /* Subtract 8 here because 'Neighbor' is
8103 vty_out(vty
, "Neighbor");
8104 vty_out(vty
, "%*s", max_neighbor_width
- 8,
8107 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
8114 json_peer
= json_object_new_object();
8116 if (peer_dynamic_neighbor(peer
)) {
8118 json_object_boolean_true_add(json_peer
,
8123 json_object_string_add(json_peer
, "hostname",
8126 if (peer
->domainname
)
8127 json_object_string_add(json_peer
, "domainname",
8130 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
8131 json_object_int_add(json_peer
, "version", 4);
8132 json_object_int_add(json_peer
, "msgRcvd",
8133 PEER_TOTAL_RX(peer
));
8134 json_object_int_add(json_peer
, "msgSent",
8135 PEER_TOTAL_TX(peer
));
8137 json_object_int_add(json_peer
, "tableVersion",
8138 peer
->version
[afi
][safi
]);
8139 json_object_int_add(json_peer
, "outq",
8141 json_object_int_add(json_peer
, "inq", 0);
8142 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8143 use_json
, json_peer
);
8146 * Adding "pfxRcd" field to match with the corresponding
8147 * CLI. "prefixReceivedCount" will be deprecated in
8150 json_object_int_add(json_peer
, "prefixReceivedCount",
8151 peer
->pcount
[afi
][pfx_rcd_safi
]);
8152 json_object_int_add(json_peer
, "pfxRcd",
8153 peer
->pcount
[afi
][pfx_rcd_safi
]);
8155 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
8156 if (paf
&& PAF_SUBGRP(paf
))
8157 json_object_int_add(json_peer
,
8159 (PAF_SUBGRP(paf
))->scount
);
8161 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8162 json_object_string_add(json_peer
, "state",
8164 else if (peer
->afc_recv
[afi
][safi
])
8165 json_object_string_add(
8167 lookup_msg(bgp_status_msg
, peer
->status
,
8169 else if (CHECK_FLAG(peer
->sflags
,
8170 PEER_STATUS_PREFIX_OVERFLOW
))
8171 json_object_string_add(json_peer
, "state",
8174 json_object_string_add(
8176 lookup_msg(bgp_status_msg
, peer
->status
,
8180 json_object_string_add(json_peer
, "idType",
8182 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8183 json_object_string_add(json_peer
, "idType",
8185 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8186 json_object_string_add(json_peer
, "idType",
8189 json_object_object_add(json_peers
, peer
->host
,
8192 memset(dn_flag
, '\0', sizeof(dn_flag
));
8193 if (peer_dynamic_neighbor(peer
)) {
8199 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8200 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8201 peer
->hostname
, peer
->host
);
8203 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8205 /* pad the neighbor column with spaces */
8206 if (len
< max_neighbor_width
)
8207 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8210 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8211 peer
->as
, PEER_TOTAL_RX(peer
),
8212 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8213 0, peer
->obuf
->count
,
8214 peer_uptime(peer
->uptime
, timebuf
,
8215 BGP_UPTIME_LEN
, 0, NULL
));
8217 if (peer
->status
== Established
)
8218 if (peer
->afc_recv
[afi
][safi
])
8219 vty_out(vty
, " %12ld",
8223 vty_out(vty
, " NoNeg");
8225 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8226 vty_out(vty
, " Idle (Admin)");
8227 else if (CHECK_FLAG(
8229 PEER_STATUS_PREFIX_OVERFLOW
))
8230 vty_out(vty
, " Idle (PfxCt)");
8232 vty_out(vty
, " %12s",
8233 lookup_msg(bgp_status_msg
,
8234 peer
->status
, NULL
));
8241 json_object_object_add(json
, "peers", json_peers
);
8243 json_object_int_add(json
, "totalPeers", count
);
8244 json_object_int_add(json
, "dynamicPeers", dn_count
);
8246 bgp_show_bestpath_json(bgp
, json
);
8248 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8249 json
, JSON_C_TO_STRING_PRETTY
));
8250 json_object_free(json
);
8253 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8255 vty_out(vty
, "No %s neighbor is configured\n",
8256 afi_safi_print(afi
, safi
));
8260 vty_out(vty
, "* - dynamic neighbor\n");
8261 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8262 dn_count
, bgp
->dynamic_neighbors_limit
);
8269 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8270 int safi
, bool use_json
,
8274 int afi_wildcard
= (afi
== AFI_MAX
);
8275 int safi_wildcard
= (safi
== SAFI_MAX
);
8276 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8277 bool nbr_output
= false;
8279 if (use_json
&& is_wildcard
)
8280 vty_out(vty
, "{\n");
8282 afi
= 1; /* AFI_IP */
8283 while (afi
< AFI_MAX
) {
8285 safi
= 1; /* SAFI_UNICAST */
8286 while (safi
< SAFI_MAX
) {
8287 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8291 * So limit output to those afi/safi
8293 * actualy have something interesting in
8297 json
= json_object_new_object();
8300 vty_out(vty
, ",\n");
8304 vty_out(vty
, "\"%s\":",
8308 vty_out(vty
, "\n%s Summary:\n",
8313 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
8325 if (use_json
&& is_wildcard
)
8326 vty_out(vty
, "}\n");
8327 else if (!nbr_output
) {
8329 vty_out(vty
, "{}\n");
8331 vty_out(vty
, "%% No BGP neighbors found\n");
8335 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8336 safi_t safi
, bool use_json
)
8338 struct listnode
*node
, *nnode
;
8340 json_object
*json
= NULL
;
8342 bool nbr_output
= false;
8345 vty_out(vty
, "{\n");
8347 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8350 json
= json_object_new_object();
8353 vty_out(vty
, ",\n");
8357 vty_out(vty
, "\"%s\":",
8358 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8362 vty_out(vty
, "\nInstance %s:\n",
8363 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8367 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
8371 vty_out(vty
, "}\n");
8372 else if (!nbr_output
)
8373 vty_out(vty
, "%% BGP instance not found\n");
8376 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8377 safi_t safi
, bool use_json
)
8382 if (strmatch(name
, "all")) {
8383 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8387 bgp
= bgp_lookup_by_name(name
);
8391 vty_out(vty
, "{}\n");
8394 "%% BGP instance not found\n");
8398 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
8404 bgp
= bgp_get_default();
8407 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
8410 vty_out(vty
, "{}\n");
8412 vty_out(vty
, "%% BGP instance not found\n");
8419 /* `show [ip] bgp summary' commands. */
8420 DEFUN (show_ip_bgp_summary
,
8421 show_ip_bgp_summary_cmd
,
8422 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8426 BGP_INSTANCE_HELP_STR
8428 BGP_SAFI_WITH_LABEL_HELP_STR
8429 "Summary of BGP neighbor status\n"
8433 afi_t afi
= AFI_MAX
;
8434 safi_t safi
= SAFI_MAX
;
8439 if (argv_find(argv
, argc
, "ip", &idx
))
8441 /* [<vrf> VIEWVRFNAME] */
8442 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8443 vrf
= argv
[idx
+ 1]->arg
;
8444 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8446 } else if (argv_find(argv
, argc
, "view", &idx
))
8447 /* [<view> VIEWVRFNAME] */
8448 vrf
= argv
[idx
+ 1]->arg
;
8449 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8450 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8451 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8454 bool uj
= use_json(argc
, argv
);
8456 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8459 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8461 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8462 return "IPv4 Unicast";
8463 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8464 return "IPv4 Multicast";
8465 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8466 return "IPv4 Labeled Unicast";
8467 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8469 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8470 return "IPv4 Encap";
8471 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8472 return "IPv4 Flowspec";
8473 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8474 return "IPv6 Unicast";
8475 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8476 return "IPv6 Multicast";
8477 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8478 return "IPv6 Labeled Unicast";
8479 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8481 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8482 return "IPv6 Encap";
8483 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8484 return "IPv6 Flowspec";
8485 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8486 return "L2VPN EVPN";
8492 * Please note that we have intentionally camelCased
8493 * the return strings here. So if you want
8494 * to use this function, please ensure you
8495 * are doing this within json output
8497 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8499 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8500 return "ipv4Unicast";
8501 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8502 return "ipv4Multicast";
8503 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8504 return "ipv4LabeledUnicast";
8505 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8507 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8509 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8510 return "ipv4Flowspec";
8511 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8512 return "ipv6Unicast";
8513 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8514 return "ipv6Multicast";
8515 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8516 return "ipv6LabeledUnicast";
8517 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8519 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8521 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8522 return "ipv6Flowspec";
8523 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8529 /* Show BGP peer's information. */
8530 enum show_type
{ show_all
, show_peer
};
8532 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8533 afi_t afi
, safi_t safi
,
8534 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8535 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8536 bool use_json
, json_object
*json_pref
)
8539 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8540 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8542 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8543 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8544 json_object_string_add(json_pref
, "sendMode",
8545 "advertisedAndReceived");
8546 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8547 json_object_string_add(json_pref
, "sendMode",
8549 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8550 json_object_string_add(json_pref
, "sendMode",
8553 vty_out(vty
, " Send-mode: ");
8554 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8555 vty_out(vty
, "advertised");
8556 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8557 vty_out(vty
, "%sreceived",
8558 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8567 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8568 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8570 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8571 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8572 json_object_string_add(json_pref
, "recvMode",
8573 "advertisedAndReceived");
8574 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8575 json_object_string_add(json_pref
, "recvMode",
8577 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8578 json_object_string_add(json_pref
, "recvMode",
8581 vty_out(vty
, " Receive-mode: ");
8582 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8583 vty_out(vty
, "advertised");
8584 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8585 vty_out(vty
, "%sreceived",
8586 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8595 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8596 safi_t safi
, bool use_json
,
8597 json_object
*json_neigh
)
8599 struct bgp_filter
*filter
;
8600 struct peer_af
*paf
;
8601 char orf_pfx_name
[BUFSIZ
];
8603 json_object
*json_af
= NULL
;
8604 json_object
*json_prefA
= NULL
;
8605 json_object
*json_prefB
= NULL
;
8606 json_object
*json_addr
= NULL
;
8609 json_addr
= json_object_new_object();
8610 json_af
= json_object_new_object();
8611 filter
= &p
->filter
[afi
][safi
];
8613 if (peer_group_active(p
))
8614 json_object_string_add(json_addr
, "peerGroupMember",
8617 paf
= peer_af_find(p
, afi
, safi
);
8618 if (paf
&& PAF_SUBGRP(paf
)) {
8619 json_object_int_add(json_addr
, "updateGroupId",
8620 PAF_UPDGRP(paf
)->id
);
8621 json_object_int_add(json_addr
, "subGroupId",
8622 PAF_SUBGRP(paf
)->id
);
8623 json_object_int_add(json_addr
, "packetQueueLength",
8624 bpacket_queue_virtual_length(paf
));
8627 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8628 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8629 PEER_CAP_ORF_PREFIX_SM_RCV
)
8630 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8631 PEER_CAP_ORF_PREFIX_RM_ADV
)
8632 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8633 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8634 json_object_int_add(json_af
, "orfType",
8636 json_prefA
= json_object_new_object();
8637 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8638 PEER_CAP_ORF_PREFIX_SM_ADV
,
8639 PEER_CAP_ORF_PREFIX_RM_ADV
,
8640 PEER_CAP_ORF_PREFIX_SM_RCV
,
8641 PEER_CAP_ORF_PREFIX_RM_RCV
,
8642 use_json
, json_prefA
);
8643 json_object_object_add(json_af
, "orfPrefixList",
8647 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8648 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8649 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8650 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8651 PEER_CAP_ORF_PREFIX_RM_ADV
)
8652 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8653 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8654 json_object_int_add(json_af
, "orfOldType",
8655 ORF_TYPE_PREFIX_OLD
);
8656 json_prefB
= json_object_new_object();
8657 bgp_show_peer_afi_orf_cap(
8658 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8659 PEER_CAP_ORF_PREFIX_RM_ADV
,
8660 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8661 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8663 json_object_object_add(json_af
, "orfOldPrefixList",
8667 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8668 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8669 PEER_CAP_ORF_PREFIX_SM_RCV
)
8670 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8671 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8672 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8673 PEER_CAP_ORF_PREFIX_RM_ADV
)
8674 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8675 PEER_CAP_ORF_PREFIX_RM_RCV
)
8676 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8677 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8678 json_object_object_add(json_addr
, "afDependentCap",
8681 json_object_free(json_af
);
8683 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8684 orf_pfx_count
= prefix_bgp_show_prefix_list(
8685 NULL
, afi
, orf_pfx_name
, use_json
);
8687 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8688 PEER_STATUS_ORF_PREFIX_SEND
)
8690 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8691 PEER_STATUS_ORF_PREFIX_SEND
))
8692 json_object_boolean_true_add(json_neigh
,
8695 json_object_int_add(json_addr
, "orfRecvCounter",
8698 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8699 PEER_STATUS_ORF_WAIT_REFRESH
))
8700 json_object_string_add(
8701 json_addr
, "orfFirstUpdate",
8702 "deferredUntilORFOrRouteRefreshRecvd");
8704 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8705 PEER_FLAG_REFLECTOR_CLIENT
))
8706 json_object_boolean_true_add(json_addr
,
8707 "routeReflectorClient");
8708 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8709 PEER_FLAG_RSERVER_CLIENT
))
8710 json_object_boolean_true_add(json_addr
,
8711 "routeServerClient");
8712 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8713 json_object_boolean_true_add(json_addr
,
8714 "inboundSoftConfigPermit");
8716 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8717 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8718 json_object_boolean_true_add(
8720 "privateAsNumsAllReplacedInUpdatesToNbr");
8721 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8722 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8723 json_object_boolean_true_add(
8725 "privateAsNumsReplacedInUpdatesToNbr");
8726 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8727 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8728 json_object_boolean_true_add(
8730 "privateAsNumsAllRemovedInUpdatesToNbr");
8731 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8732 PEER_FLAG_REMOVE_PRIVATE_AS
))
8733 json_object_boolean_true_add(
8735 "privateAsNumsRemovedInUpdatesToNbr");
8737 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8738 json_object_boolean_true_add(
8740 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8743 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8744 json_object_string_add(json_addr
,
8745 "overrideASNsInOutboundUpdates",
8746 "ifAspathEqualRemoteAs");
8748 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8749 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8750 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8751 json_object_boolean_true_add(json_addr
,
8752 "routerAlwaysNextHop");
8753 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8754 PEER_FLAG_AS_PATH_UNCHANGED
))
8755 json_object_boolean_true_add(
8756 json_addr
, "unchangedAsPathPropogatedToNbr");
8757 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8758 PEER_FLAG_NEXTHOP_UNCHANGED
))
8759 json_object_boolean_true_add(
8760 json_addr
, "unchangedNextHopPropogatedToNbr");
8761 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8762 json_object_boolean_true_add(
8763 json_addr
, "unchangedMedPropogatedToNbr");
8764 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8765 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8766 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8767 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8768 PEER_FLAG_SEND_COMMUNITY
)
8769 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8770 PEER_FLAG_SEND_EXT_COMMUNITY
))
8771 json_object_string_add(json_addr
,
8772 "commAttriSentToNbr",
8773 "extendedAndStandard");
8774 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8775 PEER_FLAG_SEND_EXT_COMMUNITY
))
8776 json_object_string_add(json_addr
,
8777 "commAttriSentToNbr",
8780 json_object_string_add(json_addr
,
8781 "commAttriSentToNbr",
8784 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8785 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8786 if (p
->default_rmap
[afi
][safi
].name
)
8787 json_object_string_add(
8788 json_addr
, "defaultRouteMap",
8789 p
->default_rmap
[afi
][safi
].name
);
8791 if (paf
&& PAF_SUBGRP(paf
)
8792 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8793 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8794 json_object_boolean_true_add(json_addr
,
8797 json_object_boolean_true_add(json_addr
,
8801 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8802 if (is_evpn_enabled())
8803 json_object_boolean_true_add(
8804 json_addr
, "advertiseAllVnis");
8807 if (filter
->plist
[FILTER_IN
].name
8808 || filter
->dlist
[FILTER_IN
].name
8809 || filter
->aslist
[FILTER_IN
].name
8810 || filter
->map
[RMAP_IN
].name
)
8811 json_object_boolean_true_add(json_addr
,
8812 "inboundPathPolicyConfig");
8813 if (filter
->plist
[FILTER_OUT
].name
8814 || filter
->dlist
[FILTER_OUT
].name
8815 || filter
->aslist
[FILTER_OUT
].name
8816 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8817 json_object_boolean_true_add(
8818 json_addr
, "outboundPathPolicyConfig");
8821 if (filter
->plist
[FILTER_IN
].name
)
8822 json_object_string_add(json_addr
,
8823 "incomingUpdatePrefixFilterList",
8824 filter
->plist
[FILTER_IN
].name
);
8825 if (filter
->plist
[FILTER_OUT
].name
)
8826 json_object_string_add(json_addr
,
8827 "outgoingUpdatePrefixFilterList",
8828 filter
->plist
[FILTER_OUT
].name
);
8830 /* distribute-list */
8831 if (filter
->dlist
[FILTER_IN
].name
)
8832 json_object_string_add(
8833 json_addr
, "incomingUpdateNetworkFilterList",
8834 filter
->dlist
[FILTER_IN
].name
);
8835 if (filter
->dlist
[FILTER_OUT
].name
)
8836 json_object_string_add(
8837 json_addr
, "outgoingUpdateNetworkFilterList",
8838 filter
->dlist
[FILTER_OUT
].name
);
8841 if (filter
->aslist
[FILTER_IN
].name
)
8842 json_object_string_add(json_addr
,
8843 "incomingUpdateAsPathFilterList",
8844 filter
->aslist
[FILTER_IN
].name
);
8845 if (filter
->aslist
[FILTER_OUT
].name
)
8846 json_object_string_add(json_addr
,
8847 "outgoingUpdateAsPathFilterList",
8848 filter
->aslist
[FILTER_OUT
].name
);
8851 if (filter
->map
[RMAP_IN
].name
)
8852 json_object_string_add(
8853 json_addr
, "routeMapForIncomingAdvertisements",
8854 filter
->map
[RMAP_IN
].name
);
8855 if (filter
->map
[RMAP_OUT
].name
)
8856 json_object_string_add(
8857 json_addr
, "routeMapForOutgoingAdvertisements",
8858 filter
->map
[RMAP_OUT
].name
);
8860 /* ebgp-requires-policy (inbound) */
8861 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8862 && !bgp_inbound_policy_exists(p
, filter
))
8863 json_object_string_add(
8864 json_addr
, "inboundEbgpRequiresPolicy",
8865 "Inbound updates discarded due to missing policy");
8867 /* ebgp-requires-policy (outbound) */
8868 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8869 && (!bgp_outbound_policy_exists(p
, filter
)))
8870 json_object_string_add(
8871 json_addr
, "outboundEbgpRequiresPolicy",
8872 "Outbound updates discarded due to missing policy");
8874 /* unsuppress-map */
8875 if (filter
->usmap
.name
)
8876 json_object_string_add(json_addr
,
8877 "selectiveUnsuppressRouteMap",
8878 filter
->usmap
.name
);
8880 /* Receive prefix count */
8881 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8882 p
->pcount
[afi
][safi
]);
8883 if (paf
&& PAF_SUBGRP(paf
))
8884 json_object_int_add(json_addr
, "sentPrefixCounter",
8885 (PAF_SUBGRP(paf
))->scount
);
8887 /* Maximum prefix */
8888 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8889 json_object_int_add(json_addr
, "prefixAllowedMax",
8890 p
->pmax
[afi
][safi
]);
8891 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8892 PEER_FLAG_MAX_PREFIX_WARNING
))
8893 json_object_boolean_true_add(
8894 json_addr
, "prefixAllowedMaxWarning");
8895 json_object_int_add(json_addr
,
8896 "prefixAllowedWarningThresh",
8897 p
->pmax_threshold
[afi
][safi
]);
8898 if (p
->pmax_restart
[afi
][safi
])
8899 json_object_int_add(
8901 "prefixAllowedRestartIntervalMsecs",
8902 p
->pmax_restart
[afi
][safi
] * 60000);
8904 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8908 filter
= &p
->filter
[afi
][safi
];
8910 vty_out(vty
, " For address family: %s\n",
8911 afi_safi_print(afi
, safi
));
8913 if (peer_group_active(p
))
8914 vty_out(vty
, " %s peer-group member\n",
8917 paf
= peer_af_find(p
, afi
, safi
);
8918 if (paf
&& PAF_SUBGRP(paf
)) {
8919 vty_out(vty
, " Update group %" PRIu64
8920 ", subgroup %" PRIu64
"\n",
8921 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8922 vty_out(vty
, " Packet Queue length %d\n",
8923 bpacket_queue_virtual_length(paf
));
8925 vty_out(vty
, " Not part of any update group\n");
8927 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8928 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8929 PEER_CAP_ORF_PREFIX_SM_RCV
)
8930 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8931 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8932 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8933 PEER_CAP_ORF_PREFIX_RM_ADV
)
8934 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8935 PEER_CAP_ORF_PREFIX_RM_RCV
)
8936 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8937 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8938 vty_out(vty
, " AF-dependant capabilities:\n");
8940 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8941 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8942 PEER_CAP_ORF_PREFIX_SM_RCV
)
8943 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8944 PEER_CAP_ORF_PREFIX_RM_ADV
)
8945 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8946 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8948 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8950 bgp_show_peer_afi_orf_cap(
8951 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8952 PEER_CAP_ORF_PREFIX_RM_ADV
,
8953 PEER_CAP_ORF_PREFIX_SM_RCV
,
8954 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8956 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8957 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8958 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8959 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8960 PEER_CAP_ORF_PREFIX_RM_ADV
)
8961 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8962 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8964 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8965 ORF_TYPE_PREFIX_OLD
);
8966 bgp_show_peer_afi_orf_cap(
8967 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8968 PEER_CAP_ORF_PREFIX_RM_ADV
,
8969 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8970 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8973 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8974 orf_pfx_count
= prefix_bgp_show_prefix_list(
8975 NULL
, afi
, orf_pfx_name
, use_json
);
8977 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8978 PEER_STATUS_ORF_PREFIX_SEND
)
8980 vty_out(vty
, " Outbound Route Filter (ORF):");
8981 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8982 PEER_STATUS_ORF_PREFIX_SEND
))
8983 vty_out(vty
, " sent;");
8985 vty_out(vty
, " received (%d entries)",
8989 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8990 PEER_STATUS_ORF_WAIT_REFRESH
))
8992 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
8994 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8995 PEER_FLAG_REFLECTOR_CLIENT
))
8996 vty_out(vty
, " Route-Reflector Client\n");
8997 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8998 PEER_FLAG_RSERVER_CLIENT
))
8999 vty_out(vty
, " Route-Server Client\n");
9000 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9002 " Inbound soft reconfiguration allowed\n");
9004 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9005 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
9007 " Private AS numbers (all) replaced in updates to this neighbor\n");
9008 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9009 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
9011 " Private AS numbers replaced in updates to this neighbor\n");
9012 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9013 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
9015 " Private AS numbers (all) removed in updates to this neighbor\n");
9016 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9017 PEER_FLAG_REMOVE_PRIVATE_AS
))
9019 " Private AS numbers removed in updates to this neighbor\n");
9021 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
9022 vty_out(vty
, " %s\n",
9023 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
9024 ->human_description
);
9026 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
9028 " Override ASNs in outbound updates if aspath equals remote-as\n");
9030 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
9031 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9032 PEER_FLAG_FORCE_NEXTHOP_SELF
))
9033 vty_out(vty
, " NEXT_HOP is always this router\n");
9034 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9035 PEER_FLAG_AS_PATH_UNCHANGED
))
9037 " AS_PATH is propagated unchanged to this neighbor\n");
9038 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9039 PEER_FLAG_NEXTHOP_UNCHANGED
))
9041 " NEXT_HOP is propagated unchanged to this neighbor\n");
9042 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
9044 " MED is propagated unchanged to this neighbor\n");
9045 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
9046 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9047 PEER_FLAG_SEND_EXT_COMMUNITY
)
9048 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9049 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
9051 " Community attribute sent to this neighbor");
9052 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9053 PEER_FLAG_SEND_COMMUNITY
)
9054 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9055 PEER_FLAG_SEND_EXT_COMMUNITY
)
9056 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9057 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9058 vty_out(vty
, "(all)\n");
9059 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9060 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9061 vty_out(vty
, "(large)\n");
9062 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9063 PEER_FLAG_SEND_EXT_COMMUNITY
))
9064 vty_out(vty
, "(extended)\n");
9066 vty_out(vty
, "(standard)\n");
9068 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9069 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9070 vty_out(vty
, " Default information originate,");
9072 if (p
->default_rmap
[afi
][safi
].name
)
9073 vty_out(vty
, " default route-map %s%s,",
9074 p
->default_rmap
[afi
][safi
].map
? "*"
9076 p
->default_rmap
[afi
][safi
].name
);
9077 if (paf
&& PAF_SUBGRP(paf
)
9078 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9079 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9080 vty_out(vty
, " default sent\n");
9082 vty_out(vty
, " default not sent\n");
9085 /* advertise-vni-all */
9086 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9087 if (is_evpn_enabled())
9088 vty_out(vty
, " advertise-all-vni\n");
9091 if (filter
->plist
[FILTER_IN
].name
9092 || filter
->dlist
[FILTER_IN
].name
9093 || filter
->aslist
[FILTER_IN
].name
9094 || filter
->map
[RMAP_IN
].name
)
9095 vty_out(vty
, " Inbound path policy configured\n");
9096 if (filter
->plist
[FILTER_OUT
].name
9097 || filter
->dlist
[FILTER_OUT
].name
9098 || filter
->aslist
[FILTER_OUT
].name
9099 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9100 vty_out(vty
, " Outbound path policy configured\n");
9103 if (filter
->plist
[FILTER_IN
].name
)
9105 " Incoming update prefix filter list is %s%s\n",
9106 filter
->plist
[FILTER_IN
].plist
? "*" : "",
9107 filter
->plist
[FILTER_IN
].name
);
9108 if (filter
->plist
[FILTER_OUT
].name
)
9110 " Outgoing update prefix filter list is %s%s\n",
9111 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
9112 filter
->plist
[FILTER_OUT
].name
);
9114 /* distribute-list */
9115 if (filter
->dlist
[FILTER_IN
].name
)
9117 " Incoming update network filter list is %s%s\n",
9118 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
9119 filter
->dlist
[FILTER_IN
].name
);
9120 if (filter
->dlist
[FILTER_OUT
].name
)
9122 " Outgoing update network filter list is %s%s\n",
9123 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
9124 filter
->dlist
[FILTER_OUT
].name
);
9127 if (filter
->aslist
[FILTER_IN
].name
)
9129 " Incoming update AS path filter list is %s%s\n",
9130 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
9131 filter
->aslist
[FILTER_IN
].name
);
9132 if (filter
->aslist
[FILTER_OUT
].name
)
9134 " Outgoing update AS path filter list is %s%s\n",
9135 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
9136 filter
->aslist
[FILTER_OUT
].name
);
9139 if (filter
->map
[RMAP_IN
].name
)
9141 " Route map for incoming advertisements is %s%s\n",
9142 filter
->map
[RMAP_IN
].map
? "*" : "",
9143 filter
->map
[RMAP_IN
].name
);
9144 if (filter
->map
[RMAP_OUT
].name
)
9146 " Route map for outgoing advertisements is %s%s\n",
9147 filter
->map
[RMAP_OUT
].map
? "*" : "",
9148 filter
->map
[RMAP_OUT
].name
);
9150 /* ebgp-requires-policy (inbound) */
9151 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9152 && !bgp_inbound_policy_exists(p
, filter
))
9154 " Inbound updates discarded due to missing policy\n");
9156 /* ebgp-requires-policy (outbound) */
9157 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9158 && !bgp_outbound_policy_exists(p
, filter
))
9160 " Outbound updates discarded due to missing policy\n");
9162 /* unsuppress-map */
9163 if (filter
->usmap
.name
)
9165 " Route map for selective unsuppress is %s%s\n",
9166 filter
->usmap
.map
? "*" : "",
9167 filter
->usmap
.name
);
9169 /* Receive prefix count */
9170 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
9172 /* Maximum prefix */
9173 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9174 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
9176 CHECK_FLAG(p
->af_flags
[afi
][safi
],
9177 PEER_FLAG_MAX_PREFIX_WARNING
)
9180 vty_out(vty
, " Threshold for warning message %d%%",
9181 p
->pmax_threshold
[afi
][safi
]);
9182 if (p
->pmax_restart
[afi
][safi
])
9183 vty_out(vty
, ", restart interval %d min",
9184 p
->pmax_restart
[afi
][safi
]);
9192 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
9196 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
9197 char timebuf
[BGP_UPTIME_LEN
];
9199 const char *subcode_str
;
9200 const char *code_str
;
9205 json_object
*json_neigh
= NULL
;
9211 json_neigh
= json_object_new_object();
9213 memset(dn_flag
, '\0', sizeof(dn_flag
));
9214 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9218 if (p
->conf_if
) /* Configured interface name. */
9219 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9220 BGP_PEER_SU_UNSPEC(p
)
9222 : sockunion2str(&p
->su
, buf
,
9224 else /* Configured IP address. */
9225 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9230 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9231 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9233 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9234 json_object_string_add(
9235 json_neigh
, "bgpNeighborAddr",
9236 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9238 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9240 if (p
->change_local_as
)
9241 json_object_int_add(json_neigh
, "localAs",
9242 p
->change_local_as
);
9244 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9246 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9247 json_object_boolean_true_add(json_neigh
,
9248 "localAsNoPrepend");
9250 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9251 json_object_boolean_true_add(json_neigh
,
9252 "localAsReplaceAs");
9254 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9255 || (p
->as_type
== AS_INTERNAL
))
9256 vty_out(vty
, "remote AS %u, ", p
->as
);
9258 vty_out(vty
, "remote AS Unspecified, ");
9259 vty_out(vty
, "local AS %u%s%s, ",
9260 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9261 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9264 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9268 /* peer type internal or confed-internal */
9269 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
9271 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9272 json_object_boolean_true_add(
9273 json_neigh
, "nbrConfedInternalLink");
9275 json_object_boolean_true_add(json_neigh
,
9278 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9279 vty_out(vty
, "confed-internal link\n");
9281 vty_out(vty
, "internal link\n");
9283 /* peer type external or confed-external */
9284 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
9286 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9287 json_object_boolean_true_add(
9288 json_neigh
, "nbrConfedExternalLink");
9290 json_object_boolean_true_add(json_neigh
,
9293 if (bgp_confederation_peers_check(bgp
, p
->as
))
9294 vty_out(vty
, "confed-external link\n");
9296 vty_out(vty
, "external link\n");
9300 json_object_boolean_true_add(json_neigh
,
9301 "nbrUnspecifiedLink");
9303 vty_out(vty
, "unspecified link\n");
9309 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9311 vty_out(vty
, " Description: %s\n", p
->desc
);
9317 json_object_string_add(json_neigh
, "hostname",
9321 json_object_string_add(json_neigh
, "domainname",
9324 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9325 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9328 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9335 json_object_string_add(json_neigh
, "peerGroup",
9339 struct prefix prefix
, *range
= NULL
;
9341 sockunion2hostprefix(&(p
->su
), &prefix
);
9342 range
= peer_group_lookup_dynamic_neighbor_range(
9346 prefix2str(range
, buf1
, sizeof(buf1
));
9347 json_object_string_add(
9349 "peerSubnetRangeGroup", buf1
);
9354 " Member of peer-group %s for session parameters\n",
9358 struct prefix prefix
, *range
= NULL
;
9360 sockunion2hostprefix(&(p
->su
), &prefix
);
9361 range
= peer_group_lookup_dynamic_neighbor_range(
9365 prefix2str(range
, buf1
, sizeof(buf1
));
9367 " Belongs to the subnet range group: %s\n",
9375 /* Administrative shutdown. */
9376 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9377 json_object_boolean_true_add(json_neigh
,
9381 json_object_int_add(json_neigh
, "bgpVersion", 4);
9382 json_object_string_add(
9383 json_neigh
, "remoteRouterId",
9384 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9385 json_object_string_add(
9386 json_neigh
, "localRouterId",
9387 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9391 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9392 && bgp_confederation_peers_check(bgp
, p
->as
))
9393 json_object_boolean_true_add(json_neigh
,
9397 json_object_string_add(
9398 json_neigh
, "bgpState",
9399 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9401 if (p
->status
== Established
) {
9404 uptime
= bgp_clock();
9405 uptime
-= p
->uptime
;
9406 epoch_tbuf
= time(NULL
) - uptime
;
9408 #if CONFDATE > 20200101
9410 "bgpTimerUp should be deprecated and can be removed now");
9413 * bgpTimerUp was miliseconds that was accurate
9414 * up to 1 day, then the value returned
9415 * became garbage. So in order to provide
9416 * some level of backwards compatability,
9417 * we still provde the data, but now
9418 * we are returning the correct value
9419 * and also adding a new bgpTimerUpMsec
9420 * which will allow us to deprecate
9423 json_object_int_add(json_neigh
, "bgpTimerUp",
9425 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9427 json_object_string_add(json_neigh
, "bgpTimerUpString",
9428 peer_uptime(p
->uptime
, timebuf
,
9431 json_object_int_add(json_neigh
,
9432 "bgpTimerUpEstablishedEpoch",
9436 else if (p
->status
== Active
) {
9437 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9438 json_object_string_add(json_neigh
, "bgpStateIs",
9440 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9441 json_object_string_add(json_neigh
, "bgpStateIs",
9449 uptime
= bgp_clock();
9450 uptime
-= p
->readtime
;
9451 tm
= gmtime(&uptime
);
9452 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9453 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9454 + (tm
->tm_hour
* 3600000));
9456 uptime
= bgp_clock();
9457 uptime
-= p
->last_write
;
9458 tm
= gmtime(&uptime
);
9459 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9460 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9461 + (tm
->tm_hour
* 3600000));
9463 uptime
= bgp_clock();
9464 uptime
-= p
->update_time
;
9465 tm
= gmtime(&uptime
);
9466 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9467 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9468 + (tm
->tm_hour
* 3600000));
9470 /* Configured timer values. */
9471 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9472 p
->v_holdtime
* 1000);
9473 json_object_int_add(json_neigh
,
9474 "bgpTimerKeepAliveIntervalMsecs",
9475 p
->v_keepalive
* 1000);
9476 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9477 json_object_int_add(json_neigh
,
9478 "bgpTimerConfiguredHoldTimeMsecs",
9479 p
->holdtime
* 1000);
9480 json_object_int_add(
9482 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9483 p
->keepalive
* 1000);
9484 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9485 || (bgp
->default_keepalive
9486 != BGP_DEFAULT_KEEPALIVE
)) {
9487 json_object_int_add(json_neigh
,
9488 "bgpTimerConfiguredHoldTimeMsecs",
9489 bgp
->default_holdtime
);
9490 json_object_int_add(
9492 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9493 bgp
->default_keepalive
);
9496 /* Administrative shutdown. */
9497 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9498 vty_out(vty
, " Administratively shut down\n");
9501 vty_out(vty
, " BGP version 4");
9502 vty_out(vty
, ", remote router ID %s",
9503 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9504 vty_out(vty
, ", local router ID %s\n",
9505 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9509 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9510 && bgp_confederation_peers_check(bgp
, p
->as
))
9512 " Neighbor under common administration\n");
9515 vty_out(vty
, " BGP state = %s",
9516 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9518 if (p
->status
== Established
)
9519 vty_out(vty
, ", up for %8s",
9520 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9523 else if (p
->status
== Active
) {
9524 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9525 vty_out(vty
, " (passive)");
9526 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9527 vty_out(vty
, " (NSF passive)");
9532 vty_out(vty
, " Last read %s",
9533 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9535 vty_out(vty
, ", Last write %s\n",
9536 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9539 /* Configured timer values. */
9541 " Hold time is %d, keepalive interval is %d seconds\n",
9542 p
->v_holdtime
, p
->v_keepalive
);
9543 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9544 vty_out(vty
, " Configured hold time is %d",
9546 vty_out(vty
, ", keepalive interval is %d seconds\n",
9548 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9549 || (bgp
->default_keepalive
9550 != BGP_DEFAULT_KEEPALIVE
)) {
9551 vty_out(vty
, " Configured hold time is %d",
9552 bgp
->default_holdtime
);
9553 vty_out(vty
, ", keepalive interval is %d seconds\n",
9554 bgp
->default_keepalive
);
9558 if (p
->status
== Established
) {
9559 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9560 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9561 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9562 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9563 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9564 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9565 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9566 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9567 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9568 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9569 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9570 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9571 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9572 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9573 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9574 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9575 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9576 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9577 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9578 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9580 json_object
*json_cap
= NULL
;
9582 json_cap
= json_object_new_object();
9585 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9586 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9587 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9588 && CHECK_FLAG(p
->cap
,
9590 json_object_string_add(
9591 json_cap
, "4byteAs",
9592 "advertisedAndReceived");
9593 else if (CHECK_FLAG(p
->cap
,
9595 json_object_string_add(
9596 json_cap
, "4byteAs",
9598 else if (CHECK_FLAG(p
->cap
,
9600 json_object_string_add(
9601 json_cap
, "4byteAs",
9606 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9607 || CHECK_FLAG(p
->cap
,
9608 PEER_CAP_ADDPATH_ADV
)) {
9609 json_object
*json_add
= NULL
;
9610 const char *print_store
;
9612 json_add
= json_object_new_object();
9614 FOREACH_AFI_SAFI (afi
, safi
) {
9615 json_object
*json_sub
= NULL
;
9617 json_object_new_object();
9618 print_store
= afi_safi_print(
9624 PEER_CAP_ADDPATH_AF_TX_ADV
)
9628 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9633 PEER_CAP_ADDPATH_AF_TX_ADV
)
9638 PEER_CAP_ADDPATH_AF_TX_RCV
))
9639 json_object_boolean_true_add(
9641 "txAdvertisedAndReceived");
9647 PEER_CAP_ADDPATH_AF_TX_ADV
))
9648 json_object_boolean_true_add(
9656 PEER_CAP_ADDPATH_AF_TX_RCV
))
9657 json_object_boolean_true_add(
9665 PEER_CAP_ADDPATH_AF_RX_ADV
)
9669 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9674 PEER_CAP_ADDPATH_AF_RX_ADV
)
9679 PEER_CAP_ADDPATH_AF_RX_RCV
))
9680 json_object_boolean_true_add(
9682 "rxAdvertisedAndReceived");
9688 PEER_CAP_ADDPATH_AF_RX_ADV
))
9689 json_object_boolean_true_add(
9697 PEER_CAP_ADDPATH_AF_RX_RCV
))
9698 json_object_boolean_true_add(
9706 PEER_CAP_ADDPATH_AF_TX_ADV
)
9710 PEER_CAP_ADDPATH_AF_TX_RCV
)
9714 PEER_CAP_ADDPATH_AF_RX_ADV
)
9718 PEER_CAP_ADDPATH_AF_RX_RCV
))
9719 json_object_object_add(
9728 json_object_object_add(
9729 json_cap
, "addPath", json_add
);
9733 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9734 || CHECK_FLAG(p
->cap
,
9735 PEER_CAP_DYNAMIC_ADV
)) {
9736 if (CHECK_FLAG(p
->cap
,
9737 PEER_CAP_DYNAMIC_ADV
)
9738 && CHECK_FLAG(p
->cap
,
9739 PEER_CAP_DYNAMIC_RCV
))
9740 json_object_string_add(
9741 json_cap
, "dynamic",
9742 "advertisedAndReceived");
9743 else if (CHECK_FLAG(
9745 PEER_CAP_DYNAMIC_ADV
))
9746 json_object_string_add(
9747 json_cap
, "dynamic",
9749 else if (CHECK_FLAG(
9751 PEER_CAP_DYNAMIC_RCV
))
9752 json_object_string_add(
9753 json_cap
, "dynamic",
9757 /* Extended nexthop */
9758 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9759 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9760 json_object
*json_nxt
= NULL
;
9761 const char *print_store
;
9764 if (CHECK_FLAG(p
->cap
,
9766 && CHECK_FLAG(p
->cap
,
9768 json_object_string_add(
9771 "advertisedAndReceived");
9772 else if (CHECK_FLAG(p
->cap
,
9774 json_object_string_add(
9778 else if (CHECK_FLAG(p
->cap
,
9780 json_object_string_add(
9785 if (CHECK_FLAG(p
->cap
,
9786 PEER_CAP_ENHE_RCV
)) {
9788 json_object_new_object();
9790 for (safi
= SAFI_UNICAST
;
9791 safi
< SAFI_MAX
; safi
++) {
9796 PEER_CAP_ENHE_AF_RCV
)) {
9797 print_store
= afi_safi_print(
9800 json_object_string_add(
9803 "recieved"); /* misspelled for compatibility */
9806 json_object_object_add(
9808 "extendedNexthopFamililesByPeer",
9814 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9815 || CHECK_FLAG(p
->cap
,
9816 PEER_CAP_REFRESH_NEW_RCV
)
9817 || CHECK_FLAG(p
->cap
,
9818 PEER_CAP_REFRESH_OLD_RCV
)) {
9819 if (CHECK_FLAG(p
->cap
,
9820 PEER_CAP_REFRESH_ADV
)
9823 PEER_CAP_REFRESH_NEW_RCV
)
9826 PEER_CAP_REFRESH_OLD_RCV
))) {
9829 PEER_CAP_REFRESH_OLD_RCV
)
9832 PEER_CAP_REFRESH_NEW_RCV
))
9833 json_object_string_add(
9836 "advertisedAndReceivedOldNew");
9840 PEER_CAP_REFRESH_OLD_RCV
))
9841 json_object_string_add(
9844 "advertisedAndReceivedOld");
9846 json_object_string_add(
9849 "advertisedAndReceivedNew");
9854 PEER_CAP_REFRESH_ADV
))
9855 json_object_string_add(
9862 PEER_CAP_REFRESH_NEW_RCV
)
9865 PEER_CAP_REFRESH_OLD_RCV
))
9866 json_object_string_add(
9872 /* Multiprotocol Extensions */
9873 json_object
*json_multi
= NULL
;
9874 json_multi
= json_object_new_object();
9876 FOREACH_AFI_SAFI (afi
, safi
) {
9877 if (p
->afc_adv
[afi
][safi
]
9878 || p
->afc_recv
[afi
][safi
]) {
9879 json_object
*json_exten
= NULL
;
9881 json_object_new_object();
9883 if (p
->afc_adv
[afi
][safi
]
9884 && p
->afc_recv
[afi
][safi
])
9885 json_object_boolean_true_add(
9887 "advertisedAndReceived");
9888 else if (p
->afc_adv
[afi
][safi
])
9889 json_object_boolean_true_add(
9892 else if (p
->afc_recv
[afi
][safi
])
9893 json_object_boolean_true_add(
9897 json_object_object_add(
9904 json_object_object_add(
9905 json_cap
, "multiprotocolExtensions",
9908 /* Hostname capabilities */
9909 json_object
*json_hname
= NULL
;
9911 json_hname
= json_object_new_object();
9913 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9914 json_object_string_add(
9915 json_hname
, "advHostName",
9916 bgp
->peer_self
->hostname
9920 json_object_string_add(
9921 json_hname
, "advDomainName",
9922 bgp
->peer_self
->domainname
9929 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9930 json_object_string_add(
9931 json_hname
, "rcvHostName",
9932 p
->hostname
? p
->hostname
9934 json_object_string_add(
9935 json_hname
, "rcvDomainName",
9936 p
->domainname
? p
->domainname
9940 json_object_object_add(json_cap
, "hostName",
9943 /* Gracefull Restart */
9944 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9945 || CHECK_FLAG(p
->cap
,
9946 PEER_CAP_RESTART_ADV
)) {
9947 if (CHECK_FLAG(p
->cap
,
9948 PEER_CAP_RESTART_ADV
)
9949 && CHECK_FLAG(p
->cap
,
9950 PEER_CAP_RESTART_RCV
))
9951 json_object_string_add(
9954 "advertisedAndReceived");
9955 else if (CHECK_FLAG(
9957 PEER_CAP_RESTART_ADV
))
9958 json_object_string_add(
9960 "gracefulRestartCapability",
9962 else if (CHECK_FLAG(
9964 PEER_CAP_RESTART_RCV
))
9965 json_object_string_add(
9967 "gracefulRestartCapability",
9970 if (CHECK_FLAG(p
->cap
,
9971 PEER_CAP_RESTART_RCV
)) {
9972 int restart_af_count
= 0;
9973 json_object
*json_restart
=
9976 json_object_new_object();
9978 json_object_int_add(
9980 "gracefulRestartRemoteTimerMsecs",
9981 p
->v_gr_restart
* 1000);
9983 FOREACH_AFI_SAFI (afi
, safi
) {
9988 PEER_CAP_RESTART_AF_RCV
)) {
9993 json_object_new_object();
9999 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
10000 json_object_boolean_true_add(
10003 restart_af_count
++;
10004 json_object_object_add(
10012 if (!restart_af_count
) {
10013 json_object_string_add(
10015 "addressFamiliesByPeer",
10020 json_object_object_add(
10022 "addressFamiliesByPeer",
10026 json_object_object_add(json_neigh
,
10027 "neighborCapabilities",
10030 vty_out(vty
, " Neighbor capabilities:\n");
10033 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
10034 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
10035 vty_out(vty
, " 4 Byte AS:");
10036 if (CHECK_FLAG(p
->cap
,
10038 vty_out(vty
, " advertised");
10039 if (CHECK_FLAG(p
->cap
,
10041 vty_out(vty
, " %sreceived",
10047 vty_out(vty
, "\n");
10051 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
10052 || CHECK_FLAG(p
->cap
,
10053 PEER_CAP_ADDPATH_ADV
)) {
10054 vty_out(vty
, " AddPath:\n");
10056 FOREACH_AFI_SAFI (afi
, safi
) {
10060 PEER_CAP_ADDPATH_AF_TX_ADV
)
10064 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
10075 PEER_CAP_ADDPATH_AF_TX_ADV
))
10086 PEER_CAP_ADDPATH_AF_TX_RCV
))
10093 PEER_CAP_ADDPATH_AF_TX_ADV
)
10097 vty_out(vty
, "\n");
10103 PEER_CAP_ADDPATH_AF_RX_ADV
)
10107 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
10118 PEER_CAP_ADDPATH_AF_RX_ADV
))
10129 PEER_CAP_ADDPATH_AF_RX_RCV
))
10136 PEER_CAP_ADDPATH_AF_RX_ADV
)
10140 vty_out(vty
, "\n");
10146 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10147 || CHECK_FLAG(p
->cap
,
10148 PEER_CAP_DYNAMIC_ADV
)) {
10149 vty_out(vty
, " Dynamic:");
10150 if (CHECK_FLAG(p
->cap
,
10151 PEER_CAP_DYNAMIC_ADV
))
10152 vty_out(vty
, " advertised");
10153 if (CHECK_FLAG(p
->cap
,
10154 PEER_CAP_DYNAMIC_RCV
))
10155 vty_out(vty
, " %sreceived",
10158 PEER_CAP_DYNAMIC_ADV
)
10161 vty_out(vty
, "\n");
10164 /* Extended nexthop */
10165 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10166 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10167 vty_out(vty
, " Extended nexthop:");
10168 if (CHECK_FLAG(p
->cap
,
10169 PEER_CAP_ENHE_ADV
))
10170 vty_out(vty
, " advertised");
10171 if (CHECK_FLAG(p
->cap
,
10172 PEER_CAP_ENHE_RCV
))
10173 vty_out(vty
, " %sreceived",
10179 vty_out(vty
, "\n");
10181 if (CHECK_FLAG(p
->cap
,
10182 PEER_CAP_ENHE_RCV
)) {
10184 " Address families by peer:\n ");
10185 for (safi
= SAFI_UNICAST
;
10186 safi
< SAFI_MAX
; safi
++)
10191 PEER_CAP_ENHE_AF_RCV
))
10200 /* Route Refresh */
10201 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10202 || CHECK_FLAG(p
->cap
,
10203 PEER_CAP_REFRESH_NEW_RCV
)
10204 || CHECK_FLAG(p
->cap
,
10205 PEER_CAP_REFRESH_OLD_RCV
)) {
10206 vty_out(vty
, " Route refresh:");
10207 if (CHECK_FLAG(p
->cap
,
10208 PEER_CAP_REFRESH_ADV
))
10209 vty_out(vty
, " advertised");
10210 if (CHECK_FLAG(p
->cap
,
10211 PEER_CAP_REFRESH_NEW_RCV
)
10214 PEER_CAP_REFRESH_OLD_RCV
))
10215 vty_out(vty
, " %sreceived(%s)",
10218 PEER_CAP_REFRESH_ADV
)
10223 PEER_CAP_REFRESH_OLD_RCV
)
10226 PEER_CAP_REFRESH_NEW_RCV
))
10230 PEER_CAP_REFRESH_OLD_RCV
)
10234 vty_out(vty
, "\n");
10237 /* Multiprotocol Extensions */
10238 FOREACH_AFI_SAFI (afi
, safi
)
10239 if (p
->afc_adv
[afi
][safi
]
10240 || p
->afc_recv
[afi
][safi
]) {
10242 " Address Family %s:",
10243 afi_safi_print(afi
,
10245 if (p
->afc_adv
[afi
][safi
])
10248 if (p
->afc_recv
[afi
][safi
])
10255 vty_out(vty
, "\n");
10258 /* Hostname capability */
10259 vty_out(vty
, " Hostname Capability:");
10261 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10263 " advertised (name: %s,domain name: %s)",
10264 bgp
->peer_self
->hostname
10268 bgp
->peer_self
->domainname
10273 vty_out(vty
, " not advertised");
10276 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10278 " received (name: %s,domain name: %s)",
10279 p
->hostname
? p
->hostname
10281 p
->domainname
? p
->domainname
10284 vty_out(vty
, " not received");
10287 vty_out(vty
, "\n");
10289 /* Gracefull Restart */
10290 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10291 || CHECK_FLAG(p
->cap
,
10292 PEER_CAP_RESTART_ADV
)) {
10294 " Graceful Restart Capabilty:");
10295 if (CHECK_FLAG(p
->cap
,
10296 PEER_CAP_RESTART_ADV
))
10297 vty_out(vty
, " advertised");
10298 if (CHECK_FLAG(p
->cap
,
10299 PEER_CAP_RESTART_RCV
))
10300 vty_out(vty
, " %sreceived",
10303 PEER_CAP_RESTART_ADV
)
10306 vty_out(vty
, "\n");
10308 if (CHECK_FLAG(p
->cap
,
10309 PEER_CAP_RESTART_RCV
)) {
10310 int restart_af_count
= 0;
10313 " Remote Restart timer is %d seconds\n",
10316 " Address families by peer:\n ");
10318 FOREACH_AFI_SAFI (afi
, safi
)
10323 PEER_CAP_RESTART_AF_RCV
)) {
10336 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10338 : "not preserved");
10339 restart_af_count
++;
10341 if (!restart_af_count
)
10342 vty_out(vty
, "none");
10343 vty_out(vty
, "\n");
10350 /* graceful restart information */
10351 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10352 || p
->t_gr_stale
) {
10353 json_object
*json_grace
= NULL
;
10354 json_object
*json_grace_send
= NULL
;
10355 json_object
*json_grace_recv
= NULL
;
10356 int eor_send_af_count
= 0;
10357 int eor_receive_af_count
= 0;
10360 json_grace
= json_object_new_object();
10361 json_grace_send
= json_object_new_object();
10362 json_grace_recv
= json_object_new_object();
10364 if (p
->status
== Established
) {
10365 FOREACH_AFI_SAFI (afi
, safi
) {
10366 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10367 PEER_STATUS_EOR_SEND
)) {
10368 json_object_boolean_true_add(
10370 afi_safi_print(afi
,
10372 eor_send_af_count
++;
10375 FOREACH_AFI_SAFI (afi
, safi
) {
10377 p
->af_sflags
[afi
][safi
],
10378 PEER_STATUS_EOR_RECEIVED
)) {
10379 json_object_boolean_true_add(
10381 afi_safi_print(afi
,
10383 eor_receive_af_count
++;
10388 json_object_object_add(json_grace
, "endOfRibSend",
10390 json_object_object_add(json_grace
, "endOfRibRecv",
10393 if (p
->t_gr_restart
)
10394 json_object_int_add(json_grace
,
10395 "gracefulRestartTimerMsecs",
10396 thread_timer_remain_second(
10401 json_object_int_add(
10403 "gracefulStalepathTimerMsecs",
10404 thread_timer_remain_second(
10408 json_object_object_add(
10409 json_neigh
, "gracefulRestartInfo", json_grace
);
10411 vty_out(vty
, " Graceful restart information:\n");
10412 if (p
->status
== Established
) {
10413 vty_out(vty
, " End-of-RIB send: ");
10414 FOREACH_AFI_SAFI (afi
, safi
) {
10415 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10416 PEER_STATUS_EOR_SEND
)) {
10417 vty_out(vty
, "%s%s",
10418 eor_send_af_count
? ", "
10420 afi_safi_print(afi
,
10422 eor_send_af_count
++;
10425 vty_out(vty
, "\n");
10426 vty_out(vty
, " End-of-RIB received: ");
10427 FOREACH_AFI_SAFI (afi
, safi
) {
10429 p
->af_sflags
[afi
][safi
],
10430 PEER_STATUS_EOR_RECEIVED
)) {
10431 vty_out(vty
, "%s%s",
10432 eor_receive_af_count
10435 afi_safi_print(afi
,
10437 eor_receive_af_count
++;
10440 vty_out(vty
, "\n");
10443 if (p
->t_gr_restart
)
10445 " The remaining time of restart timer is %ld\n",
10446 thread_timer_remain_second(
10451 " The remaining time of stalepath timer is %ld\n",
10452 thread_timer_remain_second(
10457 json_object
*json_stat
= NULL
;
10458 json_stat
= json_object_new_object();
10459 /* Packet counts. */
10460 json_object_int_add(json_stat
, "depthInq", 0);
10461 json_object_int_add(json_stat
, "depthOutq",
10462 (unsigned long)p
->obuf
->count
);
10463 json_object_int_add(json_stat
, "opensSent",
10464 atomic_load_explicit(&p
->open_out
,
10465 memory_order_relaxed
));
10466 json_object_int_add(json_stat
, "opensRecv",
10467 atomic_load_explicit(&p
->open_in
,
10468 memory_order_relaxed
));
10469 json_object_int_add(json_stat
, "notificationsSent",
10470 atomic_load_explicit(&p
->notify_out
,
10471 memory_order_relaxed
));
10472 json_object_int_add(json_stat
, "notificationsRecv",
10473 atomic_load_explicit(&p
->notify_in
,
10474 memory_order_relaxed
));
10475 json_object_int_add(json_stat
, "updatesSent",
10476 atomic_load_explicit(&p
->update_out
,
10477 memory_order_relaxed
));
10478 json_object_int_add(json_stat
, "updatesRecv",
10479 atomic_load_explicit(&p
->update_in
,
10480 memory_order_relaxed
));
10481 json_object_int_add(json_stat
, "keepalivesSent",
10482 atomic_load_explicit(&p
->keepalive_out
,
10483 memory_order_relaxed
));
10484 json_object_int_add(json_stat
, "keepalivesRecv",
10485 atomic_load_explicit(&p
->keepalive_in
,
10486 memory_order_relaxed
));
10487 json_object_int_add(json_stat
, "routeRefreshSent",
10488 atomic_load_explicit(&p
->refresh_out
,
10489 memory_order_relaxed
));
10490 json_object_int_add(json_stat
, "routeRefreshRecv",
10491 atomic_load_explicit(&p
->refresh_in
,
10492 memory_order_relaxed
));
10493 json_object_int_add(json_stat
, "capabilitySent",
10494 atomic_load_explicit(&p
->dynamic_cap_out
,
10495 memory_order_relaxed
));
10496 json_object_int_add(json_stat
, "capabilityRecv",
10497 atomic_load_explicit(&p
->dynamic_cap_in
,
10498 memory_order_relaxed
));
10499 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10500 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10501 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10503 /* Packet counts. */
10504 vty_out(vty
, " Message statistics:\n");
10505 vty_out(vty
, " Inq depth is 0\n");
10506 vty_out(vty
, " Outq depth is %lu\n",
10507 (unsigned long)p
->obuf
->count
);
10508 vty_out(vty
, " Sent Rcvd\n");
10509 vty_out(vty
, " Opens: %10d %10d\n",
10510 atomic_load_explicit(&p
->open_out
,
10511 memory_order_relaxed
),
10512 atomic_load_explicit(&p
->open_in
,
10513 memory_order_relaxed
));
10514 vty_out(vty
, " Notifications: %10d %10d\n",
10515 atomic_load_explicit(&p
->notify_out
,
10516 memory_order_relaxed
),
10517 atomic_load_explicit(&p
->notify_in
,
10518 memory_order_relaxed
));
10519 vty_out(vty
, " Updates: %10d %10d\n",
10520 atomic_load_explicit(&p
->update_out
,
10521 memory_order_relaxed
),
10522 atomic_load_explicit(&p
->update_in
,
10523 memory_order_relaxed
));
10524 vty_out(vty
, " Keepalives: %10d %10d\n",
10525 atomic_load_explicit(&p
->keepalive_out
,
10526 memory_order_relaxed
),
10527 atomic_load_explicit(&p
->keepalive_in
,
10528 memory_order_relaxed
));
10529 vty_out(vty
, " Route Refresh: %10d %10d\n",
10530 atomic_load_explicit(&p
->refresh_out
,
10531 memory_order_relaxed
),
10532 atomic_load_explicit(&p
->refresh_in
,
10533 memory_order_relaxed
));
10534 vty_out(vty
, " Capability: %10d %10d\n",
10535 atomic_load_explicit(&p
->dynamic_cap_out
,
10536 memory_order_relaxed
),
10537 atomic_load_explicit(&p
->dynamic_cap_in
,
10538 memory_order_relaxed
));
10539 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10544 /* advertisement-interval */
10545 json_object_int_add(json_neigh
,
10546 "minBtwnAdvertisementRunsTimerMsecs",
10547 p
->v_routeadv
* 1000);
10549 /* Update-source. */
10550 if (p
->update_if
|| p
->update_source
) {
10552 json_object_string_add(json_neigh
,
10555 else if (p
->update_source
)
10556 json_object_string_add(
10557 json_neigh
, "updateSource",
10558 sockunion2str(p
->update_source
, buf1
,
10562 /* advertisement-interval */
10564 " Minimum time between advertisement runs is %d seconds\n",
10567 /* Update-source. */
10568 if (p
->update_if
|| p
->update_source
) {
10569 vty_out(vty
, " Update source is ");
10571 vty_out(vty
, "%s", p
->update_if
);
10572 else if (p
->update_source
)
10574 sockunion2str(p
->update_source
, buf1
,
10576 vty_out(vty
, "\n");
10579 vty_out(vty
, "\n");
10582 /* Address Family Information */
10583 json_object
*json_hold
= NULL
;
10586 json_hold
= json_object_new_object();
10588 FOREACH_AFI_SAFI (afi
, safi
)
10589 if (p
->afc
[afi
][safi
])
10590 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10594 json_object_object_add(json_neigh
, "addressFamilyInfo",
10596 json_object_int_add(json_neigh
, "connectionsEstablished",
10598 json_object_int_add(json_neigh
, "connectionsDropped",
10601 vty_out(vty
, " Connections established %d; dropped %d\n",
10602 p
->established
, p
->dropped
);
10604 if (!p
->last_reset
) {
10606 json_object_string_add(json_neigh
, "lastReset",
10609 vty_out(vty
, " Last reset never\n");
10615 uptime
= bgp_clock();
10616 uptime
-= p
->resettime
;
10617 tm
= gmtime(&uptime
);
10618 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10619 (tm
->tm_sec
* 1000)
10620 + (tm
->tm_min
* 60000)
10621 + (tm
->tm_hour
* 3600000));
10622 json_object_string_add(
10623 json_neigh
, "lastResetDueTo",
10624 peer_down_str
[(int)p
->last_reset
]);
10625 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10626 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10627 char errorcodesubcode_hexstr
[5];
10628 char errorcodesubcode_str
[256];
10630 code_str
= bgp_notify_code_str(p
->notify
.code
);
10631 subcode_str
= bgp_notify_subcode_str(
10632 p
->notify
.code
, p
->notify
.subcode
);
10634 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10635 p
->notify
.code
, p
->notify
.subcode
);
10636 json_object_string_add(json_neigh
,
10637 "lastErrorCodeSubcode",
10638 errorcodesubcode_hexstr
);
10639 snprintf(errorcodesubcode_str
, 255, "%s%s",
10640 code_str
, subcode_str
);
10641 json_object_string_add(json_neigh
,
10642 "lastNotificationReason",
10643 errorcodesubcode_str
);
10644 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10645 && p
->notify
.code
== BGP_NOTIFY_CEASE
10646 && (p
->notify
.subcode
10647 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10648 || p
->notify
.subcode
10649 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10650 && p
->notify
.length
) {
10652 const char *msg_str
;
10654 msg_str
= bgp_notify_admin_message(
10655 msgbuf
, sizeof(msgbuf
),
10656 (uint8_t *)p
->notify
.data
,
10659 json_object_string_add(
10661 "lastShutdownDescription",
10666 vty_out(vty
, " Last reset %s, ",
10667 peer_uptime(p
->resettime
, timebuf
,
10668 BGP_UPTIME_LEN
, 0, NULL
));
10670 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10671 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10672 code_str
= bgp_notify_code_str(p
->notify
.code
);
10673 subcode_str
= bgp_notify_subcode_str(
10674 p
->notify
.code
, p
->notify
.subcode
);
10675 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10676 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10679 code_str
, subcode_str
);
10680 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10681 && p
->notify
.code
== BGP_NOTIFY_CEASE
10682 && (p
->notify
.subcode
10683 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10684 || p
->notify
.subcode
10685 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10686 && p
->notify
.length
) {
10688 const char *msg_str
;
10690 msg_str
= bgp_notify_admin_message(
10691 msgbuf
, sizeof(msgbuf
),
10692 (uint8_t *)p
->notify
.data
,
10696 " Message: \"%s\"\n",
10700 vty_out(vty
, "due to %s\n",
10701 peer_down_str
[(int)p
->last_reset
]);
10704 if (p
->last_reset_cause_size
) {
10705 msg
= p
->last_reset_cause
;
10707 " Message received that caused BGP to send a NOTIFICATION:\n ");
10708 for (i
= 1; i
<= p
->last_reset_cause_size
;
10710 vty_out(vty
, "%02X", *msg
++);
10712 if (i
!= p
->last_reset_cause_size
) {
10714 vty_out(vty
, "\n ");
10715 } else if (i
% 4 == 0) {
10720 vty_out(vty
, "\n");
10725 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10727 json_object_boolean_true_add(json_neigh
,
10728 "prefixesConfigExceedMax");
10731 " Peer had exceeded the max. no. of prefixes configured.\n");
10733 if (p
->t_pmax_restart
) {
10735 json_object_boolean_true_add(
10736 json_neigh
, "reducePrefixNumFrom");
10737 json_object_int_add(json_neigh
,
10738 "restartInTimerMsec",
10739 thread_timer_remain_second(
10744 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10745 p
->host
, thread_timer_remain_second(
10746 p
->t_pmax_restart
));
10749 json_object_boolean_true_add(
10751 "reducePrefixNumAndClearIpBgp");
10754 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10759 /* EBGP Multihop and GTSM */
10760 if (p
->sort
!= BGP_PEER_IBGP
) {
10762 if (p
->gtsm_hops
> 0)
10763 json_object_int_add(json_neigh
,
10764 "externalBgpNbrMaxHopsAway",
10766 else if (p
->ttl
> 1)
10767 json_object_int_add(json_neigh
,
10768 "externalBgpNbrMaxHopsAway",
10771 if (p
->gtsm_hops
> 0)
10773 " External BGP neighbor may be up to %d hops away.\n",
10775 else if (p
->ttl
> 1)
10777 " External BGP neighbor may be up to %d hops away.\n",
10781 if (p
->gtsm_hops
> 0) {
10783 json_object_int_add(json_neigh
,
10784 "internalBgpNbrMaxHopsAway",
10788 " Internal BGP neighbor may be up to %d hops away.\n",
10793 /* Local address. */
10796 json_object_string_add(json_neigh
, "hostLocal",
10797 sockunion2str(p
->su_local
, buf1
,
10799 json_object_int_add(json_neigh
, "portLocal",
10800 ntohs(p
->su_local
->sin
.sin_port
));
10802 vty_out(vty
, "Local host: %s, Local port: %d\n",
10803 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10804 ntohs(p
->su_local
->sin
.sin_port
));
10807 /* Remote address. */
10808 if (p
->su_remote
) {
10810 json_object_string_add(json_neigh
, "hostForeign",
10811 sockunion2str(p
->su_remote
, buf1
,
10813 json_object_int_add(json_neigh
, "portForeign",
10814 ntohs(p
->su_remote
->sin
.sin_port
));
10816 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10817 sockunion2str(p
->su_remote
, buf1
,
10819 ntohs(p
->su_remote
->sin
.sin_port
));
10822 /* Nexthop display. */
10825 json_object_string_add(json_neigh
, "nexthop",
10827 &p
->nexthop
.v4
, buf1
,
10829 json_object_string_add(json_neigh
, "nexthopGlobal",
10830 inet_ntop(AF_INET6
,
10831 &p
->nexthop
.v6_global
,
10832 buf1
, sizeof(buf1
)));
10833 json_object_string_add(json_neigh
, "nexthopLocal",
10834 inet_ntop(AF_INET6
,
10835 &p
->nexthop
.v6_local
,
10836 buf1
, sizeof(buf1
)));
10837 if (p
->shared_network
)
10838 json_object_string_add(json_neigh
,
10842 json_object_string_add(json_neigh
,
10844 "nonSharedNetwork");
10846 vty_out(vty
, "Nexthop: %s\n",
10847 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10849 vty_out(vty
, "Nexthop global: %s\n",
10850 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10852 vty_out(vty
, "Nexthop local: %s\n",
10853 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10855 vty_out(vty
, "BGP connection: %s\n",
10856 p
->shared_network
? "shared network"
10857 : "non shared network");
10861 /* Timer information. */
10863 json_object_int_add(json_neigh
, "connectRetryTimer",
10865 if (p
->status
== Established
&& p
->rtt
)
10866 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10869 json_object_int_add(
10870 json_neigh
, "nextStartTimerDueInMsecs",
10871 thread_timer_remain_second(p
->t_start
) * 1000);
10873 json_object_int_add(
10874 json_neigh
, "nextConnectTimerDueInMsecs",
10875 thread_timer_remain_second(p
->t_connect
)
10877 if (p
->t_routeadv
) {
10878 json_object_int_add(json_neigh
, "mraiInterval",
10880 json_object_int_add(
10881 json_neigh
, "mraiTimerExpireInMsecs",
10882 thread_timer_remain_second(p
->t_routeadv
)
10886 json_object_int_add(json_neigh
, "authenticationEnabled",
10890 json_object_string_add(json_neigh
, "readThread", "on");
10892 json_object_string_add(json_neigh
, "readThread", "off");
10894 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10895 json_object_string_add(json_neigh
, "writeThread", "on");
10897 json_object_string_add(json_neigh
, "writeThread",
10900 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10902 if (p
->status
== Established
&& p
->rtt
)
10903 vty_out(vty
, "Estimated round trip time: %d ms\n",
10906 vty_out(vty
, "Next start timer due in %ld seconds\n",
10907 thread_timer_remain_second(p
->t_start
));
10909 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10910 thread_timer_remain_second(p
->t_connect
));
10913 "MRAI (interval %u) timer expires in %ld seconds\n",
10915 thread_timer_remain_second(p
->t_routeadv
));
10917 vty_out(vty
, "Peer Authentication Enabled\n");
10919 vty_out(vty
, "Read thread: %s Write thread: %s\n",
10920 p
->t_read
? "on" : "off",
10921 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10926 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10927 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10928 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10931 vty_out(vty
, "\n");
10933 /* BFD information. */
10934 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10937 if (p
->conf_if
) /* Configured interface name. */
10938 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10939 else /* Configured IP address. */
10940 json_object_object_add(json
, p
->host
, json_neigh
);
10944 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10945 enum show_type type
, union sockunion
*su
,
10946 const char *conf_if
, bool use_json
,
10949 struct listnode
*node
, *nnode
;
10952 bool nbr_output
= false;
10954 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10955 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10960 bgp_show_peer(vty
, peer
, use_json
, json
);
10966 && !strcmp(peer
->conf_if
, conf_if
))
10968 && !strcmp(peer
->hostname
, conf_if
))) {
10970 bgp_show_peer(vty
, peer
, use_json
,
10974 if (sockunion_same(&peer
->su
, su
)) {
10976 bgp_show_peer(vty
, peer
, use_json
,
10984 if (type
== show_peer
&& !find
) {
10986 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
10988 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
10991 if (type
!= show_peer
&& !nbr_output
&& !use_json
)
10992 vty_out(vty
, "%% No BGP neighbors found\n");
10995 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10996 json
, JSON_C_TO_STRING_PRETTY
));
10998 vty_out(vty
, "\n");
11001 return CMD_SUCCESS
;
11004 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
11005 enum show_type type
,
11006 const char *ip_str
,
11009 struct listnode
*node
, *nnode
;
11011 union sockunion su
;
11012 json_object
*json
= NULL
;
11013 int ret
, is_first
= 1;
11014 bool nbr_output
= false;
11017 vty_out(vty
, "{\n");
11019 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11022 if (!(json
= json_object_new_object())) {
11024 EC_BGP_JSON_MEM_ERROR
,
11025 "Unable to allocate memory for JSON object");
11027 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
11031 json_object_int_add(json
, "vrfId",
11032 (bgp
->vrf_id
== VRF_UNKNOWN
)
11034 : (int64_t)bgp
->vrf_id
);
11035 json_object_string_add(
11037 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11042 vty_out(vty
, ",\n");
11046 vty_out(vty
, "\"%s\":",
11047 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11051 vty_out(vty
, "\nInstance %s:\n",
11052 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11057 if (type
== show_peer
) {
11058 ret
= str2sockunion(ip_str
, &su
);
11060 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11063 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11066 bgp_show_neighbor(vty
, bgp
, show_all
, NULL
, NULL
,
11069 json_object_free(json
);
11073 vty_out(vty
, "}\n");
11074 json_object_free(json
);
11076 else if (!nbr_output
)
11077 vty_out(vty
, "%% BGP instance not found\n");
11080 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
11081 enum show_type type
, const char *ip_str
,
11086 union sockunion su
;
11087 json_object
*json
= NULL
;
11090 if (strmatch(name
, "all")) {
11091 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
11093 return CMD_SUCCESS
;
11095 bgp
= bgp_lookup_by_name(name
);
11098 json
= json_object_new_object();
11099 vty_out(vty
, "%s\n",
11100 json_object_to_json_string_ext(
11102 JSON_C_TO_STRING_PRETTY
));
11103 json_object_free(json
);
11106 "%% BGP instance not found\n");
11108 return CMD_WARNING
;
11112 bgp
= bgp_get_default();
11116 json
= json_object_new_object();
11118 ret
= str2sockunion(ip_str
, &su
);
11120 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11123 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11126 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
11129 json_object_free(json
);
11132 vty_out(vty
, "{}\n");
11134 vty_out(vty
, "%% BGP instance not found\n");
11137 return CMD_SUCCESS
;
11140 /* "show [ip] bgp neighbors" commands. */
11141 DEFUN (show_ip_bgp_neighbors
,
11142 show_ip_bgp_neighbors_cmd
,
11143 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
11147 BGP_INSTANCE_HELP_STR
11150 "Detailed information on TCP and BGP neighbor connections\n"
11151 "Neighbor to display information about\n"
11152 "Neighbor to display information about\n"
11153 "Neighbor on BGP configured interface\n"
11157 char *sh_arg
= NULL
;
11158 enum show_type sh_type
;
11160 bool uj
= use_json(argc
, argv
);
11164 /* [<vrf> VIEWVRFNAME] */
11165 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11166 vrf
= argv
[idx
+ 1]->arg
;
11167 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11169 } else if (argv_find(argv
, argc
, "view", &idx
))
11170 /* [<view> VIEWVRFNAME] */
11171 vrf
= argv
[idx
+ 1]->arg
;
11174 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
11175 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
11176 || argv_find(argv
, argc
, "WORD", &idx
)) {
11177 sh_type
= show_peer
;
11178 sh_arg
= argv
[idx
]->arg
;
11180 sh_type
= show_all
;
11182 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
11185 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
11186 paths' and `show ip mbgp paths'. Those functions results are the
11188 DEFUN (show_ip_bgp_paths
,
11189 show_ip_bgp_paths_cmd
,
11190 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
11195 "Path information\n")
11197 vty_out(vty
, "Address Refcnt Path\n");
11198 aspath_print_all_vty(vty
);
11199 return CMD_SUCCESS
;
11204 static void community_show_all_iterator(struct hash_bucket
*bucket
,
11207 struct community
*com
;
11209 com
= (struct community
*)bucket
->data
;
11210 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
11211 community_str(com
, false));
11214 /* Show BGP's community internal data. */
11215 DEFUN (show_ip_bgp_community_info
,
11216 show_ip_bgp_community_info_cmd
,
11217 "show [ip] bgp community-info",
11221 "List all bgp community information\n")
11223 vty_out(vty
, "Address Refcnt Community\n");
11225 hash_iterate(community_hash(),
11226 (void (*)(struct hash_bucket
*,
11227 void *))community_show_all_iterator
,
11230 return CMD_SUCCESS
;
11233 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
11236 struct lcommunity
*lcom
;
11238 lcom
= (struct lcommunity
*)bucket
->data
;
11239 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11240 lcommunity_str(lcom
, false));
11243 /* Show BGP's community internal data. */
11244 DEFUN (show_ip_bgp_lcommunity_info
,
11245 show_ip_bgp_lcommunity_info_cmd
,
11246 "show ip bgp large-community-info",
11250 "List all bgp large-community information\n")
11252 vty_out(vty
, "Address Refcnt Large-community\n");
11254 hash_iterate(lcommunity_hash(),
11255 (void (*)(struct hash_bucket
*,
11256 void *))lcommunity_show_all_iterator
,
11259 return CMD_SUCCESS
;
11263 DEFUN (show_ip_bgp_attr_info
,
11264 show_ip_bgp_attr_info_cmd
,
11265 "show [ip] bgp attribute-info",
11269 "List all bgp attribute information\n")
11271 attr_show_all(vty
);
11272 return CMD_SUCCESS
;
11275 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11276 safi_t safi
, bool use_json
)
11279 struct listnode
*node
;
11281 char buf1
[INET6_ADDRSTRLEN
];
11283 vpn_policy_direction_t dir
;
11286 json_object
*json
= NULL
;
11287 json_object
*json_import_vrfs
= NULL
;
11288 json_object
*json_export_vrfs
= NULL
;
11290 json
= json_object_new_object();
11292 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11295 vty_out(vty
, "%s\n",
11296 json_object_to_json_string_ext(
11298 JSON_C_TO_STRING_PRETTY
));
11299 json_object_free(json
);
11301 return CMD_WARNING
;
11304 /* Provide context for the block */
11305 json_object_string_add(json
, "vrf", name
? name
: "default");
11306 json_object_string_add(json
, "afiSafi",
11307 afi_safi_print(afi
, safi
));
11309 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11310 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11311 json_object_string_add(json
, "importFromVrfs", "none");
11312 json_object_string_add(json
, "importRts", "none");
11314 json_import_vrfs
= json_object_new_array();
11316 for (ALL_LIST_ELEMENTS_RO(
11317 bgp
->vpn_policy
[afi
].import_vrf
,
11319 json_object_array_add(json_import_vrfs
,
11320 json_object_new_string(vname
));
11322 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11323 ecom_str
= ecommunity_ecom2str(
11324 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11325 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11326 json_object_object_add(json
, "importFromVrfs",
11328 json_object_string_add(json
, "importRts", ecom_str
);
11330 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11333 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11334 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11335 json_object_string_add(json
, "exportToVrfs", "none");
11336 json_object_string_add(json
, "routeDistinguisher",
11338 json_object_string_add(json
, "exportRts", "none");
11340 json_export_vrfs
= json_object_new_array();
11342 for (ALL_LIST_ELEMENTS_RO(
11343 bgp
->vpn_policy
[afi
].export_vrf
,
11345 json_object_array_add(json_export_vrfs
,
11346 json_object_new_string(vname
));
11347 json_object_object_add(json
, "exportToVrfs",
11349 json_object_string_add(json
, "routeDistinguisher",
11350 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11351 buf1
, RD_ADDRSTRLEN
));
11353 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11354 ecom_str
= ecommunity_ecom2str(
11355 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11356 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11357 json_object_string_add(json
, "exportRts", ecom_str
);
11359 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11362 vty_out(vty
, "%s\n",
11363 json_object_to_json_string_ext(json
,
11364 JSON_C_TO_STRING_PRETTY
));
11365 json_object_free(json
);
11368 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11371 vty_out(vty
, "%% No such BGP instance exist\n");
11372 return CMD_WARNING
;
11375 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11376 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11378 "This VRF is not importing %s routes from any other VRF\n",
11379 afi_safi_print(afi
, safi
));
11382 "This VRF is importing %s routes from the following VRFs:\n",
11383 afi_safi_print(afi
, safi
));
11385 for (ALL_LIST_ELEMENTS_RO(
11386 bgp
->vpn_policy
[afi
].import_vrf
,
11388 vty_out(vty
, " %s\n", vname
);
11390 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11391 ecom_str
= ecommunity_ecom2str(
11392 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11393 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11394 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11396 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11399 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11400 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11402 "This VRF is not exporting %s routes to any other VRF\n",
11403 afi_safi_print(afi
, safi
));
11406 "This VRF is exporting %s routes to the following VRFs:\n",
11407 afi_safi_print(afi
, safi
));
11409 for (ALL_LIST_ELEMENTS_RO(
11410 bgp
->vpn_policy
[afi
].export_vrf
,
11412 vty_out(vty
, " %s\n", vname
);
11414 vty_out(vty
, "RD: %s\n",
11415 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11416 buf1
, RD_ADDRSTRLEN
));
11418 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11419 ecom_str
= ecommunity_ecom2str(
11420 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11421 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11422 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11423 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11427 return CMD_SUCCESS
;
11430 /* "show [ip] bgp route-leak" command. */
11431 DEFUN (show_ip_bgp_route_leak
,
11432 show_ip_bgp_route_leak_cmd
,
11433 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11437 BGP_INSTANCE_HELP_STR
11440 "Route leaking information\n"
11444 afi_t afi
= AFI_MAX
;
11445 safi_t safi
= SAFI_MAX
;
11447 bool uj
= use_json(argc
, argv
);
11450 /* show [ip] bgp */
11451 if (argv_find(argv
, argc
, "ip", &idx
)) {
11453 safi
= SAFI_UNICAST
;
11455 /* [vrf VIEWVRFNAME] */
11456 if (argv_find(argv
, argc
, "view", &idx
)) {
11458 "%% This command is not applicable to BGP views\n");
11459 return CMD_WARNING
;
11462 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11463 vrf
= argv
[idx
+ 1]->arg
;
11464 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11467 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11468 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11469 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11472 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11474 "%% This command is applicable only for unicast ipv4|ipv6\n");
11475 return CMD_WARNING
;
11478 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
);
11481 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11484 struct listnode
*node
, *nnode
;
11487 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11488 vty_out(vty
, "\nInstance %s:\n",
11489 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11492 update_group_show(bgp
, afi
, safi
, vty
, 0);
11496 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11497 int safi
, uint64_t subgrp_id
)
11502 if (strmatch(name
, "all")) {
11503 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11504 return CMD_SUCCESS
;
11506 bgp
= bgp_lookup_by_name(name
);
11509 bgp
= bgp_get_default();
11513 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11514 return CMD_SUCCESS
;
11517 DEFUN (show_ip_bgp_updgrps
,
11518 show_ip_bgp_updgrps_cmd
,
11519 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11523 BGP_INSTANCE_HELP_STR
11525 BGP_SAFI_WITH_LABEL_HELP_STR
11526 "Detailed info about dynamic update groups\n"
11527 "Specific subgroup to display detailed info for\n")
11530 afi_t afi
= AFI_IP6
;
11531 safi_t safi
= SAFI_UNICAST
;
11532 uint64_t subgrp_id
= 0;
11536 /* show [ip] bgp */
11537 if (argv_find(argv
, argc
, "ip", &idx
))
11539 /* [<vrf> VIEWVRFNAME] */
11540 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11541 vrf
= argv
[idx
+ 1]->arg
;
11542 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11544 } else if (argv_find(argv
, argc
, "view", &idx
))
11545 /* [<view> VIEWVRFNAME] */
11546 vrf
= argv
[idx
+ 1]->arg
;
11547 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11548 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11549 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11552 /* get subgroup id, if provided */
11554 if (argv
[idx
]->type
== VARIABLE_TKN
)
11555 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11557 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11560 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11561 show_bgp_instance_all_ipv6_updgrps_cmd
,
11562 "show [ip] bgp <view|vrf> all update-groups",
11566 BGP_INSTANCE_ALL_HELP_STR
11567 "Detailed info about dynamic update groups\n")
11569 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11570 return CMD_SUCCESS
;
11573 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
11574 show_bgp_l2vpn_evpn_updgrps_cmd
,
11575 "show [ip] bgp l2vpn evpn update-groups",
11579 "l2vpn address family\n"
11580 "evpn sub-address family\n"
11581 "Detailed info about dynamic update groups\n")
11584 uint64_t subgrp_id
= 0;
11586 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
11587 return CMD_SUCCESS
;
11590 DEFUN (show_bgp_updgrps_stats
,
11591 show_bgp_updgrps_stats_cmd
,
11592 "show [ip] bgp update-groups statistics",
11596 "Detailed info about dynamic update groups\n"
11601 bgp
= bgp_get_default();
11603 update_group_show_stats(bgp
, vty
);
11605 return CMD_SUCCESS
;
11608 DEFUN (show_bgp_instance_updgrps_stats
,
11609 show_bgp_instance_updgrps_stats_cmd
,
11610 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11614 BGP_INSTANCE_HELP_STR
11615 "Detailed info about dynamic update groups\n"
11621 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11623 update_group_show_stats(bgp
, vty
);
11625 return CMD_SUCCESS
;
11628 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11629 afi_t afi
, safi_t safi
,
11630 const char *what
, uint64_t subgrp_id
)
11635 bgp
= bgp_lookup_by_name(name
);
11637 bgp
= bgp_get_default();
11640 if (!strcmp(what
, "advertise-queue"))
11641 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11643 else if (!strcmp(what
, "advertised-routes"))
11644 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11646 else if (!strcmp(what
, "packet-queue"))
11647 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11652 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11653 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11654 "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",
11655 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11657 "Detailed info about dynamic update groups\n"
11658 "Specific subgroup to display info for\n"
11659 "Advertisement queue\n"
11660 "Announced routes\n"
11663 uint64_t subgrp_id
= 0;
11667 subgrp_id
= strtoull(sgid
, NULL
, 10);
11672 afiz
= bgp_vty_afi_from_str(afi
);
11676 afiz
= bgp_vty_afi_from_str(afi
);
11677 if (afiz
!= AFI_IP
)
11679 "%% Cannot specify both 'ip' and 'ipv6'\n");
11680 return CMD_WARNING
;
11683 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11685 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11686 return CMD_SUCCESS
;
11689 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11691 struct listnode
*node
, *nnode
;
11692 struct prefix
*range
;
11695 char buf
[PREFIX2STR_BUFFER
];
11698 const char *peer_status
;
11699 const char *af_str
;
11704 conf
= group
->conf
;
11706 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11707 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11708 group
->name
, conf
->as
);
11709 } else if (conf
->as_type
== AS_INTERNAL
) {
11710 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11711 group
->name
, group
->bgp
->as
);
11713 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11716 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11717 vty_out(vty
, " Peer-group type is internal\n");
11719 vty_out(vty
, " Peer-group type is external\n");
11721 /* Display AFs configured. */
11722 vty_out(vty
, " Configured address-families:");
11723 FOREACH_AFI_SAFI (afi
, safi
) {
11724 if (conf
->afc
[afi
][safi
]) {
11726 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11730 vty_out(vty
, " none\n");
11732 vty_out(vty
, "\n");
11734 /* Display listen ranges (for dynamic neighbors), if any */
11735 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11738 else if (afi
== AFI_IP6
)
11742 lr_count
= listcount(group
->listen_range
[afi
]);
11744 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11748 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11750 prefix2str(range
, buf
, sizeof(buf
));
11751 vty_out(vty
, " %s\n", buf
);
11756 /* Display group members and their status */
11757 if (listcount(group
->peer
)) {
11758 vty_out(vty
, " Peer-group members:\n");
11759 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11760 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11761 peer_status
= "Idle (Admin)";
11762 else if (CHECK_FLAG(peer
->sflags
,
11763 PEER_STATUS_PREFIX_OVERFLOW
))
11764 peer_status
= "Idle (PfxCt)";
11766 peer_status
= lookup_msg(bgp_status_msg
,
11767 peer
->status
, NULL
);
11769 dynamic
= peer_dynamic_neighbor(peer
);
11770 vty_out(vty
, " %s %s %s \n", peer
->host
,
11771 dynamic
? "(dynamic)" : "", peer_status
);
11775 return CMD_SUCCESS
;
11778 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11779 const char *group_name
)
11782 struct listnode
*node
, *nnode
;
11783 struct peer_group
*group
;
11784 bool found
= false;
11786 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11789 vty_out(vty
, "%% BGP instance not found\n");
11790 return CMD_WARNING
;
11793 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11795 if (strmatch(group
->name
, group_name
)) {
11796 bgp_show_one_peer_group(vty
, group
);
11801 bgp_show_one_peer_group(vty
, group
);
11805 if (group_name
&& !found
)
11806 vty_out(vty
, "%% No such peer-group\n");
11808 return CMD_SUCCESS
;
11811 DEFUN (show_ip_bgp_peer_groups
,
11812 show_ip_bgp_peer_groups_cmd
,
11813 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11817 BGP_INSTANCE_HELP_STR
11818 "Detailed information on BGP peer groups\n"
11819 "Peer group name\n")
11824 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11826 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11828 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11832 /* Redistribute VTY commands. */
11834 DEFUN (bgp_redistribute_ipv4
,
11835 bgp_redistribute_ipv4_cmd
,
11836 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11837 "Redistribute information from another routing protocol\n"
11838 FRR_IP_REDIST_HELP_STR_BGPD
)
11840 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11841 int idx_protocol
= 1;
11844 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11846 vty_out(vty
, "%% Invalid route type\n");
11847 return CMD_WARNING_CONFIG_FAILED
;
11850 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11851 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
11855 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11856 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11857 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11859 DEFUN (bgp_redistribute_ipv4_rmap
,
11860 bgp_redistribute_ipv4_rmap_cmd
,
11861 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11862 "Redistribute information from another routing protocol\n"
11863 FRR_IP_REDIST_HELP_STR_BGPD
11864 "Route map reference\n"
11865 "Pointer to route-map entries\n")
11867 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11868 int idx_protocol
= 1;
11871 struct bgp_redist
*red
;
11873 struct route_map
*route_map
= route_map_lookup_warn_noexist(
11874 vty
, argv
[idx_word
]->arg
);
11876 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11878 vty_out(vty
, "%% Invalid route type\n");
11879 return CMD_WARNING_CONFIG_FAILED
;
11882 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11884 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
11885 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11889 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
11890 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11891 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11892 "Route map reference\n"
11893 "Pointer to route-map entries\n")
11895 DEFUN (bgp_redistribute_ipv4_metric
,
11896 bgp_redistribute_ipv4_metric_cmd
,
11897 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11898 "Redistribute information from another routing protocol\n"
11899 FRR_IP_REDIST_HELP_STR_BGPD
11900 "Metric for redistributed routes\n"
11901 "Default metric\n")
11903 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11904 int idx_protocol
= 1;
11905 int idx_number
= 3;
11908 struct bgp_redist
*red
;
11911 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11913 vty_out(vty
, "%% Invalid route type\n");
11914 return CMD_WARNING_CONFIG_FAILED
;
11916 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11918 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11919 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11920 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11924 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
11925 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11926 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11927 "Metric for redistributed routes\n"
11928 "Default metric\n")
11930 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
11931 bgp_redistribute_ipv4_rmap_metric_cmd
,
11932 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11933 "Redistribute information from another routing protocol\n"
11934 FRR_IP_REDIST_HELP_STR_BGPD
11935 "Route map reference\n"
11936 "Pointer to route-map entries\n"
11937 "Metric for redistributed routes\n"
11938 "Default metric\n")
11940 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11941 int idx_protocol
= 1;
11943 int idx_number
= 5;
11946 struct bgp_redist
*red
;
11948 struct route_map
*route_map
=
11949 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
11951 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11953 vty_out(vty
, "%% Invalid route type\n");
11954 return CMD_WARNING_CONFIG_FAILED
;
11956 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11958 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11960 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
11961 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11962 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11966 bgp_redistribute_ipv4_rmap_metric
,
11967 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
11968 "redistribute " FRR_IP_REDIST_STR_BGPD
11969 " route-map WORD metric (0-4294967295)",
11970 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11971 "Route map reference\n"
11972 "Pointer to route-map entries\n"
11973 "Metric for redistributed routes\n"
11974 "Default metric\n")
11976 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
11977 bgp_redistribute_ipv4_metric_rmap_cmd
,
11978 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
11979 "Redistribute information from another routing protocol\n"
11980 FRR_IP_REDIST_HELP_STR_BGPD
11981 "Metric for redistributed routes\n"
11983 "Route map reference\n"
11984 "Pointer to route-map entries\n")
11986 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11987 int idx_protocol
= 1;
11988 int idx_number
= 3;
11992 struct bgp_redist
*red
;
11994 struct route_map
*route_map
=
11995 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
11997 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11999 vty_out(vty
, "%% Invalid route type\n");
12000 return CMD_WARNING_CONFIG_FAILED
;
12002 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12004 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12005 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12007 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12008 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12012 bgp_redistribute_ipv4_metric_rmap
,
12013 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
12014 "redistribute " FRR_IP_REDIST_STR_BGPD
12015 " metric (0-4294967295) route-map WORD",
12016 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12017 "Metric for redistributed routes\n"
12019 "Route map reference\n"
12020 "Pointer to route-map entries\n")
12022 DEFUN (bgp_redistribute_ipv4_ospf
,
12023 bgp_redistribute_ipv4_ospf_cmd
,
12024 "redistribute <ospf|table> (1-65535)",
12025 "Redistribute information from another routing protocol\n"
12026 "Open Shortest Path First (OSPFv2)\n"
12027 "Non-main Kernel Routing Table\n"
12028 "Instance ID/Table ID\n")
12030 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12031 int idx_ospf_table
= 1;
12032 int idx_number
= 2;
12033 unsigned short instance
;
12034 unsigned short protocol
;
12036 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12038 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12039 protocol
= ZEBRA_ROUTE_OSPF
;
12041 protocol
= ZEBRA_ROUTE_TABLE
;
12043 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12044 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
12047 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
12048 "redistribute <ospf|table> (1-65535)",
12049 "Redistribute information from another routing protocol\n"
12050 "Open Shortest Path First (OSPFv2)\n"
12051 "Non-main Kernel Routing Table\n"
12052 "Instance ID/Table ID\n")
12054 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
12055 bgp_redistribute_ipv4_ospf_rmap_cmd
,
12056 "redistribute <ospf|table> (1-65535) route-map WORD",
12057 "Redistribute information from another routing protocol\n"
12058 "Open Shortest Path First (OSPFv2)\n"
12059 "Non-main Kernel Routing Table\n"
12060 "Instance ID/Table ID\n"
12061 "Route map reference\n"
12062 "Pointer to route-map entries\n")
12064 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12065 int idx_ospf_table
= 1;
12066 int idx_number
= 2;
12068 struct bgp_redist
*red
;
12069 unsigned short instance
;
12072 struct route_map
*route_map
=
12073 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12075 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12076 protocol
= ZEBRA_ROUTE_OSPF
;
12078 protocol
= ZEBRA_ROUTE_TABLE
;
12080 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12081 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12083 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12084 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12087 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
12088 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
12089 "redistribute <ospf|table> (1-65535) route-map WORD",
12090 "Redistribute information from another routing protocol\n"
12091 "Open Shortest Path First (OSPFv2)\n"
12092 "Non-main Kernel Routing Table\n"
12093 "Instance ID/Table ID\n"
12094 "Route map reference\n"
12095 "Pointer to route-map entries\n")
12097 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
12098 bgp_redistribute_ipv4_ospf_metric_cmd
,
12099 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12100 "Redistribute information from another routing protocol\n"
12101 "Open Shortest Path First (OSPFv2)\n"
12102 "Non-main Kernel Routing Table\n"
12103 "Instance ID/Table ID\n"
12104 "Metric for redistributed routes\n"
12105 "Default metric\n")
12107 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12108 int idx_ospf_table
= 1;
12109 int idx_number
= 2;
12110 int idx_number_2
= 4;
12112 struct bgp_redist
*red
;
12113 unsigned short instance
;
12117 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12118 protocol
= ZEBRA_ROUTE_OSPF
;
12120 protocol
= ZEBRA_ROUTE_TABLE
;
12122 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12123 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12125 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12126 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12128 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12131 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
12132 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
12133 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12134 "Redistribute information from another routing protocol\n"
12135 "Open Shortest Path First (OSPFv2)\n"
12136 "Non-main Kernel Routing Table\n"
12137 "Instance ID/Table ID\n"
12138 "Metric for redistributed routes\n"
12139 "Default metric\n")
12141 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
12142 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
12143 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12144 "Redistribute information from another routing protocol\n"
12145 "Open Shortest Path First (OSPFv2)\n"
12146 "Non-main Kernel Routing Table\n"
12147 "Instance ID/Table ID\n"
12148 "Route map reference\n"
12149 "Pointer to route-map entries\n"
12150 "Metric for redistributed routes\n"
12151 "Default metric\n")
12153 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12154 int idx_ospf_table
= 1;
12155 int idx_number
= 2;
12157 int idx_number_2
= 6;
12159 struct bgp_redist
*red
;
12160 unsigned short instance
;
12163 struct route_map
*route_map
=
12164 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12166 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12167 protocol
= ZEBRA_ROUTE_OSPF
;
12169 protocol
= ZEBRA_ROUTE_TABLE
;
12171 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12172 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12174 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12176 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12177 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12179 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12183 bgp_redistribute_ipv4_ospf_rmap_metric
,
12184 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
12185 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12186 "Redistribute information from another routing protocol\n"
12187 "Open Shortest Path First (OSPFv2)\n"
12188 "Non-main Kernel Routing Table\n"
12189 "Instance ID/Table ID\n"
12190 "Route map reference\n"
12191 "Pointer to route-map entries\n"
12192 "Metric for redistributed routes\n"
12193 "Default metric\n")
12195 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
12196 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
12197 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12198 "Redistribute information from another routing protocol\n"
12199 "Open Shortest Path First (OSPFv2)\n"
12200 "Non-main Kernel Routing Table\n"
12201 "Instance ID/Table ID\n"
12202 "Metric for redistributed routes\n"
12204 "Route map reference\n"
12205 "Pointer to route-map entries\n")
12207 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12208 int idx_ospf_table
= 1;
12209 int idx_number
= 2;
12210 int idx_number_2
= 4;
12213 struct bgp_redist
*red
;
12214 unsigned short instance
;
12217 struct route_map
*route_map
=
12218 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12220 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12221 protocol
= ZEBRA_ROUTE_OSPF
;
12223 protocol
= ZEBRA_ROUTE_TABLE
;
12225 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12226 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12228 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12229 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12232 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12233 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12237 bgp_redistribute_ipv4_ospf_metric_rmap
,
12238 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
12239 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12240 "Redistribute information from another routing protocol\n"
12241 "Open Shortest Path First (OSPFv2)\n"
12242 "Non-main Kernel Routing Table\n"
12243 "Instance ID/Table ID\n"
12244 "Metric for redistributed routes\n"
12246 "Route map reference\n"
12247 "Pointer to route-map entries\n")
12249 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12250 no_bgp_redistribute_ipv4_ospf_cmd
,
12251 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12253 "Redistribute information from another routing protocol\n"
12254 "Open Shortest Path First (OSPFv2)\n"
12255 "Non-main Kernel Routing Table\n"
12256 "Instance ID/Table ID\n"
12257 "Metric for redistributed routes\n"
12259 "Route map reference\n"
12260 "Pointer to route-map entries\n")
12262 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12263 int idx_ospf_table
= 2;
12264 int idx_number
= 3;
12265 unsigned short instance
;
12268 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12269 protocol
= ZEBRA_ROUTE_OSPF
;
12271 protocol
= ZEBRA_ROUTE_TABLE
;
12273 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12274 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12278 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12279 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12281 "Redistribute information from another routing protocol\n"
12282 "Open Shortest Path First (OSPFv2)\n"
12283 "Non-main Kernel Routing Table\n"
12284 "Instance ID/Table ID\n"
12285 "Metric for redistributed routes\n"
12287 "Route map reference\n"
12288 "Pointer to route-map entries\n")
12290 DEFUN (no_bgp_redistribute_ipv4
,
12291 no_bgp_redistribute_ipv4_cmd
,
12292 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12294 "Redistribute information from another routing protocol\n"
12295 FRR_IP_REDIST_HELP_STR_BGPD
12296 "Metric for redistributed routes\n"
12298 "Route map reference\n"
12299 "Pointer to route-map entries\n")
12301 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12302 int idx_protocol
= 2;
12305 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12307 vty_out(vty
, "%% Invalid route type\n");
12308 return CMD_WARNING_CONFIG_FAILED
;
12310 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12314 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12315 "no redistribute " FRR_IP_REDIST_STR_BGPD
12316 " [metric (0-4294967295)] [route-map WORD]",
12318 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12319 "Metric for redistributed routes\n"
12321 "Route map reference\n"
12322 "Pointer to route-map entries\n")
12324 DEFUN (bgp_redistribute_ipv6
,
12325 bgp_redistribute_ipv6_cmd
,
12326 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12327 "Redistribute information from another routing protocol\n"
12328 FRR_IP6_REDIST_HELP_STR_BGPD
)
12330 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12331 int idx_protocol
= 1;
12334 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12336 vty_out(vty
, "%% Invalid route type\n");
12337 return CMD_WARNING_CONFIG_FAILED
;
12340 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12341 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12344 DEFUN (bgp_redistribute_ipv6_rmap
,
12345 bgp_redistribute_ipv6_rmap_cmd
,
12346 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12347 "Redistribute information from another routing protocol\n"
12348 FRR_IP6_REDIST_HELP_STR_BGPD
12349 "Route map reference\n"
12350 "Pointer to route-map entries\n")
12352 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12353 int idx_protocol
= 1;
12356 struct bgp_redist
*red
;
12358 struct route_map
*route_map
=
12359 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12361 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12363 vty_out(vty
, "%% Invalid route type\n");
12364 return CMD_WARNING_CONFIG_FAILED
;
12367 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12369 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12370 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12373 DEFUN (bgp_redistribute_ipv6_metric
,
12374 bgp_redistribute_ipv6_metric_cmd
,
12375 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12376 "Redistribute information from another routing protocol\n"
12377 FRR_IP6_REDIST_HELP_STR_BGPD
12378 "Metric for redistributed routes\n"
12379 "Default metric\n")
12381 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12382 int idx_protocol
= 1;
12383 int idx_number
= 3;
12386 struct bgp_redist
*red
;
12389 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12391 vty_out(vty
, "%% Invalid route type\n");
12392 return CMD_WARNING_CONFIG_FAILED
;
12394 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12396 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12397 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12398 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12401 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12402 bgp_redistribute_ipv6_rmap_metric_cmd
,
12403 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12404 "Redistribute information from another routing protocol\n"
12405 FRR_IP6_REDIST_HELP_STR_BGPD
12406 "Route map reference\n"
12407 "Pointer to route-map entries\n"
12408 "Metric for redistributed routes\n"
12409 "Default metric\n")
12411 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12412 int idx_protocol
= 1;
12414 int idx_number
= 5;
12417 struct bgp_redist
*red
;
12419 struct route_map
*route_map
=
12420 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12422 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12424 vty_out(vty
, "%% Invalid route type\n");
12425 return CMD_WARNING_CONFIG_FAILED
;
12427 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12429 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12431 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12432 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12434 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12437 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12438 bgp_redistribute_ipv6_metric_rmap_cmd
,
12439 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12440 "Redistribute information from another routing protocol\n"
12441 FRR_IP6_REDIST_HELP_STR_BGPD
12442 "Metric for redistributed routes\n"
12444 "Route map reference\n"
12445 "Pointer to route-map entries\n")
12447 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12448 int idx_protocol
= 1;
12449 int idx_number
= 3;
12453 struct bgp_redist
*red
;
12455 struct route_map
*route_map
=
12456 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12458 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12460 vty_out(vty
, "%% Invalid route type\n");
12461 return CMD_WARNING_CONFIG_FAILED
;
12463 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12465 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12466 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12469 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12470 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12473 DEFUN (no_bgp_redistribute_ipv6
,
12474 no_bgp_redistribute_ipv6_cmd
,
12475 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12477 "Redistribute information from another routing protocol\n"
12478 FRR_IP6_REDIST_HELP_STR_BGPD
12479 "Metric for redistributed routes\n"
12481 "Route map reference\n"
12482 "Pointer to route-map entries\n")
12484 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12485 int idx_protocol
= 2;
12488 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12490 vty_out(vty
, "%% Invalid route type\n");
12491 return CMD_WARNING_CONFIG_FAILED
;
12494 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12497 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12502 /* Unicast redistribution only. */
12503 if (safi
!= SAFI_UNICAST
)
12506 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12507 /* Redistribute BGP does not make sense. */
12508 if (i
!= ZEBRA_ROUTE_BGP
) {
12509 struct list
*red_list
;
12510 struct listnode
*node
;
12511 struct bgp_redist
*red
;
12513 red_list
= bgp
->redist
[afi
][i
];
12517 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12518 /* "redistribute" configuration. */
12519 vty_out(vty
, " redistribute %s",
12520 zebra_route_string(i
));
12522 vty_out(vty
, " %d", red
->instance
);
12523 if (red
->redist_metric_flag
)
12524 vty_out(vty
, " metric %u",
12525 red
->redist_metric
);
12526 if (red
->rmap
.name
)
12527 vty_out(vty
, " route-map %s",
12529 vty_out(vty
, "\n");
12535 /* This is part of the address-family block (unicast only) */
12536 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12541 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12542 if (listcount(bgp
->vpn_policy
[afi
].import_vrf
))
12543 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12544 bgp
->vpn_policy
[afi
]
12545 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12547 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
12548 bgp
->vpn_policy
[afi
]
12549 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12551 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12552 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12553 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12554 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12557 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12558 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12560 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12563 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12564 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12565 bgp
->vpn_policy
[afi
].tovpn_label
);
12568 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12569 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12570 char buf
[RD_ADDRSTRLEN
];
12571 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12572 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12575 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12576 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12578 char buf
[PREFIX_STRLEN
];
12579 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12580 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12583 vty_out(vty
, "%*snexthop vpn export %s\n",
12587 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12588 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12590 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12591 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12593 char *b
= ecommunity_ecom2str(
12594 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12595 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12596 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12597 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12599 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12600 char *b
= ecommunity_ecom2str(
12601 bgp
->vpn_policy
[afi
]
12602 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12603 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12604 ECOMMUNITY_ROUTE_TARGET
);
12605 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12606 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12608 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12609 char *b
= ecommunity_ecom2str(
12610 bgp
->vpn_policy
[afi
]
12611 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12612 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12613 ECOMMUNITY_ROUTE_TARGET
);
12614 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12615 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12619 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12620 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12621 bgp
->vpn_policy
[afi
]
12622 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12624 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12625 char *b
= ecommunity_ecom2str(
12626 bgp
->vpn_policy
[afi
]
12627 .import_redirect_rtlist
,
12628 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12629 ECOMMUNITY_ROUTE_TARGET
);
12631 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12632 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12637 /* BGP node structure. */
12638 static struct cmd_node bgp_node
= {
12639 BGP_NODE
, "%s(config-router)# ", 1,
12642 static struct cmd_node bgp_ipv4_unicast_node
= {
12643 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12646 static struct cmd_node bgp_ipv4_multicast_node
= {
12647 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12650 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12651 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12654 static struct cmd_node bgp_ipv6_unicast_node
= {
12655 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12658 static struct cmd_node bgp_ipv6_multicast_node
= {
12659 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12662 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12663 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12666 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12667 "%s(config-router-af)# ", 1};
12669 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12670 "%s(config-router-af-vpnv6)# ", 1};
12672 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12673 "%s(config-router-evpn)# ", 1};
12675 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12676 "%s(config-router-af-vni)# ", 1};
12678 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12679 "%s(config-router-af)# ", 1};
12681 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12682 "%s(config-router-af-vpnv6)# ", 1};
12684 static void community_list_vty(void);
12686 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12690 struct listnode
*lnbgp
, *lnpeer
;
12692 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12693 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12694 /* only provide suggestions on the appropriate input
12696 * they'll otherwise show up multiple times */
12697 enum cmd_token_type match_type
;
12698 char *name
= peer
->host
;
12700 if (peer
->conf_if
) {
12701 match_type
= VARIABLE_TKN
;
12702 name
= peer
->conf_if
;
12703 } else if (strchr(peer
->host
, ':'))
12704 match_type
= IPV6_TKN
;
12706 match_type
= IPV4_TKN
;
12708 if (token
->type
!= match_type
)
12711 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12716 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12717 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12718 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12719 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12720 {.completions
= NULL
}};
12722 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12725 struct peer_group
*group
;
12726 struct listnode
*lnbgp
, *lnpeer
;
12728 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12729 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12730 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12735 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12736 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12737 {.completions
= NULL
} };
12739 void bgp_vty_init(void)
12741 cmd_variable_handler_register(bgp_var_neighbor
);
12742 cmd_variable_handler_register(bgp_var_peergroup
);
12744 /* Install bgp top node. */
12745 install_node(&bgp_node
, bgp_config_write
);
12746 install_node(&bgp_ipv4_unicast_node
, NULL
);
12747 install_node(&bgp_ipv4_multicast_node
, NULL
);
12748 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12749 install_node(&bgp_ipv6_unicast_node
, NULL
);
12750 install_node(&bgp_ipv6_multicast_node
, NULL
);
12751 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12752 install_node(&bgp_vpnv4_node
, NULL
);
12753 install_node(&bgp_vpnv6_node
, NULL
);
12754 install_node(&bgp_evpn_node
, NULL
);
12755 install_node(&bgp_evpn_vni_node
, NULL
);
12756 install_node(&bgp_flowspecv4_node
, NULL
);
12757 install_node(&bgp_flowspecv6_node
, NULL
);
12759 /* Install default VTY commands to new nodes. */
12760 install_default(BGP_NODE
);
12761 install_default(BGP_IPV4_NODE
);
12762 install_default(BGP_IPV4M_NODE
);
12763 install_default(BGP_IPV4L_NODE
);
12764 install_default(BGP_IPV6_NODE
);
12765 install_default(BGP_IPV6M_NODE
);
12766 install_default(BGP_IPV6L_NODE
);
12767 install_default(BGP_VPNV4_NODE
);
12768 install_default(BGP_VPNV6_NODE
);
12769 install_default(BGP_FLOWSPECV4_NODE
);
12770 install_default(BGP_FLOWSPECV6_NODE
);
12771 install_default(BGP_EVPN_NODE
);
12772 install_default(BGP_EVPN_VNI_NODE
);
12774 /* "bgp multiple-instance" commands. */
12775 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
12776 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
12778 /* "bgp config-type" commands. */
12779 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
12780 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
12782 /* "bgp local-mac" hidden commands. */
12783 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
12784 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
12786 /* bgp route-map delay-timer commands. */
12787 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12788 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12790 /* Dummy commands (Currently not supported) */
12791 install_element(BGP_NODE
, &no_synchronization_cmd
);
12792 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12794 /* "router bgp" commands. */
12795 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12797 /* "no router bgp" commands. */
12798 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12800 /* "bgp router-id" commands. */
12801 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12802 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12804 /* "bgp cluster-id" commands. */
12805 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12806 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12808 /* "bgp confederation" commands. */
12809 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12810 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12812 /* "bgp confederation peers" commands. */
12813 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12814 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12816 /* bgp max-med command */
12817 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12818 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12819 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12820 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12821 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12823 /* bgp disable-ebgp-connected-nh-check */
12824 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12825 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12827 /* bgp update-delay command */
12828 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12829 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12830 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12832 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12833 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12834 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12835 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12837 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12838 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12840 /* "maximum-paths" commands. */
12841 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12842 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12843 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12844 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12845 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12846 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12847 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12848 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12849 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12850 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12851 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12852 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12853 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12854 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12855 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12857 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12858 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12859 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12860 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12861 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12863 /* "timers bgp" commands. */
12864 install_element(BGP_NODE
, &bgp_timers_cmd
);
12865 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12867 /* route-map delay-timer commands - per instance for backwards compat.
12869 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12870 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12872 /* "bgp client-to-client reflection" commands */
12873 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
12874 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
12876 /* "bgp always-compare-med" commands */
12877 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
12878 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
12880 /* bgp ebgp-requires-policy */
12881 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
12882 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
12884 /* "bgp deterministic-med" commands */
12885 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
12886 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
12888 /* "bgp graceful-restart" commands */
12889 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
12890 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
12891 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
12892 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
12893 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
12894 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
12896 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
12897 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
12899 /* "bgp graceful-shutdown" commands */
12900 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
12901 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
12903 /* "bgp fast-external-failover" commands */
12904 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
12905 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
12907 /* "bgp enforce-first-as" commands */
12908 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
12910 /* "bgp bestpath compare-routerid" commands */
12911 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
12912 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
12914 /* "bgp bestpath as-path ignore" commands */
12915 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
12916 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
12918 /* "bgp bestpath as-path confed" commands */
12919 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
12920 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
12922 /* "bgp bestpath as-path multipath-relax" commands */
12923 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
12924 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
12926 /* "bgp log-neighbor-changes" commands */
12927 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
12928 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
12930 /* "bgp bestpath med" commands */
12931 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
12932 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
12934 /* "no bgp default ipv4-unicast" commands. */
12935 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
12936 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
12938 /* "bgp network import-check" commands. */
12939 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
12940 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
12941 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
12943 /* "bgp default local-preference" commands. */
12944 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
12945 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
12947 /* bgp default show-hostname */
12948 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
12949 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
12951 /* "bgp default subgroup-pkt-queue-max" commands. */
12952 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
12953 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
12955 /* bgp ibgp-allow-policy-mods command */
12956 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
12957 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
12959 /* "bgp listen limit" commands. */
12960 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
12961 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
12963 /* "bgp listen range" commands. */
12964 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
12965 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
12967 /* "bgp default shutdown" command */
12968 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
12970 /* "neighbor remote-as" commands. */
12971 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
12972 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
12973 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
12974 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
12975 install_element(BGP_NODE
,
12976 &neighbor_interface_v6only_config_remote_as_cmd
);
12977 install_element(BGP_NODE
, &no_neighbor_cmd
);
12978 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
12980 /* "neighbor peer-group" commands. */
12981 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
12982 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
12983 install_element(BGP_NODE
,
12984 &no_neighbor_interface_peer_group_remote_as_cmd
);
12986 /* "neighbor local-as" commands. */
12987 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
12988 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
12989 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
12990 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
12992 /* "neighbor solo" commands. */
12993 install_element(BGP_NODE
, &neighbor_solo_cmd
);
12994 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
12996 /* "neighbor password" commands. */
12997 install_element(BGP_NODE
, &neighbor_password_cmd
);
12998 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
13000 /* "neighbor activate" commands. */
13001 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
13002 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
13003 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
13004 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
13005 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
13006 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
13007 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
13008 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
13009 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
13010 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
13011 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
13012 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
13014 /* "no neighbor activate" commands. */
13015 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
13016 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
13017 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
13018 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
13019 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
13020 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
13021 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
13022 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
13023 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
13024 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
13025 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
13026 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
13028 /* "neighbor peer-group" set commands. */
13029 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
13030 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13031 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13032 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13033 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13034 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13035 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13036 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13037 install_element(BGP_FLOWSPECV4_NODE
,
13038 &neighbor_set_peer_group_hidden_cmd
);
13039 install_element(BGP_FLOWSPECV6_NODE
,
13040 &neighbor_set_peer_group_hidden_cmd
);
13042 /* "no neighbor peer-group unset" commands. */
13043 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
13044 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13045 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13046 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13047 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13048 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13049 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13050 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13051 install_element(BGP_FLOWSPECV4_NODE
,
13052 &no_neighbor_set_peer_group_hidden_cmd
);
13053 install_element(BGP_FLOWSPECV6_NODE
,
13054 &no_neighbor_set_peer_group_hidden_cmd
);
13056 /* "neighbor softreconfiguration inbound" commands.*/
13057 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
13058 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
13059 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13060 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13061 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13062 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13063 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13064 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13065 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13066 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13067 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13068 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13069 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13070 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13071 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13072 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13073 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13074 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13075 install_element(BGP_FLOWSPECV4_NODE
,
13076 &neighbor_soft_reconfiguration_cmd
);
13077 install_element(BGP_FLOWSPECV4_NODE
,
13078 &no_neighbor_soft_reconfiguration_cmd
);
13079 install_element(BGP_FLOWSPECV6_NODE
,
13080 &neighbor_soft_reconfiguration_cmd
);
13081 install_element(BGP_FLOWSPECV6_NODE
,
13082 &no_neighbor_soft_reconfiguration_cmd
);
13083 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
13084 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13086 /* "neighbor attribute-unchanged" commands. */
13087 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
13088 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
13089 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
13090 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13091 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
13092 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13093 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
13094 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13095 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
13096 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13097 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
13098 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13099 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
13100 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13101 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
13102 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13103 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
13104 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13106 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
13107 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
13109 /* "nexthop-local unchanged" commands */
13110 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
13111 install_element(BGP_IPV6_NODE
,
13112 &no_neighbor_nexthop_local_unchanged_cmd
);
13114 /* "neighbor next-hop-self" commands. */
13115 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
13116 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
13117 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
13118 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13119 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
13120 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
13121 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
13122 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
13123 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
13124 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13125 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
13126 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
13127 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
13128 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
13129 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
13130 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13131 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
13132 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13133 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
13134 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
13136 /* "neighbor next-hop-self force" commands. */
13137 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
13138 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
13139 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13140 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13141 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
13142 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13143 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
13144 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13145 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13146 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13147 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
13148 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13149 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
13150 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13151 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13152 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13153 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13154 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13156 /* "neighbor as-override" commands. */
13157 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
13158 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
13159 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
13160 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
13161 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
13162 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
13163 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
13164 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
13165 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
13166 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
13167 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
13168 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
13169 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
13170 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
13171 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
13172 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
13173 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
13174 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
13176 /* "neighbor remove-private-AS" commands. */
13177 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
13178 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
13179 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
13180 install_element(BGP_NODE
,
13181 &no_neighbor_remove_private_as_all_hidden_cmd
);
13182 install_element(BGP_NODE
,
13183 &neighbor_remove_private_as_replace_as_hidden_cmd
);
13184 install_element(BGP_NODE
,
13185 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
13186 install_element(BGP_NODE
,
13187 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13190 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13191 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
13192 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13193 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13194 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13195 install_element(BGP_IPV4_NODE
,
13196 &neighbor_remove_private_as_replace_as_cmd
);
13197 install_element(BGP_IPV4_NODE
,
13198 &no_neighbor_remove_private_as_replace_as_cmd
);
13199 install_element(BGP_IPV4_NODE
,
13200 &neighbor_remove_private_as_all_replace_as_cmd
);
13201 install_element(BGP_IPV4_NODE
,
13202 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13203 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
13204 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
13205 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
13206 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13207 install_element(BGP_IPV4M_NODE
,
13208 &neighbor_remove_private_as_replace_as_cmd
);
13209 install_element(BGP_IPV4M_NODE
,
13210 &no_neighbor_remove_private_as_replace_as_cmd
);
13211 install_element(BGP_IPV4M_NODE
,
13212 &neighbor_remove_private_as_all_replace_as_cmd
);
13213 install_element(BGP_IPV4M_NODE
,
13214 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13215 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
13216 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
13217 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
13218 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13219 install_element(BGP_IPV4L_NODE
,
13220 &neighbor_remove_private_as_replace_as_cmd
);
13221 install_element(BGP_IPV4L_NODE
,
13222 &no_neighbor_remove_private_as_replace_as_cmd
);
13223 install_element(BGP_IPV4L_NODE
,
13224 &neighbor_remove_private_as_all_replace_as_cmd
);
13225 install_element(BGP_IPV4L_NODE
,
13226 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13227 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
13228 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13229 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13230 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13231 install_element(BGP_IPV6_NODE
,
13232 &neighbor_remove_private_as_replace_as_cmd
);
13233 install_element(BGP_IPV6_NODE
,
13234 &no_neighbor_remove_private_as_replace_as_cmd
);
13235 install_element(BGP_IPV6_NODE
,
13236 &neighbor_remove_private_as_all_replace_as_cmd
);
13237 install_element(BGP_IPV6_NODE
,
13238 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13239 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
13240 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
13241 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
13242 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13243 install_element(BGP_IPV6M_NODE
,
13244 &neighbor_remove_private_as_replace_as_cmd
);
13245 install_element(BGP_IPV6M_NODE
,
13246 &no_neighbor_remove_private_as_replace_as_cmd
);
13247 install_element(BGP_IPV6M_NODE
,
13248 &neighbor_remove_private_as_all_replace_as_cmd
);
13249 install_element(BGP_IPV6M_NODE
,
13250 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13251 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
13252 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
13253 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
13254 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13255 install_element(BGP_IPV6L_NODE
,
13256 &neighbor_remove_private_as_replace_as_cmd
);
13257 install_element(BGP_IPV6L_NODE
,
13258 &no_neighbor_remove_private_as_replace_as_cmd
);
13259 install_element(BGP_IPV6L_NODE
,
13260 &neighbor_remove_private_as_all_replace_as_cmd
);
13261 install_element(BGP_IPV6L_NODE
,
13262 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13263 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
13264 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13265 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13266 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13267 install_element(BGP_VPNV4_NODE
,
13268 &neighbor_remove_private_as_replace_as_cmd
);
13269 install_element(BGP_VPNV4_NODE
,
13270 &no_neighbor_remove_private_as_replace_as_cmd
);
13271 install_element(BGP_VPNV4_NODE
,
13272 &neighbor_remove_private_as_all_replace_as_cmd
);
13273 install_element(BGP_VPNV4_NODE
,
13274 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13275 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
13276 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13277 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13278 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13279 install_element(BGP_VPNV6_NODE
,
13280 &neighbor_remove_private_as_replace_as_cmd
);
13281 install_element(BGP_VPNV6_NODE
,
13282 &no_neighbor_remove_private_as_replace_as_cmd
);
13283 install_element(BGP_VPNV6_NODE
,
13284 &neighbor_remove_private_as_all_replace_as_cmd
);
13285 install_element(BGP_VPNV6_NODE
,
13286 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13288 /* "neighbor send-community" commands.*/
13289 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
13290 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
13291 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
13292 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
13293 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
13294 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
13295 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
13296 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
13297 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
13298 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
13299 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
13300 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
13301 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
13302 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
13303 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
13304 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
13305 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
13306 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
13307 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
13308 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
13309 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
13310 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
13311 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
13312 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
13313 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
13314 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
13315 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
13316 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
13317 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
13318 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
13319 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
13320 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
13321 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
13322 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
13323 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
13324 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
13326 /* "neighbor route-reflector" commands.*/
13327 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
13328 install_element(BGP_NODE
,
13329 &no_neighbor_route_reflector_client_hidden_cmd
);
13330 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
13331 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
13332 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
13333 install_element(BGP_IPV4M_NODE
,
13334 &no_neighbor_route_reflector_client_cmd
);
13335 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
13336 install_element(BGP_IPV4L_NODE
,
13337 &no_neighbor_route_reflector_client_cmd
);
13338 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
13339 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
13340 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
13341 install_element(BGP_IPV6M_NODE
,
13342 &no_neighbor_route_reflector_client_cmd
);
13343 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
13344 install_element(BGP_IPV6L_NODE
,
13345 &no_neighbor_route_reflector_client_cmd
);
13346 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
13347 install_element(BGP_VPNV4_NODE
,
13348 &no_neighbor_route_reflector_client_cmd
);
13349 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
13350 install_element(BGP_VPNV6_NODE
,
13351 &no_neighbor_route_reflector_client_cmd
);
13352 install_element(BGP_FLOWSPECV4_NODE
,
13353 &neighbor_route_reflector_client_cmd
);
13354 install_element(BGP_FLOWSPECV4_NODE
,
13355 &no_neighbor_route_reflector_client_cmd
);
13356 install_element(BGP_FLOWSPECV6_NODE
,
13357 &neighbor_route_reflector_client_cmd
);
13358 install_element(BGP_FLOWSPECV6_NODE
,
13359 &no_neighbor_route_reflector_client_cmd
);
13360 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
13361 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
13363 /* "neighbor route-server" commands.*/
13364 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
13365 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
13366 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
13367 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
13368 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
13369 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
13370 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
13371 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
13372 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
13373 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
13374 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
13375 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
13376 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
13377 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
13378 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
13379 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
13380 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
13381 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
13382 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
13383 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
13384 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
13385 install_element(BGP_FLOWSPECV4_NODE
,
13386 &no_neighbor_route_server_client_cmd
);
13387 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
13388 install_element(BGP_FLOWSPECV6_NODE
,
13389 &no_neighbor_route_server_client_cmd
);
13391 /* "neighbor addpath-tx-all-paths" commands.*/
13392 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
13393 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
13394 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13395 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13396 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13397 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13398 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13399 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13400 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13401 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13402 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13403 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13404 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13405 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13406 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13407 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13408 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13409 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13411 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
13412 install_element(BGP_NODE
,
13413 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13414 install_element(BGP_NODE
,
13415 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13416 install_element(BGP_IPV4_NODE
,
13417 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13418 install_element(BGP_IPV4_NODE
,
13419 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13420 install_element(BGP_IPV4M_NODE
,
13421 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13422 install_element(BGP_IPV4M_NODE
,
13423 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13424 install_element(BGP_IPV4L_NODE
,
13425 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13426 install_element(BGP_IPV4L_NODE
,
13427 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13428 install_element(BGP_IPV6_NODE
,
13429 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13430 install_element(BGP_IPV6_NODE
,
13431 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13432 install_element(BGP_IPV6M_NODE
,
13433 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13434 install_element(BGP_IPV6M_NODE
,
13435 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13436 install_element(BGP_IPV6L_NODE
,
13437 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13438 install_element(BGP_IPV6L_NODE
,
13439 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13440 install_element(BGP_VPNV4_NODE
,
13441 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13442 install_element(BGP_VPNV4_NODE
,
13443 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13444 install_element(BGP_VPNV6_NODE
,
13445 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13446 install_element(BGP_VPNV6_NODE
,
13447 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13449 /* "neighbor passive" commands. */
13450 install_element(BGP_NODE
, &neighbor_passive_cmd
);
13451 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13454 /* "neighbor shutdown" commands. */
13455 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13456 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13457 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13458 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13460 /* "neighbor capability extended-nexthop" commands.*/
13461 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13462 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13464 /* "neighbor capability orf prefix-list" commands.*/
13465 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13466 install_element(BGP_NODE
,
13467 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13468 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13469 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13470 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13471 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13472 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13473 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13474 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13475 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13476 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13477 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13478 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13479 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13481 /* "neighbor capability dynamic" commands.*/
13482 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13483 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13485 /* "neighbor dont-capability-negotiate" commands. */
13486 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13487 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13489 /* "neighbor ebgp-multihop" commands. */
13490 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13491 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13492 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13494 /* "neighbor disable-connected-check" commands. */
13495 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13496 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13498 /* "neighbor enforce-first-as" commands. */
13499 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13500 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13502 /* "neighbor description" commands. */
13503 install_element(BGP_NODE
, &neighbor_description_cmd
);
13504 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13505 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13507 /* "neighbor update-source" commands. "*/
13508 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13509 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13511 /* "neighbor default-originate" commands. */
13512 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13513 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13514 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13515 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13516 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13517 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13518 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13519 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13520 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13521 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13522 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13523 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13524 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13525 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13526 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13527 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13528 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13529 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13530 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13531 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13532 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13534 /* "neighbor port" commands. */
13535 install_element(BGP_NODE
, &neighbor_port_cmd
);
13536 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13538 /* "neighbor weight" commands. */
13539 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13540 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13542 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13543 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13544 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13545 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13546 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13547 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13548 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13549 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13550 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13551 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13552 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13553 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13554 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13555 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13556 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13557 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13559 /* "neighbor override-capability" commands. */
13560 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13561 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13563 /* "neighbor strict-capability-match" commands. */
13564 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13565 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13567 /* "neighbor timers" commands. */
13568 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13569 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13571 /* "neighbor timers connect" commands. */
13572 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13573 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13575 /* "neighbor advertisement-interval" commands. */
13576 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13577 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13579 /* "neighbor interface" commands. */
13580 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13581 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13583 /* "neighbor distribute" commands. */
13584 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13585 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13586 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13587 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13588 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13589 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13590 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13591 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13592 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13593 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13594 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13595 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13596 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13597 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13598 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13599 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13600 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13601 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13603 /* "neighbor prefix-list" commands. */
13604 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13605 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13606 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13607 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13608 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13609 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13610 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13611 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13612 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13613 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13614 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13615 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13616 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13617 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13618 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13619 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13620 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13621 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13622 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13623 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13624 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13625 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13627 /* "neighbor filter-list" commands. */
13628 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13629 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13630 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13631 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13632 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13633 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13634 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13635 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13636 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13637 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13638 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13639 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13640 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13641 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13642 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13643 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13644 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13645 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13646 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13647 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13648 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13649 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13651 /* "neighbor route-map" commands. */
13652 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13653 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13654 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13655 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13656 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13657 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13658 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13659 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13660 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13661 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13662 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13663 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13664 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13665 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13666 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13667 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13668 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13669 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13670 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13671 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13672 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13673 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13674 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13675 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13677 /* "neighbor unsuppress-map" commands. */
13678 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13679 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13680 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13681 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13682 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13683 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13684 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13685 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13686 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13687 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13688 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13689 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13690 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13691 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13692 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13693 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13694 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13695 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13697 /* "neighbor maximum-prefix" commands. */
13698 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13699 install_element(BGP_NODE
,
13700 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13701 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13702 install_element(BGP_NODE
,
13703 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13704 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13705 install_element(BGP_NODE
,
13706 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13707 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13708 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13709 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13710 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13711 install_element(BGP_IPV4_NODE
,
13712 &neighbor_maximum_prefix_threshold_warning_cmd
);
13713 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13714 install_element(BGP_IPV4_NODE
,
13715 &neighbor_maximum_prefix_threshold_restart_cmd
);
13716 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13717 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13718 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13719 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13720 install_element(BGP_IPV4M_NODE
,
13721 &neighbor_maximum_prefix_threshold_warning_cmd
);
13722 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13723 install_element(BGP_IPV4M_NODE
,
13724 &neighbor_maximum_prefix_threshold_restart_cmd
);
13725 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13726 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13727 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13728 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13729 install_element(BGP_IPV4L_NODE
,
13730 &neighbor_maximum_prefix_threshold_warning_cmd
);
13731 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13732 install_element(BGP_IPV4L_NODE
,
13733 &neighbor_maximum_prefix_threshold_restart_cmd
);
13734 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13735 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13736 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13737 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13738 install_element(BGP_IPV6_NODE
,
13739 &neighbor_maximum_prefix_threshold_warning_cmd
);
13740 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13741 install_element(BGP_IPV6_NODE
,
13742 &neighbor_maximum_prefix_threshold_restart_cmd
);
13743 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13744 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13745 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13746 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13747 install_element(BGP_IPV6M_NODE
,
13748 &neighbor_maximum_prefix_threshold_warning_cmd
);
13749 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13750 install_element(BGP_IPV6M_NODE
,
13751 &neighbor_maximum_prefix_threshold_restart_cmd
);
13752 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13753 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13754 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13755 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13756 install_element(BGP_IPV6L_NODE
,
13757 &neighbor_maximum_prefix_threshold_warning_cmd
);
13758 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13759 install_element(BGP_IPV6L_NODE
,
13760 &neighbor_maximum_prefix_threshold_restart_cmd
);
13761 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13762 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13763 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13764 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13765 install_element(BGP_VPNV4_NODE
,
13766 &neighbor_maximum_prefix_threshold_warning_cmd
);
13767 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13768 install_element(BGP_VPNV4_NODE
,
13769 &neighbor_maximum_prefix_threshold_restart_cmd
);
13770 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13771 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13772 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13773 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13774 install_element(BGP_VPNV6_NODE
,
13775 &neighbor_maximum_prefix_threshold_warning_cmd
);
13776 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13777 install_element(BGP_VPNV6_NODE
,
13778 &neighbor_maximum_prefix_threshold_restart_cmd
);
13779 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13781 /* "neighbor allowas-in" */
13782 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13783 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13784 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13785 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13786 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13787 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13788 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13789 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13790 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13791 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13792 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13793 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13794 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13795 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13796 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13797 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13798 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13799 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13800 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13801 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13803 /* address-family commands. */
13804 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13805 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13806 #ifdef KEEP_OLD_VPN_COMMANDS
13807 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13808 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13809 #endif /* KEEP_OLD_VPN_COMMANDS */
13811 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13813 /* "exit-address-family" command. */
13814 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13815 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13816 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13817 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13818 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13819 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13820 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13821 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13822 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13823 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13824 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13826 /* "clear ip bgp commands" */
13827 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13829 /* clear ip bgp prefix */
13830 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13831 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13832 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13834 /* "show [ip] bgp summary" commands. */
13835 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13836 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
13837 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13838 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13839 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13840 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13841 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
13843 /* "show [ip] bgp neighbors" commands. */
13844 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
13846 /* "show [ip] bgp peer-group" commands. */
13847 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
13849 /* "show [ip] bgp paths" commands. */
13850 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
13852 /* "show [ip] bgp community" commands. */
13853 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
13855 /* "show ip bgp large-community" commands. */
13856 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
13857 /* "show [ip] bgp attribute-info" commands. */
13858 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
13859 /* "show [ip] bgp route-leak" command */
13860 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
13862 /* "redistribute" commands. */
13863 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
13864 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
13865 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
13866 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
13867 install_element(BGP_NODE
,
13868 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
13869 install_element(BGP_NODE
,
13870 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
13871 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
13872 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
13873 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
13874 install_element(BGP_NODE
,
13875 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
13876 install_element(BGP_NODE
,
13877 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
13878 install_element(BGP_NODE
,
13879 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
13880 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
13881 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
13882 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
13883 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
13884 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
13885 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
13886 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
13887 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
13888 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
13889 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
13890 install_element(BGP_IPV4_NODE
,
13891 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
13892 install_element(BGP_IPV4_NODE
,
13893 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
13894 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
13895 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
13896 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
13897 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
13898 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
13899 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
13901 /* import|export vpn [route-map WORD] */
13902 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
13903 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
13905 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
13906 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
13908 /* ttl_security commands */
13909 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
13910 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
13912 /* "show [ip] bgp memory" commands. */
13913 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
13915 /* "show bgp martian next-hop" */
13916 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
13918 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
13920 /* "show [ip] bgp views" commands. */
13921 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
13923 /* "show [ip] bgp vrfs" commands. */
13924 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
13926 /* Community-list. */
13927 community_list_vty();
13929 /* vpn-policy commands */
13930 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
13931 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
13932 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
13933 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
13934 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
13935 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
13936 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
13937 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
13938 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
13939 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
13940 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
13941 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
13943 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
13944 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
13946 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
13947 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
13948 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
13949 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
13950 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
13951 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
13952 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
13953 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
13954 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13955 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13956 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
13957 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
13960 #include "memory.h"
13961 #include "bgp_regex.h"
13962 #include "bgp_clist.h"
13963 #include "bgp_ecommunity.h"
13965 /* VTY functions. */
13967 /* Direction value to string conversion. */
13968 static const char *community_direct_str(int direct
)
13971 case COMMUNITY_DENY
:
13973 case COMMUNITY_PERMIT
:
13980 /* Display error string. */
13981 static void community_list_perror(struct vty
*vty
, int ret
)
13984 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
13985 vty_out(vty
, "%% Can't find community-list\n");
13987 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
13988 vty_out(vty
, "%% Malformed community-list value\n");
13990 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
13992 "%% Community name conflict, previously defined as standard community\n");
13994 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
13996 "%% Community name conflict, previously defined as expanded community\n");
14001 /* "community-list" keyword help string. */
14002 #define COMMUNITY_LIST_STR "Add a community list entry\n"
14004 /*community-list standard */
14005 DEFUN (community_list_standard
,
14006 bgp_community_list_standard_cmd
,
14007 "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14010 "Community list number (standard)\n"
14011 "Add an standard community-list entry\n"
14012 "Community list name\n"
14013 "Specify community to reject\n"
14014 "Specify community to accept\n"
14017 char *cl_name_or_number
= NULL
;
14019 int style
= COMMUNITY_LIST_STANDARD
;
14023 if (argv_find(argv
, argc
, "ip", &idx
)) {
14024 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14025 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14026 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14027 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14030 argv_find(argv
, argc
, "(1-99)", &idx
);
14031 argv_find(argv
, argc
, "WORD", &idx
);
14032 cl_name_or_number
= argv
[idx
]->arg
;
14033 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14035 argv_find(argv
, argc
, "AA:NN", &idx
);
14036 char *str
= argv_concat(argv
, argc
, idx
);
14038 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14041 XFREE(MTYPE_TMP
, str
);
14044 /* Display error string. */
14045 community_list_perror(vty
, ret
);
14046 return CMD_WARNING_CONFIG_FAILED
;
14049 return CMD_SUCCESS
;
14052 #if CONFDATE > 20191005
14053 CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command")
14055 ALIAS (community_list_standard
,
14056 ip_community_list_standard_cmd
,
14057 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14060 "Community list number (standard)\n"
14061 "Add an standard community-list entry\n"
14062 "Community list name\n"
14063 "Specify community to reject\n"
14064 "Specify community to accept\n"
14067 DEFUN (no_community_list_standard_all
,
14068 no_bgp_community_list_standard_all_cmd
,
14069 "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14073 "Community list number (standard)\n"
14074 "Add an standard community-list entry\n"
14075 "Community list name\n"
14076 "Specify community to reject\n"
14077 "Specify community to accept\n"
14080 char *cl_name_or_number
= NULL
;
14083 int style
= COMMUNITY_LIST_STANDARD
;
14087 if (argv_find(argv
, argc
, "ip", &idx
)) {
14088 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
14089 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14090 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14091 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used");
14094 argv_find(argv
, argc
, "permit", &idx
);
14095 argv_find(argv
, argc
, "deny", &idx
);
14098 direct
= argv_find(argv
, argc
, "permit", &idx
)
14103 argv_find(argv
, argc
, "AA:NN", &idx
);
14104 str
= argv_concat(argv
, argc
, idx
);
14108 argv_find(argv
, argc
, "(1-99)", &idx
);
14109 argv_find(argv
, argc
, "WORD", &idx
);
14110 cl_name_or_number
= argv
[idx
]->arg
;
14112 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14115 XFREE(MTYPE_TMP
, str
);
14118 community_list_perror(vty
, ret
);
14119 return CMD_WARNING_CONFIG_FAILED
;
14122 return CMD_SUCCESS
;
14124 ALIAS (no_community_list_standard_all
,
14125 no_ip_community_list_standard_all_cmd
,
14126 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14130 "Community list number (standard)\n"
14131 "Add an standard community-list entry\n"
14132 "Community list name\n"
14133 "Specify community to reject\n"
14134 "Specify community to accept\n"
14137 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
14138 "no bgp community-list <(1-99)|standard WORD>",
14139 NO_STR BGP_STR COMMUNITY_LIST_STR
14140 "Community list number (standard)\n"
14141 "Add an standard community-list entry\n"
14142 "Community list name\n")
14144 ALIAS(no_community_list_standard_all
, no_ip_community_list_standard_all_list_cmd
,
14145 "no ip community-list <(1-99)|standard WORD>",
14146 NO_STR BGP_STR COMMUNITY_LIST_STR
14147 "Community list number (standard)\n"
14148 "Add an standard community-list entry\n"
14149 "Community list name\n")
14151 /*community-list expanded */
14152 DEFUN (community_list_expanded_all
,
14153 bgp_community_list_expanded_all_cmd
,
14154 "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14157 "Community list number (expanded)\n"
14158 "Add an expanded community-list entry\n"
14159 "Community list name\n"
14160 "Specify community to reject\n"
14161 "Specify community to accept\n"
14164 char *cl_name_or_number
= NULL
;
14166 int style
= COMMUNITY_LIST_EXPANDED
;
14169 if (argv_find(argv
, argc
, "ip", &idx
)) {
14170 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14171 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14172 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14173 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14175 argv_find(argv
, argc
, "(100-500)", &idx
);
14176 argv_find(argv
, argc
, "WORD", &idx
);
14177 cl_name_or_number
= argv
[idx
]->arg
;
14178 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14180 argv_find(argv
, argc
, "AA:NN", &idx
);
14181 char *str
= argv_concat(argv
, argc
, idx
);
14183 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14186 XFREE(MTYPE_TMP
, str
);
14189 /* Display error string. */
14190 community_list_perror(vty
, ret
);
14191 return CMD_WARNING_CONFIG_FAILED
;
14194 return CMD_SUCCESS
;
14197 ALIAS (community_list_expanded_all
,
14198 ip_community_list_expanded_all_cmd
,
14199 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14202 "Community list number (expanded)\n"
14203 "Add an expanded community-list entry\n"
14204 "Community list name\n"
14205 "Specify community to reject\n"
14206 "Specify community to accept\n"
14209 DEFUN (no_community_list_expanded_all
,
14210 no_bgp_community_list_expanded_all_cmd
,
14211 "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14215 "Community list number (expanded)\n"
14216 "Add an expanded community-list entry\n"
14217 "Community list name\n"
14218 "Specify community to reject\n"
14219 "Specify community to accept\n"
14222 char *cl_name_or_number
= NULL
;
14225 int style
= COMMUNITY_LIST_EXPANDED
;
14228 if (argv_find(argv
, argc
, "ip", &idx
)) {
14229 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14230 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14231 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14232 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14236 argv_find(argv
, argc
, "permit", &idx
);
14237 argv_find(argv
, argc
, "deny", &idx
);
14240 direct
= argv_find(argv
, argc
, "permit", &idx
)
14245 argv_find(argv
, argc
, "AA:NN", &idx
);
14246 str
= argv_concat(argv
, argc
, idx
);
14250 argv_find(argv
, argc
, "(100-500)", &idx
);
14251 argv_find(argv
, argc
, "WORD", &idx
);
14252 cl_name_or_number
= argv
[idx
]->arg
;
14254 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14257 XFREE(MTYPE_TMP
, str
);
14260 community_list_perror(vty
, ret
);
14261 return CMD_WARNING_CONFIG_FAILED
;
14264 return CMD_SUCCESS
;
14267 ALIAS (no_community_list_expanded_all
,
14268 no_ip_community_list_expanded_all_cmd
,
14269 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14273 "Community list number (expanded)\n"
14274 "Add an expanded community-list entry\n"
14275 "Community list name\n"
14276 "Specify community to reject\n"
14277 "Specify community to accept\n"
14280 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
14281 "no bgp community-list <(100-500)|expanded WORD>",
14282 NO_STR IP_STR COMMUNITY_LIST_STR
14283 "Community list number (expanded)\n"
14284 "Add an expanded community-list entry\n"
14285 "Community list name\n")
14287 ALIAS(no_community_list_expanded_all
, no_ip_community_list_expanded_all_list_cmd
,
14288 "no ip community-list <(100-500)|expanded WORD>",
14289 NO_STR IP_STR COMMUNITY_LIST_STR
14290 "Community list number (expanded)\n"
14291 "Add an expanded community-list entry\n"
14292 "Community list name\n")
14294 /* Return configuration string of community-list entry. */
14295 static const char *community_list_config_str(struct community_entry
*entry
)
14302 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
14303 str
= community_str(entry
->u
.com
, false);
14304 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
14305 str
= lcommunity_str(entry
->u
.lcom
, false);
14307 str
= entry
->config
;
14312 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
14314 struct community_entry
*entry
;
14316 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14317 if (entry
== list
->head
) {
14318 if (all_digit(list
->name
))
14319 vty_out(vty
, "Community %s list %s\n",
14320 entry
->style
== COMMUNITY_LIST_STANDARD
14322 : "(expanded) access",
14325 vty_out(vty
, "Named Community %s list %s\n",
14326 entry
->style
== COMMUNITY_LIST_STANDARD
14332 vty_out(vty
, " %s\n",
14333 community_direct_str(entry
->direct
));
14335 vty_out(vty
, " %s %s\n",
14336 community_direct_str(entry
->direct
),
14337 community_list_config_str(entry
));
14341 DEFUN (show_community_list
,
14342 show_bgp_community_list_cmd
,
14343 "show bgp community-list",
14346 "List community-list\n")
14348 struct community_list
*list
;
14349 struct community_list_master
*cm
;
14352 if (argv_find(argv
, argc
, "ip", &idx
)) {
14353 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14354 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14355 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14356 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14358 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14360 return CMD_SUCCESS
;
14362 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14363 community_list_show(vty
, list
);
14365 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14366 community_list_show(vty
, list
);
14368 return CMD_SUCCESS
;
14371 ALIAS (show_community_list
,
14372 show_ip_community_list_cmd
,
14373 "show ip community-list",
14376 "List community-list\n")
14378 DEFUN (show_community_list_arg
,
14379 show_bgp_community_list_arg_cmd
,
14380 "show bgp community-list <(1-500)|WORD>",
14383 "List community-list\n"
14384 "Community-list number\n"
14385 "Community-list name\n")
14387 int idx_comm_list
= 3;
14388 struct community_list
*list
;
14391 if (argv_find(argv
, argc
, "ip", &idx
)) {
14392 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14393 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14394 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14395 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14397 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
14398 COMMUNITY_LIST_MASTER
);
14400 vty_out(vty
, "%% Can't find community-list\n");
14401 return CMD_WARNING
;
14404 community_list_show(vty
, list
);
14406 return CMD_SUCCESS
;
14409 ALIAS (show_community_list_arg
,
14410 show_ip_community_list_arg_cmd
,
14411 "show ip community-list <(1-500)|WORD>",
14414 "List community-list\n"
14415 "Community-list number\n"
14416 "Community-list name\n")
14419 * Large Community code.
14421 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
14422 struct cmd_token
**argv
, int style
,
14423 int reject_all_digit_name
)
14431 if (argv_find(argv
, argc
, "ip", &idx
)) {
14432 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14433 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14434 vty_out(vty
, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14435 zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14437 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14440 /* All digit name check. */
14442 argv_find(argv
, argc
, "WORD", &idx
);
14443 argv_find(argv
, argc
, "(1-99)", &idx
);
14444 argv_find(argv
, argc
, "(100-500)", &idx
);
14445 cl_name
= argv
[idx
]->arg
;
14446 if (reject_all_digit_name
&& all_digit(cl_name
)) {
14447 vty_out(vty
, "%% Community name cannot have all digits\n");
14448 return CMD_WARNING_CONFIG_FAILED
;
14452 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
14453 argv_find(argv
, argc
, "LINE", &idx
);
14454 /* Concat community string argument. */
14456 str
= argv_concat(argv
, argc
, idx
);
14460 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
14462 /* Free temporary community list string allocated by
14465 XFREE(MTYPE_TMP
, str
);
14468 community_list_perror(vty
, ret
);
14469 return CMD_WARNING_CONFIG_FAILED
;
14471 return CMD_SUCCESS
;
14474 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
14475 struct cmd_token
**argv
, int style
)
14482 if (argv_find(argv
, argc
, "ip", &idx
)) {
14483 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14484 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14485 vty_out(vty
, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14486 zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14488 argv_find(argv
, argc
, "permit", &idx
);
14489 argv_find(argv
, argc
, "deny", &idx
);
14492 /* Check the list direct. */
14493 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
14494 direct
= COMMUNITY_PERMIT
;
14496 direct
= COMMUNITY_DENY
;
14499 argv_find(argv
, argc
, "LINE", &idx
);
14500 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
14501 /* Concat community string argument. */
14502 str
= argv_concat(argv
, argc
, idx
);
14506 argv_find(argv
, argc
, "(1-99)", &idx
);
14507 argv_find(argv
, argc
, "(100-500)", &idx
);
14508 argv_find(argv
, argc
, "WORD", &idx
);
14510 /* Unset community list. */
14511 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
14514 /* Free temporary community list string allocated by
14517 XFREE(MTYPE_TMP
, str
);
14520 community_list_perror(vty
, ret
);
14521 return CMD_WARNING_CONFIG_FAILED
;
14524 return CMD_SUCCESS
;
14527 /* "large-community-list" keyword help string. */
14528 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
14529 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
14531 #if CONFDATE > 20191005
14532 CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command")
14534 DEFUN (lcommunity_list_standard
,
14535 bgp_lcommunity_list_standard_cmd
,
14536 "bgp large-community-list (1-99) <deny|permit>",
14538 LCOMMUNITY_LIST_STR
14539 "Large Community list number (standard)\n"
14540 "Specify large community to reject\n"
14541 "Specify large community to accept\n")
14543 return lcommunity_list_set_vty(vty
, argc
, argv
,
14544 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14547 ALIAS (lcommunity_list_standard
,
14548 ip_lcommunity_list_standard_cmd
,
14549 "ip large-community-list (1-99) <deny|permit>",
14551 LCOMMUNITY_LIST_STR
14552 "Large Community list number (standard)\n"
14553 "Specify large community to reject\n"
14554 "Specify large community to accept\n")
14556 DEFUN (lcommunity_list_standard1
,
14557 bgp_lcommunity_list_standard1_cmd
,
14558 "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...",
14560 LCOMMUNITY_LIST_STR
14561 "Large Community list number (standard)\n"
14562 "Specify large community to reject\n"
14563 "Specify large community to accept\n"
14564 LCOMMUNITY_VAL_STR
)
14566 return lcommunity_list_set_vty(vty
, argc
, argv
,
14567 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14570 ALIAS (lcommunity_list_standard1
,
14571 ip_lcommunity_list_standard1_cmd
,
14572 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
14574 LCOMMUNITY_LIST_STR
14575 "Large Community list number (standard)\n"
14576 "Specify large community to reject\n"
14577 "Specify large community to accept\n"
14578 LCOMMUNITY_VAL_STR
)
14580 DEFUN (lcommunity_list_expanded
,
14581 bgp_lcommunity_list_expanded_cmd
,
14582 "bgp large-community-list (100-500) <deny|permit> LINE...",
14584 LCOMMUNITY_LIST_STR
14585 "Large Community list number (expanded)\n"
14586 "Specify large community to reject\n"
14587 "Specify large community to accept\n"
14588 "An ordered list as a regular-expression\n")
14590 return lcommunity_list_set_vty(vty
, argc
, argv
,
14591 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
14594 ALIAS (lcommunity_list_expanded
,
14595 ip_lcommunity_list_expanded_cmd
,
14596 "ip large-community-list (100-500) <deny|permit> LINE...",
14598 LCOMMUNITY_LIST_STR
14599 "Large Community list number (expanded)\n"
14600 "Specify large community to reject\n"
14601 "Specify large community to accept\n"
14602 "An ordered list as a regular-expression\n")
14604 DEFUN (lcommunity_list_name_standard
,
14605 bgp_lcommunity_list_name_standard_cmd
,
14606 "bgp large-community-list standard WORD <deny|permit>",
14608 LCOMMUNITY_LIST_STR
14609 "Specify standard large-community-list\n"
14610 "Large Community list name\n"
14611 "Specify large community to reject\n"
14612 "Specify large community to accept\n")
14614 return lcommunity_list_set_vty(vty
, argc
, argv
,
14615 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14618 ALIAS (lcommunity_list_name_standard
,
14619 ip_lcommunity_list_name_standard_cmd
,
14620 "ip large-community-list standard WORD <deny|permit>",
14622 LCOMMUNITY_LIST_STR
14623 "Specify standard large-community-list\n"
14624 "Large Community list name\n"
14625 "Specify large community to reject\n"
14626 "Specify large community to accept\n")
14628 DEFUN (lcommunity_list_name_standard1
,
14629 bgp_lcommunity_list_name_standard1_cmd
,
14630 "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
14632 LCOMMUNITY_LIST_STR
14633 "Specify standard large-community-list\n"
14634 "Large Community list name\n"
14635 "Specify large community to reject\n"
14636 "Specify large community to accept\n"
14637 LCOMMUNITY_VAL_STR
)
14639 return lcommunity_list_set_vty(vty
, argc
, argv
,
14640 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14643 ALIAS (lcommunity_list_name_standard1
,
14644 ip_lcommunity_list_name_standard1_cmd
,
14645 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
14647 LCOMMUNITY_LIST_STR
14648 "Specify standard large-community-list\n"
14649 "Large Community list name\n"
14650 "Specify large community to reject\n"
14651 "Specify large community to accept\n"
14652 LCOMMUNITY_VAL_STR
)
14654 DEFUN (lcommunity_list_name_expanded
,
14655 bgp_lcommunity_list_name_expanded_cmd
,
14656 "bgp large-community-list expanded WORD <deny|permit> LINE...",
14658 LCOMMUNITY_LIST_STR
14659 "Specify expanded large-community-list\n"
14660 "Large Community list name\n"
14661 "Specify large community to reject\n"
14662 "Specify large community to accept\n"
14663 "An ordered list as a regular-expression\n")
14665 return lcommunity_list_set_vty(vty
, argc
, argv
,
14666 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
14669 ALIAS (lcommunity_list_name_expanded
,
14670 ip_lcommunity_list_name_expanded_cmd
,
14671 "ip large-community-list expanded WORD <deny|permit> LINE...",
14673 LCOMMUNITY_LIST_STR
14674 "Specify expanded large-community-list\n"
14675 "Large Community list name\n"
14676 "Specify large community to reject\n"
14677 "Specify large community to accept\n"
14678 "An ordered list as a regular-expression\n")
14680 DEFUN (no_lcommunity_list_standard_all
,
14681 no_bgp_lcommunity_list_standard_all_cmd
,
14682 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
14685 LCOMMUNITY_LIST_STR
14686 "Large Community list number (standard)\n"
14687 "Large Community list number (expanded)\n"
14688 "Large Community list name\n")
14690 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14691 LARGE_COMMUNITY_LIST_STANDARD
);
14694 ALIAS (no_lcommunity_list_standard_all
,
14695 no_ip_lcommunity_list_standard_all_cmd
,
14696 "no ip large-community-list <(1-99)|(100-500)|WORD>",
14699 LCOMMUNITY_LIST_STR
14700 "Large Community list number (standard)\n"
14701 "Large Community list number (expanded)\n"
14702 "Large Community list name\n")
14704 DEFUN (no_lcommunity_list_name_expanded_all
,
14705 no_bgp_lcommunity_list_name_expanded_all_cmd
,
14706 "no bgp large-community-list expanded WORD",
14709 LCOMMUNITY_LIST_STR
14710 "Specify expanded large-community-list\n"
14711 "Large Community list name\n")
14713 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14714 LARGE_COMMUNITY_LIST_EXPANDED
);
14717 ALIAS (no_lcommunity_list_name_expanded_all
,
14718 no_ip_lcommunity_list_name_expanded_all_cmd
,
14719 "no ip large-community-list expanded WORD",
14722 LCOMMUNITY_LIST_STR
14723 "Specify expanded large-community-list\n"
14724 "Large Community list name\n")
14726 DEFUN (no_lcommunity_list_standard
,
14727 no_bgp_lcommunity_list_standard_cmd
,
14728 "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
14731 LCOMMUNITY_LIST_STR
14732 "Large Community list number (standard)\n"
14733 "Specify large community to reject\n"
14734 "Specify large community to accept\n"
14735 LCOMMUNITY_VAL_STR
)
14737 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14738 LARGE_COMMUNITY_LIST_STANDARD
);
14741 ALIAS (no_lcommunity_list_standard
,
14742 no_ip_lcommunity_list_standard_cmd
,
14743 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
14746 LCOMMUNITY_LIST_STR
14747 "Large Community list number (standard)\n"
14748 "Specify large community to reject\n"
14749 "Specify large community to accept\n"
14750 LCOMMUNITY_VAL_STR
)
14752 DEFUN (no_lcommunity_list_expanded
,
14753 no_bgp_lcommunity_list_expanded_cmd
,
14754 "no bgp large-community-list (100-500) <deny|permit> LINE...",
14757 LCOMMUNITY_LIST_STR
14758 "Large Community list number (expanded)\n"
14759 "Specify large community to reject\n"
14760 "Specify large community to accept\n"
14761 "An ordered list as a regular-expression\n")
14763 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14764 LARGE_COMMUNITY_LIST_EXPANDED
);
14767 ALIAS (no_lcommunity_list_expanded
,
14768 no_ip_lcommunity_list_expanded_cmd
,
14769 "no ip large-community-list (100-500) <deny|permit> LINE...",
14772 LCOMMUNITY_LIST_STR
14773 "Large Community list number (expanded)\n"
14774 "Specify large community to reject\n"
14775 "Specify large community to accept\n"
14776 "An ordered list as a regular-expression\n")
14778 DEFUN (no_lcommunity_list_name_standard
,
14779 no_bgp_lcommunity_list_name_standard_cmd
,
14780 "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
14783 LCOMMUNITY_LIST_STR
14784 "Specify standard large-community-list\n"
14785 "Large Community list name\n"
14786 "Specify large community to reject\n"
14787 "Specify large community to accept\n"
14788 LCOMMUNITY_VAL_STR
)
14790 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14791 LARGE_COMMUNITY_LIST_STANDARD
);
14794 ALIAS (no_lcommunity_list_name_standard
,
14795 no_ip_lcommunity_list_name_standard_cmd
,
14796 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
14799 LCOMMUNITY_LIST_STR
14800 "Specify standard large-community-list\n"
14801 "Large Community list name\n"
14802 "Specify large community to reject\n"
14803 "Specify large community to accept\n"
14804 LCOMMUNITY_VAL_STR
)
14806 DEFUN (no_lcommunity_list_name_expanded
,
14807 no_bgp_lcommunity_list_name_expanded_cmd
,
14808 "no bgp large-community-list expanded WORD <deny|permit> LINE...",
14811 LCOMMUNITY_LIST_STR
14812 "Specify expanded large-community-list\n"
14813 "Large community list name\n"
14814 "Specify large community to reject\n"
14815 "Specify large community to accept\n"
14816 "An ordered list as a regular-expression\n")
14818 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14819 LARGE_COMMUNITY_LIST_EXPANDED
);
14822 ALIAS (no_lcommunity_list_name_expanded
,
14823 no_ip_lcommunity_list_name_expanded_cmd
,
14824 "no ip large-community-list expanded WORD <deny|permit> LINE...",
14827 LCOMMUNITY_LIST_STR
14828 "Specify expanded large-community-list\n"
14829 "Large community list name\n"
14830 "Specify large community to reject\n"
14831 "Specify large community to accept\n"
14832 "An ordered list as a regular-expression\n")
14834 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14836 struct community_entry
*entry
;
14838 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14839 if (entry
== list
->head
) {
14840 if (all_digit(list
->name
))
14841 vty_out(vty
, "Large community %s list %s\n",
14842 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14844 : "(expanded) access",
14848 "Named large community %s list %s\n",
14849 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14855 vty_out(vty
, " %s\n",
14856 community_direct_str(entry
->direct
));
14858 vty_out(vty
, " %s %s\n",
14859 community_direct_str(entry
->direct
),
14860 community_list_config_str(entry
));
14864 DEFUN (show_lcommunity_list
,
14865 show_bgp_lcommunity_list_cmd
,
14866 "show bgp large-community-list",
14869 "List large-community list\n")
14871 struct community_list
*list
;
14872 struct community_list_master
*cm
;
14875 if (argv_find(argv
, argc
, "ip", &idx
)) {
14876 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14877 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14878 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
14879 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
14882 cm
= community_list_master_lookup(bgp_clist
,
14883 LARGE_COMMUNITY_LIST_MASTER
);
14885 return CMD_SUCCESS
;
14887 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14888 lcommunity_list_show(vty
, list
);
14890 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14891 lcommunity_list_show(vty
, list
);
14893 return CMD_SUCCESS
;
14896 ALIAS (show_lcommunity_list
,
14897 show_ip_lcommunity_list_cmd
,
14898 "show ip large-community-list",
14901 "List large-community list\n")
14903 DEFUN (show_lcommunity_list_arg
,
14904 show_bgp_lcommunity_list_arg_cmd
,
14905 "show bgp large-community-list <(1-500)|WORD>",
14908 "List large-community list\n"
14909 "large-community-list number\n"
14910 "large-community-list name\n")
14912 struct community_list
*list
;
14915 if (argv_find(argv
, argc
, "ip", &idx
)) {
14916 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14917 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14918 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
14919 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
14922 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
14923 LARGE_COMMUNITY_LIST_MASTER
);
14925 vty_out(vty
, "%% Can't find extcommunity-list\n");
14926 return CMD_WARNING
;
14929 lcommunity_list_show(vty
, list
);
14931 return CMD_SUCCESS
;
14934 ALIAS (show_lcommunity_list_arg
,
14935 show_ip_lcommunity_list_arg_cmd
,
14936 "show ip large-community-list <(1-500)|WORD>",
14939 "List large-community list\n"
14940 "large-community-list number\n"
14941 "large-community-list name\n")
14943 /* "extcommunity-list" keyword help string. */
14944 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
14945 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
14947 DEFUN (extcommunity_list_standard
,
14948 bgp_extcommunity_list_standard_cmd
,
14949 "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14951 EXTCOMMUNITY_LIST_STR
14952 "Extended Community list number (standard)\n"
14953 "Specify standard extcommunity-list\n"
14954 "Community list name\n"
14955 "Specify community to reject\n"
14956 "Specify community to accept\n"
14957 EXTCOMMUNITY_VAL_STR
)
14959 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14961 char *cl_number_or_name
= NULL
;
14964 if (argv_find(argv
, argc
, "ip", &idx
)) {
14965 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14966 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14967 vty_out(vty
, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
14968 zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
14970 argv_find(argv
, argc
, "(1-99)", &idx
);
14971 argv_find(argv
, argc
, "WORD", &idx
);
14972 cl_number_or_name
= argv
[idx
]->arg
;
14973 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14975 argv_find(argv
, argc
, "AA:NN", &idx
);
14976 char *str
= argv_concat(argv
, argc
, idx
);
14978 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14981 XFREE(MTYPE_TMP
, str
);
14984 community_list_perror(vty
, ret
);
14985 return CMD_WARNING_CONFIG_FAILED
;
14988 return CMD_SUCCESS
;
14991 #if CONFDATE > 20191005
14992 CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command")
14994 ALIAS (extcommunity_list_standard
,
14995 ip_extcommunity_list_standard_cmd
,
14996 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14998 EXTCOMMUNITY_LIST_STR
14999 "Extended Community list number (standard)\n"
15000 "Specify standard extcommunity-list\n"
15001 "Community list name\n"
15002 "Specify community to reject\n"
15003 "Specify community to accept\n"
15004 EXTCOMMUNITY_VAL_STR
)
15006 DEFUN (extcommunity_list_name_expanded
,
15007 bgp_extcommunity_list_name_expanded_cmd
,
15008 "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15010 EXTCOMMUNITY_LIST_STR
15011 "Extended Community list number (expanded)\n"
15012 "Specify expanded extcommunity-list\n"
15013 "Extended Community list name\n"
15014 "Specify community to reject\n"
15015 "Specify community to accept\n"
15016 "An ordered list as a regular-expression\n")
15018 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15020 char *cl_number_or_name
= NULL
;
15023 if (argv_find(argv
, argc
, "ip", &idx
)) {
15024 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15025 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15026 vty_out(vty
, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15027 zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15030 argv_find(argv
, argc
, "(100-500)", &idx
);
15031 argv_find(argv
, argc
, "WORD", &idx
);
15032 cl_number_or_name
= argv
[idx
]->arg
;
15033 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15035 argv_find(argv
, argc
, "LINE", &idx
);
15036 char *str
= argv_concat(argv
, argc
, idx
);
15038 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15041 XFREE(MTYPE_TMP
, str
);
15044 community_list_perror(vty
, ret
);
15045 return CMD_WARNING_CONFIG_FAILED
;
15048 return CMD_SUCCESS
;
15051 ALIAS (extcommunity_list_name_expanded
,
15052 ip_extcommunity_list_name_expanded_cmd
,
15053 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15055 EXTCOMMUNITY_LIST_STR
15056 "Extended Community list number (expanded)\n"
15057 "Specify expanded extcommunity-list\n"
15058 "Extended Community list name\n"
15059 "Specify community to reject\n"
15060 "Specify community to accept\n"
15061 "An ordered list as a regular-expression\n")
15063 DEFUN (no_extcommunity_list_standard_all
,
15064 no_bgp_extcommunity_list_standard_all_cmd
,
15065 "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15068 EXTCOMMUNITY_LIST_STR
15069 "Extended Community list number (standard)\n"
15070 "Specify standard extcommunity-list\n"
15071 "Community list name\n"
15072 "Specify community to reject\n"
15073 "Specify community to accept\n"
15074 EXTCOMMUNITY_VAL_STR
)
15076 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15078 char *cl_number_or_name
= NULL
;
15082 if (argv_find(argv
, argc
, "ip", &idx
)) {
15083 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15084 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15085 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15086 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15090 argv_find(argv
, argc
, "permit", &idx
);
15091 argv_find(argv
, argc
, "deny", &idx
);
15094 direct
= argv_find(argv
, argc
, "permit", &idx
)
15099 argv_find(argv
, argc
, "AA:NN", &idx
);
15100 str
= argv_concat(argv
, argc
, idx
);
15104 argv_find(argv
, argc
, "(1-99)", &idx
);
15105 argv_find(argv
, argc
, "WORD", &idx
);
15106 cl_number_or_name
= argv
[idx
]->arg
;
15108 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15111 XFREE(MTYPE_TMP
, str
);
15114 community_list_perror(vty
, ret
);
15115 return CMD_WARNING_CONFIG_FAILED
;
15118 return CMD_SUCCESS
;
15121 ALIAS (no_extcommunity_list_standard_all
,
15122 no_ip_extcommunity_list_standard_all_cmd
,
15123 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15126 EXTCOMMUNITY_LIST_STR
15127 "Extended Community list number (standard)\n"
15128 "Specify standard extcommunity-list\n"
15129 "Community list name\n"
15130 "Specify community to reject\n"
15131 "Specify community to accept\n"
15132 EXTCOMMUNITY_VAL_STR
)
15134 ALIAS(no_extcommunity_list_standard_all
,
15135 no_bgp_extcommunity_list_standard_all_list_cmd
,
15136 "no bgp extcommunity-list <(1-99)|standard WORD>",
15137 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15138 "Extended Community list number (standard)\n"
15139 "Specify standard extcommunity-list\n"
15140 "Community list name\n")
15142 ALIAS(no_extcommunity_list_standard_all
,
15143 no_ip_extcommunity_list_standard_all_list_cmd
,
15144 "no ip extcommunity-list <(1-99)|standard WORD>",
15145 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15146 "Extended Community list number (standard)\n"
15147 "Specify standard extcommunity-list\n"
15148 "Community list name\n")
15150 DEFUN (no_extcommunity_list_expanded_all
,
15151 no_bgp_extcommunity_list_expanded_all_cmd
,
15152 "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15155 EXTCOMMUNITY_LIST_STR
15156 "Extended Community list number (expanded)\n"
15157 "Specify expanded extcommunity-list\n"
15158 "Extended Community list name\n"
15159 "Specify community to reject\n"
15160 "Specify community to accept\n"
15161 "An ordered list as a regular-expression\n")
15163 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15165 char *cl_number_or_name
= NULL
;
15169 if (argv_find(argv
, argc
, "ip", &idx
)) {
15170 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15171 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15172 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15173 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15177 argv_find(argv
, argc
, "permit", &idx
);
15178 argv_find(argv
, argc
, "deny", &idx
);
15181 direct
= argv_find(argv
, argc
, "permit", &idx
)
15186 argv_find(argv
, argc
, "LINE", &idx
);
15187 str
= argv_concat(argv
, argc
, idx
);
15191 argv_find(argv
, argc
, "(100-500)", &idx
);
15192 argv_find(argv
, argc
, "WORD", &idx
);
15193 cl_number_or_name
= argv
[idx
]->arg
;
15195 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15198 XFREE(MTYPE_TMP
, str
);
15201 community_list_perror(vty
, ret
);
15202 return CMD_WARNING_CONFIG_FAILED
;
15205 return CMD_SUCCESS
;
15208 ALIAS (no_extcommunity_list_expanded_all
,
15209 no_ip_extcommunity_list_expanded_all_cmd
,
15210 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15213 EXTCOMMUNITY_LIST_STR
15214 "Extended Community list number (expanded)\n"
15215 "Specify expanded extcommunity-list\n"
15216 "Extended Community list name\n"
15217 "Specify community to reject\n"
15218 "Specify community to accept\n"
15219 "An ordered list as a regular-expression\n")
15221 ALIAS(no_extcommunity_list_expanded_all
,
15222 no_ip_extcommunity_list_expanded_all_list_cmd
,
15223 "no ip extcommunity-list <(100-500)|expanded WORD>",
15224 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15225 "Extended Community list number (expanded)\n"
15226 "Specify expanded extcommunity-list\n"
15227 "Extended Community list name\n")
15229 ALIAS(no_extcommunity_list_expanded_all
,
15230 no_bgp_extcommunity_list_expanded_all_list_cmd
,
15231 "no bgp extcommunity-list <(100-500)|expanded WORD>",
15232 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15233 "Extended Community list number (expanded)\n"
15234 "Specify expanded extcommunity-list\n"
15235 "Extended Community list name\n")
15237 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
15239 struct community_entry
*entry
;
15241 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15242 if (entry
== list
->head
) {
15243 if (all_digit(list
->name
))
15244 vty_out(vty
, "Extended community %s list %s\n",
15245 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15247 : "(expanded) access",
15251 "Named extended community %s list %s\n",
15252 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15258 vty_out(vty
, " %s\n",
15259 community_direct_str(entry
->direct
));
15261 vty_out(vty
, " %s %s\n",
15262 community_direct_str(entry
->direct
),
15263 community_list_config_str(entry
));
15267 DEFUN (show_extcommunity_list
,
15268 show_bgp_extcommunity_list_cmd
,
15269 "show bgp extcommunity-list",
15272 "List extended-community list\n")
15274 struct community_list
*list
;
15275 struct community_list_master
*cm
;
15278 if (argv_find(argv
, argc
, "ip", &idx
)) {
15279 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15280 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15281 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15282 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15284 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15286 return CMD_SUCCESS
;
15288 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15289 extcommunity_list_show(vty
, list
);
15291 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15292 extcommunity_list_show(vty
, list
);
15294 return CMD_SUCCESS
;
15297 ALIAS (show_extcommunity_list
,
15298 show_ip_extcommunity_list_cmd
,
15299 "show ip extcommunity-list",
15302 "List extended-community list\n")
15304 DEFUN (show_extcommunity_list_arg
,
15305 show_bgp_extcommunity_list_arg_cmd
,
15306 "show bgp extcommunity-list <(1-500)|WORD>",
15309 "List extended-community list\n"
15310 "Extcommunity-list number\n"
15311 "Extcommunity-list name\n")
15313 int idx_comm_list
= 3;
15314 struct community_list
*list
;
15317 if (argv_find(argv
, argc
, "ip", &idx
)) {
15318 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15319 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15320 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15321 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15323 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
15324 EXTCOMMUNITY_LIST_MASTER
);
15326 vty_out(vty
, "%% Can't find extcommunity-list\n");
15327 return CMD_WARNING
;
15330 extcommunity_list_show(vty
, list
);
15332 return CMD_SUCCESS
;
15335 ALIAS (show_extcommunity_list_arg
,
15336 show_ip_extcommunity_list_arg_cmd
,
15337 "show ip extcommunity-list <(1-500)|WORD>",
15340 "List extended-community list\n"
15341 "Extcommunity-list number\n"
15342 "Extcommunity-list name\n")
15344 /* Display community-list and extcommunity-list configuration. */
15345 static int community_list_config_write(struct vty
*vty
)
15347 struct community_list
*list
;
15348 struct community_entry
*entry
;
15349 struct community_list_master
*cm
;
15352 /* Community-list. */
15353 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
15355 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15356 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15357 vty_out(vty
, "bgp community-list %s %s %s\n", list
->name
,
15358 community_direct_str(entry
->direct
),
15359 community_list_config_str(entry
));
15362 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15363 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15364 vty_out(vty
, "bgp community-list %s %s %s %s\n",
15365 entry
->style
== COMMUNITY_LIST_STANDARD
15368 list
->name
, community_direct_str(entry
->direct
),
15369 community_list_config_str(entry
));
15373 /* Extcommunity-list. */
15374 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15376 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15377 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15378 vty_out(vty
, "bgp extcommunity-list %s %s %s\n",
15379 list
->name
, community_direct_str(entry
->direct
),
15380 community_list_config_str(entry
));
15383 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15384 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15385 vty_out(vty
, "bgp extcommunity-list %s %s %s %s\n",
15386 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15389 list
->name
, community_direct_str(entry
->direct
),
15390 community_list_config_str(entry
));
15395 /* lcommunity-list. */
15396 cm
= community_list_master_lookup(bgp_clist
,
15397 LARGE_COMMUNITY_LIST_MASTER
);
15399 for (list
= cm
->num
.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\n",
15402 list
->name
, community_direct_str(entry
->direct
),
15403 community_list_config_str(entry
));
15406 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15407 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15408 vty_out(vty
, "bgp large-community-list %s %s %s %s\n",
15409 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
15412 list
->name
, community_direct_str(entry
->direct
),
15413 community_list_config_str(entry
));
15420 static struct cmd_node community_list_node
= {
15421 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
15424 static void community_list_vty(void)
15426 install_node(&community_list_node
, community_list_config_write
);
15428 /* Community-list. */
15429 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
15430 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
15431 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
15432 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
15433 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
15434 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
15435 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
15436 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
15437 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
15438 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
15439 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
15440 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_list_cmd
);
15441 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
15442 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_list_cmd
);
15443 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
15444 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
15446 /* Extcommunity-list. */
15447 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
15448 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
15449 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
15450 install_element(CONFIG_NODE
,
15451 &no_bgp_extcommunity_list_standard_all_list_cmd
);
15452 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
15453 install_element(CONFIG_NODE
,
15454 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
15455 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
15456 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
15457 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
15458 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
15459 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
15460 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_list_cmd
);
15461 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
15462 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_list_cmd
);
15463 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
15464 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
15466 /* Large Community List */
15467 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
15468 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard1_cmd
);
15469 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
15470 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
15471 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard1_cmd
);
15472 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
15473 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_all_cmd
);
15474 install_element(CONFIG_NODE
,
15475 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
15476 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
15477 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
15478 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
15479 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
15480 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
15481 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
15482 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
15483 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
15484 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
15485 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
15486 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
15487 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
15488 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
15489 install_element(CONFIG_NODE
,
15490 &no_ip_lcommunity_list_name_expanded_all_cmd
);
15491 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
15492 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
15493 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
15494 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
15495 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
15496 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);