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
,
304 struct bgp
**bgp
, bool use_json
)
306 char *vrf_name
= NULL
;
312 if (argv_find(argv
, argc
, "ip", idx
))
315 if (argv_find(argv
, argc
, "view", idx
))
316 vrf_name
= argv
[*idx
+ 1]->arg
;
317 else if (argv_find(argv
, argc
, "vrf", idx
)) {
318 vrf_name
= argv
[*idx
+ 1]->arg
;
319 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
323 if (strmatch(vrf_name
, "all"))
326 *bgp
= bgp_lookup_by_name(vrf_name
);
329 vty_out(vty
, "{}\n");
331 vty_out(vty
, "View/Vrf %s is unknown\n",
338 *bgp
= bgp_get_default();
341 vty_out(vty
, "{}\n");
344 "Default BGP instance not found\n");
350 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
351 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
357 static int peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
359 struct interface
*ifp
= NULL
;
361 if (su
->sa
.sa_family
== AF_INET
)
362 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
363 else if (su
->sa
.sa_family
== AF_INET6
)
364 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
365 su
->sin6
.sin6_scope_id
,
374 /* Utility function for looking up peer from VTY. */
375 /* This is used only for configuration, so disallow if attempted on
376 * a dynamic neighbor.
378 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
380 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
389 ret
= str2sockunion(ip_str
, &su
);
391 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
393 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
396 "%% Malformed address or name: %s\n",
402 peer
= peer_lookup(bgp
, &su
);
405 "%% Specify remote-as or peer-group commands first\n");
408 if (peer_dynamic_neighbor(peer
)) {
410 "%% Operation not allowed on a dynamic neighbor\n");
417 /* Utility function for looking up peer or peer group. */
418 /* This is used only for configuration, so disallow if attempted on
419 * a dynamic neighbor.
421 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
423 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
426 struct peer
*peer
= NULL
;
427 struct peer_group
*group
= NULL
;
433 ret
= str2sockunion(peer_str
, &su
);
435 /* IP address, locate peer. */
436 peer
= peer_lookup(bgp
, &su
);
438 /* Not IP, could match either peer configured on interface or a
440 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
442 group
= peer_group_lookup(bgp
, peer_str
);
446 if (peer_dynamic_neighbor(peer
)) {
448 "%% Operation not allowed on a dynamic neighbor\n");
458 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
463 int bgp_vty_return(struct vty
*vty
, int ret
)
465 const char *str
= NULL
;
468 case BGP_ERR_INVALID_VALUE
:
469 str
= "Invalid value";
471 case BGP_ERR_INVALID_FLAG
:
472 str
= "Invalid flag";
474 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
475 str
= "Peer-group has been shutdown. Activate the peer-group first";
477 case BGP_ERR_PEER_FLAG_CONFLICT
:
478 str
= "Can't set override-capability and strict-capability-match at the same time";
480 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
481 str
= "Specify remote-as or peer-group remote AS first";
483 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
484 str
= "Cannot change the peer-group. Deconfigure first";
486 case BGP_ERR_PEER_GROUP_MISMATCH
:
487 str
= "Peer is not a member of this peer-group";
489 case BGP_ERR_PEER_FILTER_CONFLICT
:
490 str
= "Prefix/distribute list can not co-exist";
492 case BGP_ERR_NOT_INTERNAL_PEER
:
493 str
= "Invalid command. Not an internal neighbor";
495 case BGP_ERR_REMOVE_PRIVATE_AS
:
496 str
= "remove-private-AS cannot be configured for IBGP peers";
498 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
499 str
= "Local-AS allowed only for EBGP peers";
501 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
502 str
= "Cannot have local-as same as BGP AS number";
504 case BGP_ERR_TCPSIG_FAILED
:
505 str
= "Error while applying TCP-Sig to session(s)";
507 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
508 str
= "ebgp-multihop and ttl-security cannot be configured together";
510 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
511 str
= "ttl-security only allowed for EBGP peers";
513 case BGP_ERR_AS_OVERRIDE
:
514 str
= "as-override cannot be configured for IBGP peers";
516 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
517 str
= "Invalid limit for number of dynamic neighbors";
519 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
520 str
= "Dynamic neighbor listen range already exists";
522 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
523 str
= "Operation not allowed on a dynamic neighbor";
525 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
526 str
= "Operation not allowed on a directly connected neighbor";
528 case BGP_ERR_PEER_SAFI_CONFLICT
:
529 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
533 vty_out(vty
, "%% %s\n", str
);
534 return CMD_WARNING_CONFIG_FAILED
;
539 /* BGP clear sort. */
548 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
549 safi_t safi
, int error
)
552 case BGP_ERR_AF_UNCONFIGURED
:
554 "%%BGP: Enable %s address family for the neighbor %s\n",
555 afi_safi_print(afi
, safi
), peer
->host
);
557 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
559 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
567 /* `clear ip bgp' functions. */
568 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
569 enum clear_sort sort
, enum bgp_clear_type stype
,
575 struct listnode
*node
, *nnode
;
577 /* Clear all neighbors. */
579 * Pass along pointer to next node to peer_clear() when walking all
580 * nodes on the BGP instance as that may get freed if it is a
583 if (sort
== clear_all
) {
584 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
585 if (!peer
->afc
[afi
][safi
])
588 if (stype
== BGP_CLEAR_SOFT_NONE
)
589 ret
= peer_clear(peer
, &nnode
);
591 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
594 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
599 /* This is to apply read-only mode on this clear. */
600 if (stype
== BGP_CLEAR_SOFT_NONE
)
601 bgp
->update_delay_over
= 0;
604 vty_out(vty
, "%%BGP: No %s peer configured",
605 afi_safi_print(afi
, safi
));
610 /* Clear specified neighbor. */
611 if (sort
== clear_peer
) {
614 /* Make sockunion for lookup. */
615 ret
= str2sockunion(arg
, &su
);
617 peer
= peer_lookup_by_conf_if(bgp
, arg
);
619 peer
= peer_lookup_by_hostname(bgp
, arg
);
622 "Malformed address or name: %s\n",
628 peer
= peer_lookup(bgp
, &su
);
631 "%%BGP: Unknown neighbor - \"%s\"\n",
637 if (!peer
->afc
[afi
][safi
])
638 ret
= BGP_ERR_AF_UNCONFIGURED
;
639 else if (stype
== BGP_CLEAR_SOFT_NONE
)
640 ret
= peer_clear(peer
, NULL
);
642 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
645 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
650 /* Clear all neighbors belonging to a specific peer-group. */
651 if (sort
== clear_group
) {
652 struct peer_group
*group
;
654 group
= peer_group_lookup(bgp
, arg
);
656 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
660 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
661 if (!peer
->afc
[afi
][safi
])
664 if (stype
== BGP_CLEAR_SOFT_NONE
)
665 ret
= peer_clear(peer
, NULL
);
667 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
670 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
677 "%%BGP: No %s peer belonging to peer-group %s is configured\n",
678 afi_safi_print(afi
, safi
), arg
);
683 /* Clear all external (eBGP) neighbors. */
684 if (sort
== clear_external
) {
685 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
686 if (peer
->sort
== BGP_PEER_IBGP
)
689 if (!peer
->afc
[afi
][safi
])
692 if (stype
== BGP_CLEAR_SOFT_NONE
)
693 ret
= peer_clear(peer
, &nnode
);
695 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
698 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
705 "%%BGP: No external %s peer is configured\n",
706 afi_safi_print(afi
, safi
));
711 /* Clear all neighbors belonging to a specific AS. */
712 if (sort
== clear_as
) {
713 as_t as
= strtoul(arg
, NULL
, 10);
715 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
719 if (!peer
->afc
[afi
][safi
])
720 ret
= BGP_ERR_AF_UNCONFIGURED
;
721 else if (stype
== BGP_CLEAR_SOFT_NONE
)
722 ret
= peer_clear(peer
, &nnode
);
724 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
727 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
734 "%%BGP: No %s peer is configured with AS %s\n",
735 afi_safi_print(afi
, safi
), arg
);
743 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
744 safi_t safi
, enum clear_sort sort
,
745 enum bgp_clear_type stype
, const char *arg
)
749 /* BGP structure lookup. */
751 bgp
= bgp_lookup_by_name(name
);
753 vty_out(vty
, "Can't find BGP instance %s\n", name
);
757 bgp
= bgp_get_default();
759 vty_out(vty
, "No BGP process is configured\n");
764 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
767 /* clear soft inbound */
768 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
770 bgp_clear_vty(vty
, name
, AFI_IP
, SAFI_UNICAST
, clear_all
,
771 BGP_CLEAR_SOFT_IN
, NULL
);
772 bgp_clear_vty(vty
, name
, AFI_IP6
, SAFI_UNICAST
, clear_all
,
773 BGP_CLEAR_SOFT_IN
, NULL
);
776 /* clear soft outbound */
777 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
779 bgp_clear_vty(vty
, name
, AFI_IP
, SAFI_UNICAST
, clear_all
,
780 BGP_CLEAR_SOFT_OUT
, NULL
);
781 bgp_clear_vty(vty
, name
, AFI_IP6
, SAFI_UNICAST
, clear_all
,
782 BGP_CLEAR_SOFT_OUT
, NULL
);
786 #ifndef VTYSH_EXTRACT_PL
787 #include "bgpd/bgp_vty_clippy.c"
790 /* BGP global configuration. */
791 #if (CONFDATE > 20190601)
792 CPP_NOTICE("bgpd: time to remove deprecated bgp multiple-instance")
793 CPP_NOTICE("This includes BGP_OPT_MULTIPLE_INSTANCE")
795 DEFUN_HIDDEN (bgp_multiple_instance_func
,
796 bgp_multiple_instance_cmd
,
797 "bgp multiple-instance",
799 "Enable bgp multiple instance\n")
801 bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE
);
805 DEFUN_HIDDEN (no_bgp_multiple_instance
,
806 no_bgp_multiple_instance_cmd
,
807 "no bgp multiple-instance",
810 "BGP multiple instance\n")
814 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
815 vty_out(vty
, "if you are using this please let the developers know\n");
816 zlog_info("Deprecated option: `bgp multiple-instance` being used");
817 ret
= bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE
);
819 vty_out(vty
, "%% There are more than two BGP instances\n");
820 return CMD_WARNING_CONFIG_FAILED
;
825 #if (CONFDATE > 20190601)
826 CPP_NOTICE("bgpd: time to remove deprecated cli bgp config-type cisco")
827 CPP_NOTICE("This includes BGP_OPT_CISCO_CONFIG")
829 DEFUN_HIDDEN (bgp_config_type
,
831 "bgp config-type <cisco|zebra>",
833 "Configuration type\n"
838 if (argv_find(argv
, argc
, "cisco", &idx
)) {
839 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
840 vty_out(vty
, "if you are using this please let the developers know!\n");
841 zlog_info("Deprecated option: `bgp config-type cisco` being used");
842 bgp_option_set(BGP_OPT_CONFIG_CISCO
);
844 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
849 DEFUN_HIDDEN (no_bgp_config_type
,
850 no_bgp_config_type_cmd
,
851 "no bgp config-type [<cisco|zebra>]",
854 "Display configuration type\n"
858 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
863 DEFUN (no_synchronization
,
864 no_synchronization_cmd
,
865 "no synchronization",
867 "Perform IGP synchronization\n")
872 DEFUN (no_auto_summary
,
876 "Enable automatic network number summarization\n")
881 /* "router bgp" commands. */
882 DEFUN_NOSH (router_bgp
,
884 "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
888 BGP_INSTANCE_HELP_STR
)
891 int idx_view_vrf
= 3;
896 const char *name
= NULL
;
897 enum bgp_instance_type inst_type
;
899 // "router bgp" without an ASN
901 // Pending: Make VRF option available for ASN less config
902 bgp
= bgp_get_default();
905 vty_out(vty
, "%% No BGP process is configured\n");
906 return CMD_WARNING_CONFIG_FAILED
;
909 if (listcount(bm
->bgp
) > 1) {
910 vty_out(vty
, "%% Please specify ASN and VRF\n");
911 return CMD_WARNING_CONFIG_FAILED
;
917 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
919 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
921 name
= argv
[idx_vrf
]->arg
;
923 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
924 if (strmatch(name
, VRF_DEFAULT_NAME
))
927 inst_type
= BGP_INSTANCE_TYPE_VRF
;
928 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
929 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
932 ret
= bgp_get(&bgp
, &as
, name
, inst_type
);
934 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET
:
936 "Please specify 'bgp multiple-instance' first\n");
937 return CMD_WARNING_CONFIG_FAILED
;
938 case BGP_ERR_AS_MISMATCH
:
939 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
940 return CMD_WARNING_CONFIG_FAILED
;
941 case BGP_ERR_INSTANCE_MISMATCH
:
943 "BGP instance name and AS number mismatch\n");
945 "BGP instance is already running; AS is %u\n",
947 return CMD_WARNING_CONFIG_FAILED
;
951 * If we just instantiated the default instance, complete
952 * any pending VRF-VPN leaking that was configured via
953 * earlier "router bgp X vrf FOO" blocks.
955 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
956 vpn_leak_postchange_all();
958 /* Pending: handle when user tries to change a view to vrf n vv.
962 /* unset the auto created flag as the user config is now present */
963 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
964 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
969 /* "no router bgp" commands. */
970 DEFUN (no_router_bgp
,
972 "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
977 BGP_INSTANCE_HELP_STR
)
983 const char *name
= NULL
;
985 // "no router bgp" without an ASN
987 // Pending: Make VRF option available for ASN less config
988 bgp
= bgp_get_default();
991 vty_out(vty
, "%% No BGP process is configured\n");
992 return CMD_WARNING_CONFIG_FAILED
;
995 if (listcount(bm
->bgp
) > 1) {
996 vty_out(vty
, "%% Please specify ASN and VRF\n");
997 return CMD_WARNING_CONFIG_FAILED
;
1001 vty_out(vty
, "%% Please unconfigure l3vni %u",
1003 return CMD_WARNING_CONFIG_FAILED
;
1006 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1009 name
= argv
[idx_vrf
]->arg
;
1011 /* Lookup bgp structure. */
1012 bgp
= bgp_lookup(as
, name
);
1014 vty_out(vty
, "%% Can't find BGP instance\n");
1015 return CMD_WARNING_CONFIG_FAILED
;
1019 vty_out(vty
, "%% Please unconfigure l3vni %u",
1021 return CMD_WARNING_CONFIG_FAILED
;
1031 /* BGP router-id. */
1033 DEFPY (bgp_router_id
,
1035 "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
);
1041 bgp_router_id_static_set(bgp
, router_id
);
1045 DEFPY (no_bgp_router_id
,
1046 no_bgp_router_id_cmd
,
1047 "no bgp router-id [A.B.C.D]",
1050 "Override configured router identifier\n"
1051 "Manually configured router identifier\n")
1053 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1055 if (router_id_str
) {
1056 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1057 vty_out(vty
, "%% BGP router-id doesn't match\n");
1058 return CMD_WARNING_CONFIG_FAILED
;
1062 router_id
.s_addr
= 0;
1063 bgp_router_id_static_set(bgp
, router_id
);
1069 /* BGP Cluster ID. */
1070 DEFUN (bgp_cluster_id
,
1072 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1074 "Configure Route-Reflector Cluster-id\n"
1075 "Route-Reflector Cluster-id in IP address format\n"
1076 "Route-Reflector Cluster-id as 32 bit quantity\n")
1078 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1081 struct in_addr cluster
;
1083 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1085 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1086 return CMD_WARNING_CONFIG_FAILED
;
1089 bgp_cluster_id_set(bgp
, &cluster
);
1090 bgp_clear_star_soft_out(vty
, bgp
->name
);
1095 DEFUN (no_bgp_cluster_id
,
1096 no_bgp_cluster_id_cmd
,
1097 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1100 "Configure Route-Reflector Cluster-id\n"
1101 "Route-Reflector Cluster-id in IP address format\n"
1102 "Route-Reflector Cluster-id as 32 bit quantity\n")
1104 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1105 bgp_cluster_id_unset(bgp
);
1106 bgp_clear_star_soft_out(vty
, bgp
->name
);
1111 DEFUN (bgp_confederation_identifier
,
1112 bgp_confederation_identifier_cmd
,
1113 "bgp confederation identifier (1-4294967295)",
1114 "BGP specific commands\n"
1115 "AS confederation parameters\n"
1117 "Set routing domain confederation AS\n")
1119 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1123 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1125 bgp_confederation_id_set(bgp
, as
);
1130 DEFUN (no_bgp_confederation_identifier
,
1131 no_bgp_confederation_identifier_cmd
,
1132 "no bgp confederation identifier [(1-4294967295)]",
1134 "BGP specific commands\n"
1135 "AS confederation parameters\n"
1137 "Set routing domain confederation AS\n")
1139 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1140 bgp_confederation_id_unset(bgp
);
1145 DEFUN (bgp_confederation_peers
,
1146 bgp_confederation_peers_cmd
,
1147 "bgp confederation peers (1-4294967295)...",
1148 "BGP specific commands\n"
1149 "AS confederation parameters\n"
1150 "Peer ASs in BGP confederation\n"
1153 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1158 for (i
= idx_asn
; i
< argc
; i
++) {
1159 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1161 if (bgp
->as
== as
) {
1163 "%% Local member-AS not allowed in confed peer list\n");
1167 bgp_confederation_peers_add(bgp
, as
);
1172 DEFUN (no_bgp_confederation_peers
,
1173 no_bgp_confederation_peers_cmd
,
1174 "no bgp confederation peers (1-4294967295)...",
1176 "BGP specific commands\n"
1177 "AS confederation parameters\n"
1178 "Peer ASs in BGP confederation\n"
1181 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1186 for (i
= idx_asn
; i
< argc
; i
++) {
1187 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1189 bgp_confederation_peers_remove(bgp
, as
);
1195 * Central routine for maximum-paths configuration.
1196 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1197 * @set: 1 for setting values, 0 for removing the max-paths config.
1199 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1200 const char *mpaths
, uint16_t options
,
1203 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1204 uint16_t maxpaths
= 0;
1209 afi
= bgp_node_afi(vty
);
1210 safi
= bgp_node_safi(vty
);
1213 maxpaths
= strtol(mpaths
, NULL
, 10);
1214 if (maxpaths
> multipath_num
) {
1216 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1217 maxpaths
, multipath_num
);
1218 return CMD_WARNING_CONFIG_FAILED
;
1220 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1223 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1227 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1228 (set
== 1) ? "" : "un",
1229 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1230 maxpaths
, afi
, safi
);
1231 return CMD_WARNING_CONFIG_FAILED
;
1234 bgp_recalculate_all_bestpaths(bgp
);
1239 DEFUN (bgp_maxmed_admin
,
1240 bgp_maxmed_admin_cmd
,
1241 "bgp max-med administrative ",
1243 "Advertise routes with max-med\n"
1244 "Administratively applied, for an indefinite period\n")
1246 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1248 bgp
->v_maxmed_admin
= 1;
1249 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1251 bgp_maxmed_update(bgp
);
1256 DEFUN (bgp_maxmed_admin_medv
,
1257 bgp_maxmed_admin_medv_cmd
,
1258 "bgp max-med administrative (0-4294967295)",
1260 "Advertise routes with max-med\n"
1261 "Administratively applied, for an indefinite period\n"
1262 "Max MED value to be used\n")
1264 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1267 bgp
->v_maxmed_admin
= 1;
1268 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1270 bgp_maxmed_update(bgp
);
1275 DEFUN (no_bgp_maxmed_admin
,
1276 no_bgp_maxmed_admin_cmd
,
1277 "no bgp max-med administrative [(0-4294967295)]",
1280 "Advertise routes with max-med\n"
1281 "Administratively applied, for an indefinite period\n"
1282 "Max MED value to be used\n")
1284 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1285 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1286 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1287 bgp_maxmed_update(bgp
);
1292 DEFUN (bgp_maxmed_onstartup
,
1293 bgp_maxmed_onstartup_cmd
,
1294 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1296 "Advertise routes with max-med\n"
1297 "Effective on a startup\n"
1298 "Time (seconds) period for max-med\n"
1299 "Max MED value to be used\n")
1301 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1304 argv_find(argv
, argc
, "(5-86400)", &idx
);
1305 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1306 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1307 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1309 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1311 bgp_maxmed_update(bgp
);
1316 DEFUN (no_bgp_maxmed_onstartup
,
1317 no_bgp_maxmed_onstartup_cmd
,
1318 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1321 "Advertise routes with max-med\n"
1322 "Effective on a startup\n"
1323 "Time (seconds) period for max-med\n"
1324 "Max MED value to be used\n")
1326 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1328 /* Cancel max-med onstartup if its on */
1329 if (bgp
->t_maxmed_onstartup
) {
1330 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1331 bgp
->maxmed_onstartup_over
= 1;
1334 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1335 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1337 bgp_maxmed_update(bgp
);
1342 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1345 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1346 uint16_t update_delay
;
1347 uint16_t establish_wait
;
1349 update_delay
= strtoul(delay
, NULL
, 10);
1351 if (!wait
) /* update-delay <delay> */
1353 bgp
->v_update_delay
= update_delay
;
1354 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1358 /* update-delay <delay> <establish-wait> */
1359 establish_wait
= atoi(wait
);
1360 if (update_delay
< establish_wait
) {
1362 "%%Failed: update-delay less than the establish-wait!\n");
1363 return CMD_WARNING_CONFIG_FAILED
;
1366 bgp
->v_update_delay
= update_delay
;
1367 bgp
->v_establish_wait
= establish_wait
;
1372 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1374 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1376 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1377 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1382 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1384 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1385 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1386 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1387 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1393 /* Update-delay configuration */
1394 DEFUN (bgp_update_delay
,
1395 bgp_update_delay_cmd
,
1396 "update-delay (0-3600)",
1397 "Force initial delay for best-path and updates\n"
1401 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1404 DEFUN (bgp_update_delay_establish_wait
,
1405 bgp_update_delay_establish_wait_cmd
,
1406 "update-delay (0-3600) (1-3600)",
1407 "Force initial delay for best-path and updates\n"
1412 int idx_number_2
= 2;
1413 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1414 argv
[idx_number_2
]->arg
);
1417 /* Update-delay deconfiguration */
1418 DEFUN (no_bgp_update_delay
,
1419 no_bgp_update_delay_cmd
,
1420 "no update-delay [(0-3600) [(1-3600)]]",
1422 "Force initial delay for best-path and updates\n"
1426 return bgp_update_delay_deconfig_vty(vty
);
1430 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1433 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1436 uint32_t quanta
= strtoul(num
, NULL
, 10);
1437 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
,
1438 memory_order_relaxed
);
1440 atomic_store_explicit(&bgp
->wpkt_quanta
, BGP_WRITE_PACKET_MAX
,
1441 memory_order_relaxed
);
1447 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1450 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1453 uint32_t quanta
= strtoul(num
, NULL
, 10);
1454 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
,
1455 memory_order_relaxed
);
1457 atomic_store_explicit(&bgp
->rpkt_quanta
, BGP_READ_PACKET_MAX
,
1458 memory_order_relaxed
);
1464 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1467 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1468 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1469 vty_out(vty
, " write-quanta %d\n", quanta
);
1472 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1475 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1476 if (quanta
!= BGP_READ_PACKET_MAX
)
1477 vty_out(vty
, " read-quanta %d\n", quanta
);
1480 /* Packet quanta configuration */
1481 DEFUN (bgp_wpkt_quanta
,
1482 bgp_wpkt_quanta_cmd
,
1483 "write-quanta (1-10)",
1484 "How many packets to write to peer socket per run\n"
1485 "Number of packets\n")
1488 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1491 DEFUN (no_bgp_wpkt_quanta
,
1492 no_bgp_wpkt_quanta_cmd
,
1493 "no write-quanta (1-10)",
1495 "How many packets to write to peer socket per I/O cycle\n"
1496 "Number of packets\n")
1499 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1502 DEFUN (bgp_rpkt_quanta
,
1503 bgp_rpkt_quanta_cmd
,
1504 "read-quanta (1-10)",
1505 "How many packets to read from peer socket per I/O cycle\n"
1506 "Number of packets\n")
1509 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1512 DEFUN (no_bgp_rpkt_quanta
,
1513 no_bgp_rpkt_quanta_cmd
,
1514 "no read-quanta (1-10)",
1516 "How many packets to read from peer socket per I/O cycle\n"
1517 "Number of packets\n")
1520 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1523 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1525 if (!bgp
->heuristic_coalesce
)
1526 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1530 DEFUN (bgp_coalesce_time
,
1531 bgp_coalesce_time_cmd
,
1532 "coalesce-time (0-4294967295)",
1533 "Subgroup coalesce timer\n"
1534 "Subgroup coalesce timer value (in ms)\n")
1536 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1539 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1540 bgp
->heuristic_coalesce
= false;
1541 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1545 DEFUN (no_bgp_coalesce_time
,
1546 no_bgp_coalesce_time_cmd
,
1547 "no coalesce-time (0-4294967295)",
1549 "Subgroup coalesce timer\n"
1550 "Subgroup coalesce timer value (in ms)\n")
1552 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1554 bgp
->heuristic_coalesce
= true;
1555 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1559 /* Maximum-paths configuration */
1560 DEFUN (bgp_maxpaths
,
1562 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1563 "Forward packets over multiple paths\n"
1564 "Number of paths\n")
1567 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1568 argv
[idx_number
]->arg
, 0, 1);
1571 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1572 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1573 "Forward packets over multiple paths\n"
1574 "Number of paths\n")
1576 DEFUN (bgp_maxpaths_ibgp
,
1577 bgp_maxpaths_ibgp_cmd
,
1578 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1579 "Forward packets over multiple paths\n"
1581 "Number of paths\n")
1584 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1585 argv
[idx_number
]->arg
, 0, 1);
1588 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1589 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1590 "Forward packets over multiple paths\n"
1592 "Number of paths\n")
1594 DEFUN (bgp_maxpaths_ibgp_cluster
,
1595 bgp_maxpaths_ibgp_cluster_cmd
,
1596 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1597 "Forward packets over multiple paths\n"
1600 "Match the cluster length\n")
1603 return bgp_maxpaths_config_vty(
1604 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1605 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1608 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1609 "maximum-paths ibgp " CMD_RANGE_STR(
1610 1, MULTIPATH_NUM
) " equal-cluster-length",
1611 "Forward packets over multiple paths\n"
1614 "Match the cluster length\n")
1616 DEFUN (no_bgp_maxpaths
,
1617 no_bgp_maxpaths_cmd
,
1618 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1620 "Forward packets over multiple paths\n"
1621 "Number of paths\n")
1623 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1626 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1627 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1628 "Forward packets over multiple paths\n"
1629 "Number of paths\n")
1631 DEFUN (no_bgp_maxpaths_ibgp
,
1632 no_bgp_maxpaths_ibgp_cmd
,
1633 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1635 "Forward packets over multiple paths\n"
1638 "Match the cluster length\n")
1640 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1643 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1644 "no maximum-paths ibgp [" CMD_RANGE_STR(
1645 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1647 "Forward packets over multiple paths\n"
1650 "Match the cluster length\n")
1652 void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1655 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1656 vty_out(vty
, " maximum-paths %d\n",
1657 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1660 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1661 vty_out(vty
, " maximum-paths ibgp %d",
1662 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1663 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1664 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1665 vty_out(vty
, " equal-cluster-length");
1674 "timers bgp (0-65535) (0-65535)",
1675 "Adjust routing timers\n"
1677 "Keepalive interval\n"
1680 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1682 int idx_number_2
= 3;
1683 unsigned long keepalive
= 0;
1684 unsigned long holdtime
= 0;
1686 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1687 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1689 /* Holdtime value check. */
1690 if (holdtime
< 3 && holdtime
!= 0) {
1692 "%% hold time value must be either 0 or greater than 3\n");
1693 return CMD_WARNING_CONFIG_FAILED
;
1696 bgp_timers_set(bgp
, keepalive
, holdtime
);
1701 DEFUN (no_bgp_timers
,
1703 "no timers bgp [(0-65535) (0-65535)]",
1705 "Adjust routing timers\n"
1707 "Keepalive interval\n"
1710 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1711 bgp_timers_unset(bgp
);
1717 DEFUN (bgp_client_to_client_reflection
,
1718 bgp_client_to_client_reflection_cmd
,
1719 "bgp client-to-client reflection",
1720 "BGP specific commands\n"
1721 "Configure client to client route reflection\n"
1722 "reflection of routes allowed\n")
1724 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1725 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1726 bgp_clear_star_soft_out(vty
, bgp
->name
);
1731 DEFUN (no_bgp_client_to_client_reflection
,
1732 no_bgp_client_to_client_reflection_cmd
,
1733 "no bgp client-to-client reflection",
1735 "BGP specific commands\n"
1736 "Configure client to client route reflection\n"
1737 "reflection of routes allowed\n")
1739 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1740 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1741 bgp_clear_star_soft_out(vty
, bgp
->name
);
1746 /* "bgp always-compare-med" configuration. */
1747 DEFUN (bgp_always_compare_med
,
1748 bgp_always_compare_med_cmd
,
1749 "bgp always-compare-med",
1750 "BGP specific commands\n"
1751 "Allow comparing MED from different neighbors\n")
1753 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1754 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1755 bgp_recalculate_all_bestpaths(bgp
);
1760 DEFUN (no_bgp_always_compare_med
,
1761 no_bgp_always_compare_med_cmd
,
1762 "no bgp always-compare-med",
1764 "BGP specific commands\n"
1765 "Allow comparing MED from different neighbors\n")
1767 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1768 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1769 bgp_recalculate_all_bestpaths(bgp
);
1774 /* "bgp deterministic-med" configuration. */
1775 DEFUN (bgp_deterministic_med
,
1776 bgp_deterministic_med_cmd
,
1777 "bgp deterministic-med",
1778 "BGP specific commands\n"
1779 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1781 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1783 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1784 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1785 bgp_recalculate_all_bestpaths(bgp
);
1791 DEFUN (no_bgp_deterministic_med
,
1792 no_bgp_deterministic_med_cmd
,
1793 "no bgp deterministic-med",
1795 "BGP specific commands\n"
1796 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1798 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1799 int bestpath_per_as_used
;
1803 struct listnode
*node
, *nnode
;
1805 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1806 bestpath_per_as_used
= 0;
1808 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1809 FOREACH_AFI_SAFI (afi
, safi
)
1811 peer
->af_flags
[afi
][safi
],
1812 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
)) {
1813 bestpath_per_as_used
= 1;
1817 if (bestpath_per_as_used
)
1821 if (bestpath_per_as_used
) {
1823 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
1824 return CMD_WARNING_CONFIG_FAILED
;
1826 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1827 bgp_recalculate_all_bestpaths(bgp
);
1834 /* "bgp graceful-restart" configuration. */
1835 DEFUN (bgp_graceful_restart
,
1836 bgp_graceful_restart_cmd
,
1837 "bgp graceful-restart",
1838 "BGP specific commands\n"
1839 "Graceful restart capability parameters\n")
1841 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1842 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1846 DEFUN (no_bgp_graceful_restart
,
1847 no_bgp_graceful_restart_cmd
,
1848 "no bgp graceful-restart",
1850 "BGP specific commands\n"
1851 "Graceful restart capability parameters\n")
1853 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1854 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1858 DEFUN (bgp_graceful_restart_stalepath_time
,
1859 bgp_graceful_restart_stalepath_time_cmd
,
1860 "bgp graceful-restart stalepath-time (1-3600)",
1861 "BGP specific commands\n"
1862 "Graceful restart capability parameters\n"
1863 "Set the max time to hold onto restarting peer's stale paths\n"
1864 "Delay value (seconds)\n")
1866 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1870 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1871 bgp
->stalepath_time
= stalepath
;
1875 DEFUN (bgp_graceful_restart_restart_time
,
1876 bgp_graceful_restart_restart_time_cmd
,
1877 "bgp graceful-restart restart-time (1-3600)",
1878 "BGP specific commands\n"
1879 "Graceful restart capability parameters\n"
1880 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1881 "Delay value (seconds)\n")
1883 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1887 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1888 bgp
->restart_time
= restart
;
1892 DEFUN (no_bgp_graceful_restart_stalepath_time
,
1893 no_bgp_graceful_restart_stalepath_time_cmd
,
1894 "no bgp graceful-restart stalepath-time [(1-3600)]",
1896 "BGP specific commands\n"
1897 "Graceful restart capability parameters\n"
1898 "Set the max time to hold onto restarting peer's stale paths\n"
1899 "Delay value (seconds)\n")
1901 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1903 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
1907 DEFUN (no_bgp_graceful_restart_restart_time
,
1908 no_bgp_graceful_restart_restart_time_cmd
,
1909 "no bgp graceful-restart restart-time [(1-3600)]",
1911 "BGP specific commands\n"
1912 "Graceful restart capability parameters\n"
1913 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1914 "Delay value (seconds)\n")
1916 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1918 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
1922 DEFUN (bgp_graceful_restart_preserve_fw
,
1923 bgp_graceful_restart_preserve_fw_cmd
,
1924 "bgp graceful-restart preserve-fw-state",
1925 "BGP specific commands\n"
1926 "Graceful restart capability parameters\n"
1927 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
1929 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1930 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
1934 DEFUN (no_bgp_graceful_restart_preserve_fw
,
1935 no_bgp_graceful_restart_preserve_fw_cmd
,
1936 "no bgp graceful-restart preserve-fw-state",
1938 "BGP specific commands\n"
1939 "Graceful restart capability parameters\n"
1940 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
1942 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1943 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
1947 static void bgp_redistribute_redo(struct bgp
*bgp
)
1951 struct list
*red_list
;
1952 struct listnode
*node
;
1953 struct bgp_redist
*red
;
1955 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
1956 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
1958 red_list
= bgp
->redist
[afi
][i
];
1962 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
1963 bgp_redistribute_resend(bgp
, afi
, i
,
1970 /* "bgp graceful-shutdown" configuration */
1971 DEFUN (bgp_graceful_shutdown
,
1972 bgp_graceful_shutdown_cmd
,
1973 "bgp graceful-shutdown",
1975 "Graceful shutdown parameters\n")
1977 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1979 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
1980 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
1981 bgp_static_redo_import_check(bgp
);
1982 bgp_redistribute_redo(bgp
);
1983 bgp_clear_star_soft_out(vty
, bgp
->name
);
1984 bgp_clear_star_soft_in(vty
, bgp
->name
);
1990 DEFUN (no_bgp_graceful_shutdown
,
1991 no_bgp_graceful_shutdown_cmd
,
1992 "no bgp graceful-shutdown",
1995 "Graceful shutdown parameters\n")
1997 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1999 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2000 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2001 bgp_static_redo_import_check(bgp
);
2002 bgp_redistribute_redo(bgp
);
2003 bgp_clear_star_soft_out(vty
, bgp
->name
);
2004 bgp_clear_star_soft_in(vty
, bgp
->name
);
2010 /* "bgp fast-external-failover" configuration. */
2011 DEFUN (bgp_fast_external_failover
,
2012 bgp_fast_external_failover_cmd
,
2013 "bgp fast-external-failover",
2015 "Immediately reset session if a link to a directly connected external peer goes down\n")
2017 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2018 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2022 DEFUN (no_bgp_fast_external_failover
,
2023 no_bgp_fast_external_failover_cmd
,
2024 "no bgp fast-external-failover",
2027 "Immediately reset session if a link to a directly connected external peer goes down\n")
2029 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2030 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2034 /* "bgp enforce-first-as" configuration. */
2035 #if CONFDATE > 20190517
2036 CPP_NOTICE("bgpd: remove deprecated '[no] bgp enforce-first-as' commands")
2039 DEFUN_HIDDEN (bgp_enforce_first_as
,
2040 bgp_enforce_first_as_cmd
,
2041 "[no] bgp enforce-first-as",
2044 "Enforce the first AS for EBGP routes\n")
2046 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2048 if (strmatch(argv
[0]->text
, "no"))
2049 bgp_flag_unset(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2051 bgp_flag_set(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2056 /* "bgp bestpath compare-routerid" configuration. */
2057 DEFUN (bgp_bestpath_compare_router_id
,
2058 bgp_bestpath_compare_router_id_cmd
,
2059 "bgp bestpath compare-routerid",
2060 "BGP specific commands\n"
2061 "Change the default bestpath selection\n"
2062 "Compare router-id for identical EBGP paths\n")
2064 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2065 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2066 bgp_recalculate_all_bestpaths(bgp
);
2071 DEFUN (no_bgp_bestpath_compare_router_id
,
2072 no_bgp_bestpath_compare_router_id_cmd
,
2073 "no bgp bestpath compare-routerid",
2075 "BGP specific commands\n"
2076 "Change the default bestpath selection\n"
2077 "Compare router-id for identical EBGP paths\n")
2079 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2080 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2081 bgp_recalculate_all_bestpaths(bgp
);
2086 /* "bgp bestpath as-path ignore" configuration. */
2087 DEFUN (bgp_bestpath_aspath_ignore
,
2088 bgp_bestpath_aspath_ignore_cmd
,
2089 "bgp bestpath as-path ignore",
2090 "BGP specific commands\n"
2091 "Change the default bestpath selection\n"
2092 "AS-path attribute\n"
2093 "Ignore as-path length in selecting a route\n")
2095 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2096 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2097 bgp_recalculate_all_bestpaths(bgp
);
2102 DEFUN (no_bgp_bestpath_aspath_ignore
,
2103 no_bgp_bestpath_aspath_ignore_cmd
,
2104 "no bgp bestpath as-path ignore",
2106 "BGP specific commands\n"
2107 "Change the default bestpath selection\n"
2108 "AS-path attribute\n"
2109 "Ignore as-path length in selecting a route\n")
2111 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2112 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2113 bgp_recalculate_all_bestpaths(bgp
);
2118 /* "bgp bestpath as-path confed" configuration. */
2119 DEFUN (bgp_bestpath_aspath_confed
,
2120 bgp_bestpath_aspath_confed_cmd
,
2121 "bgp bestpath as-path confed",
2122 "BGP specific commands\n"
2123 "Change the default bestpath selection\n"
2124 "AS-path attribute\n"
2125 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2127 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2128 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2129 bgp_recalculate_all_bestpaths(bgp
);
2134 DEFUN (no_bgp_bestpath_aspath_confed
,
2135 no_bgp_bestpath_aspath_confed_cmd
,
2136 "no bgp bestpath as-path confed",
2138 "BGP specific commands\n"
2139 "Change the default bestpath selection\n"
2140 "AS-path attribute\n"
2141 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2143 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2144 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2145 bgp_recalculate_all_bestpaths(bgp
);
2150 /* "bgp bestpath as-path multipath-relax" configuration. */
2151 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2152 bgp_bestpath_aspath_multipath_relax_cmd
,
2153 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2154 "BGP specific commands\n"
2155 "Change the default bestpath selection\n"
2156 "AS-path attribute\n"
2157 "Allow load sharing across routes that have different AS paths (but same length)\n"
2158 "Generate an AS_SET\n"
2159 "Do not generate an AS_SET\n")
2161 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2163 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2165 /* no-as-set is now the default behavior so we can silently
2167 if (argv_find(argv
, argc
, "as-set", &idx
))
2168 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2170 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2172 bgp_recalculate_all_bestpaths(bgp
);
2177 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2178 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2179 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2181 "BGP specific commands\n"
2182 "Change the default bestpath selection\n"
2183 "AS-path attribute\n"
2184 "Allow load sharing across routes that have different AS paths (but same length)\n"
2185 "Generate an AS_SET\n"
2186 "Do not generate an AS_SET\n")
2188 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2189 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2190 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2191 bgp_recalculate_all_bestpaths(bgp
);
2196 /* "bgp log-neighbor-changes" configuration. */
2197 DEFUN (bgp_log_neighbor_changes
,
2198 bgp_log_neighbor_changes_cmd
,
2199 "bgp log-neighbor-changes",
2200 "BGP specific commands\n"
2201 "Log neighbor up/down and reset reason\n")
2203 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2204 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2208 DEFUN (no_bgp_log_neighbor_changes
,
2209 no_bgp_log_neighbor_changes_cmd
,
2210 "no bgp log-neighbor-changes",
2212 "BGP specific commands\n"
2213 "Log neighbor up/down and reset reason\n")
2215 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2216 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2220 /* "bgp bestpath med" configuration. */
2221 DEFUN (bgp_bestpath_med
,
2222 bgp_bestpath_med_cmd
,
2223 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2224 "BGP specific commands\n"
2225 "Change the default bestpath selection\n"
2227 "Compare MED among confederation paths\n"
2228 "Treat missing MED as the least preferred one\n"
2229 "Treat missing MED as the least preferred one\n"
2230 "Compare MED among confederation paths\n")
2232 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2235 if (argv_find(argv
, argc
, "confed", &idx
))
2236 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2238 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2239 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2241 bgp_recalculate_all_bestpaths(bgp
);
2246 DEFUN (no_bgp_bestpath_med
,
2247 no_bgp_bestpath_med_cmd
,
2248 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2250 "BGP specific commands\n"
2251 "Change the default bestpath selection\n"
2253 "Compare MED among confederation paths\n"
2254 "Treat missing MED as the least preferred one\n"
2255 "Treat missing MED as the least preferred one\n"
2256 "Compare MED among confederation paths\n")
2258 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2261 if (argv_find(argv
, argc
, "confed", &idx
))
2262 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2264 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2265 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2267 bgp_recalculate_all_bestpaths(bgp
);
2272 /* "no bgp default ipv4-unicast". */
2273 DEFUN (no_bgp_default_ipv4_unicast
,
2274 no_bgp_default_ipv4_unicast_cmd
,
2275 "no bgp default ipv4-unicast",
2277 "BGP specific commands\n"
2278 "Configure BGP defaults\n"
2279 "Activate ipv4-unicast for a peer by default\n")
2281 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2282 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2286 DEFUN (bgp_default_ipv4_unicast
,
2287 bgp_default_ipv4_unicast_cmd
,
2288 "bgp default ipv4-unicast",
2289 "BGP specific commands\n"
2290 "Configure BGP defaults\n"
2291 "Activate ipv4-unicast for a peer by default\n")
2293 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2294 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2298 /* Display hostname in certain command outputs */
2299 DEFUN (bgp_default_show_hostname
,
2300 bgp_default_show_hostname_cmd
,
2301 "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_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2311 DEFUN (no_bgp_default_show_hostname
,
2312 no_bgp_default_show_hostname_cmd
,
2313 "no bgp default show-hostname",
2315 "BGP specific commands\n"
2316 "Configure BGP defaults\n"
2317 "Show hostname in certain command ouputs\n")
2319 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2320 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2324 /* "bgp network import-check" configuration. */
2325 DEFUN (bgp_network_import_check
,
2326 bgp_network_import_check_cmd
,
2327 "bgp network import-check",
2328 "BGP specific commands\n"
2329 "BGP network command\n"
2330 "Check BGP network route exists in IGP\n")
2332 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2333 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2334 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2335 bgp_static_redo_import_check(bgp
);
2341 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2342 "bgp network import-check exact",
2343 "BGP specific commands\n"
2344 "BGP network command\n"
2345 "Check BGP network route exists in IGP\n"
2346 "Match route precisely\n")
2348 DEFUN (no_bgp_network_import_check
,
2349 no_bgp_network_import_check_cmd
,
2350 "no bgp network import-check",
2352 "BGP specific commands\n"
2353 "BGP network command\n"
2354 "Check BGP network route exists in IGP\n")
2356 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2357 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2358 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2359 bgp_static_redo_import_check(bgp
);
2365 DEFUN (bgp_default_local_preference
,
2366 bgp_default_local_preference_cmd
,
2367 "bgp default local-preference (0-4294967295)",
2368 "BGP specific commands\n"
2369 "Configure BGP defaults\n"
2370 "local preference (higher=more preferred)\n"
2371 "Configure default local preference value\n")
2373 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2375 uint32_t local_pref
;
2377 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2379 bgp_default_local_preference_set(bgp
, local_pref
);
2380 bgp_clear_star_soft_in(vty
, bgp
->name
);
2385 DEFUN (no_bgp_default_local_preference
,
2386 no_bgp_default_local_preference_cmd
,
2387 "no bgp default local-preference [(0-4294967295)]",
2389 "BGP specific commands\n"
2390 "Configure BGP defaults\n"
2391 "local preference (higher=more preferred)\n"
2392 "Configure default local preference value\n")
2394 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2395 bgp_default_local_preference_unset(bgp
);
2396 bgp_clear_star_soft_in(vty
, bgp
->name
);
2402 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2403 bgp_default_subgroup_pkt_queue_max_cmd
,
2404 "bgp default subgroup-pkt-queue-max (20-100)",
2405 "BGP specific commands\n"
2406 "Configure BGP defaults\n"
2407 "subgroup-pkt-queue-max\n"
2408 "Configure subgroup packet queue max\n")
2410 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2414 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2416 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2421 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2422 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2423 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2425 "BGP specific commands\n"
2426 "Configure BGP defaults\n"
2427 "subgroup-pkt-queue-max\n"
2428 "Configure subgroup packet queue max\n")
2430 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2431 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2436 DEFUN (bgp_rr_allow_outbound_policy
,
2437 bgp_rr_allow_outbound_policy_cmd
,
2438 "bgp route-reflector allow-outbound-policy",
2439 "BGP specific commands\n"
2440 "Allow modifications made by out route-map\n"
2441 "on ibgp neighbors\n")
2443 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2445 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2446 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2447 update_group_announce_rrclients(bgp
);
2448 bgp_clear_star_soft_out(vty
, bgp
->name
);
2454 DEFUN (no_bgp_rr_allow_outbound_policy
,
2455 no_bgp_rr_allow_outbound_policy_cmd
,
2456 "no bgp route-reflector allow-outbound-policy",
2458 "BGP specific commands\n"
2459 "Allow modifications made by out route-map\n"
2460 "on ibgp neighbors\n")
2462 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2464 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2465 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2466 update_group_announce_rrclients(bgp
);
2467 bgp_clear_star_soft_out(vty
, bgp
->name
);
2473 DEFUN (bgp_listen_limit
,
2474 bgp_listen_limit_cmd
,
2475 "bgp listen limit (1-5000)",
2476 "BGP specific commands\n"
2477 "Configure BGP defaults\n"
2478 "maximum number of BGP Dynamic Neighbors that can be created\n"
2479 "Configure Dynamic Neighbors listen limit value\n")
2481 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2485 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2487 bgp_listen_limit_set(bgp
, listen_limit
);
2492 DEFUN (no_bgp_listen_limit
,
2493 no_bgp_listen_limit_cmd
,
2494 "no bgp listen limit [(1-5000)]",
2495 "BGP specific commands\n"
2496 "Configure BGP defaults\n"
2497 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2498 "Configure Dynamic Neighbors listen limit value to default\n"
2499 "Configure Dynamic Neighbors listen limit value\n")
2501 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2502 bgp_listen_limit_unset(bgp
);
2508 * Check if this listen range is already configured. Check for exact
2509 * match or overlap based on input.
2511 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2512 struct prefix
*range
, int exact
)
2514 struct listnode
*node
, *nnode
;
2515 struct listnode
*node1
, *nnode1
;
2516 struct peer_group
*group
;
2521 afi
= family2afi(range
->family
);
2522 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2523 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2526 match
= prefix_same(range
, lr
);
2528 match
= (prefix_match(range
, lr
)
2529 || prefix_match(lr
, range
));
2538 DEFUN (bgp_listen_range
,
2539 bgp_listen_range_cmd
,
2540 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2541 "BGP specific commands\n"
2542 "Configure BGP dynamic neighbors listen range\n"
2543 "Configure BGP dynamic neighbors listen range\n"
2545 "Member of the peer-group\n"
2546 "Peer-group name\n")
2548 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2549 struct prefix range
;
2550 struct peer_group
*group
, *existing_group
;
2555 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2556 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2557 char *prefix
= argv
[idx
]->arg
;
2558 argv_find(argv
, argc
, "WORD", &idx
);
2559 char *peergroup
= argv
[idx
]->arg
;
2561 /* Convert IP prefix string to struct prefix. */
2562 ret
= str2prefix(prefix
, &range
);
2564 vty_out(vty
, "%% Malformed listen range\n");
2565 return CMD_WARNING_CONFIG_FAILED
;
2568 afi
= family2afi(range
.family
);
2570 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2572 "%% Malformed listen range (link-local address)\n");
2573 return CMD_WARNING_CONFIG_FAILED
;
2578 /* Check if same listen range is already configured. */
2579 existing_group
= listen_range_exists(bgp
, &range
, 1);
2580 if (existing_group
) {
2581 if (strcmp(existing_group
->name
, peergroup
) == 0)
2585 "%% Same listen range is attached to peer-group %s\n",
2586 existing_group
->name
);
2587 return CMD_WARNING_CONFIG_FAILED
;
2591 /* Check if an overlapping listen range exists. */
2592 if (listen_range_exists(bgp
, &range
, 0)) {
2594 "%% Listen range overlaps with existing listen range\n");
2595 return CMD_WARNING_CONFIG_FAILED
;
2598 group
= peer_group_lookup(bgp
, peergroup
);
2600 vty_out(vty
, "%% Configure the peer-group first\n");
2601 return CMD_WARNING_CONFIG_FAILED
;
2604 ret
= peer_group_listen_range_add(group
, &range
);
2605 return bgp_vty_return(vty
, ret
);
2608 DEFUN (no_bgp_listen_range
,
2609 no_bgp_listen_range_cmd
,
2610 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2612 "BGP specific commands\n"
2613 "Unconfigure BGP dynamic neighbors listen range\n"
2614 "Unconfigure BGP dynamic neighbors listen range\n"
2616 "Member of the peer-group\n"
2617 "Peer-group name\n")
2619 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2620 struct prefix range
;
2621 struct peer_group
*group
;
2626 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2627 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2628 char *prefix
= argv
[idx
]->arg
;
2629 argv_find(argv
, argc
, "WORD", &idx
);
2630 char *peergroup
= argv
[idx
]->arg
;
2632 /* Convert IP prefix string to struct prefix. */
2633 ret
= str2prefix(prefix
, &range
);
2635 vty_out(vty
, "%% Malformed listen range\n");
2636 return CMD_WARNING_CONFIG_FAILED
;
2639 afi
= family2afi(range
.family
);
2641 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2643 "%% Malformed listen range (link-local address)\n");
2644 return CMD_WARNING_CONFIG_FAILED
;
2649 group
= peer_group_lookup(bgp
, peergroup
);
2651 vty_out(vty
, "%% Peer-group does not exist\n");
2652 return CMD_WARNING_CONFIG_FAILED
;
2655 ret
= peer_group_listen_range_del(group
, &range
);
2656 return bgp_vty_return(vty
, ret
);
2659 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2661 struct peer_group
*group
;
2662 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2663 struct prefix
*range
;
2665 char buf
[PREFIX2STR_BUFFER
];
2667 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2668 vty_out(vty
, " bgp listen limit %d\n",
2669 bgp
->dynamic_neighbors_limit
);
2671 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2672 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2673 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2675 prefix2str(range
, buf
, sizeof(buf
));
2677 " bgp listen range %s peer-group %s\n",
2685 DEFUN (bgp_disable_connected_route_check
,
2686 bgp_disable_connected_route_check_cmd
,
2687 "bgp disable-ebgp-connected-route-check",
2688 "BGP specific commands\n"
2689 "Disable checking if nexthop is connected on ebgp sessions\n")
2691 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2692 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2693 bgp_clear_star_soft_in(vty
, bgp
->name
);
2698 DEFUN (no_bgp_disable_connected_route_check
,
2699 no_bgp_disable_connected_route_check_cmd
,
2700 "no bgp disable-ebgp-connected-route-check",
2702 "BGP specific commands\n"
2703 "Disable checking if nexthop is connected on ebgp sessions\n")
2705 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2706 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2707 bgp_clear_star_soft_in(vty
, bgp
->name
);
2713 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2714 const char *as_str
, afi_t afi
, safi_t safi
)
2716 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2719 int as_type
= AS_SPECIFIED
;
2722 if (as_str
[0] == 'i') {
2724 as_type
= AS_INTERNAL
;
2725 } else if (as_str
[0] == 'e') {
2727 as_type
= AS_EXTERNAL
;
2729 /* Get AS number. */
2730 as
= strtoul(as_str
, NULL
, 10);
2733 /* If peer is peer group, call proper function. */
2734 ret
= str2sockunion(peer_str
, &su
);
2736 /* Check for peer by interface */
2737 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2740 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2743 "%% Create the peer-group or interface first\n");
2744 return CMD_WARNING_CONFIG_FAILED
;
2749 if (peer_address_self_check(bgp
, &su
)) {
2751 "%% Can not configure the local system as neighbor\n");
2752 return CMD_WARNING_CONFIG_FAILED
;
2754 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2757 /* This peer belongs to peer group. */
2759 case BGP_ERR_PEER_GROUP_MEMBER
:
2761 "%% Peer-group AS %u. Cannot configure remote-as for member\n",
2763 return CMD_WARNING_CONFIG_FAILED
;
2764 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2766 "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n",
2768 return CMD_WARNING_CONFIG_FAILED
;
2770 return bgp_vty_return(vty
, ret
);
2773 DEFUN (bgp_default_shutdown
,
2774 bgp_default_shutdown_cmd
,
2775 "[no] bgp default shutdown",
2778 "Configure BGP defaults\n"
2779 "Apply administrative shutdown to newly configured peers\n")
2781 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2782 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2786 DEFUN (neighbor_remote_as
,
2787 neighbor_remote_as_cmd
,
2788 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2791 "Specify a BGP neighbor\n"
2793 "Internal BGP peer\n"
2794 "External BGP peer\n")
2797 int idx_remote_as
= 3;
2798 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2799 argv
[idx_remote_as
]->arg
, AFI_IP
,
2803 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2804 afi_t afi
, safi_t safi
, int v6only
,
2805 const char *peer_group_name
,
2808 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2810 int as_type
= AS_UNSPECIFIED
;
2812 struct peer_group
*group
;
2816 group
= peer_group_lookup(bgp
, conf_if
);
2819 vty_out(vty
, "%% Name conflict with peer-group \n");
2820 return CMD_WARNING_CONFIG_FAILED
;
2824 if (as_str
[0] == 'i') {
2825 as_type
= AS_INTERNAL
;
2826 } else if (as_str
[0] == 'e') {
2827 as_type
= AS_EXTERNAL
;
2829 /* Get AS number. */
2830 as
= strtoul(as_str
, NULL
, 10);
2831 as_type
= AS_SPECIFIED
;
2835 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2838 ret
= peer_remote_as(bgp
, &su
, conf_if
, &as
, as_type
,
2841 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2842 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2843 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2844 as_type
, 0, 0, NULL
);
2846 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2847 as_type
, afi
, safi
, NULL
);
2850 vty_out(vty
, "%% BGP failed to create peer\n");
2851 return CMD_WARNING_CONFIG_FAILED
;
2855 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2857 /* Request zebra to initiate IPv6 RAs on this interface. We do
2859 * any unnumbered peer in order to not worry about run-time
2861 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2863 * gets deleted later etc.)
2866 bgp_zebra_initiate_radv(bgp
, peer
);
2869 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2870 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2872 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2874 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2876 /* v6only flag changed. Reset bgp seesion */
2877 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2878 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2879 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2880 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2882 bgp_session_reset(peer
);
2885 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
2886 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
2887 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
2888 UNSET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
2891 if (peer_group_name
) {
2892 group
= peer_group_lookup(bgp
, peer_group_name
);
2894 vty_out(vty
, "%% Configure the peer-group first\n");
2895 return CMD_WARNING_CONFIG_FAILED
;
2898 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
2901 return bgp_vty_return(vty
, ret
);
2904 DEFUN (neighbor_interface_config
,
2905 neighbor_interface_config_cmd
,
2906 "neighbor WORD interface [peer-group WORD]",
2908 "Interface name or neighbor tag\n"
2909 "Enable BGP on interface\n"
2910 "Member of the peer-group\n"
2911 "Peer-group name\n")
2914 int idx_peer_group_word
= 4;
2916 if (argc
> idx_peer_group_word
)
2917 return peer_conf_interface_get(
2918 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
2919 argv
[idx_peer_group_word
]->arg
, NULL
);
2921 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2922 SAFI_UNICAST
, 0, NULL
, NULL
);
2925 DEFUN (neighbor_interface_config_v6only
,
2926 neighbor_interface_config_v6only_cmd
,
2927 "neighbor WORD interface v6only [peer-group WORD]",
2929 "Interface name or neighbor tag\n"
2930 "Enable BGP on interface\n"
2931 "Enable BGP with v6 link-local only\n"
2932 "Member of the peer-group\n"
2933 "Peer-group name\n")
2936 int idx_peer_group_word
= 5;
2938 if (argc
> idx_peer_group_word
)
2939 return peer_conf_interface_get(
2940 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
2941 argv
[idx_peer_group_word
]->arg
, NULL
);
2943 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2944 SAFI_UNICAST
, 1, NULL
, NULL
);
2948 DEFUN (neighbor_interface_config_remote_as
,
2949 neighbor_interface_config_remote_as_cmd
,
2950 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
2952 "Interface name or neighbor tag\n"
2953 "Enable BGP on interface\n"
2954 "Specify a BGP neighbor\n"
2956 "Internal BGP peer\n"
2957 "External BGP peer\n")
2960 int idx_remote_as
= 4;
2961 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2962 SAFI_UNICAST
, 0, NULL
,
2963 argv
[idx_remote_as
]->arg
);
2966 DEFUN (neighbor_interface_v6only_config_remote_as
,
2967 neighbor_interface_v6only_config_remote_as_cmd
,
2968 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
2970 "Interface name or neighbor tag\n"
2971 "Enable BGP with v6 link-local only\n"
2972 "Enable BGP on interface\n"
2973 "Specify a BGP neighbor\n"
2975 "Internal BGP peer\n"
2976 "External BGP peer\n")
2979 int idx_remote_as
= 5;
2980 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2981 SAFI_UNICAST
, 1, NULL
,
2982 argv
[idx_remote_as
]->arg
);
2985 DEFUN (neighbor_peer_group
,
2986 neighbor_peer_group_cmd
,
2987 "neighbor WORD peer-group",
2989 "Interface name or neighbor tag\n"
2990 "Configure peer-group\n")
2992 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2995 struct peer_group
*group
;
2997 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
2999 vty_out(vty
, "%% Name conflict with interface: \n");
3000 return CMD_WARNING_CONFIG_FAILED
;
3003 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
3005 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
3006 return CMD_WARNING_CONFIG_FAILED
;
3014 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3018 "Specify a BGP neighbor\n"
3020 "Internal BGP peer\n"
3021 "External BGP peer\n")
3023 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3027 struct peer_group
*group
;
3031 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3033 /* look up for neighbor by interface name config. */
3034 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3036 /* Request zebra to terminate IPv6 RAs on this
3039 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3044 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3046 peer_group_delete(group
);
3048 vty_out(vty
, "%% Create the peer-group first\n");
3049 return CMD_WARNING_CONFIG_FAILED
;
3052 peer
= peer_lookup(bgp
, &su
);
3054 if (peer_dynamic_neighbor(peer
)) {
3056 "%% Operation not allowed on a dynamic neighbor\n");
3057 return CMD_WARNING_CONFIG_FAILED
;
3060 other
= peer
->doppelganger
;
3062 if (other
&& other
->status
!= Deleted
)
3070 DEFUN (no_neighbor_interface_config
,
3071 no_neighbor_interface_config_cmd
,
3072 "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]",
3076 "Configure BGP on interface\n"
3077 "Enable BGP with v6 link-local only\n"
3078 "Member of the peer-group\n"
3080 "Specify a BGP neighbor\n"
3082 "Internal BGP peer\n"
3083 "External BGP peer\n")
3085 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3089 /* look up for neighbor by interface name config. */
3090 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3092 /* Request zebra to terminate IPv6 RAs on this interface. */
3094 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3097 vty_out(vty
, "%% Create the bgp interface first\n");
3098 return CMD_WARNING_CONFIG_FAILED
;
3103 DEFUN (no_neighbor_peer_group
,
3104 no_neighbor_peer_group_cmd
,
3105 "no neighbor WORD peer-group",
3109 "Configure peer-group\n")
3111 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3113 struct peer_group
*group
;
3115 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3117 peer_group_delete(group
);
3119 vty_out(vty
, "%% Create the peer-group first\n");
3120 return CMD_WARNING_CONFIG_FAILED
;
3125 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3126 no_neighbor_interface_peer_group_remote_as_cmd
,
3127 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3130 "Interface name or neighbor tag\n"
3131 "Specify a BGP neighbor\n"
3133 "Internal BGP peer\n"
3134 "External BGP peer\n")
3136 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3138 struct peer_group
*group
;
3141 /* look up for neighbor by interface name config. */
3142 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3144 peer_as_change(peer
, 0, AS_SPECIFIED
);
3148 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3150 peer_group_remote_as_delete(group
);
3152 vty_out(vty
, "%% Create the peer-group or interface first\n");
3153 return CMD_WARNING_CONFIG_FAILED
;
3158 DEFUN (neighbor_local_as
,
3159 neighbor_local_as_cmd
,
3160 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3163 "Specify a local-as number\n"
3164 "AS number used as local AS\n")
3172 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3174 return CMD_WARNING_CONFIG_FAILED
;
3176 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3177 ret
= peer_local_as_set(peer
, as
, 0, 0);
3178 return bgp_vty_return(vty
, ret
);
3181 DEFUN (neighbor_local_as_no_prepend
,
3182 neighbor_local_as_no_prepend_cmd
,
3183 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3186 "Specify a local-as number\n"
3187 "AS number used as local AS\n"
3188 "Do not prepend local-as to updates from ebgp peers\n")
3196 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3198 return CMD_WARNING_CONFIG_FAILED
;
3200 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3201 ret
= peer_local_as_set(peer
, as
, 1, 0);
3202 return bgp_vty_return(vty
, ret
);
3205 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3206 neighbor_local_as_no_prepend_replace_as_cmd
,
3207 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3210 "Specify a local-as number\n"
3211 "AS number used as local AS\n"
3212 "Do not prepend local-as to updates from ebgp peers\n"
3213 "Do not prepend local-as to updates from ibgp peers\n")
3221 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3223 return CMD_WARNING_CONFIG_FAILED
;
3225 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3226 ret
= peer_local_as_set(peer
, as
, 1, 1);
3227 return bgp_vty_return(vty
, ret
);
3230 DEFUN (no_neighbor_local_as
,
3231 no_neighbor_local_as_cmd
,
3232 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3236 "Specify a local-as number\n"
3237 "AS number used as local AS\n"
3238 "Do not prepend local-as to updates from ebgp peers\n"
3239 "Do not prepend local-as to updates from ibgp peers\n")
3245 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3247 return CMD_WARNING_CONFIG_FAILED
;
3249 ret
= peer_local_as_unset(peer
);
3250 return bgp_vty_return(vty
, ret
);
3254 DEFUN (neighbor_solo
,
3256 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3259 "Solo peer - part of its own update group\n")
3265 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3267 return CMD_WARNING_CONFIG_FAILED
;
3269 ret
= update_group_adjust_soloness(peer
, 1);
3270 return bgp_vty_return(vty
, ret
);
3273 DEFUN (no_neighbor_solo
,
3274 no_neighbor_solo_cmd
,
3275 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3279 "Solo peer - part of its own update group\n")
3285 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3287 return CMD_WARNING_CONFIG_FAILED
;
3289 ret
= update_group_adjust_soloness(peer
, 0);
3290 return bgp_vty_return(vty
, ret
);
3293 DEFUN (neighbor_password
,
3294 neighbor_password_cmd
,
3295 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3306 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3308 return CMD_WARNING_CONFIG_FAILED
;
3310 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3311 return bgp_vty_return(vty
, ret
);
3314 DEFUN (no_neighbor_password
,
3315 no_neighbor_password_cmd
,
3316 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3327 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3329 return CMD_WARNING_CONFIG_FAILED
;
3331 ret
= peer_password_unset(peer
);
3332 return bgp_vty_return(vty
, ret
);
3335 DEFUN (neighbor_activate
,
3336 neighbor_activate_cmd
,
3337 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3340 "Enable the Address Family for this Neighbor\n")
3346 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3348 return CMD_WARNING_CONFIG_FAILED
;
3350 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3351 return bgp_vty_return(vty
, ret
);
3354 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3355 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3356 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3357 "Enable the Address Family for this Neighbor\n")
3359 DEFUN (no_neighbor_activate
,
3360 no_neighbor_activate_cmd
,
3361 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3365 "Enable the Address Family for this Neighbor\n")
3372 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3374 return CMD_WARNING_CONFIG_FAILED
;
3376 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3377 return bgp_vty_return(vty
, ret
);
3380 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3381 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3382 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3383 "Enable the Address Family for this Neighbor\n")
3385 DEFUN (neighbor_set_peer_group
,
3386 neighbor_set_peer_group_cmd
,
3387 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3390 "Member of the peer-group\n"
3391 "Peer-group name\n")
3393 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3400 struct peer_group
*group
;
3402 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3404 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3406 vty_out(vty
, "%% Malformed address or name: %s\n",
3407 argv
[idx_peer
]->arg
);
3408 return CMD_WARNING_CONFIG_FAILED
;
3411 if (peer_address_self_check(bgp
, &su
)) {
3413 "%% Can not configure the local system as neighbor\n");
3414 return CMD_WARNING_CONFIG_FAILED
;
3417 /* Disallow for dynamic neighbor. */
3418 peer
= peer_lookup(bgp
, &su
);
3419 if (peer
&& peer_dynamic_neighbor(peer
)) {
3421 "%% Operation not allowed on a dynamic neighbor\n");
3422 return CMD_WARNING_CONFIG_FAILED
;
3426 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3428 vty_out(vty
, "%% Configure the peer-group first\n");
3429 return CMD_WARNING_CONFIG_FAILED
;
3432 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3434 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3436 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3438 return CMD_WARNING_CONFIG_FAILED
;
3441 return bgp_vty_return(vty
, ret
);
3444 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3445 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3446 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3447 "Member of the peer-group\n"
3448 "Peer-group name\n")
3450 DEFUN (no_neighbor_set_peer_group
,
3451 no_neighbor_set_peer_group_cmd
,
3452 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3456 "Member of the peer-group\n"
3457 "Peer-group name\n")
3459 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3464 struct peer_group
*group
;
3466 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3468 return CMD_WARNING_CONFIG_FAILED
;
3470 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3472 vty_out(vty
, "%% Configure the peer-group first\n");
3473 return CMD_WARNING_CONFIG_FAILED
;
3476 ret
= peer_delete(peer
);
3478 return bgp_vty_return(vty
, ret
);
3481 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3482 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3483 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3484 "Member of the peer-group\n"
3485 "Peer-group name\n")
3487 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3488 uint32_t flag
, int set
)
3493 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3495 return CMD_WARNING_CONFIG_FAILED
;
3498 * If 'neighbor <interface>', then this is for directly connected peers,
3499 * we should not accept disable-connected-check.
3501 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3503 "%s is directly connected peer, cannot accept disable-"
3504 "connected-check\n",
3506 return CMD_WARNING_CONFIG_FAILED
;
3509 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3510 peer_tx_shutdown_message_unset(peer
);
3513 ret
= peer_flag_set(peer
, flag
);
3515 ret
= peer_flag_unset(peer
, flag
);
3517 return bgp_vty_return(vty
, ret
);
3520 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3522 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3525 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3528 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3531 /* neighbor passive. */
3532 DEFUN (neighbor_passive
,
3533 neighbor_passive_cmd
,
3534 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3537 "Don't send open messages to this neighbor\n")
3540 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3543 DEFUN (no_neighbor_passive
,
3544 no_neighbor_passive_cmd
,
3545 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3549 "Don't send open messages to this neighbor\n")
3552 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3555 /* neighbor shutdown. */
3556 DEFUN (neighbor_shutdown_msg
,
3557 neighbor_shutdown_msg_cmd
,
3558 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3561 "Administratively shut down this neighbor\n"
3562 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3563 "Shutdown message\n")
3569 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3573 return CMD_WARNING_CONFIG_FAILED
;
3574 message
= argv_concat(argv
, argc
, 4);
3575 peer_tx_shutdown_message_set(peer
, message
);
3576 XFREE(MTYPE_TMP
, message
);
3579 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3582 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3583 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3584 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3585 "Administratively shut down this neighbor\n")
3587 DEFUN (no_neighbor_shutdown_msg
,
3588 no_neighbor_shutdown_msg_cmd
,
3589 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3593 "Administratively shut down this neighbor\n"
3594 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3595 "Shutdown message\n")
3599 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3600 PEER_FLAG_SHUTDOWN
);
3603 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3604 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3605 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3606 "Administratively shut down this neighbor\n")
3608 /* neighbor capability dynamic. */
3609 DEFUN (neighbor_capability_dynamic
,
3610 neighbor_capability_dynamic_cmd
,
3611 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3614 "Advertise capability to the peer\n"
3615 "Advertise dynamic capability to this neighbor\n")
3618 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3619 PEER_FLAG_DYNAMIC_CAPABILITY
);
3622 DEFUN (no_neighbor_capability_dynamic
,
3623 no_neighbor_capability_dynamic_cmd
,
3624 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3628 "Advertise capability to the peer\n"
3629 "Advertise dynamic capability to this neighbor\n")
3632 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3633 PEER_FLAG_DYNAMIC_CAPABILITY
);
3636 /* neighbor dont-capability-negotiate */
3637 DEFUN (neighbor_dont_capability_negotiate
,
3638 neighbor_dont_capability_negotiate_cmd
,
3639 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3642 "Do not perform capability negotiation\n")
3645 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3646 PEER_FLAG_DONT_CAPABILITY
);
3649 DEFUN (no_neighbor_dont_capability_negotiate
,
3650 no_neighbor_dont_capability_negotiate_cmd
,
3651 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3655 "Do not perform capability negotiation\n")
3658 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3659 PEER_FLAG_DONT_CAPABILITY
);
3662 /* neighbor capability extended next hop encoding */
3663 DEFUN (neighbor_capability_enhe
,
3664 neighbor_capability_enhe_cmd
,
3665 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3668 "Advertise capability to the peer\n"
3669 "Advertise extended next-hop capability to the peer\n")
3672 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3673 PEER_FLAG_CAPABILITY_ENHE
);
3676 DEFUN (no_neighbor_capability_enhe
,
3677 no_neighbor_capability_enhe_cmd
,
3678 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3682 "Advertise capability to the peer\n"
3683 "Advertise extended next-hop capability to the peer\n")
3686 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3687 PEER_FLAG_CAPABILITY_ENHE
);
3690 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3691 afi_t afi
, safi_t safi
, uint32_t flag
,
3697 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3699 return CMD_WARNING_CONFIG_FAILED
;
3702 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3704 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3706 return bgp_vty_return(vty
, ret
);
3709 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3710 afi_t afi
, safi_t safi
, uint32_t flag
)
3712 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3715 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3716 afi_t afi
, safi_t safi
, uint32_t flag
)
3718 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3721 /* neighbor capability orf prefix-list. */
3722 DEFUN (neighbor_capability_orf_prefix
,
3723 neighbor_capability_orf_prefix_cmd
,
3724 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3727 "Advertise capability to the peer\n"
3728 "Advertise ORF capability to the peer\n"
3729 "Advertise prefixlist ORF capability to this neighbor\n"
3730 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3731 "Capability to RECEIVE the ORF from this neighbor\n"
3732 "Capability to SEND the ORF to this neighbor\n")
3735 int idx_send_recv
= 5;
3738 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3739 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3740 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3741 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3742 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3743 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3745 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3746 return CMD_WARNING_CONFIG_FAILED
;
3749 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3750 bgp_node_safi(vty
), flag
);
3754 neighbor_capability_orf_prefix
,
3755 neighbor_capability_orf_prefix_hidden_cmd
,
3756 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3757 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
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")
3765 DEFUN (no_neighbor_capability_orf_prefix
,
3766 no_neighbor_capability_orf_prefix_cmd
,
3767 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3771 "Advertise capability to the peer\n"
3772 "Advertise ORF capability to the peer\n"
3773 "Advertise prefixlist ORF capability to this neighbor\n"
3774 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3775 "Capability to RECEIVE the ORF from this neighbor\n"
3776 "Capability to SEND the ORF to this neighbor\n")
3779 int idx_send_recv
= 6;
3782 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3783 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3784 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3785 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3786 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3787 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3789 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3790 return CMD_WARNING_CONFIG_FAILED
;
3793 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3794 bgp_node_afi(vty
), bgp_node_safi(vty
),
3799 no_neighbor_capability_orf_prefix
,
3800 no_neighbor_capability_orf_prefix_hidden_cmd
,
3801 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3802 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3803 "Advertise capability to the peer\n"
3804 "Advertise ORF capability to the peer\n"
3805 "Advertise prefixlist ORF capability to this neighbor\n"
3806 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3807 "Capability to RECEIVE the ORF from this neighbor\n"
3808 "Capability to SEND the ORF to this neighbor\n")
3810 /* neighbor next-hop-self. */
3811 DEFUN (neighbor_nexthop_self
,
3812 neighbor_nexthop_self_cmd
,
3813 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3816 "Disable the next hop calculation for this neighbor\n")
3819 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3820 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3823 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3824 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3825 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3826 "Disable the next hop calculation for this neighbor\n")
3828 /* neighbor next-hop-self. */
3829 DEFUN (neighbor_nexthop_self_force
,
3830 neighbor_nexthop_self_force_cmd
,
3831 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3834 "Disable the next hop calculation for this neighbor\n"
3835 "Set the next hop to self for reflected routes\n")
3838 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3840 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3843 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3844 neighbor_nexthop_self_force_hidden_cmd
,
3845 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3846 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3847 "Disable the next hop calculation for this neighbor\n"
3848 "Set the next hop to self for reflected routes\n")
3850 DEFUN (no_neighbor_nexthop_self
,
3851 no_neighbor_nexthop_self_cmd
,
3852 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3856 "Disable the next hop calculation for this neighbor\n")
3859 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3860 bgp_node_afi(vty
), bgp_node_safi(vty
),
3861 PEER_FLAG_NEXTHOP_SELF
);
3864 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3865 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3866 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3867 "Disable the next hop calculation for this neighbor\n")
3869 DEFUN (no_neighbor_nexthop_self_force
,
3870 no_neighbor_nexthop_self_force_cmd
,
3871 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3875 "Disable the next hop calculation for this neighbor\n"
3876 "Set the next hop to self for reflected routes\n")
3879 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3880 bgp_node_afi(vty
), bgp_node_safi(vty
),
3881 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3884 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3885 no_neighbor_nexthop_self_force_hidden_cmd
,
3886 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3887 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3888 "Disable the next hop calculation for this neighbor\n"
3889 "Set the next hop to self for reflected routes\n")
3891 /* neighbor as-override */
3892 DEFUN (neighbor_as_override
,
3893 neighbor_as_override_cmd
,
3894 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3897 "Override ASNs in outbound updates if aspath equals remote-as\n")
3900 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3901 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
3904 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
3905 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3906 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3907 "Override ASNs in outbound updates if aspath equals remote-as\n")
3909 DEFUN (no_neighbor_as_override
,
3910 no_neighbor_as_override_cmd
,
3911 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3915 "Override ASNs in outbound updates if aspath equals remote-as\n")
3918 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3919 bgp_node_afi(vty
), bgp_node_safi(vty
),
3920 PEER_FLAG_AS_OVERRIDE
);
3923 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
3924 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3925 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3926 "Override ASNs in outbound updates if aspath equals remote-as\n")
3928 /* neighbor remove-private-AS. */
3929 DEFUN (neighbor_remove_private_as
,
3930 neighbor_remove_private_as_cmd
,
3931 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3934 "Remove private ASNs in outbound updates\n")
3937 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3939 PEER_FLAG_REMOVE_PRIVATE_AS
);
3942 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
3943 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3944 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3945 "Remove private ASNs in outbound updates\n")
3947 DEFUN (neighbor_remove_private_as_all
,
3948 neighbor_remove_private_as_all_cmd
,
3949 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3952 "Remove private ASNs in outbound updates\n"
3953 "Apply to all AS numbers\n")
3956 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3958 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
3961 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
3962 neighbor_remove_private_as_all_hidden_cmd
,
3963 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3964 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3965 "Remove private ASNs in outbound updates\n"
3966 "Apply to all AS numbers")
3968 DEFUN (neighbor_remove_private_as_replace_as
,
3969 neighbor_remove_private_as_replace_as_cmd
,
3970 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3973 "Remove private ASNs in outbound updates\n"
3974 "Replace private ASNs with our ASN in outbound updates\n")
3977 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3979 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
3982 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
3983 neighbor_remove_private_as_replace_as_hidden_cmd
,
3984 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3985 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3986 "Remove private ASNs in outbound updates\n"
3987 "Replace private ASNs with our ASN in outbound updates\n")
3989 DEFUN (neighbor_remove_private_as_all_replace_as
,
3990 neighbor_remove_private_as_all_replace_as_cmd
,
3991 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3994 "Remove private ASNs in outbound updates\n"
3995 "Apply to all AS numbers\n"
3996 "Replace private ASNs with our ASN in outbound updates\n")
3999 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4001 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4005 neighbor_remove_private_as_all_replace_as
,
4006 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4007 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4008 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4009 "Remove private ASNs in outbound updates\n"
4010 "Apply to all AS numbers\n"
4011 "Replace private ASNs with our ASN in outbound updates\n")
4013 DEFUN (no_neighbor_remove_private_as
,
4014 no_neighbor_remove_private_as_cmd
,
4015 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4019 "Remove private ASNs in outbound updates\n")
4022 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4023 bgp_node_afi(vty
), bgp_node_safi(vty
),
4024 PEER_FLAG_REMOVE_PRIVATE_AS
);
4027 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4028 no_neighbor_remove_private_as_hidden_cmd
,
4029 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4030 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4031 "Remove private ASNs in outbound updates\n")
4033 DEFUN (no_neighbor_remove_private_as_all
,
4034 no_neighbor_remove_private_as_all_cmd
,
4035 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4039 "Remove private ASNs in outbound updates\n"
4040 "Apply to all AS numbers\n")
4043 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4044 bgp_node_afi(vty
), bgp_node_safi(vty
),
4045 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4048 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4049 no_neighbor_remove_private_as_all_hidden_cmd
,
4050 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4051 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4052 "Remove private ASNs in outbound updates\n"
4053 "Apply to all AS numbers\n")
4055 DEFUN (no_neighbor_remove_private_as_replace_as
,
4056 no_neighbor_remove_private_as_replace_as_cmd
,
4057 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4061 "Remove private ASNs in outbound updates\n"
4062 "Replace private ASNs with our ASN in outbound updates\n")
4065 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4066 bgp_node_afi(vty
), bgp_node_safi(vty
),
4067 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4070 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4071 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4072 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4073 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4074 "Remove private ASNs in outbound updates\n"
4075 "Replace private ASNs with our ASN in outbound updates\n")
4077 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4078 no_neighbor_remove_private_as_all_replace_as_cmd
,
4079 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4083 "Remove private ASNs in outbound updates\n"
4084 "Apply to all AS numbers\n"
4085 "Replace private ASNs with our ASN in outbound updates\n")
4088 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4089 bgp_node_afi(vty
), bgp_node_safi(vty
),
4090 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4094 no_neighbor_remove_private_as_all_replace_as
,
4095 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4096 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4097 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4098 "Remove private ASNs in outbound updates\n"
4099 "Apply to all AS numbers\n"
4100 "Replace private ASNs with our ASN in outbound updates\n")
4103 /* neighbor send-community. */
4104 DEFUN (neighbor_send_community
,
4105 neighbor_send_community_cmd
,
4106 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4109 "Send Community attribute to this neighbor\n")
4113 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4115 PEER_FLAG_SEND_COMMUNITY
);
4118 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4119 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4120 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4121 "Send Community attribute to this neighbor\n")
4123 DEFUN (no_neighbor_send_community
,
4124 no_neighbor_send_community_cmd
,
4125 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4129 "Send Community attribute to this neighbor\n")
4133 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4134 bgp_node_afi(vty
), bgp_node_safi(vty
),
4135 PEER_FLAG_SEND_COMMUNITY
);
4138 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4139 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4140 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4141 "Send Community attribute to this neighbor\n")
4143 /* neighbor send-community extended. */
4144 DEFUN (neighbor_send_community_type
,
4145 neighbor_send_community_type_cmd
,
4146 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4149 "Send Community attribute to this neighbor\n"
4150 "Send Standard and Extended Community attributes\n"
4151 "Send Standard, Large and Extended Community attributes\n"
4152 "Send Extended Community attributes\n"
4153 "Send Standard Community attributes\n"
4154 "Send Large Community attributes\n")
4158 const char *type
= argv
[argc
- 1]->text
;
4160 if (strmatch(type
, "standard")) {
4161 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4162 } else if (strmatch(type
, "extended")) {
4163 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4164 } else if (strmatch(type
, "large")) {
4165 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4166 } else if (strmatch(type
, "both")) {
4167 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4168 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4169 } else { /* if (strmatch(type, "all")) */
4170 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4171 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4172 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4175 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4176 bgp_node_safi(vty
), flag
);
4180 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4181 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4182 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
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")
4190 DEFUN (no_neighbor_send_community_type
,
4191 no_neighbor_send_community_type_cmd
,
4192 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4196 "Send Community attribute to this neighbor\n"
4197 "Send Standard and Extended Community attributes\n"
4198 "Send Standard, Large and Extended Community attributes\n"
4199 "Send Extended Community attributes\n"
4200 "Send Standard Community attributes\n"
4201 "Send Large Community attributes\n")
4205 const char *type
= argv
[argc
- 1]->text
;
4207 if (strmatch(type
, "standard")) {
4208 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4209 } else if (strmatch(type
, "extended")) {
4210 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4211 } else if (strmatch(type
, "large")) {
4212 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4213 } else if (strmatch(type
, "both")) {
4214 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4215 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4216 } else { /* if (strmatch(type, "all")) */
4217 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4218 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4219 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4222 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4223 bgp_node_afi(vty
), bgp_node_safi(vty
),
4228 no_neighbor_send_community_type
,
4229 no_neighbor_send_community_type_hidden_cmd
,
4230 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4231 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4232 "Send Community attribute to this neighbor\n"
4233 "Send Standard and Extended Community attributes\n"
4234 "Send Standard, Large and Extended Community attributes\n"
4235 "Send Extended Community attributes\n"
4236 "Send Standard Community attributes\n"
4237 "Send Large Community attributes\n")
4239 /* neighbor soft-reconfig. */
4240 DEFUN (neighbor_soft_reconfiguration
,
4241 neighbor_soft_reconfiguration_cmd
,
4242 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4245 "Per neighbor soft reconfiguration\n"
4246 "Allow inbound soft reconfiguration for this neighbor\n")
4249 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4251 PEER_FLAG_SOFT_RECONFIG
);
4254 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4255 neighbor_soft_reconfiguration_hidden_cmd
,
4256 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4257 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4258 "Per neighbor soft reconfiguration\n"
4259 "Allow inbound soft reconfiguration for this neighbor\n")
4261 DEFUN (no_neighbor_soft_reconfiguration
,
4262 no_neighbor_soft_reconfiguration_cmd
,
4263 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4267 "Per neighbor soft reconfiguration\n"
4268 "Allow inbound soft reconfiguration for this neighbor\n")
4271 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4272 bgp_node_afi(vty
), bgp_node_safi(vty
),
4273 PEER_FLAG_SOFT_RECONFIG
);
4276 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4277 no_neighbor_soft_reconfiguration_hidden_cmd
,
4278 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4279 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4280 "Per neighbor soft reconfiguration\n"
4281 "Allow inbound soft reconfiguration for this neighbor\n")
4283 DEFUN (neighbor_route_reflector_client
,
4284 neighbor_route_reflector_client_cmd
,
4285 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4288 "Configure a neighbor as Route Reflector client\n")
4294 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4296 return CMD_WARNING_CONFIG_FAILED
;
4298 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4300 PEER_FLAG_REFLECTOR_CLIENT
);
4303 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4304 neighbor_route_reflector_client_hidden_cmd
,
4305 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4306 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4307 "Configure a neighbor as Route Reflector client\n")
4309 DEFUN (no_neighbor_route_reflector_client
,
4310 no_neighbor_route_reflector_client_cmd
,
4311 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4315 "Configure a neighbor as Route Reflector client\n")
4318 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4319 bgp_node_afi(vty
), bgp_node_safi(vty
),
4320 PEER_FLAG_REFLECTOR_CLIENT
);
4323 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4324 no_neighbor_route_reflector_client_hidden_cmd
,
4325 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4326 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4327 "Configure a neighbor as Route Reflector client\n")
4329 /* neighbor route-server-client. */
4330 DEFUN (neighbor_route_server_client
,
4331 neighbor_route_server_client_cmd
,
4332 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4335 "Configure a neighbor as Route Server client\n")
4340 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4342 return CMD_WARNING_CONFIG_FAILED
;
4343 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4345 PEER_FLAG_RSERVER_CLIENT
);
4348 ALIAS_HIDDEN(neighbor_route_server_client
,
4349 neighbor_route_server_client_hidden_cmd
,
4350 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4351 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4352 "Configure a neighbor as Route Server client\n")
4354 DEFUN (no_neighbor_route_server_client
,
4355 no_neighbor_route_server_client_cmd
,
4356 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4360 "Configure a neighbor as Route Server client\n")
4363 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4364 bgp_node_afi(vty
), bgp_node_safi(vty
),
4365 PEER_FLAG_RSERVER_CLIENT
);
4368 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4369 no_neighbor_route_server_client_hidden_cmd
,
4370 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4371 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4372 "Configure a neighbor as Route Server client\n")
4374 DEFUN (neighbor_nexthop_local_unchanged
,
4375 neighbor_nexthop_local_unchanged_cmd
,
4376 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4379 "Configure treatment of outgoing link-local nexthop attribute\n"
4380 "Leave link-local nexthop unchanged for this peer\n")
4383 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4385 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4388 DEFUN (no_neighbor_nexthop_local_unchanged
,
4389 no_neighbor_nexthop_local_unchanged_cmd
,
4390 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4394 "Configure treatment of outgoing link-local-nexthop attribute\n"
4395 "Leave link-local nexthop unchanged for this peer\n")
4398 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4399 bgp_node_afi(vty
), bgp_node_safi(vty
),
4400 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4403 DEFUN (neighbor_attr_unchanged
,
4404 neighbor_attr_unchanged_cmd
,
4405 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4408 "BGP attribute is propagated unchanged to this neighbor\n"
4409 "As-path attribute\n"
4410 "Nexthop attribute\n"
4414 char *peer_str
= argv
[1]->arg
;
4417 afi_t afi
= bgp_node_afi(vty
);
4418 safi_t safi
= bgp_node_safi(vty
);
4420 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4422 return CMD_WARNING_CONFIG_FAILED
;
4424 if (argv_find(argv
, argc
, "as-path", &idx
))
4425 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4427 if (argv_find(argv
, argc
, "next-hop", &idx
))
4428 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4430 if (argv_find(argv
, argc
, "med", &idx
))
4431 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4433 /* no flags means all of them! */
4435 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4436 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4437 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4439 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4440 && peer_af_flag_check(peer
, afi
, safi
,
4441 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4442 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4443 PEER_FLAG_AS_PATH_UNCHANGED
);
4446 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4447 && peer_af_flag_check(peer
, afi
, safi
,
4448 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4449 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4450 PEER_FLAG_NEXTHOP_UNCHANGED
);
4453 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4454 && peer_af_flag_check(peer
, afi
, safi
,
4455 PEER_FLAG_MED_UNCHANGED
)) {
4456 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4457 PEER_FLAG_MED_UNCHANGED
);
4461 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4465 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4466 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4467 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4468 "BGP attribute is propagated unchanged to this neighbor\n"
4469 "As-path attribute\n"
4470 "Nexthop attribute\n"
4473 DEFUN (no_neighbor_attr_unchanged
,
4474 no_neighbor_attr_unchanged_cmd
,
4475 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4479 "BGP attribute is propagated unchanged to this neighbor\n"
4480 "As-path attribute\n"
4481 "Nexthop attribute\n"
4485 char *peer
= argv
[2]->arg
;
4488 if (argv_find(argv
, argc
, "as-path", &idx
))
4489 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4491 if (argv_find(argv
, argc
, "next-hop", &idx
))
4492 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4494 if (argv_find(argv
, argc
, "med", &idx
))
4495 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4497 if (!flags
) // no flags means all of them!
4499 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4500 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4501 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4504 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4505 bgp_node_safi(vty
), flags
);
4509 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4510 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4511 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4512 "BGP attribute is propagated unchanged to this neighbor\n"
4513 "As-path attribute\n"
4514 "Nexthop attribute\n"
4517 /* EBGP multihop configuration. */
4518 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4519 const char *ttl_str
)
4524 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4526 return CMD_WARNING_CONFIG_FAILED
;
4529 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4534 ttl
= strtoul(ttl_str
, NULL
, 10);
4536 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4539 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4543 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4545 return CMD_WARNING_CONFIG_FAILED
;
4547 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4550 /* neighbor ebgp-multihop. */
4551 DEFUN (neighbor_ebgp_multihop
,
4552 neighbor_ebgp_multihop_cmd
,
4553 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4556 "Allow EBGP neighbors not on directly connected networks\n")
4559 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4562 DEFUN (neighbor_ebgp_multihop_ttl
,
4563 neighbor_ebgp_multihop_ttl_cmd
,
4564 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4567 "Allow EBGP neighbors not on directly connected networks\n"
4568 "maximum hop count\n")
4572 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4573 argv
[idx_number
]->arg
);
4576 DEFUN (no_neighbor_ebgp_multihop
,
4577 no_neighbor_ebgp_multihop_cmd
,
4578 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4582 "Allow EBGP neighbors not on directly connected networks\n"
4583 "maximum hop count\n")
4586 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4590 /* disable-connected-check */
4591 DEFUN (neighbor_disable_connected_check
,
4592 neighbor_disable_connected_check_cmd
,
4593 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4596 "one-hop away EBGP peer using loopback address\n"
4597 "Enforce EBGP neighbors perform multihop\n")
4600 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4601 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4604 DEFUN (no_neighbor_disable_connected_check
,
4605 no_neighbor_disable_connected_check_cmd
,
4606 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4610 "one-hop away EBGP peer using loopback address\n"
4611 "Enforce EBGP neighbors perform multihop\n")
4614 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4615 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4619 /* enforce-first-as */
4620 DEFUN (neighbor_enforce_first_as
,
4621 neighbor_enforce_first_as_cmd
,
4622 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4625 "Enforce the first AS for EBGP routes\n")
4629 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4630 PEER_FLAG_ENFORCE_FIRST_AS
);
4633 DEFUN (no_neighbor_enforce_first_as
,
4634 no_neighbor_enforce_first_as_cmd
,
4635 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4639 "Enforce the first AS for EBGP routes\n")
4643 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4644 PEER_FLAG_ENFORCE_FIRST_AS
);
4648 DEFUN (neighbor_description
,
4649 neighbor_description_cmd
,
4650 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4653 "Neighbor specific description\n"
4654 "Up to 80 characters describing this neighbor\n")
4661 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4663 return CMD_WARNING_CONFIG_FAILED
;
4665 str
= argv_concat(argv
, argc
, idx_line
);
4667 peer_description_set(peer
, str
);
4669 XFREE(MTYPE_TMP
, str
);
4674 DEFUN (no_neighbor_description
,
4675 no_neighbor_description_cmd
,
4676 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4680 "Neighbor specific description\n")
4685 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4687 return CMD_WARNING_CONFIG_FAILED
;
4689 peer_description_unset(peer
);
4694 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4695 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4696 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4697 "Neighbor specific description\n"
4698 "Up to 80 characters describing this neighbor\n")
4700 /* Neighbor update-source. */
4701 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4702 const char *source_str
)
4708 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4710 return CMD_WARNING_CONFIG_FAILED
;
4716 if (str2sockunion(source_str
, &su
) == 0)
4717 peer_update_source_addr_set(peer
, &su
);
4719 if (str2prefix(source_str
, &p
)) {
4721 "%% Invalid update-source, remove prefix length \n");
4722 return CMD_WARNING_CONFIG_FAILED
;
4724 peer_update_source_if_set(peer
, source_str
);
4727 peer_update_source_unset(peer
);
4732 #define BGP_UPDATE_SOURCE_HELP_STR \
4735 "Interface name (requires zebra to be running)\n"
4737 DEFUN (neighbor_update_source
,
4738 neighbor_update_source_cmd
,
4739 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4742 "Source of routing updates\n"
4743 BGP_UPDATE_SOURCE_HELP_STR
)
4747 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4748 argv
[idx_peer_2
]->arg
);
4751 DEFUN (no_neighbor_update_source
,
4752 no_neighbor_update_source_cmd
,
4753 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4757 "Source of routing updates\n"
4758 BGP_UPDATE_SOURCE_HELP_STR
)
4761 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4764 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4765 afi_t afi
, safi_t safi
,
4766 const char *rmap
, int set
)
4771 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4773 return CMD_WARNING_CONFIG_FAILED
;
4776 ret
= peer_default_originate_set(peer
, afi
, safi
, rmap
);
4778 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4780 return bgp_vty_return(vty
, ret
);
4783 /* neighbor default-originate. */
4784 DEFUN (neighbor_default_originate
,
4785 neighbor_default_originate_cmd
,
4786 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4789 "Originate default route to this neighbor\n")
4792 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4794 bgp_node_safi(vty
), NULL
, 1);
4797 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4798 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4799 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4800 "Originate default route to this neighbor\n")
4802 DEFUN (neighbor_default_originate_rmap
,
4803 neighbor_default_originate_rmap_cmd
,
4804 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4807 "Originate default route to this neighbor\n"
4808 "Route-map to specify criteria to originate default\n"
4813 return peer_default_originate_set_vty(
4814 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4815 argv
[idx_word
]->arg
, 1);
4819 neighbor_default_originate_rmap
,
4820 neighbor_default_originate_rmap_hidden_cmd
,
4821 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4822 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4823 "Originate default route to this neighbor\n"
4824 "Route-map to specify criteria to originate default\n"
4827 DEFUN (no_neighbor_default_originate
,
4828 no_neighbor_default_originate_cmd
,
4829 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4833 "Originate default route to this neighbor\n"
4834 "Route-map to specify criteria to originate default\n"
4838 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4840 bgp_node_safi(vty
), NULL
, 0);
4844 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4845 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4846 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4847 "Originate default route to this neighbor\n"
4848 "Route-map to specify criteria to originate default\n"
4852 /* Set neighbor's BGP port. */
4853 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4854 const char *port_str
)
4860 peer
= peer_lookup_vty(vty
, ip_str
);
4862 return CMD_WARNING_CONFIG_FAILED
;
4865 sp
= getservbyname("bgp", "tcp");
4866 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
4868 port
= strtoul(port_str
, NULL
, 10);
4871 peer_port_set(peer
, port
);
4876 /* Set specified peer's BGP port. */
4877 DEFUN (neighbor_port
,
4879 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
4882 "Neighbor's BGP port\n"
4883 "TCP port number\n")
4887 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
4888 argv
[idx_number
]->arg
);
4891 DEFUN (no_neighbor_port
,
4892 no_neighbor_port_cmd
,
4893 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
4897 "Neighbor's BGP port\n"
4898 "TCP port number\n")
4901 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
4905 /* neighbor weight. */
4906 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4907 safi_t safi
, const char *weight_str
)
4911 unsigned long weight
;
4913 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4915 return CMD_WARNING_CONFIG_FAILED
;
4917 weight
= strtoul(weight_str
, NULL
, 10);
4919 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
4920 return bgp_vty_return(vty
, ret
);
4923 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4929 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4931 return CMD_WARNING_CONFIG_FAILED
;
4933 ret
= peer_weight_unset(peer
, afi
, safi
);
4934 return bgp_vty_return(vty
, ret
);
4937 DEFUN (neighbor_weight
,
4938 neighbor_weight_cmd
,
4939 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4942 "Set default weight for routes from this neighbor\n"
4947 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4948 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
4951 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
4952 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4953 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4954 "Set default weight for routes from this neighbor\n"
4957 DEFUN (no_neighbor_weight
,
4958 no_neighbor_weight_cmd
,
4959 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4963 "Set default weight for routes from this neighbor\n"
4967 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
4968 bgp_node_afi(vty
), bgp_node_safi(vty
));
4971 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
4972 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4973 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4974 "Set default weight for routes from this neighbor\n"
4978 /* Override capability negotiation. */
4979 DEFUN (neighbor_override_capability
,
4980 neighbor_override_capability_cmd
,
4981 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4984 "Override capability negotiation result\n")
4987 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4988 PEER_FLAG_OVERRIDE_CAPABILITY
);
4991 DEFUN (no_neighbor_override_capability
,
4992 no_neighbor_override_capability_cmd
,
4993 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4997 "Override capability negotiation result\n")
5000 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5001 PEER_FLAG_OVERRIDE_CAPABILITY
);
5004 DEFUN (neighbor_strict_capability
,
5005 neighbor_strict_capability_cmd
,
5006 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5009 "Strict capability negotiation match\n")
5013 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5014 PEER_FLAG_STRICT_CAP_MATCH
);
5017 DEFUN (no_neighbor_strict_capability
,
5018 no_neighbor_strict_capability_cmd
,
5019 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5023 "Strict capability negotiation match\n")
5027 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5028 PEER_FLAG_STRICT_CAP_MATCH
);
5031 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5032 const char *keep_str
, const char *hold_str
)
5039 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5041 return CMD_WARNING_CONFIG_FAILED
;
5043 keepalive
= strtoul(keep_str
, NULL
, 10);
5044 holdtime
= strtoul(hold_str
, NULL
, 10);
5046 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5048 return bgp_vty_return(vty
, ret
);
5051 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5056 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5058 return CMD_WARNING_CONFIG_FAILED
;
5060 ret
= peer_timers_unset(peer
);
5062 return bgp_vty_return(vty
, ret
);
5065 DEFUN (neighbor_timers
,
5066 neighbor_timers_cmd
,
5067 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5070 "BGP per neighbor timers\n"
5071 "Keepalive interval\n"
5076 int idx_number_2
= 4;
5077 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5078 argv
[idx_number
]->arg
,
5079 argv
[idx_number_2
]->arg
);
5082 DEFUN (no_neighbor_timers
,
5083 no_neighbor_timers_cmd
,
5084 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5088 "BGP per neighbor timers\n"
5089 "Keepalive interval\n"
5093 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5097 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5098 const char *time_str
)
5104 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5106 return CMD_WARNING_CONFIG_FAILED
;
5108 connect
= strtoul(time_str
, NULL
, 10);
5110 ret
= peer_timers_connect_set(peer
, connect
);
5112 return bgp_vty_return(vty
, ret
);
5115 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5120 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5122 return CMD_WARNING_CONFIG_FAILED
;
5124 ret
= peer_timers_connect_unset(peer
);
5126 return bgp_vty_return(vty
, ret
);
5129 DEFUN (neighbor_timers_connect
,
5130 neighbor_timers_connect_cmd
,
5131 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5134 "BGP per neighbor timers\n"
5135 "BGP connect timer\n"
5140 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5141 argv
[idx_number
]->arg
);
5144 DEFUN (no_neighbor_timers_connect
,
5145 no_neighbor_timers_connect_cmd
,
5146 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5150 "BGP per neighbor timers\n"
5151 "BGP connect timer\n"
5155 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5159 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5160 const char *time_str
, int set
)
5164 uint32_t routeadv
= 0;
5166 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5168 return CMD_WARNING_CONFIG_FAILED
;
5171 routeadv
= strtoul(time_str
, NULL
, 10);
5174 ret
= peer_advertise_interval_set(peer
, routeadv
);
5176 ret
= peer_advertise_interval_unset(peer
);
5178 return bgp_vty_return(vty
, ret
);
5181 DEFUN (neighbor_advertise_interval
,
5182 neighbor_advertise_interval_cmd
,
5183 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5186 "Minimum interval between sending BGP routing updates\n"
5187 "time in seconds\n")
5191 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5192 argv
[idx_number
]->arg
, 1);
5195 DEFUN (no_neighbor_advertise_interval
,
5196 no_neighbor_advertise_interval_cmd
,
5197 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5201 "Minimum interval between sending BGP routing updates\n"
5202 "time in seconds\n")
5205 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5209 /* Time to wait before processing route-map updates */
5210 DEFUN (bgp_set_route_map_delay_timer
,
5211 bgp_set_route_map_delay_timer_cmd
,
5212 "bgp route-map delay-timer (0-600)",
5214 "BGP route-map delay timer\n"
5215 "Time in secs to wait before processing route-map changes\n"
5216 "0 disables the timer, no route updates happen when route-maps change\n")
5219 uint32_t rmap_delay_timer
;
5221 if (argv
[idx_number
]->arg
) {
5222 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5223 bm
->rmap_update_timer
= rmap_delay_timer
;
5225 /* if the dynamic update handling is being disabled, and a timer
5227 * running, stop the timer and act as if the timer has already
5230 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5231 BGP_TIMER_OFF(bm
->t_rmap_update
);
5232 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5237 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5238 return CMD_WARNING_CONFIG_FAILED
;
5242 DEFUN (no_bgp_set_route_map_delay_timer
,
5243 no_bgp_set_route_map_delay_timer_cmd
,
5244 "no bgp route-map delay-timer [(0-600)]",
5247 "Default BGP route-map delay timer\n"
5248 "Reset to default time to wait for processing route-map changes\n"
5249 "0 disables the timer, no route updates happen when route-maps change\n")
5252 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5258 /* neighbor interface */
5259 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5264 peer
= peer_lookup_vty(vty
, ip_str
);
5265 if (!peer
|| peer
->conf_if
) {
5266 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5267 return CMD_WARNING_CONFIG_FAILED
;
5271 peer_interface_set(peer
, str
);
5273 peer_interface_unset(peer
);
5278 DEFUN (neighbor_interface
,
5279 neighbor_interface_cmd
,
5280 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5288 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5291 DEFUN (no_neighbor_interface
,
5292 no_neighbor_interface_cmd
,
5293 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5301 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5304 DEFUN (neighbor_distribute_list
,
5305 neighbor_distribute_list_cmd
,
5306 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5309 "Filter updates to/from this neighbor\n"
5310 "IP access-list number\n"
5311 "IP access-list number (expanded range)\n"
5312 "IP Access-list name\n"
5313 "Filter incoming updates\n"
5314 "Filter outgoing updates\n")
5321 const char *pstr
= argv
[idx_peer
]->arg
;
5322 const char *acl
= argv
[idx_acl
]->arg
;
5323 const char *inout
= argv
[argc
- 1]->text
;
5325 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5327 return CMD_WARNING_CONFIG_FAILED
;
5329 /* Check filter direction. */
5330 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5331 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5334 return bgp_vty_return(vty
, ret
);
5338 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5339 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5340 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
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")
5348 DEFUN (no_neighbor_distribute_list
,
5349 no_neighbor_distribute_list_cmd
,
5350 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5354 "Filter updates to/from this neighbor\n"
5355 "IP access-list number\n"
5356 "IP access-list number (expanded range)\n"
5357 "IP Access-list name\n"
5358 "Filter incoming updates\n"
5359 "Filter outgoing updates\n")
5365 const char *pstr
= argv
[idx_peer
]->arg
;
5366 const char *inout
= argv
[argc
- 1]->text
;
5368 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5370 return CMD_WARNING_CONFIG_FAILED
;
5372 /* Check filter direction. */
5373 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5374 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5377 return bgp_vty_return(vty
, ret
);
5381 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5382 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5383 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5384 "Filter updates to/from this neighbor\n"
5385 "IP access-list number\n"
5386 "IP access-list number (expanded range)\n"
5387 "IP Access-list name\n"
5388 "Filter incoming updates\n"
5389 "Filter outgoing updates\n")
5391 /* Set prefix list to the peer. */
5392 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5393 afi_t afi
, safi_t safi
,
5394 const char *name_str
,
5395 const char *direct_str
)
5398 int direct
= FILTER_IN
;
5401 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5403 return CMD_WARNING_CONFIG_FAILED
;
5405 /* Check filter direction. */
5406 if (strncmp(direct_str
, "i", 1) == 0)
5408 else if (strncmp(direct_str
, "o", 1) == 0)
5409 direct
= FILTER_OUT
;
5411 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5413 return bgp_vty_return(vty
, ret
);
5416 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5417 afi_t afi
, safi_t safi
,
5418 const char *direct_str
)
5422 int direct
= FILTER_IN
;
5424 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5426 return CMD_WARNING_CONFIG_FAILED
;
5428 /* Check filter direction. */
5429 if (strncmp(direct_str
, "i", 1) == 0)
5431 else if (strncmp(direct_str
, "o", 1) == 0)
5432 direct
= FILTER_OUT
;
5434 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5436 return bgp_vty_return(vty
, ret
);
5439 DEFUN (neighbor_prefix_list
,
5440 neighbor_prefix_list_cmd
,
5441 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5444 "Filter updates to/from this neighbor\n"
5445 "Name of a prefix list\n"
5446 "Filter incoming updates\n"
5447 "Filter outgoing updates\n")
5452 return peer_prefix_list_set_vty(
5453 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5454 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5457 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5458 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5459 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5460 "Filter updates to/from this neighbor\n"
5461 "Name of a prefix list\n"
5462 "Filter incoming updates\n"
5463 "Filter outgoing updates\n")
5465 DEFUN (no_neighbor_prefix_list
,
5466 no_neighbor_prefix_list_cmd
,
5467 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5471 "Filter updates to/from this neighbor\n"
5472 "Name of a prefix list\n"
5473 "Filter incoming updates\n"
5474 "Filter outgoing updates\n")
5478 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5479 bgp_node_afi(vty
), bgp_node_safi(vty
),
5480 argv
[idx_in_out
]->arg
);
5483 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5484 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5485 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5486 "Filter updates to/from this neighbor\n"
5487 "Name of a prefix list\n"
5488 "Filter incoming updates\n"
5489 "Filter outgoing updates\n")
5491 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5492 safi_t safi
, const char *name_str
,
5493 const char *direct_str
)
5497 int direct
= FILTER_IN
;
5499 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5501 return CMD_WARNING_CONFIG_FAILED
;
5503 /* Check filter direction. */
5504 if (strncmp(direct_str
, "i", 1) == 0)
5506 else if (strncmp(direct_str
, "o", 1) == 0)
5507 direct
= FILTER_OUT
;
5509 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5511 return bgp_vty_return(vty
, ret
);
5514 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5515 safi_t safi
, const char *direct_str
)
5519 int direct
= FILTER_IN
;
5521 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5523 return CMD_WARNING_CONFIG_FAILED
;
5525 /* Check filter direction. */
5526 if (strncmp(direct_str
, "i", 1) == 0)
5528 else if (strncmp(direct_str
, "o", 1) == 0)
5529 direct
= FILTER_OUT
;
5531 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5533 return bgp_vty_return(vty
, ret
);
5536 DEFUN (neighbor_filter_list
,
5537 neighbor_filter_list_cmd
,
5538 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5541 "Establish BGP filters\n"
5542 "AS path access-list name\n"
5543 "Filter incoming routes\n"
5544 "Filter outgoing routes\n")
5549 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5550 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5551 argv
[idx_in_out
]->arg
);
5554 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5555 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5556 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5557 "Establish BGP filters\n"
5558 "AS path access-list name\n"
5559 "Filter incoming routes\n"
5560 "Filter outgoing routes\n")
5562 DEFUN (no_neighbor_filter_list
,
5563 no_neighbor_filter_list_cmd
,
5564 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5568 "Establish BGP filters\n"
5569 "AS path access-list name\n"
5570 "Filter incoming routes\n"
5571 "Filter outgoing routes\n")
5575 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5576 bgp_node_afi(vty
), bgp_node_safi(vty
),
5577 argv
[idx_in_out
]->arg
);
5580 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5581 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5582 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5583 "Establish BGP filters\n"
5584 "AS path access-list name\n"
5585 "Filter incoming routes\n"
5586 "Filter outgoing routes\n")
5588 /* Set route-map to the peer. */
5589 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5590 afi_t afi
, safi_t safi
, const char *name_str
,
5591 const char *direct_str
)
5595 int direct
= RMAP_IN
;
5597 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5599 return CMD_WARNING_CONFIG_FAILED
;
5601 /* Check filter direction. */
5602 if (strncmp(direct_str
, "in", 2) == 0)
5604 else if (strncmp(direct_str
, "o", 1) == 0)
5607 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
);
5609 return bgp_vty_return(vty
, ret
);
5612 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5613 afi_t afi
, safi_t safi
,
5614 const char *direct_str
)
5618 int direct
= RMAP_IN
;
5620 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5622 return CMD_WARNING_CONFIG_FAILED
;
5624 /* Check filter direction. */
5625 if (strncmp(direct_str
, "in", 2) == 0)
5627 else if (strncmp(direct_str
, "o", 1) == 0)
5630 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5632 return bgp_vty_return(vty
, ret
);
5635 DEFUN (neighbor_route_map
,
5636 neighbor_route_map_cmd
,
5637 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5640 "Apply route map to neighbor\n"
5641 "Name of route map\n"
5642 "Apply map to incoming routes\n"
5643 "Apply map to outbound routes\n")
5648 return peer_route_map_set_vty(
5649 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5650 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5653 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5654 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5655 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5656 "Apply route map to neighbor\n"
5657 "Name of route map\n"
5658 "Apply map to incoming routes\n"
5659 "Apply map to outbound routes\n")
5661 DEFUN (no_neighbor_route_map
,
5662 no_neighbor_route_map_cmd
,
5663 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5667 "Apply route map to neighbor\n"
5668 "Name of route map\n"
5669 "Apply map to incoming routes\n"
5670 "Apply map to outbound routes\n")
5674 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5675 bgp_node_afi(vty
), bgp_node_safi(vty
),
5676 argv
[idx_in_out
]->arg
);
5679 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5680 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5681 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5682 "Apply route map to neighbor\n"
5683 "Name of route map\n"
5684 "Apply map to incoming routes\n"
5685 "Apply map to outbound routes\n")
5687 /* Set unsuppress-map to the peer. */
5688 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5689 afi_t afi
, safi_t safi
,
5690 const char *name_str
)
5695 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5697 return CMD_WARNING_CONFIG_FAILED
;
5699 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
);
5701 return bgp_vty_return(vty
, ret
);
5704 /* Unset route-map from the peer. */
5705 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5706 afi_t afi
, safi_t safi
)
5711 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5713 return CMD_WARNING_CONFIG_FAILED
;
5715 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5717 return bgp_vty_return(vty
, ret
);
5720 DEFUN (neighbor_unsuppress_map
,
5721 neighbor_unsuppress_map_cmd
,
5722 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5725 "Route-map to selectively unsuppress suppressed routes\n"
5726 "Name of route map\n")
5730 return peer_unsuppress_map_set_vty(
5731 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5732 argv
[idx_word
]->arg
);
5735 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5736 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5737 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5738 "Route-map to selectively unsuppress suppressed routes\n"
5739 "Name of route map\n")
5741 DEFUN (no_neighbor_unsuppress_map
,
5742 no_neighbor_unsuppress_map_cmd
,
5743 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5747 "Route-map to selectively unsuppress suppressed routes\n"
5748 "Name of route map\n")
5751 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5753 bgp_node_safi(vty
));
5756 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5757 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5758 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5759 "Route-map to selectively unsuppress suppressed routes\n"
5760 "Name of route map\n")
5762 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5763 afi_t afi
, safi_t safi
,
5764 const char *num_str
,
5765 const char *threshold_str
, int warning
,
5766 const char *restart_str
)
5774 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5776 return CMD_WARNING_CONFIG_FAILED
;
5778 max
= strtoul(num_str
, NULL
, 10);
5780 threshold
= atoi(threshold_str
);
5782 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5785 restart
= atoi(restart_str
);
5789 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5792 return bgp_vty_return(vty
, ret
);
5795 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5796 afi_t afi
, safi_t safi
)
5801 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5803 return CMD_WARNING_CONFIG_FAILED
;
5805 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5807 return bgp_vty_return(vty
, ret
);
5810 /* Maximum number of prefix configuration. prefix count is different
5811 for each peer configuration. So this configuration can be set for
5812 each peer configuration. */
5813 DEFUN (neighbor_maximum_prefix
,
5814 neighbor_maximum_prefix_cmd
,
5815 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5818 "Maximum number of prefix accept from this peer\n"
5819 "maximum no. of prefix limit\n")
5823 return peer_maximum_prefix_set_vty(
5824 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5825 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5828 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5829 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5830 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5831 "Maximum number of prefix accept from this peer\n"
5832 "maximum no. of prefix limit\n")
5834 DEFUN (neighbor_maximum_prefix_threshold
,
5835 neighbor_maximum_prefix_threshold_cmd
,
5836 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5839 "Maximum number of prefix accept from this peer\n"
5840 "maximum no. of prefix limit\n"
5841 "Threshold value (%) at which to generate a warning msg\n")
5845 int idx_number_2
= 4;
5846 return peer_maximum_prefix_set_vty(
5847 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5848 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5852 neighbor_maximum_prefix_threshold
,
5853 neighbor_maximum_prefix_threshold_hidden_cmd
,
5854 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5855 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5856 "Maximum number of prefix accept from this peer\n"
5857 "maximum no. of prefix limit\n"
5858 "Threshold value (%) at which to generate a warning msg\n")
5860 DEFUN (neighbor_maximum_prefix_warning
,
5861 neighbor_maximum_prefix_warning_cmd
,
5862 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5865 "Maximum number of prefix accept from this peer\n"
5866 "maximum no. of prefix limit\n"
5867 "Only give warning message when limit is exceeded\n")
5871 return peer_maximum_prefix_set_vty(
5872 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5873 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
5877 neighbor_maximum_prefix_warning
,
5878 neighbor_maximum_prefix_warning_hidden_cmd
,
5879 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5880 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5881 "Maximum number of prefix accept from this peer\n"
5882 "maximum no. of prefix limit\n"
5883 "Only give warning message when limit is exceeded\n")
5885 DEFUN (neighbor_maximum_prefix_threshold_warning
,
5886 neighbor_maximum_prefix_threshold_warning_cmd
,
5887 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5890 "Maximum number of prefix accept from this peer\n"
5891 "maximum no. of prefix limit\n"
5892 "Threshold value (%) at which to generate a warning msg\n"
5893 "Only give warning message when limit is exceeded\n")
5897 int idx_number_2
= 4;
5898 return peer_maximum_prefix_set_vty(
5899 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5900 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
5904 neighbor_maximum_prefix_threshold_warning
,
5905 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
5906 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5907 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5908 "Maximum number of prefix accept from this peer\n"
5909 "maximum no. of prefix limit\n"
5910 "Threshold value (%) at which to generate a warning msg\n"
5911 "Only give warning message when limit is exceeded\n")
5913 DEFUN (neighbor_maximum_prefix_restart
,
5914 neighbor_maximum_prefix_restart_cmd
,
5915 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5918 "Maximum number of prefix accept from this peer\n"
5919 "maximum no. of prefix limit\n"
5920 "Restart bgp connection after limit is exceeded\n"
5921 "Restart interval in minutes\n")
5925 int idx_number_2
= 5;
5926 return peer_maximum_prefix_set_vty(
5927 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5928 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
5932 neighbor_maximum_prefix_restart
,
5933 neighbor_maximum_prefix_restart_hidden_cmd
,
5934 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5935 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5936 "Maximum number of prefix accept from this peer\n"
5937 "maximum no. of prefix limit\n"
5938 "Restart bgp connection after limit is exceeded\n"
5939 "Restart interval in minutes\n")
5941 DEFUN (neighbor_maximum_prefix_threshold_restart
,
5942 neighbor_maximum_prefix_threshold_restart_cmd
,
5943 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5946 "Maximum number of prefixes to accept from this peer\n"
5947 "maximum no. of prefix limit\n"
5948 "Threshold value (%) at which to generate a warning msg\n"
5949 "Restart bgp connection after limit is exceeded\n"
5950 "Restart interval in minutes\n")
5954 int idx_number_2
= 4;
5955 int idx_number_3
= 6;
5956 return peer_maximum_prefix_set_vty(
5957 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5958 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
5959 argv
[idx_number_3
]->arg
);
5963 neighbor_maximum_prefix_threshold_restart
,
5964 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
5965 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5966 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5967 "Maximum number of prefixes to accept from this peer\n"
5968 "maximum no. of prefix limit\n"
5969 "Threshold value (%) at which to generate a warning msg\n"
5970 "Restart bgp connection after limit is exceeded\n"
5971 "Restart interval in minutes\n")
5973 DEFUN (no_neighbor_maximum_prefix
,
5974 no_neighbor_maximum_prefix_cmd
,
5975 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5979 "Maximum number of prefixes to accept from this peer\n"
5980 "maximum no. of prefix limit\n"
5981 "Threshold value (%) at which to generate a warning msg\n"
5982 "Restart bgp connection after limit is exceeded\n"
5983 "Restart interval in minutes\n"
5984 "Only give warning message when limit is exceeded\n")
5987 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
5989 bgp_node_safi(vty
));
5993 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
5994 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5995 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5996 "Maximum number of prefixes to accept from this peer\n"
5997 "maximum no. of prefix limit\n"
5998 "Threshold value (%) at which to generate a warning msg\n"
5999 "Restart bgp connection after limit is exceeded\n"
6000 "Restart interval in minutes\n"
6001 "Only give warning message when limit is exceeded\n")
6004 /* "neighbor allowas-in" */
6005 DEFUN (neighbor_allowas_in
,
6006 neighbor_allowas_in_cmd
,
6007 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6010 "Accept as-path with my AS present in it\n"
6011 "Number of occurances of AS number\n"
6012 "Only accept my AS in the as-path if the route was originated in my AS\n")
6015 int idx_number_origin
= 3;
6021 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6023 return CMD_WARNING_CONFIG_FAILED
;
6025 if (argc
<= idx_number_origin
)
6028 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6031 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6034 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6037 return bgp_vty_return(vty
, ret
);
6041 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6042 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6043 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6044 "Accept as-path with my AS present in it\n"
6045 "Number of occurances of AS number\n"
6046 "Only accept my AS in the as-path if the route was originated in my AS\n")
6048 DEFUN (no_neighbor_allowas_in
,
6049 no_neighbor_allowas_in_cmd
,
6050 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6054 "allow local ASN appears in aspath attribute\n"
6055 "Number of occurances of AS number\n"
6056 "Only accept my AS in the as-path if the route was originated in my AS\n")
6062 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6064 return CMD_WARNING_CONFIG_FAILED
;
6066 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6067 bgp_node_safi(vty
));
6069 return bgp_vty_return(vty
, ret
);
6073 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6074 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6075 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6076 "allow local ASN appears in aspath attribute\n"
6077 "Number of occurances of AS number\n"
6078 "Only accept my AS in the as-path if the route was originated in my AS\n")
6080 DEFUN (neighbor_ttl_security
,
6081 neighbor_ttl_security_cmd
,
6082 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6085 "BGP ttl-security parameters\n"
6086 "Specify the maximum number of hops to the BGP peer\n"
6087 "Number of hops to BGP peer\n")
6094 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6096 return CMD_WARNING_CONFIG_FAILED
;
6098 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6101 * If 'neighbor swpX', then this is for directly connected peers,
6102 * we should not accept a ttl-security hops value greater than 1.
6104 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6106 "%s is directly connected peer, hops cannot exceed 1\n",
6107 argv
[idx_peer
]->arg
);
6108 return CMD_WARNING_CONFIG_FAILED
;
6111 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6114 DEFUN (no_neighbor_ttl_security
,
6115 no_neighbor_ttl_security_cmd
,
6116 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6120 "BGP ttl-security parameters\n"
6121 "Specify the maximum number of hops to the BGP peer\n"
6122 "Number of hops to BGP peer\n")
6127 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6129 return CMD_WARNING_CONFIG_FAILED
;
6131 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6134 DEFUN (neighbor_addpath_tx_all_paths
,
6135 neighbor_addpath_tx_all_paths_cmd
,
6136 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6139 "Use addpath to advertise all paths to a neighbor\n")
6144 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6146 return CMD_WARNING_CONFIG_FAILED
;
6148 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6150 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
6153 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6154 neighbor_addpath_tx_all_paths_hidden_cmd
,
6155 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6156 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6157 "Use addpath to advertise all paths to a neighbor\n")
6159 DEFUN (no_neighbor_addpath_tx_all_paths
,
6160 no_neighbor_addpath_tx_all_paths_cmd
,
6161 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6165 "Use addpath to advertise all paths to a neighbor\n")
6168 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6169 bgp_node_afi(vty
), bgp_node_safi(vty
),
6170 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
6173 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6174 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6175 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6176 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6177 "Use addpath to advertise all paths to a neighbor\n")
6179 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6180 neighbor_addpath_tx_bestpath_per_as_cmd
,
6181 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6184 "Use addpath to advertise the bestpath per each neighboring AS\n")
6189 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6191 return CMD_WARNING_CONFIG_FAILED
;
6193 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6195 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
6198 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6199 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6200 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6201 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6202 "Use addpath to advertise the bestpath per each neighboring AS\n")
6204 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6205 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6206 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6210 "Use addpath to advertise the bestpath per each neighboring AS\n")
6213 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6214 bgp_node_afi(vty
), bgp_node_safi(vty
),
6215 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
6218 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6219 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6220 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6221 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6222 "Use addpath to advertise the bestpath per each neighboring AS\n")
6224 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6225 struct ecommunity
**list
)
6227 struct ecommunity
*ecom
= NULL
;
6228 struct ecommunity
*ecomadd
;
6230 for (; argc
; --argc
, ++argv
) {
6232 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6233 ECOMMUNITY_ROUTE_TARGET
, 0);
6235 vty_out(vty
, "Malformed community-list value\n");
6237 ecommunity_free(&ecom
);
6238 return CMD_WARNING_CONFIG_FAILED
;
6242 ecommunity_merge(ecom
, ecomadd
);
6243 ecommunity_free(&ecomadd
);
6250 ecommunity_free(&*list
);
6258 * v2vimport is true if we are handling a `import vrf ...` command
6260 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6264 switch (vty
->node
) {
6273 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6278 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6279 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6280 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6281 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6283 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6287 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6288 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6289 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6290 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6292 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6299 DEFPY (af_rd_vpn_export
,
6300 af_rd_vpn_export_cmd
,
6301 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6303 "Specify route distinguisher\n"
6304 "Between current address-family and vpn\n"
6305 "For routes leaked from current address-family to vpn\n"
6306 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6308 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6309 struct prefix_rd prd
;
6315 if (argv_find(argv
, argc
, "no", &idx
))
6319 ret
= str2prefix_rd(rd_str
, &prd
);
6321 vty_out(vty
, "%% Malformed rd\n");
6322 return CMD_WARNING_CONFIG_FAILED
;
6326 afi
= vpn_policy_getafi(vty
, bgp
, false);
6328 return CMD_WARNING_CONFIG_FAILED
;
6331 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6333 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6334 bgp_get_default(), bgp
);
6337 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6338 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6339 BGP_VPN_POLICY_TOVPN_RD_SET
);
6341 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6342 BGP_VPN_POLICY_TOVPN_RD_SET
);
6345 /* post-change: re-export vpn routes */
6346 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6347 bgp_get_default(), bgp
);
6352 ALIAS (af_rd_vpn_export
,
6353 af_no_rd_vpn_export_cmd
,
6356 "Specify route distinguisher\n"
6357 "Between current address-family and vpn\n"
6358 "For routes leaked from current address-family to vpn\n")
6360 DEFPY (af_label_vpn_export
,
6361 af_label_vpn_export_cmd
,
6362 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6364 "label value for VRF\n"
6365 "Between current address-family and vpn\n"
6366 "For routes leaked from current address-family to vpn\n"
6367 "Label Value <0-1048575>\n"
6368 "Automatically assign a label\n")
6370 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6371 mpls_label_t label
= MPLS_LABEL_NONE
;
6376 if (argv_find(argv
, argc
, "no", &idx
))
6379 /* If "no ...", squash trailing parameter */
6385 label
= label_val
; /* parser should force unsigned */
6388 afi
= vpn_policy_getafi(vty
, bgp
, false);
6390 return CMD_WARNING_CONFIG_FAILED
;
6393 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6394 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6399 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6401 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6402 bgp_get_default(), bgp
);
6404 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6405 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6407 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6410 * label has previously been automatically
6411 * assigned by labelpool: release it
6413 * NB if tovpn_label == MPLS_LABEL_NONE it
6414 * means the automatic assignment is in flight
6415 * and therefore the labelpool callback must
6416 * detect that the auto label is not needed.
6419 bgp_lp_release(LP_TYPE_VRF
,
6420 &bgp
->vpn_policy
[afi
],
6421 bgp
->vpn_policy
[afi
].tovpn_label
);
6423 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6424 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6427 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6429 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6430 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6431 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6432 vpn_leak_label_callback
);
6435 /* post-change: re-export vpn routes */
6436 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6437 bgp_get_default(), bgp
);
6442 ALIAS (af_label_vpn_export
,
6443 af_no_label_vpn_export_cmd
,
6444 "no label vpn export",
6446 "label value for VRF\n"
6447 "Between current address-family and vpn\n"
6448 "For routes leaked from current address-family to vpn\n")
6450 DEFPY (af_nexthop_vpn_export
,
6451 af_nexthop_vpn_export_cmd
,
6452 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6454 "Specify next hop to use for VRF advertised prefixes\n"
6455 "Between current address-family and vpn\n"
6456 "For routes leaked from current address-family to vpn\n"
6460 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6466 if (argv_find(argv
, argc
, "no", &idx
))
6470 if (!sockunion2hostprefix(nexthop_str
, &p
))
6471 return CMD_WARNING_CONFIG_FAILED
;
6474 afi
= vpn_policy_getafi(vty
, bgp
, false);
6476 return CMD_WARNING_CONFIG_FAILED
;
6479 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6481 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6482 bgp_get_default(), bgp
);
6485 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6486 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6487 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6489 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6490 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6493 /* post-change: re-export vpn routes */
6494 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6495 bgp_get_default(), bgp
);
6500 ALIAS (af_nexthop_vpn_export
,
6501 af_no_nexthop_vpn_export_cmd
,
6502 "no nexthop vpn export",
6504 "Specify next hop to use for VRF advertised prefixes\n"
6505 "Between current address-family and vpn\n"
6506 "For routes leaked from current address-family to vpn\n")
6508 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6510 if (!strcmp(dstr
, "import")) {
6511 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6512 } else if (!strcmp(dstr
, "export")) {
6513 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6514 } else if (!strcmp(dstr
, "both")) {
6515 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6516 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6518 vty_out(vty
, "%% direction parse error\n");
6519 return CMD_WARNING_CONFIG_FAILED
;
6524 DEFPY (af_rt_vpn_imexport
,
6525 af_rt_vpn_imexport_cmd
,
6526 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6528 "Specify route target list\n"
6529 "Specify route target list\n"
6530 "Between current address-family and vpn\n"
6531 "For routes leaked from vpn to current address-family: match any\n"
6532 "For routes leaked from current address-family to vpn: set\n"
6533 "both import: match any and export: set\n"
6534 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6536 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6538 struct ecommunity
*ecom
= NULL
;
6539 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6540 vpn_policy_direction_t dir
;
6545 if (argv_find(argv
, argc
, "no", &idx
))
6548 afi
= vpn_policy_getafi(vty
, bgp
, false);
6550 return CMD_WARNING_CONFIG_FAILED
;
6552 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6553 if (ret
!= CMD_SUCCESS
)
6557 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6558 vty_out(vty
, "%% Missing RTLIST\n");
6559 return CMD_WARNING_CONFIG_FAILED
;
6561 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6562 if (ret
!= CMD_SUCCESS
) {
6567 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6571 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6574 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6576 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6577 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6578 ecommunity_dup(ecom
);
6580 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6582 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6583 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6586 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6590 ecommunity_free(&ecom
);
6595 ALIAS (af_rt_vpn_imexport
,
6596 af_no_rt_vpn_imexport_cmd
,
6597 "no <rt|route-target> vpn <import|export|both>$direction_str",
6599 "Specify route target list\n"
6600 "Specify route target list\n"
6601 "Between current address-family and vpn\n"
6602 "For routes leaked from vpn to current address-family\n"
6603 "For routes leaked from current address-family to vpn\n"
6604 "both import and export\n")
6606 DEFPY (af_route_map_vpn_imexport
,
6607 af_route_map_vpn_imexport_cmd
,
6608 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6609 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6611 "Specify route map\n"
6612 "Between current address-family and vpn\n"
6613 "For routes leaked from vpn to current address-family\n"
6614 "For routes leaked from current address-family to vpn\n"
6615 "name of route-map\n")
6617 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6619 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6620 vpn_policy_direction_t dir
;
6625 if (argv_find(argv
, argc
, "no", &idx
))
6628 afi
= vpn_policy_getafi(vty
, bgp
, false);
6630 return CMD_WARNING_CONFIG_FAILED
;
6632 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6633 if (ret
!= CMD_SUCCESS
)
6636 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6640 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6643 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6644 XFREE(MTYPE_ROUTE_MAP_NAME
,
6645 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6646 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6647 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6648 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6649 route_map_lookup_by_name(rmap_str
);
6650 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6653 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6654 XFREE(MTYPE_ROUTE_MAP_NAME
,
6655 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6656 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6657 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6660 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6666 ALIAS (af_route_map_vpn_imexport
,
6667 af_no_route_map_vpn_imexport_cmd
,
6668 "no route-map vpn <import|export>$direction_str",
6670 "Specify route map\n"
6671 "Between current address-family and vpn\n"
6672 "For routes leaked from vpn to current address-family\n"
6673 "For routes leaked from current address-family to vpn\n")
6675 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6676 "[no] import vrf route-map RMAP$rmap_str",
6678 "Import routes from another VRF\n"
6679 "Vrf routes being filtered\n"
6680 "Specify route map\n"
6681 "name of route-map\n")
6683 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6684 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6688 struct bgp
*bgp_default
;
6690 if (argv_find(argv
, argc
, "no", &idx
))
6693 afi
= vpn_policy_getafi(vty
, bgp
, true);
6695 return CMD_WARNING_CONFIG_FAILED
;
6697 bgp_default
= bgp_get_default();
6702 /* Auto-create assuming the same AS */
6703 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6704 BGP_INSTANCE_TYPE_DEFAULT
);
6708 "VRF default is not configured as a bgp instance\n");
6713 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6716 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6717 XFREE(MTYPE_ROUTE_MAP_NAME
,
6718 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6719 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6720 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6721 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6722 route_map_lookup_by_name(rmap_str
);
6723 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6726 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6727 XFREE(MTYPE_ROUTE_MAP_NAME
,
6728 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6729 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6730 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6733 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6738 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6739 "no import vrf route-map",
6741 "Import routes from another VRF\n"
6742 "Vrf routes being filtered\n"
6743 "Specify route map\n")
6745 DEFPY (bgp_imexport_vrf
,
6746 bgp_imexport_vrf_cmd
,
6747 "[no] import vrf NAME$import_name",
6749 "Import routes from another VRF\n"
6750 "VRF to import from\n"
6751 "The name of the VRF\n")
6753 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6754 struct listnode
*node
;
6755 struct bgp
*vrf_bgp
, *bgp_default
;
6758 bool remove
= false;
6761 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
6765 if (import_name
== NULL
) {
6766 vty_out(vty
, "%% Missing import name\n");
6770 if (argv_find(argv
, argc
, "no", &idx
))
6773 afi
= vpn_policy_getafi(vty
, bgp
, true);
6775 return CMD_WARNING_CONFIG_FAILED
;
6777 safi
= bgp_node_safi(vty
);
6779 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
6780 && (strcmp(import_name
, BGP_DEFAULT_NAME
) == 0))
6781 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
6782 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
6783 remove
? "unimport" : "import", import_name
);
6787 bgp_default
= bgp_get_default();
6789 /* Auto-create assuming the same AS */
6790 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6791 BGP_INSTANCE_TYPE_DEFAULT
);
6795 "VRF default is not configured as a bgp instance\n");
6800 vrf_bgp
= bgp_lookup_by_name(import_name
);
6802 if (strcmp(import_name
, BGP_DEFAULT_NAME
) == 0)
6803 vrf_bgp
= bgp_default
;
6805 /* Auto-create assuming the same AS */
6806 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
6810 "VRF %s is not configured as a bgp instance\n",
6817 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6819 /* Already importing from "import_vrf"? */
6820 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
6822 if (strcmp(vname
, import_name
) == 0)
6826 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6832 /* This command is valid only in a bgp vrf instance or the default instance */
6833 DEFPY (bgp_imexport_vpn
,
6834 bgp_imexport_vpn_cmd
,
6835 "[no] <import|export>$direction_str vpn",
6837 "Import routes to this address-family\n"
6838 "Export routes from this address-family\n"
6839 "to/from default instance VPN RIB\n")
6841 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6848 vpn_policy_direction_t dir
;
6850 if (argv_find(argv
, argc
, "no", &idx
))
6853 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
6854 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
6856 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
6857 return CMD_WARNING_CONFIG_FAILED
;
6860 afi
= bgp_node_afi(vty
);
6861 safi
= bgp_node_safi(vty
);
6862 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
6863 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
6864 return CMD_WARNING_CONFIG_FAILED
;
6867 if (!strcmp(direction_str
, "import")) {
6868 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
6869 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6870 } else if (!strcmp(direction_str
, "export")) {
6871 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
6872 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
6874 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
6875 return CMD_WARNING_CONFIG_FAILED
;
6878 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6881 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6882 if (!previous_state
) {
6883 /* trigger export current vrf */
6884 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6887 if (previous_state
) {
6888 /* trigger un-export current vrf */
6889 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6891 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6897 DEFPY (af_routetarget_import
,
6898 af_routetarget_import_cmd
,
6899 "[no] <rt|route-target> redirect import RTLIST...",
6901 "Specify route target list\n"
6902 "Specify route target list\n"
6903 "Flow-spec redirect type route target\n"
6904 "Import routes to this address-family\n"
6905 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6907 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6909 struct ecommunity
*ecom
= NULL
;
6914 if (argv_find(argv
, argc
, "no", &idx
))
6917 afi
= vpn_policy_getafi(vty
, bgp
, false);
6919 return CMD_WARNING_CONFIG_FAILED
;
6922 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6923 vty_out(vty
, "%% Missing RTLIST\n");
6924 return CMD_WARNING_CONFIG_FAILED
;
6926 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6927 if (ret
!= CMD_SUCCESS
)
6932 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
6933 ecommunity_free(&bgp
->vpn_policy
[afi
]
6934 .import_redirect_rtlist
);
6935 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
6936 ecommunity_dup(ecom
);
6938 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
6939 ecommunity_free(&bgp
->vpn_policy
[afi
]
6940 .import_redirect_rtlist
);
6941 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
6945 ecommunity_free(&ecom
);
6950 DEFUN_NOSH (address_family_ipv4_safi
,
6951 address_family_ipv4_safi_cmd
,
6952 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
6953 "Enter Address Family command mode\n"
6955 BGP_SAFI_WITH_LABEL_HELP_STR
)
6959 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6960 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6961 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
6962 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
6963 && safi
!= SAFI_EVPN
) {
6965 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
6966 return CMD_WARNING_CONFIG_FAILED
;
6968 vty
->node
= bgp_node_type(AFI_IP
, safi
);
6970 vty
->node
= BGP_IPV4_NODE
;
6975 DEFUN_NOSH (address_family_ipv6_safi
,
6976 address_family_ipv6_safi_cmd
,
6977 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
6978 "Enter Address Family command mode\n"
6980 BGP_SAFI_WITH_LABEL_HELP_STR
)
6983 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6984 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6985 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
6986 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
6987 && safi
!= SAFI_EVPN
) {
6989 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
6990 return CMD_WARNING_CONFIG_FAILED
;
6992 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
6994 vty
->node
= BGP_IPV6_NODE
;
6999 #ifdef KEEP_OLD_VPN_COMMANDS
7000 DEFUN_NOSH (address_family_vpnv4
,
7001 address_family_vpnv4_cmd
,
7002 "address-family vpnv4 [unicast]",
7003 "Enter Address Family command mode\n"
7005 "Address Family modifier\n")
7007 vty
->node
= BGP_VPNV4_NODE
;
7011 DEFUN_NOSH (address_family_vpnv6
,
7012 address_family_vpnv6_cmd
,
7013 "address-family vpnv6 [unicast]",
7014 "Enter Address Family command mode\n"
7016 "Address Family modifier\n")
7018 vty
->node
= BGP_VPNV6_NODE
;
7023 DEFUN_NOSH (address_family_evpn
,
7024 address_family_evpn_cmd
,
7025 "address-family l2vpn evpn",
7026 "Enter Address Family command mode\n"
7028 "Address Family modifier\n")
7030 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7031 vty
->node
= BGP_EVPN_NODE
;
7035 DEFUN_NOSH (exit_address_family
,
7036 exit_address_family_cmd
,
7037 "exit-address-family",
7038 "Exit from Address Family configuration mode\n")
7040 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7041 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7042 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7043 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7044 || vty
->node
== BGP_EVPN_NODE
7045 || vty
->node
== BGP_FLOWSPECV4_NODE
7046 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7047 vty
->node
= BGP_NODE
;
7051 /* Recalculate bestpath and re-advertise a prefix */
7052 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7053 const char *ip_str
, afi_t afi
, safi_t safi
,
7054 struct prefix_rd
*prd
)
7057 struct prefix match
;
7058 struct bgp_node
*rn
;
7059 struct bgp_node
*rm
;
7061 struct bgp_table
*table
;
7062 struct bgp_table
*rib
;
7064 /* BGP structure lookup. */
7066 bgp
= bgp_lookup_by_name(view_name
);
7068 vty_out(vty
, "%% Can't find BGP instance %s\n",
7073 bgp
= bgp_get_default();
7075 vty_out(vty
, "%% No BGP process is configured\n");
7080 /* Check IP address argument. */
7081 ret
= str2prefix(ip_str
, &match
);
7083 vty_out(vty
, "%% address is malformed\n");
7087 match
.family
= afi2family(afi
);
7088 rib
= bgp
->rib
[afi
][safi
];
7090 if (safi
== SAFI_MPLS_VPN
) {
7091 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7092 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7095 if ((table
= rn
->info
) != NULL
) {
7096 if ((rm
= bgp_node_match(table
, &match
))
7099 == match
.prefixlen
) {
7101 BGP_NODE_USER_CLEAR
);
7102 bgp_process(bgp
, rm
, afi
, safi
);
7104 bgp_unlock_node(rm
);
7109 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7110 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7111 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7112 bgp_process(bgp
, rn
, afi
, safi
);
7114 bgp_unlock_node(rn
);
7121 /* one clear bgp command to rule them all */
7122 DEFUN (clear_ip_bgp_all
,
7123 clear_ip_bgp_all_cmd
,
7124 "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>]",
7128 BGP_INSTANCE_HELP_STR
7130 BGP_SAFI_WITH_LABEL_HELP_STR
7132 "BGP neighbor address to clear\n"
7133 "BGP IPv6 neighbor to clear\n"
7134 "BGP neighbor on interface to clear\n"
7135 "Clear peers with the AS number\n"
7136 "Clear all external peers\n"
7137 "Clear all members of peer-group\n"
7138 "BGP peer-group name\n"
7143 "Push out prefix-list ORF and do inbound soft reconfig\n"
7148 afi_t afi
= AFI_IP6
;
7149 safi_t safi
= SAFI_UNICAST
;
7150 enum clear_sort clr_sort
= clear_peer
;
7151 enum bgp_clear_type clr_type
;
7152 char *clr_arg
= NULL
;
7156 /* clear [ip] bgp */
7157 if (argv_find(argv
, argc
, "ip", &idx
))
7160 /* [<vrf> VIEWVRFNAME] */
7161 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7162 vrf
= argv
[idx
+ 1]->arg
;
7164 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7166 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7167 /* [<view> VIEWVRFNAME] */
7168 vrf
= argv
[idx
+ 1]->arg
;
7171 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7172 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7173 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7175 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */
7176 if (argv_find(argv
, argc
, "*", &idx
)) {
7177 clr_sort
= clear_all
;
7178 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7179 clr_sort
= clear_peer
;
7180 clr_arg
= argv
[idx
]->arg
;
7181 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7182 clr_sort
= clear_peer
;
7183 clr_arg
= argv
[idx
]->arg
;
7184 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7185 clr_sort
= clear_group
;
7187 clr_arg
= argv
[idx
]->arg
;
7188 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7189 clr_sort
= clear_peer
;
7190 clr_arg
= argv
[idx
]->arg
;
7191 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7192 clr_sort
= clear_as
;
7193 clr_arg
= argv
[idx
]->arg
;
7194 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7195 clr_sort
= clear_external
;
7198 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7199 if (argv_find(argv
, argc
, "soft", &idx
)) {
7200 if (argv_find(argv
, argc
, "in", &idx
)
7201 || argv_find(argv
, argc
, "out", &idx
))
7202 clr_type
= strmatch(argv
[idx
]->text
, "in")
7204 : BGP_CLEAR_SOFT_OUT
;
7206 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7207 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7208 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7209 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7210 : BGP_CLEAR_SOFT_IN
;
7211 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7212 clr_type
= BGP_CLEAR_SOFT_OUT
;
7214 clr_type
= BGP_CLEAR_SOFT_NONE
;
7216 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7219 DEFUN (clear_ip_bgp_prefix
,
7220 clear_ip_bgp_prefix_cmd
,
7221 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7225 BGP_INSTANCE_HELP_STR
7226 "Clear bestpath and re-advertise\n"
7230 char *prefix
= NULL
;
7234 /* [<view|vrf> VIEWVRFNAME] */
7235 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7236 vrf
= argv
[idx
+ 1]->arg
;
7238 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7240 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7241 /* [<view> VIEWVRFNAME] */
7242 vrf
= argv
[idx
+ 1]->arg
;
7246 prefix
= argv
[argc
- 1]->arg
;
7248 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7251 DEFUN (clear_bgp_ipv6_safi_prefix
,
7252 clear_bgp_ipv6_safi_prefix_cmd
,
7253 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7259 "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
;
7268 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7269 return bgp_clear_prefix(
7270 vty
, NULL
, prefix
, AFI_IP6
,
7274 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7275 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7276 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7280 BGP_INSTANCE_HELP_STR
7283 "Clear bestpath and re-advertise\n"
7287 int idx_vrfview
= 0;
7288 int idx_ipv6_prefix
= 0;
7289 safi_t safi
= SAFI_UNICAST
;
7290 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7291 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7292 char *vrfview
= NULL
;
7294 /* [<view|vrf> VIEWVRFNAME] */
7295 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
7296 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7297 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
7299 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
7300 /* [<view> VIEWVRFNAME] */
7301 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7303 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7305 return bgp_clear_prefix(
7306 vty
, vrfview
, prefix
,
7307 AFI_IP6
, safi
, NULL
);
7310 DEFUN (show_bgp_views
,
7312 "show [ip] bgp views",
7316 "Show the defined BGP views\n")
7318 struct list
*inst
= bm
->bgp
;
7319 struct listnode
*node
;
7322 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7323 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7327 vty_out(vty
, "Defined BGP views:\n");
7328 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7330 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7332 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7339 DEFUN (show_bgp_vrfs
,
7341 "show [ip] bgp vrfs [json]",
7348 char buf
[ETHER_ADDR_STRLEN
];
7349 struct list
*inst
= bm
->bgp
;
7350 struct listnode
*node
;
7352 bool uj
= use_json(argc
, argv
);
7353 json_object
*json
= NULL
;
7354 json_object
*json_vrfs
= NULL
;
7357 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7358 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7363 json
= json_object_new_object();
7364 json_vrfs
= json_object_new_object();
7367 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7368 const char *name
, *type
;
7370 struct listnode
*node2
, *nnode2
;
7371 int peers_cfg
, peers_estb
;
7372 json_object
*json_vrf
= NULL
;
7375 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7379 if (!uj
&& count
== 1)
7381 "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n",
7382 "Type", "Id", "routerId", "#PeersVfg",
7383 "#PeersEstb", "Name", "L3-VNI", "Rmac");
7385 peers_cfg
= peers_estb
= 0;
7387 json_vrf
= json_object_new_object();
7390 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
7391 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7394 if (peer
->status
== Established
)
7398 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7408 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7410 : (int64_t)bgp
->vrf_id
;
7411 json_object_string_add(json_vrf
, "type", type
);
7412 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7413 json_object_string_add(json_vrf
, "routerId",
7414 inet_ntoa(bgp
->router_id
));
7415 json_object_int_add(json_vrf
, "numConfiguredPeers",
7417 json_object_int_add(json_vrf
, "numEstablishedPeers",
7420 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7421 json_object_string_add(
7423 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7424 json_object_object_add(json_vrfs
, name
, json_vrf
);
7427 "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n",
7429 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7431 inet_ntoa(bgp
->router_id
), peers_cfg
,
7432 peers_estb
, name
, bgp
->l3vni
,
7433 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7437 json_object_object_add(json
, "vrfs", json_vrfs
);
7439 json_object_int_add(json
, "totalVrfs", count
);
7441 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7442 json
, JSON_C_TO_STRING_PRETTY
));
7443 json_object_free(json
);
7447 "\nTotal number of VRFs (including default): %d\n",
7454 static void show_address_entry(struct hash_backet
*backet
, void *args
)
7456 struct vty
*vty
= (struct vty
*)args
;
7457 struct bgp_addr
*addr
= (struct bgp_addr
*)backet
->data
;
7459 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(addr
->addr
),
7463 static void show_tip_entry(struct hash_backet
*backet
, void *args
)
7465 struct vty
*vty
= (struct vty
*)args
;
7466 struct tip_addr
*tip
= (struct tip_addr
*)backet
->data
;
7468 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7472 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7474 vty_out(vty
, "self nexthop database:\n");
7475 hash_iterate(bgp
->address_hash
,
7476 (void (*)(struct hash_backet
*, void *))show_address_entry
,
7479 vty_out(vty
, "Tunnel-ip database:\n");
7480 hash_iterate(bgp
->tip_hash
,
7481 (void (*)(struct hash_backet
*, void *))show_tip_entry
,
7485 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7486 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7487 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7488 "martian next-hops\n"
7489 "martian next-hop database\n")
7491 struct bgp
*bgp
= NULL
;
7495 /* [<vrf> VIEWVRFNAME] */
7496 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7497 name
= argv
[idx
+ 1]->arg
;
7498 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7500 } else if (argv_find(argv
, argc
, "view", &idx
))
7501 /* [<view> VIEWVRFNAME] */
7502 name
= argv
[idx
+ 1]->arg
;
7504 bgp
= bgp_lookup_by_name(name
);
7506 bgp
= bgp_get_default();
7509 vty_out(vty
, "%% No BGP process is configured\n");
7512 bgp_show_martian_nexthops(vty
, bgp
);
7517 DEFUN (show_bgp_memory
,
7518 show_bgp_memory_cmd
,
7519 "show [ip] bgp memory",
7523 "Global BGP memory statistics\n")
7525 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7526 unsigned long count
;
7528 /* RIB related usage stats */
7529 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7530 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7531 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7532 count
* sizeof(struct bgp_node
)));
7534 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7535 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7536 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7537 count
* sizeof(struct bgp_info
)));
7538 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7539 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7541 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7542 count
* sizeof(struct bgp_info_extra
)));
7544 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7545 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7546 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7547 count
* sizeof(struct bgp_static
)));
7549 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7550 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7551 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7552 count
* sizeof(struct bpacket
)));
7555 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7556 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7557 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7558 count
* sizeof(struct bgp_adj_in
)));
7559 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7560 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7561 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7562 count
* sizeof(struct bgp_adj_out
)));
7564 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7565 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7567 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7568 count
* sizeof(struct bgp_nexthop_cache
)));
7570 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7571 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7573 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7574 count
* sizeof(struct bgp_damp_info
)));
7577 count
= attr_count();
7578 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7579 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7580 count
* sizeof(struct attr
)));
7582 if ((count
= attr_unknown_count()))
7583 vty_out(vty
, "%ld unknown attributes\n", count
);
7585 /* AS_PATH attributes */
7586 count
= aspath_count();
7587 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7588 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7589 count
* sizeof(struct aspath
)));
7591 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7592 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7593 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7594 count
* sizeof(struct assegment
)));
7596 /* Other attributes */
7597 if ((count
= community_count()))
7598 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7599 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7600 count
* sizeof(struct community
)));
7601 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7602 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7603 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7604 count
* sizeof(struct ecommunity
)));
7605 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7607 "%ld BGP large-community entries, using %s of memory\n",
7608 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7609 count
* sizeof(struct lcommunity
)));
7611 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7612 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7613 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7614 count
* sizeof(struct cluster_list
)));
7616 /* Peer related usage */
7617 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7618 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7619 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7620 count
* sizeof(struct peer
)));
7622 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7623 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7624 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7625 count
* sizeof(struct peer_group
)));
7628 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
7629 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
7630 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7631 count
* sizeof(struct hash
)));
7632 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
7633 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
7634 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7635 count
* sizeof(struct hash_backet
)));
7636 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7637 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7638 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7639 count
* sizeof(regex_t
)));
7643 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7645 json_object
*bestpath
= json_object_new_object();
7647 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7648 json_object_string_add(bestpath
, "asPath", "ignore");
7650 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7651 json_object_string_add(bestpath
, "asPath", "confed");
7653 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7654 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7655 json_object_string_add(bestpath
, "multiPathRelax",
7658 json_object_string_add(bestpath
, "multiPathRelax",
7661 json_object_string_add(bestpath
, "multiPathRelax", "false");
7663 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7664 json_object_string_add(bestpath
, "compareRouterId", "true");
7665 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7666 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7667 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7668 json_object_string_add(bestpath
, "med", "confed");
7669 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7670 json_object_string_add(bestpath
, "med",
7671 "missing-as-worst");
7673 json_object_string_add(bestpath
, "med", "true");
7676 json_object_object_add(json
, "bestPath", bestpath
);
7679 /* Show BGP peer's summary information. */
7680 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7681 bool use_json
, json_object
*json
)
7684 struct listnode
*node
, *nnode
;
7685 unsigned int count
= 0, dn_count
= 0;
7686 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7687 char neighbor_buf
[VTY_BUFSIZ
];
7688 int neighbor_col_default_width
= 16;
7690 int max_neighbor_width
= 0;
7692 json_object
*json_peer
= NULL
;
7693 json_object
*json_peers
= NULL
;
7695 /* labeled-unicast routes are installed in the unicast table so in order
7697 * display the correct PfxRcd value we must look at SAFI_UNICAST
7699 if (safi
== SAFI_LABELED_UNICAST
)
7700 pfx_rcd_safi
= SAFI_UNICAST
;
7702 pfx_rcd_safi
= safi
;
7706 json
= json_object_new_object();
7708 json_peers
= json_object_new_object();
7710 /* Loop over all neighbors that will be displayed to determine
7712 * characters are needed for the Neighbor column
7714 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7715 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7718 if (peer
->afc
[afi
][safi
]) {
7719 memset(dn_flag
, '\0', sizeof(dn_flag
));
7720 if (peer_dynamic_neighbor(peer
))
7724 && bgp_flag_check(bgp
,
7725 BGP_FLAG_SHOW_HOSTNAME
))
7726 sprintf(neighbor_buf
, "%s%s(%s) ",
7727 dn_flag
, peer
->hostname
,
7730 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7733 len
= strlen(neighbor_buf
);
7735 if (len
> max_neighbor_width
)
7736 max_neighbor_width
= len
;
7740 /* Originally we displayed the Neighbor column as 16
7741 * characters wide so make that the default
7743 if (max_neighbor_width
< neighbor_col_default_width
)
7744 max_neighbor_width
= neighbor_col_default_width
;
7747 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7748 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7751 if (!peer
->afc
[afi
][safi
])
7756 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7759 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7761 : (int64_t)bgp
->vrf_id
;
7763 /* Usage summary and header */
7765 json_object_string_add(
7767 inet_ntoa(bgp
->router_id
));
7768 json_object_int_add(json
, "as", bgp
->as
);
7769 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7770 json_object_string_add(
7773 == BGP_INSTANCE_TYPE_DEFAULT
)
7778 "BGP router identifier %s, local AS number %u vrf-id %d",
7779 inet_ntoa(bgp
->router_id
), bgp
->as
,
7780 bgp
->vrf_id
== VRF_UNKNOWN
7782 : (int)bgp
->vrf_id
);
7786 if (bgp_update_delay_configured(bgp
)) {
7788 json_object_int_add(
7789 json
, "updateDelayLimit",
7790 bgp
->v_update_delay
);
7792 if (bgp
->v_update_delay
7793 != bgp
->v_establish_wait
)
7794 json_object_int_add(
7796 "updateDelayEstablishWait",
7797 bgp
->v_establish_wait
);
7799 if (bgp_update_delay_active(bgp
)) {
7800 json_object_string_add(
7802 "updateDelayFirstNeighbor",
7803 bgp
->update_delay_begin_time
);
7804 json_object_boolean_true_add(
7806 "updateDelayInProgress");
7808 if (bgp
->update_delay_over
) {
7809 json_object_string_add(
7811 "updateDelayFirstNeighbor",
7812 bgp
->update_delay_begin_time
);
7813 json_object_string_add(
7815 "updateDelayBestpathResumed",
7816 bgp
->update_delay_end_time
);
7817 json_object_string_add(
7819 "updateDelayZebraUpdateResume",
7820 bgp
->update_delay_zebra_resume_time
);
7821 json_object_string_add(
7823 "updateDelayPeerUpdateResume",
7824 bgp
->update_delay_peers_resume_time
);
7829 "Read-only mode update-delay limit: %d seconds\n",
7830 bgp
->v_update_delay
);
7831 if (bgp
->v_update_delay
7832 != bgp
->v_establish_wait
)
7834 " Establish wait: %d seconds\n",
7835 bgp
->v_establish_wait
);
7837 if (bgp_update_delay_active(bgp
)) {
7839 " First neighbor established: %s\n",
7840 bgp
->update_delay_begin_time
);
7842 " Delay in progress\n");
7844 if (bgp
->update_delay_over
) {
7846 " First neighbor established: %s\n",
7847 bgp
->update_delay_begin_time
);
7849 " Best-paths resumed: %s\n",
7850 bgp
->update_delay_end_time
);
7852 " zebra update resumed: %s\n",
7853 bgp
->update_delay_zebra_resume_time
);
7855 " peers update resumed: %s\n",
7856 bgp
->update_delay_peers_resume_time
);
7863 if (bgp_maxmed_onstartup_configured(bgp
)
7864 && bgp
->maxmed_active
)
7865 json_object_boolean_true_add(
7866 json
, "maxMedOnStartup");
7867 if (bgp
->v_maxmed_admin
)
7868 json_object_boolean_true_add(
7869 json
, "maxMedAdministrative");
7871 json_object_int_add(
7872 json
, "tableVersion",
7873 bgp_table_version(bgp
->rib
[afi
][safi
]));
7875 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7876 json_object_int_add(json
, "ribCount", ents
);
7877 json_object_int_add(
7879 ents
* sizeof(struct bgp_node
));
7881 ents
= listcount(bgp
->peer
);
7882 json_object_int_add(json
, "peerCount", ents
);
7883 json_object_int_add(json
, "peerMemory",
7884 ents
* sizeof(struct peer
));
7886 if ((ents
= listcount(bgp
->group
))) {
7887 json_object_int_add(
7888 json
, "peerGroupCount", ents
);
7889 json_object_int_add(
7890 json
, "peerGroupMemory",
7891 ents
* sizeof(struct
7895 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7896 BGP_CONFIG_DAMPENING
))
7897 json_object_boolean_true_add(
7898 json
, "dampeningEnabled");
7900 if (bgp_maxmed_onstartup_configured(bgp
)
7901 && bgp
->maxmed_active
)
7903 "Max-med on-startup active\n");
7904 if (bgp
->v_maxmed_admin
)
7906 "Max-med administrative active\n");
7908 vty_out(vty
, "BGP table version %" PRIu64
"\n",
7909 bgp_table_version(bgp
->rib
[afi
][safi
]));
7911 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7913 "RIB entries %ld, using %s of memory\n",
7915 mtype_memstr(memstrbuf
,
7917 ents
* sizeof(struct
7920 /* Peer related usage */
7921 ents
= listcount(bgp
->peer
);
7922 vty_out(vty
, "Peers %ld, using %s of memory\n",
7925 memstrbuf
, sizeof(memstrbuf
),
7926 ents
* sizeof(struct peer
)));
7928 if ((ents
= listcount(bgp
->group
)))
7930 "Peer groups %ld, using %s of memory\n",
7935 ents
* sizeof(struct
7938 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7939 BGP_CONFIG_DAMPENING
))
7940 vty_out(vty
, "Dampening enabled.\n");
7943 /* Subtract 8 here because 'Neighbor' is
7945 vty_out(vty
, "Neighbor");
7946 vty_out(vty
, "%*s", max_neighbor_width
- 8,
7949 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
7956 json_peer
= json_object_new_object();
7958 if (peer_dynamic_neighbor(peer
)) {
7960 json_object_boolean_true_add(json_peer
,
7965 json_object_string_add(json_peer
, "hostname",
7968 if (peer
->domainname
)
7969 json_object_string_add(json_peer
, "domainname",
7972 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
7973 json_object_int_add(json_peer
, "version", 4);
7974 json_object_int_add(json_peer
, "msgRcvd",
7975 PEER_TOTAL_RX(peer
));
7976 json_object_int_add(json_peer
, "msgSent",
7977 PEER_TOTAL_TX(peer
));
7979 json_object_int_add(json_peer
, "tableVersion",
7980 peer
->version
[afi
][safi
]);
7981 json_object_int_add(json_peer
, "outq",
7983 json_object_int_add(json_peer
, "inq", 0);
7984 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
7985 use_json
, json_peer
);
7986 json_object_int_add(json_peer
, "prefixReceivedCount",
7987 peer
->pcount
[afi
][pfx_rcd_safi
]);
7989 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
7990 json_object_string_add(json_peer
, "state",
7992 else if (peer
->afc_recv
[afi
][safi
])
7993 json_object_string_add(
7995 lookup_msg(bgp_status_msg
, peer
->status
,
7997 else if (CHECK_FLAG(peer
->sflags
,
7998 PEER_STATUS_PREFIX_OVERFLOW
))
7999 json_object_string_add(json_peer
, "state",
8002 json_object_string_add(
8004 lookup_msg(bgp_status_msg
, peer
->status
,
8008 json_object_string_add(json_peer
, "idType",
8010 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8011 json_object_string_add(json_peer
, "idType",
8013 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8014 json_object_string_add(json_peer
, "idType",
8017 json_object_object_add(json_peers
, peer
->host
,
8020 memset(dn_flag
, '\0', sizeof(dn_flag
));
8021 if (peer_dynamic_neighbor(peer
)) {
8027 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8028 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8029 peer
->hostname
, peer
->host
);
8031 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8033 /* pad the neighbor column with spaces */
8034 if (len
< max_neighbor_width
)
8035 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8038 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8039 peer
->as
, PEER_TOTAL_RX(peer
),
8040 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8041 0, peer
->obuf
->count
,
8042 peer_uptime(peer
->uptime
, timebuf
,
8043 BGP_UPTIME_LEN
, 0, NULL
));
8045 if (peer
->status
== Established
)
8046 if (peer
->afc_recv
[afi
][safi
])
8047 vty_out(vty
, " %12ld",
8051 vty_out(vty
, " NoNeg");
8053 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8054 vty_out(vty
, " Idle (Admin)");
8055 else if (CHECK_FLAG(
8057 PEER_STATUS_PREFIX_OVERFLOW
))
8058 vty_out(vty
, " Idle (PfxCt)");
8060 vty_out(vty
, " %12s",
8061 lookup_msg(bgp_status_msg
,
8062 peer
->status
, NULL
));
8069 json_object_object_add(json
, "peers", json_peers
);
8071 json_object_int_add(json
, "totalPeers", count
);
8072 json_object_int_add(json
, "dynamicPeers", dn_count
);
8074 bgp_show_bestpath_json(bgp
, json
);
8076 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8077 json
, JSON_C_TO_STRING_PRETTY
));
8078 json_object_free(json
);
8081 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8083 vty_out(vty
, "No %s neighbor is configured\n",
8084 afi_safi_print(afi
, safi
));
8088 vty_out(vty
, "* - dynamic neighbor\n");
8089 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8090 dn_count
, bgp
->dynamic_neighbors_limit
);
8097 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8098 int safi
, bool use_json
,
8102 int afi_wildcard
= (afi
== AFI_MAX
);
8103 int safi_wildcard
= (safi
== SAFI_MAX
);
8104 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8105 bool nbr_output
= false;
8107 if (use_json
&& is_wildcard
)
8108 vty_out(vty
, "{\n");
8110 afi
= 1; /* AFI_IP */
8111 while (afi
< AFI_MAX
) {
8113 safi
= 1; /* SAFI_UNICAST */
8114 while (safi
< SAFI_MAX
) {
8115 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8119 * So limit output to those afi/safi
8121 * actualy have something interesting in
8125 json
= json_object_new_object();
8128 vty_out(vty
, ",\n");
8132 vty_out(vty
, "\"%s\":",
8136 vty_out(vty
, "\n%s Summary:\n",
8141 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
8153 if (use_json
&& is_wildcard
)
8154 vty_out(vty
, "}\n");
8155 else if (!nbr_output
) {
8157 vty_out(vty
, "{}\n");
8159 vty_out(vty
, "%% No BGP neighbors found\n");
8163 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8164 safi_t safi
, bool use_json
)
8166 struct listnode
*node
, *nnode
;
8168 json_object
*json
= NULL
;
8170 bool nbr_output
= false;
8173 vty_out(vty
, "{\n");
8175 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8178 json
= json_object_new_object();
8181 vty_out(vty
, ",\n");
8185 vty_out(vty
, "\"%s\":",
8186 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8190 vty_out(vty
, "\nInstance %s:\n",
8191 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8195 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
8199 vty_out(vty
, "}\n");
8200 else if (!nbr_output
)
8201 vty_out(vty
, "%% BGP instance not found\n");
8204 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8205 safi_t safi
, bool use_json
)
8210 if (strmatch(name
, "all")) {
8211 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8215 bgp
= bgp_lookup_by_name(name
);
8219 vty_out(vty
, "{}\n");
8222 "%% BGP instance not found\n");
8226 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
8232 bgp
= bgp_get_default();
8235 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
8238 vty_out(vty
, "{}\n");
8240 vty_out(vty
, "%% BGP instance not found\n");
8247 /* `show [ip] bgp summary' commands. */
8248 DEFUN (show_ip_bgp_summary
,
8249 show_ip_bgp_summary_cmd
,
8250 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8254 BGP_INSTANCE_HELP_STR
8256 BGP_SAFI_WITH_LABEL_HELP_STR
8257 "Summary of BGP neighbor status\n"
8261 afi_t afi
= AFI_MAX
;
8262 safi_t safi
= SAFI_MAX
;
8267 if (argv_find(argv
, argc
, "ip", &idx
))
8269 /* [<vrf> VIEWVRFNAME] */
8270 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8271 vrf
= argv
[idx
+ 1]->arg
;
8272 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8274 } else if (argv_find(argv
, argc
, "view", &idx
))
8275 /* [<view> VIEWVRFNAME] */
8276 vrf
= argv
[idx
+ 1]->arg
;
8277 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8278 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8279 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8282 bool uj
= use_json(argc
, argv
);
8284 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8287 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8289 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8290 return "IPv4 Unicast";
8291 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8292 return "IPv4 Multicast";
8293 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8294 return "IPv4 Labeled Unicast";
8295 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8297 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8298 return "IPv4 Encap";
8299 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8300 return "IPv4 Flowspec";
8301 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8302 return "IPv6 Unicast";
8303 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8304 return "IPv6 Multicast";
8305 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8306 return "IPv6 Labeled Unicast";
8307 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8309 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8310 return "IPv6 Encap";
8311 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8312 return "IPv6 Flowspec";
8313 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8314 return "L2VPN EVPN";
8320 * Please note that we have intentionally camelCased
8321 * the return strings here. So if you want
8322 * to use this function, please ensure you
8323 * are doing this within json output
8325 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8327 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8328 return "ipv4Unicast";
8329 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8330 return "ipv4Multicast";
8331 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8332 return "ipv4LabeledUnicast";
8333 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8335 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8337 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8338 return "ipv4Flowspec";
8339 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8340 return "ipv6Unicast";
8341 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8342 return "ipv6Multicast";
8343 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8344 return "ipv6LabeledUnicast";
8345 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8347 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8349 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8350 return "ipv6Flowspec";
8351 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8357 /* Show BGP peer's information. */
8358 enum show_type
{ show_all
, show_peer
};
8360 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8361 afi_t afi
, safi_t safi
,
8362 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8363 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8364 bool use_json
, json_object
*json_pref
)
8367 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8368 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8370 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8371 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8372 json_object_string_add(json_pref
, "sendMode",
8373 "advertisedAndReceived");
8374 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8375 json_object_string_add(json_pref
, "sendMode",
8377 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8378 json_object_string_add(json_pref
, "sendMode",
8381 vty_out(vty
, " Send-mode: ");
8382 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8383 vty_out(vty
, "advertised");
8384 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8385 vty_out(vty
, "%sreceived",
8386 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8395 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8396 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8398 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8399 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8400 json_object_string_add(json_pref
, "recvMode",
8401 "advertisedAndReceived");
8402 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8403 json_object_string_add(json_pref
, "recvMode",
8405 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8406 json_object_string_add(json_pref
, "recvMode",
8409 vty_out(vty
, " Receive-mode: ");
8410 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8411 vty_out(vty
, "advertised");
8412 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8413 vty_out(vty
, "%sreceived",
8414 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8423 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8424 safi_t safi
, bool use_json
,
8425 json_object
*json_neigh
)
8427 struct bgp_filter
*filter
;
8428 struct peer_af
*paf
;
8429 char orf_pfx_name
[BUFSIZ
];
8431 json_object
*json_af
= NULL
;
8432 json_object
*json_prefA
= NULL
;
8433 json_object
*json_prefB
= NULL
;
8434 json_object
*json_addr
= NULL
;
8437 json_addr
= json_object_new_object();
8438 json_af
= json_object_new_object();
8439 filter
= &p
->filter
[afi
][safi
];
8441 if (peer_group_active(p
))
8442 json_object_string_add(json_addr
, "peerGroupMember",
8445 paf
= peer_af_find(p
, afi
, safi
);
8446 if (paf
&& PAF_SUBGRP(paf
)) {
8447 json_object_int_add(json_addr
, "updateGroupId",
8448 PAF_UPDGRP(paf
)->id
);
8449 json_object_int_add(json_addr
, "subGroupId",
8450 PAF_SUBGRP(paf
)->id
);
8451 json_object_int_add(json_addr
, "packetQueueLength",
8452 bpacket_queue_virtual_length(paf
));
8455 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8456 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8457 PEER_CAP_ORF_PREFIX_SM_RCV
)
8458 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8459 PEER_CAP_ORF_PREFIX_RM_ADV
)
8460 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8461 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8462 json_object_int_add(json_af
, "orfType",
8464 json_prefA
= json_object_new_object();
8465 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8466 PEER_CAP_ORF_PREFIX_SM_ADV
,
8467 PEER_CAP_ORF_PREFIX_RM_ADV
,
8468 PEER_CAP_ORF_PREFIX_SM_RCV
,
8469 PEER_CAP_ORF_PREFIX_RM_RCV
,
8470 use_json
, json_prefA
);
8471 json_object_object_add(json_af
, "orfPrefixList",
8475 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8476 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8477 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8478 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8479 PEER_CAP_ORF_PREFIX_RM_ADV
)
8480 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8481 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8482 json_object_int_add(json_af
, "orfOldType",
8483 ORF_TYPE_PREFIX_OLD
);
8484 json_prefB
= json_object_new_object();
8485 bgp_show_peer_afi_orf_cap(
8486 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8487 PEER_CAP_ORF_PREFIX_RM_ADV
,
8488 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8489 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8491 json_object_object_add(json_af
, "orfOldPrefixList",
8495 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8496 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8497 PEER_CAP_ORF_PREFIX_SM_RCV
)
8498 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8499 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8500 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8501 PEER_CAP_ORF_PREFIX_RM_ADV
)
8502 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8503 PEER_CAP_ORF_PREFIX_RM_RCV
)
8504 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8505 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8506 json_object_object_add(json_addr
, "afDependentCap",
8509 json_object_free(json_af
);
8511 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8512 orf_pfx_count
= prefix_bgp_show_prefix_list(
8513 NULL
, afi
, orf_pfx_name
, use_json
);
8515 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8516 PEER_STATUS_ORF_PREFIX_SEND
)
8518 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8519 PEER_STATUS_ORF_PREFIX_SEND
))
8520 json_object_boolean_true_add(json_neigh
,
8523 json_object_int_add(json_addr
, "orfRecvCounter",
8526 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8527 PEER_STATUS_ORF_WAIT_REFRESH
))
8528 json_object_string_add(
8529 json_addr
, "orfFirstUpdate",
8530 "deferredUntilORFOrRouteRefreshRecvd");
8532 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8533 PEER_FLAG_REFLECTOR_CLIENT
))
8534 json_object_boolean_true_add(json_addr
,
8535 "routeReflectorClient");
8536 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8537 PEER_FLAG_RSERVER_CLIENT
))
8538 json_object_boolean_true_add(json_addr
,
8539 "routeServerClient");
8540 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8541 json_object_boolean_true_add(json_addr
,
8542 "inboundSoftConfigPermit");
8544 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8545 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8546 json_object_boolean_true_add(
8548 "privateAsNumsAllReplacedInUpdatesToNbr");
8549 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8550 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8551 json_object_boolean_true_add(
8553 "privateAsNumsReplacedInUpdatesToNbr");
8554 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8555 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8556 json_object_boolean_true_add(
8558 "privateAsNumsAllRemovedInUpdatesToNbr");
8559 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8560 PEER_FLAG_REMOVE_PRIVATE_AS
))
8561 json_object_boolean_true_add(
8563 "privateAsNumsRemovedInUpdatesToNbr");
8565 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8566 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
8567 json_object_boolean_true_add(json_addr
,
8568 "addpathTxAllPaths");
8570 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8571 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
8572 json_object_boolean_true_add(json_addr
,
8573 "addpathTxBestpathPerAS");
8575 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8576 json_object_string_add(json_addr
,
8577 "overrideASNsInOutboundUpdates",
8578 "ifAspathEqualRemoteAs");
8580 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8581 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8582 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8583 json_object_boolean_true_add(json_addr
,
8584 "routerAlwaysNextHop");
8585 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8586 PEER_FLAG_AS_PATH_UNCHANGED
))
8587 json_object_boolean_true_add(
8588 json_addr
, "unchangedAsPathPropogatedToNbr");
8589 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8590 PEER_FLAG_NEXTHOP_UNCHANGED
))
8591 json_object_boolean_true_add(
8592 json_addr
, "unchangedNextHopPropogatedToNbr");
8593 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8594 json_object_boolean_true_add(
8595 json_addr
, "unchangedMedPropogatedToNbr");
8596 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8597 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8598 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8599 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8600 PEER_FLAG_SEND_COMMUNITY
)
8601 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8602 PEER_FLAG_SEND_EXT_COMMUNITY
))
8603 json_object_string_add(json_addr
,
8604 "commAttriSentToNbr",
8605 "extendedAndStandard");
8606 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8607 PEER_FLAG_SEND_EXT_COMMUNITY
))
8608 json_object_string_add(json_addr
,
8609 "commAttriSentToNbr",
8612 json_object_string_add(json_addr
,
8613 "commAttriSentToNbr",
8616 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8617 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8618 if (p
->default_rmap
[afi
][safi
].name
)
8619 json_object_string_add(
8620 json_addr
, "defaultRouteMap",
8621 p
->default_rmap
[afi
][safi
].name
);
8623 if (paf
&& PAF_SUBGRP(paf
)
8624 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8625 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8626 json_object_boolean_true_add(json_addr
,
8629 json_object_boolean_true_add(json_addr
,
8633 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8634 if (is_evpn_enabled())
8635 json_object_boolean_true_add(
8636 json_addr
, "advertiseAllVnis");
8639 if (filter
->plist
[FILTER_IN
].name
8640 || filter
->dlist
[FILTER_IN
].name
8641 || filter
->aslist
[FILTER_IN
].name
8642 || filter
->map
[RMAP_IN
].name
)
8643 json_object_boolean_true_add(json_addr
,
8644 "inboundPathPolicyConfig");
8645 if (filter
->plist
[FILTER_OUT
].name
8646 || filter
->dlist
[FILTER_OUT
].name
8647 || filter
->aslist
[FILTER_OUT
].name
8648 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8649 json_object_boolean_true_add(
8650 json_addr
, "outboundPathPolicyConfig");
8653 if (filter
->plist
[FILTER_IN
].name
)
8654 json_object_string_add(json_addr
,
8655 "incomingUpdatePrefixFilterList",
8656 filter
->plist
[FILTER_IN
].name
);
8657 if (filter
->plist
[FILTER_OUT
].name
)
8658 json_object_string_add(json_addr
,
8659 "outgoingUpdatePrefixFilterList",
8660 filter
->plist
[FILTER_OUT
].name
);
8662 /* distribute-list */
8663 if (filter
->dlist
[FILTER_IN
].name
)
8664 json_object_string_add(
8665 json_addr
, "incomingUpdateNetworkFilterList",
8666 filter
->dlist
[FILTER_IN
].name
);
8667 if (filter
->dlist
[FILTER_OUT
].name
)
8668 json_object_string_add(
8669 json_addr
, "outgoingUpdateNetworkFilterList",
8670 filter
->dlist
[FILTER_OUT
].name
);
8673 if (filter
->aslist
[FILTER_IN
].name
)
8674 json_object_string_add(json_addr
,
8675 "incomingUpdateAsPathFilterList",
8676 filter
->aslist
[FILTER_IN
].name
);
8677 if (filter
->aslist
[FILTER_OUT
].name
)
8678 json_object_string_add(json_addr
,
8679 "outgoingUpdateAsPathFilterList",
8680 filter
->aslist
[FILTER_OUT
].name
);
8683 if (filter
->map
[RMAP_IN
].name
)
8684 json_object_string_add(
8685 json_addr
, "routeMapForIncomingAdvertisements",
8686 filter
->map
[RMAP_IN
].name
);
8687 if (filter
->map
[RMAP_OUT
].name
)
8688 json_object_string_add(
8689 json_addr
, "routeMapForOutgoingAdvertisements",
8690 filter
->map
[RMAP_OUT
].name
);
8692 /* unsuppress-map */
8693 if (filter
->usmap
.name
)
8694 json_object_string_add(json_addr
,
8695 "selectiveUnsuppressRouteMap",
8696 filter
->usmap
.name
);
8698 /* Receive prefix count */
8699 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8700 p
->pcount
[afi
][safi
]);
8702 /* Maximum prefix */
8703 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8704 json_object_int_add(json_addr
, "prefixAllowedMax",
8705 p
->pmax
[afi
][safi
]);
8706 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8707 PEER_FLAG_MAX_PREFIX_WARNING
))
8708 json_object_boolean_true_add(
8709 json_addr
, "prefixAllowedMaxWarning");
8710 json_object_int_add(json_addr
,
8711 "prefixAllowedWarningThresh",
8712 p
->pmax_threshold
[afi
][safi
]);
8713 if (p
->pmax_restart
[afi
][safi
])
8714 json_object_int_add(
8716 "prefixAllowedRestartIntervalMsecs",
8717 p
->pmax_restart
[afi
][safi
] * 60000);
8719 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8723 filter
= &p
->filter
[afi
][safi
];
8725 vty_out(vty
, " For address family: %s\n",
8726 afi_safi_print(afi
, safi
));
8728 if (peer_group_active(p
))
8729 vty_out(vty
, " %s peer-group member\n",
8732 paf
= peer_af_find(p
, afi
, safi
);
8733 if (paf
&& PAF_SUBGRP(paf
)) {
8734 vty_out(vty
, " Update group %" PRIu64
8735 ", subgroup %" PRIu64
"\n",
8736 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8737 vty_out(vty
, " Packet Queue length %d\n",
8738 bpacket_queue_virtual_length(paf
));
8740 vty_out(vty
, " Not part of any update group\n");
8742 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8743 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8744 PEER_CAP_ORF_PREFIX_SM_RCV
)
8745 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8746 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8747 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8748 PEER_CAP_ORF_PREFIX_RM_ADV
)
8749 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8750 PEER_CAP_ORF_PREFIX_RM_RCV
)
8751 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8752 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8753 vty_out(vty
, " AF-dependant capabilities:\n");
8755 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8756 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8757 PEER_CAP_ORF_PREFIX_SM_RCV
)
8758 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8759 PEER_CAP_ORF_PREFIX_RM_ADV
)
8760 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8761 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8763 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8765 bgp_show_peer_afi_orf_cap(
8766 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8767 PEER_CAP_ORF_PREFIX_RM_ADV
,
8768 PEER_CAP_ORF_PREFIX_SM_RCV
,
8769 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8771 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8772 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8773 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8774 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8775 PEER_CAP_ORF_PREFIX_RM_ADV
)
8776 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8777 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8779 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8780 ORF_TYPE_PREFIX_OLD
);
8781 bgp_show_peer_afi_orf_cap(
8782 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8783 PEER_CAP_ORF_PREFIX_RM_ADV
,
8784 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8785 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8788 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8789 orf_pfx_count
= prefix_bgp_show_prefix_list(
8790 NULL
, afi
, orf_pfx_name
, use_json
);
8792 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8793 PEER_STATUS_ORF_PREFIX_SEND
)
8795 vty_out(vty
, " Outbound Route Filter (ORF):");
8796 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8797 PEER_STATUS_ORF_PREFIX_SEND
))
8798 vty_out(vty
, " sent;");
8800 vty_out(vty
, " received (%d entries)",
8804 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8805 PEER_STATUS_ORF_WAIT_REFRESH
))
8807 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
8809 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8810 PEER_FLAG_REFLECTOR_CLIENT
))
8811 vty_out(vty
, " Route-Reflector Client\n");
8812 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8813 PEER_FLAG_RSERVER_CLIENT
))
8814 vty_out(vty
, " Route-Server Client\n");
8815 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8817 " Inbound soft reconfiguration allowed\n");
8819 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8820 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8822 " Private AS numbers (all) replaced in updates to this neighbor\n");
8823 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8824 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8826 " Private AS numbers replaced in updates to this neighbor\n");
8827 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8828 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8830 " Private AS numbers (all) removed in updates to this neighbor\n");
8831 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8832 PEER_FLAG_REMOVE_PRIVATE_AS
))
8834 " Private AS numbers removed in updates to this neighbor\n");
8836 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8837 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
8838 vty_out(vty
, " Advertise all paths via addpath\n");
8840 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8841 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
8843 " Advertise bestpath per AS via addpath\n");
8845 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8847 " Override ASNs in outbound updates if aspath equals remote-as\n");
8849 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8850 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8851 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8852 vty_out(vty
, " NEXT_HOP is always this router\n");
8853 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8854 PEER_FLAG_AS_PATH_UNCHANGED
))
8856 " AS_PATH is propagated unchanged to this neighbor\n");
8857 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8858 PEER_FLAG_NEXTHOP_UNCHANGED
))
8860 " NEXT_HOP is propagated unchanged to this neighbor\n");
8861 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8863 " MED is propagated unchanged to this neighbor\n");
8864 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8865 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8866 PEER_FLAG_SEND_EXT_COMMUNITY
)
8867 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8868 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
8870 " Community attribute sent to this neighbor");
8871 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8872 PEER_FLAG_SEND_COMMUNITY
)
8873 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8874 PEER_FLAG_SEND_EXT_COMMUNITY
)
8875 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8876 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8877 vty_out(vty
, "(all)\n");
8878 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8879 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8880 vty_out(vty
, "(large)\n");
8881 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8882 PEER_FLAG_SEND_EXT_COMMUNITY
))
8883 vty_out(vty
, "(extended)\n");
8885 vty_out(vty
, "(standard)\n");
8887 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8888 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8889 vty_out(vty
, " Default information originate,");
8891 if (p
->default_rmap
[afi
][safi
].name
)
8892 vty_out(vty
, " default route-map %s%s,",
8893 p
->default_rmap
[afi
][safi
].map
? "*"
8895 p
->default_rmap
[afi
][safi
].name
);
8896 if (paf
&& PAF_SUBGRP(paf
)
8897 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8898 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8899 vty_out(vty
, " default sent\n");
8901 vty_out(vty
, " default not sent\n");
8904 /* advertise-vni-all */
8905 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8906 if (is_evpn_enabled())
8907 vty_out(vty
, " advertise-all-vni\n");
8910 if (filter
->plist
[FILTER_IN
].name
8911 || filter
->dlist
[FILTER_IN
].name
8912 || filter
->aslist
[FILTER_IN
].name
8913 || filter
->map
[RMAP_IN
].name
)
8914 vty_out(vty
, " Inbound path policy configured\n");
8915 if (filter
->plist
[FILTER_OUT
].name
8916 || filter
->dlist
[FILTER_OUT
].name
8917 || filter
->aslist
[FILTER_OUT
].name
8918 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8919 vty_out(vty
, " Outbound path policy configured\n");
8922 if (filter
->plist
[FILTER_IN
].name
)
8924 " Incoming update prefix filter list is %s%s\n",
8925 filter
->plist
[FILTER_IN
].plist
? "*" : "",
8926 filter
->plist
[FILTER_IN
].name
);
8927 if (filter
->plist
[FILTER_OUT
].name
)
8929 " Outgoing update prefix filter list is %s%s\n",
8930 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
8931 filter
->plist
[FILTER_OUT
].name
);
8933 /* distribute-list */
8934 if (filter
->dlist
[FILTER_IN
].name
)
8936 " Incoming update network filter list is %s%s\n",
8937 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
8938 filter
->dlist
[FILTER_IN
].name
);
8939 if (filter
->dlist
[FILTER_OUT
].name
)
8941 " Outgoing update network filter list is %s%s\n",
8942 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
8943 filter
->dlist
[FILTER_OUT
].name
);
8946 if (filter
->aslist
[FILTER_IN
].name
)
8948 " Incoming update AS path filter list is %s%s\n",
8949 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
8950 filter
->aslist
[FILTER_IN
].name
);
8951 if (filter
->aslist
[FILTER_OUT
].name
)
8953 " Outgoing update AS path filter list is %s%s\n",
8954 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
8955 filter
->aslist
[FILTER_OUT
].name
);
8958 if (filter
->map
[RMAP_IN
].name
)
8960 " Route map for incoming advertisements is %s%s\n",
8961 filter
->map
[RMAP_IN
].map
? "*" : "",
8962 filter
->map
[RMAP_IN
].name
);
8963 if (filter
->map
[RMAP_OUT
].name
)
8965 " Route map for outgoing advertisements is %s%s\n",
8966 filter
->map
[RMAP_OUT
].map
? "*" : "",
8967 filter
->map
[RMAP_OUT
].name
);
8969 /* unsuppress-map */
8970 if (filter
->usmap
.name
)
8972 " Route map for selective unsuppress is %s%s\n",
8973 filter
->usmap
.map
? "*" : "",
8974 filter
->usmap
.name
);
8976 /* Receive prefix count */
8977 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
8979 /* Maximum prefix */
8980 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8981 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
8983 CHECK_FLAG(p
->af_flags
[afi
][safi
],
8984 PEER_FLAG_MAX_PREFIX_WARNING
)
8987 vty_out(vty
, " Threshold for warning message %d%%",
8988 p
->pmax_threshold
[afi
][safi
]);
8989 if (p
->pmax_restart
[afi
][safi
])
8990 vty_out(vty
, ", restart interval %d min",
8991 p
->pmax_restart
[afi
][safi
]);
8999 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
9003 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
9004 char timebuf
[BGP_UPTIME_LEN
];
9006 const char *subcode_str
;
9007 const char *code_str
;
9012 json_object
*json_neigh
= NULL
;
9018 json_neigh
= json_object_new_object();
9020 memset(dn_flag
, '\0', sizeof(dn_flag
));
9021 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9025 if (p
->conf_if
) /* Configured interface name. */
9026 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9027 BGP_PEER_SU_UNSPEC(p
)
9029 : sockunion2str(&p
->su
, buf
,
9031 else /* Configured IP address. */
9032 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9037 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9038 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9040 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9041 json_object_string_add(
9042 json_neigh
, "bgpNeighborAddr",
9043 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9045 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9047 if (p
->change_local_as
)
9048 json_object_int_add(json_neigh
, "localAs",
9049 p
->change_local_as
);
9051 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9053 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9054 json_object_boolean_true_add(json_neigh
,
9055 "localAsNoPrepend");
9057 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9058 json_object_boolean_true_add(json_neigh
,
9059 "localAsReplaceAs");
9061 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9062 || (p
->as_type
== AS_INTERNAL
))
9063 vty_out(vty
, "remote AS %u, ", p
->as
);
9065 vty_out(vty
, "remote AS Unspecified, ");
9066 vty_out(vty
, "local AS %u%s%s, ",
9067 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9068 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9071 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9075 /* peer type internal, external, confed-internal or confed-external */
9076 if (p
->as
== p
->local_as
) {
9078 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9079 json_object_boolean_true_add(
9080 json_neigh
, "nbrConfedInternalLink");
9082 json_object_boolean_true_add(json_neigh
,
9085 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9086 vty_out(vty
, "confed-internal link\n");
9088 vty_out(vty
, "internal link\n");
9092 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9093 json_object_boolean_true_add(
9094 json_neigh
, "nbrConfedExternalLink");
9096 json_object_boolean_true_add(json_neigh
,
9099 if (bgp_confederation_peers_check(bgp
, p
->as
))
9100 vty_out(vty
, "confed-external link\n");
9102 vty_out(vty
, "external link\n");
9109 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9111 vty_out(vty
, " Description: %s\n", p
->desc
);
9117 json_object_string_add(json_neigh
, "hostname",
9121 json_object_string_add(json_neigh
, "domainname",
9124 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9125 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9128 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9135 json_object_string_add(json_neigh
, "peerGroup",
9139 struct prefix prefix
, *range
= NULL
;
9141 sockunion2hostprefix(&(p
->su
), &prefix
);
9142 range
= peer_group_lookup_dynamic_neighbor_range(
9146 prefix2str(range
, buf1
, sizeof(buf1
));
9147 json_object_string_add(
9149 "peerSubnetRangeGroup", buf1
);
9154 " Member of peer-group %s for session parameters\n",
9158 struct prefix prefix
, *range
= NULL
;
9160 sockunion2hostprefix(&(p
->su
), &prefix
);
9161 range
= peer_group_lookup_dynamic_neighbor_range(
9165 prefix2str(range
, buf1
, sizeof(buf1
));
9167 " Belongs to the subnet range group: %s\n",
9175 /* Administrative shutdown. */
9176 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9177 json_object_boolean_true_add(json_neigh
,
9181 json_object_int_add(json_neigh
, "bgpVersion", 4);
9182 json_object_string_add(
9183 json_neigh
, "remoteRouterId",
9184 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9185 json_object_string_add(
9186 json_neigh
, "localRouterId",
9187 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9191 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9192 && bgp_confederation_peers_check(bgp
, p
->as
))
9193 json_object_boolean_true_add(json_neigh
,
9197 json_object_string_add(
9198 json_neigh
, "bgpState",
9199 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9201 if (p
->status
== Established
) {
9204 uptime
= bgp_clock();
9205 uptime
-= p
->uptime
;
9206 epoch_tbuf
= time(NULL
) - uptime
;
9208 #if CONFDATE > 20200101
9210 "bgpTimerUp should be deprecated and can be removed now");
9213 * bgpTimerUp was miliseconds that was accurate
9214 * up to 1 day, then the value returned
9215 * became garbage. So in order to provide
9216 * some level of backwards compatability,
9217 * we still provde the data, but now
9218 * we are returning the correct value
9219 * and also adding a new bgpTimerUpMsec
9220 * which will allow us to deprecate
9223 json_object_int_add(json_neigh
, "bgpTimerUp",
9225 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9227 json_object_string_add(json_neigh
, "bgpTimerUpString",
9228 peer_uptime(p
->uptime
, timebuf
,
9231 json_object_int_add(json_neigh
,
9232 "bgpTimerUpEstablishedEpoch",
9236 else if (p
->status
== Active
) {
9237 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9238 json_object_string_add(json_neigh
, "bgpStateIs",
9240 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9241 json_object_string_add(json_neigh
, "bgpStateIs",
9249 uptime
= bgp_clock();
9250 uptime
-= p
->readtime
;
9251 tm
= gmtime(&uptime
);
9252 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9253 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9254 + (tm
->tm_hour
* 3600000));
9256 uptime
= bgp_clock();
9257 uptime
-= p
->last_write
;
9258 tm
= gmtime(&uptime
);
9259 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9260 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9261 + (tm
->tm_hour
* 3600000));
9263 uptime
= bgp_clock();
9264 uptime
-= p
->update_time
;
9265 tm
= gmtime(&uptime
);
9266 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9267 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9268 + (tm
->tm_hour
* 3600000));
9270 /* Configured timer values. */
9271 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9272 p
->v_holdtime
* 1000);
9273 json_object_int_add(json_neigh
,
9274 "bgpTimerKeepAliveIntervalMsecs",
9275 p
->v_keepalive
* 1000);
9276 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9277 json_object_int_add(json_neigh
,
9278 "bgpTimerConfiguredHoldTimeMsecs",
9279 p
->holdtime
* 1000);
9280 json_object_int_add(
9282 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9283 p
->keepalive
* 1000);
9284 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9285 || (bgp
->default_keepalive
9286 != BGP_DEFAULT_KEEPALIVE
)) {
9287 json_object_int_add(json_neigh
,
9288 "bgpTimerConfiguredHoldTimeMsecs",
9289 bgp
->default_holdtime
);
9290 json_object_int_add(
9292 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9293 bgp
->default_keepalive
);
9296 /* Administrative shutdown. */
9297 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9298 vty_out(vty
, " Administratively shut down\n");
9301 vty_out(vty
, " BGP version 4");
9302 vty_out(vty
, ", remote router ID %s",
9303 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9304 vty_out(vty
, ", local router ID %s\n",
9305 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9309 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9310 && bgp_confederation_peers_check(bgp
, p
->as
))
9312 " Neighbor under common administration\n");
9315 vty_out(vty
, " BGP state = %s",
9316 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9318 if (p
->status
== Established
)
9319 vty_out(vty
, ", up for %8s",
9320 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9323 else if (p
->status
== Active
) {
9324 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9325 vty_out(vty
, " (passive)");
9326 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9327 vty_out(vty
, " (NSF passive)");
9332 vty_out(vty
, " Last read %s",
9333 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9335 vty_out(vty
, ", Last write %s\n",
9336 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9339 /* Configured timer values. */
9341 " Hold time is %d, keepalive interval is %d seconds\n",
9342 p
->v_holdtime
, p
->v_keepalive
);
9343 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9344 vty_out(vty
, " Configured hold time is %d",
9346 vty_out(vty
, ", keepalive interval is %d seconds\n",
9348 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9349 || (bgp
->default_keepalive
9350 != BGP_DEFAULT_KEEPALIVE
)) {
9351 vty_out(vty
, " Configured hold time is %d",
9352 bgp
->default_holdtime
);
9353 vty_out(vty
, ", keepalive interval is %d seconds\n",
9354 bgp
->default_keepalive
);
9358 if (p
->status
== Established
) {
9359 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9360 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9361 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9362 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9363 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9364 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9365 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9366 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9367 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9368 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9369 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9370 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9371 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9372 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9373 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9374 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9375 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9376 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9377 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9378 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9380 json_object
*json_cap
= NULL
;
9382 json_cap
= json_object_new_object();
9385 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9386 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9387 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9388 && CHECK_FLAG(p
->cap
,
9390 json_object_string_add(
9391 json_cap
, "4byteAs",
9392 "advertisedAndReceived");
9393 else if (CHECK_FLAG(p
->cap
,
9395 json_object_string_add(
9396 json_cap
, "4byteAs",
9398 else if (CHECK_FLAG(p
->cap
,
9400 json_object_string_add(
9401 json_cap
, "4byteAs",
9406 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9407 || CHECK_FLAG(p
->cap
,
9408 PEER_CAP_ADDPATH_ADV
)) {
9409 json_object
*json_add
= NULL
;
9410 const char *print_store
;
9412 json_add
= json_object_new_object();
9414 FOREACH_AFI_SAFI (afi
, safi
) {
9415 json_object
*json_sub
= NULL
;
9417 json_object_new_object();
9418 print_store
= afi_safi_print(
9424 PEER_CAP_ADDPATH_AF_TX_ADV
)
9428 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9433 PEER_CAP_ADDPATH_AF_TX_ADV
)
9438 PEER_CAP_ADDPATH_AF_TX_RCV
))
9439 json_object_boolean_true_add(
9441 "txAdvertisedAndReceived");
9447 PEER_CAP_ADDPATH_AF_TX_ADV
))
9448 json_object_boolean_true_add(
9456 PEER_CAP_ADDPATH_AF_TX_RCV
))
9457 json_object_boolean_true_add(
9465 PEER_CAP_ADDPATH_AF_RX_ADV
)
9469 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9474 PEER_CAP_ADDPATH_AF_RX_ADV
)
9479 PEER_CAP_ADDPATH_AF_RX_RCV
))
9480 json_object_boolean_true_add(
9482 "rxAdvertisedAndReceived");
9488 PEER_CAP_ADDPATH_AF_RX_ADV
))
9489 json_object_boolean_true_add(
9497 PEER_CAP_ADDPATH_AF_RX_RCV
))
9498 json_object_boolean_true_add(
9506 PEER_CAP_ADDPATH_AF_TX_ADV
)
9510 PEER_CAP_ADDPATH_AF_TX_RCV
)
9514 PEER_CAP_ADDPATH_AF_RX_ADV
)
9518 PEER_CAP_ADDPATH_AF_RX_RCV
))
9519 json_object_object_add(
9528 json_object_object_add(
9529 json_cap
, "addPath", json_add
);
9533 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9534 || CHECK_FLAG(p
->cap
,
9535 PEER_CAP_DYNAMIC_ADV
)) {
9536 if (CHECK_FLAG(p
->cap
,
9537 PEER_CAP_DYNAMIC_ADV
)
9538 && CHECK_FLAG(p
->cap
,
9539 PEER_CAP_DYNAMIC_RCV
))
9540 json_object_string_add(
9541 json_cap
, "dynamic",
9542 "advertisedAndReceived");
9543 else if (CHECK_FLAG(
9545 PEER_CAP_DYNAMIC_ADV
))
9546 json_object_string_add(
9547 json_cap
, "dynamic",
9549 else if (CHECK_FLAG(
9551 PEER_CAP_DYNAMIC_RCV
))
9552 json_object_string_add(
9553 json_cap
, "dynamic",
9557 /* Extended nexthop */
9558 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9559 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9560 json_object
*json_nxt
= NULL
;
9561 const char *print_store
;
9564 if (CHECK_FLAG(p
->cap
,
9566 && CHECK_FLAG(p
->cap
,
9568 json_object_string_add(
9571 "advertisedAndReceived");
9572 else if (CHECK_FLAG(p
->cap
,
9574 json_object_string_add(
9578 else if (CHECK_FLAG(p
->cap
,
9580 json_object_string_add(
9585 if (CHECK_FLAG(p
->cap
,
9586 PEER_CAP_ENHE_RCV
)) {
9588 json_object_new_object();
9590 for (safi
= SAFI_UNICAST
;
9591 safi
< SAFI_MAX
; safi
++) {
9596 PEER_CAP_ENHE_AF_RCV
)) {
9597 print_store
= afi_safi_print(
9600 json_object_string_add(
9606 json_object_object_add(
9608 "extendedNexthopFamililesByPeer",
9614 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9615 || CHECK_FLAG(p
->cap
,
9616 PEER_CAP_REFRESH_NEW_RCV
)
9617 || CHECK_FLAG(p
->cap
,
9618 PEER_CAP_REFRESH_OLD_RCV
)) {
9619 if (CHECK_FLAG(p
->cap
,
9620 PEER_CAP_REFRESH_ADV
)
9623 PEER_CAP_REFRESH_NEW_RCV
)
9626 PEER_CAP_REFRESH_OLD_RCV
))) {
9629 PEER_CAP_REFRESH_OLD_RCV
)
9632 PEER_CAP_REFRESH_NEW_RCV
))
9633 json_object_string_add(
9636 "advertisedAndReceivedOldNew");
9640 PEER_CAP_REFRESH_OLD_RCV
))
9641 json_object_string_add(
9644 "advertisedAndReceivedOld");
9646 json_object_string_add(
9649 "advertisedAndReceivedNew");
9654 PEER_CAP_REFRESH_ADV
))
9655 json_object_string_add(
9662 PEER_CAP_REFRESH_NEW_RCV
)
9665 PEER_CAP_REFRESH_OLD_RCV
))
9666 json_object_string_add(
9672 /* Multiprotocol Extensions */
9673 json_object
*json_multi
= NULL
;
9674 json_multi
= json_object_new_object();
9676 FOREACH_AFI_SAFI (afi
, safi
) {
9677 if (p
->afc_adv
[afi
][safi
]
9678 || p
->afc_recv
[afi
][safi
]) {
9679 json_object
*json_exten
= NULL
;
9681 json_object_new_object();
9683 if (p
->afc_adv
[afi
][safi
]
9684 && p
->afc_recv
[afi
][safi
])
9685 json_object_boolean_true_add(
9687 "advertisedAndReceived");
9688 else if (p
->afc_adv
[afi
][safi
])
9689 json_object_boolean_true_add(
9692 else if (p
->afc_recv
[afi
][safi
])
9693 json_object_boolean_true_add(
9697 json_object_object_add(
9704 json_object_object_add(
9705 json_cap
, "multiprotocolExtensions",
9708 /* Hostname capabilities */
9709 json_object
*json_hname
= NULL
;
9711 json_hname
= json_object_new_object();
9713 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9714 json_object_string_add(
9715 json_hname
, "advHostName",
9716 bgp
->peer_self
->hostname
9720 json_object_string_add(
9721 json_hname
, "advDomainName",
9722 bgp
->peer_self
->domainname
9729 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9730 json_object_string_add(
9731 json_hname
, "rcvHostName",
9732 p
->hostname
? p
->hostname
9734 json_object_string_add(
9735 json_hname
, "rcvDomainName",
9736 p
->domainname
? p
->domainname
9740 json_object_object_add(json_cap
, "hostName",
9743 /* Gracefull Restart */
9744 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9745 || CHECK_FLAG(p
->cap
,
9746 PEER_CAP_RESTART_ADV
)) {
9747 if (CHECK_FLAG(p
->cap
,
9748 PEER_CAP_RESTART_ADV
)
9749 && CHECK_FLAG(p
->cap
,
9750 PEER_CAP_RESTART_RCV
))
9751 json_object_string_add(
9754 "advertisedAndReceived");
9755 else if (CHECK_FLAG(
9757 PEER_CAP_RESTART_ADV
))
9758 json_object_string_add(
9760 "gracefulRestartCapability",
9762 else if (CHECK_FLAG(
9764 PEER_CAP_RESTART_RCV
))
9765 json_object_string_add(
9767 "gracefulRestartCapability",
9770 if (CHECK_FLAG(p
->cap
,
9771 PEER_CAP_RESTART_RCV
)) {
9772 int restart_af_count
= 0;
9773 json_object
*json_restart
=
9776 json_object_new_object();
9778 json_object_int_add(
9780 "gracefulRestartRemoteTimerMsecs",
9781 p
->v_gr_restart
* 1000);
9783 FOREACH_AFI_SAFI (afi
, safi
) {
9788 PEER_CAP_RESTART_AF_RCV
)) {
9793 json_object_new_object();
9799 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
9800 json_object_boolean_true_add(
9804 json_object_object_add(
9812 if (!restart_af_count
) {
9813 json_object_string_add(
9815 "addressFamiliesByPeer",
9820 json_object_object_add(
9822 "addressFamiliesByPeer",
9826 json_object_object_add(json_neigh
,
9827 "neighborCapabilities",
9830 vty_out(vty
, " Neighbor capabilities:\n");
9833 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9834 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9835 vty_out(vty
, " 4 Byte AS:");
9836 if (CHECK_FLAG(p
->cap
,
9838 vty_out(vty
, " advertised");
9839 if (CHECK_FLAG(p
->cap
,
9841 vty_out(vty
, " %sreceived",
9851 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9852 || CHECK_FLAG(p
->cap
,
9853 PEER_CAP_ADDPATH_ADV
)) {
9854 vty_out(vty
, " AddPath:\n");
9856 FOREACH_AFI_SAFI (afi
, safi
) {
9860 PEER_CAP_ADDPATH_AF_TX_ADV
)
9864 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9875 PEER_CAP_ADDPATH_AF_TX_ADV
))
9886 PEER_CAP_ADDPATH_AF_TX_RCV
))
9893 PEER_CAP_ADDPATH_AF_TX_ADV
)
9903 PEER_CAP_ADDPATH_AF_RX_ADV
)
9907 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9918 PEER_CAP_ADDPATH_AF_RX_ADV
))
9929 PEER_CAP_ADDPATH_AF_RX_RCV
))
9936 PEER_CAP_ADDPATH_AF_RX_ADV
)
9946 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9947 || CHECK_FLAG(p
->cap
,
9948 PEER_CAP_DYNAMIC_ADV
)) {
9949 vty_out(vty
, " Dynamic:");
9950 if (CHECK_FLAG(p
->cap
,
9951 PEER_CAP_DYNAMIC_ADV
))
9952 vty_out(vty
, " advertised");
9953 if (CHECK_FLAG(p
->cap
,
9954 PEER_CAP_DYNAMIC_RCV
))
9955 vty_out(vty
, " %sreceived",
9958 PEER_CAP_DYNAMIC_ADV
)
9964 /* Extended nexthop */
9965 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9966 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9967 vty_out(vty
, " Extended nexthop:");
9968 if (CHECK_FLAG(p
->cap
,
9970 vty_out(vty
, " advertised");
9971 if (CHECK_FLAG(p
->cap
,
9973 vty_out(vty
, " %sreceived",
9981 if (CHECK_FLAG(p
->cap
,
9982 PEER_CAP_ENHE_RCV
)) {
9984 " Address families by peer:\n ");
9985 for (safi
= SAFI_UNICAST
;
9986 safi
< SAFI_MAX
; safi
++)
9991 PEER_CAP_ENHE_AF_RCV
))
10000 /* Route Refresh */
10001 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10002 || CHECK_FLAG(p
->cap
,
10003 PEER_CAP_REFRESH_NEW_RCV
)
10004 || CHECK_FLAG(p
->cap
,
10005 PEER_CAP_REFRESH_OLD_RCV
)) {
10006 vty_out(vty
, " Route refresh:");
10007 if (CHECK_FLAG(p
->cap
,
10008 PEER_CAP_REFRESH_ADV
))
10009 vty_out(vty
, " advertised");
10010 if (CHECK_FLAG(p
->cap
,
10011 PEER_CAP_REFRESH_NEW_RCV
)
10014 PEER_CAP_REFRESH_OLD_RCV
))
10015 vty_out(vty
, " %sreceived(%s)",
10018 PEER_CAP_REFRESH_ADV
)
10023 PEER_CAP_REFRESH_OLD_RCV
)
10026 PEER_CAP_REFRESH_NEW_RCV
))
10030 PEER_CAP_REFRESH_OLD_RCV
)
10034 vty_out(vty
, "\n");
10037 /* Multiprotocol Extensions */
10038 FOREACH_AFI_SAFI (afi
, safi
)
10039 if (p
->afc_adv
[afi
][safi
]
10040 || p
->afc_recv
[afi
][safi
]) {
10042 " Address Family %s:",
10043 afi_safi_print(afi
,
10045 if (p
->afc_adv
[afi
][safi
])
10048 if (p
->afc_recv
[afi
][safi
])
10055 vty_out(vty
, "\n");
10058 /* Hostname capability */
10059 vty_out(vty
, " Hostname Capability:");
10061 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10063 " advertised (name: %s,domain name: %s)",
10064 bgp
->peer_self
->hostname
10068 bgp
->peer_self
->domainname
10073 vty_out(vty
, " not advertised");
10076 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10078 " received (name: %s,domain name: %s)",
10079 p
->hostname
? p
->hostname
10081 p
->domainname
? p
->domainname
10084 vty_out(vty
, " not received");
10087 vty_out(vty
, "\n");
10089 /* Gracefull Restart */
10090 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10091 || CHECK_FLAG(p
->cap
,
10092 PEER_CAP_RESTART_ADV
)) {
10094 " Graceful Restart Capabilty:");
10095 if (CHECK_FLAG(p
->cap
,
10096 PEER_CAP_RESTART_ADV
))
10097 vty_out(vty
, " advertised");
10098 if (CHECK_FLAG(p
->cap
,
10099 PEER_CAP_RESTART_RCV
))
10100 vty_out(vty
, " %sreceived",
10103 PEER_CAP_RESTART_ADV
)
10106 vty_out(vty
, "\n");
10108 if (CHECK_FLAG(p
->cap
,
10109 PEER_CAP_RESTART_RCV
)) {
10110 int restart_af_count
= 0;
10113 " Remote Restart timer is %d seconds\n",
10116 " Address families by peer:\n ");
10118 FOREACH_AFI_SAFI (afi
, safi
)
10123 PEER_CAP_RESTART_AF_RCV
)) {
10136 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10138 : "not preserved");
10139 restart_af_count
++;
10141 if (!restart_af_count
)
10142 vty_out(vty
, "none");
10143 vty_out(vty
, "\n");
10150 /* graceful restart information */
10151 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10152 || p
->t_gr_stale
) {
10153 json_object
*json_grace
= NULL
;
10154 json_object
*json_grace_send
= NULL
;
10155 json_object
*json_grace_recv
= NULL
;
10156 int eor_send_af_count
= 0;
10157 int eor_receive_af_count
= 0;
10160 json_grace
= json_object_new_object();
10161 json_grace_send
= json_object_new_object();
10162 json_grace_recv
= json_object_new_object();
10164 if (p
->status
== Established
) {
10165 FOREACH_AFI_SAFI (afi
, safi
) {
10166 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10167 PEER_STATUS_EOR_SEND
)) {
10168 json_object_boolean_true_add(
10170 afi_safi_print(afi
,
10172 eor_send_af_count
++;
10175 FOREACH_AFI_SAFI (afi
, safi
) {
10177 p
->af_sflags
[afi
][safi
],
10178 PEER_STATUS_EOR_RECEIVED
)) {
10179 json_object_boolean_true_add(
10181 afi_safi_print(afi
,
10183 eor_receive_af_count
++;
10188 json_object_object_add(json_grace
, "endOfRibSend",
10190 json_object_object_add(json_grace
, "endOfRibRecv",
10193 if (p
->t_gr_restart
)
10194 json_object_int_add(json_grace
,
10195 "gracefulRestartTimerMsecs",
10196 thread_timer_remain_second(
10201 json_object_int_add(
10203 "gracefulStalepathTimerMsecs",
10204 thread_timer_remain_second(
10208 json_object_object_add(
10209 json_neigh
, "gracefulRestartInfo", json_grace
);
10211 vty_out(vty
, " Graceful restart informations:\n");
10212 if (p
->status
== Established
) {
10213 vty_out(vty
, " End-of-RIB send: ");
10214 FOREACH_AFI_SAFI (afi
, safi
) {
10215 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10216 PEER_STATUS_EOR_SEND
)) {
10217 vty_out(vty
, "%s%s",
10218 eor_send_af_count
? ", "
10220 afi_safi_print(afi
,
10222 eor_send_af_count
++;
10225 vty_out(vty
, "\n");
10226 vty_out(vty
, " End-of-RIB received: ");
10227 FOREACH_AFI_SAFI (afi
, safi
) {
10229 p
->af_sflags
[afi
][safi
],
10230 PEER_STATUS_EOR_RECEIVED
)) {
10231 vty_out(vty
, "%s%s",
10232 eor_receive_af_count
10235 afi_safi_print(afi
,
10237 eor_receive_af_count
++;
10240 vty_out(vty
, "\n");
10243 if (p
->t_gr_restart
)
10245 " The remaining time of restart timer is %ld\n",
10246 thread_timer_remain_second(
10251 " The remaining time of stalepath timer is %ld\n",
10252 thread_timer_remain_second(
10257 json_object
*json_stat
= NULL
;
10258 json_stat
= json_object_new_object();
10259 /* Packet counts. */
10260 json_object_int_add(json_stat
, "depthInq", 0);
10261 json_object_int_add(json_stat
, "depthOutq",
10262 (unsigned long)p
->obuf
->count
);
10263 json_object_int_add(json_stat
, "opensSent",
10264 atomic_load_explicit(&p
->open_out
,
10265 memory_order_relaxed
));
10266 json_object_int_add(json_stat
, "opensRecv",
10267 atomic_load_explicit(&p
->open_in
,
10268 memory_order_relaxed
));
10269 json_object_int_add(json_stat
, "notificationsSent",
10270 atomic_load_explicit(&p
->notify_out
,
10271 memory_order_relaxed
));
10272 json_object_int_add(json_stat
, "notificationsRecv",
10273 atomic_load_explicit(&p
->notify_in
,
10274 memory_order_relaxed
));
10275 json_object_int_add(json_stat
, "updatesSent",
10276 atomic_load_explicit(&p
->update_out
,
10277 memory_order_relaxed
));
10278 json_object_int_add(json_stat
, "updatesRecv",
10279 atomic_load_explicit(&p
->update_in
,
10280 memory_order_relaxed
));
10281 json_object_int_add(json_stat
, "keepalivesSent",
10282 atomic_load_explicit(&p
->keepalive_out
,
10283 memory_order_relaxed
));
10284 json_object_int_add(json_stat
, "keepalivesRecv",
10285 atomic_load_explicit(&p
->keepalive_in
,
10286 memory_order_relaxed
));
10287 json_object_int_add(json_stat
, "routeRefreshSent",
10288 atomic_load_explicit(&p
->refresh_out
,
10289 memory_order_relaxed
));
10290 json_object_int_add(json_stat
, "routeRefreshRecv",
10291 atomic_load_explicit(&p
->refresh_in
,
10292 memory_order_relaxed
));
10293 json_object_int_add(json_stat
, "capabilitySent",
10294 atomic_load_explicit(&p
->dynamic_cap_out
,
10295 memory_order_relaxed
));
10296 json_object_int_add(json_stat
, "capabilityRecv",
10297 atomic_load_explicit(&p
->dynamic_cap_in
,
10298 memory_order_relaxed
));
10299 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10300 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10301 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10303 /* Packet counts. */
10304 vty_out(vty
, " Message statistics:\n");
10305 vty_out(vty
, " Inq depth is 0\n");
10306 vty_out(vty
, " Outq depth is %lu\n",
10307 (unsigned long)p
->obuf
->count
);
10308 vty_out(vty
, " Sent Rcvd\n");
10309 vty_out(vty
, " Opens: %10d %10d\n",
10310 atomic_load_explicit(&p
->open_out
,
10311 memory_order_relaxed
),
10312 atomic_load_explicit(&p
->open_in
,
10313 memory_order_relaxed
));
10314 vty_out(vty
, " Notifications: %10d %10d\n",
10315 atomic_load_explicit(&p
->notify_out
,
10316 memory_order_relaxed
),
10317 atomic_load_explicit(&p
->notify_in
,
10318 memory_order_relaxed
));
10319 vty_out(vty
, " Updates: %10d %10d\n",
10320 atomic_load_explicit(&p
->update_out
,
10321 memory_order_relaxed
),
10322 atomic_load_explicit(&p
->update_in
,
10323 memory_order_relaxed
));
10324 vty_out(vty
, " Keepalives: %10d %10d\n",
10325 atomic_load_explicit(&p
->keepalive_out
,
10326 memory_order_relaxed
),
10327 atomic_load_explicit(&p
->keepalive_in
,
10328 memory_order_relaxed
));
10329 vty_out(vty
, " Route Refresh: %10d %10d\n",
10330 atomic_load_explicit(&p
->refresh_out
,
10331 memory_order_relaxed
),
10332 atomic_load_explicit(&p
->refresh_in
,
10333 memory_order_relaxed
));
10334 vty_out(vty
, " Capability: %10d %10d\n",
10335 atomic_load_explicit(&p
->dynamic_cap_out
,
10336 memory_order_relaxed
),
10337 atomic_load_explicit(&p
->dynamic_cap_in
,
10338 memory_order_relaxed
));
10339 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10344 /* advertisement-interval */
10345 json_object_int_add(json_neigh
,
10346 "minBtwnAdvertisementRunsTimerMsecs",
10347 p
->v_routeadv
* 1000);
10349 /* Update-source. */
10350 if (p
->update_if
|| p
->update_source
) {
10352 json_object_string_add(json_neigh
,
10355 else if (p
->update_source
)
10356 json_object_string_add(
10357 json_neigh
, "updateSource",
10358 sockunion2str(p
->update_source
, buf1
,
10362 /* advertisement-interval */
10364 " Minimum time between advertisement runs is %d seconds\n",
10367 /* Update-source. */
10368 if (p
->update_if
|| p
->update_source
) {
10369 vty_out(vty
, " Update source is ");
10371 vty_out(vty
, "%s", p
->update_if
);
10372 else if (p
->update_source
)
10374 sockunion2str(p
->update_source
, buf1
,
10376 vty_out(vty
, "\n");
10379 vty_out(vty
, "\n");
10382 /* Address Family Information */
10383 json_object
*json_hold
= NULL
;
10386 json_hold
= json_object_new_object();
10388 FOREACH_AFI_SAFI (afi
, safi
)
10389 if (p
->afc
[afi
][safi
])
10390 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10394 json_object_object_add(json_neigh
, "addressFamilyInfo",
10396 json_object_int_add(json_neigh
, "connectionsEstablished",
10398 json_object_int_add(json_neigh
, "connectionsDropped",
10401 vty_out(vty
, " Connections established %d; dropped %d\n",
10402 p
->established
, p
->dropped
);
10404 if (!p
->last_reset
) {
10406 json_object_string_add(json_neigh
, "lastReset",
10409 vty_out(vty
, " Last reset never\n");
10415 uptime
= bgp_clock();
10416 uptime
-= p
->resettime
;
10417 tm
= gmtime(&uptime
);
10418 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10419 (tm
->tm_sec
* 1000)
10420 + (tm
->tm_min
* 60000)
10421 + (tm
->tm_hour
* 3600000));
10422 json_object_string_add(
10423 json_neigh
, "lastResetDueTo",
10424 peer_down_str
[(int)p
->last_reset
]);
10425 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10426 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10427 char errorcodesubcode_hexstr
[5];
10428 char errorcodesubcode_str
[256];
10430 code_str
= bgp_notify_code_str(p
->notify
.code
);
10431 subcode_str
= bgp_notify_subcode_str(
10432 p
->notify
.code
, p
->notify
.subcode
);
10434 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10435 p
->notify
.code
, p
->notify
.subcode
);
10436 json_object_string_add(json_neigh
,
10437 "lastErrorCodeSubcode",
10438 errorcodesubcode_hexstr
);
10439 snprintf(errorcodesubcode_str
, 255, "%s%s",
10440 code_str
, subcode_str
);
10441 json_object_string_add(json_neigh
,
10442 "lastNotificationReason",
10443 errorcodesubcode_str
);
10444 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10445 && p
->notify
.code
== BGP_NOTIFY_CEASE
10446 && (p
->notify
.subcode
10447 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10448 || p
->notify
.subcode
10449 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10450 && p
->notify
.length
) {
10452 const char *msg_str
;
10454 msg_str
= bgp_notify_admin_message(
10455 msgbuf
, sizeof(msgbuf
),
10456 (uint8_t *)p
->notify
.data
,
10459 json_object_string_add(
10461 "lastShutdownDescription",
10466 vty_out(vty
, " Last reset %s, ",
10467 peer_uptime(p
->resettime
, timebuf
,
10468 BGP_UPTIME_LEN
, 0, NULL
));
10470 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10471 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10472 code_str
= bgp_notify_code_str(p
->notify
.code
);
10473 subcode_str
= bgp_notify_subcode_str(
10474 p
->notify
.code
, p
->notify
.subcode
);
10475 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10476 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10479 code_str
, subcode_str
);
10480 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10481 && p
->notify
.code
== BGP_NOTIFY_CEASE
10482 && (p
->notify
.subcode
10483 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10484 || p
->notify
.subcode
10485 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10486 && p
->notify
.length
) {
10488 const char *msg_str
;
10490 msg_str
= bgp_notify_admin_message(
10491 msgbuf
, sizeof(msgbuf
),
10492 (uint8_t *)p
->notify
.data
,
10496 " Message: \"%s\"\n",
10500 vty_out(vty
, "due to %s\n",
10501 peer_down_str
[(int)p
->last_reset
]);
10504 if (p
->last_reset_cause_size
) {
10505 msg
= p
->last_reset_cause
;
10507 " Message received that caused BGP to send a NOTIFICATION:\n ");
10508 for (i
= 1; i
<= p
->last_reset_cause_size
;
10510 vty_out(vty
, "%02X", *msg
++);
10512 if (i
!= p
->last_reset_cause_size
) {
10514 vty_out(vty
, "\n ");
10515 } else if (i
% 4 == 0) {
10520 vty_out(vty
, "\n");
10525 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10527 json_object_boolean_true_add(json_neigh
,
10528 "prefixesConfigExceedMax");
10531 " Peer had exceeded the max. no. of prefixes configured.\n");
10533 if (p
->t_pmax_restart
) {
10535 json_object_boolean_true_add(
10536 json_neigh
, "reducePrefixNumFrom");
10537 json_object_int_add(json_neigh
,
10538 "restartInTimerMsec",
10539 thread_timer_remain_second(
10544 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10545 p
->host
, thread_timer_remain_second(
10546 p
->t_pmax_restart
));
10549 json_object_boolean_true_add(
10551 "reducePrefixNumAndClearIpBgp");
10554 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10559 /* EBGP Multihop and GTSM */
10560 if (p
->sort
!= BGP_PEER_IBGP
) {
10562 if (p
->gtsm_hops
> 0)
10563 json_object_int_add(json_neigh
,
10564 "externalBgpNbrMaxHopsAway",
10566 else if (p
->ttl
> 1)
10567 json_object_int_add(json_neigh
,
10568 "externalBgpNbrMaxHopsAway",
10571 if (p
->gtsm_hops
> 0)
10573 " External BGP neighbor may be up to %d hops away.\n",
10575 else if (p
->ttl
> 1)
10577 " External BGP neighbor may be up to %d hops away.\n",
10581 if (p
->gtsm_hops
> 0) {
10583 json_object_int_add(json_neigh
,
10584 "internalBgpNbrMaxHopsAway",
10588 " Internal BGP neighbor may be up to %d hops away.\n",
10593 /* Local address. */
10596 json_object_string_add(json_neigh
, "hostLocal",
10597 sockunion2str(p
->su_local
, buf1
,
10599 json_object_int_add(json_neigh
, "portLocal",
10600 ntohs(p
->su_local
->sin
.sin_port
));
10602 vty_out(vty
, "Local host: %s, Local port: %d\n",
10603 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10604 ntohs(p
->su_local
->sin
.sin_port
));
10607 /* Remote address. */
10608 if (p
->su_remote
) {
10610 json_object_string_add(json_neigh
, "hostForeign",
10611 sockunion2str(p
->su_remote
, buf1
,
10613 json_object_int_add(json_neigh
, "portForeign",
10614 ntohs(p
->su_remote
->sin
.sin_port
));
10616 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10617 sockunion2str(p
->su_remote
, buf1
,
10619 ntohs(p
->su_remote
->sin
.sin_port
));
10622 /* Nexthop display. */
10625 json_object_string_add(json_neigh
, "nexthop",
10627 &p
->nexthop
.v4
, buf1
,
10629 json_object_string_add(json_neigh
, "nexthopGlobal",
10630 inet_ntop(AF_INET6
,
10631 &p
->nexthop
.v6_global
,
10632 buf1
, sizeof(buf1
)));
10633 json_object_string_add(json_neigh
, "nexthopLocal",
10634 inet_ntop(AF_INET6
,
10635 &p
->nexthop
.v6_local
,
10636 buf1
, sizeof(buf1
)));
10637 if (p
->shared_network
)
10638 json_object_string_add(json_neigh
,
10642 json_object_string_add(json_neigh
,
10644 "nonSharedNetwork");
10646 vty_out(vty
, "Nexthop: %s\n",
10647 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10649 vty_out(vty
, "Nexthop global: %s\n",
10650 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10652 vty_out(vty
, "Nexthop local: %s\n",
10653 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10655 vty_out(vty
, "BGP connection: %s\n",
10656 p
->shared_network
? "shared network"
10657 : "non shared network");
10661 /* Timer information. */
10663 json_object_int_add(json_neigh
, "connectRetryTimer",
10665 if (p
->status
== Established
&& p
->rtt
)
10666 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10669 json_object_int_add(
10670 json_neigh
, "nextStartTimerDueInMsecs",
10671 thread_timer_remain_second(p
->t_start
) * 1000);
10673 json_object_int_add(
10674 json_neigh
, "nextConnectTimerDueInMsecs",
10675 thread_timer_remain_second(p
->t_connect
)
10677 if (p
->t_routeadv
) {
10678 json_object_int_add(json_neigh
, "mraiInterval",
10680 json_object_int_add(
10681 json_neigh
, "mraiTimerExpireInMsecs",
10682 thread_timer_remain_second(p
->t_routeadv
)
10686 json_object_int_add(json_neigh
, "authenticationEnabled",
10690 json_object_string_add(json_neigh
, "readThread", "on");
10692 json_object_string_add(json_neigh
, "readThread", "off");
10694 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10695 json_object_string_add(json_neigh
, "writeThread", "on");
10697 json_object_string_add(json_neigh
, "writeThread",
10700 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10702 if (p
->status
== Established
&& p
->rtt
)
10703 vty_out(vty
, "Estimated round trip time: %d ms\n",
10706 vty_out(vty
, "Next start timer due in %ld seconds\n",
10707 thread_timer_remain_second(p
->t_start
));
10709 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10710 thread_timer_remain_second(p
->t_connect
));
10713 "MRAI (interval %u) timer expires in %ld seconds\n",
10715 thread_timer_remain_second(p
->t_routeadv
));
10717 vty_out(vty
, "Peer Authentication Enabled\n");
10719 vty_out(vty
, "Read thread: %s Write thread: %s\n",
10720 p
->t_read
? "on" : "off",
10721 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10726 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10727 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10728 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10731 vty_out(vty
, "\n");
10733 /* BFD information. */
10734 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10737 if (p
->conf_if
) /* Configured interface name. */
10738 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10739 else /* Configured IP address. */
10740 json_object_object_add(json
, p
->host
, json_neigh
);
10744 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10745 enum show_type type
, union sockunion
*su
,
10746 const char *conf_if
, bool use_json
,
10749 struct listnode
*node
, *nnode
;
10752 bool nbr_output
= false;
10754 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10755 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10760 bgp_show_peer(vty
, peer
, use_json
, json
);
10766 && !strcmp(peer
->conf_if
, conf_if
))
10768 && !strcmp(peer
->hostname
, conf_if
))) {
10770 bgp_show_peer(vty
, peer
, use_json
,
10774 if (sockunion_same(&peer
->su
, su
)) {
10776 bgp_show_peer(vty
, peer
, use_json
,
10784 if (type
== show_peer
&& !find
) {
10786 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
10788 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
10791 if (type
!= show_peer
&& !nbr_output
&& !use_json
)
10792 vty_out(vty
, "%% No BGP neighbors found\n");
10795 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10796 json
, JSON_C_TO_STRING_PRETTY
));
10797 json_object_free(json
);
10799 vty_out(vty
, "\n");
10802 return CMD_SUCCESS
;
10805 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
10806 enum show_type type
,
10807 const char *ip_str
,
10810 struct listnode
*node
, *nnode
;
10812 union sockunion su
;
10813 json_object
*json
= NULL
;
10814 int ret
, is_first
= 1;
10815 bool nbr_output
= false;
10818 vty_out(vty
, "{\n");
10820 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
10823 if (!(json
= json_object_new_object())) {
10825 EC_BGP_JSON_MEM_ERROR
,
10826 "Unable to allocate memory for JSON object");
10828 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
10832 json_object_int_add(json
, "vrfId",
10833 (bgp
->vrf_id
== VRF_UNKNOWN
)
10835 : (int64_t)bgp
->vrf_id
);
10836 json_object_string_add(
10838 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10843 vty_out(vty
, ",\n");
10847 vty_out(vty
, "\"%s\":",
10848 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10852 vty_out(vty
, "\nInstance %s:\n",
10853 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10858 if (type
== show_peer
) {
10859 ret
= str2sockunion(ip_str
, &su
);
10861 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10864 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10867 bgp_show_neighbor(vty
, bgp
, show_all
, NULL
, NULL
,
10873 vty_out(vty
, "}\n");
10874 else if (!nbr_output
)
10875 vty_out(vty
, "%% BGP instance not found\n");
10878 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
10879 enum show_type type
, const char *ip_str
,
10884 union sockunion su
;
10885 json_object
*json
= NULL
;
10888 if (strmatch(name
, "all")) {
10889 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
10891 return CMD_SUCCESS
;
10893 bgp
= bgp_lookup_by_name(name
);
10896 json
= json_object_new_object();
10897 vty_out(vty
, "%s\n",
10898 json_object_to_json_string_ext(
10900 JSON_C_TO_STRING_PRETTY
));
10901 json_object_free(json
);
10904 "%% BGP instance not found\n");
10906 return CMD_WARNING
;
10910 bgp
= bgp_get_default();
10914 json
= json_object_new_object();
10916 ret
= str2sockunion(ip_str
, &su
);
10918 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10921 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10924 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
10927 json_object_free(json
);
10930 vty_out(vty
, "{}\n");
10932 vty_out(vty
, "%% BGP instance not found\n");
10935 return CMD_SUCCESS
;
10938 /* "show [ip] bgp neighbors" commands. */
10939 DEFUN (show_ip_bgp_neighbors
,
10940 show_ip_bgp_neighbors_cmd
,
10941 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
10945 BGP_INSTANCE_HELP_STR
10948 "Detailed information on TCP and BGP neighbor connections\n"
10949 "Neighbor to display information about\n"
10950 "Neighbor to display information about\n"
10951 "Neighbor on BGP configured interface\n"
10955 char *sh_arg
= NULL
;
10956 enum show_type sh_type
;
10958 bool uj
= use_json(argc
, argv
);
10962 /* [<vrf> VIEWVRFNAME] */
10963 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10964 vrf
= argv
[idx
+ 1]->arg
;
10965 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10967 } else if (argv_find(argv
, argc
, "view", &idx
))
10968 /* [<view> VIEWVRFNAME] */
10969 vrf
= argv
[idx
+ 1]->arg
;
10972 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
10973 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
10974 || argv_find(argv
, argc
, "WORD", &idx
)) {
10975 sh_type
= show_peer
;
10976 sh_arg
= argv
[idx
]->arg
;
10978 sh_type
= show_all
;
10980 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
10983 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
10984 paths' and `show ip mbgp paths'. Those functions results are the
10986 DEFUN (show_ip_bgp_paths
,
10987 show_ip_bgp_paths_cmd
,
10988 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
10993 "Path information\n")
10995 vty_out(vty
, "Address Refcnt Path\n");
10996 aspath_print_all_vty(vty
);
10997 return CMD_SUCCESS
;
11002 static void community_show_all_iterator(struct hash_backet
*backet
,
11005 struct community
*com
;
11007 com
= (struct community
*)backet
->data
;
11008 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
11009 community_str(com
, false));
11012 /* Show BGP's community internal data. */
11013 DEFUN (show_ip_bgp_community_info
,
11014 show_ip_bgp_community_info_cmd
,
11015 "show [ip] bgp community-info",
11019 "List all bgp community information\n")
11021 vty_out(vty
, "Address Refcnt Community\n");
11023 hash_iterate(community_hash(),
11024 (void (*)(struct hash_backet
*,
11025 void *))community_show_all_iterator
,
11028 return CMD_SUCCESS
;
11031 static void lcommunity_show_all_iterator(struct hash_backet
*backet
,
11034 struct lcommunity
*lcom
;
11036 lcom
= (struct lcommunity
*)backet
->data
;
11037 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11038 lcommunity_str(lcom
, false));
11041 /* Show BGP's community internal data. */
11042 DEFUN (show_ip_bgp_lcommunity_info
,
11043 show_ip_bgp_lcommunity_info_cmd
,
11044 "show ip bgp large-community-info",
11048 "List all bgp large-community information\n")
11050 vty_out(vty
, "Address Refcnt Large-community\n");
11052 hash_iterate(lcommunity_hash(),
11053 (void (*)(struct hash_backet
*,
11054 void *))lcommunity_show_all_iterator
,
11057 return CMD_SUCCESS
;
11061 DEFUN (show_ip_bgp_attr_info
,
11062 show_ip_bgp_attr_info_cmd
,
11063 "show [ip] bgp attribute-info",
11067 "List all bgp attribute information\n")
11069 attr_show_all(vty
);
11070 return CMD_SUCCESS
;
11073 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11074 safi_t safi
, bool use_json
)
11077 struct listnode
*node
;
11079 char buf1
[INET6_ADDRSTRLEN
];
11081 vpn_policy_direction_t dir
;
11084 json_object
*json
= NULL
;
11085 json_object
*json_import_vrfs
= NULL
;
11086 json_object
*json_export_vrfs
= NULL
;
11088 json
= json_object_new_object();
11090 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11093 vty_out(vty
, "%s\n",
11094 json_object_to_json_string_ext(
11096 JSON_C_TO_STRING_PRETTY
));
11097 json_object_free(json
);
11099 return CMD_WARNING
;
11102 /* Provide context for the block */
11103 json_object_string_add(json
, "vrf", name
? name
: "default");
11104 json_object_string_add(json
, "afiSafi",
11105 afi_safi_print(afi
, safi
));
11107 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11108 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11109 json_object_string_add(json
, "importFromVrfs", "none");
11110 json_object_string_add(json
, "importRts", "none");
11112 json_import_vrfs
= json_object_new_array();
11114 for (ALL_LIST_ELEMENTS_RO(
11115 bgp
->vpn_policy
[afi
].import_vrf
,
11117 json_object_array_add(json_import_vrfs
,
11118 json_object_new_string(vname
));
11120 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11121 ecom_str
= ecommunity_ecom2str(
11122 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11123 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11124 json_object_object_add(json
, "importFromVrfs",
11126 json_object_string_add(json
, "importRts", ecom_str
);
11128 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11131 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11132 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11133 json_object_string_add(json
, "exportToVrfs", "none");
11134 json_object_string_add(json
, "routeDistinguisher",
11136 json_object_string_add(json
, "exportRts", "none");
11138 json_export_vrfs
= json_object_new_array();
11140 for (ALL_LIST_ELEMENTS_RO(
11141 bgp
->vpn_policy
[afi
].export_vrf
,
11143 json_object_array_add(json_export_vrfs
,
11144 json_object_new_string(vname
));
11145 json_object_object_add(json
, "exportToVrfs",
11147 json_object_string_add(json
, "routeDistinguisher",
11148 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11149 buf1
, RD_ADDRSTRLEN
));
11151 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11152 ecom_str
= ecommunity_ecom2str(
11153 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11154 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11155 json_object_string_add(json
, "exportRts", ecom_str
);
11157 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11160 vty_out(vty
, "%s\n",
11161 json_object_to_json_string_ext(json
,
11162 JSON_C_TO_STRING_PRETTY
));
11163 json_object_free(json
);
11166 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11169 vty_out(vty
, "%% No such BGP instance exist\n");
11170 return CMD_WARNING
;
11173 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11174 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11176 "This VRF is not importing %s routes from any other VRF\n",
11177 afi_safi_print(afi
, safi
));
11180 "This VRF is importing %s routes from the following VRFs:\n",
11181 afi_safi_print(afi
, safi
));
11183 for (ALL_LIST_ELEMENTS_RO(
11184 bgp
->vpn_policy
[afi
].import_vrf
,
11186 vty_out(vty
, " %s\n", vname
);
11188 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11189 ecom_str
= ecommunity_ecom2str(
11190 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11191 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11192 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11194 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11197 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11198 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11200 "This VRF is not exporting %s routes to any other VRF\n",
11201 afi_safi_print(afi
, safi
));
11204 "This VRF is exporting %s routes to the following VRFs:\n",
11205 afi_safi_print(afi
, safi
));
11207 for (ALL_LIST_ELEMENTS_RO(
11208 bgp
->vpn_policy
[afi
].export_vrf
,
11210 vty_out(vty
, " %s\n", vname
);
11212 vty_out(vty
, "RD: %s\n",
11213 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11214 buf1
, RD_ADDRSTRLEN
));
11216 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11217 ecom_str
= ecommunity_ecom2str(
11218 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11219 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11220 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11221 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11225 return CMD_SUCCESS
;
11228 /* "show [ip] bgp route-leak" command. */
11229 DEFUN (show_ip_bgp_route_leak
,
11230 show_ip_bgp_route_leak_cmd
,
11231 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11235 BGP_INSTANCE_HELP_STR
11238 "Route leaking information\n"
11242 afi_t afi
= AFI_MAX
;
11243 safi_t safi
= SAFI_MAX
;
11245 bool uj
= use_json(argc
, argv
);
11248 /* show [ip] bgp */
11249 if (argv_find(argv
, argc
, "ip", &idx
)) {
11251 safi
= SAFI_UNICAST
;
11253 /* [vrf VIEWVRFNAME] */
11254 if (argv_find(argv
, argc
, "view", &idx
)) {
11256 "%% This command is not applicable to BGP views\n");
11257 return CMD_WARNING
;
11260 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11261 vrf
= argv
[idx
+ 1]->arg
;
11262 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11265 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11266 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11267 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11270 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11272 "%% This command is applicable only for unicast ipv4|ipv6\n");
11273 return CMD_WARNING
;
11276 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
);
11279 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11282 struct listnode
*node
, *nnode
;
11285 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11286 vty_out(vty
, "\nInstance %s:\n",
11287 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11290 update_group_show(bgp
, afi
, safi
, vty
, 0);
11294 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11295 int safi
, uint64_t subgrp_id
)
11300 if (strmatch(name
, "all")) {
11301 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11302 return CMD_SUCCESS
;
11304 bgp
= bgp_lookup_by_name(name
);
11307 bgp
= bgp_get_default();
11311 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11312 return CMD_SUCCESS
;
11315 DEFUN (show_ip_bgp_updgrps
,
11316 show_ip_bgp_updgrps_cmd
,
11317 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11321 BGP_INSTANCE_HELP_STR
11323 BGP_SAFI_WITH_LABEL_HELP_STR
11324 "Detailed info about dynamic update groups\n"
11325 "Specific subgroup to display detailed info for\n")
11328 afi_t afi
= AFI_IP6
;
11329 safi_t safi
= SAFI_UNICAST
;
11330 uint64_t subgrp_id
= 0;
11334 /* show [ip] bgp */
11335 if (argv_find(argv
, argc
, "ip", &idx
))
11337 /* [<vrf> VIEWVRFNAME] */
11338 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11339 vrf
= argv
[idx
+ 1]->arg
;
11340 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11342 } else if (argv_find(argv
, argc
, "view", &idx
))
11343 /* [<view> VIEWVRFNAME] */
11344 vrf
= argv
[idx
+ 1]->arg
;
11345 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11346 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11347 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11350 /* get subgroup id, if provided */
11352 if (argv
[idx
]->type
== VARIABLE_TKN
)
11353 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11355 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11358 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11359 show_bgp_instance_all_ipv6_updgrps_cmd
,
11360 "show [ip] bgp <view|vrf> all update-groups",
11364 BGP_INSTANCE_ALL_HELP_STR
11365 "Detailed info about dynamic update groups\n")
11367 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11368 return CMD_SUCCESS
;
11371 DEFUN (show_bgp_updgrps_stats
,
11372 show_bgp_updgrps_stats_cmd
,
11373 "show [ip] bgp update-groups statistics",
11377 "Detailed info about dynamic update groups\n"
11382 bgp
= bgp_get_default();
11384 update_group_show_stats(bgp
, vty
);
11386 return CMD_SUCCESS
;
11389 DEFUN (show_bgp_instance_updgrps_stats
,
11390 show_bgp_instance_updgrps_stats_cmd
,
11391 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11395 BGP_INSTANCE_HELP_STR
11396 "Detailed info about dynamic update groups\n"
11402 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11404 update_group_show_stats(bgp
, vty
);
11406 return CMD_SUCCESS
;
11409 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11410 afi_t afi
, safi_t safi
,
11411 const char *what
, uint64_t subgrp_id
)
11416 bgp
= bgp_lookup_by_name(name
);
11418 bgp
= bgp_get_default();
11421 if (!strcmp(what
, "advertise-queue"))
11422 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11424 else if (!strcmp(what
, "advertised-routes"))
11425 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11427 else if (!strcmp(what
, "packet-queue"))
11428 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11433 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11434 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11435 "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",
11436 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11438 "Detailed info about dynamic update groups\n"
11439 "Specific subgroup to display info for\n"
11440 "Advertisement queue\n"
11441 "Announced routes\n"
11444 uint64_t subgrp_id
= 0;
11448 subgrp_id
= strtoull(sgid
, NULL
, 10);
11453 afiz
= bgp_vty_afi_from_str(afi
);
11457 afiz
= bgp_vty_afi_from_str(afi
);
11458 if (afiz
!= AFI_IP
)
11460 "%% Cannot specify both 'ip' and 'ipv6'\n");
11461 return CMD_WARNING
;
11464 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11466 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11467 return CMD_SUCCESS
;
11470 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11472 struct listnode
*node
, *nnode
;
11473 struct prefix
*range
;
11476 char buf
[PREFIX2STR_BUFFER
];
11479 const char *peer_status
;
11480 const char *af_str
;
11485 conf
= group
->conf
;
11487 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11488 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
11490 } else if (conf
->as_type
== AS_INTERNAL
) {
11491 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
11494 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11497 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11498 vty_out(vty
, " Peer-group type is internal\n");
11500 vty_out(vty
, " Peer-group type is external\n");
11502 /* Display AFs configured. */
11503 vty_out(vty
, " Configured address-families:");
11504 FOREACH_AFI_SAFI (afi
, safi
) {
11505 if (conf
->afc
[afi
][safi
]) {
11507 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11511 vty_out(vty
, " none\n");
11513 vty_out(vty
, "\n");
11515 /* Display listen ranges (for dynamic neighbors), if any */
11516 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11519 else if (afi
== AFI_IP6
)
11523 lr_count
= listcount(group
->listen_range
[afi
]);
11525 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11529 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11531 prefix2str(range
, buf
, sizeof(buf
));
11532 vty_out(vty
, " %s\n", buf
);
11537 /* Display group members and their status */
11538 if (listcount(group
->peer
)) {
11539 vty_out(vty
, " Peer-group members:\n");
11540 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11541 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11542 peer_status
= "Idle (Admin)";
11543 else if (CHECK_FLAG(peer
->sflags
,
11544 PEER_STATUS_PREFIX_OVERFLOW
))
11545 peer_status
= "Idle (PfxCt)";
11547 peer_status
= lookup_msg(bgp_status_msg
,
11548 peer
->status
, NULL
);
11550 dynamic
= peer_dynamic_neighbor(peer
);
11551 vty_out(vty
, " %s %s %s \n", peer
->host
,
11552 dynamic
? "(dynamic)" : "", peer_status
);
11556 return CMD_SUCCESS
;
11559 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11560 const char *group_name
)
11563 struct listnode
*node
, *nnode
;
11564 struct peer_group
*group
;
11565 bool found
= false;
11567 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11570 vty_out(vty
, "%% BGP instance not found\n");
11571 return CMD_WARNING
;
11574 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11576 if (strmatch(group
->name
, group_name
)) {
11577 bgp_show_one_peer_group(vty
, group
);
11582 bgp_show_one_peer_group(vty
, group
);
11586 if (group_name
&& !found
)
11587 vty_out(vty
, "%% No such peer-group\n");
11589 return CMD_SUCCESS
;
11592 DEFUN (show_ip_bgp_peer_groups
,
11593 show_ip_bgp_peer_groups_cmd
,
11594 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11598 BGP_INSTANCE_HELP_STR
11599 "Detailed information on BGP peer groups\n"
11600 "Peer group name\n")
11605 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11607 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11609 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11613 /* Redistribute VTY commands. */
11615 DEFUN (bgp_redistribute_ipv4
,
11616 bgp_redistribute_ipv4_cmd
,
11617 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11618 "Redistribute information from another routing protocol\n"
11619 FRR_IP_REDIST_HELP_STR_BGPD
)
11621 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11622 int idx_protocol
= 1;
11625 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11627 vty_out(vty
, "%% Invalid route type\n");
11628 return CMD_WARNING_CONFIG_FAILED
;
11631 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11632 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
11636 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11637 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11638 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11640 DEFUN (bgp_redistribute_ipv4_rmap
,
11641 bgp_redistribute_ipv4_rmap_cmd
,
11642 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11643 "Redistribute information from another routing protocol\n"
11644 FRR_IP_REDIST_HELP_STR_BGPD
11645 "Route map reference\n"
11646 "Pointer to route-map entries\n")
11648 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11649 int idx_protocol
= 1;
11652 struct bgp_redist
*red
;
11655 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11657 vty_out(vty
, "%% Invalid route type\n");
11658 return CMD_WARNING_CONFIG_FAILED
;
11661 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11662 changed
= bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11663 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11667 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
11668 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11669 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11670 "Route map reference\n"
11671 "Pointer to route-map entries\n")
11673 DEFUN (bgp_redistribute_ipv4_metric
,
11674 bgp_redistribute_ipv4_metric_cmd
,
11675 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11676 "Redistribute information from another routing protocol\n"
11677 FRR_IP_REDIST_HELP_STR_BGPD
11678 "Metric for redistributed routes\n"
11679 "Default metric\n")
11681 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11682 int idx_protocol
= 1;
11683 int idx_number
= 3;
11686 struct bgp_redist
*red
;
11689 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11691 vty_out(vty
, "%% Invalid route type\n");
11692 return CMD_WARNING_CONFIG_FAILED
;
11694 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11696 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11697 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11698 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11702 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
11703 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11704 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11705 "Metric for redistributed routes\n"
11706 "Default metric\n")
11708 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
11709 bgp_redistribute_ipv4_rmap_metric_cmd
,
11710 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11711 "Redistribute information from another routing protocol\n"
11712 FRR_IP_REDIST_HELP_STR_BGPD
11713 "Route map reference\n"
11714 "Pointer to route-map entries\n"
11715 "Metric for redistributed routes\n"
11716 "Default metric\n")
11718 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11719 int idx_protocol
= 1;
11721 int idx_number
= 5;
11724 struct bgp_redist
*red
;
11727 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11729 vty_out(vty
, "%% Invalid route type\n");
11730 return CMD_WARNING_CONFIG_FAILED
;
11732 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11734 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11735 changed
= bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11736 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11737 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11741 bgp_redistribute_ipv4_rmap_metric
,
11742 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
11743 "redistribute " FRR_IP_REDIST_STR_BGPD
11744 " route-map WORD metric (0-4294967295)",
11745 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11746 "Route map reference\n"
11747 "Pointer to route-map entries\n"
11748 "Metric for redistributed routes\n"
11749 "Default metric\n")
11751 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
11752 bgp_redistribute_ipv4_metric_rmap_cmd
,
11753 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
11754 "Redistribute information from another routing protocol\n"
11755 FRR_IP_REDIST_HELP_STR_BGPD
11756 "Metric for redistributed routes\n"
11758 "Route map reference\n"
11759 "Pointer to route-map entries\n")
11761 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11762 int idx_protocol
= 1;
11763 int idx_number
= 3;
11767 struct bgp_redist
*red
;
11770 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11772 vty_out(vty
, "%% Invalid route type\n");
11773 return CMD_WARNING_CONFIG_FAILED
;
11775 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11777 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11778 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11779 changed
|= bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11780 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11784 bgp_redistribute_ipv4_metric_rmap
,
11785 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
11786 "redistribute " FRR_IP_REDIST_STR_BGPD
11787 " metric (0-4294967295) route-map WORD",
11788 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11789 "Metric for redistributed routes\n"
11791 "Route map reference\n"
11792 "Pointer to route-map entries\n")
11794 DEFUN (bgp_redistribute_ipv4_ospf
,
11795 bgp_redistribute_ipv4_ospf_cmd
,
11796 "redistribute <ospf|table> (1-65535)",
11797 "Redistribute information from another routing protocol\n"
11798 "Open Shortest Path First (OSPFv2)\n"
11799 "Non-main Kernel Routing Table\n"
11800 "Instance ID/Table ID\n")
11802 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11803 int idx_ospf_table
= 1;
11804 int idx_number
= 2;
11805 unsigned short instance
;
11806 unsigned short protocol
;
11808 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11810 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11811 protocol
= ZEBRA_ROUTE_OSPF
;
11813 protocol
= ZEBRA_ROUTE_TABLE
;
11815 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11816 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
11819 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
11820 "redistribute <ospf|table> (1-65535)",
11821 "Redistribute information from another routing protocol\n"
11822 "Open Shortest Path First (OSPFv2)\n"
11823 "Non-main Kernel Routing Table\n"
11824 "Instance ID/Table ID\n")
11826 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
11827 bgp_redistribute_ipv4_ospf_rmap_cmd
,
11828 "redistribute <ospf|table> (1-65535) route-map WORD",
11829 "Redistribute information from another routing protocol\n"
11830 "Open Shortest Path First (OSPFv2)\n"
11831 "Non-main Kernel Routing Table\n"
11832 "Instance ID/Table ID\n"
11833 "Route map reference\n"
11834 "Pointer to route-map entries\n")
11836 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11837 int idx_ospf_table
= 1;
11838 int idx_number
= 2;
11840 struct bgp_redist
*red
;
11841 unsigned short instance
;
11845 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11846 protocol
= ZEBRA_ROUTE_OSPF
;
11848 protocol
= ZEBRA_ROUTE_TABLE
;
11850 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11851 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11852 changed
= bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11853 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
11856 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
11857 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
11858 "redistribute <ospf|table> (1-65535) route-map WORD",
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")
11866 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
11867 bgp_redistribute_ipv4_ospf_metric_cmd
,
11868 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
11869 "Redistribute information from another routing protocol\n"
11870 "Open Shortest Path First (OSPFv2)\n"
11871 "Non-main Kernel Routing Table\n"
11872 "Instance ID/Table ID\n"
11873 "Metric for redistributed routes\n"
11874 "Default metric\n")
11876 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11877 int idx_ospf_table
= 1;
11878 int idx_number
= 2;
11879 int idx_number_2
= 4;
11881 struct bgp_redist
*red
;
11882 unsigned short instance
;
11886 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11887 protocol
= ZEBRA_ROUTE_OSPF
;
11889 protocol
= ZEBRA_ROUTE_TABLE
;
11891 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11892 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11894 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11895 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
11897 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
11900 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
11901 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
11902 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
11903 "Redistribute information from another routing protocol\n"
11904 "Open Shortest Path First (OSPFv2)\n"
11905 "Non-main Kernel Routing Table\n"
11906 "Instance ID/Table ID\n"
11907 "Metric for redistributed routes\n"
11908 "Default metric\n")
11910 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
11911 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
11912 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
11913 "Redistribute information from another routing protocol\n"
11914 "Open Shortest Path First (OSPFv2)\n"
11915 "Non-main Kernel Routing Table\n"
11916 "Instance ID/Table ID\n"
11917 "Route map reference\n"
11918 "Pointer to route-map entries\n"
11919 "Metric for redistributed routes\n"
11920 "Default metric\n")
11922 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11923 int idx_ospf_table
= 1;
11924 int idx_number
= 2;
11926 int idx_number_2
= 6;
11928 struct bgp_redist
*red
;
11929 unsigned short instance
;
11933 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11934 protocol
= ZEBRA_ROUTE_OSPF
;
11936 protocol
= ZEBRA_ROUTE_TABLE
;
11938 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11939 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11941 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11942 changed
= bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11943 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
11945 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
11949 bgp_redistribute_ipv4_ospf_rmap_metric
,
11950 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
11951 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
11952 "Redistribute information from another routing protocol\n"
11953 "Open Shortest Path First (OSPFv2)\n"
11954 "Non-main Kernel Routing Table\n"
11955 "Instance ID/Table ID\n"
11956 "Route map reference\n"
11957 "Pointer to route-map entries\n"
11958 "Metric for redistributed routes\n"
11959 "Default metric\n")
11961 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
11962 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
11963 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
11964 "Redistribute information from another routing protocol\n"
11965 "Open Shortest Path First (OSPFv2)\n"
11966 "Non-main Kernel Routing Table\n"
11967 "Instance ID/Table ID\n"
11968 "Metric for redistributed routes\n"
11970 "Route map reference\n"
11971 "Pointer to route-map entries\n")
11973 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11974 int idx_ospf_table
= 1;
11975 int idx_number
= 2;
11976 int idx_number_2
= 4;
11979 struct bgp_redist
*red
;
11980 unsigned short instance
;
11984 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11985 protocol
= ZEBRA_ROUTE_OSPF
;
11987 protocol
= ZEBRA_ROUTE_TABLE
;
11989 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11990 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11992 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11993 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
11995 changed
|= bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11996 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12000 bgp_redistribute_ipv4_ospf_metric_rmap
,
12001 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
12002 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12003 "Redistribute information from another routing protocol\n"
12004 "Open Shortest Path First (OSPFv2)\n"
12005 "Non-main Kernel Routing Table\n"
12006 "Instance ID/Table ID\n"
12007 "Metric for redistributed routes\n"
12009 "Route map reference\n"
12010 "Pointer to route-map entries\n")
12012 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12013 no_bgp_redistribute_ipv4_ospf_cmd
,
12014 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12016 "Redistribute information from another routing protocol\n"
12017 "Open Shortest Path First (OSPFv2)\n"
12018 "Non-main Kernel Routing Table\n"
12019 "Instance ID/Table ID\n"
12020 "Metric for redistributed routes\n"
12022 "Route map reference\n"
12023 "Pointer to route-map entries\n")
12025 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12026 int idx_ospf_table
= 2;
12027 int idx_number
= 3;
12028 unsigned short instance
;
12031 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12032 protocol
= ZEBRA_ROUTE_OSPF
;
12034 protocol
= ZEBRA_ROUTE_TABLE
;
12036 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12037 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12041 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12042 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12044 "Redistribute information from another routing protocol\n"
12045 "Open Shortest Path First (OSPFv2)\n"
12046 "Non-main Kernel Routing Table\n"
12047 "Instance ID/Table ID\n"
12048 "Metric for redistributed routes\n"
12050 "Route map reference\n"
12051 "Pointer to route-map entries\n")
12053 DEFUN (no_bgp_redistribute_ipv4
,
12054 no_bgp_redistribute_ipv4_cmd
,
12055 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12057 "Redistribute information from another routing protocol\n"
12058 FRR_IP_REDIST_HELP_STR_BGPD
12059 "Metric for redistributed routes\n"
12061 "Route map reference\n"
12062 "Pointer to route-map entries\n")
12064 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12065 int idx_protocol
= 2;
12068 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12070 vty_out(vty
, "%% Invalid route type\n");
12071 return CMD_WARNING_CONFIG_FAILED
;
12073 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12077 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12078 "no redistribute " FRR_IP_REDIST_STR_BGPD
12079 " [metric (0-4294967295)] [route-map WORD]",
12081 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12082 "Metric for redistributed routes\n"
12084 "Route map reference\n"
12085 "Pointer to route-map entries\n")
12087 DEFUN (bgp_redistribute_ipv6
,
12088 bgp_redistribute_ipv6_cmd
,
12089 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12090 "Redistribute information from another routing protocol\n"
12091 FRR_IP6_REDIST_HELP_STR_BGPD
)
12093 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12094 int idx_protocol
= 1;
12097 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12099 vty_out(vty
, "%% Invalid route type\n");
12100 return CMD_WARNING_CONFIG_FAILED
;
12103 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12104 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12107 DEFUN (bgp_redistribute_ipv6_rmap
,
12108 bgp_redistribute_ipv6_rmap_cmd
,
12109 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12110 "Redistribute information from another routing protocol\n"
12111 FRR_IP6_REDIST_HELP_STR_BGPD
12112 "Route map reference\n"
12113 "Pointer to route-map entries\n")
12115 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12116 int idx_protocol
= 1;
12119 struct bgp_redist
*red
;
12122 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12124 vty_out(vty
, "%% Invalid route type\n");
12125 return CMD_WARNING_CONFIG_FAILED
;
12128 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12129 changed
= bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
12130 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12133 DEFUN (bgp_redistribute_ipv6_metric
,
12134 bgp_redistribute_ipv6_metric_cmd
,
12135 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12136 "Redistribute information from another routing protocol\n"
12137 FRR_IP6_REDIST_HELP_STR_BGPD
12138 "Metric for redistributed routes\n"
12139 "Default metric\n")
12141 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12142 int idx_protocol
= 1;
12143 int idx_number
= 3;
12146 struct bgp_redist
*red
;
12149 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12151 vty_out(vty
, "%% Invalid route type\n");
12152 return CMD_WARNING_CONFIG_FAILED
;
12154 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12156 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12157 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12158 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12161 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12162 bgp_redistribute_ipv6_rmap_metric_cmd
,
12163 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12164 "Redistribute information from another routing protocol\n"
12165 FRR_IP6_REDIST_HELP_STR_BGPD
12166 "Route map reference\n"
12167 "Pointer to route-map entries\n"
12168 "Metric for redistributed routes\n"
12169 "Default metric\n")
12171 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12172 int idx_protocol
= 1;
12174 int idx_number
= 5;
12177 struct bgp_redist
*red
;
12180 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12182 vty_out(vty
, "%% Invalid route type\n");
12183 return CMD_WARNING_CONFIG_FAILED
;
12185 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12187 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12188 changed
= bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
12189 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12191 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12194 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12195 bgp_redistribute_ipv6_metric_rmap_cmd
,
12196 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12197 "Redistribute information from another routing protocol\n"
12198 FRR_IP6_REDIST_HELP_STR_BGPD
12199 "Metric for redistributed routes\n"
12201 "Route map reference\n"
12202 "Pointer to route-map entries\n")
12204 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12205 int idx_protocol
= 1;
12206 int idx_number
= 3;
12210 struct bgp_redist
*red
;
12213 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12215 vty_out(vty
, "%% Invalid route type\n");
12216 return CMD_WARNING_CONFIG_FAILED
;
12218 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12220 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12221 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12223 changed
|= bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
12224 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12227 DEFUN (no_bgp_redistribute_ipv6
,
12228 no_bgp_redistribute_ipv6_cmd
,
12229 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12231 "Redistribute information from another routing protocol\n"
12232 FRR_IP6_REDIST_HELP_STR_BGPD
12233 "Metric for redistributed routes\n"
12235 "Route map reference\n"
12236 "Pointer to route-map entries\n")
12238 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12239 int idx_protocol
= 2;
12242 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12244 vty_out(vty
, "%% Invalid route type\n");
12245 return CMD_WARNING_CONFIG_FAILED
;
12248 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12251 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12256 /* Unicast redistribution only. */
12257 if (safi
!= SAFI_UNICAST
)
12260 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12261 /* Redistribute BGP does not make sense. */
12262 if (i
!= ZEBRA_ROUTE_BGP
) {
12263 struct list
*red_list
;
12264 struct listnode
*node
;
12265 struct bgp_redist
*red
;
12267 red_list
= bgp
->redist
[afi
][i
];
12271 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12272 /* "redistribute" configuration. */
12273 vty_out(vty
, " redistribute %s",
12274 zebra_route_string(i
));
12276 vty_out(vty
, " %d", red
->instance
);
12277 if (red
->redist_metric_flag
)
12278 vty_out(vty
, " metric %u",
12279 red
->redist_metric
);
12280 if (red
->rmap
.name
)
12281 vty_out(vty
, " route-map %s",
12283 vty_out(vty
, "\n");
12289 /* This is part of the address-family block (unicast only) */
12290 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12295 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
])
12296 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12297 bgp
->vpn_policy
[afi
]
12298 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12300 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12301 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12302 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12303 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12306 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12307 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12309 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12312 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12313 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12314 bgp
->vpn_policy
[afi
].tovpn_label
);
12317 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12318 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12319 char buf
[RD_ADDRSTRLEN
];
12320 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12321 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12324 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12325 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12327 char buf
[PREFIX_STRLEN
];
12328 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12329 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12332 vty_out(vty
, "%*snexthop vpn export %s\n",
12336 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12337 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12339 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12340 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12342 char *b
= ecommunity_ecom2str(
12343 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12344 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12345 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12346 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12348 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12349 char *b
= ecommunity_ecom2str(
12350 bgp
->vpn_policy
[afi
]
12351 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12352 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12353 ECOMMUNITY_ROUTE_TARGET
);
12354 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12355 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12357 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12358 char *b
= ecommunity_ecom2str(
12359 bgp
->vpn_policy
[afi
]
12360 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12361 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12362 ECOMMUNITY_ROUTE_TARGET
);
12363 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12364 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12368 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12369 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12370 bgp
->vpn_policy
[afi
]
12371 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12373 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12374 char *b
= ecommunity_ecom2str(
12375 bgp
->vpn_policy
[afi
]
12376 .import_redirect_rtlist
,
12377 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12378 ECOMMUNITY_ROUTE_TARGET
);
12380 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12381 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12386 /* BGP node structure. */
12387 static struct cmd_node bgp_node
= {
12388 BGP_NODE
, "%s(config-router)# ", 1,
12391 static struct cmd_node bgp_ipv4_unicast_node
= {
12392 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12395 static struct cmd_node bgp_ipv4_multicast_node
= {
12396 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12399 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12400 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12403 static struct cmd_node bgp_ipv6_unicast_node
= {
12404 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12407 static struct cmd_node bgp_ipv6_multicast_node
= {
12408 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12411 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12412 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12415 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12416 "%s(config-router-af)# ", 1};
12418 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12419 "%s(config-router-af-vpnv6)# ", 1};
12421 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12422 "%s(config-router-evpn)# ", 1};
12424 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12425 "%s(config-router-af-vni)# ", 1};
12427 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12428 "%s(config-router-af)# ", 1};
12430 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12431 "%s(config-router-af-vpnv6)# ", 1};
12433 static void community_list_vty(void);
12435 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12439 struct listnode
*lnbgp
, *lnpeer
;
12441 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12442 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12443 /* only provide suggestions on the appropriate input
12445 * they'll otherwise show up multiple times */
12446 enum cmd_token_type match_type
;
12447 char *name
= peer
->host
;
12449 if (peer
->conf_if
) {
12450 match_type
= VARIABLE_TKN
;
12451 name
= peer
->conf_if
;
12452 } else if (strchr(peer
->host
, ':'))
12453 match_type
= IPV6_TKN
;
12455 match_type
= IPV4_TKN
;
12457 if (token
->type
!= match_type
)
12460 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12465 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12466 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12467 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12468 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12469 {.completions
= NULL
}};
12471 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12474 struct peer_group
*group
;
12475 struct listnode
*lnbgp
, *lnpeer
;
12477 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12478 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12479 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12484 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12485 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12486 {.completions
= NULL
} };
12488 void bgp_vty_init(void)
12490 cmd_variable_handler_register(bgp_var_neighbor
);
12491 cmd_variable_handler_register(bgp_var_peergroup
);
12493 /* Install bgp top node. */
12494 install_node(&bgp_node
, bgp_config_write
);
12495 install_node(&bgp_ipv4_unicast_node
, NULL
);
12496 install_node(&bgp_ipv4_multicast_node
, NULL
);
12497 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12498 install_node(&bgp_ipv6_unicast_node
, NULL
);
12499 install_node(&bgp_ipv6_multicast_node
, NULL
);
12500 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12501 install_node(&bgp_vpnv4_node
, NULL
);
12502 install_node(&bgp_vpnv6_node
, NULL
);
12503 install_node(&bgp_evpn_node
, NULL
);
12504 install_node(&bgp_evpn_vni_node
, NULL
);
12505 install_node(&bgp_flowspecv4_node
, NULL
);
12506 install_node(&bgp_flowspecv6_node
, NULL
);
12508 /* Install default VTY commands to new nodes. */
12509 install_default(BGP_NODE
);
12510 install_default(BGP_IPV4_NODE
);
12511 install_default(BGP_IPV4M_NODE
);
12512 install_default(BGP_IPV4L_NODE
);
12513 install_default(BGP_IPV6_NODE
);
12514 install_default(BGP_IPV6M_NODE
);
12515 install_default(BGP_IPV6L_NODE
);
12516 install_default(BGP_VPNV4_NODE
);
12517 install_default(BGP_VPNV6_NODE
);
12518 install_default(BGP_FLOWSPECV4_NODE
);
12519 install_default(BGP_FLOWSPECV6_NODE
);
12520 install_default(BGP_EVPN_NODE
);
12521 install_default(BGP_EVPN_VNI_NODE
);
12523 /* "bgp multiple-instance" commands. */
12524 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
12525 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
12527 /* "bgp config-type" commands. */
12528 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
12529 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
12531 /* bgp route-map delay-timer commands. */
12532 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12533 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12535 /* Dummy commands (Currently not supported) */
12536 install_element(BGP_NODE
, &no_synchronization_cmd
);
12537 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12539 /* "router bgp" commands. */
12540 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12542 /* "no router bgp" commands. */
12543 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12545 /* "bgp router-id" commands. */
12546 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12547 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12549 /* "bgp cluster-id" commands. */
12550 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12551 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12553 /* "bgp confederation" commands. */
12554 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12555 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12557 /* "bgp confederation peers" commands. */
12558 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12559 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12561 /* bgp max-med command */
12562 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12563 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12564 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12565 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12566 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12568 /* bgp disable-ebgp-connected-nh-check */
12569 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12570 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12572 /* bgp update-delay command */
12573 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12574 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12575 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12577 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12578 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12579 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12580 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12582 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12583 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12585 /* "maximum-paths" commands. */
12586 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12587 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12588 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12589 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12590 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12591 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12592 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12593 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12594 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12595 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12596 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12597 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12598 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12599 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12600 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12602 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12603 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12604 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12605 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12606 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12608 /* "timers bgp" commands. */
12609 install_element(BGP_NODE
, &bgp_timers_cmd
);
12610 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12612 /* route-map delay-timer commands - per instance for backwards compat.
12614 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12615 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12617 /* "bgp client-to-client reflection" commands */
12618 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
12619 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
12621 /* "bgp always-compare-med" commands */
12622 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
12623 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
12625 /* "bgp deterministic-med" commands */
12626 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
12627 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
12629 /* "bgp graceful-restart" commands */
12630 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
12631 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
12632 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
12633 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
12634 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
12635 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
12637 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
12638 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
12640 /* "bgp graceful-shutdown" commands */
12641 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
12642 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
12644 /* "bgp fast-external-failover" commands */
12645 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
12646 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
12648 /* "bgp enforce-first-as" commands */
12649 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
12651 /* "bgp bestpath compare-routerid" commands */
12652 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
12653 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
12655 /* "bgp bestpath as-path ignore" commands */
12656 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
12657 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
12659 /* "bgp bestpath as-path confed" commands */
12660 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
12661 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
12663 /* "bgp bestpath as-path multipath-relax" commands */
12664 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
12665 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
12667 /* "bgp log-neighbor-changes" commands */
12668 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
12669 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
12671 /* "bgp bestpath med" commands */
12672 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
12673 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
12675 /* "no bgp default ipv4-unicast" commands. */
12676 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
12677 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
12679 /* "bgp network import-check" commands. */
12680 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
12681 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
12682 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
12684 /* "bgp default local-preference" commands. */
12685 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
12686 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
12688 /* bgp default show-hostname */
12689 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
12690 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
12692 /* "bgp default subgroup-pkt-queue-max" commands. */
12693 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
12694 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
12696 /* bgp ibgp-allow-policy-mods command */
12697 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
12698 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
12700 /* "bgp listen limit" commands. */
12701 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
12702 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
12704 /* "bgp listen range" commands. */
12705 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
12706 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
12708 /* "bgp default shutdown" command */
12709 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
12711 /* "neighbor remote-as" commands. */
12712 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
12713 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
12714 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
12715 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
12716 install_element(BGP_NODE
,
12717 &neighbor_interface_v6only_config_remote_as_cmd
);
12718 install_element(BGP_NODE
, &no_neighbor_cmd
);
12719 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
12721 /* "neighbor peer-group" commands. */
12722 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
12723 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
12724 install_element(BGP_NODE
,
12725 &no_neighbor_interface_peer_group_remote_as_cmd
);
12727 /* "neighbor local-as" commands. */
12728 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
12729 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
12730 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
12731 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
12733 /* "neighbor solo" commands. */
12734 install_element(BGP_NODE
, &neighbor_solo_cmd
);
12735 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
12737 /* "neighbor password" commands. */
12738 install_element(BGP_NODE
, &neighbor_password_cmd
);
12739 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
12741 /* "neighbor activate" commands. */
12742 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
12743 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
12744 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
12745 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
12746 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
12747 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
12748 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
12749 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
12750 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
12751 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
12752 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
12753 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
12755 /* "no neighbor activate" commands. */
12756 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
12757 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
12758 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
12759 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
12760 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
12761 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
12762 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
12763 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
12764 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
12765 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
12766 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
12767 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
12769 /* "neighbor peer-group" set commands. */
12770 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
12771 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12772 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12773 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12774 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12775 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12776 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12777 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12778 install_element(BGP_FLOWSPECV4_NODE
,
12779 &neighbor_set_peer_group_hidden_cmd
);
12780 install_element(BGP_FLOWSPECV6_NODE
,
12781 &neighbor_set_peer_group_hidden_cmd
);
12783 /* "no neighbor peer-group unset" commands. */
12784 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
12785 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12786 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12787 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12788 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12789 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12790 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12791 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12792 install_element(BGP_FLOWSPECV4_NODE
,
12793 &no_neighbor_set_peer_group_hidden_cmd
);
12794 install_element(BGP_FLOWSPECV6_NODE
,
12795 &no_neighbor_set_peer_group_hidden_cmd
);
12797 /* "neighbor softreconfiguration inbound" commands.*/
12798 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
12799 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
12800 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12801 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12802 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12803 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12804 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12805 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12806 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12807 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12808 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12809 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12810 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12811 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12812 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12813 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12814 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12815 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12816 install_element(BGP_FLOWSPECV4_NODE
,
12817 &neighbor_soft_reconfiguration_cmd
);
12818 install_element(BGP_FLOWSPECV4_NODE
,
12819 &no_neighbor_soft_reconfiguration_cmd
);
12820 install_element(BGP_FLOWSPECV6_NODE
,
12821 &neighbor_soft_reconfiguration_cmd
);
12822 install_element(BGP_FLOWSPECV6_NODE
,
12823 &no_neighbor_soft_reconfiguration_cmd
);
12825 /* "neighbor attribute-unchanged" commands. */
12826 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
12827 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
12828 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
12829 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
12830 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
12831 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
12832 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
12833 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
12834 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
12835 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
12836 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
12837 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
12838 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
12839 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
12840 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
12841 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
12842 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
12843 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
12845 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
12846 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
12848 /* "nexthop-local unchanged" commands */
12849 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
12850 install_element(BGP_IPV6_NODE
,
12851 &no_neighbor_nexthop_local_unchanged_cmd
);
12853 /* "neighbor next-hop-self" commands. */
12854 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
12855 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
12856 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
12857 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
12858 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
12859 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
12860 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
12861 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
12862 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
12863 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
12864 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
12865 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
12866 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
12867 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
12868 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
12869 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
12870 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
12871 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
12872 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
12873 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
12875 /* "neighbor next-hop-self force" commands. */
12876 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
12877 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
12878 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
12879 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12880 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
12881 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12882 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
12883 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12884 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
12885 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12886 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
12887 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12888 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
12889 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12890 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
12891 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12892 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
12893 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12895 /* "neighbor as-override" commands. */
12896 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
12897 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
12898 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
12899 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
12900 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
12901 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
12902 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
12903 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
12904 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
12905 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
12906 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
12907 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
12908 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
12909 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
12910 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
12911 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
12912 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
12913 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
12915 /* "neighbor remove-private-AS" commands. */
12916 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
12917 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
12918 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
12919 install_element(BGP_NODE
,
12920 &no_neighbor_remove_private_as_all_hidden_cmd
);
12921 install_element(BGP_NODE
,
12922 &neighbor_remove_private_as_replace_as_hidden_cmd
);
12923 install_element(BGP_NODE
,
12924 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
12925 install_element(BGP_NODE
,
12926 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
12929 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
12930 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
12931 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
12932 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
12933 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12934 install_element(BGP_IPV4_NODE
,
12935 &neighbor_remove_private_as_replace_as_cmd
);
12936 install_element(BGP_IPV4_NODE
,
12937 &no_neighbor_remove_private_as_replace_as_cmd
);
12938 install_element(BGP_IPV4_NODE
,
12939 &neighbor_remove_private_as_all_replace_as_cmd
);
12940 install_element(BGP_IPV4_NODE
,
12941 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12942 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
12943 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
12944 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
12945 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12946 install_element(BGP_IPV4M_NODE
,
12947 &neighbor_remove_private_as_replace_as_cmd
);
12948 install_element(BGP_IPV4M_NODE
,
12949 &no_neighbor_remove_private_as_replace_as_cmd
);
12950 install_element(BGP_IPV4M_NODE
,
12951 &neighbor_remove_private_as_all_replace_as_cmd
);
12952 install_element(BGP_IPV4M_NODE
,
12953 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12954 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
12955 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
12956 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
12957 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12958 install_element(BGP_IPV4L_NODE
,
12959 &neighbor_remove_private_as_replace_as_cmd
);
12960 install_element(BGP_IPV4L_NODE
,
12961 &no_neighbor_remove_private_as_replace_as_cmd
);
12962 install_element(BGP_IPV4L_NODE
,
12963 &neighbor_remove_private_as_all_replace_as_cmd
);
12964 install_element(BGP_IPV4L_NODE
,
12965 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12966 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
12967 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
12968 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
12969 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12970 install_element(BGP_IPV6_NODE
,
12971 &neighbor_remove_private_as_replace_as_cmd
);
12972 install_element(BGP_IPV6_NODE
,
12973 &no_neighbor_remove_private_as_replace_as_cmd
);
12974 install_element(BGP_IPV6_NODE
,
12975 &neighbor_remove_private_as_all_replace_as_cmd
);
12976 install_element(BGP_IPV6_NODE
,
12977 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12978 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
12979 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
12980 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
12981 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12982 install_element(BGP_IPV6M_NODE
,
12983 &neighbor_remove_private_as_replace_as_cmd
);
12984 install_element(BGP_IPV6M_NODE
,
12985 &no_neighbor_remove_private_as_replace_as_cmd
);
12986 install_element(BGP_IPV6M_NODE
,
12987 &neighbor_remove_private_as_all_replace_as_cmd
);
12988 install_element(BGP_IPV6M_NODE
,
12989 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12990 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
12991 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
12992 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
12993 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12994 install_element(BGP_IPV6L_NODE
,
12995 &neighbor_remove_private_as_replace_as_cmd
);
12996 install_element(BGP_IPV6L_NODE
,
12997 &no_neighbor_remove_private_as_replace_as_cmd
);
12998 install_element(BGP_IPV6L_NODE
,
12999 &neighbor_remove_private_as_all_replace_as_cmd
);
13000 install_element(BGP_IPV6L_NODE
,
13001 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13002 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
13003 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13004 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13005 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13006 install_element(BGP_VPNV4_NODE
,
13007 &neighbor_remove_private_as_replace_as_cmd
);
13008 install_element(BGP_VPNV4_NODE
,
13009 &no_neighbor_remove_private_as_replace_as_cmd
);
13010 install_element(BGP_VPNV4_NODE
,
13011 &neighbor_remove_private_as_all_replace_as_cmd
);
13012 install_element(BGP_VPNV4_NODE
,
13013 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13014 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
13015 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13016 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13017 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13018 install_element(BGP_VPNV6_NODE
,
13019 &neighbor_remove_private_as_replace_as_cmd
);
13020 install_element(BGP_VPNV6_NODE
,
13021 &no_neighbor_remove_private_as_replace_as_cmd
);
13022 install_element(BGP_VPNV6_NODE
,
13023 &neighbor_remove_private_as_all_replace_as_cmd
);
13024 install_element(BGP_VPNV6_NODE
,
13025 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13027 /* "neighbor send-community" commands.*/
13028 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
13029 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
13030 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
13031 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
13032 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
13033 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
13034 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
13035 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
13036 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
13037 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
13038 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
13039 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
13040 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
13041 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
13042 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
13043 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
13044 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
13045 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
13046 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
13047 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
13048 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
13049 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
13050 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
13051 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
13052 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
13053 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
13054 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
13055 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
13056 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
13057 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
13058 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
13059 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
13060 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
13061 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
13062 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
13063 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
13065 /* "neighbor route-reflector" commands.*/
13066 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
13067 install_element(BGP_NODE
,
13068 &no_neighbor_route_reflector_client_hidden_cmd
);
13069 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
13070 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
13071 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
13072 install_element(BGP_IPV4M_NODE
,
13073 &no_neighbor_route_reflector_client_cmd
);
13074 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
13075 install_element(BGP_IPV4L_NODE
,
13076 &no_neighbor_route_reflector_client_cmd
);
13077 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
13078 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
13079 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
13080 install_element(BGP_IPV6M_NODE
,
13081 &no_neighbor_route_reflector_client_cmd
);
13082 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
13083 install_element(BGP_IPV6L_NODE
,
13084 &no_neighbor_route_reflector_client_cmd
);
13085 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
13086 install_element(BGP_VPNV4_NODE
,
13087 &no_neighbor_route_reflector_client_cmd
);
13088 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
13089 install_element(BGP_VPNV6_NODE
,
13090 &no_neighbor_route_reflector_client_cmd
);
13091 install_element(BGP_FLOWSPECV4_NODE
,
13092 &neighbor_route_reflector_client_cmd
);
13093 install_element(BGP_FLOWSPECV4_NODE
,
13094 &no_neighbor_route_reflector_client_cmd
);
13095 install_element(BGP_FLOWSPECV6_NODE
,
13096 &neighbor_route_reflector_client_cmd
);
13097 install_element(BGP_FLOWSPECV6_NODE
,
13098 &no_neighbor_route_reflector_client_cmd
);
13099 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
13100 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
13102 /* "neighbor route-server" commands.*/
13103 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
13104 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
13105 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
13106 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
13107 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
13108 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
13109 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
13110 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
13111 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
13112 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
13113 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
13114 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
13115 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
13116 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
13117 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
13118 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
13119 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
13120 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
13121 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
13122 install_element(BGP_FLOWSPECV4_NODE
,
13123 &no_neighbor_route_server_client_cmd
);
13124 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
13125 install_element(BGP_FLOWSPECV6_NODE
,
13126 &no_neighbor_route_server_client_cmd
);
13128 /* "neighbor addpath-tx-all-paths" commands.*/
13129 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
13130 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
13131 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13132 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13133 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13134 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13135 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13136 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13137 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13138 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13139 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13140 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13141 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13142 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13143 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13144 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13145 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13146 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13148 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
13149 install_element(BGP_NODE
,
13150 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13151 install_element(BGP_NODE
,
13152 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13153 install_element(BGP_IPV4_NODE
,
13154 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13155 install_element(BGP_IPV4_NODE
,
13156 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13157 install_element(BGP_IPV4M_NODE
,
13158 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13159 install_element(BGP_IPV4M_NODE
,
13160 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13161 install_element(BGP_IPV4L_NODE
,
13162 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13163 install_element(BGP_IPV4L_NODE
,
13164 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13165 install_element(BGP_IPV6_NODE
,
13166 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13167 install_element(BGP_IPV6_NODE
,
13168 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13169 install_element(BGP_IPV6M_NODE
,
13170 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13171 install_element(BGP_IPV6M_NODE
,
13172 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13173 install_element(BGP_IPV6L_NODE
,
13174 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13175 install_element(BGP_IPV6L_NODE
,
13176 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13177 install_element(BGP_VPNV4_NODE
,
13178 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13179 install_element(BGP_VPNV4_NODE
,
13180 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13181 install_element(BGP_VPNV6_NODE
,
13182 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13183 install_element(BGP_VPNV6_NODE
,
13184 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13186 /* "neighbor passive" commands. */
13187 install_element(BGP_NODE
, &neighbor_passive_cmd
);
13188 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13191 /* "neighbor shutdown" commands. */
13192 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13193 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13194 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13195 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13197 /* "neighbor capability extended-nexthop" commands.*/
13198 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13199 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13201 /* "neighbor capability orf prefix-list" commands.*/
13202 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13203 install_element(BGP_NODE
,
13204 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13205 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13206 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13207 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13208 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13209 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13210 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13211 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13212 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13213 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13214 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13215 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13216 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13218 /* "neighbor capability dynamic" commands.*/
13219 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13220 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13222 /* "neighbor dont-capability-negotiate" commands. */
13223 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13224 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13226 /* "neighbor ebgp-multihop" commands. */
13227 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13228 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13229 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13231 /* "neighbor disable-connected-check" commands. */
13232 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13233 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13235 /* "neighbor enforce-first-as" commands. */
13236 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13237 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13239 /* "neighbor description" commands. */
13240 install_element(BGP_NODE
, &neighbor_description_cmd
);
13241 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13242 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13244 /* "neighbor update-source" commands. "*/
13245 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13246 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13248 /* "neighbor default-originate" commands. */
13249 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13250 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13251 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13252 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13253 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13254 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13255 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13256 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13257 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13258 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13259 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13260 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13261 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13262 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13263 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13264 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13265 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13266 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13267 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13268 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13269 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13271 /* "neighbor port" commands. */
13272 install_element(BGP_NODE
, &neighbor_port_cmd
);
13273 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13275 /* "neighbor weight" commands. */
13276 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13277 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13279 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13280 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13281 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13282 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13283 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13284 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13285 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13286 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13287 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13288 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13289 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13290 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13291 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13292 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13293 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13294 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13296 /* "neighbor override-capability" commands. */
13297 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13298 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13300 /* "neighbor strict-capability-match" commands. */
13301 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13302 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13304 /* "neighbor timers" commands. */
13305 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13306 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13308 /* "neighbor timers connect" commands. */
13309 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13310 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13312 /* "neighbor advertisement-interval" commands. */
13313 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13314 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13316 /* "neighbor interface" commands. */
13317 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13318 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13320 /* "neighbor distribute" commands. */
13321 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13322 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13323 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13324 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13325 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13326 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13327 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13328 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13329 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13330 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13331 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13332 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13333 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13334 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13335 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13336 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13337 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13338 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13340 /* "neighbor prefix-list" commands. */
13341 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13342 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13343 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13344 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13345 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13346 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13347 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13348 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13349 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13350 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13351 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13352 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13353 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13354 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13355 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13356 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13357 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13358 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13359 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13360 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13361 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13362 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13364 /* "neighbor filter-list" commands. */
13365 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13366 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13367 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13368 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13369 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13370 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13371 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13372 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13373 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13374 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13375 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13376 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13377 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13378 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13379 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13380 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13381 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13382 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13383 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13384 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13385 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13386 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13388 /* "neighbor route-map" commands. */
13389 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13390 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13391 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13392 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13393 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13394 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13395 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13396 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13397 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13398 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13399 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13400 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13401 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13402 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13403 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13404 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13405 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13406 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13407 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13408 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13409 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13410 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13411 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13412 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13414 /* "neighbor unsuppress-map" commands. */
13415 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13416 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13417 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13418 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13419 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13420 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13421 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13422 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13423 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13424 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13425 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13426 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13427 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13428 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13429 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13430 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13431 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13432 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13434 /* "neighbor maximum-prefix" commands. */
13435 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13436 install_element(BGP_NODE
,
13437 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13438 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13439 install_element(BGP_NODE
,
13440 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13441 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13442 install_element(BGP_NODE
,
13443 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13444 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13445 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13446 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13447 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13448 install_element(BGP_IPV4_NODE
,
13449 &neighbor_maximum_prefix_threshold_warning_cmd
);
13450 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13451 install_element(BGP_IPV4_NODE
,
13452 &neighbor_maximum_prefix_threshold_restart_cmd
);
13453 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13454 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13455 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13456 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13457 install_element(BGP_IPV4M_NODE
,
13458 &neighbor_maximum_prefix_threshold_warning_cmd
);
13459 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13460 install_element(BGP_IPV4M_NODE
,
13461 &neighbor_maximum_prefix_threshold_restart_cmd
);
13462 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13463 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13464 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13465 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13466 install_element(BGP_IPV4L_NODE
,
13467 &neighbor_maximum_prefix_threshold_warning_cmd
);
13468 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13469 install_element(BGP_IPV4L_NODE
,
13470 &neighbor_maximum_prefix_threshold_restart_cmd
);
13471 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13472 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13473 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13474 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13475 install_element(BGP_IPV6_NODE
,
13476 &neighbor_maximum_prefix_threshold_warning_cmd
);
13477 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13478 install_element(BGP_IPV6_NODE
,
13479 &neighbor_maximum_prefix_threshold_restart_cmd
);
13480 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13481 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13482 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13483 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13484 install_element(BGP_IPV6M_NODE
,
13485 &neighbor_maximum_prefix_threshold_warning_cmd
);
13486 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13487 install_element(BGP_IPV6M_NODE
,
13488 &neighbor_maximum_prefix_threshold_restart_cmd
);
13489 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13490 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13491 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13492 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13493 install_element(BGP_IPV6L_NODE
,
13494 &neighbor_maximum_prefix_threshold_warning_cmd
);
13495 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13496 install_element(BGP_IPV6L_NODE
,
13497 &neighbor_maximum_prefix_threshold_restart_cmd
);
13498 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13499 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13500 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13501 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13502 install_element(BGP_VPNV4_NODE
,
13503 &neighbor_maximum_prefix_threshold_warning_cmd
);
13504 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13505 install_element(BGP_VPNV4_NODE
,
13506 &neighbor_maximum_prefix_threshold_restart_cmd
);
13507 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13508 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13509 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13510 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13511 install_element(BGP_VPNV6_NODE
,
13512 &neighbor_maximum_prefix_threshold_warning_cmd
);
13513 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13514 install_element(BGP_VPNV6_NODE
,
13515 &neighbor_maximum_prefix_threshold_restart_cmd
);
13516 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13518 /* "neighbor allowas-in" */
13519 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13520 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13521 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13522 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13523 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13524 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13525 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13526 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13527 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13528 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13529 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13530 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13531 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13532 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13533 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13534 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13535 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13536 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13537 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13538 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13540 /* address-family commands. */
13541 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13542 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13543 #ifdef KEEP_OLD_VPN_COMMANDS
13544 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13545 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13546 #endif /* KEEP_OLD_VPN_COMMANDS */
13548 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13550 /* "exit-address-family" command. */
13551 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13552 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13553 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13554 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13555 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13556 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13557 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13558 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13559 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13560 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13561 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13563 /* "clear ip bgp commands" */
13564 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13566 /* clear ip bgp prefix */
13567 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13568 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13569 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13571 /* "show [ip] bgp summary" commands. */
13572 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13573 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13574 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13575 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13576 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13577 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
13579 /* "show [ip] bgp neighbors" commands. */
13580 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
13582 /* "show [ip] bgp peer-group" commands. */
13583 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
13585 /* "show [ip] bgp paths" commands. */
13586 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
13588 /* "show [ip] bgp community" commands. */
13589 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
13591 /* "show ip bgp large-community" commands. */
13592 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
13593 /* "show [ip] bgp attribute-info" commands. */
13594 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
13595 /* "show [ip] bgp route-leak" command */
13596 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
13598 /* "redistribute" commands. */
13599 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
13600 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
13601 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
13602 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
13603 install_element(BGP_NODE
,
13604 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
13605 install_element(BGP_NODE
,
13606 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
13607 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
13608 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
13609 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
13610 install_element(BGP_NODE
,
13611 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
13612 install_element(BGP_NODE
,
13613 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
13614 install_element(BGP_NODE
,
13615 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
13616 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
13617 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
13618 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
13619 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
13620 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
13621 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
13622 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
13623 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
13624 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
13625 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
13626 install_element(BGP_IPV4_NODE
,
13627 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
13628 install_element(BGP_IPV4_NODE
,
13629 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
13630 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
13631 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
13632 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
13633 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
13634 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
13635 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
13637 /* import|export vpn [route-map WORD] */
13638 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
13639 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
13641 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
13642 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
13644 /* ttl_security commands */
13645 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
13646 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
13648 /* "show [ip] bgp memory" commands. */
13649 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
13651 /* "show bgp martian next-hop" */
13652 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
13654 /* "show [ip] bgp views" commands. */
13655 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
13657 /* "show [ip] bgp vrfs" commands. */
13658 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
13660 /* Community-list. */
13661 community_list_vty();
13663 /* vpn-policy commands */
13664 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
13665 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
13666 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
13667 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
13668 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
13669 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
13670 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
13671 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
13672 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
13673 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
13674 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
13675 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
13677 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
13678 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
13680 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
13681 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
13682 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
13683 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
13684 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
13685 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
13686 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
13687 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
13688 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13689 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13690 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
13691 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
13694 #include "memory.h"
13695 #include "bgp_regex.h"
13696 #include "bgp_clist.h"
13697 #include "bgp_ecommunity.h"
13699 /* VTY functions. */
13701 /* Direction value to string conversion. */
13702 static const char *community_direct_str(int direct
)
13705 case COMMUNITY_DENY
:
13707 case COMMUNITY_PERMIT
:
13714 /* Display error string. */
13715 static void community_list_perror(struct vty
*vty
, int ret
)
13718 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
13719 vty_out(vty
, "%% Can't find community-list\n");
13721 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
13722 vty_out(vty
, "%% Malformed community-list value\n");
13724 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
13726 "%% Community name conflict, previously defined as standard community\n");
13728 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
13730 "%% Community name conflict, previously defined as expanded community\n");
13735 /* "community-list" keyword help string. */
13736 #define COMMUNITY_LIST_STR "Add a community list entry\n"
13738 /* ip community-list standard */
13739 DEFUN (ip_community_list_standard
,
13740 ip_community_list_standard_cmd
,
13741 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13744 "Community list number (standard)\n"
13745 "Add an standard community-list entry\n"
13746 "Community list name\n"
13747 "Specify community to reject\n"
13748 "Specify community to accept\n"
13751 char *cl_name_or_number
= NULL
;
13753 int style
= COMMUNITY_LIST_STANDARD
;
13756 argv_find(argv
, argc
, "(1-99)", &idx
);
13757 argv_find(argv
, argc
, "WORD", &idx
);
13758 cl_name_or_number
= argv
[idx
]->arg
;
13759 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13761 argv_find(argv
, argc
, "AA:NN", &idx
);
13762 char *str
= argv_concat(argv
, argc
, idx
);
13764 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
13767 XFREE(MTYPE_TMP
, str
);
13770 /* Display error string. */
13771 community_list_perror(vty
, ret
);
13772 return CMD_WARNING_CONFIG_FAILED
;
13775 return CMD_SUCCESS
;
13778 DEFUN (no_ip_community_list_standard_all
,
13779 no_ip_community_list_standard_all_cmd
,
13780 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13784 "Community list number (standard)\n"
13785 "Add an standard community-list entry\n"
13786 "Community list name\n"
13787 "Specify community to reject\n"
13788 "Specify community to accept\n"
13791 char *cl_name_or_number
= NULL
;
13793 int style
= COMMUNITY_LIST_STANDARD
;
13796 argv_find(argv
, argc
, "(1-99)", &idx
);
13797 argv_find(argv
, argc
, "WORD", &idx
);
13798 cl_name_or_number
= argv
[idx
]->arg
;
13799 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13801 argv_find(argv
, argc
, "AA:NN", &idx
);
13802 char *str
= argv_concat(argv
, argc
, idx
);
13804 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
13807 XFREE(MTYPE_TMP
, str
);
13810 community_list_perror(vty
, ret
);
13811 return CMD_WARNING_CONFIG_FAILED
;
13814 return CMD_SUCCESS
;
13817 /* ip community-list expanded */
13818 DEFUN (ip_community_list_expanded_all
,
13819 ip_community_list_expanded_all_cmd
,
13820 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13823 "Community list number (expanded)\n"
13824 "Add an expanded community-list entry\n"
13825 "Community list name\n"
13826 "Specify community to reject\n"
13827 "Specify community to accept\n"
13830 char *cl_name_or_number
= NULL
;
13832 int style
= COMMUNITY_LIST_EXPANDED
;
13835 argv_find(argv
, argc
, "(100-500)", &idx
);
13836 argv_find(argv
, argc
, "WORD", &idx
);
13837 cl_name_or_number
= argv
[idx
]->arg
;
13838 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13840 argv_find(argv
, argc
, "AA:NN", &idx
);
13841 char *str
= argv_concat(argv
, argc
, idx
);
13843 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
13846 XFREE(MTYPE_TMP
, str
);
13849 /* Display error string. */
13850 community_list_perror(vty
, ret
);
13851 return CMD_WARNING_CONFIG_FAILED
;
13854 return CMD_SUCCESS
;
13857 DEFUN (no_ip_community_list_expanded_all
,
13858 no_ip_community_list_expanded_all_cmd
,
13859 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13863 "Community list number (expanded)\n"
13864 "Add an expanded community-list entry\n"
13865 "Community list name\n"
13866 "Specify community to reject\n"
13867 "Specify community to accept\n"
13870 char *cl_name_or_number
= NULL
;
13872 int style
= COMMUNITY_LIST_EXPANDED
;
13875 argv_find(argv
, argc
, "(100-500)", &idx
);
13876 argv_find(argv
, argc
, "WORD", &idx
);
13877 cl_name_or_number
= argv
[idx
]->arg
;
13878 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13880 argv_find(argv
, argc
, "AA:NN", &idx
);
13881 char *str
= argv_concat(argv
, argc
, idx
);
13883 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
13886 XFREE(MTYPE_TMP
, str
);
13889 community_list_perror(vty
, ret
);
13890 return CMD_WARNING_CONFIG_FAILED
;
13893 return CMD_SUCCESS
;
13896 /* Return configuration string of community-list entry. */
13897 static const char *community_list_config_str(struct community_entry
*entry
)
13904 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
13905 str
= community_str(entry
->u
.com
, false);
13906 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
13907 str
= lcommunity_str(entry
->u
.lcom
, false);
13909 str
= entry
->config
;
13914 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
13916 struct community_entry
*entry
;
13918 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13919 if (entry
== list
->head
) {
13920 if (all_digit(list
->name
))
13921 vty_out(vty
, "Community %s list %s\n",
13922 entry
->style
== COMMUNITY_LIST_STANDARD
13924 : "(expanded) access",
13927 vty_out(vty
, "Named Community %s list %s\n",
13928 entry
->style
== COMMUNITY_LIST_STANDARD
13934 vty_out(vty
, " %s\n",
13935 community_direct_str(entry
->direct
));
13937 vty_out(vty
, " %s %s\n",
13938 community_direct_str(entry
->direct
),
13939 community_list_config_str(entry
));
13943 DEFUN (show_ip_community_list
,
13944 show_ip_community_list_cmd
,
13945 "show ip community-list",
13948 "List community-list\n")
13950 struct community_list
*list
;
13951 struct community_list_master
*cm
;
13953 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
13955 return CMD_SUCCESS
;
13957 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13958 community_list_show(vty
, list
);
13960 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13961 community_list_show(vty
, list
);
13963 return CMD_SUCCESS
;
13966 DEFUN (show_ip_community_list_arg
,
13967 show_ip_community_list_arg_cmd
,
13968 "show ip community-list <(1-500)|WORD>",
13971 "List community-list\n"
13972 "Community-list number\n"
13973 "Community-list name\n")
13975 int idx_comm_list
= 3;
13976 struct community_list
*list
;
13978 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
13979 COMMUNITY_LIST_MASTER
);
13981 vty_out(vty
, "%% Can't find community-list\n");
13982 return CMD_WARNING
;
13985 community_list_show(vty
, list
);
13987 return CMD_SUCCESS
;
13991 * Large Community code.
13993 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
13994 struct cmd_token
**argv
, int style
,
13995 int reject_all_digit_name
)
14003 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14006 /* All digit name check. */
14008 argv_find(argv
, argc
, "WORD", &idx
);
14009 argv_find(argv
, argc
, "(1-99)", &idx
);
14010 argv_find(argv
, argc
, "(100-500)", &idx
);
14011 cl_name
= argv
[idx
]->arg
;
14012 if (reject_all_digit_name
&& all_digit(cl_name
)) {
14013 vty_out(vty
, "%% Community name cannot have all digits\n");
14014 return CMD_WARNING_CONFIG_FAILED
;
14018 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
14019 argv_find(argv
, argc
, "LINE", &idx
);
14020 /* Concat community string argument. */
14022 str
= argv_concat(argv
, argc
, idx
);
14026 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
14028 /* Free temporary community list string allocated by
14031 XFREE(MTYPE_TMP
, str
);
14034 community_list_perror(vty
, ret
);
14035 return CMD_WARNING_CONFIG_FAILED
;
14037 return CMD_SUCCESS
;
14040 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
14041 struct cmd_token
**argv
, int style
)
14048 argv_find(argv
, argc
, "permit", &idx
);
14049 argv_find(argv
, argc
, "deny", &idx
);
14052 /* Check the list direct. */
14053 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
14054 direct
= COMMUNITY_PERMIT
;
14056 direct
= COMMUNITY_DENY
;
14059 argv_find(argv
, argc
, "LINE", &idx
);
14060 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
14061 /* Concat community string argument. */
14062 str
= argv_concat(argv
, argc
, idx
);
14066 argv_find(argv
, argc
, "(1-99)", &idx
);
14067 argv_find(argv
, argc
, "(100-500)", &idx
);
14068 argv_find(argv
, argc
, "WORD", &idx
);
14070 /* Unset community list. */
14071 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
14074 /* Free temporary community list string allocated by
14077 XFREE(MTYPE_TMP
, str
);
14080 community_list_perror(vty
, ret
);
14081 return CMD_WARNING_CONFIG_FAILED
;
14084 return CMD_SUCCESS
;
14087 /* "large-community-list" keyword help string. */
14088 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
14089 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
14091 DEFUN (ip_lcommunity_list_standard
,
14092 ip_lcommunity_list_standard_cmd
,
14093 "ip large-community-list (1-99) <deny|permit>",
14095 LCOMMUNITY_LIST_STR
14096 "Large Community list number (standard)\n"
14097 "Specify large community to reject\n"
14098 "Specify large community to accept\n")
14100 return lcommunity_list_set_vty(vty
, argc
, argv
,
14101 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14104 DEFUN (ip_lcommunity_list_standard1
,
14105 ip_lcommunity_list_standard1_cmd
,
14106 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
14108 LCOMMUNITY_LIST_STR
14109 "Large Community list number (standard)\n"
14110 "Specify large community to reject\n"
14111 "Specify large community to accept\n"
14112 LCOMMUNITY_VAL_STR
)
14114 return lcommunity_list_set_vty(vty
, argc
, argv
,
14115 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14118 DEFUN (ip_lcommunity_list_expanded
,
14119 ip_lcommunity_list_expanded_cmd
,
14120 "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_set_vty(vty
, argc
, argv
,
14129 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
14132 DEFUN (ip_lcommunity_list_name_standard
,
14133 ip_lcommunity_list_name_standard_cmd
,
14134 "ip large-community-list standard WORD <deny|permit>",
14136 LCOMMUNITY_LIST_STR
14137 "Specify standard large-community-list\n"
14138 "Large Community list name\n"
14139 "Specify large community to reject\n"
14140 "Specify large community to accept\n")
14142 return lcommunity_list_set_vty(vty
, argc
, argv
,
14143 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14146 DEFUN (ip_lcommunity_list_name_standard1
,
14147 ip_lcommunity_list_name_standard1_cmd
,
14148 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
14150 LCOMMUNITY_LIST_STR
14151 "Specify standard large-community-list\n"
14152 "Large Community list name\n"
14153 "Specify large community to reject\n"
14154 "Specify large community to accept\n"
14155 LCOMMUNITY_VAL_STR
)
14157 return lcommunity_list_set_vty(vty
, argc
, argv
,
14158 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14161 DEFUN (ip_lcommunity_list_name_expanded
,
14162 ip_lcommunity_list_name_expanded_cmd
,
14163 "ip large-community-list expanded WORD <deny|permit> LINE...",
14165 LCOMMUNITY_LIST_STR
14166 "Specify expanded large-community-list\n"
14167 "Large Community list name\n"
14168 "Specify large community to reject\n"
14169 "Specify large community to accept\n"
14170 "An ordered list as a regular-expression\n")
14172 return lcommunity_list_set_vty(vty
, argc
, argv
,
14173 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
14176 DEFUN (no_ip_lcommunity_list_standard_all
,
14177 no_ip_lcommunity_list_standard_all_cmd
,
14178 "no ip large-community-list <(1-99)|(100-500)|WORD>",
14181 LCOMMUNITY_LIST_STR
14182 "Large Community list number (standard)\n"
14183 "Large Community list number (expanded)\n"
14184 "Large Community list name\n")
14186 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14187 LARGE_COMMUNITY_LIST_STANDARD
);
14190 DEFUN (no_ip_lcommunity_list_name_expanded_all
,
14191 no_ip_lcommunity_list_name_expanded_all_cmd
,
14192 "no ip large-community-list expanded WORD",
14195 LCOMMUNITY_LIST_STR
14196 "Specify expanded large-community-list\n"
14197 "Large Community list name\n")
14199 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14200 LARGE_COMMUNITY_LIST_EXPANDED
);
14203 DEFUN (no_ip_lcommunity_list_standard
,
14204 no_ip_lcommunity_list_standard_cmd
,
14205 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
14208 LCOMMUNITY_LIST_STR
14209 "Large Community list number (standard)\n"
14210 "Specify large community to reject\n"
14211 "Specify large community to accept\n"
14212 LCOMMUNITY_VAL_STR
)
14214 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14215 LARGE_COMMUNITY_LIST_STANDARD
);
14218 DEFUN (no_ip_lcommunity_list_expanded
,
14219 no_ip_lcommunity_list_expanded_cmd
,
14220 "no ip large-community-list (100-500) <deny|permit> LINE...",
14223 LCOMMUNITY_LIST_STR
14224 "Large Community list number (expanded)\n"
14225 "Specify large community to reject\n"
14226 "Specify large community to accept\n"
14227 "An ordered list as a regular-expression\n")
14229 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14230 LARGE_COMMUNITY_LIST_EXPANDED
);
14233 DEFUN (no_ip_lcommunity_list_name_standard
,
14234 no_ip_lcommunity_list_name_standard_cmd
,
14235 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
14238 LCOMMUNITY_LIST_STR
14239 "Specify standard large-community-list\n"
14240 "Large Community list name\n"
14241 "Specify large community to reject\n"
14242 "Specify large community to accept\n"
14243 LCOMMUNITY_VAL_STR
)
14245 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14246 LARGE_COMMUNITY_LIST_STANDARD
);
14249 DEFUN (no_ip_lcommunity_list_name_expanded
,
14250 no_ip_lcommunity_list_name_expanded_cmd
,
14251 "no ip large-community-list expanded WORD <deny|permit> LINE...",
14254 LCOMMUNITY_LIST_STR
14255 "Specify expanded large-community-list\n"
14256 "Large community list name\n"
14257 "Specify large community to reject\n"
14258 "Specify large community to accept\n"
14259 "An ordered list as a regular-expression\n")
14261 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14262 LARGE_COMMUNITY_LIST_EXPANDED
);
14265 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14267 struct community_entry
*entry
;
14269 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14270 if (entry
== list
->head
) {
14271 if (all_digit(list
->name
))
14272 vty_out(vty
, "Large community %s list %s\n",
14273 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14275 : "(expanded) access",
14279 "Named large community %s list %s\n",
14280 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14286 vty_out(vty
, " %s\n",
14287 community_direct_str(entry
->direct
));
14289 vty_out(vty
, " %s %s\n",
14290 community_direct_str(entry
->direct
),
14291 community_list_config_str(entry
));
14295 DEFUN (show_ip_lcommunity_list
,
14296 show_ip_lcommunity_list_cmd
,
14297 "show ip large-community-list",
14300 "List large-community list\n")
14302 struct community_list
*list
;
14303 struct community_list_master
*cm
;
14305 cm
= community_list_master_lookup(bgp_clist
,
14306 LARGE_COMMUNITY_LIST_MASTER
);
14308 return CMD_SUCCESS
;
14310 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14311 lcommunity_list_show(vty
, list
);
14313 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14314 lcommunity_list_show(vty
, list
);
14316 return CMD_SUCCESS
;
14319 DEFUN (show_ip_lcommunity_list_arg
,
14320 show_ip_lcommunity_list_arg_cmd
,
14321 "show ip large-community-list <(1-500)|WORD>",
14324 "List large-community list\n"
14325 "large-community-list number\n"
14326 "large-community-list name\n")
14328 struct community_list
*list
;
14330 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
,
14331 LARGE_COMMUNITY_LIST_MASTER
);
14333 vty_out(vty
, "%% Can't find extcommunity-list\n");
14334 return CMD_WARNING
;
14337 lcommunity_list_show(vty
, list
);
14339 return CMD_SUCCESS
;
14342 /* "extcommunity-list" keyword help string. */
14343 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
14344 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
14346 DEFUN (ip_extcommunity_list_standard
,
14347 ip_extcommunity_list_standard_cmd
,
14348 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14350 EXTCOMMUNITY_LIST_STR
14351 "Extended Community list number (standard)\n"
14352 "Specify standard extcommunity-list\n"
14353 "Community list name\n"
14354 "Specify community to reject\n"
14355 "Specify community to accept\n"
14356 EXTCOMMUNITY_VAL_STR
)
14358 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14360 char *cl_number_or_name
= NULL
;
14363 argv_find(argv
, argc
, "(1-99)", &idx
);
14364 argv_find(argv
, argc
, "WORD", &idx
);
14365 cl_number_or_name
= argv
[idx
]->arg
;
14366 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14368 argv_find(argv
, argc
, "AA:NN", &idx
);
14369 char *str
= argv_concat(argv
, argc
, idx
);
14371 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14374 XFREE(MTYPE_TMP
, str
);
14377 community_list_perror(vty
, ret
);
14378 return CMD_WARNING_CONFIG_FAILED
;
14381 return CMD_SUCCESS
;
14384 DEFUN (ip_extcommunity_list_name_expanded
,
14385 ip_extcommunity_list_name_expanded_cmd
,
14386 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14388 EXTCOMMUNITY_LIST_STR
14389 "Extended Community list number (expanded)\n"
14390 "Specify expanded extcommunity-list\n"
14391 "Extended Community list name\n"
14392 "Specify community to reject\n"
14393 "Specify community to accept\n"
14394 "An ordered list as a regular-expression\n")
14396 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
14398 char *cl_number_or_name
= NULL
;
14401 argv_find(argv
, argc
, "(100-500)", &idx
);
14402 argv_find(argv
, argc
, "WORD", &idx
);
14403 cl_number_or_name
= argv
[idx
]->arg
;
14404 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14406 argv_find(argv
, argc
, "LINE", &idx
);
14407 char *str
= argv_concat(argv
, argc
, idx
);
14409 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14412 XFREE(MTYPE_TMP
, str
);
14415 community_list_perror(vty
, ret
);
14416 return CMD_WARNING_CONFIG_FAILED
;
14419 return CMD_SUCCESS
;
14422 DEFUN (no_ip_extcommunity_list_standard_all
,
14423 no_ip_extcommunity_list_standard_all_cmd
,
14424 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14427 EXTCOMMUNITY_LIST_STR
14428 "Extended Community list number (standard)\n"
14429 "Specify standard extcommunity-list\n"
14430 "Community list name\n"
14431 "Specify community to reject\n"
14432 "Specify community to accept\n"
14433 EXTCOMMUNITY_VAL_STR
)
14435 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14437 char *cl_number_or_name
= NULL
;
14440 argv_find(argv
, argc
, "(1-99)", &idx
);
14441 argv_find(argv
, argc
, "WORD", &idx
);
14442 cl_number_or_name
= argv
[idx
]->arg
;
14443 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14445 argv_find(argv
, argc
, "AA:NN", &idx
);
14446 char *str
= argv_concat(argv
, argc
, idx
);
14448 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
14451 XFREE(MTYPE_TMP
, str
);
14454 community_list_perror(vty
, ret
);
14455 return CMD_WARNING_CONFIG_FAILED
;
14458 return CMD_SUCCESS
;
14461 DEFUN (no_ip_extcommunity_list_expanded_all
,
14462 no_ip_extcommunity_list_expanded_all_cmd
,
14463 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14466 EXTCOMMUNITY_LIST_STR
14467 "Extended Community list number (expanded)\n"
14468 "Specify expanded extcommunity-list\n"
14469 "Extended Community list name\n"
14470 "Specify community to reject\n"
14471 "Specify community to accept\n"
14472 "An ordered list as a regular-expression\n")
14474 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
14476 char *cl_number_or_name
= NULL
;
14479 argv_find(argv
, argc
, "(100-500)", &idx
);
14480 argv_find(argv
, argc
, "WORD", &idx
);
14481 cl_number_or_name
= argv
[idx
]->arg
;
14482 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14484 argv_find(argv
, argc
, "LINE", &idx
);
14485 char *str
= argv_concat(argv
, argc
, idx
);
14487 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
14490 XFREE(MTYPE_TMP
, str
);
14493 community_list_perror(vty
, ret
);
14494 return CMD_WARNING_CONFIG_FAILED
;
14497 return CMD_SUCCESS
;
14500 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14502 struct community_entry
*entry
;
14504 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14505 if (entry
== list
->head
) {
14506 if (all_digit(list
->name
))
14507 vty_out(vty
, "Extended community %s list %s\n",
14508 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14510 : "(expanded) access",
14514 "Named extended community %s list %s\n",
14515 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14521 vty_out(vty
, " %s\n",
14522 community_direct_str(entry
->direct
));
14524 vty_out(vty
, " %s %s\n",
14525 community_direct_str(entry
->direct
),
14526 community_list_config_str(entry
));
14530 DEFUN (show_ip_extcommunity_list
,
14531 show_ip_extcommunity_list_cmd
,
14532 "show ip extcommunity-list",
14535 "List extended-community list\n")
14537 struct community_list
*list
;
14538 struct community_list_master
*cm
;
14540 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
14542 return CMD_SUCCESS
;
14544 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14545 extcommunity_list_show(vty
, list
);
14547 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14548 extcommunity_list_show(vty
, list
);
14550 return CMD_SUCCESS
;
14553 DEFUN (show_ip_extcommunity_list_arg
,
14554 show_ip_extcommunity_list_arg_cmd
,
14555 "show ip extcommunity-list <(1-500)|WORD>",
14558 "List extended-community list\n"
14559 "Extcommunity-list number\n"
14560 "Extcommunity-list name\n")
14562 int idx_comm_list
= 3;
14563 struct community_list
*list
;
14565 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
14566 EXTCOMMUNITY_LIST_MASTER
);
14568 vty_out(vty
, "%% Can't find extcommunity-list\n");
14569 return CMD_WARNING
;
14572 extcommunity_list_show(vty
, list
);
14574 return CMD_SUCCESS
;
14577 /* Display community-list and extcommunity-list configuration. */
14578 static int community_list_config_write(struct vty
*vty
)
14580 struct community_list
*list
;
14581 struct community_entry
*entry
;
14582 struct community_list_master
*cm
;
14585 /* Community-list. */
14586 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14588 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14589 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14590 vty_out(vty
, "ip community-list %s %s %s\n", list
->name
,
14591 community_direct_str(entry
->direct
),
14592 community_list_config_str(entry
));
14595 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14596 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14597 vty_out(vty
, "ip community-list %s %s %s %s\n",
14598 entry
->style
== COMMUNITY_LIST_STANDARD
14601 list
->name
, community_direct_str(entry
->direct
),
14602 community_list_config_str(entry
));
14606 /* Extcommunity-list. */
14607 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
14609 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14610 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14611 vty_out(vty
, "ip extcommunity-list %s %s %s\n",
14612 list
->name
, community_direct_str(entry
->direct
),
14613 community_list_config_str(entry
));
14616 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14617 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14618 vty_out(vty
, "ip extcommunity-list %s %s %s %s\n",
14619 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14622 list
->name
, community_direct_str(entry
->direct
),
14623 community_list_config_str(entry
));
14628 /* lcommunity-list. */
14629 cm
= community_list_master_lookup(bgp_clist
,
14630 LARGE_COMMUNITY_LIST_MASTER
);
14632 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14633 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14634 vty_out(vty
, "ip large-community-list %s %s %s\n",
14635 list
->name
, community_direct_str(entry
->direct
),
14636 community_list_config_str(entry
));
14639 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14640 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14641 vty_out(vty
, "ip large-community-list %s %s %s %s\n",
14642 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
14645 list
->name
, community_direct_str(entry
->direct
),
14646 community_list_config_str(entry
));
14653 static struct cmd_node community_list_node
= {
14654 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
14657 static void community_list_vty(void)
14659 install_node(&community_list_node
, community_list_config_write
);
14661 /* Community-list. */
14662 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
14663 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
14664 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
14665 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
14666 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
14667 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
14669 /* Extcommunity-list. */
14670 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
14671 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
14672 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
14673 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
14674 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
14675 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
14677 /* Large Community List */
14678 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
14679 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
14680 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
14681 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
14682 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
14683 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
14684 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
14685 install_element(CONFIG_NODE
,
14686 &no_ip_lcommunity_list_name_expanded_all_cmd
);
14687 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
14688 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
14689 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
14690 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
14691 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
14692 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);