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 outputs\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 outputs\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 or specify \"interface\" keyword\n");
2744 vty_out(vty
, "%% if using an unnumbered interface neighbor\n");
2745 return CMD_WARNING_CONFIG_FAILED
;
2750 if (peer_address_self_check(bgp
, &su
)) {
2752 "%% Can not configure the local system as neighbor\n");
2753 return CMD_WARNING_CONFIG_FAILED
;
2755 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2758 /* This peer belongs to peer group. */
2760 case BGP_ERR_PEER_GROUP_MEMBER
:
2762 "%% Peer-group AS %u. Cannot configure remote-as for member\n",
2764 return CMD_WARNING_CONFIG_FAILED
;
2765 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2767 "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n",
2769 return CMD_WARNING_CONFIG_FAILED
;
2771 return bgp_vty_return(vty
, ret
);
2774 DEFUN (bgp_default_shutdown
,
2775 bgp_default_shutdown_cmd
,
2776 "[no] bgp default shutdown",
2779 "Configure BGP defaults\n"
2780 "Apply administrative shutdown to newly configured peers\n")
2782 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2783 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2787 DEFUN (neighbor_remote_as
,
2788 neighbor_remote_as_cmd
,
2789 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2792 "Specify a BGP neighbor\n"
2794 "Internal BGP peer\n"
2795 "External BGP peer\n")
2798 int idx_remote_as
= 3;
2799 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2800 argv
[idx_remote_as
]->arg
, AFI_IP
,
2804 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2805 afi_t afi
, safi_t safi
, int v6only
,
2806 const char *peer_group_name
,
2809 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2811 int as_type
= AS_UNSPECIFIED
;
2813 struct peer_group
*group
;
2817 group
= peer_group_lookup(bgp
, conf_if
);
2820 vty_out(vty
, "%% Name conflict with peer-group \n");
2821 return CMD_WARNING_CONFIG_FAILED
;
2825 if (as_str
[0] == 'i') {
2826 as_type
= AS_INTERNAL
;
2827 } else if (as_str
[0] == 'e') {
2828 as_type
= AS_EXTERNAL
;
2830 /* Get AS number. */
2831 as
= strtoul(as_str
, NULL
, 10);
2832 as_type
= AS_SPECIFIED
;
2836 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2839 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
2842 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2843 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2844 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2845 as_type
, 0, 0, NULL
);
2847 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2848 as_type
, afi
, safi
, NULL
);
2851 vty_out(vty
, "%% BGP failed to create peer\n");
2852 return CMD_WARNING_CONFIG_FAILED
;
2856 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2858 /* Request zebra to initiate IPv6 RAs on this interface. We do
2860 * any unnumbered peer in order to not worry about run-time
2862 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2864 * gets deleted later etc.)
2867 bgp_zebra_initiate_radv(bgp
, peer
);
2870 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2871 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2873 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2875 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2877 /* v6only flag changed. Reset bgp seesion */
2878 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2879 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2880 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2881 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2883 bgp_session_reset(peer
);
2886 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
2887 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
2888 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
2889 UNSET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
2892 if (peer_group_name
) {
2893 group
= peer_group_lookup(bgp
, peer_group_name
);
2895 vty_out(vty
, "%% Configure the peer-group first\n");
2896 return CMD_WARNING_CONFIG_FAILED
;
2899 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
2902 return bgp_vty_return(vty
, ret
);
2905 DEFUN (neighbor_interface_config
,
2906 neighbor_interface_config_cmd
,
2907 "neighbor WORD interface [peer-group WORD]",
2909 "Interface name or neighbor tag\n"
2910 "Enable BGP on interface\n"
2911 "Member of the peer-group\n"
2912 "Peer-group name\n")
2915 int idx_peer_group_word
= 4;
2917 if (argc
> idx_peer_group_word
)
2918 return peer_conf_interface_get(
2919 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
2920 argv
[idx_peer_group_word
]->arg
, NULL
);
2922 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2923 SAFI_UNICAST
, 0, NULL
, NULL
);
2926 DEFUN (neighbor_interface_config_v6only
,
2927 neighbor_interface_config_v6only_cmd
,
2928 "neighbor WORD interface v6only [peer-group WORD]",
2930 "Interface name or neighbor tag\n"
2931 "Enable BGP on interface\n"
2932 "Enable BGP with v6 link-local only\n"
2933 "Member of the peer-group\n"
2934 "Peer-group name\n")
2937 int idx_peer_group_word
= 5;
2939 if (argc
> idx_peer_group_word
)
2940 return peer_conf_interface_get(
2941 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
2942 argv
[idx_peer_group_word
]->arg
, NULL
);
2944 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2945 SAFI_UNICAST
, 1, NULL
, NULL
);
2949 DEFUN (neighbor_interface_config_remote_as
,
2950 neighbor_interface_config_remote_as_cmd
,
2951 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
2953 "Interface name or neighbor tag\n"
2954 "Enable BGP on interface\n"
2955 "Specify a BGP neighbor\n"
2957 "Internal BGP peer\n"
2958 "External BGP peer\n")
2961 int idx_remote_as
= 4;
2962 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2963 SAFI_UNICAST
, 0, NULL
,
2964 argv
[idx_remote_as
]->arg
);
2967 DEFUN (neighbor_interface_v6only_config_remote_as
,
2968 neighbor_interface_v6only_config_remote_as_cmd
,
2969 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
2971 "Interface name or neighbor tag\n"
2972 "Enable BGP with v6 link-local only\n"
2973 "Enable BGP on interface\n"
2974 "Specify a BGP neighbor\n"
2976 "Internal BGP peer\n"
2977 "External BGP peer\n")
2980 int idx_remote_as
= 5;
2981 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2982 SAFI_UNICAST
, 1, NULL
,
2983 argv
[idx_remote_as
]->arg
);
2986 DEFUN (neighbor_peer_group
,
2987 neighbor_peer_group_cmd
,
2988 "neighbor WORD peer-group",
2990 "Interface name or neighbor tag\n"
2991 "Configure peer-group\n")
2993 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2996 struct peer_group
*group
;
2998 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3000 vty_out(vty
, "%% Name conflict with interface: \n");
3001 return CMD_WARNING_CONFIG_FAILED
;
3004 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
3006 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
3007 return CMD_WARNING_CONFIG_FAILED
;
3015 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3019 "Specify a BGP neighbor\n"
3021 "Internal BGP peer\n"
3022 "External BGP peer\n")
3024 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3028 struct peer_group
*group
;
3032 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3034 /* look up for neighbor by interface name config. */
3035 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3037 /* Request zebra to terminate IPv6 RAs on this
3040 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3045 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3047 peer_group_delete(group
);
3049 vty_out(vty
, "%% Create the peer-group first\n");
3050 return CMD_WARNING_CONFIG_FAILED
;
3053 peer
= peer_lookup(bgp
, &su
);
3055 if (peer_dynamic_neighbor(peer
)) {
3057 "%% Operation not allowed on a dynamic neighbor\n");
3058 return CMD_WARNING_CONFIG_FAILED
;
3061 other
= peer
->doppelganger
;
3063 if (other
&& other
->status
!= Deleted
)
3071 DEFUN (no_neighbor_interface_config
,
3072 no_neighbor_interface_config_cmd
,
3073 "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]",
3077 "Configure BGP on interface\n"
3078 "Enable BGP with v6 link-local only\n"
3079 "Member of the peer-group\n"
3081 "Specify a BGP neighbor\n"
3083 "Internal BGP peer\n"
3084 "External BGP peer\n")
3086 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3090 /* look up for neighbor by interface name config. */
3091 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3093 /* Request zebra to terminate IPv6 RAs on this interface. */
3095 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3098 vty_out(vty
, "%% Create the bgp interface first\n");
3099 return CMD_WARNING_CONFIG_FAILED
;
3104 DEFUN (no_neighbor_peer_group
,
3105 no_neighbor_peer_group_cmd
,
3106 "no neighbor WORD peer-group",
3110 "Configure peer-group\n")
3112 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3114 struct peer_group
*group
;
3116 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3118 peer_group_delete(group
);
3120 vty_out(vty
, "%% Create the peer-group first\n");
3121 return CMD_WARNING_CONFIG_FAILED
;
3126 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3127 no_neighbor_interface_peer_group_remote_as_cmd
,
3128 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3131 "Interface name or neighbor tag\n"
3132 "Specify a BGP neighbor\n"
3134 "Internal BGP peer\n"
3135 "External BGP peer\n")
3137 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3139 struct peer_group
*group
;
3142 /* look up for neighbor by interface name config. */
3143 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3145 peer_as_change(peer
, 0, AS_SPECIFIED
);
3149 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3151 peer_group_remote_as_delete(group
);
3153 vty_out(vty
, "%% Create the peer-group or interface first\n");
3154 return CMD_WARNING_CONFIG_FAILED
;
3159 DEFUN (neighbor_local_as
,
3160 neighbor_local_as_cmd
,
3161 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3164 "Specify a local-as number\n"
3165 "AS number used as local AS\n")
3173 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3175 return CMD_WARNING_CONFIG_FAILED
;
3177 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3178 ret
= peer_local_as_set(peer
, as
, 0, 0);
3179 return bgp_vty_return(vty
, ret
);
3182 DEFUN (neighbor_local_as_no_prepend
,
3183 neighbor_local_as_no_prepend_cmd
,
3184 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3187 "Specify a local-as number\n"
3188 "AS number used as local AS\n"
3189 "Do not prepend local-as to updates from ebgp peers\n")
3197 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3199 return CMD_WARNING_CONFIG_FAILED
;
3201 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3202 ret
= peer_local_as_set(peer
, as
, 1, 0);
3203 return bgp_vty_return(vty
, ret
);
3206 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3207 neighbor_local_as_no_prepend_replace_as_cmd
,
3208 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3211 "Specify a local-as number\n"
3212 "AS number used as local AS\n"
3213 "Do not prepend local-as to updates from ebgp peers\n"
3214 "Do not prepend local-as to updates from ibgp peers\n")
3222 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3224 return CMD_WARNING_CONFIG_FAILED
;
3226 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3227 ret
= peer_local_as_set(peer
, as
, 1, 1);
3228 return bgp_vty_return(vty
, ret
);
3231 DEFUN (no_neighbor_local_as
,
3232 no_neighbor_local_as_cmd
,
3233 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3237 "Specify a local-as number\n"
3238 "AS number used as local AS\n"
3239 "Do not prepend local-as to updates from ebgp peers\n"
3240 "Do not prepend local-as to updates from ibgp peers\n")
3246 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3248 return CMD_WARNING_CONFIG_FAILED
;
3250 ret
= peer_local_as_unset(peer
);
3251 return bgp_vty_return(vty
, ret
);
3255 DEFUN (neighbor_solo
,
3257 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3260 "Solo peer - part of its own update group\n")
3266 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3268 return CMD_WARNING_CONFIG_FAILED
;
3270 ret
= update_group_adjust_soloness(peer
, 1);
3271 return bgp_vty_return(vty
, ret
);
3274 DEFUN (no_neighbor_solo
,
3275 no_neighbor_solo_cmd
,
3276 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3280 "Solo peer - part of its own update group\n")
3286 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3288 return CMD_WARNING_CONFIG_FAILED
;
3290 ret
= update_group_adjust_soloness(peer
, 0);
3291 return bgp_vty_return(vty
, ret
);
3294 DEFUN (neighbor_password
,
3295 neighbor_password_cmd
,
3296 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3307 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3309 return CMD_WARNING_CONFIG_FAILED
;
3311 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3312 return bgp_vty_return(vty
, ret
);
3315 DEFUN (no_neighbor_password
,
3316 no_neighbor_password_cmd
,
3317 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3328 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3330 return CMD_WARNING_CONFIG_FAILED
;
3332 ret
= peer_password_unset(peer
);
3333 return bgp_vty_return(vty
, ret
);
3336 DEFUN (neighbor_activate
,
3337 neighbor_activate_cmd
,
3338 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3341 "Enable the Address Family for this Neighbor\n")
3347 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3349 return CMD_WARNING_CONFIG_FAILED
;
3351 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3352 return bgp_vty_return(vty
, ret
);
3355 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3356 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3357 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3358 "Enable the Address Family for this Neighbor\n")
3360 DEFUN (no_neighbor_activate
,
3361 no_neighbor_activate_cmd
,
3362 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3366 "Enable the Address Family for this Neighbor\n")
3373 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3375 return CMD_WARNING_CONFIG_FAILED
;
3377 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3378 return bgp_vty_return(vty
, ret
);
3381 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3382 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3383 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3384 "Enable the Address Family for this Neighbor\n")
3386 DEFUN (neighbor_set_peer_group
,
3387 neighbor_set_peer_group_cmd
,
3388 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3391 "Member of the peer-group\n"
3392 "Peer-group name\n")
3394 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3401 struct peer_group
*group
;
3403 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3405 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3407 vty_out(vty
, "%% Malformed address or name: %s\n",
3408 argv
[idx_peer
]->arg
);
3409 return CMD_WARNING_CONFIG_FAILED
;
3412 if (peer_address_self_check(bgp
, &su
)) {
3414 "%% Can not configure the local system as neighbor\n");
3415 return CMD_WARNING_CONFIG_FAILED
;
3418 /* Disallow for dynamic neighbor. */
3419 peer
= peer_lookup(bgp
, &su
);
3420 if (peer
&& peer_dynamic_neighbor(peer
)) {
3422 "%% Operation not allowed on a dynamic neighbor\n");
3423 return CMD_WARNING_CONFIG_FAILED
;
3427 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3429 vty_out(vty
, "%% Configure the peer-group first\n");
3430 return CMD_WARNING_CONFIG_FAILED
;
3433 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3435 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3437 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3439 return CMD_WARNING_CONFIG_FAILED
;
3442 return bgp_vty_return(vty
, ret
);
3445 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3446 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3447 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3448 "Member of the peer-group\n"
3449 "Peer-group name\n")
3451 DEFUN (no_neighbor_set_peer_group
,
3452 no_neighbor_set_peer_group_cmd
,
3453 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3457 "Member of the peer-group\n"
3458 "Peer-group name\n")
3460 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3465 struct peer_group
*group
;
3467 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3469 return CMD_WARNING_CONFIG_FAILED
;
3471 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3473 vty_out(vty
, "%% Configure the peer-group first\n");
3474 return CMD_WARNING_CONFIG_FAILED
;
3477 ret
= peer_delete(peer
);
3479 return bgp_vty_return(vty
, ret
);
3482 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3483 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3484 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3485 "Member of the peer-group\n"
3486 "Peer-group name\n")
3488 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3489 uint32_t flag
, int set
)
3494 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3496 return CMD_WARNING_CONFIG_FAILED
;
3499 * If 'neighbor <interface>', then this is for directly connected peers,
3500 * we should not accept disable-connected-check.
3502 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3504 "%s is directly connected peer, cannot accept disable-"
3505 "connected-check\n",
3507 return CMD_WARNING_CONFIG_FAILED
;
3510 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3511 peer_tx_shutdown_message_unset(peer
);
3514 ret
= peer_flag_set(peer
, flag
);
3516 ret
= peer_flag_unset(peer
, flag
);
3518 return bgp_vty_return(vty
, ret
);
3521 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3523 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3526 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3529 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3532 /* neighbor passive. */
3533 DEFUN (neighbor_passive
,
3534 neighbor_passive_cmd
,
3535 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3538 "Don't send open messages to this neighbor\n")
3541 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3544 DEFUN (no_neighbor_passive
,
3545 no_neighbor_passive_cmd
,
3546 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3550 "Don't send open messages to this neighbor\n")
3553 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3556 /* neighbor shutdown. */
3557 DEFUN (neighbor_shutdown_msg
,
3558 neighbor_shutdown_msg_cmd
,
3559 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3562 "Administratively shut down this neighbor\n"
3563 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3564 "Shutdown message\n")
3570 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3574 return CMD_WARNING_CONFIG_FAILED
;
3575 message
= argv_concat(argv
, argc
, 4);
3576 peer_tx_shutdown_message_set(peer
, message
);
3577 XFREE(MTYPE_TMP
, message
);
3580 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3583 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3584 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3585 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3586 "Administratively shut down this neighbor\n")
3588 DEFUN (no_neighbor_shutdown_msg
,
3589 no_neighbor_shutdown_msg_cmd
,
3590 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3594 "Administratively shut down this neighbor\n"
3595 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3596 "Shutdown message\n")
3600 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3601 PEER_FLAG_SHUTDOWN
);
3604 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3605 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3606 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3607 "Administratively shut down this neighbor\n")
3609 /* neighbor capability dynamic. */
3610 DEFUN (neighbor_capability_dynamic
,
3611 neighbor_capability_dynamic_cmd
,
3612 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3615 "Advertise capability to the peer\n"
3616 "Advertise dynamic capability to this neighbor\n")
3619 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3620 PEER_FLAG_DYNAMIC_CAPABILITY
);
3623 DEFUN (no_neighbor_capability_dynamic
,
3624 no_neighbor_capability_dynamic_cmd
,
3625 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3629 "Advertise capability to the peer\n"
3630 "Advertise dynamic capability to this neighbor\n")
3633 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3634 PEER_FLAG_DYNAMIC_CAPABILITY
);
3637 /* neighbor dont-capability-negotiate */
3638 DEFUN (neighbor_dont_capability_negotiate
,
3639 neighbor_dont_capability_negotiate_cmd
,
3640 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3643 "Do not perform capability negotiation\n")
3646 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3647 PEER_FLAG_DONT_CAPABILITY
);
3650 DEFUN (no_neighbor_dont_capability_negotiate
,
3651 no_neighbor_dont_capability_negotiate_cmd
,
3652 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3656 "Do not perform capability negotiation\n")
3659 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3660 PEER_FLAG_DONT_CAPABILITY
);
3663 /* neighbor capability extended next hop encoding */
3664 DEFUN (neighbor_capability_enhe
,
3665 neighbor_capability_enhe_cmd
,
3666 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3669 "Advertise capability to the peer\n"
3670 "Advertise extended next-hop capability to the peer\n")
3673 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3674 PEER_FLAG_CAPABILITY_ENHE
);
3677 DEFUN (no_neighbor_capability_enhe
,
3678 no_neighbor_capability_enhe_cmd
,
3679 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3683 "Advertise capability to the peer\n"
3684 "Advertise extended next-hop capability to the peer\n")
3687 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3688 PEER_FLAG_CAPABILITY_ENHE
);
3691 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3692 afi_t afi
, safi_t safi
, uint32_t flag
,
3698 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3700 return CMD_WARNING_CONFIG_FAILED
;
3703 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3705 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3707 return bgp_vty_return(vty
, ret
);
3710 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3711 afi_t afi
, safi_t safi
, uint32_t flag
)
3713 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3716 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3717 afi_t afi
, safi_t safi
, uint32_t flag
)
3719 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3722 /* neighbor capability orf prefix-list. */
3723 DEFUN (neighbor_capability_orf_prefix
,
3724 neighbor_capability_orf_prefix_cmd
,
3725 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3728 "Advertise capability to the peer\n"
3729 "Advertise ORF capability to the peer\n"
3730 "Advertise prefixlist ORF capability to this neighbor\n"
3731 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3732 "Capability to RECEIVE the ORF from this neighbor\n"
3733 "Capability to SEND the ORF to this neighbor\n")
3736 int idx_send_recv
= 5;
3739 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3740 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3741 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3742 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3743 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3744 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3746 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3747 return CMD_WARNING_CONFIG_FAILED
;
3750 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3751 bgp_node_safi(vty
), flag
);
3755 neighbor_capability_orf_prefix
,
3756 neighbor_capability_orf_prefix_hidden_cmd
,
3757 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3758 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3759 "Advertise capability to the peer\n"
3760 "Advertise ORF capability to the peer\n"
3761 "Advertise prefixlist ORF capability to this neighbor\n"
3762 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3763 "Capability to RECEIVE the ORF from this neighbor\n"
3764 "Capability to SEND the ORF to this neighbor\n")
3766 DEFUN (no_neighbor_capability_orf_prefix
,
3767 no_neighbor_capability_orf_prefix_cmd
,
3768 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3772 "Advertise capability to the peer\n"
3773 "Advertise ORF capability to the peer\n"
3774 "Advertise prefixlist ORF capability to this neighbor\n"
3775 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3776 "Capability to RECEIVE the ORF from this neighbor\n"
3777 "Capability to SEND the ORF to this neighbor\n")
3780 int idx_send_recv
= 6;
3783 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3784 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3785 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3786 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3787 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3788 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3790 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3791 return CMD_WARNING_CONFIG_FAILED
;
3794 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3795 bgp_node_afi(vty
), bgp_node_safi(vty
),
3800 no_neighbor_capability_orf_prefix
,
3801 no_neighbor_capability_orf_prefix_hidden_cmd
,
3802 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3803 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3804 "Advertise capability to the peer\n"
3805 "Advertise ORF capability to the peer\n"
3806 "Advertise prefixlist ORF capability to this neighbor\n"
3807 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3808 "Capability to RECEIVE the ORF from this neighbor\n"
3809 "Capability to SEND the ORF to this neighbor\n")
3811 /* neighbor next-hop-self. */
3812 DEFUN (neighbor_nexthop_self
,
3813 neighbor_nexthop_self_cmd
,
3814 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3817 "Disable the next hop calculation for this neighbor\n")
3820 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3821 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3824 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3825 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3826 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3827 "Disable the next hop calculation for this neighbor\n")
3829 /* neighbor next-hop-self. */
3830 DEFUN (neighbor_nexthop_self_force
,
3831 neighbor_nexthop_self_force_cmd
,
3832 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3835 "Disable the next hop calculation for this neighbor\n"
3836 "Set the next hop to self for reflected routes\n")
3839 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3841 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3844 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3845 neighbor_nexthop_self_force_hidden_cmd
,
3846 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3847 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3848 "Disable the next hop calculation for this neighbor\n"
3849 "Set the next hop to self for reflected routes\n")
3851 DEFUN (no_neighbor_nexthop_self
,
3852 no_neighbor_nexthop_self_cmd
,
3853 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3857 "Disable the next hop calculation for this neighbor\n")
3860 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3861 bgp_node_afi(vty
), bgp_node_safi(vty
),
3862 PEER_FLAG_NEXTHOP_SELF
);
3865 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3866 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3867 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3868 "Disable the next hop calculation for this neighbor\n")
3870 DEFUN (no_neighbor_nexthop_self_force
,
3871 no_neighbor_nexthop_self_force_cmd
,
3872 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3876 "Disable the next hop calculation for this neighbor\n"
3877 "Set the next hop to self for reflected routes\n")
3880 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3881 bgp_node_afi(vty
), bgp_node_safi(vty
),
3882 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3885 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3886 no_neighbor_nexthop_self_force_hidden_cmd
,
3887 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3888 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3889 "Disable the next hop calculation for this neighbor\n"
3890 "Set the next hop to self for reflected routes\n")
3892 /* neighbor as-override */
3893 DEFUN (neighbor_as_override
,
3894 neighbor_as_override_cmd
,
3895 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3898 "Override ASNs in outbound updates if aspath equals remote-as\n")
3901 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3902 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
3905 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
3906 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3907 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3908 "Override ASNs in outbound updates if aspath equals remote-as\n")
3910 DEFUN (no_neighbor_as_override
,
3911 no_neighbor_as_override_cmd
,
3912 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3916 "Override ASNs in outbound updates if aspath equals remote-as\n")
3919 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3920 bgp_node_afi(vty
), bgp_node_safi(vty
),
3921 PEER_FLAG_AS_OVERRIDE
);
3924 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
3925 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3926 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3927 "Override ASNs in outbound updates if aspath equals remote-as\n")
3929 /* neighbor remove-private-AS. */
3930 DEFUN (neighbor_remove_private_as
,
3931 neighbor_remove_private_as_cmd
,
3932 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3935 "Remove private ASNs in outbound updates\n")
3938 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3940 PEER_FLAG_REMOVE_PRIVATE_AS
);
3943 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
3944 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3945 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3946 "Remove private ASNs in outbound updates\n")
3948 DEFUN (neighbor_remove_private_as_all
,
3949 neighbor_remove_private_as_all_cmd
,
3950 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3953 "Remove private ASNs in outbound updates\n"
3954 "Apply to all AS numbers\n")
3957 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3959 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
3962 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
3963 neighbor_remove_private_as_all_hidden_cmd
,
3964 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3965 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3966 "Remove private ASNs in outbound updates\n"
3967 "Apply to all AS numbers")
3969 DEFUN (neighbor_remove_private_as_replace_as
,
3970 neighbor_remove_private_as_replace_as_cmd
,
3971 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3974 "Remove private ASNs in outbound updates\n"
3975 "Replace private ASNs with our ASN in outbound updates\n")
3978 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3980 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
3983 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
3984 neighbor_remove_private_as_replace_as_hidden_cmd
,
3985 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3986 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3987 "Remove private ASNs in outbound updates\n"
3988 "Replace private ASNs with our ASN in outbound updates\n")
3990 DEFUN (neighbor_remove_private_as_all_replace_as
,
3991 neighbor_remove_private_as_all_replace_as_cmd
,
3992 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3995 "Remove private ASNs in outbound updates\n"
3996 "Apply to all AS numbers\n"
3997 "Replace private ASNs with our ASN in outbound updates\n")
4000 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4002 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4006 neighbor_remove_private_as_all_replace_as
,
4007 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4008 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4009 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4010 "Remove private ASNs in outbound updates\n"
4011 "Apply to all AS numbers\n"
4012 "Replace private ASNs with our ASN in outbound updates\n")
4014 DEFUN (no_neighbor_remove_private_as
,
4015 no_neighbor_remove_private_as_cmd
,
4016 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4020 "Remove private ASNs in outbound updates\n")
4023 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4024 bgp_node_afi(vty
), bgp_node_safi(vty
),
4025 PEER_FLAG_REMOVE_PRIVATE_AS
);
4028 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4029 no_neighbor_remove_private_as_hidden_cmd
,
4030 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4031 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4032 "Remove private ASNs in outbound updates\n")
4034 DEFUN (no_neighbor_remove_private_as_all
,
4035 no_neighbor_remove_private_as_all_cmd
,
4036 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4040 "Remove private ASNs in outbound updates\n"
4041 "Apply to all AS numbers\n")
4044 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4045 bgp_node_afi(vty
), bgp_node_safi(vty
),
4046 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4049 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4050 no_neighbor_remove_private_as_all_hidden_cmd
,
4051 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4052 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4053 "Remove private ASNs in outbound updates\n"
4054 "Apply to all AS numbers\n")
4056 DEFUN (no_neighbor_remove_private_as_replace_as
,
4057 no_neighbor_remove_private_as_replace_as_cmd
,
4058 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4062 "Remove private ASNs in outbound updates\n"
4063 "Replace private ASNs with our ASN in outbound updates\n")
4066 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4067 bgp_node_afi(vty
), bgp_node_safi(vty
),
4068 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4071 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4072 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4073 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4074 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4075 "Remove private ASNs in outbound updates\n"
4076 "Replace private ASNs with our ASN in outbound updates\n")
4078 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4079 no_neighbor_remove_private_as_all_replace_as_cmd
,
4080 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4084 "Remove private ASNs in outbound updates\n"
4085 "Apply to all AS numbers\n"
4086 "Replace private ASNs with our ASN in outbound updates\n")
4089 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4090 bgp_node_afi(vty
), bgp_node_safi(vty
),
4091 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4095 no_neighbor_remove_private_as_all_replace_as
,
4096 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4097 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4098 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4099 "Remove private ASNs in outbound updates\n"
4100 "Apply to all AS numbers\n"
4101 "Replace private ASNs with our ASN in outbound updates\n")
4104 /* neighbor send-community. */
4105 DEFUN (neighbor_send_community
,
4106 neighbor_send_community_cmd
,
4107 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4110 "Send Community attribute to this neighbor\n")
4114 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4116 PEER_FLAG_SEND_COMMUNITY
);
4119 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4120 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4121 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4122 "Send Community attribute to this neighbor\n")
4124 DEFUN (no_neighbor_send_community
,
4125 no_neighbor_send_community_cmd
,
4126 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4130 "Send Community attribute to this neighbor\n")
4134 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4135 bgp_node_afi(vty
), bgp_node_safi(vty
),
4136 PEER_FLAG_SEND_COMMUNITY
);
4139 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4140 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4141 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4142 "Send Community attribute to this neighbor\n")
4144 /* neighbor send-community extended. */
4145 DEFUN (neighbor_send_community_type
,
4146 neighbor_send_community_type_cmd
,
4147 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4150 "Send Community attribute to this neighbor\n"
4151 "Send Standard and Extended Community attributes\n"
4152 "Send Standard, Large and Extended Community attributes\n"
4153 "Send Extended Community attributes\n"
4154 "Send Standard Community attributes\n"
4155 "Send Large Community attributes\n")
4159 const char *type
= argv
[argc
- 1]->text
;
4161 if (strmatch(type
, "standard")) {
4162 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4163 } else if (strmatch(type
, "extended")) {
4164 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4165 } else if (strmatch(type
, "large")) {
4166 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4167 } else if (strmatch(type
, "both")) {
4168 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4169 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4170 } else { /* if (strmatch(type, "all")) */
4171 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4172 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4173 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4176 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4177 bgp_node_safi(vty
), flag
);
4181 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4182 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4183 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4184 "Send Community attribute to this neighbor\n"
4185 "Send Standard and Extended Community attributes\n"
4186 "Send Standard, Large and Extended Community attributes\n"
4187 "Send Extended Community attributes\n"
4188 "Send Standard Community attributes\n"
4189 "Send Large Community attributes\n")
4191 DEFUN (no_neighbor_send_community_type
,
4192 no_neighbor_send_community_type_cmd
,
4193 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4197 "Send Community attribute to this neighbor\n"
4198 "Send Standard and Extended Community attributes\n"
4199 "Send Standard, Large and Extended Community attributes\n"
4200 "Send Extended Community attributes\n"
4201 "Send Standard Community attributes\n"
4202 "Send Large Community attributes\n")
4206 const char *type
= argv
[argc
- 1]->text
;
4208 if (strmatch(type
, "standard")) {
4209 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4210 } else if (strmatch(type
, "extended")) {
4211 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4212 } else if (strmatch(type
, "large")) {
4213 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4214 } else if (strmatch(type
, "both")) {
4215 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4216 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4217 } else { /* if (strmatch(type, "all")) */
4218 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4219 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4220 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4223 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4224 bgp_node_afi(vty
), bgp_node_safi(vty
),
4229 no_neighbor_send_community_type
,
4230 no_neighbor_send_community_type_hidden_cmd
,
4231 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4232 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4233 "Send Community attribute to this neighbor\n"
4234 "Send Standard and Extended Community attributes\n"
4235 "Send Standard, Large and Extended Community attributes\n"
4236 "Send Extended Community attributes\n"
4237 "Send Standard Community attributes\n"
4238 "Send Large Community attributes\n")
4240 /* neighbor soft-reconfig. */
4241 DEFUN (neighbor_soft_reconfiguration
,
4242 neighbor_soft_reconfiguration_cmd
,
4243 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4246 "Per neighbor soft reconfiguration\n"
4247 "Allow inbound soft reconfiguration for this neighbor\n")
4250 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4252 PEER_FLAG_SOFT_RECONFIG
);
4255 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4256 neighbor_soft_reconfiguration_hidden_cmd
,
4257 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4258 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4259 "Per neighbor soft reconfiguration\n"
4260 "Allow inbound soft reconfiguration for this neighbor\n")
4262 DEFUN (no_neighbor_soft_reconfiguration
,
4263 no_neighbor_soft_reconfiguration_cmd
,
4264 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4268 "Per neighbor soft reconfiguration\n"
4269 "Allow inbound soft reconfiguration for this neighbor\n")
4272 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4273 bgp_node_afi(vty
), bgp_node_safi(vty
),
4274 PEER_FLAG_SOFT_RECONFIG
);
4277 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4278 no_neighbor_soft_reconfiguration_hidden_cmd
,
4279 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4280 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4281 "Per neighbor soft reconfiguration\n"
4282 "Allow inbound soft reconfiguration for this neighbor\n")
4284 DEFUN (neighbor_route_reflector_client
,
4285 neighbor_route_reflector_client_cmd
,
4286 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4289 "Configure a neighbor as Route Reflector client\n")
4295 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4297 return CMD_WARNING_CONFIG_FAILED
;
4299 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4301 PEER_FLAG_REFLECTOR_CLIENT
);
4304 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4305 neighbor_route_reflector_client_hidden_cmd
,
4306 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4307 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4308 "Configure a neighbor as Route Reflector client\n")
4310 DEFUN (no_neighbor_route_reflector_client
,
4311 no_neighbor_route_reflector_client_cmd
,
4312 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4316 "Configure a neighbor as Route Reflector client\n")
4319 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4320 bgp_node_afi(vty
), bgp_node_safi(vty
),
4321 PEER_FLAG_REFLECTOR_CLIENT
);
4324 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4325 no_neighbor_route_reflector_client_hidden_cmd
,
4326 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4327 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4328 "Configure a neighbor as Route Reflector client\n")
4330 /* neighbor route-server-client. */
4331 DEFUN (neighbor_route_server_client
,
4332 neighbor_route_server_client_cmd
,
4333 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4336 "Configure a neighbor as Route Server client\n")
4341 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4343 return CMD_WARNING_CONFIG_FAILED
;
4344 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4346 PEER_FLAG_RSERVER_CLIENT
);
4349 ALIAS_HIDDEN(neighbor_route_server_client
,
4350 neighbor_route_server_client_hidden_cmd
,
4351 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4352 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4353 "Configure a neighbor as Route Server client\n")
4355 DEFUN (no_neighbor_route_server_client
,
4356 no_neighbor_route_server_client_cmd
,
4357 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4361 "Configure a neighbor as Route Server client\n")
4364 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4365 bgp_node_afi(vty
), bgp_node_safi(vty
),
4366 PEER_FLAG_RSERVER_CLIENT
);
4369 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4370 no_neighbor_route_server_client_hidden_cmd
,
4371 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4372 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4373 "Configure a neighbor as Route Server client\n")
4375 DEFUN (neighbor_nexthop_local_unchanged
,
4376 neighbor_nexthop_local_unchanged_cmd
,
4377 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4380 "Configure treatment of outgoing link-local nexthop attribute\n"
4381 "Leave link-local nexthop unchanged for this peer\n")
4384 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4386 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4389 DEFUN (no_neighbor_nexthop_local_unchanged
,
4390 no_neighbor_nexthop_local_unchanged_cmd
,
4391 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4395 "Configure treatment of outgoing link-local-nexthop attribute\n"
4396 "Leave link-local nexthop unchanged for this peer\n")
4399 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4400 bgp_node_afi(vty
), bgp_node_safi(vty
),
4401 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4404 DEFUN (neighbor_attr_unchanged
,
4405 neighbor_attr_unchanged_cmd
,
4406 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4409 "BGP attribute is propagated unchanged to this neighbor\n"
4410 "As-path attribute\n"
4411 "Nexthop attribute\n"
4415 char *peer_str
= argv
[1]->arg
;
4418 afi_t afi
= bgp_node_afi(vty
);
4419 safi_t safi
= bgp_node_safi(vty
);
4421 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4423 return CMD_WARNING_CONFIG_FAILED
;
4425 if (argv_find(argv
, argc
, "as-path", &idx
))
4426 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4428 if (argv_find(argv
, argc
, "next-hop", &idx
))
4429 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4431 if (argv_find(argv
, argc
, "med", &idx
))
4432 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4434 /* no flags means all of them! */
4436 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4437 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4438 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4440 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4441 && peer_af_flag_check(peer
, afi
, safi
,
4442 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4443 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4444 PEER_FLAG_AS_PATH_UNCHANGED
);
4447 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4448 && peer_af_flag_check(peer
, afi
, safi
,
4449 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4450 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4451 PEER_FLAG_NEXTHOP_UNCHANGED
);
4454 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4455 && peer_af_flag_check(peer
, afi
, safi
,
4456 PEER_FLAG_MED_UNCHANGED
)) {
4457 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4458 PEER_FLAG_MED_UNCHANGED
);
4462 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4466 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4467 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4468 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4469 "BGP attribute is propagated unchanged to this neighbor\n"
4470 "As-path attribute\n"
4471 "Nexthop attribute\n"
4474 DEFUN (no_neighbor_attr_unchanged
,
4475 no_neighbor_attr_unchanged_cmd
,
4476 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4480 "BGP attribute is propagated unchanged to this neighbor\n"
4481 "As-path attribute\n"
4482 "Nexthop attribute\n"
4486 char *peer
= argv
[2]->arg
;
4489 if (argv_find(argv
, argc
, "as-path", &idx
))
4490 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4492 if (argv_find(argv
, argc
, "next-hop", &idx
))
4493 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4495 if (argv_find(argv
, argc
, "med", &idx
))
4496 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4498 if (!flags
) // no flags means all of them!
4500 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4501 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4502 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4505 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4506 bgp_node_safi(vty
), flags
);
4510 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4511 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4512 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4513 "BGP attribute is propagated unchanged to this neighbor\n"
4514 "As-path attribute\n"
4515 "Nexthop attribute\n"
4518 /* EBGP multihop configuration. */
4519 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4520 const char *ttl_str
)
4525 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4527 return CMD_WARNING_CONFIG_FAILED
;
4530 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4535 ttl
= strtoul(ttl_str
, NULL
, 10);
4537 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4540 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4544 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4546 return CMD_WARNING_CONFIG_FAILED
;
4548 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4551 /* neighbor ebgp-multihop. */
4552 DEFUN (neighbor_ebgp_multihop
,
4553 neighbor_ebgp_multihop_cmd
,
4554 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4557 "Allow EBGP neighbors not on directly connected networks\n")
4560 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4563 DEFUN (neighbor_ebgp_multihop_ttl
,
4564 neighbor_ebgp_multihop_ttl_cmd
,
4565 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4568 "Allow EBGP neighbors not on directly connected networks\n"
4569 "maximum hop count\n")
4573 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4574 argv
[idx_number
]->arg
);
4577 DEFUN (no_neighbor_ebgp_multihop
,
4578 no_neighbor_ebgp_multihop_cmd
,
4579 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4583 "Allow EBGP neighbors not on directly connected networks\n"
4584 "maximum hop count\n")
4587 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4591 /* disable-connected-check */
4592 DEFUN (neighbor_disable_connected_check
,
4593 neighbor_disable_connected_check_cmd
,
4594 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4597 "one-hop away EBGP peer using loopback address\n"
4598 "Enforce EBGP neighbors perform multihop\n")
4601 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4602 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4605 DEFUN (no_neighbor_disable_connected_check
,
4606 no_neighbor_disable_connected_check_cmd
,
4607 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4611 "one-hop away EBGP peer using loopback address\n"
4612 "Enforce EBGP neighbors perform multihop\n")
4615 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4616 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4620 /* enforce-first-as */
4621 DEFUN (neighbor_enforce_first_as
,
4622 neighbor_enforce_first_as_cmd
,
4623 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4626 "Enforce the first AS for EBGP routes\n")
4630 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4631 PEER_FLAG_ENFORCE_FIRST_AS
);
4634 DEFUN (no_neighbor_enforce_first_as
,
4635 no_neighbor_enforce_first_as_cmd
,
4636 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4640 "Enforce the first AS for EBGP routes\n")
4644 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4645 PEER_FLAG_ENFORCE_FIRST_AS
);
4649 DEFUN (neighbor_description
,
4650 neighbor_description_cmd
,
4651 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4654 "Neighbor specific description\n"
4655 "Up to 80 characters describing this neighbor\n")
4662 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4664 return CMD_WARNING_CONFIG_FAILED
;
4666 str
= argv_concat(argv
, argc
, idx_line
);
4668 peer_description_set(peer
, str
);
4670 XFREE(MTYPE_TMP
, str
);
4675 DEFUN (no_neighbor_description
,
4676 no_neighbor_description_cmd
,
4677 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4681 "Neighbor specific description\n")
4686 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4688 return CMD_WARNING_CONFIG_FAILED
;
4690 peer_description_unset(peer
);
4695 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4696 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4697 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4698 "Neighbor specific description\n"
4699 "Up to 80 characters describing this neighbor\n")
4701 /* Neighbor update-source. */
4702 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4703 const char *source_str
)
4709 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4711 return CMD_WARNING_CONFIG_FAILED
;
4717 if (str2sockunion(source_str
, &su
) == 0)
4718 peer_update_source_addr_set(peer
, &su
);
4720 if (str2prefix(source_str
, &p
)) {
4722 "%% Invalid update-source, remove prefix length \n");
4723 return CMD_WARNING_CONFIG_FAILED
;
4725 peer_update_source_if_set(peer
, source_str
);
4728 peer_update_source_unset(peer
);
4733 #define BGP_UPDATE_SOURCE_HELP_STR \
4736 "Interface name (requires zebra to be running)\n"
4738 DEFUN (neighbor_update_source
,
4739 neighbor_update_source_cmd
,
4740 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4743 "Source of routing updates\n"
4744 BGP_UPDATE_SOURCE_HELP_STR
)
4748 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4749 argv
[idx_peer_2
]->arg
);
4752 DEFUN (no_neighbor_update_source
,
4753 no_neighbor_update_source_cmd
,
4754 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4758 "Source of routing updates\n"
4759 BGP_UPDATE_SOURCE_HELP_STR
)
4762 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4765 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4766 afi_t afi
, safi_t safi
,
4767 const char *rmap
, int set
)
4771 struct route_map
*route_map
;
4773 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4775 return CMD_WARNING_CONFIG_FAILED
;
4778 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
4779 ret
= peer_default_originate_set(peer
, afi
, safi
,
4782 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4784 return bgp_vty_return(vty
, ret
);
4787 /* neighbor default-originate. */
4788 DEFUN (neighbor_default_originate
,
4789 neighbor_default_originate_cmd
,
4790 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4793 "Originate default route to this neighbor\n")
4796 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4798 bgp_node_safi(vty
), NULL
, 1);
4801 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4802 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4803 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4804 "Originate default route to this neighbor\n")
4806 DEFUN (neighbor_default_originate_rmap
,
4807 neighbor_default_originate_rmap_cmd
,
4808 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4811 "Originate default route to this neighbor\n"
4812 "Route-map to specify criteria to originate default\n"
4817 return peer_default_originate_set_vty(
4818 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4819 argv
[idx_word
]->arg
, 1);
4823 neighbor_default_originate_rmap
,
4824 neighbor_default_originate_rmap_hidden_cmd
,
4825 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4826 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4827 "Originate default route to this neighbor\n"
4828 "Route-map to specify criteria to originate default\n"
4831 DEFUN (no_neighbor_default_originate
,
4832 no_neighbor_default_originate_cmd
,
4833 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4837 "Originate default route to this neighbor\n"
4838 "Route-map to specify criteria to originate default\n"
4842 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4844 bgp_node_safi(vty
), NULL
, 0);
4848 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4849 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4850 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4851 "Originate default route to this neighbor\n"
4852 "Route-map to specify criteria to originate default\n"
4856 /* Set neighbor's BGP port. */
4857 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4858 const char *port_str
)
4864 peer
= peer_lookup_vty(vty
, ip_str
);
4866 return CMD_WARNING_CONFIG_FAILED
;
4869 sp
= getservbyname("bgp", "tcp");
4870 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
4872 port
= strtoul(port_str
, NULL
, 10);
4875 peer_port_set(peer
, port
);
4880 /* Set specified peer's BGP port. */
4881 DEFUN (neighbor_port
,
4883 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
4886 "Neighbor's BGP port\n"
4887 "TCP port number\n")
4891 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
4892 argv
[idx_number
]->arg
);
4895 DEFUN (no_neighbor_port
,
4896 no_neighbor_port_cmd
,
4897 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
4901 "Neighbor's BGP port\n"
4902 "TCP port number\n")
4905 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
4909 /* neighbor weight. */
4910 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4911 safi_t safi
, const char *weight_str
)
4915 unsigned long weight
;
4917 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4919 return CMD_WARNING_CONFIG_FAILED
;
4921 weight
= strtoul(weight_str
, NULL
, 10);
4923 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
4924 return bgp_vty_return(vty
, ret
);
4927 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4933 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4935 return CMD_WARNING_CONFIG_FAILED
;
4937 ret
= peer_weight_unset(peer
, afi
, safi
);
4938 return bgp_vty_return(vty
, ret
);
4941 DEFUN (neighbor_weight
,
4942 neighbor_weight_cmd
,
4943 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4946 "Set default weight for routes from this neighbor\n"
4951 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4952 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
4955 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
4956 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4957 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4958 "Set default weight for routes from this neighbor\n"
4961 DEFUN (no_neighbor_weight
,
4962 no_neighbor_weight_cmd
,
4963 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4967 "Set default weight for routes from this neighbor\n"
4971 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
4972 bgp_node_afi(vty
), bgp_node_safi(vty
));
4975 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
4976 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4977 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4978 "Set default weight for routes from this neighbor\n"
4982 /* Override capability negotiation. */
4983 DEFUN (neighbor_override_capability
,
4984 neighbor_override_capability_cmd
,
4985 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4988 "Override capability negotiation result\n")
4991 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4992 PEER_FLAG_OVERRIDE_CAPABILITY
);
4995 DEFUN (no_neighbor_override_capability
,
4996 no_neighbor_override_capability_cmd
,
4997 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5001 "Override capability negotiation result\n")
5004 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5005 PEER_FLAG_OVERRIDE_CAPABILITY
);
5008 DEFUN (neighbor_strict_capability
,
5009 neighbor_strict_capability_cmd
,
5010 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5013 "Strict capability negotiation match\n")
5017 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5018 PEER_FLAG_STRICT_CAP_MATCH
);
5021 DEFUN (no_neighbor_strict_capability
,
5022 no_neighbor_strict_capability_cmd
,
5023 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5027 "Strict capability negotiation match\n")
5031 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5032 PEER_FLAG_STRICT_CAP_MATCH
);
5035 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5036 const char *keep_str
, const char *hold_str
)
5043 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5045 return CMD_WARNING_CONFIG_FAILED
;
5047 keepalive
= strtoul(keep_str
, NULL
, 10);
5048 holdtime
= strtoul(hold_str
, NULL
, 10);
5050 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5052 return bgp_vty_return(vty
, ret
);
5055 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5060 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5062 return CMD_WARNING_CONFIG_FAILED
;
5064 ret
= peer_timers_unset(peer
);
5066 return bgp_vty_return(vty
, ret
);
5069 DEFUN (neighbor_timers
,
5070 neighbor_timers_cmd
,
5071 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5074 "BGP per neighbor timers\n"
5075 "Keepalive interval\n"
5080 int idx_number_2
= 4;
5081 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5082 argv
[idx_number
]->arg
,
5083 argv
[idx_number_2
]->arg
);
5086 DEFUN (no_neighbor_timers
,
5087 no_neighbor_timers_cmd
,
5088 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5092 "BGP per neighbor timers\n"
5093 "Keepalive interval\n"
5097 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5101 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5102 const char *time_str
)
5108 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5110 return CMD_WARNING_CONFIG_FAILED
;
5112 connect
= strtoul(time_str
, NULL
, 10);
5114 ret
= peer_timers_connect_set(peer
, connect
);
5116 return bgp_vty_return(vty
, ret
);
5119 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5124 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5126 return CMD_WARNING_CONFIG_FAILED
;
5128 ret
= peer_timers_connect_unset(peer
);
5130 return bgp_vty_return(vty
, ret
);
5133 DEFUN (neighbor_timers_connect
,
5134 neighbor_timers_connect_cmd
,
5135 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5138 "BGP per neighbor timers\n"
5139 "BGP connect timer\n"
5144 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5145 argv
[idx_number
]->arg
);
5148 DEFUN (no_neighbor_timers_connect
,
5149 no_neighbor_timers_connect_cmd
,
5150 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5154 "BGP per neighbor timers\n"
5155 "BGP connect timer\n"
5159 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5163 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5164 const char *time_str
, int set
)
5168 uint32_t routeadv
= 0;
5170 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5172 return CMD_WARNING_CONFIG_FAILED
;
5175 routeadv
= strtoul(time_str
, NULL
, 10);
5178 ret
= peer_advertise_interval_set(peer
, routeadv
);
5180 ret
= peer_advertise_interval_unset(peer
);
5182 return bgp_vty_return(vty
, ret
);
5185 DEFUN (neighbor_advertise_interval
,
5186 neighbor_advertise_interval_cmd
,
5187 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5190 "Minimum interval between sending BGP routing updates\n"
5191 "time in seconds\n")
5195 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5196 argv
[idx_number
]->arg
, 1);
5199 DEFUN (no_neighbor_advertise_interval
,
5200 no_neighbor_advertise_interval_cmd
,
5201 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5205 "Minimum interval between sending BGP routing updates\n"
5206 "time in seconds\n")
5209 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5213 /* Time to wait before processing route-map updates */
5214 DEFUN (bgp_set_route_map_delay_timer
,
5215 bgp_set_route_map_delay_timer_cmd
,
5216 "bgp route-map delay-timer (0-600)",
5218 "BGP route-map delay timer\n"
5219 "Time in secs to wait before processing route-map changes\n"
5220 "0 disables the timer, no route updates happen when route-maps change\n")
5223 uint32_t rmap_delay_timer
;
5225 if (argv
[idx_number
]->arg
) {
5226 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5227 bm
->rmap_update_timer
= rmap_delay_timer
;
5229 /* if the dynamic update handling is being disabled, and a timer
5231 * running, stop the timer and act as if the timer has already
5234 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5235 BGP_TIMER_OFF(bm
->t_rmap_update
);
5236 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5241 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5242 return CMD_WARNING_CONFIG_FAILED
;
5246 DEFUN (no_bgp_set_route_map_delay_timer
,
5247 no_bgp_set_route_map_delay_timer_cmd
,
5248 "no bgp route-map delay-timer [(0-600)]",
5251 "Default BGP route-map delay timer\n"
5252 "Reset to default time to wait for processing route-map changes\n"
5253 "0 disables the timer, no route updates happen when route-maps change\n")
5256 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5262 /* neighbor interface */
5263 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5268 peer
= peer_lookup_vty(vty
, ip_str
);
5269 if (!peer
|| peer
->conf_if
) {
5270 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5271 return CMD_WARNING_CONFIG_FAILED
;
5275 peer_interface_set(peer
, str
);
5277 peer_interface_unset(peer
);
5282 DEFUN (neighbor_interface
,
5283 neighbor_interface_cmd
,
5284 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5292 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5295 DEFUN (no_neighbor_interface
,
5296 no_neighbor_interface_cmd
,
5297 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5305 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5308 DEFUN (neighbor_distribute_list
,
5309 neighbor_distribute_list_cmd
,
5310 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5313 "Filter updates to/from this neighbor\n"
5314 "IP access-list number\n"
5315 "IP access-list number (expanded range)\n"
5316 "IP Access-list name\n"
5317 "Filter incoming updates\n"
5318 "Filter outgoing updates\n")
5325 const char *pstr
= argv
[idx_peer
]->arg
;
5326 const char *acl
= argv
[idx_acl
]->arg
;
5327 const char *inout
= argv
[argc
- 1]->text
;
5329 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5331 return CMD_WARNING_CONFIG_FAILED
;
5333 /* Check filter direction. */
5334 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5335 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5338 return bgp_vty_return(vty
, ret
);
5342 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5343 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5344 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5345 "Filter updates to/from this neighbor\n"
5346 "IP access-list number\n"
5347 "IP access-list number (expanded range)\n"
5348 "IP Access-list name\n"
5349 "Filter incoming updates\n"
5350 "Filter outgoing updates\n")
5352 DEFUN (no_neighbor_distribute_list
,
5353 no_neighbor_distribute_list_cmd
,
5354 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5358 "Filter updates to/from this neighbor\n"
5359 "IP access-list number\n"
5360 "IP access-list number (expanded range)\n"
5361 "IP Access-list name\n"
5362 "Filter incoming updates\n"
5363 "Filter outgoing updates\n")
5369 const char *pstr
= argv
[idx_peer
]->arg
;
5370 const char *inout
= argv
[argc
- 1]->text
;
5372 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5374 return CMD_WARNING_CONFIG_FAILED
;
5376 /* Check filter direction. */
5377 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5378 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5381 return bgp_vty_return(vty
, ret
);
5385 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5386 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5387 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5388 "Filter updates to/from this neighbor\n"
5389 "IP access-list number\n"
5390 "IP access-list number (expanded range)\n"
5391 "IP Access-list name\n"
5392 "Filter incoming updates\n"
5393 "Filter outgoing updates\n")
5395 /* Set prefix list to the peer. */
5396 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5397 afi_t afi
, safi_t safi
,
5398 const char *name_str
,
5399 const char *direct_str
)
5402 int direct
= FILTER_IN
;
5405 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5407 return CMD_WARNING_CONFIG_FAILED
;
5409 /* Check filter direction. */
5410 if (strncmp(direct_str
, "i", 1) == 0)
5412 else if (strncmp(direct_str
, "o", 1) == 0)
5413 direct
= FILTER_OUT
;
5415 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5417 return bgp_vty_return(vty
, ret
);
5420 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5421 afi_t afi
, safi_t safi
,
5422 const char *direct_str
)
5426 int direct
= FILTER_IN
;
5428 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5430 return CMD_WARNING_CONFIG_FAILED
;
5432 /* Check filter direction. */
5433 if (strncmp(direct_str
, "i", 1) == 0)
5435 else if (strncmp(direct_str
, "o", 1) == 0)
5436 direct
= FILTER_OUT
;
5438 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5440 return bgp_vty_return(vty
, ret
);
5443 DEFUN (neighbor_prefix_list
,
5444 neighbor_prefix_list_cmd
,
5445 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5448 "Filter updates to/from this neighbor\n"
5449 "Name of a prefix list\n"
5450 "Filter incoming updates\n"
5451 "Filter outgoing updates\n")
5456 return peer_prefix_list_set_vty(
5457 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5458 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5461 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5462 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5463 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5464 "Filter updates to/from this neighbor\n"
5465 "Name of a prefix list\n"
5466 "Filter incoming updates\n"
5467 "Filter outgoing updates\n")
5469 DEFUN (no_neighbor_prefix_list
,
5470 no_neighbor_prefix_list_cmd
,
5471 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5475 "Filter updates to/from this neighbor\n"
5476 "Name of a prefix list\n"
5477 "Filter incoming updates\n"
5478 "Filter outgoing updates\n")
5482 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5483 bgp_node_afi(vty
), bgp_node_safi(vty
),
5484 argv
[idx_in_out
]->arg
);
5487 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5488 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5489 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5490 "Filter updates to/from this neighbor\n"
5491 "Name of a prefix list\n"
5492 "Filter incoming updates\n"
5493 "Filter outgoing updates\n")
5495 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5496 safi_t safi
, const char *name_str
,
5497 const char *direct_str
)
5501 int direct
= FILTER_IN
;
5503 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5505 return CMD_WARNING_CONFIG_FAILED
;
5507 /* Check filter direction. */
5508 if (strncmp(direct_str
, "i", 1) == 0)
5510 else if (strncmp(direct_str
, "o", 1) == 0)
5511 direct
= FILTER_OUT
;
5513 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5515 return bgp_vty_return(vty
, ret
);
5518 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5519 safi_t safi
, const char *direct_str
)
5523 int direct
= FILTER_IN
;
5525 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5527 return CMD_WARNING_CONFIG_FAILED
;
5529 /* Check filter direction. */
5530 if (strncmp(direct_str
, "i", 1) == 0)
5532 else if (strncmp(direct_str
, "o", 1) == 0)
5533 direct
= FILTER_OUT
;
5535 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5537 return bgp_vty_return(vty
, ret
);
5540 DEFUN (neighbor_filter_list
,
5541 neighbor_filter_list_cmd
,
5542 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5545 "Establish BGP filters\n"
5546 "AS path access-list name\n"
5547 "Filter incoming routes\n"
5548 "Filter outgoing routes\n")
5553 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5554 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5555 argv
[idx_in_out
]->arg
);
5558 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5559 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5560 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5561 "Establish BGP filters\n"
5562 "AS path access-list name\n"
5563 "Filter incoming routes\n"
5564 "Filter outgoing routes\n")
5566 DEFUN (no_neighbor_filter_list
,
5567 no_neighbor_filter_list_cmd
,
5568 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5572 "Establish BGP filters\n"
5573 "AS path access-list name\n"
5574 "Filter incoming routes\n"
5575 "Filter outgoing routes\n")
5579 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5580 bgp_node_afi(vty
), bgp_node_safi(vty
),
5581 argv
[idx_in_out
]->arg
);
5584 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5585 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5586 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5587 "Establish BGP filters\n"
5588 "AS path access-list name\n"
5589 "Filter incoming routes\n"
5590 "Filter outgoing routes\n")
5592 /* Set route-map to the peer. */
5593 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5594 afi_t afi
, safi_t safi
, const char *name_str
,
5595 const char *direct_str
)
5599 int direct
= RMAP_IN
;
5600 struct route_map
*route_map
;
5602 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5604 return CMD_WARNING_CONFIG_FAILED
;
5606 /* Check filter direction. */
5607 if (strncmp(direct_str
, "in", 2) == 0)
5609 else if (strncmp(direct_str
, "o", 1) == 0)
5612 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5613 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
5615 return bgp_vty_return(vty
, ret
);
5618 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5619 afi_t afi
, safi_t safi
,
5620 const char *direct_str
)
5624 int direct
= RMAP_IN
;
5626 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5628 return CMD_WARNING_CONFIG_FAILED
;
5630 /* Check filter direction. */
5631 if (strncmp(direct_str
, "in", 2) == 0)
5633 else if (strncmp(direct_str
, "o", 1) == 0)
5636 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5638 return bgp_vty_return(vty
, ret
);
5641 DEFUN (neighbor_route_map
,
5642 neighbor_route_map_cmd
,
5643 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5646 "Apply route map to neighbor\n"
5647 "Name of route map\n"
5648 "Apply map to incoming routes\n"
5649 "Apply map to outbound routes\n")
5654 return peer_route_map_set_vty(
5655 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5656 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5659 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5660 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5661 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5662 "Apply route map to neighbor\n"
5663 "Name of route map\n"
5664 "Apply map to incoming routes\n"
5665 "Apply map to outbound routes\n")
5667 DEFUN (no_neighbor_route_map
,
5668 no_neighbor_route_map_cmd
,
5669 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5673 "Apply route map to neighbor\n"
5674 "Name of route map\n"
5675 "Apply map to incoming routes\n"
5676 "Apply map to outbound routes\n")
5680 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5681 bgp_node_afi(vty
), bgp_node_safi(vty
),
5682 argv
[idx_in_out
]->arg
);
5685 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5686 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5687 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5688 "Apply route map to neighbor\n"
5689 "Name of route map\n"
5690 "Apply map to incoming routes\n"
5691 "Apply map to outbound routes\n")
5693 /* Set unsuppress-map to the peer. */
5694 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5695 afi_t afi
, safi_t safi
,
5696 const char *name_str
)
5700 struct route_map
*route_map
;
5702 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5704 return CMD_WARNING_CONFIG_FAILED
;
5706 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5707 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
5709 return bgp_vty_return(vty
, ret
);
5712 /* Unset route-map from the peer. */
5713 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5714 afi_t afi
, safi_t safi
)
5719 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5721 return CMD_WARNING_CONFIG_FAILED
;
5723 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5725 return bgp_vty_return(vty
, ret
);
5728 DEFUN (neighbor_unsuppress_map
,
5729 neighbor_unsuppress_map_cmd
,
5730 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5733 "Route-map to selectively unsuppress suppressed routes\n"
5734 "Name of route map\n")
5738 return peer_unsuppress_map_set_vty(
5739 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5740 argv
[idx_word
]->arg
);
5743 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5744 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5745 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5746 "Route-map to selectively unsuppress suppressed routes\n"
5747 "Name of route map\n")
5749 DEFUN (no_neighbor_unsuppress_map
,
5750 no_neighbor_unsuppress_map_cmd
,
5751 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5755 "Route-map to selectively unsuppress suppressed routes\n"
5756 "Name of route map\n")
5759 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5761 bgp_node_safi(vty
));
5764 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5765 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5766 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5767 "Route-map to selectively unsuppress suppressed routes\n"
5768 "Name of route map\n")
5770 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5771 afi_t afi
, safi_t safi
,
5772 const char *num_str
,
5773 const char *threshold_str
, int warning
,
5774 const char *restart_str
)
5782 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5784 return CMD_WARNING_CONFIG_FAILED
;
5786 max
= strtoul(num_str
, NULL
, 10);
5788 threshold
= atoi(threshold_str
);
5790 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5793 restart
= atoi(restart_str
);
5797 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5800 return bgp_vty_return(vty
, ret
);
5803 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5804 afi_t afi
, safi_t safi
)
5809 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5811 return CMD_WARNING_CONFIG_FAILED
;
5813 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5815 return bgp_vty_return(vty
, ret
);
5818 /* Maximum number of prefix configuration. prefix count is different
5819 for each peer configuration. So this configuration can be set for
5820 each peer configuration. */
5821 DEFUN (neighbor_maximum_prefix
,
5822 neighbor_maximum_prefix_cmd
,
5823 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5826 "Maximum number of prefix accept from this peer\n"
5827 "maximum no. of prefix limit\n")
5831 return peer_maximum_prefix_set_vty(
5832 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5833 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5836 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5837 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5838 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5839 "Maximum number of prefix accept from this peer\n"
5840 "maximum no. of prefix limit\n")
5842 DEFUN (neighbor_maximum_prefix_threshold
,
5843 neighbor_maximum_prefix_threshold_cmd
,
5844 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5847 "Maximum number of prefix accept from this peer\n"
5848 "maximum no. of prefix limit\n"
5849 "Threshold value (%) at which to generate a warning msg\n")
5853 int idx_number_2
= 4;
5854 return peer_maximum_prefix_set_vty(
5855 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5856 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5860 neighbor_maximum_prefix_threshold
,
5861 neighbor_maximum_prefix_threshold_hidden_cmd
,
5862 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5863 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5864 "Maximum number of prefix accept from this peer\n"
5865 "maximum no. of prefix limit\n"
5866 "Threshold value (%) at which to generate a warning msg\n")
5868 DEFUN (neighbor_maximum_prefix_warning
,
5869 neighbor_maximum_prefix_warning_cmd
,
5870 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5873 "Maximum number of prefix accept from this peer\n"
5874 "maximum no. of prefix limit\n"
5875 "Only give warning message when limit is exceeded\n")
5879 return peer_maximum_prefix_set_vty(
5880 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5881 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
5885 neighbor_maximum_prefix_warning
,
5886 neighbor_maximum_prefix_warning_hidden_cmd
,
5887 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5888 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5889 "Maximum number of prefix accept from this peer\n"
5890 "maximum no. of prefix limit\n"
5891 "Only give warning message when limit is exceeded\n")
5893 DEFUN (neighbor_maximum_prefix_threshold_warning
,
5894 neighbor_maximum_prefix_threshold_warning_cmd
,
5895 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5898 "Maximum number of prefix accept from this peer\n"
5899 "maximum no. of prefix limit\n"
5900 "Threshold value (%) at which to generate a warning msg\n"
5901 "Only give warning message when limit is exceeded\n")
5905 int idx_number_2
= 4;
5906 return peer_maximum_prefix_set_vty(
5907 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5908 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
5912 neighbor_maximum_prefix_threshold_warning
,
5913 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
5914 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5915 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5916 "Maximum number of prefix accept from this peer\n"
5917 "maximum no. of prefix limit\n"
5918 "Threshold value (%) at which to generate a warning msg\n"
5919 "Only give warning message when limit is exceeded\n")
5921 DEFUN (neighbor_maximum_prefix_restart
,
5922 neighbor_maximum_prefix_restart_cmd
,
5923 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5926 "Maximum number of prefix accept from this peer\n"
5927 "maximum no. of prefix limit\n"
5928 "Restart bgp connection after limit is exceeded\n"
5929 "Restart interval in minutes\n")
5933 int idx_number_2
= 5;
5934 return peer_maximum_prefix_set_vty(
5935 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5936 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
5940 neighbor_maximum_prefix_restart
,
5941 neighbor_maximum_prefix_restart_hidden_cmd
,
5942 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5943 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5944 "Maximum number of prefix accept from this peer\n"
5945 "maximum no. of prefix limit\n"
5946 "Restart bgp connection after limit is exceeded\n"
5947 "Restart interval in minutes\n")
5949 DEFUN (neighbor_maximum_prefix_threshold_restart
,
5950 neighbor_maximum_prefix_threshold_restart_cmd
,
5951 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5954 "Maximum number of prefixes to accept from this peer\n"
5955 "maximum no. of prefix limit\n"
5956 "Threshold value (%) at which to generate a warning msg\n"
5957 "Restart bgp connection after limit is exceeded\n"
5958 "Restart interval in minutes\n")
5962 int idx_number_2
= 4;
5963 int idx_number_3
= 6;
5964 return peer_maximum_prefix_set_vty(
5965 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5966 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
5967 argv
[idx_number_3
]->arg
);
5971 neighbor_maximum_prefix_threshold_restart
,
5972 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
5973 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5974 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5975 "Maximum number of prefixes to accept from this peer\n"
5976 "maximum no. of prefix limit\n"
5977 "Threshold value (%) at which to generate a warning msg\n"
5978 "Restart bgp connection after limit is exceeded\n"
5979 "Restart interval in minutes\n")
5981 DEFUN (no_neighbor_maximum_prefix
,
5982 no_neighbor_maximum_prefix_cmd
,
5983 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5987 "Maximum number of prefixes to accept from this peer\n"
5988 "maximum no. of prefix limit\n"
5989 "Threshold value (%) at which to generate a warning msg\n"
5990 "Restart bgp connection after limit is exceeded\n"
5991 "Restart interval in minutes\n"
5992 "Only give warning message when limit is exceeded\n")
5995 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
5997 bgp_node_safi(vty
));
6001 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
6002 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6003 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6004 "Maximum number of prefixes to accept from this peer\n"
6005 "maximum no. of prefix limit\n"
6006 "Threshold value (%) at which to generate a warning msg\n"
6007 "Restart bgp connection after limit is exceeded\n"
6008 "Restart interval in minutes\n"
6009 "Only give warning message when limit is exceeded\n")
6012 /* "neighbor allowas-in" */
6013 DEFUN (neighbor_allowas_in
,
6014 neighbor_allowas_in_cmd
,
6015 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6018 "Accept as-path with my AS present in it\n"
6019 "Number of occurences of AS number\n"
6020 "Only accept my AS in the as-path if the route was originated in my AS\n")
6023 int idx_number_origin
= 3;
6029 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6031 return CMD_WARNING_CONFIG_FAILED
;
6033 if (argc
<= idx_number_origin
)
6036 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6039 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6042 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6045 return bgp_vty_return(vty
, ret
);
6049 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6050 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6051 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6052 "Accept as-path with my AS present in it\n"
6053 "Number of occurences of AS number\n"
6054 "Only accept my AS in the as-path if the route was originated in my AS\n")
6056 DEFUN (no_neighbor_allowas_in
,
6057 no_neighbor_allowas_in_cmd
,
6058 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6062 "allow local ASN appears in aspath attribute\n"
6063 "Number of occurences of AS number\n"
6064 "Only accept my AS in the as-path if the route was originated in my AS\n")
6070 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6072 return CMD_WARNING_CONFIG_FAILED
;
6074 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6075 bgp_node_safi(vty
));
6077 return bgp_vty_return(vty
, ret
);
6081 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6082 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6083 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6084 "allow local ASN appears in aspath attribute\n"
6085 "Number of occurences of AS number\n"
6086 "Only accept my AS in the as-path if the route was originated in my AS\n")
6088 DEFUN (neighbor_ttl_security
,
6089 neighbor_ttl_security_cmd
,
6090 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6093 "BGP ttl-security parameters\n"
6094 "Specify the maximum number of hops to the BGP peer\n"
6095 "Number of hops to BGP peer\n")
6102 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6104 return CMD_WARNING_CONFIG_FAILED
;
6106 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6109 * If 'neighbor swpX', then this is for directly connected peers,
6110 * we should not accept a ttl-security hops value greater than 1.
6112 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6114 "%s is directly connected peer, hops cannot exceed 1\n",
6115 argv
[idx_peer
]->arg
);
6116 return CMD_WARNING_CONFIG_FAILED
;
6119 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6122 DEFUN (no_neighbor_ttl_security
,
6123 no_neighbor_ttl_security_cmd
,
6124 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6128 "BGP ttl-security parameters\n"
6129 "Specify the maximum number of hops to the BGP peer\n"
6130 "Number of hops to BGP peer\n")
6135 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6137 return CMD_WARNING_CONFIG_FAILED
;
6139 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6142 DEFUN (neighbor_addpath_tx_all_paths
,
6143 neighbor_addpath_tx_all_paths_cmd
,
6144 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6147 "Use addpath to advertise all paths to a neighbor\n")
6152 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6154 return CMD_WARNING_CONFIG_FAILED
;
6156 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6158 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
6161 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6162 neighbor_addpath_tx_all_paths_hidden_cmd
,
6163 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6164 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6165 "Use addpath to advertise all paths to a neighbor\n")
6167 DEFUN (no_neighbor_addpath_tx_all_paths
,
6168 no_neighbor_addpath_tx_all_paths_cmd
,
6169 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6173 "Use addpath to advertise all paths to a neighbor\n")
6176 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6177 bgp_node_afi(vty
), bgp_node_safi(vty
),
6178 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
6181 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6182 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6183 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6184 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6185 "Use addpath to advertise all paths to a neighbor\n")
6187 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6188 neighbor_addpath_tx_bestpath_per_as_cmd
,
6189 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6192 "Use addpath to advertise the bestpath per each neighboring AS\n")
6197 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6199 return CMD_WARNING_CONFIG_FAILED
;
6201 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6203 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
6206 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6207 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6208 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6209 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6210 "Use addpath to advertise the bestpath per each neighboring AS\n")
6212 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6213 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6214 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6218 "Use addpath to advertise the bestpath per each neighboring AS\n")
6221 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6222 bgp_node_afi(vty
), bgp_node_safi(vty
),
6223 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
6226 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6227 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6228 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6229 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6230 "Use addpath to advertise the bestpath per each neighboring AS\n")
6232 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6233 struct ecommunity
**list
)
6235 struct ecommunity
*ecom
= NULL
;
6236 struct ecommunity
*ecomadd
;
6238 for (; argc
; --argc
, ++argv
) {
6240 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6241 ECOMMUNITY_ROUTE_TARGET
, 0);
6243 vty_out(vty
, "Malformed community-list value\n");
6245 ecommunity_free(&ecom
);
6246 return CMD_WARNING_CONFIG_FAILED
;
6250 ecommunity_merge(ecom
, ecomadd
);
6251 ecommunity_free(&ecomadd
);
6258 ecommunity_free(&*list
);
6266 * v2vimport is true if we are handling a `import vrf ...` command
6268 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6272 switch (vty
->node
) {
6281 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6286 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6287 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6288 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6289 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6291 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6295 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6296 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6297 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6298 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6300 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6307 DEFPY (af_rd_vpn_export
,
6308 af_rd_vpn_export_cmd
,
6309 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6311 "Specify route distinguisher\n"
6312 "Between current address-family and vpn\n"
6313 "For routes leaked from current address-family to vpn\n"
6314 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6316 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6317 struct prefix_rd prd
;
6323 if (argv_find(argv
, argc
, "no", &idx
))
6327 ret
= str2prefix_rd(rd_str
, &prd
);
6329 vty_out(vty
, "%% Malformed rd\n");
6330 return CMD_WARNING_CONFIG_FAILED
;
6334 afi
= vpn_policy_getafi(vty
, bgp
, false);
6336 return CMD_WARNING_CONFIG_FAILED
;
6339 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6341 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6342 bgp_get_default(), bgp
);
6345 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6346 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6347 BGP_VPN_POLICY_TOVPN_RD_SET
);
6349 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6350 BGP_VPN_POLICY_TOVPN_RD_SET
);
6353 /* post-change: re-export vpn routes */
6354 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6355 bgp_get_default(), bgp
);
6360 ALIAS (af_rd_vpn_export
,
6361 af_no_rd_vpn_export_cmd
,
6364 "Specify route distinguisher\n"
6365 "Between current address-family and vpn\n"
6366 "For routes leaked from current address-family to vpn\n")
6368 DEFPY (af_label_vpn_export
,
6369 af_label_vpn_export_cmd
,
6370 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6372 "label value for VRF\n"
6373 "Between current address-family and vpn\n"
6374 "For routes leaked from current address-family to vpn\n"
6375 "Label Value <0-1048575>\n"
6376 "Automatically assign a label\n")
6378 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6379 mpls_label_t label
= MPLS_LABEL_NONE
;
6384 if (argv_find(argv
, argc
, "no", &idx
))
6387 /* If "no ...", squash trailing parameter */
6393 label
= label_val
; /* parser should force unsigned */
6396 afi
= vpn_policy_getafi(vty
, bgp
, false);
6398 return CMD_WARNING_CONFIG_FAILED
;
6401 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6402 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6407 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6409 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6410 bgp_get_default(), bgp
);
6412 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6413 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6415 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6418 * label has previously been automatically
6419 * assigned by labelpool: release it
6421 * NB if tovpn_label == MPLS_LABEL_NONE it
6422 * means the automatic assignment is in flight
6423 * and therefore the labelpool callback must
6424 * detect that the auto label is not needed.
6427 bgp_lp_release(LP_TYPE_VRF
,
6428 &bgp
->vpn_policy
[afi
],
6429 bgp
->vpn_policy
[afi
].tovpn_label
);
6431 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6432 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6435 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6437 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6438 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6439 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6440 vpn_leak_label_callback
);
6443 /* post-change: re-export vpn routes */
6444 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6445 bgp_get_default(), bgp
);
6450 ALIAS (af_label_vpn_export
,
6451 af_no_label_vpn_export_cmd
,
6452 "no label vpn export",
6454 "label value for VRF\n"
6455 "Between current address-family and vpn\n"
6456 "For routes leaked from current address-family to vpn\n")
6458 DEFPY (af_nexthop_vpn_export
,
6459 af_nexthop_vpn_export_cmd
,
6460 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6462 "Specify next hop to use for VRF advertised prefixes\n"
6463 "Between current address-family and vpn\n"
6464 "For routes leaked from current address-family to vpn\n"
6468 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6474 if (argv_find(argv
, argc
, "no", &idx
))
6478 if (!sockunion2hostprefix(nexthop_str
, &p
))
6479 return CMD_WARNING_CONFIG_FAILED
;
6482 afi
= vpn_policy_getafi(vty
, bgp
, false);
6484 return CMD_WARNING_CONFIG_FAILED
;
6487 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6489 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6490 bgp_get_default(), bgp
);
6493 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6494 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6495 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6497 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6498 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6501 /* post-change: re-export vpn routes */
6502 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6503 bgp_get_default(), bgp
);
6508 ALIAS (af_nexthop_vpn_export
,
6509 af_no_nexthop_vpn_export_cmd
,
6510 "no nexthop vpn export",
6512 "Specify next hop to use for VRF advertised prefixes\n"
6513 "Between current address-family and vpn\n"
6514 "For routes leaked from current address-family to vpn\n")
6516 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6518 if (!strcmp(dstr
, "import")) {
6519 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6520 } else if (!strcmp(dstr
, "export")) {
6521 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6522 } else if (!strcmp(dstr
, "both")) {
6523 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6524 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6526 vty_out(vty
, "%% direction parse error\n");
6527 return CMD_WARNING_CONFIG_FAILED
;
6532 DEFPY (af_rt_vpn_imexport
,
6533 af_rt_vpn_imexport_cmd
,
6534 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6536 "Specify route target list\n"
6537 "Specify route target list\n"
6538 "Between current address-family and vpn\n"
6539 "For routes leaked from vpn to current address-family: match any\n"
6540 "For routes leaked from current address-family to vpn: set\n"
6541 "both import: match any and export: set\n"
6542 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6544 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6546 struct ecommunity
*ecom
= NULL
;
6547 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6548 vpn_policy_direction_t dir
;
6553 if (argv_find(argv
, argc
, "no", &idx
))
6556 afi
= vpn_policy_getafi(vty
, bgp
, false);
6558 return CMD_WARNING_CONFIG_FAILED
;
6560 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6561 if (ret
!= CMD_SUCCESS
)
6565 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6566 vty_out(vty
, "%% Missing RTLIST\n");
6567 return CMD_WARNING_CONFIG_FAILED
;
6569 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6570 if (ret
!= CMD_SUCCESS
) {
6575 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6579 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6582 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6584 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6585 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6586 ecommunity_dup(ecom
);
6588 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6590 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6591 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6594 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6598 ecommunity_free(&ecom
);
6603 ALIAS (af_rt_vpn_imexport
,
6604 af_no_rt_vpn_imexport_cmd
,
6605 "no <rt|route-target> vpn <import|export|both>$direction_str",
6607 "Specify route target list\n"
6608 "Specify route target list\n"
6609 "Between current address-family and vpn\n"
6610 "For routes leaked from vpn to current address-family\n"
6611 "For routes leaked from current address-family to vpn\n"
6612 "both import and export\n")
6614 DEFPY (af_route_map_vpn_imexport
,
6615 af_route_map_vpn_imexport_cmd
,
6616 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6617 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6619 "Specify route map\n"
6620 "Between current address-family and vpn\n"
6621 "For routes leaked from vpn to current address-family\n"
6622 "For routes leaked from current address-family to vpn\n"
6623 "name of route-map\n")
6625 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6627 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6628 vpn_policy_direction_t dir
;
6633 if (argv_find(argv
, argc
, "no", &idx
))
6636 afi
= vpn_policy_getafi(vty
, bgp
, false);
6638 return CMD_WARNING_CONFIG_FAILED
;
6640 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6641 if (ret
!= CMD_SUCCESS
)
6644 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6648 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6651 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6652 XFREE(MTYPE_ROUTE_MAP_NAME
,
6653 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6654 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6655 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6656 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6657 route_map_lookup_warn_noexist(vty
, rmap_str
);
6658 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6661 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6662 XFREE(MTYPE_ROUTE_MAP_NAME
,
6663 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6664 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6665 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6668 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6674 ALIAS (af_route_map_vpn_imexport
,
6675 af_no_route_map_vpn_imexport_cmd
,
6676 "no route-map vpn <import|export>$direction_str",
6678 "Specify route map\n"
6679 "Between current address-family and vpn\n"
6680 "For routes leaked from vpn to current address-family\n"
6681 "For routes leaked from current address-family to vpn\n")
6683 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6684 "[no] import vrf route-map RMAP$rmap_str",
6686 "Import routes from another VRF\n"
6687 "Vrf routes being filtered\n"
6688 "Specify route map\n"
6689 "name of route-map\n")
6691 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6692 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6696 struct bgp
*bgp_default
;
6698 if (argv_find(argv
, argc
, "no", &idx
))
6701 afi
= vpn_policy_getafi(vty
, bgp
, true);
6703 return CMD_WARNING_CONFIG_FAILED
;
6705 bgp_default
= bgp_get_default();
6710 /* Auto-create assuming the same AS */
6711 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6712 BGP_INSTANCE_TYPE_DEFAULT
);
6716 "VRF default is not configured as a bgp instance\n");
6721 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6724 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6725 XFREE(MTYPE_ROUTE_MAP_NAME
,
6726 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6727 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6728 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6729 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6730 route_map_lookup_warn_noexist(vty
, rmap_str
);
6731 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6734 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6735 XFREE(MTYPE_ROUTE_MAP_NAME
,
6736 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6737 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6738 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6741 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6746 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6747 "no import vrf route-map",
6749 "Import routes from another VRF\n"
6750 "Vrf routes being filtered\n"
6751 "Specify route map\n")
6753 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
6754 "[no] import vrf VIEWVRFNAME$import_name",
6756 "Import routes from another VRF\n"
6757 "VRF to import from\n"
6758 "The name of the VRF\n")
6760 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6761 struct listnode
*node
;
6762 struct bgp
*vrf_bgp
, *bgp_default
;
6765 bool remove
= false;
6768 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
6772 if (import_name
== NULL
) {
6773 vty_out(vty
, "%% Missing import name\n");
6777 if (argv_find(argv
, argc
, "no", &idx
))
6780 afi
= vpn_policy_getafi(vty
, bgp
, true);
6782 return CMD_WARNING_CONFIG_FAILED
;
6784 safi
= bgp_node_safi(vty
);
6786 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
6787 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
6788 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
6789 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
6790 remove
? "unimport" : "import", import_name
);
6794 bgp_default
= bgp_get_default();
6796 /* Auto-create assuming the same AS */
6797 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6798 BGP_INSTANCE_TYPE_DEFAULT
);
6802 "VRF default is not configured as a bgp instance\n");
6807 vrf_bgp
= bgp_lookup_by_name(import_name
);
6809 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
6810 vrf_bgp
= bgp_default
;
6812 /* Auto-create assuming the same AS */
6813 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
6817 "VRF %s is not configured as a bgp instance\n",
6824 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6826 /* Already importing from "import_vrf"? */
6827 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
6829 if (strcmp(vname
, import_name
) == 0)
6833 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6839 /* This command is valid only in a bgp vrf instance or the default instance */
6840 DEFPY (bgp_imexport_vpn
,
6841 bgp_imexport_vpn_cmd
,
6842 "[no] <import|export>$direction_str vpn",
6844 "Import routes to this address-family\n"
6845 "Export routes from this address-family\n"
6846 "to/from default instance VPN RIB\n")
6848 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6855 vpn_policy_direction_t dir
;
6857 if (argv_find(argv
, argc
, "no", &idx
))
6860 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
6861 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
6863 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
6864 return CMD_WARNING_CONFIG_FAILED
;
6867 afi
= bgp_node_afi(vty
);
6868 safi
= bgp_node_safi(vty
);
6869 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
6870 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
6871 return CMD_WARNING_CONFIG_FAILED
;
6874 if (!strcmp(direction_str
, "import")) {
6875 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
6876 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6877 } else if (!strcmp(direction_str
, "export")) {
6878 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
6879 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
6881 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
6882 return CMD_WARNING_CONFIG_FAILED
;
6885 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6888 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6889 if (!previous_state
) {
6890 /* trigger export current vrf */
6891 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6894 if (previous_state
) {
6895 /* trigger un-export current vrf */
6896 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6898 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6904 DEFPY (af_routetarget_import
,
6905 af_routetarget_import_cmd
,
6906 "[no] <rt|route-target> redirect import RTLIST...",
6908 "Specify route target list\n"
6909 "Specify route target list\n"
6910 "Flow-spec redirect type route target\n"
6911 "Import routes to this address-family\n"
6912 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6914 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6916 struct ecommunity
*ecom
= NULL
;
6921 if (argv_find(argv
, argc
, "no", &idx
))
6924 afi
= vpn_policy_getafi(vty
, bgp
, false);
6926 return CMD_WARNING_CONFIG_FAILED
;
6929 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6930 vty_out(vty
, "%% Missing RTLIST\n");
6931 return CMD_WARNING_CONFIG_FAILED
;
6933 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6934 if (ret
!= CMD_SUCCESS
)
6939 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
6940 ecommunity_free(&bgp
->vpn_policy
[afi
]
6941 .import_redirect_rtlist
);
6942 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
6943 ecommunity_dup(ecom
);
6945 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
6946 ecommunity_free(&bgp
->vpn_policy
[afi
]
6947 .import_redirect_rtlist
);
6948 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
6952 ecommunity_free(&ecom
);
6957 DEFUN_NOSH (address_family_ipv4_safi
,
6958 address_family_ipv4_safi_cmd
,
6959 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
6960 "Enter Address Family command mode\n"
6962 BGP_SAFI_WITH_LABEL_HELP_STR
)
6966 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6967 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6968 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
6969 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
6970 && safi
!= SAFI_EVPN
) {
6972 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
6973 return CMD_WARNING_CONFIG_FAILED
;
6975 vty
->node
= bgp_node_type(AFI_IP
, safi
);
6977 vty
->node
= BGP_IPV4_NODE
;
6982 DEFUN_NOSH (address_family_ipv6_safi
,
6983 address_family_ipv6_safi_cmd
,
6984 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
6985 "Enter Address Family command mode\n"
6987 BGP_SAFI_WITH_LABEL_HELP_STR
)
6990 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6991 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6992 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
6993 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
6994 && safi
!= SAFI_EVPN
) {
6996 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
6997 return CMD_WARNING_CONFIG_FAILED
;
6999 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
7001 vty
->node
= BGP_IPV6_NODE
;
7006 #ifdef KEEP_OLD_VPN_COMMANDS
7007 DEFUN_NOSH (address_family_vpnv4
,
7008 address_family_vpnv4_cmd
,
7009 "address-family vpnv4 [unicast]",
7010 "Enter Address Family command mode\n"
7012 "Address Family modifier\n")
7014 vty
->node
= BGP_VPNV4_NODE
;
7018 DEFUN_NOSH (address_family_vpnv6
,
7019 address_family_vpnv6_cmd
,
7020 "address-family vpnv6 [unicast]",
7021 "Enter Address Family command mode\n"
7023 "Address Family modifier\n")
7025 vty
->node
= BGP_VPNV6_NODE
;
7030 DEFUN_NOSH (address_family_evpn
,
7031 address_family_evpn_cmd
,
7032 "address-family l2vpn evpn",
7033 "Enter Address Family command mode\n"
7035 "Address Family modifier\n")
7037 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7038 vty
->node
= BGP_EVPN_NODE
;
7042 DEFUN_NOSH (exit_address_family
,
7043 exit_address_family_cmd
,
7044 "exit-address-family",
7045 "Exit from Address Family configuration mode\n")
7047 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7048 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7049 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7050 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7051 || vty
->node
== BGP_EVPN_NODE
7052 || vty
->node
== BGP_FLOWSPECV4_NODE
7053 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7054 vty
->node
= BGP_NODE
;
7058 /* Recalculate bestpath and re-advertise a prefix */
7059 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7060 const char *ip_str
, afi_t afi
, safi_t safi
,
7061 struct prefix_rd
*prd
)
7064 struct prefix match
;
7065 struct bgp_node
*rn
;
7066 struct bgp_node
*rm
;
7068 struct bgp_table
*table
;
7069 struct bgp_table
*rib
;
7071 /* BGP structure lookup. */
7073 bgp
= bgp_lookup_by_name(view_name
);
7075 vty_out(vty
, "%% Can't find BGP instance %s\n",
7080 bgp
= bgp_get_default();
7082 vty_out(vty
, "%% No BGP process is configured\n");
7087 /* Check IP address argument. */
7088 ret
= str2prefix(ip_str
, &match
);
7090 vty_out(vty
, "%% address is malformed\n");
7094 match
.family
= afi2family(afi
);
7095 rib
= bgp
->rib
[afi
][safi
];
7097 if (safi
== SAFI_MPLS_VPN
) {
7098 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7099 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7102 if ((table
= rn
->info
) != NULL
) {
7103 if ((rm
= bgp_node_match(table
, &match
))
7106 == match
.prefixlen
) {
7108 BGP_NODE_USER_CLEAR
);
7109 bgp_process(bgp
, rm
, afi
, safi
);
7111 bgp_unlock_node(rm
);
7116 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7117 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7118 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7119 bgp_process(bgp
, rn
, afi
, safi
);
7121 bgp_unlock_node(rn
);
7128 /* one clear bgp command to rule them all */
7129 DEFUN (clear_ip_bgp_all
,
7130 clear_ip_bgp_all_cmd
,
7131 "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>]",
7135 BGP_INSTANCE_HELP_STR
7137 BGP_SAFI_WITH_LABEL_HELP_STR
7139 "BGP neighbor address to clear\n"
7140 "BGP IPv6 neighbor to clear\n"
7141 "BGP neighbor on interface to clear\n"
7142 "Clear peers with the AS number\n"
7143 "Clear all external peers\n"
7144 "Clear all members of peer-group\n"
7145 "BGP peer-group name\n"
7150 "Push out prefix-list ORF and do inbound soft reconfig\n"
7155 afi_t afi
= AFI_IP6
;
7156 safi_t safi
= SAFI_UNICAST
;
7157 enum clear_sort clr_sort
= clear_peer
;
7158 enum bgp_clear_type clr_type
;
7159 char *clr_arg
= NULL
;
7163 /* clear [ip] bgp */
7164 if (argv_find(argv
, argc
, "ip", &idx
))
7167 /* [<vrf> VIEWVRFNAME] */
7168 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7169 vrf
= argv
[idx
+ 1]->arg
;
7171 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7173 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7174 /* [<view> VIEWVRFNAME] */
7175 vrf
= argv
[idx
+ 1]->arg
;
7178 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7179 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7180 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7182 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */
7183 if (argv_find(argv
, argc
, "*", &idx
)) {
7184 clr_sort
= clear_all
;
7185 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7186 clr_sort
= clear_peer
;
7187 clr_arg
= argv
[idx
]->arg
;
7188 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7189 clr_sort
= clear_peer
;
7190 clr_arg
= argv
[idx
]->arg
;
7191 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7192 clr_sort
= clear_group
;
7194 clr_arg
= argv
[idx
]->arg
;
7195 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7196 clr_sort
= clear_peer
;
7197 clr_arg
= argv
[idx
]->arg
;
7198 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7199 clr_sort
= clear_as
;
7200 clr_arg
= argv
[idx
]->arg
;
7201 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7202 clr_sort
= clear_external
;
7205 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7206 if (argv_find(argv
, argc
, "soft", &idx
)) {
7207 if (argv_find(argv
, argc
, "in", &idx
)
7208 || argv_find(argv
, argc
, "out", &idx
))
7209 clr_type
= strmatch(argv
[idx
]->text
, "in")
7211 : BGP_CLEAR_SOFT_OUT
;
7213 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7214 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7215 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7216 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7217 : BGP_CLEAR_SOFT_IN
;
7218 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7219 clr_type
= BGP_CLEAR_SOFT_OUT
;
7221 clr_type
= BGP_CLEAR_SOFT_NONE
;
7223 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7226 DEFUN (clear_ip_bgp_prefix
,
7227 clear_ip_bgp_prefix_cmd
,
7228 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7232 BGP_INSTANCE_HELP_STR
7233 "Clear bestpath and re-advertise\n"
7237 char *prefix
= NULL
;
7241 /* [<view|vrf> VIEWVRFNAME] */
7242 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7243 vrf
= argv
[idx
+ 1]->arg
;
7245 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7247 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7248 /* [<view> VIEWVRFNAME] */
7249 vrf
= argv
[idx
+ 1]->arg
;
7253 prefix
= argv
[argc
- 1]->arg
;
7255 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7258 DEFUN (clear_bgp_ipv6_safi_prefix
,
7259 clear_bgp_ipv6_safi_prefix_cmd
,
7260 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7266 "Clear bestpath and re-advertise\n"
7270 int idx_ipv6_prefix
= 0;
7271 safi_t safi
= SAFI_UNICAST
;
7272 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7273 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7275 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7276 return bgp_clear_prefix(
7277 vty
, NULL
, prefix
, AFI_IP6
,
7281 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7282 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7283 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7287 BGP_INSTANCE_HELP_STR
7290 "Clear bestpath and re-advertise\n"
7294 int idx_vrfview
= 0;
7295 int idx_ipv6_prefix
= 0;
7296 safi_t safi
= SAFI_UNICAST
;
7297 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7298 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7299 char *vrfview
= NULL
;
7301 /* [<view|vrf> VIEWVRFNAME] */
7302 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
7303 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7304 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
7306 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
7307 /* [<view> VIEWVRFNAME] */
7308 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7310 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7312 return bgp_clear_prefix(
7313 vty
, vrfview
, prefix
,
7314 AFI_IP6
, safi
, NULL
);
7317 DEFUN (show_bgp_views
,
7319 "show [ip] bgp views",
7323 "Show the defined BGP views\n")
7325 struct list
*inst
= bm
->bgp
;
7326 struct listnode
*node
;
7329 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7330 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7334 vty_out(vty
, "Defined BGP views:\n");
7335 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7337 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7339 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7346 DEFUN (show_bgp_vrfs
,
7348 "show [ip] bgp vrfs [json]",
7355 char buf
[ETHER_ADDR_STRLEN
];
7356 struct list
*inst
= bm
->bgp
;
7357 struct listnode
*node
;
7359 bool uj
= use_json(argc
, argv
);
7360 json_object
*json
= NULL
;
7361 json_object
*json_vrfs
= NULL
;
7364 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7365 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7370 json
= json_object_new_object();
7371 json_vrfs
= json_object_new_object();
7374 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7375 const char *name
, *type
;
7377 struct listnode
*node2
, *nnode2
;
7378 int peers_cfg
, peers_estb
;
7379 json_object
*json_vrf
= NULL
;
7382 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7386 if (!uj
&& count
== 1)
7388 "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n",
7389 "Type", "Id", "routerId", "#PeersVfg",
7390 "#PeersEstb", "Name", "L3-VNI", "Rmac");
7392 peers_cfg
= peers_estb
= 0;
7394 json_vrf
= json_object_new_object();
7397 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
7398 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7401 if (peer
->status
== Established
)
7405 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7406 name
= VRF_DEFAULT_NAME
;
7415 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7417 : (int64_t)bgp
->vrf_id
;
7418 json_object_string_add(json_vrf
, "type", type
);
7419 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7420 json_object_string_add(json_vrf
, "routerId",
7421 inet_ntoa(bgp
->router_id
));
7422 json_object_int_add(json_vrf
, "numConfiguredPeers",
7424 json_object_int_add(json_vrf
, "numEstablishedPeers",
7427 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7428 json_object_string_add(
7430 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7431 json_object_object_add(json_vrfs
, name
, json_vrf
);
7434 "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n",
7436 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7438 inet_ntoa(bgp
->router_id
), peers_cfg
,
7439 peers_estb
, name
, bgp
->l3vni
,
7440 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7444 json_object_object_add(json
, "vrfs", json_vrfs
);
7446 json_object_int_add(json
, "totalVrfs", count
);
7448 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7449 json
, JSON_C_TO_STRING_PRETTY
));
7450 json_object_free(json
);
7454 "\nTotal number of VRFs (including default): %d\n",
7462 static void show_tip_entry(struct hash_backet
*backet
, void *args
)
7464 struct vty
*vty
= (struct vty
*)args
;
7465 struct tip_addr
*tip
= (struct tip_addr
*)backet
->data
;
7467 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7471 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7473 vty_out(vty
, "self nexthop database:\n");
7474 bgp_nexthop_show_address_hash(vty
, bgp
);
7476 vty_out(vty
, "Tunnel-ip database:\n");
7477 hash_iterate(bgp
->tip_hash
,
7478 (void (*)(struct hash_backet
*, void *))show_tip_entry
,
7482 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7483 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7484 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7485 "martian next-hops\n"
7486 "martian next-hop database\n")
7488 struct bgp
*bgp
= NULL
;
7492 /* [<vrf> VIEWVRFNAME] */
7493 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7494 name
= argv
[idx
+ 1]->arg
;
7495 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7497 } else if (argv_find(argv
, argc
, "view", &idx
))
7498 /* [<view> VIEWVRFNAME] */
7499 name
= argv
[idx
+ 1]->arg
;
7501 bgp
= bgp_lookup_by_name(name
);
7503 bgp
= bgp_get_default();
7506 vty_out(vty
, "%% No BGP process is configured\n");
7509 bgp_show_martian_nexthops(vty
, bgp
);
7514 DEFUN (show_bgp_memory
,
7515 show_bgp_memory_cmd
,
7516 "show [ip] bgp memory",
7520 "Global BGP memory statistics\n")
7522 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7523 unsigned long count
;
7525 /* RIB related usage stats */
7526 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7527 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7528 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7529 count
* sizeof(struct bgp_node
)));
7531 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7532 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7533 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7534 count
* sizeof(struct bgp_path_info
)));
7535 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7536 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7539 memstrbuf
, sizeof(memstrbuf
),
7540 count
* sizeof(struct bgp_path_info_extra
)));
7542 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7543 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7544 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7545 count
* sizeof(struct bgp_static
)));
7547 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7548 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7549 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7550 count
* sizeof(struct bpacket
)));
7553 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7554 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7555 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7556 count
* sizeof(struct bgp_adj_in
)));
7557 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7558 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7559 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7560 count
* sizeof(struct bgp_adj_out
)));
7562 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7563 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7565 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7566 count
* sizeof(struct bgp_nexthop_cache
)));
7568 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7569 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7571 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7572 count
* sizeof(struct bgp_damp_info
)));
7575 count
= attr_count();
7576 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7577 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7578 count
* sizeof(struct attr
)));
7580 if ((count
= attr_unknown_count()))
7581 vty_out(vty
, "%ld unknown attributes\n", count
);
7583 /* AS_PATH attributes */
7584 count
= aspath_count();
7585 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7586 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7587 count
* sizeof(struct aspath
)));
7589 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7590 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7591 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7592 count
* sizeof(struct assegment
)));
7594 /* Other attributes */
7595 if ((count
= community_count()))
7596 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7597 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7598 count
* sizeof(struct community
)));
7599 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7600 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7601 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7602 count
* sizeof(struct ecommunity
)));
7603 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7605 "%ld BGP large-community entries, using %s of memory\n",
7606 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7607 count
* sizeof(struct lcommunity
)));
7609 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7610 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7611 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7612 count
* sizeof(struct cluster_list
)));
7614 /* Peer related usage */
7615 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7616 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7617 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7618 count
* sizeof(struct peer
)));
7620 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7621 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7622 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7623 count
* sizeof(struct peer_group
)));
7626 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
7627 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
7628 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7629 count
* sizeof(struct hash
)));
7630 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
7631 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
7632 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7633 count
* sizeof(struct hash_backet
)));
7634 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7635 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7636 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7637 count
* sizeof(regex_t
)));
7641 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7643 json_object
*bestpath
= json_object_new_object();
7645 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7646 json_object_string_add(bestpath
, "asPath", "ignore");
7648 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7649 json_object_string_add(bestpath
, "asPath", "confed");
7651 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7652 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7653 json_object_string_add(bestpath
, "multiPathRelax",
7656 json_object_string_add(bestpath
, "multiPathRelax",
7659 json_object_string_add(bestpath
, "multiPathRelax", "false");
7661 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7662 json_object_string_add(bestpath
, "compareRouterId", "true");
7663 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7664 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7665 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7666 json_object_string_add(bestpath
, "med", "confed");
7667 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7668 json_object_string_add(bestpath
, "med",
7669 "missing-as-worst");
7671 json_object_string_add(bestpath
, "med", "true");
7674 json_object_object_add(json
, "bestPath", bestpath
);
7677 /* Show BGP peer's summary information. */
7678 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7679 bool use_json
, json_object
*json
)
7682 struct listnode
*node
, *nnode
;
7683 unsigned int count
= 0, dn_count
= 0;
7684 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7685 char neighbor_buf
[VTY_BUFSIZ
];
7686 int neighbor_col_default_width
= 16;
7688 int max_neighbor_width
= 0;
7690 json_object
*json_peer
= NULL
;
7691 json_object
*json_peers
= NULL
;
7692 struct peer_af
*paf
;
7694 /* labeled-unicast routes are installed in the unicast table so in order
7696 * display the correct PfxRcd value we must look at SAFI_UNICAST
7698 if (safi
== SAFI_LABELED_UNICAST
)
7699 pfx_rcd_safi
= SAFI_UNICAST
;
7701 pfx_rcd_safi
= safi
;
7705 json
= json_object_new_object();
7707 json_peers
= json_object_new_object();
7709 /* Loop over all neighbors that will be displayed to determine
7711 * characters are needed for the Neighbor column
7713 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7714 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7717 if (peer
->afc
[afi
][safi
]) {
7718 memset(dn_flag
, '\0', sizeof(dn_flag
));
7719 if (peer_dynamic_neighbor(peer
))
7723 && bgp_flag_check(bgp
,
7724 BGP_FLAG_SHOW_HOSTNAME
))
7725 sprintf(neighbor_buf
, "%s%s(%s) ",
7726 dn_flag
, peer
->hostname
,
7729 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7732 len
= strlen(neighbor_buf
);
7734 if (len
> max_neighbor_width
)
7735 max_neighbor_width
= len
;
7739 /* Originally we displayed the Neighbor column as 16
7740 * characters wide so make that the default
7742 if (max_neighbor_width
< neighbor_col_default_width
)
7743 max_neighbor_width
= neighbor_col_default_width
;
7746 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7747 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7750 if (!peer
->afc
[afi
][safi
])
7755 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7758 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7760 : (int64_t)bgp
->vrf_id
;
7762 /* Usage summary and header */
7764 json_object_string_add(
7766 inet_ntoa(bgp
->router_id
));
7767 json_object_int_add(json
, "as", bgp
->as
);
7768 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7769 json_object_string_add(
7772 == BGP_INSTANCE_TYPE_DEFAULT
)
7777 "BGP router identifier %s, local AS number %u vrf-id %d",
7778 inet_ntoa(bgp
->router_id
), bgp
->as
,
7779 bgp
->vrf_id
== VRF_UNKNOWN
7781 : (int)bgp
->vrf_id
);
7785 if (bgp_update_delay_configured(bgp
)) {
7787 json_object_int_add(
7788 json
, "updateDelayLimit",
7789 bgp
->v_update_delay
);
7791 if (bgp
->v_update_delay
7792 != bgp
->v_establish_wait
)
7793 json_object_int_add(
7795 "updateDelayEstablishWait",
7796 bgp
->v_establish_wait
);
7798 if (bgp_update_delay_active(bgp
)) {
7799 json_object_string_add(
7801 "updateDelayFirstNeighbor",
7802 bgp
->update_delay_begin_time
);
7803 json_object_boolean_true_add(
7805 "updateDelayInProgress");
7807 if (bgp
->update_delay_over
) {
7808 json_object_string_add(
7810 "updateDelayFirstNeighbor",
7811 bgp
->update_delay_begin_time
);
7812 json_object_string_add(
7814 "updateDelayBestpathResumed",
7815 bgp
->update_delay_end_time
);
7816 json_object_string_add(
7818 "updateDelayZebraUpdateResume",
7819 bgp
->update_delay_zebra_resume_time
);
7820 json_object_string_add(
7822 "updateDelayPeerUpdateResume",
7823 bgp
->update_delay_peers_resume_time
);
7828 "Read-only mode update-delay limit: %d seconds\n",
7829 bgp
->v_update_delay
);
7830 if (bgp
->v_update_delay
7831 != bgp
->v_establish_wait
)
7833 " Establish wait: %d seconds\n",
7834 bgp
->v_establish_wait
);
7836 if (bgp_update_delay_active(bgp
)) {
7838 " First neighbor established: %s\n",
7839 bgp
->update_delay_begin_time
);
7841 " Delay in progress\n");
7843 if (bgp
->update_delay_over
) {
7845 " First neighbor established: %s\n",
7846 bgp
->update_delay_begin_time
);
7848 " Best-paths resumed: %s\n",
7849 bgp
->update_delay_end_time
);
7851 " zebra update resumed: %s\n",
7852 bgp
->update_delay_zebra_resume_time
);
7854 " peers update resumed: %s\n",
7855 bgp
->update_delay_peers_resume_time
);
7862 if (bgp_maxmed_onstartup_configured(bgp
)
7863 && bgp
->maxmed_active
)
7864 json_object_boolean_true_add(
7865 json
, "maxMedOnStartup");
7866 if (bgp
->v_maxmed_admin
)
7867 json_object_boolean_true_add(
7868 json
, "maxMedAdministrative");
7870 json_object_int_add(
7871 json
, "tableVersion",
7872 bgp_table_version(bgp
->rib
[afi
][safi
]));
7874 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7875 json_object_int_add(json
, "ribCount", ents
);
7876 json_object_int_add(
7878 ents
* sizeof(struct bgp_node
));
7880 ents
= listcount(bgp
->peer
);
7881 json_object_int_add(json
, "peerCount", ents
);
7882 json_object_int_add(json
, "peerMemory",
7883 ents
* sizeof(struct peer
));
7885 if ((ents
= listcount(bgp
->group
))) {
7886 json_object_int_add(
7887 json
, "peerGroupCount", ents
);
7888 json_object_int_add(
7889 json
, "peerGroupMemory",
7890 ents
* sizeof(struct
7894 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7895 BGP_CONFIG_DAMPENING
))
7896 json_object_boolean_true_add(
7897 json
, "dampeningEnabled");
7899 if (bgp_maxmed_onstartup_configured(bgp
)
7900 && bgp
->maxmed_active
)
7902 "Max-med on-startup active\n");
7903 if (bgp
->v_maxmed_admin
)
7905 "Max-med administrative active\n");
7907 vty_out(vty
, "BGP table version %" PRIu64
"\n",
7908 bgp_table_version(bgp
->rib
[afi
][safi
]));
7910 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7912 "RIB entries %ld, using %s of memory\n",
7914 mtype_memstr(memstrbuf
,
7916 ents
* sizeof(struct
7919 /* Peer related usage */
7920 ents
= listcount(bgp
->peer
);
7921 vty_out(vty
, "Peers %ld, using %s of memory\n",
7924 memstrbuf
, sizeof(memstrbuf
),
7925 ents
* sizeof(struct peer
)));
7927 if ((ents
= listcount(bgp
->group
)))
7929 "Peer groups %ld, using %s of memory\n",
7934 ents
* sizeof(struct
7937 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7938 BGP_CONFIG_DAMPENING
))
7939 vty_out(vty
, "Dampening enabled.\n");
7942 /* Subtract 8 here because 'Neighbor' is
7944 vty_out(vty
, "Neighbor");
7945 vty_out(vty
, "%*s", max_neighbor_width
- 8,
7948 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
7955 json_peer
= json_object_new_object();
7957 if (peer_dynamic_neighbor(peer
)) {
7959 json_object_boolean_true_add(json_peer
,
7964 json_object_string_add(json_peer
, "hostname",
7967 if (peer
->domainname
)
7968 json_object_string_add(json_peer
, "domainname",
7971 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
7972 json_object_int_add(json_peer
, "version", 4);
7973 json_object_int_add(json_peer
, "msgRcvd",
7974 PEER_TOTAL_RX(peer
));
7975 json_object_int_add(json_peer
, "msgSent",
7976 PEER_TOTAL_TX(peer
));
7978 json_object_int_add(json_peer
, "tableVersion",
7979 peer
->version
[afi
][safi
]);
7980 json_object_int_add(json_peer
, "outq",
7982 json_object_int_add(json_peer
, "inq", 0);
7983 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
7984 use_json
, json_peer
);
7985 json_object_int_add(json_peer
, "prefixReceivedCount",
7986 peer
->pcount
[afi
][pfx_rcd_safi
]);
7987 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
7988 if (paf
&& PAF_SUBGRP(paf
))
7989 json_object_int_add(json_peer
,
7991 (PAF_SUBGRP(paf
))->scount
);
7993 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
7994 json_object_string_add(json_peer
, "state",
7996 else if (peer
->afc_recv
[afi
][safi
])
7997 json_object_string_add(
7999 lookup_msg(bgp_status_msg
, peer
->status
,
8001 else if (CHECK_FLAG(peer
->sflags
,
8002 PEER_STATUS_PREFIX_OVERFLOW
))
8003 json_object_string_add(json_peer
, "state",
8006 json_object_string_add(
8008 lookup_msg(bgp_status_msg
, peer
->status
,
8012 json_object_string_add(json_peer
, "idType",
8014 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8015 json_object_string_add(json_peer
, "idType",
8017 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8018 json_object_string_add(json_peer
, "idType",
8021 json_object_object_add(json_peers
, peer
->host
,
8024 memset(dn_flag
, '\0', sizeof(dn_flag
));
8025 if (peer_dynamic_neighbor(peer
)) {
8031 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8032 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8033 peer
->hostname
, peer
->host
);
8035 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8037 /* pad the neighbor column with spaces */
8038 if (len
< max_neighbor_width
)
8039 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8042 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8043 peer
->as
, PEER_TOTAL_RX(peer
),
8044 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8045 0, peer
->obuf
->count
,
8046 peer_uptime(peer
->uptime
, timebuf
,
8047 BGP_UPTIME_LEN
, 0, NULL
));
8049 if (peer
->status
== Established
)
8050 if (peer
->afc_recv
[afi
][safi
])
8051 vty_out(vty
, " %12ld",
8055 vty_out(vty
, " NoNeg");
8057 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8058 vty_out(vty
, " Idle (Admin)");
8059 else if (CHECK_FLAG(
8061 PEER_STATUS_PREFIX_OVERFLOW
))
8062 vty_out(vty
, " Idle (PfxCt)");
8064 vty_out(vty
, " %12s",
8065 lookup_msg(bgp_status_msg
,
8066 peer
->status
, NULL
));
8073 json_object_object_add(json
, "peers", json_peers
);
8075 json_object_int_add(json
, "totalPeers", count
);
8076 json_object_int_add(json
, "dynamicPeers", dn_count
);
8078 bgp_show_bestpath_json(bgp
, json
);
8080 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8081 json
, JSON_C_TO_STRING_PRETTY
));
8082 json_object_free(json
);
8085 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8087 vty_out(vty
, "No %s neighbor is configured\n",
8088 afi_safi_print(afi
, safi
));
8092 vty_out(vty
, "* - dynamic neighbor\n");
8093 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8094 dn_count
, bgp
->dynamic_neighbors_limit
);
8101 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8102 int safi
, bool use_json
,
8106 int afi_wildcard
= (afi
== AFI_MAX
);
8107 int safi_wildcard
= (safi
== SAFI_MAX
);
8108 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8109 bool nbr_output
= false;
8111 if (use_json
&& is_wildcard
)
8112 vty_out(vty
, "{\n");
8114 afi
= 1; /* AFI_IP */
8115 while (afi
< AFI_MAX
) {
8117 safi
= 1; /* SAFI_UNICAST */
8118 while (safi
< SAFI_MAX
) {
8119 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8123 * So limit output to those afi/safi
8125 * actualy have something interesting in
8129 json
= json_object_new_object();
8132 vty_out(vty
, ",\n");
8136 vty_out(vty
, "\"%s\":",
8140 vty_out(vty
, "\n%s Summary:\n",
8145 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
8157 if (use_json
&& is_wildcard
)
8158 vty_out(vty
, "}\n");
8159 else if (!nbr_output
) {
8161 vty_out(vty
, "{}\n");
8163 vty_out(vty
, "%% No BGP neighbors found\n");
8167 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8168 safi_t safi
, bool use_json
)
8170 struct listnode
*node
, *nnode
;
8172 json_object
*json
= NULL
;
8174 bool nbr_output
= false;
8177 vty_out(vty
, "{\n");
8179 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8182 json
= json_object_new_object();
8185 vty_out(vty
, ",\n");
8189 vty_out(vty
, "\"%s\":",
8190 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8194 vty_out(vty
, "\nInstance %s:\n",
8195 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8199 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
8203 vty_out(vty
, "}\n");
8204 else if (!nbr_output
)
8205 vty_out(vty
, "%% BGP instance not found\n");
8208 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8209 safi_t safi
, bool use_json
)
8214 if (strmatch(name
, "all")) {
8215 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8219 bgp
= bgp_lookup_by_name(name
);
8223 vty_out(vty
, "{}\n");
8226 "%% BGP instance not found\n");
8230 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
8236 bgp
= bgp_get_default();
8239 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
8242 vty_out(vty
, "{}\n");
8244 vty_out(vty
, "%% BGP instance not found\n");
8251 /* `show [ip] bgp summary' commands. */
8252 DEFUN (show_ip_bgp_summary
,
8253 show_ip_bgp_summary_cmd
,
8254 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8258 BGP_INSTANCE_HELP_STR
8260 BGP_SAFI_WITH_LABEL_HELP_STR
8261 "Summary of BGP neighbor status\n"
8265 afi_t afi
= AFI_MAX
;
8266 safi_t safi
= SAFI_MAX
;
8271 if (argv_find(argv
, argc
, "ip", &idx
))
8273 /* [<vrf> VIEWVRFNAME] */
8274 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8275 vrf
= argv
[idx
+ 1]->arg
;
8276 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8278 } else if (argv_find(argv
, argc
, "view", &idx
))
8279 /* [<view> VIEWVRFNAME] */
8280 vrf
= argv
[idx
+ 1]->arg
;
8281 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8282 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8283 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8286 bool uj
= use_json(argc
, argv
);
8288 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8291 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8293 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8294 return "IPv4 Unicast";
8295 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8296 return "IPv4 Multicast";
8297 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8298 return "IPv4 Labeled Unicast";
8299 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8301 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8302 return "IPv4 Encap";
8303 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8304 return "IPv4 Flowspec";
8305 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8306 return "IPv6 Unicast";
8307 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8308 return "IPv6 Multicast";
8309 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8310 return "IPv6 Labeled Unicast";
8311 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8313 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8314 return "IPv6 Encap";
8315 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8316 return "IPv6 Flowspec";
8317 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8318 return "L2VPN EVPN";
8324 * Please note that we have intentionally camelCased
8325 * the return strings here. So if you want
8326 * to use this function, please ensure you
8327 * are doing this within json output
8329 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8331 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8332 return "ipv4Unicast";
8333 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8334 return "ipv4Multicast";
8335 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8336 return "ipv4LabeledUnicast";
8337 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8339 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8341 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8342 return "ipv4Flowspec";
8343 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8344 return "ipv6Unicast";
8345 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8346 return "ipv6Multicast";
8347 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8348 return "ipv6LabeledUnicast";
8349 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8351 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8353 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8354 return "ipv6Flowspec";
8355 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8361 /* Show BGP peer's information. */
8362 enum show_type
{ show_all
, show_peer
};
8364 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8365 afi_t afi
, safi_t safi
,
8366 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8367 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8368 bool use_json
, json_object
*json_pref
)
8371 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8372 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8374 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8375 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8376 json_object_string_add(json_pref
, "sendMode",
8377 "advertisedAndReceived");
8378 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8379 json_object_string_add(json_pref
, "sendMode",
8381 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8382 json_object_string_add(json_pref
, "sendMode",
8385 vty_out(vty
, " Send-mode: ");
8386 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8387 vty_out(vty
, "advertised");
8388 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8389 vty_out(vty
, "%sreceived",
8390 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8399 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8400 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8402 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8403 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8404 json_object_string_add(json_pref
, "recvMode",
8405 "advertisedAndReceived");
8406 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8407 json_object_string_add(json_pref
, "recvMode",
8409 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8410 json_object_string_add(json_pref
, "recvMode",
8413 vty_out(vty
, " Receive-mode: ");
8414 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8415 vty_out(vty
, "advertised");
8416 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8417 vty_out(vty
, "%sreceived",
8418 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8427 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8428 safi_t safi
, bool use_json
,
8429 json_object
*json_neigh
)
8431 struct bgp_filter
*filter
;
8432 struct peer_af
*paf
;
8433 char orf_pfx_name
[BUFSIZ
];
8435 json_object
*json_af
= NULL
;
8436 json_object
*json_prefA
= NULL
;
8437 json_object
*json_prefB
= NULL
;
8438 json_object
*json_addr
= NULL
;
8441 json_addr
= json_object_new_object();
8442 json_af
= json_object_new_object();
8443 filter
= &p
->filter
[afi
][safi
];
8445 if (peer_group_active(p
))
8446 json_object_string_add(json_addr
, "peerGroupMember",
8449 paf
= peer_af_find(p
, afi
, safi
);
8450 if (paf
&& PAF_SUBGRP(paf
)) {
8451 json_object_int_add(json_addr
, "updateGroupId",
8452 PAF_UPDGRP(paf
)->id
);
8453 json_object_int_add(json_addr
, "subGroupId",
8454 PAF_SUBGRP(paf
)->id
);
8455 json_object_int_add(json_addr
, "packetQueueLength",
8456 bpacket_queue_virtual_length(paf
));
8459 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8460 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8461 PEER_CAP_ORF_PREFIX_SM_RCV
)
8462 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8463 PEER_CAP_ORF_PREFIX_RM_ADV
)
8464 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8465 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8466 json_object_int_add(json_af
, "orfType",
8468 json_prefA
= json_object_new_object();
8469 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8470 PEER_CAP_ORF_PREFIX_SM_ADV
,
8471 PEER_CAP_ORF_PREFIX_RM_ADV
,
8472 PEER_CAP_ORF_PREFIX_SM_RCV
,
8473 PEER_CAP_ORF_PREFIX_RM_RCV
,
8474 use_json
, json_prefA
);
8475 json_object_object_add(json_af
, "orfPrefixList",
8479 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8480 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8481 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8482 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8483 PEER_CAP_ORF_PREFIX_RM_ADV
)
8484 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8485 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8486 json_object_int_add(json_af
, "orfOldType",
8487 ORF_TYPE_PREFIX_OLD
);
8488 json_prefB
= json_object_new_object();
8489 bgp_show_peer_afi_orf_cap(
8490 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8491 PEER_CAP_ORF_PREFIX_RM_ADV
,
8492 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8493 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8495 json_object_object_add(json_af
, "orfOldPrefixList",
8499 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8500 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8501 PEER_CAP_ORF_PREFIX_SM_RCV
)
8502 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8503 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8504 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8505 PEER_CAP_ORF_PREFIX_RM_ADV
)
8506 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8507 PEER_CAP_ORF_PREFIX_RM_RCV
)
8508 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8509 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8510 json_object_object_add(json_addr
, "afDependentCap",
8513 json_object_free(json_af
);
8515 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8516 orf_pfx_count
= prefix_bgp_show_prefix_list(
8517 NULL
, afi
, orf_pfx_name
, use_json
);
8519 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8520 PEER_STATUS_ORF_PREFIX_SEND
)
8522 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8523 PEER_STATUS_ORF_PREFIX_SEND
))
8524 json_object_boolean_true_add(json_neigh
,
8527 json_object_int_add(json_addr
, "orfRecvCounter",
8530 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8531 PEER_STATUS_ORF_WAIT_REFRESH
))
8532 json_object_string_add(
8533 json_addr
, "orfFirstUpdate",
8534 "deferredUntilORFOrRouteRefreshRecvd");
8536 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8537 PEER_FLAG_REFLECTOR_CLIENT
))
8538 json_object_boolean_true_add(json_addr
,
8539 "routeReflectorClient");
8540 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8541 PEER_FLAG_RSERVER_CLIENT
))
8542 json_object_boolean_true_add(json_addr
,
8543 "routeServerClient");
8544 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8545 json_object_boolean_true_add(json_addr
,
8546 "inboundSoftConfigPermit");
8548 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8549 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8550 json_object_boolean_true_add(
8552 "privateAsNumsAllReplacedInUpdatesToNbr");
8553 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8554 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8555 json_object_boolean_true_add(
8557 "privateAsNumsReplacedInUpdatesToNbr");
8558 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8559 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8560 json_object_boolean_true_add(
8562 "privateAsNumsAllRemovedInUpdatesToNbr");
8563 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8564 PEER_FLAG_REMOVE_PRIVATE_AS
))
8565 json_object_boolean_true_add(
8567 "privateAsNumsRemovedInUpdatesToNbr");
8569 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8570 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
8571 json_object_boolean_true_add(json_addr
,
8572 "addpathTxAllPaths");
8574 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8575 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
8576 json_object_boolean_true_add(json_addr
,
8577 "addpathTxBestpathPerAS");
8579 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8580 json_object_string_add(json_addr
,
8581 "overrideASNsInOutboundUpdates",
8582 "ifAspathEqualRemoteAs");
8584 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8585 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8586 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8587 json_object_boolean_true_add(json_addr
,
8588 "routerAlwaysNextHop");
8589 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8590 PEER_FLAG_AS_PATH_UNCHANGED
))
8591 json_object_boolean_true_add(
8592 json_addr
, "unchangedAsPathPropogatedToNbr");
8593 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8594 PEER_FLAG_NEXTHOP_UNCHANGED
))
8595 json_object_boolean_true_add(
8596 json_addr
, "unchangedNextHopPropogatedToNbr");
8597 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8598 json_object_boolean_true_add(
8599 json_addr
, "unchangedMedPropogatedToNbr");
8600 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8601 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8602 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8603 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8604 PEER_FLAG_SEND_COMMUNITY
)
8605 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8606 PEER_FLAG_SEND_EXT_COMMUNITY
))
8607 json_object_string_add(json_addr
,
8608 "commAttriSentToNbr",
8609 "extendedAndStandard");
8610 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8611 PEER_FLAG_SEND_EXT_COMMUNITY
))
8612 json_object_string_add(json_addr
,
8613 "commAttriSentToNbr",
8616 json_object_string_add(json_addr
,
8617 "commAttriSentToNbr",
8620 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8621 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8622 if (p
->default_rmap
[afi
][safi
].name
)
8623 json_object_string_add(
8624 json_addr
, "defaultRouteMap",
8625 p
->default_rmap
[afi
][safi
].name
);
8627 if (paf
&& PAF_SUBGRP(paf
)
8628 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8629 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8630 json_object_boolean_true_add(json_addr
,
8633 json_object_boolean_true_add(json_addr
,
8637 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8638 if (is_evpn_enabled())
8639 json_object_boolean_true_add(
8640 json_addr
, "advertiseAllVnis");
8643 if (filter
->plist
[FILTER_IN
].name
8644 || filter
->dlist
[FILTER_IN
].name
8645 || filter
->aslist
[FILTER_IN
].name
8646 || filter
->map
[RMAP_IN
].name
)
8647 json_object_boolean_true_add(json_addr
,
8648 "inboundPathPolicyConfig");
8649 if (filter
->plist
[FILTER_OUT
].name
8650 || filter
->dlist
[FILTER_OUT
].name
8651 || filter
->aslist
[FILTER_OUT
].name
8652 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8653 json_object_boolean_true_add(
8654 json_addr
, "outboundPathPolicyConfig");
8657 if (filter
->plist
[FILTER_IN
].name
)
8658 json_object_string_add(json_addr
,
8659 "incomingUpdatePrefixFilterList",
8660 filter
->plist
[FILTER_IN
].name
);
8661 if (filter
->plist
[FILTER_OUT
].name
)
8662 json_object_string_add(json_addr
,
8663 "outgoingUpdatePrefixFilterList",
8664 filter
->plist
[FILTER_OUT
].name
);
8666 /* distribute-list */
8667 if (filter
->dlist
[FILTER_IN
].name
)
8668 json_object_string_add(
8669 json_addr
, "incomingUpdateNetworkFilterList",
8670 filter
->dlist
[FILTER_IN
].name
);
8671 if (filter
->dlist
[FILTER_OUT
].name
)
8672 json_object_string_add(
8673 json_addr
, "outgoingUpdateNetworkFilterList",
8674 filter
->dlist
[FILTER_OUT
].name
);
8677 if (filter
->aslist
[FILTER_IN
].name
)
8678 json_object_string_add(json_addr
,
8679 "incomingUpdateAsPathFilterList",
8680 filter
->aslist
[FILTER_IN
].name
);
8681 if (filter
->aslist
[FILTER_OUT
].name
)
8682 json_object_string_add(json_addr
,
8683 "outgoingUpdateAsPathFilterList",
8684 filter
->aslist
[FILTER_OUT
].name
);
8687 if (filter
->map
[RMAP_IN
].name
)
8688 json_object_string_add(
8689 json_addr
, "routeMapForIncomingAdvertisements",
8690 filter
->map
[RMAP_IN
].name
);
8691 if (filter
->map
[RMAP_OUT
].name
)
8692 json_object_string_add(
8693 json_addr
, "routeMapForOutgoingAdvertisements",
8694 filter
->map
[RMAP_OUT
].name
);
8696 /* unsuppress-map */
8697 if (filter
->usmap
.name
)
8698 json_object_string_add(json_addr
,
8699 "selectiveUnsuppressRouteMap",
8700 filter
->usmap
.name
);
8702 /* Receive prefix count */
8703 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8704 p
->pcount
[afi
][safi
]);
8705 if (paf
&& PAF_SUBGRP(paf
))
8706 json_object_int_add(json_addr
, "sentPrefixCounter",
8707 (PAF_SUBGRP(paf
))->scount
);
8709 /* Maximum prefix */
8710 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8711 json_object_int_add(json_addr
, "prefixAllowedMax",
8712 p
->pmax
[afi
][safi
]);
8713 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8714 PEER_FLAG_MAX_PREFIX_WARNING
))
8715 json_object_boolean_true_add(
8716 json_addr
, "prefixAllowedMaxWarning");
8717 json_object_int_add(json_addr
,
8718 "prefixAllowedWarningThresh",
8719 p
->pmax_threshold
[afi
][safi
]);
8720 if (p
->pmax_restart
[afi
][safi
])
8721 json_object_int_add(
8723 "prefixAllowedRestartIntervalMsecs",
8724 p
->pmax_restart
[afi
][safi
] * 60000);
8726 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8730 filter
= &p
->filter
[afi
][safi
];
8732 vty_out(vty
, " For address family: %s\n",
8733 afi_safi_print(afi
, safi
));
8735 if (peer_group_active(p
))
8736 vty_out(vty
, " %s peer-group member\n",
8739 paf
= peer_af_find(p
, afi
, safi
);
8740 if (paf
&& PAF_SUBGRP(paf
)) {
8741 vty_out(vty
, " Update group %" PRIu64
8742 ", subgroup %" PRIu64
"\n",
8743 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8744 vty_out(vty
, " Packet Queue length %d\n",
8745 bpacket_queue_virtual_length(paf
));
8747 vty_out(vty
, " Not part of any update group\n");
8749 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8750 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8751 PEER_CAP_ORF_PREFIX_SM_RCV
)
8752 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8753 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8754 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8755 PEER_CAP_ORF_PREFIX_RM_ADV
)
8756 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8757 PEER_CAP_ORF_PREFIX_RM_RCV
)
8758 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8759 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8760 vty_out(vty
, " AF-dependant capabilities:\n");
8762 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8763 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8764 PEER_CAP_ORF_PREFIX_SM_RCV
)
8765 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8766 PEER_CAP_ORF_PREFIX_RM_ADV
)
8767 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8768 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8770 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8772 bgp_show_peer_afi_orf_cap(
8773 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8774 PEER_CAP_ORF_PREFIX_RM_ADV
,
8775 PEER_CAP_ORF_PREFIX_SM_RCV
,
8776 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8778 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8779 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8780 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8781 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8782 PEER_CAP_ORF_PREFIX_RM_ADV
)
8783 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8784 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8786 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8787 ORF_TYPE_PREFIX_OLD
);
8788 bgp_show_peer_afi_orf_cap(
8789 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8790 PEER_CAP_ORF_PREFIX_RM_ADV
,
8791 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8792 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8795 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8796 orf_pfx_count
= prefix_bgp_show_prefix_list(
8797 NULL
, afi
, orf_pfx_name
, use_json
);
8799 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8800 PEER_STATUS_ORF_PREFIX_SEND
)
8802 vty_out(vty
, " Outbound Route Filter (ORF):");
8803 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8804 PEER_STATUS_ORF_PREFIX_SEND
))
8805 vty_out(vty
, " sent;");
8807 vty_out(vty
, " received (%d entries)",
8811 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8812 PEER_STATUS_ORF_WAIT_REFRESH
))
8814 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
8816 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8817 PEER_FLAG_REFLECTOR_CLIENT
))
8818 vty_out(vty
, " Route-Reflector Client\n");
8819 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8820 PEER_FLAG_RSERVER_CLIENT
))
8821 vty_out(vty
, " Route-Server Client\n");
8822 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8824 " Inbound soft reconfiguration allowed\n");
8826 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8827 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8829 " Private AS numbers (all) replaced in updates to this neighbor\n");
8830 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8831 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8833 " Private AS numbers replaced in updates to this neighbor\n");
8834 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8835 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8837 " Private AS numbers (all) removed in updates to this neighbor\n");
8838 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8839 PEER_FLAG_REMOVE_PRIVATE_AS
))
8841 " Private AS numbers removed in updates to this neighbor\n");
8843 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8844 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
8845 vty_out(vty
, " Advertise all paths via addpath\n");
8847 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8848 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
8850 " Advertise bestpath per AS via addpath\n");
8852 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8854 " Override ASNs in outbound updates if aspath equals remote-as\n");
8856 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8857 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8858 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8859 vty_out(vty
, " NEXT_HOP is always this router\n");
8860 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8861 PEER_FLAG_AS_PATH_UNCHANGED
))
8863 " AS_PATH is propagated unchanged to this neighbor\n");
8864 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8865 PEER_FLAG_NEXTHOP_UNCHANGED
))
8867 " NEXT_HOP is propagated unchanged to this neighbor\n");
8868 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8870 " MED is propagated unchanged to this neighbor\n");
8871 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8872 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8873 PEER_FLAG_SEND_EXT_COMMUNITY
)
8874 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8875 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
8877 " Community attribute sent to this neighbor");
8878 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8879 PEER_FLAG_SEND_COMMUNITY
)
8880 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8881 PEER_FLAG_SEND_EXT_COMMUNITY
)
8882 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8883 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8884 vty_out(vty
, "(all)\n");
8885 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8886 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8887 vty_out(vty
, "(large)\n");
8888 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8889 PEER_FLAG_SEND_EXT_COMMUNITY
))
8890 vty_out(vty
, "(extended)\n");
8892 vty_out(vty
, "(standard)\n");
8894 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8895 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8896 vty_out(vty
, " Default information originate,");
8898 if (p
->default_rmap
[afi
][safi
].name
)
8899 vty_out(vty
, " default route-map %s%s,",
8900 p
->default_rmap
[afi
][safi
].map
? "*"
8902 p
->default_rmap
[afi
][safi
].name
);
8903 if (paf
&& PAF_SUBGRP(paf
)
8904 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8905 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8906 vty_out(vty
, " default sent\n");
8908 vty_out(vty
, " default not sent\n");
8911 /* advertise-vni-all */
8912 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8913 if (is_evpn_enabled())
8914 vty_out(vty
, " advertise-all-vni\n");
8917 if (filter
->plist
[FILTER_IN
].name
8918 || filter
->dlist
[FILTER_IN
].name
8919 || filter
->aslist
[FILTER_IN
].name
8920 || filter
->map
[RMAP_IN
].name
)
8921 vty_out(vty
, " Inbound path policy configured\n");
8922 if (filter
->plist
[FILTER_OUT
].name
8923 || filter
->dlist
[FILTER_OUT
].name
8924 || filter
->aslist
[FILTER_OUT
].name
8925 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8926 vty_out(vty
, " Outbound path policy configured\n");
8929 if (filter
->plist
[FILTER_IN
].name
)
8931 " Incoming update prefix filter list is %s%s\n",
8932 filter
->plist
[FILTER_IN
].plist
? "*" : "",
8933 filter
->plist
[FILTER_IN
].name
);
8934 if (filter
->plist
[FILTER_OUT
].name
)
8936 " Outgoing update prefix filter list is %s%s\n",
8937 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
8938 filter
->plist
[FILTER_OUT
].name
);
8940 /* distribute-list */
8941 if (filter
->dlist
[FILTER_IN
].name
)
8943 " Incoming update network filter list is %s%s\n",
8944 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
8945 filter
->dlist
[FILTER_IN
].name
);
8946 if (filter
->dlist
[FILTER_OUT
].name
)
8948 " Outgoing update network filter list is %s%s\n",
8949 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
8950 filter
->dlist
[FILTER_OUT
].name
);
8953 if (filter
->aslist
[FILTER_IN
].name
)
8955 " Incoming update AS path filter list is %s%s\n",
8956 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
8957 filter
->aslist
[FILTER_IN
].name
);
8958 if (filter
->aslist
[FILTER_OUT
].name
)
8960 " Outgoing update AS path filter list is %s%s\n",
8961 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
8962 filter
->aslist
[FILTER_OUT
].name
);
8965 if (filter
->map
[RMAP_IN
].name
)
8967 " Route map for incoming advertisements is %s%s\n",
8968 filter
->map
[RMAP_IN
].map
? "*" : "",
8969 filter
->map
[RMAP_IN
].name
);
8970 if (filter
->map
[RMAP_OUT
].name
)
8972 " Route map for outgoing advertisements is %s%s\n",
8973 filter
->map
[RMAP_OUT
].map
? "*" : "",
8974 filter
->map
[RMAP_OUT
].name
);
8976 /* unsuppress-map */
8977 if (filter
->usmap
.name
)
8979 " Route map for selective unsuppress is %s%s\n",
8980 filter
->usmap
.map
? "*" : "",
8981 filter
->usmap
.name
);
8983 /* Receive prefix count */
8984 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
8986 /* Maximum prefix */
8987 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8988 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
8990 CHECK_FLAG(p
->af_flags
[afi
][safi
],
8991 PEER_FLAG_MAX_PREFIX_WARNING
)
8994 vty_out(vty
, " Threshold for warning message %d%%",
8995 p
->pmax_threshold
[afi
][safi
]);
8996 if (p
->pmax_restart
[afi
][safi
])
8997 vty_out(vty
, ", restart interval %d min",
8998 p
->pmax_restart
[afi
][safi
]);
9006 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
9010 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
9011 char timebuf
[BGP_UPTIME_LEN
];
9013 const char *subcode_str
;
9014 const char *code_str
;
9019 json_object
*json_neigh
= NULL
;
9025 json_neigh
= json_object_new_object();
9027 memset(dn_flag
, '\0', sizeof(dn_flag
));
9028 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9032 if (p
->conf_if
) /* Configured interface name. */
9033 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9034 BGP_PEER_SU_UNSPEC(p
)
9036 : sockunion2str(&p
->su
, buf
,
9038 else /* Configured IP address. */
9039 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9044 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9045 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9047 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9048 json_object_string_add(
9049 json_neigh
, "bgpNeighborAddr",
9050 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9052 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9054 if (p
->change_local_as
)
9055 json_object_int_add(json_neigh
, "localAs",
9056 p
->change_local_as
);
9058 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9060 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9061 json_object_boolean_true_add(json_neigh
,
9062 "localAsNoPrepend");
9064 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9065 json_object_boolean_true_add(json_neigh
,
9066 "localAsReplaceAs");
9068 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9069 || (p
->as_type
== AS_INTERNAL
))
9070 vty_out(vty
, "remote AS %u, ", p
->as
);
9072 vty_out(vty
, "remote AS Unspecified, ");
9073 vty_out(vty
, "local AS %u%s%s, ",
9074 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9075 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9078 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9082 /* peer type internal, external, confed-internal or confed-external */
9083 if (p
->as
== p
->local_as
) {
9085 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9086 json_object_boolean_true_add(
9087 json_neigh
, "nbrConfedInternalLink");
9089 json_object_boolean_true_add(json_neigh
,
9092 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9093 vty_out(vty
, "confed-internal link\n");
9095 vty_out(vty
, "internal link\n");
9099 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9100 json_object_boolean_true_add(
9101 json_neigh
, "nbrConfedExternalLink");
9103 json_object_boolean_true_add(json_neigh
,
9106 if (bgp_confederation_peers_check(bgp
, p
->as
))
9107 vty_out(vty
, "confed-external link\n");
9109 vty_out(vty
, "external link\n");
9116 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9118 vty_out(vty
, " Description: %s\n", p
->desc
);
9124 json_object_string_add(json_neigh
, "hostname",
9128 json_object_string_add(json_neigh
, "domainname",
9131 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9132 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9135 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9142 json_object_string_add(json_neigh
, "peerGroup",
9146 struct prefix prefix
, *range
= NULL
;
9148 sockunion2hostprefix(&(p
->su
), &prefix
);
9149 range
= peer_group_lookup_dynamic_neighbor_range(
9153 prefix2str(range
, buf1
, sizeof(buf1
));
9154 json_object_string_add(
9156 "peerSubnetRangeGroup", buf1
);
9161 " Member of peer-group %s for session parameters\n",
9165 struct prefix prefix
, *range
= NULL
;
9167 sockunion2hostprefix(&(p
->su
), &prefix
);
9168 range
= peer_group_lookup_dynamic_neighbor_range(
9172 prefix2str(range
, buf1
, sizeof(buf1
));
9174 " Belongs to the subnet range group: %s\n",
9182 /* Administrative shutdown. */
9183 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9184 json_object_boolean_true_add(json_neigh
,
9188 json_object_int_add(json_neigh
, "bgpVersion", 4);
9189 json_object_string_add(
9190 json_neigh
, "remoteRouterId",
9191 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9192 json_object_string_add(
9193 json_neigh
, "localRouterId",
9194 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9198 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9199 && bgp_confederation_peers_check(bgp
, p
->as
))
9200 json_object_boolean_true_add(json_neigh
,
9204 json_object_string_add(
9205 json_neigh
, "bgpState",
9206 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9208 if (p
->status
== Established
) {
9211 uptime
= bgp_clock();
9212 uptime
-= p
->uptime
;
9213 epoch_tbuf
= time(NULL
) - uptime
;
9215 #if CONFDATE > 20200101
9217 "bgpTimerUp should be deprecated and can be removed now");
9220 * bgpTimerUp was miliseconds that was accurate
9221 * up to 1 day, then the value returned
9222 * became garbage. So in order to provide
9223 * some level of backwards compatability,
9224 * we still provde the data, but now
9225 * we are returning the correct value
9226 * and also adding a new bgpTimerUpMsec
9227 * which will allow us to deprecate
9230 json_object_int_add(json_neigh
, "bgpTimerUp",
9232 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9234 json_object_string_add(json_neigh
, "bgpTimerUpString",
9235 peer_uptime(p
->uptime
, timebuf
,
9238 json_object_int_add(json_neigh
,
9239 "bgpTimerUpEstablishedEpoch",
9243 else if (p
->status
== Active
) {
9244 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9245 json_object_string_add(json_neigh
, "bgpStateIs",
9247 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9248 json_object_string_add(json_neigh
, "bgpStateIs",
9256 uptime
= bgp_clock();
9257 uptime
-= p
->readtime
;
9258 tm
= gmtime(&uptime
);
9259 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9260 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9261 + (tm
->tm_hour
* 3600000));
9263 uptime
= bgp_clock();
9264 uptime
-= p
->last_write
;
9265 tm
= gmtime(&uptime
);
9266 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9267 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9268 + (tm
->tm_hour
* 3600000));
9270 uptime
= bgp_clock();
9271 uptime
-= p
->update_time
;
9272 tm
= gmtime(&uptime
);
9273 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9274 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9275 + (tm
->tm_hour
* 3600000));
9277 /* Configured timer values. */
9278 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9279 p
->v_holdtime
* 1000);
9280 json_object_int_add(json_neigh
,
9281 "bgpTimerKeepAliveIntervalMsecs",
9282 p
->v_keepalive
* 1000);
9283 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9284 json_object_int_add(json_neigh
,
9285 "bgpTimerConfiguredHoldTimeMsecs",
9286 p
->holdtime
* 1000);
9287 json_object_int_add(
9289 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9290 p
->keepalive
* 1000);
9291 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9292 || (bgp
->default_keepalive
9293 != BGP_DEFAULT_KEEPALIVE
)) {
9294 json_object_int_add(json_neigh
,
9295 "bgpTimerConfiguredHoldTimeMsecs",
9296 bgp
->default_holdtime
);
9297 json_object_int_add(
9299 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9300 bgp
->default_keepalive
);
9303 /* Administrative shutdown. */
9304 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9305 vty_out(vty
, " Administratively shut down\n");
9308 vty_out(vty
, " BGP version 4");
9309 vty_out(vty
, ", remote router ID %s",
9310 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9311 vty_out(vty
, ", local router ID %s\n",
9312 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9316 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9317 && bgp_confederation_peers_check(bgp
, p
->as
))
9319 " Neighbor under common administration\n");
9322 vty_out(vty
, " BGP state = %s",
9323 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9325 if (p
->status
== Established
)
9326 vty_out(vty
, ", up for %8s",
9327 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9330 else if (p
->status
== Active
) {
9331 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9332 vty_out(vty
, " (passive)");
9333 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9334 vty_out(vty
, " (NSF passive)");
9339 vty_out(vty
, " Last read %s",
9340 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9342 vty_out(vty
, ", Last write %s\n",
9343 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9346 /* Configured timer values. */
9348 " Hold time is %d, keepalive interval is %d seconds\n",
9349 p
->v_holdtime
, p
->v_keepalive
);
9350 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9351 vty_out(vty
, " Configured hold time is %d",
9353 vty_out(vty
, ", keepalive interval is %d seconds\n",
9355 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9356 || (bgp
->default_keepalive
9357 != BGP_DEFAULT_KEEPALIVE
)) {
9358 vty_out(vty
, " Configured hold time is %d",
9359 bgp
->default_holdtime
);
9360 vty_out(vty
, ", keepalive interval is %d seconds\n",
9361 bgp
->default_keepalive
);
9365 if (p
->status
== Established
) {
9366 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9367 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9368 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9369 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9370 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9371 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9372 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9373 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9374 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9375 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9376 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9377 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9378 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9379 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9380 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9381 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9382 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9383 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9384 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9385 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9387 json_object
*json_cap
= NULL
;
9389 json_cap
= json_object_new_object();
9392 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9393 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9394 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9395 && CHECK_FLAG(p
->cap
,
9397 json_object_string_add(
9398 json_cap
, "4byteAs",
9399 "advertisedAndReceived");
9400 else if (CHECK_FLAG(p
->cap
,
9402 json_object_string_add(
9403 json_cap
, "4byteAs",
9405 else if (CHECK_FLAG(p
->cap
,
9407 json_object_string_add(
9408 json_cap
, "4byteAs",
9413 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9414 || CHECK_FLAG(p
->cap
,
9415 PEER_CAP_ADDPATH_ADV
)) {
9416 json_object
*json_add
= NULL
;
9417 const char *print_store
;
9419 json_add
= json_object_new_object();
9421 FOREACH_AFI_SAFI (afi
, safi
) {
9422 json_object
*json_sub
= NULL
;
9424 json_object_new_object();
9425 print_store
= afi_safi_print(
9431 PEER_CAP_ADDPATH_AF_TX_ADV
)
9435 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9440 PEER_CAP_ADDPATH_AF_TX_ADV
)
9445 PEER_CAP_ADDPATH_AF_TX_RCV
))
9446 json_object_boolean_true_add(
9448 "txAdvertisedAndReceived");
9454 PEER_CAP_ADDPATH_AF_TX_ADV
))
9455 json_object_boolean_true_add(
9463 PEER_CAP_ADDPATH_AF_TX_RCV
))
9464 json_object_boolean_true_add(
9472 PEER_CAP_ADDPATH_AF_RX_ADV
)
9476 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9481 PEER_CAP_ADDPATH_AF_RX_ADV
)
9486 PEER_CAP_ADDPATH_AF_RX_RCV
))
9487 json_object_boolean_true_add(
9489 "rxAdvertisedAndReceived");
9495 PEER_CAP_ADDPATH_AF_RX_ADV
))
9496 json_object_boolean_true_add(
9504 PEER_CAP_ADDPATH_AF_RX_RCV
))
9505 json_object_boolean_true_add(
9513 PEER_CAP_ADDPATH_AF_TX_ADV
)
9517 PEER_CAP_ADDPATH_AF_TX_RCV
)
9521 PEER_CAP_ADDPATH_AF_RX_ADV
)
9525 PEER_CAP_ADDPATH_AF_RX_RCV
))
9526 json_object_object_add(
9535 json_object_object_add(
9536 json_cap
, "addPath", json_add
);
9540 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9541 || CHECK_FLAG(p
->cap
,
9542 PEER_CAP_DYNAMIC_ADV
)) {
9543 if (CHECK_FLAG(p
->cap
,
9544 PEER_CAP_DYNAMIC_ADV
)
9545 && CHECK_FLAG(p
->cap
,
9546 PEER_CAP_DYNAMIC_RCV
))
9547 json_object_string_add(
9548 json_cap
, "dynamic",
9549 "advertisedAndReceived");
9550 else if (CHECK_FLAG(
9552 PEER_CAP_DYNAMIC_ADV
))
9553 json_object_string_add(
9554 json_cap
, "dynamic",
9556 else if (CHECK_FLAG(
9558 PEER_CAP_DYNAMIC_RCV
))
9559 json_object_string_add(
9560 json_cap
, "dynamic",
9564 /* Extended nexthop */
9565 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9566 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9567 json_object
*json_nxt
= NULL
;
9568 const char *print_store
;
9571 if (CHECK_FLAG(p
->cap
,
9573 && CHECK_FLAG(p
->cap
,
9575 json_object_string_add(
9578 "advertisedAndReceived");
9579 else if (CHECK_FLAG(p
->cap
,
9581 json_object_string_add(
9585 else if (CHECK_FLAG(p
->cap
,
9587 json_object_string_add(
9592 if (CHECK_FLAG(p
->cap
,
9593 PEER_CAP_ENHE_RCV
)) {
9595 json_object_new_object();
9597 for (safi
= SAFI_UNICAST
;
9598 safi
< SAFI_MAX
; safi
++) {
9603 PEER_CAP_ENHE_AF_RCV
)) {
9604 print_store
= afi_safi_print(
9607 json_object_string_add(
9613 json_object_object_add(
9615 "extendedNexthopFamililesByPeer",
9621 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9622 || CHECK_FLAG(p
->cap
,
9623 PEER_CAP_REFRESH_NEW_RCV
)
9624 || CHECK_FLAG(p
->cap
,
9625 PEER_CAP_REFRESH_OLD_RCV
)) {
9626 if (CHECK_FLAG(p
->cap
,
9627 PEER_CAP_REFRESH_ADV
)
9630 PEER_CAP_REFRESH_NEW_RCV
)
9633 PEER_CAP_REFRESH_OLD_RCV
))) {
9636 PEER_CAP_REFRESH_OLD_RCV
)
9639 PEER_CAP_REFRESH_NEW_RCV
))
9640 json_object_string_add(
9643 "advertisedAndReceivedOldNew");
9647 PEER_CAP_REFRESH_OLD_RCV
))
9648 json_object_string_add(
9651 "advertisedAndReceivedOld");
9653 json_object_string_add(
9656 "advertisedAndReceivedNew");
9661 PEER_CAP_REFRESH_ADV
))
9662 json_object_string_add(
9669 PEER_CAP_REFRESH_NEW_RCV
)
9672 PEER_CAP_REFRESH_OLD_RCV
))
9673 json_object_string_add(
9679 /* Multiprotocol Extensions */
9680 json_object
*json_multi
= NULL
;
9681 json_multi
= json_object_new_object();
9683 FOREACH_AFI_SAFI (afi
, safi
) {
9684 if (p
->afc_adv
[afi
][safi
]
9685 || p
->afc_recv
[afi
][safi
]) {
9686 json_object
*json_exten
= NULL
;
9688 json_object_new_object();
9690 if (p
->afc_adv
[afi
][safi
]
9691 && p
->afc_recv
[afi
][safi
])
9692 json_object_boolean_true_add(
9694 "advertisedAndReceived");
9695 else if (p
->afc_adv
[afi
][safi
])
9696 json_object_boolean_true_add(
9699 else if (p
->afc_recv
[afi
][safi
])
9700 json_object_boolean_true_add(
9704 json_object_object_add(
9711 json_object_object_add(
9712 json_cap
, "multiprotocolExtensions",
9715 /* Hostname capabilities */
9716 json_object
*json_hname
= NULL
;
9718 json_hname
= json_object_new_object();
9720 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9721 json_object_string_add(
9722 json_hname
, "advHostName",
9723 bgp
->peer_self
->hostname
9727 json_object_string_add(
9728 json_hname
, "advDomainName",
9729 bgp
->peer_self
->domainname
9736 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9737 json_object_string_add(
9738 json_hname
, "rcvHostName",
9739 p
->hostname
? p
->hostname
9741 json_object_string_add(
9742 json_hname
, "rcvDomainName",
9743 p
->domainname
? p
->domainname
9747 json_object_object_add(json_cap
, "hostName",
9750 /* Gracefull Restart */
9751 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9752 || CHECK_FLAG(p
->cap
,
9753 PEER_CAP_RESTART_ADV
)) {
9754 if (CHECK_FLAG(p
->cap
,
9755 PEER_CAP_RESTART_ADV
)
9756 && CHECK_FLAG(p
->cap
,
9757 PEER_CAP_RESTART_RCV
))
9758 json_object_string_add(
9761 "advertisedAndReceived");
9762 else if (CHECK_FLAG(
9764 PEER_CAP_RESTART_ADV
))
9765 json_object_string_add(
9767 "gracefulRestartCapability",
9769 else if (CHECK_FLAG(
9771 PEER_CAP_RESTART_RCV
))
9772 json_object_string_add(
9774 "gracefulRestartCapability",
9777 if (CHECK_FLAG(p
->cap
,
9778 PEER_CAP_RESTART_RCV
)) {
9779 int restart_af_count
= 0;
9780 json_object
*json_restart
=
9783 json_object_new_object();
9785 json_object_int_add(
9787 "gracefulRestartRemoteTimerMsecs",
9788 p
->v_gr_restart
* 1000);
9790 FOREACH_AFI_SAFI (afi
, safi
) {
9795 PEER_CAP_RESTART_AF_RCV
)) {
9800 json_object_new_object();
9806 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
9807 json_object_boolean_true_add(
9811 json_object_object_add(
9819 if (!restart_af_count
) {
9820 json_object_string_add(
9822 "addressFamiliesByPeer",
9827 json_object_object_add(
9829 "addressFamiliesByPeer",
9833 json_object_object_add(json_neigh
,
9834 "neighborCapabilities",
9837 vty_out(vty
, " Neighbor capabilities:\n");
9840 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9841 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9842 vty_out(vty
, " 4 Byte AS:");
9843 if (CHECK_FLAG(p
->cap
,
9845 vty_out(vty
, " advertised");
9846 if (CHECK_FLAG(p
->cap
,
9848 vty_out(vty
, " %sreceived",
9858 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9859 || CHECK_FLAG(p
->cap
,
9860 PEER_CAP_ADDPATH_ADV
)) {
9861 vty_out(vty
, " AddPath:\n");
9863 FOREACH_AFI_SAFI (afi
, safi
) {
9867 PEER_CAP_ADDPATH_AF_TX_ADV
)
9871 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9882 PEER_CAP_ADDPATH_AF_TX_ADV
))
9893 PEER_CAP_ADDPATH_AF_TX_RCV
))
9900 PEER_CAP_ADDPATH_AF_TX_ADV
)
9910 PEER_CAP_ADDPATH_AF_RX_ADV
)
9914 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9925 PEER_CAP_ADDPATH_AF_RX_ADV
))
9936 PEER_CAP_ADDPATH_AF_RX_RCV
))
9943 PEER_CAP_ADDPATH_AF_RX_ADV
)
9953 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9954 || CHECK_FLAG(p
->cap
,
9955 PEER_CAP_DYNAMIC_ADV
)) {
9956 vty_out(vty
, " Dynamic:");
9957 if (CHECK_FLAG(p
->cap
,
9958 PEER_CAP_DYNAMIC_ADV
))
9959 vty_out(vty
, " advertised");
9960 if (CHECK_FLAG(p
->cap
,
9961 PEER_CAP_DYNAMIC_RCV
))
9962 vty_out(vty
, " %sreceived",
9965 PEER_CAP_DYNAMIC_ADV
)
9971 /* Extended nexthop */
9972 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9973 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9974 vty_out(vty
, " Extended nexthop:");
9975 if (CHECK_FLAG(p
->cap
,
9977 vty_out(vty
, " advertised");
9978 if (CHECK_FLAG(p
->cap
,
9980 vty_out(vty
, " %sreceived",
9988 if (CHECK_FLAG(p
->cap
,
9989 PEER_CAP_ENHE_RCV
)) {
9991 " Address families by peer:\n ");
9992 for (safi
= SAFI_UNICAST
;
9993 safi
< SAFI_MAX
; safi
++)
9998 PEER_CAP_ENHE_AF_RCV
))
10007 /* Route Refresh */
10008 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10009 || CHECK_FLAG(p
->cap
,
10010 PEER_CAP_REFRESH_NEW_RCV
)
10011 || CHECK_FLAG(p
->cap
,
10012 PEER_CAP_REFRESH_OLD_RCV
)) {
10013 vty_out(vty
, " Route refresh:");
10014 if (CHECK_FLAG(p
->cap
,
10015 PEER_CAP_REFRESH_ADV
))
10016 vty_out(vty
, " advertised");
10017 if (CHECK_FLAG(p
->cap
,
10018 PEER_CAP_REFRESH_NEW_RCV
)
10021 PEER_CAP_REFRESH_OLD_RCV
))
10022 vty_out(vty
, " %sreceived(%s)",
10025 PEER_CAP_REFRESH_ADV
)
10030 PEER_CAP_REFRESH_OLD_RCV
)
10033 PEER_CAP_REFRESH_NEW_RCV
))
10037 PEER_CAP_REFRESH_OLD_RCV
)
10041 vty_out(vty
, "\n");
10044 /* Multiprotocol Extensions */
10045 FOREACH_AFI_SAFI (afi
, safi
)
10046 if (p
->afc_adv
[afi
][safi
]
10047 || p
->afc_recv
[afi
][safi
]) {
10049 " Address Family %s:",
10050 afi_safi_print(afi
,
10052 if (p
->afc_adv
[afi
][safi
])
10055 if (p
->afc_recv
[afi
][safi
])
10062 vty_out(vty
, "\n");
10065 /* Hostname capability */
10066 vty_out(vty
, " Hostname Capability:");
10068 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10070 " advertised (name: %s,domain name: %s)",
10071 bgp
->peer_self
->hostname
10075 bgp
->peer_self
->domainname
10080 vty_out(vty
, " not advertised");
10083 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10085 " received (name: %s,domain name: %s)",
10086 p
->hostname
? p
->hostname
10088 p
->domainname
? p
->domainname
10091 vty_out(vty
, " not received");
10094 vty_out(vty
, "\n");
10096 /* Gracefull Restart */
10097 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10098 || CHECK_FLAG(p
->cap
,
10099 PEER_CAP_RESTART_ADV
)) {
10101 " Graceful Restart Capabilty:");
10102 if (CHECK_FLAG(p
->cap
,
10103 PEER_CAP_RESTART_ADV
))
10104 vty_out(vty
, " advertised");
10105 if (CHECK_FLAG(p
->cap
,
10106 PEER_CAP_RESTART_RCV
))
10107 vty_out(vty
, " %sreceived",
10110 PEER_CAP_RESTART_ADV
)
10113 vty_out(vty
, "\n");
10115 if (CHECK_FLAG(p
->cap
,
10116 PEER_CAP_RESTART_RCV
)) {
10117 int restart_af_count
= 0;
10120 " Remote Restart timer is %d seconds\n",
10123 " Address families by peer:\n ");
10125 FOREACH_AFI_SAFI (afi
, safi
)
10130 PEER_CAP_RESTART_AF_RCV
)) {
10143 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10145 : "not preserved");
10146 restart_af_count
++;
10148 if (!restart_af_count
)
10149 vty_out(vty
, "none");
10150 vty_out(vty
, "\n");
10157 /* graceful restart information */
10158 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10159 || p
->t_gr_stale
) {
10160 json_object
*json_grace
= NULL
;
10161 json_object
*json_grace_send
= NULL
;
10162 json_object
*json_grace_recv
= NULL
;
10163 int eor_send_af_count
= 0;
10164 int eor_receive_af_count
= 0;
10167 json_grace
= json_object_new_object();
10168 json_grace_send
= json_object_new_object();
10169 json_grace_recv
= json_object_new_object();
10171 if (p
->status
== Established
) {
10172 FOREACH_AFI_SAFI (afi
, safi
) {
10173 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10174 PEER_STATUS_EOR_SEND
)) {
10175 json_object_boolean_true_add(
10177 afi_safi_print(afi
,
10179 eor_send_af_count
++;
10182 FOREACH_AFI_SAFI (afi
, safi
) {
10184 p
->af_sflags
[afi
][safi
],
10185 PEER_STATUS_EOR_RECEIVED
)) {
10186 json_object_boolean_true_add(
10188 afi_safi_print(afi
,
10190 eor_receive_af_count
++;
10195 json_object_object_add(json_grace
, "endOfRibSend",
10197 json_object_object_add(json_grace
, "endOfRibRecv",
10200 if (p
->t_gr_restart
)
10201 json_object_int_add(json_grace
,
10202 "gracefulRestartTimerMsecs",
10203 thread_timer_remain_second(
10208 json_object_int_add(
10210 "gracefulStalepathTimerMsecs",
10211 thread_timer_remain_second(
10215 json_object_object_add(
10216 json_neigh
, "gracefulRestartInfo", json_grace
);
10218 vty_out(vty
, " Graceful restart information:\n");
10219 if (p
->status
== Established
) {
10220 vty_out(vty
, " End-of-RIB send: ");
10221 FOREACH_AFI_SAFI (afi
, safi
) {
10222 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10223 PEER_STATUS_EOR_SEND
)) {
10224 vty_out(vty
, "%s%s",
10225 eor_send_af_count
? ", "
10227 afi_safi_print(afi
,
10229 eor_send_af_count
++;
10232 vty_out(vty
, "\n");
10233 vty_out(vty
, " End-of-RIB received: ");
10234 FOREACH_AFI_SAFI (afi
, safi
) {
10236 p
->af_sflags
[afi
][safi
],
10237 PEER_STATUS_EOR_RECEIVED
)) {
10238 vty_out(vty
, "%s%s",
10239 eor_receive_af_count
10242 afi_safi_print(afi
,
10244 eor_receive_af_count
++;
10247 vty_out(vty
, "\n");
10250 if (p
->t_gr_restart
)
10252 " The remaining time of restart timer is %ld\n",
10253 thread_timer_remain_second(
10258 " The remaining time of stalepath timer is %ld\n",
10259 thread_timer_remain_second(
10264 json_object
*json_stat
= NULL
;
10265 json_stat
= json_object_new_object();
10266 /* Packet counts. */
10267 json_object_int_add(json_stat
, "depthInq", 0);
10268 json_object_int_add(json_stat
, "depthOutq",
10269 (unsigned long)p
->obuf
->count
);
10270 json_object_int_add(json_stat
, "opensSent",
10271 atomic_load_explicit(&p
->open_out
,
10272 memory_order_relaxed
));
10273 json_object_int_add(json_stat
, "opensRecv",
10274 atomic_load_explicit(&p
->open_in
,
10275 memory_order_relaxed
));
10276 json_object_int_add(json_stat
, "notificationsSent",
10277 atomic_load_explicit(&p
->notify_out
,
10278 memory_order_relaxed
));
10279 json_object_int_add(json_stat
, "notificationsRecv",
10280 atomic_load_explicit(&p
->notify_in
,
10281 memory_order_relaxed
));
10282 json_object_int_add(json_stat
, "updatesSent",
10283 atomic_load_explicit(&p
->update_out
,
10284 memory_order_relaxed
));
10285 json_object_int_add(json_stat
, "updatesRecv",
10286 atomic_load_explicit(&p
->update_in
,
10287 memory_order_relaxed
));
10288 json_object_int_add(json_stat
, "keepalivesSent",
10289 atomic_load_explicit(&p
->keepalive_out
,
10290 memory_order_relaxed
));
10291 json_object_int_add(json_stat
, "keepalivesRecv",
10292 atomic_load_explicit(&p
->keepalive_in
,
10293 memory_order_relaxed
));
10294 json_object_int_add(json_stat
, "routeRefreshSent",
10295 atomic_load_explicit(&p
->refresh_out
,
10296 memory_order_relaxed
));
10297 json_object_int_add(json_stat
, "routeRefreshRecv",
10298 atomic_load_explicit(&p
->refresh_in
,
10299 memory_order_relaxed
));
10300 json_object_int_add(json_stat
, "capabilitySent",
10301 atomic_load_explicit(&p
->dynamic_cap_out
,
10302 memory_order_relaxed
));
10303 json_object_int_add(json_stat
, "capabilityRecv",
10304 atomic_load_explicit(&p
->dynamic_cap_in
,
10305 memory_order_relaxed
));
10306 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10307 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10308 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10310 /* Packet counts. */
10311 vty_out(vty
, " Message statistics:\n");
10312 vty_out(vty
, " Inq depth is 0\n");
10313 vty_out(vty
, " Outq depth is %lu\n",
10314 (unsigned long)p
->obuf
->count
);
10315 vty_out(vty
, " Sent Rcvd\n");
10316 vty_out(vty
, " Opens: %10d %10d\n",
10317 atomic_load_explicit(&p
->open_out
,
10318 memory_order_relaxed
),
10319 atomic_load_explicit(&p
->open_in
,
10320 memory_order_relaxed
));
10321 vty_out(vty
, " Notifications: %10d %10d\n",
10322 atomic_load_explicit(&p
->notify_out
,
10323 memory_order_relaxed
),
10324 atomic_load_explicit(&p
->notify_in
,
10325 memory_order_relaxed
));
10326 vty_out(vty
, " Updates: %10d %10d\n",
10327 atomic_load_explicit(&p
->update_out
,
10328 memory_order_relaxed
),
10329 atomic_load_explicit(&p
->update_in
,
10330 memory_order_relaxed
));
10331 vty_out(vty
, " Keepalives: %10d %10d\n",
10332 atomic_load_explicit(&p
->keepalive_out
,
10333 memory_order_relaxed
),
10334 atomic_load_explicit(&p
->keepalive_in
,
10335 memory_order_relaxed
));
10336 vty_out(vty
, " Route Refresh: %10d %10d\n",
10337 atomic_load_explicit(&p
->refresh_out
,
10338 memory_order_relaxed
),
10339 atomic_load_explicit(&p
->refresh_in
,
10340 memory_order_relaxed
));
10341 vty_out(vty
, " Capability: %10d %10d\n",
10342 atomic_load_explicit(&p
->dynamic_cap_out
,
10343 memory_order_relaxed
),
10344 atomic_load_explicit(&p
->dynamic_cap_in
,
10345 memory_order_relaxed
));
10346 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10351 /* advertisement-interval */
10352 json_object_int_add(json_neigh
,
10353 "minBtwnAdvertisementRunsTimerMsecs",
10354 p
->v_routeadv
* 1000);
10356 /* Update-source. */
10357 if (p
->update_if
|| p
->update_source
) {
10359 json_object_string_add(json_neigh
,
10362 else if (p
->update_source
)
10363 json_object_string_add(
10364 json_neigh
, "updateSource",
10365 sockunion2str(p
->update_source
, buf1
,
10369 /* advertisement-interval */
10371 " Minimum time between advertisement runs is %d seconds\n",
10374 /* Update-source. */
10375 if (p
->update_if
|| p
->update_source
) {
10376 vty_out(vty
, " Update source is ");
10378 vty_out(vty
, "%s", p
->update_if
);
10379 else if (p
->update_source
)
10381 sockunion2str(p
->update_source
, buf1
,
10383 vty_out(vty
, "\n");
10386 vty_out(vty
, "\n");
10389 /* Address Family Information */
10390 json_object
*json_hold
= NULL
;
10393 json_hold
= json_object_new_object();
10395 FOREACH_AFI_SAFI (afi
, safi
)
10396 if (p
->afc
[afi
][safi
])
10397 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10401 json_object_object_add(json_neigh
, "addressFamilyInfo",
10403 json_object_int_add(json_neigh
, "connectionsEstablished",
10405 json_object_int_add(json_neigh
, "connectionsDropped",
10408 vty_out(vty
, " Connections established %d; dropped %d\n",
10409 p
->established
, p
->dropped
);
10411 if (!p
->last_reset
) {
10413 json_object_string_add(json_neigh
, "lastReset",
10416 vty_out(vty
, " Last reset never\n");
10422 uptime
= bgp_clock();
10423 uptime
-= p
->resettime
;
10424 tm
= gmtime(&uptime
);
10425 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10426 (tm
->tm_sec
* 1000)
10427 + (tm
->tm_min
* 60000)
10428 + (tm
->tm_hour
* 3600000));
10429 json_object_string_add(
10430 json_neigh
, "lastResetDueTo",
10431 peer_down_str
[(int)p
->last_reset
]);
10432 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10433 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10434 char errorcodesubcode_hexstr
[5];
10435 char errorcodesubcode_str
[256];
10437 code_str
= bgp_notify_code_str(p
->notify
.code
);
10438 subcode_str
= bgp_notify_subcode_str(
10439 p
->notify
.code
, p
->notify
.subcode
);
10441 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10442 p
->notify
.code
, p
->notify
.subcode
);
10443 json_object_string_add(json_neigh
,
10444 "lastErrorCodeSubcode",
10445 errorcodesubcode_hexstr
);
10446 snprintf(errorcodesubcode_str
, 255, "%s%s",
10447 code_str
, subcode_str
);
10448 json_object_string_add(json_neigh
,
10449 "lastNotificationReason",
10450 errorcodesubcode_str
);
10451 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10452 && p
->notify
.code
== BGP_NOTIFY_CEASE
10453 && (p
->notify
.subcode
10454 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10455 || p
->notify
.subcode
10456 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10457 && p
->notify
.length
) {
10459 const char *msg_str
;
10461 msg_str
= bgp_notify_admin_message(
10462 msgbuf
, sizeof(msgbuf
),
10463 (uint8_t *)p
->notify
.data
,
10466 json_object_string_add(
10468 "lastShutdownDescription",
10473 vty_out(vty
, " Last reset %s, ",
10474 peer_uptime(p
->resettime
, timebuf
,
10475 BGP_UPTIME_LEN
, 0, NULL
));
10477 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10478 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10479 code_str
= bgp_notify_code_str(p
->notify
.code
);
10480 subcode_str
= bgp_notify_subcode_str(
10481 p
->notify
.code
, p
->notify
.subcode
);
10482 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10483 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10486 code_str
, subcode_str
);
10487 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10488 && p
->notify
.code
== BGP_NOTIFY_CEASE
10489 && (p
->notify
.subcode
10490 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10491 || p
->notify
.subcode
10492 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10493 && p
->notify
.length
) {
10495 const char *msg_str
;
10497 msg_str
= bgp_notify_admin_message(
10498 msgbuf
, sizeof(msgbuf
),
10499 (uint8_t *)p
->notify
.data
,
10503 " Message: \"%s\"\n",
10507 vty_out(vty
, "due to %s\n",
10508 peer_down_str
[(int)p
->last_reset
]);
10511 if (p
->last_reset_cause_size
) {
10512 msg
= p
->last_reset_cause
;
10514 " Message received that caused BGP to send a NOTIFICATION:\n ");
10515 for (i
= 1; i
<= p
->last_reset_cause_size
;
10517 vty_out(vty
, "%02X", *msg
++);
10519 if (i
!= p
->last_reset_cause_size
) {
10521 vty_out(vty
, "\n ");
10522 } else if (i
% 4 == 0) {
10527 vty_out(vty
, "\n");
10532 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10534 json_object_boolean_true_add(json_neigh
,
10535 "prefixesConfigExceedMax");
10538 " Peer had exceeded the max. no. of prefixes configured.\n");
10540 if (p
->t_pmax_restart
) {
10542 json_object_boolean_true_add(
10543 json_neigh
, "reducePrefixNumFrom");
10544 json_object_int_add(json_neigh
,
10545 "restartInTimerMsec",
10546 thread_timer_remain_second(
10551 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10552 p
->host
, thread_timer_remain_second(
10553 p
->t_pmax_restart
));
10556 json_object_boolean_true_add(
10558 "reducePrefixNumAndClearIpBgp");
10561 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10566 /* EBGP Multihop and GTSM */
10567 if (p
->sort
!= BGP_PEER_IBGP
) {
10569 if (p
->gtsm_hops
> 0)
10570 json_object_int_add(json_neigh
,
10571 "externalBgpNbrMaxHopsAway",
10573 else if (p
->ttl
> 1)
10574 json_object_int_add(json_neigh
,
10575 "externalBgpNbrMaxHopsAway",
10578 if (p
->gtsm_hops
> 0)
10580 " External BGP neighbor may be up to %d hops away.\n",
10582 else if (p
->ttl
> 1)
10584 " External BGP neighbor may be up to %d hops away.\n",
10588 if (p
->gtsm_hops
> 0) {
10590 json_object_int_add(json_neigh
,
10591 "internalBgpNbrMaxHopsAway",
10595 " Internal BGP neighbor may be up to %d hops away.\n",
10600 /* Local address. */
10603 json_object_string_add(json_neigh
, "hostLocal",
10604 sockunion2str(p
->su_local
, buf1
,
10606 json_object_int_add(json_neigh
, "portLocal",
10607 ntohs(p
->su_local
->sin
.sin_port
));
10609 vty_out(vty
, "Local host: %s, Local port: %d\n",
10610 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10611 ntohs(p
->su_local
->sin
.sin_port
));
10614 /* Remote address. */
10615 if (p
->su_remote
) {
10617 json_object_string_add(json_neigh
, "hostForeign",
10618 sockunion2str(p
->su_remote
, buf1
,
10620 json_object_int_add(json_neigh
, "portForeign",
10621 ntohs(p
->su_remote
->sin
.sin_port
));
10623 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10624 sockunion2str(p
->su_remote
, buf1
,
10626 ntohs(p
->su_remote
->sin
.sin_port
));
10629 /* Nexthop display. */
10632 json_object_string_add(json_neigh
, "nexthop",
10634 &p
->nexthop
.v4
, buf1
,
10636 json_object_string_add(json_neigh
, "nexthopGlobal",
10637 inet_ntop(AF_INET6
,
10638 &p
->nexthop
.v6_global
,
10639 buf1
, sizeof(buf1
)));
10640 json_object_string_add(json_neigh
, "nexthopLocal",
10641 inet_ntop(AF_INET6
,
10642 &p
->nexthop
.v6_local
,
10643 buf1
, sizeof(buf1
)));
10644 if (p
->shared_network
)
10645 json_object_string_add(json_neigh
,
10649 json_object_string_add(json_neigh
,
10651 "nonSharedNetwork");
10653 vty_out(vty
, "Nexthop: %s\n",
10654 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10656 vty_out(vty
, "Nexthop global: %s\n",
10657 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10659 vty_out(vty
, "Nexthop local: %s\n",
10660 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10662 vty_out(vty
, "BGP connection: %s\n",
10663 p
->shared_network
? "shared network"
10664 : "non shared network");
10668 /* Timer information. */
10670 json_object_int_add(json_neigh
, "connectRetryTimer",
10672 if (p
->status
== Established
&& p
->rtt
)
10673 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10676 json_object_int_add(
10677 json_neigh
, "nextStartTimerDueInMsecs",
10678 thread_timer_remain_second(p
->t_start
) * 1000);
10680 json_object_int_add(
10681 json_neigh
, "nextConnectTimerDueInMsecs",
10682 thread_timer_remain_second(p
->t_connect
)
10684 if (p
->t_routeadv
) {
10685 json_object_int_add(json_neigh
, "mraiInterval",
10687 json_object_int_add(
10688 json_neigh
, "mraiTimerExpireInMsecs",
10689 thread_timer_remain_second(p
->t_routeadv
)
10693 json_object_int_add(json_neigh
, "authenticationEnabled",
10697 json_object_string_add(json_neigh
, "readThread", "on");
10699 json_object_string_add(json_neigh
, "readThread", "off");
10701 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10702 json_object_string_add(json_neigh
, "writeThread", "on");
10704 json_object_string_add(json_neigh
, "writeThread",
10707 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10709 if (p
->status
== Established
&& p
->rtt
)
10710 vty_out(vty
, "Estimated round trip time: %d ms\n",
10713 vty_out(vty
, "Next start timer due in %ld seconds\n",
10714 thread_timer_remain_second(p
->t_start
));
10716 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10717 thread_timer_remain_second(p
->t_connect
));
10720 "MRAI (interval %u) timer expires in %ld seconds\n",
10722 thread_timer_remain_second(p
->t_routeadv
));
10724 vty_out(vty
, "Peer Authentication Enabled\n");
10726 vty_out(vty
, "Read thread: %s Write thread: %s\n",
10727 p
->t_read
? "on" : "off",
10728 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10733 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10734 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10735 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10738 vty_out(vty
, "\n");
10740 /* BFD information. */
10741 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10744 if (p
->conf_if
) /* Configured interface name. */
10745 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10746 else /* Configured IP address. */
10747 json_object_object_add(json
, p
->host
, json_neigh
);
10751 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10752 enum show_type type
, union sockunion
*su
,
10753 const char *conf_if
, bool use_json
,
10756 struct listnode
*node
, *nnode
;
10759 bool nbr_output
= false;
10761 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10762 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10767 bgp_show_peer(vty
, peer
, use_json
, json
);
10773 && !strcmp(peer
->conf_if
, conf_if
))
10775 && !strcmp(peer
->hostname
, conf_if
))) {
10777 bgp_show_peer(vty
, peer
, use_json
,
10781 if (sockunion_same(&peer
->su
, su
)) {
10783 bgp_show_peer(vty
, peer
, use_json
,
10791 if (type
== show_peer
&& !find
) {
10793 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
10795 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
10798 if (type
!= show_peer
&& !nbr_output
&& !use_json
)
10799 vty_out(vty
, "%% No BGP neighbors found\n");
10802 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10803 json
, JSON_C_TO_STRING_PRETTY
));
10804 json_object_free(json
);
10806 vty_out(vty
, "\n");
10809 return CMD_SUCCESS
;
10812 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
10813 enum show_type type
,
10814 const char *ip_str
,
10817 struct listnode
*node
, *nnode
;
10819 union sockunion su
;
10820 json_object
*json
= NULL
;
10821 int ret
, is_first
= 1;
10822 bool nbr_output
= false;
10825 vty_out(vty
, "{\n");
10827 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
10830 if (!(json
= json_object_new_object())) {
10832 EC_BGP_JSON_MEM_ERROR
,
10833 "Unable to allocate memory for JSON object");
10835 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
10839 json_object_int_add(json
, "vrfId",
10840 (bgp
->vrf_id
== VRF_UNKNOWN
)
10842 : (int64_t)bgp
->vrf_id
);
10843 json_object_string_add(
10845 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10850 vty_out(vty
, ",\n");
10854 vty_out(vty
, "\"%s\":",
10855 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10859 vty_out(vty
, "\nInstance %s:\n",
10860 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10865 if (type
== show_peer
) {
10866 ret
= str2sockunion(ip_str
, &su
);
10868 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10871 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10874 bgp_show_neighbor(vty
, bgp
, show_all
, NULL
, NULL
,
10880 vty_out(vty
, "}\n");
10881 else if (!nbr_output
)
10882 vty_out(vty
, "%% BGP instance not found\n");
10885 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
10886 enum show_type type
, const char *ip_str
,
10891 union sockunion su
;
10892 json_object
*json
= NULL
;
10895 if (strmatch(name
, "all")) {
10896 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
10898 return CMD_SUCCESS
;
10900 bgp
= bgp_lookup_by_name(name
);
10903 json
= json_object_new_object();
10904 vty_out(vty
, "%s\n",
10905 json_object_to_json_string_ext(
10907 JSON_C_TO_STRING_PRETTY
));
10908 json_object_free(json
);
10911 "%% BGP instance not found\n");
10913 return CMD_WARNING
;
10917 bgp
= bgp_get_default();
10921 json
= json_object_new_object();
10923 ret
= str2sockunion(ip_str
, &su
);
10925 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10928 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10931 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
10934 json_object_free(json
);
10937 vty_out(vty
, "{}\n");
10939 vty_out(vty
, "%% BGP instance not found\n");
10942 return CMD_SUCCESS
;
10945 /* "show [ip] bgp neighbors" commands. */
10946 DEFUN (show_ip_bgp_neighbors
,
10947 show_ip_bgp_neighbors_cmd
,
10948 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
10952 BGP_INSTANCE_HELP_STR
10955 "Detailed information on TCP and BGP neighbor connections\n"
10956 "Neighbor to display information about\n"
10957 "Neighbor to display information about\n"
10958 "Neighbor on BGP configured interface\n"
10962 char *sh_arg
= NULL
;
10963 enum show_type sh_type
;
10965 bool uj
= use_json(argc
, argv
);
10969 /* [<vrf> VIEWVRFNAME] */
10970 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10971 vrf
= argv
[idx
+ 1]->arg
;
10972 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10974 } else if (argv_find(argv
, argc
, "view", &idx
))
10975 /* [<view> VIEWVRFNAME] */
10976 vrf
= argv
[idx
+ 1]->arg
;
10979 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
10980 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
10981 || argv_find(argv
, argc
, "WORD", &idx
)) {
10982 sh_type
= show_peer
;
10983 sh_arg
= argv
[idx
]->arg
;
10985 sh_type
= show_all
;
10987 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
10990 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
10991 paths' and `show ip mbgp paths'. Those functions results are the
10993 DEFUN (show_ip_bgp_paths
,
10994 show_ip_bgp_paths_cmd
,
10995 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
11000 "Path information\n")
11002 vty_out(vty
, "Address Refcnt Path\n");
11003 aspath_print_all_vty(vty
);
11004 return CMD_SUCCESS
;
11009 static void community_show_all_iterator(struct hash_backet
*backet
,
11012 struct community
*com
;
11014 com
= (struct community
*)backet
->data
;
11015 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
11016 community_str(com
, false));
11019 /* Show BGP's community internal data. */
11020 DEFUN (show_ip_bgp_community_info
,
11021 show_ip_bgp_community_info_cmd
,
11022 "show [ip] bgp community-info",
11026 "List all bgp community information\n")
11028 vty_out(vty
, "Address Refcnt Community\n");
11030 hash_iterate(community_hash(),
11031 (void (*)(struct hash_backet
*,
11032 void *))community_show_all_iterator
,
11035 return CMD_SUCCESS
;
11038 static void lcommunity_show_all_iterator(struct hash_backet
*backet
,
11041 struct lcommunity
*lcom
;
11043 lcom
= (struct lcommunity
*)backet
->data
;
11044 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11045 lcommunity_str(lcom
, false));
11048 /* Show BGP's community internal data. */
11049 DEFUN (show_ip_bgp_lcommunity_info
,
11050 show_ip_bgp_lcommunity_info_cmd
,
11051 "show ip bgp large-community-info",
11055 "List all bgp large-community information\n")
11057 vty_out(vty
, "Address Refcnt Large-community\n");
11059 hash_iterate(lcommunity_hash(),
11060 (void (*)(struct hash_backet
*,
11061 void *))lcommunity_show_all_iterator
,
11064 return CMD_SUCCESS
;
11068 DEFUN (show_ip_bgp_attr_info
,
11069 show_ip_bgp_attr_info_cmd
,
11070 "show [ip] bgp attribute-info",
11074 "List all bgp attribute information\n")
11076 attr_show_all(vty
);
11077 return CMD_SUCCESS
;
11080 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11081 safi_t safi
, bool use_json
)
11084 struct listnode
*node
;
11086 char buf1
[INET6_ADDRSTRLEN
];
11088 vpn_policy_direction_t dir
;
11091 json_object
*json
= NULL
;
11092 json_object
*json_import_vrfs
= NULL
;
11093 json_object
*json_export_vrfs
= NULL
;
11095 json
= json_object_new_object();
11097 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11100 vty_out(vty
, "%s\n",
11101 json_object_to_json_string_ext(
11103 JSON_C_TO_STRING_PRETTY
));
11104 json_object_free(json
);
11106 return CMD_WARNING
;
11109 /* Provide context for the block */
11110 json_object_string_add(json
, "vrf", name
? name
: "default");
11111 json_object_string_add(json
, "afiSafi",
11112 afi_safi_print(afi
, safi
));
11114 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11115 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11116 json_object_string_add(json
, "importFromVrfs", "none");
11117 json_object_string_add(json
, "importRts", "none");
11119 json_import_vrfs
= json_object_new_array();
11121 for (ALL_LIST_ELEMENTS_RO(
11122 bgp
->vpn_policy
[afi
].import_vrf
,
11124 json_object_array_add(json_import_vrfs
,
11125 json_object_new_string(vname
));
11127 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11128 ecom_str
= ecommunity_ecom2str(
11129 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11130 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11131 json_object_object_add(json
, "importFromVrfs",
11133 json_object_string_add(json
, "importRts", ecom_str
);
11135 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11138 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11139 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11140 json_object_string_add(json
, "exportToVrfs", "none");
11141 json_object_string_add(json
, "routeDistinguisher",
11143 json_object_string_add(json
, "exportRts", "none");
11145 json_export_vrfs
= json_object_new_array();
11147 for (ALL_LIST_ELEMENTS_RO(
11148 bgp
->vpn_policy
[afi
].export_vrf
,
11150 json_object_array_add(json_export_vrfs
,
11151 json_object_new_string(vname
));
11152 json_object_object_add(json
, "exportToVrfs",
11154 json_object_string_add(json
, "routeDistinguisher",
11155 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11156 buf1
, RD_ADDRSTRLEN
));
11158 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11159 ecom_str
= ecommunity_ecom2str(
11160 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11161 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11162 json_object_string_add(json
, "exportRts", ecom_str
);
11164 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11167 vty_out(vty
, "%s\n",
11168 json_object_to_json_string_ext(json
,
11169 JSON_C_TO_STRING_PRETTY
));
11170 json_object_free(json
);
11173 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11176 vty_out(vty
, "%% No such BGP instance exist\n");
11177 return CMD_WARNING
;
11180 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11181 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11183 "This VRF is not importing %s routes from any other VRF\n",
11184 afi_safi_print(afi
, safi
));
11187 "This VRF is importing %s routes from the following VRFs:\n",
11188 afi_safi_print(afi
, safi
));
11190 for (ALL_LIST_ELEMENTS_RO(
11191 bgp
->vpn_policy
[afi
].import_vrf
,
11193 vty_out(vty
, " %s\n", vname
);
11195 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11196 ecom_str
= ecommunity_ecom2str(
11197 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11198 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11199 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11201 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11204 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11205 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11207 "This VRF is not exporting %s routes to any other VRF\n",
11208 afi_safi_print(afi
, safi
));
11211 "This VRF is exporting %s routes to the following VRFs:\n",
11212 afi_safi_print(afi
, safi
));
11214 for (ALL_LIST_ELEMENTS_RO(
11215 bgp
->vpn_policy
[afi
].export_vrf
,
11217 vty_out(vty
, " %s\n", vname
);
11219 vty_out(vty
, "RD: %s\n",
11220 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11221 buf1
, RD_ADDRSTRLEN
));
11223 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11224 ecom_str
= ecommunity_ecom2str(
11225 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11226 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11227 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11228 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11232 return CMD_SUCCESS
;
11235 /* "show [ip] bgp route-leak" command. */
11236 DEFUN (show_ip_bgp_route_leak
,
11237 show_ip_bgp_route_leak_cmd
,
11238 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11242 BGP_INSTANCE_HELP_STR
11245 "Route leaking information\n"
11249 afi_t afi
= AFI_MAX
;
11250 safi_t safi
= SAFI_MAX
;
11252 bool uj
= use_json(argc
, argv
);
11255 /* show [ip] bgp */
11256 if (argv_find(argv
, argc
, "ip", &idx
)) {
11258 safi
= SAFI_UNICAST
;
11260 /* [vrf VIEWVRFNAME] */
11261 if (argv_find(argv
, argc
, "view", &idx
)) {
11263 "%% This command is not applicable to BGP views\n");
11264 return CMD_WARNING
;
11267 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11268 vrf
= argv
[idx
+ 1]->arg
;
11269 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11272 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11273 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11274 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11277 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11279 "%% This command is applicable only for unicast ipv4|ipv6\n");
11280 return CMD_WARNING
;
11283 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
);
11286 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11289 struct listnode
*node
, *nnode
;
11292 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11293 vty_out(vty
, "\nInstance %s:\n",
11294 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11297 update_group_show(bgp
, afi
, safi
, vty
, 0);
11301 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11302 int safi
, uint64_t subgrp_id
)
11307 if (strmatch(name
, "all")) {
11308 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11309 return CMD_SUCCESS
;
11311 bgp
= bgp_lookup_by_name(name
);
11314 bgp
= bgp_get_default();
11318 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11319 return CMD_SUCCESS
;
11322 DEFUN (show_ip_bgp_updgrps
,
11323 show_ip_bgp_updgrps_cmd
,
11324 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11328 BGP_INSTANCE_HELP_STR
11330 BGP_SAFI_WITH_LABEL_HELP_STR
11331 "Detailed info about dynamic update groups\n"
11332 "Specific subgroup to display detailed info for\n")
11335 afi_t afi
= AFI_IP6
;
11336 safi_t safi
= SAFI_UNICAST
;
11337 uint64_t subgrp_id
= 0;
11341 /* show [ip] bgp */
11342 if (argv_find(argv
, argc
, "ip", &idx
))
11344 /* [<vrf> VIEWVRFNAME] */
11345 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11346 vrf
= argv
[idx
+ 1]->arg
;
11347 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11349 } else if (argv_find(argv
, argc
, "view", &idx
))
11350 /* [<view> VIEWVRFNAME] */
11351 vrf
= argv
[idx
+ 1]->arg
;
11352 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11353 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11354 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11357 /* get subgroup id, if provided */
11359 if (argv
[idx
]->type
== VARIABLE_TKN
)
11360 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11362 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11365 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11366 show_bgp_instance_all_ipv6_updgrps_cmd
,
11367 "show [ip] bgp <view|vrf> all update-groups",
11371 BGP_INSTANCE_ALL_HELP_STR
11372 "Detailed info about dynamic update groups\n")
11374 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11375 return CMD_SUCCESS
;
11378 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
11379 show_bgp_l2vpn_evpn_updgrps_cmd
,
11380 "show [ip] bgp l2vpn evpn update-groups",
11384 "l2vpn address family\n"
11385 "evpn sub-address family\n"
11386 "Detailed info about dynamic update groups\n")
11389 uint64_t subgrp_id
= 0;
11391 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
11392 return CMD_SUCCESS
;
11395 DEFUN (show_bgp_updgrps_stats
,
11396 show_bgp_updgrps_stats_cmd
,
11397 "show [ip] bgp update-groups statistics",
11401 "Detailed info about dynamic update groups\n"
11406 bgp
= bgp_get_default();
11408 update_group_show_stats(bgp
, vty
);
11410 return CMD_SUCCESS
;
11413 DEFUN (show_bgp_instance_updgrps_stats
,
11414 show_bgp_instance_updgrps_stats_cmd
,
11415 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11419 BGP_INSTANCE_HELP_STR
11420 "Detailed info about dynamic update groups\n"
11426 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11428 update_group_show_stats(bgp
, vty
);
11430 return CMD_SUCCESS
;
11433 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11434 afi_t afi
, safi_t safi
,
11435 const char *what
, uint64_t subgrp_id
)
11440 bgp
= bgp_lookup_by_name(name
);
11442 bgp
= bgp_get_default();
11445 if (!strcmp(what
, "advertise-queue"))
11446 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11448 else if (!strcmp(what
, "advertised-routes"))
11449 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11451 else if (!strcmp(what
, "packet-queue"))
11452 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11457 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11458 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11459 "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",
11460 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11462 "Detailed info about dynamic update groups\n"
11463 "Specific subgroup to display info for\n"
11464 "Advertisement queue\n"
11465 "Announced routes\n"
11468 uint64_t subgrp_id
= 0;
11472 subgrp_id
= strtoull(sgid
, NULL
, 10);
11477 afiz
= bgp_vty_afi_from_str(afi
);
11481 afiz
= bgp_vty_afi_from_str(afi
);
11482 if (afiz
!= AFI_IP
)
11484 "%% Cannot specify both 'ip' and 'ipv6'\n");
11485 return CMD_WARNING
;
11488 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11490 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11491 return CMD_SUCCESS
;
11494 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11496 struct listnode
*node
, *nnode
;
11497 struct prefix
*range
;
11500 char buf
[PREFIX2STR_BUFFER
];
11503 const char *peer_status
;
11504 const char *af_str
;
11509 conf
= group
->conf
;
11511 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11512 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
11514 } else if (conf
->as_type
== AS_INTERNAL
) {
11515 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
11518 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11521 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11522 vty_out(vty
, " Peer-group type is internal\n");
11524 vty_out(vty
, " Peer-group type is external\n");
11526 /* Display AFs configured. */
11527 vty_out(vty
, " Configured address-families:");
11528 FOREACH_AFI_SAFI (afi
, safi
) {
11529 if (conf
->afc
[afi
][safi
]) {
11531 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11535 vty_out(vty
, " none\n");
11537 vty_out(vty
, "\n");
11539 /* Display listen ranges (for dynamic neighbors), if any */
11540 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11543 else if (afi
== AFI_IP6
)
11547 lr_count
= listcount(group
->listen_range
[afi
]);
11549 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11553 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11555 prefix2str(range
, buf
, sizeof(buf
));
11556 vty_out(vty
, " %s\n", buf
);
11561 /* Display group members and their status */
11562 if (listcount(group
->peer
)) {
11563 vty_out(vty
, " Peer-group members:\n");
11564 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11565 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11566 peer_status
= "Idle (Admin)";
11567 else if (CHECK_FLAG(peer
->sflags
,
11568 PEER_STATUS_PREFIX_OVERFLOW
))
11569 peer_status
= "Idle (PfxCt)";
11571 peer_status
= lookup_msg(bgp_status_msg
,
11572 peer
->status
, NULL
);
11574 dynamic
= peer_dynamic_neighbor(peer
);
11575 vty_out(vty
, " %s %s %s \n", peer
->host
,
11576 dynamic
? "(dynamic)" : "", peer_status
);
11580 return CMD_SUCCESS
;
11583 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11584 const char *group_name
)
11587 struct listnode
*node
, *nnode
;
11588 struct peer_group
*group
;
11589 bool found
= false;
11591 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11594 vty_out(vty
, "%% BGP instance not found\n");
11595 return CMD_WARNING
;
11598 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11600 if (strmatch(group
->name
, group_name
)) {
11601 bgp_show_one_peer_group(vty
, group
);
11606 bgp_show_one_peer_group(vty
, group
);
11610 if (group_name
&& !found
)
11611 vty_out(vty
, "%% No such peer-group\n");
11613 return CMD_SUCCESS
;
11616 DEFUN (show_ip_bgp_peer_groups
,
11617 show_ip_bgp_peer_groups_cmd
,
11618 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11622 BGP_INSTANCE_HELP_STR
11623 "Detailed information on BGP peer groups\n"
11624 "Peer group name\n")
11629 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11631 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11633 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11637 /* Redistribute VTY commands. */
11639 DEFUN (bgp_redistribute_ipv4
,
11640 bgp_redistribute_ipv4_cmd
,
11641 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11642 "Redistribute information from another routing protocol\n"
11643 FRR_IP_REDIST_HELP_STR_BGPD
)
11645 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11646 int idx_protocol
= 1;
11649 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11651 vty_out(vty
, "%% Invalid route type\n");
11652 return CMD_WARNING_CONFIG_FAILED
;
11655 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11656 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
11660 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11661 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11662 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11664 DEFUN (bgp_redistribute_ipv4_rmap
,
11665 bgp_redistribute_ipv4_rmap_cmd
,
11666 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11667 "Redistribute information from another routing protocol\n"
11668 FRR_IP_REDIST_HELP_STR_BGPD
11669 "Route map reference\n"
11670 "Pointer to route-map entries\n")
11672 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11673 int idx_protocol
= 1;
11676 struct bgp_redist
*red
;
11678 struct route_map
*route_map
= route_map_lookup_warn_noexist(
11679 vty
, argv
[idx_word
]->arg
);
11681 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11683 vty_out(vty
, "%% Invalid route type\n");
11684 return CMD_WARNING_CONFIG_FAILED
;
11687 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11689 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
11690 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11694 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
11695 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11696 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11697 "Route map reference\n"
11698 "Pointer to route-map entries\n")
11700 DEFUN (bgp_redistribute_ipv4_metric
,
11701 bgp_redistribute_ipv4_metric_cmd
,
11702 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11703 "Redistribute information from another routing protocol\n"
11704 FRR_IP_REDIST_HELP_STR_BGPD
11705 "Metric for redistributed routes\n"
11706 "Default metric\n")
11708 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11709 int idx_protocol
= 1;
11710 int idx_number
= 3;
11713 struct bgp_redist
*red
;
11716 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11718 vty_out(vty
, "%% Invalid route type\n");
11719 return CMD_WARNING_CONFIG_FAILED
;
11721 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11723 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11724 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11725 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11729 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
11730 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11731 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11732 "Metric for redistributed routes\n"
11733 "Default metric\n")
11735 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
11736 bgp_redistribute_ipv4_rmap_metric_cmd
,
11737 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11738 "Redistribute information from another routing protocol\n"
11739 FRR_IP_REDIST_HELP_STR_BGPD
11740 "Route map reference\n"
11741 "Pointer to route-map entries\n"
11742 "Metric for redistributed routes\n"
11743 "Default metric\n")
11745 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11746 int idx_protocol
= 1;
11748 int idx_number
= 5;
11751 struct bgp_redist
*red
;
11753 struct route_map
*route_map
=
11754 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
11756 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11758 vty_out(vty
, "%% Invalid route type\n");
11759 return CMD_WARNING_CONFIG_FAILED
;
11761 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11763 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11765 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
11766 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11767 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11771 bgp_redistribute_ipv4_rmap_metric
,
11772 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
11773 "redistribute " FRR_IP_REDIST_STR_BGPD
11774 " route-map WORD metric (0-4294967295)",
11775 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11776 "Route map reference\n"
11777 "Pointer to route-map entries\n"
11778 "Metric for redistributed routes\n"
11779 "Default metric\n")
11781 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
11782 bgp_redistribute_ipv4_metric_rmap_cmd
,
11783 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
11784 "Redistribute information from another routing protocol\n"
11785 FRR_IP_REDIST_HELP_STR_BGPD
11786 "Metric for redistributed routes\n"
11788 "Route map reference\n"
11789 "Pointer to route-map entries\n")
11791 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11792 int idx_protocol
= 1;
11793 int idx_number
= 3;
11797 struct bgp_redist
*red
;
11799 struct route_map
*route_map
=
11800 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
11802 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11804 vty_out(vty
, "%% Invalid route type\n");
11805 return CMD_WARNING_CONFIG_FAILED
;
11807 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11809 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11810 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11812 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
11813 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11817 bgp_redistribute_ipv4_metric_rmap
,
11818 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
11819 "redistribute " FRR_IP_REDIST_STR_BGPD
11820 " metric (0-4294967295) route-map WORD",
11821 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11822 "Metric for redistributed routes\n"
11824 "Route map reference\n"
11825 "Pointer to route-map entries\n")
11827 DEFUN (bgp_redistribute_ipv4_ospf
,
11828 bgp_redistribute_ipv4_ospf_cmd
,
11829 "redistribute <ospf|table> (1-65535)",
11830 "Redistribute information from another routing protocol\n"
11831 "Open Shortest Path First (OSPFv2)\n"
11832 "Non-main Kernel Routing Table\n"
11833 "Instance ID/Table ID\n")
11835 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11836 int idx_ospf_table
= 1;
11837 int idx_number
= 2;
11838 unsigned short instance
;
11839 unsigned short protocol
;
11841 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11843 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11844 protocol
= ZEBRA_ROUTE_OSPF
;
11846 protocol
= ZEBRA_ROUTE_TABLE
;
11848 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11849 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
11852 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
11853 "redistribute <ospf|table> (1-65535)",
11854 "Redistribute information from another routing protocol\n"
11855 "Open Shortest Path First (OSPFv2)\n"
11856 "Non-main Kernel Routing Table\n"
11857 "Instance ID/Table ID\n")
11859 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
11860 bgp_redistribute_ipv4_ospf_rmap_cmd
,
11861 "redistribute <ospf|table> (1-65535) route-map WORD",
11862 "Redistribute information from another routing protocol\n"
11863 "Open Shortest Path First (OSPFv2)\n"
11864 "Non-main Kernel Routing Table\n"
11865 "Instance ID/Table ID\n"
11866 "Route map reference\n"
11867 "Pointer to route-map entries\n")
11869 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11870 int idx_ospf_table
= 1;
11871 int idx_number
= 2;
11873 struct bgp_redist
*red
;
11874 unsigned short instance
;
11877 struct route_map
*route_map
=
11878 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
11880 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11881 protocol
= ZEBRA_ROUTE_OSPF
;
11883 protocol
= ZEBRA_ROUTE_TABLE
;
11885 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11886 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11888 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
11889 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
11892 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
11893 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
11894 "redistribute <ospf|table> (1-65535) route-map WORD",
11895 "Redistribute information from another routing protocol\n"
11896 "Open Shortest Path First (OSPFv2)\n"
11897 "Non-main Kernel Routing Table\n"
11898 "Instance ID/Table ID\n"
11899 "Route map reference\n"
11900 "Pointer to route-map entries\n")
11902 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
11903 bgp_redistribute_ipv4_ospf_metric_cmd
,
11904 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
11905 "Redistribute information from another routing protocol\n"
11906 "Open Shortest Path First (OSPFv2)\n"
11907 "Non-main Kernel Routing Table\n"
11908 "Instance ID/Table ID\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;
11915 int idx_number_2
= 4;
11917 struct bgp_redist
*red
;
11918 unsigned short instance
;
11922 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11923 protocol
= ZEBRA_ROUTE_OSPF
;
11925 protocol
= ZEBRA_ROUTE_TABLE
;
11927 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11928 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11930 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11931 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
11933 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
11936 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
11937 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
11938 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
11939 "Redistribute information from another routing protocol\n"
11940 "Open Shortest Path First (OSPFv2)\n"
11941 "Non-main Kernel Routing Table\n"
11942 "Instance ID/Table ID\n"
11943 "Metric for redistributed routes\n"
11944 "Default metric\n")
11946 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
11947 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
11948 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
11949 "Redistribute information from another routing protocol\n"
11950 "Open Shortest Path First (OSPFv2)\n"
11951 "Non-main Kernel Routing Table\n"
11952 "Instance ID/Table ID\n"
11953 "Route map reference\n"
11954 "Pointer to route-map entries\n"
11955 "Metric for redistributed routes\n"
11956 "Default metric\n")
11958 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11959 int idx_ospf_table
= 1;
11960 int idx_number
= 2;
11962 int idx_number_2
= 6;
11964 struct bgp_redist
*red
;
11965 unsigned short instance
;
11968 struct route_map
*route_map
=
11969 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
11971 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11972 protocol
= ZEBRA_ROUTE_OSPF
;
11974 protocol
= ZEBRA_ROUTE_TABLE
;
11976 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11977 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11979 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11981 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
11982 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
11984 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
11988 bgp_redistribute_ipv4_ospf_rmap_metric
,
11989 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
11990 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
11991 "Redistribute information from another routing protocol\n"
11992 "Open Shortest Path First (OSPFv2)\n"
11993 "Non-main Kernel Routing Table\n"
11994 "Instance ID/Table ID\n"
11995 "Route map reference\n"
11996 "Pointer to route-map entries\n"
11997 "Metric for redistributed routes\n"
11998 "Default metric\n")
12000 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
12001 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
12002 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12003 "Redistribute information from another routing protocol\n"
12004 "Open Shortest Path First (OSPFv2)\n"
12005 "Non-main Kernel Routing Table\n"
12006 "Instance ID/Table ID\n"
12007 "Metric for redistributed routes\n"
12009 "Route map reference\n"
12010 "Pointer to route-map entries\n")
12012 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12013 int idx_ospf_table
= 1;
12014 int idx_number
= 2;
12015 int idx_number_2
= 4;
12018 struct bgp_redist
*red
;
12019 unsigned short instance
;
12022 struct route_map
*route_map
=
12023 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12025 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12026 protocol
= ZEBRA_ROUTE_OSPF
;
12028 protocol
= ZEBRA_ROUTE_TABLE
;
12030 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12031 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12033 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12034 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12037 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12038 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12042 bgp_redistribute_ipv4_ospf_metric_rmap
,
12043 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
12044 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12045 "Redistribute information from another routing protocol\n"
12046 "Open Shortest Path First (OSPFv2)\n"
12047 "Non-main Kernel Routing Table\n"
12048 "Instance ID/Table ID\n"
12049 "Metric for redistributed routes\n"
12051 "Route map reference\n"
12052 "Pointer to route-map entries\n")
12054 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12055 no_bgp_redistribute_ipv4_ospf_cmd
,
12056 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12058 "Redistribute information from another routing protocol\n"
12059 "Open Shortest Path First (OSPFv2)\n"
12060 "Non-main Kernel Routing Table\n"
12061 "Instance ID/Table ID\n"
12062 "Metric for redistributed routes\n"
12064 "Route map reference\n"
12065 "Pointer to route-map entries\n")
12067 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12068 int idx_ospf_table
= 2;
12069 int idx_number
= 3;
12070 unsigned short instance
;
12073 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12074 protocol
= ZEBRA_ROUTE_OSPF
;
12076 protocol
= ZEBRA_ROUTE_TABLE
;
12078 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12079 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12083 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12084 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12086 "Redistribute information from another routing protocol\n"
12087 "Open Shortest Path First (OSPFv2)\n"
12088 "Non-main Kernel Routing Table\n"
12089 "Instance ID/Table ID\n"
12090 "Metric for redistributed routes\n"
12092 "Route map reference\n"
12093 "Pointer to route-map entries\n")
12095 DEFUN (no_bgp_redistribute_ipv4
,
12096 no_bgp_redistribute_ipv4_cmd
,
12097 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12099 "Redistribute information from another routing protocol\n"
12100 FRR_IP_REDIST_HELP_STR_BGPD
12101 "Metric for redistributed routes\n"
12103 "Route map reference\n"
12104 "Pointer to route-map entries\n")
12106 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12107 int idx_protocol
= 2;
12110 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12112 vty_out(vty
, "%% Invalid route type\n");
12113 return CMD_WARNING_CONFIG_FAILED
;
12115 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12119 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12120 "no redistribute " FRR_IP_REDIST_STR_BGPD
12121 " [metric (0-4294967295)] [route-map WORD]",
12123 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12124 "Metric for redistributed routes\n"
12126 "Route map reference\n"
12127 "Pointer to route-map entries\n")
12129 DEFUN (bgp_redistribute_ipv6
,
12130 bgp_redistribute_ipv6_cmd
,
12131 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12132 "Redistribute information from another routing protocol\n"
12133 FRR_IP6_REDIST_HELP_STR_BGPD
)
12135 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12136 int idx_protocol
= 1;
12139 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12141 vty_out(vty
, "%% Invalid route type\n");
12142 return CMD_WARNING_CONFIG_FAILED
;
12145 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12146 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12149 DEFUN (bgp_redistribute_ipv6_rmap
,
12150 bgp_redistribute_ipv6_rmap_cmd
,
12151 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12152 "Redistribute information from another routing protocol\n"
12153 FRR_IP6_REDIST_HELP_STR_BGPD
12154 "Route map reference\n"
12155 "Pointer to route-map entries\n")
12157 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12158 int idx_protocol
= 1;
12161 struct bgp_redist
*red
;
12163 struct route_map
*route_map
=
12164 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12166 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12168 vty_out(vty
, "%% Invalid route type\n");
12169 return CMD_WARNING_CONFIG_FAILED
;
12172 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12174 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12175 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12178 DEFUN (bgp_redistribute_ipv6_metric
,
12179 bgp_redistribute_ipv6_metric_cmd
,
12180 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12181 "Redistribute information from another routing protocol\n"
12182 FRR_IP6_REDIST_HELP_STR_BGPD
12183 "Metric for redistributed routes\n"
12184 "Default metric\n")
12186 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12187 int idx_protocol
= 1;
12188 int idx_number
= 3;
12191 struct bgp_redist
*red
;
12194 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12196 vty_out(vty
, "%% Invalid route type\n");
12197 return CMD_WARNING_CONFIG_FAILED
;
12199 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12201 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12202 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12203 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12206 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12207 bgp_redistribute_ipv6_rmap_metric_cmd
,
12208 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12209 "Redistribute information from another routing protocol\n"
12210 FRR_IP6_REDIST_HELP_STR_BGPD
12211 "Route map reference\n"
12212 "Pointer to route-map entries\n"
12213 "Metric for redistributed routes\n"
12214 "Default metric\n")
12216 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12217 int idx_protocol
= 1;
12219 int idx_number
= 5;
12222 struct bgp_redist
*red
;
12224 struct route_map
*route_map
=
12225 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12227 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12229 vty_out(vty
, "%% Invalid route type\n");
12230 return CMD_WARNING_CONFIG_FAILED
;
12232 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12234 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12236 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12237 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12239 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12242 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12243 bgp_redistribute_ipv6_metric_rmap_cmd
,
12244 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12245 "Redistribute information from another routing protocol\n"
12246 FRR_IP6_REDIST_HELP_STR_BGPD
12247 "Metric for redistributed routes\n"
12249 "Route map reference\n"
12250 "Pointer to route-map entries\n")
12252 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12253 int idx_protocol
= 1;
12254 int idx_number
= 3;
12258 struct bgp_redist
*red
;
12260 struct route_map
*route_map
=
12261 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12263 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12265 vty_out(vty
, "%% Invalid route type\n");
12266 return CMD_WARNING_CONFIG_FAILED
;
12268 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12270 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12271 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12274 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12275 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12278 DEFUN (no_bgp_redistribute_ipv6
,
12279 no_bgp_redistribute_ipv6_cmd
,
12280 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12282 "Redistribute information from another routing protocol\n"
12283 FRR_IP6_REDIST_HELP_STR_BGPD
12284 "Metric for redistributed routes\n"
12286 "Route map reference\n"
12287 "Pointer to route-map entries\n")
12289 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12290 int idx_protocol
= 2;
12293 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12295 vty_out(vty
, "%% Invalid route type\n");
12296 return CMD_WARNING_CONFIG_FAILED
;
12299 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12302 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12307 /* Unicast redistribution only. */
12308 if (safi
!= SAFI_UNICAST
)
12311 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12312 /* Redistribute BGP does not make sense. */
12313 if (i
!= ZEBRA_ROUTE_BGP
) {
12314 struct list
*red_list
;
12315 struct listnode
*node
;
12316 struct bgp_redist
*red
;
12318 red_list
= bgp
->redist
[afi
][i
];
12322 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12323 /* "redistribute" configuration. */
12324 vty_out(vty
, " redistribute %s",
12325 zebra_route_string(i
));
12327 vty_out(vty
, " %d", red
->instance
);
12328 if (red
->redist_metric_flag
)
12329 vty_out(vty
, " metric %u",
12330 red
->redist_metric
);
12331 if (red
->rmap
.name
)
12332 vty_out(vty
, " route-map %s",
12334 vty_out(vty
, "\n");
12340 /* This is part of the address-family block (unicast only) */
12341 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12346 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
])
12347 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12348 bgp
->vpn_policy
[afi
]
12349 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12351 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12352 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12353 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12354 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12357 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12358 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12360 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12363 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12364 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12365 bgp
->vpn_policy
[afi
].tovpn_label
);
12368 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12369 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12370 char buf
[RD_ADDRSTRLEN
];
12371 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12372 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12375 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12376 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12378 char buf
[PREFIX_STRLEN
];
12379 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12380 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12383 vty_out(vty
, "%*snexthop vpn export %s\n",
12387 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12388 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12390 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12391 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12393 char *b
= ecommunity_ecom2str(
12394 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12395 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12396 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12397 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12399 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12400 char *b
= ecommunity_ecom2str(
12401 bgp
->vpn_policy
[afi
]
12402 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12403 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12404 ECOMMUNITY_ROUTE_TARGET
);
12405 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12406 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12408 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12409 char *b
= ecommunity_ecom2str(
12410 bgp
->vpn_policy
[afi
]
12411 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12412 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12413 ECOMMUNITY_ROUTE_TARGET
);
12414 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12415 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12419 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12420 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12421 bgp
->vpn_policy
[afi
]
12422 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12424 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12425 char *b
= ecommunity_ecom2str(
12426 bgp
->vpn_policy
[afi
]
12427 .import_redirect_rtlist
,
12428 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12429 ECOMMUNITY_ROUTE_TARGET
);
12431 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12432 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12437 /* BGP node structure. */
12438 static struct cmd_node bgp_node
= {
12439 BGP_NODE
, "%s(config-router)# ", 1,
12442 static struct cmd_node bgp_ipv4_unicast_node
= {
12443 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12446 static struct cmd_node bgp_ipv4_multicast_node
= {
12447 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12450 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12451 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12454 static struct cmd_node bgp_ipv6_unicast_node
= {
12455 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12458 static struct cmd_node bgp_ipv6_multicast_node
= {
12459 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12462 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12463 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12466 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12467 "%s(config-router-af)# ", 1};
12469 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12470 "%s(config-router-af-vpnv6)# ", 1};
12472 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12473 "%s(config-router-evpn)# ", 1};
12475 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12476 "%s(config-router-af-vni)# ", 1};
12478 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12479 "%s(config-router-af)# ", 1};
12481 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12482 "%s(config-router-af-vpnv6)# ", 1};
12484 static void community_list_vty(void);
12486 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12490 struct listnode
*lnbgp
, *lnpeer
;
12492 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12493 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12494 /* only provide suggestions on the appropriate input
12496 * they'll otherwise show up multiple times */
12497 enum cmd_token_type match_type
;
12498 char *name
= peer
->host
;
12500 if (peer
->conf_if
) {
12501 match_type
= VARIABLE_TKN
;
12502 name
= peer
->conf_if
;
12503 } else if (strchr(peer
->host
, ':'))
12504 match_type
= IPV6_TKN
;
12506 match_type
= IPV4_TKN
;
12508 if (token
->type
!= match_type
)
12511 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12516 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12517 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12518 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12519 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12520 {.completions
= NULL
}};
12522 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12525 struct peer_group
*group
;
12526 struct listnode
*lnbgp
, *lnpeer
;
12528 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12529 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12530 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12535 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12536 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12537 {.completions
= NULL
} };
12539 void bgp_vty_init(void)
12541 cmd_variable_handler_register(bgp_var_neighbor
);
12542 cmd_variable_handler_register(bgp_var_peergroup
);
12544 /* Install bgp top node. */
12545 install_node(&bgp_node
, bgp_config_write
);
12546 install_node(&bgp_ipv4_unicast_node
, NULL
);
12547 install_node(&bgp_ipv4_multicast_node
, NULL
);
12548 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12549 install_node(&bgp_ipv6_unicast_node
, NULL
);
12550 install_node(&bgp_ipv6_multicast_node
, NULL
);
12551 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12552 install_node(&bgp_vpnv4_node
, NULL
);
12553 install_node(&bgp_vpnv6_node
, NULL
);
12554 install_node(&bgp_evpn_node
, NULL
);
12555 install_node(&bgp_evpn_vni_node
, NULL
);
12556 install_node(&bgp_flowspecv4_node
, NULL
);
12557 install_node(&bgp_flowspecv6_node
, NULL
);
12559 /* Install default VTY commands to new nodes. */
12560 install_default(BGP_NODE
);
12561 install_default(BGP_IPV4_NODE
);
12562 install_default(BGP_IPV4M_NODE
);
12563 install_default(BGP_IPV4L_NODE
);
12564 install_default(BGP_IPV6_NODE
);
12565 install_default(BGP_IPV6M_NODE
);
12566 install_default(BGP_IPV6L_NODE
);
12567 install_default(BGP_VPNV4_NODE
);
12568 install_default(BGP_VPNV6_NODE
);
12569 install_default(BGP_FLOWSPECV4_NODE
);
12570 install_default(BGP_FLOWSPECV6_NODE
);
12571 install_default(BGP_EVPN_NODE
);
12572 install_default(BGP_EVPN_VNI_NODE
);
12574 /* "bgp multiple-instance" commands. */
12575 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
12576 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
12578 /* "bgp config-type" commands. */
12579 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
12580 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
12582 /* bgp route-map delay-timer commands. */
12583 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12584 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12586 /* Dummy commands (Currently not supported) */
12587 install_element(BGP_NODE
, &no_synchronization_cmd
);
12588 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12590 /* "router bgp" commands. */
12591 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12593 /* "no router bgp" commands. */
12594 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12596 /* "bgp router-id" commands. */
12597 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12598 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12600 /* "bgp cluster-id" commands. */
12601 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12602 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12604 /* "bgp confederation" commands. */
12605 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12606 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12608 /* "bgp confederation peers" commands. */
12609 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12610 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12612 /* bgp max-med command */
12613 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12614 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12615 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12616 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12617 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12619 /* bgp disable-ebgp-connected-nh-check */
12620 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12621 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12623 /* bgp update-delay command */
12624 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12625 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12626 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12628 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12629 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12630 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12631 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12633 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12634 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12636 /* "maximum-paths" commands. */
12637 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12638 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12639 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12640 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12641 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12642 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12643 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12644 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12645 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12646 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12647 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12648 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12649 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12650 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12651 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12653 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12654 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12655 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12656 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12657 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12659 /* "timers bgp" commands. */
12660 install_element(BGP_NODE
, &bgp_timers_cmd
);
12661 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12663 /* route-map delay-timer commands - per instance for backwards compat.
12665 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12666 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12668 /* "bgp client-to-client reflection" commands */
12669 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
12670 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
12672 /* "bgp always-compare-med" commands */
12673 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
12674 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
12676 /* "bgp deterministic-med" commands */
12677 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
12678 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
12680 /* "bgp graceful-restart" commands */
12681 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
12682 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
12683 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
12684 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
12685 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
12686 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
12688 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
12689 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
12691 /* "bgp graceful-shutdown" commands */
12692 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
12693 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
12695 /* "bgp fast-external-failover" commands */
12696 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
12697 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
12699 /* "bgp enforce-first-as" commands */
12700 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
12702 /* "bgp bestpath compare-routerid" commands */
12703 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
12704 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
12706 /* "bgp bestpath as-path ignore" commands */
12707 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
12708 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
12710 /* "bgp bestpath as-path confed" commands */
12711 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
12712 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
12714 /* "bgp bestpath as-path multipath-relax" commands */
12715 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
12716 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
12718 /* "bgp log-neighbor-changes" commands */
12719 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
12720 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
12722 /* "bgp bestpath med" commands */
12723 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
12724 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
12726 /* "no bgp default ipv4-unicast" commands. */
12727 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
12728 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
12730 /* "bgp network import-check" commands. */
12731 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
12732 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
12733 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
12735 /* "bgp default local-preference" commands. */
12736 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
12737 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
12739 /* bgp default show-hostname */
12740 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
12741 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
12743 /* "bgp default subgroup-pkt-queue-max" commands. */
12744 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
12745 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
12747 /* bgp ibgp-allow-policy-mods command */
12748 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
12749 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
12751 /* "bgp listen limit" commands. */
12752 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
12753 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
12755 /* "bgp listen range" commands. */
12756 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
12757 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
12759 /* "bgp default shutdown" command */
12760 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
12762 /* "neighbor remote-as" commands. */
12763 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
12764 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
12765 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
12766 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
12767 install_element(BGP_NODE
,
12768 &neighbor_interface_v6only_config_remote_as_cmd
);
12769 install_element(BGP_NODE
, &no_neighbor_cmd
);
12770 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
12772 /* "neighbor peer-group" commands. */
12773 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
12774 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
12775 install_element(BGP_NODE
,
12776 &no_neighbor_interface_peer_group_remote_as_cmd
);
12778 /* "neighbor local-as" commands. */
12779 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
12780 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
12781 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
12782 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
12784 /* "neighbor solo" commands. */
12785 install_element(BGP_NODE
, &neighbor_solo_cmd
);
12786 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
12788 /* "neighbor password" commands. */
12789 install_element(BGP_NODE
, &neighbor_password_cmd
);
12790 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
12792 /* "neighbor activate" commands. */
12793 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
12794 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
12795 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
12796 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
12797 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
12798 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
12799 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
12800 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
12801 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
12802 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
12803 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
12804 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
12806 /* "no neighbor activate" commands. */
12807 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
12808 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
12809 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
12810 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
12811 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
12812 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
12813 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
12814 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
12815 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
12816 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
12817 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
12818 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
12820 /* "neighbor peer-group" set commands. */
12821 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
12822 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12823 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12824 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12825 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12826 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12827 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12828 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12829 install_element(BGP_FLOWSPECV4_NODE
,
12830 &neighbor_set_peer_group_hidden_cmd
);
12831 install_element(BGP_FLOWSPECV6_NODE
,
12832 &neighbor_set_peer_group_hidden_cmd
);
12834 /* "no neighbor peer-group unset" commands. */
12835 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
12836 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12837 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12838 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12839 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12840 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12841 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12842 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12843 install_element(BGP_FLOWSPECV4_NODE
,
12844 &no_neighbor_set_peer_group_hidden_cmd
);
12845 install_element(BGP_FLOWSPECV6_NODE
,
12846 &no_neighbor_set_peer_group_hidden_cmd
);
12848 /* "neighbor softreconfiguration inbound" commands.*/
12849 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
12850 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
12851 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12852 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12853 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12854 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12855 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12856 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12857 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12858 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12859 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12860 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12861 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12862 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12863 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12864 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12865 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12866 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12867 install_element(BGP_FLOWSPECV4_NODE
,
12868 &neighbor_soft_reconfiguration_cmd
);
12869 install_element(BGP_FLOWSPECV4_NODE
,
12870 &no_neighbor_soft_reconfiguration_cmd
);
12871 install_element(BGP_FLOWSPECV6_NODE
,
12872 &neighbor_soft_reconfiguration_cmd
);
12873 install_element(BGP_FLOWSPECV6_NODE
,
12874 &no_neighbor_soft_reconfiguration_cmd
);
12876 /* "neighbor attribute-unchanged" commands. */
12877 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
12878 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
12879 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
12880 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
12881 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
12882 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
12883 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
12884 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
12885 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
12886 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
12887 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
12888 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
12889 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
12890 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
12891 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
12892 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
12893 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
12894 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
12896 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
12897 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
12899 /* "nexthop-local unchanged" commands */
12900 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
12901 install_element(BGP_IPV6_NODE
,
12902 &no_neighbor_nexthop_local_unchanged_cmd
);
12904 /* "neighbor next-hop-self" commands. */
12905 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
12906 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
12907 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
12908 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
12909 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
12910 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
12911 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
12912 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
12913 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
12914 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
12915 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
12916 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
12917 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
12918 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
12919 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
12920 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
12921 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
12922 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
12923 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
12924 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
12926 /* "neighbor next-hop-self force" commands. */
12927 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
12928 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
12929 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
12930 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12931 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
12932 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12933 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
12934 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12935 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
12936 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12937 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
12938 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12939 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
12940 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12941 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
12942 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12943 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
12944 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12946 /* "neighbor as-override" commands. */
12947 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
12948 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
12949 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
12950 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
12951 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
12952 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
12953 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
12954 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
12955 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
12956 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
12957 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
12958 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
12959 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
12960 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
12961 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
12962 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
12963 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
12964 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
12966 /* "neighbor remove-private-AS" commands. */
12967 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
12968 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
12969 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
12970 install_element(BGP_NODE
,
12971 &no_neighbor_remove_private_as_all_hidden_cmd
);
12972 install_element(BGP_NODE
,
12973 &neighbor_remove_private_as_replace_as_hidden_cmd
);
12974 install_element(BGP_NODE
,
12975 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
12976 install_element(BGP_NODE
,
12977 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
12980 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
12981 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
12982 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
12983 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
12984 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12985 install_element(BGP_IPV4_NODE
,
12986 &neighbor_remove_private_as_replace_as_cmd
);
12987 install_element(BGP_IPV4_NODE
,
12988 &no_neighbor_remove_private_as_replace_as_cmd
);
12989 install_element(BGP_IPV4_NODE
,
12990 &neighbor_remove_private_as_all_replace_as_cmd
);
12991 install_element(BGP_IPV4_NODE
,
12992 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12993 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
12994 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
12995 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
12996 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12997 install_element(BGP_IPV4M_NODE
,
12998 &neighbor_remove_private_as_replace_as_cmd
);
12999 install_element(BGP_IPV4M_NODE
,
13000 &no_neighbor_remove_private_as_replace_as_cmd
);
13001 install_element(BGP_IPV4M_NODE
,
13002 &neighbor_remove_private_as_all_replace_as_cmd
);
13003 install_element(BGP_IPV4M_NODE
,
13004 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13005 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
13006 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
13007 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
13008 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13009 install_element(BGP_IPV4L_NODE
,
13010 &neighbor_remove_private_as_replace_as_cmd
);
13011 install_element(BGP_IPV4L_NODE
,
13012 &no_neighbor_remove_private_as_replace_as_cmd
);
13013 install_element(BGP_IPV4L_NODE
,
13014 &neighbor_remove_private_as_all_replace_as_cmd
);
13015 install_element(BGP_IPV4L_NODE
,
13016 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13017 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
13018 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13019 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13020 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13021 install_element(BGP_IPV6_NODE
,
13022 &neighbor_remove_private_as_replace_as_cmd
);
13023 install_element(BGP_IPV6_NODE
,
13024 &no_neighbor_remove_private_as_replace_as_cmd
);
13025 install_element(BGP_IPV6_NODE
,
13026 &neighbor_remove_private_as_all_replace_as_cmd
);
13027 install_element(BGP_IPV6_NODE
,
13028 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13029 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
13030 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
13031 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
13032 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13033 install_element(BGP_IPV6M_NODE
,
13034 &neighbor_remove_private_as_replace_as_cmd
);
13035 install_element(BGP_IPV6M_NODE
,
13036 &no_neighbor_remove_private_as_replace_as_cmd
);
13037 install_element(BGP_IPV6M_NODE
,
13038 &neighbor_remove_private_as_all_replace_as_cmd
);
13039 install_element(BGP_IPV6M_NODE
,
13040 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13041 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
13042 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
13043 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
13044 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13045 install_element(BGP_IPV6L_NODE
,
13046 &neighbor_remove_private_as_replace_as_cmd
);
13047 install_element(BGP_IPV6L_NODE
,
13048 &no_neighbor_remove_private_as_replace_as_cmd
);
13049 install_element(BGP_IPV6L_NODE
,
13050 &neighbor_remove_private_as_all_replace_as_cmd
);
13051 install_element(BGP_IPV6L_NODE
,
13052 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13053 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
13054 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13055 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13056 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13057 install_element(BGP_VPNV4_NODE
,
13058 &neighbor_remove_private_as_replace_as_cmd
);
13059 install_element(BGP_VPNV4_NODE
,
13060 &no_neighbor_remove_private_as_replace_as_cmd
);
13061 install_element(BGP_VPNV4_NODE
,
13062 &neighbor_remove_private_as_all_replace_as_cmd
);
13063 install_element(BGP_VPNV4_NODE
,
13064 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13065 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
13066 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13067 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13068 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13069 install_element(BGP_VPNV6_NODE
,
13070 &neighbor_remove_private_as_replace_as_cmd
);
13071 install_element(BGP_VPNV6_NODE
,
13072 &no_neighbor_remove_private_as_replace_as_cmd
);
13073 install_element(BGP_VPNV6_NODE
,
13074 &neighbor_remove_private_as_all_replace_as_cmd
);
13075 install_element(BGP_VPNV6_NODE
,
13076 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13078 /* "neighbor send-community" commands.*/
13079 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
13080 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
13081 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
13082 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
13083 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
13084 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
13085 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
13086 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
13087 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
13088 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
13089 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
13090 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
13091 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
13092 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
13093 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
13094 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
13095 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
13096 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
13097 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
13098 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
13099 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
13100 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
13101 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
13102 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
13103 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
13104 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
13105 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
13106 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
13107 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
13108 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
13109 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
13110 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
13111 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
13112 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
13113 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
13114 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
13116 /* "neighbor route-reflector" commands.*/
13117 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
13118 install_element(BGP_NODE
,
13119 &no_neighbor_route_reflector_client_hidden_cmd
);
13120 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
13121 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
13122 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
13123 install_element(BGP_IPV4M_NODE
,
13124 &no_neighbor_route_reflector_client_cmd
);
13125 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
13126 install_element(BGP_IPV4L_NODE
,
13127 &no_neighbor_route_reflector_client_cmd
);
13128 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
13129 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
13130 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
13131 install_element(BGP_IPV6M_NODE
,
13132 &no_neighbor_route_reflector_client_cmd
);
13133 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
13134 install_element(BGP_IPV6L_NODE
,
13135 &no_neighbor_route_reflector_client_cmd
);
13136 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
13137 install_element(BGP_VPNV4_NODE
,
13138 &no_neighbor_route_reflector_client_cmd
);
13139 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
13140 install_element(BGP_VPNV6_NODE
,
13141 &no_neighbor_route_reflector_client_cmd
);
13142 install_element(BGP_FLOWSPECV4_NODE
,
13143 &neighbor_route_reflector_client_cmd
);
13144 install_element(BGP_FLOWSPECV4_NODE
,
13145 &no_neighbor_route_reflector_client_cmd
);
13146 install_element(BGP_FLOWSPECV6_NODE
,
13147 &neighbor_route_reflector_client_cmd
);
13148 install_element(BGP_FLOWSPECV6_NODE
,
13149 &no_neighbor_route_reflector_client_cmd
);
13150 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
13151 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
13153 /* "neighbor route-server" commands.*/
13154 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
13155 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
13156 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
13157 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
13158 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
13159 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
13160 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
13161 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
13162 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
13163 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
13164 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
13165 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
13166 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
13167 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
13168 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
13169 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
13170 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
13171 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
13172 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
13173 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
13174 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
13175 install_element(BGP_FLOWSPECV4_NODE
,
13176 &no_neighbor_route_server_client_cmd
);
13177 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
13178 install_element(BGP_FLOWSPECV6_NODE
,
13179 &no_neighbor_route_server_client_cmd
);
13181 /* "neighbor addpath-tx-all-paths" commands.*/
13182 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
13183 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
13184 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13185 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13186 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13187 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13188 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13189 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13190 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13191 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13192 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13193 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13194 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13195 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13196 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13197 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13198 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13199 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13201 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
13202 install_element(BGP_NODE
,
13203 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13204 install_element(BGP_NODE
,
13205 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13206 install_element(BGP_IPV4_NODE
,
13207 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13208 install_element(BGP_IPV4_NODE
,
13209 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13210 install_element(BGP_IPV4M_NODE
,
13211 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13212 install_element(BGP_IPV4M_NODE
,
13213 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13214 install_element(BGP_IPV4L_NODE
,
13215 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13216 install_element(BGP_IPV4L_NODE
,
13217 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13218 install_element(BGP_IPV6_NODE
,
13219 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13220 install_element(BGP_IPV6_NODE
,
13221 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13222 install_element(BGP_IPV6M_NODE
,
13223 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13224 install_element(BGP_IPV6M_NODE
,
13225 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13226 install_element(BGP_IPV6L_NODE
,
13227 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13228 install_element(BGP_IPV6L_NODE
,
13229 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13230 install_element(BGP_VPNV4_NODE
,
13231 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13232 install_element(BGP_VPNV4_NODE
,
13233 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13234 install_element(BGP_VPNV6_NODE
,
13235 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13236 install_element(BGP_VPNV6_NODE
,
13237 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13239 /* "neighbor passive" commands. */
13240 install_element(BGP_NODE
, &neighbor_passive_cmd
);
13241 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13244 /* "neighbor shutdown" commands. */
13245 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13246 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13247 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13248 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13250 /* "neighbor capability extended-nexthop" commands.*/
13251 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13252 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13254 /* "neighbor capability orf prefix-list" commands.*/
13255 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13256 install_element(BGP_NODE
,
13257 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13258 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13259 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13260 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13261 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13262 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13263 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13264 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13265 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13266 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13267 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13268 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13269 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13271 /* "neighbor capability dynamic" commands.*/
13272 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13273 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13275 /* "neighbor dont-capability-negotiate" commands. */
13276 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13277 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13279 /* "neighbor ebgp-multihop" commands. */
13280 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13281 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13282 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13284 /* "neighbor disable-connected-check" commands. */
13285 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13286 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13288 /* "neighbor enforce-first-as" commands. */
13289 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13290 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13292 /* "neighbor description" commands. */
13293 install_element(BGP_NODE
, &neighbor_description_cmd
);
13294 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13295 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13297 /* "neighbor update-source" commands. "*/
13298 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13299 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13301 /* "neighbor default-originate" commands. */
13302 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13303 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13304 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13305 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13306 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13307 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13308 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13309 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13310 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13311 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13312 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13313 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13314 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13315 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13316 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13317 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13318 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13319 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13320 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13321 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13322 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13324 /* "neighbor port" commands. */
13325 install_element(BGP_NODE
, &neighbor_port_cmd
);
13326 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13328 /* "neighbor weight" commands. */
13329 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13330 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13332 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13333 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13334 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13335 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13336 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13337 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13338 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13339 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13340 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13341 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13342 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13343 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13344 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13345 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13346 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13347 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13349 /* "neighbor override-capability" commands. */
13350 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13351 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13353 /* "neighbor strict-capability-match" commands. */
13354 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13355 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13357 /* "neighbor timers" commands. */
13358 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13359 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13361 /* "neighbor timers connect" commands. */
13362 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13363 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13365 /* "neighbor advertisement-interval" commands. */
13366 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13367 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13369 /* "neighbor interface" commands. */
13370 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13371 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13373 /* "neighbor distribute" commands. */
13374 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13375 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13376 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13377 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13378 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13379 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13380 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13381 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13382 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13383 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13384 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13385 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13386 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13387 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13388 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13389 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13390 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13391 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13393 /* "neighbor prefix-list" commands. */
13394 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13395 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13396 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13397 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13398 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13399 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13400 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13401 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13402 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13403 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13404 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13405 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13406 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13407 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13408 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13409 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13410 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13411 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13412 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13413 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13414 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13415 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13417 /* "neighbor filter-list" commands. */
13418 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13419 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13420 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13421 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13422 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13423 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13424 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13425 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13426 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13427 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13428 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13429 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13430 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13431 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13432 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13433 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13434 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13435 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13436 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13437 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13438 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13439 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13441 /* "neighbor route-map" commands. */
13442 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13443 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13444 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13445 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13446 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13447 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13448 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13449 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13450 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13451 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13452 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13453 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13454 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13455 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13456 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13457 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13458 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13459 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13460 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13461 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13462 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13463 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13464 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13465 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13467 /* "neighbor unsuppress-map" commands. */
13468 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13469 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13470 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13471 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13472 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13473 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13474 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13475 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13476 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13477 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13478 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13479 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13480 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13481 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13482 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13483 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13484 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13485 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13487 /* "neighbor maximum-prefix" commands. */
13488 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13489 install_element(BGP_NODE
,
13490 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13491 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13492 install_element(BGP_NODE
,
13493 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13494 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13495 install_element(BGP_NODE
,
13496 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13497 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13498 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13499 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13500 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13501 install_element(BGP_IPV4_NODE
,
13502 &neighbor_maximum_prefix_threshold_warning_cmd
);
13503 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13504 install_element(BGP_IPV4_NODE
,
13505 &neighbor_maximum_prefix_threshold_restart_cmd
);
13506 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13507 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13508 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13509 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13510 install_element(BGP_IPV4M_NODE
,
13511 &neighbor_maximum_prefix_threshold_warning_cmd
);
13512 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13513 install_element(BGP_IPV4M_NODE
,
13514 &neighbor_maximum_prefix_threshold_restart_cmd
);
13515 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13516 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13517 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13518 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13519 install_element(BGP_IPV4L_NODE
,
13520 &neighbor_maximum_prefix_threshold_warning_cmd
);
13521 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13522 install_element(BGP_IPV4L_NODE
,
13523 &neighbor_maximum_prefix_threshold_restart_cmd
);
13524 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13525 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13526 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13527 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13528 install_element(BGP_IPV6_NODE
,
13529 &neighbor_maximum_prefix_threshold_warning_cmd
);
13530 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13531 install_element(BGP_IPV6_NODE
,
13532 &neighbor_maximum_prefix_threshold_restart_cmd
);
13533 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13534 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13535 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13536 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13537 install_element(BGP_IPV6M_NODE
,
13538 &neighbor_maximum_prefix_threshold_warning_cmd
);
13539 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13540 install_element(BGP_IPV6M_NODE
,
13541 &neighbor_maximum_prefix_threshold_restart_cmd
);
13542 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13543 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13544 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13545 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13546 install_element(BGP_IPV6L_NODE
,
13547 &neighbor_maximum_prefix_threshold_warning_cmd
);
13548 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13549 install_element(BGP_IPV6L_NODE
,
13550 &neighbor_maximum_prefix_threshold_restart_cmd
);
13551 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13552 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13553 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13554 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13555 install_element(BGP_VPNV4_NODE
,
13556 &neighbor_maximum_prefix_threshold_warning_cmd
);
13557 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13558 install_element(BGP_VPNV4_NODE
,
13559 &neighbor_maximum_prefix_threshold_restart_cmd
);
13560 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13561 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13562 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13563 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13564 install_element(BGP_VPNV6_NODE
,
13565 &neighbor_maximum_prefix_threshold_warning_cmd
);
13566 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13567 install_element(BGP_VPNV6_NODE
,
13568 &neighbor_maximum_prefix_threshold_restart_cmd
);
13569 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13571 /* "neighbor allowas-in" */
13572 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13573 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13574 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13575 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13576 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13577 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13578 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13579 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13580 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13581 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13582 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13583 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13584 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13585 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13586 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13587 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13588 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13589 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13590 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13591 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13593 /* address-family commands. */
13594 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13595 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13596 #ifdef KEEP_OLD_VPN_COMMANDS
13597 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13598 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13599 #endif /* KEEP_OLD_VPN_COMMANDS */
13601 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13603 /* "exit-address-family" command. */
13604 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13605 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13606 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13607 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13608 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13609 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13610 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13611 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13612 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13613 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13614 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13616 /* "clear ip bgp commands" */
13617 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13619 /* clear ip bgp prefix */
13620 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13621 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13622 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13624 /* "show [ip] bgp summary" commands. */
13625 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13626 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
13627 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13628 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13629 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13630 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13631 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
13633 /* "show [ip] bgp neighbors" commands. */
13634 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
13636 /* "show [ip] bgp peer-group" commands. */
13637 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
13639 /* "show [ip] bgp paths" commands. */
13640 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
13642 /* "show [ip] bgp community" commands. */
13643 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
13645 /* "show ip bgp large-community" commands. */
13646 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
13647 /* "show [ip] bgp attribute-info" commands. */
13648 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
13649 /* "show [ip] bgp route-leak" command */
13650 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
13652 /* "redistribute" commands. */
13653 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
13654 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
13655 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
13656 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
13657 install_element(BGP_NODE
,
13658 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
13659 install_element(BGP_NODE
,
13660 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
13661 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
13662 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
13663 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
13664 install_element(BGP_NODE
,
13665 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
13666 install_element(BGP_NODE
,
13667 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
13668 install_element(BGP_NODE
,
13669 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
13670 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
13671 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
13672 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
13673 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
13674 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
13675 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
13676 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
13677 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
13678 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
13679 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
13680 install_element(BGP_IPV4_NODE
,
13681 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
13682 install_element(BGP_IPV4_NODE
,
13683 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
13684 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
13685 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
13686 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
13687 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
13688 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
13689 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
13691 /* import|export vpn [route-map WORD] */
13692 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
13693 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
13695 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
13696 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
13698 /* ttl_security commands */
13699 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
13700 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
13702 /* "show [ip] bgp memory" commands. */
13703 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
13705 /* "show bgp martian next-hop" */
13706 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
13708 /* "show [ip] bgp views" commands. */
13709 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
13711 /* "show [ip] bgp vrfs" commands. */
13712 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
13714 /* Community-list. */
13715 community_list_vty();
13717 /* vpn-policy commands */
13718 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
13719 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
13720 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
13721 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
13722 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
13723 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
13724 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
13725 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
13726 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
13727 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
13728 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
13729 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
13731 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
13732 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
13734 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
13735 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
13736 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
13737 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
13738 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
13739 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
13740 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
13741 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
13742 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13743 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13744 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
13745 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
13748 #include "memory.h"
13749 #include "bgp_regex.h"
13750 #include "bgp_clist.h"
13751 #include "bgp_ecommunity.h"
13753 /* VTY functions. */
13755 /* Direction value to string conversion. */
13756 static const char *community_direct_str(int direct
)
13759 case COMMUNITY_DENY
:
13761 case COMMUNITY_PERMIT
:
13768 /* Display error string. */
13769 static void community_list_perror(struct vty
*vty
, int ret
)
13772 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
13773 vty_out(vty
, "%% Can't find community-list\n");
13775 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
13776 vty_out(vty
, "%% Malformed community-list value\n");
13778 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
13780 "%% Community name conflict, previously defined as standard community\n");
13782 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
13784 "%% Community name conflict, previously defined as expanded community\n");
13789 /* "community-list" keyword help string. */
13790 #define COMMUNITY_LIST_STR "Add a community list entry\n"
13792 /*community-list standard */
13793 DEFUN (community_list_standard
,
13794 bgp_community_list_standard_cmd
,
13795 "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13798 "Community list number (standard)\n"
13799 "Add an standard community-list entry\n"
13800 "Community list name\n"
13801 "Specify community to reject\n"
13802 "Specify community to accept\n"
13805 char *cl_name_or_number
= NULL
;
13807 int style
= COMMUNITY_LIST_STANDARD
;
13811 if (argv_find(argv
, argc
, "ip", &idx
)) {
13812 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
13813 vty_out(vty
, "if you are using this please migrate to the below command.\n");
13814 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
13815 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
13818 argv_find(argv
, argc
, "(1-99)", &idx
);
13819 argv_find(argv
, argc
, "WORD", &idx
);
13820 cl_name_or_number
= argv
[idx
]->arg
;
13821 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13823 argv_find(argv
, argc
, "AA:NN", &idx
);
13824 char *str
= argv_concat(argv
, argc
, idx
);
13826 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
13829 XFREE(MTYPE_TMP
, str
);
13832 /* Display error string. */
13833 community_list_perror(vty
, ret
);
13834 return CMD_WARNING_CONFIG_FAILED
;
13837 return CMD_SUCCESS
;
13840 #if CONFDATE > 20191005
13841 CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command")
13843 ALIAS (community_list_standard
,
13844 ip_community_list_standard_cmd
,
13845 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13848 "Community list number (standard)\n"
13849 "Add an standard community-list entry\n"
13850 "Community list name\n"
13851 "Specify community to reject\n"
13852 "Specify community to accept\n"
13855 DEFUN (no_community_list_standard_all
,
13856 no_bgp_community_list_standard_all_cmd
,
13857 "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13861 "Community list number (standard)\n"
13862 "Add an standard community-list entry\n"
13863 "Community list name\n"
13864 "Specify community to reject\n"
13865 "Specify community to accept\n"
13868 char *cl_name_or_number
= NULL
;
13870 int style
= COMMUNITY_LIST_STANDARD
;
13874 if (argv_find(argv
, argc
, "ip", &idx
)) {
13875 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
13876 vty_out(vty
, "if you are using this please migrate to the below command.\n");
13877 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
13878 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used");
13881 argv_find(argv
, argc
, "(1-99)", &idx
);
13882 argv_find(argv
, argc
, "WORD", &idx
);
13883 cl_name_or_number
= argv
[idx
]->arg
;
13884 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13886 argv_find(argv
, argc
, "AA:NN", &idx
);
13887 char *str
= argv_concat(argv
, argc
, idx
);
13889 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
13892 XFREE(MTYPE_TMP
, str
);
13895 community_list_perror(vty
, ret
);
13896 return CMD_WARNING_CONFIG_FAILED
;
13899 return CMD_SUCCESS
;
13901 ALIAS (no_community_list_standard_all
,
13902 no_ip_community_list_standard_all_cmd
,
13903 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13907 "Community list number (standard)\n"
13908 "Add an standard community-list entry\n"
13909 "Community list name\n"
13910 "Specify community to reject\n"
13911 "Specify community to accept\n"
13914 /*community-list expanded */
13915 DEFUN (community_list_expanded_all
,
13916 bgp_community_list_expanded_all_cmd
,
13917 "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13920 "Community list number (expanded)\n"
13921 "Add an expanded community-list entry\n"
13922 "Community list name\n"
13923 "Specify community to reject\n"
13924 "Specify community to accept\n"
13927 char *cl_name_or_number
= NULL
;
13929 int style
= COMMUNITY_LIST_EXPANDED
;
13932 if (argv_find(argv
, argc
, "ip", &idx
)) {
13933 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
13934 vty_out(vty
, "if you are using this please migrate to the below command.\n");
13935 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
13936 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
13938 argv_find(argv
, argc
, "(100-500)", &idx
);
13939 argv_find(argv
, argc
, "WORD", &idx
);
13940 cl_name_or_number
= argv
[idx
]->arg
;
13941 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13943 argv_find(argv
, argc
, "AA:NN", &idx
);
13944 char *str
= argv_concat(argv
, argc
, idx
);
13946 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
13949 XFREE(MTYPE_TMP
, str
);
13952 /* Display error string. */
13953 community_list_perror(vty
, ret
);
13954 return CMD_WARNING_CONFIG_FAILED
;
13957 return CMD_SUCCESS
;
13960 ALIAS (community_list_expanded_all
,
13961 ip_community_list_expanded_all_cmd
,
13962 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13965 "Community list number (expanded)\n"
13966 "Add an expanded community-list entry\n"
13967 "Community list name\n"
13968 "Specify community to reject\n"
13969 "Specify community to accept\n"
13972 DEFUN (no_community_list_expanded_all
,
13973 no_bgp_community_list_expanded_all_cmd
,
13974 "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13978 "Community list number (expanded)\n"
13979 "Add an expanded community-list entry\n"
13980 "Community list name\n"
13981 "Specify community to reject\n"
13982 "Specify community to accept\n"
13985 char *cl_name_or_number
= NULL
;
13987 int style
= COMMUNITY_LIST_EXPANDED
;
13990 if (argv_find(argv
, argc
, "ip", &idx
)) {
13991 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
13992 vty_out(vty
, "if you are using this please migrate to the below command.\n");
13993 vty_out(vty
, "'no community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
13994 zlog_warn("Deprecated option: 'no community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
13996 argv_find(argv
, argc
, "(100-500)", &idx
);
13997 argv_find(argv
, argc
, "WORD", &idx
);
13998 cl_name_or_number
= argv
[idx
]->arg
;
13999 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14001 argv_find(argv
, argc
, "AA:NN", &idx
);
14002 char *str
= argv_concat(argv
, argc
, idx
);
14004 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14007 XFREE(MTYPE_TMP
, str
);
14010 community_list_perror(vty
, ret
);
14011 return CMD_WARNING_CONFIG_FAILED
;
14014 return CMD_SUCCESS
;
14017 ALIAS (no_community_list_expanded_all
,
14018 no_ip_community_list_expanded_all_cmd
,
14019 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14023 "Community list number (expanded)\n"
14024 "Add an expanded community-list entry\n"
14025 "Community list name\n"
14026 "Specify community to reject\n"
14027 "Specify community to accept\n"
14030 /* Return configuration string of community-list entry. */
14031 static const char *community_list_config_str(struct community_entry
*entry
)
14038 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
14039 str
= community_str(entry
->u
.com
, false);
14040 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
14041 str
= lcommunity_str(entry
->u
.lcom
, false);
14043 str
= entry
->config
;
14048 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
14050 struct community_entry
*entry
;
14052 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14053 if (entry
== list
->head
) {
14054 if (all_digit(list
->name
))
14055 vty_out(vty
, "Community %s list %s\n",
14056 entry
->style
== COMMUNITY_LIST_STANDARD
14058 : "(expanded) access",
14061 vty_out(vty
, "Named Community %s list %s\n",
14062 entry
->style
== COMMUNITY_LIST_STANDARD
14068 vty_out(vty
, " %s\n",
14069 community_direct_str(entry
->direct
));
14071 vty_out(vty
, " %s %s\n",
14072 community_direct_str(entry
->direct
),
14073 community_list_config_str(entry
));
14077 DEFUN (show_community_list
,
14078 show_bgp_community_list_cmd
,
14079 "show bgp community-list",
14082 "List community-list\n")
14084 struct community_list
*list
;
14085 struct community_list_master
*cm
;
14088 if (argv_find(argv
, argc
, "ip", &idx
)) {
14089 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14090 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14091 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14092 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14094 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14096 return CMD_SUCCESS
;
14098 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14099 community_list_show(vty
, list
);
14101 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14102 community_list_show(vty
, list
);
14104 return CMD_SUCCESS
;
14107 ALIAS (show_community_list
,
14108 show_ip_community_list_cmd
,
14109 "show ip community-list",
14112 "List community-list\n")
14114 DEFUN (show_community_list_arg
,
14115 show_bgp_community_list_arg_cmd
,
14116 "show bgp community-list <(1-500)|WORD>",
14119 "List community-list\n"
14120 "Community-list number\n"
14121 "Community-list name\n")
14123 int idx_comm_list
= 3;
14124 struct community_list
*list
;
14127 if (argv_find(argv
, argc
, "ip", &idx
)) {
14128 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14129 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14130 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14131 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14133 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
14134 COMMUNITY_LIST_MASTER
);
14136 vty_out(vty
, "%% Can't find community-list\n");
14137 return CMD_WARNING
;
14140 community_list_show(vty
, list
);
14142 return CMD_SUCCESS
;
14145 ALIAS (show_community_list_arg
,
14146 show_ip_community_list_arg_cmd
,
14147 "show ip community-list <(1-500)|WORD>",
14150 "List community-list\n"
14151 "Community-list number\n"
14152 "Community-list name\n")
14155 * Large Community code.
14157 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
14158 struct cmd_token
**argv
, int style
,
14159 int reject_all_digit_name
)
14167 if (argv_find(argv
, argc
, "ip", &idx
)) {
14168 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14169 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14170 vty_out(vty
, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14171 zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14173 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14176 /* All digit name check. */
14178 argv_find(argv
, argc
, "WORD", &idx
);
14179 argv_find(argv
, argc
, "(1-99)", &idx
);
14180 argv_find(argv
, argc
, "(100-500)", &idx
);
14181 cl_name
= argv
[idx
]->arg
;
14182 if (reject_all_digit_name
&& all_digit(cl_name
)) {
14183 vty_out(vty
, "%% Community name cannot have all digits\n");
14184 return CMD_WARNING_CONFIG_FAILED
;
14188 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
14189 argv_find(argv
, argc
, "LINE", &idx
);
14190 /* Concat community string argument. */
14192 str
= argv_concat(argv
, argc
, idx
);
14196 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
14198 /* Free temporary community list string allocated by
14201 XFREE(MTYPE_TMP
, str
);
14204 community_list_perror(vty
, ret
);
14205 return CMD_WARNING_CONFIG_FAILED
;
14207 return CMD_SUCCESS
;
14210 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
14211 struct cmd_token
**argv
, int style
)
14218 if (argv_find(argv
, argc
, "ip", &idx
)) {
14219 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14220 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14221 vty_out(vty
, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14222 zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14224 argv_find(argv
, argc
, "permit", &idx
);
14225 argv_find(argv
, argc
, "deny", &idx
);
14228 /* Check the list direct. */
14229 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
14230 direct
= COMMUNITY_PERMIT
;
14232 direct
= COMMUNITY_DENY
;
14235 argv_find(argv
, argc
, "LINE", &idx
);
14236 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
14237 /* Concat community string argument. */
14238 str
= argv_concat(argv
, argc
, idx
);
14242 argv_find(argv
, argc
, "(1-99)", &idx
);
14243 argv_find(argv
, argc
, "(100-500)", &idx
);
14244 argv_find(argv
, argc
, "WORD", &idx
);
14246 /* Unset community list. */
14247 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
14250 /* Free temporary community list string allocated by
14253 XFREE(MTYPE_TMP
, str
);
14256 community_list_perror(vty
, ret
);
14257 return CMD_WARNING_CONFIG_FAILED
;
14260 return CMD_SUCCESS
;
14263 /* "large-community-list" keyword help string. */
14264 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
14265 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
14267 #if CONFDATE > 20191005
14268 CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command")
14270 DEFUN (lcommunity_list_standard
,
14271 bgp_lcommunity_list_standard_cmd
,
14272 "bgp large-community-list (1-99) <deny|permit>",
14274 LCOMMUNITY_LIST_STR
14275 "Large Community list number (standard)\n"
14276 "Specify large community to reject\n"
14277 "Specify large community to accept\n")
14279 return lcommunity_list_set_vty(vty
, argc
, argv
,
14280 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14283 ALIAS (lcommunity_list_standard
,
14284 ip_lcommunity_list_standard_cmd
,
14285 "ip large-community-list (1-99) <deny|permit>",
14287 LCOMMUNITY_LIST_STR
14288 "Large Community list number (standard)\n"
14289 "Specify large community to reject\n"
14290 "Specify large community to accept\n")
14292 DEFUN (lcommunity_list_standard1
,
14293 bgp_lcommunity_list_standard1_cmd
,
14294 "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...",
14296 LCOMMUNITY_LIST_STR
14297 "Large Community list number (standard)\n"
14298 "Specify large community to reject\n"
14299 "Specify large community to accept\n"
14300 LCOMMUNITY_VAL_STR
)
14302 return lcommunity_list_set_vty(vty
, argc
, argv
,
14303 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14306 ALIAS (lcommunity_list_standard1
,
14307 ip_lcommunity_list_standard1_cmd
,
14308 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
14310 LCOMMUNITY_LIST_STR
14311 "Large Community list number (standard)\n"
14312 "Specify large community to reject\n"
14313 "Specify large community to accept\n"
14314 LCOMMUNITY_VAL_STR
)
14316 DEFUN (lcommunity_list_expanded
,
14317 bgp_lcommunity_list_expanded_cmd
,
14318 "bgp large-community-list (100-500) <deny|permit> LINE...",
14320 LCOMMUNITY_LIST_STR
14321 "Large Community list number (expanded)\n"
14322 "Specify large community to reject\n"
14323 "Specify large community to accept\n"
14324 "An ordered list as a regular-expression\n")
14326 return lcommunity_list_set_vty(vty
, argc
, argv
,
14327 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
14330 ALIAS (lcommunity_list_expanded
,
14331 ip_lcommunity_list_expanded_cmd
,
14332 "ip large-community-list (100-500) <deny|permit> LINE...",
14334 LCOMMUNITY_LIST_STR
14335 "Large Community list number (expanded)\n"
14336 "Specify large community to reject\n"
14337 "Specify large community to accept\n"
14338 "An ordered list as a regular-expression\n")
14340 DEFUN (lcommunity_list_name_standard
,
14341 bgp_lcommunity_list_name_standard_cmd
,
14342 "bgp large-community-list standard WORD <deny|permit>",
14344 LCOMMUNITY_LIST_STR
14345 "Specify standard large-community-list\n"
14346 "Large Community list name\n"
14347 "Specify large community to reject\n"
14348 "Specify large community to accept\n")
14350 return lcommunity_list_set_vty(vty
, argc
, argv
,
14351 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14354 ALIAS (lcommunity_list_name_standard
,
14355 ip_lcommunity_list_name_standard_cmd
,
14356 "ip large-community-list standard WORD <deny|permit>",
14358 LCOMMUNITY_LIST_STR
14359 "Specify standard large-community-list\n"
14360 "Large Community list name\n"
14361 "Specify large community to reject\n"
14362 "Specify large community to accept\n")
14364 DEFUN (lcommunity_list_name_standard1
,
14365 bgp_lcommunity_list_name_standard1_cmd
,
14366 "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
14368 LCOMMUNITY_LIST_STR
14369 "Specify standard large-community-list\n"
14370 "Large Community list name\n"
14371 "Specify large community to reject\n"
14372 "Specify large community to accept\n"
14373 LCOMMUNITY_VAL_STR
)
14375 return lcommunity_list_set_vty(vty
, argc
, argv
,
14376 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14379 ALIAS (lcommunity_list_name_standard1
,
14380 ip_lcommunity_list_name_standard1_cmd
,
14381 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
14383 LCOMMUNITY_LIST_STR
14384 "Specify standard large-community-list\n"
14385 "Large Community list name\n"
14386 "Specify large community to reject\n"
14387 "Specify large community to accept\n"
14388 LCOMMUNITY_VAL_STR
)
14390 DEFUN (lcommunity_list_name_expanded
,
14391 bgp_lcommunity_list_name_expanded_cmd
,
14392 "bgp large-community-list expanded WORD <deny|permit> LINE...",
14394 LCOMMUNITY_LIST_STR
14395 "Specify expanded large-community-list\n"
14396 "Large Community list name\n"
14397 "Specify large community to reject\n"
14398 "Specify large community to accept\n"
14399 "An ordered list as a regular-expression\n")
14401 return lcommunity_list_set_vty(vty
, argc
, argv
,
14402 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
14405 ALIAS (lcommunity_list_name_expanded
,
14406 ip_lcommunity_list_name_expanded_cmd
,
14407 "ip large-community-list expanded WORD <deny|permit> LINE...",
14409 LCOMMUNITY_LIST_STR
14410 "Specify expanded large-community-list\n"
14411 "Large Community list name\n"
14412 "Specify large community to reject\n"
14413 "Specify large community to accept\n"
14414 "An ordered list as a regular-expression\n")
14416 DEFUN (no_lcommunity_list_standard_all
,
14417 no_bgp_lcommunity_list_standard_all_cmd
,
14418 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
14421 LCOMMUNITY_LIST_STR
14422 "Large Community list number (standard)\n"
14423 "Large Community list number (expanded)\n"
14424 "Large Community list name\n")
14426 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14427 LARGE_COMMUNITY_LIST_STANDARD
);
14430 ALIAS (no_lcommunity_list_standard_all
,
14431 no_ip_lcommunity_list_standard_all_cmd
,
14432 "no ip large-community-list <(1-99)|(100-500)|WORD>",
14435 LCOMMUNITY_LIST_STR
14436 "Large Community list number (standard)\n"
14437 "Large Community list number (expanded)\n"
14438 "Large Community list name\n")
14440 DEFUN (no_lcommunity_list_name_expanded_all
,
14441 no_bgp_lcommunity_list_name_expanded_all_cmd
,
14442 "no bgp large-community-list expanded WORD",
14445 LCOMMUNITY_LIST_STR
14446 "Specify expanded large-community-list\n"
14447 "Large Community list name\n")
14449 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14450 LARGE_COMMUNITY_LIST_EXPANDED
);
14453 ALIAS (no_lcommunity_list_name_expanded_all
,
14454 no_ip_lcommunity_list_name_expanded_all_cmd
,
14455 "no ip large-community-list expanded WORD",
14458 LCOMMUNITY_LIST_STR
14459 "Specify expanded large-community-list\n"
14460 "Large Community list name\n")
14462 DEFUN (no_lcommunity_list_standard
,
14463 no_bgp_lcommunity_list_standard_cmd
,
14464 "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
14467 LCOMMUNITY_LIST_STR
14468 "Large Community list number (standard)\n"
14469 "Specify large community to reject\n"
14470 "Specify large community to accept\n"
14471 LCOMMUNITY_VAL_STR
)
14473 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14474 LARGE_COMMUNITY_LIST_STANDARD
);
14477 ALIAS (no_lcommunity_list_standard
,
14478 no_ip_lcommunity_list_standard_cmd
,
14479 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
14482 LCOMMUNITY_LIST_STR
14483 "Large Community list number (standard)\n"
14484 "Specify large community to reject\n"
14485 "Specify large community to accept\n"
14486 LCOMMUNITY_VAL_STR
)
14488 DEFUN (no_lcommunity_list_expanded
,
14489 no_bgp_lcommunity_list_expanded_cmd
,
14490 "no bgp large-community-list (100-500) <deny|permit> LINE...",
14493 LCOMMUNITY_LIST_STR
14494 "Large Community list number (expanded)\n"
14495 "Specify large community to reject\n"
14496 "Specify large community to accept\n"
14497 "An ordered list as a regular-expression\n")
14499 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14500 LARGE_COMMUNITY_LIST_EXPANDED
);
14503 ALIAS (no_lcommunity_list_expanded
,
14504 no_ip_lcommunity_list_expanded_cmd
,
14505 "no ip large-community-list (100-500) <deny|permit> LINE...",
14508 LCOMMUNITY_LIST_STR
14509 "Large Community list number (expanded)\n"
14510 "Specify large community to reject\n"
14511 "Specify large community to accept\n"
14512 "An ordered list as a regular-expression\n")
14514 DEFUN (no_lcommunity_list_name_standard
,
14515 no_bgp_lcommunity_list_name_standard_cmd
,
14516 "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
14519 LCOMMUNITY_LIST_STR
14520 "Specify standard large-community-list\n"
14521 "Large Community list name\n"
14522 "Specify large community to reject\n"
14523 "Specify large community to accept\n"
14524 LCOMMUNITY_VAL_STR
)
14526 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14527 LARGE_COMMUNITY_LIST_STANDARD
);
14530 ALIAS (no_lcommunity_list_name_standard
,
14531 no_ip_lcommunity_list_name_standard_cmd
,
14532 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
14535 LCOMMUNITY_LIST_STR
14536 "Specify standard large-community-list\n"
14537 "Large Community list name\n"
14538 "Specify large community to reject\n"
14539 "Specify large community to accept\n"
14540 LCOMMUNITY_VAL_STR
)
14542 DEFUN (no_lcommunity_list_name_expanded
,
14543 no_bgp_lcommunity_list_name_expanded_cmd
,
14544 "no bgp large-community-list expanded WORD <deny|permit> LINE...",
14547 LCOMMUNITY_LIST_STR
14548 "Specify expanded large-community-list\n"
14549 "Large community list name\n"
14550 "Specify large community to reject\n"
14551 "Specify large community to accept\n"
14552 "An ordered list as a regular-expression\n")
14554 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14555 LARGE_COMMUNITY_LIST_EXPANDED
);
14558 ALIAS (no_lcommunity_list_name_expanded
,
14559 no_ip_lcommunity_list_name_expanded_cmd
,
14560 "no ip large-community-list expanded WORD <deny|permit> LINE...",
14563 LCOMMUNITY_LIST_STR
14564 "Specify expanded large-community-list\n"
14565 "Large community list name\n"
14566 "Specify large community to reject\n"
14567 "Specify large community to accept\n"
14568 "An ordered list as a regular-expression\n")
14570 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14572 struct community_entry
*entry
;
14574 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14575 if (entry
== list
->head
) {
14576 if (all_digit(list
->name
))
14577 vty_out(vty
, "Large community %s list %s\n",
14578 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14580 : "(expanded) access",
14584 "Named large community %s list %s\n",
14585 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14591 vty_out(vty
, " %s\n",
14592 community_direct_str(entry
->direct
));
14594 vty_out(vty
, " %s %s\n",
14595 community_direct_str(entry
->direct
),
14596 community_list_config_str(entry
));
14600 DEFUN (show_lcommunity_list
,
14601 show_bgp_lcommunity_list_cmd
,
14602 "show bgp large-community-list",
14605 "List large-community list\n")
14607 struct community_list
*list
;
14608 struct community_list_master
*cm
;
14611 if (argv_find(argv
, argc
, "ip", &idx
)) {
14612 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14613 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14614 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
14615 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
14618 cm
= community_list_master_lookup(bgp_clist
,
14619 LARGE_COMMUNITY_LIST_MASTER
);
14621 return CMD_SUCCESS
;
14623 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14624 lcommunity_list_show(vty
, list
);
14626 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14627 lcommunity_list_show(vty
, list
);
14629 return CMD_SUCCESS
;
14632 ALIAS (show_lcommunity_list
,
14633 show_ip_lcommunity_list_cmd
,
14634 "show ip large-community-list",
14637 "List large-community list\n")
14639 DEFUN (show_lcommunity_list_arg
,
14640 show_bgp_lcommunity_list_arg_cmd
,
14641 "show bgp large-community-list <(1-500)|WORD>",
14644 "List large-community list\n"
14645 "large-community-list number\n"
14646 "large-community-list name\n")
14648 struct community_list
*list
;
14651 if (argv_find(argv
, argc
, "ip", &idx
)) {
14652 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14653 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14654 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
14655 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
14658 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
,
14659 LARGE_COMMUNITY_LIST_MASTER
);
14661 vty_out(vty
, "%% Can't find extcommunity-list\n");
14662 return CMD_WARNING
;
14665 lcommunity_list_show(vty
, list
);
14667 return CMD_SUCCESS
;
14670 ALIAS (show_lcommunity_list_arg
,
14671 show_ip_lcommunity_list_arg_cmd
,
14672 "show ip large-community-list <(1-500)|WORD>",
14675 "List large-community list\n"
14676 "large-community-list number\n"
14677 "large-community-list name\n")
14679 /* "extcommunity-list" keyword help string. */
14680 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
14681 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
14683 DEFUN (extcommunity_list_standard
,
14684 bgp_extcommunity_list_standard_cmd
,
14685 "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14687 EXTCOMMUNITY_LIST_STR
14688 "Extended Community list number (standard)\n"
14689 "Specify standard extcommunity-list\n"
14690 "Community list name\n"
14691 "Specify community to reject\n"
14692 "Specify community to accept\n"
14693 EXTCOMMUNITY_VAL_STR
)
14695 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14697 char *cl_number_or_name
= NULL
;
14700 if (argv_find(argv
, argc
, "ip", &idx
)) {
14701 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14702 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14703 vty_out(vty
, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
14704 zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
14706 argv_find(argv
, argc
, "(1-99)", &idx
);
14707 argv_find(argv
, argc
, "WORD", &idx
);
14708 cl_number_or_name
= argv
[idx
]->arg
;
14709 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14711 argv_find(argv
, argc
, "AA:NN", &idx
);
14712 char *str
= argv_concat(argv
, argc
, idx
);
14714 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14717 XFREE(MTYPE_TMP
, str
);
14720 community_list_perror(vty
, ret
);
14721 return CMD_WARNING_CONFIG_FAILED
;
14724 return CMD_SUCCESS
;
14727 #if CONFDATE > 20191005
14728 CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command")
14730 ALIAS (extcommunity_list_standard
,
14731 ip_extcommunity_list_standard_cmd
,
14732 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14734 EXTCOMMUNITY_LIST_STR
14735 "Extended Community list number (standard)\n"
14736 "Specify standard extcommunity-list\n"
14737 "Community list name\n"
14738 "Specify community to reject\n"
14739 "Specify community to accept\n"
14740 EXTCOMMUNITY_VAL_STR
)
14742 DEFUN (extcommunity_list_name_expanded
,
14743 bgp_extcommunity_list_name_expanded_cmd
,
14744 "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14746 EXTCOMMUNITY_LIST_STR
14747 "Extended Community list number (expanded)\n"
14748 "Specify expanded extcommunity-list\n"
14749 "Extended Community list name\n"
14750 "Specify community to reject\n"
14751 "Specify community to accept\n"
14752 "An ordered list as a regular-expression\n")
14754 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
14756 char *cl_number_or_name
= NULL
;
14759 if (argv_find(argv
, argc
, "ip", &idx
)) {
14760 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14761 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14762 vty_out(vty
, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
14763 zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
14766 argv_find(argv
, argc
, "(100-500)", &idx
);
14767 argv_find(argv
, argc
, "WORD", &idx
);
14768 cl_number_or_name
= argv
[idx
]->arg
;
14769 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14771 argv_find(argv
, argc
, "LINE", &idx
);
14772 char *str
= argv_concat(argv
, argc
, idx
);
14774 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14777 XFREE(MTYPE_TMP
, str
);
14780 community_list_perror(vty
, ret
);
14781 return CMD_WARNING_CONFIG_FAILED
;
14784 return CMD_SUCCESS
;
14787 ALIAS (extcommunity_list_name_expanded
,
14788 ip_extcommunity_list_name_expanded_cmd
,
14789 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14791 EXTCOMMUNITY_LIST_STR
14792 "Extended Community list number (expanded)\n"
14793 "Specify expanded extcommunity-list\n"
14794 "Extended Community list name\n"
14795 "Specify community to reject\n"
14796 "Specify community to accept\n"
14797 "An ordered list as a regular-expression\n")
14799 DEFUN (no_extcommunity_list_standard_all
,
14800 no_bgp_extcommunity_list_standard_all_cmd
,
14801 "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14804 EXTCOMMUNITY_LIST_STR
14805 "Extended Community list number (standard)\n"
14806 "Specify standard extcommunity-list\n"
14807 "Community list name\n"
14808 "Specify community to reject\n"
14809 "Specify community to accept\n"
14810 EXTCOMMUNITY_VAL_STR
)
14812 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14814 char *cl_number_or_name
= NULL
;
14817 if (argv_find(argv
, argc
, "ip", &idx
)) {
14818 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
14819 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14820 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
14821 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
14823 argv_find(argv
, argc
, "(1-99)", &idx
);
14824 argv_find(argv
, argc
, "WORD", &idx
);
14825 cl_number_or_name
= argv
[idx
]->arg
;
14826 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14828 argv_find(argv
, argc
, "AA:NN", &idx
);
14829 char *str
= argv_concat(argv
, argc
, idx
);
14831 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
14834 XFREE(MTYPE_TMP
, str
);
14837 community_list_perror(vty
, ret
);
14838 return CMD_WARNING_CONFIG_FAILED
;
14841 return CMD_SUCCESS
;
14844 ALIAS (no_extcommunity_list_standard_all
,
14845 no_ip_extcommunity_list_standard_all_cmd
,
14846 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14849 EXTCOMMUNITY_LIST_STR
14850 "Extended Community list number (standard)\n"
14851 "Specify standard extcommunity-list\n"
14852 "Community list name\n"
14853 "Specify community to reject\n"
14854 "Specify community to accept\n"
14855 EXTCOMMUNITY_VAL_STR
)
14857 DEFUN (no_extcommunity_list_expanded_all
,
14858 no_bgp_extcommunity_list_expanded_all_cmd
,
14859 "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14862 EXTCOMMUNITY_LIST_STR
14863 "Extended Community list number (expanded)\n"
14864 "Specify expanded extcommunity-list\n"
14865 "Extended Community list name\n"
14866 "Specify community to reject\n"
14867 "Specify community to accept\n"
14868 "An ordered list as a regular-expression\n")
14870 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
14872 char *cl_number_or_name
= NULL
;
14875 if (argv_find(argv
, argc
, "ip", &idx
)) {
14876 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14877 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14878 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
14879 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
14881 argv_find(argv
, argc
, "(100-500)", &idx
);
14882 argv_find(argv
, argc
, "WORD", &idx
);
14883 cl_number_or_name
= argv
[idx
]->arg
;
14884 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14886 argv_find(argv
, argc
, "LINE", &idx
);
14887 char *str
= argv_concat(argv
, argc
, idx
);
14889 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
14892 XFREE(MTYPE_TMP
, str
);
14895 community_list_perror(vty
, ret
);
14896 return CMD_WARNING_CONFIG_FAILED
;
14899 return CMD_SUCCESS
;
14902 ALIAS (no_extcommunity_list_expanded_all
,
14903 no_ip_extcommunity_list_expanded_all_cmd
,
14904 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14907 EXTCOMMUNITY_LIST_STR
14908 "Extended Community list number (expanded)\n"
14909 "Specify expanded extcommunity-list\n"
14910 "Extended Community list name\n"
14911 "Specify community to reject\n"
14912 "Specify community to accept\n"
14913 "An ordered list as a regular-expression\n")
14915 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14917 struct community_entry
*entry
;
14919 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14920 if (entry
== list
->head
) {
14921 if (all_digit(list
->name
))
14922 vty_out(vty
, "Extended community %s list %s\n",
14923 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14925 : "(expanded) access",
14929 "Named extended community %s list %s\n",
14930 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14936 vty_out(vty
, " %s\n",
14937 community_direct_str(entry
->direct
));
14939 vty_out(vty
, " %s %s\n",
14940 community_direct_str(entry
->direct
),
14941 community_list_config_str(entry
));
14945 DEFUN (show_extcommunity_list
,
14946 show_bgp_extcommunity_list_cmd
,
14947 "show bgp extcommunity-list",
14950 "List extended-community list\n")
14952 struct community_list
*list
;
14953 struct community_list_master
*cm
;
14956 if (argv_find(argv
, argc
, "ip", &idx
)) {
14957 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
14958 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14959 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
14960 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
14962 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
14964 return CMD_SUCCESS
;
14966 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14967 extcommunity_list_show(vty
, list
);
14969 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14970 extcommunity_list_show(vty
, list
);
14972 return CMD_SUCCESS
;
14975 ALIAS (show_extcommunity_list
,
14976 show_ip_extcommunity_list_cmd
,
14977 "show ip extcommunity-list",
14980 "List extended-community list\n")
14982 DEFUN (show_extcommunity_list_arg
,
14983 show_bgp_extcommunity_list_arg_cmd
,
14984 "show bgp extcommunity-list <(1-500)|WORD>",
14987 "List extended-community list\n"
14988 "Extcommunity-list number\n"
14989 "Extcommunity-list name\n")
14991 int idx_comm_list
= 3;
14992 struct community_list
*list
;
14995 if (argv_find(argv
, argc
, "ip", &idx
)) {
14996 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14997 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14998 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
14999 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15001 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
15002 EXTCOMMUNITY_LIST_MASTER
);
15004 vty_out(vty
, "%% Can't find extcommunity-list\n");
15005 return CMD_WARNING
;
15008 extcommunity_list_show(vty
, list
);
15010 return CMD_SUCCESS
;
15013 ALIAS (show_extcommunity_list_arg
,
15014 show_ip_extcommunity_list_arg_cmd
,
15015 "show ip extcommunity-list <(1-500)|WORD>",
15018 "List extended-community list\n"
15019 "Extcommunity-list number\n"
15020 "Extcommunity-list name\n")
15022 /* Display community-list and extcommunity-list configuration. */
15023 static int community_list_config_write(struct vty
*vty
)
15025 struct community_list
*list
;
15026 struct community_entry
*entry
;
15027 struct community_list_master
*cm
;
15030 /* Community-list. */
15031 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
15033 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15034 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15035 vty_out(vty
, "bgp community-list %s %s %s\n", list
->name
,
15036 community_direct_str(entry
->direct
),
15037 community_list_config_str(entry
));
15040 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15041 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15042 vty_out(vty
, "bgp community-list %s %s %s %s\n",
15043 entry
->style
== COMMUNITY_LIST_STANDARD
15046 list
->name
, community_direct_str(entry
->direct
),
15047 community_list_config_str(entry
));
15051 /* Extcommunity-list. */
15052 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15054 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15055 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15056 vty_out(vty
, "bgp extcommunity-list %s %s %s\n",
15057 list
->name
, community_direct_str(entry
->direct
),
15058 community_list_config_str(entry
));
15061 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15062 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15063 vty_out(vty
, "bgp extcommunity-list %s %s %s %s\n",
15064 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15067 list
->name
, community_direct_str(entry
->direct
),
15068 community_list_config_str(entry
));
15073 /* lcommunity-list. */
15074 cm
= community_list_master_lookup(bgp_clist
,
15075 LARGE_COMMUNITY_LIST_MASTER
);
15077 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15078 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15079 vty_out(vty
, "bgp large-community-list %s %s %s\n",
15080 list
->name
, community_direct_str(entry
->direct
),
15081 community_list_config_str(entry
));
15084 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15085 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15086 vty_out(vty
, "bgp large-community-list %s %s %s %s\n",
15087 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
15090 list
->name
, community_direct_str(entry
->direct
),
15091 community_list_config_str(entry
));
15098 static struct cmd_node community_list_node
= {
15099 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
15102 static void community_list_vty(void)
15104 install_node(&community_list_node
, community_list_config_write
);
15106 /* Community-list. */
15107 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
15108 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
15109 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
15110 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
15111 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
15112 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
15113 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
15114 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
15115 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
15116 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
15117 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
15118 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
15120 /* Extcommunity-list. */
15121 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
15122 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
15123 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
15124 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
15125 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
15126 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
15127 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
15128 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
15129 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
15130 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
15131 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
15132 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
15134 /* Large Community List */
15135 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
15136 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard1_cmd
);
15137 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
15138 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
15139 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard1_cmd
);
15140 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
15141 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_all_cmd
);
15142 install_element(CONFIG_NODE
,
15143 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
15144 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
15145 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
15146 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
15147 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
15148 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
15149 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
15150 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
15151 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
15152 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
15153 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
15154 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
15155 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
15156 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
15157 install_element(CONFIG_NODE
,
15158 &no_ip_lcommunity_list_name_expanded_all_cmd
);
15159 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
15160 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
15161 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
15162 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
15163 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
15164 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);