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",
7455 static void show_tip_entry(struct hash_backet
*backet
, void *args
)
7457 struct vty
*vty
= (struct vty
*)args
;
7458 struct tip_addr
*tip
= (struct tip_addr
*)backet
->data
;
7460 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7464 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7466 vty_out(vty
, "self nexthop database:\n");
7467 bgp_nexthop_show_address_hash(vty
, bgp
);
7469 vty_out(vty
, "Tunnel-ip database:\n");
7470 hash_iterate(bgp
->tip_hash
,
7471 (void (*)(struct hash_backet
*, void *))show_tip_entry
,
7475 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7476 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7477 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7478 "martian next-hops\n"
7479 "martian next-hop database\n")
7481 struct bgp
*bgp
= NULL
;
7485 /* [<vrf> VIEWVRFNAME] */
7486 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7487 name
= argv
[idx
+ 1]->arg
;
7488 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7490 } else if (argv_find(argv
, argc
, "view", &idx
))
7491 /* [<view> VIEWVRFNAME] */
7492 name
= argv
[idx
+ 1]->arg
;
7494 bgp
= bgp_lookup_by_name(name
);
7496 bgp
= bgp_get_default();
7499 vty_out(vty
, "%% No BGP process is configured\n");
7502 bgp_show_martian_nexthops(vty
, bgp
);
7507 DEFUN (show_bgp_memory
,
7508 show_bgp_memory_cmd
,
7509 "show [ip] bgp memory",
7513 "Global BGP memory statistics\n")
7515 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7516 unsigned long count
;
7518 /* RIB related usage stats */
7519 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7520 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7521 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7522 count
* sizeof(struct bgp_node
)));
7524 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7525 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7526 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7527 count
* sizeof(struct bgp_info
)));
7528 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7529 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7531 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7532 count
* sizeof(struct bgp_info_extra
)));
7534 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7535 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7536 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7537 count
* sizeof(struct bgp_static
)));
7539 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7540 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7541 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7542 count
* sizeof(struct bpacket
)));
7545 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7546 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7547 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7548 count
* sizeof(struct bgp_adj_in
)));
7549 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7550 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7551 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7552 count
* sizeof(struct bgp_adj_out
)));
7554 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7555 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7557 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7558 count
* sizeof(struct bgp_nexthop_cache
)));
7560 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7561 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7563 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7564 count
* sizeof(struct bgp_damp_info
)));
7567 count
= attr_count();
7568 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7569 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7570 count
* sizeof(struct attr
)));
7572 if ((count
= attr_unknown_count()))
7573 vty_out(vty
, "%ld unknown attributes\n", count
);
7575 /* AS_PATH attributes */
7576 count
= aspath_count();
7577 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7578 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7579 count
* sizeof(struct aspath
)));
7581 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7582 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7583 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7584 count
* sizeof(struct assegment
)));
7586 /* Other attributes */
7587 if ((count
= community_count()))
7588 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7589 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7590 count
* sizeof(struct community
)));
7591 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7592 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7593 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7594 count
* sizeof(struct ecommunity
)));
7595 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7597 "%ld BGP large-community entries, using %s of memory\n",
7598 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7599 count
* sizeof(struct lcommunity
)));
7601 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7602 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7603 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7604 count
* sizeof(struct cluster_list
)));
7606 /* Peer related usage */
7607 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7608 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7609 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7610 count
* sizeof(struct peer
)));
7612 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7613 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7614 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7615 count
* sizeof(struct peer_group
)));
7618 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
7619 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
7620 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7621 count
* sizeof(struct hash
)));
7622 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
7623 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
7624 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7625 count
* sizeof(struct hash_backet
)));
7626 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7627 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7628 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7629 count
* sizeof(regex_t
)));
7633 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7635 json_object
*bestpath
= json_object_new_object();
7637 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7638 json_object_string_add(bestpath
, "asPath", "ignore");
7640 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7641 json_object_string_add(bestpath
, "asPath", "confed");
7643 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7644 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7645 json_object_string_add(bestpath
, "multiPathRelax",
7648 json_object_string_add(bestpath
, "multiPathRelax",
7651 json_object_string_add(bestpath
, "multiPathRelax", "false");
7653 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7654 json_object_string_add(bestpath
, "compareRouterId", "true");
7655 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7656 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7657 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7658 json_object_string_add(bestpath
, "med", "confed");
7659 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7660 json_object_string_add(bestpath
, "med",
7661 "missing-as-worst");
7663 json_object_string_add(bestpath
, "med", "true");
7666 json_object_object_add(json
, "bestPath", bestpath
);
7669 /* Show BGP peer's summary information. */
7670 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7671 bool use_json
, json_object
*json
)
7674 struct listnode
*node
, *nnode
;
7675 unsigned int count
= 0, dn_count
= 0;
7676 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7677 char neighbor_buf
[VTY_BUFSIZ
];
7678 int neighbor_col_default_width
= 16;
7680 int max_neighbor_width
= 0;
7682 json_object
*json_peer
= NULL
;
7683 json_object
*json_peers
= NULL
;
7685 /* labeled-unicast routes are installed in the unicast table so in order
7687 * display the correct PfxRcd value we must look at SAFI_UNICAST
7689 if (safi
== SAFI_LABELED_UNICAST
)
7690 pfx_rcd_safi
= SAFI_UNICAST
;
7692 pfx_rcd_safi
= safi
;
7696 json
= json_object_new_object();
7698 json_peers
= json_object_new_object();
7700 /* Loop over all neighbors that will be displayed to determine
7702 * characters are needed for the Neighbor column
7704 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7705 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7708 if (peer
->afc
[afi
][safi
]) {
7709 memset(dn_flag
, '\0', sizeof(dn_flag
));
7710 if (peer_dynamic_neighbor(peer
))
7714 && bgp_flag_check(bgp
,
7715 BGP_FLAG_SHOW_HOSTNAME
))
7716 sprintf(neighbor_buf
, "%s%s(%s) ",
7717 dn_flag
, peer
->hostname
,
7720 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7723 len
= strlen(neighbor_buf
);
7725 if (len
> max_neighbor_width
)
7726 max_neighbor_width
= len
;
7730 /* Originally we displayed the Neighbor column as 16
7731 * characters wide so make that the default
7733 if (max_neighbor_width
< neighbor_col_default_width
)
7734 max_neighbor_width
= neighbor_col_default_width
;
7737 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7738 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7741 if (!peer
->afc
[afi
][safi
])
7746 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7749 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7751 : (int64_t)bgp
->vrf_id
;
7753 /* Usage summary and header */
7755 json_object_string_add(
7757 inet_ntoa(bgp
->router_id
));
7758 json_object_int_add(json
, "as", bgp
->as
);
7759 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7760 json_object_string_add(
7763 == BGP_INSTANCE_TYPE_DEFAULT
)
7768 "BGP router identifier %s, local AS number %u vrf-id %d",
7769 inet_ntoa(bgp
->router_id
), bgp
->as
,
7770 bgp
->vrf_id
== VRF_UNKNOWN
7772 : (int)bgp
->vrf_id
);
7776 if (bgp_update_delay_configured(bgp
)) {
7778 json_object_int_add(
7779 json
, "updateDelayLimit",
7780 bgp
->v_update_delay
);
7782 if (bgp
->v_update_delay
7783 != bgp
->v_establish_wait
)
7784 json_object_int_add(
7786 "updateDelayEstablishWait",
7787 bgp
->v_establish_wait
);
7789 if (bgp_update_delay_active(bgp
)) {
7790 json_object_string_add(
7792 "updateDelayFirstNeighbor",
7793 bgp
->update_delay_begin_time
);
7794 json_object_boolean_true_add(
7796 "updateDelayInProgress");
7798 if (bgp
->update_delay_over
) {
7799 json_object_string_add(
7801 "updateDelayFirstNeighbor",
7802 bgp
->update_delay_begin_time
);
7803 json_object_string_add(
7805 "updateDelayBestpathResumed",
7806 bgp
->update_delay_end_time
);
7807 json_object_string_add(
7809 "updateDelayZebraUpdateResume",
7810 bgp
->update_delay_zebra_resume_time
);
7811 json_object_string_add(
7813 "updateDelayPeerUpdateResume",
7814 bgp
->update_delay_peers_resume_time
);
7819 "Read-only mode update-delay limit: %d seconds\n",
7820 bgp
->v_update_delay
);
7821 if (bgp
->v_update_delay
7822 != bgp
->v_establish_wait
)
7824 " Establish wait: %d seconds\n",
7825 bgp
->v_establish_wait
);
7827 if (bgp_update_delay_active(bgp
)) {
7829 " First neighbor established: %s\n",
7830 bgp
->update_delay_begin_time
);
7832 " Delay in progress\n");
7834 if (bgp
->update_delay_over
) {
7836 " First neighbor established: %s\n",
7837 bgp
->update_delay_begin_time
);
7839 " Best-paths resumed: %s\n",
7840 bgp
->update_delay_end_time
);
7842 " zebra update resumed: %s\n",
7843 bgp
->update_delay_zebra_resume_time
);
7845 " peers update resumed: %s\n",
7846 bgp
->update_delay_peers_resume_time
);
7853 if (bgp_maxmed_onstartup_configured(bgp
)
7854 && bgp
->maxmed_active
)
7855 json_object_boolean_true_add(
7856 json
, "maxMedOnStartup");
7857 if (bgp
->v_maxmed_admin
)
7858 json_object_boolean_true_add(
7859 json
, "maxMedAdministrative");
7861 json_object_int_add(
7862 json
, "tableVersion",
7863 bgp_table_version(bgp
->rib
[afi
][safi
]));
7865 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7866 json_object_int_add(json
, "ribCount", ents
);
7867 json_object_int_add(
7869 ents
* sizeof(struct bgp_node
));
7871 ents
= listcount(bgp
->peer
);
7872 json_object_int_add(json
, "peerCount", ents
);
7873 json_object_int_add(json
, "peerMemory",
7874 ents
* sizeof(struct peer
));
7876 if ((ents
= listcount(bgp
->group
))) {
7877 json_object_int_add(
7878 json
, "peerGroupCount", ents
);
7879 json_object_int_add(
7880 json
, "peerGroupMemory",
7881 ents
* sizeof(struct
7885 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7886 BGP_CONFIG_DAMPENING
))
7887 json_object_boolean_true_add(
7888 json
, "dampeningEnabled");
7890 if (bgp_maxmed_onstartup_configured(bgp
)
7891 && bgp
->maxmed_active
)
7893 "Max-med on-startup active\n");
7894 if (bgp
->v_maxmed_admin
)
7896 "Max-med administrative active\n");
7898 vty_out(vty
, "BGP table version %" PRIu64
"\n",
7899 bgp_table_version(bgp
->rib
[afi
][safi
]));
7901 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7903 "RIB entries %ld, using %s of memory\n",
7905 mtype_memstr(memstrbuf
,
7907 ents
* sizeof(struct
7910 /* Peer related usage */
7911 ents
= listcount(bgp
->peer
);
7912 vty_out(vty
, "Peers %ld, using %s of memory\n",
7915 memstrbuf
, sizeof(memstrbuf
),
7916 ents
* sizeof(struct peer
)));
7918 if ((ents
= listcount(bgp
->group
)))
7920 "Peer groups %ld, using %s of memory\n",
7925 ents
* sizeof(struct
7928 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7929 BGP_CONFIG_DAMPENING
))
7930 vty_out(vty
, "Dampening enabled.\n");
7933 /* Subtract 8 here because 'Neighbor' is
7935 vty_out(vty
, "Neighbor");
7936 vty_out(vty
, "%*s", max_neighbor_width
- 8,
7939 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
7946 json_peer
= json_object_new_object();
7948 if (peer_dynamic_neighbor(peer
)) {
7950 json_object_boolean_true_add(json_peer
,
7955 json_object_string_add(json_peer
, "hostname",
7958 if (peer
->domainname
)
7959 json_object_string_add(json_peer
, "domainname",
7962 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
7963 json_object_int_add(json_peer
, "version", 4);
7964 json_object_int_add(json_peer
, "msgRcvd",
7965 PEER_TOTAL_RX(peer
));
7966 json_object_int_add(json_peer
, "msgSent",
7967 PEER_TOTAL_TX(peer
));
7969 json_object_int_add(json_peer
, "tableVersion",
7970 peer
->version
[afi
][safi
]);
7971 json_object_int_add(json_peer
, "outq",
7973 json_object_int_add(json_peer
, "inq", 0);
7974 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
7975 use_json
, json_peer
);
7976 json_object_int_add(json_peer
, "prefixReceivedCount",
7977 peer
->pcount
[afi
][pfx_rcd_safi
]);
7979 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
7980 json_object_string_add(json_peer
, "state",
7982 else if (peer
->afc_recv
[afi
][safi
])
7983 json_object_string_add(
7985 lookup_msg(bgp_status_msg
, peer
->status
,
7987 else if (CHECK_FLAG(peer
->sflags
,
7988 PEER_STATUS_PREFIX_OVERFLOW
))
7989 json_object_string_add(json_peer
, "state",
7992 json_object_string_add(
7994 lookup_msg(bgp_status_msg
, peer
->status
,
7998 json_object_string_add(json_peer
, "idType",
8000 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8001 json_object_string_add(json_peer
, "idType",
8003 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8004 json_object_string_add(json_peer
, "idType",
8007 json_object_object_add(json_peers
, peer
->host
,
8010 memset(dn_flag
, '\0', sizeof(dn_flag
));
8011 if (peer_dynamic_neighbor(peer
)) {
8017 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8018 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8019 peer
->hostname
, peer
->host
);
8021 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8023 /* pad the neighbor column with spaces */
8024 if (len
< max_neighbor_width
)
8025 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8028 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8029 peer
->as
, PEER_TOTAL_RX(peer
),
8030 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8031 0, peer
->obuf
->count
,
8032 peer_uptime(peer
->uptime
, timebuf
,
8033 BGP_UPTIME_LEN
, 0, NULL
));
8035 if (peer
->status
== Established
)
8036 if (peer
->afc_recv
[afi
][safi
])
8037 vty_out(vty
, " %12ld",
8041 vty_out(vty
, " NoNeg");
8043 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8044 vty_out(vty
, " Idle (Admin)");
8045 else if (CHECK_FLAG(
8047 PEER_STATUS_PREFIX_OVERFLOW
))
8048 vty_out(vty
, " Idle (PfxCt)");
8050 vty_out(vty
, " %12s",
8051 lookup_msg(bgp_status_msg
,
8052 peer
->status
, NULL
));
8059 json_object_object_add(json
, "peers", json_peers
);
8061 json_object_int_add(json
, "totalPeers", count
);
8062 json_object_int_add(json
, "dynamicPeers", dn_count
);
8064 bgp_show_bestpath_json(bgp
, json
);
8066 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8067 json
, JSON_C_TO_STRING_PRETTY
));
8068 json_object_free(json
);
8071 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8073 vty_out(vty
, "No %s neighbor is configured\n",
8074 afi_safi_print(afi
, safi
));
8078 vty_out(vty
, "* - dynamic neighbor\n");
8079 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8080 dn_count
, bgp
->dynamic_neighbors_limit
);
8087 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8088 int safi
, bool use_json
,
8092 int afi_wildcard
= (afi
== AFI_MAX
);
8093 int safi_wildcard
= (safi
== SAFI_MAX
);
8094 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8095 bool nbr_output
= false;
8097 if (use_json
&& is_wildcard
)
8098 vty_out(vty
, "{\n");
8100 afi
= 1; /* AFI_IP */
8101 while (afi
< AFI_MAX
) {
8103 safi
= 1; /* SAFI_UNICAST */
8104 while (safi
< SAFI_MAX
) {
8105 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8109 * So limit output to those afi/safi
8111 * actualy have something interesting in
8115 json
= json_object_new_object();
8118 vty_out(vty
, ",\n");
8122 vty_out(vty
, "\"%s\":",
8126 vty_out(vty
, "\n%s Summary:\n",
8131 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
8143 if (use_json
&& is_wildcard
)
8144 vty_out(vty
, "}\n");
8145 else if (!nbr_output
) {
8147 vty_out(vty
, "{}\n");
8149 vty_out(vty
, "%% No BGP neighbors found\n");
8153 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8154 safi_t safi
, bool use_json
)
8156 struct listnode
*node
, *nnode
;
8158 json_object
*json
= NULL
;
8160 bool nbr_output
= false;
8163 vty_out(vty
, "{\n");
8165 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8168 json
= json_object_new_object();
8171 vty_out(vty
, ",\n");
8175 vty_out(vty
, "\"%s\":",
8176 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8180 vty_out(vty
, "\nInstance %s:\n",
8181 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8185 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
8189 vty_out(vty
, "}\n");
8190 else if (!nbr_output
)
8191 vty_out(vty
, "%% BGP instance not found\n");
8194 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8195 safi_t safi
, bool use_json
)
8200 if (strmatch(name
, "all")) {
8201 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8205 bgp
= bgp_lookup_by_name(name
);
8209 vty_out(vty
, "{}\n");
8212 "%% BGP instance not found\n");
8216 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
8222 bgp
= bgp_get_default();
8225 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
8228 vty_out(vty
, "{}\n");
8230 vty_out(vty
, "%% BGP instance not found\n");
8237 /* `show [ip] bgp summary' commands. */
8238 DEFUN (show_ip_bgp_summary
,
8239 show_ip_bgp_summary_cmd
,
8240 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8244 BGP_INSTANCE_HELP_STR
8246 BGP_SAFI_WITH_LABEL_HELP_STR
8247 "Summary of BGP neighbor status\n"
8251 afi_t afi
= AFI_MAX
;
8252 safi_t safi
= SAFI_MAX
;
8257 if (argv_find(argv
, argc
, "ip", &idx
))
8259 /* [<vrf> VIEWVRFNAME] */
8260 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8261 vrf
= argv
[idx
+ 1]->arg
;
8262 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8264 } else if (argv_find(argv
, argc
, "view", &idx
))
8265 /* [<view> VIEWVRFNAME] */
8266 vrf
= argv
[idx
+ 1]->arg
;
8267 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8268 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8269 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8272 bool uj
= use_json(argc
, argv
);
8274 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8277 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8279 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8280 return "IPv4 Unicast";
8281 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8282 return "IPv4 Multicast";
8283 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8284 return "IPv4 Labeled Unicast";
8285 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8287 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8288 return "IPv4 Encap";
8289 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8290 return "IPv4 Flowspec";
8291 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8292 return "IPv6 Unicast";
8293 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8294 return "IPv6 Multicast";
8295 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8296 return "IPv6 Labeled Unicast";
8297 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8299 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8300 return "IPv6 Encap";
8301 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8302 return "IPv6 Flowspec";
8303 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8304 return "L2VPN EVPN";
8310 * Please note that we have intentionally camelCased
8311 * the return strings here. So if you want
8312 * to use this function, please ensure you
8313 * are doing this within json output
8315 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8317 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8318 return "ipv4Unicast";
8319 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8320 return "ipv4Multicast";
8321 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8322 return "ipv4LabeledUnicast";
8323 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8325 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8327 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8328 return "ipv4Flowspec";
8329 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8330 return "ipv6Unicast";
8331 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8332 return "ipv6Multicast";
8333 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8334 return "ipv6LabeledUnicast";
8335 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8337 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8339 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8340 return "ipv6Flowspec";
8341 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8347 /* Show BGP peer's information. */
8348 enum show_type
{ show_all
, show_peer
};
8350 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8351 afi_t afi
, safi_t safi
,
8352 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8353 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8354 bool use_json
, json_object
*json_pref
)
8357 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8358 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8360 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8361 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8362 json_object_string_add(json_pref
, "sendMode",
8363 "advertisedAndReceived");
8364 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8365 json_object_string_add(json_pref
, "sendMode",
8367 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8368 json_object_string_add(json_pref
, "sendMode",
8371 vty_out(vty
, " Send-mode: ");
8372 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8373 vty_out(vty
, "advertised");
8374 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8375 vty_out(vty
, "%sreceived",
8376 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8385 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8386 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8388 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8389 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8390 json_object_string_add(json_pref
, "recvMode",
8391 "advertisedAndReceived");
8392 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8393 json_object_string_add(json_pref
, "recvMode",
8395 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8396 json_object_string_add(json_pref
, "recvMode",
8399 vty_out(vty
, " Receive-mode: ");
8400 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8401 vty_out(vty
, "advertised");
8402 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8403 vty_out(vty
, "%sreceived",
8404 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8413 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8414 safi_t safi
, bool use_json
,
8415 json_object
*json_neigh
)
8417 struct bgp_filter
*filter
;
8418 struct peer_af
*paf
;
8419 char orf_pfx_name
[BUFSIZ
];
8421 json_object
*json_af
= NULL
;
8422 json_object
*json_prefA
= NULL
;
8423 json_object
*json_prefB
= NULL
;
8424 json_object
*json_addr
= NULL
;
8427 json_addr
= json_object_new_object();
8428 json_af
= json_object_new_object();
8429 filter
= &p
->filter
[afi
][safi
];
8431 if (peer_group_active(p
))
8432 json_object_string_add(json_addr
, "peerGroupMember",
8435 paf
= peer_af_find(p
, afi
, safi
);
8436 if (paf
&& PAF_SUBGRP(paf
)) {
8437 json_object_int_add(json_addr
, "updateGroupId",
8438 PAF_UPDGRP(paf
)->id
);
8439 json_object_int_add(json_addr
, "subGroupId",
8440 PAF_SUBGRP(paf
)->id
);
8441 json_object_int_add(json_addr
, "packetQueueLength",
8442 bpacket_queue_virtual_length(paf
));
8445 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8446 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8447 PEER_CAP_ORF_PREFIX_SM_RCV
)
8448 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8449 PEER_CAP_ORF_PREFIX_RM_ADV
)
8450 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8451 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8452 json_object_int_add(json_af
, "orfType",
8454 json_prefA
= json_object_new_object();
8455 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8456 PEER_CAP_ORF_PREFIX_SM_ADV
,
8457 PEER_CAP_ORF_PREFIX_RM_ADV
,
8458 PEER_CAP_ORF_PREFIX_SM_RCV
,
8459 PEER_CAP_ORF_PREFIX_RM_RCV
,
8460 use_json
, json_prefA
);
8461 json_object_object_add(json_af
, "orfPrefixList",
8465 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8466 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8467 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8468 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8469 PEER_CAP_ORF_PREFIX_RM_ADV
)
8470 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8471 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8472 json_object_int_add(json_af
, "orfOldType",
8473 ORF_TYPE_PREFIX_OLD
);
8474 json_prefB
= json_object_new_object();
8475 bgp_show_peer_afi_orf_cap(
8476 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8477 PEER_CAP_ORF_PREFIX_RM_ADV
,
8478 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8479 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8481 json_object_object_add(json_af
, "orfOldPrefixList",
8485 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8486 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8487 PEER_CAP_ORF_PREFIX_SM_RCV
)
8488 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8489 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8490 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8491 PEER_CAP_ORF_PREFIX_RM_ADV
)
8492 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8493 PEER_CAP_ORF_PREFIX_RM_RCV
)
8494 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8495 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8496 json_object_object_add(json_addr
, "afDependentCap",
8499 json_object_free(json_af
);
8501 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8502 orf_pfx_count
= prefix_bgp_show_prefix_list(
8503 NULL
, afi
, orf_pfx_name
, use_json
);
8505 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8506 PEER_STATUS_ORF_PREFIX_SEND
)
8508 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8509 PEER_STATUS_ORF_PREFIX_SEND
))
8510 json_object_boolean_true_add(json_neigh
,
8513 json_object_int_add(json_addr
, "orfRecvCounter",
8516 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8517 PEER_STATUS_ORF_WAIT_REFRESH
))
8518 json_object_string_add(
8519 json_addr
, "orfFirstUpdate",
8520 "deferredUntilORFOrRouteRefreshRecvd");
8522 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8523 PEER_FLAG_REFLECTOR_CLIENT
))
8524 json_object_boolean_true_add(json_addr
,
8525 "routeReflectorClient");
8526 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8527 PEER_FLAG_RSERVER_CLIENT
))
8528 json_object_boolean_true_add(json_addr
,
8529 "routeServerClient");
8530 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8531 json_object_boolean_true_add(json_addr
,
8532 "inboundSoftConfigPermit");
8534 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8535 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8536 json_object_boolean_true_add(
8538 "privateAsNumsAllReplacedInUpdatesToNbr");
8539 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8540 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8541 json_object_boolean_true_add(
8543 "privateAsNumsReplacedInUpdatesToNbr");
8544 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8545 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8546 json_object_boolean_true_add(
8548 "privateAsNumsAllRemovedInUpdatesToNbr");
8549 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8550 PEER_FLAG_REMOVE_PRIVATE_AS
))
8551 json_object_boolean_true_add(
8553 "privateAsNumsRemovedInUpdatesToNbr");
8555 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8556 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
8557 json_object_boolean_true_add(json_addr
,
8558 "addpathTxAllPaths");
8560 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8561 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
8562 json_object_boolean_true_add(json_addr
,
8563 "addpathTxBestpathPerAS");
8565 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8566 json_object_string_add(json_addr
,
8567 "overrideASNsInOutboundUpdates",
8568 "ifAspathEqualRemoteAs");
8570 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8571 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8572 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8573 json_object_boolean_true_add(json_addr
,
8574 "routerAlwaysNextHop");
8575 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8576 PEER_FLAG_AS_PATH_UNCHANGED
))
8577 json_object_boolean_true_add(
8578 json_addr
, "unchangedAsPathPropogatedToNbr");
8579 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8580 PEER_FLAG_NEXTHOP_UNCHANGED
))
8581 json_object_boolean_true_add(
8582 json_addr
, "unchangedNextHopPropogatedToNbr");
8583 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8584 json_object_boolean_true_add(
8585 json_addr
, "unchangedMedPropogatedToNbr");
8586 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8587 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8588 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8589 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8590 PEER_FLAG_SEND_COMMUNITY
)
8591 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8592 PEER_FLAG_SEND_EXT_COMMUNITY
))
8593 json_object_string_add(json_addr
,
8594 "commAttriSentToNbr",
8595 "extendedAndStandard");
8596 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8597 PEER_FLAG_SEND_EXT_COMMUNITY
))
8598 json_object_string_add(json_addr
,
8599 "commAttriSentToNbr",
8602 json_object_string_add(json_addr
,
8603 "commAttriSentToNbr",
8606 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8607 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8608 if (p
->default_rmap
[afi
][safi
].name
)
8609 json_object_string_add(
8610 json_addr
, "defaultRouteMap",
8611 p
->default_rmap
[afi
][safi
].name
);
8613 if (paf
&& PAF_SUBGRP(paf
)
8614 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8615 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8616 json_object_boolean_true_add(json_addr
,
8619 json_object_boolean_true_add(json_addr
,
8623 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8624 if (is_evpn_enabled())
8625 json_object_boolean_true_add(
8626 json_addr
, "advertiseAllVnis");
8629 if (filter
->plist
[FILTER_IN
].name
8630 || filter
->dlist
[FILTER_IN
].name
8631 || filter
->aslist
[FILTER_IN
].name
8632 || filter
->map
[RMAP_IN
].name
)
8633 json_object_boolean_true_add(json_addr
,
8634 "inboundPathPolicyConfig");
8635 if (filter
->plist
[FILTER_OUT
].name
8636 || filter
->dlist
[FILTER_OUT
].name
8637 || filter
->aslist
[FILTER_OUT
].name
8638 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8639 json_object_boolean_true_add(
8640 json_addr
, "outboundPathPolicyConfig");
8643 if (filter
->plist
[FILTER_IN
].name
)
8644 json_object_string_add(json_addr
,
8645 "incomingUpdatePrefixFilterList",
8646 filter
->plist
[FILTER_IN
].name
);
8647 if (filter
->plist
[FILTER_OUT
].name
)
8648 json_object_string_add(json_addr
,
8649 "outgoingUpdatePrefixFilterList",
8650 filter
->plist
[FILTER_OUT
].name
);
8652 /* distribute-list */
8653 if (filter
->dlist
[FILTER_IN
].name
)
8654 json_object_string_add(
8655 json_addr
, "incomingUpdateNetworkFilterList",
8656 filter
->dlist
[FILTER_IN
].name
);
8657 if (filter
->dlist
[FILTER_OUT
].name
)
8658 json_object_string_add(
8659 json_addr
, "outgoingUpdateNetworkFilterList",
8660 filter
->dlist
[FILTER_OUT
].name
);
8663 if (filter
->aslist
[FILTER_IN
].name
)
8664 json_object_string_add(json_addr
,
8665 "incomingUpdateAsPathFilterList",
8666 filter
->aslist
[FILTER_IN
].name
);
8667 if (filter
->aslist
[FILTER_OUT
].name
)
8668 json_object_string_add(json_addr
,
8669 "outgoingUpdateAsPathFilterList",
8670 filter
->aslist
[FILTER_OUT
].name
);
8673 if (filter
->map
[RMAP_IN
].name
)
8674 json_object_string_add(
8675 json_addr
, "routeMapForIncomingAdvertisements",
8676 filter
->map
[RMAP_IN
].name
);
8677 if (filter
->map
[RMAP_OUT
].name
)
8678 json_object_string_add(
8679 json_addr
, "routeMapForOutgoingAdvertisements",
8680 filter
->map
[RMAP_OUT
].name
);
8682 /* unsuppress-map */
8683 if (filter
->usmap
.name
)
8684 json_object_string_add(json_addr
,
8685 "selectiveUnsuppressRouteMap",
8686 filter
->usmap
.name
);
8688 /* Receive prefix count */
8689 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8690 p
->pcount
[afi
][safi
]);
8692 /* Maximum prefix */
8693 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8694 json_object_int_add(json_addr
, "prefixAllowedMax",
8695 p
->pmax
[afi
][safi
]);
8696 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8697 PEER_FLAG_MAX_PREFIX_WARNING
))
8698 json_object_boolean_true_add(
8699 json_addr
, "prefixAllowedMaxWarning");
8700 json_object_int_add(json_addr
,
8701 "prefixAllowedWarningThresh",
8702 p
->pmax_threshold
[afi
][safi
]);
8703 if (p
->pmax_restart
[afi
][safi
])
8704 json_object_int_add(
8706 "prefixAllowedRestartIntervalMsecs",
8707 p
->pmax_restart
[afi
][safi
] * 60000);
8709 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8713 filter
= &p
->filter
[afi
][safi
];
8715 vty_out(vty
, " For address family: %s\n",
8716 afi_safi_print(afi
, safi
));
8718 if (peer_group_active(p
))
8719 vty_out(vty
, " %s peer-group member\n",
8722 paf
= peer_af_find(p
, afi
, safi
);
8723 if (paf
&& PAF_SUBGRP(paf
)) {
8724 vty_out(vty
, " Update group %" PRIu64
8725 ", subgroup %" PRIu64
"\n",
8726 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8727 vty_out(vty
, " Packet Queue length %d\n",
8728 bpacket_queue_virtual_length(paf
));
8730 vty_out(vty
, " Not part of any update group\n");
8732 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8733 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8734 PEER_CAP_ORF_PREFIX_SM_RCV
)
8735 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8736 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8737 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8738 PEER_CAP_ORF_PREFIX_RM_ADV
)
8739 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8740 PEER_CAP_ORF_PREFIX_RM_RCV
)
8741 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8742 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8743 vty_out(vty
, " AF-dependant capabilities:\n");
8745 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8746 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8747 PEER_CAP_ORF_PREFIX_SM_RCV
)
8748 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8749 PEER_CAP_ORF_PREFIX_RM_ADV
)
8750 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8751 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8753 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8755 bgp_show_peer_afi_orf_cap(
8756 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8757 PEER_CAP_ORF_PREFIX_RM_ADV
,
8758 PEER_CAP_ORF_PREFIX_SM_RCV
,
8759 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8761 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8762 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8763 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8764 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8765 PEER_CAP_ORF_PREFIX_RM_ADV
)
8766 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8767 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8769 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8770 ORF_TYPE_PREFIX_OLD
);
8771 bgp_show_peer_afi_orf_cap(
8772 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8773 PEER_CAP_ORF_PREFIX_RM_ADV
,
8774 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8775 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8778 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8779 orf_pfx_count
= prefix_bgp_show_prefix_list(
8780 NULL
, afi
, orf_pfx_name
, use_json
);
8782 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8783 PEER_STATUS_ORF_PREFIX_SEND
)
8785 vty_out(vty
, " Outbound Route Filter (ORF):");
8786 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8787 PEER_STATUS_ORF_PREFIX_SEND
))
8788 vty_out(vty
, " sent;");
8790 vty_out(vty
, " received (%d entries)",
8794 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8795 PEER_STATUS_ORF_WAIT_REFRESH
))
8797 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
8799 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8800 PEER_FLAG_REFLECTOR_CLIENT
))
8801 vty_out(vty
, " Route-Reflector Client\n");
8802 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8803 PEER_FLAG_RSERVER_CLIENT
))
8804 vty_out(vty
, " Route-Server Client\n");
8805 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8807 " Inbound soft reconfiguration allowed\n");
8809 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8810 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8812 " Private AS numbers (all) replaced in updates to this neighbor\n");
8813 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8814 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8816 " Private AS numbers replaced in updates to this neighbor\n");
8817 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8818 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8820 " Private AS numbers (all) removed in updates to this neighbor\n");
8821 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8822 PEER_FLAG_REMOVE_PRIVATE_AS
))
8824 " Private AS numbers removed in updates to this neighbor\n");
8826 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8827 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
8828 vty_out(vty
, " Advertise all paths via addpath\n");
8830 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8831 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
8833 " Advertise bestpath per AS via addpath\n");
8835 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8837 " Override ASNs in outbound updates if aspath equals remote-as\n");
8839 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8840 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8841 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8842 vty_out(vty
, " NEXT_HOP is always this router\n");
8843 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8844 PEER_FLAG_AS_PATH_UNCHANGED
))
8846 " AS_PATH is propagated unchanged to this neighbor\n");
8847 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8848 PEER_FLAG_NEXTHOP_UNCHANGED
))
8850 " NEXT_HOP is propagated unchanged to this neighbor\n");
8851 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8853 " MED is propagated unchanged to this neighbor\n");
8854 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8855 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8856 PEER_FLAG_SEND_EXT_COMMUNITY
)
8857 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8858 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
8860 " Community attribute sent to this neighbor");
8861 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8862 PEER_FLAG_SEND_COMMUNITY
)
8863 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8864 PEER_FLAG_SEND_EXT_COMMUNITY
)
8865 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8866 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8867 vty_out(vty
, "(all)\n");
8868 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8869 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8870 vty_out(vty
, "(large)\n");
8871 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8872 PEER_FLAG_SEND_EXT_COMMUNITY
))
8873 vty_out(vty
, "(extended)\n");
8875 vty_out(vty
, "(standard)\n");
8877 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8878 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8879 vty_out(vty
, " Default information originate,");
8881 if (p
->default_rmap
[afi
][safi
].name
)
8882 vty_out(vty
, " default route-map %s%s,",
8883 p
->default_rmap
[afi
][safi
].map
? "*"
8885 p
->default_rmap
[afi
][safi
].name
);
8886 if (paf
&& PAF_SUBGRP(paf
)
8887 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8888 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8889 vty_out(vty
, " default sent\n");
8891 vty_out(vty
, " default not sent\n");
8894 /* advertise-vni-all */
8895 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8896 if (is_evpn_enabled())
8897 vty_out(vty
, " advertise-all-vni\n");
8900 if (filter
->plist
[FILTER_IN
].name
8901 || filter
->dlist
[FILTER_IN
].name
8902 || filter
->aslist
[FILTER_IN
].name
8903 || filter
->map
[RMAP_IN
].name
)
8904 vty_out(vty
, " Inbound path policy configured\n");
8905 if (filter
->plist
[FILTER_OUT
].name
8906 || filter
->dlist
[FILTER_OUT
].name
8907 || filter
->aslist
[FILTER_OUT
].name
8908 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8909 vty_out(vty
, " Outbound path policy configured\n");
8912 if (filter
->plist
[FILTER_IN
].name
)
8914 " Incoming update prefix filter list is %s%s\n",
8915 filter
->plist
[FILTER_IN
].plist
? "*" : "",
8916 filter
->plist
[FILTER_IN
].name
);
8917 if (filter
->plist
[FILTER_OUT
].name
)
8919 " Outgoing update prefix filter list is %s%s\n",
8920 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
8921 filter
->plist
[FILTER_OUT
].name
);
8923 /* distribute-list */
8924 if (filter
->dlist
[FILTER_IN
].name
)
8926 " Incoming update network filter list is %s%s\n",
8927 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
8928 filter
->dlist
[FILTER_IN
].name
);
8929 if (filter
->dlist
[FILTER_OUT
].name
)
8931 " Outgoing update network filter list is %s%s\n",
8932 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
8933 filter
->dlist
[FILTER_OUT
].name
);
8936 if (filter
->aslist
[FILTER_IN
].name
)
8938 " Incoming update AS path filter list is %s%s\n",
8939 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
8940 filter
->aslist
[FILTER_IN
].name
);
8941 if (filter
->aslist
[FILTER_OUT
].name
)
8943 " Outgoing update AS path filter list is %s%s\n",
8944 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
8945 filter
->aslist
[FILTER_OUT
].name
);
8948 if (filter
->map
[RMAP_IN
].name
)
8950 " Route map for incoming advertisements is %s%s\n",
8951 filter
->map
[RMAP_IN
].map
? "*" : "",
8952 filter
->map
[RMAP_IN
].name
);
8953 if (filter
->map
[RMAP_OUT
].name
)
8955 " Route map for outgoing advertisements is %s%s\n",
8956 filter
->map
[RMAP_OUT
].map
? "*" : "",
8957 filter
->map
[RMAP_OUT
].name
);
8959 /* unsuppress-map */
8960 if (filter
->usmap
.name
)
8962 " Route map for selective unsuppress is %s%s\n",
8963 filter
->usmap
.map
? "*" : "",
8964 filter
->usmap
.name
);
8966 /* Receive prefix count */
8967 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
8969 /* Maximum prefix */
8970 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8971 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
8973 CHECK_FLAG(p
->af_flags
[afi
][safi
],
8974 PEER_FLAG_MAX_PREFIX_WARNING
)
8977 vty_out(vty
, " Threshold for warning message %d%%",
8978 p
->pmax_threshold
[afi
][safi
]);
8979 if (p
->pmax_restart
[afi
][safi
])
8980 vty_out(vty
, ", restart interval %d min",
8981 p
->pmax_restart
[afi
][safi
]);
8989 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
8993 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
8994 char timebuf
[BGP_UPTIME_LEN
];
8996 const char *subcode_str
;
8997 const char *code_str
;
9002 json_object
*json_neigh
= NULL
;
9008 json_neigh
= json_object_new_object();
9010 memset(dn_flag
, '\0', sizeof(dn_flag
));
9011 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9015 if (p
->conf_if
) /* Configured interface name. */
9016 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9017 BGP_PEER_SU_UNSPEC(p
)
9019 : sockunion2str(&p
->su
, buf
,
9021 else /* Configured IP address. */
9022 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9027 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9028 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9030 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9031 json_object_string_add(
9032 json_neigh
, "bgpNeighborAddr",
9033 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9035 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9037 if (p
->change_local_as
)
9038 json_object_int_add(json_neigh
, "localAs",
9039 p
->change_local_as
);
9041 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9043 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9044 json_object_boolean_true_add(json_neigh
,
9045 "localAsNoPrepend");
9047 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9048 json_object_boolean_true_add(json_neigh
,
9049 "localAsReplaceAs");
9051 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9052 || (p
->as_type
== AS_INTERNAL
))
9053 vty_out(vty
, "remote AS %u, ", p
->as
);
9055 vty_out(vty
, "remote AS Unspecified, ");
9056 vty_out(vty
, "local AS %u%s%s, ",
9057 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9058 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9061 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9065 /* peer type internal, external, confed-internal or confed-external */
9066 if (p
->as
== p
->local_as
) {
9068 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9069 json_object_boolean_true_add(
9070 json_neigh
, "nbrConfedInternalLink");
9072 json_object_boolean_true_add(json_neigh
,
9075 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9076 vty_out(vty
, "confed-internal link\n");
9078 vty_out(vty
, "internal link\n");
9082 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9083 json_object_boolean_true_add(
9084 json_neigh
, "nbrConfedExternalLink");
9086 json_object_boolean_true_add(json_neigh
,
9089 if (bgp_confederation_peers_check(bgp
, p
->as
))
9090 vty_out(vty
, "confed-external link\n");
9092 vty_out(vty
, "external link\n");
9099 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9101 vty_out(vty
, " Description: %s\n", p
->desc
);
9107 json_object_string_add(json_neigh
, "hostname",
9111 json_object_string_add(json_neigh
, "domainname",
9114 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9115 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9118 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9125 json_object_string_add(json_neigh
, "peerGroup",
9129 struct prefix prefix
, *range
= NULL
;
9131 sockunion2hostprefix(&(p
->su
), &prefix
);
9132 range
= peer_group_lookup_dynamic_neighbor_range(
9136 prefix2str(range
, buf1
, sizeof(buf1
));
9137 json_object_string_add(
9139 "peerSubnetRangeGroup", buf1
);
9144 " Member of peer-group %s for session parameters\n",
9148 struct prefix prefix
, *range
= NULL
;
9150 sockunion2hostprefix(&(p
->su
), &prefix
);
9151 range
= peer_group_lookup_dynamic_neighbor_range(
9155 prefix2str(range
, buf1
, sizeof(buf1
));
9157 " Belongs to the subnet range group: %s\n",
9165 /* Administrative shutdown. */
9166 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9167 json_object_boolean_true_add(json_neigh
,
9171 json_object_int_add(json_neigh
, "bgpVersion", 4);
9172 json_object_string_add(
9173 json_neigh
, "remoteRouterId",
9174 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9175 json_object_string_add(
9176 json_neigh
, "localRouterId",
9177 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9181 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9182 && bgp_confederation_peers_check(bgp
, p
->as
))
9183 json_object_boolean_true_add(json_neigh
,
9187 json_object_string_add(
9188 json_neigh
, "bgpState",
9189 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9191 if (p
->status
== Established
) {
9194 uptime
= bgp_clock();
9195 uptime
-= p
->uptime
;
9196 epoch_tbuf
= time(NULL
) - uptime
;
9198 #if CONFDATE > 20200101
9200 "bgpTimerUp should be deprecated and can be removed now");
9203 * bgpTimerUp was miliseconds that was accurate
9204 * up to 1 day, then the value returned
9205 * became garbage. So in order to provide
9206 * some level of backwards compatability,
9207 * we still provde the data, but now
9208 * we are returning the correct value
9209 * and also adding a new bgpTimerUpMsec
9210 * which will allow us to deprecate
9213 json_object_int_add(json_neigh
, "bgpTimerUp",
9215 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9217 json_object_string_add(json_neigh
, "bgpTimerUpString",
9218 peer_uptime(p
->uptime
, timebuf
,
9221 json_object_int_add(json_neigh
,
9222 "bgpTimerUpEstablishedEpoch",
9226 else if (p
->status
== Active
) {
9227 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9228 json_object_string_add(json_neigh
, "bgpStateIs",
9230 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9231 json_object_string_add(json_neigh
, "bgpStateIs",
9239 uptime
= bgp_clock();
9240 uptime
-= p
->readtime
;
9241 tm
= gmtime(&uptime
);
9242 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9243 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9244 + (tm
->tm_hour
* 3600000));
9246 uptime
= bgp_clock();
9247 uptime
-= p
->last_write
;
9248 tm
= gmtime(&uptime
);
9249 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9250 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9251 + (tm
->tm_hour
* 3600000));
9253 uptime
= bgp_clock();
9254 uptime
-= p
->update_time
;
9255 tm
= gmtime(&uptime
);
9256 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9257 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9258 + (tm
->tm_hour
* 3600000));
9260 /* Configured timer values. */
9261 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9262 p
->v_holdtime
* 1000);
9263 json_object_int_add(json_neigh
,
9264 "bgpTimerKeepAliveIntervalMsecs",
9265 p
->v_keepalive
* 1000);
9266 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9267 json_object_int_add(json_neigh
,
9268 "bgpTimerConfiguredHoldTimeMsecs",
9269 p
->holdtime
* 1000);
9270 json_object_int_add(
9272 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9273 p
->keepalive
* 1000);
9274 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9275 || (bgp
->default_keepalive
9276 != BGP_DEFAULT_KEEPALIVE
)) {
9277 json_object_int_add(json_neigh
,
9278 "bgpTimerConfiguredHoldTimeMsecs",
9279 bgp
->default_holdtime
);
9280 json_object_int_add(
9282 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9283 bgp
->default_keepalive
);
9286 /* Administrative shutdown. */
9287 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9288 vty_out(vty
, " Administratively shut down\n");
9291 vty_out(vty
, " BGP version 4");
9292 vty_out(vty
, ", remote router ID %s",
9293 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9294 vty_out(vty
, ", local router ID %s\n",
9295 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9299 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9300 && bgp_confederation_peers_check(bgp
, p
->as
))
9302 " Neighbor under common administration\n");
9305 vty_out(vty
, " BGP state = %s",
9306 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9308 if (p
->status
== Established
)
9309 vty_out(vty
, ", up for %8s",
9310 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9313 else if (p
->status
== Active
) {
9314 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9315 vty_out(vty
, " (passive)");
9316 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9317 vty_out(vty
, " (NSF passive)");
9322 vty_out(vty
, " Last read %s",
9323 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9325 vty_out(vty
, ", Last write %s\n",
9326 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9329 /* Configured timer values. */
9331 " Hold time is %d, keepalive interval is %d seconds\n",
9332 p
->v_holdtime
, p
->v_keepalive
);
9333 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9334 vty_out(vty
, " Configured hold time is %d",
9336 vty_out(vty
, ", keepalive interval is %d seconds\n",
9338 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9339 || (bgp
->default_keepalive
9340 != BGP_DEFAULT_KEEPALIVE
)) {
9341 vty_out(vty
, " Configured hold time is %d",
9342 bgp
->default_holdtime
);
9343 vty_out(vty
, ", keepalive interval is %d seconds\n",
9344 bgp
->default_keepalive
);
9348 if (p
->status
== Established
) {
9349 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9350 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9351 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9352 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9353 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9354 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9355 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9356 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9357 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9358 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9359 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9360 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9361 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9362 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9363 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9364 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9365 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9366 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9367 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9368 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9370 json_object
*json_cap
= NULL
;
9372 json_cap
= json_object_new_object();
9375 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9376 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9377 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9378 && CHECK_FLAG(p
->cap
,
9380 json_object_string_add(
9381 json_cap
, "4byteAs",
9382 "advertisedAndReceived");
9383 else if (CHECK_FLAG(p
->cap
,
9385 json_object_string_add(
9386 json_cap
, "4byteAs",
9388 else if (CHECK_FLAG(p
->cap
,
9390 json_object_string_add(
9391 json_cap
, "4byteAs",
9396 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9397 || CHECK_FLAG(p
->cap
,
9398 PEER_CAP_ADDPATH_ADV
)) {
9399 json_object
*json_add
= NULL
;
9400 const char *print_store
;
9402 json_add
= json_object_new_object();
9404 FOREACH_AFI_SAFI (afi
, safi
) {
9405 json_object
*json_sub
= NULL
;
9407 json_object_new_object();
9408 print_store
= afi_safi_print(
9414 PEER_CAP_ADDPATH_AF_TX_ADV
)
9418 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9423 PEER_CAP_ADDPATH_AF_TX_ADV
)
9428 PEER_CAP_ADDPATH_AF_TX_RCV
))
9429 json_object_boolean_true_add(
9431 "txAdvertisedAndReceived");
9437 PEER_CAP_ADDPATH_AF_TX_ADV
))
9438 json_object_boolean_true_add(
9446 PEER_CAP_ADDPATH_AF_TX_RCV
))
9447 json_object_boolean_true_add(
9455 PEER_CAP_ADDPATH_AF_RX_ADV
)
9459 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9464 PEER_CAP_ADDPATH_AF_RX_ADV
)
9469 PEER_CAP_ADDPATH_AF_RX_RCV
))
9470 json_object_boolean_true_add(
9472 "rxAdvertisedAndReceived");
9478 PEER_CAP_ADDPATH_AF_RX_ADV
))
9479 json_object_boolean_true_add(
9487 PEER_CAP_ADDPATH_AF_RX_RCV
))
9488 json_object_boolean_true_add(
9496 PEER_CAP_ADDPATH_AF_TX_ADV
)
9500 PEER_CAP_ADDPATH_AF_TX_RCV
)
9504 PEER_CAP_ADDPATH_AF_RX_ADV
)
9508 PEER_CAP_ADDPATH_AF_RX_RCV
))
9509 json_object_object_add(
9518 json_object_object_add(
9519 json_cap
, "addPath", json_add
);
9523 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9524 || CHECK_FLAG(p
->cap
,
9525 PEER_CAP_DYNAMIC_ADV
)) {
9526 if (CHECK_FLAG(p
->cap
,
9527 PEER_CAP_DYNAMIC_ADV
)
9528 && CHECK_FLAG(p
->cap
,
9529 PEER_CAP_DYNAMIC_RCV
))
9530 json_object_string_add(
9531 json_cap
, "dynamic",
9532 "advertisedAndReceived");
9533 else if (CHECK_FLAG(
9535 PEER_CAP_DYNAMIC_ADV
))
9536 json_object_string_add(
9537 json_cap
, "dynamic",
9539 else if (CHECK_FLAG(
9541 PEER_CAP_DYNAMIC_RCV
))
9542 json_object_string_add(
9543 json_cap
, "dynamic",
9547 /* Extended nexthop */
9548 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9549 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9550 json_object
*json_nxt
= NULL
;
9551 const char *print_store
;
9554 if (CHECK_FLAG(p
->cap
,
9556 && CHECK_FLAG(p
->cap
,
9558 json_object_string_add(
9561 "advertisedAndReceived");
9562 else if (CHECK_FLAG(p
->cap
,
9564 json_object_string_add(
9568 else if (CHECK_FLAG(p
->cap
,
9570 json_object_string_add(
9575 if (CHECK_FLAG(p
->cap
,
9576 PEER_CAP_ENHE_RCV
)) {
9578 json_object_new_object();
9580 for (safi
= SAFI_UNICAST
;
9581 safi
< SAFI_MAX
; safi
++) {
9586 PEER_CAP_ENHE_AF_RCV
)) {
9587 print_store
= afi_safi_print(
9590 json_object_string_add(
9596 json_object_object_add(
9598 "extendedNexthopFamililesByPeer",
9604 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9605 || CHECK_FLAG(p
->cap
,
9606 PEER_CAP_REFRESH_NEW_RCV
)
9607 || CHECK_FLAG(p
->cap
,
9608 PEER_CAP_REFRESH_OLD_RCV
)) {
9609 if (CHECK_FLAG(p
->cap
,
9610 PEER_CAP_REFRESH_ADV
)
9613 PEER_CAP_REFRESH_NEW_RCV
)
9616 PEER_CAP_REFRESH_OLD_RCV
))) {
9619 PEER_CAP_REFRESH_OLD_RCV
)
9622 PEER_CAP_REFRESH_NEW_RCV
))
9623 json_object_string_add(
9626 "advertisedAndReceivedOldNew");
9630 PEER_CAP_REFRESH_OLD_RCV
))
9631 json_object_string_add(
9634 "advertisedAndReceivedOld");
9636 json_object_string_add(
9639 "advertisedAndReceivedNew");
9644 PEER_CAP_REFRESH_ADV
))
9645 json_object_string_add(
9652 PEER_CAP_REFRESH_NEW_RCV
)
9655 PEER_CAP_REFRESH_OLD_RCV
))
9656 json_object_string_add(
9662 /* Multiprotocol Extensions */
9663 json_object
*json_multi
= NULL
;
9664 json_multi
= json_object_new_object();
9666 FOREACH_AFI_SAFI (afi
, safi
) {
9667 if (p
->afc_adv
[afi
][safi
]
9668 || p
->afc_recv
[afi
][safi
]) {
9669 json_object
*json_exten
= NULL
;
9671 json_object_new_object();
9673 if (p
->afc_adv
[afi
][safi
]
9674 && p
->afc_recv
[afi
][safi
])
9675 json_object_boolean_true_add(
9677 "advertisedAndReceived");
9678 else if (p
->afc_adv
[afi
][safi
])
9679 json_object_boolean_true_add(
9682 else if (p
->afc_recv
[afi
][safi
])
9683 json_object_boolean_true_add(
9687 json_object_object_add(
9694 json_object_object_add(
9695 json_cap
, "multiprotocolExtensions",
9698 /* Hostname capabilities */
9699 json_object
*json_hname
= NULL
;
9701 json_hname
= json_object_new_object();
9703 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9704 json_object_string_add(
9705 json_hname
, "advHostName",
9706 bgp
->peer_self
->hostname
9710 json_object_string_add(
9711 json_hname
, "advDomainName",
9712 bgp
->peer_self
->domainname
9719 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9720 json_object_string_add(
9721 json_hname
, "rcvHostName",
9722 p
->hostname
? p
->hostname
9724 json_object_string_add(
9725 json_hname
, "rcvDomainName",
9726 p
->domainname
? p
->domainname
9730 json_object_object_add(json_cap
, "hostName",
9733 /* Gracefull Restart */
9734 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9735 || CHECK_FLAG(p
->cap
,
9736 PEER_CAP_RESTART_ADV
)) {
9737 if (CHECK_FLAG(p
->cap
,
9738 PEER_CAP_RESTART_ADV
)
9739 && CHECK_FLAG(p
->cap
,
9740 PEER_CAP_RESTART_RCV
))
9741 json_object_string_add(
9744 "advertisedAndReceived");
9745 else if (CHECK_FLAG(
9747 PEER_CAP_RESTART_ADV
))
9748 json_object_string_add(
9750 "gracefulRestartCapability",
9752 else if (CHECK_FLAG(
9754 PEER_CAP_RESTART_RCV
))
9755 json_object_string_add(
9757 "gracefulRestartCapability",
9760 if (CHECK_FLAG(p
->cap
,
9761 PEER_CAP_RESTART_RCV
)) {
9762 int restart_af_count
= 0;
9763 json_object
*json_restart
=
9766 json_object_new_object();
9768 json_object_int_add(
9770 "gracefulRestartRemoteTimerMsecs",
9771 p
->v_gr_restart
* 1000);
9773 FOREACH_AFI_SAFI (afi
, safi
) {
9778 PEER_CAP_RESTART_AF_RCV
)) {
9783 json_object_new_object();
9789 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
9790 json_object_boolean_true_add(
9794 json_object_object_add(
9802 if (!restart_af_count
) {
9803 json_object_string_add(
9805 "addressFamiliesByPeer",
9810 json_object_object_add(
9812 "addressFamiliesByPeer",
9816 json_object_object_add(json_neigh
,
9817 "neighborCapabilities",
9820 vty_out(vty
, " Neighbor capabilities:\n");
9823 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9824 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9825 vty_out(vty
, " 4 Byte AS:");
9826 if (CHECK_FLAG(p
->cap
,
9828 vty_out(vty
, " advertised");
9829 if (CHECK_FLAG(p
->cap
,
9831 vty_out(vty
, " %sreceived",
9841 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9842 || CHECK_FLAG(p
->cap
,
9843 PEER_CAP_ADDPATH_ADV
)) {
9844 vty_out(vty
, " AddPath:\n");
9846 FOREACH_AFI_SAFI (afi
, safi
) {
9850 PEER_CAP_ADDPATH_AF_TX_ADV
)
9854 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9865 PEER_CAP_ADDPATH_AF_TX_ADV
))
9876 PEER_CAP_ADDPATH_AF_TX_RCV
))
9883 PEER_CAP_ADDPATH_AF_TX_ADV
)
9893 PEER_CAP_ADDPATH_AF_RX_ADV
)
9897 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9908 PEER_CAP_ADDPATH_AF_RX_ADV
))
9919 PEER_CAP_ADDPATH_AF_RX_RCV
))
9926 PEER_CAP_ADDPATH_AF_RX_ADV
)
9936 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9937 || CHECK_FLAG(p
->cap
,
9938 PEER_CAP_DYNAMIC_ADV
)) {
9939 vty_out(vty
, " Dynamic:");
9940 if (CHECK_FLAG(p
->cap
,
9941 PEER_CAP_DYNAMIC_ADV
))
9942 vty_out(vty
, " advertised");
9943 if (CHECK_FLAG(p
->cap
,
9944 PEER_CAP_DYNAMIC_RCV
))
9945 vty_out(vty
, " %sreceived",
9948 PEER_CAP_DYNAMIC_ADV
)
9954 /* Extended nexthop */
9955 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9956 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9957 vty_out(vty
, " Extended nexthop:");
9958 if (CHECK_FLAG(p
->cap
,
9960 vty_out(vty
, " advertised");
9961 if (CHECK_FLAG(p
->cap
,
9963 vty_out(vty
, " %sreceived",
9971 if (CHECK_FLAG(p
->cap
,
9972 PEER_CAP_ENHE_RCV
)) {
9974 " Address families by peer:\n ");
9975 for (safi
= SAFI_UNICAST
;
9976 safi
< SAFI_MAX
; safi
++)
9981 PEER_CAP_ENHE_AF_RCV
))
9991 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9992 || CHECK_FLAG(p
->cap
,
9993 PEER_CAP_REFRESH_NEW_RCV
)
9994 || CHECK_FLAG(p
->cap
,
9995 PEER_CAP_REFRESH_OLD_RCV
)) {
9996 vty_out(vty
, " Route refresh:");
9997 if (CHECK_FLAG(p
->cap
,
9998 PEER_CAP_REFRESH_ADV
))
9999 vty_out(vty
, " advertised");
10000 if (CHECK_FLAG(p
->cap
,
10001 PEER_CAP_REFRESH_NEW_RCV
)
10004 PEER_CAP_REFRESH_OLD_RCV
))
10005 vty_out(vty
, " %sreceived(%s)",
10008 PEER_CAP_REFRESH_ADV
)
10013 PEER_CAP_REFRESH_OLD_RCV
)
10016 PEER_CAP_REFRESH_NEW_RCV
))
10020 PEER_CAP_REFRESH_OLD_RCV
)
10024 vty_out(vty
, "\n");
10027 /* Multiprotocol Extensions */
10028 FOREACH_AFI_SAFI (afi
, safi
)
10029 if (p
->afc_adv
[afi
][safi
]
10030 || p
->afc_recv
[afi
][safi
]) {
10032 " Address Family %s:",
10033 afi_safi_print(afi
,
10035 if (p
->afc_adv
[afi
][safi
])
10038 if (p
->afc_recv
[afi
][safi
])
10045 vty_out(vty
, "\n");
10048 /* Hostname capability */
10049 vty_out(vty
, " Hostname Capability:");
10051 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10053 " advertised (name: %s,domain name: %s)",
10054 bgp
->peer_self
->hostname
10058 bgp
->peer_self
->domainname
10063 vty_out(vty
, " not advertised");
10066 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10068 " received (name: %s,domain name: %s)",
10069 p
->hostname
? p
->hostname
10071 p
->domainname
? p
->domainname
10074 vty_out(vty
, " not received");
10077 vty_out(vty
, "\n");
10079 /* Gracefull Restart */
10080 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10081 || CHECK_FLAG(p
->cap
,
10082 PEER_CAP_RESTART_ADV
)) {
10084 " Graceful Restart Capabilty:");
10085 if (CHECK_FLAG(p
->cap
,
10086 PEER_CAP_RESTART_ADV
))
10087 vty_out(vty
, " advertised");
10088 if (CHECK_FLAG(p
->cap
,
10089 PEER_CAP_RESTART_RCV
))
10090 vty_out(vty
, " %sreceived",
10093 PEER_CAP_RESTART_ADV
)
10096 vty_out(vty
, "\n");
10098 if (CHECK_FLAG(p
->cap
,
10099 PEER_CAP_RESTART_RCV
)) {
10100 int restart_af_count
= 0;
10103 " Remote Restart timer is %d seconds\n",
10106 " Address families by peer:\n ");
10108 FOREACH_AFI_SAFI (afi
, safi
)
10113 PEER_CAP_RESTART_AF_RCV
)) {
10126 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10128 : "not preserved");
10129 restart_af_count
++;
10131 if (!restart_af_count
)
10132 vty_out(vty
, "none");
10133 vty_out(vty
, "\n");
10140 /* graceful restart information */
10141 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10142 || p
->t_gr_stale
) {
10143 json_object
*json_grace
= NULL
;
10144 json_object
*json_grace_send
= NULL
;
10145 json_object
*json_grace_recv
= NULL
;
10146 int eor_send_af_count
= 0;
10147 int eor_receive_af_count
= 0;
10150 json_grace
= json_object_new_object();
10151 json_grace_send
= json_object_new_object();
10152 json_grace_recv
= json_object_new_object();
10154 if (p
->status
== Established
) {
10155 FOREACH_AFI_SAFI (afi
, safi
) {
10156 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10157 PEER_STATUS_EOR_SEND
)) {
10158 json_object_boolean_true_add(
10160 afi_safi_print(afi
,
10162 eor_send_af_count
++;
10165 FOREACH_AFI_SAFI (afi
, safi
) {
10167 p
->af_sflags
[afi
][safi
],
10168 PEER_STATUS_EOR_RECEIVED
)) {
10169 json_object_boolean_true_add(
10171 afi_safi_print(afi
,
10173 eor_receive_af_count
++;
10178 json_object_object_add(json_grace
, "endOfRibSend",
10180 json_object_object_add(json_grace
, "endOfRibRecv",
10183 if (p
->t_gr_restart
)
10184 json_object_int_add(json_grace
,
10185 "gracefulRestartTimerMsecs",
10186 thread_timer_remain_second(
10191 json_object_int_add(
10193 "gracefulStalepathTimerMsecs",
10194 thread_timer_remain_second(
10198 json_object_object_add(
10199 json_neigh
, "gracefulRestartInfo", json_grace
);
10201 vty_out(vty
, " Graceful restart informations:\n");
10202 if (p
->status
== Established
) {
10203 vty_out(vty
, " End-of-RIB send: ");
10204 FOREACH_AFI_SAFI (afi
, safi
) {
10205 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10206 PEER_STATUS_EOR_SEND
)) {
10207 vty_out(vty
, "%s%s",
10208 eor_send_af_count
? ", "
10210 afi_safi_print(afi
,
10212 eor_send_af_count
++;
10215 vty_out(vty
, "\n");
10216 vty_out(vty
, " End-of-RIB received: ");
10217 FOREACH_AFI_SAFI (afi
, safi
) {
10219 p
->af_sflags
[afi
][safi
],
10220 PEER_STATUS_EOR_RECEIVED
)) {
10221 vty_out(vty
, "%s%s",
10222 eor_receive_af_count
10225 afi_safi_print(afi
,
10227 eor_receive_af_count
++;
10230 vty_out(vty
, "\n");
10233 if (p
->t_gr_restart
)
10235 " The remaining time of restart timer is %ld\n",
10236 thread_timer_remain_second(
10241 " The remaining time of stalepath timer is %ld\n",
10242 thread_timer_remain_second(
10247 json_object
*json_stat
= NULL
;
10248 json_stat
= json_object_new_object();
10249 /* Packet counts. */
10250 json_object_int_add(json_stat
, "depthInq", 0);
10251 json_object_int_add(json_stat
, "depthOutq",
10252 (unsigned long)p
->obuf
->count
);
10253 json_object_int_add(json_stat
, "opensSent",
10254 atomic_load_explicit(&p
->open_out
,
10255 memory_order_relaxed
));
10256 json_object_int_add(json_stat
, "opensRecv",
10257 atomic_load_explicit(&p
->open_in
,
10258 memory_order_relaxed
));
10259 json_object_int_add(json_stat
, "notificationsSent",
10260 atomic_load_explicit(&p
->notify_out
,
10261 memory_order_relaxed
));
10262 json_object_int_add(json_stat
, "notificationsRecv",
10263 atomic_load_explicit(&p
->notify_in
,
10264 memory_order_relaxed
));
10265 json_object_int_add(json_stat
, "updatesSent",
10266 atomic_load_explicit(&p
->update_out
,
10267 memory_order_relaxed
));
10268 json_object_int_add(json_stat
, "updatesRecv",
10269 atomic_load_explicit(&p
->update_in
,
10270 memory_order_relaxed
));
10271 json_object_int_add(json_stat
, "keepalivesSent",
10272 atomic_load_explicit(&p
->keepalive_out
,
10273 memory_order_relaxed
));
10274 json_object_int_add(json_stat
, "keepalivesRecv",
10275 atomic_load_explicit(&p
->keepalive_in
,
10276 memory_order_relaxed
));
10277 json_object_int_add(json_stat
, "routeRefreshSent",
10278 atomic_load_explicit(&p
->refresh_out
,
10279 memory_order_relaxed
));
10280 json_object_int_add(json_stat
, "routeRefreshRecv",
10281 atomic_load_explicit(&p
->refresh_in
,
10282 memory_order_relaxed
));
10283 json_object_int_add(json_stat
, "capabilitySent",
10284 atomic_load_explicit(&p
->dynamic_cap_out
,
10285 memory_order_relaxed
));
10286 json_object_int_add(json_stat
, "capabilityRecv",
10287 atomic_load_explicit(&p
->dynamic_cap_in
,
10288 memory_order_relaxed
));
10289 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10290 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10291 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10293 /* Packet counts. */
10294 vty_out(vty
, " Message statistics:\n");
10295 vty_out(vty
, " Inq depth is 0\n");
10296 vty_out(vty
, " Outq depth is %lu\n",
10297 (unsigned long)p
->obuf
->count
);
10298 vty_out(vty
, " Sent Rcvd\n");
10299 vty_out(vty
, " Opens: %10d %10d\n",
10300 atomic_load_explicit(&p
->open_out
,
10301 memory_order_relaxed
),
10302 atomic_load_explicit(&p
->open_in
,
10303 memory_order_relaxed
));
10304 vty_out(vty
, " Notifications: %10d %10d\n",
10305 atomic_load_explicit(&p
->notify_out
,
10306 memory_order_relaxed
),
10307 atomic_load_explicit(&p
->notify_in
,
10308 memory_order_relaxed
));
10309 vty_out(vty
, " Updates: %10d %10d\n",
10310 atomic_load_explicit(&p
->update_out
,
10311 memory_order_relaxed
),
10312 atomic_load_explicit(&p
->update_in
,
10313 memory_order_relaxed
));
10314 vty_out(vty
, " Keepalives: %10d %10d\n",
10315 atomic_load_explicit(&p
->keepalive_out
,
10316 memory_order_relaxed
),
10317 atomic_load_explicit(&p
->keepalive_in
,
10318 memory_order_relaxed
));
10319 vty_out(vty
, " Route Refresh: %10d %10d\n",
10320 atomic_load_explicit(&p
->refresh_out
,
10321 memory_order_relaxed
),
10322 atomic_load_explicit(&p
->refresh_in
,
10323 memory_order_relaxed
));
10324 vty_out(vty
, " Capability: %10d %10d\n",
10325 atomic_load_explicit(&p
->dynamic_cap_out
,
10326 memory_order_relaxed
),
10327 atomic_load_explicit(&p
->dynamic_cap_in
,
10328 memory_order_relaxed
));
10329 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10334 /* advertisement-interval */
10335 json_object_int_add(json_neigh
,
10336 "minBtwnAdvertisementRunsTimerMsecs",
10337 p
->v_routeadv
* 1000);
10339 /* Update-source. */
10340 if (p
->update_if
|| p
->update_source
) {
10342 json_object_string_add(json_neigh
,
10345 else if (p
->update_source
)
10346 json_object_string_add(
10347 json_neigh
, "updateSource",
10348 sockunion2str(p
->update_source
, buf1
,
10352 /* advertisement-interval */
10354 " Minimum time between advertisement runs is %d seconds\n",
10357 /* Update-source. */
10358 if (p
->update_if
|| p
->update_source
) {
10359 vty_out(vty
, " Update source is ");
10361 vty_out(vty
, "%s", p
->update_if
);
10362 else if (p
->update_source
)
10364 sockunion2str(p
->update_source
, buf1
,
10366 vty_out(vty
, "\n");
10369 vty_out(vty
, "\n");
10372 /* Address Family Information */
10373 json_object
*json_hold
= NULL
;
10376 json_hold
= json_object_new_object();
10378 FOREACH_AFI_SAFI (afi
, safi
)
10379 if (p
->afc
[afi
][safi
])
10380 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10384 json_object_object_add(json_neigh
, "addressFamilyInfo",
10386 json_object_int_add(json_neigh
, "connectionsEstablished",
10388 json_object_int_add(json_neigh
, "connectionsDropped",
10391 vty_out(vty
, " Connections established %d; dropped %d\n",
10392 p
->established
, p
->dropped
);
10394 if (!p
->last_reset
) {
10396 json_object_string_add(json_neigh
, "lastReset",
10399 vty_out(vty
, " Last reset never\n");
10405 uptime
= bgp_clock();
10406 uptime
-= p
->resettime
;
10407 tm
= gmtime(&uptime
);
10408 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10409 (tm
->tm_sec
* 1000)
10410 + (tm
->tm_min
* 60000)
10411 + (tm
->tm_hour
* 3600000));
10412 json_object_string_add(
10413 json_neigh
, "lastResetDueTo",
10414 peer_down_str
[(int)p
->last_reset
]);
10415 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10416 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10417 char errorcodesubcode_hexstr
[5];
10418 char errorcodesubcode_str
[256];
10420 code_str
= bgp_notify_code_str(p
->notify
.code
);
10421 subcode_str
= bgp_notify_subcode_str(
10422 p
->notify
.code
, p
->notify
.subcode
);
10424 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10425 p
->notify
.code
, p
->notify
.subcode
);
10426 json_object_string_add(json_neigh
,
10427 "lastErrorCodeSubcode",
10428 errorcodesubcode_hexstr
);
10429 snprintf(errorcodesubcode_str
, 255, "%s%s",
10430 code_str
, subcode_str
);
10431 json_object_string_add(json_neigh
,
10432 "lastNotificationReason",
10433 errorcodesubcode_str
);
10434 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10435 && p
->notify
.code
== BGP_NOTIFY_CEASE
10436 && (p
->notify
.subcode
10437 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10438 || p
->notify
.subcode
10439 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10440 && p
->notify
.length
) {
10442 const char *msg_str
;
10444 msg_str
= bgp_notify_admin_message(
10445 msgbuf
, sizeof(msgbuf
),
10446 (uint8_t *)p
->notify
.data
,
10449 json_object_string_add(
10451 "lastShutdownDescription",
10456 vty_out(vty
, " Last reset %s, ",
10457 peer_uptime(p
->resettime
, timebuf
,
10458 BGP_UPTIME_LEN
, 0, NULL
));
10460 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10461 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10462 code_str
= bgp_notify_code_str(p
->notify
.code
);
10463 subcode_str
= bgp_notify_subcode_str(
10464 p
->notify
.code
, p
->notify
.subcode
);
10465 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10466 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10469 code_str
, subcode_str
);
10470 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10471 && p
->notify
.code
== BGP_NOTIFY_CEASE
10472 && (p
->notify
.subcode
10473 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10474 || p
->notify
.subcode
10475 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10476 && p
->notify
.length
) {
10478 const char *msg_str
;
10480 msg_str
= bgp_notify_admin_message(
10481 msgbuf
, sizeof(msgbuf
),
10482 (uint8_t *)p
->notify
.data
,
10486 " Message: \"%s\"\n",
10490 vty_out(vty
, "due to %s\n",
10491 peer_down_str
[(int)p
->last_reset
]);
10494 if (p
->last_reset_cause_size
) {
10495 msg
= p
->last_reset_cause
;
10497 " Message received that caused BGP to send a NOTIFICATION:\n ");
10498 for (i
= 1; i
<= p
->last_reset_cause_size
;
10500 vty_out(vty
, "%02X", *msg
++);
10502 if (i
!= p
->last_reset_cause_size
) {
10504 vty_out(vty
, "\n ");
10505 } else if (i
% 4 == 0) {
10510 vty_out(vty
, "\n");
10515 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10517 json_object_boolean_true_add(json_neigh
,
10518 "prefixesConfigExceedMax");
10521 " Peer had exceeded the max. no. of prefixes configured.\n");
10523 if (p
->t_pmax_restart
) {
10525 json_object_boolean_true_add(
10526 json_neigh
, "reducePrefixNumFrom");
10527 json_object_int_add(json_neigh
,
10528 "restartInTimerMsec",
10529 thread_timer_remain_second(
10534 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10535 p
->host
, thread_timer_remain_second(
10536 p
->t_pmax_restart
));
10539 json_object_boolean_true_add(
10541 "reducePrefixNumAndClearIpBgp");
10544 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10549 /* EBGP Multihop and GTSM */
10550 if (p
->sort
!= BGP_PEER_IBGP
) {
10552 if (p
->gtsm_hops
> 0)
10553 json_object_int_add(json_neigh
,
10554 "externalBgpNbrMaxHopsAway",
10556 else if (p
->ttl
> 1)
10557 json_object_int_add(json_neigh
,
10558 "externalBgpNbrMaxHopsAway",
10561 if (p
->gtsm_hops
> 0)
10563 " External BGP neighbor may be up to %d hops away.\n",
10565 else if (p
->ttl
> 1)
10567 " External BGP neighbor may be up to %d hops away.\n",
10571 if (p
->gtsm_hops
> 0) {
10573 json_object_int_add(json_neigh
,
10574 "internalBgpNbrMaxHopsAway",
10578 " Internal BGP neighbor may be up to %d hops away.\n",
10583 /* Local address. */
10586 json_object_string_add(json_neigh
, "hostLocal",
10587 sockunion2str(p
->su_local
, buf1
,
10589 json_object_int_add(json_neigh
, "portLocal",
10590 ntohs(p
->su_local
->sin
.sin_port
));
10592 vty_out(vty
, "Local host: %s, Local port: %d\n",
10593 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10594 ntohs(p
->su_local
->sin
.sin_port
));
10597 /* Remote address. */
10598 if (p
->su_remote
) {
10600 json_object_string_add(json_neigh
, "hostForeign",
10601 sockunion2str(p
->su_remote
, buf1
,
10603 json_object_int_add(json_neigh
, "portForeign",
10604 ntohs(p
->su_remote
->sin
.sin_port
));
10606 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10607 sockunion2str(p
->su_remote
, buf1
,
10609 ntohs(p
->su_remote
->sin
.sin_port
));
10612 /* Nexthop display. */
10615 json_object_string_add(json_neigh
, "nexthop",
10617 &p
->nexthop
.v4
, buf1
,
10619 json_object_string_add(json_neigh
, "nexthopGlobal",
10620 inet_ntop(AF_INET6
,
10621 &p
->nexthop
.v6_global
,
10622 buf1
, sizeof(buf1
)));
10623 json_object_string_add(json_neigh
, "nexthopLocal",
10624 inet_ntop(AF_INET6
,
10625 &p
->nexthop
.v6_local
,
10626 buf1
, sizeof(buf1
)));
10627 if (p
->shared_network
)
10628 json_object_string_add(json_neigh
,
10632 json_object_string_add(json_neigh
,
10634 "nonSharedNetwork");
10636 vty_out(vty
, "Nexthop: %s\n",
10637 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10639 vty_out(vty
, "Nexthop global: %s\n",
10640 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10642 vty_out(vty
, "Nexthop local: %s\n",
10643 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10645 vty_out(vty
, "BGP connection: %s\n",
10646 p
->shared_network
? "shared network"
10647 : "non shared network");
10651 /* Timer information. */
10653 json_object_int_add(json_neigh
, "connectRetryTimer",
10655 if (p
->status
== Established
&& p
->rtt
)
10656 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10659 json_object_int_add(
10660 json_neigh
, "nextStartTimerDueInMsecs",
10661 thread_timer_remain_second(p
->t_start
) * 1000);
10663 json_object_int_add(
10664 json_neigh
, "nextConnectTimerDueInMsecs",
10665 thread_timer_remain_second(p
->t_connect
)
10667 if (p
->t_routeadv
) {
10668 json_object_int_add(json_neigh
, "mraiInterval",
10670 json_object_int_add(
10671 json_neigh
, "mraiTimerExpireInMsecs",
10672 thread_timer_remain_second(p
->t_routeadv
)
10676 json_object_int_add(json_neigh
, "authenticationEnabled",
10680 json_object_string_add(json_neigh
, "readThread", "on");
10682 json_object_string_add(json_neigh
, "readThread", "off");
10684 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10685 json_object_string_add(json_neigh
, "writeThread", "on");
10687 json_object_string_add(json_neigh
, "writeThread",
10690 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10692 if (p
->status
== Established
&& p
->rtt
)
10693 vty_out(vty
, "Estimated round trip time: %d ms\n",
10696 vty_out(vty
, "Next start timer due in %ld seconds\n",
10697 thread_timer_remain_second(p
->t_start
));
10699 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10700 thread_timer_remain_second(p
->t_connect
));
10703 "MRAI (interval %u) timer expires in %ld seconds\n",
10705 thread_timer_remain_second(p
->t_routeadv
));
10707 vty_out(vty
, "Peer Authentication Enabled\n");
10709 vty_out(vty
, "Read thread: %s Write thread: %s\n",
10710 p
->t_read
? "on" : "off",
10711 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10716 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10717 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10718 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10721 vty_out(vty
, "\n");
10723 /* BFD information. */
10724 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10727 if (p
->conf_if
) /* Configured interface name. */
10728 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10729 else /* Configured IP address. */
10730 json_object_object_add(json
, p
->host
, json_neigh
);
10734 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10735 enum show_type type
, union sockunion
*su
,
10736 const char *conf_if
, bool use_json
,
10739 struct listnode
*node
, *nnode
;
10742 bool nbr_output
= false;
10744 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10745 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10750 bgp_show_peer(vty
, peer
, use_json
, json
);
10756 && !strcmp(peer
->conf_if
, conf_if
))
10758 && !strcmp(peer
->hostname
, conf_if
))) {
10760 bgp_show_peer(vty
, peer
, use_json
,
10764 if (sockunion_same(&peer
->su
, su
)) {
10766 bgp_show_peer(vty
, peer
, use_json
,
10774 if (type
== show_peer
&& !find
) {
10776 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
10778 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
10781 if (type
!= show_peer
&& !nbr_output
&& !use_json
)
10782 vty_out(vty
, "%% No BGP neighbors found\n");
10785 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10786 json
, JSON_C_TO_STRING_PRETTY
));
10787 json_object_free(json
);
10789 vty_out(vty
, "\n");
10792 return CMD_SUCCESS
;
10795 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
10796 enum show_type type
,
10797 const char *ip_str
,
10800 struct listnode
*node
, *nnode
;
10802 union sockunion su
;
10803 json_object
*json
= NULL
;
10804 int ret
, is_first
= 1;
10805 bool nbr_output
= false;
10808 vty_out(vty
, "{\n");
10810 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
10813 if (!(json
= json_object_new_object())) {
10815 EC_BGP_JSON_MEM_ERROR
,
10816 "Unable to allocate memory for JSON object");
10818 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
10822 json_object_int_add(json
, "vrfId",
10823 (bgp
->vrf_id
== VRF_UNKNOWN
)
10825 : (int64_t)bgp
->vrf_id
);
10826 json_object_string_add(
10828 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10833 vty_out(vty
, ",\n");
10837 vty_out(vty
, "\"%s\":",
10838 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10842 vty_out(vty
, "\nInstance %s:\n",
10843 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10848 if (type
== show_peer
) {
10849 ret
= str2sockunion(ip_str
, &su
);
10851 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10854 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10857 bgp_show_neighbor(vty
, bgp
, show_all
, NULL
, NULL
,
10863 vty_out(vty
, "}\n");
10864 else if (!nbr_output
)
10865 vty_out(vty
, "%% BGP instance not found\n");
10868 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
10869 enum show_type type
, const char *ip_str
,
10874 union sockunion su
;
10875 json_object
*json
= NULL
;
10878 if (strmatch(name
, "all")) {
10879 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
10881 return CMD_SUCCESS
;
10883 bgp
= bgp_lookup_by_name(name
);
10886 json
= json_object_new_object();
10887 vty_out(vty
, "%s\n",
10888 json_object_to_json_string_ext(
10890 JSON_C_TO_STRING_PRETTY
));
10891 json_object_free(json
);
10894 "%% BGP instance not found\n");
10896 return CMD_WARNING
;
10900 bgp
= bgp_get_default();
10904 json
= json_object_new_object();
10906 ret
= str2sockunion(ip_str
, &su
);
10908 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10911 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10914 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
10917 json_object_free(json
);
10920 vty_out(vty
, "{}\n");
10922 vty_out(vty
, "%% BGP instance not found\n");
10925 return CMD_SUCCESS
;
10928 /* "show [ip] bgp neighbors" commands. */
10929 DEFUN (show_ip_bgp_neighbors
,
10930 show_ip_bgp_neighbors_cmd
,
10931 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
10935 BGP_INSTANCE_HELP_STR
10938 "Detailed information on TCP and BGP neighbor connections\n"
10939 "Neighbor to display information about\n"
10940 "Neighbor to display information about\n"
10941 "Neighbor on BGP configured interface\n"
10945 char *sh_arg
= NULL
;
10946 enum show_type sh_type
;
10948 bool uj
= use_json(argc
, argv
);
10952 /* [<vrf> VIEWVRFNAME] */
10953 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10954 vrf
= argv
[idx
+ 1]->arg
;
10955 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10957 } else if (argv_find(argv
, argc
, "view", &idx
))
10958 /* [<view> VIEWVRFNAME] */
10959 vrf
= argv
[idx
+ 1]->arg
;
10962 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
10963 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
10964 || argv_find(argv
, argc
, "WORD", &idx
)) {
10965 sh_type
= show_peer
;
10966 sh_arg
= argv
[idx
]->arg
;
10968 sh_type
= show_all
;
10970 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
10973 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
10974 paths' and `show ip mbgp paths'. Those functions results are the
10976 DEFUN (show_ip_bgp_paths
,
10977 show_ip_bgp_paths_cmd
,
10978 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
10983 "Path information\n")
10985 vty_out(vty
, "Address Refcnt Path\n");
10986 aspath_print_all_vty(vty
);
10987 return CMD_SUCCESS
;
10992 static void community_show_all_iterator(struct hash_backet
*backet
,
10995 struct community
*com
;
10997 com
= (struct community
*)backet
->data
;
10998 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
10999 community_str(com
, false));
11002 /* Show BGP's community internal data. */
11003 DEFUN (show_ip_bgp_community_info
,
11004 show_ip_bgp_community_info_cmd
,
11005 "show [ip] bgp community-info",
11009 "List all bgp community information\n")
11011 vty_out(vty
, "Address Refcnt Community\n");
11013 hash_iterate(community_hash(),
11014 (void (*)(struct hash_backet
*,
11015 void *))community_show_all_iterator
,
11018 return CMD_SUCCESS
;
11021 static void lcommunity_show_all_iterator(struct hash_backet
*backet
,
11024 struct lcommunity
*lcom
;
11026 lcom
= (struct lcommunity
*)backet
->data
;
11027 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11028 lcommunity_str(lcom
, false));
11031 /* Show BGP's community internal data. */
11032 DEFUN (show_ip_bgp_lcommunity_info
,
11033 show_ip_bgp_lcommunity_info_cmd
,
11034 "show ip bgp large-community-info",
11038 "List all bgp large-community information\n")
11040 vty_out(vty
, "Address Refcnt Large-community\n");
11042 hash_iterate(lcommunity_hash(),
11043 (void (*)(struct hash_backet
*,
11044 void *))lcommunity_show_all_iterator
,
11047 return CMD_SUCCESS
;
11051 DEFUN (show_ip_bgp_attr_info
,
11052 show_ip_bgp_attr_info_cmd
,
11053 "show [ip] bgp attribute-info",
11057 "List all bgp attribute information\n")
11059 attr_show_all(vty
);
11060 return CMD_SUCCESS
;
11063 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11064 safi_t safi
, bool use_json
)
11067 struct listnode
*node
;
11069 char buf1
[INET6_ADDRSTRLEN
];
11071 vpn_policy_direction_t dir
;
11074 json_object
*json
= NULL
;
11075 json_object
*json_import_vrfs
= NULL
;
11076 json_object
*json_export_vrfs
= NULL
;
11078 json
= json_object_new_object();
11080 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11083 vty_out(vty
, "%s\n",
11084 json_object_to_json_string_ext(
11086 JSON_C_TO_STRING_PRETTY
));
11087 json_object_free(json
);
11089 return CMD_WARNING
;
11092 /* Provide context for the block */
11093 json_object_string_add(json
, "vrf", name
? name
: "default");
11094 json_object_string_add(json
, "afiSafi",
11095 afi_safi_print(afi
, safi
));
11097 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11098 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11099 json_object_string_add(json
, "importFromVrfs", "none");
11100 json_object_string_add(json
, "importRts", "none");
11102 json_import_vrfs
= json_object_new_array();
11104 for (ALL_LIST_ELEMENTS_RO(
11105 bgp
->vpn_policy
[afi
].import_vrf
,
11107 json_object_array_add(json_import_vrfs
,
11108 json_object_new_string(vname
));
11110 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11111 ecom_str
= ecommunity_ecom2str(
11112 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11113 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11114 json_object_object_add(json
, "importFromVrfs",
11116 json_object_string_add(json
, "importRts", ecom_str
);
11118 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11121 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11122 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11123 json_object_string_add(json
, "exportToVrfs", "none");
11124 json_object_string_add(json
, "routeDistinguisher",
11126 json_object_string_add(json
, "exportRts", "none");
11128 json_export_vrfs
= json_object_new_array();
11130 for (ALL_LIST_ELEMENTS_RO(
11131 bgp
->vpn_policy
[afi
].export_vrf
,
11133 json_object_array_add(json_export_vrfs
,
11134 json_object_new_string(vname
));
11135 json_object_object_add(json
, "exportToVrfs",
11137 json_object_string_add(json
, "routeDistinguisher",
11138 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11139 buf1
, RD_ADDRSTRLEN
));
11141 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11142 ecom_str
= ecommunity_ecom2str(
11143 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11144 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11145 json_object_string_add(json
, "exportRts", ecom_str
);
11147 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11150 vty_out(vty
, "%s\n",
11151 json_object_to_json_string_ext(json
,
11152 JSON_C_TO_STRING_PRETTY
));
11153 json_object_free(json
);
11156 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11159 vty_out(vty
, "%% No such BGP instance exist\n");
11160 return CMD_WARNING
;
11163 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11164 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11166 "This VRF is not importing %s routes from any other VRF\n",
11167 afi_safi_print(afi
, safi
));
11170 "This VRF is importing %s routes from the following VRFs:\n",
11171 afi_safi_print(afi
, safi
));
11173 for (ALL_LIST_ELEMENTS_RO(
11174 bgp
->vpn_policy
[afi
].import_vrf
,
11176 vty_out(vty
, " %s\n", vname
);
11178 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11179 ecom_str
= ecommunity_ecom2str(
11180 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11181 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11182 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11184 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11187 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11188 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11190 "This VRF is not exporting %s routes to any other VRF\n",
11191 afi_safi_print(afi
, safi
));
11194 "This VRF is exporting %s routes to the following VRFs:\n",
11195 afi_safi_print(afi
, safi
));
11197 for (ALL_LIST_ELEMENTS_RO(
11198 bgp
->vpn_policy
[afi
].export_vrf
,
11200 vty_out(vty
, " %s\n", vname
);
11202 vty_out(vty
, "RD: %s\n",
11203 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11204 buf1
, RD_ADDRSTRLEN
));
11206 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11207 ecom_str
= ecommunity_ecom2str(
11208 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11209 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11210 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11211 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11215 return CMD_SUCCESS
;
11218 /* "show [ip] bgp route-leak" command. */
11219 DEFUN (show_ip_bgp_route_leak
,
11220 show_ip_bgp_route_leak_cmd
,
11221 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11225 BGP_INSTANCE_HELP_STR
11228 "Route leaking information\n"
11232 afi_t afi
= AFI_MAX
;
11233 safi_t safi
= SAFI_MAX
;
11235 bool uj
= use_json(argc
, argv
);
11238 /* show [ip] bgp */
11239 if (argv_find(argv
, argc
, "ip", &idx
)) {
11241 safi
= SAFI_UNICAST
;
11243 /* [vrf VIEWVRFNAME] */
11244 if (argv_find(argv
, argc
, "view", &idx
)) {
11246 "%% This command is not applicable to BGP views\n");
11247 return CMD_WARNING
;
11250 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11251 vrf
= argv
[idx
+ 1]->arg
;
11252 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11255 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11256 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11257 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11260 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11262 "%% This command is applicable only for unicast ipv4|ipv6\n");
11263 return CMD_WARNING
;
11266 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
);
11269 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11272 struct listnode
*node
, *nnode
;
11275 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11276 vty_out(vty
, "\nInstance %s:\n",
11277 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11280 update_group_show(bgp
, afi
, safi
, vty
, 0);
11284 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11285 int safi
, uint64_t subgrp_id
)
11290 if (strmatch(name
, "all")) {
11291 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11292 return CMD_SUCCESS
;
11294 bgp
= bgp_lookup_by_name(name
);
11297 bgp
= bgp_get_default();
11301 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11302 return CMD_SUCCESS
;
11305 DEFUN (show_ip_bgp_updgrps
,
11306 show_ip_bgp_updgrps_cmd
,
11307 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11311 BGP_INSTANCE_HELP_STR
11313 BGP_SAFI_WITH_LABEL_HELP_STR
11314 "Detailed info about dynamic update groups\n"
11315 "Specific subgroup to display detailed info for\n")
11318 afi_t afi
= AFI_IP6
;
11319 safi_t safi
= SAFI_UNICAST
;
11320 uint64_t subgrp_id
= 0;
11324 /* show [ip] bgp */
11325 if (argv_find(argv
, argc
, "ip", &idx
))
11327 /* [<vrf> VIEWVRFNAME] */
11328 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11329 vrf
= argv
[idx
+ 1]->arg
;
11330 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11332 } else if (argv_find(argv
, argc
, "view", &idx
))
11333 /* [<view> VIEWVRFNAME] */
11334 vrf
= argv
[idx
+ 1]->arg
;
11335 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11336 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11337 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11340 /* get subgroup id, if provided */
11342 if (argv
[idx
]->type
== VARIABLE_TKN
)
11343 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11345 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11348 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11349 show_bgp_instance_all_ipv6_updgrps_cmd
,
11350 "show [ip] bgp <view|vrf> all update-groups",
11354 BGP_INSTANCE_ALL_HELP_STR
11355 "Detailed info about dynamic update groups\n")
11357 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11358 return CMD_SUCCESS
;
11361 DEFUN (show_bgp_updgrps_stats
,
11362 show_bgp_updgrps_stats_cmd
,
11363 "show [ip] bgp update-groups statistics",
11367 "Detailed info about dynamic update groups\n"
11372 bgp
= bgp_get_default();
11374 update_group_show_stats(bgp
, vty
);
11376 return CMD_SUCCESS
;
11379 DEFUN (show_bgp_instance_updgrps_stats
,
11380 show_bgp_instance_updgrps_stats_cmd
,
11381 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11385 BGP_INSTANCE_HELP_STR
11386 "Detailed info about dynamic update groups\n"
11392 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11394 update_group_show_stats(bgp
, vty
);
11396 return CMD_SUCCESS
;
11399 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11400 afi_t afi
, safi_t safi
,
11401 const char *what
, uint64_t subgrp_id
)
11406 bgp
= bgp_lookup_by_name(name
);
11408 bgp
= bgp_get_default();
11411 if (!strcmp(what
, "advertise-queue"))
11412 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11414 else if (!strcmp(what
, "advertised-routes"))
11415 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11417 else if (!strcmp(what
, "packet-queue"))
11418 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11423 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11424 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11425 "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",
11426 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11428 "Detailed info about dynamic update groups\n"
11429 "Specific subgroup to display info for\n"
11430 "Advertisement queue\n"
11431 "Announced routes\n"
11434 uint64_t subgrp_id
= 0;
11438 subgrp_id
= strtoull(sgid
, NULL
, 10);
11443 afiz
= bgp_vty_afi_from_str(afi
);
11447 afiz
= bgp_vty_afi_from_str(afi
);
11448 if (afiz
!= AFI_IP
)
11450 "%% Cannot specify both 'ip' and 'ipv6'\n");
11451 return CMD_WARNING
;
11454 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11456 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11457 return CMD_SUCCESS
;
11460 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11462 struct listnode
*node
, *nnode
;
11463 struct prefix
*range
;
11466 char buf
[PREFIX2STR_BUFFER
];
11469 const char *peer_status
;
11470 const char *af_str
;
11475 conf
= group
->conf
;
11477 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11478 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
11480 } else if (conf
->as_type
== AS_INTERNAL
) {
11481 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
11484 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11487 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11488 vty_out(vty
, " Peer-group type is internal\n");
11490 vty_out(vty
, " Peer-group type is external\n");
11492 /* Display AFs configured. */
11493 vty_out(vty
, " Configured address-families:");
11494 FOREACH_AFI_SAFI (afi
, safi
) {
11495 if (conf
->afc
[afi
][safi
]) {
11497 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11501 vty_out(vty
, " none\n");
11503 vty_out(vty
, "\n");
11505 /* Display listen ranges (for dynamic neighbors), if any */
11506 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11509 else if (afi
== AFI_IP6
)
11513 lr_count
= listcount(group
->listen_range
[afi
]);
11515 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11519 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11521 prefix2str(range
, buf
, sizeof(buf
));
11522 vty_out(vty
, " %s\n", buf
);
11527 /* Display group members and their status */
11528 if (listcount(group
->peer
)) {
11529 vty_out(vty
, " Peer-group members:\n");
11530 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11531 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11532 peer_status
= "Idle (Admin)";
11533 else if (CHECK_FLAG(peer
->sflags
,
11534 PEER_STATUS_PREFIX_OVERFLOW
))
11535 peer_status
= "Idle (PfxCt)";
11537 peer_status
= lookup_msg(bgp_status_msg
,
11538 peer
->status
, NULL
);
11540 dynamic
= peer_dynamic_neighbor(peer
);
11541 vty_out(vty
, " %s %s %s \n", peer
->host
,
11542 dynamic
? "(dynamic)" : "", peer_status
);
11546 return CMD_SUCCESS
;
11549 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11550 const char *group_name
)
11553 struct listnode
*node
, *nnode
;
11554 struct peer_group
*group
;
11555 bool found
= false;
11557 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11560 vty_out(vty
, "%% BGP instance not found\n");
11561 return CMD_WARNING
;
11564 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11566 if (strmatch(group
->name
, group_name
)) {
11567 bgp_show_one_peer_group(vty
, group
);
11572 bgp_show_one_peer_group(vty
, group
);
11576 if (group_name
&& !found
)
11577 vty_out(vty
, "%% No such peer-group\n");
11579 return CMD_SUCCESS
;
11582 DEFUN (show_ip_bgp_peer_groups
,
11583 show_ip_bgp_peer_groups_cmd
,
11584 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11588 BGP_INSTANCE_HELP_STR
11589 "Detailed information on BGP peer groups\n"
11590 "Peer group name\n")
11595 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11597 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11599 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11603 /* Redistribute VTY commands. */
11605 DEFUN (bgp_redistribute_ipv4
,
11606 bgp_redistribute_ipv4_cmd
,
11607 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11608 "Redistribute information from another routing protocol\n"
11609 FRR_IP_REDIST_HELP_STR_BGPD
)
11611 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11612 int idx_protocol
= 1;
11615 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11617 vty_out(vty
, "%% Invalid route type\n");
11618 return CMD_WARNING_CONFIG_FAILED
;
11621 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11622 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
11626 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11627 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11628 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11630 DEFUN (bgp_redistribute_ipv4_rmap
,
11631 bgp_redistribute_ipv4_rmap_cmd
,
11632 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11633 "Redistribute information from another routing protocol\n"
11634 FRR_IP_REDIST_HELP_STR_BGPD
11635 "Route map reference\n"
11636 "Pointer to route-map entries\n")
11638 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11639 int idx_protocol
= 1;
11642 struct bgp_redist
*red
;
11645 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11647 vty_out(vty
, "%% Invalid route type\n");
11648 return CMD_WARNING_CONFIG_FAILED
;
11651 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11652 changed
= bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11653 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11657 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
11658 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11659 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11660 "Route map reference\n"
11661 "Pointer to route-map entries\n")
11663 DEFUN (bgp_redistribute_ipv4_metric
,
11664 bgp_redistribute_ipv4_metric_cmd
,
11665 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11666 "Redistribute information from another routing protocol\n"
11667 FRR_IP_REDIST_HELP_STR_BGPD
11668 "Metric for redistributed routes\n"
11669 "Default metric\n")
11671 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11672 int idx_protocol
= 1;
11673 int idx_number
= 3;
11676 struct bgp_redist
*red
;
11679 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11681 vty_out(vty
, "%% Invalid route type\n");
11682 return CMD_WARNING_CONFIG_FAILED
;
11684 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11686 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11687 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11688 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11692 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
11693 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11694 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11695 "Metric for redistributed routes\n"
11696 "Default metric\n")
11698 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
11699 bgp_redistribute_ipv4_rmap_metric_cmd
,
11700 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11701 "Redistribute information from another routing protocol\n"
11702 FRR_IP_REDIST_HELP_STR_BGPD
11703 "Route map reference\n"
11704 "Pointer to route-map entries\n"
11705 "Metric for redistributed routes\n"
11706 "Default metric\n")
11708 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11709 int idx_protocol
= 1;
11711 int idx_number
= 5;
11714 struct bgp_redist
*red
;
11717 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11719 vty_out(vty
, "%% Invalid route type\n");
11720 return CMD_WARNING_CONFIG_FAILED
;
11722 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11724 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11725 changed
= bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11726 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11727 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11731 bgp_redistribute_ipv4_rmap_metric
,
11732 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
11733 "redistribute " FRR_IP_REDIST_STR_BGPD
11734 " route-map WORD metric (0-4294967295)",
11735 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11736 "Route map reference\n"
11737 "Pointer to route-map entries\n"
11738 "Metric for redistributed routes\n"
11739 "Default metric\n")
11741 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
11742 bgp_redistribute_ipv4_metric_rmap_cmd
,
11743 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
11744 "Redistribute information from another routing protocol\n"
11745 FRR_IP_REDIST_HELP_STR_BGPD
11746 "Metric for redistributed routes\n"
11748 "Route map reference\n"
11749 "Pointer to route-map entries\n")
11751 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11752 int idx_protocol
= 1;
11753 int idx_number
= 3;
11757 struct bgp_redist
*red
;
11760 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11762 vty_out(vty
, "%% Invalid route type\n");
11763 return CMD_WARNING_CONFIG_FAILED
;
11765 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11767 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11768 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11769 changed
|= bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11770 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11774 bgp_redistribute_ipv4_metric_rmap
,
11775 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
11776 "redistribute " FRR_IP_REDIST_STR_BGPD
11777 " metric (0-4294967295) route-map WORD",
11778 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11779 "Metric for redistributed routes\n"
11781 "Route map reference\n"
11782 "Pointer to route-map entries\n")
11784 DEFUN (bgp_redistribute_ipv4_ospf
,
11785 bgp_redistribute_ipv4_ospf_cmd
,
11786 "redistribute <ospf|table> (1-65535)",
11787 "Redistribute information from another routing protocol\n"
11788 "Open Shortest Path First (OSPFv2)\n"
11789 "Non-main Kernel Routing Table\n"
11790 "Instance ID/Table ID\n")
11792 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11793 int idx_ospf_table
= 1;
11794 int idx_number
= 2;
11795 unsigned short instance
;
11796 unsigned short protocol
;
11798 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11800 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11801 protocol
= ZEBRA_ROUTE_OSPF
;
11803 protocol
= ZEBRA_ROUTE_TABLE
;
11805 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11806 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
11809 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
11810 "redistribute <ospf|table> (1-65535)",
11811 "Redistribute information from another routing protocol\n"
11812 "Open Shortest Path First (OSPFv2)\n"
11813 "Non-main Kernel Routing Table\n"
11814 "Instance ID/Table ID\n")
11816 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
11817 bgp_redistribute_ipv4_ospf_rmap_cmd
,
11818 "redistribute <ospf|table> (1-65535) route-map WORD",
11819 "Redistribute information from another routing protocol\n"
11820 "Open Shortest Path First (OSPFv2)\n"
11821 "Non-main Kernel Routing Table\n"
11822 "Instance ID/Table ID\n"
11823 "Route map reference\n"
11824 "Pointer to route-map entries\n")
11826 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11827 int idx_ospf_table
= 1;
11828 int idx_number
= 2;
11830 struct bgp_redist
*red
;
11831 unsigned short instance
;
11835 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11836 protocol
= ZEBRA_ROUTE_OSPF
;
11838 protocol
= ZEBRA_ROUTE_TABLE
;
11840 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11841 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11842 changed
= bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11843 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
11846 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
11847 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
11848 "redistribute <ospf|table> (1-65535) route-map WORD",
11849 "Redistribute information from another routing protocol\n"
11850 "Open Shortest Path First (OSPFv2)\n"
11851 "Non-main Kernel Routing Table\n"
11852 "Instance ID/Table ID\n"
11853 "Route map reference\n"
11854 "Pointer to route-map entries\n")
11856 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
11857 bgp_redistribute_ipv4_ospf_metric_cmd
,
11858 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
11859 "Redistribute information from another routing protocol\n"
11860 "Open Shortest Path First (OSPFv2)\n"
11861 "Non-main Kernel Routing Table\n"
11862 "Instance ID/Table ID\n"
11863 "Metric for redistributed routes\n"
11864 "Default metric\n")
11866 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11867 int idx_ospf_table
= 1;
11868 int idx_number
= 2;
11869 int idx_number_2
= 4;
11871 struct bgp_redist
*red
;
11872 unsigned short instance
;
11876 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11877 protocol
= ZEBRA_ROUTE_OSPF
;
11879 protocol
= ZEBRA_ROUTE_TABLE
;
11881 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11882 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11884 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11885 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
11887 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
11890 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
11891 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
11892 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
11893 "Redistribute information from another routing protocol\n"
11894 "Open Shortest Path First (OSPFv2)\n"
11895 "Non-main Kernel Routing Table\n"
11896 "Instance ID/Table ID\n"
11897 "Metric for redistributed routes\n"
11898 "Default metric\n")
11900 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
11901 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
11902 "redistribute <ospf|table> (1-65535) route-map WORD 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 "Route map reference\n"
11908 "Pointer to route-map entries\n"
11909 "Metric for redistributed routes\n"
11910 "Default metric\n")
11912 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11913 int idx_ospf_table
= 1;
11914 int idx_number
= 2;
11916 int idx_number_2
= 6;
11918 struct bgp_redist
*red
;
11919 unsigned short instance
;
11923 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11924 protocol
= ZEBRA_ROUTE_OSPF
;
11926 protocol
= ZEBRA_ROUTE_TABLE
;
11928 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11929 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11931 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11932 changed
= bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11933 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
11935 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
11939 bgp_redistribute_ipv4_ospf_rmap_metric
,
11940 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
11941 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
11942 "Redistribute information from another routing protocol\n"
11943 "Open Shortest Path First (OSPFv2)\n"
11944 "Non-main Kernel Routing Table\n"
11945 "Instance ID/Table ID\n"
11946 "Route map reference\n"
11947 "Pointer to route-map entries\n"
11948 "Metric for redistributed routes\n"
11949 "Default metric\n")
11951 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
11952 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
11953 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
11954 "Redistribute information from another routing protocol\n"
11955 "Open Shortest Path First (OSPFv2)\n"
11956 "Non-main Kernel Routing Table\n"
11957 "Instance ID/Table ID\n"
11958 "Metric for redistributed routes\n"
11960 "Route map reference\n"
11961 "Pointer to route-map entries\n")
11963 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11964 int idx_ospf_table
= 1;
11965 int idx_number
= 2;
11966 int idx_number_2
= 4;
11969 struct bgp_redist
*red
;
11970 unsigned short instance
;
11974 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11975 protocol
= ZEBRA_ROUTE_OSPF
;
11977 protocol
= ZEBRA_ROUTE_TABLE
;
11979 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11980 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11982 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11983 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
11985 changed
|= bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11986 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
11990 bgp_redistribute_ipv4_ospf_metric_rmap
,
11991 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
11992 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
11993 "Redistribute information from another routing protocol\n"
11994 "Open Shortest Path First (OSPFv2)\n"
11995 "Non-main Kernel Routing Table\n"
11996 "Instance ID/Table ID\n"
11997 "Metric for redistributed routes\n"
11999 "Route map reference\n"
12000 "Pointer to route-map entries\n")
12002 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12003 no_bgp_redistribute_ipv4_ospf_cmd
,
12004 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12006 "Redistribute information from another routing protocol\n"
12007 "Open Shortest Path First (OSPFv2)\n"
12008 "Non-main Kernel Routing Table\n"
12009 "Instance ID/Table ID\n"
12010 "Metric for redistributed routes\n"
12012 "Route map reference\n"
12013 "Pointer to route-map entries\n")
12015 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12016 int idx_ospf_table
= 2;
12017 int idx_number
= 3;
12018 unsigned short instance
;
12021 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12022 protocol
= ZEBRA_ROUTE_OSPF
;
12024 protocol
= ZEBRA_ROUTE_TABLE
;
12026 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12027 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12031 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12032 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12034 "Redistribute information from another routing protocol\n"
12035 "Open Shortest Path First (OSPFv2)\n"
12036 "Non-main Kernel Routing Table\n"
12037 "Instance ID/Table ID\n"
12038 "Metric for redistributed routes\n"
12040 "Route map reference\n"
12041 "Pointer to route-map entries\n")
12043 DEFUN (no_bgp_redistribute_ipv4
,
12044 no_bgp_redistribute_ipv4_cmd
,
12045 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12047 "Redistribute information from another routing protocol\n"
12048 FRR_IP_REDIST_HELP_STR_BGPD
12049 "Metric for redistributed routes\n"
12051 "Route map reference\n"
12052 "Pointer to route-map entries\n")
12054 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12055 int idx_protocol
= 2;
12058 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12060 vty_out(vty
, "%% Invalid route type\n");
12061 return CMD_WARNING_CONFIG_FAILED
;
12063 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12067 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12068 "no redistribute " FRR_IP_REDIST_STR_BGPD
12069 " [metric (0-4294967295)] [route-map WORD]",
12071 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12072 "Metric for redistributed routes\n"
12074 "Route map reference\n"
12075 "Pointer to route-map entries\n")
12077 DEFUN (bgp_redistribute_ipv6
,
12078 bgp_redistribute_ipv6_cmd
,
12079 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12080 "Redistribute information from another routing protocol\n"
12081 FRR_IP6_REDIST_HELP_STR_BGPD
)
12083 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12084 int idx_protocol
= 1;
12087 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12089 vty_out(vty
, "%% Invalid route type\n");
12090 return CMD_WARNING_CONFIG_FAILED
;
12093 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12094 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12097 DEFUN (bgp_redistribute_ipv6_rmap
,
12098 bgp_redistribute_ipv6_rmap_cmd
,
12099 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12100 "Redistribute information from another routing protocol\n"
12101 FRR_IP6_REDIST_HELP_STR_BGPD
12102 "Route map reference\n"
12103 "Pointer to route-map entries\n")
12105 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12106 int idx_protocol
= 1;
12109 struct bgp_redist
*red
;
12112 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12114 vty_out(vty
, "%% Invalid route type\n");
12115 return CMD_WARNING_CONFIG_FAILED
;
12118 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12119 changed
= bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
12120 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12123 DEFUN (bgp_redistribute_ipv6_metric
,
12124 bgp_redistribute_ipv6_metric_cmd
,
12125 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12126 "Redistribute information from another routing protocol\n"
12127 FRR_IP6_REDIST_HELP_STR_BGPD
12128 "Metric for redistributed routes\n"
12129 "Default metric\n")
12131 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12132 int idx_protocol
= 1;
12133 int idx_number
= 3;
12136 struct bgp_redist
*red
;
12139 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12141 vty_out(vty
, "%% Invalid route type\n");
12142 return CMD_WARNING_CONFIG_FAILED
;
12144 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12146 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12147 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12148 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12151 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12152 bgp_redistribute_ipv6_rmap_metric_cmd
,
12153 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12154 "Redistribute information from another routing protocol\n"
12155 FRR_IP6_REDIST_HELP_STR_BGPD
12156 "Route map reference\n"
12157 "Pointer to route-map entries\n"
12158 "Metric for redistributed routes\n"
12159 "Default metric\n")
12161 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12162 int idx_protocol
= 1;
12164 int idx_number
= 5;
12167 struct bgp_redist
*red
;
12170 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12172 vty_out(vty
, "%% Invalid route type\n");
12173 return CMD_WARNING_CONFIG_FAILED
;
12175 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12177 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12178 changed
= bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
12179 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12181 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12184 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12185 bgp_redistribute_ipv6_metric_rmap_cmd
,
12186 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12187 "Redistribute information from another routing protocol\n"
12188 FRR_IP6_REDIST_HELP_STR_BGPD
12189 "Metric for redistributed routes\n"
12191 "Route map reference\n"
12192 "Pointer to route-map entries\n")
12194 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12195 int idx_protocol
= 1;
12196 int idx_number
= 3;
12200 struct bgp_redist
*red
;
12203 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12205 vty_out(vty
, "%% Invalid route type\n");
12206 return CMD_WARNING_CONFIG_FAILED
;
12208 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12210 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12211 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12213 changed
|= bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
12214 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12217 DEFUN (no_bgp_redistribute_ipv6
,
12218 no_bgp_redistribute_ipv6_cmd
,
12219 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12221 "Redistribute information from another routing protocol\n"
12222 FRR_IP6_REDIST_HELP_STR_BGPD
12223 "Metric for redistributed routes\n"
12225 "Route map reference\n"
12226 "Pointer to route-map entries\n")
12228 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12229 int idx_protocol
= 2;
12232 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12234 vty_out(vty
, "%% Invalid route type\n");
12235 return CMD_WARNING_CONFIG_FAILED
;
12238 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12241 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12246 /* Unicast redistribution only. */
12247 if (safi
!= SAFI_UNICAST
)
12250 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12251 /* Redistribute BGP does not make sense. */
12252 if (i
!= ZEBRA_ROUTE_BGP
) {
12253 struct list
*red_list
;
12254 struct listnode
*node
;
12255 struct bgp_redist
*red
;
12257 red_list
= bgp
->redist
[afi
][i
];
12261 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12262 /* "redistribute" configuration. */
12263 vty_out(vty
, " redistribute %s",
12264 zebra_route_string(i
));
12266 vty_out(vty
, " %d", red
->instance
);
12267 if (red
->redist_metric_flag
)
12268 vty_out(vty
, " metric %u",
12269 red
->redist_metric
);
12270 if (red
->rmap
.name
)
12271 vty_out(vty
, " route-map %s",
12273 vty_out(vty
, "\n");
12279 /* This is part of the address-family block (unicast only) */
12280 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12285 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
])
12286 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12287 bgp
->vpn_policy
[afi
]
12288 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12290 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12291 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12292 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12293 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12296 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12297 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12299 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12302 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12303 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12304 bgp
->vpn_policy
[afi
].tovpn_label
);
12307 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12308 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12309 char buf
[RD_ADDRSTRLEN
];
12310 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12311 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12314 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12315 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12317 char buf
[PREFIX_STRLEN
];
12318 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12319 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12322 vty_out(vty
, "%*snexthop vpn export %s\n",
12326 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12327 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12329 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12330 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12332 char *b
= ecommunity_ecom2str(
12333 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12334 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12335 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12336 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12338 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12339 char *b
= ecommunity_ecom2str(
12340 bgp
->vpn_policy
[afi
]
12341 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12342 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12343 ECOMMUNITY_ROUTE_TARGET
);
12344 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12345 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12347 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12348 char *b
= ecommunity_ecom2str(
12349 bgp
->vpn_policy
[afi
]
12350 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12351 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12352 ECOMMUNITY_ROUTE_TARGET
);
12353 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12354 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12358 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12359 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12360 bgp
->vpn_policy
[afi
]
12361 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12363 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12364 char *b
= ecommunity_ecom2str(
12365 bgp
->vpn_policy
[afi
]
12366 .import_redirect_rtlist
,
12367 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12368 ECOMMUNITY_ROUTE_TARGET
);
12370 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12371 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12376 /* BGP node structure. */
12377 static struct cmd_node bgp_node
= {
12378 BGP_NODE
, "%s(config-router)# ", 1,
12381 static struct cmd_node bgp_ipv4_unicast_node
= {
12382 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12385 static struct cmd_node bgp_ipv4_multicast_node
= {
12386 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12389 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12390 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12393 static struct cmd_node bgp_ipv6_unicast_node
= {
12394 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12397 static struct cmd_node bgp_ipv6_multicast_node
= {
12398 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12401 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12402 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12405 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12406 "%s(config-router-af)# ", 1};
12408 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12409 "%s(config-router-af-vpnv6)# ", 1};
12411 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12412 "%s(config-router-evpn)# ", 1};
12414 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12415 "%s(config-router-af-vni)# ", 1};
12417 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12418 "%s(config-router-af)# ", 1};
12420 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12421 "%s(config-router-af-vpnv6)# ", 1};
12423 static void community_list_vty(void);
12425 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12429 struct listnode
*lnbgp
, *lnpeer
;
12431 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12432 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12433 /* only provide suggestions on the appropriate input
12435 * they'll otherwise show up multiple times */
12436 enum cmd_token_type match_type
;
12437 char *name
= peer
->host
;
12439 if (peer
->conf_if
) {
12440 match_type
= VARIABLE_TKN
;
12441 name
= peer
->conf_if
;
12442 } else if (strchr(peer
->host
, ':'))
12443 match_type
= IPV6_TKN
;
12445 match_type
= IPV4_TKN
;
12447 if (token
->type
!= match_type
)
12450 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12455 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12456 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12457 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12458 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12459 {.completions
= NULL
}};
12461 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12464 struct peer_group
*group
;
12465 struct listnode
*lnbgp
, *lnpeer
;
12467 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12468 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12469 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12474 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12475 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12476 {.completions
= NULL
} };
12478 void bgp_vty_init(void)
12480 cmd_variable_handler_register(bgp_var_neighbor
);
12481 cmd_variable_handler_register(bgp_var_peergroup
);
12483 /* Install bgp top node. */
12484 install_node(&bgp_node
, bgp_config_write
);
12485 install_node(&bgp_ipv4_unicast_node
, NULL
);
12486 install_node(&bgp_ipv4_multicast_node
, NULL
);
12487 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12488 install_node(&bgp_ipv6_unicast_node
, NULL
);
12489 install_node(&bgp_ipv6_multicast_node
, NULL
);
12490 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12491 install_node(&bgp_vpnv4_node
, NULL
);
12492 install_node(&bgp_vpnv6_node
, NULL
);
12493 install_node(&bgp_evpn_node
, NULL
);
12494 install_node(&bgp_evpn_vni_node
, NULL
);
12495 install_node(&bgp_flowspecv4_node
, NULL
);
12496 install_node(&bgp_flowspecv6_node
, NULL
);
12498 /* Install default VTY commands to new nodes. */
12499 install_default(BGP_NODE
);
12500 install_default(BGP_IPV4_NODE
);
12501 install_default(BGP_IPV4M_NODE
);
12502 install_default(BGP_IPV4L_NODE
);
12503 install_default(BGP_IPV6_NODE
);
12504 install_default(BGP_IPV6M_NODE
);
12505 install_default(BGP_IPV6L_NODE
);
12506 install_default(BGP_VPNV4_NODE
);
12507 install_default(BGP_VPNV6_NODE
);
12508 install_default(BGP_FLOWSPECV4_NODE
);
12509 install_default(BGP_FLOWSPECV6_NODE
);
12510 install_default(BGP_EVPN_NODE
);
12511 install_default(BGP_EVPN_VNI_NODE
);
12513 /* "bgp multiple-instance" commands. */
12514 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
12515 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
12517 /* "bgp config-type" commands. */
12518 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
12519 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
12521 /* bgp route-map delay-timer commands. */
12522 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12523 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12525 /* Dummy commands (Currently not supported) */
12526 install_element(BGP_NODE
, &no_synchronization_cmd
);
12527 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12529 /* "router bgp" commands. */
12530 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12532 /* "no router bgp" commands. */
12533 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12535 /* "bgp router-id" commands. */
12536 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12537 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12539 /* "bgp cluster-id" commands. */
12540 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12541 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12543 /* "bgp confederation" commands. */
12544 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12545 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12547 /* "bgp confederation peers" commands. */
12548 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12549 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12551 /* bgp max-med command */
12552 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12553 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12554 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12555 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12556 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12558 /* bgp disable-ebgp-connected-nh-check */
12559 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12560 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12562 /* bgp update-delay command */
12563 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12564 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12565 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12567 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12568 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12569 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12570 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12572 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12573 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12575 /* "maximum-paths" commands. */
12576 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12577 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12578 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12579 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12580 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12581 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12582 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12583 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12584 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12585 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12586 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12587 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12588 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12589 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12590 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12592 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12593 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12594 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12595 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12596 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12598 /* "timers bgp" commands. */
12599 install_element(BGP_NODE
, &bgp_timers_cmd
);
12600 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12602 /* route-map delay-timer commands - per instance for backwards compat.
12604 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12605 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12607 /* "bgp client-to-client reflection" commands */
12608 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
12609 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
12611 /* "bgp always-compare-med" commands */
12612 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
12613 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
12615 /* "bgp deterministic-med" commands */
12616 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
12617 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
12619 /* "bgp graceful-restart" commands */
12620 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
12621 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
12622 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
12623 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
12624 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
12625 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
12627 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
12628 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
12630 /* "bgp graceful-shutdown" commands */
12631 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
12632 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
12634 /* "bgp fast-external-failover" commands */
12635 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
12636 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
12638 /* "bgp enforce-first-as" commands */
12639 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
12641 /* "bgp bestpath compare-routerid" commands */
12642 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
12643 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
12645 /* "bgp bestpath as-path ignore" commands */
12646 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
12647 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
12649 /* "bgp bestpath as-path confed" commands */
12650 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
12651 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
12653 /* "bgp bestpath as-path multipath-relax" commands */
12654 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
12655 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
12657 /* "bgp log-neighbor-changes" commands */
12658 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
12659 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
12661 /* "bgp bestpath med" commands */
12662 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
12663 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
12665 /* "no bgp default ipv4-unicast" commands. */
12666 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
12667 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
12669 /* "bgp network import-check" commands. */
12670 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
12671 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
12672 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
12674 /* "bgp default local-preference" commands. */
12675 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
12676 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
12678 /* bgp default show-hostname */
12679 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
12680 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
12682 /* "bgp default subgroup-pkt-queue-max" commands. */
12683 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
12684 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
12686 /* bgp ibgp-allow-policy-mods command */
12687 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
12688 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
12690 /* "bgp listen limit" commands. */
12691 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
12692 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
12694 /* "bgp listen range" commands. */
12695 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
12696 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
12698 /* "bgp default shutdown" command */
12699 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
12701 /* "neighbor remote-as" commands. */
12702 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
12703 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
12704 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
12705 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
12706 install_element(BGP_NODE
,
12707 &neighbor_interface_v6only_config_remote_as_cmd
);
12708 install_element(BGP_NODE
, &no_neighbor_cmd
);
12709 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
12711 /* "neighbor peer-group" commands. */
12712 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
12713 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
12714 install_element(BGP_NODE
,
12715 &no_neighbor_interface_peer_group_remote_as_cmd
);
12717 /* "neighbor local-as" commands. */
12718 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
12719 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
12720 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
12721 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
12723 /* "neighbor solo" commands. */
12724 install_element(BGP_NODE
, &neighbor_solo_cmd
);
12725 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
12727 /* "neighbor password" commands. */
12728 install_element(BGP_NODE
, &neighbor_password_cmd
);
12729 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
12731 /* "neighbor activate" commands. */
12732 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
12733 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
12734 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
12735 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
12736 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
12737 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
12738 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
12739 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
12740 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
12741 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
12742 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
12743 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
12745 /* "no neighbor activate" commands. */
12746 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
12747 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
12748 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
12749 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
12750 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
12751 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
12752 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
12753 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
12754 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
12755 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
12756 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
12757 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
12759 /* "neighbor peer-group" set commands. */
12760 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
12761 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12762 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12763 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12764 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12765 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12766 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12767 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12768 install_element(BGP_FLOWSPECV4_NODE
,
12769 &neighbor_set_peer_group_hidden_cmd
);
12770 install_element(BGP_FLOWSPECV6_NODE
,
12771 &neighbor_set_peer_group_hidden_cmd
);
12773 /* "no neighbor peer-group unset" commands. */
12774 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
12775 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12776 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12777 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12778 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12779 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12780 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12781 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12782 install_element(BGP_FLOWSPECV4_NODE
,
12783 &no_neighbor_set_peer_group_hidden_cmd
);
12784 install_element(BGP_FLOWSPECV6_NODE
,
12785 &no_neighbor_set_peer_group_hidden_cmd
);
12787 /* "neighbor softreconfiguration inbound" commands.*/
12788 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
12789 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
12790 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12791 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12792 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12793 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12794 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12795 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12796 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12797 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12798 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12799 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12800 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12801 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12802 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12803 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12804 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12805 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12806 install_element(BGP_FLOWSPECV4_NODE
,
12807 &neighbor_soft_reconfiguration_cmd
);
12808 install_element(BGP_FLOWSPECV4_NODE
,
12809 &no_neighbor_soft_reconfiguration_cmd
);
12810 install_element(BGP_FLOWSPECV6_NODE
,
12811 &neighbor_soft_reconfiguration_cmd
);
12812 install_element(BGP_FLOWSPECV6_NODE
,
12813 &no_neighbor_soft_reconfiguration_cmd
);
12815 /* "neighbor attribute-unchanged" commands. */
12816 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
12817 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
12818 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
12819 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
12820 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
12821 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
12822 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
12823 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
12824 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
12825 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
12826 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
12827 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
12828 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
12829 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
12830 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
12831 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
12832 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
12833 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
12835 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
12836 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
12838 /* "nexthop-local unchanged" commands */
12839 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
12840 install_element(BGP_IPV6_NODE
,
12841 &no_neighbor_nexthop_local_unchanged_cmd
);
12843 /* "neighbor next-hop-self" commands. */
12844 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
12845 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
12846 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
12847 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
12848 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
12849 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
12850 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
12851 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
12852 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
12853 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
12854 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
12855 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
12856 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
12857 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
12858 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
12859 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
12860 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
12861 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
12862 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
12863 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
12865 /* "neighbor next-hop-self force" commands. */
12866 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
12867 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
12868 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
12869 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12870 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
12871 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12872 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
12873 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12874 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
12875 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12876 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
12877 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12878 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
12879 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12880 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
12881 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12882 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
12883 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12885 /* "neighbor as-override" commands. */
12886 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
12887 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
12888 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
12889 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
12890 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
12891 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
12892 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
12893 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
12894 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
12895 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
12896 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
12897 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
12898 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
12899 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
12900 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
12901 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
12902 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
12903 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
12905 /* "neighbor remove-private-AS" commands. */
12906 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
12907 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
12908 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
12909 install_element(BGP_NODE
,
12910 &no_neighbor_remove_private_as_all_hidden_cmd
);
12911 install_element(BGP_NODE
,
12912 &neighbor_remove_private_as_replace_as_hidden_cmd
);
12913 install_element(BGP_NODE
,
12914 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
12915 install_element(BGP_NODE
,
12916 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
12919 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
12920 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
12921 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
12922 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
12923 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12924 install_element(BGP_IPV4_NODE
,
12925 &neighbor_remove_private_as_replace_as_cmd
);
12926 install_element(BGP_IPV4_NODE
,
12927 &no_neighbor_remove_private_as_replace_as_cmd
);
12928 install_element(BGP_IPV4_NODE
,
12929 &neighbor_remove_private_as_all_replace_as_cmd
);
12930 install_element(BGP_IPV4_NODE
,
12931 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12932 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
12933 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
12934 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
12935 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12936 install_element(BGP_IPV4M_NODE
,
12937 &neighbor_remove_private_as_replace_as_cmd
);
12938 install_element(BGP_IPV4M_NODE
,
12939 &no_neighbor_remove_private_as_replace_as_cmd
);
12940 install_element(BGP_IPV4M_NODE
,
12941 &neighbor_remove_private_as_all_replace_as_cmd
);
12942 install_element(BGP_IPV4M_NODE
,
12943 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12944 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
12945 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
12946 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
12947 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12948 install_element(BGP_IPV4L_NODE
,
12949 &neighbor_remove_private_as_replace_as_cmd
);
12950 install_element(BGP_IPV4L_NODE
,
12951 &no_neighbor_remove_private_as_replace_as_cmd
);
12952 install_element(BGP_IPV4L_NODE
,
12953 &neighbor_remove_private_as_all_replace_as_cmd
);
12954 install_element(BGP_IPV4L_NODE
,
12955 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12956 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
12957 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
12958 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
12959 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12960 install_element(BGP_IPV6_NODE
,
12961 &neighbor_remove_private_as_replace_as_cmd
);
12962 install_element(BGP_IPV6_NODE
,
12963 &no_neighbor_remove_private_as_replace_as_cmd
);
12964 install_element(BGP_IPV6_NODE
,
12965 &neighbor_remove_private_as_all_replace_as_cmd
);
12966 install_element(BGP_IPV6_NODE
,
12967 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12968 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
12969 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
12970 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
12971 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12972 install_element(BGP_IPV6M_NODE
,
12973 &neighbor_remove_private_as_replace_as_cmd
);
12974 install_element(BGP_IPV6M_NODE
,
12975 &no_neighbor_remove_private_as_replace_as_cmd
);
12976 install_element(BGP_IPV6M_NODE
,
12977 &neighbor_remove_private_as_all_replace_as_cmd
);
12978 install_element(BGP_IPV6M_NODE
,
12979 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12980 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
12981 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
12982 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
12983 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12984 install_element(BGP_IPV6L_NODE
,
12985 &neighbor_remove_private_as_replace_as_cmd
);
12986 install_element(BGP_IPV6L_NODE
,
12987 &no_neighbor_remove_private_as_replace_as_cmd
);
12988 install_element(BGP_IPV6L_NODE
,
12989 &neighbor_remove_private_as_all_replace_as_cmd
);
12990 install_element(BGP_IPV6L_NODE
,
12991 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12992 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
12993 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
12994 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
12995 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12996 install_element(BGP_VPNV4_NODE
,
12997 &neighbor_remove_private_as_replace_as_cmd
);
12998 install_element(BGP_VPNV4_NODE
,
12999 &no_neighbor_remove_private_as_replace_as_cmd
);
13000 install_element(BGP_VPNV4_NODE
,
13001 &neighbor_remove_private_as_all_replace_as_cmd
);
13002 install_element(BGP_VPNV4_NODE
,
13003 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13004 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
13005 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13006 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13007 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13008 install_element(BGP_VPNV6_NODE
,
13009 &neighbor_remove_private_as_replace_as_cmd
);
13010 install_element(BGP_VPNV6_NODE
,
13011 &no_neighbor_remove_private_as_replace_as_cmd
);
13012 install_element(BGP_VPNV6_NODE
,
13013 &neighbor_remove_private_as_all_replace_as_cmd
);
13014 install_element(BGP_VPNV6_NODE
,
13015 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13017 /* "neighbor send-community" commands.*/
13018 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
13019 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
13020 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
13021 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
13022 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
13023 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
13024 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
13025 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
13026 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
13027 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
13028 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
13029 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
13030 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
13031 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
13032 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
13033 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
13034 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
13035 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
13036 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
13037 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
13038 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
13039 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
13040 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
13041 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
13042 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
13043 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
13044 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
13045 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
13046 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
13047 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
13048 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
13049 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
13050 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
13051 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
13052 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
13053 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
13055 /* "neighbor route-reflector" commands.*/
13056 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
13057 install_element(BGP_NODE
,
13058 &no_neighbor_route_reflector_client_hidden_cmd
);
13059 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
13060 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
13061 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
13062 install_element(BGP_IPV4M_NODE
,
13063 &no_neighbor_route_reflector_client_cmd
);
13064 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
13065 install_element(BGP_IPV4L_NODE
,
13066 &no_neighbor_route_reflector_client_cmd
);
13067 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
13068 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
13069 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
13070 install_element(BGP_IPV6M_NODE
,
13071 &no_neighbor_route_reflector_client_cmd
);
13072 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
13073 install_element(BGP_IPV6L_NODE
,
13074 &no_neighbor_route_reflector_client_cmd
);
13075 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
13076 install_element(BGP_VPNV4_NODE
,
13077 &no_neighbor_route_reflector_client_cmd
);
13078 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
13079 install_element(BGP_VPNV6_NODE
,
13080 &no_neighbor_route_reflector_client_cmd
);
13081 install_element(BGP_FLOWSPECV4_NODE
,
13082 &neighbor_route_reflector_client_cmd
);
13083 install_element(BGP_FLOWSPECV4_NODE
,
13084 &no_neighbor_route_reflector_client_cmd
);
13085 install_element(BGP_FLOWSPECV6_NODE
,
13086 &neighbor_route_reflector_client_cmd
);
13087 install_element(BGP_FLOWSPECV6_NODE
,
13088 &no_neighbor_route_reflector_client_cmd
);
13089 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
13090 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
13092 /* "neighbor route-server" commands.*/
13093 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
13094 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
13095 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
13096 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
13097 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
13098 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
13099 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
13100 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
13101 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
13102 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
13103 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
13104 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
13105 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
13106 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
13107 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
13108 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
13109 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
13110 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
13111 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
13112 install_element(BGP_FLOWSPECV4_NODE
,
13113 &no_neighbor_route_server_client_cmd
);
13114 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
13115 install_element(BGP_FLOWSPECV6_NODE
,
13116 &no_neighbor_route_server_client_cmd
);
13118 /* "neighbor addpath-tx-all-paths" commands.*/
13119 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
13120 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
13121 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13122 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13123 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13124 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13125 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13126 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13127 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13128 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13129 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13130 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13131 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13132 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13133 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13134 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13135 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13136 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13138 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
13139 install_element(BGP_NODE
,
13140 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13141 install_element(BGP_NODE
,
13142 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13143 install_element(BGP_IPV4_NODE
,
13144 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13145 install_element(BGP_IPV4_NODE
,
13146 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13147 install_element(BGP_IPV4M_NODE
,
13148 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13149 install_element(BGP_IPV4M_NODE
,
13150 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13151 install_element(BGP_IPV4L_NODE
,
13152 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13153 install_element(BGP_IPV4L_NODE
,
13154 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13155 install_element(BGP_IPV6_NODE
,
13156 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13157 install_element(BGP_IPV6_NODE
,
13158 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13159 install_element(BGP_IPV6M_NODE
,
13160 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13161 install_element(BGP_IPV6M_NODE
,
13162 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13163 install_element(BGP_IPV6L_NODE
,
13164 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13165 install_element(BGP_IPV6L_NODE
,
13166 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13167 install_element(BGP_VPNV4_NODE
,
13168 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13169 install_element(BGP_VPNV4_NODE
,
13170 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13171 install_element(BGP_VPNV6_NODE
,
13172 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13173 install_element(BGP_VPNV6_NODE
,
13174 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13176 /* "neighbor passive" commands. */
13177 install_element(BGP_NODE
, &neighbor_passive_cmd
);
13178 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13181 /* "neighbor shutdown" commands. */
13182 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13183 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13184 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13185 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13187 /* "neighbor capability extended-nexthop" commands.*/
13188 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13189 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13191 /* "neighbor capability orf prefix-list" commands.*/
13192 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13193 install_element(BGP_NODE
,
13194 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13195 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13196 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13197 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13198 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13199 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13200 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13201 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13202 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13203 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13204 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13205 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13206 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13208 /* "neighbor capability dynamic" commands.*/
13209 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13210 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13212 /* "neighbor dont-capability-negotiate" commands. */
13213 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13214 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13216 /* "neighbor ebgp-multihop" commands. */
13217 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13218 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13219 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13221 /* "neighbor disable-connected-check" commands. */
13222 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13223 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13225 /* "neighbor enforce-first-as" commands. */
13226 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13227 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13229 /* "neighbor description" commands. */
13230 install_element(BGP_NODE
, &neighbor_description_cmd
);
13231 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13232 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13234 /* "neighbor update-source" commands. "*/
13235 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13236 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13238 /* "neighbor default-originate" commands. */
13239 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13240 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13241 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13242 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13243 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13244 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13245 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13246 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13247 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13248 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13249 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13250 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13251 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13252 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13253 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13254 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13255 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13256 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13257 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13258 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13259 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13261 /* "neighbor port" commands. */
13262 install_element(BGP_NODE
, &neighbor_port_cmd
);
13263 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13265 /* "neighbor weight" commands. */
13266 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13267 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13269 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13270 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13271 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13272 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13273 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13274 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13275 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13276 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13277 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13278 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13279 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13280 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13281 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13282 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13283 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13284 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13286 /* "neighbor override-capability" commands. */
13287 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13288 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13290 /* "neighbor strict-capability-match" commands. */
13291 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13292 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13294 /* "neighbor timers" commands. */
13295 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13296 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13298 /* "neighbor timers connect" commands. */
13299 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13300 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13302 /* "neighbor advertisement-interval" commands. */
13303 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13304 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13306 /* "neighbor interface" commands. */
13307 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13308 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13310 /* "neighbor distribute" commands. */
13311 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13312 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13313 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13314 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13315 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13316 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13317 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13318 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13319 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13320 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13321 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13322 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13323 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13324 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13325 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13326 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13327 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13328 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13330 /* "neighbor prefix-list" commands. */
13331 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13332 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13333 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13334 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13335 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13336 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13337 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13338 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13339 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13340 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13341 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13342 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13343 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13344 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13345 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13346 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13347 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13348 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13349 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13350 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13351 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13352 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13354 /* "neighbor filter-list" commands. */
13355 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13356 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13357 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13358 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13359 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13360 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13361 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13362 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13363 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13364 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13365 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13366 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13367 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13368 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13369 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13370 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13371 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13372 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13373 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13374 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13375 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13376 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13378 /* "neighbor route-map" commands. */
13379 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13380 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13381 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13382 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13383 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13384 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13385 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13386 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13387 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13388 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13389 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13390 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13391 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13392 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13393 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13394 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13395 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13396 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13397 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13398 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13399 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13400 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13401 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13402 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13404 /* "neighbor unsuppress-map" commands. */
13405 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13406 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13407 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13408 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13409 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13410 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13411 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13412 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13413 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13414 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13415 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13416 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13417 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13418 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13419 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13420 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13421 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13422 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13424 /* "neighbor maximum-prefix" commands. */
13425 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13426 install_element(BGP_NODE
,
13427 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13428 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13429 install_element(BGP_NODE
,
13430 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13431 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13432 install_element(BGP_NODE
,
13433 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13434 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13435 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13436 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13437 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13438 install_element(BGP_IPV4_NODE
,
13439 &neighbor_maximum_prefix_threshold_warning_cmd
);
13440 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13441 install_element(BGP_IPV4_NODE
,
13442 &neighbor_maximum_prefix_threshold_restart_cmd
);
13443 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13444 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13445 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13446 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13447 install_element(BGP_IPV4M_NODE
,
13448 &neighbor_maximum_prefix_threshold_warning_cmd
);
13449 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13450 install_element(BGP_IPV4M_NODE
,
13451 &neighbor_maximum_prefix_threshold_restart_cmd
);
13452 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13453 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13454 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13455 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13456 install_element(BGP_IPV4L_NODE
,
13457 &neighbor_maximum_prefix_threshold_warning_cmd
);
13458 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13459 install_element(BGP_IPV4L_NODE
,
13460 &neighbor_maximum_prefix_threshold_restart_cmd
);
13461 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13462 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13463 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13464 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13465 install_element(BGP_IPV6_NODE
,
13466 &neighbor_maximum_prefix_threshold_warning_cmd
);
13467 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13468 install_element(BGP_IPV6_NODE
,
13469 &neighbor_maximum_prefix_threshold_restart_cmd
);
13470 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13471 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13472 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13473 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13474 install_element(BGP_IPV6M_NODE
,
13475 &neighbor_maximum_prefix_threshold_warning_cmd
);
13476 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13477 install_element(BGP_IPV6M_NODE
,
13478 &neighbor_maximum_prefix_threshold_restart_cmd
);
13479 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13480 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13481 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13482 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13483 install_element(BGP_IPV6L_NODE
,
13484 &neighbor_maximum_prefix_threshold_warning_cmd
);
13485 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13486 install_element(BGP_IPV6L_NODE
,
13487 &neighbor_maximum_prefix_threshold_restart_cmd
);
13488 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13489 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13490 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13491 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13492 install_element(BGP_VPNV4_NODE
,
13493 &neighbor_maximum_prefix_threshold_warning_cmd
);
13494 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13495 install_element(BGP_VPNV4_NODE
,
13496 &neighbor_maximum_prefix_threshold_restart_cmd
);
13497 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13498 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13499 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13500 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13501 install_element(BGP_VPNV6_NODE
,
13502 &neighbor_maximum_prefix_threshold_warning_cmd
);
13503 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13504 install_element(BGP_VPNV6_NODE
,
13505 &neighbor_maximum_prefix_threshold_restart_cmd
);
13506 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13508 /* "neighbor allowas-in" */
13509 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13510 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13511 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13512 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13513 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13514 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13515 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13516 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13517 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13518 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13519 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13520 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13521 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13522 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13523 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13524 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13525 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13526 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13527 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13528 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13530 /* address-family commands. */
13531 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13532 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13533 #ifdef KEEP_OLD_VPN_COMMANDS
13534 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13535 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13536 #endif /* KEEP_OLD_VPN_COMMANDS */
13538 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13540 /* "exit-address-family" command. */
13541 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13542 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13543 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13544 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13545 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13546 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13547 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13548 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13549 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13550 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13551 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13553 /* "clear ip bgp commands" */
13554 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13556 /* clear ip bgp prefix */
13557 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13558 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13559 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13561 /* "show [ip] bgp summary" commands. */
13562 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13563 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13564 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13565 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13566 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13567 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
13569 /* "show [ip] bgp neighbors" commands. */
13570 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
13572 /* "show [ip] bgp peer-group" commands. */
13573 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
13575 /* "show [ip] bgp paths" commands. */
13576 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
13578 /* "show [ip] bgp community" commands. */
13579 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
13581 /* "show ip bgp large-community" commands. */
13582 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
13583 /* "show [ip] bgp attribute-info" commands. */
13584 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
13585 /* "show [ip] bgp route-leak" command */
13586 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
13588 /* "redistribute" commands. */
13589 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
13590 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
13591 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
13592 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
13593 install_element(BGP_NODE
,
13594 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
13595 install_element(BGP_NODE
,
13596 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
13597 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
13598 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
13599 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
13600 install_element(BGP_NODE
,
13601 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
13602 install_element(BGP_NODE
,
13603 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
13604 install_element(BGP_NODE
,
13605 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
13606 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
13607 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
13608 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
13609 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
13610 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
13611 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
13612 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
13613 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
13614 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
13615 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
13616 install_element(BGP_IPV4_NODE
,
13617 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
13618 install_element(BGP_IPV4_NODE
,
13619 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
13620 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
13621 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
13622 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
13623 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
13624 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
13625 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
13627 /* import|export vpn [route-map WORD] */
13628 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
13629 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
13631 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
13632 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
13634 /* ttl_security commands */
13635 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
13636 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
13638 /* "show [ip] bgp memory" commands. */
13639 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
13641 /* "show bgp martian next-hop" */
13642 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
13644 /* "show [ip] bgp views" commands. */
13645 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
13647 /* "show [ip] bgp vrfs" commands. */
13648 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
13650 /* Community-list. */
13651 community_list_vty();
13653 /* vpn-policy commands */
13654 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
13655 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
13656 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
13657 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
13658 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
13659 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
13660 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
13661 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
13662 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
13663 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
13664 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
13665 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
13667 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
13668 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
13670 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
13671 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
13672 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
13673 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
13674 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
13675 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
13676 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
13677 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
13678 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13679 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13680 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
13681 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
13684 #include "memory.h"
13685 #include "bgp_regex.h"
13686 #include "bgp_clist.h"
13687 #include "bgp_ecommunity.h"
13689 /* VTY functions. */
13691 /* Direction value to string conversion. */
13692 static const char *community_direct_str(int direct
)
13695 case COMMUNITY_DENY
:
13697 case COMMUNITY_PERMIT
:
13704 /* Display error string. */
13705 static void community_list_perror(struct vty
*vty
, int ret
)
13708 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
13709 vty_out(vty
, "%% Can't find community-list\n");
13711 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
13712 vty_out(vty
, "%% Malformed community-list value\n");
13714 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
13716 "%% Community name conflict, previously defined as standard community\n");
13718 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
13720 "%% Community name conflict, previously defined as expanded community\n");
13725 /* "community-list" keyword help string. */
13726 #define COMMUNITY_LIST_STR "Add a community list entry\n"
13728 /*community-list standard */
13729 DEFUN (community_list_standard
,
13730 bgp_community_list_standard_cmd
,
13731 "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13734 "Community list number (standard)\n"
13735 "Add an standard community-list entry\n"
13736 "Community list name\n"
13737 "Specify community to reject\n"
13738 "Specify community to accept\n"
13741 char *cl_name_or_number
= NULL
;
13743 int style
= COMMUNITY_LIST_STANDARD
;
13747 if (argv_find(argv
, argc
, "ip", &idx
)) {
13748 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
13749 vty_out(vty
, "if you are using this please migrate to the below command.\n");
13750 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
13751 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
13754 argv_find(argv
, argc
, "(1-99)", &idx
);
13755 argv_find(argv
, argc
, "WORD", &idx
);
13756 cl_name_or_number
= argv
[idx
]->arg
;
13757 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13759 argv_find(argv
, argc
, "AA:NN", &idx
);
13760 char *str
= argv_concat(argv
, argc
, idx
);
13762 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
13765 XFREE(MTYPE_TMP
, str
);
13768 /* Display error string. */
13769 community_list_perror(vty
, ret
);
13770 return CMD_WARNING_CONFIG_FAILED
;
13773 return CMD_SUCCESS
;
13776 #if CONFDATE > 20191005
13777 CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command")
13779 ALIAS (community_list_standard
,
13780 ip_community_list_standard_cmd
,
13781 "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 DEFUN (no_community_list_standard_all
,
13792 no_bgp_community_list_standard_all_cmd
,
13793 "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13797 "Community list number (standard)\n"
13798 "Add an standard community-list entry\n"
13799 "Community list name\n"
13800 "Specify community to reject\n"
13801 "Specify community to accept\n"
13804 char *cl_name_or_number
= NULL
;
13806 int style
= COMMUNITY_LIST_STANDARD
;
13810 if (argv_find(argv
, argc
, "ip", &idx
)) {
13811 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
13812 vty_out(vty
, "if you are using this please migrate to the below command.\n");
13813 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
13814 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used");
13817 argv_find(argv
, argc
, "(1-99)", &idx
);
13818 argv_find(argv
, argc
, "WORD", &idx
);
13819 cl_name_or_number
= argv
[idx
]->arg
;
13820 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13822 argv_find(argv
, argc
, "AA:NN", &idx
);
13823 char *str
= argv_concat(argv
, argc
, idx
);
13825 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
13828 XFREE(MTYPE_TMP
, str
);
13831 community_list_perror(vty
, ret
);
13832 return CMD_WARNING_CONFIG_FAILED
;
13835 return CMD_SUCCESS
;
13837 ALIAS (no_community_list_standard_all
,
13838 no_ip_community_list_standard_all_cmd
,
13839 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13843 "Community list number (standard)\n"
13844 "Add an standard community-list entry\n"
13845 "Community list name\n"
13846 "Specify community to reject\n"
13847 "Specify community to accept\n"
13850 /*community-list expanded */
13851 DEFUN (community_list_expanded_all
,
13852 bgp_community_list_expanded_all_cmd
,
13853 "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13856 "Community list number (expanded)\n"
13857 "Add an expanded community-list entry\n"
13858 "Community list name\n"
13859 "Specify community to reject\n"
13860 "Specify community to accept\n"
13863 char *cl_name_or_number
= NULL
;
13865 int style
= COMMUNITY_LIST_EXPANDED
;
13868 if (argv_find(argv
, argc
, "ip", &idx
)) {
13869 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
13870 vty_out(vty
, "if you are using this please migrate to the below command.\n");
13871 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
13872 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
13874 argv_find(argv
, argc
, "(100-500)", &idx
);
13875 argv_find(argv
, argc
, "WORD", &idx
);
13876 cl_name_or_number
= argv
[idx
]->arg
;
13877 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13879 argv_find(argv
, argc
, "AA:NN", &idx
);
13880 char *str
= argv_concat(argv
, argc
, idx
);
13882 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
13885 XFREE(MTYPE_TMP
, str
);
13888 /* Display error string. */
13889 community_list_perror(vty
, ret
);
13890 return CMD_WARNING_CONFIG_FAILED
;
13893 return CMD_SUCCESS
;
13896 ALIAS (community_list_expanded_all
,
13897 ip_community_list_expanded_all_cmd
,
13898 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13901 "Community list number (expanded)\n"
13902 "Add an expanded community-list entry\n"
13903 "Community list name\n"
13904 "Specify community to reject\n"
13905 "Specify community to accept\n"
13908 DEFUN (no_community_list_expanded_all
,
13909 no_bgp_community_list_expanded_all_cmd
,
13910 "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13914 "Community list number (expanded)\n"
13915 "Add an expanded community-list entry\n"
13916 "Community list name\n"
13917 "Specify community to reject\n"
13918 "Specify community to accept\n"
13921 char *cl_name_or_number
= NULL
;
13923 int style
= COMMUNITY_LIST_EXPANDED
;
13926 if (argv_find(argv
, argc
, "ip", &idx
)) {
13927 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
13928 vty_out(vty
, "if you are using this please migrate to the below command.\n");
13929 vty_out(vty
, "'no community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
13930 zlog_warn("Deprecated option: 'no community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
13932 argv_find(argv
, argc
, "(100-500)", &idx
);
13933 argv_find(argv
, argc
, "WORD", &idx
);
13934 cl_name_or_number
= argv
[idx
]->arg
;
13935 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13937 argv_find(argv
, argc
, "AA:NN", &idx
);
13938 char *str
= argv_concat(argv
, argc
, idx
);
13940 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
13943 XFREE(MTYPE_TMP
, str
);
13946 community_list_perror(vty
, ret
);
13947 return CMD_WARNING_CONFIG_FAILED
;
13950 return CMD_SUCCESS
;
13953 ALIAS (no_community_list_expanded_all
,
13954 no_ip_community_list_expanded_all_cmd
,
13955 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13959 "Community list number (expanded)\n"
13960 "Add an expanded community-list entry\n"
13961 "Community list name\n"
13962 "Specify community to reject\n"
13963 "Specify community to accept\n"
13966 /* Return configuration string of community-list entry. */
13967 static const char *community_list_config_str(struct community_entry
*entry
)
13974 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
13975 str
= community_str(entry
->u
.com
, false);
13976 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
13977 str
= lcommunity_str(entry
->u
.lcom
, false);
13979 str
= entry
->config
;
13984 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
13986 struct community_entry
*entry
;
13988 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13989 if (entry
== list
->head
) {
13990 if (all_digit(list
->name
))
13991 vty_out(vty
, "Community %s list %s\n",
13992 entry
->style
== COMMUNITY_LIST_STANDARD
13994 : "(expanded) access",
13997 vty_out(vty
, "Named Community %s list %s\n",
13998 entry
->style
== COMMUNITY_LIST_STANDARD
14004 vty_out(vty
, " %s\n",
14005 community_direct_str(entry
->direct
));
14007 vty_out(vty
, " %s %s\n",
14008 community_direct_str(entry
->direct
),
14009 community_list_config_str(entry
));
14013 DEFUN (show_community_list
,
14014 show_bgp_community_list_cmd
,
14015 "show bgp community-list",
14018 "List community-list\n")
14020 struct community_list
*list
;
14021 struct community_list_master
*cm
;
14024 if (argv_find(argv
, argc
, "ip", &idx
)) {
14025 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14026 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14027 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14028 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14030 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14032 return CMD_SUCCESS
;
14034 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14035 community_list_show(vty
, list
);
14037 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14038 community_list_show(vty
, list
);
14040 return CMD_SUCCESS
;
14043 ALIAS (show_community_list
,
14044 show_ip_community_list_cmd
,
14045 "show ip community-list",
14048 "List community-list\n")
14050 DEFUN (show_community_list_arg
,
14051 show_bgp_community_list_arg_cmd
,
14052 "show bgp community-list <(1-500)|WORD>",
14055 "List community-list\n"
14056 "Community-list number\n"
14057 "Community-list name\n")
14059 int idx_comm_list
= 3;
14060 struct community_list
*list
;
14063 if (argv_find(argv
, argc
, "ip", &idx
)) {
14064 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14065 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14066 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14067 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14069 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
14070 COMMUNITY_LIST_MASTER
);
14072 vty_out(vty
, "%% Can't find community-list\n");
14073 return CMD_WARNING
;
14076 community_list_show(vty
, list
);
14078 return CMD_SUCCESS
;
14081 ALIAS (show_community_list_arg
,
14082 show_ip_community_list_arg_cmd
,
14083 "show ip community-list <(1-500)|WORD>",
14086 "List community-list\n"
14087 "Community-list number\n"
14088 "Community-list name\n")
14091 * Large Community code.
14093 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
14094 struct cmd_token
**argv
, int style
,
14095 int reject_all_digit_name
)
14103 if (argv_find(argv
, argc
, "ip", &idx
)) {
14104 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14105 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14106 vty_out(vty
, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14107 zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14109 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14112 /* All digit name check. */
14114 argv_find(argv
, argc
, "WORD", &idx
);
14115 argv_find(argv
, argc
, "(1-99)", &idx
);
14116 argv_find(argv
, argc
, "(100-500)", &idx
);
14117 cl_name
= argv
[idx
]->arg
;
14118 if (reject_all_digit_name
&& all_digit(cl_name
)) {
14119 vty_out(vty
, "%% Community name cannot have all digits\n");
14120 return CMD_WARNING_CONFIG_FAILED
;
14124 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
14125 argv_find(argv
, argc
, "LINE", &idx
);
14126 /* Concat community string argument. */
14128 str
= argv_concat(argv
, argc
, idx
);
14132 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
14134 /* Free temporary community list string allocated by
14137 XFREE(MTYPE_TMP
, str
);
14140 community_list_perror(vty
, ret
);
14141 return CMD_WARNING_CONFIG_FAILED
;
14143 return CMD_SUCCESS
;
14146 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
14147 struct cmd_token
**argv
, int style
)
14154 if (argv_find(argv
, argc
, "ip", &idx
)) {
14155 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14156 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14157 vty_out(vty
, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14158 zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14160 argv_find(argv
, argc
, "permit", &idx
);
14161 argv_find(argv
, argc
, "deny", &idx
);
14164 /* Check the list direct. */
14165 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
14166 direct
= COMMUNITY_PERMIT
;
14168 direct
= COMMUNITY_DENY
;
14171 argv_find(argv
, argc
, "LINE", &idx
);
14172 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
14173 /* Concat community string argument. */
14174 str
= argv_concat(argv
, argc
, idx
);
14178 argv_find(argv
, argc
, "(1-99)", &idx
);
14179 argv_find(argv
, argc
, "(100-500)", &idx
);
14180 argv_find(argv
, argc
, "WORD", &idx
);
14182 /* Unset community list. */
14183 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
14186 /* Free temporary community list string allocated by
14189 XFREE(MTYPE_TMP
, str
);
14192 community_list_perror(vty
, ret
);
14193 return CMD_WARNING_CONFIG_FAILED
;
14196 return CMD_SUCCESS
;
14199 /* "large-community-list" keyword help string. */
14200 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
14201 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
14203 #if CONFDATE > 20191005
14204 CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command")
14206 DEFUN (lcommunity_list_standard
,
14207 bgp_lcommunity_list_standard_cmd
,
14208 "bgp large-community-list (1-99) <deny|permit>",
14210 LCOMMUNITY_LIST_STR
14211 "Large Community list number (standard)\n"
14212 "Specify large community to reject\n"
14213 "Specify large community to accept\n")
14215 return lcommunity_list_set_vty(vty
, argc
, argv
,
14216 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14219 ALIAS (lcommunity_list_standard
,
14220 ip_lcommunity_list_standard_cmd
,
14221 "ip large-community-list (1-99) <deny|permit>",
14223 LCOMMUNITY_LIST_STR
14224 "Large Community list number (standard)\n"
14225 "Specify large community to reject\n"
14226 "Specify large community to accept\n")
14228 DEFUN (lcommunity_list_standard1
,
14229 bgp_lcommunity_list_standard1_cmd
,
14230 "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...",
14232 LCOMMUNITY_LIST_STR
14233 "Large Community list number (standard)\n"
14234 "Specify large community to reject\n"
14235 "Specify large community to accept\n"
14236 LCOMMUNITY_VAL_STR
)
14238 return lcommunity_list_set_vty(vty
, argc
, argv
,
14239 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14242 ALIAS (lcommunity_list_standard1
,
14243 ip_lcommunity_list_standard1_cmd
,
14244 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
14246 LCOMMUNITY_LIST_STR
14247 "Large Community list number (standard)\n"
14248 "Specify large community to reject\n"
14249 "Specify large community to accept\n"
14250 LCOMMUNITY_VAL_STR
)
14252 DEFUN (lcommunity_list_expanded
,
14253 bgp_lcommunity_list_expanded_cmd
,
14254 "bgp large-community-list (100-500) <deny|permit> LINE...",
14256 LCOMMUNITY_LIST_STR
14257 "Large Community list number (expanded)\n"
14258 "Specify large community to reject\n"
14259 "Specify large community to accept\n"
14260 "An ordered list as a regular-expression\n")
14262 return lcommunity_list_set_vty(vty
, argc
, argv
,
14263 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
14266 ALIAS (lcommunity_list_expanded
,
14267 ip_lcommunity_list_expanded_cmd
,
14268 "ip large-community-list (100-500) <deny|permit> LINE...",
14270 LCOMMUNITY_LIST_STR
14271 "Large Community list number (expanded)\n"
14272 "Specify large community to reject\n"
14273 "Specify large community to accept\n"
14274 "An ordered list as a regular-expression\n")
14276 DEFUN (lcommunity_list_name_standard
,
14277 bgp_lcommunity_list_name_standard_cmd
,
14278 "bgp large-community-list standard WORD <deny|permit>",
14280 LCOMMUNITY_LIST_STR
14281 "Specify standard large-community-list\n"
14282 "Large Community list name\n"
14283 "Specify large community to reject\n"
14284 "Specify large community to accept\n")
14286 return lcommunity_list_set_vty(vty
, argc
, argv
,
14287 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14290 ALIAS (lcommunity_list_name_standard
,
14291 ip_lcommunity_list_name_standard_cmd
,
14292 "ip large-community-list standard WORD <deny|permit>",
14294 LCOMMUNITY_LIST_STR
14295 "Specify standard large-community-list\n"
14296 "Large Community list name\n"
14297 "Specify large community to reject\n"
14298 "Specify large community to accept\n")
14300 DEFUN (lcommunity_list_name_standard1
,
14301 bgp_lcommunity_list_name_standard1_cmd
,
14302 "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
14304 LCOMMUNITY_LIST_STR
14305 "Specify standard large-community-list\n"
14306 "Large Community list name\n"
14307 "Specify large community to reject\n"
14308 "Specify large community to accept\n"
14309 LCOMMUNITY_VAL_STR
)
14311 return lcommunity_list_set_vty(vty
, argc
, argv
,
14312 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14315 ALIAS (lcommunity_list_name_standard1
,
14316 ip_lcommunity_list_name_standard1_cmd
,
14317 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
14319 LCOMMUNITY_LIST_STR
14320 "Specify standard large-community-list\n"
14321 "Large Community list name\n"
14322 "Specify large community to reject\n"
14323 "Specify large community to accept\n"
14324 LCOMMUNITY_VAL_STR
)
14326 DEFUN (lcommunity_list_name_expanded
,
14327 bgp_lcommunity_list_name_expanded_cmd
,
14328 "bgp large-community-list expanded WORD <deny|permit> LINE...",
14330 LCOMMUNITY_LIST_STR
14331 "Specify expanded large-community-list\n"
14332 "Large Community list name\n"
14333 "Specify large community to reject\n"
14334 "Specify large community to accept\n"
14335 "An ordered list as a regular-expression\n")
14337 return lcommunity_list_set_vty(vty
, argc
, argv
,
14338 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
14341 ALIAS (lcommunity_list_name_expanded
,
14342 ip_lcommunity_list_name_expanded_cmd
,
14343 "ip large-community-list expanded WORD <deny|permit> LINE...",
14345 LCOMMUNITY_LIST_STR
14346 "Specify expanded large-community-list\n"
14347 "Large Community list name\n"
14348 "Specify large community to reject\n"
14349 "Specify large community to accept\n"
14350 "An ordered list as a regular-expression\n")
14352 DEFUN (no_lcommunity_list_standard_all
,
14353 no_bgp_lcommunity_list_standard_all_cmd
,
14354 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
14357 LCOMMUNITY_LIST_STR
14358 "Large Community list number (standard)\n"
14359 "Large Community list number (expanded)\n"
14360 "Large Community list name\n")
14362 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14363 LARGE_COMMUNITY_LIST_STANDARD
);
14366 ALIAS (no_lcommunity_list_standard_all
,
14367 no_ip_lcommunity_list_standard_all_cmd
,
14368 "no ip large-community-list <(1-99)|(100-500)|WORD>",
14371 LCOMMUNITY_LIST_STR
14372 "Large Community list number (standard)\n"
14373 "Large Community list number (expanded)\n"
14374 "Large Community list name\n")
14376 DEFUN (no_lcommunity_list_name_expanded_all
,
14377 no_bgp_lcommunity_list_name_expanded_all_cmd
,
14378 "no bgp large-community-list expanded WORD",
14381 LCOMMUNITY_LIST_STR
14382 "Specify expanded large-community-list\n"
14383 "Large Community list name\n")
14385 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14386 LARGE_COMMUNITY_LIST_EXPANDED
);
14389 ALIAS (no_lcommunity_list_name_expanded_all
,
14390 no_ip_lcommunity_list_name_expanded_all_cmd
,
14391 "no ip large-community-list expanded WORD",
14394 LCOMMUNITY_LIST_STR
14395 "Specify expanded large-community-list\n"
14396 "Large Community list name\n")
14398 DEFUN (no_lcommunity_list_standard
,
14399 no_bgp_lcommunity_list_standard_cmd
,
14400 "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
14403 LCOMMUNITY_LIST_STR
14404 "Large Community list number (standard)\n"
14405 "Specify large community to reject\n"
14406 "Specify large community to accept\n"
14407 LCOMMUNITY_VAL_STR
)
14409 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14410 LARGE_COMMUNITY_LIST_STANDARD
);
14413 ALIAS (no_lcommunity_list_standard
,
14414 no_ip_lcommunity_list_standard_cmd
,
14415 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
14418 LCOMMUNITY_LIST_STR
14419 "Large Community list number (standard)\n"
14420 "Specify large community to reject\n"
14421 "Specify large community to accept\n"
14422 LCOMMUNITY_VAL_STR
)
14424 DEFUN (no_lcommunity_list_expanded
,
14425 no_bgp_lcommunity_list_expanded_cmd
,
14426 "no bgp large-community-list (100-500) <deny|permit> LINE...",
14429 LCOMMUNITY_LIST_STR
14430 "Large Community list number (expanded)\n"
14431 "Specify large community to reject\n"
14432 "Specify large community to accept\n"
14433 "An ordered list as a regular-expression\n")
14435 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14436 LARGE_COMMUNITY_LIST_EXPANDED
);
14439 ALIAS (no_lcommunity_list_expanded
,
14440 no_ip_lcommunity_list_expanded_cmd
,
14441 "no ip large-community-list (100-500) <deny|permit> LINE...",
14444 LCOMMUNITY_LIST_STR
14445 "Large Community list number (expanded)\n"
14446 "Specify large community to reject\n"
14447 "Specify large community to accept\n"
14448 "An ordered list as a regular-expression\n")
14450 DEFUN (no_lcommunity_list_name_standard
,
14451 no_bgp_lcommunity_list_name_standard_cmd
,
14452 "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
14455 LCOMMUNITY_LIST_STR
14456 "Specify standard large-community-list\n"
14457 "Large Community list name\n"
14458 "Specify large community to reject\n"
14459 "Specify large community to accept\n"
14460 LCOMMUNITY_VAL_STR
)
14462 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14463 LARGE_COMMUNITY_LIST_STANDARD
);
14466 ALIAS (no_lcommunity_list_name_standard
,
14467 no_ip_lcommunity_list_name_standard_cmd
,
14468 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
14471 LCOMMUNITY_LIST_STR
14472 "Specify standard large-community-list\n"
14473 "Large Community list name\n"
14474 "Specify large community to reject\n"
14475 "Specify large community to accept\n"
14476 LCOMMUNITY_VAL_STR
)
14478 DEFUN (no_lcommunity_list_name_expanded
,
14479 no_bgp_lcommunity_list_name_expanded_cmd
,
14480 "no bgp large-community-list expanded WORD <deny|permit> LINE...",
14483 LCOMMUNITY_LIST_STR
14484 "Specify expanded large-community-list\n"
14485 "Large community list name\n"
14486 "Specify large community to reject\n"
14487 "Specify large community to accept\n"
14488 "An ordered list as a regular-expression\n")
14490 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14491 LARGE_COMMUNITY_LIST_EXPANDED
);
14494 ALIAS (no_lcommunity_list_name_expanded
,
14495 no_ip_lcommunity_list_name_expanded_cmd
,
14496 "no ip large-community-list expanded WORD <deny|permit> LINE...",
14499 LCOMMUNITY_LIST_STR
14500 "Specify expanded large-community-list\n"
14501 "Large community list name\n"
14502 "Specify large community to reject\n"
14503 "Specify large community to accept\n"
14504 "An ordered list as a regular-expression\n")
14506 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14508 struct community_entry
*entry
;
14510 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14511 if (entry
== list
->head
) {
14512 if (all_digit(list
->name
))
14513 vty_out(vty
, "Large community %s list %s\n",
14514 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14516 : "(expanded) access",
14520 "Named large community %s list %s\n",
14521 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14527 vty_out(vty
, " %s\n",
14528 community_direct_str(entry
->direct
));
14530 vty_out(vty
, " %s %s\n",
14531 community_direct_str(entry
->direct
),
14532 community_list_config_str(entry
));
14536 DEFUN (show_lcommunity_list
,
14537 show_bgp_lcommunity_list_cmd
,
14538 "show bgp large-community-list",
14541 "List large-community list\n")
14543 struct community_list
*list
;
14544 struct community_list_master
*cm
;
14547 if (argv_find(argv
, argc
, "ip", &idx
)) {
14548 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14549 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14550 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
14551 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
14554 cm
= community_list_master_lookup(bgp_clist
,
14555 LARGE_COMMUNITY_LIST_MASTER
);
14557 return CMD_SUCCESS
;
14559 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14560 lcommunity_list_show(vty
, list
);
14562 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14563 lcommunity_list_show(vty
, list
);
14565 return CMD_SUCCESS
;
14568 ALIAS (show_lcommunity_list
,
14569 show_ip_lcommunity_list_cmd
,
14570 "show ip large-community-list",
14573 "List large-community list\n")
14575 DEFUN (show_lcommunity_list_arg
,
14576 show_bgp_lcommunity_list_arg_cmd
,
14577 "show bgp large-community-list <(1-500)|WORD>",
14580 "List large-community list\n"
14581 "large-community-list number\n"
14582 "large-community-list name\n")
14584 struct community_list
*list
;
14587 if (argv_find(argv
, argc
, "ip", &idx
)) {
14588 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14589 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14590 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
14591 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
14594 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
,
14595 LARGE_COMMUNITY_LIST_MASTER
);
14597 vty_out(vty
, "%% Can't find extcommunity-list\n");
14598 return CMD_WARNING
;
14601 lcommunity_list_show(vty
, list
);
14603 return CMD_SUCCESS
;
14606 ALIAS (show_lcommunity_list_arg
,
14607 show_ip_lcommunity_list_arg_cmd
,
14608 "show ip large-community-list <(1-500)|WORD>",
14611 "List large-community list\n"
14612 "large-community-list number\n"
14613 "large-community-list name\n")
14615 /* "extcommunity-list" keyword help string. */
14616 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
14617 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
14619 DEFUN (extcommunity_list_standard
,
14620 bgp_extcommunity_list_standard_cmd
,
14621 "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14623 EXTCOMMUNITY_LIST_STR
14624 "Extended Community list number (standard)\n"
14625 "Specify standard extcommunity-list\n"
14626 "Community list name\n"
14627 "Specify community to reject\n"
14628 "Specify community to accept\n"
14629 EXTCOMMUNITY_VAL_STR
)
14631 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14633 char *cl_number_or_name
= NULL
;
14636 if (argv_find(argv
, argc
, "ip", &idx
)) {
14637 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14638 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14639 vty_out(vty
, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
14640 zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
14642 argv_find(argv
, argc
, "(1-99)", &idx
);
14643 argv_find(argv
, argc
, "WORD", &idx
);
14644 cl_number_or_name
= argv
[idx
]->arg
;
14645 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14647 argv_find(argv
, argc
, "AA:NN", &idx
);
14648 char *str
= argv_concat(argv
, argc
, idx
);
14650 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14653 XFREE(MTYPE_TMP
, str
);
14656 community_list_perror(vty
, ret
);
14657 return CMD_WARNING_CONFIG_FAILED
;
14660 return CMD_SUCCESS
;
14663 #if CONFDATE > 20191005
14664 CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command")
14666 ALIAS (extcommunity_list_standard
,
14667 ip_extcommunity_list_standard_cmd
,
14668 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14670 EXTCOMMUNITY_LIST_STR
14671 "Extended Community list number (standard)\n"
14672 "Specify standard extcommunity-list\n"
14673 "Community list name\n"
14674 "Specify community to reject\n"
14675 "Specify community to accept\n"
14676 EXTCOMMUNITY_VAL_STR
)
14678 DEFUN (extcommunity_list_name_expanded
,
14679 bgp_extcommunity_list_name_expanded_cmd
,
14680 "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14682 EXTCOMMUNITY_LIST_STR
14683 "Extended Community list number (expanded)\n"
14684 "Specify expanded extcommunity-list\n"
14685 "Extended Community list name\n"
14686 "Specify community to reject\n"
14687 "Specify community to accept\n"
14688 "An ordered list as a regular-expression\n")
14690 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
14692 char *cl_number_or_name
= NULL
;
14695 if (argv_find(argv
, argc
, "ip", &idx
)) {
14696 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14697 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14698 vty_out(vty
, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
14699 zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
14702 argv_find(argv
, argc
, "(100-500)", &idx
);
14703 argv_find(argv
, argc
, "WORD", &idx
);
14704 cl_number_or_name
= argv
[idx
]->arg
;
14705 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14707 argv_find(argv
, argc
, "LINE", &idx
);
14708 char *str
= argv_concat(argv
, argc
, idx
);
14710 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14713 XFREE(MTYPE_TMP
, str
);
14716 community_list_perror(vty
, ret
);
14717 return CMD_WARNING_CONFIG_FAILED
;
14720 return CMD_SUCCESS
;
14723 ALIAS (extcommunity_list_name_expanded
,
14724 ip_extcommunity_list_name_expanded_cmd
,
14725 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14727 EXTCOMMUNITY_LIST_STR
14728 "Extended Community list number (expanded)\n"
14729 "Specify expanded extcommunity-list\n"
14730 "Extended Community list name\n"
14731 "Specify community to reject\n"
14732 "Specify community to accept\n"
14733 "An ordered list as a regular-expression\n")
14735 DEFUN (no_extcommunity_list_standard_all
,
14736 no_bgp_extcommunity_list_standard_all_cmd
,
14737 "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14740 EXTCOMMUNITY_LIST_STR
14741 "Extended Community list number (standard)\n"
14742 "Specify standard extcommunity-list\n"
14743 "Community list name\n"
14744 "Specify community to reject\n"
14745 "Specify community to accept\n"
14746 EXTCOMMUNITY_VAL_STR
)
14748 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14750 char *cl_number_or_name
= NULL
;
14753 if (argv_find(argv
, argc
, "ip", &idx
)) {
14754 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
14755 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14756 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
14757 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
14759 argv_find(argv
, argc
, "(1-99)", &idx
);
14760 argv_find(argv
, argc
, "WORD", &idx
);
14761 cl_number_or_name
= argv
[idx
]->arg
;
14762 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14764 argv_find(argv
, argc
, "AA:NN", &idx
);
14765 char *str
= argv_concat(argv
, argc
, idx
);
14767 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
14770 XFREE(MTYPE_TMP
, str
);
14773 community_list_perror(vty
, ret
);
14774 return CMD_WARNING_CONFIG_FAILED
;
14777 return CMD_SUCCESS
;
14780 ALIAS (no_extcommunity_list_standard_all
,
14781 no_ip_extcommunity_list_standard_all_cmd
,
14782 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14785 EXTCOMMUNITY_LIST_STR
14786 "Extended Community list number (standard)\n"
14787 "Specify standard extcommunity-list\n"
14788 "Community list name\n"
14789 "Specify community to reject\n"
14790 "Specify community to accept\n"
14791 EXTCOMMUNITY_VAL_STR
)
14793 DEFUN (no_extcommunity_list_expanded_all
,
14794 no_bgp_extcommunity_list_expanded_all_cmd
,
14795 "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14798 EXTCOMMUNITY_LIST_STR
14799 "Extended Community list number (expanded)\n"
14800 "Specify expanded extcommunity-list\n"
14801 "Extended Community list name\n"
14802 "Specify community to reject\n"
14803 "Specify community to accept\n"
14804 "An ordered list as a regular-expression\n")
14806 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
14808 char *cl_number_or_name
= NULL
;
14811 if (argv_find(argv
, argc
, "ip", &idx
)) {
14812 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14813 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14814 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
14815 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
14817 argv_find(argv
, argc
, "(100-500)", &idx
);
14818 argv_find(argv
, argc
, "WORD", &idx
);
14819 cl_number_or_name
= argv
[idx
]->arg
;
14820 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14822 argv_find(argv
, argc
, "LINE", &idx
);
14823 char *str
= argv_concat(argv
, argc
, idx
);
14825 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
14828 XFREE(MTYPE_TMP
, str
);
14831 community_list_perror(vty
, ret
);
14832 return CMD_WARNING_CONFIG_FAILED
;
14835 return CMD_SUCCESS
;
14838 ALIAS (no_extcommunity_list_expanded_all
,
14839 no_ip_extcommunity_list_expanded_all_cmd
,
14840 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14843 EXTCOMMUNITY_LIST_STR
14844 "Extended Community list number (expanded)\n"
14845 "Specify expanded extcommunity-list\n"
14846 "Extended Community list name\n"
14847 "Specify community to reject\n"
14848 "Specify community to accept\n"
14849 "An ordered list as a regular-expression\n")
14851 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14853 struct community_entry
*entry
;
14855 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14856 if (entry
== list
->head
) {
14857 if (all_digit(list
->name
))
14858 vty_out(vty
, "Extended community %s list %s\n",
14859 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14861 : "(expanded) access",
14865 "Named extended community %s list %s\n",
14866 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14872 vty_out(vty
, " %s\n",
14873 community_direct_str(entry
->direct
));
14875 vty_out(vty
, " %s %s\n",
14876 community_direct_str(entry
->direct
),
14877 community_list_config_str(entry
));
14881 DEFUN (show_extcommunity_list
,
14882 show_bgp_extcommunity_list_cmd
,
14883 "show bgp extcommunity-list",
14886 "List extended-community list\n")
14888 struct community_list
*list
;
14889 struct community_list_master
*cm
;
14892 if (argv_find(argv
, argc
, "ip", &idx
)) {
14893 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
14894 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14895 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
14896 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
14898 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
14900 return CMD_SUCCESS
;
14902 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14903 extcommunity_list_show(vty
, list
);
14905 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14906 extcommunity_list_show(vty
, list
);
14908 return CMD_SUCCESS
;
14911 ALIAS (show_extcommunity_list
,
14912 show_ip_extcommunity_list_cmd
,
14913 "show ip extcommunity-list",
14916 "List extended-community list\n")
14918 DEFUN (show_extcommunity_list_arg
,
14919 show_bgp_extcommunity_list_arg_cmd
,
14920 "show bgp extcommunity-list <(1-500)|WORD>",
14923 "List extended-community list\n"
14924 "Extcommunity-list number\n"
14925 "Extcommunity-list name\n")
14927 int idx_comm_list
= 3;
14928 struct community_list
*list
;
14931 if (argv_find(argv
, argc
, "ip", &idx
)) {
14932 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14933 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14934 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
14935 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
14937 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
14938 EXTCOMMUNITY_LIST_MASTER
);
14940 vty_out(vty
, "%% Can't find extcommunity-list\n");
14941 return CMD_WARNING
;
14944 extcommunity_list_show(vty
, list
);
14946 return CMD_SUCCESS
;
14949 ALIAS (show_extcommunity_list_arg
,
14950 show_ip_extcommunity_list_arg_cmd
,
14951 "show ip extcommunity-list <(1-500)|WORD>",
14954 "List extended-community list\n"
14955 "Extcommunity-list number\n"
14956 "Extcommunity-list name\n")
14958 /* Display community-list and extcommunity-list configuration. */
14959 static int community_list_config_write(struct vty
*vty
)
14961 struct community_list
*list
;
14962 struct community_entry
*entry
;
14963 struct community_list_master
*cm
;
14966 /* Community-list. */
14967 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14969 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14970 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14971 vty_out(vty
, "bgp community-list %s %s %s\n", list
->name
,
14972 community_direct_str(entry
->direct
),
14973 community_list_config_str(entry
));
14976 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14977 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14978 vty_out(vty
, "bgp community-list %s %s %s %s\n",
14979 entry
->style
== COMMUNITY_LIST_STANDARD
14982 list
->name
, community_direct_str(entry
->direct
),
14983 community_list_config_str(entry
));
14987 /* Extcommunity-list. */
14988 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
14990 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14991 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14992 vty_out(vty
, "bgp extcommunity-list %s %s %s\n",
14993 list
->name
, community_direct_str(entry
->direct
),
14994 community_list_config_str(entry
));
14997 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14998 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14999 vty_out(vty
, "bgp extcommunity-list %s %s %s %s\n",
15000 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15003 list
->name
, community_direct_str(entry
->direct
),
15004 community_list_config_str(entry
));
15009 /* lcommunity-list. */
15010 cm
= community_list_master_lookup(bgp_clist
,
15011 LARGE_COMMUNITY_LIST_MASTER
);
15013 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15014 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15015 vty_out(vty
, "bgp large-community-list %s %s %s\n",
15016 list
->name
, community_direct_str(entry
->direct
),
15017 community_list_config_str(entry
));
15020 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15021 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15022 vty_out(vty
, "bgp large-community-list %s %s %s %s\n",
15023 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
15026 list
->name
, community_direct_str(entry
->direct
),
15027 community_list_config_str(entry
));
15034 static struct cmd_node community_list_node
= {
15035 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
15038 static void community_list_vty(void)
15040 install_node(&community_list_node
, community_list_config_write
);
15042 /* Community-list. */
15043 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
15044 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
15045 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
15046 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
15047 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
15048 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
15049 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
15050 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
15051 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
15052 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
15053 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
15054 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
15056 /* Extcommunity-list. */
15057 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
15058 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
15059 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
15060 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
15061 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
15062 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
15063 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
15064 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
15065 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
15066 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
15067 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
15068 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
15070 /* Large Community List */
15071 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
15072 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard1_cmd
);
15073 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
15074 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
15075 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard1_cmd
);
15076 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
15077 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_all_cmd
);
15078 install_element(CONFIG_NODE
,
15079 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
15080 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
15081 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
15082 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
15083 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
15084 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
15085 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
15086 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
15087 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
15088 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
15089 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
15090 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
15091 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
15092 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
15093 install_element(CONFIG_NODE
,
15094 &no_ip_lcommunity_list_name_expanded_all_cmd
);
15095 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
15096 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
15097 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
15098 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
15099 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
15100 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);