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
33 #include "memory_vty.h"
39 #include "bgpd/bgpd.h"
40 #include "bgpd/bgp_advertise.h"
41 #include "bgpd/bgp_attr.h"
42 #include "bgpd/bgp_aspath.h"
43 #include "bgpd/bgp_community.h"
44 #include "bgpd/bgp_ecommunity.h"
45 #include "bgpd/bgp_lcommunity.h"
46 #include "bgpd/bgp_damp.h"
47 #include "bgpd/bgp_debug.h"
48 #include "bgpd/bgp_errors.h"
49 #include "bgpd/bgp_fsm.h"
50 #include "bgpd/bgp_nexthop.h"
51 #include "bgpd/bgp_open.h"
52 #include "bgpd/bgp_regex.h"
53 #include "bgpd/bgp_route.h"
54 #include "bgpd/bgp_mplsvpn.h"
55 #include "bgpd/bgp_zebra.h"
56 #include "bgpd/bgp_table.h"
57 #include "bgpd/bgp_vty.h"
58 #include "bgpd/bgp_mpath.h"
59 #include "bgpd/bgp_packet.h"
60 #include "bgpd/bgp_updgrp.h"
61 #include "bgpd/bgp_bfd.h"
62 #include "bgpd/bgp_io.h"
63 #include "bgpd/bgp_evpn.h"
65 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
66 struct prefix
*range
, int exact
);
68 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
77 return BGP_IPV4M_NODE
;
79 case SAFI_LABELED_UNICAST
:
80 return BGP_IPV4L_NODE
;
83 return BGP_VPNV4_NODE
;
86 return BGP_FLOWSPECV4_NODE
;
99 return BGP_IPV6M_NODE
;
101 case SAFI_LABELED_UNICAST
:
102 return BGP_IPV6L_NODE
;
105 return BGP_VPNV6_NODE
;
108 return BGP_FLOWSPECV6_NODE
;
111 return BGP_IPV4_NODE
;
116 return BGP_EVPN_NODE
;
119 // We should never be here but to clarify the switch statement..
120 return BGP_IPV4_NODE
;
124 // Impossible to happen
125 return BGP_IPV4_NODE
;
128 /* Utility function to get address family from current node. */
129 afi_t
bgp_node_afi(struct vty
*vty
)
137 case BGP_FLOWSPECV6_NODE
:
150 /* Utility function to get subsequent address family from current
152 safi_t
bgp_node_safi(struct vty
*vty
)
158 safi
= SAFI_MPLS_VPN
;
162 safi
= SAFI_MULTICAST
;
169 safi
= SAFI_LABELED_UNICAST
;
171 case BGP_FLOWSPECV4_NODE
:
172 case BGP_FLOWSPECV6_NODE
:
173 safi
= SAFI_FLOWSPEC
;
183 * Converts an AFI in string form to afi_t
185 * @param afi string, one of
189 * @return the corresponding afi_t
191 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
193 afi_t afi
= AFI_MAX
; /* unknown */
194 if (strmatch(afi_str
, "ipv4"))
196 else if (strmatch(afi_str
, "ipv6"))
198 else if (strmatch(afi_str
, "l2vpn"))
203 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
207 if (argv_find(argv
, argc
, "ipv4", index
)) {
211 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
219 /* supports <unicast|multicast|vpn|labeled-unicast> */
220 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
222 safi_t safi
= SAFI_MAX
; /* unknown */
223 if (strmatch(safi_str
, "multicast"))
224 safi
= SAFI_MULTICAST
;
225 else if (strmatch(safi_str
, "unicast"))
227 else if (strmatch(safi_str
, "vpn"))
228 safi
= SAFI_MPLS_VPN
;
229 else if (strmatch(safi_str
, "evpn"))
231 else if (strmatch(safi_str
, "labeled-unicast"))
232 safi
= SAFI_LABELED_UNICAST
;
233 else if (strmatch(safi_str
, "flowspec"))
234 safi
= SAFI_FLOWSPEC
;
238 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
242 if (argv_find(argv
, argc
, "unicast", index
)) {
245 *safi
= SAFI_UNICAST
;
246 } else if (argv_find(argv
, argc
, "multicast", index
)) {
249 *safi
= SAFI_MULTICAST
;
250 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
253 *safi
= SAFI_LABELED_UNICAST
;
254 } else if (argv_find(argv
, argc
, "vpn", index
)) {
257 *safi
= SAFI_MPLS_VPN
;
258 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
261 *safi
= SAFI_FLOWSPEC
;
267 * bgp_vty_find_and_parse_afi_safi_bgp
269 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
270 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
271 * to appropriate values for the calling function. This is to allow the
272 * calling function to make decisions appropriate for the show command
273 * that is being parsed.
275 * The show commands are generally of the form:
276 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
277 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
279 * Since we use argv_find if the show command in particular doesn't have:
281 * [<view|vrf> VIEWVRFNAME]
282 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
283 * The command parsing should still be ok.
285 * vty -> The vty for the command so we can output some useful data in
286 * the event of a parse error in the vrf.
287 * argv -> The command tokens
288 * argc -> How many command tokens we have
289 * idx -> The current place in the command, generally should be 0 for this
291 * afi -> The parsed afi if it was included in the show command, returned here
292 * safi -> The parsed safi if it was included in the show command, returned here
293 * bgp -> Pointer to the bgp data structure we need to fill in.
295 * The function returns the correct location in the parse tree for the
298 * Returns 0 for failure to parse correctly, else the idx position of where
299 * it found the last token.
301 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
302 struct cmd_token
**argv
, int argc
,
303 int *idx
, afi_t
*afi
, safi_t
*safi
,
306 char *vrf_name
= NULL
;
312 if (argv_find(argv
, argc
, "ip", idx
))
315 if (argv_find(argv
, argc
, "view", idx
)
316 || argv_find(argv
, argc
, "vrf", idx
)) {
317 vrf_name
= argv
[*idx
+ 1]->arg
;
319 if (strmatch(vrf_name
, "all"))
322 *bgp
= bgp_lookup_by_name(vrf_name
);
325 "View/Vrf specified is unknown: %s\n",
332 *bgp
= bgp_get_default();
334 vty_out(vty
, "Unable to find default BGP instance\n");
340 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
341 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
347 static int peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
349 struct interface
*ifp
= NULL
;
351 if (su
->sa
.sa_family
== AF_INET
)
352 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
353 else if (su
->sa
.sa_family
== AF_INET6
)
354 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
355 su
->sin6
.sin6_scope_id
,
364 /* Utility function for looking up peer from VTY. */
365 /* This is used only for configuration, so disallow if attempted on
366 * a dynamic neighbor.
368 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
370 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
379 ret
= str2sockunion(ip_str
, &su
);
381 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
383 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
386 "%% Malformed address or name: %s\n",
392 peer
= peer_lookup(bgp
, &su
);
395 "%% Specify remote-as or peer-group commands first\n");
398 if (peer_dynamic_neighbor(peer
)) {
400 "%% Operation not allowed on a dynamic neighbor\n");
407 /* Utility function for looking up peer or peer group. */
408 /* This is used only for configuration, so disallow if attempted on
409 * a dynamic neighbor.
411 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
413 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
416 struct peer
*peer
= NULL
;
417 struct peer_group
*group
= NULL
;
423 ret
= str2sockunion(peer_str
, &su
);
425 /* IP address, locate peer. */
426 peer
= peer_lookup(bgp
, &su
);
428 /* Not IP, could match either peer configured on interface or a
430 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
432 group
= peer_group_lookup(bgp
, peer_str
);
436 if (peer_dynamic_neighbor(peer
)) {
438 "%% Operation not allowed on a dynamic neighbor\n");
448 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
453 int bgp_vty_return(struct vty
*vty
, int ret
)
455 const char *str
= NULL
;
458 case BGP_ERR_INVALID_VALUE
:
459 str
= "Invalid value";
461 case BGP_ERR_INVALID_FLAG
:
462 str
= "Invalid flag";
464 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
465 str
= "Peer-group has been shutdown. Activate the peer-group first";
467 case BGP_ERR_PEER_FLAG_CONFLICT
:
468 str
= "Can't set override-capability and strict-capability-match at the same time";
470 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
471 str
= "Specify remote-as or peer-group remote AS first";
473 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
474 str
= "Cannot change the peer-group. Deconfigure first";
476 case BGP_ERR_PEER_GROUP_MISMATCH
:
477 str
= "Peer is not a member of this peer-group";
479 case BGP_ERR_PEER_FILTER_CONFLICT
:
480 str
= "Prefix/distribute list can not co-exist";
482 case BGP_ERR_NOT_INTERNAL_PEER
:
483 str
= "Invalid command. Not an internal neighbor";
485 case BGP_ERR_REMOVE_PRIVATE_AS
:
486 str
= "remove-private-AS cannot be configured for IBGP peers";
488 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
489 str
= "Local-AS allowed only for EBGP peers";
491 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
492 str
= "Cannot have local-as same as BGP AS number";
494 case BGP_ERR_TCPSIG_FAILED
:
495 str
= "Error while applying TCP-Sig to session(s)";
497 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
498 str
= "ebgp-multihop and ttl-security cannot be configured together";
500 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
501 str
= "ttl-security only allowed for EBGP peers";
503 case BGP_ERR_AS_OVERRIDE
:
504 str
= "as-override cannot be configured for IBGP peers";
506 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
507 str
= "Invalid limit for number of dynamic neighbors";
509 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
510 str
= "Dynamic neighbor listen range already exists";
512 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
513 str
= "Operation not allowed on a dynamic neighbor";
515 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
516 str
= "Operation not allowed on a directly connected neighbor";
518 case BGP_ERR_PEER_SAFI_CONFLICT
:
519 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
523 vty_out(vty
, "%% %s\n", str
);
524 return CMD_WARNING_CONFIG_FAILED
;
529 /* BGP clear sort. */
538 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
539 safi_t safi
, int error
)
542 case BGP_ERR_AF_UNCONFIGURED
:
544 "%%BGP: Enable %s address family for the neighbor %s\n",
545 afi_safi_print(afi
, safi
), peer
->host
);
547 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
549 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
557 /* `clear ip bgp' functions. */
558 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
559 enum clear_sort sort
, enum bgp_clear_type stype
,
565 struct listnode
*node
, *nnode
;
567 /* Clear all neighbors. */
569 * Pass along pointer to next node to peer_clear() when walking all
570 * nodes on the BGP instance as that may get freed if it is a
573 if (sort
== clear_all
) {
574 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
575 if (!peer
->afc
[afi
][safi
])
578 if (stype
== BGP_CLEAR_SOFT_NONE
)
579 ret
= peer_clear(peer
, &nnode
);
581 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
584 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
589 /* This is to apply read-only mode on this clear. */
590 if (stype
== BGP_CLEAR_SOFT_NONE
)
591 bgp
->update_delay_over
= 0;
594 vty_out(vty
, "%%BGP: No %s peer configured",
595 afi_safi_print(afi
, safi
));
600 /* Clear specified neighbor. */
601 if (sort
== clear_peer
) {
604 /* Make sockunion for lookup. */
605 ret
= str2sockunion(arg
, &su
);
607 peer
= peer_lookup_by_conf_if(bgp
, arg
);
609 peer
= peer_lookup_by_hostname(bgp
, arg
);
612 "Malformed address or name: %s\n",
618 peer
= peer_lookup(bgp
, &su
);
621 "%%BGP: Unknown neighbor - \"%s\"\n",
627 if (!peer
->afc
[afi
][safi
])
628 ret
= BGP_ERR_AF_UNCONFIGURED
;
629 else if (stype
== BGP_CLEAR_SOFT_NONE
)
630 ret
= peer_clear(peer
, NULL
);
632 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
635 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
640 /* Clear all neighbors belonging to a specific peer-group. */
641 if (sort
== clear_group
) {
642 struct peer_group
*group
;
644 group
= peer_group_lookup(bgp
, arg
);
646 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
650 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
651 if (!peer
->afc
[afi
][safi
])
654 if (stype
== BGP_CLEAR_SOFT_NONE
)
655 ret
= peer_clear(peer
, NULL
);
657 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
660 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
667 "%%BGP: No %s peer belonging to peer-group %s is configured\n",
668 afi_safi_print(afi
, safi
), arg
);
673 /* Clear all external (eBGP) neighbors. */
674 if (sort
== clear_external
) {
675 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
676 if (peer
->sort
== BGP_PEER_IBGP
)
679 if (!peer
->afc
[afi
][safi
])
682 if (stype
== BGP_CLEAR_SOFT_NONE
)
683 ret
= peer_clear(peer
, &nnode
);
685 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
688 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
695 "%%BGP: No external %s peer is configured\n",
696 afi_safi_print(afi
, safi
));
701 /* Clear all neighbors belonging to a specific AS. */
702 if (sort
== clear_as
) {
703 as_t as
= strtoul(arg
, NULL
, 10);
705 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
709 if (!peer
->afc
[afi
][safi
])
710 ret
= BGP_ERR_AF_UNCONFIGURED
;
711 else if (stype
== BGP_CLEAR_SOFT_NONE
)
712 ret
= peer_clear(peer
, &nnode
);
714 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
717 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
724 "%%BGP: No %s peer is configured with AS %s\n",
725 afi_safi_print(afi
, safi
), arg
);
733 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
734 safi_t safi
, enum clear_sort sort
,
735 enum bgp_clear_type stype
, const char *arg
)
739 /* BGP structure lookup. */
741 bgp
= bgp_lookup_by_name(name
);
743 vty_out(vty
, "Can't find BGP instance %s\n", name
);
747 bgp
= bgp_get_default();
749 vty_out(vty
, "No BGP process is configured\n");
754 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
757 /* clear soft inbound */
758 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
760 bgp_clear_vty(vty
, name
, AFI_IP
, SAFI_UNICAST
, clear_all
,
761 BGP_CLEAR_SOFT_IN
, NULL
);
762 bgp_clear_vty(vty
, name
, AFI_IP6
, SAFI_UNICAST
, clear_all
,
763 BGP_CLEAR_SOFT_IN
, NULL
);
766 /* clear soft outbound */
767 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
769 bgp_clear_vty(vty
, name
, AFI_IP
, SAFI_UNICAST
, clear_all
,
770 BGP_CLEAR_SOFT_OUT
, NULL
);
771 bgp_clear_vty(vty
, name
, AFI_IP6
, SAFI_UNICAST
, clear_all
,
772 BGP_CLEAR_SOFT_OUT
, NULL
);
776 #ifndef VTYSH_EXTRACT_PL
777 #include "bgpd/bgp_vty_clippy.c"
780 /* BGP global configuration. */
781 #if (CONFDATE > 20190601)
782 CPP_NOTICE("bgpd: time to remove deprecated bgp multiple-instance")
783 CPP_NOTICE("This includes BGP_OPT_MULTIPLE_INSTANCE")
785 DEFUN_HIDDEN (bgp_multiple_instance_func
,
786 bgp_multiple_instance_cmd
,
787 "bgp multiple-instance",
789 "Enable bgp multiple instance\n")
791 bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE
);
795 DEFUN_HIDDEN (no_bgp_multiple_instance
,
796 no_bgp_multiple_instance_cmd
,
797 "no bgp multiple-instance",
800 "BGP multiple instance\n")
804 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
805 vty_out(vty
, "if you are using this please let the developers know\n");
806 zlog_info("Deprecated option: `bgp multiple-instance` being used");
807 ret
= bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE
);
809 vty_out(vty
, "%% There are more than two BGP instances\n");
810 return CMD_WARNING_CONFIG_FAILED
;
815 #if (CONFDATE > 20190601)
816 CPP_NOTICE("bgpd: time to remove deprecated cli bgp config-type cisco")
817 CPP_NOTICE("This includes BGP_OPT_CISCO_CONFIG")
819 DEFUN_HIDDEN (bgp_config_type
,
821 "bgp config-type <cisco|zebra>",
823 "Configuration type\n"
828 if (argv_find(argv
, argc
, "cisco", &idx
)) {
829 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
830 vty_out(vty
, "if you are using this please let the developers know!\n");
831 zlog_info("Deprecated option: `bgp config-type cisco` being used");
832 bgp_option_set(BGP_OPT_CONFIG_CISCO
);
834 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
839 DEFUN_HIDDEN (no_bgp_config_type
,
840 no_bgp_config_type_cmd
,
841 "no bgp config-type [<cisco|zebra>]",
844 "Display configuration type\n"
848 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
853 DEFUN (no_synchronization
,
854 no_synchronization_cmd
,
855 "no synchronization",
857 "Perform IGP synchronization\n")
862 DEFUN (no_auto_summary
,
866 "Enable automatic network number summarization\n")
871 /* "router bgp" commands. */
872 DEFUN_NOSH (router_bgp
,
874 "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
878 BGP_INSTANCE_HELP_STR
)
881 int idx_view_vrf
= 3;
886 const char *name
= NULL
;
887 enum bgp_instance_type inst_type
;
889 // "router bgp" without an ASN
891 // Pending: Make VRF option available for ASN less config
892 bgp
= bgp_get_default();
895 vty_out(vty
, "%% No BGP process is configured\n");
896 return CMD_WARNING_CONFIG_FAILED
;
899 if (listcount(bm
->bgp
) > 1) {
900 vty_out(vty
, "%% Please specify ASN and VRF\n");
901 return CMD_WARNING_CONFIG_FAILED
;
907 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
909 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
911 name
= argv
[idx_vrf
]->arg
;
913 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf"))
914 inst_type
= BGP_INSTANCE_TYPE_VRF
;
915 else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
916 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
919 ret
= bgp_get(&bgp
, &as
, name
, inst_type
);
921 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET
:
923 "Please specify 'bgp multiple-instance' first\n");
924 return CMD_WARNING_CONFIG_FAILED
;
925 case BGP_ERR_AS_MISMATCH
:
926 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
927 return CMD_WARNING_CONFIG_FAILED
;
928 case BGP_ERR_INSTANCE_MISMATCH
:
930 "BGP instance name and AS number mismatch\n");
932 "BGP instance is already running; AS is %u\n",
934 return CMD_WARNING_CONFIG_FAILED
;
938 * If we just instantiated the default instance, complete
939 * any pending VRF-VPN leaking that was configured via
940 * earlier "router bgp X vrf FOO" blocks.
942 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
943 vpn_leak_postchange_all();
945 /* Pending: handle when user tries to change a view to vrf n vv.
949 /* unset the auto created flag as the user config is now present */
950 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
951 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
956 /* "no router bgp" commands. */
957 DEFUN (no_router_bgp
,
959 "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
964 BGP_INSTANCE_HELP_STR
)
970 const char *name
= NULL
;
972 // "no router bgp" without an ASN
974 // Pending: Make VRF option available for ASN less config
975 bgp
= bgp_get_default();
978 vty_out(vty
, "%% No BGP process is configured\n");
979 return CMD_WARNING_CONFIG_FAILED
;
982 if (listcount(bm
->bgp
) > 1) {
983 vty_out(vty
, "%% Please specify ASN and VRF\n");
984 return CMD_WARNING_CONFIG_FAILED
;
988 vty_out(vty
, "%% Please unconfigure l3vni %u",
990 return CMD_WARNING_CONFIG_FAILED
;
993 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
996 name
= argv
[idx_vrf
]->arg
;
998 /* Lookup bgp structure. */
999 bgp
= bgp_lookup(as
, name
);
1001 vty_out(vty
, "%% Can't find BGP instance\n");
1002 return CMD_WARNING_CONFIG_FAILED
;
1006 vty_out(vty
, "%% Please unconfigure l3vni %u",
1008 return CMD_WARNING_CONFIG_FAILED
;
1018 /* BGP router-id. */
1020 DEFPY (bgp_router_id
,
1022 "bgp router-id A.B.C.D",
1024 "Override configured router identifier\n"
1025 "Manually configured router identifier\n")
1027 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1028 bgp_router_id_static_set(bgp
, router_id
);
1032 DEFPY (no_bgp_router_id
,
1033 no_bgp_router_id_cmd
,
1034 "no bgp router-id [A.B.C.D]",
1037 "Override configured router identifier\n"
1038 "Manually configured router identifier\n")
1040 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1042 if (router_id_str
) {
1043 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1044 vty_out(vty
, "%% BGP router-id doesn't match\n");
1045 return CMD_WARNING_CONFIG_FAILED
;
1049 router_id
.s_addr
= 0;
1050 bgp_router_id_static_set(bgp
, router_id
);
1056 /* BGP Cluster ID. */
1057 DEFUN (bgp_cluster_id
,
1059 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1061 "Configure Route-Reflector Cluster-id\n"
1062 "Route-Reflector Cluster-id in IP address format\n"
1063 "Route-Reflector Cluster-id as 32 bit quantity\n")
1065 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1068 struct in_addr cluster
;
1070 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1072 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1073 return CMD_WARNING_CONFIG_FAILED
;
1076 bgp_cluster_id_set(bgp
, &cluster
);
1077 bgp_clear_star_soft_out(vty
, bgp
->name
);
1082 DEFUN (no_bgp_cluster_id
,
1083 no_bgp_cluster_id_cmd
,
1084 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1087 "Configure Route-Reflector Cluster-id\n"
1088 "Route-Reflector Cluster-id in IP address format\n"
1089 "Route-Reflector Cluster-id as 32 bit quantity\n")
1091 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1092 bgp_cluster_id_unset(bgp
);
1093 bgp_clear_star_soft_out(vty
, bgp
->name
);
1098 DEFUN (bgp_confederation_identifier
,
1099 bgp_confederation_identifier_cmd
,
1100 "bgp confederation identifier (1-4294967295)",
1101 "BGP specific commands\n"
1102 "AS confederation parameters\n"
1104 "Set routing domain confederation AS\n")
1106 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1110 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1112 bgp_confederation_id_set(bgp
, as
);
1117 DEFUN (no_bgp_confederation_identifier
,
1118 no_bgp_confederation_identifier_cmd
,
1119 "no bgp confederation identifier [(1-4294967295)]",
1121 "BGP specific commands\n"
1122 "AS confederation parameters\n"
1124 "Set routing domain confederation AS\n")
1126 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1127 bgp_confederation_id_unset(bgp
);
1132 DEFUN (bgp_confederation_peers
,
1133 bgp_confederation_peers_cmd
,
1134 "bgp confederation peers (1-4294967295)...",
1135 "BGP specific commands\n"
1136 "AS confederation parameters\n"
1137 "Peer ASs in BGP confederation\n"
1140 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1145 for (i
= idx_asn
; i
< argc
; i
++) {
1146 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1148 if (bgp
->as
== as
) {
1150 "%% Local member-AS not allowed in confed peer list\n");
1154 bgp_confederation_peers_add(bgp
, as
);
1159 DEFUN (no_bgp_confederation_peers
,
1160 no_bgp_confederation_peers_cmd
,
1161 "no bgp confederation peers (1-4294967295)...",
1163 "BGP specific commands\n"
1164 "AS confederation parameters\n"
1165 "Peer ASs in BGP confederation\n"
1168 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1173 for (i
= idx_asn
; i
< argc
; i
++) {
1174 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1176 bgp_confederation_peers_remove(bgp
, as
);
1182 * Central routine for maximum-paths configuration.
1183 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1184 * @set: 1 for setting values, 0 for removing the max-paths config.
1186 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1187 const char *mpaths
, uint16_t options
,
1190 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1191 uint16_t maxpaths
= 0;
1196 afi
= bgp_node_afi(vty
);
1197 safi
= bgp_node_safi(vty
);
1200 maxpaths
= strtol(mpaths
, NULL
, 10);
1201 if (maxpaths
> multipath_num
) {
1203 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1204 maxpaths
, multipath_num
);
1205 return CMD_WARNING_CONFIG_FAILED
;
1207 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1210 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1214 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1215 (set
== 1) ? "" : "un",
1216 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1217 maxpaths
, afi
, safi
);
1218 return CMD_WARNING_CONFIG_FAILED
;
1221 bgp_recalculate_all_bestpaths(bgp
);
1226 DEFUN (bgp_maxmed_admin
,
1227 bgp_maxmed_admin_cmd
,
1228 "bgp max-med administrative ",
1230 "Advertise routes with max-med\n"
1231 "Administratively applied, for an indefinite period\n")
1233 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1235 bgp
->v_maxmed_admin
= 1;
1236 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1238 bgp_maxmed_update(bgp
);
1243 DEFUN (bgp_maxmed_admin_medv
,
1244 bgp_maxmed_admin_medv_cmd
,
1245 "bgp max-med administrative (0-4294967295)",
1247 "Advertise routes with max-med\n"
1248 "Administratively applied, for an indefinite period\n"
1249 "Max MED value to be used\n")
1251 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1254 bgp
->v_maxmed_admin
= 1;
1255 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1257 bgp_maxmed_update(bgp
);
1262 DEFUN (no_bgp_maxmed_admin
,
1263 no_bgp_maxmed_admin_cmd
,
1264 "no bgp max-med administrative [(0-4294967295)]",
1267 "Advertise routes with max-med\n"
1268 "Administratively applied, for an indefinite period\n"
1269 "Max MED value to be used\n")
1271 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1272 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1273 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1274 bgp_maxmed_update(bgp
);
1279 DEFUN (bgp_maxmed_onstartup
,
1280 bgp_maxmed_onstartup_cmd
,
1281 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1283 "Advertise routes with max-med\n"
1284 "Effective on a startup\n"
1285 "Time (seconds) period for max-med\n"
1286 "Max MED value to be used\n")
1288 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1291 argv_find(argv
, argc
, "(5-86400)", &idx
);
1292 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1293 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1294 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1296 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1298 bgp_maxmed_update(bgp
);
1303 DEFUN (no_bgp_maxmed_onstartup
,
1304 no_bgp_maxmed_onstartup_cmd
,
1305 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1308 "Advertise routes with max-med\n"
1309 "Effective on a startup\n"
1310 "Time (seconds) period for max-med\n"
1311 "Max MED value to be used\n")
1313 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1315 /* Cancel max-med onstartup if its on */
1316 if (bgp
->t_maxmed_onstartup
) {
1317 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1318 bgp
->maxmed_onstartup_over
= 1;
1321 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1322 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1324 bgp_maxmed_update(bgp
);
1329 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1332 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1333 uint16_t update_delay
;
1334 uint16_t establish_wait
;
1336 update_delay
= strtoul(delay
, NULL
, 10);
1338 if (!wait
) /* update-delay <delay> */
1340 bgp
->v_update_delay
= update_delay
;
1341 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1345 /* update-delay <delay> <establish-wait> */
1346 establish_wait
= atoi(wait
);
1347 if (update_delay
< establish_wait
) {
1349 "%%Failed: update-delay less than the establish-wait!\n");
1350 return CMD_WARNING_CONFIG_FAILED
;
1353 bgp
->v_update_delay
= update_delay
;
1354 bgp
->v_establish_wait
= establish_wait
;
1359 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1361 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1363 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1364 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1369 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1371 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1372 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1373 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1374 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1380 /* Update-delay configuration */
1381 DEFUN (bgp_update_delay
,
1382 bgp_update_delay_cmd
,
1383 "update-delay (0-3600)",
1384 "Force initial delay for best-path and updates\n"
1388 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1391 DEFUN (bgp_update_delay_establish_wait
,
1392 bgp_update_delay_establish_wait_cmd
,
1393 "update-delay (0-3600) (1-3600)",
1394 "Force initial delay for best-path and updates\n"
1399 int idx_number_2
= 2;
1400 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1401 argv
[idx_number_2
]->arg
);
1404 /* Update-delay deconfiguration */
1405 DEFUN (no_bgp_update_delay
,
1406 no_bgp_update_delay_cmd
,
1407 "no update-delay [(0-3600) [(1-3600)]]",
1409 "Force initial delay for best-path and updates\n"
1413 return bgp_update_delay_deconfig_vty(vty
);
1417 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1420 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1423 uint32_t quanta
= strtoul(num
, NULL
, 10);
1424 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
,
1425 memory_order_relaxed
);
1427 atomic_store_explicit(&bgp
->wpkt_quanta
, BGP_WRITE_PACKET_MAX
,
1428 memory_order_relaxed
);
1434 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1437 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1440 uint32_t quanta
= strtoul(num
, NULL
, 10);
1441 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
,
1442 memory_order_relaxed
);
1444 atomic_store_explicit(&bgp
->rpkt_quanta
, BGP_READ_PACKET_MAX
,
1445 memory_order_relaxed
);
1451 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1454 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1455 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1456 vty_out(vty
, " write-quanta %d\n", quanta
);
1459 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1462 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1463 if (quanta
!= BGP_READ_PACKET_MAX
)
1464 vty_out(vty
, " read-quanta %d\n", quanta
);
1467 /* Packet quanta configuration */
1468 DEFUN (bgp_wpkt_quanta
,
1469 bgp_wpkt_quanta_cmd
,
1470 "write-quanta (1-10)",
1471 "How many packets to write to peer socket per run\n"
1472 "Number of packets\n")
1475 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1478 DEFUN (no_bgp_wpkt_quanta
,
1479 no_bgp_wpkt_quanta_cmd
,
1480 "no write-quanta (1-10)",
1482 "How many packets to write to peer socket per I/O cycle\n"
1483 "Number of packets\n")
1486 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1489 DEFUN (bgp_rpkt_quanta
,
1490 bgp_rpkt_quanta_cmd
,
1491 "read-quanta (1-10)",
1492 "How many packets to read from peer socket per I/O cycle\n"
1493 "Number of packets\n")
1496 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1499 DEFUN (no_bgp_rpkt_quanta
,
1500 no_bgp_rpkt_quanta_cmd
,
1501 "no read-quanta (1-10)",
1503 "How many packets to read from peer socket per I/O cycle\n"
1504 "Number of packets\n")
1507 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1510 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1512 if (!bgp
->heuristic_coalesce
)
1513 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1517 DEFUN (bgp_coalesce_time
,
1518 bgp_coalesce_time_cmd
,
1519 "coalesce-time (0-4294967295)",
1520 "Subgroup coalesce timer\n"
1521 "Subgroup coalesce timer value (in ms)\n")
1523 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1526 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1527 bgp
->heuristic_coalesce
= false;
1528 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1532 DEFUN (no_bgp_coalesce_time
,
1533 no_bgp_coalesce_time_cmd
,
1534 "no coalesce-time (0-4294967295)",
1536 "Subgroup coalesce timer\n"
1537 "Subgroup coalesce timer value (in ms)\n")
1539 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1541 bgp
->heuristic_coalesce
= true;
1542 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1546 /* Maximum-paths configuration */
1547 DEFUN (bgp_maxpaths
,
1549 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1550 "Forward packets over multiple paths\n"
1551 "Number of paths\n")
1554 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1555 argv
[idx_number
]->arg
, 0, 1);
1558 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1559 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1560 "Forward packets over multiple paths\n"
1561 "Number of paths\n")
1563 DEFUN (bgp_maxpaths_ibgp
,
1564 bgp_maxpaths_ibgp_cmd
,
1565 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1566 "Forward packets over multiple paths\n"
1568 "Number of paths\n")
1571 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1572 argv
[idx_number
]->arg
, 0, 1);
1575 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1576 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1577 "Forward packets over multiple paths\n"
1579 "Number of paths\n")
1581 DEFUN (bgp_maxpaths_ibgp_cluster
,
1582 bgp_maxpaths_ibgp_cluster_cmd
,
1583 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1584 "Forward packets over multiple paths\n"
1587 "Match the cluster length\n")
1590 return bgp_maxpaths_config_vty(
1591 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1592 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1595 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1596 "maximum-paths ibgp " CMD_RANGE_STR(
1597 1, MULTIPATH_NUM
) " equal-cluster-length",
1598 "Forward packets over multiple paths\n"
1601 "Match the cluster length\n")
1603 DEFUN (no_bgp_maxpaths
,
1604 no_bgp_maxpaths_cmd
,
1605 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1607 "Forward packets over multiple paths\n"
1608 "Number of paths\n")
1610 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1613 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1614 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1615 "Forward packets over multiple paths\n"
1616 "Number of paths\n")
1618 DEFUN (no_bgp_maxpaths_ibgp
,
1619 no_bgp_maxpaths_ibgp_cmd
,
1620 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1622 "Forward packets over multiple paths\n"
1625 "Match the cluster length\n")
1627 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1630 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1631 "no maximum-paths ibgp [" CMD_RANGE_STR(
1632 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1634 "Forward packets over multiple paths\n"
1637 "Match the cluster length\n")
1639 void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1642 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1643 vty_out(vty
, " maximum-paths %d\n",
1644 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1647 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1648 vty_out(vty
, " maximum-paths ibgp %d",
1649 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1650 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1651 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1652 vty_out(vty
, " equal-cluster-length");
1661 "timers bgp (0-65535) (0-65535)",
1662 "Adjust routing timers\n"
1664 "Keepalive interval\n"
1667 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1669 int idx_number_2
= 3;
1670 unsigned long keepalive
= 0;
1671 unsigned long holdtime
= 0;
1673 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1674 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1676 /* Holdtime value check. */
1677 if (holdtime
< 3 && holdtime
!= 0) {
1679 "%% hold time value must be either 0 or greater than 3\n");
1680 return CMD_WARNING_CONFIG_FAILED
;
1683 bgp_timers_set(bgp
, keepalive
, holdtime
);
1688 DEFUN (no_bgp_timers
,
1690 "no timers bgp [(0-65535) (0-65535)]",
1692 "Adjust routing timers\n"
1694 "Keepalive interval\n"
1697 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1698 bgp_timers_unset(bgp
);
1704 DEFUN (bgp_client_to_client_reflection
,
1705 bgp_client_to_client_reflection_cmd
,
1706 "bgp client-to-client reflection",
1707 "BGP specific commands\n"
1708 "Configure client to client route reflection\n"
1709 "reflection of routes allowed\n")
1711 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1712 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1713 bgp_clear_star_soft_out(vty
, bgp
->name
);
1718 DEFUN (no_bgp_client_to_client_reflection
,
1719 no_bgp_client_to_client_reflection_cmd
,
1720 "no bgp client-to-client reflection",
1722 "BGP specific commands\n"
1723 "Configure client to client route reflection\n"
1724 "reflection of routes allowed\n")
1726 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1727 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1728 bgp_clear_star_soft_out(vty
, bgp
->name
);
1733 /* "bgp always-compare-med" configuration. */
1734 DEFUN (bgp_always_compare_med
,
1735 bgp_always_compare_med_cmd
,
1736 "bgp always-compare-med",
1737 "BGP specific commands\n"
1738 "Allow comparing MED from different neighbors\n")
1740 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1741 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1742 bgp_recalculate_all_bestpaths(bgp
);
1747 DEFUN (no_bgp_always_compare_med
,
1748 no_bgp_always_compare_med_cmd
,
1749 "no bgp always-compare-med",
1751 "BGP specific commands\n"
1752 "Allow comparing MED from different neighbors\n")
1754 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1755 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1756 bgp_recalculate_all_bestpaths(bgp
);
1761 /* "bgp deterministic-med" configuration. */
1762 DEFUN (bgp_deterministic_med
,
1763 bgp_deterministic_med_cmd
,
1764 "bgp deterministic-med",
1765 "BGP specific commands\n"
1766 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1768 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1770 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1771 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1772 bgp_recalculate_all_bestpaths(bgp
);
1778 DEFUN (no_bgp_deterministic_med
,
1779 no_bgp_deterministic_med_cmd
,
1780 "no bgp deterministic-med",
1782 "BGP specific commands\n"
1783 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1785 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1786 int bestpath_per_as_used
;
1790 struct listnode
*node
, *nnode
;
1792 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1793 bestpath_per_as_used
= 0;
1795 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1796 FOREACH_AFI_SAFI (afi
, safi
)
1798 peer
->af_flags
[afi
][safi
],
1799 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
)) {
1800 bestpath_per_as_used
= 1;
1804 if (bestpath_per_as_used
)
1808 if (bestpath_per_as_used
) {
1810 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
1811 return CMD_WARNING_CONFIG_FAILED
;
1813 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1814 bgp_recalculate_all_bestpaths(bgp
);
1821 /* "bgp graceful-restart" configuration. */
1822 DEFUN (bgp_graceful_restart
,
1823 bgp_graceful_restart_cmd
,
1824 "bgp graceful-restart",
1825 "BGP specific commands\n"
1826 "Graceful restart capability parameters\n")
1828 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1829 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1833 DEFUN (no_bgp_graceful_restart
,
1834 no_bgp_graceful_restart_cmd
,
1835 "no bgp graceful-restart",
1837 "BGP specific commands\n"
1838 "Graceful restart capability parameters\n")
1840 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1841 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1845 DEFUN (bgp_graceful_restart_stalepath_time
,
1846 bgp_graceful_restart_stalepath_time_cmd
,
1847 "bgp graceful-restart stalepath-time (1-3600)",
1848 "BGP specific commands\n"
1849 "Graceful restart capability parameters\n"
1850 "Set the max time to hold onto restarting peer's stale paths\n"
1851 "Delay value (seconds)\n")
1853 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1857 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1858 bgp
->stalepath_time
= stalepath
;
1862 DEFUN (bgp_graceful_restart_restart_time
,
1863 bgp_graceful_restart_restart_time_cmd
,
1864 "bgp graceful-restart restart-time (1-3600)",
1865 "BGP specific commands\n"
1866 "Graceful restart capability parameters\n"
1867 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1868 "Delay value (seconds)\n")
1870 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1874 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1875 bgp
->restart_time
= restart
;
1879 DEFUN (no_bgp_graceful_restart_stalepath_time
,
1880 no_bgp_graceful_restart_stalepath_time_cmd
,
1881 "no bgp graceful-restart stalepath-time [(1-3600)]",
1883 "BGP specific commands\n"
1884 "Graceful restart capability parameters\n"
1885 "Set the max time to hold onto restarting peer's stale paths\n"
1886 "Delay value (seconds)\n")
1888 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1890 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
1894 DEFUN (no_bgp_graceful_restart_restart_time
,
1895 no_bgp_graceful_restart_restart_time_cmd
,
1896 "no bgp graceful-restart restart-time [(1-3600)]",
1898 "BGP specific commands\n"
1899 "Graceful restart capability parameters\n"
1900 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1901 "Delay value (seconds)\n")
1903 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1905 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
1909 DEFUN (bgp_graceful_restart_preserve_fw
,
1910 bgp_graceful_restart_preserve_fw_cmd
,
1911 "bgp graceful-restart preserve-fw-state",
1912 "BGP specific commands\n"
1913 "Graceful restart capability parameters\n"
1914 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
1916 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1917 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
1921 DEFUN (no_bgp_graceful_restart_preserve_fw
,
1922 no_bgp_graceful_restart_preserve_fw_cmd
,
1923 "no bgp graceful-restart preserve-fw-state",
1925 "BGP specific commands\n"
1926 "Graceful restart capability parameters\n"
1927 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
1929 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1930 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
1934 static void bgp_redistribute_redo(struct bgp
*bgp
)
1938 struct list
*red_list
;
1939 struct listnode
*node
;
1940 struct bgp_redist
*red
;
1942 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
1943 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
1945 red_list
= bgp
->redist
[afi
][i
];
1949 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
1950 bgp_redistribute_resend(bgp
, afi
, i
,
1957 /* "bgp graceful-shutdown" configuration */
1958 DEFUN (bgp_graceful_shutdown
,
1959 bgp_graceful_shutdown_cmd
,
1960 "bgp graceful-shutdown",
1962 "Graceful shutdown parameters\n")
1964 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1966 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
1967 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
1968 bgp_static_redo_import_check(bgp
);
1969 bgp_redistribute_redo(bgp
);
1970 bgp_clear_star_soft_out(vty
, bgp
->name
);
1971 bgp_clear_star_soft_in(vty
, bgp
->name
);
1977 DEFUN (no_bgp_graceful_shutdown
,
1978 no_bgp_graceful_shutdown_cmd
,
1979 "no bgp graceful-shutdown",
1982 "Graceful shutdown parameters\n")
1984 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1986 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
1987 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
1988 bgp_static_redo_import_check(bgp
);
1989 bgp_redistribute_redo(bgp
);
1990 bgp_clear_star_soft_out(vty
, bgp
->name
);
1991 bgp_clear_star_soft_in(vty
, bgp
->name
);
1997 /* "bgp fast-external-failover" configuration. */
1998 DEFUN (bgp_fast_external_failover
,
1999 bgp_fast_external_failover_cmd
,
2000 "bgp fast-external-failover",
2002 "Immediately reset session if a link to a directly connected external peer goes down\n")
2004 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2005 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2009 DEFUN (no_bgp_fast_external_failover
,
2010 no_bgp_fast_external_failover_cmd
,
2011 "no bgp fast-external-failover",
2014 "Immediately reset session if a link to a directly connected external peer goes down\n")
2016 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2017 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2021 /* "bgp enforce-first-as" configuration. */
2022 #if CONFDATE > 20180517
2023 CPP_NOTICE("bgpd: remove deprecated '[no] bgp enforce-first-as' commands")
2026 DEFUN_HIDDEN (bgp_enforce_first_as
,
2027 bgp_enforce_first_as_cmd
,
2028 "[no] bgp enforce-first-as",
2031 "Enforce the first AS for EBGP routes\n")
2033 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2035 if (strmatch(argv
[0]->text
, "no"))
2036 bgp_flag_unset(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2038 bgp_flag_set(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2043 /* "bgp bestpath compare-routerid" configuration. */
2044 DEFUN (bgp_bestpath_compare_router_id
,
2045 bgp_bestpath_compare_router_id_cmd
,
2046 "bgp bestpath compare-routerid",
2047 "BGP specific commands\n"
2048 "Change the default bestpath selection\n"
2049 "Compare router-id for identical EBGP paths\n")
2051 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2052 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2053 bgp_recalculate_all_bestpaths(bgp
);
2058 DEFUN (no_bgp_bestpath_compare_router_id
,
2059 no_bgp_bestpath_compare_router_id_cmd
,
2060 "no bgp bestpath compare-routerid",
2062 "BGP specific commands\n"
2063 "Change the default bestpath selection\n"
2064 "Compare router-id for identical EBGP paths\n")
2066 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2067 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2068 bgp_recalculate_all_bestpaths(bgp
);
2073 /* "bgp bestpath as-path ignore" configuration. */
2074 DEFUN (bgp_bestpath_aspath_ignore
,
2075 bgp_bestpath_aspath_ignore_cmd
,
2076 "bgp bestpath as-path ignore",
2077 "BGP specific commands\n"
2078 "Change the default bestpath selection\n"
2079 "AS-path attribute\n"
2080 "Ignore as-path length in selecting a route\n")
2082 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2083 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2084 bgp_recalculate_all_bestpaths(bgp
);
2089 DEFUN (no_bgp_bestpath_aspath_ignore
,
2090 no_bgp_bestpath_aspath_ignore_cmd
,
2091 "no bgp bestpath as-path ignore",
2093 "BGP specific commands\n"
2094 "Change the default bestpath selection\n"
2095 "AS-path attribute\n"
2096 "Ignore as-path length in selecting a route\n")
2098 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2099 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2100 bgp_recalculate_all_bestpaths(bgp
);
2105 /* "bgp bestpath as-path confed" configuration. */
2106 DEFUN (bgp_bestpath_aspath_confed
,
2107 bgp_bestpath_aspath_confed_cmd
,
2108 "bgp bestpath as-path confed",
2109 "BGP specific commands\n"
2110 "Change the default bestpath selection\n"
2111 "AS-path attribute\n"
2112 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2114 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2115 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2116 bgp_recalculate_all_bestpaths(bgp
);
2121 DEFUN (no_bgp_bestpath_aspath_confed
,
2122 no_bgp_bestpath_aspath_confed_cmd
,
2123 "no bgp bestpath as-path confed",
2125 "BGP specific commands\n"
2126 "Change the default bestpath selection\n"
2127 "AS-path attribute\n"
2128 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2130 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2131 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2132 bgp_recalculate_all_bestpaths(bgp
);
2137 /* "bgp bestpath as-path multipath-relax" configuration. */
2138 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2139 bgp_bestpath_aspath_multipath_relax_cmd
,
2140 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2141 "BGP specific commands\n"
2142 "Change the default bestpath selection\n"
2143 "AS-path attribute\n"
2144 "Allow load sharing across routes that have different AS paths (but same length)\n"
2145 "Generate an AS_SET\n"
2146 "Do not generate an AS_SET\n")
2148 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2150 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2152 /* no-as-set is now the default behavior so we can silently
2154 if (argv_find(argv
, argc
, "as-set", &idx
))
2155 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2157 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2159 bgp_recalculate_all_bestpaths(bgp
);
2164 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2165 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2166 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2168 "BGP specific commands\n"
2169 "Change the default bestpath selection\n"
2170 "AS-path attribute\n"
2171 "Allow load sharing across routes that have different AS paths (but same length)\n"
2172 "Generate an AS_SET\n"
2173 "Do not generate an AS_SET\n")
2175 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2176 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2177 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2178 bgp_recalculate_all_bestpaths(bgp
);
2183 /* "bgp log-neighbor-changes" configuration. */
2184 DEFUN (bgp_log_neighbor_changes
,
2185 bgp_log_neighbor_changes_cmd
,
2186 "bgp log-neighbor-changes",
2187 "BGP specific commands\n"
2188 "Log neighbor up/down and reset reason\n")
2190 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2191 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2195 DEFUN (no_bgp_log_neighbor_changes
,
2196 no_bgp_log_neighbor_changes_cmd
,
2197 "no bgp log-neighbor-changes",
2199 "BGP specific commands\n"
2200 "Log neighbor up/down and reset reason\n")
2202 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2203 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2207 /* "bgp bestpath med" configuration. */
2208 DEFUN (bgp_bestpath_med
,
2209 bgp_bestpath_med_cmd
,
2210 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2211 "BGP specific commands\n"
2212 "Change the default bestpath selection\n"
2214 "Compare MED among confederation paths\n"
2215 "Treat missing MED as the least preferred one\n"
2216 "Treat missing MED as the least preferred one\n"
2217 "Compare MED among confederation paths\n")
2219 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2222 if (argv_find(argv
, argc
, "confed", &idx
))
2223 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2225 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2226 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2228 bgp_recalculate_all_bestpaths(bgp
);
2233 DEFUN (no_bgp_bestpath_med
,
2234 no_bgp_bestpath_med_cmd
,
2235 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2237 "BGP specific commands\n"
2238 "Change the default bestpath selection\n"
2240 "Compare MED among confederation paths\n"
2241 "Treat missing MED as the least preferred one\n"
2242 "Treat missing MED as the least preferred one\n"
2243 "Compare MED among confederation paths\n")
2245 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2248 if (argv_find(argv
, argc
, "confed", &idx
))
2249 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2251 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2252 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2254 bgp_recalculate_all_bestpaths(bgp
);
2259 /* "no bgp default ipv4-unicast". */
2260 DEFUN (no_bgp_default_ipv4_unicast
,
2261 no_bgp_default_ipv4_unicast_cmd
,
2262 "no bgp default ipv4-unicast",
2264 "BGP specific commands\n"
2265 "Configure BGP defaults\n"
2266 "Activate ipv4-unicast for a peer by default\n")
2268 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2269 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2273 DEFUN (bgp_default_ipv4_unicast
,
2274 bgp_default_ipv4_unicast_cmd
,
2275 "bgp default ipv4-unicast",
2276 "BGP specific commands\n"
2277 "Configure BGP defaults\n"
2278 "Activate ipv4-unicast for a peer by default\n")
2280 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2281 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2285 /* Display hostname in certain command outputs */
2286 DEFUN (bgp_default_show_hostname
,
2287 bgp_default_show_hostname_cmd
,
2288 "bgp default show-hostname",
2289 "BGP specific commands\n"
2290 "Configure BGP defaults\n"
2291 "Show hostname in certain command ouputs\n")
2293 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2294 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2298 DEFUN (no_bgp_default_show_hostname
,
2299 no_bgp_default_show_hostname_cmd
,
2300 "no bgp default show-hostname",
2302 "BGP specific commands\n"
2303 "Configure BGP defaults\n"
2304 "Show hostname in certain command ouputs\n")
2306 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2307 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2311 /* "bgp network import-check" configuration. */
2312 DEFUN (bgp_network_import_check
,
2313 bgp_network_import_check_cmd
,
2314 "bgp network import-check",
2315 "BGP specific commands\n"
2316 "BGP network command\n"
2317 "Check BGP network route exists in IGP\n")
2319 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2320 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2321 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2322 bgp_static_redo_import_check(bgp
);
2328 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2329 "bgp network import-check exact",
2330 "BGP specific commands\n"
2331 "BGP network command\n"
2332 "Check BGP network route exists in IGP\n"
2333 "Match route precisely\n")
2335 DEFUN (no_bgp_network_import_check
,
2336 no_bgp_network_import_check_cmd
,
2337 "no bgp network import-check",
2339 "BGP specific commands\n"
2340 "BGP network command\n"
2341 "Check BGP network route exists in IGP\n")
2343 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2344 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2345 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2346 bgp_static_redo_import_check(bgp
);
2352 DEFUN (bgp_default_local_preference
,
2353 bgp_default_local_preference_cmd
,
2354 "bgp default local-preference (0-4294967295)",
2355 "BGP specific commands\n"
2356 "Configure BGP defaults\n"
2357 "local preference (higher=more preferred)\n"
2358 "Configure default local preference value\n")
2360 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2362 uint32_t local_pref
;
2364 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2366 bgp_default_local_preference_set(bgp
, local_pref
);
2367 bgp_clear_star_soft_in(vty
, bgp
->name
);
2372 DEFUN (no_bgp_default_local_preference
,
2373 no_bgp_default_local_preference_cmd
,
2374 "no bgp default local-preference [(0-4294967295)]",
2376 "BGP specific commands\n"
2377 "Configure BGP defaults\n"
2378 "local preference (higher=more preferred)\n"
2379 "Configure default local preference value\n")
2381 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2382 bgp_default_local_preference_unset(bgp
);
2383 bgp_clear_star_soft_in(vty
, bgp
->name
);
2389 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2390 bgp_default_subgroup_pkt_queue_max_cmd
,
2391 "bgp default subgroup-pkt-queue-max (20-100)",
2392 "BGP specific commands\n"
2393 "Configure BGP defaults\n"
2394 "subgroup-pkt-queue-max\n"
2395 "Configure subgroup packet queue max\n")
2397 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2401 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2403 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2408 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2409 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2410 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2412 "BGP specific commands\n"
2413 "Configure BGP defaults\n"
2414 "subgroup-pkt-queue-max\n"
2415 "Configure subgroup packet queue max\n")
2417 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2418 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2423 DEFUN (bgp_rr_allow_outbound_policy
,
2424 bgp_rr_allow_outbound_policy_cmd
,
2425 "bgp route-reflector allow-outbound-policy",
2426 "BGP specific commands\n"
2427 "Allow modifications made by out route-map\n"
2428 "on ibgp neighbors\n")
2430 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2432 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2433 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2434 update_group_announce_rrclients(bgp
);
2435 bgp_clear_star_soft_out(vty
, bgp
->name
);
2441 DEFUN (no_bgp_rr_allow_outbound_policy
,
2442 no_bgp_rr_allow_outbound_policy_cmd
,
2443 "no bgp route-reflector allow-outbound-policy",
2445 "BGP specific commands\n"
2446 "Allow modifications made by out route-map\n"
2447 "on ibgp neighbors\n")
2449 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2451 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2452 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2453 update_group_announce_rrclients(bgp
);
2454 bgp_clear_star_soft_out(vty
, bgp
->name
);
2460 DEFUN (bgp_listen_limit
,
2461 bgp_listen_limit_cmd
,
2462 "bgp listen limit (1-5000)",
2463 "BGP specific commands\n"
2464 "Configure BGP defaults\n"
2465 "maximum number of BGP Dynamic Neighbors that can be created\n"
2466 "Configure Dynamic Neighbors listen limit value\n")
2468 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2472 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2474 bgp_listen_limit_set(bgp
, listen_limit
);
2479 DEFUN (no_bgp_listen_limit
,
2480 no_bgp_listen_limit_cmd
,
2481 "no bgp listen limit [(1-5000)]",
2482 "BGP specific commands\n"
2483 "Configure BGP defaults\n"
2484 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2485 "Configure Dynamic Neighbors listen limit value to default\n"
2486 "Configure Dynamic Neighbors listen limit value\n")
2488 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2489 bgp_listen_limit_unset(bgp
);
2495 * Check if this listen range is already configured. Check for exact
2496 * match or overlap based on input.
2498 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2499 struct prefix
*range
, int exact
)
2501 struct listnode
*node
, *nnode
;
2502 struct listnode
*node1
, *nnode1
;
2503 struct peer_group
*group
;
2508 afi
= family2afi(range
->family
);
2509 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2510 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2513 match
= prefix_same(range
, lr
);
2515 match
= (prefix_match(range
, lr
)
2516 || prefix_match(lr
, range
));
2525 DEFUN (bgp_listen_range
,
2526 bgp_listen_range_cmd
,
2527 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2528 "BGP specific commands\n"
2529 "Configure BGP dynamic neighbors listen range\n"
2530 "Configure BGP dynamic neighbors listen range\n"
2532 "Member of the peer-group\n"
2533 "Peer-group name\n")
2535 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2536 struct prefix range
;
2537 struct peer_group
*group
, *existing_group
;
2542 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2543 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2544 char *prefix
= argv
[idx
]->arg
;
2545 argv_find(argv
, argc
, "WORD", &idx
);
2546 char *peergroup
= argv
[idx
]->arg
;
2548 /* Convert IP prefix string to struct prefix. */
2549 ret
= str2prefix(prefix
, &range
);
2551 vty_out(vty
, "%% Malformed listen range\n");
2552 return CMD_WARNING_CONFIG_FAILED
;
2555 afi
= family2afi(range
.family
);
2557 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2559 "%% Malformed listen range (link-local address)\n");
2560 return CMD_WARNING_CONFIG_FAILED
;
2565 /* Check if same listen range is already configured. */
2566 existing_group
= listen_range_exists(bgp
, &range
, 1);
2567 if (existing_group
) {
2568 if (strcmp(existing_group
->name
, peergroup
) == 0)
2572 "%% Same listen range is attached to peer-group %s\n",
2573 existing_group
->name
);
2574 return CMD_WARNING_CONFIG_FAILED
;
2578 /* Check if an overlapping listen range exists. */
2579 if (listen_range_exists(bgp
, &range
, 0)) {
2581 "%% Listen range overlaps with existing listen range\n");
2582 return CMD_WARNING_CONFIG_FAILED
;
2585 group
= peer_group_lookup(bgp
, peergroup
);
2587 vty_out(vty
, "%% Configure the peer-group first\n");
2588 return CMD_WARNING_CONFIG_FAILED
;
2591 ret
= peer_group_listen_range_add(group
, &range
);
2592 return bgp_vty_return(vty
, ret
);
2595 DEFUN (no_bgp_listen_range
,
2596 no_bgp_listen_range_cmd
,
2597 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2599 "BGP specific commands\n"
2600 "Unconfigure BGP dynamic neighbors listen range\n"
2601 "Unconfigure BGP dynamic neighbors listen range\n"
2603 "Member of the peer-group\n"
2604 "Peer-group name\n")
2606 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2607 struct prefix range
;
2608 struct peer_group
*group
;
2613 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2614 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2615 char *prefix
= argv
[idx
]->arg
;
2616 argv_find(argv
, argc
, "WORD", &idx
);
2617 char *peergroup
= argv
[idx
]->arg
;
2619 /* Convert IP prefix string to struct prefix. */
2620 ret
= str2prefix(prefix
, &range
);
2622 vty_out(vty
, "%% Malformed listen range\n");
2623 return CMD_WARNING_CONFIG_FAILED
;
2626 afi
= family2afi(range
.family
);
2628 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2630 "%% Malformed listen range (link-local address)\n");
2631 return CMD_WARNING_CONFIG_FAILED
;
2636 group
= peer_group_lookup(bgp
, peergroup
);
2638 vty_out(vty
, "%% Peer-group does not exist\n");
2639 return CMD_WARNING_CONFIG_FAILED
;
2642 ret
= peer_group_listen_range_del(group
, &range
);
2643 return bgp_vty_return(vty
, ret
);
2646 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2648 struct peer_group
*group
;
2649 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2650 struct prefix
*range
;
2652 char buf
[PREFIX2STR_BUFFER
];
2654 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2655 vty_out(vty
, " bgp listen limit %d\n",
2656 bgp
->dynamic_neighbors_limit
);
2658 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2659 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2660 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2662 prefix2str(range
, buf
, sizeof(buf
));
2664 " bgp listen range %s peer-group %s\n",
2672 DEFUN (bgp_disable_connected_route_check
,
2673 bgp_disable_connected_route_check_cmd
,
2674 "bgp disable-ebgp-connected-route-check",
2675 "BGP specific commands\n"
2676 "Disable checking if nexthop is connected on ebgp sessions\n")
2678 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2679 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2680 bgp_clear_star_soft_in(vty
, bgp
->name
);
2685 DEFUN (no_bgp_disable_connected_route_check
,
2686 no_bgp_disable_connected_route_check_cmd
,
2687 "no bgp disable-ebgp-connected-route-check",
2689 "BGP specific commands\n"
2690 "Disable checking if nexthop is connected on ebgp sessions\n")
2692 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2693 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2694 bgp_clear_star_soft_in(vty
, bgp
->name
);
2700 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2701 const char *as_str
, afi_t afi
, safi_t safi
)
2703 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2706 int as_type
= AS_SPECIFIED
;
2709 if (as_str
[0] == 'i') {
2711 as_type
= AS_INTERNAL
;
2712 } else if (as_str
[0] == 'e') {
2714 as_type
= AS_EXTERNAL
;
2716 /* Get AS number. */
2717 as
= strtoul(as_str
, NULL
, 10);
2720 /* If peer is peer group, call proper function. */
2721 ret
= str2sockunion(peer_str
, &su
);
2723 /* Check for peer by interface */
2724 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2727 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2730 "%% Create the peer-group or interface first\n");
2731 return CMD_WARNING_CONFIG_FAILED
;
2736 if (peer_address_self_check(bgp
, &su
)) {
2738 "%% Can not configure the local system as neighbor\n");
2739 return CMD_WARNING_CONFIG_FAILED
;
2741 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2744 /* This peer belongs to peer group. */
2746 case BGP_ERR_PEER_GROUP_MEMBER
:
2748 "%% Peer-group AS %u. Cannot configure remote-as for member\n",
2750 return CMD_WARNING_CONFIG_FAILED
;
2751 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2753 "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n",
2755 return CMD_WARNING_CONFIG_FAILED
;
2757 return bgp_vty_return(vty
, ret
);
2760 DEFUN (bgp_default_shutdown
,
2761 bgp_default_shutdown_cmd
,
2762 "[no] bgp default shutdown",
2765 "Configure BGP defaults\n"
2766 "Apply administrative shutdown to newly configured peers\n")
2768 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2769 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2773 DEFUN (neighbor_remote_as
,
2774 neighbor_remote_as_cmd
,
2775 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2778 "Specify a BGP neighbor\n"
2780 "Internal BGP peer\n"
2781 "External BGP peer\n")
2784 int idx_remote_as
= 3;
2785 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2786 argv
[idx_remote_as
]->arg
, AFI_IP
,
2790 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2791 afi_t afi
, safi_t safi
, int v6only
,
2792 const char *peer_group_name
,
2795 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2797 int as_type
= AS_UNSPECIFIED
;
2799 struct peer_group
*group
;
2803 group
= peer_group_lookup(bgp
, conf_if
);
2806 vty_out(vty
, "%% Name conflict with peer-group \n");
2807 return CMD_WARNING_CONFIG_FAILED
;
2811 if (as_str
[0] == 'i') {
2812 as_type
= AS_INTERNAL
;
2813 } else if (as_str
[0] == 'e') {
2814 as_type
= AS_EXTERNAL
;
2816 /* Get AS number. */
2817 as
= strtoul(as_str
, NULL
, 10);
2818 as_type
= AS_SPECIFIED
;
2822 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2825 ret
= peer_remote_as(bgp
, &su
, conf_if
, &as
, as_type
,
2828 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2829 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2830 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2831 as_type
, 0, 0, NULL
);
2833 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2834 as_type
, afi
, safi
, NULL
);
2837 vty_out(vty
, "%% BGP failed to create peer\n");
2838 return CMD_WARNING_CONFIG_FAILED
;
2842 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2844 /* Request zebra to initiate IPv6 RAs on this interface. We do
2846 * any unnumbered peer in order to not worry about run-time
2848 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2850 * gets deleted later etc.)
2853 bgp_zebra_initiate_radv(bgp
, peer
);
2856 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2857 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2859 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2861 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2863 /* v6only flag changed. Reset bgp seesion */
2864 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2865 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2866 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2867 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2869 bgp_session_reset(peer
);
2872 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
2873 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
2874 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
2875 UNSET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
2878 if (peer_group_name
) {
2879 group
= peer_group_lookup(bgp
, peer_group_name
);
2881 vty_out(vty
, "%% Configure the peer-group first\n");
2882 return CMD_WARNING_CONFIG_FAILED
;
2885 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
2888 return bgp_vty_return(vty
, ret
);
2891 DEFUN (neighbor_interface_config
,
2892 neighbor_interface_config_cmd
,
2893 "neighbor WORD interface [peer-group WORD]",
2895 "Interface name or neighbor tag\n"
2896 "Enable BGP on interface\n"
2897 "Member of the peer-group\n"
2898 "Peer-group name\n")
2901 int idx_peer_group_word
= 4;
2903 if (argc
> idx_peer_group_word
)
2904 return peer_conf_interface_get(
2905 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
2906 argv
[idx_peer_group_word
]->arg
, NULL
);
2908 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2909 SAFI_UNICAST
, 0, NULL
, NULL
);
2912 DEFUN (neighbor_interface_config_v6only
,
2913 neighbor_interface_config_v6only_cmd
,
2914 "neighbor WORD interface v6only [peer-group WORD]",
2916 "Interface name or neighbor tag\n"
2917 "Enable BGP on interface\n"
2918 "Enable BGP with v6 link-local only\n"
2919 "Member of the peer-group\n"
2920 "Peer-group name\n")
2923 int idx_peer_group_word
= 5;
2925 if (argc
> idx_peer_group_word
)
2926 return peer_conf_interface_get(
2927 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
2928 argv
[idx_peer_group_word
]->arg
, NULL
);
2930 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2931 SAFI_UNICAST
, 1, NULL
, NULL
);
2935 DEFUN (neighbor_interface_config_remote_as
,
2936 neighbor_interface_config_remote_as_cmd
,
2937 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
2939 "Interface name or neighbor tag\n"
2940 "Enable BGP on interface\n"
2941 "Specify a BGP neighbor\n"
2943 "Internal BGP peer\n"
2944 "External BGP peer\n")
2947 int idx_remote_as
= 4;
2948 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2949 SAFI_UNICAST
, 0, NULL
,
2950 argv
[idx_remote_as
]->arg
);
2953 DEFUN (neighbor_interface_v6only_config_remote_as
,
2954 neighbor_interface_v6only_config_remote_as_cmd
,
2955 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
2957 "Interface name or neighbor tag\n"
2958 "Enable BGP with v6 link-local only\n"
2959 "Enable BGP on interface\n"
2960 "Specify a BGP neighbor\n"
2962 "Internal BGP peer\n"
2963 "External BGP peer\n")
2966 int idx_remote_as
= 5;
2967 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2968 SAFI_UNICAST
, 1, NULL
,
2969 argv
[idx_remote_as
]->arg
);
2972 DEFUN (neighbor_peer_group
,
2973 neighbor_peer_group_cmd
,
2974 "neighbor WORD peer-group",
2976 "Interface name or neighbor tag\n"
2977 "Configure peer-group\n")
2979 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2982 struct peer_group
*group
;
2984 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
2986 vty_out(vty
, "%% Name conflict with interface: \n");
2987 return CMD_WARNING_CONFIG_FAILED
;
2990 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
2992 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
2993 return CMD_WARNING_CONFIG_FAILED
;
3001 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3005 "Specify a BGP neighbor\n"
3007 "Internal BGP peer\n"
3008 "External BGP peer\n")
3010 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3014 struct peer_group
*group
;
3018 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3020 /* look up for neighbor by interface name config. */
3021 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3023 /* Request zebra to terminate IPv6 RAs on this
3026 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3031 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3033 peer_group_delete(group
);
3035 vty_out(vty
, "%% Create the peer-group first\n");
3036 return CMD_WARNING_CONFIG_FAILED
;
3039 peer
= peer_lookup(bgp
, &su
);
3041 if (peer_dynamic_neighbor(peer
)) {
3043 "%% Operation not allowed on a dynamic neighbor\n");
3044 return CMD_WARNING_CONFIG_FAILED
;
3047 other
= peer
->doppelganger
;
3049 if (other
&& other
->status
!= Deleted
)
3057 DEFUN (no_neighbor_interface_config
,
3058 no_neighbor_interface_config_cmd
,
3059 "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]",
3063 "Configure BGP on interface\n"
3064 "Enable BGP with v6 link-local only\n"
3065 "Member of the peer-group\n"
3067 "Specify a BGP neighbor\n"
3069 "Internal BGP peer\n"
3070 "External BGP peer\n")
3072 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3076 /* look up for neighbor by interface name config. */
3077 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3079 /* Request zebra to terminate IPv6 RAs on this interface. */
3081 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3084 vty_out(vty
, "%% Create the bgp interface first\n");
3085 return CMD_WARNING_CONFIG_FAILED
;
3090 DEFUN (no_neighbor_peer_group
,
3091 no_neighbor_peer_group_cmd
,
3092 "no neighbor WORD peer-group",
3096 "Configure peer-group\n")
3098 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3100 struct peer_group
*group
;
3102 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3104 peer_group_delete(group
);
3106 vty_out(vty
, "%% Create the peer-group first\n");
3107 return CMD_WARNING_CONFIG_FAILED
;
3112 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3113 no_neighbor_interface_peer_group_remote_as_cmd
,
3114 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3117 "Interface name or neighbor tag\n"
3118 "Specify a BGP neighbor\n"
3120 "Internal BGP peer\n"
3121 "External BGP peer\n")
3123 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3125 struct peer_group
*group
;
3128 /* look up for neighbor by interface name config. */
3129 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3131 peer_as_change(peer
, 0, AS_SPECIFIED
);
3135 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3137 peer_group_remote_as_delete(group
);
3139 vty_out(vty
, "%% Create the peer-group or interface first\n");
3140 return CMD_WARNING_CONFIG_FAILED
;
3145 DEFUN (neighbor_local_as
,
3146 neighbor_local_as_cmd
,
3147 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3150 "Specify a local-as number\n"
3151 "AS number used as local AS\n")
3159 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3161 return CMD_WARNING_CONFIG_FAILED
;
3163 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3164 ret
= peer_local_as_set(peer
, as
, 0, 0);
3165 return bgp_vty_return(vty
, ret
);
3168 DEFUN (neighbor_local_as_no_prepend
,
3169 neighbor_local_as_no_prepend_cmd
,
3170 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3173 "Specify a local-as number\n"
3174 "AS number used as local AS\n"
3175 "Do not prepend local-as to updates from ebgp peers\n")
3183 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3185 return CMD_WARNING_CONFIG_FAILED
;
3187 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3188 ret
= peer_local_as_set(peer
, as
, 1, 0);
3189 return bgp_vty_return(vty
, ret
);
3192 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3193 neighbor_local_as_no_prepend_replace_as_cmd
,
3194 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3197 "Specify a local-as number\n"
3198 "AS number used as local AS\n"
3199 "Do not prepend local-as to updates from ebgp peers\n"
3200 "Do not prepend local-as to updates from ibgp peers\n")
3208 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3210 return CMD_WARNING_CONFIG_FAILED
;
3212 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3213 ret
= peer_local_as_set(peer
, as
, 1, 1);
3214 return bgp_vty_return(vty
, ret
);
3217 DEFUN (no_neighbor_local_as
,
3218 no_neighbor_local_as_cmd
,
3219 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3223 "Specify a local-as number\n"
3224 "AS number used as local AS\n"
3225 "Do not prepend local-as to updates from ebgp peers\n"
3226 "Do not prepend local-as to updates from ibgp peers\n")
3232 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3234 return CMD_WARNING_CONFIG_FAILED
;
3236 ret
= peer_local_as_unset(peer
);
3237 return bgp_vty_return(vty
, ret
);
3241 DEFUN (neighbor_solo
,
3243 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3246 "Solo peer - part of its own update group\n")
3252 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3254 return CMD_WARNING_CONFIG_FAILED
;
3256 ret
= update_group_adjust_soloness(peer
, 1);
3257 return bgp_vty_return(vty
, ret
);
3260 DEFUN (no_neighbor_solo
,
3261 no_neighbor_solo_cmd
,
3262 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3266 "Solo peer - part of its own update group\n")
3272 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3274 return CMD_WARNING_CONFIG_FAILED
;
3276 ret
= update_group_adjust_soloness(peer
, 0);
3277 return bgp_vty_return(vty
, ret
);
3280 DEFUN (neighbor_password
,
3281 neighbor_password_cmd
,
3282 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3293 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3295 return CMD_WARNING_CONFIG_FAILED
;
3297 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3298 return bgp_vty_return(vty
, ret
);
3301 DEFUN (no_neighbor_password
,
3302 no_neighbor_password_cmd
,
3303 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3314 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3316 return CMD_WARNING_CONFIG_FAILED
;
3318 ret
= peer_password_unset(peer
);
3319 return bgp_vty_return(vty
, ret
);
3322 DEFUN (neighbor_activate
,
3323 neighbor_activate_cmd
,
3324 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3327 "Enable the Address Family for this Neighbor\n")
3333 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3335 return CMD_WARNING_CONFIG_FAILED
;
3337 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3338 return bgp_vty_return(vty
, ret
);
3341 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3342 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3343 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3344 "Enable the Address Family for this Neighbor\n")
3346 DEFUN (no_neighbor_activate
,
3347 no_neighbor_activate_cmd
,
3348 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3352 "Enable the Address Family for this Neighbor\n")
3359 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3361 return CMD_WARNING_CONFIG_FAILED
;
3363 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3364 return bgp_vty_return(vty
, ret
);
3367 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3368 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3369 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3370 "Enable the Address Family for this Neighbor\n")
3372 DEFUN (neighbor_set_peer_group
,
3373 neighbor_set_peer_group_cmd
,
3374 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3377 "Member of the peer-group\n"
3378 "Peer-group name\n")
3380 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3387 struct peer_group
*group
;
3389 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3391 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3393 vty_out(vty
, "%% Malformed address or name: %s\n",
3394 argv
[idx_peer
]->arg
);
3395 return CMD_WARNING_CONFIG_FAILED
;
3398 if (peer_address_self_check(bgp
, &su
)) {
3400 "%% Can not configure the local system as neighbor\n");
3401 return CMD_WARNING_CONFIG_FAILED
;
3404 /* Disallow for dynamic neighbor. */
3405 peer
= peer_lookup(bgp
, &su
);
3406 if (peer
&& peer_dynamic_neighbor(peer
)) {
3408 "%% Operation not allowed on a dynamic neighbor\n");
3409 return CMD_WARNING_CONFIG_FAILED
;
3413 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3415 vty_out(vty
, "%% Configure the peer-group first\n");
3416 return CMD_WARNING_CONFIG_FAILED
;
3419 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3421 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3423 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3425 return CMD_WARNING_CONFIG_FAILED
;
3428 return bgp_vty_return(vty
, ret
);
3431 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3432 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3433 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3434 "Member of the peer-group\n"
3435 "Peer-group name\n")
3437 DEFUN (no_neighbor_set_peer_group
,
3438 no_neighbor_set_peer_group_cmd
,
3439 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3443 "Member of the peer-group\n"
3444 "Peer-group name\n")
3446 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3451 struct peer_group
*group
;
3453 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3455 return CMD_WARNING_CONFIG_FAILED
;
3457 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3459 vty_out(vty
, "%% Configure the peer-group first\n");
3460 return CMD_WARNING_CONFIG_FAILED
;
3463 ret
= peer_delete(peer
);
3465 return bgp_vty_return(vty
, ret
);
3468 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3469 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3470 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3471 "Member of the peer-group\n"
3472 "Peer-group name\n")
3474 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3475 uint32_t flag
, int set
)
3480 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3482 return CMD_WARNING_CONFIG_FAILED
;
3485 * If 'neighbor <interface>', then this is for directly connected peers,
3486 * we should not accept disable-connected-check.
3488 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3490 "%s is directly connected peer, cannot accept disable-"
3491 "connected-check\n",
3493 return CMD_WARNING_CONFIG_FAILED
;
3496 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3497 peer_tx_shutdown_message_unset(peer
);
3500 ret
= peer_flag_set(peer
, flag
);
3502 ret
= peer_flag_unset(peer
, flag
);
3504 return bgp_vty_return(vty
, ret
);
3507 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3509 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3512 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3515 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3518 /* neighbor passive. */
3519 DEFUN (neighbor_passive
,
3520 neighbor_passive_cmd
,
3521 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3524 "Don't send open messages to this neighbor\n")
3527 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3530 DEFUN (no_neighbor_passive
,
3531 no_neighbor_passive_cmd
,
3532 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3536 "Don't send open messages to this neighbor\n")
3539 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3542 /* neighbor shutdown. */
3543 DEFUN (neighbor_shutdown_msg
,
3544 neighbor_shutdown_msg_cmd
,
3545 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3548 "Administratively shut down this neighbor\n"
3549 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3550 "Shutdown message\n")
3556 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3560 return CMD_WARNING_CONFIG_FAILED
;
3561 message
= argv_concat(argv
, argc
, 4);
3562 peer_tx_shutdown_message_set(peer
, message
);
3563 XFREE(MTYPE_TMP
, message
);
3566 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3569 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3570 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3571 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3572 "Administratively shut down this neighbor\n")
3574 DEFUN (no_neighbor_shutdown_msg
,
3575 no_neighbor_shutdown_msg_cmd
,
3576 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3580 "Administratively shut down this neighbor\n"
3581 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3582 "Shutdown message\n")
3586 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3587 PEER_FLAG_SHUTDOWN
);
3590 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3591 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3592 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3593 "Administratively shut down this neighbor\n")
3595 /* neighbor capability dynamic. */
3596 DEFUN (neighbor_capability_dynamic
,
3597 neighbor_capability_dynamic_cmd
,
3598 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3601 "Advertise capability to the peer\n"
3602 "Advertise dynamic capability to this neighbor\n")
3605 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3606 PEER_FLAG_DYNAMIC_CAPABILITY
);
3609 DEFUN (no_neighbor_capability_dynamic
,
3610 no_neighbor_capability_dynamic_cmd
,
3611 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3615 "Advertise capability to the peer\n"
3616 "Advertise dynamic capability to this neighbor\n")
3619 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3620 PEER_FLAG_DYNAMIC_CAPABILITY
);
3623 /* neighbor dont-capability-negotiate */
3624 DEFUN (neighbor_dont_capability_negotiate
,
3625 neighbor_dont_capability_negotiate_cmd
,
3626 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3629 "Do not perform capability negotiation\n")
3632 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3633 PEER_FLAG_DONT_CAPABILITY
);
3636 DEFUN (no_neighbor_dont_capability_negotiate
,
3637 no_neighbor_dont_capability_negotiate_cmd
,
3638 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3642 "Do not perform capability negotiation\n")
3645 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3646 PEER_FLAG_DONT_CAPABILITY
);
3649 /* neighbor capability extended next hop encoding */
3650 DEFUN (neighbor_capability_enhe
,
3651 neighbor_capability_enhe_cmd
,
3652 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3655 "Advertise capability to the peer\n"
3656 "Advertise extended next-hop capability to the peer\n")
3659 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3660 PEER_FLAG_CAPABILITY_ENHE
);
3663 DEFUN (no_neighbor_capability_enhe
,
3664 no_neighbor_capability_enhe_cmd
,
3665 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3669 "Advertise capability to the peer\n"
3670 "Advertise extended next-hop capability to the peer\n")
3673 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3674 PEER_FLAG_CAPABILITY_ENHE
);
3677 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3678 afi_t afi
, safi_t safi
, uint32_t flag
,
3684 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3686 return CMD_WARNING_CONFIG_FAILED
;
3689 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3691 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3693 return bgp_vty_return(vty
, ret
);
3696 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3697 afi_t afi
, safi_t safi
, uint32_t flag
)
3699 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3702 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3703 afi_t afi
, safi_t safi
, uint32_t flag
)
3705 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3708 /* neighbor capability orf prefix-list. */
3709 DEFUN (neighbor_capability_orf_prefix
,
3710 neighbor_capability_orf_prefix_cmd
,
3711 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3714 "Advertise capability to the peer\n"
3715 "Advertise ORF capability to the peer\n"
3716 "Advertise prefixlist ORF capability to this neighbor\n"
3717 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3718 "Capability to RECEIVE the ORF from this neighbor\n"
3719 "Capability to SEND the ORF to this neighbor\n")
3722 int idx_send_recv
= 5;
3725 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3726 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3727 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3728 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3729 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3730 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3732 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3733 return CMD_WARNING_CONFIG_FAILED
;
3736 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3737 bgp_node_safi(vty
), flag
);
3741 neighbor_capability_orf_prefix
,
3742 neighbor_capability_orf_prefix_hidden_cmd
,
3743 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3744 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3745 "Advertise capability to the peer\n"
3746 "Advertise ORF capability to the peer\n"
3747 "Advertise prefixlist ORF capability to this neighbor\n"
3748 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3749 "Capability to RECEIVE the ORF from this neighbor\n"
3750 "Capability to SEND the ORF to this neighbor\n")
3752 DEFUN (no_neighbor_capability_orf_prefix
,
3753 no_neighbor_capability_orf_prefix_cmd
,
3754 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3758 "Advertise capability to the peer\n"
3759 "Advertise ORF capability to the peer\n"
3760 "Advertise prefixlist ORF capability to this neighbor\n"
3761 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3762 "Capability to RECEIVE the ORF from this neighbor\n"
3763 "Capability to SEND the ORF to this neighbor\n")
3766 int idx_send_recv
= 6;
3769 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3770 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3771 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3772 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3773 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3774 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3776 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3777 return CMD_WARNING_CONFIG_FAILED
;
3780 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3781 bgp_node_afi(vty
), bgp_node_safi(vty
),
3786 no_neighbor_capability_orf_prefix
,
3787 no_neighbor_capability_orf_prefix_hidden_cmd
,
3788 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3789 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3790 "Advertise capability to the peer\n"
3791 "Advertise ORF capability to the peer\n"
3792 "Advertise prefixlist ORF capability to this neighbor\n"
3793 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3794 "Capability to RECEIVE the ORF from this neighbor\n"
3795 "Capability to SEND the ORF to this neighbor\n")
3797 /* neighbor next-hop-self. */
3798 DEFUN (neighbor_nexthop_self
,
3799 neighbor_nexthop_self_cmd
,
3800 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3803 "Disable the next hop calculation for this neighbor\n")
3806 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3807 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3810 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3811 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3812 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3813 "Disable the next hop calculation for this neighbor\n")
3815 /* neighbor next-hop-self. */
3816 DEFUN (neighbor_nexthop_self_force
,
3817 neighbor_nexthop_self_force_cmd
,
3818 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3821 "Disable the next hop calculation for this neighbor\n"
3822 "Set the next hop to self for reflected routes\n")
3825 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3827 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3830 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3831 neighbor_nexthop_self_force_hidden_cmd
,
3832 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3833 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3834 "Disable the next hop calculation for this neighbor\n"
3835 "Set the next hop to self for reflected routes\n")
3837 DEFUN (no_neighbor_nexthop_self
,
3838 no_neighbor_nexthop_self_cmd
,
3839 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3843 "Disable the next hop calculation for this neighbor\n")
3846 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3847 bgp_node_afi(vty
), bgp_node_safi(vty
),
3848 PEER_FLAG_NEXTHOP_SELF
);
3851 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3852 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3853 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3854 "Disable the next hop calculation for this neighbor\n")
3856 DEFUN (no_neighbor_nexthop_self_force
,
3857 no_neighbor_nexthop_self_force_cmd
,
3858 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3862 "Disable the next hop calculation for this neighbor\n"
3863 "Set the next hop to self for reflected routes\n")
3866 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3867 bgp_node_afi(vty
), bgp_node_safi(vty
),
3868 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3871 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3872 no_neighbor_nexthop_self_force_hidden_cmd
,
3873 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3874 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3875 "Disable the next hop calculation for this neighbor\n"
3876 "Set the next hop to self for reflected routes\n")
3878 /* neighbor as-override */
3879 DEFUN (neighbor_as_override
,
3880 neighbor_as_override_cmd
,
3881 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3884 "Override ASNs in outbound updates if aspath equals remote-as\n")
3887 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3888 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
3891 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
3892 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3893 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3894 "Override ASNs in outbound updates if aspath equals remote-as\n")
3896 DEFUN (no_neighbor_as_override
,
3897 no_neighbor_as_override_cmd
,
3898 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3902 "Override ASNs in outbound updates if aspath equals remote-as\n")
3905 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3906 bgp_node_afi(vty
), bgp_node_safi(vty
),
3907 PEER_FLAG_AS_OVERRIDE
);
3910 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
3911 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3912 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3913 "Override ASNs in outbound updates if aspath equals remote-as\n")
3915 /* neighbor remove-private-AS. */
3916 DEFUN (neighbor_remove_private_as
,
3917 neighbor_remove_private_as_cmd
,
3918 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3921 "Remove private ASNs in outbound updates\n")
3924 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3926 PEER_FLAG_REMOVE_PRIVATE_AS
);
3929 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
3930 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3931 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3932 "Remove private ASNs in outbound updates\n")
3934 DEFUN (neighbor_remove_private_as_all
,
3935 neighbor_remove_private_as_all_cmd
,
3936 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3939 "Remove private ASNs in outbound updates\n"
3940 "Apply to all AS numbers\n")
3943 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3945 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
3948 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
3949 neighbor_remove_private_as_all_hidden_cmd
,
3950 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3951 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3952 "Remove private ASNs in outbound updates\n"
3953 "Apply to all AS numbers")
3955 DEFUN (neighbor_remove_private_as_replace_as
,
3956 neighbor_remove_private_as_replace_as_cmd
,
3957 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3960 "Remove private ASNs in outbound updates\n"
3961 "Replace private ASNs with our ASN in outbound updates\n")
3964 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3966 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
3969 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
3970 neighbor_remove_private_as_replace_as_hidden_cmd
,
3971 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3972 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3973 "Remove private ASNs in outbound updates\n"
3974 "Replace private ASNs with our ASN in outbound updates\n")
3976 DEFUN (neighbor_remove_private_as_all_replace_as
,
3977 neighbor_remove_private_as_all_replace_as_cmd
,
3978 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3981 "Remove private ASNs in outbound updates\n"
3982 "Apply to all AS numbers\n"
3983 "Replace private ASNs with our ASN in outbound updates\n")
3986 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3988 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
3992 neighbor_remove_private_as_all_replace_as
,
3993 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
3994 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3995 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3996 "Remove private ASNs in outbound updates\n"
3997 "Apply to all AS numbers\n"
3998 "Replace private ASNs with our ASN in outbound updates\n")
4000 DEFUN (no_neighbor_remove_private_as
,
4001 no_neighbor_remove_private_as_cmd
,
4002 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4006 "Remove private ASNs in outbound updates\n")
4009 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4010 bgp_node_afi(vty
), bgp_node_safi(vty
),
4011 PEER_FLAG_REMOVE_PRIVATE_AS
);
4014 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4015 no_neighbor_remove_private_as_hidden_cmd
,
4016 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4017 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4018 "Remove private ASNs in outbound updates\n")
4020 DEFUN (no_neighbor_remove_private_as_all
,
4021 no_neighbor_remove_private_as_all_cmd
,
4022 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4026 "Remove private ASNs in outbound updates\n"
4027 "Apply to all AS numbers\n")
4030 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4031 bgp_node_afi(vty
), bgp_node_safi(vty
),
4032 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4035 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4036 no_neighbor_remove_private_as_all_hidden_cmd
,
4037 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4038 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4039 "Remove private ASNs in outbound updates\n"
4040 "Apply to all AS numbers\n")
4042 DEFUN (no_neighbor_remove_private_as_replace_as
,
4043 no_neighbor_remove_private_as_replace_as_cmd
,
4044 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4048 "Remove private ASNs in outbound updates\n"
4049 "Replace private ASNs with our ASN in outbound updates\n")
4052 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4053 bgp_node_afi(vty
), bgp_node_safi(vty
),
4054 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4057 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4058 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4059 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4060 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4061 "Remove private ASNs in outbound updates\n"
4062 "Replace private ASNs with our ASN in outbound updates\n")
4064 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4065 no_neighbor_remove_private_as_all_replace_as_cmd
,
4066 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4070 "Remove private ASNs in outbound updates\n"
4071 "Apply to all AS numbers\n"
4072 "Replace private ASNs with our ASN in outbound updates\n")
4075 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4076 bgp_node_afi(vty
), bgp_node_safi(vty
),
4077 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4081 no_neighbor_remove_private_as_all_replace_as
,
4082 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4083 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4084 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4085 "Remove private ASNs in outbound updates\n"
4086 "Apply to all AS numbers\n"
4087 "Replace private ASNs with our ASN in outbound updates\n")
4090 /* neighbor send-community. */
4091 DEFUN (neighbor_send_community
,
4092 neighbor_send_community_cmd
,
4093 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4096 "Send Community attribute to this neighbor\n")
4100 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4102 PEER_FLAG_SEND_COMMUNITY
);
4105 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4106 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4107 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4108 "Send Community attribute to this neighbor\n")
4110 DEFUN (no_neighbor_send_community
,
4111 no_neighbor_send_community_cmd
,
4112 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4116 "Send Community attribute to this neighbor\n")
4120 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4121 bgp_node_afi(vty
), bgp_node_safi(vty
),
4122 PEER_FLAG_SEND_COMMUNITY
);
4125 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4126 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4127 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4128 "Send Community attribute to this neighbor\n")
4130 /* neighbor send-community extended. */
4131 DEFUN (neighbor_send_community_type
,
4132 neighbor_send_community_type_cmd
,
4133 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4136 "Send Community attribute to this neighbor\n"
4137 "Send Standard and Extended Community attributes\n"
4138 "Send Standard, Large and Extended Community attributes\n"
4139 "Send Extended Community attributes\n"
4140 "Send Standard Community attributes\n"
4141 "Send Large Community attributes\n")
4145 const char *type
= argv
[argc
- 1]->text
;
4147 if (strmatch(type
, "standard")) {
4148 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4149 } else if (strmatch(type
, "extended")) {
4150 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4151 } else if (strmatch(type
, "large")) {
4152 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4153 } else if (strmatch(type
, "both")) {
4154 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4155 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4156 } else { /* if (strmatch(type, "all")) */
4157 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4158 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4159 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4162 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4163 bgp_node_safi(vty
), flag
);
4167 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4168 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4169 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4170 "Send Community attribute to this neighbor\n"
4171 "Send Standard and Extended Community attributes\n"
4172 "Send Standard, Large and Extended Community attributes\n"
4173 "Send Extended Community attributes\n"
4174 "Send Standard Community attributes\n"
4175 "Send Large Community attributes\n")
4177 DEFUN (no_neighbor_send_community_type
,
4178 no_neighbor_send_community_type_cmd
,
4179 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4183 "Send Community attribute to this neighbor\n"
4184 "Send Standard and Extended Community attributes\n"
4185 "Send Standard, Large and Extended Community attributes\n"
4186 "Send Extended Community attributes\n"
4187 "Send Standard Community attributes\n"
4188 "Send Large Community attributes\n")
4192 const char *type
= argv
[argc
- 1]->text
;
4194 if (strmatch(type
, "standard")) {
4195 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4196 } else if (strmatch(type
, "extended")) {
4197 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4198 } else if (strmatch(type
, "large")) {
4199 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4200 } else if (strmatch(type
, "both")) {
4201 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4202 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4203 } else { /* if (strmatch(type, "all")) */
4204 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4205 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4206 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4209 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4210 bgp_node_afi(vty
), bgp_node_safi(vty
),
4215 no_neighbor_send_community_type
,
4216 no_neighbor_send_community_type_hidden_cmd
,
4217 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4218 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4219 "Send Community attribute to this neighbor\n"
4220 "Send Standard and Extended Community attributes\n"
4221 "Send Standard, Large and Extended Community attributes\n"
4222 "Send Extended Community attributes\n"
4223 "Send Standard Community attributes\n"
4224 "Send Large Community attributes\n")
4226 /* neighbor soft-reconfig. */
4227 DEFUN (neighbor_soft_reconfiguration
,
4228 neighbor_soft_reconfiguration_cmd
,
4229 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4232 "Per neighbor soft reconfiguration\n"
4233 "Allow inbound soft reconfiguration for this neighbor\n")
4236 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4238 PEER_FLAG_SOFT_RECONFIG
);
4241 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4242 neighbor_soft_reconfiguration_hidden_cmd
,
4243 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4244 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4245 "Per neighbor soft reconfiguration\n"
4246 "Allow inbound soft reconfiguration for this neighbor\n")
4248 DEFUN (no_neighbor_soft_reconfiguration
,
4249 no_neighbor_soft_reconfiguration_cmd
,
4250 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4254 "Per neighbor soft reconfiguration\n"
4255 "Allow inbound soft reconfiguration for this neighbor\n")
4258 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4259 bgp_node_afi(vty
), bgp_node_safi(vty
),
4260 PEER_FLAG_SOFT_RECONFIG
);
4263 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4264 no_neighbor_soft_reconfiguration_hidden_cmd
,
4265 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4266 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4267 "Per neighbor soft reconfiguration\n"
4268 "Allow inbound soft reconfiguration for this neighbor\n")
4270 DEFUN (neighbor_route_reflector_client
,
4271 neighbor_route_reflector_client_cmd
,
4272 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4275 "Configure a neighbor as Route Reflector client\n")
4281 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4283 return CMD_WARNING_CONFIG_FAILED
;
4285 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4287 PEER_FLAG_REFLECTOR_CLIENT
);
4290 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4291 neighbor_route_reflector_client_hidden_cmd
,
4292 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4293 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4294 "Configure a neighbor as Route Reflector client\n")
4296 DEFUN (no_neighbor_route_reflector_client
,
4297 no_neighbor_route_reflector_client_cmd
,
4298 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4302 "Configure a neighbor as Route Reflector client\n")
4305 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4306 bgp_node_afi(vty
), bgp_node_safi(vty
),
4307 PEER_FLAG_REFLECTOR_CLIENT
);
4310 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4311 no_neighbor_route_reflector_client_hidden_cmd
,
4312 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4313 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4314 "Configure a neighbor as Route Reflector client\n")
4316 /* neighbor route-server-client. */
4317 DEFUN (neighbor_route_server_client
,
4318 neighbor_route_server_client_cmd
,
4319 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4322 "Configure a neighbor as Route Server client\n")
4327 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4329 return CMD_WARNING_CONFIG_FAILED
;
4330 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4332 PEER_FLAG_RSERVER_CLIENT
);
4335 ALIAS_HIDDEN(neighbor_route_server_client
,
4336 neighbor_route_server_client_hidden_cmd
,
4337 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4338 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4339 "Configure a neighbor as Route Server client\n")
4341 DEFUN (no_neighbor_route_server_client
,
4342 no_neighbor_route_server_client_cmd
,
4343 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4347 "Configure a neighbor as Route Server client\n")
4350 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4351 bgp_node_afi(vty
), bgp_node_safi(vty
),
4352 PEER_FLAG_RSERVER_CLIENT
);
4355 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4356 no_neighbor_route_server_client_hidden_cmd
,
4357 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4358 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4359 "Configure a neighbor as Route Server client\n")
4361 DEFUN (neighbor_nexthop_local_unchanged
,
4362 neighbor_nexthop_local_unchanged_cmd
,
4363 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4366 "Configure treatment of outgoing link-local nexthop attribute\n"
4367 "Leave link-local nexthop unchanged for this peer\n")
4370 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4372 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4375 DEFUN (no_neighbor_nexthop_local_unchanged
,
4376 no_neighbor_nexthop_local_unchanged_cmd
,
4377 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4381 "Configure treatment of outgoing link-local-nexthop attribute\n"
4382 "Leave link-local nexthop unchanged for this peer\n")
4385 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4386 bgp_node_afi(vty
), bgp_node_safi(vty
),
4387 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4390 DEFUN (neighbor_attr_unchanged
,
4391 neighbor_attr_unchanged_cmd
,
4392 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4395 "BGP attribute is propagated unchanged to this neighbor\n"
4396 "As-path attribute\n"
4397 "Nexthop attribute\n"
4401 char *peer_str
= argv
[1]->arg
;
4404 afi_t afi
= bgp_node_afi(vty
);
4405 safi_t safi
= bgp_node_safi(vty
);
4407 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4409 return CMD_WARNING_CONFIG_FAILED
;
4411 if (argv_find(argv
, argc
, "as-path", &idx
))
4412 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4414 if (argv_find(argv
, argc
, "next-hop", &idx
))
4415 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4417 if (argv_find(argv
, argc
, "med", &idx
))
4418 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4420 /* no flags means all of them! */
4422 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4423 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4424 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4426 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4427 && peer_af_flag_check(peer
, afi
, safi
,
4428 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4429 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4430 PEER_FLAG_AS_PATH_UNCHANGED
);
4433 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4434 && peer_af_flag_check(peer
, afi
, safi
,
4435 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4436 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4437 PEER_FLAG_NEXTHOP_UNCHANGED
);
4440 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4441 && peer_af_flag_check(peer
, afi
, safi
,
4442 PEER_FLAG_MED_UNCHANGED
)) {
4443 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4444 PEER_FLAG_MED_UNCHANGED
);
4448 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4452 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4453 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4454 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4455 "BGP attribute is propagated unchanged to this neighbor\n"
4456 "As-path attribute\n"
4457 "Nexthop attribute\n"
4460 DEFUN (no_neighbor_attr_unchanged
,
4461 no_neighbor_attr_unchanged_cmd
,
4462 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4466 "BGP attribute is propagated unchanged to this neighbor\n"
4467 "As-path attribute\n"
4468 "Nexthop attribute\n"
4472 char *peer
= argv
[2]->arg
;
4475 if (argv_find(argv
, argc
, "as-path", &idx
))
4476 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4478 if (argv_find(argv
, argc
, "next-hop", &idx
))
4479 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4481 if (argv_find(argv
, argc
, "med", &idx
))
4482 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4484 if (!flags
) // no flags means all of them!
4486 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4487 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4488 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4491 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4492 bgp_node_safi(vty
), flags
);
4496 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4497 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4498 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4499 "BGP attribute is propagated unchanged to this neighbor\n"
4500 "As-path attribute\n"
4501 "Nexthop attribute\n"
4504 /* EBGP multihop configuration. */
4505 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4506 const char *ttl_str
)
4511 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4513 return CMD_WARNING_CONFIG_FAILED
;
4516 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4521 ttl
= strtoul(ttl_str
, NULL
, 10);
4523 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4526 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4530 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4532 return CMD_WARNING_CONFIG_FAILED
;
4534 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4537 /* neighbor ebgp-multihop. */
4538 DEFUN (neighbor_ebgp_multihop
,
4539 neighbor_ebgp_multihop_cmd
,
4540 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4543 "Allow EBGP neighbors not on directly connected networks\n")
4546 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4549 DEFUN (neighbor_ebgp_multihop_ttl
,
4550 neighbor_ebgp_multihop_ttl_cmd
,
4551 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4554 "Allow EBGP neighbors not on directly connected networks\n"
4555 "maximum hop count\n")
4559 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4560 argv
[idx_number
]->arg
);
4563 DEFUN (no_neighbor_ebgp_multihop
,
4564 no_neighbor_ebgp_multihop_cmd
,
4565 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4569 "Allow EBGP neighbors not on directly connected networks\n"
4570 "maximum hop count\n")
4573 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4577 /* disable-connected-check */
4578 DEFUN (neighbor_disable_connected_check
,
4579 neighbor_disable_connected_check_cmd
,
4580 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4583 "one-hop away EBGP peer using loopback address\n"
4584 "Enforce EBGP neighbors perform multihop\n")
4587 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4588 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4591 DEFUN (no_neighbor_disable_connected_check
,
4592 no_neighbor_disable_connected_check_cmd
,
4593 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4597 "one-hop away EBGP peer using loopback address\n"
4598 "Enforce EBGP neighbors perform multihop\n")
4601 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4602 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4606 /* enforce-first-as */
4607 DEFUN (neighbor_enforce_first_as
,
4608 neighbor_enforce_first_as_cmd
,
4609 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4612 "Enforce the first AS for EBGP routes\n")
4616 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4617 PEER_FLAG_ENFORCE_FIRST_AS
);
4620 DEFUN (no_neighbor_enforce_first_as
,
4621 no_neighbor_enforce_first_as_cmd
,
4622 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4626 "Enforce the first AS for EBGP routes\n")
4630 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4631 PEER_FLAG_ENFORCE_FIRST_AS
);
4635 DEFUN (neighbor_description
,
4636 neighbor_description_cmd
,
4637 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4640 "Neighbor specific description\n"
4641 "Up to 80 characters describing this neighbor\n")
4648 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4650 return CMD_WARNING_CONFIG_FAILED
;
4652 str
= argv_concat(argv
, argc
, idx_line
);
4654 peer_description_set(peer
, str
);
4656 XFREE(MTYPE_TMP
, str
);
4661 DEFUN (no_neighbor_description
,
4662 no_neighbor_description_cmd
,
4663 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4667 "Neighbor specific description\n")
4672 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4674 return CMD_WARNING_CONFIG_FAILED
;
4676 peer_description_unset(peer
);
4681 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4682 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4683 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4684 "Neighbor specific description\n"
4685 "Up to 80 characters describing this neighbor\n")
4687 /* Neighbor update-source. */
4688 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4689 const char *source_str
)
4695 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4697 return CMD_WARNING_CONFIG_FAILED
;
4703 if (str2sockunion(source_str
, &su
) == 0)
4704 peer_update_source_addr_set(peer
, &su
);
4706 if (str2prefix(source_str
, &p
)) {
4708 "%% Invalid update-source, remove prefix length \n");
4709 return CMD_WARNING_CONFIG_FAILED
;
4711 peer_update_source_if_set(peer
, source_str
);
4714 peer_update_source_unset(peer
);
4719 #define BGP_UPDATE_SOURCE_HELP_STR \
4722 "Interface name (requires zebra to be running)\n"
4724 DEFUN (neighbor_update_source
,
4725 neighbor_update_source_cmd
,
4726 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4729 "Source of routing updates\n"
4730 BGP_UPDATE_SOURCE_HELP_STR
)
4734 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4735 argv
[idx_peer_2
]->arg
);
4738 DEFUN (no_neighbor_update_source
,
4739 no_neighbor_update_source_cmd
,
4740 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4744 "Source of routing updates\n"
4745 BGP_UPDATE_SOURCE_HELP_STR
)
4748 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4751 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4752 afi_t afi
, safi_t safi
,
4753 const char *rmap
, int set
)
4758 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4760 return CMD_WARNING_CONFIG_FAILED
;
4763 ret
= peer_default_originate_set(peer
, afi
, safi
, rmap
);
4765 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4767 return bgp_vty_return(vty
, ret
);
4770 /* neighbor default-originate. */
4771 DEFUN (neighbor_default_originate
,
4772 neighbor_default_originate_cmd
,
4773 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4776 "Originate default route to this neighbor\n")
4779 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4781 bgp_node_safi(vty
), NULL
, 1);
4784 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4785 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4786 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4787 "Originate default route to this neighbor\n")
4789 DEFUN (neighbor_default_originate_rmap
,
4790 neighbor_default_originate_rmap_cmd
,
4791 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4794 "Originate default route to this neighbor\n"
4795 "Route-map to specify criteria to originate default\n"
4800 return peer_default_originate_set_vty(
4801 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4802 argv
[idx_word
]->arg
, 1);
4806 neighbor_default_originate_rmap
,
4807 neighbor_default_originate_rmap_hidden_cmd
,
4808 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4809 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4810 "Originate default route to this neighbor\n"
4811 "Route-map to specify criteria to originate default\n"
4814 DEFUN (no_neighbor_default_originate
,
4815 no_neighbor_default_originate_cmd
,
4816 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4820 "Originate default route to this neighbor\n"
4821 "Route-map to specify criteria to originate default\n"
4825 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4827 bgp_node_safi(vty
), NULL
, 0);
4831 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4832 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4833 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4834 "Originate default route to this neighbor\n"
4835 "Route-map to specify criteria to originate default\n"
4839 /* Set neighbor's BGP port. */
4840 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4841 const char *port_str
)
4847 peer
= peer_lookup_vty(vty
, ip_str
);
4849 return CMD_WARNING_CONFIG_FAILED
;
4852 sp
= getservbyname("bgp", "tcp");
4853 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
4855 port
= strtoul(port_str
, NULL
, 10);
4858 peer_port_set(peer
, port
);
4863 /* Set specified peer's BGP port. */
4864 DEFUN (neighbor_port
,
4866 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
4869 "Neighbor's BGP port\n"
4870 "TCP port number\n")
4874 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
4875 argv
[idx_number
]->arg
);
4878 DEFUN (no_neighbor_port
,
4879 no_neighbor_port_cmd
,
4880 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
4884 "Neighbor's BGP port\n"
4885 "TCP port number\n")
4888 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
4892 /* neighbor weight. */
4893 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4894 safi_t safi
, const char *weight_str
)
4898 unsigned long weight
;
4900 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4902 return CMD_WARNING_CONFIG_FAILED
;
4904 weight
= strtoul(weight_str
, NULL
, 10);
4906 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
4907 return bgp_vty_return(vty
, ret
);
4910 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4916 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4918 return CMD_WARNING_CONFIG_FAILED
;
4920 ret
= peer_weight_unset(peer
, afi
, safi
);
4921 return bgp_vty_return(vty
, ret
);
4924 DEFUN (neighbor_weight
,
4925 neighbor_weight_cmd
,
4926 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4929 "Set default weight for routes from this neighbor\n"
4934 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4935 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
4938 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
4939 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4940 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4941 "Set default weight for routes from this neighbor\n"
4944 DEFUN (no_neighbor_weight
,
4945 no_neighbor_weight_cmd
,
4946 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4950 "Set default weight for routes from this neighbor\n"
4954 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
4955 bgp_node_afi(vty
), bgp_node_safi(vty
));
4958 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
4959 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4960 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4961 "Set default weight for routes from this neighbor\n"
4965 /* Override capability negotiation. */
4966 DEFUN (neighbor_override_capability
,
4967 neighbor_override_capability_cmd
,
4968 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4971 "Override capability negotiation result\n")
4974 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4975 PEER_FLAG_OVERRIDE_CAPABILITY
);
4978 DEFUN (no_neighbor_override_capability
,
4979 no_neighbor_override_capability_cmd
,
4980 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4984 "Override capability negotiation result\n")
4987 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4988 PEER_FLAG_OVERRIDE_CAPABILITY
);
4991 DEFUN (neighbor_strict_capability
,
4992 neighbor_strict_capability_cmd
,
4993 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
4996 "Strict capability negotiation match\n")
5000 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5001 PEER_FLAG_STRICT_CAP_MATCH
);
5004 DEFUN (no_neighbor_strict_capability
,
5005 no_neighbor_strict_capability_cmd
,
5006 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5010 "Strict capability negotiation match\n")
5014 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5015 PEER_FLAG_STRICT_CAP_MATCH
);
5018 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5019 const char *keep_str
, const char *hold_str
)
5026 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5028 return CMD_WARNING_CONFIG_FAILED
;
5030 keepalive
= strtoul(keep_str
, NULL
, 10);
5031 holdtime
= strtoul(hold_str
, NULL
, 10);
5033 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5035 return bgp_vty_return(vty
, ret
);
5038 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5043 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5045 return CMD_WARNING_CONFIG_FAILED
;
5047 ret
= peer_timers_unset(peer
);
5049 return bgp_vty_return(vty
, ret
);
5052 DEFUN (neighbor_timers
,
5053 neighbor_timers_cmd
,
5054 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5057 "BGP per neighbor timers\n"
5058 "Keepalive interval\n"
5063 int idx_number_2
= 4;
5064 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5065 argv
[idx_number
]->arg
,
5066 argv
[idx_number_2
]->arg
);
5069 DEFUN (no_neighbor_timers
,
5070 no_neighbor_timers_cmd
,
5071 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5075 "BGP per neighbor timers\n"
5076 "Keepalive interval\n"
5080 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5084 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5085 const char *time_str
)
5091 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5093 return CMD_WARNING_CONFIG_FAILED
;
5095 connect
= strtoul(time_str
, NULL
, 10);
5097 ret
= peer_timers_connect_set(peer
, connect
);
5099 return bgp_vty_return(vty
, ret
);
5102 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5107 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5109 return CMD_WARNING_CONFIG_FAILED
;
5111 ret
= peer_timers_connect_unset(peer
);
5113 return bgp_vty_return(vty
, ret
);
5116 DEFUN (neighbor_timers_connect
,
5117 neighbor_timers_connect_cmd
,
5118 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5121 "BGP per neighbor timers\n"
5122 "BGP connect timer\n"
5127 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5128 argv
[idx_number
]->arg
);
5131 DEFUN (no_neighbor_timers_connect
,
5132 no_neighbor_timers_connect_cmd
,
5133 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5137 "BGP per neighbor timers\n"
5138 "BGP connect timer\n"
5142 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5146 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5147 const char *time_str
, int set
)
5151 uint32_t routeadv
= 0;
5153 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5155 return CMD_WARNING_CONFIG_FAILED
;
5158 routeadv
= strtoul(time_str
, NULL
, 10);
5161 ret
= peer_advertise_interval_set(peer
, routeadv
);
5163 ret
= peer_advertise_interval_unset(peer
);
5165 return bgp_vty_return(vty
, ret
);
5168 DEFUN (neighbor_advertise_interval
,
5169 neighbor_advertise_interval_cmd
,
5170 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5173 "Minimum interval between sending BGP routing updates\n"
5174 "time in seconds\n")
5178 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5179 argv
[idx_number
]->arg
, 1);
5182 DEFUN (no_neighbor_advertise_interval
,
5183 no_neighbor_advertise_interval_cmd
,
5184 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5188 "Minimum interval between sending BGP routing updates\n"
5189 "time in seconds\n")
5192 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5196 /* Time to wait before processing route-map updates */
5197 DEFUN (bgp_set_route_map_delay_timer
,
5198 bgp_set_route_map_delay_timer_cmd
,
5199 "bgp route-map delay-timer (0-600)",
5201 "BGP route-map delay timer\n"
5202 "Time in secs to wait before processing route-map changes\n"
5203 "0 disables the timer, no route updates happen when route-maps change\n")
5206 uint32_t rmap_delay_timer
;
5208 if (argv
[idx_number
]->arg
) {
5209 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5210 bm
->rmap_update_timer
= rmap_delay_timer
;
5212 /* if the dynamic update handling is being disabled, and a timer
5214 * running, stop the timer and act as if the timer has already
5217 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5218 BGP_TIMER_OFF(bm
->t_rmap_update
);
5219 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5224 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5225 return CMD_WARNING_CONFIG_FAILED
;
5229 DEFUN (no_bgp_set_route_map_delay_timer
,
5230 no_bgp_set_route_map_delay_timer_cmd
,
5231 "no bgp route-map delay-timer [(0-600)]",
5234 "Default BGP route-map delay timer\n"
5235 "Reset to default time to wait for processing route-map changes\n"
5236 "0 disables the timer, no route updates happen when route-maps change\n")
5239 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5245 /* neighbor interface */
5246 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5251 peer
= peer_lookup_vty(vty
, ip_str
);
5252 if (!peer
|| peer
->conf_if
) {
5253 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5254 return CMD_WARNING_CONFIG_FAILED
;
5258 peer_interface_set(peer
, str
);
5260 peer_interface_unset(peer
);
5265 DEFUN (neighbor_interface
,
5266 neighbor_interface_cmd
,
5267 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5275 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5278 DEFUN (no_neighbor_interface
,
5279 no_neighbor_interface_cmd
,
5280 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5288 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5291 DEFUN (neighbor_distribute_list
,
5292 neighbor_distribute_list_cmd
,
5293 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5296 "Filter updates to/from this neighbor\n"
5297 "IP access-list number\n"
5298 "IP access-list number (expanded range)\n"
5299 "IP Access-list name\n"
5300 "Filter incoming updates\n"
5301 "Filter outgoing updates\n")
5308 const char *pstr
= argv
[idx_peer
]->arg
;
5309 const char *acl
= argv
[idx_acl
]->arg
;
5310 const char *inout
= argv
[argc
- 1]->text
;
5312 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5314 return CMD_WARNING_CONFIG_FAILED
;
5316 /* Check filter direction. */
5317 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5318 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5321 return bgp_vty_return(vty
, ret
);
5325 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5326 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5327 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5328 "Filter updates to/from this neighbor\n"
5329 "IP access-list number\n"
5330 "IP access-list number (expanded range)\n"
5331 "IP Access-list name\n"
5332 "Filter incoming updates\n"
5333 "Filter outgoing updates\n")
5335 DEFUN (no_neighbor_distribute_list
,
5336 no_neighbor_distribute_list_cmd
,
5337 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5341 "Filter updates to/from this neighbor\n"
5342 "IP access-list number\n"
5343 "IP access-list number (expanded range)\n"
5344 "IP Access-list name\n"
5345 "Filter incoming updates\n"
5346 "Filter outgoing updates\n")
5352 const char *pstr
= argv
[idx_peer
]->arg
;
5353 const char *inout
= argv
[argc
- 1]->text
;
5355 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5357 return CMD_WARNING_CONFIG_FAILED
;
5359 /* Check filter direction. */
5360 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5361 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5364 return bgp_vty_return(vty
, ret
);
5368 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5369 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5370 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5371 "Filter updates to/from this neighbor\n"
5372 "IP access-list number\n"
5373 "IP access-list number (expanded range)\n"
5374 "IP Access-list name\n"
5375 "Filter incoming updates\n"
5376 "Filter outgoing updates\n")
5378 /* Set prefix list to the peer. */
5379 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5380 afi_t afi
, safi_t safi
,
5381 const char *name_str
,
5382 const char *direct_str
)
5385 int direct
= FILTER_IN
;
5388 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5390 return CMD_WARNING_CONFIG_FAILED
;
5392 /* Check filter direction. */
5393 if (strncmp(direct_str
, "i", 1) == 0)
5395 else if (strncmp(direct_str
, "o", 1) == 0)
5396 direct
= FILTER_OUT
;
5398 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5400 return bgp_vty_return(vty
, ret
);
5403 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5404 afi_t afi
, safi_t safi
,
5405 const char *direct_str
)
5409 int direct
= FILTER_IN
;
5411 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5413 return CMD_WARNING_CONFIG_FAILED
;
5415 /* Check filter direction. */
5416 if (strncmp(direct_str
, "i", 1) == 0)
5418 else if (strncmp(direct_str
, "o", 1) == 0)
5419 direct
= FILTER_OUT
;
5421 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5423 return bgp_vty_return(vty
, ret
);
5426 DEFUN (neighbor_prefix_list
,
5427 neighbor_prefix_list_cmd
,
5428 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5431 "Filter updates to/from this neighbor\n"
5432 "Name of a prefix list\n"
5433 "Filter incoming updates\n"
5434 "Filter outgoing updates\n")
5439 return peer_prefix_list_set_vty(
5440 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5441 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5444 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5445 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5446 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5447 "Filter updates to/from this neighbor\n"
5448 "Name of a prefix list\n"
5449 "Filter incoming updates\n"
5450 "Filter outgoing updates\n")
5452 DEFUN (no_neighbor_prefix_list
,
5453 no_neighbor_prefix_list_cmd
,
5454 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5458 "Filter updates to/from this neighbor\n"
5459 "Name of a prefix list\n"
5460 "Filter incoming updates\n"
5461 "Filter outgoing updates\n")
5465 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5466 bgp_node_afi(vty
), bgp_node_safi(vty
),
5467 argv
[idx_in_out
]->arg
);
5470 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5471 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5472 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5473 "Filter updates to/from this neighbor\n"
5474 "Name of a prefix list\n"
5475 "Filter incoming updates\n"
5476 "Filter outgoing updates\n")
5478 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5479 safi_t safi
, const char *name_str
,
5480 const char *direct_str
)
5484 int direct
= FILTER_IN
;
5486 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5488 return CMD_WARNING_CONFIG_FAILED
;
5490 /* Check filter direction. */
5491 if (strncmp(direct_str
, "i", 1) == 0)
5493 else if (strncmp(direct_str
, "o", 1) == 0)
5494 direct
= FILTER_OUT
;
5496 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5498 return bgp_vty_return(vty
, ret
);
5501 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5502 safi_t safi
, const char *direct_str
)
5506 int direct
= FILTER_IN
;
5508 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5510 return CMD_WARNING_CONFIG_FAILED
;
5512 /* Check filter direction. */
5513 if (strncmp(direct_str
, "i", 1) == 0)
5515 else if (strncmp(direct_str
, "o", 1) == 0)
5516 direct
= FILTER_OUT
;
5518 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5520 return bgp_vty_return(vty
, ret
);
5523 DEFUN (neighbor_filter_list
,
5524 neighbor_filter_list_cmd
,
5525 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5528 "Establish BGP filters\n"
5529 "AS path access-list name\n"
5530 "Filter incoming routes\n"
5531 "Filter outgoing routes\n")
5536 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5537 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5538 argv
[idx_in_out
]->arg
);
5541 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5542 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5543 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5544 "Establish BGP filters\n"
5545 "AS path access-list name\n"
5546 "Filter incoming routes\n"
5547 "Filter outgoing routes\n")
5549 DEFUN (no_neighbor_filter_list
,
5550 no_neighbor_filter_list_cmd
,
5551 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5555 "Establish BGP filters\n"
5556 "AS path access-list name\n"
5557 "Filter incoming routes\n"
5558 "Filter outgoing routes\n")
5562 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5563 bgp_node_afi(vty
), bgp_node_safi(vty
),
5564 argv
[idx_in_out
]->arg
);
5567 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5568 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5569 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5570 "Establish BGP filters\n"
5571 "AS path access-list name\n"
5572 "Filter incoming routes\n"
5573 "Filter outgoing routes\n")
5575 /* Set route-map to the peer. */
5576 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5577 afi_t afi
, safi_t safi
, const char *name_str
,
5578 const char *direct_str
)
5582 int direct
= RMAP_IN
;
5584 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5586 return CMD_WARNING_CONFIG_FAILED
;
5588 /* Check filter direction. */
5589 if (strncmp(direct_str
, "in", 2) == 0)
5591 else if (strncmp(direct_str
, "o", 1) == 0)
5594 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
);
5596 return bgp_vty_return(vty
, ret
);
5599 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5600 afi_t afi
, safi_t safi
,
5601 const char *direct_str
)
5605 int direct
= RMAP_IN
;
5607 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5609 return CMD_WARNING_CONFIG_FAILED
;
5611 /* Check filter direction. */
5612 if (strncmp(direct_str
, "in", 2) == 0)
5614 else if (strncmp(direct_str
, "o", 1) == 0)
5617 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5619 return bgp_vty_return(vty
, ret
);
5622 DEFUN (neighbor_route_map
,
5623 neighbor_route_map_cmd
,
5624 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5627 "Apply route map to neighbor\n"
5628 "Name of route map\n"
5629 "Apply map to incoming routes\n"
5630 "Apply map to outbound routes\n")
5635 return peer_route_map_set_vty(
5636 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5637 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5640 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5641 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5642 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5643 "Apply route map to neighbor\n"
5644 "Name of route map\n"
5645 "Apply map to incoming routes\n"
5646 "Apply map to outbound routes\n")
5648 DEFUN (no_neighbor_route_map
,
5649 no_neighbor_route_map_cmd
,
5650 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5654 "Apply route map to neighbor\n"
5655 "Name of route map\n"
5656 "Apply map to incoming routes\n"
5657 "Apply map to outbound routes\n")
5661 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5662 bgp_node_afi(vty
), bgp_node_safi(vty
),
5663 argv
[idx_in_out
]->arg
);
5666 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5667 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5668 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5669 "Apply route map to neighbor\n"
5670 "Name of route map\n"
5671 "Apply map to incoming routes\n"
5672 "Apply map to outbound routes\n")
5674 /* Set unsuppress-map to the peer. */
5675 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5676 afi_t afi
, safi_t safi
,
5677 const char *name_str
)
5682 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5684 return CMD_WARNING_CONFIG_FAILED
;
5686 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
);
5688 return bgp_vty_return(vty
, ret
);
5691 /* Unset route-map from the peer. */
5692 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5693 afi_t afi
, safi_t safi
)
5698 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5700 return CMD_WARNING_CONFIG_FAILED
;
5702 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5704 return bgp_vty_return(vty
, ret
);
5707 DEFUN (neighbor_unsuppress_map
,
5708 neighbor_unsuppress_map_cmd
,
5709 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5712 "Route-map to selectively unsuppress suppressed routes\n"
5713 "Name of route map\n")
5717 return peer_unsuppress_map_set_vty(
5718 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5719 argv
[idx_word
]->arg
);
5722 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5723 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5724 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5725 "Route-map to selectively unsuppress suppressed routes\n"
5726 "Name of route map\n")
5728 DEFUN (no_neighbor_unsuppress_map
,
5729 no_neighbor_unsuppress_map_cmd
,
5730 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5734 "Route-map to selectively unsuppress suppressed routes\n"
5735 "Name of route map\n")
5738 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5740 bgp_node_safi(vty
));
5743 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5744 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5745 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5746 "Route-map to selectively unsuppress suppressed routes\n"
5747 "Name of route map\n")
5749 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5750 afi_t afi
, safi_t safi
,
5751 const char *num_str
,
5752 const char *threshold_str
, int warning
,
5753 const char *restart_str
)
5761 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5763 return CMD_WARNING_CONFIG_FAILED
;
5765 max
= strtoul(num_str
, NULL
, 10);
5767 threshold
= atoi(threshold_str
);
5769 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5772 restart
= atoi(restart_str
);
5776 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5779 return bgp_vty_return(vty
, ret
);
5782 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5783 afi_t afi
, safi_t safi
)
5788 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5790 return CMD_WARNING_CONFIG_FAILED
;
5792 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5794 return bgp_vty_return(vty
, ret
);
5797 /* Maximum number of prefix configuration. prefix count is different
5798 for each peer configuration. So this configuration can be set for
5799 each peer configuration. */
5800 DEFUN (neighbor_maximum_prefix
,
5801 neighbor_maximum_prefix_cmd
,
5802 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5805 "Maximum number of prefix accept from this peer\n"
5806 "maximum no. of prefix limit\n")
5810 return peer_maximum_prefix_set_vty(
5811 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5812 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5815 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5816 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5817 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5818 "Maximum number of prefix accept from this peer\n"
5819 "maximum no. of prefix limit\n")
5821 DEFUN (neighbor_maximum_prefix_threshold
,
5822 neighbor_maximum_prefix_threshold_cmd
,
5823 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5826 "Maximum number of prefix accept from this peer\n"
5827 "maximum no. of prefix limit\n"
5828 "Threshold value (%) at which to generate a warning msg\n")
5832 int idx_number_2
= 4;
5833 return peer_maximum_prefix_set_vty(
5834 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5835 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5839 neighbor_maximum_prefix_threshold
,
5840 neighbor_maximum_prefix_threshold_hidden_cmd
,
5841 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5842 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5843 "Maximum number of prefix accept from this peer\n"
5844 "maximum no. of prefix limit\n"
5845 "Threshold value (%) at which to generate a warning msg\n")
5847 DEFUN (neighbor_maximum_prefix_warning
,
5848 neighbor_maximum_prefix_warning_cmd
,
5849 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5852 "Maximum number of prefix accept from this peer\n"
5853 "maximum no. of prefix limit\n"
5854 "Only give warning message when limit is exceeded\n")
5858 return peer_maximum_prefix_set_vty(
5859 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5860 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
5864 neighbor_maximum_prefix_warning
,
5865 neighbor_maximum_prefix_warning_hidden_cmd
,
5866 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5867 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5868 "Maximum number of prefix accept from this peer\n"
5869 "maximum no. of prefix limit\n"
5870 "Only give warning message when limit is exceeded\n")
5872 DEFUN (neighbor_maximum_prefix_threshold_warning
,
5873 neighbor_maximum_prefix_threshold_warning_cmd
,
5874 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5877 "Maximum number of prefix accept from this peer\n"
5878 "maximum no. of prefix limit\n"
5879 "Threshold value (%) at which to generate a warning msg\n"
5880 "Only give warning message when limit is exceeded\n")
5884 int idx_number_2
= 4;
5885 return peer_maximum_prefix_set_vty(
5886 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5887 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
5891 neighbor_maximum_prefix_threshold_warning
,
5892 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
5893 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5894 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5895 "Maximum number of prefix accept from this peer\n"
5896 "maximum no. of prefix limit\n"
5897 "Threshold value (%) at which to generate a warning msg\n"
5898 "Only give warning message when limit is exceeded\n")
5900 DEFUN (neighbor_maximum_prefix_restart
,
5901 neighbor_maximum_prefix_restart_cmd
,
5902 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5905 "Maximum number of prefix accept from this peer\n"
5906 "maximum no. of prefix limit\n"
5907 "Restart bgp connection after limit is exceeded\n"
5908 "Restart interval in minutes\n")
5912 int idx_number_2
= 5;
5913 return peer_maximum_prefix_set_vty(
5914 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5915 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
5919 neighbor_maximum_prefix_restart
,
5920 neighbor_maximum_prefix_restart_hidden_cmd
,
5921 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5922 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5923 "Maximum number of prefix accept from this peer\n"
5924 "maximum no. of prefix limit\n"
5925 "Restart bgp connection after limit is exceeded\n"
5926 "Restart interval in minutes\n")
5928 DEFUN (neighbor_maximum_prefix_threshold_restart
,
5929 neighbor_maximum_prefix_threshold_restart_cmd
,
5930 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5933 "Maximum number of prefixes to accept from this peer\n"
5934 "maximum no. of prefix limit\n"
5935 "Threshold value (%) at which to generate a warning msg\n"
5936 "Restart bgp connection after limit is exceeded\n"
5937 "Restart interval in minutes\n")
5941 int idx_number_2
= 4;
5942 int idx_number_3
= 6;
5943 return peer_maximum_prefix_set_vty(
5944 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5945 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
5946 argv
[idx_number_3
]->arg
);
5950 neighbor_maximum_prefix_threshold_restart
,
5951 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
5952 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5953 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5954 "Maximum number of prefixes to accept from this peer\n"
5955 "maximum no. of prefix limit\n"
5956 "Threshold value (%) at which to generate a warning msg\n"
5957 "Restart bgp connection after limit is exceeded\n"
5958 "Restart interval in minutes\n")
5960 DEFUN (no_neighbor_maximum_prefix
,
5961 no_neighbor_maximum_prefix_cmd
,
5962 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5966 "Maximum number of prefixes to accept from this peer\n"
5967 "maximum no. of prefix limit\n"
5968 "Threshold value (%) at which to generate a warning msg\n"
5969 "Restart bgp connection after limit is exceeded\n"
5970 "Restart interval in minutes\n"
5971 "Only give warning message when limit is exceeded\n")
5974 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
5976 bgp_node_safi(vty
));
5980 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
5981 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5982 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5983 "Maximum number of prefixes to accept from this peer\n"
5984 "maximum no. of prefix limit\n"
5985 "Threshold value (%) at which to generate a warning msg\n"
5986 "Restart bgp connection after limit is exceeded\n"
5987 "Restart interval in minutes\n"
5988 "Only give warning message when limit is exceeded\n")
5991 /* "neighbor allowas-in" */
5992 DEFUN (neighbor_allowas_in
,
5993 neighbor_allowas_in_cmd
,
5994 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5997 "Accept as-path with my AS present in it\n"
5998 "Number of occurances of AS number\n"
5999 "Only accept my AS in the as-path if the route was originated in my AS\n")
6002 int idx_number_origin
= 3;
6008 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6010 return CMD_WARNING_CONFIG_FAILED
;
6012 if (argc
<= idx_number_origin
)
6015 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6018 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6021 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6024 return bgp_vty_return(vty
, ret
);
6028 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6029 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6030 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6031 "Accept as-path with my AS present in it\n"
6032 "Number of occurances of AS number\n"
6033 "Only accept my AS in the as-path if the route was originated in my AS\n")
6035 DEFUN (no_neighbor_allowas_in
,
6036 no_neighbor_allowas_in_cmd
,
6037 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6041 "allow local ASN appears in aspath attribute\n"
6042 "Number of occurances of AS number\n"
6043 "Only accept my AS in the as-path if the route was originated in my AS\n")
6049 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6051 return CMD_WARNING_CONFIG_FAILED
;
6053 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6054 bgp_node_safi(vty
));
6056 return bgp_vty_return(vty
, ret
);
6060 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6061 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6062 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6063 "allow local ASN appears in aspath attribute\n"
6064 "Number of occurances of AS number\n"
6065 "Only accept my AS in the as-path if the route was originated in my AS\n")
6067 DEFUN (neighbor_ttl_security
,
6068 neighbor_ttl_security_cmd
,
6069 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6072 "BGP ttl-security parameters\n"
6073 "Specify the maximum number of hops to the BGP peer\n"
6074 "Number of hops to BGP peer\n")
6081 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6083 return CMD_WARNING_CONFIG_FAILED
;
6085 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6088 * If 'neighbor swpX', then this is for directly connected peers,
6089 * we should not accept a ttl-security hops value greater than 1.
6091 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6093 "%s is directly connected peer, hops cannot exceed 1\n",
6094 argv
[idx_peer
]->arg
);
6095 return CMD_WARNING_CONFIG_FAILED
;
6098 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6101 DEFUN (no_neighbor_ttl_security
,
6102 no_neighbor_ttl_security_cmd
,
6103 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6107 "BGP ttl-security parameters\n"
6108 "Specify the maximum number of hops to the BGP peer\n"
6109 "Number of hops to BGP peer\n")
6114 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6116 return CMD_WARNING_CONFIG_FAILED
;
6118 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6121 DEFUN (neighbor_addpath_tx_all_paths
,
6122 neighbor_addpath_tx_all_paths_cmd
,
6123 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6126 "Use addpath to advertise all paths to a neighbor\n")
6131 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6133 return CMD_WARNING_CONFIG_FAILED
;
6135 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6137 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
6140 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6141 neighbor_addpath_tx_all_paths_hidden_cmd
,
6142 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6143 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6144 "Use addpath to advertise all paths to a neighbor\n")
6146 DEFUN (no_neighbor_addpath_tx_all_paths
,
6147 no_neighbor_addpath_tx_all_paths_cmd
,
6148 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6152 "Use addpath to advertise all paths to a neighbor\n")
6155 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6156 bgp_node_afi(vty
), bgp_node_safi(vty
),
6157 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
6160 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6161 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6162 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6163 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6164 "Use addpath to advertise all paths to a neighbor\n")
6166 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6167 neighbor_addpath_tx_bestpath_per_as_cmd
,
6168 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6171 "Use addpath to advertise the bestpath per each neighboring AS\n")
6176 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6178 return CMD_WARNING_CONFIG_FAILED
;
6180 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6182 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
6185 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6186 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6187 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6188 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6189 "Use addpath to advertise the bestpath per each neighboring AS\n")
6191 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6192 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6193 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6197 "Use addpath to advertise the bestpath per each neighboring AS\n")
6200 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6201 bgp_node_afi(vty
), bgp_node_safi(vty
),
6202 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
6205 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6206 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6207 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6208 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6209 "Use addpath to advertise the bestpath per each neighboring AS\n")
6211 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6212 struct ecommunity
**list
)
6214 struct ecommunity
*ecom
= NULL
;
6215 struct ecommunity
*ecomadd
;
6217 for (; argc
; --argc
, ++argv
) {
6219 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6220 ECOMMUNITY_ROUTE_TARGET
, 0);
6222 vty_out(vty
, "Malformed community-list value\n");
6224 ecommunity_free(&ecom
);
6225 return CMD_WARNING_CONFIG_FAILED
;
6229 ecommunity_merge(ecom
, ecomadd
);
6230 ecommunity_free(&ecomadd
);
6237 ecommunity_free(&*list
);
6245 * v2vimport is true if we are handling a `import vrf ...` command
6247 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6251 switch (vty
->node
) {
6260 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6265 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6266 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6267 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6268 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6270 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6274 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6275 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6276 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6277 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6279 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6286 DEFPY (af_rd_vpn_export
,
6287 af_rd_vpn_export_cmd
,
6288 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6290 "Specify route distinguisher\n"
6291 "Between current address-family and vpn\n"
6292 "For routes leaked from current address-family to vpn\n"
6293 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6295 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6296 struct prefix_rd prd
;
6302 if (argv_find(argv
, argc
, "no", &idx
))
6306 ret
= str2prefix_rd(rd_str
, &prd
);
6308 vty_out(vty
, "%% Malformed rd\n");
6309 return CMD_WARNING_CONFIG_FAILED
;
6313 afi
= vpn_policy_getafi(vty
, bgp
, false);
6315 return CMD_WARNING_CONFIG_FAILED
;
6318 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6320 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6321 bgp_get_default(), bgp
);
6324 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6325 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6326 BGP_VPN_POLICY_TOVPN_RD_SET
);
6328 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6329 BGP_VPN_POLICY_TOVPN_RD_SET
);
6332 /* post-change: re-export vpn routes */
6333 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6334 bgp_get_default(), bgp
);
6339 ALIAS (af_rd_vpn_export
,
6340 af_no_rd_vpn_export_cmd
,
6343 "Specify route distinguisher\n"
6344 "Between current address-family and vpn\n"
6345 "For routes leaked from current address-family to vpn\n")
6347 DEFPY (af_label_vpn_export
,
6348 af_label_vpn_export_cmd
,
6349 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6351 "label value for VRF\n"
6352 "Between current address-family and vpn\n"
6353 "For routes leaked from current address-family to vpn\n"
6354 "Label Value <0-1048575>\n"
6355 "Automatically assign a label\n")
6357 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6358 mpls_label_t label
= MPLS_LABEL_NONE
;
6363 if (argv_find(argv
, argc
, "no", &idx
))
6366 /* If "no ...", squash trailing parameter */
6372 label
= label_val
; /* parser should force unsigned */
6375 afi
= vpn_policy_getafi(vty
, bgp
, false);
6377 return CMD_WARNING_CONFIG_FAILED
;
6380 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6381 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6386 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6388 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6389 bgp_get_default(), bgp
);
6391 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6392 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6394 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6397 * label has previously been automatically
6398 * assigned by labelpool: release it
6400 * NB if tovpn_label == MPLS_LABEL_NONE it
6401 * means the automatic assignment is in flight
6402 * and therefore the labelpool callback must
6403 * detect that the auto label is not needed.
6406 bgp_lp_release(LP_TYPE_VRF
,
6407 &bgp
->vpn_policy
[afi
],
6408 bgp
->vpn_policy
[afi
].tovpn_label
);
6410 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6411 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6414 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6416 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6417 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6418 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6419 vpn_leak_label_callback
);
6422 /* post-change: re-export vpn routes */
6423 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6424 bgp_get_default(), bgp
);
6429 ALIAS (af_label_vpn_export
,
6430 af_no_label_vpn_export_cmd
,
6431 "no label vpn export",
6433 "label value for VRF\n"
6434 "Between current address-family and vpn\n"
6435 "For routes leaked from current address-family to vpn\n")
6437 DEFPY (af_nexthop_vpn_export
,
6438 af_nexthop_vpn_export_cmd
,
6439 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6441 "Specify next hop to use for VRF advertised prefixes\n"
6442 "Between current address-family and vpn\n"
6443 "For routes leaked from current address-family to vpn\n"
6447 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6453 if (argv_find(argv
, argc
, "no", &idx
))
6457 if (!sockunion2hostprefix(nexthop_str
, &p
))
6458 return CMD_WARNING_CONFIG_FAILED
;
6461 afi
= vpn_policy_getafi(vty
, bgp
, false);
6463 return CMD_WARNING_CONFIG_FAILED
;
6466 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6468 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6469 bgp_get_default(), bgp
);
6472 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6473 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6474 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6476 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6477 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6480 /* post-change: re-export vpn routes */
6481 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6482 bgp_get_default(), bgp
);
6487 ALIAS (af_nexthop_vpn_export
,
6488 af_no_nexthop_vpn_export_cmd
,
6489 "no nexthop vpn export",
6491 "Specify next hop to use for VRF advertised prefixes\n"
6492 "Between current address-family and vpn\n"
6493 "For routes leaked from current address-family to vpn\n")
6495 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6497 if (!strcmp(dstr
, "import")) {
6498 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6499 } else if (!strcmp(dstr
, "export")) {
6500 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6501 } else if (!strcmp(dstr
, "both")) {
6502 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6503 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6505 vty_out(vty
, "%% direction parse error\n");
6506 return CMD_WARNING_CONFIG_FAILED
;
6511 DEFPY (af_rt_vpn_imexport
,
6512 af_rt_vpn_imexport_cmd
,
6513 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6515 "Specify route target list\n"
6516 "Specify route target list\n"
6517 "Between current address-family and vpn\n"
6518 "For routes leaked from vpn to current address-family: match any\n"
6519 "For routes leaked from current address-family to vpn: set\n"
6520 "both import: match any and export: set\n"
6521 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6523 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6525 struct ecommunity
*ecom
= NULL
;
6526 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6527 vpn_policy_direction_t dir
;
6532 if (argv_find(argv
, argc
, "no", &idx
))
6535 afi
= vpn_policy_getafi(vty
, bgp
, false);
6537 return CMD_WARNING_CONFIG_FAILED
;
6539 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6540 if (ret
!= CMD_SUCCESS
)
6544 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6545 vty_out(vty
, "%% Missing RTLIST\n");
6546 return CMD_WARNING_CONFIG_FAILED
;
6548 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6549 if (ret
!= CMD_SUCCESS
) {
6554 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6558 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6561 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6563 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6564 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6565 ecommunity_dup(ecom
);
6567 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6569 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6570 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6573 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6577 ecommunity_free(&ecom
);
6582 ALIAS (af_rt_vpn_imexport
,
6583 af_no_rt_vpn_imexport_cmd
,
6584 "no <rt|route-target> vpn <import|export|both>$direction_str",
6586 "Specify route target list\n"
6587 "Specify route target list\n"
6588 "Between current address-family and vpn\n"
6589 "For routes leaked from vpn to current address-family\n"
6590 "For routes leaked from current address-family to vpn\n"
6591 "both import and export\n")
6593 DEFPY (af_route_map_vpn_imexport
,
6594 af_route_map_vpn_imexport_cmd
,
6595 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6596 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6598 "Specify route map\n"
6599 "Between current address-family and vpn\n"
6600 "For routes leaked from vpn to current address-family\n"
6601 "For routes leaked from current address-family to vpn\n"
6602 "name of route-map\n")
6604 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6606 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6607 vpn_policy_direction_t dir
;
6612 if (argv_find(argv
, argc
, "no", &idx
))
6615 afi
= vpn_policy_getafi(vty
, bgp
, false);
6617 return CMD_WARNING_CONFIG_FAILED
;
6619 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6620 if (ret
!= CMD_SUCCESS
)
6623 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6627 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6630 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6631 XFREE(MTYPE_ROUTE_MAP_NAME
,
6632 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6633 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6634 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6635 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6636 route_map_lookup_by_name(rmap_str
);
6637 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6640 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6641 XFREE(MTYPE_ROUTE_MAP_NAME
,
6642 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6643 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6644 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6647 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6653 ALIAS (af_route_map_vpn_imexport
,
6654 af_no_route_map_vpn_imexport_cmd
,
6655 "no route-map vpn <import|export>$direction_str",
6657 "Specify route map\n"
6658 "Between current address-family and vpn\n"
6659 "For routes leaked from vpn to current address-family\n"
6660 "For routes leaked from current address-family to vpn\n")
6662 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6663 "[no] import vrf route-map RMAP$rmap_str",
6665 "Import routes from another VRF\n"
6666 "Vrf routes being filtered\n"
6667 "Specify route map\n"
6668 "name of route-map\n")
6670 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6671 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6675 struct bgp
*bgp_default
;
6677 if (argv_find(argv
, argc
, "no", &idx
))
6680 afi
= vpn_policy_getafi(vty
, bgp
, true);
6682 return CMD_WARNING_CONFIG_FAILED
;
6684 bgp_default
= bgp_get_default();
6689 /* Auto-create assuming the same AS */
6690 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6691 BGP_INSTANCE_TYPE_DEFAULT
);
6695 "VRF default is not configured as a bgp instance\n");
6700 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6703 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6704 XFREE(MTYPE_ROUTE_MAP_NAME
,
6705 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6706 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6707 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6708 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6709 route_map_lookup_by_name(rmap_str
);
6710 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6713 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6714 XFREE(MTYPE_ROUTE_MAP_NAME
,
6715 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6716 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6717 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6720 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6725 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6726 "no import vrf route-map",
6728 "Import routes from another VRF\n"
6729 "Vrf routes being filtered\n"
6730 "Specify route map\n")
6732 DEFPY (bgp_imexport_vrf
,
6733 bgp_imexport_vrf_cmd
,
6734 "[no] import vrf NAME$import_name",
6736 "Import routes from another VRF\n"
6737 "VRF to import from\n"
6738 "The name of the VRF\n")
6740 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6741 struct listnode
*node
;
6742 struct bgp
*vrf_bgp
, *bgp_default
;
6745 bool remove
= false;
6748 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
6752 if (import_name
== NULL
) {
6753 vty_out(vty
, "%% Missing import name\n");
6757 if (argv_find(argv
, argc
, "no", &idx
))
6760 afi
= vpn_policy_getafi(vty
, bgp
, true);
6762 return CMD_WARNING_CONFIG_FAILED
;
6764 safi
= bgp_node_safi(vty
);
6766 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
6767 && (strcmp(import_name
, BGP_DEFAULT_NAME
) == 0))
6768 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
6769 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
6770 remove
? "unimport" : "import", import_name
);
6774 bgp_default
= bgp_get_default();
6776 /* Auto-create assuming the same AS */
6777 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6778 BGP_INSTANCE_TYPE_DEFAULT
);
6782 "VRF default is not configured as a bgp instance\n");
6787 vrf_bgp
= bgp_lookup_by_name(import_name
);
6789 if (strcmp(import_name
, BGP_DEFAULT_NAME
) == 0)
6790 vrf_bgp
= bgp_default
;
6792 /* Auto-create assuming the same AS */
6793 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
6797 "VRF %s is not configured as a bgp instance\n",
6804 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6806 /* Already importing from "import_vrf"? */
6807 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
6809 if (strcmp(vname
, import_name
) == 0)
6813 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6819 /* This command is valid only in a bgp vrf instance or the default instance */
6820 DEFPY (bgp_imexport_vpn
,
6821 bgp_imexport_vpn_cmd
,
6822 "[no] <import|export>$direction_str vpn",
6824 "Import routes to this address-family\n"
6825 "Export routes from this address-family\n"
6826 "to/from default instance VPN RIB\n")
6828 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6835 vpn_policy_direction_t dir
;
6837 if (argv_find(argv
, argc
, "no", &idx
))
6840 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
6841 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
6843 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
6844 return CMD_WARNING_CONFIG_FAILED
;
6847 afi
= bgp_node_afi(vty
);
6848 safi
= bgp_node_safi(vty
);
6849 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
6850 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
6851 return CMD_WARNING_CONFIG_FAILED
;
6854 if (!strcmp(direction_str
, "import")) {
6855 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
6856 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6857 } else if (!strcmp(direction_str
, "export")) {
6858 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
6859 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
6861 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
6862 return CMD_WARNING_CONFIG_FAILED
;
6865 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6868 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6869 if (!previous_state
) {
6870 /* trigger export current vrf */
6871 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6874 if (previous_state
) {
6875 /* trigger un-export current vrf */
6876 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6878 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6884 DEFPY (af_routetarget_import
,
6885 af_routetarget_import_cmd
,
6886 "[no] <rt|route-target> redirect import RTLIST...",
6888 "Specify route target list\n"
6889 "Specify route target list\n"
6890 "Flow-spec redirect type route target\n"
6891 "Import routes to this address-family\n"
6892 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6894 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6896 struct ecommunity
*ecom
= NULL
;
6901 if (argv_find(argv
, argc
, "no", &idx
))
6904 afi
= vpn_policy_getafi(vty
, bgp
, false);
6906 return CMD_WARNING_CONFIG_FAILED
;
6909 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6910 vty_out(vty
, "%% Missing RTLIST\n");
6911 return CMD_WARNING_CONFIG_FAILED
;
6913 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6914 if (ret
!= CMD_SUCCESS
)
6919 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
6920 ecommunity_free(&bgp
->vpn_policy
[afi
]
6921 .import_redirect_rtlist
);
6922 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
6923 ecommunity_dup(ecom
);
6925 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
6926 ecommunity_free(&bgp
->vpn_policy
[afi
]
6927 .import_redirect_rtlist
);
6928 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
6932 ecommunity_free(&ecom
);
6937 DEFUN_NOSH (address_family_ipv4_safi
,
6938 address_family_ipv4_safi_cmd
,
6939 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
6940 "Enter Address Family command mode\n"
6942 BGP_SAFI_WITH_LABEL_HELP_STR
)
6946 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6947 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6948 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
6949 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
6950 && safi
!= SAFI_EVPN
) {
6952 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
6953 return CMD_WARNING_CONFIG_FAILED
;
6955 vty
->node
= bgp_node_type(AFI_IP
, safi
);
6957 vty
->node
= BGP_IPV4_NODE
;
6962 DEFUN_NOSH (address_family_ipv6_safi
,
6963 address_family_ipv6_safi_cmd
,
6964 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
6965 "Enter Address Family command mode\n"
6967 BGP_SAFI_WITH_LABEL_HELP_STR
)
6970 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6971 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6972 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
6973 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
6974 && safi
!= SAFI_EVPN
) {
6976 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
6977 return CMD_WARNING_CONFIG_FAILED
;
6979 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
6981 vty
->node
= BGP_IPV6_NODE
;
6986 #ifdef KEEP_OLD_VPN_COMMANDS
6987 DEFUN_NOSH (address_family_vpnv4
,
6988 address_family_vpnv4_cmd
,
6989 "address-family vpnv4 [unicast]",
6990 "Enter Address Family command mode\n"
6992 "Address Family modifier\n")
6994 vty
->node
= BGP_VPNV4_NODE
;
6998 DEFUN_NOSH (address_family_vpnv6
,
6999 address_family_vpnv6_cmd
,
7000 "address-family vpnv6 [unicast]",
7001 "Enter Address Family command mode\n"
7003 "Address Family modifier\n")
7005 vty
->node
= BGP_VPNV6_NODE
;
7010 DEFUN_NOSH (address_family_evpn
,
7011 address_family_evpn_cmd
,
7012 "address-family l2vpn evpn",
7013 "Enter Address Family command mode\n"
7015 "Address Family modifier\n")
7017 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7018 vty
->node
= BGP_EVPN_NODE
;
7022 DEFUN_NOSH (exit_address_family
,
7023 exit_address_family_cmd
,
7024 "exit-address-family",
7025 "Exit from Address Family configuration mode\n")
7027 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7028 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7029 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7030 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7031 || vty
->node
== BGP_EVPN_NODE
7032 || vty
->node
== BGP_FLOWSPECV4_NODE
7033 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7034 vty
->node
= BGP_NODE
;
7038 /* Recalculate bestpath and re-advertise a prefix */
7039 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7040 const char *ip_str
, afi_t afi
, safi_t safi
,
7041 struct prefix_rd
*prd
)
7044 struct prefix match
;
7045 struct bgp_node
*rn
;
7046 struct bgp_node
*rm
;
7048 struct bgp_table
*table
;
7049 struct bgp_table
*rib
;
7051 /* BGP structure lookup. */
7053 bgp
= bgp_lookup_by_name(view_name
);
7055 vty_out(vty
, "%% Can't find BGP instance %s\n",
7060 bgp
= bgp_get_default();
7062 vty_out(vty
, "%% No BGP process is configured\n");
7067 /* Check IP address argument. */
7068 ret
= str2prefix(ip_str
, &match
);
7070 vty_out(vty
, "%% address is malformed\n");
7074 match
.family
= afi2family(afi
);
7075 rib
= bgp
->rib
[afi
][safi
];
7077 if (safi
== SAFI_MPLS_VPN
) {
7078 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7079 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7082 if ((table
= rn
->info
) != NULL
) {
7083 if ((rm
= bgp_node_match(table
, &match
))
7086 == match
.prefixlen
) {
7088 BGP_NODE_USER_CLEAR
);
7089 bgp_process(bgp
, rm
, afi
, safi
);
7091 bgp_unlock_node(rm
);
7096 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7097 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7098 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7099 bgp_process(bgp
, rn
, afi
, safi
);
7101 bgp_unlock_node(rn
);
7108 /* one clear bgp command to rule them all */
7109 DEFUN (clear_ip_bgp_all
,
7110 clear_ip_bgp_all_cmd
,
7111 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> [<soft [<in|out>]|in [prefix-filter]|out>]",
7115 BGP_INSTANCE_HELP_STR
7117 BGP_SAFI_WITH_LABEL_HELP_STR
7119 "BGP neighbor address to clear\n"
7120 "BGP IPv6 neighbor to clear\n"
7121 "BGP neighbor on interface to clear\n"
7122 "Clear peers with the AS number\n"
7123 "Clear all external peers\n"
7124 "Clear all members of peer-group\n"
7125 "BGP peer-group name\n"
7130 "Push out prefix-list ORF and do inbound soft reconfig\n"
7135 afi_t afi
= AFI_IP6
;
7136 safi_t safi
= SAFI_UNICAST
;
7137 enum clear_sort clr_sort
= clear_peer
;
7138 enum bgp_clear_type clr_type
;
7139 char *clr_arg
= NULL
;
7143 /* clear [ip] bgp */
7144 if (argv_find(argv
, argc
, "ip", &idx
))
7147 /* [<view|vrf> VIEWVRFNAME] */
7148 if (argv_find(argv
, argc
, "view", &idx
)
7149 || argv_find(argv
, argc
, "vrf", &idx
)) {
7150 vrf
= argv
[idx
+ 1]->arg
;
7154 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7155 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7156 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7158 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */
7159 if (argv_find(argv
, argc
, "*", &idx
)) {
7160 clr_sort
= clear_all
;
7161 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7162 clr_sort
= clear_peer
;
7163 clr_arg
= argv
[idx
]->arg
;
7164 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7165 clr_sort
= clear_peer
;
7166 clr_arg
= argv
[idx
]->arg
;
7167 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7168 clr_sort
= clear_group
;
7170 clr_arg
= argv
[idx
]->arg
;
7171 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7172 clr_sort
= clear_peer
;
7173 clr_arg
= argv
[idx
]->arg
;
7174 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7175 clr_sort
= clear_as
;
7176 clr_arg
= argv
[idx
]->arg
;
7177 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7178 clr_sort
= clear_external
;
7181 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7182 if (argv_find(argv
, argc
, "soft", &idx
)) {
7183 if (argv_find(argv
, argc
, "in", &idx
)
7184 || argv_find(argv
, argc
, "out", &idx
))
7185 clr_type
= strmatch(argv
[idx
]->text
, "in")
7187 : BGP_CLEAR_SOFT_OUT
;
7189 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7190 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7191 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7192 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7193 : BGP_CLEAR_SOFT_IN
;
7194 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7195 clr_type
= BGP_CLEAR_SOFT_OUT
;
7197 clr_type
= BGP_CLEAR_SOFT_NONE
;
7199 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7202 DEFUN (clear_ip_bgp_prefix
,
7203 clear_ip_bgp_prefix_cmd
,
7204 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7208 BGP_INSTANCE_HELP_STR
7209 "Clear bestpath and re-advertise\n"
7213 char *prefix
= NULL
;
7217 /* [<view|vrf> VIEWVRFNAME] */
7218 if (argv_find(argv
, argc
, "VIEWVRFNAME", &idx
))
7219 vrf
= argv
[idx
]->arg
;
7221 prefix
= argv
[argc
- 1]->arg
;
7223 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7226 DEFUN (clear_bgp_ipv6_safi_prefix
,
7227 clear_bgp_ipv6_safi_prefix_cmd
,
7228 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7234 "Clear bestpath and re-advertise\n"
7238 int idx_ipv6_prefix
= 0;
7239 safi_t safi
= SAFI_UNICAST
;
7240 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7241 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7243 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7244 return bgp_clear_prefix(
7245 vty
, NULL
, prefix
, AFI_IP6
,
7249 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7250 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7251 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7255 BGP_INSTANCE_HELP_STR
7258 "Clear bestpath and re-advertise\n"
7263 int idx_ipv6_prefix
= 0;
7264 safi_t safi
= SAFI_UNICAST
;
7265 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7266 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7267 /* [<view|vrf> VIEWVRFNAME] */
7268 char *vrfview
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx_word
) ?
7269 argv
[idx_word
]->arg
: NULL
;
7271 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7273 return bgp_clear_prefix(
7274 vty
, vrfview
, prefix
,
7275 AFI_IP6
, safi
, NULL
);
7278 DEFUN (show_bgp_views
,
7280 "show [ip] bgp views",
7284 "Show the defined BGP views\n")
7286 struct list
*inst
= bm
->bgp
;
7287 struct listnode
*node
;
7290 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7291 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7295 vty_out(vty
, "Defined BGP views:\n");
7296 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7298 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7300 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7307 DEFUN (show_bgp_vrfs
,
7309 "show [ip] bgp vrfs [json]",
7316 char buf
[ETHER_ADDR_STRLEN
];
7317 struct list
*inst
= bm
->bgp
;
7318 struct listnode
*node
;
7320 uint8_t uj
= use_json(argc
, argv
);
7321 json_object
*json
= NULL
;
7322 json_object
*json_vrfs
= NULL
;
7325 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7326 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7331 json
= json_object_new_object();
7332 json_vrfs
= json_object_new_object();
7335 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7336 const char *name
, *type
;
7338 struct listnode
*node
, *nnode
;
7339 int peers_cfg
, peers_estb
;
7340 json_object
*json_vrf
= NULL
;
7343 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7347 if (!uj
&& count
== 1)
7349 "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n",
7350 "Type", "Id", "routerId", "#PeersVfg",
7351 "#PeersEstb", "Name", "L3-VNI", "Rmac");
7353 peers_cfg
= peers_estb
= 0;
7355 json_vrf
= json_object_new_object();
7358 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7359 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7362 if (peer
->status
== Established
)
7366 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7376 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7378 : (int64_t)bgp
->vrf_id
;
7379 json_object_string_add(json_vrf
, "type", type
);
7380 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7381 json_object_string_add(json_vrf
, "routerId",
7382 inet_ntoa(bgp
->router_id
));
7383 json_object_int_add(json_vrf
, "numConfiguredPeers",
7385 json_object_int_add(json_vrf
, "numEstablishedPeers",
7388 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7389 json_object_string_add(
7391 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7392 json_object_object_add(json_vrfs
, name
, json_vrf
);
7395 "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n",
7397 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7399 inet_ntoa(bgp
->router_id
), peers_cfg
,
7400 peers_estb
, name
, bgp
->l3vni
,
7401 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7405 json_object_object_add(json
, "vrfs", json_vrfs
);
7407 json_object_int_add(json
, "totalVrfs", count
);
7409 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7410 json
, JSON_C_TO_STRING_PRETTY
));
7411 json_object_free(json
);
7415 "\nTotal number of VRFs (including default): %d\n",
7422 static void show_address_entry(struct hash_backet
*backet
, void *args
)
7424 struct vty
*vty
= (struct vty
*)args
;
7425 struct bgp_addr
*addr
= (struct bgp_addr
*)backet
->data
;
7427 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(addr
->addr
),
7431 static void show_tip_entry(struct hash_backet
*backet
, void *args
)
7433 struct vty
*vty
= (struct vty
*)args
;
7434 struct tip_addr
*tip
= (struct tip_addr
*)backet
->data
;
7436 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7440 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7442 vty_out(vty
, "self nexthop database:\n");
7443 hash_iterate(bgp
->address_hash
,
7444 (void (*)(struct hash_backet
*, void *))show_address_entry
,
7447 vty_out(vty
, "Tunnel-ip database:\n");
7448 hash_iterate(bgp
->tip_hash
,
7449 (void (*)(struct hash_backet
*, void *))show_tip_entry
,
7453 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7454 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7455 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7456 "martian next-hops\n"
7457 "martian next-hop database\n")
7459 struct bgp
*bgp
= NULL
;
7462 if (argv_find(argv
, argc
, "view", &idx
)
7463 || argv_find(argv
, argc
, "vrf", &idx
))
7464 bgp
= bgp_lookup_by_name(argv
[idx
+ 1]->arg
);
7466 bgp
= bgp_get_default();
7469 vty_out(vty
, "%% No BGP process is configured\n");
7472 bgp_show_martian_nexthops(vty
, bgp
);
7477 DEFUN (show_bgp_memory
,
7478 show_bgp_memory_cmd
,
7479 "show [ip] bgp memory",
7483 "Global BGP memory statistics\n")
7485 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7486 unsigned long count
;
7488 /* RIB related usage stats */
7489 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7490 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7491 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7492 count
* sizeof(struct bgp_node
)));
7494 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7495 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7496 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7497 count
* sizeof(struct bgp_info
)));
7498 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7499 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7501 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7502 count
* sizeof(struct bgp_info_extra
)));
7504 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7505 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7506 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7507 count
* sizeof(struct bgp_static
)));
7509 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7510 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7511 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7512 count
* sizeof(struct bpacket
)));
7515 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7516 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7517 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7518 count
* sizeof(struct bgp_adj_in
)));
7519 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7520 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7521 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7522 count
* sizeof(struct bgp_adj_out
)));
7524 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7525 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7527 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7528 count
* sizeof(struct bgp_nexthop_cache
)));
7530 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7531 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7533 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7534 count
* sizeof(struct bgp_damp_info
)));
7537 count
= attr_count();
7538 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7539 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7540 count
* sizeof(struct attr
)));
7542 if ((count
= attr_unknown_count()))
7543 vty_out(vty
, "%ld unknown attributes\n", count
);
7545 /* AS_PATH attributes */
7546 count
= aspath_count();
7547 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7548 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7549 count
* sizeof(struct aspath
)));
7551 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7552 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7553 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7554 count
* sizeof(struct assegment
)));
7556 /* Other attributes */
7557 if ((count
= community_count()))
7558 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7559 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7560 count
* sizeof(struct community
)));
7561 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7562 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7563 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7564 count
* sizeof(struct ecommunity
)));
7565 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7567 "%ld BGP large-community entries, using %s of memory\n",
7568 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7569 count
* sizeof(struct lcommunity
)));
7571 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7572 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7573 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7574 count
* sizeof(struct cluster_list
)));
7576 /* Peer related usage */
7577 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7578 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7579 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7580 count
* sizeof(struct peer
)));
7582 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7583 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7584 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7585 count
* sizeof(struct peer_group
)));
7588 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
7589 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
7590 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7591 count
* sizeof(struct hash
)));
7592 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
7593 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
7594 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7595 count
* sizeof(struct hash_backet
)));
7596 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7597 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7598 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7599 count
* sizeof(regex_t
)));
7603 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7605 json_object
*bestpath
= json_object_new_object();
7607 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7608 json_object_string_add(bestpath
, "asPath", "ignore");
7610 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7611 json_object_string_add(bestpath
, "asPath", "confed");
7613 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7614 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7615 json_object_string_add(bestpath
, "multiPathRelax",
7618 json_object_string_add(bestpath
, "multiPathRelax",
7621 json_object_string_add(bestpath
, "multiPathRelax", "false");
7623 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7624 json_object_string_add(bestpath
, "compareRouterId", "true");
7625 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7626 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7627 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7628 json_object_string_add(bestpath
, "med", "confed");
7629 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7630 json_object_string_add(bestpath
, "med",
7631 "missing-as-worst");
7633 json_object_string_add(bestpath
, "med", "true");
7636 json_object_object_add(json
, "bestPath", bestpath
);
7639 /* Show BGP peer's summary information. */
7640 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7641 uint8_t use_json
, json_object
*json
)
7644 struct listnode
*node
, *nnode
;
7645 unsigned int count
= 0, dn_count
= 0;
7646 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7647 char neighbor_buf
[VTY_BUFSIZ
];
7648 int neighbor_col_default_width
= 16;
7650 int max_neighbor_width
= 0;
7652 json_object
*json_peer
= NULL
;
7653 json_object
*json_peers
= NULL
;
7655 /* labeled-unicast routes are installed in the unicast table so in order
7657 * display the correct PfxRcd value we must look at SAFI_UNICAST
7659 if (safi
== SAFI_LABELED_UNICAST
)
7660 pfx_rcd_safi
= SAFI_UNICAST
;
7662 pfx_rcd_safi
= safi
;
7666 json
= json_object_new_object();
7668 json_peers
= json_object_new_object();
7670 /* Loop over all neighbors that will be displayed to determine
7672 * characters are needed for the Neighbor column
7674 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7675 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7678 if (peer
->afc
[afi
][safi
]) {
7679 memset(dn_flag
, '\0', sizeof(dn_flag
));
7680 if (peer_dynamic_neighbor(peer
))
7684 && bgp_flag_check(bgp
,
7685 BGP_FLAG_SHOW_HOSTNAME
))
7686 sprintf(neighbor_buf
, "%s%s(%s) ",
7687 dn_flag
, peer
->hostname
,
7690 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7693 len
= strlen(neighbor_buf
);
7695 if (len
> max_neighbor_width
)
7696 max_neighbor_width
= len
;
7700 /* Originally we displayed the Neighbor column as 16
7701 * characters wide so make that the default
7703 if (max_neighbor_width
< neighbor_col_default_width
)
7704 max_neighbor_width
= neighbor_col_default_width
;
7707 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7708 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7711 if (!peer
->afc
[afi
][safi
])
7716 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7719 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7721 : (int64_t)bgp
->vrf_id
;
7723 /* Usage summary and header */
7725 json_object_string_add(
7727 inet_ntoa(bgp
->router_id
));
7728 json_object_int_add(json
, "as", bgp
->as
);
7729 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7730 json_object_string_add(
7733 == BGP_INSTANCE_TYPE_DEFAULT
)
7738 "BGP router identifier %s, local AS number %u vrf-id %d",
7739 inet_ntoa(bgp
->router_id
), bgp
->as
,
7740 bgp
->vrf_id
== VRF_UNKNOWN
7742 : (int)bgp
->vrf_id
);
7746 if (bgp_update_delay_configured(bgp
)) {
7748 json_object_int_add(
7749 json
, "updateDelayLimit",
7750 bgp
->v_update_delay
);
7752 if (bgp
->v_update_delay
7753 != bgp
->v_establish_wait
)
7754 json_object_int_add(
7756 "updateDelayEstablishWait",
7757 bgp
->v_establish_wait
);
7759 if (bgp_update_delay_active(bgp
)) {
7760 json_object_string_add(
7762 "updateDelayFirstNeighbor",
7763 bgp
->update_delay_begin_time
);
7764 json_object_boolean_true_add(
7766 "updateDelayInProgress");
7768 if (bgp
->update_delay_over
) {
7769 json_object_string_add(
7771 "updateDelayFirstNeighbor",
7772 bgp
->update_delay_begin_time
);
7773 json_object_string_add(
7775 "updateDelayBestpathResumed",
7776 bgp
->update_delay_end_time
);
7777 json_object_string_add(
7779 "updateDelayZebraUpdateResume",
7780 bgp
->update_delay_zebra_resume_time
);
7781 json_object_string_add(
7783 "updateDelayPeerUpdateResume",
7784 bgp
->update_delay_peers_resume_time
);
7789 "Read-only mode update-delay limit: %d seconds\n",
7790 bgp
->v_update_delay
);
7791 if (bgp
->v_update_delay
7792 != bgp
->v_establish_wait
)
7794 " Establish wait: %d seconds\n",
7795 bgp
->v_establish_wait
);
7797 if (bgp_update_delay_active(bgp
)) {
7799 " First neighbor established: %s\n",
7800 bgp
->update_delay_begin_time
);
7802 " Delay in progress\n");
7804 if (bgp
->update_delay_over
) {
7806 " First neighbor established: %s\n",
7807 bgp
->update_delay_begin_time
);
7809 " Best-paths resumed: %s\n",
7810 bgp
->update_delay_end_time
);
7812 " zebra update resumed: %s\n",
7813 bgp
->update_delay_zebra_resume_time
);
7815 " peers update resumed: %s\n",
7816 bgp
->update_delay_peers_resume_time
);
7823 if (bgp_maxmed_onstartup_configured(bgp
)
7824 && bgp
->maxmed_active
)
7825 json_object_boolean_true_add(
7826 json
, "maxMedOnStartup");
7827 if (bgp
->v_maxmed_admin
)
7828 json_object_boolean_true_add(
7829 json
, "maxMedAdministrative");
7831 json_object_int_add(
7832 json
, "tableVersion",
7833 bgp_table_version(bgp
->rib
[afi
][safi
]));
7835 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7836 json_object_int_add(json
, "ribCount", ents
);
7837 json_object_int_add(
7839 ents
* sizeof(struct bgp_node
));
7841 ents
= listcount(bgp
->peer
);
7842 json_object_int_add(json
, "peerCount", ents
);
7843 json_object_int_add(json
, "peerMemory",
7844 ents
* sizeof(struct peer
));
7846 if ((ents
= listcount(bgp
->group
))) {
7847 json_object_int_add(
7848 json
, "peerGroupCount", ents
);
7849 json_object_int_add(
7850 json
, "peerGroupMemory",
7851 ents
* sizeof(struct
7855 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7856 BGP_CONFIG_DAMPENING
))
7857 json_object_boolean_true_add(
7858 json
, "dampeningEnabled");
7860 if (bgp_maxmed_onstartup_configured(bgp
)
7861 && bgp
->maxmed_active
)
7863 "Max-med on-startup active\n");
7864 if (bgp
->v_maxmed_admin
)
7866 "Max-med administrative active\n");
7868 vty_out(vty
, "BGP table version %" PRIu64
"\n",
7869 bgp_table_version(bgp
->rib
[afi
][safi
]));
7871 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7873 "RIB entries %ld, using %s of memory\n",
7875 mtype_memstr(memstrbuf
,
7877 ents
* sizeof(struct
7880 /* Peer related usage */
7881 ents
= listcount(bgp
->peer
);
7882 vty_out(vty
, "Peers %ld, using %s of memory\n",
7885 memstrbuf
, sizeof(memstrbuf
),
7886 ents
* sizeof(struct peer
)));
7888 if ((ents
= listcount(bgp
->group
)))
7890 "Peer groups %ld, using %s of memory\n",
7895 ents
* sizeof(struct
7898 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7899 BGP_CONFIG_DAMPENING
))
7900 vty_out(vty
, "Dampening enabled.\n");
7903 /* Subtract 8 here because 'Neighbor' is
7905 vty_out(vty
, "Neighbor");
7906 vty_out(vty
, "%*s", max_neighbor_width
- 8,
7909 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
7916 json_peer
= json_object_new_object();
7918 if (peer_dynamic_neighbor(peer
)) {
7920 json_object_boolean_true_add(json_peer
,
7925 json_object_string_add(json_peer
, "hostname",
7928 if (peer
->domainname
)
7929 json_object_string_add(json_peer
, "domainname",
7932 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
7933 json_object_int_add(json_peer
, "version", 4);
7934 json_object_int_add(json_peer
, "msgRcvd",
7935 PEER_TOTAL_RX(peer
));
7936 json_object_int_add(json_peer
, "msgSent",
7937 PEER_TOTAL_TX(peer
));
7939 json_object_int_add(json_peer
, "tableVersion",
7940 peer
->version
[afi
][safi
]);
7941 json_object_int_add(json_peer
, "outq",
7943 json_object_int_add(json_peer
, "inq", 0);
7944 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
7945 use_json
, json_peer
);
7946 json_object_int_add(json_peer
, "prefixReceivedCount",
7947 peer
->pcount
[afi
][pfx_rcd_safi
]);
7949 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
7950 json_object_string_add(json_peer
, "state",
7952 else if (peer
->afc_recv
[afi
][safi
])
7953 json_object_string_add(
7955 lookup_msg(bgp_status_msg
, peer
->status
,
7957 else if (CHECK_FLAG(peer
->sflags
,
7958 PEER_STATUS_PREFIX_OVERFLOW
))
7959 json_object_string_add(json_peer
, "state",
7962 json_object_string_add(
7964 lookup_msg(bgp_status_msg
, peer
->status
,
7968 json_object_string_add(json_peer
, "idType",
7970 else if (peer
->su
.sa
.sa_family
== AF_INET
)
7971 json_object_string_add(json_peer
, "idType",
7973 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
7974 json_object_string_add(json_peer
, "idType",
7977 json_object_object_add(json_peers
, peer
->host
,
7980 memset(dn_flag
, '\0', sizeof(dn_flag
));
7981 if (peer_dynamic_neighbor(peer
)) {
7987 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7988 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
7989 peer
->hostname
, peer
->host
);
7991 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
7993 /* pad the neighbor column with spaces */
7994 if (len
< max_neighbor_width
)
7995 vty_out(vty
, "%*s", max_neighbor_width
- len
,
7998 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
7999 peer
->as
, PEER_TOTAL_RX(peer
),
8000 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8001 0, peer
->obuf
->count
,
8002 peer_uptime(peer
->uptime
, timebuf
,
8003 BGP_UPTIME_LEN
, 0, NULL
));
8005 if (peer
->status
== Established
)
8006 if (peer
->afc_recv
[afi
][safi
])
8007 vty_out(vty
, " %12ld",
8011 vty_out(vty
, " NoNeg");
8013 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8014 vty_out(vty
, " Idle (Admin)");
8015 else if (CHECK_FLAG(
8017 PEER_STATUS_PREFIX_OVERFLOW
))
8018 vty_out(vty
, " Idle (PfxCt)");
8020 vty_out(vty
, " %12s",
8021 lookup_msg(bgp_status_msg
,
8022 peer
->status
, NULL
));
8029 json_object_object_add(json
, "peers", json_peers
);
8031 json_object_int_add(json
, "totalPeers", count
);
8032 json_object_int_add(json
, "dynamicPeers", dn_count
);
8034 bgp_show_bestpath_json(bgp
, json
);
8036 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8037 json
, JSON_C_TO_STRING_PRETTY
));
8038 json_object_free(json
);
8041 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8043 vty_out(vty
, "No %s neighbor is configured\n",
8044 afi_safi_print(afi
, safi
));
8048 vty_out(vty
, "* - dynamic neighbor\n");
8049 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8050 dn_count
, bgp
->dynamic_neighbors_limit
);
8057 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8058 int safi
, uint8_t use_json
,
8062 int afi_wildcard
= (afi
== AFI_MAX
);
8063 int safi_wildcard
= (safi
== SAFI_MAX
);
8064 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8065 bool json_output
= false;
8067 if (use_json
&& is_wildcard
)
8068 vty_out(vty
, "{\n");
8070 afi
= 1; /* AFI_IP */
8071 while (afi
< AFI_MAX
) {
8073 safi
= 1; /* SAFI_UNICAST */
8074 while (safi
< SAFI_MAX
) {
8075 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8079 * So limit output to those afi/safi
8081 * actualy have something interesting in
8085 json
= json_object_new_object();
8088 vty_out(vty
, ",\n");
8092 vty_out(vty
, "\"%s\":",
8096 vty_out(vty
, "\n%s Summary:\n",
8101 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
8113 if (use_json
&& is_wildcard
)
8114 vty_out(vty
, "}\n");
8115 else if (use_json
&& !json_output
)
8116 vty_out(vty
, "{}\n");
8119 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8120 safi_t safi
, uint8_t use_json
)
8122 struct listnode
*node
, *nnode
;
8124 json_object
*json
= NULL
;
8128 vty_out(vty
, "{\n");
8130 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8132 json
= json_object_new_object();
8135 vty_out(vty
, ",\n");
8139 vty_out(vty
, "\"%s\":",
8140 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8144 vty_out(vty
, "\nInstance %s:\n",
8145 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8149 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
8153 vty_out(vty
, "}\n");
8156 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8157 safi_t safi
, uint8_t use_json
)
8162 if (strmatch(name
, "all")) {
8163 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8167 bgp
= bgp_lookup_by_name(name
);
8171 vty_out(vty
, "{}\n");
8174 "%% No such BGP instance exist\n");
8178 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
8184 bgp
= bgp_get_default();
8187 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
8192 /* `show [ip] bgp summary' commands. */
8193 DEFUN (show_ip_bgp_summary
,
8194 show_ip_bgp_summary_cmd
,
8195 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8199 BGP_INSTANCE_HELP_STR
8201 BGP_SAFI_WITH_LABEL_HELP_STR
8202 "Summary of BGP neighbor status\n"
8206 afi_t afi
= AFI_MAX
;
8207 safi_t safi
= SAFI_MAX
;
8212 if (argv_find(argv
, argc
, "ip", &idx
))
8214 /* [<view|vrf> VIEWVRFNAME] */
8215 if (argv_find(argv
, argc
, "view", &idx
)
8216 || argv_find(argv
, argc
, "vrf", &idx
))
8217 vrf
= argv
[++idx
]->arg
;
8218 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8219 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8220 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8223 int uj
= use_json(argc
, argv
);
8225 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8228 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8230 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8231 return "IPv4 Unicast";
8232 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8233 return "IPv4 Multicast";
8234 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8235 return "IPv4 Labeled Unicast";
8236 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8238 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8239 return "IPv4 Encap";
8240 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8241 return "IPv4 Flowspec";
8242 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8243 return "IPv6 Unicast";
8244 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8245 return "IPv6 Multicast";
8246 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8247 return "IPv6 Labeled Unicast";
8248 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8250 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8251 return "IPv6 Encap";
8252 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8253 return "IPv6 Flowspec";
8254 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8255 return "L2VPN EVPN";
8261 * Please note that we have intentionally camelCased
8262 * the return strings here. So if you want
8263 * to use this function, please ensure you
8264 * are doing this within json output
8266 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8268 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8269 return "ipv4Unicast";
8270 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8271 return "ipv4Multicast";
8272 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8273 return "ipv4LabeledUnicast";
8274 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8276 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8278 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8279 return "ipv4Flowspec";
8280 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8281 return "ipv6Unicast";
8282 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8283 return "ipv6Multicast";
8284 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8285 return "ipv6LabeledUnicast";
8286 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8288 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8290 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8291 return "ipv6Flowspec";
8292 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8298 /* Show BGP peer's information. */
8299 enum show_type
{ show_all
, show_peer
};
8301 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8302 afi_t afi
, safi_t safi
,
8303 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8304 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8305 uint8_t use_json
, json_object
*json_pref
)
8308 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8309 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8311 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8312 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8313 json_object_string_add(json_pref
, "sendMode",
8314 "advertisedAndReceived");
8315 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8316 json_object_string_add(json_pref
, "sendMode",
8318 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8319 json_object_string_add(json_pref
, "sendMode",
8322 vty_out(vty
, " Send-mode: ");
8323 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8324 vty_out(vty
, "advertised");
8325 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8326 vty_out(vty
, "%sreceived",
8327 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8336 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8337 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8339 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8340 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8341 json_object_string_add(json_pref
, "recvMode",
8342 "advertisedAndReceived");
8343 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8344 json_object_string_add(json_pref
, "recvMode",
8346 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8347 json_object_string_add(json_pref
, "recvMode",
8350 vty_out(vty
, " Receive-mode: ");
8351 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8352 vty_out(vty
, "advertised");
8353 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8354 vty_out(vty
, "%sreceived",
8355 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8364 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8365 safi_t safi
, uint8_t use_json
,
8366 json_object
*json_neigh
)
8368 struct bgp_filter
*filter
;
8369 struct peer_af
*paf
;
8370 char orf_pfx_name
[BUFSIZ
];
8372 json_object
*json_af
= NULL
;
8373 json_object
*json_prefA
= NULL
;
8374 json_object
*json_prefB
= NULL
;
8375 json_object
*json_addr
= NULL
;
8378 json_addr
= json_object_new_object();
8379 json_af
= json_object_new_object();
8380 filter
= &p
->filter
[afi
][safi
];
8382 if (peer_group_active(p
))
8383 json_object_string_add(json_addr
, "peerGroupMember",
8386 paf
= peer_af_find(p
, afi
, safi
);
8387 if (paf
&& PAF_SUBGRP(paf
)) {
8388 json_object_int_add(json_addr
, "updateGroupId",
8389 PAF_UPDGRP(paf
)->id
);
8390 json_object_int_add(json_addr
, "subGroupId",
8391 PAF_SUBGRP(paf
)->id
);
8392 json_object_int_add(json_addr
, "packetQueueLength",
8393 bpacket_queue_virtual_length(paf
));
8396 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8397 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8398 PEER_CAP_ORF_PREFIX_SM_RCV
)
8399 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8400 PEER_CAP_ORF_PREFIX_RM_ADV
)
8401 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8402 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8403 json_object_int_add(json_af
, "orfType",
8405 json_prefA
= json_object_new_object();
8406 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8407 PEER_CAP_ORF_PREFIX_SM_ADV
,
8408 PEER_CAP_ORF_PREFIX_RM_ADV
,
8409 PEER_CAP_ORF_PREFIX_SM_RCV
,
8410 PEER_CAP_ORF_PREFIX_RM_RCV
,
8411 use_json
, json_prefA
);
8412 json_object_object_add(json_af
, "orfPrefixList",
8416 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8417 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8418 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8419 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8420 PEER_CAP_ORF_PREFIX_RM_ADV
)
8421 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8422 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8423 json_object_int_add(json_af
, "orfOldType",
8424 ORF_TYPE_PREFIX_OLD
);
8425 json_prefB
= json_object_new_object();
8426 bgp_show_peer_afi_orf_cap(
8427 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8428 PEER_CAP_ORF_PREFIX_RM_ADV
,
8429 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8430 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8432 json_object_object_add(json_af
, "orfOldPrefixList",
8436 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8437 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8438 PEER_CAP_ORF_PREFIX_SM_RCV
)
8439 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8440 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8441 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8442 PEER_CAP_ORF_PREFIX_RM_ADV
)
8443 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8444 PEER_CAP_ORF_PREFIX_RM_RCV
)
8445 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8446 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8447 json_object_object_add(json_addr
, "afDependentCap",
8450 json_object_free(json_af
);
8452 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8453 orf_pfx_count
= prefix_bgp_show_prefix_list(
8454 NULL
, afi
, orf_pfx_name
, use_json
);
8456 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8457 PEER_STATUS_ORF_PREFIX_SEND
)
8459 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8460 PEER_STATUS_ORF_PREFIX_SEND
))
8461 json_object_boolean_true_add(json_neigh
,
8464 json_object_int_add(json_addr
, "orfRecvCounter",
8467 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8468 PEER_STATUS_ORF_WAIT_REFRESH
))
8469 json_object_string_add(
8470 json_addr
, "orfFirstUpdate",
8471 "deferredUntilORFOrRouteRefreshRecvd");
8473 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8474 PEER_FLAG_REFLECTOR_CLIENT
))
8475 json_object_boolean_true_add(json_addr
,
8476 "routeReflectorClient");
8477 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8478 PEER_FLAG_RSERVER_CLIENT
))
8479 json_object_boolean_true_add(json_addr
,
8480 "routeServerClient");
8481 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8482 json_object_boolean_true_add(json_addr
,
8483 "inboundSoftConfigPermit");
8485 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8486 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8487 json_object_boolean_true_add(
8489 "privateAsNumsAllReplacedInUpdatesToNbr");
8490 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8491 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8492 json_object_boolean_true_add(
8494 "privateAsNumsReplacedInUpdatesToNbr");
8495 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8496 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8497 json_object_boolean_true_add(
8499 "privateAsNumsAllRemovedInUpdatesToNbr");
8500 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8501 PEER_FLAG_REMOVE_PRIVATE_AS
))
8502 json_object_boolean_true_add(
8504 "privateAsNumsRemovedInUpdatesToNbr");
8506 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8507 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
8508 json_object_boolean_true_add(json_addr
,
8509 "addpathTxAllPaths");
8511 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8512 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
8513 json_object_boolean_true_add(json_addr
,
8514 "addpathTxBestpathPerAS");
8516 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8517 json_object_string_add(json_addr
,
8518 "overrideASNsInOutboundUpdates",
8519 "ifAspathEqualRemoteAs");
8521 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8522 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8523 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8524 json_object_boolean_true_add(json_addr
,
8525 "routerAlwaysNextHop");
8526 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8527 PEER_FLAG_AS_PATH_UNCHANGED
))
8528 json_object_boolean_true_add(
8529 json_addr
, "unchangedAsPathPropogatedToNbr");
8530 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8531 PEER_FLAG_NEXTHOP_UNCHANGED
))
8532 json_object_boolean_true_add(
8533 json_addr
, "unchangedNextHopPropogatedToNbr");
8534 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8535 json_object_boolean_true_add(
8536 json_addr
, "unchangedMedPropogatedToNbr");
8537 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8538 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8539 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8540 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8541 PEER_FLAG_SEND_COMMUNITY
)
8542 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8543 PEER_FLAG_SEND_EXT_COMMUNITY
))
8544 json_object_string_add(json_addr
,
8545 "commAttriSentToNbr",
8546 "extendedAndStandard");
8547 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8548 PEER_FLAG_SEND_EXT_COMMUNITY
))
8549 json_object_string_add(json_addr
,
8550 "commAttriSentToNbr",
8553 json_object_string_add(json_addr
,
8554 "commAttriSentToNbr",
8557 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8558 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8559 if (p
->default_rmap
[afi
][safi
].name
)
8560 json_object_string_add(
8561 json_addr
, "defaultRouteMap",
8562 p
->default_rmap
[afi
][safi
].name
);
8564 if (paf
&& PAF_SUBGRP(paf
)
8565 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8566 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8567 json_object_boolean_true_add(json_addr
,
8570 json_object_boolean_true_add(json_addr
,
8574 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8575 if (is_evpn_enabled())
8576 json_object_boolean_true_add(
8577 json_addr
, "advertiseAllVnis");
8580 if (filter
->plist
[FILTER_IN
].name
8581 || filter
->dlist
[FILTER_IN
].name
8582 || filter
->aslist
[FILTER_IN
].name
8583 || filter
->map
[RMAP_IN
].name
)
8584 json_object_boolean_true_add(json_addr
,
8585 "inboundPathPolicyConfig");
8586 if (filter
->plist
[FILTER_OUT
].name
8587 || filter
->dlist
[FILTER_OUT
].name
8588 || filter
->aslist
[FILTER_OUT
].name
8589 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8590 json_object_boolean_true_add(
8591 json_addr
, "outboundPathPolicyConfig");
8594 if (filter
->plist
[FILTER_IN
].name
)
8595 json_object_string_add(json_addr
,
8596 "incomingUpdatePrefixFilterList",
8597 filter
->plist
[FILTER_IN
].name
);
8598 if (filter
->plist
[FILTER_OUT
].name
)
8599 json_object_string_add(json_addr
,
8600 "outgoingUpdatePrefixFilterList",
8601 filter
->plist
[FILTER_OUT
].name
);
8603 /* distribute-list */
8604 if (filter
->dlist
[FILTER_IN
].name
)
8605 json_object_string_add(
8606 json_addr
, "incomingUpdateNetworkFilterList",
8607 filter
->dlist
[FILTER_IN
].name
);
8608 if (filter
->dlist
[FILTER_OUT
].name
)
8609 json_object_string_add(
8610 json_addr
, "outgoingUpdateNetworkFilterList",
8611 filter
->dlist
[FILTER_OUT
].name
);
8614 if (filter
->aslist
[FILTER_IN
].name
)
8615 json_object_string_add(json_addr
,
8616 "incomingUpdateAsPathFilterList",
8617 filter
->aslist
[FILTER_IN
].name
);
8618 if (filter
->aslist
[FILTER_OUT
].name
)
8619 json_object_string_add(json_addr
,
8620 "outgoingUpdateAsPathFilterList",
8621 filter
->aslist
[FILTER_OUT
].name
);
8624 if (filter
->map
[RMAP_IN
].name
)
8625 json_object_string_add(
8626 json_addr
, "routeMapForIncomingAdvertisements",
8627 filter
->map
[RMAP_IN
].name
);
8628 if (filter
->map
[RMAP_OUT
].name
)
8629 json_object_string_add(
8630 json_addr
, "routeMapForOutgoingAdvertisements",
8631 filter
->map
[RMAP_OUT
].name
);
8633 /* unsuppress-map */
8634 if (filter
->usmap
.name
)
8635 json_object_string_add(json_addr
,
8636 "selectiveUnsuppressRouteMap",
8637 filter
->usmap
.name
);
8639 /* Receive prefix count */
8640 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8641 p
->pcount
[afi
][safi
]);
8643 /* Maximum prefix */
8644 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8645 json_object_int_add(json_addr
, "prefixAllowedMax",
8646 p
->pmax
[afi
][safi
]);
8647 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8648 PEER_FLAG_MAX_PREFIX_WARNING
))
8649 json_object_boolean_true_add(
8650 json_addr
, "prefixAllowedMaxWarning");
8651 json_object_int_add(json_addr
,
8652 "prefixAllowedWarningThresh",
8653 p
->pmax_threshold
[afi
][safi
]);
8654 if (p
->pmax_restart
[afi
][safi
])
8655 json_object_int_add(
8657 "prefixAllowedRestartIntervalMsecs",
8658 p
->pmax_restart
[afi
][safi
] * 60000);
8660 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8664 filter
= &p
->filter
[afi
][safi
];
8666 vty_out(vty
, " For address family: %s\n",
8667 afi_safi_print(afi
, safi
));
8669 if (peer_group_active(p
))
8670 vty_out(vty
, " %s peer-group member\n",
8673 paf
= peer_af_find(p
, afi
, safi
);
8674 if (paf
&& PAF_SUBGRP(paf
)) {
8675 vty_out(vty
, " Update group %" PRIu64
8676 ", subgroup %" PRIu64
"\n",
8677 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8678 vty_out(vty
, " Packet Queue length %d\n",
8679 bpacket_queue_virtual_length(paf
));
8681 vty_out(vty
, " Not part of any update group\n");
8683 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8684 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8685 PEER_CAP_ORF_PREFIX_SM_RCV
)
8686 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8687 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8688 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8689 PEER_CAP_ORF_PREFIX_RM_ADV
)
8690 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8691 PEER_CAP_ORF_PREFIX_RM_RCV
)
8692 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8693 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8694 vty_out(vty
, " AF-dependant capabilities:\n");
8696 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8697 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8698 PEER_CAP_ORF_PREFIX_SM_RCV
)
8699 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8700 PEER_CAP_ORF_PREFIX_RM_ADV
)
8701 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8702 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8704 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8706 bgp_show_peer_afi_orf_cap(
8707 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8708 PEER_CAP_ORF_PREFIX_RM_ADV
,
8709 PEER_CAP_ORF_PREFIX_SM_RCV
,
8710 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8712 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8713 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8714 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8715 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8716 PEER_CAP_ORF_PREFIX_RM_ADV
)
8717 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8718 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8720 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8721 ORF_TYPE_PREFIX_OLD
);
8722 bgp_show_peer_afi_orf_cap(
8723 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8724 PEER_CAP_ORF_PREFIX_RM_ADV
,
8725 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8726 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8729 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8730 orf_pfx_count
= prefix_bgp_show_prefix_list(
8731 NULL
, afi
, orf_pfx_name
, use_json
);
8733 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8734 PEER_STATUS_ORF_PREFIX_SEND
)
8736 vty_out(vty
, " Outbound Route Filter (ORF):");
8737 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8738 PEER_STATUS_ORF_PREFIX_SEND
))
8739 vty_out(vty
, " sent;");
8741 vty_out(vty
, " received (%d entries)",
8745 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8746 PEER_STATUS_ORF_WAIT_REFRESH
))
8748 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
8750 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8751 PEER_FLAG_REFLECTOR_CLIENT
))
8752 vty_out(vty
, " Route-Reflector Client\n");
8753 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8754 PEER_FLAG_RSERVER_CLIENT
))
8755 vty_out(vty
, " Route-Server Client\n");
8756 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8758 " Inbound soft reconfiguration allowed\n");
8760 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8761 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8763 " Private AS numbers (all) replaced in updates to this neighbor\n");
8764 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8765 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8767 " Private AS numbers replaced in updates to this neighbor\n");
8768 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8769 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8771 " Private AS numbers (all) removed in updates to this neighbor\n");
8772 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8773 PEER_FLAG_REMOVE_PRIVATE_AS
))
8775 " Private AS numbers removed in updates to this neighbor\n");
8777 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8778 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
8779 vty_out(vty
, " Advertise all paths via addpath\n");
8781 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8782 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
8784 " Advertise bestpath per AS via addpath\n");
8786 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8788 " Override ASNs in outbound updates if aspath equals remote-as\n");
8790 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8791 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8792 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8793 vty_out(vty
, " NEXT_HOP is always this router\n");
8794 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8795 PEER_FLAG_AS_PATH_UNCHANGED
))
8797 " AS_PATH is propagated unchanged to this neighbor\n");
8798 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8799 PEER_FLAG_NEXTHOP_UNCHANGED
))
8801 " NEXT_HOP is propagated unchanged to this neighbor\n");
8802 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8804 " MED is propagated unchanged to this neighbor\n");
8805 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8806 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8807 PEER_FLAG_SEND_EXT_COMMUNITY
)
8808 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8809 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
8811 " Community attribute sent to this neighbor");
8812 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8813 PEER_FLAG_SEND_COMMUNITY
)
8814 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8815 PEER_FLAG_SEND_EXT_COMMUNITY
)
8816 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8817 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8818 vty_out(vty
, "(all)\n");
8819 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8820 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8821 vty_out(vty
, "(large)\n");
8822 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8823 PEER_FLAG_SEND_EXT_COMMUNITY
))
8824 vty_out(vty
, "(extended)\n");
8826 vty_out(vty
, "(standard)\n");
8828 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8829 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8830 vty_out(vty
, " Default information originate,");
8832 if (p
->default_rmap
[afi
][safi
].name
)
8833 vty_out(vty
, " default route-map %s%s,",
8834 p
->default_rmap
[afi
][safi
].map
? "*"
8836 p
->default_rmap
[afi
][safi
].name
);
8837 if (paf
&& PAF_SUBGRP(paf
)
8838 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8839 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8840 vty_out(vty
, " default sent\n");
8842 vty_out(vty
, " default not sent\n");
8845 /* advertise-vni-all */
8846 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8847 if (is_evpn_enabled())
8848 vty_out(vty
, " advertise-all-vni\n");
8851 if (filter
->plist
[FILTER_IN
].name
8852 || filter
->dlist
[FILTER_IN
].name
8853 || filter
->aslist
[FILTER_IN
].name
8854 || filter
->map
[RMAP_IN
].name
)
8855 vty_out(vty
, " Inbound path policy configured\n");
8856 if (filter
->plist
[FILTER_OUT
].name
8857 || filter
->dlist
[FILTER_OUT
].name
8858 || filter
->aslist
[FILTER_OUT
].name
8859 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8860 vty_out(vty
, " Outbound path policy configured\n");
8863 if (filter
->plist
[FILTER_IN
].name
)
8865 " Incoming update prefix filter list is %s%s\n",
8866 filter
->plist
[FILTER_IN
].plist
? "*" : "",
8867 filter
->plist
[FILTER_IN
].name
);
8868 if (filter
->plist
[FILTER_OUT
].name
)
8870 " Outgoing update prefix filter list is %s%s\n",
8871 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
8872 filter
->plist
[FILTER_OUT
].name
);
8874 /* distribute-list */
8875 if (filter
->dlist
[FILTER_IN
].name
)
8877 " Incoming update network filter list is %s%s\n",
8878 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
8879 filter
->dlist
[FILTER_IN
].name
);
8880 if (filter
->dlist
[FILTER_OUT
].name
)
8882 " Outgoing update network filter list is %s%s\n",
8883 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
8884 filter
->dlist
[FILTER_OUT
].name
);
8887 if (filter
->aslist
[FILTER_IN
].name
)
8889 " Incoming update AS path filter list is %s%s\n",
8890 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
8891 filter
->aslist
[FILTER_IN
].name
);
8892 if (filter
->aslist
[FILTER_OUT
].name
)
8894 " Outgoing update AS path filter list is %s%s\n",
8895 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
8896 filter
->aslist
[FILTER_OUT
].name
);
8899 if (filter
->map
[RMAP_IN
].name
)
8901 " Route map for incoming advertisements is %s%s\n",
8902 filter
->map
[RMAP_IN
].map
? "*" : "",
8903 filter
->map
[RMAP_IN
].name
);
8904 if (filter
->map
[RMAP_OUT
].name
)
8906 " Route map for outgoing advertisements is %s%s\n",
8907 filter
->map
[RMAP_OUT
].map
? "*" : "",
8908 filter
->map
[RMAP_OUT
].name
);
8910 /* unsuppress-map */
8911 if (filter
->usmap
.name
)
8913 " Route map for selective unsuppress is %s%s\n",
8914 filter
->usmap
.map
? "*" : "",
8915 filter
->usmap
.name
);
8917 /* Receive prefix count */
8918 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
8920 /* Maximum prefix */
8921 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8922 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
8924 CHECK_FLAG(p
->af_flags
[afi
][safi
],
8925 PEER_FLAG_MAX_PREFIX_WARNING
)
8928 vty_out(vty
, " Threshold for warning message %d%%",
8929 p
->pmax_threshold
[afi
][safi
]);
8930 if (p
->pmax_restart
[afi
][safi
])
8931 vty_out(vty
, ", restart interval %d min",
8932 p
->pmax_restart
[afi
][safi
]);
8940 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, uint8_t use_json
,
8944 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
8945 char timebuf
[BGP_UPTIME_LEN
];
8947 const char *subcode_str
;
8948 const char *code_str
;
8953 json_object
*json_neigh
= NULL
;
8959 json_neigh
= json_object_new_object();
8961 memset(dn_flag
, '\0', sizeof(dn_flag
));
8962 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
8966 if (p
->conf_if
) /* Configured interface name. */
8967 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
8968 BGP_PEER_SU_UNSPEC(p
)
8970 : sockunion2str(&p
->su
, buf
,
8972 else /* Configured IP address. */
8973 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
8978 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
8979 json_object_string_add(json_neigh
, "bgpNeighborAddr",
8981 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
8982 json_object_string_add(
8983 json_neigh
, "bgpNeighborAddr",
8984 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
8986 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
8988 if (p
->change_local_as
)
8989 json_object_int_add(json_neigh
, "localAs",
8990 p
->change_local_as
);
8992 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
8994 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
8995 json_object_boolean_true_add(json_neigh
,
8996 "localAsNoPrepend");
8998 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
8999 json_object_boolean_true_add(json_neigh
,
9000 "localAsReplaceAs");
9002 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9003 || (p
->as_type
== AS_INTERNAL
))
9004 vty_out(vty
, "remote AS %u, ", p
->as
);
9006 vty_out(vty
, "remote AS Unspecified, ");
9007 vty_out(vty
, "local AS %u%s%s, ",
9008 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9009 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9012 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9016 /* peer type internal, external, confed-internal or confed-external */
9017 if (p
->as
== p
->local_as
) {
9019 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9020 json_object_boolean_true_add(
9021 json_neigh
, "nbrConfedInternalLink");
9023 json_object_boolean_true_add(json_neigh
,
9026 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9027 vty_out(vty
, "confed-internal link\n");
9029 vty_out(vty
, "internal link\n");
9033 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9034 json_object_boolean_true_add(
9035 json_neigh
, "nbrConfedExternalLink");
9037 json_object_boolean_true_add(json_neigh
,
9040 if (bgp_confederation_peers_check(bgp
, p
->as
))
9041 vty_out(vty
, "confed-external link\n");
9043 vty_out(vty
, "external link\n");
9050 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9052 vty_out(vty
, " Description: %s\n", p
->desc
);
9058 json_object_string_add(json_neigh
, "hostname",
9062 json_object_string_add(json_neigh
, "domainname",
9065 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9066 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9069 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9076 json_object_string_add(json_neigh
, "peerGroup",
9080 struct prefix prefix
, *range
= NULL
;
9082 sockunion2hostprefix(&(p
->su
), &prefix
);
9083 range
= peer_group_lookup_dynamic_neighbor_range(
9087 prefix2str(range
, buf1
, sizeof(buf1
));
9088 json_object_string_add(
9090 "peerSubnetRangeGroup", buf1
);
9095 " Member of peer-group %s for session parameters\n",
9099 struct prefix prefix
, *range
= NULL
;
9101 sockunion2hostprefix(&(p
->su
), &prefix
);
9102 range
= peer_group_lookup_dynamic_neighbor_range(
9106 prefix2str(range
, buf1
, sizeof(buf1
));
9108 " Belongs to the subnet range group: %s\n",
9116 /* Administrative shutdown. */
9117 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9118 json_object_boolean_true_add(json_neigh
,
9122 json_object_int_add(json_neigh
, "bgpVersion", 4);
9123 json_object_string_add(
9124 json_neigh
, "remoteRouterId",
9125 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9126 json_object_string_add(
9127 json_neigh
, "localRouterId",
9128 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9132 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9133 && bgp_confederation_peers_check(bgp
, p
->as
))
9134 json_object_boolean_true_add(json_neigh
,
9138 json_object_string_add(
9139 json_neigh
, "bgpState",
9140 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9142 if (p
->status
== Established
) {
9145 uptime
= bgp_clock();
9146 uptime
-= p
->uptime
;
9147 epoch_tbuf
= time(NULL
) - uptime
;
9149 #if CONFDATE > 20200101
9151 "bgpTimerUp should be deprecated and can be removed now");
9154 * bgpTimerUp was miliseconds that was accurate
9155 * up to 1 day, then the value returned
9156 * became garbage. So in order to provide
9157 * some level of backwards compatability,
9158 * we still provde the data, but now
9159 * we are returning the correct value
9160 * and also adding a new bgpTimerUpMsec
9161 * which will allow us to deprecate
9164 json_object_int_add(json_neigh
, "bgpTimerUp",
9166 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9168 json_object_string_add(json_neigh
, "bgpTimerUpString",
9169 peer_uptime(p
->uptime
, timebuf
,
9172 json_object_int_add(json_neigh
,
9173 "bgpTimerUpEstablishedEpoch",
9177 else if (p
->status
== Active
) {
9178 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9179 json_object_string_add(json_neigh
, "bgpStateIs",
9181 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9182 json_object_string_add(json_neigh
, "bgpStateIs",
9190 uptime
= bgp_clock();
9191 uptime
-= p
->readtime
;
9192 tm
= gmtime(&uptime
);
9193 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9194 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9195 + (tm
->tm_hour
* 3600000));
9197 uptime
= bgp_clock();
9198 uptime
-= p
->last_write
;
9199 tm
= gmtime(&uptime
);
9200 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9201 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9202 + (tm
->tm_hour
* 3600000));
9204 uptime
= bgp_clock();
9205 uptime
-= p
->update_time
;
9206 tm
= gmtime(&uptime
);
9207 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9208 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9209 + (tm
->tm_hour
* 3600000));
9211 /* Configured timer values. */
9212 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9213 p
->v_holdtime
* 1000);
9214 json_object_int_add(json_neigh
,
9215 "bgpTimerKeepAliveIntervalMsecs",
9216 p
->v_keepalive
* 1000);
9217 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9218 json_object_int_add(json_neigh
,
9219 "bgpTimerConfiguredHoldTimeMsecs",
9220 p
->holdtime
* 1000);
9221 json_object_int_add(
9223 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9224 p
->keepalive
* 1000);
9225 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9226 || (bgp
->default_keepalive
9227 != BGP_DEFAULT_KEEPALIVE
)) {
9228 json_object_int_add(json_neigh
,
9229 "bgpTimerConfiguredHoldTimeMsecs",
9230 bgp
->default_holdtime
);
9231 json_object_int_add(
9233 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9234 bgp
->default_keepalive
);
9237 /* Administrative shutdown. */
9238 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9239 vty_out(vty
, " Administratively shut down\n");
9242 vty_out(vty
, " BGP version 4");
9243 vty_out(vty
, ", remote router ID %s",
9244 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9245 vty_out(vty
, ", local router ID %s\n",
9246 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9250 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9251 && bgp_confederation_peers_check(bgp
, p
->as
))
9253 " Neighbor under common administration\n");
9256 vty_out(vty
, " BGP state = %s",
9257 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9259 if (p
->status
== Established
)
9260 vty_out(vty
, ", up for %8s",
9261 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9264 else if (p
->status
== Active
) {
9265 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9266 vty_out(vty
, " (passive)");
9267 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9268 vty_out(vty
, " (NSF passive)");
9273 vty_out(vty
, " Last read %s",
9274 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9276 vty_out(vty
, ", Last write %s\n",
9277 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9280 /* Configured timer values. */
9282 " Hold time is %d, keepalive interval is %d seconds\n",
9283 p
->v_holdtime
, p
->v_keepalive
);
9284 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9285 vty_out(vty
, " Configured hold time is %d",
9287 vty_out(vty
, ", keepalive interval is %d seconds\n",
9289 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9290 || (bgp
->default_keepalive
9291 != BGP_DEFAULT_KEEPALIVE
)) {
9292 vty_out(vty
, " Configured hold time is %d",
9293 bgp
->default_holdtime
);
9294 vty_out(vty
, ", keepalive interval is %d seconds\n",
9295 bgp
->default_keepalive
);
9299 if (p
->status
== Established
) {
9300 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9301 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9302 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9303 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9304 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9305 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9306 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9307 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9308 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9309 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9310 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9311 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9312 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9313 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9314 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9315 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9316 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9317 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9318 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9319 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9321 json_object
*json_cap
= NULL
;
9323 json_cap
= json_object_new_object();
9326 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9327 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9328 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9329 && CHECK_FLAG(p
->cap
,
9331 json_object_string_add(
9332 json_cap
, "4byteAs",
9333 "advertisedAndReceived");
9334 else if (CHECK_FLAG(p
->cap
,
9336 json_object_string_add(
9337 json_cap
, "4byteAs",
9339 else if (CHECK_FLAG(p
->cap
,
9341 json_object_string_add(
9342 json_cap
, "4byteAs",
9347 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9348 || CHECK_FLAG(p
->cap
,
9349 PEER_CAP_ADDPATH_ADV
)) {
9350 json_object
*json_add
= NULL
;
9351 const char *print_store
;
9353 json_add
= json_object_new_object();
9355 FOREACH_AFI_SAFI (afi
, safi
) {
9356 json_object
*json_sub
= NULL
;
9358 json_object_new_object();
9359 print_store
= afi_safi_print(
9365 PEER_CAP_ADDPATH_AF_TX_ADV
)
9369 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9374 PEER_CAP_ADDPATH_AF_TX_ADV
)
9379 PEER_CAP_ADDPATH_AF_TX_RCV
))
9380 json_object_boolean_true_add(
9382 "txAdvertisedAndReceived");
9388 PEER_CAP_ADDPATH_AF_TX_ADV
))
9389 json_object_boolean_true_add(
9397 PEER_CAP_ADDPATH_AF_TX_RCV
))
9398 json_object_boolean_true_add(
9406 PEER_CAP_ADDPATH_AF_RX_ADV
)
9410 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9415 PEER_CAP_ADDPATH_AF_RX_ADV
)
9420 PEER_CAP_ADDPATH_AF_RX_RCV
))
9421 json_object_boolean_true_add(
9423 "rxAdvertisedAndReceived");
9429 PEER_CAP_ADDPATH_AF_RX_ADV
))
9430 json_object_boolean_true_add(
9438 PEER_CAP_ADDPATH_AF_RX_RCV
))
9439 json_object_boolean_true_add(
9447 PEER_CAP_ADDPATH_AF_TX_ADV
)
9451 PEER_CAP_ADDPATH_AF_TX_RCV
)
9455 PEER_CAP_ADDPATH_AF_RX_ADV
)
9459 PEER_CAP_ADDPATH_AF_RX_RCV
))
9460 json_object_object_add(
9469 json_object_object_add(
9470 json_cap
, "addPath", json_add
);
9474 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9475 || CHECK_FLAG(p
->cap
,
9476 PEER_CAP_DYNAMIC_ADV
)) {
9477 if (CHECK_FLAG(p
->cap
,
9478 PEER_CAP_DYNAMIC_ADV
)
9479 && CHECK_FLAG(p
->cap
,
9480 PEER_CAP_DYNAMIC_RCV
))
9481 json_object_string_add(
9482 json_cap
, "dynamic",
9483 "advertisedAndReceived");
9484 else if (CHECK_FLAG(
9486 PEER_CAP_DYNAMIC_ADV
))
9487 json_object_string_add(
9488 json_cap
, "dynamic",
9490 else if (CHECK_FLAG(
9492 PEER_CAP_DYNAMIC_RCV
))
9493 json_object_string_add(
9494 json_cap
, "dynamic",
9498 /* Extended nexthop */
9499 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9500 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9501 json_object
*json_nxt
= NULL
;
9502 const char *print_store
;
9505 if (CHECK_FLAG(p
->cap
,
9507 && CHECK_FLAG(p
->cap
,
9509 json_object_string_add(
9512 "advertisedAndReceived");
9513 else if (CHECK_FLAG(p
->cap
,
9515 json_object_string_add(
9519 else if (CHECK_FLAG(p
->cap
,
9521 json_object_string_add(
9526 if (CHECK_FLAG(p
->cap
,
9527 PEER_CAP_ENHE_RCV
)) {
9529 json_object_new_object();
9531 for (safi
= SAFI_UNICAST
;
9532 safi
< SAFI_MAX
; safi
++) {
9537 PEER_CAP_ENHE_AF_RCV
)) {
9538 print_store
= afi_safi_print(
9541 json_object_string_add(
9547 json_object_object_add(
9549 "extendedNexthopFamililesByPeer",
9555 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9556 || CHECK_FLAG(p
->cap
,
9557 PEER_CAP_REFRESH_NEW_RCV
)
9558 || CHECK_FLAG(p
->cap
,
9559 PEER_CAP_REFRESH_OLD_RCV
)) {
9560 if (CHECK_FLAG(p
->cap
,
9561 PEER_CAP_REFRESH_ADV
)
9564 PEER_CAP_REFRESH_NEW_RCV
)
9567 PEER_CAP_REFRESH_OLD_RCV
))) {
9570 PEER_CAP_REFRESH_OLD_RCV
)
9573 PEER_CAP_REFRESH_NEW_RCV
))
9574 json_object_string_add(
9577 "advertisedAndReceivedOldNew");
9581 PEER_CAP_REFRESH_OLD_RCV
))
9582 json_object_string_add(
9585 "advertisedAndReceivedOld");
9587 json_object_string_add(
9590 "advertisedAndReceivedNew");
9595 PEER_CAP_REFRESH_ADV
))
9596 json_object_string_add(
9603 PEER_CAP_REFRESH_NEW_RCV
)
9606 PEER_CAP_REFRESH_OLD_RCV
))
9607 json_object_string_add(
9613 /* Multiprotocol Extensions */
9614 json_object
*json_multi
= NULL
;
9615 json_multi
= json_object_new_object();
9617 FOREACH_AFI_SAFI (afi
, safi
) {
9618 if (p
->afc_adv
[afi
][safi
]
9619 || p
->afc_recv
[afi
][safi
]) {
9620 json_object
*json_exten
= NULL
;
9622 json_object_new_object();
9624 if (p
->afc_adv
[afi
][safi
]
9625 && p
->afc_recv
[afi
][safi
])
9626 json_object_boolean_true_add(
9628 "advertisedAndReceived");
9629 else if (p
->afc_adv
[afi
][safi
])
9630 json_object_boolean_true_add(
9633 else if (p
->afc_recv
[afi
][safi
])
9634 json_object_boolean_true_add(
9638 json_object_object_add(
9645 json_object_object_add(
9646 json_cap
, "multiprotocolExtensions",
9649 /* Hostname capabilities */
9650 json_object
*json_hname
= NULL
;
9652 json_hname
= json_object_new_object();
9654 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9655 json_object_string_add(
9656 json_hname
, "advHostName",
9657 bgp
->peer_self
->hostname
9661 json_object_string_add(
9662 json_hname
, "advDomainName",
9663 bgp
->peer_self
->domainname
9670 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9671 json_object_string_add(
9672 json_hname
, "rcvHostName",
9673 p
->hostname
? p
->hostname
9675 json_object_string_add(
9676 json_hname
, "rcvDomainName",
9677 p
->domainname
? p
->domainname
9681 json_object_object_add(json_cap
, "hostName",
9684 /* Gracefull Restart */
9685 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9686 || CHECK_FLAG(p
->cap
,
9687 PEER_CAP_RESTART_ADV
)) {
9688 if (CHECK_FLAG(p
->cap
,
9689 PEER_CAP_RESTART_ADV
)
9690 && CHECK_FLAG(p
->cap
,
9691 PEER_CAP_RESTART_RCV
))
9692 json_object_string_add(
9695 "advertisedAndReceived");
9696 else if (CHECK_FLAG(
9698 PEER_CAP_RESTART_ADV
))
9699 json_object_string_add(
9701 "gracefulRestartCapability",
9703 else if (CHECK_FLAG(
9705 PEER_CAP_RESTART_RCV
))
9706 json_object_string_add(
9708 "gracefulRestartCapability",
9711 if (CHECK_FLAG(p
->cap
,
9712 PEER_CAP_RESTART_RCV
)) {
9713 int restart_af_count
= 0;
9714 json_object
*json_restart
=
9717 json_object_new_object();
9719 json_object_int_add(
9721 "gracefulRestartRemoteTimerMsecs",
9722 p
->v_gr_restart
* 1000);
9724 FOREACH_AFI_SAFI (afi
, safi
) {
9729 PEER_CAP_RESTART_AF_RCV
)) {
9734 json_object_new_object();
9740 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
9741 json_object_boolean_true_add(
9745 json_object_object_add(
9753 if (!restart_af_count
) {
9754 json_object_string_add(
9756 "addressFamiliesByPeer",
9761 json_object_object_add(
9763 "addressFamiliesByPeer",
9767 json_object_object_add(json_neigh
,
9768 "neighborCapabilities",
9771 vty_out(vty
, " Neighbor capabilities:\n");
9774 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9775 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9776 vty_out(vty
, " 4 Byte AS:");
9777 if (CHECK_FLAG(p
->cap
,
9779 vty_out(vty
, " advertised");
9780 if (CHECK_FLAG(p
->cap
,
9782 vty_out(vty
, " %sreceived",
9792 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9793 || CHECK_FLAG(p
->cap
,
9794 PEER_CAP_ADDPATH_ADV
)) {
9795 vty_out(vty
, " AddPath:\n");
9797 FOREACH_AFI_SAFI (afi
, safi
) {
9801 PEER_CAP_ADDPATH_AF_TX_ADV
)
9805 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9816 PEER_CAP_ADDPATH_AF_TX_ADV
))
9827 PEER_CAP_ADDPATH_AF_TX_RCV
))
9834 PEER_CAP_ADDPATH_AF_TX_ADV
)
9844 PEER_CAP_ADDPATH_AF_RX_ADV
)
9848 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9859 PEER_CAP_ADDPATH_AF_RX_ADV
))
9870 PEER_CAP_ADDPATH_AF_RX_RCV
))
9877 PEER_CAP_ADDPATH_AF_RX_ADV
)
9887 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9888 || CHECK_FLAG(p
->cap
,
9889 PEER_CAP_DYNAMIC_ADV
)) {
9890 vty_out(vty
, " Dynamic:");
9891 if (CHECK_FLAG(p
->cap
,
9892 PEER_CAP_DYNAMIC_ADV
))
9893 vty_out(vty
, " advertised");
9894 if (CHECK_FLAG(p
->cap
,
9895 PEER_CAP_DYNAMIC_RCV
))
9896 vty_out(vty
, " %sreceived",
9899 PEER_CAP_DYNAMIC_ADV
)
9905 /* Extended nexthop */
9906 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9907 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9908 vty_out(vty
, " Extended nexthop:");
9909 if (CHECK_FLAG(p
->cap
,
9911 vty_out(vty
, " advertised");
9912 if (CHECK_FLAG(p
->cap
,
9914 vty_out(vty
, " %sreceived",
9922 if (CHECK_FLAG(p
->cap
,
9923 PEER_CAP_ENHE_RCV
)) {
9925 " Address families by peer:\n ");
9926 for (safi
= SAFI_UNICAST
;
9927 safi
< SAFI_MAX
; safi
++)
9932 PEER_CAP_ENHE_AF_RCV
))
9942 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9943 || CHECK_FLAG(p
->cap
,
9944 PEER_CAP_REFRESH_NEW_RCV
)
9945 || CHECK_FLAG(p
->cap
,
9946 PEER_CAP_REFRESH_OLD_RCV
)) {
9947 vty_out(vty
, " Route refresh:");
9948 if (CHECK_FLAG(p
->cap
,
9949 PEER_CAP_REFRESH_ADV
))
9950 vty_out(vty
, " advertised");
9951 if (CHECK_FLAG(p
->cap
,
9952 PEER_CAP_REFRESH_NEW_RCV
)
9955 PEER_CAP_REFRESH_OLD_RCV
))
9956 vty_out(vty
, " %sreceived(%s)",
9959 PEER_CAP_REFRESH_ADV
)
9964 PEER_CAP_REFRESH_OLD_RCV
)
9967 PEER_CAP_REFRESH_NEW_RCV
))
9971 PEER_CAP_REFRESH_OLD_RCV
)
9978 /* Multiprotocol Extensions */
9979 FOREACH_AFI_SAFI (afi
, safi
)
9980 if (p
->afc_adv
[afi
][safi
]
9981 || p
->afc_recv
[afi
][safi
]) {
9983 " Address Family %s:",
9986 if (p
->afc_adv
[afi
][safi
])
9989 if (p
->afc_recv
[afi
][safi
])
9999 /* Hostname capability */
10000 vty_out(vty
, " Hostname Capability:");
10002 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10004 " advertised (name: %s,domain name: %s)",
10005 bgp
->peer_self
->hostname
10009 bgp
->peer_self
->domainname
10014 vty_out(vty
, " not advertised");
10017 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10019 " received (name: %s,domain name: %s)",
10020 p
->hostname
? p
->hostname
10022 p
->domainname
? p
->domainname
10025 vty_out(vty
, " not received");
10028 vty_out(vty
, "\n");
10030 /* Gracefull Restart */
10031 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10032 || CHECK_FLAG(p
->cap
,
10033 PEER_CAP_RESTART_ADV
)) {
10035 " Graceful Restart Capabilty:");
10036 if (CHECK_FLAG(p
->cap
,
10037 PEER_CAP_RESTART_ADV
))
10038 vty_out(vty
, " advertised");
10039 if (CHECK_FLAG(p
->cap
,
10040 PEER_CAP_RESTART_RCV
))
10041 vty_out(vty
, " %sreceived",
10044 PEER_CAP_RESTART_ADV
)
10047 vty_out(vty
, "\n");
10049 if (CHECK_FLAG(p
->cap
,
10050 PEER_CAP_RESTART_RCV
)) {
10051 int restart_af_count
= 0;
10054 " Remote Restart timer is %d seconds\n",
10057 " Address families by peer:\n ");
10059 FOREACH_AFI_SAFI (afi
, safi
)
10064 PEER_CAP_RESTART_AF_RCV
)) {
10077 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10079 : "not preserved");
10080 restart_af_count
++;
10082 if (!restart_af_count
)
10083 vty_out(vty
, "none");
10084 vty_out(vty
, "\n");
10091 /* graceful restart information */
10092 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10093 || p
->t_gr_stale
) {
10094 json_object
*json_grace
= NULL
;
10095 json_object
*json_grace_send
= NULL
;
10096 json_object
*json_grace_recv
= NULL
;
10097 int eor_send_af_count
= 0;
10098 int eor_receive_af_count
= 0;
10101 json_grace
= json_object_new_object();
10102 json_grace_send
= json_object_new_object();
10103 json_grace_recv
= json_object_new_object();
10105 if (p
->status
== Established
) {
10106 FOREACH_AFI_SAFI (afi
, safi
) {
10107 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10108 PEER_STATUS_EOR_SEND
)) {
10109 json_object_boolean_true_add(
10111 afi_safi_print(afi
,
10113 eor_send_af_count
++;
10116 FOREACH_AFI_SAFI (afi
, safi
) {
10118 p
->af_sflags
[afi
][safi
],
10119 PEER_STATUS_EOR_RECEIVED
)) {
10120 json_object_boolean_true_add(
10122 afi_safi_print(afi
,
10124 eor_receive_af_count
++;
10129 json_object_object_add(json_grace
, "endOfRibSend",
10131 json_object_object_add(json_grace
, "endOfRibRecv",
10134 if (p
->t_gr_restart
)
10135 json_object_int_add(json_grace
,
10136 "gracefulRestartTimerMsecs",
10137 thread_timer_remain_second(
10142 json_object_int_add(
10144 "gracefulStalepathTimerMsecs",
10145 thread_timer_remain_second(
10149 json_object_object_add(
10150 json_neigh
, "gracefulRestartInfo", json_grace
);
10152 vty_out(vty
, " Graceful restart informations:\n");
10153 if (p
->status
== Established
) {
10154 vty_out(vty
, " End-of-RIB send: ");
10155 FOREACH_AFI_SAFI (afi
, safi
) {
10156 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10157 PEER_STATUS_EOR_SEND
)) {
10158 vty_out(vty
, "%s%s",
10159 eor_send_af_count
? ", "
10161 afi_safi_print(afi
,
10163 eor_send_af_count
++;
10166 vty_out(vty
, "\n");
10167 vty_out(vty
, " End-of-RIB received: ");
10168 FOREACH_AFI_SAFI (afi
, safi
) {
10170 p
->af_sflags
[afi
][safi
],
10171 PEER_STATUS_EOR_RECEIVED
)) {
10172 vty_out(vty
, "%s%s",
10173 eor_receive_af_count
10176 afi_safi_print(afi
,
10178 eor_receive_af_count
++;
10181 vty_out(vty
, "\n");
10184 if (p
->t_gr_restart
)
10186 " The remaining time of restart timer is %ld\n",
10187 thread_timer_remain_second(
10192 " The remaining time of stalepath timer is %ld\n",
10193 thread_timer_remain_second(
10198 json_object
*json_stat
= NULL
;
10199 json_stat
= json_object_new_object();
10200 /* Packet counts. */
10201 json_object_int_add(json_stat
, "depthInq", 0);
10202 json_object_int_add(json_stat
, "depthOutq",
10203 (unsigned long)p
->obuf
->count
);
10204 json_object_int_add(json_stat
, "opensSent",
10205 atomic_load_explicit(&p
->open_out
,
10206 memory_order_relaxed
));
10207 json_object_int_add(json_stat
, "opensRecv",
10208 atomic_load_explicit(&p
->open_in
,
10209 memory_order_relaxed
));
10210 json_object_int_add(json_stat
, "notificationsSent",
10211 atomic_load_explicit(&p
->notify_out
,
10212 memory_order_relaxed
));
10213 json_object_int_add(json_stat
, "notificationsRecv",
10214 atomic_load_explicit(&p
->notify_in
,
10215 memory_order_relaxed
));
10216 json_object_int_add(json_stat
, "updatesSent",
10217 atomic_load_explicit(&p
->update_out
,
10218 memory_order_relaxed
));
10219 json_object_int_add(json_stat
, "updatesRecv",
10220 atomic_load_explicit(&p
->update_in
,
10221 memory_order_relaxed
));
10222 json_object_int_add(json_stat
, "keepalivesSent",
10223 atomic_load_explicit(&p
->keepalive_out
,
10224 memory_order_relaxed
));
10225 json_object_int_add(json_stat
, "keepalivesRecv",
10226 atomic_load_explicit(&p
->keepalive_in
,
10227 memory_order_relaxed
));
10228 json_object_int_add(json_stat
, "routeRefreshSent",
10229 atomic_load_explicit(&p
->refresh_out
,
10230 memory_order_relaxed
));
10231 json_object_int_add(json_stat
, "routeRefreshRecv",
10232 atomic_load_explicit(&p
->refresh_in
,
10233 memory_order_relaxed
));
10234 json_object_int_add(json_stat
, "capabilitySent",
10235 atomic_load_explicit(&p
->dynamic_cap_out
,
10236 memory_order_relaxed
));
10237 json_object_int_add(json_stat
, "capabilityRecv",
10238 atomic_load_explicit(&p
->dynamic_cap_in
,
10239 memory_order_relaxed
));
10240 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10241 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10242 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10244 /* Packet counts. */
10245 vty_out(vty
, " Message statistics:\n");
10246 vty_out(vty
, " Inq depth is 0\n");
10247 vty_out(vty
, " Outq depth is %lu\n",
10248 (unsigned long)p
->obuf
->count
);
10249 vty_out(vty
, " Sent Rcvd\n");
10250 vty_out(vty
, " Opens: %10d %10d\n",
10251 atomic_load_explicit(&p
->open_out
,
10252 memory_order_relaxed
),
10253 atomic_load_explicit(&p
->open_in
,
10254 memory_order_relaxed
));
10255 vty_out(vty
, " Notifications: %10d %10d\n",
10256 atomic_load_explicit(&p
->notify_out
,
10257 memory_order_relaxed
),
10258 atomic_load_explicit(&p
->notify_in
,
10259 memory_order_relaxed
));
10260 vty_out(vty
, " Updates: %10d %10d\n",
10261 atomic_load_explicit(&p
->update_out
,
10262 memory_order_relaxed
),
10263 atomic_load_explicit(&p
->update_in
,
10264 memory_order_relaxed
));
10265 vty_out(vty
, " Keepalives: %10d %10d\n",
10266 atomic_load_explicit(&p
->keepalive_out
,
10267 memory_order_relaxed
),
10268 atomic_load_explicit(&p
->keepalive_in
,
10269 memory_order_relaxed
));
10270 vty_out(vty
, " Route Refresh: %10d %10d\n",
10271 atomic_load_explicit(&p
->refresh_out
,
10272 memory_order_relaxed
),
10273 atomic_load_explicit(&p
->refresh_in
,
10274 memory_order_relaxed
));
10275 vty_out(vty
, " Capability: %10d %10d\n",
10276 atomic_load_explicit(&p
->dynamic_cap_out
,
10277 memory_order_relaxed
),
10278 atomic_load_explicit(&p
->dynamic_cap_in
,
10279 memory_order_relaxed
));
10280 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10285 /* advertisement-interval */
10286 json_object_int_add(json_neigh
,
10287 "minBtwnAdvertisementRunsTimerMsecs",
10288 p
->v_routeadv
* 1000);
10290 /* Update-source. */
10291 if (p
->update_if
|| p
->update_source
) {
10293 json_object_string_add(json_neigh
,
10296 else if (p
->update_source
)
10297 json_object_string_add(
10298 json_neigh
, "updateSource",
10299 sockunion2str(p
->update_source
, buf1
,
10303 /* advertisement-interval */
10305 " Minimum time between advertisement runs is %d seconds\n",
10308 /* Update-source. */
10309 if (p
->update_if
|| p
->update_source
) {
10310 vty_out(vty
, " Update source is ");
10312 vty_out(vty
, "%s", p
->update_if
);
10313 else if (p
->update_source
)
10315 sockunion2str(p
->update_source
, buf1
,
10317 vty_out(vty
, "\n");
10320 vty_out(vty
, "\n");
10323 /* Address Family Information */
10324 json_object
*json_hold
= NULL
;
10327 json_hold
= json_object_new_object();
10329 FOREACH_AFI_SAFI (afi
, safi
)
10330 if (p
->afc
[afi
][safi
])
10331 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10335 json_object_object_add(json_neigh
, "addressFamilyInfo",
10337 json_object_int_add(json_neigh
, "connectionsEstablished",
10339 json_object_int_add(json_neigh
, "connectionsDropped",
10342 vty_out(vty
, " Connections established %d; dropped %d\n",
10343 p
->established
, p
->dropped
);
10345 if (!p
->last_reset
) {
10347 json_object_string_add(json_neigh
, "lastReset",
10350 vty_out(vty
, " Last reset never\n");
10356 uptime
= bgp_clock();
10357 uptime
-= p
->resettime
;
10358 tm
= gmtime(&uptime
);
10359 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10360 (tm
->tm_sec
* 1000)
10361 + (tm
->tm_min
* 60000)
10362 + (tm
->tm_hour
* 3600000));
10363 json_object_string_add(
10364 json_neigh
, "lastResetDueTo",
10365 peer_down_str
[(int)p
->last_reset
]);
10366 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10367 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10368 char errorcodesubcode_hexstr
[5];
10369 char errorcodesubcode_str
[256];
10371 code_str
= bgp_notify_code_str(p
->notify
.code
);
10372 subcode_str
= bgp_notify_subcode_str(
10373 p
->notify
.code
, p
->notify
.subcode
);
10375 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10376 p
->notify
.code
, p
->notify
.subcode
);
10377 json_object_string_add(json_neigh
,
10378 "lastErrorCodeSubcode",
10379 errorcodesubcode_hexstr
);
10380 snprintf(errorcodesubcode_str
, 255, "%s%s",
10381 code_str
, subcode_str
);
10382 json_object_string_add(json_neigh
,
10383 "lastNotificationReason",
10384 errorcodesubcode_str
);
10385 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10386 && p
->notify
.code
== BGP_NOTIFY_CEASE
10387 && (p
->notify
.subcode
10388 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10389 || p
->notify
.subcode
10390 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10391 && p
->notify
.length
) {
10393 const char *msg_str
;
10395 msg_str
= bgp_notify_admin_message(
10396 msgbuf
, sizeof(msgbuf
),
10397 (uint8_t *)p
->notify
.data
,
10400 json_object_string_add(
10402 "lastShutdownDescription",
10407 vty_out(vty
, " Last reset %s, ",
10408 peer_uptime(p
->resettime
, timebuf
,
10409 BGP_UPTIME_LEN
, 0, NULL
));
10411 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10412 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10413 code_str
= bgp_notify_code_str(p
->notify
.code
);
10414 subcode_str
= bgp_notify_subcode_str(
10415 p
->notify
.code
, p
->notify
.subcode
);
10416 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10417 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10420 code_str
, subcode_str
);
10421 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10422 && p
->notify
.code
== BGP_NOTIFY_CEASE
10423 && (p
->notify
.subcode
10424 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10425 || p
->notify
.subcode
10426 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10427 && p
->notify
.length
) {
10429 const char *msg_str
;
10431 msg_str
= bgp_notify_admin_message(
10432 msgbuf
, sizeof(msgbuf
),
10433 (uint8_t *)p
->notify
.data
,
10437 " Message: \"%s\"\n",
10441 vty_out(vty
, "due to %s\n",
10442 peer_down_str
[(int)p
->last_reset
]);
10445 if (p
->last_reset_cause_size
) {
10446 msg
= p
->last_reset_cause
;
10448 " Message received that caused BGP to send a NOTIFICATION:\n ");
10449 for (i
= 1; i
<= p
->last_reset_cause_size
;
10451 vty_out(vty
, "%02X", *msg
++);
10453 if (i
!= p
->last_reset_cause_size
) {
10455 vty_out(vty
, "\n ");
10456 } else if (i
% 4 == 0) {
10461 vty_out(vty
, "\n");
10466 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10468 json_object_boolean_true_add(json_neigh
,
10469 "prefixesConfigExceedMax");
10472 " Peer had exceeded the max. no. of prefixes configured.\n");
10474 if (p
->t_pmax_restart
) {
10476 json_object_boolean_true_add(
10477 json_neigh
, "reducePrefixNumFrom");
10478 json_object_int_add(json_neigh
,
10479 "restartInTimerMsec",
10480 thread_timer_remain_second(
10485 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10486 p
->host
, thread_timer_remain_second(
10487 p
->t_pmax_restart
));
10490 json_object_boolean_true_add(
10492 "reducePrefixNumAndClearIpBgp");
10495 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10500 /* EBGP Multihop and GTSM */
10501 if (p
->sort
!= BGP_PEER_IBGP
) {
10503 if (p
->gtsm_hops
> 0)
10504 json_object_int_add(json_neigh
,
10505 "externalBgpNbrMaxHopsAway",
10507 else if (p
->ttl
> 1)
10508 json_object_int_add(json_neigh
,
10509 "externalBgpNbrMaxHopsAway",
10512 if (p
->gtsm_hops
> 0)
10514 " External BGP neighbor may be up to %d hops away.\n",
10516 else if (p
->ttl
> 1)
10518 " External BGP neighbor may be up to %d hops away.\n",
10522 if (p
->gtsm_hops
> 0) {
10524 json_object_int_add(json_neigh
,
10525 "internalBgpNbrMaxHopsAway",
10529 " Internal BGP neighbor may be up to %d hops away.\n",
10534 /* Local address. */
10537 json_object_string_add(json_neigh
, "hostLocal",
10538 sockunion2str(p
->su_local
, buf1
,
10540 json_object_int_add(json_neigh
, "portLocal",
10541 ntohs(p
->su_local
->sin
.sin_port
));
10543 vty_out(vty
, "Local host: %s, Local port: %d\n",
10544 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10545 ntohs(p
->su_local
->sin
.sin_port
));
10548 /* Remote address. */
10549 if (p
->su_remote
) {
10551 json_object_string_add(json_neigh
, "hostForeign",
10552 sockunion2str(p
->su_remote
, buf1
,
10554 json_object_int_add(json_neigh
, "portForeign",
10555 ntohs(p
->su_remote
->sin
.sin_port
));
10557 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10558 sockunion2str(p
->su_remote
, buf1
,
10560 ntohs(p
->su_remote
->sin
.sin_port
));
10563 /* Nexthop display. */
10566 json_object_string_add(json_neigh
, "nexthop",
10568 &p
->nexthop
.v4
, buf1
,
10570 json_object_string_add(json_neigh
, "nexthopGlobal",
10571 inet_ntop(AF_INET6
,
10572 &p
->nexthop
.v6_global
,
10573 buf1
, sizeof(buf1
)));
10574 json_object_string_add(json_neigh
, "nexthopLocal",
10575 inet_ntop(AF_INET6
,
10576 &p
->nexthop
.v6_local
,
10577 buf1
, sizeof(buf1
)));
10578 if (p
->shared_network
)
10579 json_object_string_add(json_neigh
,
10583 json_object_string_add(json_neigh
,
10585 "nonSharedNetwork");
10587 vty_out(vty
, "Nexthop: %s\n",
10588 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10590 vty_out(vty
, "Nexthop global: %s\n",
10591 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10593 vty_out(vty
, "Nexthop local: %s\n",
10594 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10596 vty_out(vty
, "BGP connection: %s\n",
10597 p
->shared_network
? "shared network"
10598 : "non shared network");
10602 /* Timer information. */
10604 json_object_int_add(json_neigh
, "connectRetryTimer",
10606 if (p
->status
== Established
&& p
->rtt
)
10607 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10610 json_object_int_add(
10611 json_neigh
, "nextStartTimerDueInMsecs",
10612 thread_timer_remain_second(p
->t_start
) * 1000);
10614 json_object_int_add(
10615 json_neigh
, "nextConnectTimerDueInMsecs",
10616 thread_timer_remain_second(p
->t_connect
)
10618 if (p
->t_routeadv
) {
10619 json_object_int_add(json_neigh
, "mraiInterval",
10621 json_object_int_add(
10622 json_neigh
, "mraiTimerExpireInMsecs",
10623 thread_timer_remain_second(p
->t_routeadv
)
10627 json_object_int_add(json_neigh
, "authenticationEnabled",
10631 json_object_string_add(json_neigh
, "readThread", "on");
10633 json_object_string_add(json_neigh
, "readThread", "off");
10635 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10636 json_object_string_add(json_neigh
, "writeThread", "on");
10638 json_object_string_add(json_neigh
, "writeThread",
10641 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10643 if (p
->status
== Established
&& p
->rtt
)
10644 vty_out(vty
, "Estimated round trip time: %d ms\n",
10647 vty_out(vty
, "Next start timer due in %ld seconds\n",
10648 thread_timer_remain_second(p
->t_start
));
10650 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10651 thread_timer_remain_second(p
->t_connect
));
10654 "MRAI (interval %u) timer expires in %ld seconds\n",
10656 thread_timer_remain_second(p
->t_routeadv
));
10658 vty_out(vty
, "Peer Authentication Enabled\n");
10660 vty_out(vty
, "Read thread: %s Write thread: %s\n",
10661 p
->t_read
? "on" : "off",
10662 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10667 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10668 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10669 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10672 vty_out(vty
, "\n");
10674 /* BFD information. */
10675 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10678 if (p
->conf_if
) /* Configured interface name. */
10679 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10680 else /* Configured IP address. */
10681 json_object_object_add(json
, p
->host
, json_neigh
);
10685 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10686 enum show_type type
, union sockunion
*su
,
10687 const char *conf_if
, uint8_t use_json
,
10690 struct listnode
*node
, *nnode
;
10694 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10695 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10700 bgp_show_peer(vty
, peer
, use_json
, json
);
10705 && !strcmp(peer
->conf_if
, conf_if
))
10707 && !strcmp(peer
->hostname
, conf_if
))) {
10709 bgp_show_peer(vty
, peer
, use_json
,
10713 if (sockunion_same(&peer
->su
, su
)) {
10715 bgp_show_peer(vty
, peer
, use_json
,
10723 if (type
== show_peer
&& !find
) {
10725 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
10727 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
10731 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10732 json
, JSON_C_TO_STRING_PRETTY
));
10733 json_object_free(json
);
10735 vty_out(vty
, "\n");
10738 return CMD_SUCCESS
;
10741 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
10742 enum show_type type
,
10743 const char *ip_str
,
10746 struct listnode
*node
, *nnode
;
10748 union sockunion su
;
10749 json_object
*json
= NULL
;
10750 int ret
, is_first
= 1;
10753 vty_out(vty
, "{\n");
10755 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
10757 if (!(json
= json_object_new_object())) {
10759 BGP_ERR_JSON_MEM_ERROR
,
10760 "Unable to allocate memory for JSON object");
10762 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
10766 json_object_int_add(json
, "vrfId",
10767 (bgp
->vrf_id
== VRF_UNKNOWN
)
10769 : (int64_t)bgp
->vrf_id
);
10770 json_object_string_add(
10772 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10777 vty_out(vty
, ",\n");
10781 vty_out(vty
, "\"%s\":",
10782 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10786 vty_out(vty
, "\nInstance %s:\n",
10787 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10792 if (type
== show_peer
) {
10793 ret
= str2sockunion(ip_str
, &su
);
10795 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10798 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10801 bgp_show_neighbor(vty
, bgp
, show_all
, NULL
, NULL
,
10807 vty_out(vty
, "}\n");
10810 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
10811 enum show_type type
, const char *ip_str
,
10816 union sockunion su
;
10817 json_object
*json
= NULL
;
10820 if (strmatch(name
, "all")) {
10821 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
10823 return CMD_SUCCESS
;
10825 bgp
= bgp_lookup_by_name(name
);
10828 json
= json_object_new_object();
10829 json_object_boolean_true_add(
10830 json
, "bgpNoSuchInstance");
10831 vty_out(vty
, "%s\n",
10832 json_object_to_json_string_ext(
10834 JSON_C_TO_STRING_PRETTY
));
10835 json_object_free(json
);
10838 "%% No such BGP instance exist\n");
10840 return CMD_WARNING
;
10844 bgp
= bgp_get_default();
10848 json
= json_object_new_object();
10850 ret
= str2sockunion(ip_str
, &su
);
10852 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10855 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10858 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
10861 json_object_free(json
);
10864 return CMD_SUCCESS
;
10867 /* "show [ip] bgp neighbors" commands. */
10868 DEFUN (show_ip_bgp_neighbors
,
10869 show_ip_bgp_neighbors_cmd
,
10870 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
10874 BGP_INSTANCE_HELP_STR
10877 "Detailed information on TCP and BGP neighbor connections\n"
10878 "Neighbor to display information about\n"
10879 "Neighbor to display information about\n"
10880 "Neighbor on BGP configured interface\n"
10884 char *sh_arg
= NULL
;
10885 enum show_type sh_type
;
10887 uint8_t uj
= use_json(argc
, argv
);
10891 if (argv_find(argv
, argc
, "view", &idx
)
10892 || argv_find(argv
, argc
, "vrf", &idx
))
10893 vrf
= argv
[idx
+ 1]->arg
;
10896 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
10897 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
10898 || argv_find(argv
, argc
, "WORD", &idx
)) {
10899 sh_type
= show_peer
;
10900 sh_arg
= argv
[idx
]->arg
;
10902 sh_type
= show_all
;
10904 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
10907 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
10908 paths' and `show ip mbgp paths'. Those functions results are the
10910 DEFUN (show_ip_bgp_paths
,
10911 show_ip_bgp_paths_cmd
,
10912 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
10917 "Path information\n")
10919 vty_out(vty
, "Address Refcnt Path\n");
10920 aspath_print_all_vty(vty
);
10921 return CMD_SUCCESS
;
10926 static void community_show_all_iterator(struct hash_backet
*backet
,
10929 struct community
*com
;
10931 com
= (struct community
*)backet
->data
;
10932 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
10933 community_str(com
, false));
10936 /* Show BGP's community internal data. */
10937 DEFUN (show_ip_bgp_community_info
,
10938 show_ip_bgp_community_info_cmd
,
10939 "show [ip] bgp community-info",
10943 "List all bgp community information\n")
10945 vty_out(vty
, "Address Refcnt Community\n");
10947 hash_iterate(community_hash(),
10948 (void (*)(struct hash_backet
*,
10949 void *))community_show_all_iterator
,
10952 return CMD_SUCCESS
;
10955 static void lcommunity_show_all_iterator(struct hash_backet
*backet
,
10958 struct lcommunity
*lcom
;
10960 lcom
= (struct lcommunity
*)backet
->data
;
10961 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
10962 lcommunity_str(lcom
, false));
10965 /* Show BGP's community internal data. */
10966 DEFUN (show_ip_bgp_lcommunity_info
,
10967 show_ip_bgp_lcommunity_info_cmd
,
10968 "show ip bgp large-community-info",
10972 "List all bgp large-community information\n")
10974 vty_out(vty
, "Address Refcnt Large-community\n");
10976 hash_iterate(lcommunity_hash(),
10977 (void (*)(struct hash_backet
*,
10978 void *))lcommunity_show_all_iterator
,
10981 return CMD_SUCCESS
;
10985 DEFUN (show_ip_bgp_attr_info
,
10986 show_ip_bgp_attr_info_cmd
,
10987 "show [ip] bgp attribute-info",
10991 "List all bgp attribute information\n")
10993 attr_show_all(vty
);
10994 return CMD_SUCCESS
;
10997 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
10998 afi_t afi
, safi_t safi
, uint8_t use_json
)
11001 struct listnode
*node
;
11003 char buf1
[INET6_ADDRSTRLEN
];
11005 vpn_policy_direction_t dir
;
11008 json_object
*json
= NULL
;
11009 json_object
*json_import_vrfs
= NULL
;
11010 json_object
*json_export_vrfs
= NULL
;
11012 json
= json_object_new_object();
11013 json_import_vrfs
= json_object_new_array();
11014 json_export_vrfs
= json_object_new_array();
11016 /* Provide context for the block */
11017 json_object_string_add(json
, "vrf", name
? name
: "default");
11018 json_object_string_add(json
, "afiSafi",
11019 afi_safi_print(afi
, safi
));
11021 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11024 json_object_boolean_true_add(json
,
11025 "bgpNoSuchInstance");
11026 vty_out(vty
, "%s\n",
11027 json_object_to_json_string_ext(
11029 JSON_C_TO_STRING_PRETTY
));
11030 json_object_free(json
);
11032 return CMD_WARNING
;
11035 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11036 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11037 json_object_string_add(json
, "importFromVrfs", "none");
11038 json_object_string_add(json
, "importRts", "none");
11040 for (ALL_LIST_ELEMENTS_RO(
11041 bgp
->vpn_policy
[afi
].import_vrf
,
11043 json_object_array_add(json_import_vrfs
,
11044 json_object_new_string(vname
));
11046 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11047 ecom_str
= ecommunity_ecom2str(
11048 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11049 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11050 json_object_object_add(json
, "importFromVrfs",
11052 json_object_string_add(json
, "importRts", ecom_str
);
11054 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11057 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11058 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11059 json_object_string_add(json
, "exportToVrfs", "none");
11060 json_object_string_add(json
, "routeDistinguisher",
11062 json_object_string_add(json
, "exportRts", "none");
11064 for (ALL_LIST_ELEMENTS_RO(
11065 bgp
->vpn_policy
[afi
].export_vrf
,
11067 json_object_array_add(json_export_vrfs
,
11068 json_object_new_string(vname
));
11069 json_object_object_add(json
, "exportToVrfs",
11071 json_object_string_add(json
, "routeDistinguisher",
11072 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11073 buf1
, RD_ADDRSTRLEN
));
11075 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11076 ecom_str
= ecommunity_ecom2str(
11077 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11078 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11079 json_object_string_add(json
, "exportRts", ecom_str
);
11081 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11084 vty_out(vty
, "%s\n",
11085 json_object_to_json_string_ext(json
,
11086 JSON_C_TO_STRING_PRETTY
));
11087 json_object_free(json
);
11090 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11093 vty_out(vty
, "%% No such BGP instance exist\n");
11094 return CMD_WARNING
;
11097 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11098 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11100 "This VRF is not importing %s routes from any other VRF\n",
11101 afi_safi_print(afi
, safi
));
11104 "This VRF is importing %s routes from the following VRFs:\n",
11105 afi_safi_print(afi
, safi
));
11107 for (ALL_LIST_ELEMENTS_RO(
11108 bgp
->vpn_policy
[afi
].import_vrf
,
11110 vty_out(vty
, " %s\n", vname
);
11112 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11113 ecom_str
= ecommunity_ecom2str(
11114 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11115 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11116 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11118 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11121 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11122 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11124 "This VRF is not exporting %s routes to any other VRF\n",
11125 afi_safi_print(afi
, safi
));
11128 "This VRF is exporting %s routes to the ollowing VRFs:\n",
11129 afi_safi_print(afi
, safi
));
11131 for (ALL_LIST_ELEMENTS_RO(
11132 bgp
->vpn_policy
[afi
].export_vrf
,
11134 vty_out(vty
, " %s\n", vname
);
11136 vty_out(vty
, "RD: %s\n",
11137 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11138 buf1
, RD_ADDRSTRLEN
));
11140 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11141 ecom_str
= ecommunity_ecom2str(
11142 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11143 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11144 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11148 return CMD_SUCCESS
;
11151 /* "show [ip] bgp route-leak" command. */
11152 DEFUN (show_ip_bgp_route_leak
,
11153 show_ip_bgp_route_leak_cmd
,
11154 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11158 BGP_INSTANCE_HELP_STR
11161 "Route leaking information\n"
11165 afi_t afi
= AFI_MAX
;
11166 safi_t safi
= SAFI_MAX
;
11168 uint8_t uj
= use_json(argc
, argv
);
11171 /* show [ip] bgp */
11172 if (argv_find(argv
, argc
, "ip", &idx
)) {
11174 safi
= SAFI_UNICAST
;
11176 /* [vrf VIEWVRFNAME] */
11177 if (argv_find(argv
, argc
, "view", &idx
)) {
11179 "%% This command is not applicable to BGP views\n");
11180 return CMD_WARNING
;
11183 if (argv_find(argv
, argc
, "vrf", &idx
))
11184 vrf
= argv
[++idx
]->arg
;
11185 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11186 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11187 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11190 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11192 "%% This command is applicable only for unicast ipv4|ipv6\n");
11193 return CMD_WARNING
;
11196 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
);
11199 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11202 struct listnode
*node
, *nnode
;
11205 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11206 vty_out(vty
, "\nInstance %s:\n",
11207 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11210 update_group_show(bgp
, afi
, safi
, vty
, 0);
11214 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11215 int safi
, uint64_t subgrp_id
)
11220 if (strmatch(name
, "all")) {
11221 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11222 return CMD_SUCCESS
;
11224 bgp
= bgp_lookup_by_name(name
);
11227 bgp
= bgp_get_default();
11231 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11232 return CMD_SUCCESS
;
11235 DEFUN (show_ip_bgp_updgrps
,
11236 show_ip_bgp_updgrps_cmd
,
11237 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11241 BGP_INSTANCE_HELP_STR
11243 BGP_SAFI_WITH_LABEL_HELP_STR
11244 "Detailed info about dynamic update groups\n"
11245 "Specific subgroup to display detailed info for\n")
11248 afi_t afi
= AFI_IP6
;
11249 safi_t safi
= SAFI_UNICAST
;
11250 uint64_t subgrp_id
= 0;
11254 /* show [ip] bgp */
11255 if (argv_find(argv
, argc
, "ip", &idx
))
11257 /* [<view|vrf> VIEWVRFNAME] */
11258 if (argv_find(argv
, argc
, "view", &idx
)
11259 || argv_find(argv
, argc
, "vrf", &idx
))
11260 vrf
= argv
[++idx
]->arg
;
11261 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11262 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11263 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11266 /* get subgroup id, if provided */
11268 if (argv
[idx
]->type
== VARIABLE_TKN
)
11269 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11271 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11274 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11275 show_bgp_instance_all_ipv6_updgrps_cmd
,
11276 "show [ip] bgp <view|vrf> all update-groups",
11280 BGP_INSTANCE_ALL_HELP_STR
11281 "Detailed info about dynamic update groups\n")
11283 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11284 return CMD_SUCCESS
;
11287 DEFUN (show_bgp_updgrps_stats
,
11288 show_bgp_updgrps_stats_cmd
,
11289 "show [ip] bgp update-groups statistics",
11293 "Detailed info about dynamic update groups\n"
11298 bgp
= bgp_get_default();
11300 update_group_show_stats(bgp
, vty
);
11302 return CMD_SUCCESS
;
11305 DEFUN (show_bgp_instance_updgrps_stats
,
11306 show_bgp_instance_updgrps_stats_cmd
,
11307 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11311 BGP_INSTANCE_HELP_STR
11312 "Detailed info about dynamic update groups\n"
11318 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11320 update_group_show_stats(bgp
, vty
);
11322 return CMD_SUCCESS
;
11325 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11326 afi_t afi
, safi_t safi
,
11327 const char *what
, uint64_t subgrp_id
)
11332 bgp
= bgp_lookup_by_name(name
);
11334 bgp
= bgp_get_default();
11337 if (!strcmp(what
, "advertise-queue"))
11338 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11340 else if (!strcmp(what
, "advertised-routes"))
11341 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11343 else if (!strcmp(what
, "packet-queue"))
11344 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11349 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11350 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11351 "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",
11352 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11354 "Detailed info about dynamic update groups\n"
11355 "Specific subgroup to display info for\n"
11356 "Advertisement queue\n"
11357 "Announced routes\n"
11360 uint64_t subgrp_id
= 0;
11364 subgrp_id
= strtoull(sgid
, NULL
, 10);
11369 afiz
= bgp_vty_afi_from_str(afi
);
11373 afiz
= bgp_vty_afi_from_str(afi
);
11374 if (afiz
!= AFI_IP
)
11376 "%% Cannot specify both 'ip' and 'ipv6'\n");
11377 return CMD_WARNING
;
11380 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11382 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11383 return CMD_SUCCESS
;
11386 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11388 struct listnode
*node
, *nnode
;
11389 struct prefix
*range
;
11392 char buf
[PREFIX2STR_BUFFER
];
11395 const char *peer_status
;
11396 const char *af_str
;
11401 conf
= group
->conf
;
11403 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11404 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
11406 } else if (conf
->as_type
== AS_INTERNAL
) {
11407 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
11410 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11413 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11414 vty_out(vty
, " Peer-group type is internal\n");
11416 vty_out(vty
, " Peer-group type is external\n");
11418 /* Display AFs configured. */
11419 vty_out(vty
, " Configured address-families:");
11420 FOREACH_AFI_SAFI (afi
, safi
) {
11421 if (conf
->afc
[afi
][safi
]) {
11423 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11427 vty_out(vty
, " none\n");
11429 vty_out(vty
, "\n");
11431 /* Display listen ranges (for dynamic neighbors), if any */
11432 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11435 else if (afi
== AFI_IP6
)
11439 lr_count
= listcount(group
->listen_range
[afi
]);
11441 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11445 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11447 prefix2str(range
, buf
, sizeof(buf
));
11448 vty_out(vty
, " %s\n", buf
);
11453 /* Display group members and their status */
11454 if (listcount(group
->peer
)) {
11455 vty_out(vty
, " Peer-group members:\n");
11456 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11457 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11458 peer_status
= "Idle (Admin)";
11459 else if (CHECK_FLAG(peer
->sflags
,
11460 PEER_STATUS_PREFIX_OVERFLOW
))
11461 peer_status
= "Idle (PfxCt)";
11463 peer_status
= lookup_msg(bgp_status_msg
,
11464 peer
->status
, NULL
);
11466 dynamic
= peer_dynamic_neighbor(peer
);
11467 vty_out(vty
, " %s %s %s \n", peer
->host
,
11468 dynamic
? "(dynamic)" : "", peer_status
);
11472 return CMD_SUCCESS
;
11475 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11476 const char *group_name
)
11479 struct listnode
*node
, *nnode
;
11480 struct peer_group
*group
;
11481 bool found
= false;
11483 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11486 vty_out(vty
, "%% No such BGP instance exists\n");
11487 return CMD_WARNING
;
11490 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11492 if (strmatch(group
->name
, group_name
)) {
11493 bgp_show_one_peer_group(vty
, group
);
11498 bgp_show_one_peer_group(vty
, group
);
11502 if (group_name
&& !found
)
11503 vty_out(vty
, "%% No such peer-group\n");
11505 return CMD_SUCCESS
;
11508 DEFUN (show_ip_bgp_peer_groups
,
11509 show_ip_bgp_peer_groups_cmd
,
11510 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11514 BGP_INSTANCE_HELP_STR
11515 "Detailed information on BGP peer groups\n"
11516 "Peer group name\n")
11521 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11523 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11525 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11529 /* Redistribute VTY commands. */
11531 DEFUN (bgp_redistribute_ipv4
,
11532 bgp_redistribute_ipv4_cmd
,
11533 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11534 "Redistribute information from another routing protocol\n"
11535 FRR_IP_REDIST_HELP_STR_BGPD
)
11537 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11538 int idx_protocol
= 1;
11541 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11543 vty_out(vty
, "%% Invalid route type\n");
11544 return CMD_WARNING_CONFIG_FAILED
;
11547 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11548 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11552 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11553 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11554 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11556 DEFUN (bgp_redistribute_ipv4_rmap
,
11557 bgp_redistribute_ipv4_rmap_cmd
,
11558 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11559 "Redistribute information from another routing protocol\n"
11560 FRR_IP_REDIST_HELP_STR_BGPD
11561 "Route map reference\n"
11562 "Pointer to route-map entries\n")
11564 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11565 int idx_protocol
= 1;
11568 struct bgp_redist
*red
;
11570 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11572 vty_out(vty
, "%% Invalid route type\n");
11573 return CMD_WARNING_CONFIG_FAILED
;
11576 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11577 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11578 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11582 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
11583 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11584 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11585 "Route map reference\n"
11586 "Pointer to route-map entries\n")
11588 DEFUN (bgp_redistribute_ipv4_metric
,
11589 bgp_redistribute_ipv4_metric_cmd
,
11590 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11591 "Redistribute information from another routing protocol\n"
11592 FRR_IP_REDIST_HELP_STR_BGPD
11593 "Metric for redistributed routes\n"
11594 "Default metric\n")
11596 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11597 int idx_protocol
= 1;
11598 int idx_number
= 3;
11601 struct bgp_redist
*red
;
11603 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11605 vty_out(vty
, "%% Invalid route type\n");
11606 return CMD_WARNING_CONFIG_FAILED
;
11608 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11610 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11611 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11612 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11616 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
11617 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11618 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11619 "Metric for redistributed routes\n"
11620 "Default metric\n")
11622 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
11623 bgp_redistribute_ipv4_rmap_metric_cmd
,
11624 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11625 "Redistribute information from another routing protocol\n"
11626 FRR_IP_REDIST_HELP_STR_BGPD
11627 "Route map reference\n"
11628 "Pointer to route-map entries\n"
11629 "Metric for redistributed routes\n"
11630 "Default metric\n")
11632 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11633 int idx_protocol
= 1;
11635 int idx_number
= 5;
11638 struct bgp_redist
*red
;
11640 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11642 vty_out(vty
, "%% Invalid route type\n");
11643 return CMD_WARNING_CONFIG_FAILED
;
11645 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11647 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11648 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11649 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11650 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11654 bgp_redistribute_ipv4_rmap_metric
,
11655 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
11656 "redistribute " FRR_IP_REDIST_STR_BGPD
11657 " route-map WORD metric (0-4294967295)",
11658 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11659 "Route map reference\n"
11660 "Pointer to route-map entries\n"
11661 "Metric for redistributed routes\n"
11662 "Default metric\n")
11664 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
11665 bgp_redistribute_ipv4_metric_rmap_cmd
,
11666 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
11667 "Redistribute information from another routing protocol\n"
11668 FRR_IP_REDIST_HELP_STR_BGPD
11669 "Metric for redistributed routes\n"
11671 "Route map reference\n"
11672 "Pointer to route-map entries\n")
11674 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11675 int idx_protocol
= 1;
11676 int idx_number
= 3;
11680 struct bgp_redist
*red
;
11682 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11684 vty_out(vty
, "%% Invalid route type\n");
11685 return CMD_WARNING_CONFIG_FAILED
;
11687 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11689 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11690 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11691 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11692 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11696 bgp_redistribute_ipv4_metric_rmap
,
11697 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
11698 "redistribute " FRR_IP_REDIST_STR_BGPD
11699 " metric (0-4294967295) route-map WORD",
11700 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11701 "Metric for redistributed routes\n"
11703 "Route map reference\n"
11704 "Pointer to route-map entries\n")
11706 DEFUN (bgp_redistribute_ipv4_ospf
,
11707 bgp_redistribute_ipv4_ospf_cmd
,
11708 "redistribute <ospf|table> (1-65535)",
11709 "Redistribute information from another routing protocol\n"
11710 "Open Shortest Path First (OSPFv2)\n"
11711 "Non-main Kernel Routing Table\n"
11712 "Instance ID/Table ID\n")
11714 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11715 int idx_ospf_table
= 1;
11716 int idx_number
= 2;
11717 unsigned short instance
;
11718 unsigned short protocol
;
11720 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11722 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11723 protocol
= ZEBRA_ROUTE_OSPF
;
11725 protocol
= ZEBRA_ROUTE_TABLE
;
11727 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11728 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11731 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
11732 "redistribute <ospf|table> (1-65535)",
11733 "Redistribute information from another routing protocol\n"
11734 "Open Shortest Path First (OSPFv2)\n"
11735 "Non-main Kernel Routing Table\n"
11736 "Instance ID/Table ID\n")
11738 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
11739 bgp_redistribute_ipv4_ospf_rmap_cmd
,
11740 "redistribute <ospf|table> (1-65535) route-map WORD",
11741 "Redistribute information from another routing protocol\n"
11742 "Open Shortest Path First (OSPFv2)\n"
11743 "Non-main Kernel Routing Table\n"
11744 "Instance ID/Table ID\n"
11745 "Route map reference\n"
11746 "Pointer to route-map entries\n")
11748 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11749 int idx_ospf_table
= 1;
11750 int idx_number
= 2;
11752 struct bgp_redist
*red
;
11753 unsigned short instance
;
11756 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11757 protocol
= ZEBRA_ROUTE_OSPF
;
11759 protocol
= ZEBRA_ROUTE_TABLE
;
11761 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11762 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11763 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11764 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11767 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
11768 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
11769 "redistribute <ospf|table> (1-65535) route-map WORD",
11770 "Redistribute information from another routing protocol\n"
11771 "Open Shortest Path First (OSPFv2)\n"
11772 "Non-main Kernel Routing Table\n"
11773 "Instance ID/Table ID\n"
11774 "Route map reference\n"
11775 "Pointer to route-map entries\n")
11777 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
11778 bgp_redistribute_ipv4_ospf_metric_cmd
,
11779 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
11780 "Redistribute information from another routing protocol\n"
11781 "Open Shortest Path First (OSPFv2)\n"
11782 "Non-main Kernel Routing Table\n"
11783 "Instance ID/Table ID\n"
11784 "Metric for redistributed routes\n"
11785 "Default metric\n")
11787 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11788 int idx_ospf_table
= 1;
11789 int idx_number
= 2;
11790 int idx_number_2
= 4;
11792 struct bgp_redist
*red
;
11793 unsigned short instance
;
11796 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11797 protocol
= ZEBRA_ROUTE_OSPF
;
11799 protocol
= ZEBRA_ROUTE_TABLE
;
11801 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11802 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11804 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11805 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11806 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11809 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
11810 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
11811 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
11812 "Redistribute information from another routing protocol\n"
11813 "Open Shortest Path First (OSPFv2)\n"
11814 "Non-main Kernel Routing Table\n"
11815 "Instance ID/Table ID\n"
11816 "Metric for redistributed routes\n"
11817 "Default metric\n")
11819 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
11820 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
11821 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
11822 "Redistribute information from another routing protocol\n"
11823 "Open Shortest Path First (OSPFv2)\n"
11824 "Non-main Kernel Routing Table\n"
11825 "Instance ID/Table ID\n"
11826 "Route map reference\n"
11827 "Pointer to route-map entries\n"
11828 "Metric for redistributed routes\n"
11829 "Default metric\n")
11831 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11832 int idx_ospf_table
= 1;
11833 int idx_number
= 2;
11835 int idx_number_2
= 6;
11837 struct bgp_redist
*red
;
11838 unsigned short instance
;
11841 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11842 protocol
= ZEBRA_ROUTE_OSPF
;
11844 protocol
= ZEBRA_ROUTE_TABLE
;
11846 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11847 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11849 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11850 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11851 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11852 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11856 bgp_redistribute_ipv4_ospf_rmap_metric
,
11857 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
11858 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
11859 "Redistribute information from another routing protocol\n"
11860 "Open Shortest Path First (OSPFv2)\n"
11861 "Non-main Kernel Routing Table\n"
11862 "Instance ID/Table ID\n"
11863 "Route map reference\n"
11864 "Pointer to route-map entries\n"
11865 "Metric for redistributed routes\n"
11866 "Default metric\n")
11868 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
11869 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
11870 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
11871 "Redistribute information from another routing protocol\n"
11872 "Open Shortest Path First (OSPFv2)\n"
11873 "Non-main Kernel Routing Table\n"
11874 "Instance ID/Table ID\n"
11875 "Metric for redistributed routes\n"
11877 "Route map reference\n"
11878 "Pointer to route-map entries\n")
11880 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11881 int idx_ospf_table
= 1;
11882 int idx_number
= 2;
11883 int idx_number_2
= 4;
11886 struct bgp_redist
*red
;
11887 unsigned short instance
;
11890 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11891 protocol
= ZEBRA_ROUTE_OSPF
;
11893 protocol
= ZEBRA_ROUTE_TABLE
;
11895 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11896 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11898 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11899 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11900 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11901 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11905 bgp_redistribute_ipv4_ospf_metric_rmap
,
11906 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
11907 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
11908 "Redistribute information from another routing protocol\n"
11909 "Open Shortest Path First (OSPFv2)\n"
11910 "Non-main Kernel Routing Table\n"
11911 "Instance ID/Table ID\n"
11912 "Metric for redistributed routes\n"
11914 "Route map reference\n"
11915 "Pointer to route-map entries\n")
11917 DEFUN (no_bgp_redistribute_ipv4_ospf
,
11918 no_bgp_redistribute_ipv4_ospf_cmd
,
11919 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
11921 "Redistribute information from another routing protocol\n"
11922 "Open Shortest Path First (OSPFv2)\n"
11923 "Non-main Kernel Routing Table\n"
11924 "Instance ID/Table ID\n"
11925 "Metric for redistributed routes\n"
11927 "Route map reference\n"
11928 "Pointer to route-map entries\n")
11930 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11931 int idx_ospf_table
= 2;
11932 int idx_number
= 3;
11933 unsigned short instance
;
11936 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11937 protocol
= ZEBRA_ROUTE_OSPF
;
11939 protocol
= ZEBRA_ROUTE_TABLE
;
11941 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11942 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
11946 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
11947 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
11949 "Redistribute information from another routing protocol\n"
11950 "Open Shortest Path First (OSPFv2)\n"
11951 "Non-main Kernel Routing Table\n"
11952 "Instance ID/Table ID\n"
11953 "Metric for redistributed routes\n"
11955 "Route map reference\n"
11956 "Pointer to route-map entries\n")
11958 DEFUN (no_bgp_redistribute_ipv4
,
11959 no_bgp_redistribute_ipv4_cmd
,
11960 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
11962 "Redistribute information from another routing protocol\n"
11963 FRR_IP_REDIST_HELP_STR_BGPD
11964 "Metric for redistributed routes\n"
11966 "Route map reference\n"
11967 "Pointer to route-map entries\n")
11969 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11970 int idx_protocol
= 2;
11973 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11975 vty_out(vty
, "%% Invalid route type\n");
11976 return CMD_WARNING_CONFIG_FAILED
;
11978 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
11982 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
11983 "no redistribute " FRR_IP_REDIST_STR_BGPD
11984 " [metric (0-4294967295)] [route-map WORD]",
11986 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11987 "Metric for redistributed routes\n"
11989 "Route map reference\n"
11990 "Pointer to route-map entries\n")
11992 DEFUN (bgp_redistribute_ipv6
,
11993 bgp_redistribute_ipv6_cmd
,
11994 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
11995 "Redistribute information from another routing protocol\n"
11996 FRR_IP6_REDIST_HELP_STR_BGPD
)
11998 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11999 int idx_protocol
= 1;
12002 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12004 vty_out(vty
, "%% Invalid route type\n");
12005 return CMD_WARNING_CONFIG_FAILED
;
12008 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12009 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
12012 DEFUN (bgp_redistribute_ipv6_rmap
,
12013 bgp_redistribute_ipv6_rmap_cmd
,
12014 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12015 "Redistribute information from another routing protocol\n"
12016 FRR_IP6_REDIST_HELP_STR_BGPD
12017 "Route map reference\n"
12018 "Pointer to route-map entries\n")
12020 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12021 int idx_protocol
= 1;
12024 struct bgp_redist
*red
;
12026 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12028 vty_out(vty
, "%% Invalid route type\n");
12029 return CMD_WARNING_CONFIG_FAILED
;
12032 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12033 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
12034 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
12037 DEFUN (bgp_redistribute_ipv6_metric
,
12038 bgp_redistribute_ipv6_metric_cmd
,
12039 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12040 "Redistribute information from another routing protocol\n"
12041 FRR_IP6_REDIST_HELP_STR_BGPD
12042 "Metric for redistributed routes\n"
12043 "Default metric\n")
12045 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12046 int idx_protocol
= 1;
12047 int idx_number
= 3;
12050 struct bgp_redist
*red
;
12052 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12054 vty_out(vty
, "%% Invalid route type\n");
12055 return CMD_WARNING_CONFIG_FAILED
;
12057 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12059 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12060 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12061 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
12064 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12065 bgp_redistribute_ipv6_rmap_metric_cmd
,
12066 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12067 "Redistribute information from another routing protocol\n"
12068 FRR_IP6_REDIST_HELP_STR_BGPD
12069 "Route map reference\n"
12070 "Pointer to route-map entries\n"
12071 "Metric for redistributed routes\n"
12072 "Default metric\n")
12074 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12075 int idx_protocol
= 1;
12077 int idx_number
= 5;
12080 struct bgp_redist
*red
;
12082 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12084 vty_out(vty
, "%% Invalid route type\n");
12085 return CMD_WARNING_CONFIG_FAILED
;
12087 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12089 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12090 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
12091 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12092 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
12095 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12096 bgp_redistribute_ipv6_metric_rmap_cmd
,
12097 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12098 "Redistribute information from another routing protocol\n"
12099 FRR_IP6_REDIST_HELP_STR_BGPD
12100 "Metric for redistributed routes\n"
12102 "Route map reference\n"
12103 "Pointer to route-map entries\n")
12105 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12106 int idx_protocol
= 1;
12107 int idx_number
= 3;
12111 struct bgp_redist
*red
;
12113 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12115 vty_out(vty
, "%% Invalid route type\n");
12116 return CMD_WARNING_CONFIG_FAILED
;
12118 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12120 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12121 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
, metric
);
12122 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
12123 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
12126 DEFUN (no_bgp_redistribute_ipv6
,
12127 no_bgp_redistribute_ipv6_cmd
,
12128 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12130 "Redistribute information from another routing protocol\n"
12131 FRR_IP6_REDIST_HELP_STR_BGPD
12132 "Metric for redistributed routes\n"
12134 "Route map reference\n"
12135 "Pointer to route-map entries\n")
12137 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12138 int idx_protocol
= 2;
12141 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12143 vty_out(vty
, "%% Invalid route type\n");
12144 return CMD_WARNING_CONFIG_FAILED
;
12147 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12150 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12155 /* Unicast redistribution only. */
12156 if (safi
!= SAFI_UNICAST
)
12159 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12160 /* Redistribute BGP does not make sense. */
12161 if (i
!= ZEBRA_ROUTE_BGP
) {
12162 struct list
*red_list
;
12163 struct listnode
*node
;
12164 struct bgp_redist
*red
;
12166 red_list
= bgp
->redist
[afi
][i
];
12170 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12171 /* "redistribute" configuration. */
12172 vty_out(vty
, " redistribute %s",
12173 zebra_route_string(i
));
12175 vty_out(vty
, " %d", red
->instance
);
12176 if (red
->redist_metric_flag
)
12177 vty_out(vty
, " metric %u",
12178 red
->redist_metric
);
12179 if (red
->rmap
.name
)
12180 vty_out(vty
, " route-map %s",
12182 vty_out(vty
, "\n");
12188 /* This is part of the address-family block (unicast only) */
12189 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12194 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
])
12195 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12196 bgp
->vpn_policy
[afi
]
12197 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12199 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12200 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12201 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12202 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12205 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12206 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12208 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12211 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12212 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12213 bgp
->vpn_policy
[afi
].tovpn_label
);
12216 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12217 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12218 char buf
[RD_ADDRSTRLEN
];
12219 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12220 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12223 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12224 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12226 char buf
[PREFIX_STRLEN
];
12227 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12228 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12231 vty_out(vty
, "%*snexthop vpn export %s\n",
12235 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12236 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12238 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12239 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12241 char *b
= ecommunity_ecom2str(
12242 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12243 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12244 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12245 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12247 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12248 char *b
= ecommunity_ecom2str(
12249 bgp
->vpn_policy
[afi
]
12250 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12251 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12252 ECOMMUNITY_ROUTE_TARGET
);
12253 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12254 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12256 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12257 char *b
= ecommunity_ecom2str(
12258 bgp
->vpn_policy
[afi
]
12259 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12260 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12261 ECOMMUNITY_ROUTE_TARGET
);
12262 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12263 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12267 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12268 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12269 bgp
->vpn_policy
[afi
]
12270 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12272 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12273 char *b
= ecommunity_ecom2str(
12274 bgp
->vpn_policy
[afi
]
12275 .import_redirect_rtlist
,
12276 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12277 ECOMMUNITY_ROUTE_TARGET
);
12279 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12280 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12285 /* BGP node structure. */
12286 static struct cmd_node bgp_node
= {
12287 BGP_NODE
, "%s(config-router)# ", 1,
12290 static struct cmd_node bgp_ipv4_unicast_node
= {
12291 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12294 static struct cmd_node bgp_ipv4_multicast_node
= {
12295 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12298 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12299 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12302 static struct cmd_node bgp_ipv6_unicast_node
= {
12303 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12306 static struct cmd_node bgp_ipv6_multicast_node
= {
12307 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12310 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12311 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12314 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12315 "%s(config-router-af)# ", 1};
12317 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12318 "%s(config-router-af-vpnv6)# ", 1};
12320 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12321 "%s(config-router-evpn)# ", 1};
12323 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12324 "%s(config-router-af-vni)# ", 1};
12326 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12327 "%s(config-router-af)# ", 1};
12329 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12330 "%s(config-router-af-vpnv6)# ", 1};
12332 static void community_list_vty(void);
12334 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12338 struct listnode
*lnbgp
, *lnpeer
;
12340 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12341 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12342 /* only provide suggestions on the appropriate input
12344 * they'll otherwise show up multiple times */
12345 enum cmd_token_type match_type
;
12346 char *name
= peer
->host
;
12348 if (peer
->conf_if
) {
12349 match_type
= VARIABLE_TKN
;
12350 name
= peer
->conf_if
;
12351 } else if (strchr(peer
->host
, ':'))
12352 match_type
= IPV6_TKN
;
12354 match_type
= IPV4_TKN
;
12356 if (token
->type
!= match_type
)
12359 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12364 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12365 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12366 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12367 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12368 {.completions
= NULL
}};
12370 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12373 struct peer_group
*group
;
12374 struct listnode
*lnbgp
, *lnpeer
;
12376 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12377 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12378 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12383 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12384 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12385 {.completions
= NULL
} };
12387 void bgp_vty_init(void)
12389 cmd_variable_handler_register(bgp_var_neighbor
);
12390 cmd_variable_handler_register(bgp_var_peergroup
);
12392 /* Install bgp top node. */
12393 install_node(&bgp_node
, bgp_config_write
);
12394 install_node(&bgp_ipv4_unicast_node
, NULL
);
12395 install_node(&bgp_ipv4_multicast_node
, NULL
);
12396 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12397 install_node(&bgp_ipv6_unicast_node
, NULL
);
12398 install_node(&bgp_ipv6_multicast_node
, NULL
);
12399 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12400 install_node(&bgp_vpnv4_node
, NULL
);
12401 install_node(&bgp_vpnv6_node
, NULL
);
12402 install_node(&bgp_evpn_node
, NULL
);
12403 install_node(&bgp_evpn_vni_node
, NULL
);
12404 install_node(&bgp_flowspecv4_node
, NULL
);
12405 install_node(&bgp_flowspecv6_node
, NULL
);
12407 /* Install default VTY commands to new nodes. */
12408 install_default(BGP_NODE
);
12409 install_default(BGP_IPV4_NODE
);
12410 install_default(BGP_IPV4M_NODE
);
12411 install_default(BGP_IPV4L_NODE
);
12412 install_default(BGP_IPV6_NODE
);
12413 install_default(BGP_IPV6M_NODE
);
12414 install_default(BGP_IPV6L_NODE
);
12415 install_default(BGP_VPNV4_NODE
);
12416 install_default(BGP_VPNV6_NODE
);
12417 install_default(BGP_FLOWSPECV4_NODE
);
12418 install_default(BGP_FLOWSPECV6_NODE
);
12419 install_default(BGP_EVPN_NODE
);
12420 install_default(BGP_EVPN_VNI_NODE
);
12422 /* "bgp multiple-instance" commands. */
12423 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
12424 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
12426 /* "bgp config-type" commands. */
12427 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
12428 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
12430 /* bgp route-map delay-timer commands. */
12431 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12432 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12434 /* Dummy commands (Currently not supported) */
12435 install_element(BGP_NODE
, &no_synchronization_cmd
);
12436 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12438 /* "router bgp" commands. */
12439 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12441 /* "no router bgp" commands. */
12442 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12444 /* "bgp router-id" commands. */
12445 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12446 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12448 /* "bgp cluster-id" commands. */
12449 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12450 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12452 /* "bgp confederation" commands. */
12453 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12454 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12456 /* "bgp confederation peers" commands. */
12457 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12458 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12460 /* bgp max-med command */
12461 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12462 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12463 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12464 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12465 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12467 /* bgp disable-ebgp-connected-nh-check */
12468 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12469 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12471 /* bgp update-delay command */
12472 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12473 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12474 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12476 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12477 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12478 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12479 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12481 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12482 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12484 /* "maximum-paths" commands. */
12485 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12486 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12487 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12488 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12489 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12490 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12491 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12492 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12493 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12494 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12495 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12496 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12497 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12498 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12499 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12501 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12502 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12503 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12504 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12505 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12507 /* "timers bgp" commands. */
12508 install_element(BGP_NODE
, &bgp_timers_cmd
);
12509 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12511 /* route-map delay-timer commands - per instance for backwards compat.
12513 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12514 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12516 /* "bgp client-to-client reflection" commands */
12517 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
12518 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
12520 /* "bgp always-compare-med" commands */
12521 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
12522 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
12524 /* "bgp deterministic-med" commands */
12525 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
12526 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
12528 /* "bgp graceful-restart" commands */
12529 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
12530 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
12531 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
12532 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
12533 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
12534 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
12536 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
12537 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
12539 /* "bgp graceful-shutdown" commands */
12540 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
12541 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
12543 /* "bgp fast-external-failover" commands */
12544 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
12545 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
12547 /* "bgp enforce-first-as" commands */
12548 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
12550 /* "bgp bestpath compare-routerid" commands */
12551 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
12552 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
12554 /* "bgp bestpath as-path ignore" commands */
12555 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
12556 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
12558 /* "bgp bestpath as-path confed" commands */
12559 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
12560 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
12562 /* "bgp bestpath as-path multipath-relax" commands */
12563 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
12564 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
12566 /* "bgp log-neighbor-changes" commands */
12567 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
12568 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
12570 /* "bgp bestpath med" commands */
12571 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
12572 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
12574 /* "no bgp default ipv4-unicast" commands. */
12575 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
12576 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
12578 /* "bgp network import-check" commands. */
12579 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
12580 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
12581 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
12583 /* "bgp default local-preference" commands. */
12584 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
12585 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
12587 /* bgp default show-hostname */
12588 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
12589 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
12591 /* "bgp default subgroup-pkt-queue-max" commands. */
12592 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
12593 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
12595 /* bgp ibgp-allow-policy-mods command */
12596 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
12597 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
12599 /* "bgp listen limit" commands. */
12600 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
12601 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
12603 /* "bgp listen range" commands. */
12604 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
12605 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
12607 /* "bgp default shutdown" command */
12608 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
12610 /* "neighbor remote-as" commands. */
12611 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
12612 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
12613 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
12614 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
12615 install_element(BGP_NODE
,
12616 &neighbor_interface_v6only_config_remote_as_cmd
);
12617 install_element(BGP_NODE
, &no_neighbor_cmd
);
12618 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
12620 /* "neighbor peer-group" commands. */
12621 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
12622 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
12623 install_element(BGP_NODE
,
12624 &no_neighbor_interface_peer_group_remote_as_cmd
);
12626 /* "neighbor local-as" commands. */
12627 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
12628 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
12629 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
12630 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
12632 /* "neighbor solo" commands. */
12633 install_element(BGP_NODE
, &neighbor_solo_cmd
);
12634 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
12636 /* "neighbor password" commands. */
12637 install_element(BGP_NODE
, &neighbor_password_cmd
);
12638 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
12640 /* "neighbor activate" commands. */
12641 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
12642 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
12643 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
12644 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
12645 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
12646 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
12647 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
12648 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
12649 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
12650 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
12651 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
12652 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
12654 /* "no neighbor activate" commands. */
12655 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
12656 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
12657 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
12658 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
12659 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
12660 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
12661 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
12662 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
12663 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
12664 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
12665 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
12666 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
12668 /* "neighbor peer-group" set commands. */
12669 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
12670 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12671 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12672 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12673 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12674 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12675 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12676 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12677 install_element(BGP_FLOWSPECV4_NODE
,
12678 &neighbor_set_peer_group_hidden_cmd
);
12679 install_element(BGP_FLOWSPECV6_NODE
,
12680 &neighbor_set_peer_group_hidden_cmd
);
12682 /* "no neighbor peer-group unset" commands. */
12683 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
12684 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12685 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12686 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12687 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12688 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12689 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12690 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12691 install_element(BGP_FLOWSPECV4_NODE
,
12692 &no_neighbor_set_peer_group_hidden_cmd
);
12693 install_element(BGP_FLOWSPECV6_NODE
,
12694 &no_neighbor_set_peer_group_hidden_cmd
);
12696 /* "neighbor softreconfiguration inbound" commands.*/
12697 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
12698 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
12699 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12700 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12701 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12702 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12703 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12704 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12705 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12706 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12707 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12708 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12709 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12710 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12711 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12712 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12713 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12714 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12715 install_element(BGP_FLOWSPECV4_NODE
,
12716 &neighbor_soft_reconfiguration_cmd
);
12717 install_element(BGP_FLOWSPECV4_NODE
,
12718 &no_neighbor_soft_reconfiguration_cmd
);
12719 install_element(BGP_FLOWSPECV6_NODE
,
12720 &neighbor_soft_reconfiguration_cmd
);
12721 install_element(BGP_FLOWSPECV6_NODE
,
12722 &no_neighbor_soft_reconfiguration_cmd
);
12724 /* "neighbor attribute-unchanged" commands. */
12725 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
12726 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
12727 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
12728 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
12729 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
12730 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
12731 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
12732 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
12733 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
12734 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
12735 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
12736 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
12737 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
12738 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
12739 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
12740 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
12741 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
12742 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
12744 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
12745 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
12747 /* "nexthop-local unchanged" commands */
12748 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
12749 install_element(BGP_IPV6_NODE
,
12750 &no_neighbor_nexthop_local_unchanged_cmd
);
12752 /* "neighbor next-hop-self" commands. */
12753 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
12754 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
12755 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
12756 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
12757 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
12758 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
12759 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
12760 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
12761 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
12762 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
12763 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
12764 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
12765 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
12766 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
12767 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
12768 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
12769 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
12770 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
12771 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
12772 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
12774 /* "neighbor next-hop-self force" commands. */
12775 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
12776 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
12777 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
12778 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12779 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
12780 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12781 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
12782 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12783 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
12784 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12785 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
12786 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12787 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
12788 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12789 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
12790 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12791 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
12792 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12794 /* "neighbor as-override" commands. */
12795 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
12796 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
12797 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
12798 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
12799 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
12800 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
12801 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
12802 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
12803 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
12804 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
12805 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
12806 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
12807 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
12808 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
12809 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
12810 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
12811 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
12812 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
12814 /* "neighbor remove-private-AS" commands. */
12815 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
12816 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
12817 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
12818 install_element(BGP_NODE
,
12819 &no_neighbor_remove_private_as_all_hidden_cmd
);
12820 install_element(BGP_NODE
,
12821 &neighbor_remove_private_as_replace_as_hidden_cmd
);
12822 install_element(BGP_NODE
,
12823 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
12824 install_element(BGP_NODE
,
12825 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
12828 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
12829 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
12830 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
12831 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
12832 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12833 install_element(BGP_IPV4_NODE
,
12834 &neighbor_remove_private_as_replace_as_cmd
);
12835 install_element(BGP_IPV4_NODE
,
12836 &no_neighbor_remove_private_as_replace_as_cmd
);
12837 install_element(BGP_IPV4_NODE
,
12838 &neighbor_remove_private_as_all_replace_as_cmd
);
12839 install_element(BGP_IPV4_NODE
,
12840 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12841 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
12842 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
12843 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
12844 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12845 install_element(BGP_IPV4M_NODE
,
12846 &neighbor_remove_private_as_replace_as_cmd
);
12847 install_element(BGP_IPV4M_NODE
,
12848 &no_neighbor_remove_private_as_replace_as_cmd
);
12849 install_element(BGP_IPV4M_NODE
,
12850 &neighbor_remove_private_as_all_replace_as_cmd
);
12851 install_element(BGP_IPV4M_NODE
,
12852 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12853 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
12854 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
12855 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
12856 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12857 install_element(BGP_IPV4L_NODE
,
12858 &neighbor_remove_private_as_replace_as_cmd
);
12859 install_element(BGP_IPV4L_NODE
,
12860 &no_neighbor_remove_private_as_replace_as_cmd
);
12861 install_element(BGP_IPV4L_NODE
,
12862 &neighbor_remove_private_as_all_replace_as_cmd
);
12863 install_element(BGP_IPV4L_NODE
,
12864 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12865 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
12866 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
12867 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
12868 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12869 install_element(BGP_IPV6_NODE
,
12870 &neighbor_remove_private_as_replace_as_cmd
);
12871 install_element(BGP_IPV6_NODE
,
12872 &no_neighbor_remove_private_as_replace_as_cmd
);
12873 install_element(BGP_IPV6_NODE
,
12874 &neighbor_remove_private_as_all_replace_as_cmd
);
12875 install_element(BGP_IPV6_NODE
,
12876 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12877 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
12878 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
12879 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
12880 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12881 install_element(BGP_IPV6M_NODE
,
12882 &neighbor_remove_private_as_replace_as_cmd
);
12883 install_element(BGP_IPV6M_NODE
,
12884 &no_neighbor_remove_private_as_replace_as_cmd
);
12885 install_element(BGP_IPV6M_NODE
,
12886 &neighbor_remove_private_as_all_replace_as_cmd
);
12887 install_element(BGP_IPV6M_NODE
,
12888 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12889 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
12890 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
12891 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
12892 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12893 install_element(BGP_IPV6L_NODE
,
12894 &neighbor_remove_private_as_replace_as_cmd
);
12895 install_element(BGP_IPV6L_NODE
,
12896 &no_neighbor_remove_private_as_replace_as_cmd
);
12897 install_element(BGP_IPV6L_NODE
,
12898 &neighbor_remove_private_as_all_replace_as_cmd
);
12899 install_element(BGP_IPV6L_NODE
,
12900 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12901 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
12902 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
12903 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
12904 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12905 install_element(BGP_VPNV4_NODE
,
12906 &neighbor_remove_private_as_replace_as_cmd
);
12907 install_element(BGP_VPNV4_NODE
,
12908 &no_neighbor_remove_private_as_replace_as_cmd
);
12909 install_element(BGP_VPNV4_NODE
,
12910 &neighbor_remove_private_as_all_replace_as_cmd
);
12911 install_element(BGP_VPNV4_NODE
,
12912 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12913 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
12914 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
12915 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
12916 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12917 install_element(BGP_VPNV6_NODE
,
12918 &neighbor_remove_private_as_replace_as_cmd
);
12919 install_element(BGP_VPNV6_NODE
,
12920 &no_neighbor_remove_private_as_replace_as_cmd
);
12921 install_element(BGP_VPNV6_NODE
,
12922 &neighbor_remove_private_as_all_replace_as_cmd
);
12923 install_element(BGP_VPNV6_NODE
,
12924 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12926 /* "neighbor send-community" commands.*/
12927 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
12928 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
12929 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
12930 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
12931 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
12932 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
12933 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
12934 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
12935 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
12936 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
12937 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
12938 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
12939 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
12940 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
12941 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
12942 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
12943 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
12944 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
12945 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
12946 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
12947 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
12948 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
12949 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
12950 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
12951 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
12952 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
12953 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
12954 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
12955 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
12956 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
12957 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
12958 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
12959 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
12960 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
12961 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
12962 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
12964 /* "neighbor route-reflector" commands.*/
12965 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
12966 install_element(BGP_NODE
,
12967 &no_neighbor_route_reflector_client_hidden_cmd
);
12968 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
12969 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
12970 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
12971 install_element(BGP_IPV4M_NODE
,
12972 &no_neighbor_route_reflector_client_cmd
);
12973 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
12974 install_element(BGP_IPV4L_NODE
,
12975 &no_neighbor_route_reflector_client_cmd
);
12976 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
12977 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
12978 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
12979 install_element(BGP_IPV6M_NODE
,
12980 &no_neighbor_route_reflector_client_cmd
);
12981 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
12982 install_element(BGP_IPV6L_NODE
,
12983 &no_neighbor_route_reflector_client_cmd
);
12984 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
12985 install_element(BGP_VPNV4_NODE
,
12986 &no_neighbor_route_reflector_client_cmd
);
12987 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
12988 install_element(BGP_VPNV6_NODE
,
12989 &no_neighbor_route_reflector_client_cmd
);
12990 install_element(BGP_FLOWSPECV4_NODE
,
12991 &neighbor_route_reflector_client_cmd
);
12992 install_element(BGP_FLOWSPECV4_NODE
,
12993 &no_neighbor_route_reflector_client_cmd
);
12994 install_element(BGP_FLOWSPECV6_NODE
,
12995 &neighbor_route_reflector_client_cmd
);
12996 install_element(BGP_FLOWSPECV6_NODE
,
12997 &no_neighbor_route_reflector_client_cmd
);
12998 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
12999 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
13001 /* "neighbor route-server" commands.*/
13002 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
13003 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
13004 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
13005 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
13006 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
13007 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
13008 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
13009 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
13010 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
13011 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
13012 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
13013 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
13014 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
13015 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
13016 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
13017 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
13018 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
13019 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
13020 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
13021 install_element(BGP_FLOWSPECV4_NODE
,
13022 &no_neighbor_route_server_client_cmd
);
13023 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
13024 install_element(BGP_FLOWSPECV6_NODE
,
13025 &no_neighbor_route_server_client_cmd
);
13027 /* "neighbor addpath-tx-all-paths" commands.*/
13028 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
13029 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
13030 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13031 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13032 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13033 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13034 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13035 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13036 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13037 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13038 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13039 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13040 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13041 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13042 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13043 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13044 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13045 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13047 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
13048 install_element(BGP_NODE
,
13049 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13050 install_element(BGP_NODE
,
13051 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13052 install_element(BGP_IPV4_NODE
,
13053 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13054 install_element(BGP_IPV4_NODE
,
13055 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13056 install_element(BGP_IPV4M_NODE
,
13057 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13058 install_element(BGP_IPV4M_NODE
,
13059 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13060 install_element(BGP_IPV4L_NODE
,
13061 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13062 install_element(BGP_IPV4L_NODE
,
13063 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13064 install_element(BGP_IPV6_NODE
,
13065 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13066 install_element(BGP_IPV6_NODE
,
13067 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13068 install_element(BGP_IPV6M_NODE
,
13069 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13070 install_element(BGP_IPV6M_NODE
,
13071 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13072 install_element(BGP_IPV6L_NODE
,
13073 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13074 install_element(BGP_IPV6L_NODE
,
13075 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13076 install_element(BGP_VPNV4_NODE
,
13077 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13078 install_element(BGP_VPNV4_NODE
,
13079 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13080 install_element(BGP_VPNV6_NODE
,
13081 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13082 install_element(BGP_VPNV6_NODE
,
13083 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13085 /* "neighbor passive" commands. */
13086 install_element(BGP_NODE
, &neighbor_passive_cmd
);
13087 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13090 /* "neighbor shutdown" commands. */
13091 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13092 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13093 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13094 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13096 /* "neighbor capability extended-nexthop" commands.*/
13097 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13098 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13100 /* "neighbor capability orf prefix-list" commands.*/
13101 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13102 install_element(BGP_NODE
,
13103 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13104 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13105 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13106 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13107 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13108 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13109 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13110 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13111 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13112 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13113 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13114 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13115 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13117 /* "neighbor capability dynamic" commands.*/
13118 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13119 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13121 /* "neighbor dont-capability-negotiate" commands. */
13122 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13123 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13125 /* "neighbor ebgp-multihop" commands. */
13126 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13127 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13128 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13130 /* "neighbor disable-connected-check" commands. */
13131 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13132 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13134 /* "neighbor enforce-first-as" commands. */
13135 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13136 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13138 /* "neighbor description" commands. */
13139 install_element(BGP_NODE
, &neighbor_description_cmd
);
13140 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13141 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13143 /* "neighbor update-source" commands. "*/
13144 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13145 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13147 /* "neighbor default-originate" commands. */
13148 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13149 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13150 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13151 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13152 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13153 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13154 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13155 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13156 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13157 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13158 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13159 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13160 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13161 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13162 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13163 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13164 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13165 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13166 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13167 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13168 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13170 /* "neighbor port" commands. */
13171 install_element(BGP_NODE
, &neighbor_port_cmd
);
13172 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13174 /* "neighbor weight" commands. */
13175 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13176 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13178 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13179 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13180 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13181 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13182 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13183 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13184 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13185 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13186 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13187 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13188 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13189 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13190 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13191 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13192 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13193 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13195 /* "neighbor override-capability" commands. */
13196 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13197 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13199 /* "neighbor strict-capability-match" commands. */
13200 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13201 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13203 /* "neighbor timers" commands. */
13204 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13205 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13207 /* "neighbor timers connect" commands. */
13208 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13209 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13211 /* "neighbor advertisement-interval" commands. */
13212 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13213 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13215 /* "neighbor interface" commands. */
13216 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13217 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13219 /* "neighbor distribute" commands. */
13220 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13221 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13222 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13223 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13224 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13225 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13226 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13227 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13228 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13229 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13230 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13231 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13232 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13233 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13234 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13235 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13236 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13237 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13239 /* "neighbor prefix-list" commands. */
13240 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13241 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13242 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13243 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13244 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13245 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13246 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13247 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13248 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13249 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13250 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13251 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13252 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13253 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13254 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13255 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13256 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13257 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13258 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13259 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13260 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13261 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13263 /* "neighbor filter-list" commands. */
13264 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13265 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13266 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13267 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13268 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13269 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13270 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13271 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13272 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13273 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13274 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13275 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13276 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13277 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13278 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13279 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13280 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13281 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13282 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13283 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13284 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13285 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13287 /* "neighbor route-map" commands. */
13288 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13289 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13290 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13291 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13292 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13293 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13294 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13295 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13296 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13297 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13298 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13299 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13300 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13301 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13302 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13303 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13304 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13305 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13306 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13307 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13308 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13309 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13310 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13311 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13313 /* "neighbor unsuppress-map" commands. */
13314 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13315 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13316 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13317 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13318 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13319 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13320 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13321 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13322 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13323 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13324 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13325 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13326 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13327 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13328 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13329 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13330 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13331 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13333 /* "neighbor maximum-prefix" commands. */
13334 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13335 install_element(BGP_NODE
,
13336 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13337 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13338 install_element(BGP_NODE
,
13339 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13340 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13341 install_element(BGP_NODE
,
13342 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13343 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13344 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13345 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13346 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13347 install_element(BGP_IPV4_NODE
,
13348 &neighbor_maximum_prefix_threshold_warning_cmd
);
13349 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13350 install_element(BGP_IPV4_NODE
,
13351 &neighbor_maximum_prefix_threshold_restart_cmd
);
13352 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13353 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13354 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13355 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13356 install_element(BGP_IPV4M_NODE
,
13357 &neighbor_maximum_prefix_threshold_warning_cmd
);
13358 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13359 install_element(BGP_IPV4M_NODE
,
13360 &neighbor_maximum_prefix_threshold_restart_cmd
);
13361 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13362 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13363 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13364 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13365 install_element(BGP_IPV4L_NODE
,
13366 &neighbor_maximum_prefix_threshold_warning_cmd
);
13367 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13368 install_element(BGP_IPV4L_NODE
,
13369 &neighbor_maximum_prefix_threshold_restart_cmd
);
13370 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13371 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13372 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13373 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13374 install_element(BGP_IPV6_NODE
,
13375 &neighbor_maximum_prefix_threshold_warning_cmd
);
13376 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13377 install_element(BGP_IPV6_NODE
,
13378 &neighbor_maximum_prefix_threshold_restart_cmd
);
13379 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13380 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13381 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13382 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13383 install_element(BGP_IPV6M_NODE
,
13384 &neighbor_maximum_prefix_threshold_warning_cmd
);
13385 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13386 install_element(BGP_IPV6M_NODE
,
13387 &neighbor_maximum_prefix_threshold_restart_cmd
);
13388 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13389 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13390 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13391 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13392 install_element(BGP_IPV6L_NODE
,
13393 &neighbor_maximum_prefix_threshold_warning_cmd
);
13394 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13395 install_element(BGP_IPV6L_NODE
,
13396 &neighbor_maximum_prefix_threshold_restart_cmd
);
13397 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13398 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13399 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13400 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13401 install_element(BGP_VPNV4_NODE
,
13402 &neighbor_maximum_prefix_threshold_warning_cmd
);
13403 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13404 install_element(BGP_VPNV4_NODE
,
13405 &neighbor_maximum_prefix_threshold_restart_cmd
);
13406 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13407 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13408 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13409 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13410 install_element(BGP_VPNV6_NODE
,
13411 &neighbor_maximum_prefix_threshold_warning_cmd
);
13412 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13413 install_element(BGP_VPNV6_NODE
,
13414 &neighbor_maximum_prefix_threshold_restart_cmd
);
13415 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13417 /* "neighbor allowas-in" */
13418 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13419 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13420 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13421 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13422 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13423 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13424 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13425 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13426 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13427 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13428 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13429 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13430 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13431 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13432 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13433 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13434 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13435 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13436 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13437 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13439 /* address-family commands. */
13440 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13441 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13442 #ifdef KEEP_OLD_VPN_COMMANDS
13443 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13444 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13445 #endif /* KEEP_OLD_VPN_COMMANDS */
13447 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13449 /* "exit-address-family" command. */
13450 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13451 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13452 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13453 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13454 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13455 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13456 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13457 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13458 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13459 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13460 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13462 /* "clear ip bgp commands" */
13463 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13465 /* clear ip bgp prefix */
13466 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13467 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13468 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13470 /* "show [ip] bgp summary" commands. */
13471 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13472 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13473 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13474 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13475 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13476 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
13478 /* "show [ip] bgp neighbors" commands. */
13479 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
13481 /* "show [ip] bgp peer-group" commands. */
13482 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
13484 /* "show [ip] bgp paths" commands. */
13485 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
13487 /* "show [ip] bgp community" commands. */
13488 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
13490 /* "show ip bgp large-community" commands. */
13491 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
13492 /* "show [ip] bgp attribute-info" commands. */
13493 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
13494 /* "show [ip] bgp route-leak" command */
13495 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
13497 /* "redistribute" commands. */
13498 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
13499 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
13500 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
13501 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
13502 install_element(BGP_NODE
,
13503 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
13504 install_element(BGP_NODE
,
13505 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
13506 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
13507 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
13508 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
13509 install_element(BGP_NODE
,
13510 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
13511 install_element(BGP_NODE
,
13512 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
13513 install_element(BGP_NODE
,
13514 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
13515 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
13516 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
13517 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
13518 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
13519 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
13520 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
13521 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
13522 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
13523 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
13524 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
13525 install_element(BGP_IPV4_NODE
,
13526 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
13527 install_element(BGP_IPV4_NODE
,
13528 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
13529 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
13530 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
13531 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
13532 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
13533 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
13534 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
13536 /* import|export vpn [route-map WORD] */
13537 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
13538 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
13540 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
13541 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
13543 /* ttl_security commands */
13544 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
13545 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
13547 /* "show [ip] bgp memory" commands. */
13548 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
13550 /* "show bgp martian next-hop" */
13551 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
13553 /* "show [ip] bgp views" commands. */
13554 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
13556 /* "show [ip] bgp vrfs" commands. */
13557 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
13559 /* Community-list. */
13560 community_list_vty();
13562 /* vpn-policy commands */
13563 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
13564 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
13565 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
13566 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
13567 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
13568 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
13569 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
13570 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
13571 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
13572 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
13573 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
13574 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
13576 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
13577 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
13579 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
13580 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
13581 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
13582 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
13583 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
13584 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
13585 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
13586 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
13587 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13588 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13589 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
13590 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
13593 #include "memory.h"
13594 #include "bgp_regex.h"
13595 #include "bgp_clist.h"
13596 #include "bgp_ecommunity.h"
13598 /* VTY functions. */
13600 /* Direction value to string conversion. */
13601 static const char *community_direct_str(int direct
)
13604 case COMMUNITY_DENY
:
13606 case COMMUNITY_PERMIT
:
13613 /* Display error string. */
13614 static void community_list_perror(struct vty
*vty
, int ret
)
13617 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
13618 vty_out(vty
, "%% Can't find community-list\n");
13620 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
13621 vty_out(vty
, "%% Malformed community-list value\n");
13623 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
13625 "%% Community name conflict, previously defined as standard community\n");
13627 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
13629 "%% Community name conflict, previously defined as expanded community\n");
13634 /* "community-list" keyword help string. */
13635 #define COMMUNITY_LIST_STR "Add a community list entry\n"
13637 /* ip community-list standard */
13638 DEFUN (ip_community_list_standard
,
13639 ip_community_list_standard_cmd
,
13640 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13643 "Community list number (standard)\n"
13644 "Add an standard community-list entry\n"
13645 "Community list name\n"
13646 "Specify community to reject\n"
13647 "Specify community to accept\n"
13650 char *cl_name_or_number
= NULL
;
13652 int style
= COMMUNITY_LIST_STANDARD
;
13655 argv_find(argv
, argc
, "(1-99)", &idx
);
13656 argv_find(argv
, argc
, "WORD", &idx
);
13657 cl_name_or_number
= argv
[idx
]->arg
;
13658 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13660 argv_find(argv
, argc
, "AA:NN", &idx
);
13661 char *str
= argv_concat(argv
, argc
, idx
);
13663 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
13666 XFREE(MTYPE_TMP
, str
);
13669 /* Display error string. */
13670 community_list_perror(vty
, ret
);
13671 return CMD_WARNING_CONFIG_FAILED
;
13674 return CMD_SUCCESS
;
13677 DEFUN (no_ip_community_list_standard_all
,
13678 no_ip_community_list_standard_all_cmd
,
13679 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13683 "Community list number (standard)\n"
13684 "Add an standard community-list entry\n"
13685 "Community list name\n"
13686 "Specify community to reject\n"
13687 "Specify community to accept\n"
13690 char *cl_name_or_number
= NULL
;
13692 int style
= COMMUNITY_LIST_STANDARD
;
13695 argv_find(argv
, argc
, "(1-99)", &idx
);
13696 argv_find(argv
, argc
, "WORD", &idx
);
13697 cl_name_or_number
= argv
[idx
]->arg
;
13698 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13700 argv_find(argv
, argc
, "AA:NN", &idx
);
13701 char *str
= argv_concat(argv
, argc
, idx
);
13703 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
13706 XFREE(MTYPE_TMP
, str
);
13709 community_list_perror(vty
, ret
);
13710 return CMD_WARNING_CONFIG_FAILED
;
13713 return CMD_SUCCESS
;
13716 /* ip community-list expanded */
13717 DEFUN (ip_community_list_expanded_all
,
13718 ip_community_list_expanded_all_cmd
,
13719 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13722 "Community list number (expanded)\n"
13723 "Add an expanded community-list entry\n"
13724 "Community list name\n"
13725 "Specify community to reject\n"
13726 "Specify community to accept\n"
13729 char *cl_name_or_number
= NULL
;
13731 int style
= COMMUNITY_LIST_EXPANDED
;
13734 argv_find(argv
, argc
, "(100-500)", &idx
);
13735 argv_find(argv
, argc
, "WORD", &idx
);
13736 cl_name_or_number
= argv
[idx
]->arg
;
13737 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13739 argv_find(argv
, argc
, "AA:NN", &idx
);
13740 char *str
= argv_concat(argv
, argc
, idx
);
13742 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
13745 XFREE(MTYPE_TMP
, str
);
13748 /* Display error string. */
13749 community_list_perror(vty
, ret
);
13750 return CMD_WARNING_CONFIG_FAILED
;
13753 return CMD_SUCCESS
;
13756 DEFUN (no_ip_community_list_expanded_all
,
13757 no_ip_community_list_expanded_all_cmd
,
13758 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13762 "Community list number (expanded)\n"
13763 "Add an expanded community-list entry\n"
13764 "Community list name\n"
13765 "Specify community to reject\n"
13766 "Specify community to accept\n"
13769 char *cl_name_or_number
= NULL
;
13771 int style
= COMMUNITY_LIST_EXPANDED
;
13774 argv_find(argv
, argc
, "(100-500)", &idx
);
13775 argv_find(argv
, argc
, "WORD", &idx
);
13776 cl_name_or_number
= argv
[idx
]->arg
;
13777 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13779 argv_find(argv
, argc
, "AA:NN", &idx
);
13780 char *str
= argv_concat(argv
, argc
, idx
);
13782 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
13785 XFREE(MTYPE_TMP
, str
);
13788 community_list_perror(vty
, ret
);
13789 return CMD_WARNING_CONFIG_FAILED
;
13792 return CMD_SUCCESS
;
13795 /* Return configuration string of community-list entry. */
13796 static const char *community_list_config_str(struct community_entry
*entry
)
13803 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
13804 str
= community_str(entry
->u
.com
, false);
13805 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
13806 str
= lcommunity_str(entry
->u
.lcom
, false);
13808 str
= entry
->config
;
13813 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
13815 struct community_entry
*entry
;
13817 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13818 if (entry
== list
->head
) {
13819 if (all_digit(list
->name
))
13820 vty_out(vty
, "Community %s list %s\n",
13821 entry
->style
== COMMUNITY_LIST_STANDARD
13823 : "(expanded) access",
13826 vty_out(vty
, "Named Community %s list %s\n",
13827 entry
->style
== COMMUNITY_LIST_STANDARD
13833 vty_out(vty
, " %s\n",
13834 community_direct_str(entry
->direct
));
13836 vty_out(vty
, " %s %s\n",
13837 community_direct_str(entry
->direct
),
13838 community_list_config_str(entry
));
13842 DEFUN (show_ip_community_list
,
13843 show_ip_community_list_cmd
,
13844 "show ip community-list",
13847 "List community-list\n")
13849 struct community_list
*list
;
13850 struct community_list_master
*cm
;
13852 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
13854 return CMD_SUCCESS
;
13856 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13857 community_list_show(vty
, list
);
13859 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13860 community_list_show(vty
, list
);
13862 return CMD_SUCCESS
;
13865 DEFUN (show_ip_community_list_arg
,
13866 show_ip_community_list_arg_cmd
,
13867 "show ip community-list <(1-500)|WORD>",
13870 "List community-list\n"
13871 "Community-list number\n"
13872 "Community-list name\n")
13874 int idx_comm_list
= 3;
13875 struct community_list
*list
;
13877 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
13878 COMMUNITY_LIST_MASTER
);
13880 vty_out(vty
, "%% Can't find community-list\n");
13881 return CMD_WARNING
;
13884 community_list_show(vty
, list
);
13886 return CMD_SUCCESS
;
13890 * Large Community code.
13892 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
13893 struct cmd_token
**argv
, int style
,
13894 int reject_all_digit_name
)
13902 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13905 /* All digit name check. */
13907 argv_find(argv
, argc
, "WORD", &idx
);
13908 argv_find(argv
, argc
, "(1-99)", &idx
);
13909 argv_find(argv
, argc
, "(100-500)", &idx
);
13910 cl_name
= argv
[idx
]->arg
;
13911 if (reject_all_digit_name
&& all_digit(cl_name
)) {
13912 vty_out(vty
, "%% Community name cannot have all digits\n");
13913 return CMD_WARNING_CONFIG_FAILED
;
13917 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
13918 argv_find(argv
, argc
, "LINE", &idx
);
13919 /* Concat community string argument. */
13921 str
= argv_concat(argv
, argc
, idx
);
13925 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
13927 /* Free temporary community list string allocated by
13930 XFREE(MTYPE_TMP
, str
);
13933 community_list_perror(vty
, ret
);
13934 return CMD_WARNING_CONFIG_FAILED
;
13936 return CMD_SUCCESS
;
13939 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
13940 struct cmd_token
**argv
, int style
)
13947 argv_find(argv
, argc
, "permit", &idx
);
13948 argv_find(argv
, argc
, "deny", &idx
);
13951 /* Check the list direct. */
13952 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
13953 direct
= COMMUNITY_PERMIT
;
13955 direct
= COMMUNITY_DENY
;
13958 argv_find(argv
, argc
, "LINE", &idx
);
13959 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
13960 /* Concat community string argument. */
13961 str
= argv_concat(argv
, argc
, idx
);
13965 argv_find(argv
, argc
, "(1-99)", &idx
);
13966 argv_find(argv
, argc
, "(100-500)", &idx
);
13967 argv_find(argv
, argc
, "WORD", &idx
);
13969 /* Unset community list. */
13970 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
13973 /* Free temporary community list string allocated by
13976 XFREE(MTYPE_TMP
, str
);
13979 community_list_perror(vty
, ret
);
13980 return CMD_WARNING_CONFIG_FAILED
;
13983 return CMD_SUCCESS
;
13986 /* "large-community-list" keyword help string. */
13987 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
13988 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
13990 DEFUN (ip_lcommunity_list_standard
,
13991 ip_lcommunity_list_standard_cmd
,
13992 "ip large-community-list (1-99) <deny|permit>",
13994 LCOMMUNITY_LIST_STR
13995 "Large Community list number (standard)\n"
13996 "Specify large community to reject\n"
13997 "Specify large community to accept\n")
13999 return lcommunity_list_set_vty(vty
, argc
, argv
,
14000 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14003 DEFUN (ip_lcommunity_list_standard1
,
14004 ip_lcommunity_list_standard1_cmd
,
14005 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
14007 LCOMMUNITY_LIST_STR
14008 "Large Community list number (standard)\n"
14009 "Specify large community to reject\n"
14010 "Specify large community to accept\n"
14011 LCOMMUNITY_VAL_STR
)
14013 return lcommunity_list_set_vty(vty
, argc
, argv
,
14014 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14017 DEFUN (ip_lcommunity_list_expanded
,
14018 ip_lcommunity_list_expanded_cmd
,
14019 "ip large-community-list (100-500) <deny|permit> LINE...",
14021 LCOMMUNITY_LIST_STR
14022 "Large Community list number (expanded)\n"
14023 "Specify large community to reject\n"
14024 "Specify large community to accept\n"
14025 "An ordered list as a regular-expression\n")
14027 return lcommunity_list_set_vty(vty
, argc
, argv
,
14028 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
14031 DEFUN (ip_lcommunity_list_name_standard
,
14032 ip_lcommunity_list_name_standard_cmd
,
14033 "ip large-community-list standard WORD <deny|permit>",
14035 LCOMMUNITY_LIST_STR
14036 "Specify standard large-community-list\n"
14037 "Large Community list name\n"
14038 "Specify large community to reject\n"
14039 "Specify large community to accept\n")
14041 return lcommunity_list_set_vty(vty
, argc
, argv
,
14042 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14045 DEFUN (ip_lcommunity_list_name_standard1
,
14046 ip_lcommunity_list_name_standard1_cmd
,
14047 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
14049 LCOMMUNITY_LIST_STR
14050 "Specify standard large-community-list\n"
14051 "Large Community list name\n"
14052 "Specify large community to reject\n"
14053 "Specify large community to accept\n"
14054 LCOMMUNITY_VAL_STR
)
14056 return lcommunity_list_set_vty(vty
, argc
, argv
,
14057 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14060 DEFUN (ip_lcommunity_list_name_expanded
,
14061 ip_lcommunity_list_name_expanded_cmd
,
14062 "ip large-community-list expanded WORD <deny|permit> LINE...",
14064 LCOMMUNITY_LIST_STR
14065 "Specify expanded large-community-list\n"
14066 "Large Community list name\n"
14067 "Specify large community to reject\n"
14068 "Specify large community to accept\n"
14069 "An ordered list as a regular-expression\n")
14071 return lcommunity_list_set_vty(vty
, argc
, argv
,
14072 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
14075 DEFUN (no_ip_lcommunity_list_standard_all
,
14076 no_ip_lcommunity_list_standard_all_cmd
,
14077 "no ip large-community-list <(1-99)|(100-500)|WORD>",
14080 LCOMMUNITY_LIST_STR
14081 "Large Community list number (standard)\n"
14082 "Large Community list number (expanded)\n"
14083 "Large Community list name\n")
14085 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14086 LARGE_COMMUNITY_LIST_STANDARD
);
14089 DEFUN (no_ip_lcommunity_list_name_expanded_all
,
14090 no_ip_lcommunity_list_name_expanded_all_cmd
,
14091 "no ip large-community-list expanded WORD",
14094 LCOMMUNITY_LIST_STR
14095 "Specify expanded large-community-list\n"
14096 "Large Community list name\n")
14098 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14099 LARGE_COMMUNITY_LIST_EXPANDED
);
14102 DEFUN (no_ip_lcommunity_list_standard
,
14103 no_ip_lcommunity_list_standard_cmd
,
14104 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
14107 LCOMMUNITY_LIST_STR
14108 "Large Community list number (standard)\n"
14109 "Specify large community to reject\n"
14110 "Specify large community to accept\n"
14111 LCOMMUNITY_VAL_STR
)
14113 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14114 LARGE_COMMUNITY_LIST_STANDARD
);
14117 DEFUN (no_ip_lcommunity_list_expanded
,
14118 no_ip_lcommunity_list_expanded_cmd
,
14119 "no ip large-community-list (100-500) <deny|permit> LINE...",
14122 LCOMMUNITY_LIST_STR
14123 "Large Community list number (expanded)\n"
14124 "Specify large community to reject\n"
14125 "Specify large community to accept\n"
14126 "An ordered list as a regular-expression\n")
14128 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14129 LARGE_COMMUNITY_LIST_EXPANDED
);
14132 DEFUN (no_ip_lcommunity_list_name_standard
,
14133 no_ip_lcommunity_list_name_standard_cmd
,
14134 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
14137 LCOMMUNITY_LIST_STR
14138 "Specify standard large-community-list\n"
14139 "Large Community list name\n"
14140 "Specify large community to reject\n"
14141 "Specify large community to accept\n"
14142 LCOMMUNITY_VAL_STR
)
14144 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14145 LARGE_COMMUNITY_LIST_STANDARD
);
14148 DEFUN (no_ip_lcommunity_list_name_expanded
,
14149 no_ip_lcommunity_list_name_expanded_cmd
,
14150 "no ip large-community-list expanded WORD <deny|permit> LINE...",
14153 LCOMMUNITY_LIST_STR
14154 "Specify expanded large-community-list\n"
14155 "Large community list name\n"
14156 "Specify large community to reject\n"
14157 "Specify large community to accept\n"
14158 "An ordered list as a regular-expression\n")
14160 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14161 LARGE_COMMUNITY_LIST_EXPANDED
);
14164 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14166 struct community_entry
*entry
;
14168 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14169 if (entry
== list
->head
) {
14170 if (all_digit(list
->name
))
14171 vty_out(vty
, "Large community %s list %s\n",
14172 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14174 : "(expanded) access",
14178 "Named large community %s list %s\n",
14179 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14185 vty_out(vty
, " %s\n",
14186 community_direct_str(entry
->direct
));
14188 vty_out(vty
, " %s %s\n",
14189 community_direct_str(entry
->direct
),
14190 community_list_config_str(entry
));
14194 DEFUN (show_ip_lcommunity_list
,
14195 show_ip_lcommunity_list_cmd
,
14196 "show ip large-community-list",
14199 "List large-community list\n")
14201 struct community_list
*list
;
14202 struct community_list_master
*cm
;
14204 cm
= community_list_master_lookup(bgp_clist
,
14205 LARGE_COMMUNITY_LIST_MASTER
);
14207 return CMD_SUCCESS
;
14209 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14210 lcommunity_list_show(vty
, list
);
14212 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14213 lcommunity_list_show(vty
, list
);
14215 return CMD_SUCCESS
;
14218 DEFUN (show_ip_lcommunity_list_arg
,
14219 show_ip_lcommunity_list_arg_cmd
,
14220 "show ip large-community-list <(1-500)|WORD>",
14223 "List large-community list\n"
14224 "large-community-list number\n"
14225 "large-community-list name\n")
14227 struct community_list
*list
;
14229 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
,
14230 LARGE_COMMUNITY_LIST_MASTER
);
14232 vty_out(vty
, "%% Can't find extcommunity-list\n");
14233 return CMD_WARNING
;
14236 lcommunity_list_show(vty
, list
);
14238 return CMD_SUCCESS
;
14241 /* "extcommunity-list" keyword help string. */
14242 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
14243 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
14245 DEFUN (ip_extcommunity_list_standard
,
14246 ip_extcommunity_list_standard_cmd
,
14247 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14249 EXTCOMMUNITY_LIST_STR
14250 "Extended Community list number (standard)\n"
14251 "Specify standard extcommunity-list\n"
14252 "Community list name\n"
14253 "Specify community to reject\n"
14254 "Specify community to accept\n"
14255 EXTCOMMUNITY_VAL_STR
)
14257 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14259 char *cl_number_or_name
= NULL
;
14262 argv_find(argv
, argc
, "(1-99)", &idx
);
14263 argv_find(argv
, argc
, "WORD", &idx
);
14264 cl_number_or_name
= argv
[idx
]->arg
;
14265 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14267 argv_find(argv
, argc
, "AA:NN", &idx
);
14268 char *str
= argv_concat(argv
, argc
, idx
);
14270 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14273 XFREE(MTYPE_TMP
, str
);
14276 community_list_perror(vty
, ret
);
14277 return CMD_WARNING_CONFIG_FAILED
;
14280 return CMD_SUCCESS
;
14283 DEFUN (ip_extcommunity_list_name_expanded
,
14284 ip_extcommunity_list_name_expanded_cmd
,
14285 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14287 EXTCOMMUNITY_LIST_STR
14288 "Extended Community list number (expanded)\n"
14289 "Specify expanded extcommunity-list\n"
14290 "Extended Community list name\n"
14291 "Specify community to reject\n"
14292 "Specify community to accept\n"
14293 "An ordered list as a regular-expression\n")
14295 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
14297 char *cl_number_or_name
= NULL
;
14300 argv_find(argv
, argc
, "(100-500)", &idx
);
14301 argv_find(argv
, argc
, "WORD", &idx
);
14302 cl_number_or_name
= argv
[idx
]->arg
;
14303 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14305 argv_find(argv
, argc
, "LINE", &idx
);
14306 char *str
= argv_concat(argv
, argc
, idx
);
14308 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14311 XFREE(MTYPE_TMP
, str
);
14314 community_list_perror(vty
, ret
);
14315 return CMD_WARNING_CONFIG_FAILED
;
14318 return CMD_SUCCESS
;
14321 DEFUN (no_ip_extcommunity_list_standard_all
,
14322 no_ip_extcommunity_list_standard_all_cmd
,
14323 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14326 EXTCOMMUNITY_LIST_STR
14327 "Extended Community list number (standard)\n"
14328 "Specify standard extcommunity-list\n"
14329 "Community list name\n"
14330 "Specify community to reject\n"
14331 "Specify community to accept\n"
14332 EXTCOMMUNITY_VAL_STR
)
14334 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14336 char *cl_number_or_name
= NULL
;
14339 argv_find(argv
, argc
, "(1-99)", &idx
);
14340 argv_find(argv
, argc
, "WORD", &idx
);
14341 cl_number_or_name
= argv
[idx
]->arg
;
14342 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14344 argv_find(argv
, argc
, "AA:NN", &idx
);
14345 char *str
= argv_concat(argv
, argc
, idx
);
14347 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
14350 XFREE(MTYPE_TMP
, str
);
14353 community_list_perror(vty
, ret
);
14354 return CMD_WARNING_CONFIG_FAILED
;
14357 return CMD_SUCCESS
;
14360 DEFUN (no_ip_extcommunity_list_expanded_all
,
14361 no_ip_extcommunity_list_expanded_all_cmd
,
14362 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14365 EXTCOMMUNITY_LIST_STR
14366 "Extended Community list number (expanded)\n"
14367 "Specify expanded extcommunity-list\n"
14368 "Extended Community list name\n"
14369 "Specify community to reject\n"
14370 "Specify community to accept\n"
14371 "An ordered list as a regular-expression\n")
14373 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
14375 char *cl_number_or_name
= NULL
;
14378 argv_find(argv
, argc
, "(100-500)", &idx
);
14379 argv_find(argv
, argc
, "WORD", &idx
);
14380 cl_number_or_name
= argv
[idx
]->arg
;
14381 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14383 argv_find(argv
, argc
, "LINE", &idx
);
14384 char *str
= argv_concat(argv
, argc
, idx
);
14386 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
14389 XFREE(MTYPE_TMP
, str
);
14392 community_list_perror(vty
, ret
);
14393 return CMD_WARNING_CONFIG_FAILED
;
14396 return CMD_SUCCESS
;
14399 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14401 struct community_entry
*entry
;
14403 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14404 if (entry
== list
->head
) {
14405 if (all_digit(list
->name
))
14406 vty_out(vty
, "Extended community %s list %s\n",
14407 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14409 : "(expanded) access",
14413 "Named extended community %s list %s\n",
14414 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14420 vty_out(vty
, " %s\n",
14421 community_direct_str(entry
->direct
));
14423 vty_out(vty
, " %s %s\n",
14424 community_direct_str(entry
->direct
),
14425 community_list_config_str(entry
));
14429 DEFUN (show_ip_extcommunity_list
,
14430 show_ip_extcommunity_list_cmd
,
14431 "show ip extcommunity-list",
14434 "List extended-community list\n")
14436 struct community_list
*list
;
14437 struct community_list_master
*cm
;
14439 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
14441 return CMD_SUCCESS
;
14443 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14444 extcommunity_list_show(vty
, list
);
14446 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14447 extcommunity_list_show(vty
, list
);
14449 return CMD_SUCCESS
;
14452 DEFUN (show_ip_extcommunity_list_arg
,
14453 show_ip_extcommunity_list_arg_cmd
,
14454 "show ip extcommunity-list <(1-500)|WORD>",
14457 "List extended-community list\n"
14458 "Extcommunity-list number\n"
14459 "Extcommunity-list name\n")
14461 int idx_comm_list
= 3;
14462 struct community_list
*list
;
14464 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
14465 EXTCOMMUNITY_LIST_MASTER
);
14467 vty_out(vty
, "%% Can't find extcommunity-list\n");
14468 return CMD_WARNING
;
14471 extcommunity_list_show(vty
, list
);
14473 return CMD_SUCCESS
;
14476 /* Display community-list and extcommunity-list configuration. */
14477 static int community_list_config_write(struct vty
*vty
)
14479 struct community_list
*list
;
14480 struct community_entry
*entry
;
14481 struct community_list_master
*cm
;
14484 /* Community-list. */
14485 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14487 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14488 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14489 vty_out(vty
, "ip community-list %s %s %s\n", list
->name
,
14490 community_direct_str(entry
->direct
),
14491 community_list_config_str(entry
));
14494 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14495 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14496 vty_out(vty
, "ip community-list %s %s %s %s\n",
14497 entry
->style
== COMMUNITY_LIST_STANDARD
14500 list
->name
, community_direct_str(entry
->direct
),
14501 community_list_config_str(entry
));
14505 /* Extcommunity-list. */
14506 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
14508 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14509 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14510 vty_out(vty
, "ip extcommunity-list %s %s %s\n",
14511 list
->name
, community_direct_str(entry
->direct
),
14512 community_list_config_str(entry
));
14515 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14516 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14517 vty_out(vty
, "ip extcommunity-list %s %s %s %s\n",
14518 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14521 list
->name
, community_direct_str(entry
->direct
),
14522 community_list_config_str(entry
));
14527 /* lcommunity-list. */
14528 cm
= community_list_master_lookup(bgp_clist
,
14529 LARGE_COMMUNITY_LIST_MASTER
);
14531 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14532 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14533 vty_out(vty
, "ip large-community-list %s %s %s\n",
14534 list
->name
, community_direct_str(entry
->direct
),
14535 community_list_config_str(entry
));
14538 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14539 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14540 vty_out(vty
, "ip large-community-list %s %s %s %s\n",
14541 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
14544 list
->name
, community_direct_str(entry
->direct
),
14545 community_list_config_str(entry
));
14552 static struct cmd_node community_list_node
= {
14553 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
14556 static void community_list_vty(void)
14558 install_node(&community_list_node
, community_list_config_write
);
14560 /* Community-list. */
14561 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
14562 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
14563 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
14564 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
14565 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
14566 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
14568 /* Extcommunity-list. */
14569 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
14570 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
14571 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
14572 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
14573 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
14574 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
14576 /* Large Community List */
14577 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
14578 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
14579 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
14580 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
14581 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
14582 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
14583 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
14584 install_element(CONFIG_NODE
,
14585 &no_ip_lcommunity_list_name_expanded_all_cmd
);
14586 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
14587 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
14588 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
14589 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
14590 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
14591 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);