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"
38 #include "bgpd/bgpd.h"
39 #include "bgpd/bgp_advertise.h"
40 #include "bgpd/bgp_attr.h"
41 #include "bgpd/bgp_aspath.h"
42 #include "bgpd/bgp_community.h"
43 #include "bgpd/bgp_ecommunity.h"
44 #include "bgpd/bgp_lcommunity.h"
45 #include "bgpd/bgp_damp.h"
46 #include "bgpd/bgp_debug.h"
47 #include "bgpd/bgp_fsm.h"
48 #include "bgpd/bgp_nexthop.h"
49 #include "bgpd/bgp_open.h"
50 #include "bgpd/bgp_regex.h"
51 #include "bgpd/bgp_route.h"
52 #include "bgpd/bgp_mplsvpn.h"
53 #include "bgpd/bgp_zebra.h"
54 #include "bgpd/bgp_table.h"
55 #include "bgpd/bgp_vty.h"
56 #include "bgpd/bgp_mpath.h"
57 #include "bgpd/bgp_packet.h"
58 #include "bgpd/bgp_updgrp.h"
59 #include "bgpd/bgp_bfd.h"
60 #include "bgpd/bgp_io.h"
61 #include "bgpd/bgp_evpn.h"
63 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
64 struct prefix
*range
, int exact
);
66 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
75 return BGP_IPV4M_NODE
;
77 case SAFI_LABELED_UNICAST
:
78 return BGP_IPV4L_NODE
;
81 return BGP_VPNV4_NODE
;
84 return BGP_FLOWSPECV4_NODE
;
97 return BGP_IPV6M_NODE
;
99 case SAFI_LABELED_UNICAST
:
100 return BGP_IPV6L_NODE
;
103 return BGP_VPNV6_NODE
;
106 return BGP_FLOWSPECV6_NODE
;
109 return BGP_IPV4_NODE
;
114 return BGP_EVPN_NODE
;
117 // We should never be here but to clarify the switch statement..
118 return BGP_IPV4_NODE
;
122 // Impossible to happen
123 return BGP_IPV4_NODE
;
126 /* Utility function to get address family from current node. */
127 afi_t
bgp_node_afi(struct vty
*vty
)
135 case BGP_FLOWSPECV6_NODE
:
148 /* Utility function to get subsequent address family from current
150 safi_t
bgp_node_safi(struct vty
*vty
)
156 safi
= SAFI_MPLS_VPN
;
160 safi
= SAFI_MULTICAST
;
167 safi
= SAFI_LABELED_UNICAST
;
169 case BGP_FLOWSPECV4_NODE
:
170 case BGP_FLOWSPECV6_NODE
:
171 safi
= SAFI_FLOWSPEC
;
181 * Converts an AFI in string form to afi_t
183 * @param afi string, one of
186 * @return the corresponding afi_t
188 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
190 afi_t afi
= AFI_MAX
; /* unknown */
191 if (strmatch(afi_str
, "ipv4"))
193 else if (strmatch(afi_str
, "ipv6"))
198 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
202 if (argv_find(argv
, argc
, "ipv4", index
)) {
206 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
214 /* supports <unicast|multicast|vpn|labeled-unicast> */
215 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
217 safi_t safi
= SAFI_MAX
; /* unknown */
218 if (strmatch(safi_str
, "multicast"))
219 safi
= SAFI_MULTICAST
;
220 else if (strmatch(safi_str
, "unicast"))
222 else if (strmatch(safi_str
, "vpn"))
223 safi
= SAFI_MPLS_VPN
;
224 else if (strmatch(safi_str
, "labeled-unicast"))
225 safi
= SAFI_LABELED_UNICAST
;
226 else if (strmatch(safi_str
, "flowspec"))
227 safi
= SAFI_FLOWSPEC
;
231 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
235 if (argv_find(argv
, argc
, "unicast", index
)) {
238 *safi
= SAFI_UNICAST
;
239 } else if (argv_find(argv
, argc
, "multicast", index
)) {
242 *safi
= SAFI_MULTICAST
;
243 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
246 *safi
= SAFI_LABELED_UNICAST
;
247 } else if (argv_find(argv
, argc
, "vpn", index
)) {
250 *safi
= SAFI_MPLS_VPN
;
251 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
254 *safi
= SAFI_FLOWSPEC
;
260 * bgp_vty_find_and_parse_afi_safi_bgp
262 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
263 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
264 * to appropriate values for the calling function. This is to allow the
265 * calling function to make decisions appropriate for the show command
266 * that is being parsed.
268 * The show commands are generally of the form:
269 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
270 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
272 * Since we use argv_find if the show command in particular doesn't have:
274 * [<view|vrf> VIEWVRFNAME]
275 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
276 * The command parsing should still be ok.
278 * vty -> The vty for the command so we can output some useful data in
279 * the event of a parse error in the vrf.
280 * argv -> The command tokens
281 * argc -> How many command tokens we have
282 * idx -> The current place in the command, generally should be 0 for this
284 * afi -> The parsed afi if it was included in the show command, returned here
285 * safi -> The parsed safi if it was included in the show command, returned here
286 * bgp -> Pointer to the bgp data structure we need to fill in.
288 * The function returns the correct location in the parse tree for the
291 * Returns 0 for failure to parse correctly, else the idx position of where
292 * it found the last token.
294 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
295 struct cmd_token
**argv
, int argc
,
296 int *idx
, afi_t
*afi
, safi_t
*safi
,
299 char *vrf_name
= NULL
;
305 if (argv_find(argv
, argc
, "ip", idx
))
308 if (argv_find(argv
, argc
, "view", idx
)
309 || argv_find(argv
, argc
, "vrf", idx
)) {
310 vrf_name
= argv
[*idx
+ 1]->arg
;
312 if (strmatch(vrf_name
, "all"))
315 *bgp
= bgp_lookup_by_name(vrf_name
);
318 "View/Vrf specified is unknown: %s\n",
325 *bgp
= bgp_get_default();
327 vty_out(vty
, "Unable to find default BGP instance\n");
333 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
334 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
340 static int peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
342 struct interface
*ifp
= NULL
;
344 if (su
->sa
.sa_family
== AF_INET
)
345 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
346 else if (su
->sa
.sa_family
== AF_INET6
)
347 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
348 su
->sin6
.sin6_scope_id
,
357 /* Utility function for looking up peer from VTY. */
358 /* This is used only for configuration, so disallow if attempted on
359 * a dynamic neighbor.
361 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
363 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
372 ret
= str2sockunion(ip_str
, &su
);
374 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
376 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
379 "%% Malformed address or name: %s\n",
385 peer
= peer_lookup(bgp
, &su
);
388 "%% Specify remote-as or peer-group commands first\n");
391 if (peer_dynamic_neighbor(peer
)) {
393 "%% Operation not allowed on a dynamic neighbor\n");
400 /* Utility function for looking up peer or peer group. */
401 /* This is used only for configuration, so disallow if attempted on
402 * a dynamic neighbor.
404 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
406 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
409 struct peer
*peer
= NULL
;
410 struct peer_group
*group
= NULL
;
416 ret
= str2sockunion(peer_str
, &su
);
418 /* IP address, locate peer. */
419 peer
= peer_lookup(bgp
, &su
);
421 /* Not IP, could match either peer configured on interface or a
423 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
425 group
= peer_group_lookup(bgp
, peer_str
);
429 if (peer_dynamic_neighbor(peer
)) {
431 "%% Operation not allowed on a dynamic neighbor\n");
441 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
446 int bgp_vty_return(struct vty
*vty
, int ret
)
448 const char *str
= NULL
;
451 case BGP_ERR_INVALID_VALUE
:
452 str
= "Invalid value";
454 case BGP_ERR_INVALID_FLAG
:
455 str
= "Invalid flag";
457 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
458 str
= "Peer-group has been shutdown. Activate the peer-group first";
460 case BGP_ERR_PEER_FLAG_CONFLICT
:
461 str
= "Can't set override-capability and strict-capability-match at the same time";
463 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
464 str
= "Specify remote-as or peer-group remote AS first";
466 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
467 str
= "Cannot change the peer-group. Deconfigure first";
469 case BGP_ERR_PEER_GROUP_MISMATCH
:
470 str
= "Peer is not a member of this peer-group";
472 case BGP_ERR_PEER_FILTER_CONFLICT
:
473 str
= "Prefix/distribute list can not co-exist";
475 case BGP_ERR_NOT_INTERNAL_PEER
:
476 str
= "Invalid command. Not an internal neighbor";
478 case BGP_ERR_REMOVE_PRIVATE_AS
:
479 str
= "remove-private-AS cannot be configured for IBGP peers";
481 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
482 str
= "Local-AS allowed only for EBGP peers";
484 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
485 str
= "Cannot have local-as same as BGP AS number";
487 case BGP_ERR_TCPSIG_FAILED
:
488 str
= "Error while applying TCP-Sig to session(s)";
490 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
491 str
= "ebgp-multihop and ttl-security cannot be configured together";
493 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
494 str
= "ttl-security only allowed for EBGP peers";
496 case BGP_ERR_AS_OVERRIDE
:
497 str
= "as-override cannot be configured for IBGP peers";
499 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
500 str
= "Invalid limit for number of dynamic neighbors";
502 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
503 str
= "Dynamic neighbor listen range already exists";
505 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
506 str
= "Operation not allowed on a dynamic neighbor";
508 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
509 str
= "Operation not allowed on a directly connected neighbor";
511 case BGP_ERR_PEER_SAFI_CONFLICT
:
512 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
516 vty_out(vty
, "%% %s\n", str
);
517 return CMD_WARNING_CONFIG_FAILED
;
522 /* BGP clear sort. */
531 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
532 safi_t safi
, int error
)
535 case BGP_ERR_AF_UNCONFIGURED
:
537 "%%BGP: Enable %s address family for the neighbor %s\n",
538 afi_safi_print(afi
, safi
), peer
->host
);
540 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
542 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
550 /* `clear ip bgp' functions. */
551 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
552 enum clear_sort sort
, enum bgp_clear_type stype
,
557 struct listnode
*node
, *nnode
;
559 /* Clear all neighbors. */
561 * Pass along pointer to next node to peer_clear() when walking all
563 * on the BGP instance as that may get freed if it is a doppelganger
565 if (sort
== clear_all
) {
566 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
567 if (stype
== BGP_CLEAR_SOFT_NONE
)
568 ret
= peer_clear(peer
, &nnode
);
569 else if (peer
->afc
[afi
][safi
])
570 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
575 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
578 /* This is to apply read-only mode on this clear. */
579 if (stype
== BGP_CLEAR_SOFT_NONE
)
580 bgp
->update_delay_over
= 0;
585 /* Clear specified neighbors. */
586 if (sort
== clear_peer
) {
590 /* Make sockunion for lookup. */
591 ret
= str2sockunion(arg
, &su
);
593 peer
= peer_lookup_by_conf_if(bgp
, arg
);
595 peer
= peer_lookup_by_hostname(bgp
, arg
);
598 "Malformed address or name: %s\n",
604 peer
= peer_lookup(bgp
, &su
);
607 "%%BGP: Unknown neighbor - \"%s\"\n",
613 if (stype
== BGP_CLEAR_SOFT_NONE
)
614 ret
= peer_clear(peer
, NULL
);
616 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
619 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
624 /* Clear all peer-group members. */
625 if (sort
== clear_group
) {
626 struct peer_group
*group
;
628 group
= peer_group_lookup(bgp
, arg
);
630 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
634 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
635 if (stype
== BGP_CLEAR_SOFT_NONE
) {
636 peer_clear(peer
, NULL
);
640 if (!peer
->afc
[afi
][safi
])
643 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
646 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
651 if (sort
== clear_external
) {
652 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
653 if (peer
->sort
== BGP_PEER_IBGP
)
656 if (stype
== BGP_CLEAR_SOFT_NONE
)
657 ret
= peer_clear(peer
, &nnode
);
659 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
662 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
667 if (sort
== clear_as
) {
671 as
= strtoul(arg
, NULL
, 10);
673 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
678 if (stype
== BGP_CLEAR_SOFT_NONE
)
679 ret
= peer_clear(peer
, &nnode
);
681 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
684 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
688 "%%BGP: No peer is configured with AS %s\n",
696 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
697 safi_t safi
, enum clear_sort sort
,
698 enum bgp_clear_type stype
, const char *arg
)
702 /* BGP structure lookup. */
704 bgp
= bgp_lookup_by_name(name
);
706 vty_out(vty
, "Can't find BGP instance %s\n", name
);
710 bgp
= bgp_get_default();
712 vty_out(vty
, "No BGP process is configured\n");
717 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
720 /* clear soft inbound */
721 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
723 bgp_clear_vty(vty
, name
, AFI_IP
, SAFI_UNICAST
, clear_all
,
724 BGP_CLEAR_SOFT_IN
, NULL
);
725 bgp_clear_vty(vty
, name
, AFI_IP6
, SAFI_UNICAST
, clear_all
,
726 BGP_CLEAR_SOFT_IN
, NULL
);
729 /* clear soft outbound */
730 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
732 bgp_clear_vty(vty
, name
, AFI_IP
, SAFI_UNICAST
, clear_all
,
733 BGP_CLEAR_SOFT_OUT
, NULL
);
734 bgp_clear_vty(vty
, name
, AFI_IP6
, SAFI_UNICAST
, clear_all
,
735 BGP_CLEAR_SOFT_OUT
, NULL
);
739 #ifndef VTYSH_EXTRACT_PL
740 #include "bgpd/bgp_vty_clippy.c"
743 /* BGP global configuration. */
745 DEFUN (bgp_multiple_instance_func
,
746 bgp_multiple_instance_cmd
,
747 "bgp multiple-instance",
749 "Enable bgp multiple instance\n")
751 bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE
);
755 DEFUN (no_bgp_multiple_instance
,
756 no_bgp_multiple_instance_cmd
,
757 "no bgp multiple-instance",
760 "BGP multiple instance\n")
764 ret
= bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE
);
766 vty_out(vty
, "%% There are more than two BGP instances\n");
767 return CMD_WARNING_CONFIG_FAILED
;
772 DEFUN (bgp_config_type
,
774 "bgp config-type <cisco|zebra>",
776 "Configuration type\n"
781 if (argv_find(argv
, argc
, "cisco", &idx
))
782 bgp_option_set(BGP_OPT_CONFIG_CISCO
);
784 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
789 DEFUN (no_bgp_config_type
,
790 no_bgp_config_type_cmd
,
791 "no bgp config-type [<cisco|zebra>]",
794 "Display configuration type\n"
798 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
803 DEFUN (no_synchronization
,
804 no_synchronization_cmd
,
805 "no synchronization",
807 "Perform IGP synchronization\n")
812 DEFUN (no_auto_summary
,
816 "Enable automatic network number summarization\n")
821 /* "router bgp" commands. */
822 DEFUN_NOSH (router_bgp
,
824 "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
828 BGP_INSTANCE_HELP_STR
)
831 int idx_view_vrf
= 3;
836 const char *name
= NULL
;
837 enum bgp_instance_type inst_type
;
839 // "router bgp" without an ASN
841 // Pending: Make VRF option available for ASN less config
842 bgp
= bgp_get_default();
845 vty_out(vty
, "%% No BGP process is configured\n");
846 return CMD_WARNING_CONFIG_FAILED
;
849 if (listcount(bm
->bgp
) > 1) {
850 vty_out(vty
, "%% Please specify ASN and VRF\n");
851 return CMD_WARNING_CONFIG_FAILED
;
857 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
859 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
861 name
= argv
[idx_vrf
]->arg
;
863 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf"))
864 inst_type
= BGP_INSTANCE_TYPE_VRF
;
865 else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
866 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
869 ret
= bgp_get(&bgp
, &as
, name
, inst_type
);
871 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET
:
873 "Please specify 'bgp multiple-instance' first\n");
874 return CMD_WARNING_CONFIG_FAILED
;
875 case BGP_ERR_AS_MISMATCH
:
876 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
877 return CMD_WARNING_CONFIG_FAILED
;
878 case BGP_ERR_INSTANCE_MISMATCH
:
880 "BGP instance name and AS number mismatch\n");
882 "BGP instance is already running; AS is %u\n",
884 return CMD_WARNING_CONFIG_FAILED
;
887 /* Pending: handle when user tries to change a view to vrf n vv.
891 /* unset the auto created flag as the user config is now present */
892 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
893 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
898 /* "no router bgp" commands. */
899 DEFUN (no_router_bgp
,
901 "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
906 BGP_INSTANCE_HELP_STR
)
912 const char *name
= NULL
;
914 // "no router bgp" without an ASN
916 // Pending: Make VRF option available for ASN less config
917 bgp
= bgp_get_default();
920 vty_out(vty
, "%% No BGP process is configured\n");
921 return CMD_WARNING_CONFIG_FAILED
;
924 if (listcount(bm
->bgp
) > 1) {
925 vty_out(vty
, "%% Please specify ASN and VRF\n");
926 return CMD_WARNING_CONFIG_FAILED
;
930 vty_out(vty
, "%% Please unconfigure l3vni %u",
932 return CMD_WARNING_CONFIG_FAILED
;
935 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
938 name
= argv
[idx_vrf
]->arg
;
940 /* Lookup bgp structure. */
941 bgp
= bgp_lookup(as
, name
);
943 vty_out(vty
, "%% Can't find BGP instance\n");
944 return CMD_WARNING_CONFIG_FAILED
;
948 vty_out(vty
, "%% Please unconfigure l3vni %u",
950 return CMD_WARNING_CONFIG_FAILED
;
962 DEFPY (bgp_router_id
,
964 "bgp router-id A.B.C.D",
966 "Override configured router identifier\n"
967 "Manually configured router identifier\n")
969 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
970 bgp_router_id_static_set(bgp
, router_id
);
974 DEFPY (no_bgp_router_id
,
975 no_bgp_router_id_cmd
,
976 "no bgp router-id [A.B.C.D]",
979 "Override configured router identifier\n"
980 "Manually configured router identifier\n")
982 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
985 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
986 vty_out(vty
, "%% BGP router-id doesn't match\n");
987 return CMD_WARNING_CONFIG_FAILED
;
991 router_id
.s_addr
= 0;
992 bgp_router_id_static_set(bgp
, router_id
);
998 /* BGP Cluster ID. */
999 DEFUN (bgp_cluster_id
,
1001 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1003 "Configure Route-Reflector Cluster-id\n"
1004 "Route-Reflector Cluster-id in IP address format\n"
1005 "Route-Reflector Cluster-id as 32 bit quantity\n")
1007 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1010 struct in_addr cluster
;
1012 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1014 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1015 return CMD_WARNING_CONFIG_FAILED
;
1018 bgp_cluster_id_set(bgp
, &cluster
);
1019 bgp_clear_star_soft_out(vty
, bgp
->name
);
1024 DEFUN (no_bgp_cluster_id
,
1025 no_bgp_cluster_id_cmd
,
1026 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1029 "Configure Route-Reflector Cluster-id\n"
1030 "Route-Reflector Cluster-id in IP address format\n"
1031 "Route-Reflector Cluster-id as 32 bit quantity\n")
1033 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1034 bgp_cluster_id_unset(bgp
);
1035 bgp_clear_star_soft_out(vty
, bgp
->name
);
1040 DEFUN (bgp_confederation_identifier
,
1041 bgp_confederation_identifier_cmd
,
1042 "bgp confederation identifier (1-4294967295)",
1043 "BGP specific commands\n"
1044 "AS confederation parameters\n"
1046 "Set routing domain confederation AS\n")
1048 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1052 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1054 bgp_confederation_id_set(bgp
, as
);
1059 DEFUN (no_bgp_confederation_identifier
,
1060 no_bgp_confederation_identifier_cmd
,
1061 "no bgp confederation identifier [(1-4294967295)]",
1063 "BGP specific commands\n"
1064 "AS confederation parameters\n"
1066 "Set routing domain confederation AS\n")
1068 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1069 bgp_confederation_id_unset(bgp
);
1074 DEFUN (bgp_confederation_peers
,
1075 bgp_confederation_peers_cmd
,
1076 "bgp confederation peers (1-4294967295)...",
1077 "BGP specific commands\n"
1078 "AS confederation parameters\n"
1079 "Peer ASs in BGP confederation\n"
1082 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1087 for (i
= idx_asn
; i
< argc
; i
++) {
1088 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1090 if (bgp
->as
== as
) {
1092 "%% Local member-AS not allowed in confed peer list\n");
1096 bgp_confederation_peers_add(bgp
, as
);
1101 DEFUN (no_bgp_confederation_peers
,
1102 no_bgp_confederation_peers_cmd
,
1103 "no bgp confederation peers (1-4294967295)...",
1105 "BGP specific commands\n"
1106 "AS confederation parameters\n"
1107 "Peer ASs in BGP confederation\n"
1110 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1115 for (i
= idx_asn
; i
< argc
; i
++) {
1116 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1118 bgp_confederation_peers_remove(bgp
, as
);
1124 * Central routine for maximum-paths configuration.
1125 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1126 * @set: 1 for setting values, 0 for removing the max-paths config.
1128 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1129 const char *mpaths
, uint16_t options
,
1132 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1133 uint16_t maxpaths
= 0;
1138 afi
= bgp_node_afi(vty
);
1139 safi
= bgp_node_safi(vty
);
1142 maxpaths
= strtol(mpaths
, NULL
, 10);
1143 if (maxpaths
> multipath_num
) {
1145 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1146 maxpaths
, multipath_num
);
1147 return CMD_WARNING_CONFIG_FAILED
;
1149 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1152 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1156 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1157 (set
== 1) ? "" : "un",
1158 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1159 maxpaths
, afi
, safi
);
1160 return CMD_WARNING_CONFIG_FAILED
;
1163 bgp_recalculate_all_bestpaths(bgp
);
1168 DEFUN (bgp_maxmed_admin
,
1169 bgp_maxmed_admin_cmd
,
1170 "bgp max-med administrative ",
1172 "Advertise routes with max-med\n"
1173 "Administratively applied, for an indefinite period\n")
1175 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1177 bgp
->v_maxmed_admin
= 1;
1178 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1180 bgp_maxmed_update(bgp
);
1185 DEFUN (bgp_maxmed_admin_medv
,
1186 bgp_maxmed_admin_medv_cmd
,
1187 "bgp max-med administrative (0-4294967295)",
1189 "Advertise routes with max-med\n"
1190 "Administratively applied, for an indefinite period\n"
1191 "Max MED value to be used\n")
1193 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1196 bgp
->v_maxmed_admin
= 1;
1197 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1199 bgp_maxmed_update(bgp
);
1204 DEFUN (no_bgp_maxmed_admin
,
1205 no_bgp_maxmed_admin_cmd
,
1206 "no bgp max-med administrative [(0-4294967295)]",
1209 "Advertise routes with max-med\n"
1210 "Administratively applied, for an indefinite period\n"
1211 "Max MED value to be used\n")
1213 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1214 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1215 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1216 bgp_maxmed_update(bgp
);
1221 DEFUN (bgp_maxmed_onstartup
,
1222 bgp_maxmed_onstartup_cmd
,
1223 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1225 "Advertise routes with max-med\n"
1226 "Effective on a startup\n"
1227 "Time (seconds) period for max-med\n"
1228 "Max MED value to be used\n")
1230 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1233 argv_find(argv
, argc
, "(5-86400)", &idx
);
1234 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1235 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1236 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1238 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1240 bgp_maxmed_update(bgp
);
1245 DEFUN (no_bgp_maxmed_onstartup
,
1246 no_bgp_maxmed_onstartup_cmd
,
1247 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1250 "Advertise routes with max-med\n"
1251 "Effective on a startup\n"
1252 "Time (seconds) period for max-med\n"
1253 "Max MED value to be used\n")
1255 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1257 /* Cancel max-med onstartup if its on */
1258 if (bgp
->t_maxmed_onstartup
) {
1259 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1260 bgp
->maxmed_onstartup_over
= 1;
1263 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1264 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1266 bgp_maxmed_update(bgp
);
1271 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1274 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1275 uint16_t update_delay
;
1276 uint16_t establish_wait
;
1278 update_delay
= strtoul(delay
, NULL
, 10);
1280 if (!wait
) /* update-delay <delay> */
1282 bgp
->v_update_delay
= update_delay
;
1283 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1287 /* update-delay <delay> <establish-wait> */
1288 establish_wait
= atoi(wait
);
1289 if (update_delay
< establish_wait
) {
1291 "%%Failed: update-delay less than the establish-wait!\n");
1292 return CMD_WARNING_CONFIG_FAILED
;
1295 bgp
->v_update_delay
= update_delay
;
1296 bgp
->v_establish_wait
= establish_wait
;
1301 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1303 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1305 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1306 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1311 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1313 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1314 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1315 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1316 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1322 /* Update-delay configuration */
1323 DEFUN (bgp_update_delay
,
1324 bgp_update_delay_cmd
,
1325 "update-delay (0-3600)",
1326 "Force initial delay for best-path and updates\n"
1330 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1333 DEFUN (bgp_update_delay_establish_wait
,
1334 bgp_update_delay_establish_wait_cmd
,
1335 "update-delay (0-3600) (1-3600)",
1336 "Force initial delay for best-path and updates\n"
1341 int idx_number_2
= 2;
1342 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1343 argv
[idx_number_2
]->arg
);
1346 /* Update-delay deconfiguration */
1347 DEFUN (no_bgp_update_delay
,
1348 no_bgp_update_delay_cmd
,
1349 "no update-delay [(0-3600) [(1-3600)]]",
1351 "Force initial delay for best-path and updates\n"
1355 return bgp_update_delay_deconfig_vty(vty
);
1359 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1362 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1365 uint32_t quanta
= strtoul(num
, NULL
, 10);
1366 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
,
1367 memory_order_relaxed
);
1369 atomic_store_explicit(&bgp
->wpkt_quanta
, BGP_WRITE_PACKET_MAX
,
1370 memory_order_relaxed
);
1376 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1379 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1382 uint32_t quanta
= strtoul(num
, NULL
, 10);
1383 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
,
1384 memory_order_relaxed
);
1386 atomic_store_explicit(&bgp
->rpkt_quanta
, BGP_READ_PACKET_MAX
,
1387 memory_order_relaxed
);
1393 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1396 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1397 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1398 vty_out(vty
, " write-quanta %d\n", quanta
);
1401 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1404 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1405 if (quanta
!= BGP_READ_PACKET_MAX
)
1406 vty_out(vty
, " read-quanta %d\n", quanta
);
1409 /* Packet quanta configuration */
1410 DEFUN (bgp_wpkt_quanta
,
1411 bgp_wpkt_quanta_cmd
,
1412 "write-quanta (1-10)",
1413 "How many packets to write to peer socket per run\n"
1414 "Number of packets\n")
1417 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1420 DEFUN (no_bgp_wpkt_quanta
,
1421 no_bgp_wpkt_quanta_cmd
,
1422 "no write-quanta (1-10)",
1424 "How many packets to write to peer socket per I/O cycle\n"
1425 "Number of packets\n")
1428 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1431 DEFUN (bgp_rpkt_quanta
,
1432 bgp_rpkt_quanta_cmd
,
1433 "read-quanta (1-10)",
1434 "How many packets to read from peer socket per I/O cycle\n"
1435 "Number of packets\n")
1438 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1441 DEFUN (no_bgp_rpkt_quanta
,
1442 no_bgp_rpkt_quanta_cmd
,
1443 "no read-quanta (1-10)",
1445 "How many packets to read from peer socket per I/O cycle\n"
1446 "Number of packets\n")
1449 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1452 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1454 if (!bgp
->heuristic_coalesce
)
1455 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1459 DEFUN (bgp_coalesce_time
,
1460 bgp_coalesce_time_cmd
,
1461 "coalesce-time (0-4294967295)",
1462 "Subgroup coalesce timer\n"
1463 "Subgroup coalesce timer value (in ms)\n")
1465 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1468 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1469 bgp
->heuristic_coalesce
= false;
1470 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1474 DEFUN (no_bgp_coalesce_time
,
1475 no_bgp_coalesce_time_cmd
,
1476 "no coalesce-time (0-4294967295)",
1478 "Subgroup coalesce timer\n"
1479 "Subgroup coalesce timer value (in ms)\n")
1481 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1483 bgp
->heuristic_coalesce
= true;
1484 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1488 /* Maximum-paths configuration */
1489 DEFUN (bgp_maxpaths
,
1491 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1492 "Forward packets over multiple paths\n"
1493 "Number of paths\n")
1496 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1497 argv
[idx_number
]->arg
, 0, 1);
1500 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1501 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1502 "Forward packets over multiple paths\n"
1503 "Number of paths\n")
1505 DEFUN (bgp_maxpaths_ibgp
,
1506 bgp_maxpaths_ibgp_cmd
,
1507 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1508 "Forward packets over multiple paths\n"
1510 "Number of paths\n")
1513 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1514 argv
[idx_number
]->arg
, 0, 1);
1517 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1518 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1519 "Forward packets over multiple paths\n"
1521 "Number of paths\n")
1523 DEFUN (bgp_maxpaths_ibgp_cluster
,
1524 bgp_maxpaths_ibgp_cluster_cmd
,
1525 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1526 "Forward packets over multiple paths\n"
1529 "Match the cluster length\n")
1532 return bgp_maxpaths_config_vty(
1533 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1534 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1537 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1538 "maximum-paths ibgp " CMD_RANGE_STR(
1539 1, MULTIPATH_NUM
) " equal-cluster-length",
1540 "Forward packets over multiple paths\n"
1543 "Match the cluster length\n")
1545 DEFUN (no_bgp_maxpaths
,
1546 no_bgp_maxpaths_cmd
,
1547 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1549 "Forward packets over multiple paths\n"
1550 "Number of paths\n")
1552 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1555 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1556 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1557 "Forward packets over multiple paths\n"
1558 "Number of paths\n")
1560 DEFUN (no_bgp_maxpaths_ibgp
,
1561 no_bgp_maxpaths_ibgp_cmd
,
1562 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1564 "Forward packets over multiple paths\n"
1567 "Match the cluster length\n")
1569 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1572 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1573 "no maximum-paths ibgp [" CMD_RANGE_STR(
1574 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1576 "Forward packets over multiple paths\n"
1579 "Match the cluster length\n")
1581 void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1584 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1585 vty_out(vty
, " maximum-paths %d\n",
1586 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1589 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1590 vty_out(vty
, " maximum-paths ibgp %d",
1591 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1592 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1593 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1594 vty_out(vty
, " equal-cluster-length");
1603 "timers bgp (0-65535) (0-65535)",
1604 "Adjust routing timers\n"
1606 "Keepalive interval\n"
1609 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1611 int idx_number_2
= 3;
1612 unsigned long keepalive
= 0;
1613 unsigned long holdtime
= 0;
1615 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1616 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1618 /* Holdtime value check. */
1619 if (holdtime
< 3 && holdtime
!= 0) {
1621 "%% hold time value must be either 0 or greater than 3\n");
1622 return CMD_WARNING_CONFIG_FAILED
;
1625 bgp_timers_set(bgp
, keepalive
, holdtime
);
1630 DEFUN (no_bgp_timers
,
1632 "no timers bgp [(0-65535) (0-65535)]",
1634 "Adjust routing timers\n"
1636 "Keepalive interval\n"
1639 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1640 bgp_timers_unset(bgp
);
1646 DEFUN (bgp_client_to_client_reflection
,
1647 bgp_client_to_client_reflection_cmd
,
1648 "bgp client-to-client reflection",
1649 "BGP specific commands\n"
1650 "Configure client to client route reflection\n"
1651 "reflection of routes allowed\n")
1653 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1654 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1655 bgp_clear_star_soft_out(vty
, bgp
->name
);
1660 DEFUN (no_bgp_client_to_client_reflection
,
1661 no_bgp_client_to_client_reflection_cmd
,
1662 "no bgp client-to-client reflection",
1664 "BGP specific commands\n"
1665 "Configure client to client route reflection\n"
1666 "reflection of routes allowed\n")
1668 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1669 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1670 bgp_clear_star_soft_out(vty
, bgp
->name
);
1675 /* "bgp always-compare-med" configuration. */
1676 DEFUN (bgp_always_compare_med
,
1677 bgp_always_compare_med_cmd
,
1678 "bgp always-compare-med",
1679 "BGP specific commands\n"
1680 "Allow comparing MED from different neighbors\n")
1682 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1683 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1684 bgp_recalculate_all_bestpaths(bgp
);
1689 DEFUN (no_bgp_always_compare_med
,
1690 no_bgp_always_compare_med_cmd
,
1691 "no bgp always-compare-med",
1693 "BGP specific commands\n"
1694 "Allow comparing MED from different neighbors\n")
1696 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1697 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1698 bgp_recalculate_all_bestpaths(bgp
);
1703 /* "bgp deterministic-med" configuration. */
1704 DEFUN (bgp_deterministic_med
,
1705 bgp_deterministic_med_cmd
,
1706 "bgp deterministic-med",
1707 "BGP specific commands\n"
1708 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1710 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1712 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1713 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1714 bgp_recalculate_all_bestpaths(bgp
);
1720 DEFUN (no_bgp_deterministic_med
,
1721 no_bgp_deterministic_med_cmd
,
1722 "no bgp deterministic-med",
1724 "BGP specific commands\n"
1725 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1727 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1728 int bestpath_per_as_used
;
1732 struct listnode
*node
, *nnode
;
1734 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1735 bestpath_per_as_used
= 0;
1737 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1738 FOREACH_AFI_SAFI (afi
, safi
)
1740 peer
->af_flags
[afi
][safi
],
1741 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
)) {
1742 bestpath_per_as_used
= 1;
1746 if (bestpath_per_as_used
)
1750 if (bestpath_per_as_used
) {
1752 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
1753 return CMD_WARNING_CONFIG_FAILED
;
1755 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1756 bgp_recalculate_all_bestpaths(bgp
);
1763 /* "bgp graceful-restart" configuration. */
1764 DEFUN (bgp_graceful_restart
,
1765 bgp_graceful_restart_cmd
,
1766 "bgp graceful-restart",
1767 "BGP specific commands\n"
1768 "Graceful restart capability parameters\n")
1770 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1771 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1775 DEFUN (no_bgp_graceful_restart
,
1776 no_bgp_graceful_restart_cmd
,
1777 "no bgp graceful-restart",
1779 "BGP specific commands\n"
1780 "Graceful restart capability parameters\n")
1782 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1783 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1787 DEFUN (bgp_graceful_restart_stalepath_time
,
1788 bgp_graceful_restart_stalepath_time_cmd
,
1789 "bgp graceful-restart stalepath-time (1-3600)",
1790 "BGP specific commands\n"
1791 "Graceful restart capability parameters\n"
1792 "Set the max time to hold onto restarting peer's stale paths\n"
1793 "Delay value (seconds)\n")
1795 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1799 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1800 bgp
->stalepath_time
= stalepath
;
1804 DEFUN (bgp_graceful_restart_restart_time
,
1805 bgp_graceful_restart_restart_time_cmd
,
1806 "bgp graceful-restart restart-time (1-3600)",
1807 "BGP specific commands\n"
1808 "Graceful restart capability parameters\n"
1809 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1810 "Delay value (seconds)\n")
1812 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1816 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1817 bgp
->restart_time
= restart
;
1821 DEFUN (no_bgp_graceful_restart_stalepath_time
,
1822 no_bgp_graceful_restart_stalepath_time_cmd
,
1823 "no bgp graceful-restart stalepath-time [(1-3600)]",
1825 "BGP specific commands\n"
1826 "Graceful restart capability parameters\n"
1827 "Set the max time to hold onto restarting peer's stale paths\n"
1828 "Delay value (seconds)\n")
1830 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1832 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
1836 DEFUN (no_bgp_graceful_restart_restart_time
,
1837 no_bgp_graceful_restart_restart_time_cmd
,
1838 "no bgp graceful-restart restart-time [(1-3600)]",
1840 "BGP specific commands\n"
1841 "Graceful restart capability parameters\n"
1842 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1843 "Delay value (seconds)\n")
1845 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1847 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
1851 DEFUN (bgp_graceful_restart_preserve_fw
,
1852 bgp_graceful_restart_preserve_fw_cmd
,
1853 "bgp graceful-restart preserve-fw-state",
1854 "BGP specific commands\n"
1855 "Graceful restart capability parameters\n"
1856 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
1858 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1859 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
1863 DEFUN (no_bgp_graceful_restart_preserve_fw
,
1864 no_bgp_graceful_restart_preserve_fw_cmd
,
1865 "no bgp graceful-restart preserve-fw-state",
1867 "BGP specific commands\n"
1868 "Graceful restart capability parameters\n"
1869 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
1871 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1872 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
1876 static void bgp_redistribute_redo(struct bgp
*bgp
)
1880 struct list
*red_list
;
1881 struct listnode
*node
;
1882 struct bgp_redist
*red
;
1884 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
1885 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
1887 red_list
= bgp
->redist
[afi
][i
];
1891 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
1892 bgp_redistribute_resend(bgp
, afi
, i
,
1899 /* "bgp graceful-shutdown" configuration */
1900 DEFUN (bgp_graceful_shutdown
,
1901 bgp_graceful_shutdown_cmd
,
1902 "bgp graceful-shutdown",
1904 "Graceful shutdown parameters\n")
1906 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1908 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
1909 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
1910 bgp_static_redo_import_check(bgp
);
1911 bgp_redistribute_redo(bgp
);
1912 bgp_clear_star_soft_out(vty
, bgp
->name
);
1913 bgp_clear_star_soft_in(vty
, bgp
->name
);
1919 DEFUN (no_bgp_graceful_shutdown
,
1920 no_bgp_graceful_shutdown_cmd
,
1921 "no bgp graceful-shutdown",
1924 "Graceful shutdown parameters\n")
1926 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1928 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
1929 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
1930 bgp_static_redo_import_check(bgp
);
1931 bgp_redistribute_redo(bgp
);
1932 bgp_clear_star_soft_out(vty
, bgp
->name
);
1933 bgp_clear_star_soft_in(vty
, bgp
->name
);
1939 /* "bgp fast-external-failover" configuration. */
1940 DEFUN (bgp_fast_external_failover
,
1941 bgp_fast_external_failover_cmd
,
1942 "bgp fast-external-failover",
1944 "Immediately reset session if a link to a directly connected external peer goes down\n")
1946 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1947 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
1951 DEFUN (no_bgp_fast_external_failover
,
1952 no_bgp_fast_external_failover_cmd
,
1953 "no bgp fast-external-failover",
1956 "Immediately reset session if a link to a directly connected external peer goes down\n")
1958 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1959 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
1963 /* "bgp enforce-first-as" configuration. */
1964 DEFUN (bgp_enforce_first_as
,
1965 bgp_enforce_first_as_cmd
,
1966 "bgp enforce-first-as",
1968 "Enforce the first AS for EBGP routes\n")
1970 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1971 bgp_flag_set(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
1972 bgp_clear_star_soft_in(vty
, bgp
->name
);
1977 DEFUN (no_bgp_enforce_first_as
,
1978 no_bgp_enforce_first_as_cmd
,
1979 "no bgp enforce-first-as",
1982 "Enforce the first AS for EBGP routes\n")
1984 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1985 bgp_flag_unset(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
1986 bgp_clear_star_soft_in(vty
, bgp
->name
);
1991 /* "bgp bestpath compare-routerid" configuration. */
1992 DEFUN (bgp_bestpath_compare_router_id
,
1993 bgp_bestpath_compare_router_id_cmd
,
1994 "bgp bestpath compare-routerid",
1995 "BGP specific commands\n"
1996 "Change the default bestpath selection\n"
1997 "Compare router-id for identical EBGP paths\n")
1999 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2000 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2001 bgp_recalculate_all_bestpaths(bgp
);
2006 DEFUN (no_bgp_bestpath_compare_router_id
,
2007 no_bgp_bestpath_compare_router_id_cmd
,
2008 "no bgp bestpath compare-routerid",
2010 "BGP specific commands\n"
2011 "Change the default bestpath selection\n"
2012 "Compare router-id for identical EBGP paths\n")
2014 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2015 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2016 bgp_recalculate_all_bestpaths(bgp
);
2021 /* "bgp bestpath as-path ignore" configuration. */
2022 DEFUN (bgp_bestpath_aspath_ignore
,
2023 bgp_bestpath_aspath_ignore_cmd
,
2024 "bgp bestpath as-path ignore",
2025 "BGP specific commands\n"
2026 "Change the default bestpath selection\n"
2027 "AS-path attribute\n"
2028 "Ignore as-path length in selecting a route\n")
2030 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2031 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2032 bgp_recalculate_all_bestpaths(bgp
);
2037 DEFUN (no_bgp_bestpath_aspath_ignore
,
2038 no_bgp_bestpath_aspath_ignore_cmd
,
2039 "no bgp bestpath as-path ignore",
2041 "BGP specific commands\n"
2042 "Change the default bestpath selection\n"
2043 "AS-path attribute\n"
2044 "Ignore as-path length in selecting a route\n")
2046 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2047 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2048 bgp_recalculate_all_bestpaths(bgp
);
2053 /* "bgp bestpath as-path confed" configuration. */
2054 DEFUN (bgp_bestpath_aspath_confed
,
2055 bgp_bestpath_aspath_confed_cmd
,
2056 "bgp bestpath as-path confed",
2057 "BGP specific commands\n"
2058 "Change the default bestpath selection\n"
2059 "AS-path attribute\n"
2060 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2062 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2063 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2064 bgp_recalculate_all_bestpaths(bgp
);
2069 DEFUN (no_bgp_bestpath_aspath_confed
,
2070 no_bgp_bestpath_aspath_confed_cmd
,
2071 "no bgp bestpath as-path confed",
2073 "BGP specific commands\n"
2074 "Change the default bestpath selection\n"
2075 "AS-path attribute\n"
2076 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2078 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2079 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2080 bgp_recalculate_all_bestpaths(bgp
);
2085 /* "bgp bestpath as-path multipath-relax" configuration. */
2086 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2087 bgp_bestpath_aspath_multipath_relax_cmd
,
2088 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2089 "BGP specific commands\n"
2090 "Change the default bestpath selection\n"
2091 "AS-path attribute\n"
2092 "Allow load sharing across routes that have different AS paths (but same length)\n"
2093 "Generate an AS_SET\n"
2094 "Do not generate an AS_SET\n")
2096 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2098 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2100 /* no-as-set is now the default behavior so we can silently
2102 if (argv_find(argv
, argc
, "as-set", &idx
))
2103 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2105 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2107 bgp_recalculate_all_bestpaths(bgp
);
2112 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2113 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2114 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2116 "BGP specific commands\n"
2117 "Change the default bestpath selection\n"
2118 "AS-path attribute\n"
2119 "Allow load sharing across routes that have different AS paths (but same length)\n"
2120 "Generate an AS_SET\n"
2121 "Do not generate an AS_SET\n")
2123 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2124 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2125 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2126 bgp_recalculate_all_bestpaths(bgp
);
2131 /* "bgp log-neighbor-changes" configuration. */
2132 DEFUN (bgp_log_neighbor_changes
,
2133 bgp_log_neighbor_changes_cmd
,
2134 "bgp log-neighbor-changes",
2135 "BGP specific commands\n"
2136 "Log neighbor up/down and reset reason\n")
2138 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2139 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2143 DEFUN (no_bgp_log_neighbor_changes
,
2144 no_bgp_log_neighbor_changes_cmd
,
2145 "no bgp log-neighbor-changes",
2147 "BGP specific commands\n"
2148 "Log neighbor up/down and reset reason\n")
2150 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2151 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2155 /* "bgp bestpath med" configuration. */
2156 DEFUN (bgp_bestpath_med
,
2157 bgp_bestpath_med_cmd
,
2158 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2159 "BGP specific commands\n"
2160 "Change the default bestpath selection\n"
2162 "Compare MED among confederation paths\n"
2163 "Treat missing MED as the least preferred one\n"
2164 "Treat missing MED as the least preferred one\n"
2165 "Compare MED among confederation paths\n")
2167 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2170 if (argv_find(argv
, argc
, "confed", &idx
))
2171 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2173 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2174 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2176 bgp_recalculate_all_bestpaths(bgp
);
2181 DEFUN (no_bgp_bestpath_med
,
2182 no_bgp_bestpath_med_cmd
,
2183 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2185 "BGP specific commands\n"
2186 "Change the default bestpath selection\n"
2188 "Compare MED among confederation paths\n"
2189 "Treat missing MED as the least preferred one\n"
2190 "Treat missing MED as the least preferred one\n"
2191 "Compare MED among confederation paths\n")
2193 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2196 if (argv_find(argv
, argc
, "confed", &idx
))
2197 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2199 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2200 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2202 bgp_recalculate_all_bestpaths(bgp
);
2207 /* "no bgp default ipv4-unicast". */
2208 DEFUN (no_bgp_default_ipv4_unicast
,
2209 no_bgp_default_ipv4_unicast_cmd
,
2210 "no bgp default ipv4-unicast",
2212 "BGP specific commands\n"
2213 "Configure BGP defaults\n"
2214 "Activate ipv4-unicast for a peer by default\n")
2216 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2217 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2221 DEFUN (bgp_default_ipv4_unicast
,
2222 bgp_default_ipv4_unicast_cmd
,
2223 "bgp default ipv4-unicast",
2224 "BGP specific commands\n"
2225 "Configure BGP defaults\n"
2226 "Activate ipv4-unicast for a peer by default\n")
2228 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2229 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2233 /* Display hostname in certain command outputs */
2234 DEFUN (bgp_default_show_hostname
,
2235 bgp_default_show_hostname_cmd
,
2236 "bgp default show-hostname",
2237 "BGP specific commands\n"
2238 "Configure BGP defaults\n"
2239 "Show hostname in certain command ouputs\n")
2241 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2242 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2246 DEFUN (no_bgp_default_show_hostname
,
2247 no_bgp_default_show_hostname_cmd
,
2248 "no bgp default show-hostname",
2250 "BGP specific commands\n"
2251 "Configure BGP defaults\n"
2252 "Show hostname in certain command ouputs\n")
2254 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2255 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2259 /* "bgp network import-check" configuration. */
2260 DEFUN (bgp_network_import_check
,
2261 bgp_network_import_check_cmd
,
2262 "bgp network import-check",
2263 "BGP specific commands\n"
2264 "BGP network command\n"
2265 "Check BGP network route exists in IGP\n")
2267 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2268 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2269 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2270 bgp_static_redo_import_check(bgp
);
2276 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2277 "bgp network import-check exact",
2278 "BGP specific commands\n"
2279 "BGP network command\n"
2280 "Check BGP network route exists in IGP\n"
2281 "Match route precisely\n")
2283 DEFUN (no_bgp_network_import_check
,
2284 no_bgp_network_import_check_cmd
,
2285 "no bgp network import-check",
2287 "BGP specific commands\n"
2288 "BGP network command\n"
2289 "Check BGP network route exists in IGP\n")
2291 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2292 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2293 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2294 bgp_static_redo_import_check(bgp
);
2300 DEFUN (bgp_default_local_preference
,
2301 bgp_default_local_preference_cmd
,
2302 "bgp default local-preference (0-4294967295)",
2303 "BGP specific commands\n"
2304 "Configure BGP defaults\n"
2305 "local preference (higher=more preferred)\n"
2306 "Configure default local preference value\n")
2308 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2310 uint32_t local_pref
;
2312 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2314 bgp_default_local_preference_set(bgp
, local_pref
);
2315 bgp_clear_star_soft_in(vty
, bgp
->name
);
2320 DEFUN (no_bgp_default_local_preference
,
2321 no_bgp_default_local_preference_cmd
,
2322 "no bgp default local-preference [(0-4294967295)]",
2324 "BGP specific commands\n"
2325 "Configure BGP defaults\n"
2326 "local preference (higher=more preferred)\n"
2327 "Configure default local preference value\n")
2329 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2330 bgp_default_local_preference_unset(bgp
);
2331 bgp_clear_star_soft_in(vty
, bgp
->name
);
2337 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2338 bgp_default_subgroup_pkt_queue_max_cmd
,
2339 "bgp default subgroup-pkt-queue-max (20-100)",
2340 "BGP specific commands\n"
2341 "Configure BGP defaults\n"
2342 "subgroup-pkt-queue-max\n"
2343 "Configure subgroup packet queue max\n")
2345 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2349 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2351 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2356 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2357 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2358 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2360 "BGP specific commands\n"
2361 "Configure BGP defaults\n"
2362 "subgroup-pkt-queue-max\n"
2363 "Configure subgroup packet queue max\n")
2365 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2366 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2371 DEFUN (bgp_rr_allow_outbound_policy
,
2372 bgp_rr_allow_outbound_policy_cmd
,
2373 "bgp route-reflector allow-outbound-policy",
2374 "BGP specific commands\n"
2375 "Allow modifications made by out route-map\n"
2376 "on ibgp neighbors\n")
2378 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2380 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2381 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2382 update_group_announce_rrclients(bgp
);
2383 bgp_clear_star_soft_out(vty
, bgp
->name
);
2389 DEFUN (no_bgp_rr_allow_outbound_policy
,
2390 no_bgp_rr_allow_outbound_policy_cmd
,
2391 "no bgp route-reflector allow-outbound-policy",
2393 "BGP specific commands\n"
2394 "Allow modifications made by out route-map\n"
2395 "on ibgp neighbors\n")
2397 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2399 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2400 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2401 update_group_announce_rrclients(bgp
);
2402 bgp_clear_star_soft_out(vty
, bgp
->name
);
2408 DEFUN (bgp_listen_limit
,
2409 bgp_listen_limit_cmd
,
2410 "bgp listen limit (1-5000)",
2411 "BGP specific commands\n"
2412 "Configure BGP defaults\n"
2413 "maximum number of BGP Dynamic Neighbors that can be created\n"
2414 "Configure Dynamic Neighbors listen limit value\n")
2416 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2420 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2422 bgp_listen_limit_set(bgp
, listen_limit
);
2427 DEFUN (no_bgp_listen_limit
,
2428 no_bgp_listen_limit_cmd
,
2429 "no bgp listen limit [(1-5000)]",
2430 "BGP specific commands\n"
2431 "Configure BGP defaults\n"
2432 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2433 "Configure Dynamic Neighbors listen limit value to default\n"
2434 "Configure Dynamic Neighbors listen limit value\n")
2436 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2437 bgp_listen_limit_unset(bgp
);
2443 * Check if this listen range is already configured. Check for exact
2444 * match or overlap based on input.
2446 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2447 struct prefix
*range
, int exact
)
2449 struct listnode
*node
, *nnode
;
2450 struct listnode
*node1
, *nnode1
;
2451 struct peer_group
*group
;
2456 afi
= family2afi(range
->family
);
2457 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2458 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2461 match
= prefix_same(range
, lr
);
2463 match
= (prefix_match(range
, lr
)
2464 || prefix_match(lr
, range
));
2473 DEFUN (bgp_listen_range
,
2474 bgp_listen_range_cmd
,
2475 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2476 "BGP specific commands\n"
2477 "Configure BGP dynamic neighbors listen range\n"
2478 "Configure BGP dynamic neighbors listen range\n"
2480 "Member of the peer-group\n"
2481 "Peer-group name\n")
2483 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2484 struct prefix range
;
2485 struct peer_group
*group
, *existing_group
;
2490 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2491 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2492 char *prefix
= argv
[idx
]->arg
;
2493 argv_find(argv
, argc
, "WORD", &idx
);
2494 char *peergroup
= argv
[idx
]->arg
;
2496 /* Convert IP prefix string to struct prefix. */
2497 ret
= str2prefix(prefix
, &range
);
2499 vty_out(vty
, "%% Malformed listen range\n");
2500 return CMD_WARNING_CONFIG_FAILED
;
2503 afi
= family2afi(range
.family
);
2505 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2507 "%% Malformed listen range (link-local address)\n");
2508 return CMD_WARNING_CONFIG_FAILED
;
2513 /* Check if same listen range is already configured. */
2514 existing_group
= listen_range_exists(bgp
, &range
, 1);
2515 if (existing_group
) {
2516 if (strcmp(existing_group
->name
, peergroup
) == 0)
2520 "%% Same listen range is attached to peer-group %s\n",
2521 existing_group
->name
);
2522 return CMD_WARNING_CONFIG_FAILED
;
2526 /* Check if an overlapping listen range exists. */
2527 if (listen_range_exists(bgp
, &range
, 0)) {
2529 "%% Listen range overlaps with existing listen range\n");
2530 return CMD_WARNING_CONFIG_FAILED
;
2533 group
= peer_group_lookup(bgp
, peergroup
);
2535 vty_out(vty
, "%% Configure the peer-group first\n");
2536 return CMD_WARNING_CONFIG_FAILED
;
2539 ret
= peer_group_listen_range_add(group
, &range
);
2540 return bgp_vty_return(vty
, ret
);
2543 DEFUN (no_bgp_listen_range
,
2544 no_bgp_listen_range_cmd
,
2545 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2547 "BGP specific commands\n"
2548 "Unconfigure BGP dynamic neighbors listen range\n"
2549 "Unconfigure BGP dynamic neighbors listen range\n"
2551 "Member of the peer-group\n"
2552 "Peer-group name\n")
2554 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2555 struct prefix range
;
2556 struct peer_group
*group
;
2561 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2562 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2563 char *prefix
= argv
[idx
]->arg
;
2564 argv_find(argv
, argc
, "WORD", &idx
);
2565 char *peergroup
= argv
[idx
]->arg
;
2567 /* Convert IP prefix string to struct prefix. */
2568 ret
= str2prefix(prefix
, &range
);
2570 vty_out(vty
, "%% Malformed listen range\n");
2571 return CMD_WARNING_CONFIG_FAILED
;
2574 afi
= family2afi(range
.family
);
2576 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2578 "%% Malformed listen range (link-local address)\n");
2579 return CMD_WARNING_CONFIG_FAILED
;
2584 group
= peer_group_lookup(bgp
, peergroup
);
2586 vty_out(vty
, "%% Peer-group does not exist\n");
2587 return CMD_WARNING_CONFIG_FAILED
;
2590 ret
= peer_group_listen_range_del(group
, &range
);
2591 return bgp_vty_return(vty
, ret
);
2594 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2596 struct peer_group
*group
;
2597 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2598 struct prefix
*range
;
2600 char buf
[PREFIX2STR_BUFFER
];
2602 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2603 vty_out(vty
, " bgp listen limit %d\n",
2604 bgp
->dynamic_neighbors_limit
);
2606 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2607 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2608 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2610 prefix2str(range
, buf
, sizeof(buf
));
2612 " bgp listen range %s peer-group %s\n",
2620 DEFUN (bgp_disable_connected_route_check
,
2621 bgp_disable_connected_route_check_cmd
,
2622 "bgp disable-ebgp-connected-route-check",
2623 "BGP specific commands\n"
2624 "Disable checking if nexthop is connected on ebgp sessions\n")
2626 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2627 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2628 bgp_clear_star_soft_in(vty
, bgp
->name
);
2633 DEFUN (no_bgp_disable_connected_route_check
,
2634 no_bgp_disable_connected_route_check_cmd
,
2635 "no bgp disable-ebgp-connected-route-check",
2637 "BGP specific commands\n"
2638 "Disable checking if nexthop is connected on ebgp sessions\n")
2640 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2641 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2642 bgp_clear_star_soft_in(vty
, bgp
->name
);
2648 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2649 const char *as_str
, afi_t afi
, safi_t safi
)
2651 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2654 int as_type
= AS_SPECIFIED
;
2657 if (as_str
[0] == 'i') {
2659 as_type
= AS_INTERNAL
;
2660 } else if (as_str
[0] == 'e') {
2662 as_type
= AS_EXTERNAL
;
2664 /* Get AS number. */
2665 as
= strtoul(as_str
, NULL
, 10);
2668 /* If peer is peer group, call proper function. */
2669 ret
= str2sockunion(peer_str
, &su
);
2671 /* Check for peer by interface */
2672 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2675 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2678 "%% Create the peer-group or interface first\n");
2679 return CMD_WARNING_CONFIG_FAILED
;
2684 if (peer_address_self_check(bgp
, &su
)) {
2686 "%% Can not configure the local system as neighbor\n");
2687 return CMD_WARNING_CONFIG_FAILED
;
2689 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2692 /* This peer belongs to peer group. */
2694 case BGP_ERR_PEER_GROUP_MEMBER
:
2696 "%% Peer-group AS %u. Cannot configure remote-as for member\n",
2698 return CMD_WARNING_CONFIG_FAILED
;
2699 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2701 "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n",
2703 return CMD_WARNING_CONFIG_FAILED
;
2705 return bgp_vty_return(vty
, ret
);
2708 DEFUN (bgp_default_shutdown
,
2709 bgp_default_shutdown_cmd
,
2710 "[no] bgp default shutdown",
2713 "Configure BGP defaults\n"
2714 "Apply administrative shutdown to newly configured peers\n")
2716 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2717 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2721 DEFUN (neighbor_remote_as
,
2722 neighbor_remote_as_cmd
,
2723 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2726 "Specify a BGP neighbor\n"
2728 "Internal BGP peer\n"
2729 "External BGP peer\n")
2732 int idx_remote_as
= 3;
2733 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2734 argv
[idx_remote_as
]->arg
, AFI_IP
,
2738 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2739 afi_t afi
, safi_t safi
, int v6only
,
2740 const char *peer_group_name
,
2743 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2745 int as_type
= AS_UNSPECIFIED
;
2747 struct peer_group
*group
;
2751 group
= peer_group_lookup(bgp
, conf_if
);
2754 vty_out(vty
, "%% Name conflict with peer-group \n");
2755 return CMD_WARNING_CONFIG_FAILED
;
2759 if (as_str
[0] == 'i') {
2760 as_type
= AS_INTERNAL
;
2761 } else if (as_str
[0] == 'e') {
2762 as_type
= AS_EXTERNAL
;
2764 /* Get AS number. */
2765 as
= strtoul(as_str
, NULL
, 10);
2766 as_type
= AS_SPECIFIED
;
2770 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2773 ret
= peer_remote_as(bgp
, &su
, conf_if
, &as
, as_type
,
2776 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2777 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2778 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2779 as_type
, 0, 0, NULL
);
2781 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2782 as_type
, afi
, safi
, NULL
);
2785 vty_out(vty
, "%% BGP failed to create peer\n");
2786 return CMD_WARNING_CONFIG_FAILED
;
2790 SET_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
);
2792 /* Request zebra to initiate IPv6 RAs on this interface. We do
2794 * any unnumbered peer in order to not worry about run-time
2796 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2798 * gets deleted later etc.)
2801 bgp_zebra_initiate_radv(bgp
, peer
);
2804 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2805 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2807 SET_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
);
2809 UNSET_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
);
2811 /* v6only flag changed. Reset bgp seesion */
2812 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2813 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2814 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2815 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2817 bgp_session_reset(peer
);
2820 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
2821 peer_flag_set(peer
, PEER_FLAG_CAPABILITY_ENHE
);
2823 if (peer_group_name
) {
2824 group
= peer_group_lookup(bgp
, peer_group_name
);
2826 vty_out(vty
, "%% Configure the peer-group first\n");
2827 return CMD_WARNING_CONFIG_FAILED
;
2830 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
2833 return bgp_vty_return(vty
, ret
);
2836 DEFUN (neighbor_interface_config
,
2837 neighbor_interface_config_cmd
,
2838 "neighbor WORD interface [peer-group WORD]",
2840 "Interface name or neighbor tag\n"
2841 "Enable BGP on interface\n"
2842 "Member of the peer-group\n"
2843 "Peer-group name\n")
2846 int idx_peer_group_word
= 4;
2848 if (argc
> idx_peer_group_word
)
2849 return peer_conf_interface_get(
2850 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
2851 argv
[idx_peer_group_word
]->arg
, NULL
);
2853 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2854 SAFI_UNICAST
, 0, NULL
, NULL
);
2857 DEFUN (neighbor_interface_config_v6only
,
2858 neighbor_interface_config_v6only_cmd
,
2859 "neighbor WORD interface v6only [peer-group WORD]",
2861 "Interface name or neighbor tag\n"
2862 "Enable BGP on interface\n"
2863 "Enable BGP with v6 link-local only\n"
2864 "Member of the peer-group\n"
2865 "Peer-group name\n")
2868 int idx_peer_group_word
= 5;
2870 if (argc
> idx_peer_group_word
)
2871 return peer_conf_interface_get(
2872 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
2873 argv
[idx_peer_group_word
]->arg
, NULL
);
2875 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2876 SAFI_UNICAST
, 1, NULL
, NULL
);
2880 DEFUN (neighbor_interface_config_remote_as
,
2881 neighbor_interface_config_remote_as_cmd
,
2882 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
2884 "Interface name or neighbor tag\n"
2885 "Enable BGP on interface\n"
2886 "Specify a BGP neighbor\n"
2888 "Internal BGP peer\n"
2889 "External BGP peer\n")
2892 int idx_remote_as
= 4;
2893 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2894 SAFI_UNICAST
, 0, NULL
,
2895 argv
[idx_remote_as
]->arg
);
2898 DEFUN (neighbor_interface_v6only_config_remote_as
,
2899 neighbor_interface_v6only_config_remote_as_cmd
,
2900 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
2902 "Interface name or neighbor tag\n"
2903 "Enable BGP with v6 link-local only\n"
2904 "Enable BGP on interface\n"
2905 "Specify a BGP neighbor\n"
2907 "Internal BGP peer\n"
2908 "External BGP peer\n")
2911 int idx_remote_as
= 5;
2912 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2913 SAFI_UNICAST
, 1, NULL
,
2914 argv
[idx_remote_as
]->arg
);
2917 DEFUN (neighbor_peer_group
,
2918 neighbor_peer_group_cmd
,
2919 "neighbor WORD peer-group",
2921 "Interface name or neighbor tag\n"
2922 "Configure peer-group\n")
2924 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2927 struct peer_group
*group
;
2929 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
2931 vty_out(vty
, "%% Name conflict with interface: \n");
2932 return CMD_WARNING_CONFIG_FAILED
;
2935 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
2937 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
2938 return CMD_WARNING_CONFIG_FAILED
;
2946 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
2950 "Specify a BGP neighbor\n"
2952 "Internal BGP peer\n"
2953 "External BGP peer\n")
2955 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2959 struct peer_group
*group
;
2963 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
2965 /* look up for neighbor by interface name config. */
2966 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
2968 /* Request zebra to terminate IPv6 RAs on this
2971 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
2976 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
2978 peer_group_delete(group
);
2980 vty_out(vty
, "%% Create the peer-group first\n");
2981 return CMD_WARNING_CONFIG_FAILED
;
2984 peer
= peer_lookup(bgp
, &su
);
2986 if (peer_dynamic_neighbor(peer
)) {
2988 "%% Operation not allowed on a dynamic neighbor\n");
2989 return CMD_WARNING_CONFIG_FAILED
;
2992 other
= peer
->doppelganger
;
2994 if (other
&& other
->status
!= Deleted
)
3002 DEFUN (no_neighbor_interface_config
,
3003 no_neighbor_interface_config_cmd
,
3004 "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]",
3008 "Configure BGP on interface\n"
3009 "Enable BGP with v6 link-local only\n"
3010 "Member of the peer-group\n"
3012 "Specify a BGP neighbor\n"
3014 "Internal BGP peer\n"
3015 "External BGP peer\n")
3017 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3021 /* look up for neighbor by interface name config. */
3022 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3024 /* Request zebra to terminate IPv6 RAs on this interface. */
3026 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3029 vty_out(vty
, "%% Create the bgp interface first\n");
3030 return CMD_WARNING_CONFIG_FAILED
;
3035 DEFUN (no_neighbor_peer_group
,
3036 no_neighbor_peer_group_cmd
,
3037 "no neighbor WORD peer-group",
3041 "Configure peer-group\n")
3043 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3045 struct peer_group
*group
;
3047 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3049 peer_group_delete(group
);
3051 vty_out(vty
, "%% Create the peer-group first\n");
3052 return CMD_WARNING_CONFIG_FAILED
;
3057 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3058 no_neighbor_interface_peer_group_remote_as_cmd
,
3059 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3062 "Interface name or neighbor tag\n"
3063 "Specify a BGP neighbor\n"
3065 "Internal BGP peer\n"
3066 "External BGP peer\n")
3068 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3070 struct peer_group
*group
;
3073 /* look up for neighbor by interface name config. */
3074 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3076 peer_as_change(peer
, 0, AS_SPECIFIED
);
3080 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3082 peer_group_remote_as_delete(group
);
3084 vty_out(vty
, "%% Create the peer-group or interface first\n");
3085 return CMD_WARNING_CONFIG_FAILED
;
3090 DEFUN (neighbor_local_as
,
3091 neighbor_local_as_cmd
,
3092 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3095 "Specify a local-as number\n"
3096 "AS number used as local AS\n")
3104 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3106 return CMD_WARNING_CONFIG_FAILED
;
3108 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3109 ret
= peer_local_as_set(peer
, as
, 0, 0);
3110 return bgp_vty_return(vty
, ret
);
3113 DEFUN (neighbor_local_as_no_prepend
,
3114 neighbor_local_as_no_prepend_cmd
,
3115 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3118 "Specify a local-as number\n"
3119 "AS number used as local AS\n"
3120 "Do not prepend local-as to updates from ebgp peers\n")
3128 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3130 return CMD_WARNING_CONFIG_FAILED
;
3132 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3133 ret
= peer_local_as_set(peer
, as
, 1, 0);
3134 return bgp_vty_return(vty
, ret
);
3137 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3138 neighbor_local_as_no_prepend_replace_as_cmd
,
3139 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3142 "Specify a local-as number\n"
3143 "AS number used as local AS\n"
3144 "Do not prepend local-as to updates from ebgp peers\n"
3145 "Do not prepend local-as to updates from ibgp peers\n")
3153 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3155 return CMD_WARNING_CONFIG_FAILED
;
3157 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3158 ret
= peer_local_as_set(peer
, as
, 1, 1);
3159 return bgp_vty_return(vty
, ret
);
3162 DEFUN (no_neighbor_local_as
,
3163 no_neighbor_local_as_cmd
,
3164 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3168 "Specify a local-as number\n"
3169 "AS number used as local AS\n"
3170 "Do not prepend local-as to updates from ebgp peers\n"
3171 "Do not prepend local-as to updates from ibgp peers\n")
3177 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3179 return CMD_WARNING_CONFIG_FAILED
;
3181 ret
= peer_local_as_unset(peer
);
3182 return bgp_vty_return(vty
, ret
);
3186 DEFUN (neighbor_solo
,
3188 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3191 "Solo peer - part of its own update group\n")
3197 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3199 return CMD_WARNING_CONFIG_FAILED
;
3201 ret
= update_group_adjust_soloness(peer
, 1);
3202 return bgp_vty_return(vty
, ret
);
3205 DEFUN (no_neighbor_solo
,
3206 no_neighbor_solo_cmd
,
3207 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3211 "Solo peer - part of its own update group\n")
3217 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3219 return CMD_WARNING_CONFIG_FAILED
;
3221 ret
= update_group_adjust_soloness(peer
, 0);
3222 return bgp_vty_return(vty
, ret
);
3225 DEFUN (neighbor_password
,
3226 neighbor_password_cmd
,
3227 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3238 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3240 return CMD_WARNING_CONFIG_FAILED
;
3242 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3243 return bgp_vty_return(vty
, ret
);
3246 DEFUN (no_neighbor_password
,
3247 no_neighbor_password_cmd
,
3248 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3259 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3261 return CMD_WARNING_CONFIG_FAILED
;
3263 ret
= peer_password_unset(peer
);
3264 return bgp_vty_return(vty
, ret
);
3267 DEFUN (neighbor_activate
,
3268 neighbor_activate_cmd
,
3269 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3272 "Enable the Address Family for this Neighbor\n")
3278 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3280 return CMD_WARNING_CONFIG_FAILED
;
3282 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3283 return bgp_vty_return(vty
, ret
);
3286 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3287 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3288 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3289 "Enable the Address Family for this Neighbor\n")
3291 DEFUN (no_neighbor_activate
,
3292 no_neighbor_activate_cmd
,
3293 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3297 "Enable the Address Family for this Neighbor\n")
3304 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3306 return CMD_WARNING_CONFIG_FAILED
;
3308 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3309 return bgp_vty_return(vty
, ret
);
3312 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3313 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3314 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3315 "Enable the Address Family for this Neighbor\n")
3317 DEFUN (neighbor_set_peer_group
,
3318 neighbor_set_peer_group_cmd
,
3319 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3322 "Member of the peer-group\n"
3323 "Peer-group name\n")
3325 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3332 struct peer_group
*group
;
3336 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3338 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3340 vty_out(vty
, "%% Malformed address or name: %s\n",
3341 argv
[idx_peer
]->arg
);
3342 return CMD_WARNING_CONFIG_FAILED
;
3345 if (peer_address_self_check(bgp
, &su
)) {
3347 "%% Can not configure the local system as neighbor\n");
3348 return CMD_WARNING_CONFIG_FAILED
;
3351 /* Disallow for dynamic neighbor. */
3352 peer
= peer_lookup(bgp
, &su
);
3353 if (peer
&& peer_dynamic_neighbor(peer
)) {
3355 "%% Operation not allowed on a dynamic neighbor\n");
3356 return CMD_WARNING_CONFIG_FAILED
;
3360 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3362 vty_out(vty
, "%% Configure the peer-group first\n");
3363 return CMD_WARNING_CONFIG_FAILED
;
3366 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3368 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3370 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3372 return CMD_WARNING_CONFIG_FAILED
;
3375 return bgp_vty_return(vty
, ret
);
3378 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3379 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3380 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3381 "Member of the peer-group\n"
3382 "Peer-group name\n")
3384 DEFUN (no_neighbor_set_peer_group
,
3385 no_neighbor_set_peer_group_cmd
,
3386 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3390 "Member of the peer-group\n"
3391 "Peer-group name\n")
3393 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3398 struct peer_group
*group
;
3400 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3402 return CMD_WARNING_CONFIG_FAILED
;
3404 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3406 vty_out(vty
, "%% Configure the peer-group first\n");
3407 return CMD_WARNING_CONFIG_FAILED
;
3410 ret
= peer_delete(peer
);
3412 return bgp_vty_return(vty
, ret
);
3415 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3416 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3417 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3418 "Member of the peer-group\n"
3419 "Peer-group name\n")
3421 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3422 uint16_t flag
, int set
)
3427 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3429 return CMD_WARNING_CONFIG_FAILED
;
3432 * If 'neighbor <interface>', then this is for directly connected peers,
3433 * we should not accept disable-connected-check.
3435 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3437 "%s is directly connected peer, cannot accept disable-"
3438 "connected-check\n",
3440 return CMD_WARNING_CONFIG_FAILED
;
3443 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3444 peer_tx_shutdown_message_unset(peer
);
3447 ret
= peer_flag_set(peer
, flag
);
3449 ret
= peer_flag_unset(peer
, flag
);
3451 return bgp_vty_return(vty
, ret
);
3454 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint16_t flag
)
3456 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3459 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3462 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3465 /* neighbor passive. */
3466 DEFUN (neighbor_passive
,
3467 neighbor_passive_cmd
,
3468 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3471 "Don't send open messages to this neighbor\n")
3474 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3477 DEFUN (no_neighbor_passive
,
3478 no_neighbor_passive_cmd
,
3479 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3483 "Don't send open messages to this neighbor\n")
3486 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3489 /* neighbor shutdown. */
3490 DEFUN (neighbor_shutdown_msg
,
3491 neighbor_shutdown_msg_cmd
,
3492 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3495 "Administratively shut down this neighbor\n"
3496 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3497 "Shutdown message\n")
3503 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3507 return CMD_WARNING_CONFIG_FAILED
;
3508 message
= argv_concat(argv
, argc
, 4);
3509 peer_tx_shutdown_message_set(peer
, message
);
3510 XFREE(MTYPE_TMP
, message
);
3513 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3516 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3517 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3518 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3519 "Administratively shut down this neighbor\n")
3521 DEFUN (no_neighbor_shutdown_msg
,
3522 no_neighbor_shutdown_msg_cmd
,
3523 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3527 "Administratively shut down this neighbor\n"
3528 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3529 "Shutdown message\n")
3533 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3534 PEER_FLAG_SHUTDOWN
);
3537 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3538 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3539 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3540 "Administratively shut down this neighbor\n")
3542 /* neighbor capability dynamic. */
3543 DEFUN (neighbor_capability_dynamic
,
3544 neighbor_capability_dynamic_cmd
,
3545 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3548 "Advertise capability to the peer\n"
3549 "Advertise dynamic capability to this neighbor\n")
3552 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3553 PEER_FLAG_DYNAMIC_CAPABILITY
);
3556 DEFUN (no_neighbor_capability_dynamic
,
3557 no_neighbor_capability_dynamic_cmd
,
3558 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3562 "Advertise capability to the peer\n"
3563 "Advertise dynamic capability to this neighbor\n")
3566 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3567 PEER_FLAG_DYNAMIC_CAPABILITY
);
3570 /* neighbor dont-capability-negotiate */
3571 DEFUN (neighbor_dont_capability_negotiate
,
3572 neighbor_dont_capability_negotiate_cmd
,
3573 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3576 "Do not perform capability negotiation\n")
3579 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3580 PEER_FLAG_DONT_CAPABILITY
);
3583 DEFUN (no_neighbor_dont_capability_negotiate
,
3584 no_neighbor_dont_capability_negotiate_cmd
,
3585 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3589 "Do not perform capability negotiation\n")
3592 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3593 PEER_FLAG_DONT_CAPABILITY
);
3596 /* neighbor capability extended next hop encoding */
3597 DEFUN (neighbor_capability_enhe
,
3598 neighbor_capability_enhe_cmd
,
3599 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3602 "Advertise capability to the peer\n"
3603 "Advertise extended next-hop capability to the peer\n")
3606 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3607 PEER_FLAG_CAPABILITY_ENHE
);
3610 DEFUN (no_neighbor_capability_enhe
,
3611 no_neighbor_capability_enhe_cmd
,
3612 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3616 "Advertise capability to the peer\n"
3617 "Advertise extended next-hop capability to the peer\n")
3620 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3621 PEER_FLAG_CAPABILITY_ENHE
);
3624 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3625 afi_t afi
, safi_t safi
, uint32_t flag
,
3631 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3633 return CMD_WARNING_CONFIG_FAILED
;
3636 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3638 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3640 return bgp_vty_return(vty
, ret
);
3643 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3644 afi_t afi
, safi_t safi
, uint32_t flag
)
3646 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3649 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3650 afi_t afi
, safi_t safi
, uint32_t flag
)
3652 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3655 /* neighbor capability orf prefix-list. */
3656 DEFUN (neighbor_capability_orf_prefix
,
3657 neighbor_capability_orf_prefix_cmd
,
3658 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3661 "Advertise capability to the peer\n"
3662 "Advertise ORF capability to the peer\n"
3663 "Advertise prefixlist ORF capability to this neighbor\n"
3664 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3665 "Capability to RECEIVE the ORF from this neighbor\n"
3666 "Capability to SEND the ORF to this neighbor\n")
3669 int idx_send_recv
= 5;
3672 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3673 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3674 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3675 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3676 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3677 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3679 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3680 return CMD_WARNING_CONFIG_FAILED
;
3683 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3684 bgp_node_safi(vty
), flag
);
3688 neighbor_capability_orf_prefix
,
3689 neighbor_capability_orf_prefix_hidden_cmd
,
3690 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3691 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3692 "Advertise capability to the peer\n"
3693 "Advertise ORF capability to the peer\n"
3694 "Advertise prefixlist ORF capability to this neighbor\n"
3695 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3696 "Capability to RECEIVE the ORF from this neighbor\n"
3697 "Capability to SEND the ORF to this neighbor\n")
3699 DEFUN (no_neighbor_capability_orf_prefix
,
3700 no_neighbor_capability_orf_prefix_cmd
,
3701 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3705 "Advertise capability to the peer\n"
3706 "Advertise ORF capability to the peer\n"
3707 "Advertise prefixlist ORF capability to this neighbor\n"
3708 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3709 "Capability to RECEIVE the ORF from this neighbor\n"
3710 "Capability to SEND the ORF to this neighbor\n")
3713 int idx_send_recv
= 6;
3716 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3717 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3718 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3719 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3720 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3721 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3723 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3724 return CMD_WARNING_CONFIG_FAILED
;
3727 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3728 bgp_node_afi(vty
), bgp_node_safi(vty
),
3733 no_neighbor_capability_orf_prefix
,
3734 no_neighbor_capability_orf_prefix_hidden_cmd
,
3735 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3736 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3737 "Advertise capability to the peer\n"
3738 "Advertise ORF capability to the peer\n"
3739 "Advertise prefixlist ORF capability to this neighbor\n"
3740 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3741 "Capability to RECEIVE the ORF from this neighbor\n"
3742 "Capability to SEND the ORF to this neighbor\n")
3744 /* neighbor next-hop-self. */
3745 DEFUN (neighbor_nexthop_self
,
3746 neighbor_nexthop_self_cmd
,
3747 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3750 "Disable the next hop calculation for this neighbor\n")
3753 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3754 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3757 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3758 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3759 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3760 "Disable the next hop calculation for this neighbor\n")
3762 /* neighbor next-hop-self. */
3763 DEFUN (neighbor_nexthop_self_force
,
3764 neighbor_nexthop_self_force_cmd
,
3765 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3768 "Disable the next hop calculation for this neighbor\n"
3769 "Set the next hop to self for reflected routes\n")
3772 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3774 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3777 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3778 neighbor_nexthop_self_force_hidden_cmd
,
3779 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3780 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3781 "Disable the next hop calculation for this neighbor\n"
3782 "Set the next hop to self for reflected routes\n")
3784 DEFUN (no_neighbor_nexthop_self
,
3785 no_neighbor_nexthop_self_cmd
,
3786 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3790 "Disable the next hop calculation for this neighbor\n")
3793 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3794 bgp_node_afi(vty
), bgp_node_safi(vty
),
3795 PEER_FLAG_NEXTHOP_SELF
);
3798 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3799 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3800 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3801 "Disable the next hop calculation for this neighbor\n")
3803 DEFUN (no_neighbor_nexthop_self_force
,
3804 no_neighbor_nexthop_self_force_cmd
,
3805 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3809 "Disable the next hop calculation for this neighbor\n"
3810 "Set the next hop to self for reflected routes\n")
3813 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3814 bgp_node_afi(vty
), bgp_node_safi(vty
),
3815 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3818 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3819 no_neighbor_nexthop_self_force_hidden_cmd
,
3820 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3821 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3822 "Disable the next hop calculation for this neighbor\n"
3823 "Set the next hop to self for reflected routes\n")
3825 /* neighbor as-override */
3826 DEFUN (neighbor_as_override
,
3827 neighbor_as_override_cmd
,
3828 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3831 "Override ASNs in outbound updates if aspath equals remote-as\n")
3834 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3835 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
3838 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
3839 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3840 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3841 "Override ASNs in outbound updates if aspath equals remote-as\n")
3843 DEFUN (no_neighbor_as_override
,
3844 no_neighbor_as_override_cmd
,
3845 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3849 "Override ASNs in outbound updates if aspath equals remote-as\n")
3852 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3853 bgp_node_afi(vty
), bgp_node_safi(vty
),
3854 PEER_FLAG_AS_OVERRIDE
);
3857 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
3858 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3859 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3860 "Override ASNs in outbound updates if aspath equals remote-as\n")
3862 /* neighbor remove-private-AS. */
3863 DEFUN (neighbor_remove_private_as
,
3864 neighbor_remove_private_as_cmd
,
3865 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3868 "Remove private ASNs in outbound updates\n")
3871 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3873 PEER_FLAG_REMOVE_PRIVATE_AS
);
3876 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
3877 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3878 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3879 "Remove private ASNs in outbound updates\n")
3881 DEFUN (neighbor_remove_private_as_all
,
3882 neighbor_remove_private_as_all_cmd
,
3883 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3886 "Remove private ASNs in outbound updates\n"
3887 "Apply to all AS numbers\n")
3890 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3892 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
3895 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
3896 neighbor_remove_private_as_all_hidden_cmd
,
3897 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3898 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3899 "Remove private ASNs in outbound updates\n"
3900 "Apply to all AS numbers")
3902 DEFUN (neighbor_remove_private_as_replace_as
,
3903 neighbor_remove_private_as_replace_as_cmd
,
3904 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3907 "Remove private ASNs in outbound updates\n"
3908 "Replace private ASNs with our ASN in outbound updates\n")
3911 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3913 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
3916 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
3917 neighbor_remove_private_as_replace_as_hidden_cmd
,
3918 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3919 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3920 "Remove private ASNs in outbound updates\n"
3921 "Replace private ASNs with our ASN in outbound updates\n")
3923 DEFUN (neighbor_remove_private_as_all_replace_as
,
3924 neighbor_remove_private_as_all_replace_as_cmd
,
3925 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3928 "Remove private ASNs in outbound updates\n"
3929 "Apply to all AS numbers\n"
3930 "Replace private ASNs with our ASN in outbound updates\n")
3933 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3935 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
3939 neighbor_remove_private_as_all_replace_as
,
3940 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
3941 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3942 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3943 "Remove private ASNs in outbound updates\n"
3944 "Apply to all AS numbers\n"
3945 "Replace private ASNs with our ASN in outbound updates\n")
3947 DEFUN (no_neighbor_remove_private_as
,
3948 no_neighbor_remove_private_as_cmd
,
3949 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3953 "Remove private ASNs in outbound updates\n")
3956 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3957 bgp_node_afi(vty
), bgp_node_safi(vty
),
3958 PEER_FLAG_REMOVE_PRIVATE_AS
);
3961 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
3962 no_neighbor_remove_private_as_hidden_cmd
,
3963 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3964 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3965 "Remove private ASNs in outbound updates\n")
3967 DEFUN (no_neighbor_remove_private_as_all
,
3968 no_neighbor_remove_private_as_all_cmd
,
3969 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3973 "Remove private ASNs in outbound updates\n"
3974 "Apply to all AS numbers\n")
3977 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3978 bgp_node_afi(vty
), bgp_node_safi(vty
),
3979 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
3982 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
3983 no_neighbor_remove_private_as_all_hidden_cmd
,
3984 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3985 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3986 "Remove private ASNs in outbound updates\n"
3987 "Apply to all AS numbers\n")
3989 DEFUN (no_neighbor_remove_private_as_replace_as
,
3990 no_neighbor_remove_private_as_replace_as_cmd
,
3991 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3995 "Remove private ASNs in outbound updates\n"
3996 "Replace private ASNs with our ASN in outbound updates\n")
3999 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4000 bgp_node_afi(vty
), bgp_node_safi(vty
),
4001 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4004 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4005 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4006 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4007 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4008 "Remove private ASNs in outbound updates\n"
4009 "Replace private ASNs with our ASN in outbound updates\n")
4011 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4012 no_neighbor_remove_private_as_all_replace_as_cmd
,
4013 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4017 "Remove private ASNs in outbound updates\n"
4018 "Apply to all AS numbers\n"
4019 "Replace private ASNs with our ASN in outbound updates\n")
4022 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4023 bgp_node_afi(vty
), bgp_node_safi(vty
),
4024 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4028 no_neighbor_remove_private_as_all_replace_as
,
4029 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4030 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4031 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4032 "Remove private ASNs in outbound updates\n"
4033 "Apply to all AS numbers\n"
4034 "Replace private ASNs with our ASN in outbound updates\n")
4037 /* neighbor send-community. */
4038 DEFUN (neighbor_send_community
,
4039 neighbor_send_community_cmd
,
4040 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4043 "Send Community attribute to this neighbor\n")
4046 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4048 PEER_FLAG_SEND_COMMUNITY
);
4051 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4052 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4053 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4054 "Send Community attribute to this neighbor\n")
4056 DEFUN (no_neighbor_send_community
,
4057 no_neighbor_send_community_cmd
,
4058 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4062 "Send Community attribute to this neighbor\n")
4065 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4066 bgp_node_afi(vty
), bgp_node_safi(vty
),
4067 PEER_FLAG_SEND_COMMUNITY
);
4070 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4071 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4072 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4073 "Send Community attribute to this neighbor\n")
4075 /* neighbor send-community extended. */
4076 DEFUN (neighbor_send_community_type
,
4077 neighbor_send_community_type_cmd
,
4078 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4081 "Send Community attribute to this neighbor\n"
4082 "Send Standard and Extended Community attributes\n"
4083 "Send Standard, Large and Extended Community attributes\n"
4084 "Send Extended Community attributes\n"
4085 "Send Standard Community attributes\n"
4086 "Send Large Community attributes\n")
4091 char *peer
= argv
[1]->arg
;
4093 if (argv_find(argv
, argc
, "standard", &idx
))
4094 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4095 else if (argv_find(argv
, argc
, "extended", &idx
))
4096 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4097 else if (argv_find(argv
, argc
, "large", &idx
))
4098 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4099 else if (argv_find(argv
, argc
, "both", &idx
)) {
4100 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4101 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4103 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4104 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4105 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4108 return peer_af_flag_set_vty(vty
, peer
, bgp_node_afi(vty
),
4109 bgp_node_safi(vty
), flag
);
4113 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4114 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4115 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4116 "Send Community attribute to this neighbor\n"
4117 "Send Standard and Extended Community attributes\n"
4118 "Send Standard, Large and Extended Community attributes\n"
4119 "Send Extended Community attributes\n"
4120 "Send Standard Community attributes\n"
4121 "Send Large Community attributes\n")
4123 DEFUN (no_neighbor_send_community_type
,
4124 no_neighbor_send_community_type_cmd
,
4125 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4129 "Send Community attribute to this neighbor\n"
4130 "Send Standard and Extended Community attributes\n"
4131 "Send Standard, Large and Extended Community attributes\n"
4132 "Send Extended Community attributes\n"
4133 "Send Standard Community attributes\n"
4134 "Send Large Community attributes\n")
4138 const char *type
= argv
[argc
- 1]->text
;
4140 if (strmatch(type
, "standard"))
4141 return peer_af_flag_unset_vty(
4142 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4143 bgp_node_safi(vty
), PEER_FLAG_SEND_COMMUNITY
);
4144 if (strmatch(type
, "extended"))
4145 return peer_af_flag_unset_vty(
4146 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4147 bgp_node_safi(vty
), PEER_FLAG_SEND_EXT_COMMUNITY
);
4148 if (strmatch(type
, "large"))
4149 return peer_af_flag_unset_vty(
4150 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4151 bgp_node_safi(vty
), PEER_FLAG_SEND_LARGE_COMMUNITY
);
4152 if (strmatch(type
, "both"))
4153 return peer_af_flag_unset_vty(
4154 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4156 PEER_FLAG_SEND_COMMUNITY
4157 | PEER_FLAG_SEND_EXT_COMMUNITY
);
4159 /* if (strmatch (type, "all")) */
4160 return peer_af_flag_unset_vty(
4161 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4162 (PEER_FLAG_SEND_COMMUNITY
| PEER_FLAG_SEND_EXT_COMMUNITY
4163 | PEER_FLAG_SEND_LARGE_COMMUNITY
));
4167 no_neighbor_send_community_type
,
4168 no_neighbor_send_community_type_hidden_cmd
,
4169 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4170 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4171 "Send Community attribute to this neighbor\n"
4172 "Send Standard and Extended Community attributes\n"
4173 "Send Standard, Large and Extended Community attributes\n"
4174 "Send Extended Community attributes\n"
4175 "Send Standard Community attributes\n"
4176 "Send Large Community attributes\n")
4178 /* neighbor soft-reconfig. */
4179 DEFUN (neighbor_soft_reconfiguration
,
4180 neighbor_soft_reconfiguration_cmd
,
4181 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4184 "Per neighbor soft reconfiguration\n"
4185 "Allow inbound soft reconfiguration for this neighbor\n")
4188 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4190 PEER_FLAG_SOFT_RECONFIG
);
4193 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4194 neighbor_soft_reconfiguration_hidden_cmd
,
4195 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4196 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4197 "Per neighbor soft reconfiguration\n"
4198 "Allow inbound soft reconfiguration for this neighbor\n")
4200 DEFUN (no_neighbor_soft_reconfiguration
,
4201 no_neighbor_soft_reconfiguration_cmd
,
4202 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4206 "Per neighbor soft reconfiguration\n"
4207 "Allow inbound soft reconfiguration for this neighbor\n")
4210 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4211 bgp_node_afi(vty
), bgp_node_safi(vty
),
4212 PEER_FLAG_SOFT_RECONFIG
);
4215 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4216 no_neighbor_soft_reconfiguration_hidden_cmd
,
4217 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4218 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4219 "Per neighbor soft reconfiguration\n"
4220 "Allow inbound soft reconfiguration for this neighbor\n")
4222 DEFUN (neighbor_route_reflector_client
,
4223 neighbor_route_reflector_client_cmd
,
4224 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4227 "Configure a neighbor as Route Reflector client\n")
4233 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4235 return CMD_WARNING_CONFIG_FAILED
;
4237 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4239 PEER_FLAG_REFLECTOR_CLIENT
);
4242 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4243 neighbor_route_reflector_client_hidden_cmd
,
4244 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4245 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4246 "Configure a neighbor as Route Reflector client\n")
4248 DEFUN (no_neighbor_route_reflector_client
,
4249 no_neighbor_route_reflector_client_cmd
,
4250 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4254 "Configure a neighbor as Route Reflector client\n")
4257 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4258 bgp_node_afi(vty
), bgp_node_safi(vty
),
4259 PEER_FLAG_REFLECTOR_CLIENT
);
4262 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4263 no_neighbor_route_reflector_client_hidden_cmd
,
4264 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4265 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4266 "Configure a neighbor as Route Reflector client\n")
4268 /* neighbor route-server-client. */
4269 DEFUN (neighbor_route_server_client
,
4270 neighbor_route_server_client_cmd
,
4271 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4274 "Configure a neighbor as Route Server client\n")
4279 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4281 return CMD_WARNING_CONFIG_FAILED
;
4282 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4284 PEER_FLAG_RSERVER_CLIENT
);
4287 ALIAS_HIDDEN(neighbor_route_server_client
,
4288 neighbor_route_server_client_hidden_cmd
,
4289 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4290 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4291 "Configure a neighbor as Route Server client\n")
4293 DEFUN (no_neighbor_route_server_client
,
4294 no_neighbor_route_server_client_cmd
,
4295 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4299 "Configure a neighbor as Route Server client\n")
4302 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4303 bgp_node_afi(vty
), bgp_node_safi(vty
),
4304 PEER_FLAG_RSERVER_CLIENT
);
4307 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4308 no_neighbor_route_server_client_hidden_cmd
,
4309 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4310 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4311 "Configure a neighbor as Route Server client\n")
4313 DEFUN (neighbor_nexthop_local_unchanged
,
4314 neighbor_nexthop_local_unchanged_cmd
,
4315 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4318 "Configure treatment of outgoing link-local nexthop attribute\n"
4319 "Leave link-local nexthop unchanged for this peer\n")
4322 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4324 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4327 DEFUN (no_neighbor_nexthop_local_unchanged
,
4328 no_neighbor_nexthop_local_unchanged_cmd
,
4329 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4333 "Configure treatment of outgoing link-local-nexthop attribute\n"
4334 "Leave link-local nexthop unchanged for this peer\n")
4337 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4338 bgp_node_afi(vty
), bgp_node_safi(vty
),
4339 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4342 DEFUN (neighbor_attr_unchanged
,
4343 neighbor_attr_unchanged_cmd
,
4344 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4347 "BGP attribute is propagated unchanged to this neighbor\n"
4348 "As-path attribute\n"
4349 "Nexthop attribute\n"
4353 char *peer_str
= argv
[1]->arg
;
4356 afi_t afi
= bgp_node_afi(vty
);
4357 safi_t safi
= bgp_node_safi(vty
);
4359 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4361 return CMD_WARNING_CONFIG_FAILED
;
4363 if (argv_find(argv
, argc
, "as-path", &idx
))
4364 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4366 if (argv_find(argv
, argc
, "next-hop", &idx
))
4367 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4369 if (argv_find(argv
, argc
, "med", &idx
))
4370 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4372 /* no flags means all of them! */
4374 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4375 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4376 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4378 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4379 && peer_af_flag_check(peer
, afi
, safi
,
4380 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4381 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4382 PEER_FLAG_AS_PATH_UNCHANGED
);
4385 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4386 && peer_af_flag_check(peer
, afi
, safi
,
4387 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4388 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4389 PEER_FLAG_NEXTHOP_UNCHANGED
);
4392 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4393 && peer_af_flag_check(peer
, afi
, safi
,
4394 PEER_FLAG_MED_UNCHANGED
)) {
4395 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4396 PEER_FLAG_MED_UNCHANGED
);
4400 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4404 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4405 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4406 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4407 "BGP attribute is propagated unchanged to this neighbor\n"
4408 "As-path attribute\n"
4409 "Nexthop attribute\n"
4412 DEFUN (no_neighbor_attr_unchanged
,
4413 no_neighbor_attr_unchanged_cmd
,
4414 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4418 "BGP attribute is propagated unchanged to this neighbor\n"
4419 "As-path attribute\n"
4420 "Nexthop attribute\n"
4424 char *peer
= argv
[2]->arg
;
4427 if (argv_find(argv
, argc
, "as-path", &idx
))
4428 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4430 if (argv_find(argv
, argc
, "next-hop", &idx
))
4431 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4433 if (argv_find(argv
, argc
, "med", &idx
))
4434 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4436 if (!flags
) // no flags means all of them!
4438 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4439 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4440 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4443 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4444 bgp_node_safi(vty
), flags
);
4448 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4449 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4450 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4451 "BGP attribute is propagated unchanged to this neighbor\n"
4452 "As-path attribute\n"
4453 "Nexthop attribute\n"
4456 /* EBGP multihop configuration. */
4457 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4458 const char *ttl_str
)
4463 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4465 return CMD_WARNING_CONFIG_FAILED
;
4468 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4473 ttl
= strtoul(ttl_str
, NULL
, 10);
4475 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4478 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4482 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4484 return CMD_WARNING_CONFIG_FAILED
;
4486 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4489 /* neighbor ebgp-multihop. */
4490 DEFUN (neighbor_ebgp_multihop
,
4491 neighbor_ebgp_multihop_cmd
,
4492 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4495 "Allow EBGP neighbors not on directly connected networks\n")
4498 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4501 DEFUN (neighbor_ebgp_multihop_ttl
,
4502 neighbor_ebgp_multihop_ttl_cmd
,
4503 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4506 "Allow EBGP neighbors not on directly connected networks\n"
4507 "maximum hop count\n")
4511 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4512 argv
[idx_number
]->arg
);
4515 DEFUN (no_neighbor_ebgp_multihop
,
4516 no_neighbor_ebgp_multihop_cmd
,
4517 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4521 "Allow EBGP neighbors not on directly connected networks\n"
4522 "maximum hop count\n")
4525 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4529 /* disable-connected-check */
4530 DEFUN (neighbor_disable_connected_check
,
4531 neighbor_disable_connected_check_cmd
,
4532 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4535 "one-hop away EBGP peer using loopback address\n"
4536 "Enforce EBGP neighbors perform multihop\n")
4539 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4540 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4543 DEFUN (no_neighbor_disable_connected_check
,
4544 no_neighbor_disable_connected_check_cmd
,
4545 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4549 "one-hop away EBGP peer using loopback address\n"
4550 "Enforce EBGP neighbors perform multihop\n")
4553 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4554 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4557 DEFUN (neighbor_description
,
4558 neighbor_description_cmd
,
4559 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4562 "Neighbor specific description\n"
4563 "Up to 80 characters describing this neighbor\n")
4570 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4572 return CMD_WARNING_CONFIG_FAILED
;
4574 str
= argv_concat(argv
, argc
, idx_line
);
4576 peer_description_set(peer
, str
);
4578 XFREE(MTYPE_TMP
, str
);
4583 DEFUN (no_neighbor_description
,
4584 no_neighbor_description_cmd
,
4585 "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]",
4589 "Neighbor specific description\n"
4590 "Up to 80 characters describing this neighbor\n")
4595 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4597 return CMD_WARNING_CONFIG_FAILED
;
4599 peer_description_unset(peer
);
4605 /* Neighbor update-source. */
4606 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4607 const char *source_str
)
4612 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4614 return CMD_WARNING_CONFIG_FAILED
;
4621 int ret
= str2sockunion(source_str
, &su
);
4624 peer_update_source_addr_set(peer
, &su
);
4626 if (str2prefix(source_str
, &p
)) {
4628 "%% Invalid update-source, remove prefix length \n");
4629 return CMD_WARNING_CONFIG_FAILED
;
4631 peer_update_source_if_set(peer
, source_str
);
4634 peer_update_source_unset(peer
);
4639 #define BGP_UPDATE_SOURCE_HELP_STR \
4642 "Interface name (requires zebra to be running)\n"
4644 DEFUN (neighbor_update_source
,
4645 neighbor_update_source_cmd
,
4646 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4649 "Source of routing updates\n"
4650 BGP_UPDATE_SOURCE_HELP_STR
)
4654 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4655 argv
[idx_peer_2
]->arg
);
4658 DEFUN (no_neighbor_update_source
,
4659 no_neighbor_update_source_cmd
,
4660 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4664 "Source of routing updates\n"
4665 BGP_UPDATE_SOURCE_HELP_STR
)
4668 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4671 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4672 afi_t afi
, safi_t safi
,
4673 const char *rmap
, int set
)
4678 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4680 return CMD_WARNING_CONFIG_FAILED
;
4683 ret
= peer_default_originate_set(peer
, afi
, safi
, rmap
);
4685 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4687 return bgp_vty_return(vty
, ret
);
4690 /* neighbor default-originate. */
4691 DEFUN (neighbor_default_originate
,
4692 neighbor_default_originate_cmd
,
4693 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4696 "Originate default route to this neighbor\n")
4699 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4701 bgp_node_safi(vty
), NULL
, 1);
4704 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4705 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4706 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4707 "Originate default route to this neighbor\n")
4709 DEFUN (neighbor_default_originate_rmap
,
4710 neighbor_default_originate_rmap_cmd
,
4711 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4714 "Originate default route to this neighbor\n"
4715 "Route-map to specify criteria to originate default\n"
4720 return peer_default_originate_set_vty(
4721 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4722 argv
[idx_word
]->arg
, 1);
4726 neighbor_default_originate_rmap
,
4727 neighbor_default_originate_rmap_hidden_cmd
,
4728 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4729 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4730 "Originate default route to this neighbor\n"
4731 "Route-map to specify criteria to originate default\n"
4734 DEFUN (no_neighbor_default_originate
,
4735 no_neighbor_default_originate_cmd
,
4736 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4740 "Originate default route to this neighbor\n"
4741 "Route-map to specify criteria to originate default\n"
4745 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4747 bgp_node_safi(vty
), NULL
, 0);
4751 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4752 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4753 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4754 "Originate default route to this neighbor\n"
4755 "Route-map to specify criteria to originate default\n"
4759 /* Set neighbor's BGP port. */
4760 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4761 const char *port_str
)
4767 peer
= peer_lookup_vty(vty
, ip_str
);
4769 return CMD_WARNING_CONFIG_FAILED
;
4772 sp
= getservbyname("bgp", "tcp");
4773 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
4775 port
= strtoul(port_str
, NULL
, 10);
4778 peer_port_set(peer
, port
);
4783 /* Set specified peer's BGP port. */
4784 DEFUN (neighbor_port
,
4786 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
4789 "Neighbor's BGP port\n"
4790 "TCP port number\n")
4794 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
4795 argv
[idx_number
]->arg
);
4798 DEFUN (no_neighbor_port
,
4799 no_neighbor_port_cmd
,
4800 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
4804 "Neighbor's BGP port\n"
4805 "TCP port number\n")
4808 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
4812 /* neighbor weight. */
4813 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4814 safi_t safi
, const char *weight_str
)
4818 unsigned long weight
;
4820 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4822 return CMD_WARNING_CONFIG_FAILED
;
4824 weight
= strtoul(weight_str
, NULL
, 10);
4826 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
4827 return bgp_vty_return(vty
, ret
);
4830 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4836 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4838 return CMD_WARNING_CONFIG_FAILED
;
4840 ret
= peer_weight_unset(peer
, afi
, safi
);
4841 return bgp_vty_return(vty
, ret
);
4844 DEFUN (neighbor_weight
,
4845 neighbor_weight_cmd
,
4846 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4849 "Set default weight for routes from this neighbor\n"
4854 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4855 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
4858 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
4859 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4860 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4861 "Set default weight for routes from this neighbor\n"
4864 DEFUN (no_neighbor_weight
,
4865 no_neighbor_weight_cmd
,
4866 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4870 "Set default weight for routes from this neighbor\n"
4874 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
4875 bgp_node_afi(vty
), bgp_node_safi(vty
));
4878 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
4879 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4880 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4881 "Set default weight for routes from this neighbor\n"
4885 /* Override capability negotiation. */
4886 DEFUN (neighbor_override_capability
,
4887 neighbor_override_capability_cmd
,
4888 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4891 "Override capability negotiation result\n")
4894 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4895 PEER_FLAG_OVERRIDE_CAPABILITY
);
4898 DEFUN (no_neighbor_override_capability
,
4899 no_neighbor_override_capability_cmd
,
4900 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4904 "Override capability negotiation result\n")
4907 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4908 PEER_FLAG_OVERRIDE_CAPABILITY
);
4911 DEFUN (neighbor_strict_capability
,
4912 neighbor_strict_capability_cmd
,
4913 "neighbor <A.B.C.D|X:X::X:X> strict-capability-match",
4916 "Strict capability negotiation match\n")
4919 return peer_flag_set_vty(vty
, argv
[idx_ip
]->arg
,
4920 PEER_FLAG_STRICT_CAP_MATCH
);
4923 DEFUN (no_neighbor_strict_capability
,
4924 no_neighbor_strict_capability_cmd
,
4925 "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match",
4929 "Strict capability negotiation match\n")
4932 return peer_flag_unset_vty(vty
, argv
[idx_ip
]->arg
,
4933 PEER_FLAG_STRICT_CAP_MATCH
);
4936 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
4937 const char *keep_str
, const char *hold_str
)
4944 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4946 return CMD_WARNING_CONFIG_FAILED
;
4948 keepalive
= strtoul(keep_str
, NULL
, 10);
4949 holdtime
= strtoul(hold_str
, NULL
, 10);
4951 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
4953 return bgp_vty_return(vty
, ret
);
4956 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
4961 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4963 return CMD_WARNING_CONFIG_FAILED
;
4965 ret
= peer_timers_unset(peer
);
4967 return bgp_vty_return(vty
, ret
);
4970 DEFUN (neighbor_timers
,
4971 neighbor_timers_cmd
,
4972 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
4975 "BGP per neighbor timers\n"
4976 "Keepalive interval\n"
4981 int idx_number_2
= 4;
4982 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
4983 argv
[idx_number
]->arg
,
4984 argv
[idx_number_2
]->arg
);
4987 DEFUN (no_neighbor_timers
,
4988 no_neighbor_timers_cmd
,
4989 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
4993 "BGP per neighbor timers\n"
4994 "Keepalive interval\n"
4998 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5002 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5003 const char *time_str
)
5009 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5011 return CMD_WARNING_CONFIG_FAILED
;
5013 connect
= strtoul(time_str
, NULL
, 10);
5015 ret
= peer_timers_connect_set(peer
, connect
);
5017 return bgp_vty_return(vty
, ret
);
5020 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5025 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5027 return CMD_WARNING_CONFIG_FAILED
;
5029 ret
= peer_timers_connect_unset(peer
);
5031 return bgp_vty_return(vty
, ret
);
5034 DEFUN (neighbor_timers_connect
,
5035 neighbor_timers_connect_cmd
,
5036 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5039 "BGP per neighbor timers\n"
5040 "BGP connect timer\n"
5045 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5046 argv
[idx_number
]->arg
);
5049 DEFUN (no_neighbor_timers_connect
,
5050 no_neighbor_timers_connect_cmd
,
5051 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5055 "BGP per neighbor timers\n"
5056 "BGP connect timer\n"
5060 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5064 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5065 const char *time_str
, int set
)
5069 uint32_t routeadv
= 0;
5071 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5073 return CMD_WARNING_CONFIG_FAILED
;
5076 routeadv
= strtoul(time_str
, NULL
, 10);
5079 ret
= peer_advertise_interval_set(peer
, routeadv
);
5081 ret
= peer_advertise_interval_unset(peer
);
5083 return bgp_vty_return(vty
, ret
);
5086 DEFUN (neighbor_advertise_interval
,
5087 neighbor_advertise_interval_cmd
,
5088 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5091 "Minimum interval between sending BGP routing updates\n"
5092 "time in seconds\n")
5096 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5097 argv
[idx_number
]->arg
, 1);
5100 DEFUN (no_neighbor_advertise_interval
,
5101 no_neighbor_advertise_interval_cmd
,
5102 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5106 "Minimum interval between sending BGP routing updates\n"
5107 "time in seconds\n")
5110 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5114 /* Time to wait before processing route-map updates */
5115 DEFUN (bgp_set_route_map_delay_timer
,
5116 bgp_set_route_map_delay_timer_cmd
,
5117 "bgp route-map delay-timer (0-600)",
5119 "BGP route-map delay timer\n"
5120 "Time in secs to wait before processing route-map changes\n"
5121 "0 disables the timer, no route updates happen when route-maps change\n")
5124 uint32_t rmap_delay_timer
;
5126 if (argv
[idx_number
]->arg
) {
5127 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5128 bm
->rmap_update_timer
= rmap_delay_timer
;
5130 /* if the dynamic update handling is being disabled, and a timer
5132 * running, stop the timer and act as if the timer has already
5135 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5136 BGP_TIMER_OFF(bm
->t_rmap_update
);
5137 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5142 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5143 return CMD_WARNING_CONFIG_FAILED
;
5147 DEFUN (no_bgp_set_route_map_delay_timer
,
5148 no_bgp_set_route_map_delay_timer_cmd
,
5149 "no bgp route-map delay-timer [(0-600)]",
5152 "Default BGP route-map delay timer\n"
5153 "Reset to default time to wait for processing route-map changes\n"
5154 "0 disables the timer, no route updates happen when route-maps change\n")
5157 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5163 /* neighbor interface */
5164 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5169 peer
= peer_lookup_vty(vty
, ip_str
);
5170 if (!peer
|| peer
->conf_if
) {
5171 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5172 return CMD_WARNING_CONFIG_FAILED
;
5176 peer_interface_set(peer
, str
);
5178 peer_interface_unset(peer
);
5183 DEFUN (neighbor_interface
,
5184 neighbor_interface_cmd
,
5185 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5193 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5196 DEFUN (no_neighbor_interface
,
5197 no_neighbor_interface_cmd
,
5198 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5206 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5209 DEFUN (neighbor_distribute_list
,
5210 neighbor_distribute_list_cmd
,
5211 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5214 "Filter updates to/from this neighbor\n"
5215 "IP access-list number\n"
5216 "IP access-list number (expanded range)\n"
5217 "IP Access-list name\n"
5218 "Filter incoming updates\n"
5219 "Filter outgoing updates\n")
5226 const char *pstr
= argv
[idx_peer
]->arg
;
5227 const char *acl
= argv
[idx_acl
]->arg
;
5228 const char *inout
= argv
[argc
- 1]->text
;
5230 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5232 return CMD_WARNING_CONFIG_FAILED
;
5234 /* Check filter direction. */
5235 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5236 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5239 return bgp_vty_return(vty
, ret
);
5243 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5244 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5245 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5246 "Filter updates to/from this neighbor\n"
5247 "IP access-list number\n"
5248 "IP access-list number (expanded range)\n"
5249 "IP Access-list name\n"
5250 "Filter incoming updates\n"
5251 "Filter outgoing updates\n")
5253 DEFUN (no_neighbor_distribute_list
,
5254 no_neighbor_distribute_list_cmd
,
5255 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5259 "Filter updates to/from this neighbor\n"
5260 "IP access-list number\n"
5261 "IP access-list number (expanded range)\n"
5262 "IP Access-list name\n"
5263 "Filter incoming updates\n"
5264 "Filter outgoing updates\n")
5270 const char *pstr
= argv
[idx_peer
]->arg
;
5271 const char *inout
= argv
[argc
- 1]->text
;
5273 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5275 return CMD_WARNING_CONFIG_FAILED
;
5277 /* Check filter direction. */
5278 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5279 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5282 return bgp_vty_return(vty
, ret
);
5286 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5287 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5288 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5289 "Filter updates to/from this neighbor\n"
5290 "IP access-list number\n"
5291 "IP access-list number (expanded range)\n"
5292 "IP Access-list name\n"
5293 "Filter incoming updates\n"
5294 "Filter outgoing updates\n")
5296 /* Set prefix list to the peer. */
5297 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5298 afi_t afi
, safi_t safi
,
5299 const char *name_str
,
5300 const char *direct_str
)
5304 int direct
= FILTER_IN
;
5306 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5308 return CMD_WARNING_CONFIG_FAILED
;
5310 /* Check filter direction. */
5311 if (strncmp(direct_str
, "i", 1) == 0)
5313 else if (strncmp(direct_str
, "o", 1) == 0)
5314 direct
= FILTER_OUT
;
5316 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5318 return bgp_vty_return(vty
, ret
);
5321 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5322 afi_t afi
, safi_t safi
,
5323 const char *direct_str
)
5327 int direct
= FILTER_IN
;
5329 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5331 return CMD_WARNING_CONFIG_FAILED
;
5333 /* Check filter direction. */
5334 if (strncmp(direct_str
, "i", 1) == 0)
5336 else if (strncmp(direct_str
, "o", 1) == 0)
5337 direct
= FILTER_OUT
;
5339 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5341 return bgp_vty_return(vty
, ret
);
5344 DEFUN (neighbor_prefix_list
,
5345 neighbor_prefix_list_cmd
,
5346 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5349 "Filter updates to/from this neighbor\n"
5350 "Name of a prefix list\n"
5351 "Filter incoming updates\n"
5352 "Filter outgoing updates\n")
5357 return peer_prefix_list_set_vty(
5358 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5359 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5362 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5363 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5364 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5365 "Filter updates to/from this neighbor\n"
5366 "Name of a prefix list\n"
5367 "Filter incoming updates\n"
5368 "Filter outgoing updates\n")
5370 DEFUN (no_neighbor_prefix_list
,
5371 no_neighbor_prefix_list_cmd
,
5372 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5376 "Filter updates to/from this neighbor\n"
5377 "Name of a prefix list\n"
5378 "Filter incoming updates\n"
5379 "Filter outgoing updates\n")
5383 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5384 bgp_node_afi(vty
), bgp_node_safi(vty
),
5385 argv
[idx_in_out
]->arg
);
5388 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5389 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5390 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5391 "Filter updates to/from this neighbor\n"
5392 "Name of a prefix list\n"
5393 "Filter incoming updates\n"
5394 "Filter outgoing updates\n")
5396 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5397 safi_t safi
, const char *name_str
,
5398 const char *direct_str
)
5402 int direct
= FILTER_IN
;
5404 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5406 return CMD_WARNING_CONFIG_FAILED
;
5408 /* Check filter direction. */
5409 if (strncmp(direct_str
, "i", 1) == 0)
5411 else if (strncmp(direct_str
, "o", 1) == 0)
5412 direct
= FILTER_OUT
;
5414 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5416 return bgp_vty_return(vty
, ret
);
5419 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5420 safi_t safi
, const char *direct_str
)
5424 int direct
= FILTER_IN
;
5426 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5428 return CMD_WARNING_CONFIG_FAILED
;
5430 /* Check filter direction. */
5431 if (strncmp(direct_str
, "i", 1) == 0)
5433 else if (strncmp(direct_str
, "o", 1) == 0)
5434 direct
= FILTER_OUT
;
5436 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5438 return bgp_vty_return(vty
, ret
);
5441 DEFUN (neighbor_filter_list
,
5442 neighbor_filter_list_cmd
,
5443 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5446 "Establish BGP filters\n"
5447 "AS path access-list name\n"
5448 "Filter incoming routes\n"
5449 "Filter outgoing routes\n")
5454 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5455 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5456 argv
[idx_in_out
]->arg
);
5459 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5460 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5461 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5462 "Establish BGP filters\n"
5463 "AS path access-list name\n"
5464 "Filter incoming routes\n"
5465 "Filter outgoing routes\n")
5467 DEFUN (no_neighbor_filter_list
,
5468 no_neighbor_filter_list_cmd
,
5469 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5473 "Establish BGP filters\n"
5474 "AS path access-list name\n"
5475 "Filter incoming routes\n"
5476 "Filter outgoing routes\n")
5480 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5481 bgp_node_afi(vty
), bgp_node_safi(vty
),
5482 argv
[idx_in_out
]->arg
);
5485 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5486 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5487 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5488 "Establish BGP filters\n"
5489 "AS path access-list name\n"
5490 "Filter incoming routes\n"
5491 "Filter outgoing routes\n")
5493 /* Set route-map to the peer. */
5494 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5495 afi_t afi
, safi_t safi
, const char *name_str
,
5496 const char *direct_str
)
5500 int direct
= RMAP_IN
;
5502 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5504 return CMD_WARNING_CONFIG_FAILED
;
5506 /* Check filter direction. */
5507 if (strncmp(direct_str
, "in", 2) == 0)
5509 else if (strncmp(direct_str
, "o", 1) == 0)
5512 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
);
5514 return bgp_vty_return(vty
, ret
);
5517 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5518 afi_t afi
, safi_t safi
,
5519 const char *direct_str
)
5523 int direct
= RMAP_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
, "in", 2) == 0)
5532 else if (strncmp(direct_str
, "o", 1) == 0)
5535 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5537 return bgp_vty_return(vty
, ret
);
5540 DEFUN (neighbor_route_map
,
5541 neighbor_route_map_cmd
,
5542 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5545 "Apply route map to neighbor\n"
5546 "Name of route map\n"
5547 "Apply map to incoming routes\n"
5548 "Apply map to outbound routes\n")
5553 return peer_route_map_set_vty(
5554 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5555 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5558 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5559 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5560 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5561 "Apply route map to neighbor\n"
5562 "Name of route map\n"
5563 "Apply map to incoming routes\n"
5564 "Apply map to outbound routes\n")
5566 DEFUN (no_neighbor_route_map
,
5567 no_neighbor_route_map_cmd
,
5568 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5572 "Apply route map to neighbor\n"
5573 "Name of route map\n"
5574 "Apply map to incoming routes\n"
5575 "Apply map to outbound routes\n")
5579 return peer_route_map_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_route_map
, no_neighbor_route_map_hidden_cmd
,
5585 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5586 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5587 "Apply route map to neighbor\n"
5588 "Name of route map\n"
5589 "Apply map to incoming routes\n"
5590 "Apply map to outbound routes\n")
5592 /* Set unsuppress-map to the peer. */
5593 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5594 afi_t afi
, safi_t safi
,
5595 const char *name_str
)
5600 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5602 return CMD_WARNING_CONFIG_FAILED
;
5604 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
);
5606 return bgp_vty_return(vty
, ret
);
5609 /* Unset route-map from the peer. */
5610 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5611 afi_t afi
, safi_t safi
)
5616 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5618 return CMD_WARNING_CONFIG_FAILED
;
5620 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5622 return bgp_vty_return(vty
, ret
);
5625 DEFUN (neighbor_unsuppress_map
,
5626 neighbor_unsuppress_map_cmd
,
5627 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5630 "Route-map to selectively unsuppress suppressed routes\n"
5631 "Name of route map\n")
5635 return peer_unsuppress_map_set_vty(
5636 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5637 argv
[idx_word
]->arg
);
5640 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5641 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5642 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5643 "Route-map to selectively unsuppress suppressed routes\n"
5644 "Name of route map\n")
5646 DEFUN (no_neighbor_unsuppress_map
,
5647 no_neighbor_unsuppress_map_cmd
,
5648 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5652 "Route-map to selectively unsuppress suppressed routes\n"
5653 "Name of route map\n")
5656 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5658 bgp_node_safi(vty
));
5661 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5662 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5663 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5664 "Route-map to selectively unsuppress suppressed routes\n"
5665 "Name of route map\n")
5667 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5668 afi_t afi
, safi_t safi
,
5669 const char *num_str
,
5670 const char *threshold_str
, int warning
,
5671 const char *restart_str
)
5679 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5681 return CMD_WARNING_CONFIG_FAILED
;
5683 max
= strtoul(num_str
, NULL
, 10);
5685 threshold
= atoi(threshold_str
);
5687 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5690 restart
= atoi(restart_str
);
5694 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5697 return bgp_vty_return(vty
, ret
);
5700 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5701 afi_t afi
, safi_t safi
)
5706 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5708 return CMD_WARNING_CONFIG_FAILED
;
5710 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5712 return bgp_vty_return(vty
, ret
);
5715 /* Maximum number of prefix configuration. prefix count is different
5716 for each peer configuration. So this configuration can be set for
5717 each peer configuration. */
5718 DEFUN (neighbor_maximum_prefix
,
5719 neighbor_maximum_prefix_cmd
,
5720 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5723 "Maximum number of prefix accept from this peer\n"
5724 "maximum no. of prefix limit\n")
5728 return peer_maximum_prefix_set_vty(
5729 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5730 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5733 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5734 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5735 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5736 "Maximum number of prefix accept from this peer\n"
5737 "maximum no. of prefix limit\n")
5739 DEFUN (neighbor_maximum_prefix_threshold
,
5740 neighbor_maximum_prefix_threshold_cmd
,
5741 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5744 "Maximum number of prefix accept from this peer\n"
5745 "maximum no. of prefix limit\n"
5746 "Threshold value (%) at which to generate a warning msg\n")
5750 int idx_number_2
= 4;
5751 return peer_maximum_prefix_set_vty(
5752 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5753 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5757 neighbor_maximum_prefix_threshold
,
5758 neighbor_maximum_prefix_threshold_hidden_cmd
,
5759 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5760 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5761 "Maximum number of prefix accept from this peer\n"
5762 "maximum no. of prefix limit\n"
5763 "Threshold value (%) at which to generate a warning msg\n")
5765 DEFUN (neighbor_maximum_prefix_warning
,
5766 neighbor_maximum_prefix_warning_cmd
,
5767 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5770 "Maximum number of prefix accept from this peer\n"
5771 "maximum no. of prefix limit\n"
5772 "Only give warning message when limit is exceeded\n")
5776 return peer_maximum_prefix_set_vty(
5777 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5778 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
5782 neighbor_maximum_prefix_warning
,
5783 neighbor_maximum_prefix_warning_hidden_cmd
,
5784 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5785 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5786 "Maximum number of prefix accept from this peer\n"
5787 "maximum no. of prefix limit\n"
5788 "Only give warning message when limit is exceeded\n")
5790 DEFUN (neighbor_maximum_prefix_threshold_warning
,
5791 neighbor_maximum_prefix_threshold_warning_cmd
,
5792 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5795 "Maximum number of prefix accept from this peer\n"
5796 "maximum no. of prefix limit\n"
5797 "Threshold value (%) at which to generate a warning msg\n"
5798 "Only give warning message when limit is exceeded\n")
5802 int idx_number_2
= 4;
5803 return peer_maximum_prefix_set_vty(
5804 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5805 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
5809 neighbor_maximum_prefix_threshold_warning
,
5810 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
5811 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5812 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5813 "Maximum number of prefix accept from this peer\n"
5814 "maximum no. of prefix limit\n"
5815 "Threshold value (%) at which to generate a warning msg\n"
5816 "Only give warning message when limit is exceeded\n")
5818 DEFUN (neighbor_maximum_prefix_restart
,
5819 neighbor_maximum_prefix_restart_cmd
,
5820 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5823 "Maximum number of prefix accept from this peer\n"
5824 "maximum no. of prefix limit\n"
5825 "Restart bgp connection after limit is exceeded\n"
5826 "Restart interval in minutes\n")
5830 int idx_number_2
= 5;
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, argv
[idx_number_2
]->arg
);
5837 neighbor_maximum_prefix_restart
,
5838 neighbor_maximum_prefix_restart_hidden_cmd
,
5839 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5840 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5841 "Maximum number of prefix accept from this peer\n"
5842 "maximum no. of prefix limit\n"
5843 "Restart bgp connection after limit is exceeded\n"
5844 "Restart interval in minutes\n")
5846 DEFUN (neighbor_maximum_prefix_threshold_restart
,
5847 neighbor_maximum_prefix_threshold_restart_cmd
,
5848 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5851 "Maximum number of prefixes to accept from this peer\n"
5852 "maximum no. of prefix limit\n"
5853 "Threshold value (%) at which to generate a warning msg\n"
5854 "Restart bgp connection after limit is exceeded\n"
5855 "Restart interval in minutes\n")
5859 int idx_number_2
= 4;
5860 int idx_number_3
= 6;
5861 return peer_maximum_prefix_set_vty(
5862 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5863 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
5864 argv
[idx_number_3
]->arg
);
5868 neighbor_maximum_prefix_threshold_restart
,
5869 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
5870 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5871 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5872 "Maximum number of prefixes to accept from this peer\n"
5873 "maximum no. of prefix limit\n"
5874 "Threshold value (%) at which to generate a warning msg\n"
5875 "Restart bgp connection after limit is exceeded\n"
5876 "Restart interval in minutes\n")
5878 DEFUN (no_neighbor_maximum_prefix
,
5879 no_neighbor_maximum_prefix_cmd
,
5880 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5884 "Maximum number of prefixes to accept from this peer\n"
5885 "maximum no. of prefix limit\n"
5886 "Threshold value (%) at which to generate a warning msg\n"
5887 "Restart bgp connection after limit is exceeded\n"
5888 "Restart interval in minutes\n"
5889 "Only give warning message when limit is exceeded\n")
5892 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
5894 bgp_node_safi(vty
));
5898 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
5899 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5900 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5901 "Maximum number of prefixes to accept from this peer\n"
5902 "maximum no. of prefix limit\n"
5903 "Threshold value (%) at which to generate a warning msg\n"
5904 "Restart bgp connection after limit is exceeded\n"
5905 "Restart interval in minutes\n"
5906 "Only give warning message when limit is exceeded\n")
5909 /* "neighbor allowas-in" */
5910 DEFUN (neighbor_allowas_in
,
5911 neighbor_allowas_in_cmd
,
5912 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5915 "Accept as-path with my AS present in it\n"
5916 "Number of occurances of AS number\n"
5917 "Only accept my AS in the as-path if the route was originated in my AS\n")
5920 int idx_number_origin
= 3;
5926 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5928 return CMD_WARNING_CONFIG_FAILED
;
5930 if (argc
<= idx_number_origin
)
5933 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
5936 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
5939 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5942 return bgp_vty_return(vty
, ret
);
5946 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
5947 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5948 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5949 "Accept as-path with my AS present in it\n"
5950 "Number of occurances of AS number\n"
5951 "Only accept my AS in the as-path if the route was originated in my AS\n")
5953 DEFUN (no_neighbor_allowas_in
,
5954 no_neighbor_allowas_in_cmd
,
5955 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5959 "allow local ASN appears in aspath attribute\n"
5960 "Number of occurances of AS number\n"
5961 "Only accept my AS in the as-path if the route was originated in my AS\n")
5967 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5969 return CMD_WARNING_CONFIG_FAILED
;
5971 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
5972 bgp_node_safi(vty
));
5974 return bgp_vty_return(vty
, ret
);
5978 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
5979 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5980 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5981 "allow local ASN appears in aspath attribute\n"
5982 "Number of occurances of AS number\n"
5983 "Only accept my AS in the as-path if the route was originated in my AS\n")
5985 DEFUN (neighbor_ttl_security
,
5986 neighbor_ttl_security_cmd
,
5987 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
5990 "BGP ttl-security parameters\n"
5991 "Specify the maximum number of hops to the BGP peer\n"
5992 "Number of hops to BGP peer\n")
5999 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6001 return CMD_WARNING_CONFIG_FAILED
;
6003 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6006 * If 'neighbor swpX', then this is for directly connected peers,
6007 * we should not accept a ttl-security hops value greater than 1.
6009 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6011 "%s is directly connected peer, hops cannot exceed 1\n",
6012 argv
[idx_peer
]->arg
);
6013 return CMD_WARNING_CONFIG_FAILED
;
6016 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6019 DEFUN (no_neighbor_ttl_security
,
6020 no_neighbor_ttl_security_cmd
,
6021 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6025 "BGP ttl-security parameters\n"
6026 "Specify the maximum number of hops to the BGP peer\n"
6027 "Number of hops to BGP peer\n")
6032 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6034 return CMD_WARNING_CONFIG_FAILED
;
6036 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6039 DEFUN (neighbor_addpath_tx_all_paths
,
6040 neighbor_addpath_tx_all_paths_cmd
,
6041 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6044 "Use addpath to advertise all paths to a neighbor\n")
6049 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6051 return CMD_WARNING_CONFIG_FAILED
;
6053 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6055 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
6058 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6059 neighbor_addpath_tx_all_paths_hidden_cmd
,
6060 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6061 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6062 "Use addpath to advertise all paths to a neighbor\n")
6064 DEFUN (no_neighbor_addpath_tx_all_paths
,
6065 no_neighbor_addpath_tx_all_paths_cmd
,
6066 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6070 "Use addpath to advertise all paths to a neighbor\n")
6073 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6074 bgp_node_afi(vty
), bgp_node_safi(vty
),
6075 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
6078 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6079 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6080 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6081 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6082 "Use addpath to advertise all paths to a neighbor\n")
6084 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6085 neighbor_addpath_tx_bestpath_per_as_cmd
,
6086 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6089 "Use addpath to advertise the bestpath per each neighboring AS\n")
6094 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6096 return CMD_WARNING_CONFIG_FAILED
;
6098 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6100 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
6103 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6104 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6105 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6106 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6107 "Use addpath to advertise the bestpath per each neighboring AS\n")
6109 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6110 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6111 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6115 "Use addpath to advertise the bestpath per each neighboring AS\n")
6118 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6119 bgp_node_afi(vty
), bgp_node_safi(vty
),
6120 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
6123 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6124 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6125 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6126 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6127 "Use addpath to advertise the bestpath per each neighboring AS\n")
6129 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6130 struct ecommunity
**list
)
6132 struct ecommunity
*ecom
= NULL
;
6133 struct ecommunity
*ecomadd
;
6135 for (; argc
; --argc
, ++argv
) {
6137 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6138 ECOMMUNITY_ROUTE_TARGET
, 0);
6140 vty_out(vty
, "Malformed community-list value\n");
6142 ecommunity_free(&ecom
);
6143 return CMD_WARNING_CONFIG_FAILED
;
6147 ecommunity_merge(ecom
, ecomadd
);
6148 ecommunity_free(&ecomadd
);
6155 ecommunity_free(&*list
);
6162 static int vpn_policy_getafi(struct vty
*vty
, int *doafi
)
6164 switch (vty
->node
) {
6173 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6174 return CMD_WARNING_CONFIG_FAILED
;
6179 DEFPY (af_rd_vpn_export
,
6180 af_rd_vpn_export_cmd
,
6181 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6183 "Specify route distinguisher\n"
6184 "Between current address-family and vpn\n"
6185 "For routes leaked from current address-family to vpn\n"
6186 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6188 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6189 struct prefix_rd prd
;
6191 int doafi
[AFI_MAX
] = {0};
6196 if (argv_find(argv
, argc
, "no", &idx
))
6200 ret
= str2prefix_rd(rd_str
, &prd
);
6202 vty_out(vty
, "%% Malformed rd\n");
6203 return CMD_WARNING_CONFIG_FAILED
;
6207 ret
= vpn_policy_getafi(vty
, doafi
);
6208 if (ret
!= CMD_SUCCESS
)
6212 for (afi
= 0; afi
< AFI_MAX
; ++afi
) {
6216 /* pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6218 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6219 bgp_get_default(), bgp
);
6222 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6223 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6224 BGP_VPN_POLICY_TOVPN_RD_SET
);
6226 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6227 BGP_VPN_POLICY_TOVPN_RD_SET
);
6230 /* post-change: re-export vpn routes */
6231 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6232 bgp_get_default(), bgp
);
6238 ALIAS (af_rd_vpn_export
,
6239 af_no_rd_vpn_export_cmd
,
6242 "Specify route distinguisher\n"
6243 "Between current address-family and vpn\n"
6244 "For routes leaked from current address-family to vpn\n")
6246 DEFPY (af_label_vpn_export
,
6247 af_label_vpn_export_cmd
,
6248 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6250 "label value for VRF\n"
6251 "Between current address-family and vpn\n"
6252 "For routes leaked from current address-family to vpn\n"
6253 "Label Value <0-1048575>\n"
6254 "Automatically assign a label\n")
6256 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6257 mpls_label_t label
= MPLS_LABEL_NONE
;
6258 int doafi
[AFI_MAX
] = {0};
6264 if (argv_find(argv
, argc
, "no", &idx
))
6269 label
= label_val
; /* parser should force unsigned */
6272 ret
= vpn_policy_getafi(vty
, doafi
);
6273 if (ret
!= CMD_SUCCESS
)
6276 for (afi
= 0; afi
< AFI_MAX
; ++afi
) {
6280 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6281 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6283 continue; /* no change */
6286 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6288 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6289 bgp_get_default(), bgp
);
6291 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6292 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6294 if (bgp
->vpn_policy
[afi
].tovpn_label
!=
6298 * label has previously been automatically
6299 * assigned by labelpool: release it
6301 * NB if tovpn_label == MPLS_LABEL_NONE it
6302 * means the automatic assignment is in flight
6303 * and therefore the labelpool callback must
6304 * detect that the auto label is not needed.
6307 bgp_lp_release(LP_TYPE_VRF
,
6308 &bgp
->vpn_policy
[afi
],
6309 bgp
->vpn_policy
[afi
].tovpn_label
);
6311 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6312 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6315 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6317 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6318 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6319 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6320 vpn_leak_label_callback
);
6323 /* post-change: re-export vpn routes */
6324 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6325 bgp_get_default(), bgp
);
6331 ALIAS (af_label_vpn_export
,
6332 af_no_label_vpn_export_cmd
,
6333 "no label vpn export",
6335 "label value for VRF\n"
6336 "Between current address-family and vpn\n"
6337 "For routes leaked from current address-family to vpn\n")
6339 DEFPY (af_nexthop_vpn_export
,
6340 af_nexthop_vpn_export_cmd
,
6341 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6343 "Specify next hop to use for VRF advertised prefixes\n"
6344 "Between current address-family and vpn\n"
6345 "For routes leaked from current address-family to vpn\n"
6349 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6350 int doafi
[AFI_MAX
] = {0};
6357 if (argv_find(argv
, argc
, "no", &idx
))
6361 if (!sockunion2hostprefix(nexthop_str
, &p
))
6362 return CMD_WARNING_CONFIG_FAILED
;
6365 ret
= vpn_policy_getafi(vty
, doafi
);
6366 if (ret
!= CMD_SUCCESS
)
6369 for (afi
= 0; afi
< AFI_MAX
; ++afi
) {
6374 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6376 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6377 bgp_get_default(), bgp
);
6380 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6381 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6382 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6384 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6385 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6388 /* post-change: re-export vpn routes */
6389 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6390 bgp_get_default(), bgp
);
6396 ALIAS (af_nexthop_vpn_export
,
6397 af_no_nexthop_vpn_export_cmd
,
6398 "no nexthop vpn export",
6400 "Specify next hop to use for VRF advertised prefixes\n"
6401 "Between current address-family and vpn\n"
6402 "For routes leaked from current address-family to vpn\n")
6404 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6406 if (!strcmp(dstr
, "import")) {
6407 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6408 } else if (!strcmp(dstr
, "export")) {
6409 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6410 } else if (!strcmp(dstr
, "both")) {
6411 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6412 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6414 vty_out(vty
, "%% direction parse error\n");
6415 return CMD_WARNING_CONFIG_FAILED
;
6420 DEFPY (af_rt_vpn_imexport
,
6421 af_rt_vpn_imexport_cmd
,
6422 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6424 "Specify route target list\n"
6425 "Specify route target list\n"
6426 "Between current address-family and vpn\n"
6427 "For routes leaked from vpn to current address-family: match any\n"
6428 "For routes leaked from current address-family to vpn: set\n"
6429 "both import: match any and export: set\n"
6430 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6432 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6434 struct ecommunity
*ecom
= NULL
;
6435 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6436 int doafi
[AFI_MAX
] = {0};
6437 vpn_policy_direction_t dir
;
6442 if (argv_find(argv
, argc
, "no", &idx
))
6445 ret
= vpn_policy_getafi(vty
, doafi
);
6446 if (ret
!= CMD_SUCCESS
)
6449 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6450 if (ret
!= CMD_SUCCESS
)
6454 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6455 vty_out(vty
, "%% Missing RTLIST\n");
6456 return CMD_WARNING_CONFIG_FAILED
;
6458 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6459 if (ret
!= CMD_SUCCESS
) {
6464 for (afi
= 0; afi
< AFI_MAX
; ++afi
) {
6467 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6471 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6474 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6476 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6477 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6478 ecommunity_dup(ecom
);
6480 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6482 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6483 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6486 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6490 ecommunity_free(&ecom
);
6495 ALIAS (af_rt_vpn_imexport
,
6496 af_no_rt_vpn_imexport_cmd
,
6497 "no <rt|route-target> vpn <import|export|both>$direction_str",
6499 "Specify route target list\n"
6500 "Specify route target list\n"
6501 "Between current address-family and vpn\n"
6502 "For routes leaked from vpn to current address-family\n"
6503 "For routes leaked from current address-family to vpn\n"
6504 "both import and export\n")
6506 DEFPY (af_route_map_vpn_imexport
,
6507 af_route_map_vpn_imexport_cmd
,
6508 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6509 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6511 "Specify route map\n"
6512 "Between current address-family and vpn\n"
6513 "For routes leaked from vpn to current address-family\n"
6514 "For routes leaked from current address-family to vpn\n"
6515 "name of route-map\n")
6517 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6519 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6520 int doafi
[AFI_MAX
] = {0};
6521 vpn_policy_direction_t dir
;
6526 if (argv_find(argv
, argc
, "no", &idx
))
6529 ret
= vpn_policy_getafi(vty
, doafi
);
6530 if (ret
!= CMD_SUCCESS
)
6533 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6534 if (ret
!= CMD_SUCCESS
)
6537 for (afi
= 0; afi
< AFI_MAX
; ++afi
) {
6540 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6544 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6547 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6548 XFREE(MTYPE_ROUTE_MAP_NAME
,
6549 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6550 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6551 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6552 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6553 route_map_lookup_by_name(rmap_str
);
6555 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6556 XFREE(MTYPE_ROUTE_MAP_NAME
,
6557 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6558 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6559 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6562 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6569 ALIAS (af_route_map_vpn_imexport
,
6570 af_no_route_map_vpn_imexport_cmd
,
6571 "no route-map vpn <import|export>$direction_str",
6573 "Specify route map\n"
6574 "Between current address-family and vpn\n"
6575 "For routes leaked from vpn to current address-family\n"
6576 "For routes leaked from current address-family to vpn\n")
6578 /* This command is valid only in a bgp vrf instance or the default instance */
6579 DEFPY (bgp_imexport_vpn
,
6580 bgp_imexport_vpn_cmd
,
6581 "[no] <import|export>$direction_str vpn",
6583 "Import routes to this address-family\n"
6584 "Export routes from this address-family\n"
6585 "to/from default instance VPN RIB\n")
6587 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6594 vpn_policy_direction_t dir
;
6596 if (argv_find(argv
, argc
, "no", &idx
))
6599 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
6600 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
6602 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
6603 return CMD_WARNING_CONFIG_FAILED
;
6606 afi
= bgp_node_afi(vty
);
6607 safi
= bgp_node_safi(vty
);
6608 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
6609 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
6610 return CMD_WARNING_CONFIG_FAILED
;
6613 if (!strcmp(direction_str
, "import")) {
6614 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
6615 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6616 } else if (!strcmp(direction_str
, "export")) {
6617 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
6618 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
6620 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
6621 return CMD_WARNING_CONFIG_FAILED
;
6624 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6627 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6628 if (!previous_state
) {
6629 /* trigger export current vrf */
6630 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6633 if (previous_state
) {
6634 /* trigger un-export current vrf */
6635 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6637 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6643 DEFPY (af_routetarget_import
,
6644 af_routetarget_import_cmd
,
6645 "[no] <rt|route-target> redirect import RTLIST...",
6647 "Specify route target list\n"
6648 "Specify route target list\n"
6649 "Flow-spec redirect type route target\n"
6650 "Import routes to this address-family\n"
6651 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6653 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6655 struct ecommunity
*ecom
= NULL
;
6656 int doafi
[AFI_MAX
] = {0};
6661 if (argv_find(argv
, argc
, "no", &idx
))
6664 ret
= vpn_policy_getafi(vty
, doafi
);
6665 if (ret
!= CMD_SUCCESS
)
6668 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6669 vty_out(vty
, "%% Missing RTLIST\n");
6670 return CMD_WARNING_CONFIG_FAILED
;
6672 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6673 if (ret
!= CMD_SUCCESS
)
6676 for (afi
= 0; afi
< AFI_MAX
; ++afi
) {
6680 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
6682 &bgp
->vpn_policy
[afi
]
6683 .import_redirect_rtlist
);
6684 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
6685 ecommunity_dup(ecom
);
6687 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
6689 &bgp
->vpn_policy
[afi
]
6690 .import_redirect_rtlist
);
6691 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
6695 ecommunity_free(&ecom
);
6700 DEFUN_NOSH (address_family_ipv4_safi
,
6701 address_family_ipv4_safi_cmd
,
6702 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
6703 "Enter Address Family command mode\n"
6705 BGP_SAFI_WITH_LABEL_HELP_STR
)
6709 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6710 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6711 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
6712 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
6713 && safi
!= SAFI_EVPN
) {
6715 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
6716 return CMD_WARNING_CONFIG_FAILED
;
6718 vty
->node
= bgp_node_type(AFI_IP
, safi
);
6720 vty
->node
= BGP_IPV4_NODE
;
6725 DEFUN_NOSH (address_family_ipv6_safi
,
6726 address_family_ipv6_safi_cmd
,
6727 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
6728 "Enter Address Family command mode\n"
6730 BGP_SAFI_WITH_LABEL_HELP_STR
)
6733 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6734 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6735 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
6736 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
6737 && safi
!= SAFI_EVPN
) {
6739 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
6740 return CMD_WARNING_CONFIG_FAILED
;
6742 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
6744 vty
->node
= BGP_IPV6_NODE
;
6749 #ifdef KEEP_OLD_VPN_COMMANDS
6750 DEFUN_NOSH (address_family_vpnv4
,
6751 address_family_vpnv4_cmd
,
6752 "address-family vpnv4 [unicast]",
6753 "Enter Address Family command mode\n"
6755 "Address Family modifier\n")
6757 vty
->node
= BGP_VPNV4_NODE
;
6761 DEFUN_NOSH (address_family_vpnv6
,
6762 address_family_vpnv6_cmd
,
6763 "address-family vpnv6 [unicast]",
6764 "Enter Address Family command mode\n"
6766 "Address Family modifier\n")
6768 vty
->node
= BGP_VPNV6_NODE
;
6773 DEFUN_NOSH (address_family_evpn
,
6774 address_family_evpn_cmd
,
6775 "address-family l2vpn evpn",
6776 "Enter Address Family command mode\n"
6778 "Address Family modifier\n")
6780 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6781 vty
->node
= BGP_EVPN_NODE
;
6785 DEFUN_NOSH (exit_address_family
,
6786 exit_address_family_cmd
,
6787 "exit-address-family",
6788 "Exit from Address Family configuration mode\n")
6790 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
6791 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
6792 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
6793 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
6794 || vty
->node
== BGP_EVPN_NODE
6795 || vty
->node
== BGP_FLOWSPECV4_NODE
6796 || vty
->node
== BGP_FLOWSPECV6_NODE
)
6797 vty
->node
= BGP_NODE
;
6801 /* Recalculate bestpath and re-advertise a prefix */
6802 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
6803 const char *ip_str
, afi_t afi
, safi_t safi
,
6804 struct prefix_rd
*prd
)
6807 struct prefix match
;
6808 struct bgp_node
*rn
;
6809 struct bgp_node
*rm
;
6811 struct bgp_table
*table
;
6812 struct bgp_table
*rib
;
6814 /* BGP structure lookup. */
6816 bgp
= bgp_lookup_by_name(view_name
);
6818 vty_out(vty
, "%% Can't find BGP instance %s\n",
6823 bgp
= bgp_get_default();
6825 vty_out(vty
, "%% No BGP process is configured\n");
6830 /* Check IP address argument. */
6831 ret
= str2prefix(ip_str
, &match
);
6833 vty_out(vty
, "%% address is malformed\n");
6837 match
.family
= afi2family(afi
);
6838 rib
= bgp
->rib
[afi
][safi
];
6840 if (safi
== SAFI_MPLS_VPN
) {
6841 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
6842 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
6845 if ((table
= rn
->info
) != NULL
) {
6846 if ((rm
= bgp_node_match(table
, &match
))
6849 == match
.prefixlen
) {
6851 BGP_NODE_USER_CLEAR
);
6852 bgp_process(bgp
, rm
, afi
, safi
);
6854 bgp_unlock_node(rm
);
6859 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
6860 if (rn
->p
.prefixlen
== match
.prefixlen
) {
6861 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
6862 bgp_process(bgp
, rn
, afi
, safi
);
6864 bgp_unlock_node(rn
);
6871 /* one clear bgp command to rule them all */
6872 DEFUN (clear_ip_bgp_all
,
6873 clear_ip_bgp_all_cmd
,
6874 "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>]",
6878 BGP_INSTANCE_HELP_STR
6880 BGP_SAFI_WITH_LABEL_HELP_STR
6882 "BGP neighbor address to clear\n"
6883 "BGP IPv6 neighbor to clear\n"
6884 "BGP neighbor on interface to clear\n"
6885 "Clear peers with the AS number\n"
6886 "Clear all external peers\n"
6887 "Clear all members of peer-group\n"
6888 "BGP peer-group name\n"
6893 "Push out prefix-list ORF and do inbound soft reconfig\n"
6898 afi_t afi
= AFI_IP6
;
6899 safi_t safi
= SAFI_UNICAST
;
6900 enum clear_sort clr_sort
= clear_peer
;
6901 enum bgp_clear_type clr_type
;
6902 char *clr_arg
= NULL
;
6906 /* clear [ip] bgp */
6907 if (argv_find(argv
, argc
, "ip", &idx
))
6910 /* [<view|vrf> VIEWVRFNAME] */
6911 if (argv_find(argv
, argc
, "view", &idx
)
6912 || argv_find(argv
, argc
, "vrf", &idx
)) {
6913 vrf
= argv
[idx
+ 1]->arg
;
6917 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
6918 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
6919 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
6921 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */
6922 if (argv_find(argv
, argc
, "*", &idx
)) {
6923 clr_sort
= clear_all
;
6924 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6925 clr_sort
= clear_peer
;
6926 clr_arg
= argv
[idx
]->arg
;
6927 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
6928 clr_sort
= clear_peer
;
6929 clr_arg
= argv
[idx
]->arg
;
6930 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
6931 clr_sort
= clear_group
;
6933 clr_arg
= argv
[idx
]->arg
;
6934 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
6935 clr_sort
= clear_peer
;
6936 clr_arg
= argv
[idx
]->arg
;
6937 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
6938 clr_sort
= clear_as
;
6939 clr_arg
= argv
[idx
]->arg
;
6940 } else if (argv_find(argv
, argc
, "external", &idx
)) {
6941 clr_sort
= clear_external
;
6944 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
6945 if (argv_find(argv
, argc
, "soft", &idx
)) {
6946 if (argv_find(argv
, argc
, "in", &idx
)
6947 || argv_find(argv
, argc
, "out", &idx
))
6948 clr_type
= strmatch(argv
[idx
]->text
, "in")
6950 : BGP_CLEAR_SOFT_OUT
;
6952 clr_type
= BGP_CLEAR_SOFT_BOTH
;
6953 } else if (argv_find(argv
, argc
, "in", &idx
)) {
6954 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
6955 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
6956 : BGP_CLEAR_SOFT_IN
;
6957 } else if (argv_find(argv
, argc
, "out", &idx
)) {
6958 clr_type
= BGP_CLEAR_SOFT_OUT
;
6960 clr_type
= BGP_CLEAR_SOFT_NONE
;
6962 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
6965 DEFUN (clear_ip_bgp_prefix
,
6966 clear_ip_bgp_prefix_cmd
,
6967 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
6971 BGP_INSTANCE_HELP_STR
6972 "Clear bestpath and re-advertise\n"
6976 char *prefix
= NULL
;
6980 /* [<view|vrf> VIEWVRFNAME] */
6981 if (argv_find(argv
, argc
, "VIEWVRFNAME", &idx
))
6982 vrf
= argv
[idx
]->arg
;
6984 prefix
= argv
[argc
- 1]->arg
;
6986 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
6989 DEFUN (clear_bgp_ipv6_safi_prefix
,
6990 clear_bgp_ipv6_safi_prefix_cmd
,
6991 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
6997 "Clear bestpath and re-advertise\n"
7001 int idx_ipv6_prefix
= 0;
7002 safi_t safi
= SAFI_UNICAST
;
7003 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7004 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7006 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7007 return bgp_clear_prefix(
7008 vty
, NULL
, prefix
, AFI_IP6
,
7012 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7013 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7014 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7018 BGP_INSTANCE_HELP_STR
7021 "Clear bestpath and re-advertise\n"
7026 int idx_ipv6_prefix
= 0;
7027 safi_t safi
= SAFI_UNICAST
;
7028 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7029 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7030 /* [<view|vrf> VIEWVRFNAME] */
7031 char *vrfview
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx_word
) ?
7032 argv
[idx_word
]->arg
: NULL
;
7034 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7036 return bgp_clear_prefix(
7037 vty
, vrfview
, prefix
,
7038 AFI_IP6
, safi
, NULL
);
7041 DEFUN (show_bgp_views
,
7043 "show [ip] bgp views",
7047 "Show the defined BGP views\n")
7049 struct list
*inst
= bm
->bgp
;
7050 struct listnode
*node
;
7053 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7054 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7058 vty_out(vty
, "Defined BGP views:\n");
7059 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7061 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7063 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7070 DEFUN (show_bgp_vrfs
,
7072 "show [ip] bgp vrfs [json]",
7079 char buf
[ETHER_ADDR_STRLEN
];
7080 struct list
*inst
= bm
->bgp
;
7081 struct listnode
*node
;
7083 uint8_t uj
= use_json(argc
, argv
);
7084 json_object
*json
= NULL
;
7085 json_object
*json_vrfs
= NULL
;
7088 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7089 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7094 json
= json_object_new_object();
7095 json_vrfs
= json_object_new_object();
7098 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7099 const char *name
, *type
;
7101 struct listnode
*node
, *nnode
;
7102 int peers_cfg
, peers_estb
;
7103 json_object
*json_vrf
= NULL
;
7106 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7110 if (!uj
&& count
== 1)
7112 "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n",
7113 "Type", "Id", "routerId", "#PeersVfg",
7114 "#PeersEstb", "Name", "L3-VNI", "Rmac");
7116 peers_cfg
= peers_estb
= 0;
7118 json_vrf
= json_object_new_object();
7121 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7122 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7125 if (peer
->status
== Established
)
7129 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7139 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7141 : (int64_t)bgp
->vrf_id
;
7142 json_object_string_add(json_vrf
, "type", type
);
7143 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7144 json_object_string_add(json_vrf
, "routerId",
7145 inet_ntoa(bgp
->router_id
));
7146 json_object_int_add(json_vrf
, "numConfiguredPeers",
7148 json_object_int_add(json_vrf
, "numEstablishedPeers",
7151 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7152 json_object_string_add(
7154 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7155 json_object_object_add(json_vrfs
, name
, json_vrf
);
7158 "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n",
7160 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7162 inet_ntoa(bgp
->router_id
), peers_cfg
,
7163 peers_estb
, name
, bgp
->l3vni
,
7164 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7168 json_object_object_add(json
, "vrfs", json_vrfs
);
7170 json_object_int_add(json
, "totalVrfs", count
);
7172 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7173 json
, JSON_C_TO_STRING_PRETTY
));
7174 json_object_free(json
);
7178 "\nTotal number of VRFs (including default): %d\n",
7185 static void show_address_entry(struct hash_backet
*backet
, void *args
)
7187 struct vty
*vty
= (struct vty
*)args
;
7188 struct bgp_addr
*addr
= (struct bgp_addr
*)backet
->data
;
7190 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(addr
->addr
),
7194 static void show_tip_entry(struct hash_backet
*backet
, void *args
)
7196 struct vty
*vty
= (struct vty
*)args
;
7197 struct tip_addr
*tip
= (struct tip_addr
*)backet
->data
;
7199 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7203 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7205 vty_out(vty
, "self nexthop database:\n");
7206 hash_iterate(bgp
->address_hash
,
7207 (void (*)(struct hash_backet
*, void *))show_address_entry
,
7210 vty_out(vty
, "Tunnel-ip database:\n");
7211 hash_iterate(bgp
->tip_hash
,
7212 (void (*)(struct hash_backet
*, void *))show_tip_entry
,
7216 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7217 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7218 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7219 "martian next-hops\n"
7220 "martian next-hop database\n")
7222 struct bgp
*bgp
= NULL
;
7225 if (argv_find(argv
, argc
, "view", &idx
)
7226 || argv_find(argv
, argc
, "vrf", &idx
))
7227 bgp
= bgp_lookup_by_name(argv
[idx
+ 1]->arg
);
7229 bgp
= bgp_get_default();
7232 vty_out(vty
, "%% No BGP process is configured\n");
7235 bgp_show_martian_nexthops(vty
, bgp
);
7240 DEFUN (show_bgp_memory
,
7241 show_bgp_memory_cmd
,
7242 "show [ip] bgp memory",
7246 "Global BGP memory statistics\n")
7248 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7249 unsigned long count
;
7251 /* RIB related usage stats */
7252 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7253 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7254 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7255 count
* sizeof(struct bgp_node
)));
7257 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7258 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7259 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7260 count
* sizeof(struct bgp_info
)));
7261 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7262 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7264 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7265 count
* sizeof(struct bgp_info_extra
)));
7267 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7268 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7269 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7270 count
* sizeof(struct bgp_static
)));
7272 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7273 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7274 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7275 count
* sizeof(struct bpacket
)));
7278 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7279 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7280 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7281 count
* sizeof(struct bgp_adj_in
)));
7282 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7283 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7284 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7285 count
* sizeof(struct bgp_adj_out
)));
7287 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7288 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7290 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7291 count
* sizeof(struct bgp_nexthop_cache
)));
7293 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7294 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7296 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7297 count
* sizeof(struct bgp_damp_info
)));
7300 count
= attr_count();
7301 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7302 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7303 count
* sizeof(struct attr
)));
7305 if ((count
= attr_unknown_count()))
7306 vty_out(vty
, "%ld unknown attributes\n", count
);
7308 /* AS_PATH attributes */
7309 count
= aspath_count();
7310 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7311 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7312 count
* sizeof(struct aspath
)));
7314 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7315 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7316 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7317 count
* sizeof(struct assegment
)));
7319 /* Other attributes */
7320 if ((count
= community_count()))
7321 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7322 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7323 count
* sizeof(struct community
)));
7324 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7325 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7326 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7327 count
* sizeof(struct ecommunity
)));
7328 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7330 "%ld BGP large-community entries, using %s of memory\n",
7331 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7332 count
* sizeof(struct lcommunity
)));
7334 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7335 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7336 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7337 count
* sizeof(struct cluster_list
)));
7339 /* Peer related usage */
7340 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7341 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7342 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7343 count
* sizeof(struct peer
)));
7345 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7346 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7347 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7348 count
* sizeof(struct peer_group
)));
7351 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
7352 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
7353 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7354 count
* sizeof(struct hash
)));
7355 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
7356 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
7357 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7358 count
* sizeof(struct hash_backet
)));
7359 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7360 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7361 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7362 count
* sizeof(regex_t
)));
7366 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7368 json_object
*bestpath
= json_object_new_object();
7370 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7371 json_object_string_add(bestpath
, "asPath", "ignore");
7373 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7374 json_object_string_add(bestpath
, "asPath", "confed");
7376 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7377 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7378 json_object_string_add(bestpath
, "multiPathRelax",
7381 json_object_string_add(bestpath
, "multiPathRelax",
7384 json_object_string_add(bestpath
, "multiPathRelax", "false");
7386 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7387 json_object_string_add(bestpath
, "compareRouterId", "true");
7388 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7389 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7390 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7391 json_object_string_add(bestpath
, "med", "confed");
7392 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7393 json_object_string_add(bestpath
, "med",
7394 "missing-as-worst");
7396 json_object_string_add(bestpath
, "med", "true");
7399 json_object_object_add(json
, "bestPath", bestpath
);
7402 /* Show BGP peer's summary information. */
7403 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7404 uint8_t use_json
, json_object
*json
)
7407 struct listnode
*node
, *nnode
;
7408 unsigned int count
= 0, dn_count
= 0;
7409 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7410 char neighbor_buf
[VTY_BUFSIZ
];
7411 int neighbor_col_default_width
= 16;
7413 int max_neighbor_width
= 0;
7415 json_object
*json_peer
= NULL
;
7416 json_object
*json_peers
= NULL
;
7418 /* labeled-unicast routes are installed in the unicast table so in order
7420 * display the correct PfxRcd value we must look at SAFI_UNICAST
7422 if (safi
== SAFI_LABELED_UNICAST
)
7423 pfx_rcd_safi
= SAFI_UNICAST
;
7425 pfx_rcd_safi
= safi
;
7429 json
= json_object_new_object();
7431 json_peers
= json_object_new_object();
7433 /* Loop over all neighbors that will be displayed to determine
7435 * characters are needed for the Neighbor column
7437 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7438 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7441 if (peer
->afc
[afi
][safi
]) {
7442 memset(dn_flag
, '\0', sizeof(dn_flag
));
7443 if (peer_dynamic_neighbor(peer
))
7447 && bgp_flag_check(bgp
,
7448 BGP_FLAG_SHOW_HOSTNAME
))
7449 sprintf(neighbor_buf
, "%s%s(%s) ",
7450 dn_flag
, peer
->hostname
,
7453 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7456 len
= strlen(neighbor_buf
);
7458 if (len
> max_neighbor_width
)
7459 max_neighbor_width
= len
;
7463 /* Originally we displayed the Neighbor column as 16
7464 * characters wide so make that the default
7466 if (max_neighbor_width
< neighbor_col_default_width
)
7467 max_neighbor_width
= neighbor_col_default_width
;
7470 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7471 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7474 if (!peer
->afc
[afi
][safi
])
7479 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7482 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7484 : (int64_t)bgp
->vrf_id
;
7486 /* Usage summary and header */
7488 json_object_string_add(
7490 inet_ntoa(bgp
->router_id
));
7491 json_object_int_add(json
, "as", bgp
->as
);
7492 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7493 json_object_string_add(
7496 == BGP_INSTANCE_TYPE_DEFAULT
)
7501 "BGP router identifier %s, local AS number %u vrf-id %d",
7502 inet_ntoa(bgp
->router_id
), bgp
->as
,
7503 bgp
->vrf_id
== VRF_UNKNOWN
7505 : (int)bgp
->vrf_id
);
7509 if (bgp_update_delay_configured(bgp
)) {
7511 json_object_int_add(
7512 json
, "updateDelayLimit",
7513 bgp
->v_update_delay
);
7515 if (bgp
->v_update_delay
7516 != bgp
->v_establish_wait
)
7517 json_object_int_add(
7519 "updateDelayEstablishWait",
7520 bgp
->v_establish_wait
);
7522 if (bgp_update_delay_active(bgp
)) {
7523 json_object_string_add(
7525 "updateDelayFirstNeighbor",
7526 bgp
->update_delay_begin_time
);
7527 json_object_boolean_true_add(
7529 "updateDelayInProgress");
7531 if (bgp
->update_delay_over
) {
7532 json_object_string_add(
7534 "updateDelayFirstNeighbor",
7535 bgp
->update_delay_begin_time
);
7536 json_object_string_add(
7538 "updateDelayBestpathResumed",
7539 bgp
->update_delay_end_time
);
7540 json_object_string_add(
7542 "updateDelayZebraUpdateResume",
7543 bgp
->update_delay_zebra_resume_time
);
7544 json_object_string_add(
7546 "updateDelayPeerUpdateResume",
7547 bgp
->update_delay_peers_resume_time
);
7552 "Read-only mode update-delay limit: %d seconds\n",
7553 bgp
->v_update_delay
);
7554 if (bgp
->v_update_delay
7555 != bgp
->v_establish_wait
)
7557 " Establish wait: %d seconds\n",
7558 bgp
->v_establish_wait
);
7560 if (bgp_update_delay_active(bgp
)) {
7562 " First neighbor established: %s\n",
7563 bgp
->update_delay_begin_time
);
7565 " Delay in progress\n");
7567 if (bgp
->update_delay_over
) {
7569 " First neighbor established: %s\n",
7570 bgp
->update_delay_begin_time
);
7572 " Best-paths resumed: %s\n",
7573 bgp
->update_delay_end_time
);
7575 " zebra update resumed: %s\n",
7576 bgp
->update_delay_zebra_resume_time
);
7578 " peers update resumed: %s\n",
7579 bgp
->update_delay_peers_resume_time
);
7586 if (bgp_maxmed_onstartup_configured(bgp
)
7587 && bgp
->maxmed_active
)
7588 json_object_boolean_true_add(
7589 json
, "maxMedOnStartup");
7590 if (bgp
->v_maxmed_admin
)
7591 json_object_boolean_true_add(
7592 json
, "maxMedAdministrative");
7594 json_object_int_add(
7595 json
, "tableVersion",
7596 bgp_table_version(bgp
->rib
[afi
][safi
]));
7598 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7599 json_object_int_add(json
, "ribCount", ents
);
7600 json_object_int_add(
7602 ents
* sizeof(struct bgp_node
));
7604 ents
= listcount(bgp
->peer
);
7605 json_object_int_add(json
, "peerCount", ents
);
7606 json_object_int_add(json
, "peerMemory",
7607 ents
* sizeof(struct peer
));
7609 if ((ents
= listcount(bgp
->group
))) {
7610 json_object_int_add(
7611 json
, "peerGroupCount", ents
);
7612 json_object_int_add(
7613 json
, "peerGroupMemory",
7614 ents
* sizeof(struct
7618 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7619 BGP_CONFIG_DAMPENING
))
7620 json_object_boolean_true_add(
7621 json
, "dampeningEnabled");
7623 if (bgp_maxmed_onstartup_configured(bgp
)
7624 && bgp
->maxmed_active
)
7626 "Max-med on-startup active\n");
7627 if (bgp
->v_maxmed_admin
)
7629 "Max-med administrative active\n");
7631 vty_out(vty
, "BGP table version %" PRIu64
"\n",
7632 bgp_table_version(bgp
->rib
[afi
][safi
]));
7634 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7636 "RIB entries %ld, using %s of memory\n",
7638 mtype_memstr(memstrbuf
,
7640 ents
* sizeof(struct
7643 /* Peer related usage */
7644 ents
= listcount(bgp
->peer
);
7645 vty_out(vty
, "Peers %ld, using %s of memory\n",
7648 memstrbuf
, sizeof(memstrbuf
),
7649 ents
* sizeof(struct peer
)));
7651 if ((ents
= listcount(bgp
->group
)))
7653 "Peer groups %ld, using %s of memory\n",
7658 ents
* sizeof(struct
7661 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7662 BGP_CONFIG_DAMPENING
))
7663 vty_out(vty
, "Dampening enabled.\n");
7666 /* Subtract 8 here because 'Neighbor' is
7668 vty_out(vty
, "Neighbor");
7669 vty_out(vty
, "%*s", max_neighbor_width
- 8,
7672 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
7679 json_peer
= json_object_new_object();
7681 if (peer_dynamic_neighbor(peer
))
7682 json_object_boolean_true_add(json_peer
,
7686 json_object_string_add(json_peer
, "hostname",
7689 if (peer
->domainname
)
7690 json_object_string_add(json_peer
, "domainname",
7693 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
7694 json_object_int_add(json_peer
, "version", 4);
7695 json_object_int_add(json_peer
, "msgRcvd",
7696 PEER_TOTAL_RX(peer
));
7697 json_object_int_add(json_peer
, "msgSent",
7698 PEER_TOTAL_TX(peer
));
7700 json_object_int_add(json_peer
, "tableVersion",
7701 peer
->version
[afi
][safi
]);
7702 json_object_int_add(json_peer
, "outq",
7704 json_object_int_add(json_peer
, "inq", 0);
7705 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
7706 use_json
, json_peer
);
7707 json_object_int_add(json_peer
, "prefixReceivedCount",
7708 peer
->pcount
[afi
][pfx_rcd_safi
]);
7710 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
7711 json_object_string_add(json_peer
, "state",
7713 else if (CHECK_FLAG(peer
->sflags
,
7714 PEER_STATUS_PREFIX_OVERFLOW
))
7715 json_object_string_add(json_peer
, "state",
7718 json_object_string_add(
7720 lookup_msg(bgp_status_msg
, peer
->status
,
7724 json_object_string_add(json_peer
, "idType",
7726 else if (peer
->su
.sa
.sa_family
== AF_INET
)
7727 json_object_string_add(json_peer
, "idType",
7729 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
7730 json_object_string_add(json_peer
, "idType",
7733 json_object_object_add(json_peers
, peer
->host
,
7736 memset(dn_flag
, '\0', sizeof(dn_flag
));
7737 if (peer_dynamic_neighbor(peer
)) {
7743 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7744 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
7745 peer
->hostname
, peer
->host
);
7747 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
7749 /* pad the neighbor column with spaces */
7750 if (len
< max_neighbor_width
)
7751 vty_out(vty
, "%*s", max_neighbor_width
- len
,
7754 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
7755 peer
->as
, PEER_TOTAL_RX(peer
),
7756 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
7757 0, peer
->obuf
->count
,
7758 peer_uptime(peer
->uptime
, timebuf
,
7759 BGP_UPTIME_LEN
, 0, NULL
));
7761 if (peer
->status
== Established
)
7762 if (peer
->afc_recv
[afi
][pfx_rcd_safi
])
7763 vty_out(vty
, " %12ld",
7767 vty_out(vty
, " NoNeg");
7769 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
7770 vty_out(vty
, " Idle (Admin)");
7771 else if (CHECK_FLAG(
7773 PEER_STATUS_PREFIX_OVERFLOW
))
7774 vty_out(vty
, " Idle (PfxCt)");
7776 vty_out(vty
, " %12s",
7777 lookup_msg(bgp_status_msg
,
7778 peer
->status
, NULL
));
7785 json_object_object_add(json
, "peers", json_peers
);
7787 json_object_int_add(json
, "totalPeers", count
);
7788 json_object_int_add(json
, "dynamicPeers", dn_count
);
7790 bgp_show_bestpath_json(bgp
, json
);
7792 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7793 json
, JSON_C_TO_STRING_PRETTY
));
7794 json_object_free(json
);
7797 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
7801 "{\"error\": {\"message\": \"No %s neighbor configured\"}}\n",
7802 afi_safi_print(afi
, safi
));
7804 vty_out(vty
, "No %s neighbor is configured\n",
7805 afi_safi_print(afi
, safi
));
7808 if (dn_count
&& !use_json
) {
7809 vty_out(vty
, "* - dynamic neighbor\n");
7810 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
7811 dn_count
, bgp
->dynamic_neighbors_limit
);
7818 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
7819 int safi
, uint8_t use_json
,
7823 int afi_wildcard
= (afi
== AFI_MAX
);
7824 int safi_wildcard
= (safi
== SAFI_MAX
);
7825 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
7826 bool json_output
= false;
7828 if (use_json
&& is_wildcard
)
7829 vty_out(vty
, "{\n");
7831 afi
= 1; /* AFI_IP */
7832 while (afi
< AFI_MAX
) {
7834 safi
= 1; /* SAFI_UNICAST */
7835 while (safi
< SAFI_MAX
) {
7836 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
7840 * So limit output to those afi/safi
7842 * actualy have something interesting in
7846 json
= json_object_new_object();
7849 vty_out(vty
, ",\n");
7853 vty_out(vty
, "\"%s\":",
7857 vty_out(vty
, "\n%s Summary:\n",
7862 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
7874 if (use_json
&& is_wildcard
)
7875 vty_out(vty
, "}\n");
7876 else if (use_json
&& !json_output
)
7877 vty_out(vty
, "{}\n");
7880 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
7881 safi_t safi
, uint8_t use_json
)
7883 struct listnode
*node
, *nnode
;
7885 json_object
*json
= NULL
;
7889 vty_out(vty
, "{\n");
7891 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
7893 json
= json_object_new_object();
7896 vty_out(vty
, ",\n");
7900 vty_out(vty
, "\"%s\":",
7901 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7905 vty_out(vty
, "\nInstance %s:\n",
7906 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7910 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
7914 vty_out(vty
, "}\n");
7917 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
7918 safi_t safi
, uint8_t use_json
)
7923 if (strmatch(name
, "all")) {
7924 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
7928 bgp
= bgp_lookup_by_name(name
);
7932 vty_out(vty
, "{}\n");
7935 "%% No such BGP instance exist\n");
7939 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
7945 bgp
= bgp_get_default();
7948 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
7953 /* `show [ip] bgp summary' commands. */
7954 DEFUN (show_ip_bgp_summary
,
7955 show_ip_bgp_summary_cmd
,
7956 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
7960 BGP_INSTANCE_HELP_STR
7962 BGP_SAFI_WITH_LABEL_HELP_STR
7963 "Summary of BGP neighbor status\n"
7967 afi_t afi
= AFI_MAX
;
7968 safi_t safi
= SAFI_MAX
;
7973 if (argv_find(argv
, argc
, "ip", &idx
))
7975 /* [<view|vrf> VIEWVRFNAME] */
7976 if (argv_find(argv
, argc
, "view", &idx
)
7977 || argv_find(argv
, argc
, "vrf", &idx
))
7978 vrf
= argv
[++idx
]->arg
;
7979 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7980 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
7981 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7984 int uj
= use_json(argc
, argv
);
7986 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
7989 const char *afi_safi_print(afi_t afi
, safi_t safi
)
7991 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
7992 return "IPv4 Unicast";
7993 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
7994 return "IPv4 Multicast";
7995 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
7996 return "IPv4 Labeled Unicast";
7997 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
7999 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8000 return "IPv4 Encap";
8001 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8002 return "IPv4 Flowspec";
8003 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8004 return "IPv6 Unicast";
8005 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8006 return "IPv6 Multicast";
8007 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8008 return "IPv6 Labeled Unicast";
8009 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8011 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8012 return "IPv6 Encap";
8013 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8014 return "IPv6 Flowspec";
8015 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8016 return "L2VPN EVPN";
8022 * Please note that we have intentionally camelCased
8023 * the return strings here. So if you want
8024 * to use this function, please ensure you
8025 * are doing this within json output
8027 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8029 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8030 return "ipv4Unicast";
8031 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8032 return "ipv4Multicast";
8033 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8034 return "ipv4LabeledUnicast";
8035 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8037 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8039 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8040 return "ipv4Flowspec";
8041 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8042 return "ipv6Unicast";
8043 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8044 return "ipv6Multicast";
8045 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8046 return "ipv6LabeledUnicast";
8047 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8049 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8051 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8052 return "ipv6Flowspec";
8053 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8059 /* Show BGP peer's information. */
8060 enum show_type
{ show_all
, show_peer
};
8062 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8063 afi_t afi
, safi_t safi
,
8064 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8065 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8066 uint8_t use_json
, json_object
*json_pref
)
8069 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8070 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8072 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8073 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8074 json_object_string_add(json_pref
, "sendMode",
8075 "advertisedAndReceived");
8076 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8077 json_object_string_add(json_pref
, "sendMode",
8079 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8080 json_object_string_add(json_pref
, "sendMode",
8083 vty_out(vty
, " Send-mode: ");
8084 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8085 vty_out(vty
, "advertised");
8086 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8087 vty_out(vty
, "%sreceived",
8088 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8097 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8098 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8100 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8101 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8102 json_object_string_add(json_pref
, "recvMode",
8103 "advertisedAndReceived");
8104 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8105 json_object_string_add(json_pref
, "recvMode",
8107 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8108 json_object_string_add(json_pref
, "recvMode",
8111 vty_out(vty
, " Receive-mode: ");
8112 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8113 vty_out(vty
, "advertised");
8114 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8115 vty_out(vty
, "%sreceived",
8116 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8125 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8126 safi_t safi
, uint8_t use_json
,
8127 json_object
*json_neigh
)
8129 struct bgp_filter
*filter
;
8130 struct peer_af
*paf
;
8131 char orf_pfx_name
[BUFSIZ
];
8133 json_object
*json_af
= NULL
;
8134 json_object
*json_prefA
= NULL
;
8135 json_object
*json_prefB
= NULL
;
8136 json_object
*json_addr
= NULL
;
8139 json_addr
= json_object_new_object();
8140 json_af
= json_object_new_object();
8141 filter
= &p
->filter
[afi
][safi
];
8143 if (peer_group_active(p
))
8144 json_object_string_add(json_addr
, "peerGroupMember",
8147 paf
= peer_af_find(p
, afi
, safi
);
8148 if (paf
&& PAF_SUBGRP(paf
)) {
8149 json_object_int_add(json_addr
, "updateGroupId",
8150 PAF_UPDGRP(paf
)->id
);
8151 json_object_int_add(json_addr
, "subGroupId",
8152 PAF_SUBGRP(paf
)->id
);
8153 json_object_int_add(json_addr
, "packetQueueLength",
8154 bpacket_queue_virtual_length(paf
));
8157 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8158 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8159 PEER_CAP_ORF_PREFIX_SM_RCV
)
8160 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8161 PEER_CAP_ORF_PREFIX_RM_ADV
)
8162 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8163 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8164 json_object_int_add(json_af
, "orfType",
8166 json_prefA
= json_object_new_object();
8167 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8168 PEER_CAP_ORF_PREFIX_SM_ADV
,
8169 PEER_CAP_ORF_PREFIX_RM_ADV
,
8170 PEER_CAP_ORF_PREFIX_SM_RCV
,
8171 PEER_CAP_ORF_PREFIX_RM_RCV
,
8172 use_json
, json_prefA
);
8173 json_object_object_add(json_af
, "orfPrefixList",
8177 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8178 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8179 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8180 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8181 PEER_CAP_ORF_PREFIX_RM_ADV
)
8182 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8183 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8184 json_object_int_add(json_af
, "orfOldType",
8185 ORF_TYPE_PREFIX_OLD
);
8186 json_prefB
= json_object_new_object();
8187 bgp_show_peer_afi_orf_cap(
8188 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8189 PEER_CAP_ORF_PREFIX_RM_ADV
,
8190 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8191 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8193 json_object_object_add(json_af
, "orfOldPrefixList",
8197 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8198 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8199 PEER_CAP_ORF_PREFIX_SM_RCV
)
8200 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8201 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8202 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8203 PEER_CAP_ORF_PREFIX_RM_ADV
)
8204 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8205 PEER_CAP_ORF_PREFIX_RM_RCV
)
8206 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8207 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8208 json_object_object_add(json_addr
, "afDependentCap",
8211 json_object_free(json_af
);
8213 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8214 orf_pfx_count
= prefix_bgp_show_prefix_list(
8215 NULL
, afi
, orf_pfx_name
, use_json
);
8217 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8218 PEER_STATUS_ORF_PREFIX_SEND
)
8220 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8221 PEER_STATUS_ORF_PREFIX_SEND
))
8222 json_object_boolean_true_add(json_neigh
,
8225 json_object_int_add(json_addr
, "orfRecvCounter",
8228 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8229 PEER_STATUS_ORF_WAIT_REFRESH
))
8230 json_object_string_add(
8231 json_addr
, "orfFirstUpdate",
8232 "deferredUntilORFOrRouteRefreshRecvd");
8234 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8235 PEER_FLAG_REFLECTOR_CLIENT
))
8236 json_object_boolean_true_add(json_addr
,
8237 "routeReflectorClient");
8238 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8239 PEER_FLAG_RSERVER_CLIENT
))
8240 json_object_boolean_true_add(json_addr
,
8241 "routeServerClient");
8242 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8243 json_object_boolean_true_add(json_addr
,
8244 "inboundSoftConfigPermit");
8246 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8247 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8248 json_object_boolean_true_add(
8250 "privateAsNumsAllReplacedInUpdatesToNbr");
8251 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8252 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8253 json_object_boolean_true_add(
8255 "privateAsNumsReplacedInUpdatesToNbr");
8256 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8257 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8258 json_object_boolean_true_add(
8260 "privateAsNumsAllRemovedInUpdatesToNbr");
8261 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8262 PEER_FLAG_REMOVE_PRIVATE_AS
))
8263 json_object_boolean_true_add(
8265 "privateAsNumsRemovedInUpdatesToNbr");
8267 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8268 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
8269 json_object_boolean_true_add(json_addr
,
8270 "addpathTxAllPaths");
8272 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8273 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
8274 json_object_boolean_true_add(json_addr
,
8275 "addpathTxBestpathPerAS");
8277 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8278 json_object_string_add(json_addr
,
8279 "overrideASNsInOutboundUpdates",
8280 "ifAspathEqualRemoteAs");
8282 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8283 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8284 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8285 json_object_boolean_true_add(json_addr
,
8286 "routerAlwaysNextHop");
8287 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8288 PEER_FLAG_AS_PATH_UNCHANGED
))
8289 json_object_boolean_true_add(
8290 json_addr
, "unchangedAsPathPropogatedToNbr");
8291 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8292 PEER_FLAG_NEXTHOP_UNCHANGED
))
8293 json_object_boolean_true_add(
8294 json_addr
, "unchangedNextHopPropogatedToNbr");
8295 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8296 json_object_boolean_true_add(
8297 json_addr
, "unchangedMedPropogatedToNbr");
8298 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8299 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8300 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8301 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8302 PEER_FLAG_SEND_COMMUNITY
)
8303 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8304 PEER_FLAG_SEND_EXT_COMMUNITY
))
8305 json_object_string_add(json_addr
,
8306 "commAttriSentToNbr",
8307 "extendedAndStandard");
8308 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8309 PEER_FLAG_SEND_EXT_COMMUNITY
))
8310 json_object_string_add(json_addr
,
8311 "commAttriSentToNbr",
8314 json_object_string_add(json_addr
,
8315 "commAttriSentToNbr",
8318 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8319 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8320 if (p
->default_rmap
[afi
][safi
].name
)
8321 json_object_string_add(
8322 json_addr
, "defaultRouteMap",
8323 p
->default_rmap
[afi
][safi
].name
);
8325 if (paf
&& PAF_SUBGRP(paf
)
8326 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8327 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8328 json_object_boolean_true_add(json_addr
,
8331 json_object_boolean_true_add(json_addr
,
8335 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8336 if (is_evpn_enabled())
8337 json_object_boolean_true_add(
8338 json_addr
, "advertiseAllVnis");
8341 if (filter
->plist
[FILTER_IN
].name
8342 || filter
->dlist
[FILTER_IN
].name
8343 || filter
->aslist
[FILTER_IN
].name
8344 || filter
->map
[RMAP_IN
].name
)
8345 json_object_boolean_true_add(json_addr
,
8346 "inboundPathPolicyConfig");
8347 if (filter
->plist
[FILTER_OUT
].name
8348 || filter
->dlist
[FILTER_OUT
].name
8349 || filter
->aslist
[FILTER_OUT
].name
8350 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8351 json_object_boolean_true_add(
8352 json_addr
, "outboundPathPolicyConfig");
8355 if (filter
->plist
[FILTER_IN
].name
)
8356 json_object_string_add(json_addr
,
8357 "incomingUpdatePrefixFilterList",
8358 filter
->plist
[FILTER_IN
].name
);
8359 if (filter
->plist
[FILTER_OUT
].name
)
8360 json_object_string_add(json_addr
,
8361 "outgoingUpdatePrefixFilterList",
8362 filter
->plist
[FILTER_OUT
].name
);
8364 /* distribute-list */
8365 if (filter
->dlist
[FILTER_IN
].name
)
8366 json_object_string_add(
8367 json_addr
, "incomingUpdateNetworkFilterList",
8368 filter
->dlist
[FILTER_IN
].name
);
8369 if (filter
->dlist
[FILTER_OUT
].name
)
8370 json_object_string_add(
8371 json_addr
, "outgoingUpdateNetworkFilterList",
8372 filter
->dlist
[FILTER_OUT
].name
);
8375 if (filter
->aslist
[FILTER_IN
].name
)
8376 json_object_string_add(json_addr
,
8377 "incomingUpdateAsPathFilterList",
8378 filter
->aslist
[FILTER_IN
].name
);
8379 if (filter
->aslist
[FILTER_OUT
].name
)
8380 json_object_string_add(json_addr
,
8381 "outgoingUpdateAsPathFilterList",
8382 filter
->aslist
[FILTER_OUT
].name
);
8385 if (filter
->map
[RMAP_IN
].name
)
8386 json_object_string_add(
8387 json_addr
, "routeMapForIncomingAdvertisements",
8388 filter
->map
[RMAP_IN
].name
);
8389 if (filter
->map
[RMAP_OUT
].name
)
8390 json_object_string_add(
8391 json_addr
, "routeMapForOutgoingAdvertisements",
8392 filter
->map
[RMAP_OUT
].name
);
8394 /* unsuppress-map */
8395 if (filter
->usmap
.name
)
8396 json_object_string_add(json_addr
,
8397 "selectiveUnsuppressRouteMap",
8398 filter
->usmap
.name
);
8400 /* Receive prefix count */
8401 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8402 p
->pcount
[afi
][safi
]);
8404 /* Maximum prefix */
8405 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8406 json_object_int_add(json_addr
, "prefixAllowedMax",
8407 p
->pmax
[afi
][safi
]);
8408 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8409 PEER_FLAG_MAX_PREFIX_WARNING
))
8410 json_object_boolean_true_add(
8411 json_addr
, "prefixAllowedMaxWarning");
8412 json_object_int_add(json_addr
,
8413 "prefixAllowedWarningThresh",
8414 p
->pmax_threshold
[afi
][safi
]);
8415 if (p
->pmax_restart
[afi
][safi
])
8416 json_object_int_add(
8418 "prefixAllowedRestartIntervalMsecs",
8419 p
->pmax_restart
[afi
][safi
] * 60000);
8421 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8425 filter
= &p
->filter
[afi
][safi
];
8427 vty_out(vty
, " For address family: %s\n",
8428 afi_safi_print(afi
, safi
));
8430 if (peer_group_active(p
))
8431 vty_out(vty
, " %s peer-group member\n",
8434 paf
= peer_af_find(p
, afi
, safi
);
8435 if (paf
&& PAF_SUBGRP(paf
)) {
8436 vty_out(vty
, " Update group %" PRIu64
8437 ", subgroup %" PRIu64
"\n",
8438 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8439 vty_out(vty
, " Packet Queue length %d\n",
8440 bpacket_queue_virtual_length(paf
));
8442 vty_out(vty
, " Not part of any update group\n");
8444 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8445 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8446 PEER_CAP_ORF_PREFIX_SM_RCV
)
8447 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8448 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8449 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8450 PEER_CAP_ORF_PREFIX_RM_ADV
)
8451 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8452 PEER_CAP_ORF_PREFIX_RM_RCV
)
8453 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8454 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8455 vty_out(vty
, " AF-dependant capabilities:\n");
8457 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8458 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8459 PEER_CAP_ORF_PREFIX_SM_RCV
)
8460 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8461 PEER_CAP_ORF_PREFIX_RM_ADV
)
8462 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8463 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8465 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8467 bgp_show_peer_afi_orf_cap(
8468 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8469 PEER_CAP_ORF_PREFIX_RM_ADV
,
8470 PEER_CAP_ORF_PREFIX_SM_RCV
,
8471 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8473 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8474 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8475 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8476 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8477 PEER_CAP_ORF_PREFIX_RM_ADV
)
8478 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8479 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8481 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8482 ORF_TYPE_PREFIX_OLD
);
8483 bgp_show_peer_afi_orf_cap(
8484 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8485 PEER_CAP_ORF_PREFIX_RM_ADV
,
8486 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8487 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8490 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8491 orf_pfx_count
= prefix_bgp_show_prefix_list(
8492 NULL
, afi
, orf_pfx_name
, use_json
);
8494 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8495 PEER_STATUS_ORF_PREFIX_SEND
)
8497 vty_out(vty
, " Outbound Route Filter (ORF):");
8498 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8499 PEER_STATUS_ORF_PREFIX_SEND
))
8500 vty_out(vty
, " sent;");
8502 vty_out(vty
, " received (%d entries)",
8506 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8507 PEER_STATUS_ORF_WAIT_REFRESH
))
8509 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
8511 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8512 PEER_FLAG_REFLECTOR_CLIENT
))
8513 vty_out(vty
, " Route-Reflector Client\n");
8514 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8515 PEER_FLAG_RSERVER_CLIENT
))
8516 vty_out(vty
, " Route-Server Client\n");
8517 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8519 " Inbound soft reconfiguration allowed\n");
8521 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8522 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8524 " Private AS numbers (all) replaced in updates to this neighbor\n");
8525 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8526 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8528 " Private AS numbers replaced in updates to this neighbor\n");
8529 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8530 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8532 " Private AS numbers (all) removed in updates to this neighbor\n");
8533 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8534 PEER_FLAG_REMOVE_PRIVATE_AS
))
8536 " Private AS numbers removed in updates to this neighbor\n");
8538 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8539 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
8540 vty_out(vty
, " Advertise all paths via addpath\n");
8542 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8543 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
8545 " Advertise bestpath per AS via addpath\n");
8547 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8549 " Override ASNs in outbound updates if aspath equals remote-as\n");
8551 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8552 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8553 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8554 vty_out(vty
, " NEXT_HOP is always this router\n");
8555 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8556 PEER_FLAG_AS_PATH_UNCHANGED
))
8558 " AS_PATH is propagated unchanged to this neighbor\n");
8559 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8560 PEER_FLAG_NEXTHOP_UNCHANGED
))
8562 " NEXT_HOP is propagated unchanged to this neighbor\n");
8563 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8565 " MED is propagated unchanged to this neighbor\n");
8566 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8567 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8568 PEER_FLAG_SEND_EXT_COMMUNITY
)
8569 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8570 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
8572 " Community attribute sent to this neighbor");
8573 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8574 PEER_FLAG_SEND_COMMUNITY
)
8575 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8576 PEER_FLAG_SEND_EXT_COMMUNITY
)
8577 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8578 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8579 vty_out(vty
, "(all)\n");
8580 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8581 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8582 vty_out(vty
, "(large)\n");
8583 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8584 PEER_FLAG_SEND_EXT_COMMUNITY
))
8585 vty_out(vty
, "(extended)\n");
8587 vty_out(vty
, "(standard)\n");
8589 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8590 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8591 vty_out(vty
, " Default information originate,");
8593 if (p
->default_rmap
[afi
][safi
].name
)
8594 vty_out(vty
, " default route-map %s%s,",
8595 p
->default_rmap
[afi
][safi
].map
? "*"
8597 p
->default_rmap
[afi
][safi
].name
);
8598 if (paf
&& PAF_SUBGRP(paf
)
8599 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8600 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8601 vty_out(vty
, " default sent\n");
8603 vty_out(vty
, " default not sent\n");
8606 /* advertise-vni-all */
8607 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8608 if (is_evpn_enabled())
8609 vty_out(vty
, " advertise-all-vni\n");
8612 if (filter
->plist
[FILTER_IN
].name
8613 || filter
->dlist
[FILTER_IN
].name
8614 || filter
->aslist
[FILTER_IN
].name
8615 || filter
->map
[RMAP_IN
].name
)
8616 vty_out(vty
, " Inbound path policy configured\n");
8617 if (filter
->plist
[FILTER_OUT
].name
8618 || filter
->dlist
[FILTER_OUT
].name
8619 || filter
->aslist
[FILTER_OUT
].name
8620 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8621 vty_out(vty
, " Outbound path policy configured\n");
8624 if (filter
->plist
[FILTER_IN
].name
)
8626 " Incoming update prefix filter list is %s%s\n",
8627 filter
->plist
[FILTER_IN
].plist
? "*" : "",
8628 filter
->plist
[FILTER_IN
].name
);
8629 if (filter
->plist
[FILTER_OUT
].name
)
8631 " Outgoing update prefix filter list is %s%s\n",
8632 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
8633 filter
->plist
[FILTER_OUT
].name
);
8635 /* distribute-list */
8636 if (filter
->dlist
[FILTER_IN
].name
)
8638 " Incoming update network filter list is %s%s\n",
8639 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
8640 filter
->dlist
[FILTER_IN
].name
);
8641 if (filter
->dlist
[FILTER_OUT
].name
)
8643 " Outgoing update network filter list is %s%s\n",
8644 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
8645 filter
->dlist
[FILTER_OUT
].name
);
8648 if (filter
->aslist
[FILTER_IN
].name
)
8650 " Incoming update AS path filter list is %s%s\n",
8651 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
8652 filter
->aslist
[FILTER_IN
].name
);
8653 if (filter
->aslist
[FILTER_OUT
].name
)
8655 " Outgoing update AS path filter list is %s%s\n",
8656 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
8657 filter
->aslist
[FILTER_OUT
].name
);
8660 if (filter
->map
[RMAP_IN
].name
)
8662 " Route map for incoming advertisements is %s%s\n",
8663 filter
->map
[RMAP_IN
].map
? "*" : "",
8664 filter
->map
[RMAP_IN
].name
);
8665 if (filter
->map
[RMAP_OUT
].name
)
8667 " Route map for outgoing advertisements is %s%s\n",
8668 filter
->map
[RMAP_OUT
].map
? "*" : "",
8669 filter
->map
[RMAP_OUT
].name
);
8671 /* unsuppress-map */
8672 if (filter
->usmap
.name
)
8674 " Route map for selective unsuppress is %s%s\n",
8675 filter
->usmap
.map
? "*" : "",
8676 filter
->usmap
.name
);
8678 /* Receive prefix count */
8679 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
8681 /* Maximum prefix */
8682 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8683 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
8685 CHECK_FLAG(p
->af_flags
[afi
][safi
],
8686 PEER_FLAG_MAX_PREFIX_WARNING
)
8689 vty_out(vty
, " Threshold for warning message %d%%",
8690 p
->pmax_threshold
[afi
][safi
]);
8691 if (p
->pmax_restart
[afi
][safi
])
8692 vty_out(vty
, ", restart interval %d min",
8693 p
->pmax_restart
[afi
][safi
]);
8701 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, uint8_t use_json
,
8705 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
8706 char timebuf
[BGP_UPTIME_LEN
];
8708 const char *subcode_str
;
8709 const char *code_str
;
8714 json_object
*json_neigh
= NULL
;
8720 json_neigh
= json_object_new_object();
8722 memset(dn_flag
, '\0', sizeof(dn_flag
));
8723 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
8727 if (p
->conf_if
) /* Configured interface name. */
8728 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
8729 BGP_PEER_SU_UNSPEC(p
)
8731 : sockunion2str(&p
->su
, buf
,
8733 else /* Configured IP address. */
8734 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
8739 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
8740 json_object_string_add(json_neigh
, "bgpNeighborAddr",
8742 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
8743 json_object_string_add(
8744 json_neigh
, "bgpNeighborAddr",
8745 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
8747 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
8749 if (p
->change_local_as
)
8750 json_object_int_add(json_neigh
, "localAs",
8751 p
->change_local_as
);
8753 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
8755 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
8756 json_object_boolean_true_add(json_neigh
,
8757 "localAsNoPrepend");
8759 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
8760 json_object_boolean_true_add(json_neigh
,
8761 "localAsReplaceAs");
8763 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
8764 || (p
->as_type
== AS_INTERNAL
))
8765 vty_out(vty
, "remote AS %u, ", p
->as
);
8767 vty_out(vty
, "remote AS Unspecified, ");
8768 vty_out(vty
, "local AS %u%s%s, ",
8769 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
8770 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
8773 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
8777 /* peer type internal, external, confed-internal or confed-external */
8778 if (p
->as
== p
->local_as
) {
8780 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
8781 json_object_boolean_true_add(
8782 json_neigh
, "nbrConfedInternalLink");
8784 json_object_boolean_true_add(json_neigh
,
8787 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
8788 vty_out(vty
, "confed-internal link\n");
8790 vty_out(vty
, "internal link\n");
8794 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
8795 json_object_boolean_true_add(
8796 json_neigh
, "nbrConfedExternalLink");
8798 json_object_boolean_true_add(json_neigh
,
8801 if (bgp_confederation_peers_check(bgp
, p
->as
))
8802 vty_out(vty
, "confed-external link\n");
8804 vty_out(vty
, "external link\n");
8811 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
8813 vty_out(vty
, " Description: %s\n", p
->desc
);
8819 json_object_string_add(json_neigh
, "hostname",
8823 json_object_string_add(json_neigh
, "domainname",
8826 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
8827 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
8830 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
8837 json_object_string_add(json_neigh
, "peerGroup",
8841 struct prefix prefix
, *range
= NULL
;
8843 sockunion2hostprefix(&(p
->su
), &prefix
);
8844 range
= peer_group_lookup_dynamic_neighbor_range(
8848 prefix2str(range
, buf1
, sizeof(buf1
));
8849 json_object_string_add(
8851 "peerSubnetRangeGroup", buf1
);
8856 " Member of peer-group %s for session parameters\n",
8860 struct prefix prefix
, *range
= NULL
;
8862 sockunion2hostprefix(&(p
->su
), &prefix
);
8863 range
= peer_group_lookup_dynamic_neighbor_range(
8867 prefix2str(range
, buf1
, sizeof(buf1
));
8869 " Belongs to the subnet range group: %s\n",
8877 /* Administrative shutdown. */
8878 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
8879 json_object_boolean_true_add(json_neigh
,
8883 json_object_int_add(json_neigh
, "bgpVersion", 4);
8884 json_object_string_add(
8885 json_neigh
, "remoteRouterId",
8886 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
8889 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
8890 && bgp_confederation_peers_check(bgp
, p
->as
))
8891 json_object_boolean_true_add(json_neigh
,
8895 json_object_string_add(
8896 json_neigh
, "bgpState",
8897 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
8899 if (p
->status
== Established
) {
8902 uptime
= bgp_clock();
8903 uptime
-= p
->uptime
;
8904 epoch_tbuf
= time(NULL
) - uptime
;
8906 #if defined(VERSION_TYPE_DEV) && CONFDATE > 20200101
8908 "bgpTimerUp should be deprecated and can be removed now");
8911 * bgpTimerUp was miliseconds that was accurate
8912 * up to 1 day, then the value returned
8913 * became garbage. So in order to provide
8914 * some level of backwards compatability,
8915 * we still provde the data, but now
8916 * we are returning the correct value
8917 * and also adding a new bgpTimerUpMsec
8918 * which will allow us to deprecate
8921 json_object_int_add(json_neigh
, "bgpTimerUp",
8923 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
8925 json_object_string_add(json_neigh
, "bgpTimerUpString",
8926 peer_uptime(p
->uptime
, timebuf
,
8929 json_object_int_add(json_neigh
,
8930 "bgpTimerUpEstablishedEpoch",
8934 else if (p
->status
== Active
) {
8935 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
8936 json_object_string_add(json_neigh
, "bgpStateIs",
8938 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
8939 json_object_string_add(json_neigh
, "bgpStateIs",
8947 uptime
= bgp_clock();
8948 uptime
-= p
->readtime
;
8949 tm
= gmtime(&uptime
);
8950 json_object_int_add(json_neigh
, "bgpTimerLastRead",
8951 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
8952 + (tm
->tm_hour
* 3600000));
8954 uptime
= bgp_clock();
8955 uptime
-= p
->last_write
;
8956 tm
= gmtime(&uptime
);
8957 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
8958 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
8959 + (tm
->tm_hour
* 3600000));
8961 uptime
= bgp_clock();
8962 uptime
-= p
->update_time
;
8963 tm
= gmtime(&uptime
);
8964 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
8965 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
8966 + (tm
->tm_hour
* 3600000));
8968 /* Configured timer values. */
8969 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
8970 p
->v_holdtime
* 1000);
8971 json_object_int_add(json_neigh
,
8972 "bgpTimerKeepAliveIntervalMsecs",
8973 p
->v_keepalive
* 1000);
8975 if (PEER_OR_GROUP_TIMER_SET(p
)) {
8976 json_object_int_add(json_neigh
,
8977 "bgpTimerConfiguredHoldTimeMsecs",
8978 p
->holdtime
* 1000);
8979 json_object_int_add(
8981 "bgpTimerConfiguredKeepAliveIntervalMsecs",
8982 p
->keepalive
* 1000);
8983 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
8984 || (bgp
->default_keepalive
8985 != BGP_DEFAULT_KEEPALIVE
)) {
8986 json_object_int_add(json_neigh
,
8987 "bgpTimerConfiguredHoldTimeMsecs",
8988 bgp
->default_holdtime
);
8989 json_object_int_add(
8991 "bgpTimerConfiguredKeepAliveIntervalMsecs",
8992 bgp
->default_keepalive
);
8995 /* Administrative shutdown. */
8996 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
8997 vty_out(vty
, " Administratively shut down\n");
9000 vty_out(vty
, " BGP version 4");
9001 vty_out(vty
, ", remote router ID %s\n",
9002 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9005 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9006 && bgp_confederation_peers_check(bgp
, p
->as
))
9008 " Neighbor under common administration\n");
9011 vty_out(vty
, " BGP state = %s",
9012 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9014 if (p
->status
== Established
)
9015 vty_out(vty
, ", up for %8s",
9016 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9019 else if (p
->status
== Active
) {
9020 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9021 vty_out(vty
, " (passive)");
9022 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9023 vty_out(vty
, " (NSF passive)");
9028 vty_out(vty
, " Last read %s",
9029 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9031 vty_out(vty
, ", Last write %s\n",
9032 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9035 /* Configured timer values. */
9037 " Hold time is %d, keepalive interval is %d seconds\n",
9038 p
->v_holdtime
, p
->v_keepalive
);
9039 if (PEER_OR_GROUP_TIMER_SET(p
)) {
9040 vty_out(vty
, " Configured hold time is %d",
9042 vty_out(vty
, ", keepalive interval is %d seconds\n",
9044 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9045 || (bgp
->default_keepalive
9046 != BGP_DEFAULT_KEEPALIVE
)) {
9047 vty_out(vty
, " Configured hold time is %d",
9048 bgp
->default_holdtime
);
9049 vty_out(vty
, ", keepalive interval is %d seconds\n",
9050 bgp
->default_keepalive
);
9054 if (p
->status
== Established
) {
9055 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9056 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9057 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9058 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9059 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9060 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9061 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9062 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9063 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9064 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9065 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9066 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9067 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9068 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9069 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9070 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9071 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9072 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9073 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9074 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9076 json_object
*json_cap
= NULL
;
9078 json_cap
= json_object_new_object();
9081 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9082 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9083 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9084 && CHECK_FLAG(p
->cap
,
9086 json_object_string_add(
9087 json_cap
, "4byteAs",
9088 "advertisedAndReceived");
9089 else if (CHECK_FLAG(p
->cap
,
9091 json_object_string_add(
9092 json_cap
, "4byteAs",
9094 else if (CHECK_FLAG(p
->cap
,
9096 json_object_string_add(
9097 json_cap
, "4byteAs",
9102 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9103 || CHECK_FLAG(p
->cap
,
9104 PEER_CAP_ADDPATH_ADV
)) {
9105 json_object
*json_add
= NULL
;
9106 const char *print_store
;
9108 json_add
= json_object_new_object();
9110 FOREACH_AFI_SAFI (afi
, safi
) {
9111 json_object
*json_sub
= NULL
;
9113 json_object_new_object();
9114 print_store
= afi_safi_print(
9120 PEER_CAP_ADDPATH_AF_TX_ADV
)
9124 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9129 PEER_CAP_ADDPATH_AF_TX_ADV
)
9134 PEER_CAP_ADDPATH_AF_TX_RCV
))
9135 json_object_boolean_true_add(
9137 "txAdvertisedAndReceived");
9143 PEER_CAP_ADDPATH_AF_TX_ADV
))
9144 json_object_boolean_true_add(
9152 PEER_CAP_ADDPATH_AF_TX_RCV
))
9153 json_object_boolean_true_add(
9161 PEER_CAP_ADDPATH_AF_RX_ADV
)
9165 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9170 PEER_CAP_ADDPATH_AF_RX_ADV
)
9175 PEER_CAP_ADDPATH_AF_RX_RCV
))
9176 json_object_boolean_true_add(
9178 "rxAdvertisedAndReceived");
9184 PEER_CAP_ADDPATH_AF_RX_ADV
))
9185 json_object_boolean_true_add(
9193 PEER_CAP_ADDPATH_AF_RX_RCV
))
9194 json_object_boolean_true_add(
9202 PEER_CAP_ADDPATH_AF_TX_ADV
)
9206 PEER_CAP_ADDPATH_AF_TX_RCV
)
9210 PEER_CAP_ADDPATH_AF_RX_ADV
)
9214 PEER_CAP_ADDPATH_AF_RX_RCV
))
9215 json_object_object_add(
9224 json_object_object_add(
9225 json_cap
, "addPath", json_add
);
9229 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9230 || CHECK_FLAG(p
->cap
,
9231 PEER_CAP_DYNAMIC_ADV
)) {
9232 if (CHECK_FLAG(p
->cap
,
9233 PEER_CAP_DYNAMIC_ADV
)
9234 && CHECK_FLAG(p
->cap
,
9235 PEER_CAP_DYNAMIC_RCV
))
9236 json_object_string_add(
9237 json_cap
, "dynamic",
9238 "advertisedAndReceived");
9239 else if (CHECK_FLAG(
9241 PEER_CAP_DYNAMIC_ADV
))
9242 json_object_string_add(
9243 json_cap
, "dynamic",
9245 else if (CHECK_FLAG(
9247 PEER_CAP_DYNAMIC_RCV
))
9248 json_object_string_add(
9249 json_cap
, "dynamic",
9253 /* Extended nexthop */
9254 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9255 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9256 json_object
*json_nxt
= NULL
;
9257 const char *print_store
;
9260 if (CHECK_FLAG(p
->cap
,
9262 && CHECK_FLAG(p
->cap
,
9264 json_object_string_add(
9267 "advertisedAndReceived");
9268 else if (CHECK_FLAG(p
->cap
,
9270 json_object_string_add(
9274 else if (CHECK_FLAG(p
->cap
,
9276 json_object_string_add(
9281 if (CHECK_FLAG(p
->cap
,
9282 PEER_CAP_ENHE_RCV
)) {
9284 json_object_new_object();
9286 for (safi
= SAFI_UNICAST
;
9287 safi
< SAFI_MAX
; safi
++) {
9292 PEER_CAP_ENHE_AF_RCV
)) {
9293 print_store
= afi_safi_print(
9296 json_object_string_add(
9302 json_object_object_add(
9304 "extendedNexthopFamililesByPeer",
9310 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9311 || CHECK_FLAG(p
->cap
,
9312 PEER_CAP_REFRESH_NEW_RCV
)
9313 || CHECK_FLAG(p
->cap
,
9314 PEER_CAP_REFRESH_OLD_RCV
)) {
9315 if (CHECK_FLAG(p
->cap
,
9316 PEER_CAP_REFRESH_ADV
)
9319 PEER_CAP_REFRESH_NEW_RCV
)
9322 PEER_CAP_REFRESH_OLD_RCV
))) {
9325 PEER_CAP_REFRESH_OLD_RCV
)
9328 PEER_CAP_REFRESH_NEW_RCV
))
9329 json_object_string_add(
9332 "advertisedAndReceivedOldNew");
9336 PEER_CAP_REFRESH_OLD_RCV
))
9337 json_object_string_add(
9340 "advertisedAndReceivedOld");
9342 json_object_string_add(
9345 "advertisedAndReceivedNew");
9350 PEER_CAP_REFRESH_ADV
))
9351 json_object_string_add(
9358 PEER_CAP_REFRESH_NEW_RCV
)
9361 PEER_CAP_REFRESH_OLD_RCV
))
9362 json_object_string_add(
9368 /* Multiprotocol Extensions */
9369 json_object
*json_multi
= NULL
;
9370 json_multi
= json_object_new_object();
9372 FOREACH_AFI_SAFI (afi
, safi
) {
9373 if (p
->afc_adv
[afi
][safi
]
9374 || p
->afc_recv
[afi
][safi
]) {
9375 json_object
*json_exten
= NULL
;
9377 json_object_new_object();
9379 if (p
->afc_adv
[afi
][safi
]
9380 && p
->afc_recv
[afi
][safi
])
9381 json_object_boolean_true_add(
9383 "advertisedAndReceived");
9384 else if (p
->afc_adv
[afi
][safi
])
9385 json_object_boolean_true_add(
9388 else if (p
->afc_recv
[afi
][safi
])
9389 json_object_boolean_true_add(
9393 json_object_object_add(
9400 json_object_object_add(
9401 json_cap
, "multiprotocolExtensions",
9404 /* Hostname capabilities */
9405 json_object
*json_hname
= NULL
;
9407 json_hname
= json_object_new_object();
9409 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9410 json_object_string_add(
9411 json_hname
, "advHostName",
9412 bgp
->peer_self
->hostname
9416 json_object_string_add(
9417 json_hname
, "advDomainName",
9418 bgp
->peer_self
->domainname
9425 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9426 json_object_string_add(
9427 json_hname
, "rcvHostName",
9428 p
->hostname
? p
->hostname
9430 json_object_string_add(
9431 json_hname
, "rcvDomainName",
9432 p
->domainname
? p
->domainname
9436 json_object_object_add(json_cap
, "hostName",
9439 /* Gracefull Restart */
9440 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9441 || CHECK_FLAG(p
->cap
,
9442 PEER_CAP_RESTART_ADV
)) {
9443 if (CHECK_FLAG(p
->cap
,
9444 PEER_CAP_RESTART_ADV
)
9445 && CHECK_FLAG(p
->cap
,
9446 PEER_CAP_RESTART_RCV
))
9447 json_object_string_add(
9450 "advertisedAndReceived");
9451 else if (CHECK_FLAG(
9453 PEER_CAP_RESTART_ADV
))
9454 json_object_string_add(
9456 "gracefulRestartCapability",
9458 else if (CHECK_FLAG(
9460 PEER_CAP_RESTART_RCV
))
9461 json_object_string_add(
9463 "gracefulRestartCapability",
9466 if (CHECK_FLAG(p
->cap
,
9467 PEER_CAP_RESTART_RCV
)) {
9468 int restart_af_count
= 0;
9469 json_object
*json_restart
=
9472 json_object_new_object();
9474 json_object_int_add(
9476 "gracefulRestartRemoteTimerMsecs",
9477 p
->v_gr_restart
* 1000);
9479 FOREACH_AFI_SAFI (afi
, safi
) {
9484 PEER_CAP_RESTART_AF_RCV
)) {
9489 json_object_new_object();
9495 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
9496 json_object_boolean_true_add(
9500 json_object_object_add(
9508 if (!restart_af_count
) {
9509 json_object_string_add(
9511 "addressFamiliesByPeer",
9516 json_object_object_add(
9518 "addressFamiliesByPeer",
9522 json_object_object_add(json_neigh
,
9523 "neighborCapabilities",
9526 vty_out(vty
, " Neighbor capabilities:\n");
9529 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9530 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9531 vty_out(vty
, " 4 Byte AS:");
9532 if (CHECK_FLAG(p
->cap
,
9534 vty_out(vty
, " advertised");
9535 if (CHECK_FLAG(p
->cap
,
9537 vty_out(vty
, " %sreceived",
9547 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9548 || CHECK_FLAG(p
->cap
,
9549 PEER_CAP_ADDPATH_ADV
)) {
9550 vty_out(vty
, " AddPath:\n");
9552 FOREACH_AFI_SAFI (afi
, safi
) {
9556 PEER_CAP_ADDPATH_AF_TX_ADV
)
9560 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9571 PEER_CAP_ADDPATH_AF_TX_ADV
))
9582 PEER_CAP_ADDPATH_AF_TX_RCV
))
9589 PEER_CAP_ADDPATH_AF_TX_ADV
)
9599 PEER_CAP_ADDPATH_AF_RX_ADV
)
9603 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9614 PEER_CAP_ADDPATH_AF_RX_ADV
))
9625 PEER_CAP_ADDPATH_AF_RX_RCV
))
9632 PEER_CAP_ADDPATH_AF_RX_ADV
)
9642 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9643 || CHECK_FLAG(p
->cap
,
9644 PEER_CAP_DYNAMIC_ADV
)) {
9645 vty_out(vty
, " Dynamic:");
9646 if (CHECK_FLAG(p
->cap
,
9647 PEER_CAP_DYNAMIC_ADV
))
9648 vty_out(vty
, " advertised");
9649 if (CHECK_FLAG(p
->cap
,
9650 PEER_CAP_DYNAMIC_RCV
))
9651 vty_out(vty
, " %sreceived",
9654 PEER_CAP_DYNAMIC_ADV
)
9660 /* Extended nexthop */
9661 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9662 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9663 vty_out(vty
, " Extended nexthop:");
9664 if (CHECK_FLAG(p
->cap
,
9666 vty_out(vty
, " advertised");
9667 if (CHECK_FLAG(p
->cap
,
9669 vty_out(vty
, " %sreceived",
9677 if (CHECK_FLAG(p
->cap
,
9678 PEER_CAP_ENHE_RCV
)) {
9680 " Address families by peer:\n ");
9681 for (safi
= SAFI_UNICAST
;
9682 safi
< SAFI_MAX
; safi
++)
9687 PEER_CAP_ENHE_AF_RCV
))
9697 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9698 || CHECK_FLAG(p
->cap
,
9699 PEER_CAP_REFRESH_NEW_RCV
)
9700 || CHECK_FLAG(p
->cap
,
9701 PEER_CAP_REFRESH_OLD_RCV
)) {
9702 vty_out(vty
, " Route refresh:");
9703 if (CHECK_FLAG(p
->cap
,
9704 PEER_CAP_REFRESH_ADV
))
9705 vty_out(vty
, " advertised");
9706 if (CHECK_FLAG(p
->cap
,
9707 PEER_CAP_REFRESH_NEW_RCV
)
9710 PEER_CAP_REFRESH_OLD_RCV
))
9711 vty_out(vty
, " %sreceived(%s)",
9714 PEER_CAP_REFRESH_ADV
)
9719 PEER_CAP_REFRESH_OLD_RCV
)
9722 PEER_CAP_REFRESH_NEW_RCV
))
9726 PEER_CAP_REFRESH_OLD_RCV
)
9733 /* Multiprotocol Extensions */
9734 FOREACH_AFI_SAFI (afi
, safi
)
9735 if (p
->afc_adv
[afi
][safi
]
9736 || p
->afc_recv
[afi
][safi
]) {
9738 " Address Family %s:",
9741 if (p
->afc_adv
[afi
][safi
])
9744 if (p
->afc_recv
[afi
][safi
])
9754 /* Hostname capability */
9755 vty_out(vty
, " Hostname Capability:");
9757 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9759 " advertised (name: %s,domain name: %s)",
9760 bgp
->peer_self
->hostname
9764 bgp
->peer_self
->domainname
9769 vty_out(vty
, " not advertised");
9772 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9774 " received (name: %s,domain name: %s)",
9775 p
->hostname
? p
->hostname
9777 p
->domainname
? p
->domainname
9780 vty_out(vty
, " not received");
9785 /* Gracefull Restart */
9786 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9787 || CHECK_FLAG(p
->cap
,
9788 PEER_CAP_RESTART_ADV
)) {
9790 " Graceful Restart Capabilty:");
9791 if (CHECK_FLAG(p
->cap
,
9792 PEER_CAP_RESTART_ADV
))
9793 vty_out(vty
, " advertised");
9794 if (CHECK_FLAG(p
->cap
,
9795 PEER_CAP_RESTART_RCV
))
9796 vty_out(vty
, " %sreceived",
9799 PEER_CAP_RESTART_ADV
)
9804 if (CHECK_FLAG(p
->cap
,
9805 PEER_CAP_RESTART_RCV
)) {
9806 int restart_af_count
= 0;
9809 " Remote Restart timer is %d seconds\n",
9812 " Address families by peer:\n ");
9814 FOREACH_AFI_SAFI (afi
, safi
)
9819 PEER_CAP_RESTART_AF_RCV
)) {
9832 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
9837 if (!restart_af_count
)
9838 vty_out(vty
, "none");
9846 /* graceful restart information */
9847 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
9849 json_object
*json_grace
= NULL
;
9850 json_object
*json_grace_send
= NULL
;
9851 json_object
*json_grace_recv
= NULL
;
9852 int eor_send_af_count
= 0;
9853 int eor_receive_af_count
= 0;
9856 json_grace
= json_object_new_object();
9857 json_grace_send
= json_object_new_object();
9858 json_grace_recv
= json_object_new_object();
9860 if (p
->status
== Established
) {
9861 FOREACH_AFI_SAFI (afi
, safi
) {
9862 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9863 PEER_STATUS_EOR_SEND
)) {
9864 json_object_boolean_true_add(
9868 eor_send_af_count
++;
9871 FOREACH_AFI_SAFI (afi
, safi
) {
9873 p
->af_sflags
[afi
][safi
],
9874 PEER_STATUS_EOR_RECEIVED
)) {
9875 json_object_boolean_true_add(
9879 eor_receive_af_count
++;
9884 json_object_object_add(json_grace
, "endOfRibSend",
9886 json_object_object_add(json_grace
, "endOfRibRecv",
9889 if (p
->t_gr_restart
)
9890 json_object_int_add(json_grace
,
9891 "gracefulRestartTimerMsecs",
9892 thread_timer_remain_second(
9897 json_object_int_add(
9899 "gracefulStalepathTimerMsecs",
9900 thread_timer_remain_second(
9904 json_object_object_add(
9905 json_neigh
, "gracefulRestartInfo", json_grace
);
9907 vty_out(vty
, " Graceful restart informations:\n");
9908 if (p
->status
== Established
) {
9909 vty_out(vty
, " End-of-RIB send: ");
9910 FOREACH_AFI_SAFI (afi
, safi
) {
9911 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9912 PEER_STATUS_EOR_SEND
)) {
9913 vty_out(vty
, "%s%s",
9914 eor_send_af_count
? ", "
9918 eor_send_af_count
++;
9922 vty_out(vty
, " End-of-RIB received: ");
9923 FOREACH_AFI_SAFI (afi
, safi
) {
9925 p
->af_sflags
[afi
][safi
],
9926 PEER_STATUS_EOR_RECEIVED
)) {
9927 vty_out(vty
, "%s%s",
9928 eor_receive_af_count
9933 eor_receive_af_count
++;
9939 if (p
->t_gr_restart
)
9941 " The remaining time of restart timer is %ld\n",
9942 thread_timer_remain_second(
9947 " The remaining time of stalepath timer is %ld\n",
9948 thread_timer_remain_second(
9953 json_object
*json_stat
= NULL
;
9954 json_stat
= json_object_new_object();
9955 /* Packet counts. */
9956 json_object_int_add(json_stat
, "depthInq", 0);
9957 json_object_int_add(json_stat
, "depthOutq",
9958 (unsigned long)p
->obuf
->count
);
9959 json_object_int_add(json_stat
, "opensSent",
9960 atomic_load_explicit(&p
->open_out
,
9961 memory_order_relaxed
));
9962 json_object_int_add(json_stat
, "opensRecv",
9963 atomic_load_explicit(&p
->open_in
,
9964 memory_order_relaxed
));
9965 json_object_int_add(json_stat
, "notificationsSent",
9966 atomic_load_explicit(&p
->notify_out
,
9967 memory_order_relaxed
));
9968 json_object_int_add(json_stat
, "notificationsRecv",
9969 atomic_load_explicit(&p
->notify_in
,
9970 memory_order_relaxed
));
9971 json_object_int_add(json_stat
, "updatesSent",
9972 atomic_load_explicit(&p
->update_out
,
9973 memory_order_relaxed
));
9974 json_object_int_add(json_stat
, "updatesRecv",
9975 atomic_load_explicit(&p
->update_in
,
9976 memory_order_relaxed
));
9977 json_object_int_add(json_stat
, "keepalivesSent",
9978 atomic_load_explicit(&p
->keepalive_out
,
9979 memory_order_relaxed
));
9980 json_object_int_add(json_stat
, "keepalivesRecv",
9981 atomic_load_explicit(&p
->keepalive_in
,
9982 memory_order_relaxed
));
9983 json_object_int_add(json_stat
, "routeRefreshSent",
9984 atomic_load_explicit(&p
->refresh_out
,
9985 memory_order_relaxed
));
9986 json_object_int_add(json_stat
, "routeRefreshRecv",
9987 atomic_load_explicit(&p
->refresh_in
,
9988 memory_order_relaxed
));
9989 json_object_int_add(json_stat
, "capabilitySent",
9990 atomic_load_explicit(&p
->dynamic_cap_out
,
9991 memory_order_relaxed
));
9992 json_object_int_add(json_stat
, "capabilityRecv",
9993 atomic_load_explicit(&p
->dynamic_cap_in
,
9994 memory_order_relaxed
));
9995 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
9996 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
9997 json_object_object_add(json_neigh
, "messageStats", json_stat
);
9999 /* Packet counts. */
10000 vty_out(vty
, " Message statistics:\n");
10001 vty_out(vty
, " Inq depth is 0\n");
10002 vty_out(vty
, " Outq depth is %lu\n",
10003 (unsigned long)p
->obuf
->count
);
10004 vty_out(vty
, " Sent Rcvd\n");
10005 vty_out(vty
, " Opens: %10d %10d\n",
10006 atomic_load_explicit(&p
->open_out
,
10007 memory_order_relaxed
),
10008 atomic_load_explicit(&p
->open_in
,
10009 memory_order_relaxed
));
10010 vty_out(vty
, " Notifications: %10d %10d\n",
10011 atomic_load_explicit(&p
->notify_out
,
10012 memory_order_relaxed
),
10013 atomic_load_explicit(&p
->notify_in
,
10014 memory_order_relaxed
));
10015 vty_out(vty
, " Updates: %10d %10d\n",
10016 atomic_load_explicit(&p
->update_out
,
10017 memory_order_relaxed
),
10018 atomic_load_explicit(&p
->update_in
,
10019 memory_order_relaxed
));
10020 vty_out(vty
, " Keepalives: %10d %10d\n",
10021 atomic_load_explicit(&p
->keepalive_out
,
10022 memory_order_relaxed
),
10023 atomic_load_explicit(&p
->keepalive_in
,
10024 memory_order_relaxed
));
10025 vty_out(vty
, " Route Refresh: %10d %10d\n",
10026 atomic_load_explicit(&p
->refresh_out
,
10027 memory_order_relaxed
),
10028 atomic_load_explicit(&p
->refresh_in
,
10029 memory_order_relaxed
));
10030 vty_out(vty
, " Capability: %10d %10d\n",
10031 atomic_load_explicit(&p
->dynamic_cap_out
,
10032 memory_order_relaxed
),
10033 atomic_load_explicit(&p
->dynamic_cap_in
,
10034 memory_order_relaxed
));
10035 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10040 /* advertisement-interval */
10041 json_object_int_add(json_neigh
,
10042 "minBtwnAdvertisementRunsTimerMsecs",
10043 p
->v_routeadv
* 1000);
10045 /* Update-source. */
10046 if (p
->update_if
|| p
->update_source
) {
10048 json_object_string_add(json_neigh
,
10051 else if (p
->update_source
)
10052 json_object_string_add(
10053 json_neigh
, "updateSource",
10054 sockunion2str(p
->update_source
, buf1
,
10058 /* advertisement-interval */
10060 " Minimum time between advertisement runs is %d seconds\n",
10063 /* Update-source. */
10064 if (p
->update_if
|| p
->update_source
) {
10065 vty_out(vty
, " Update source is ");
10067 vty_out(vty
, "%s", p
->update_if
);
10068 else if (p
->update_source
)
10070 sockunion2str(p
->update_source
, buf1
,
10072 vty_out(vty
, "\n");
10075 vty_out(vty
, "\n");
10078 /* Address Family Information */
10079 json_object
*json_hold
= NULL
;
10082 json_hold
= json_object_new_object();
10084 FOREACH_AFI_SAFI (afi
, safi
)
10085 if (p
->afc
[afi
][safi
])
10086 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10090 json_object_object_add(json_neigh
, "addressFamilyInfo",
10092 json_object_int_add(json_neigh
, "connectionsEstablished",
10094 json_object_int_add(json_neigh
, "connectionsDropped",
10097 vty_out(vty
, " Connections established %d; dropped %d\n",
10098 p
->established
, p
->dropped
);
10100 if (!p
->last_reset
) {
10102 json_object_string_add(json_neigh
, "lastReset",
10105 vty_out(vty
, " Last reset never\n");
10111 uptime
= bgp_clock();
10112 uptime
-= p
->resettime
;
10113 tm
= gmtime(&uptime
);
10114 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10115 (tm
->tm_sec
* 1000)
10116 + (tm
->tm_min
* 60000)
10117 + (tm
->tm_hour
* 3600000));
10118 json_object_string_add(
10119 json_neigh
, "lastResetDueTo",
10120 peer_down_str
[(int)p
->last_reset
]);
10121 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10122 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10123 char errorcodesubcode_hexstr
[5];
10124 char errorcodesubcode_str
[256];
10126 code_str
= bgp_notify_code_str(p
->notify
.code
);
10127 subcode_str
= bgp_notify_subcode_str(
10128 p
->notify
.code
, p
->notify
.subcode
);
10130 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10131 p
->notify
.code
, p
->notify
.subcode
);
10132 json_object_string_add(json_neigh
,
10133 "lastErrorCodeSubcode",
10134 errorcodesubcode_hexstr
);
10135 snprintf(errorcodesubcode_str
, 255, "%s%s",
10136 code_str
, subcode_str
);
10137 json_object_string_add(json_neigh
,
10138 "lastNotificationReason",
10139 errorcodesubcode_str
);
10140 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10141 && p
->notify
.code
== BGP_NOTIFY_CEASE
10142 && (p
->notify
.subcode
10143 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10144 || p
->notify
.subcode
10145 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10146 && p
->notify
.length
) {
10148 const char *msg_str
;
10150 msg_str
= bgp_notify_admin_message(
10151 msgbuf
, sizeof(msgbuf
),
10152 (uint8_t *)p
->notify
.data
,
10155 json_object_string_add(
10157 "lastShutdownDescription",
10162 vty_out(vty
, " Last reset %s, ",
10163 peer_uptime(p
->resettime
, timebuf
,
10164 BGP_UPTIME_LEN
, 0, NULL
));
10166 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10167 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10168 code_str
= bgp_notify_code_str(p
->notify
.code
);
10169 subcode_str
= bgp_notify_subcode_str(
10170 p
->notify
.code
, p
->notify
.subcode
);
10171 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10172 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10175 code_str
, subcode_str
);
10176 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10177 && p
->notify
.code
== BGP_NOTIFY_CEASE
10178 && (p
->notify
.subcode
10179 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10180 || p
->notify
.subcode
10181 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10182 && p
->notify
.length
) {
10184 const char *msg_str
;
10186 msg_str
= bgp_notify_admin_message(
10187 msgbuf
, sizeof(msgbuf
),
10188 (uint8_t *)p
->notify
.data
,
10192 " Message: \"%s\"\n",
10196 vty_out(vty
, "due to %s\n",
10197 peer_down_str
[(int)p
->last_reset
]);
10200 if (p
->last_reset_cause_size
) {
10201 msg
= p
->last_reset_cause
;
10203 " Message received that caused BGP to send a NOTIFICATION:\n ");
10204 for (i
= 1; i
<= p
->last_reset_cause_size
;
10206 vty_out(vty
, "%02X", *msg
++);
10208 if (i
!= p
->last_reset_cause_size
) {
10210 vty_out(vty
, "\n ");
10211 } else if (i
% 4 == 0) {
10216 vty_out(vty
, "\n");
10221 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10223 json_object_boolean_true_add(json_neigh
,
10224 "prefixesConfigExceedMax");
10227 " Peer had exceeded the max. no. of prefixes configured.\n");
10229 if (p
->t_pmax_restart
) {
10231 json_object_boolean_true_add(
10232 json_neigh
, "reducePrefixNumFrom");
10233 json_object_int_add(json_neigh
,
10234 "restartInTimerMsec",
10235 thread_timer_remain_second(
10240 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10241 p
->host
, thread_timer_remain_second(
10242 p
->t_pmax_restart
));
10245 json_object_boolean_true_add(
10247 "reducePrefixNumAndClearIpBgp");
10250 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10255 /* EBGP Multihop and GTSM */
10256 if (p
->sort
!= BGP_PEER_IBGP
) {
10258 if (p
->gtsm_hops
> 0)
10259 json_object_int_add(json_neigh
,
10260 "externalBgpNbrMaxHopsAway",
10262 else if (p
->ttl
> 1)
10263 json_object_int_add(json_neigh
,
10264 "externalBgpNbrMaxHopsAway",
10267 if (p
->gtsm_hops
> 0)
10269 " External BGP neighbor may be up to %d hops away.\n",
10271 else if (p
->ttl
> 1)
10273 " External BGP neighbor may be up to %d hops away.\n",
10277 if (p
->gtsm_hops
> 0) {
10279 json_object_int_add(json_neigh
,
10280 "internalBgpNbrMaxHopsAway",
10284 " Internal BGP neighbor may be up to %d hops away.\n",
10289 /* Local address. */
10292 json_object_string_add(json_neigh
, "hostLocal",
10293 sockunion2str(p
->su_local
, buf1
,
10295 json_object_int_add(json_neigh
, "portLocal",
10296 ntohs(p
->su_local
->sin
.sin_port
));
10298 vty_out(vty
, "Local host: %s, Local port: %d\n",
10299 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10300 ntohs(p
->su_local
->sin
.sin_port
));
10303 /* Remote address. */
10304 if (p
->su_remote
) {
10306 json_object_string_add(json_neigh
, "hostForeign",
10307 sockunion2str(p
->su_remote
, buf1
,
10309 json_object_int_add(json_neigh
, "portForeign",
10310 ntohs(p
->su_remote
->sin
.sin_port
));
10312 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10313 sockunion2str(p
->su_remote
, buf1
,
10315 ntohs(p
->su_remote
->sin
.sin_port
));
10318 /* Nexthop display. */
10321 json_object_string_add(json_neigh
, "nexthop",
10323 &p
->nexthop
.v4
, buf1
,
10325 json_object_string_add(json_neigh
, "nexthopGlobal",
10326 inet_ntop(AF_INET6
,
10327 &p
->nexthop
.v6_global
,
10328 buf1
, sizeof(buf1
)));
10329 json_object_string_add(json_neigh
, "nexthopLocal",
10330 inet_ntop(AF_INET6
,
10331 &p
->nexthop
.v6_local
,
10332 buf1
, sizeof(buf1
)));
10333 if (p
->shared_network
)
10334 json_object_string_add(json_neigh
,
10338 json_object_string_add(json_neigh
,
10340 "nonSharedNetwork");
10342 vty_out(vty
, "Nexthop: %s\n",
10343 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10345 vty_out(vty
, "Nexthop global: %s\n",
10346 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10348 vty_out(vty
, "Nexthop local: %s\n",
10349 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10351 vty_out(vty
, "BGP connection: %s\n",
10352 p
->shared_network
? "shared network"
10353 : "non shared network");
10357 /* Timer information. */
10359 json_object_int_add(json_neigh
, "connectRetryTimer",
10361 if (p
->status
== Established
&& p
->rtt
)
10362 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10365 json_object_int_add(
10366 json_neigh
, "nextStartTimerDueInMsecs",
10367 thread_timer_remain_second(p
->t_start
) * 1000);
10369 json_object_int_add(
10370 json_neigh
, "nextConnectTimerDueInMsecs",
10371 thread_timer_remain_second(p
->t_connect
)
10373 if (p
->t_routeadv
) {
10374 json_object_int_add(json_neigh
, "mraiInterval",
10376 json_object_int_add(
10377 json_neigh
, "mraiTimerExpireInMsecs",
10378 thread_timer_remain_second(p
->t_routeadv
)
10382 json_object_int_add(json_neigh
, "authenticationEnabled",
10386 json_object_string_add(json_neigh
, "readThread", "on");
10388 json_object_string_add(json_neigh
, "readThread", "off");
10390 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10391 json_object_string_add(json_neigh
, "writeThread", "on");
10393 json_object_string_add(json_neigh
, "writeThread",
10396 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10398 if (p
->status
== Established
&& p
->rtt
)
10399 vty_out(vty
, "Estimated round trip time: %d ms\n",
10402 vty_out(vty
, "Next start timer due in %ld seconds\n",
10403 thread_timer_remain_second(p
->t_start
));
10405 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10406 thread_timer_remain_second(p
->t_connect
));
10409 "MRAI (interval %u) timer expires in %ld seconds\n",
10411 thread_timer_remain_second(p
->t_routeadv
));
10413 vty_out(vty
, "Peer Authentication Enabled\n");
10415 vty_out(vty
, "Read thread: %s Write thread: %s\n",
10416 p
->t_read
? "on" : "off",
10417 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10422 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10423 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10424 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10427 vty_out(vty
, "\n");
10429 /* BFD information. */
10430 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10433 if (p
->conf_if
) /* Configured interface name. */
10434 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10435 else /* Configured IP address. */
10436 json_object_object_add(json
, p
->host
, json_neigh
);
10440 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10441 enum show_type type
, union sockunion
*su
,
10442 const char *conf_if
, uint8_t use_json
,
10445 struct listnode
*node
, *nnode
;
10449 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10450 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10455 bgp_show_peer(vty
, peer
, use_json
, json
);
10460 && !strcmp(peer
->conf_if
, conf_if
))
10462 && !strcmp(peer
->hostname
, conf_if
))) {
10464 bgp_show_peer(vty
, peer
, use_json
,
10468 if (sockunion_same(&peer
->su
, su
)) {
10470 bgp_show_peer(vty
, peer
, use_json
,
10478 if (type
== show_peer
&& !find
) {
10480 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
10482 vty_out(vty
, "%% No such neighbor\n");
10486 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10487 json
, JSON_C_TO_STRING_PRETTY
));
10488 json_object_free(json
);
10490 vty_out(vty
, "\n");
10493 return CMD_SUCCESS
;
10496 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
10497 enum show_type type
,
10498 const char *ip_str
,
10501 struct listnode
*node
, *nnode
;
10503 union sockunion su
;
10504 json_object
*json
= NULL
;
10505 int ret
, is_first
= 1;
10508 vty_out(vty
, "{\n");
10510 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
10512 if (!(json
= json_object_new_object())) {
10514 "Unable to allocate memory for JSON object");
10516 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
10520 json_object_int_add(json
, "vrfId",
10521 (bgp
->vrf_id
== VRF_UNKNOWN
)
10523 : (int64_t)bgp
->vrf_id
);
10524 json_object_string_add(
10526 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10531 vty_out(vty
, ",\n");
10535 vty_out(vty
, "\"%s\":",
10536 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10540 vty_out(vty
, "\nInstance %s:\n",
10541 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10546 if (type
== show_peer
) {
10547 ret
= str2sockunion(ip_str
, &su
);
10549 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10552 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10555 bgp_show_neighbor(vty
, bgp
, show_all
, NULL
, NULL
,
10561 vty_out(vty
, "}\n");
10564 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
10565 enum show_type type
, const char *ip_str
,
10570 union sockunion su
;
10571 json_object
*json
= NULL
;
10574 if (strmatch(name
, "all")) {
10575 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
10577 return CMD_SUCCESS
;
10579 bgp
= bgp_lookup_by_name(name
);
10582 json
= json_object_new_object();
10583 json_object_boolean_true_add(
10584 json
, "bgpNoSuchInstance");
10585 vty_out(vty
, "%s\n",
10586 json_object_to_json_string_ext(
10588 JSON_C_TO_STRING_PRETTY
));
10589 json_object_free(json
);
10592 "%% No such BGP instance exist\n");
10594 return CMD_WARNING
;
10598 bgp
= bgp_get_default();
10602 json
= json_object_new_object();
10604 ret
= str2sockunion(ip_str
, &su
);
10606 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10609 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10612 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
10615 json_object_free(json
);
10618 return CMD_SUCCESS
;
10621 /* "show [ip] bgp neighbors" commands. */
10622 DEFUN (show_ip_bgp_neighbors
,
10623 show_ip_bgp_neighbors_cmd
,
10624 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
10628 BGP_INSTANCE_HELP_STR
10631 "Detailed information on TCP and BGP neighbor connections\n"
10632 "Neighbor to display information about\n"
10633 "Neighbor to display information about\n"
10634 "Neighbor on BGP configured interface\n"
10638 char *sh_arg
= NULL
;
10639 enum show_type sh_type
;
10641 uint8_t uj
= use_json(argc
, argv
);
10645 if (argv_find(argv
, argc
, "view", &idx
)
10646 || argv_find(argv
, argc
, "vrf", &idx
))
10647 vrf
= argv
[idx
+ 1]->arg
;
10650 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
10651 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
10652 || argv_find(argv
, argc
, "WORD", &idx
)) {
10653 sh_type
= show_peer
;
10654 sh_arg
= argv
[idx
]->arg
;
10656 sh_type
= show_all
;
10658 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
10661 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
10662 paths' and `show ip mbgp paths'. Those functions results are the
10664 DEFUN (show_ip_bgp_paths
,
10665 show_ip_bgp_paths_cmd
,
10666 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
10671 "Path information\n")
10673 vty_out(vty
, "Address Refcnt Path\n");
10674 aspath_print_all_vty(vty
);
10675 return CMD_SUCCESS
;
10680 static void community_show_all_iterator(struct hash_backet
*backet
,
10683 struct community
*com
;
10685 com
= (struct community
*)backet
->data
;
10686 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
10687 community_str(com
, false));
10690 /* Show BGP's community internal data. */
10691 DEFUN (show_ip_bgp_community_info
,
10692 show_ip_bgp_community_info_cmd
,
10693 "show [ip] bgp community-info",
10697 "List all bgp community information\n")
10699 vty_out(vty
, "Address Refcnt Community\n");
10701 hash_iterate(community_hash(),
10702 (void (*)(struct hash_backet
*,
10703 void *))community_show_all_iterator
,
10706 return CMD_SUCCESS
;
10709 static void lcommunity_show_all_iterator(struct hash_backet
*backet
,
10712 struct lcommunity
*lcom
;
10714 lcom
= (struct lcommunity
*)backet
->data
;
10715 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
10716 lcommunity_str(lcom
));
10719 /* Show BGP's community internal data. */
10720 DEFUN (show_ip_bgp_lcommunity_info
,
10721 show_ip_bgp_lcommunity_info_cmd
,
10722 "show ip bgp large-community-info",
10726 "List all bgp large-community information\n")
10728 vty_out(vty
, "Address Refcnt Large-community\n");
10730 hash_iterate(lcommunity_hash(),
10731 (void (*)(struct hash_backet
*,
10732 void *))lcommunity_show_all_iterator
,
10735 return CMD_SUCCESS
;
10739 DEFUN (show_ip_bgp_attr_info
,
10740 show_ip_bgp_attr_info_cmd
,
10741 "show [ip] bgp attribute-info",
10745 "List all bgp attribute information\n")
10747 attr_show_all(vty
);
10748 return CMD_SUCCESS
;
10751 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
10754 struct listnode
*node
, *nnode
;
10757 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
10758 vty_out(vty
, "\nInstance %s:\n",
10759 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10762 update_group_show(bgp
, afi
, safi
, vty
, 0);
10766 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
10767 int safi
, uint64_t subgrp_id
)
10772 if (strmatch(name
, "all")) {
10773 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
10774 return CMD_SUCCESS
;
10776 bgp
= bgp_lookup_by_name(name
);
10779 bgp
= bgp_get_default();
10783 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
10784 return CMD_SUCCESS
;
10787 DEFUN (show_ip_bgp_updgrps
,
10788 show_ip_bgp_updgrps_cmd
,
10789 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
10793 BGP_INSTANCE_HELP_STR
10795 BGP_SAFI_WITH_LABEL_HELP_STR
10796 "Detailed info about dynamic update groups\n"
10797 "Specific subgroup to display detailed info for\n")
10800 afi_t afi
= AFI_IP6
;
10801 safi_t safi
= SAFI_UNICAST
;
10802 uint64_t subgrp_id
= 0;
10806 /* show [ip] bgp */
10807 if (argv_find(argv
, argc
, "ip", &idx
))
10809 /* [<view|vrf> VIEWVRFNAME] */
10810 if (argv_find(argv
, argc
, "view", &idx
)
10811 || argv_find(argv
, argc
, "vrf", &idx
))
10812 vrf
= argv
[++idx
]->arg
;
10813 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
10814 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
10815 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
10818 /* get subgroup id, if provided */
10820 if (argv
[idx
]->type
== VARIABLE_TKN
)
10821 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
10823 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
10826 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
10827 show_bgp_instance_all_ipv6_updgrps_cmd
,
10828 "show [ip] bgp <view|vrf> all update-groups",
10832 BGP_INSTANCE_ALL_HELP_STR
10833 "Detailed info about dynamic update groups\n")
10835 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
10836 return CMD_SUCCESS
;
10839 DEFUN (show_bgp_updgrps_stats
,
10840 show_bgp_updgrps_stats_cmd
,
10841 "show [ip] bgp update-groups statistics",
10845 "Detailed info about dynamic update groups\n"
10850 bgp
= bgp_get_default();
10852 update_group_show_stats(bgp
, vty
);
10854 return CMD_SUCCESS
;
10857 DEFUN (show_bgp_instance_updgrps_stats
,
10858 show_bgp_instance_updgrps_stats_cmd
,
10859 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
10863 BGP_INSTANCE_HELP_STR
10864 "Detailed info about dynamic update groups\n"
10870 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
10872 update_group_show_stats(bgp
, vty
);
10874 return CMD_SUCCESS
;
10877 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
10878 afi_t afi
, safi_t safi
,
10879 const char *what
, uint64_t subgrp_id
)
10884 bgp
= bgp_lookup_by_name(name
);
10886 bgp
= bgp_get_default();
10889 if (!strcmp(what
, "advertise-queue"))
10890 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
10892 else if (!strcmp(what
, "advertised-routes"))
10893 update_group_show_advertised(bgp
, afi
, safi
, vty
,
10895 else if (!strcmp(what
, "packet-queue"))
10896 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
10901 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
10902 show_ip_bgp_instance_updgrps_adj_s_cmd
,
10903 "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",
10904 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
10906 "Detailed info about dynamic update groups\n"
10907 "Specific subgroup to display info for\n"
10908 "Advertisement queue\n"
10909 "Announced routes\n"
10912 uint64_t subgrp_id
= 0;
10916 subgrp_id
= strtoull(sgid
, NULL
, 10);
10921 afiz
= bgp_vty_afi_from_str(afi
);
10925 afiz
= bgp_vty_afi_from_str(afi
);
10926 if (afiz
!= AFI_IP
)
10928 "%% Cannot specify both 'ip' and 'ipv6'\n");
10929 return CMD_WARNING
;
10932 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
10934 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
10935 return CMD_SUCCESS
;
10938 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
10940 struct listnode
*node
, *nnode
;
10941 struct prefix
*range
;
10944 char buf
[PREFIX2STR_BUFFER
];
10947 const char *peer_status
;
10948 const char *af_str
;
10953 conf
= group
->conf
;
10955 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
10956 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
10958 } else if (conf
->as_type
== AS_INTERNAL
) {
10959 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
10962 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
10965 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
10966 vty_out(vty
, " Peer-group type is internal\n");
10968 vty_out(vty
, " Peer-group type is external\n");
10970 /* Display AFs configured. */
10971 vty_out(vty
, " Configured address-families:");
10972 FOREACH_AFI_SAFI (afi
, safi
) {
10973 if (conf
->afc
[afi
][safi
]) {
10975 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
10979 vty_out(vty
, " none\n");
10981 vty_out(vty
, "\n");
10983 /* Display listen ranges (for dynamic neighbors), if any */
10984 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
10987 else if (afi
== AFI_IP6
)
10991 lr_count
= listcount(group
->listen_range
[afi
]);
10993 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
10997 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
10999 prefix2str(range
, buf
, sizeof(buf
));
11000 vty_out(vty
, " %s\n", buf
);
11005 /* Display group members and their status */
11006 if (listcount(group
->peer
)) {
11007 vty_out(vty
, " Peer-group members:\n");
11008 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11009 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11010 peer_status
= "Idle (Admin)";
11011 else if (CHECK_FLAG(peer
->sflags
,
11012 PEER_STATUS_PREFIX_OVERFLOW
))
11013 peer_status
= "Idle (PfxCt)";
11015 peer_status
= lookup_msg(bgp_status_msg
,
11016 peer
->status
, NULL
);
11018 dynamic
= peer_dynamic_neighbor(peer
);
11019 vty_out(vty
, " %s %s %s \n", peer
->host
,
11020 dynamic
? "(dynamic)" : "", peer_status
);
11024 return CMD_SUCCESS
;
11027 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11028 const char *group_name
)
11031 struct listnode
*node
, *nnode
;
11032 struct peer_group
*group
;
11033 bool found
= false;
11035 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11038 vty_out(vty
, "%% No such BGP instance exists\n");
11039 return CMD_WARNING
;
11042 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11044 if (strmatch(group
->name
, group_name
)) {
11045 bgp_show_one_peer_group(vty
, group
);
11050 bgp_show_one_peer_group(vty
, group
);
11054 if (group_name
&& !found
)
11055 vty_out(vty
, "%% No such peer-group\n");
11057 return CMD_SUCCESS
;
11060 DEFUN (show_ip_bgp_peer_groups
,
11061 show_ip_bgp_peer_groups_cmd
,
11062 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11066 BGP_INSTANCE_HELP_STR
11067 "Detailed information on BGP peer groups\n"
11068 "Peer group name\n")
11074 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11076 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11078 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11082 /* Redistribute VTY commands. */
11084 DEFUN (bgp_redistribute_ipv4
,
11085 bgp_redistribute_ipv4_cmd
,
11086 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11087 "Redistribute information from another routing protocol\n"
11088 FRR_IP_REDIST_HELP_STR_BGPD
)
11090 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11091 int idx_protocol
= 1;
11094 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11096 vty_out(vty
, "%% Invalid route type\n");
11097 return CMD_WARNING_CONFIG_FAILED
;
11100 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11101 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11105 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11106 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11107 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11109 DEFUN (bgp_redistribute_ipv4_rmap
,
11110 bgp_redistribute_ipv4_rmap_cmd
,
11111 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11112 "Redistribute information from another routing protocol\n"
11113 FRR_IP_REDIST_HELP_STR_BGPD
11114 "Route map reference\n"
11115 "Pointer to route-map entries\n")
11117 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11118 int idx_protocol
= 1;
11121 struct bgp_redist
*red
;
11123 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11125 vty_out(vty
, "%% Invalid route type\n");
11126 return CMD_WARNING_CONFIG_FAILED
;
11129 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11130 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11131 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11135 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
11136 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11137 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11138 "Route map reference\n"
11139 "Pointer to route-map entries\n")
11141 DEFUN (bgp_redistribute_ipv4_metric
,
11142 bgp_redistribute_ipv4_metric_cmd
,
11143 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11144 "Redistribute information from another routing protocol\n"
11145 FRR_IP_REDIST_HELP_STR_BGPD
11146 "Metric for redistributed routes\n"
11147 "Default metric\n")
11149 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11150 int idx_protocol
= 1;
11151 int idx_number
= 3;
11154 struct bgp_redist
*red
;
11156 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11158 vty_out(vty
, "%% Invalid route type\n");
11159 return CMD_WARNING_CONFIG_FAILED
;
11161 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11163 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11164 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11165 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11169 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
11170 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11171 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11172 "Metric for redistributed routes\n"
11173 "Default metric\n")
11175 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
11176 bgp_redistribute_ipv4_rmap_metric_cmd
,
11177 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11178 "Redistribute information from another routing protocol\n"
11179 FRR_IP_REDIST_HELP_STR_BGPD
11180 "Route map reference\n"
11181 "Pointer to route-map entries\n"
11182 "Metric for redistributed routes\n"
11183 "Default metric\n")
11185 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11186 int idx_protocol
= 1;
11188 int idx_number
= 5;
11191 struct bgp_redist
*red
;
11193 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11195 vty_out(vty
, "%% Invalid route type\n");
11196 return CMD_WARNING_CONFIG_FAILED
;
11198 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11200 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11201 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11202 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11203 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11207 bgp_redistribute_ipv4_rmap_metric
,
11208 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
11209 "redistribute " FRR_IP_REDIST_STR_BGPD
11210 " route-map WORD metric (0-4294967295)",
11211 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11212 "Route map reference\n"
11213 "Pointer to route-map entries\n"
11214 "Metric for redistributed routes\n"
11215 "Default metric\n")
11217 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
11218 bgp_redistribute_ipv4_metric_rmap_cmd
,
11219 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
11220 "Redistribute information from another routing protocol\n"
11221 FRR_IP_REDIST_HELP_STR_BGPD
11222 "Metric for redistributed routes\n"
11224 "Route map reference\n"
11225 "Pointer to route-map entries\n")
11227 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11228 int idx_protocol
= 1;
11229 int idx_number
= 3;
11233 struct bgp_redist
*red
;
11235 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11237 vty_out(vty
, "%% Invalid route type\n");
11238 return CMD_WARNING_CONFIG_FAILED
;
11240 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11242 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11243 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11244 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11245 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11249 bgp_redistribute_ipv4_metric_rmap
,
11250 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
11251 "redistribute " FRR_IP_REDIST_STR_BGPD
11252 " metric (0-4294967295) route-map WORD",
11253 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11254 "Metric for redistributed routes\n"
11256 "Route map reference\n"
11257 "Pointer to route-map entries\n")
11259 DEFUN (bgp_redistribute_ipv4_ospf
,
11260 bgp_redistribute_ipv4_ospf_cmd
,
11261 "redistribute <ospf|table> (1-65535)",
11262 "Redistribute information from another routing protocol\n"
11263 "Open Shortest Path First (OSPFv2)\n"
11264 "Non-main Kernel Routing Table\n"
11265 "Instance ID/Table ID\n")
11267 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11268 int idx_ospf_table
= 1;
11269 int idx_number
= 2;
11270 unsigned short instance
;
11271 unsigned short protocol
;
11273 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11275 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11276 protocol
= ZEBRA_ROUTE_OSPF
;
11278 protocol
= ZEBRA_ROUTE_TABLE
;
11280 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11281 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11284 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
11285 "redistribute <ospf|table> (1-65535)",
11286 "Redistribute information from another routing protocol\n"
11287 "Open Shortest Path First (OSPFv2)\n"
11288 "Non-main Kernel Routing Table\n"
11289 "Instance ID/Table ID\n")
11291 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
11292 bgp_redistribute_ipv4_ospf_rmap_cmd
,
11293 "redistribute <ospf|table> (1-65535) route-map WORD",
11294 "Redistribute information from another routing protocol\n"
11295 "Open Shortest Path First (OSPFv2)\n"
11296 "Non-main Kernel Routing Table\n"
11297 "Instance ID/Table ID\n"
11298 "Route map reference\n"
11299 "Pointer to route-map entries\n")
11301 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11302 int idx_ospf_table
= 1;
11303 int idx_number
= 2;
11305 struct bgp_redist
*red
;
11306 unsigned short instance
;
11309 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11310 protocol
= ZEBRA_ROUTE_OSPF
;
11312 protocol
= ZEBRA_ROUTE_TABLE
;
11314 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11315 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11316 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11317 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11320 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
11321 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
11322 "redistribute <ospf|table> (1-65535) route-map WORD",
11323 "Redistribute information from another routing protocol\n"
11324 "Open Shortest Path First (OSPFv2)\n"
11325 "Non-main Kernel Routing Table\n"
11326 "Instance ID/Table ID\n"
11327 "Route map reference\n"
11328 "Pointer to route-map entries\n")
11330 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
11331 bgp_redistribute_ipv4_ospf_metric_cmd
,
11332 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
11333 "Redistribute information from another routing protocol\n"
11334 "Open Shortest Path First (OSPFv2)\n"
11335 "Non-main Kernel Routing Table\n"
11336 "Instance ID/Table ID\n"
11337 "Metric for redistributed routes\n"
11338 "Default metric\n")
11340 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11341 int idx_ospf_table
= 1;
11342 int idx_number
= 2;
11343 int idx_number_2
= 4;
11345 struct bgp_redist
*red
;
11346 unsigned short instance
;
11349 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11350 protocol
= ZEBRA_ROUTE_OSPF
;
11352 protocol
= ZEBRA_ROUTE_TABLE
;
11354 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11355 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11357 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11358 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11359 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11362 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
11363 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
11364 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
11365 "Redistribute information from another routing protocol\n"
11366 "Open Shortest Path First (OSPFv2)\n"
11367 "Non-main Kernel Routing Table\n"
11368 "Instance ID/Table ID\n"
11369 "Metric for redistributed routes\n"
11370 "Default metric\n")
11372 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
11373 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
11374 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
11375 "Redistribute information from another routing protocol\n"
11376 "Open Shortest Path First (OSPFv2)\n"
11377 "Non-main Kernel Routing Table\n"
11378 "Instance ID/Table ID\n"
11379 "Route map reference\n"
11380 "Pointer to route-map entries\n"
11381 "Metric for redistributed routes\n"
11382 "Default metric\n")
11384 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11385 int idx_ospf_table
= 1;
11386 int idx_number
= 2;
11388 int idx_number_2
= 6;
11390 struct bgp_redist
*red
;
11391 unsigned short instance
;
11394 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11395 protocol
= ZEBRA_ROUTE_OSPF
;
11397 protocol
= ZEBRA_ROUTE_TABLE
;
11399 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11400 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11402 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11403 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11404 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11405 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11409 bgp_redistribute_ipv4_ospf_rmap_metric
,
11410 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
11411 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
11412 "Redistribute information from another routing protocol\n"
11413 "Open Shortest Path First (OSPFv2)\n"
11414 "Non-main Kernel Routing Table\n"
11415 "Instance ID/Table ID\n"
11416 "Route map reference\n"
11417 "Pointer to route-map entries\n"
11418 "Metric for redistributed routes\n"
11419 "Default metric\n")
11421 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
11422 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
11423 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
11424 "Redistribute information from another routing protocol\n"
11425 "Open Shortest Path First (OSPFv2)\n"
11426 "Non-main Kernel Routing Table\n"
11427 "Instance ID/Table ID\n"
11428 "Metric for redistributed routes\n"
11430 "Route map reference\n"
11431 "Pointer to route-map entries\n")
11433 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11434 int idx_ospf_table
= 1;
11435 int idx_number
= 2;
11436 int idx_number_2
= 4;
11439 struct bgp_redist
*red
;
11440 unsigned short instance
;
11443 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11444 protocol
= ZEBRA_ROUTE_OSPF
;
11446 protocol
= ZEBRA_ROUTE_TABLE
;
11448 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11449 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11451 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11452 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11453 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11454 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11458 bgp_redistribute_ipv4_ospf_metric_rmap
,
11459 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
11460 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
11461 "Redistribute information from another routing protocol\n"
11462 "Open Shortest Path First (OSPFv2)\n"
11463 "Non-main Kernel Routing Table\n"
11464 "Instance ID/Table ID\n"
11465 "Metric for redistributed routes\n"
11467 "Route map reference\n"
11468 "Pointer to route-map entries\n")
11470 DEFUN (no_bgp_redistribute_ipv4_ospf
,
11471 no_bgp_redistribute_ipv4_ospf_cmd
,
11472 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
11474 "Redistribute information from another routing protocol\n"
11475 "Open Shortest Path First (OSPFv2)\n"
11476 "Non-main Kernel Routing Table\n"
11477 "Instance ID/Table ID\n"
11478 "Metric for redistributed routes\n"
11480 "Route map reference\n"
11481 "Pointer to route-map entries\n")
11483 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11484 int idx_ospf_table
= 2;
11485 int idx_number
= 3;
11486 unsigned short instance
;
11489 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11490 protocol
= ZEBRA_ROUTE_OSPF
;
11492 protocol
= ZEBRA_ROUTE_TABLE
;
11494 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11495 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
11499 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
11500 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
11502 "Redistribute information from another routing protocol\n"
11503 "Open Shortest Path First (OSPFv2)\n"
11504 "Non-main Kernel Routing Table\n"
11505 "Instance ID/Table ID\n"
11506 "Metric for redistributed routes\n"
11508 "Route map reference\n"
11509 "Pointer to route-map entries\n")
11511 DEFUN (no_bgp_redistribute_ipv4
,
11512 no_bgp_redistribute_ipv4_cmd
,
11513 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
11515 "Redistribute information from another routing protocol\n"
11516 FRR_IP_REDIST_HELP_STR_BGPD
11517 "Metric for redistributed routes\n"
11519 "Route map reference\n"
11520 "Pointer to route-map entries\n")
11522 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11523 int idx_protocol
= 2;
11526 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11528 vty_out(vty
, "%% Invalid route type\n");
11529 return CMD_WARNING_CONFIG_FAILED
;
11531 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
11535 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
11536 "no redistribute " FRR_IP_REDIST_STR_BGPD
11537 " [metric (0-4294967295)] [route-map WORD]",
11539 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11540 "Metric for redistributed routes\n"
11542 "Route map reference\n"
11543 "Pointer to route-map entries\n")
11545 DEFUN (bgp_redistribute_ipv6
,
11546 bgp_redistribute_ipv6_cmd
,
11547 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
11548 "Redistribute information from another routing protocol\n"
11549 FRR_IP6_REDIST_HELP_STR_BGPD
)
11551 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11552 int idx_protocol
= 1;
11555 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11557 vty_out(vty
, "%% Invalid route type\n");
11558 return CMD_WARNING_CONFIG_FAILED
;
11561 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11562 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11565 DEFUN (bgp_redistribute_ipv6_rmap
,
11566 bgp_redistribute_ipv6_rmap_cmd
,
11567 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
11568 "Redistribute information from another routing protocol\n"
11569 FRR_IP6_REDIST_HELP_STR_BGPD
11570 "Route map reference\n"
11571 "Pointer to route-map entries\n")
11573 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11574 int idx_protocol
= 1;
11577 struct bgp_redist
*red
;
11579 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11581 vty_out(vty
, "%% Invalid route type\n");
11582 return CMD_WARNING_CONFIG_FAILED
;
11585 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11586 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11587 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11590 DEFUN (bgp_redistribute_ipv6_metric
,
11591 bgp_redistribute_ipv6_metric_cmd
,
11592 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
11593 "Redistribute information from another routing protocol\n"
11594 FRR_IP6_REDIST_HELP_STR_BGPD
11595 "Metric for redistributed routes\n"
11596 "Default metric\n")
11598 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11599 int idx_protocol
= 1;
11600 int idx_number
= 3;
11603 struct bgp_redist
*red
;
11605 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11607 vty_out(vty
, "%% Invalid route type\n");
11608 return CMD_WARNING_CONFIG_FAILED
;
11610 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11612 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11613 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
11614 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11617 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
11618 bgp_redistribute_ipv6_rmap_metric_cmd
,
11619 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11620 "Redistribute information from another routing protocol\n"
11621 FRR_IP6_REDIST_HELP_STR_BGPD
11622 "Route map reference\n"
11623 "Pointer to route-map entries\n"
11624 "Metric for redistributed routes\n"
11625 "Default metric\n")
11627 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11628 int idx_protocol
= 1;
11630 int idx_number
= 5;
11633 struct bgp_redist
*red
;
11635 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11637 vty_out(vty
, "%% Invalid route type\n");
11638 return CMD_WARNING_CONFIG_FAILED
;
11640 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11642 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11643 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11644 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
11645 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11648 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
11649 bgp_redistribute_ipv6_metric_rmap_cmd
,
11650 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
11651 "Redistribute information from another routing protocol\n"
11652 FRR_IP6_REDIST_HELP_STR_BGPD
11653 "Metric for redistributed routes\n"
11655 "Route map reference\n"
11656 "Pointer to route-map entries\n")
11658 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11659 int idx_protocol
= 1;
11660 int idx_number
= 3;
11664 struct bgp_redist
*red
;
11666 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11668 vty_out(vty
, "%% Invalid route type\n");
11669 return CMD_WARNING_CONFIG_FAILED
;
11671 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11673 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11674 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
, metric
);
11675 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11676 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11679 DEFUN (no_bgp_redistribute_ipv6
,
11680 no_bgp_redistribute_ipv6_cmd
,
11681 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
11683 "Redistribute information from another routing protocol\n"
11684 FRR_IP6_REDIST_HELP_STR_BGPD
11685 "Metric for redistributed routes\n"
11687 "Route map reference\n"
11688 "Pointer to route-map entries\n")
11690 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11691 int idx_protocol
= 2;
11694 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11696 vty_out(vty
, "%% Invalid route type\n");
11697 return CMD_WARNING_CONFIG_FAILED
;
11700 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
11703 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
11708 /* Unicast redistribution only. */
11709 if (safi
!= SAFI_UNICAST
)
11712 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
11713 /* Redistribute BGP does not make sense. */
11714 if (i
!= ZEBRA_ROUTE_BGP
) {
11715 struct list
*red_list
;
11716 struct listnode
*node
;
11717 struct bgp_redist
*red
;
11719 red_list
= bgp
->redist
[afi
][i
];
11723 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
11724 /* "redistribute" configuration. */
11725 vty_out(vty
, " redistribute %s",
11726 zebra_route_string(i
));
11728 vty_out(vty
, " %d", red
->instance
);
11729 if (red
->redist_metric_flag
)
11730 vty_out(vty
, " metric %u",
11731 red
->redist_metric
);
11732 if (red
->rmap
.name
)
11733 vty_out(vty
, " route-map %s",
11735 vty_out(vty
, "\n");
11741 /* This is part of the address-family block (unicast only) */
11742 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
11747 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
11748 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
11750 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
11753 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
11754 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
11755 bgp
->vpn_policy
[afi
].tovpn_label
);
11758 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
11759 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
11760 char buf
[RD_ADDRSTRLEN
];
11761 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
11762 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
11765 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
11766 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
11768 char buf
[PREFIX_STRLEN
];
11769 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
11770 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
11773 vty_out(vty
, "%*snexthop vpn export %s\n",
11777 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
11778 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
11780 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
11781 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
11783 char *b
= ecommunity_ecom2str(
11784 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
11785 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
11786 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
11787 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
11789 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
11790 char *b
= ecommunity_ecom2str(
11791 bgp
->vpn_policy
[afi
]
11792 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
11793 ECOMMUNITY_FORMAT_ROUTE_MAP
,
11794 ECOMMUNITY_ROUTE_TARGET
);
11795 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
11796 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
11798 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
11799 char *b
= ecommunity_ecom2str(
11800 bgp
->vpn_policy
[afi
]
11801 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
11802 ECOMMUNITY_FORMAT_ROUTE_MAP
,
11803 ECOMMUNITY_ROUTE_TARGET
);
11804 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
11805 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
11808 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
11809 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
11810 bgp
->vpn_policy
[afi
]
11811 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
11813 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]) {
11814 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
11815 bgp
->vpn_policy
[afi
]
11816 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
11818 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
11819 char *b
= ecommunity_ecom2str(
11820 bgp
->vpn_policy
[afi
]
11821 .import_redirect_rtlist
,
11822 ECOMMUNITY_FORMAT_ROUTE_MAP
,
11823 ECOMMUNITY_ROUTE_TARGET
);
11825 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
11826 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
11831 /* BGP node structure. */
11832 static struct cmd_node bgp_node
= {
11833 BGP_NODE
, "%s(config-router)# ", 1,
11836 static struct cmd_node bgp_ipv4_unicast_node
= {
11837 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
11840 static struct cmd_node bgp_ipv4_multicast_node
= {
11841 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
11844 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
11845 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
11848 static struct cmd_node bgp_ipv6_unicast_node
= {
11849 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
11852 static struct cmd_node bgp_ipv6_multicast_node
= {
11853 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
11856 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
11857 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
11860 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
11861 "%s(config-router-af)# ", 1};
11863 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
11864 "%s(config-router-af-vpnv6)# ", 1};
11866 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
11867 "%s(config-router-evpn)# ", 1};
11869 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
11870 "%s(config-router-af-vni)# ", 1};
11872 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
11873 "%s(config-router-af)# ", 1};
11875 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
11876 "%s(config-router-af-vpnv6)# ", 1};
11878 static void community_list_vty(void);
11880 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
11884 struct peer_group
*group
;
11885 struct listnode
*lnbgp
, *lnpeer
;
11887 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
11888 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
11889 /* only provide suggestions on the appropriate input
11891 * they'll otherwise show up multiple times */
11892 enum cmd_token_type match_type
;
11893 char *name
= peer
->host
;
11895 if (peer
->conf_if
) {
11896 match_type
= VARIABLE_TKN
;
11897 name
= peer
->conf_if
;
11898 } else if (strchr(peer
->host
, ':'))
11899 match_type
= IPV6_TKN
;
11901 match_type
= IPV4_TKN
;
11903 if (token
->type
!= match_type
)
11906 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
11909 if (token
->type
== VARIABLE_TKN
)
11910 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
11911 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
11916 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
11917 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
11918 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
11919 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
11920 {.completions
= NULL
}};
11922 void bgp_vty_init(void)
11924 cmd_variable_handler_register(bgp_var_neighbor
);
11926 /* Install bgp top node. */
11927 install_node(&bgp_node
, bgp_config_write
);
11928 install_node(&bgp_ipv4_unicast_node
, NULL
);
11929 install_node(&bgp_ipv4_multicast_node
, NULL
);
11930 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
11931 install_node(&bgp_ipv6_unicast_node
, NULL
);
11932 install_node(&bgp_ipv6_multicast_node
, NULL
);
11933 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
11934 install_node(&bgp_vpnv4_node
, NULL
);
11935 install_node(&bgp_vpnv6_node
, NULL
);
11936 install_node(&bgp_evpn_node
, NULL
);
11937 install_node(&bgp_evpn_vni_node
, NULL
);
11938 install_node(&bgp_flowspecv4_node
, NULL
);
11939 install_node(&bgp_flowspecv6_node
, NULL
);
11941 /* Install default VTY commands to new nodes. */
11942 install_default(BGP_NODE
);
11943 install_default(BGP_IPV4_NODE
);
11944 install_default(BGP_IPV4M_NODE
);
11945 install_default(BGP_IPV4L_NODE
);
11946 install_default(BGP_IPV6_NODE
);
11947 install_default(BGP_IPV6M_NODE
);
11948 install_default(BGP_IPV6L_NODE
);
11949 install_default(BGP_VPNV4_NODE
);
11950 install_default(BGP_VPNV6_NODE
);
11951 install_default(BGP_FLOWSPECV4_NODE
);
11952 install_default(BGP_FLOWSPECV6_NODE
);
11953 install_default(BGP_EVPN_NODE
);
11954 install_default(BGP_EVPN_VNI_NODE
);
11956 /* "bgp multiple-instance" commands. */
11957 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
11958 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
11960 /* "bgp config-type" commands. */
11961 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
11962 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
11964 /* bgp route-map delay-timer commands. */
11965 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
11966 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
11968 /* Dummy commands (Currently not supported) */
11969 install_element(BGP_NODE
, &no_synchronization_cmd
);
11970 install_element(BGP_NODE
, &no_auto_summary_cmd
);
11972 /* "router bgp" commands. */
11973 install_element(CONFIG_NODE
, &router_bgp_cmd
);
11975 /* "no router bgp" commands. */
11976 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
11978 /* "bgp router-id" commands. */
11979 install_element(BGP_NODE
, &bgp_router_id_cmd
);
11980 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
11982 /* "bgp cluster-id" commands. */
11983 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
11984 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
11986 /* "bgp confederation" commands. */
11987 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
11988 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
11990 /* "bgp confederation peers" commands. */
11991 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
11992 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
11994 /* bgp max-med command */
11995 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
11996 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
11997 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
11998 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
11999 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12001 /* bgp disable-ebgp-connected-nh-check */
12002 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12003 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12005 /* bgp update-delay command */
12006 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12007 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12008 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12010 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12011 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12012 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12013 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12015 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12016 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12018 /* "maximum-paths" commands. */
12019 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12020 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12021 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12022 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12023 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12024 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12025 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12026 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12027 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12028 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12029 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12030 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12031 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12032 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12033 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12035 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12036 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12037 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12038 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12039 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12041 /* "timers bgp" commands. */
12042 install_element(BGP_NODE
, &bgp_timers_cmd
);
12043 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12045 /* route-map delay-timer commands - per instance for backwards compat.
12047 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12048 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12050 /* "bgp client-to-client reflection" commands */
12051 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
12052 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
12054 /* "bgp always-compare-med" commands */
12055 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
12056 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
12058 /* "bgp deterministic-med" commands */
12059 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
12060 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
12062 /* "bgp graceful-restart" commands */
12063 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
12064 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
12065 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
12066 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
12067 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
12068 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
12070 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
12071 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
12073 /* "bgp graceful-shutdown" commands */
12074 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
12075 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
12077 /* "bgp fast-external-failover" commands */
12078 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
12079 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
12081 /* "bgp enforce-first-as" commands */
12082 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
12083 install_element(BGP_NODE
, &no_bgp_enforce_first_as_cmd
);
12085 /* "bgp bestpath compare-routerid" commands */
12086 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
12087 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
12089 /* "bgp bestpath as-path ignore" commands */
12090 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
12091 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
12093 /* "bgp bestpath as-path confed" commands */
12094 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
12095 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
12097 /* "bgp bestpath as-path multipath-relax" commands */
12098 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
12099 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
12101 /* "bgp log-neighbor-changes" commands */
12102 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
12103 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
12105 /* "bgp bestpath med" commands */
12106 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
12107 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
12109 /* "no bgp default ipv4-unicast" commands. */
12110 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
12111 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
12113 /* "bgp network import-check" commands. */
12114 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
12115 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
12116 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
12118 /* "bgp default local-preference" commands. */
12119 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
12120 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
12122 /* bgp default show-hostname */
12123 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
12124 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
12126 /* "bgp default subgroup-pkt-queue-max" commands. */
12127 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
12128 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
12130 /* bgp ibgp-allow-policy-mods command */
12131 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
12132 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
12134 /* "bgp listen limit" commands. */
12135 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
12136 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
12138 /* "bgp listen range" commands. */
12139 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
12140 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
12142 /* "bgp default shutdown" command */
12143 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
12145 /* "neighbor remote-as" commands. */
12146 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
12147 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
12148 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
12149 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
12150 install_element(BGP_NODE
,
12151 &neighbor_interface_v6only_config_remote_as_cmd
);
12152 install_element(BGP_NODE
, &no_neighbor_cmd
);
12153 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
12155 /* "neighbor peer-group" commands. */
12156 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
12157 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
12158 install_element(BGP_NODE
,
12159 &no_neighbor_interface_peer_group_remote_as_cmd
);
12161 /* "neighbor local-as" commands. */
12162 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
12163 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
12164 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
12165 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
12167 /* "neighbor solo" commands. */
12168 install_element(BGP_NODE
, &neighbor_solo_cmd
);
12169 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
12171 /* "neighbor password" commands. */
12172 install_element(BGP_NODE
, &neighbor_password_cmd
);
12173 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
12175 /* "neighbor activate" commands. */
12176 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
12177 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
12178 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
12179 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
12180 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
12181 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
12182 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
12183 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
12184 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
12185 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
12186 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
12187 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
12189 /* "no neighbor activate" commands. */
12190 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
12191 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
12192 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
12193 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
12194 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
12195 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
12196 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
12197 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
12198 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
12199 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
12200 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
12201 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
12203 /* "neighbor peer-group" set commands. */
12204 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
12205 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12206 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12207 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12208 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12209 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12210 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12211 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12212 install_element(BGP_FLOWSPECV4_NODE
,
12213 &neighbor_set_peer_group_hidden_cmd
);
12214 install_element(BGP_FLOWSPECV6_NODE
,
12215 &neighbor_set_peer_group_hidden_cmd
);
12217 /* "no neighbor peer-group unset" commands. */
12218 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
12219 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12220 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12221 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12222 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12223 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12224 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12225 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12226 install_element(BGP_FLOWSPECV4_NODE
,
12227 &no_neighbor_set_peer_group_hidden_cmd
);
12228 install_element(BGP_FLOWSPECV6_NODE
,
12229 &no_neighbor_set_peer_group_hidden_cmd
);
12231 /* "neighbor softreconfiguration inbound" commands.*/
12232 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
12233 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
12234 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12235 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12236 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12237 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12238 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12239 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12240 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12241 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12242 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12243 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12244 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12245 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12246 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12247 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12248 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12249 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12250 install_element(BGP_FLOWSPECV4_NODE
,
12251 &neighbor_soft_reconfiguration_cmd
);
12252 install_element(BGP_FLOWSPECV4_NODE
,
12253 &no_neighbor_soft_reconfiguration_cmd
);
12254 install_element(BGP_FLOWSPECV6_NODE
,
12255 &neighbor_soft_reconfiguration_cmd
);
12256 install_element(BGP_FLOWSPECV6_NODE
,
12257 &no_neighbor_soft_reconfiguration_cmd
);
12259 /* "neighbor attribute-unchanged" commands. */
12260 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
12261 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
12262 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
12263 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
12264 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
12265 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
12266 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
12267 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
12268 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
12269 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
12270 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
12271 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
12272 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
12273 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
12274 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
12275 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
12276 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
12277 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
12279 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
12280 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
12282 /* "nexthop-local unchanged" commands */
12283 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
12284 install_element(BGP_IPV6_NODE
,
12285 &no_neighbor_nexthop_local_unchanged_cmd
);
12287 /* "neighbor next-hop-self" commands. */
12288 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
12289 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
12290 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
12291 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
12292 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
12293 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
12294 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
12295 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
12296 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
12297 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
12298 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
12299 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
12300 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
12301 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
12302 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
12303 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
12304 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
12305 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
12307 /* "neighbor next-hop-self force" commands. */
12308 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
12309 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
12310 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
12311 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12312 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
12313 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12314 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
12315 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12316 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
12317 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12318 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
12319 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12320 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
12321 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12322 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
12323 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12324 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
12325 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12327 /* "neighbor as-override" commands. */
12328 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
12329 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
12330 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
12331 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
12332 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
12333 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
12334 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
12335 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
12336 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
12337 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
12338 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
12339 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
12340 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
12341 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
12342 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
12343 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
12344 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
12345 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
12347 /* "neighbor remove-private-AS" commands. */
12348 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
12349 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
12350 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
12351 install_element(BGP_NODE
,
12352 &no_neighbor_remove_private_as_all_hidden_cmd
);
12353 install_element(BGP_NODE
,
12354 &neighbor_remove_private_as_replace_as_hidden_cmd
);
12355 install_element(BGP_NODE
,
12356 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
12357 install_element(BGP_NODE
,
12358 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
12361 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
12362 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
12363 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
12364 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
12365 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12366 install_element(BGP_IPV4_NODE
,
12367 &neighbor_remove_private_as_replace_as_cmd
);
12368 install_element(BGP_IPV4_NODE
,
12369 &no_neighbor_remove_private_as_replace_as_cmd
);
12370 install_element(BGP_IPV4_NODE
,
12371 &neighbor_remove_private_as_all_replace_as_cmd
);
12372 install_element(BGP_IPV4_NODE
,
12373 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12374 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
12375 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
12376 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
12377 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12378 install_element(BGP_IPV4M_NODE
,
12379 &neighbor_remove_private_as_replace_as_cmd
);
12380 install_element(BGP_IPV4M_NODE
,
12381 &no_neighbor_remove_private_as_replace_as_cmd
);
12382 install_element(BGP_IPV4M_NODE
,
12383 &neighbor_remove_private_as_all_replace_as_cmd
);
12384 install_element(BGP_IPV4M_NODE
,
12385 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12386 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
12387 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
12388 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
12389 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12390 install_element(BGP_IPV4L_NODE
,
12391 &neighbor_remove_private_as_replace_as_cmd
);
12392 install_element(BGP_IPV4L_NODE
,
12393 &no_neighbor_remove_private_as_replace_as_cmd
);
12394 install_element(BGP_IPV4L_NODE
,
12395 &neighbor_remove_private_as_all_replace_as_cmd
);
12396 install_element(BGP_IPV4L_NODE
,
12397 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12398 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
12399 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
12400 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
12401 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12402 install_element(BGP_IPV6_NODE
,
12403 &neighbor_remove_private_as_replace_as_cmd
);
12404 install_element(BGP_IPV6_NODE
,
12405 &no_neighbor_remove_private_as_replace_as_cmd
);
12406 install_element(BGP_IPV6_NODE
,
12407 &neighbor_remove_private_as_all_replace_as_cmd
);
12408 install_element(BGP_IPV6_NODE
,
12409 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12410 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
12411 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
12412 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
12413 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12414 install_element(BGP_IPV6M_NODE
,
12415 &neighbor_remove_private_as_replace_as_cmd
);
12416 install_element(BGP_IPV6M_NODE
,
12417 &no_neighbor_remove_private_as_replace_as_cmd
);
12418 install_element(BGP_IPV6M_NODE
,
12419 &neighbor_remove_private_as_all_replace_as_cmd
);
12420 install_element(BGP_IPV6M_NODE
,
12421 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12422 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
12423 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
12424 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
12425 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12426 install_element(BGP_IPV6L_NODE
,
12427 &neighbor_remove_private_as_replace_as_cmd
);
12428 install_element(BGP_IPV6L_NODE
,
12429 &no_neighbor_remove_private_as_replace_as_cmd
);
12430 install_element(BGP_IPV6L_NODE
,
12431 &neighbor_remove_private_as_all_replace_as_cmd
);
12432 install_element(BGP_IPV6L_NODE
,
12433 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12434 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
12435 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
12436 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
12437 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12438 install_element(BGP_VPNV4_NODE
,
12439 &neighbor_remove_private_as_replace_as_cmd
);
12440 install_element(BGP_VPNV4_NODE
,
12441 &no_neighbor_remove_private_as_replace_as_cmd
);
12442 install_element(BGP_VPNV4_NODE
,
12443 &neighbor_remove_private_as_all_replace_as_cmd
);
12444 install_element(BGP_VPNV4_NODE
,
12445 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12446 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
12447 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
12448 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
12449 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12450 install_element(BGP_VPNV6_NODE
,
12451 &neighbor_remove_private_as_replace_as_cmd
);
12452 install_element(BGP_VPNV6_NODE
,
12453 &no_neighbor_remove_private_as_replace_as_cmd
);
12454 install_element(BGP_VPNV6_NODE
,
12455 &neighbor_remove_private_as_all_replace_as_cmd
);
12456 install_element(BGP_VPNV6_NODE
,
12457 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12459 /* "neighbor send-community" commands.*/
12460 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
12461 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
12462 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
12463 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
12464 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
12465 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
12466 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
12467 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
12468 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
12469 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
12470 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
12471 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
12472 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
12473 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
12474 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
12475 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
12476 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
12477 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
12478 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
12479 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
12480 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
12481 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
12482 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
12483 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
12484 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
12485 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
12486 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
12487 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
12488 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
12489 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
12490 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
12491 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
12492 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
12493 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
12494 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
12495 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
12497 /* "neighbor route-reflector" commands.*/
12498 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
12499 install_element(BGP_NODE
,
12500 &no_neighbor_route_reflector_client_hidden_cmd
);
12501 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
12502 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
12503 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
12504 install_element(BGP_IPV4M_NODE
,
12505 &no_neighbor_route_reflector_client_cmd
);
12506 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
12507 install_element(BGP_IPV4L_NODE
,
12508 &no_neighbor_route_reflector_client_cmd
);
12509 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
12510 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
12511 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
12512 install_element(BGP_IPV6M_NODE
,
12513 &no_neighbor_route_reflector_client_cmd
);
12514 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
12515 install_element(BGP_IPV6L_NODE
,
12516 &no_neighbor_route_reflector_client_cmd
);
12517 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
12518 install_element(BGP_VPNV4_NODE
,
12519 &no_neighbor_route_reflector_client_cmd
);
12520 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
12521 install_element(BGP_VPNV6_NODE
,
12522 &no_neighbor_route_reflector_client_cmd
);
12523 install_element(BGP_FLOWSPECV4_NODE
,
12524 &neighbor_route_reflector_client_cmd
);
12525 install_element(BGP_FLOWSPECV4_NODE
,
12526 &no_neighbor_route_reflector_client_cmd
);
12527 install_element(BGP_FLOWSPECV6_NODE
,
12528 &neighbor_route_reflector_client_cmd
);
12529 install_element(BGP_FLOWSPECV6_NODE
,
12530 &no_neighbor_route_reflector_client_cmd
);
12531 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
12532 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
12534 /* "neighbor route-server" commands.*/
12535 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
12536 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
12537 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
12538 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
12539 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
12540 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
12541 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
12542 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
12543 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
12544 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
12545 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
12546 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
12547 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
12548 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
12549 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
12550 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
12551 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
12552 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
12553 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
12554 install_element(BGP_FLOWSPECV4_NODE
,
12555 &no_neighbor_route_server_client_cmd
);
12556 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
12557 install_element(BGP_FLOWSPECV6_NODE
,
12558 &no_neighbor_route_server_client_cmd
);
12560 /* "neighbor addpath-tx-all-paths" commands.*/
12561 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
12562 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
12563 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12564 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12565 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12566 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12567 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12568 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12569 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12570 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12571 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12572 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12573 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12574 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12575 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12576 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12577 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12578 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12580 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
12581 install_element(BGP_NODE
,
12582 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
12583 install_element(BGP_NODE
,
12584 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
12585 install_element(BGP_IPV4_NODE
,
12586 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12587 install_element(BGP_IPV4_NODE
,
12588 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12589 install_element(BGP_IPV4M_NODE
,
12590 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12591 install_element(BGP_IPV4M_NODE
,
12592 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12593 install_element(BGP_IPV4L_NODE
,
12594 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12595 install_element(BGP_IPV4L_NODE
,
12596 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12597 install_element(BGP_IPV6_NODE
,
12598 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12599 install_element(BGP_IPV6_NODE
,
12600 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12601 install_element(BGP_IPV6M_NODE
,
12602 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12603 install_element(BGP_IPV6M_NODE
,
12604 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12605 install_element(BGP_IPV6L_NODE
,
12606 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12607 install_element(BGP_IPV6L_NODE
,
12608 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12609 install_element(BGP_VPNV4_NODE
,
12610 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12611 install_element(BGP_VPNV4_NODE
,
12612 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12613 install_element(BGP_VPNV6_NODE
,
12614 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12615 install_element(BGP_VPNV6_NODE
,
12616 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12618 /* "neighbor passive" commands. */
12619 install_element(BGP_NODE
, &neighbor_passive_cmd
);
12620 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
12623 /* "neighbor shutdown" commands. */
12624 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
12625 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
12626 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
12627 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
12629 /* "neighbor capability extended-nexthop" commands.*/
12630 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
12631 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
12633 /* "neighbor capability orf prefix-list" commands.*/
12634 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
12635 install_element(BGP_NODE
,
12636 &no_neighbor_capability_orf_prefix_hidden_cmd
);
12637 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
12638 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12639 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
12640 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12641 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
12642 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12643 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
12644 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12645 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
12646 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12647 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
12648 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12650 /* "neighbor capability dynamic" commands.*/
12651 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
12652 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
12654 /* "neighbor dont-capability-negotiate" commands. */
12655 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
12656 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
12658 /* "neighbor ebgp-multihop" commands. */
12659 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
12660 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
12661 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
12663 /* "neighbor disable-connected-check" commands. */
12664 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
12665 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
12667 /* "neighbor description" commands. */
12668 install_element(BGP_NODE
, &neighbor_description_cmd
);
12669 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
12671 /* "neighbor update-source" commands. "*/
12672 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
12673 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
12675 /* "neighbor default-originate" commands. */
12676 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
12677 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
12678 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
12679 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
12680 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
12681 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
12682 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
12683 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
12684 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
12685 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
12686 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
12687 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
12688 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
12689 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
12690 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
12691 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
12692 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
12693 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
12694 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
12695 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
12696 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
12698 /* "neighbor port" commands. */
12699 install_element(BGP_NODE
, &neighbor_port_cmd
);
12700 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
12702 /* "neighbor weight" commands. */
12703 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
12704 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
12706 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
12707 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
12708 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
12709 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
12710 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
12711 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
12712 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
12713 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
12714 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
12715 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
12716 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
12717 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
12718 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
12719 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
12720 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
12721 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
12723 /* "neighbor override-capability" commands. */
12724 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
12725 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
12727 /* "neighbor strict-capability-match" commands. */
12728 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
12729 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
12731 /* "neighbor timers" commands. */
12732 install_element(BGP_NODE
, &neighbor_timers_cmd
);
12733 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
12735 /* "neighbor timers connect" commands. */
12736 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
12737 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
12739 /* "neighbor advertisement-interval" commands. */
12740 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
12741 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
12743 /* "neighbor interface" commands. */
12744 install_element(BGP_NODE
, &neighbor_interface_cmd
);
12745 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
12747 /* "neighbor distribute" commands. */
12748 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
12749 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
12750 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
12751 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
12752 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
12753 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
12754 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
12755 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
12756 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
12757 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
12758 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
12759 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
12760 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
12761 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
12762 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
12763 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
12764 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
12765 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
12767 /* "neighbor prefix-list" commands. */
12768 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
12769 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
12770 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
12771 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
12772 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
12773 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
12774 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
12775 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
12776 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
12777 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
12778 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
12779 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
12780 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
12781 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
12782 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
12783 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
12784 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
12785 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
12786 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
12787 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
12788 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
12789 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
12791 /* "neighbor filter-list" commands. */
12792 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
12793 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
12794 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
12795 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
12796 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
12797 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
12798 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
12799 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
12800 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
12801 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
12802 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
12803 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
12804 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
12805 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
12806 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
12807 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
12808 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
12809 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
12810 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
12811 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
12812 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
12813 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
12815 /* "neighbor route-map" commands. */
12816 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
12817 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
12818 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
12819 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
12820 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
12821 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
12822 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
12823 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
12824 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
12825 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
12826 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
12827 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
12828 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
12829 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
12830 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
12831 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
12832 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
12833 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
12834 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
12835 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
12836 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
12837 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
12838 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
12839 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
12841 /* "neighbor unsuppress-map" commands. */
12842 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
12843 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
12844 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
12845 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
12846 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
12847 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
12848 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
12849 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
12850 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
12851 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
12852 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
12853 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
12854 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
12855 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
12856 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
12857 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
12858 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
12859 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
12861 /* "neighbor maximum-prefix" commands. */
12862 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
12863 install_element(BGP_NODE
,
12864 &neighbor_maximum_prefix_threshold_hidden_cmd
);
12865 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
12866 install_element(BGP_NODE
,
12867 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
12868 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
12869 install_element(BGP_NODE
,
12870 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
12871 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
12872 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
12873 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12874 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12875 install_element(BGP_IPV4_NODE
,
12876 &neighbor_maximum_prefix_threshold_warning_cmd
);
12877 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12878 install_element(BGP_IPV4_NODE
,
12879 &neighbor_maximum_prefix_threshold_restart_cmd
);
12880 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
12881 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
12882 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12883 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12884 install_element(BGP_IPV4M_NODE
,
12885 &neighbor_maximum_prefix_threshold_warning_cmd
);
12886 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12887 install_element(BGP_IPV4M_NODE
,
12888 &neighbor_maximum_prefix_threshold_restart_cmd
);
12889 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
12890 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
12891 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12892 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12893 install_element(BGP_IPV4L_NODE
,
12894 &neighbor_maximum_prefix_threshold_warning_cmd
);
12895 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12896 install_element(BGP_IPV4L_NODE
,
12897 &neighbor_maximum_prefix_threshold_restart_cmd
);
12898 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
12899 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
12900 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12901 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12902 install_element(BGP_IPV6_NODE
,
12903 &neighbor_maximum_prefix_threshold_warning_cmd
);
12904 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12905 install_element(BGP_IPV6_NODE
,
12906 &neighbor_maximum_prefix_threshold_restart_cmd
);
12907 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
12908 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
12909 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12910 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12911 install_element(BGP_IPV6M_NODE
,
12912 &neighbor_maximum_prefix_threshold_warning_cmd
);
12913 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12914 install_element(BGP_IPV6M_NODE
,
12915 &neighbor_maximum_prefix_threshold_restart_cmd
);
12916 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
12917 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
12918 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12919 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12920 install_element(BGP_IPV6L_NODE
,
12921 &neighbor_maximum_prefix_threshold_warning_cmd
);
12922 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12923 install_element(BGP_IPV6L_NODE
,
12924 &neighbor_maximum_prefix_threshold_restart_cmd
);
12925 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
12926 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
12927 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12928 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12929 install_element(BGP_VPNV4_NODE
,
12930 &neighbor_maximum_prefix_threshold_warning_cmd
);
12931 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12932 install_element(BGP_VPNV4_NODE
,
12933 &neighbor_maximum_prefix_threshold_restart_cmd
);
12934 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
12935 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
12936 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12937 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12938 install_element(BGP_VPNV6_NODE
,
12939 &neighbor_maximum_prefix_threshold_warning_cmd
);
12940 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12941 install_element(BGP_VPNV6_NODE
,
12942 &neighbor_maximum_prefix_threshold_restart_cmd
);
12943 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
12945 /* "neighbor allowas-in" */
12946 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
12947 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
12948 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
12949 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
12950 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
12951 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
12952 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
12953 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
12954 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
12955 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
12956 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
12957 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
12958 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
12959 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
12960 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
12961 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
12962 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
12963 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
12964 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
12965 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
12967 /* address-family commands. */
12968 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
12969 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
12970 #ifdef KEEP_OLD_VPN_COMMANDS
12971 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
12972 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
12973 #endif /* KEEP_OLD_VPN_COMMANDS */
12975 install_element(BGP_NODE
, &address_family_evpn_cmd
);
12977 /* "exit-address-family" command. */
12978 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
12979 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
12980 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
12981 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
12982 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
12983 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
12984 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
12985 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
12986 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
12987 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
12988 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
12990 /* "clear ip bgp commands" */
12991 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
12993 /* clear ip bgp prefix */
12994 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
12995 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
12996 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
12998 /* "show [ip] bgp summary" commands. */
12999 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13000 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13001 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13002 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13003 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13004 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
13006 /* "show [ip] bgp neighbors" commands. */
13007 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
13009 /* "show [ip] bgp peer-group" commands. */
13010 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
13012 /* "show [ip] bgp paths" commands. */
13013 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
13015 /* "show [ip] bgp community" commands. */
13016 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
13018 /* "show ip bgp large-community" commands. */
13019 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
13020 /* "show [ip] bgp attribute-info" commands. */
13021 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
13023 /* "redistribute" commands. */
13024 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
13025 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
13026 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
13027 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
13028 install_element(BGP_NODE
,
13029 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
13030 install_element(BGP_NODE
,
13031 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
13032 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
13033 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
13034 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
13035 install_element(BGP_NODE
,
13036 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
13037 install_element(BGP_NODE
,
13038 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
13039 install_element(BGP_NODE
,
13040 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
13041 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
13042 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
13043 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
13044 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
13045 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
13046 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
13047 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
13048 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
13049 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
13050 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
13051 install_element(BGP_IPV4_NODE
,
13052 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
13053 install_element(BGP_IPV4_NODE
,
13054 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
13055 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
13056 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
13057 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
13058 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
13059 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
13060 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
13062 /* import|export vpn [route-map WORD] */
13063 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
13064 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
13066 /* ttl_security commands */
13067 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
13068 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
13070 /* "show [ip] bgp memory" commands. */
13071 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
13073 /* "show bgp martian next-hop" */
13074 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
13076 /* "show [ip] bgp views" commands. */
13077 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
13079 /* "show [ip] bgp vrfs" commands. */
13080 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
13082 /* Community-list. */
13083 community_list_vty();
13085 /* vpn-policy commands */
13086 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
13087 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
13088 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
13089 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
13090 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
13091 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
13092 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
13093 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
13094 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
13095 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
13097 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
13098 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
13100 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
13101 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
13102 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
13103 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
13104 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
13105 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
13106 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
13107 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
13108 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13109 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13112 #include "memory.h"
13113 #include "bgp_regex.h"
13114 #include "bgp_clist.h"
13115 #include "bgp_ecommunity.h"
13117 /* VTY functions. */
13119 /* Direction value to string conversion. */
13120 static const char *community_direct_str(int direct
)
13123 case COMMUNITY_DENY
:
13125 case COMMUNITY_PERMIT
:
13132 /* Display error string. */
13133 static void community_list_perror(struct vty
*vty
, int ret
)
13136 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
13137 vty_out(vty
, "%% Can't find community-list\n");
13139 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
13140 vty_out(vty
, "%% Malformed community-list value\n");
13142 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
13144 "%% Community name conflict, previously defined as standard community\n");
13146 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
13148 "%% Community name conflict, previously defined as expanded community\n");
13153 /* "community-list" keyword help string. */
13154 #define COMMUNITY_LIST_STR "Add a community list entry\n"
13156 /* ip community-list standard */
13157 DEFUN (ip_community_list_standard
,
13158 ip_community_list_standard_cmd
,
13159 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13162 "Community list number (standard)\n"
13163 "Add an standard community-list entry\n"
13164 "Community list name\n"
13165 "Specify community to reject\n"
13166 "Specify community to accept\n"
13169 char *cl_name_or_number
= NULL
;
13171 int style
= COMMUNITY_LIST_STANDARD
;
13174 argv_find(argv
, argc
, "(1-99)", &idx
);
13175 argv_find(argv
, argc
, "WORD", &idx
);
13176 cl_name_or_number
= argv
[idx
]->arg
;
13177 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13179 argv_find(argv
, argc
, "AA:NN", &idx
);
13180 char *str
= argv_concat(argv
, argc
, idx
);
13182 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
13185 XFREE(MTYPE_TMP
, str
);
13188 /* Display error string. */
13189 community_list_perror(vty
, ret
);
13190 return CMD_WARNING_CONFIG_FAILED
;
13193 return CMD_SUCCESS
;
13196 DEFUN (no_ip_community_list_standard_all
,
13197 no_ip_community_list_standard_all_cmd
,
13198 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13202 "Community list number (standard)\n"
13203 "Add an standard community-list entry\n"
13204 "Community list name\n"
13205 "Specify community to reject\n"
13206 "Specify community to accept\n"
13209 int delete_all
= 0;
13211 char *cl_name_or_number
= NULL
;
13213 int style
= COMMUNITY_LIST_STANDARD
;
13216 argv_find(argv
, argc
, "(1-99)", &idx
);
13217 argv_find(argv
, argc
, "WORD", &idx
);
13218 cl_name_or_number
= argv
[idx
]->arg
;
13219 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13221 argv_find(argv
, argc
, "AA:NN", &idx
);
13222 char *str
= argv_concat(argv
, argc
, idx
);
13224 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
13225 direct
, style
, delete_all
);
13227 XFREE(MTYPE_TMP
, str
);
13230 community_list_perror(vty
, ret
);
13231 return CMD_WARNING_CONFIG_FAILED
;
13234 return CMD_SUCCESS
;
13237 /* ip community-list expanded */
13238 DEFUN (ip_community_list_expanded_all
,
13239 ip_community_list_expanded_all_cmd
,
13240 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13243 "Community list number (expanded)\n"
13244 "Add an expanded community-list entry\n"
13245 "Community list name\n"
13246 "Specify community to reject\n"
13247 "Specify community to accept\n"
13250 char *cl_name_or_number
= NULL
;
13252 int style
= COMMUNITY_LIST_EXPANDED
;
13255 argv_find(argv
, argc
, "(100-500)", &idx
);
13256 argv_find(argv
, argc
, "WORD", &idx
);
13257 cl_name_or_number
= argv
[idx
]->arg
;
13258 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13260 argv_find(argv
, argc
, "AA:NN", &idx
);
13261 char *str
= argv_concat(argv
, argc
, idx
);
13263 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
13266 XFREE(MTYPE_TMP
, str
);
13269 /* Display error string. */
13270 community_list_perror(vty
, ret
);
13271 return CMD_WARNING_CONFIG_FAILED
;
13274 return CMD_SUCCESS
;
13277 DEFUN (no_ip_community_list_expanded_all
,
13278 no_ip_community_list_expanded_all_cmd
,
13279 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13283 "Community list number (expanded)\n"
13284 "Add an expanded community-list entry\n"
13285 "Community list name\n"
13286 "Specify community to reject\n"
13287 "Specify community to accept\n"
13290 int delete_all
= 0;
13292 char *cl_name_or_number
= NULL
;
13294 int style
= COMMUNITY_LIST_EXPANDED
;
13297 argv_find(argv
, argc
, "(100-500)", &idx
);
13298 argv_find(argv
, argc
, "WORD", &idx
);
13299 cl_name_or_number
= argv
[idx
]->arg
;
13300 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13302 argv_find(argv
, argc
, "AA:NN", &idx
);
13303 char *str
= argv_concat(argv
, argc
, idx
);
13305 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
13306 direct
, style
, delete_all
);
13308 XFREE(MTYPE_TMP
, str
);
13311 community_list_perror(vty
, ret
);
13312 return CMD_WARNING_CONFIG_FAILED
;
13315 return CMD_SUCCESS
;
13318 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
13320 struct community_entry
*entry
;
13322 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13323 if (entry
== list
->head
) {
13324 if (all_digit(list
->name
))
13325 vty_out(vty
, "Community %s list %s\n",
13326 entry
->style
== COMMUNITY_LIST_STANDARD
13328 : "(expanded) access",
13331 vty_out(vty
, "Named Community %s list %s\n",
13332 entry
->style
== COMMUNITY_LIST_STANDARD
13338 vty_out(vty
, " %s\n",
13339 community_direct_str(entry
->direct
));
13341 vty_out(vty
, " %s %s\n",
13342 community_direct_str(entry
->direct
),
13343 entry
->style
== COMMUNITY_LIST_STANDARD
13344 ? community_str(entry
->u
.com
, false)
13349 DEFUN (show_ip_community_list
,
13350 show_ip_community_list_cmd
,
13351 "show ip community-list",
13354 "List community-list\n")
13356 struct community_list
*list
;
13357 struct community_list_master
*cm
;
13359 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
13361 return CMD_SUCCESS
;
13363 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13364 community_list_show(vty
, list
);
13366 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13367 community_list_show(vty
, list
);
13369 return CMD_SUCCESS
;
13372 DEFUN (show_ip_community_list_arg
,
13373 show_ip_community_list_arg_cmd
,
13374 "show ip community-list <(1-500)|WORD>",
13377 "List community-list\n"
13378 "Community-list number\n"
13379 "Community-list name\n")
13381 int idx_comm_list
= 3;
13382 struct community_list
*list
;
13384 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
13385 COMMUNITY_LIST_MASTER
);
13387 vty_out(vty
, "%% Can't find community-list\n");
13388 return CMD_WARNING
;
13391 community_list_show(vty
, list
);
13393 return CMD_SUCCESS
;
13397 * Large Community code.
13399 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
13400 struct cmd_token
**argv
, int style
,
13401 int reject_all_digit_name
)
13409 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13412 /* All digit name check. */
13414 argv_find(argv
, argc
, "WORD", &idx
);
13415 argv_find(argv
, argc
, "(1-99)", &idx
);
13416 argv_find(argv
, argc
, "(100-500)", &idx
);
13417 cl_name
= argv
[idx
]->arg
;
13418 if (reject_all_digit_name
&& all_digit(cl_name
)) {
13419 vty_out(vty
, "%% Community name cannot have all digits\n");
13420 return CMD_WARNING_CONFIG_FAILED
;
13424 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
13425 argv_find(argv
, argc
, "LINE", &idx
);
13426 /* Concat community string argument. */
13428 str
= argv_concat(argv
, argc
, idx
);
13432 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
13434 /* Free temporary community list string allocated by
13437 XFREE(MTYPE_TMP
, str
);
13440 community_list_perror(vty
, ret
);
13441 return CMD_WARNING_CONFIG_FAILED
;
13443 return CMD_SUCCESS
;
13446 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
13447 struct cmd_token
**argv
, int style
)
13454 argv_find(argv
, argc
, "permit", &idx
);
13455 argv_find(argv
, argc
, "deny", &idx
);
13458 /* Check the list direct. */
13459 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
13460 direct
= COMMUNITY_PERMIT
;
13462 direct
= COMMUNITY_DENY
;
13465 argv_find(argv
, argc
, "LINE", &idx
);
13466 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
13467 /* Concat community string argument. */
13468 str
= argv_concat(argv
, argc
, idx
);
13472 argv_find(argv
, argc
, "(1-99)", &idx
);
13473 argv_find(argv
, argc
, "(100-500)", &idx
);
13474 argv_find(argv
, argc
, "WORD", &idx
);
13476 /* Unset community list. */
13477 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
13480 /* Free temporary community list string allocated by
13483 XFREE(MTYPE_TMP
, str
);
13486 community_list_perror(vty
, ret
);
13487 return CMD_WARNING_CONFIG_FAILED
;
13490 return CMD_SUCCESS
;
13493 /* "large-community-list" keyword help string. */
13494 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
13495 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
13497 DEFUN (ip_lcommunity_list_standard
,
13498 ip_lcommunity_list_standard_cmd
,
13499 "ip large-community-list (1-99) <deny|permit>",
13501 LCOMMUNITY_LIST_STR
13502 "Large Community list number (standard)\n"
13503 "Specify large community to reject\n"
13504 "Specify large community to accept\n")
13506 return lcommunity_list_set_vty(vty
, argc
, argv
,
13507 LARGE_COMMUNITY_LIST_STANDARD
, 0);
13510 DEFUN (ip_lcommunity_list_standard1
,
13511 ip_lcommunity_list_standard1_cmd
,
13512 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
13514 LCOMMUNITY_LIST_STR
13515 "Large Community list number (standard)\n"
13516 "Specify large community to reject\n"
13517 "Specify large community to accept\n"
13518 LCOMMUNITY_VAL_STR
)
13520 return lcommunity_list_set_vty(vty
, argc
, argv
,
13521 LARGE_COMMUNITY_LIST_STANDARD
, 0);
13524 DEFUN (ip_lcommunity_list_expanded
,
13525 ip_lcommunity_list_expanded_cmd
,
13526 "ip large-community-list (100-500) <deny|permit> LINE...",
13528 LCOMMUNITY_LIST_STR
13529 "Large Community list number (expanded)\n"
13530 "Specify large community to reject\n"
13531 "Specify large community to accept\n"
13532 "An ordered list as a regular-expression\n")
13534 return lcommunity_list_set_vty(vty
, argc
, argv
,
13535 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
13538 DEFUN (ip_lcommunity_list_name_standard
,
13539 ip_lcommunity_list_name_standard_cmd
,
13540 "ip large-community-list standard WORD <deny|permit>",
13542 LCOMMUNITY_LIST_STR
13543 "Specify standard large-community-list\n"
13544 "Large Community list name\n"
13545 "Specify large community to reject\n"
13546 "Specify large community to accept\n")
13548 return lcommunity_list_set_vty(vty
, argc
, argv
,
13549 LARGE_COMMUNITY_LIST_STANDARD
, 1);
13552 DEFUN (ip_lcommunity_list_name_standard1
,
13553 ip_lcommunity_list_name_standard1_cmd
,
13554 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
13556 LCOMMUNITY_LIST_STR
13557 "Specify standard large-community-list\n"
13558 "Large Community list name\n"
13559 "Specify large community to reject\n"
13560 "Specify large community to accept\n"
13561 LCOMMUNITY_VAL_STR
)
13563 return lcommunity_list_set_vty(vty
, argc
, argv
,
13564 LARGE_COMMUNITY_LIST_STANDARD
, 1);
13567 DEFUN (ip_lcommunity_list_name_expanded
,
13568 ip_lcommunity_list_name_expanded_cmd
,
13569 "ip large-community-list expanded WORD <deny|permit> LINE...",
13571 LCOMMUNITY_LIST_STR
13572 "Specify expanded large-community-list\n"
13573 "Large Community list name\n"
13574 "Specify large community to reject\n"
13575 "Specify large community to accept\n"
13576 "An ordered list as a regular-expression\n")
13578 return lcommunity_list_set_vty(vty
, argc
, argv
,
13579 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
13582 DEFUN (no_ip_lcommunity_list_standard_all
,
13583 no_ip_lcommunity_list_standard_all_cmd
,
13584 "no ip large-community-list <(1-99)|(100-500)|WORD>",
13587 LCOMMUNITY_LIST_STR
13588 "Large Community list number (standard)\n"
13589 "Large Community list number (expanded)\n"
13590 "Large Community list name\n")
13592 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13593 LARGE_COMMUNITY_LIST_STANDARD
);
13596 DEFUN (no_ip_lcommunity_list_name_expanded_all
,
13597 no_ip_lcommunity_list_name_expanded_all_cmd
,
13598 "no ip large-community-list expanded WORD",
13601 LCOMMUNITY_LIST_STR
13602 "Specify expanded large-community-list\n"
13603 "Large Community list name\n")
13605 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13606 LARGE_COMMUNITY_LIST_EXPANDED
);
13609 DEFUN (no_ip_lcommunity_list_standard
,
13610 no_ip_lcommunity_list_standard_cmd
,
13611 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
13614 LCOMMUNITY_LIST_STR
13615 "Large Community list number (standard)\n"
13616 "Specify large community to reject\n"
13617 "Specify large community to accept\n"
13618 LCOMMUNITY_VAL_STR
)
13620 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13621 LARGE_COMMUNITY_LIST_STANDARD
);
13624 DEFUN (no_ip_lcommunity_list_expanded
,
13625 no_ip_lcommunity_list_expanded_cmd
,
13626 "no ip large-community-list (100-500) <deny|permit> LINE...",
13629 LCOMMUNITY_LIST_STR
13630 "Large Community list number (expanded)\n"
13631 "Specify large community to reject\n"
13632 "Specify large community to accept\n"
13633 "An ordered list as a regular-expression\n")
13635 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13636 LARGE_COMMUNITY_LIST_EXPANDED
);
13639 DEFUN (no_ip_lcommunity_list_name_standard
,
13640 no_ip_lcommunity_list_name_standard_cmd
,
13641 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
13644 LCOMMUNITY_LIST_STR
13645 "Specify standard large-community-list\n"
13646 "Large Community list name\n"
13647 "Specify large community to reject\n"
13648 "Specify large community to accept\n"
13649 LCOMMUNITY_VAL_STR
)
13651 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13652 LARGE_COMMUNITY_LIST_STANDARD
);
13655 DEFUN (no_ip_lcommunity_list_name_expanded
,
13656 no_ip_lcommunity_list_name_expanded_cmd
,
13657 "no ip large-community-list expanded WORD <deny|permit> LINE...",
13660 LCOMMUNITY_LIST_STR
13661 "Specify expanded large-community-list\n"
13662 "Large community list name\n"
13663 "Specify large community to reject\n"
13664 "Specify large community to accept\n"
13665 "An ordered list as a regular-expression\n")
13667 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13668 LARGE_COMMUNITY_LIST_EXPANDED
);
13671 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
13673 struct community_entry
*entry
;
13675 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13676 if (entry
== list
->head
) {
13677 if (all_digit(list
->name
))
13678 vty_out(vty
, "Large community %s list %s\n",
13679 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13681 : "(expanded) access",
13685 "Named large community %s list %s\n",
13686 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13692 vty_out(vty
, " %s\n",
13693 community_direct_str(entry
->direct
));
13695 vty_out(vty
, " %s %s\n",
13696 community_direct_str(entry
->direct
),
13697 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13698 ? entry
->u
.ecom
->str
13703 DEFUN (show_ip_lcommunity_list
,
13704 show_ip_lcommunity_list_cmd
,
13705 "show ip large-community-list",
13708 "List large-community list\n")
13710 struct community_list
*list
;
13711 struct community_list_master
*cm
;
13713 cm
= community_list_master_lookup(bgp_clist
,
13714 LARGE_COMMUNITY_LIST_MASTER
);
13716 return CMD_SUCCESS
;
13718 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13719 lcommunity_list_show(vty
, list
);
13721 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13722 lcommunity_list_show(vty
, list
);
13724 return CMD_SUCCESS
;
13727 DEFUN (show_ip_lcommunity_list_arg
,
13728 show_ip_lcommunity_list_arg_cmd
,
13729 "show ip large-community-list <(1-500)|WORD>",
13732 "List large-community list\n"
13733 "large-community-list number\n"
13734 "large-community-list name\n")
13736 struct community_list
*list
;
13738 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
,
13739 LARGE_COMMUNITY_LIST_MASTER
);
13741 vty_out(vty
, "%% Can't find extcommunity-list\n");
13742 return CMD_WARNING
;
13745 lcommunity_list_show(vty
, list
);
13747 return CMD_SUCCESS
;
13750 /* "extcommunity-list" keyword help string. */
13751 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
13752 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
13754 DEFUN (ip_extcommunity_list_standard
,
13755 ip_extcommunity_list_standard_cmd
,
13756 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13758 EXTCOMMUNITY_LIST_STR
13759 "Extended Community list number (standard)\n"
13760 "Specify standard extcommunity-list\n"
13761 "Community list name\n"
13762 "Specify community to reject\n"
13763 "Specify community to accept\n"
13764 EXTCOMMUNITY_VAL_STR
)
13766 int style
= EXTCOMMUNITY_LIST_STANDARD
;
13768 char *cl_number_or_name
= NULL
;
13771 argv_find(argv
, argc
, "(1-99)", &idx
);
13772 argv_find(argv
, argc
, "WORD", &idx
);
13773 cl_number_or_name
= argv
[idx
]->arg
;
13774 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13776 argv_find(argv
, argc
, "AA:NN", &idx
);
13777 char *str
= argv_concat(argv
, argc
, idx
);
13779 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
13782 XFREE(MTYPE_TMP
, str
);
13785 community_list_perror(vty
, ret
);
13786 return CMD_WARNING_CONFIG_FAILED
;
13789 return CMD_SUCCESS
;
13792 DEFUN (ip_extcommunity_list_name_expanded
,
13793 ip_extcommunity_list_name_expanded_cmd
,
13794 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
13796 EXTCOMMUNITY_LIST_STR
13797 "Extended Community list number (expanded)\n"
13798 "Specify expanded extcommunity-list\n"
13799 "Extended Community list name\n"
13800 "Specify community to reject\n"
13801 "Specify community to accept\n"
13802 "An ordered list as a regular-expression\n")
13804 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
13806 char *cl_number_or_name
= NULL
;
13809 argv_find(argv
, argc
, "(100-500)", &idx
);
13810 argv_find(argv
, argc
, "WORD", &idx
);
13811 cl_number_or_name
= argv
[idx
]->arg
;
13812 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13814 argv_find(argv
, argc
, "LINE", &idx
);
13815 char *str
= argv_concat(argv
, argc
, idx
);
13817 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
13820 XFREE(MTYPE_TMP
, str
);
13823 community_list_perror(vty
, ret
);
13824 return CMD_WARNING_CONFIG_FAILED
;
13827 return CMD_SUCCESS
;
13830 DEFUN (no_ip_extcommunity_list_standard_all
,
13831 no_ip_extcommunity_list_standard_all_cmd
,
13832 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13835 EXTCOMMUNITY_LIST_STR
13836 "Extended Community list number (standard)\n"
13837 "Specify standard extcommunity-list\n"
13838 "Community list name\n"
13839 "Specify community to reject\n"
13840 "Specify community to accept\n"
13841 EXTCOMMUNITY_VAL_STR
)
13845 int style
= EXTCOMMUNITY_LIST_STANDARD
;
13847 char *cl_number_or_name
= NULL
;
13850 argv_find(argv
, argc
, "(1-99)", &idx
);
13851 argv_find(argv
, argc
, "WORD", &idx
);
13852 cl_number_or_name
= argv
[idx
]->arg
;
13853 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13855 argv_find(argv
, argc
, "AA:NN", &idx
);
13856 char *str
= argv_concat(argv
, argc
, idx
);
13858 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
13859 direct
, style
, deleteall
);
13861 XFREE(MTYPE_TMP
, str
);
13864 community_list_perror(vty
, ret
);
13865 return CMD_WARNING_CONFIG_FAILED
;
13868 return CMD_SUCCESS
;
13871 DEFUN (no_ip_extcommunity_list_expanded_all
,
13872 no_ip_extcommunity_list_expanded_all_cmd
,
13873 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
13876 EXTCOMMUNITY_LIST_STR
13877 "Extended Community list number (expanded)\n"
13878 "Specify expanded extcommunity-list\n"
13879 "Extended Community list name\n"
13880 "Specify community to reject\n"
13881 "Specify community to accept\n"
13882 "An ordered list as a regular-expression\n")
13886 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
13888 char *cl_number_or_name
= NULL
;
13891 argv_find(argv
, argc
, "(100-500)", &idx
);
13892 argv_find(argv
, argc
, "WORD", &idx
);
13893 cl_number_or_name
= argv
[idx
]->arg
;
13894 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13896 argv_find(argv
, argc
, "LINE", &idx
);
13897 char *str
= argv_concat(argv
, argc
, idx
);
13899 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
13900 direct
, style
, deleteall
);
13902 XFREE(MTYPE_TMP
, str
);
13905 community_list_perror(vty
, ret
);
13906 return CMD_WARNING_CONFIG_FAILED
;
13909 return CMD_SUCCESS
;
13912 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
13914 struct community_entry
*entry
;
13916 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13917 if (entry
== list
->head
) {
13918 if (all_digit(list
->name
))
13919 vty_out(vty
, "Extended community %s list %s\n",
13920 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13922 : "(expanded) access",
13926 "Named extended community %s list %s\n",
13927 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13933 vty_out(vty
, " %s\n",
13934 community_direct_str(entry
->direct
));
13936 vty_out(vty
, " %s %s\n",
13937 community_direct_str(entry
->direct
),
13938 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13939 ? entry
->u
.ecom
->str
13944 DEFUN (show_ip_extcommunity_list
,
13945 show_ip_extcommunity_list_cmd
,
13946 "show ip extcommunity-list",
13949 "List extended-community list\n")
13951 struct community_list
*list
;
13952 struct community_list_master
*cm
;
13954 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
13956 return CMD_SUCCESS
;
13958 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13959 extcommunity_list_show(vty
, list
);
13961 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13962 extcommunity_list_show(vty
, list
);
13964 return CMD_SUCCESS
;
13967 DEFUN (show_ip_extcommunity_list_arg
,
13968 show_ip_extcommunity_list_arg_cmd
,
13969 "show ip extcommunity-list <(1-500)|WORD>",
13972 "List extended-community list\n"
13973 "Extcommunity-list number\n"
13974 "Extcommunity-list name\n")
13976 int idx_comm_list
= 3;
13977 struct community_list
*list
;
13979 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
13980 EXTCOMMUNITY_LIST_MASTER
);
13982 vty_out(vty
, "%% Can't find extcommunity-list\n");
13983 return CMD_WARNING
;
13986 extcommunity_list_show(vty
, list
);
13988 return CMD_SUCCESS
;
13991 /* Return configuration string of community-list entry. */
13992 static const char *community_list_config_str(struct community_entry
*entry
)
13999 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
14000 str
= community_str(entry
->u
.com
, false);
14002 str
= entry
->config
;
14007 /* Display community-list and extcommunity-list configuration. */
14008 static int community_list_config_write(struct vty
*vty
)
14010 struct community_list
*list
;
14011 struct community_entry
*entry
;
14012 struct community_list_master
*cm
;
14015 /* Community-list. */
14016 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14018 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14019 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14020 vty_out(vty
, "ip community-list %s %s %s\n", list
->name
,
14021 community_direct_str(entry
->direct
),
14022 community_list_config_str(entry
));
14025 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14026 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14027 vty_out(vty
, "ip community-list %s %s %s %s\n",
14028 entry
->style
== COMMUNITY_LIST_STANDARD
14031 list
->name
, community_direct_str(entry
->direct
),
14032 community_list_config_str(entry
));
14036 /* Extcommunity-list. */
14037 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
14039 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14040 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14041 vty_out(vty
, "ip extcommunity-list %s %s %s\n",
14042 list
->name
, community_direct_str(entry
->direct
),
14043 community_list_config_str(entry
));
14046 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14047 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14048 vty_out(vty
, "ip extcommunity-list %s %s %s %s\n",
14049 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14052 list
->name
, community_direct_str(entry
->direct
),
14053 community_list_config_str(entry
));
14058 /* lcommunity-list. */
14059 cm
= community_list_master_lookup(bgp_clist
,
14060 LARGE_COMMUNITY_LIST_MASTER
);
14062 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14063 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14064 vty_out(vty
, "ip large-community-list %s %s %s\n",
14065 list
->name
, community_direct_str(entry
->direct
),
14066 community_list_config_str(entry
));
14069 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14070 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14071 vty_out(vty
, "ip large-community-list %s %s %s %s\n",
14072 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
14075 list
->name
, community_direct_str(entry
->direct
),
14076 community_list_config_str(entry
));
14083 static struct cmd_node community_list_node
= {
14084 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
14087 static void community_list_vty(void)
14089 install_node(&community_list_node
, community_list_config_write
);
14091 /* Community-list. */
14092 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
14093 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
14094 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
14095 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
14096 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
14097 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
14099 /* Extcommunity-list. */
14100 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
14101 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
14102 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
14103 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
14104 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
14105 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
14107 /* Large Community List */
14108 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
14109 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
14110 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
14111 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
14112 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
14113 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
14114 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
14115 install_element(CONFIG_NODE
,
14116 &no_ip_lcommunity_list_name_expanded_all_cmd
);
14117 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
14118 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
14119 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
14120 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
14121 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
14122 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);