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
25 #include "lib/zclient.h"
34 #include "memory_vty.h"
40 #include "bgpd/bgpd.h"
41 #include "bgpd/bgp_attr_evpn.h"
42 #include "bgpd/bgp_advertise.h"
43 #include "bgpd/bgp_attr.h"
44 #include "bgpd/bgp_aspath.h"
45 #include "bgpd/bgp_community.h"
46 #include "bgpd/bgp_ecommunity.h"
47 #include "bgpd/bgp_lcommunity.h"
48 #include "bgpd/bgp_damp.h"
49 #include "bgpd/bgp_debug.h"
50 #include "bgpd/bgp_errors.h"
51 #include "bgpd/bgp_fsm.h"
52 #include "bgpd/bgp_nexthop.h"
53 #include "bgpd/bgp_open.h"
54 #include "bgpd/bgp_regex.h"
55 #include "bgpd/bgp_route.h"
56 #include "bgpd/bgp_mplsvpn.h"
57 #include "bgpd/bgp_zebra.h"
58 #include "bgpd/bgp_table.h"
59 #include "bgpd/bgp_vty.h"
60 #include "bgpd/bgp_mpath.h"
61 #include "bgpd/bgp_packet.h"
62 #include "bgpd/bgp_updgrp.h"
63 #include "bgpd/bgp_bfd.h"
64 #include "bgpd/bgp_io.h"
65 #include "bgpd/bgp_evpn.h"
66 #include "bgpd/bgp_addpath.h"
67 #include "bgpd/bgp_mac.h"
69 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
70 struct prefix
*range
, int exact
);
72 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
81 return BGP_IPV4M_NODE
;
83 case SAFI_LABELED_UNICAST
:
84 return BGP_IPV4L_NODE
;
87 return BGP_VPNV4_NODE
;
90 return BGP_FLOWSPECV4_NODE
;
100 return BGP_IPV6_NODE
;
103 return BGP_IPV6M_NODE
;
105 case SAFI_LABELED_UNICAST
:
106 return BGP_IPV6L_NODE
;
109 return BGP_VPNV6_NODE
;
112 return BGP_FLOWSPECV6_NODE
;
115 return BGP_IPV4_NODE
;
120 return BGP_EVPN_NODE
;
124 // We should never be here but to clarify the switch statement..
125 return BGP_IPV4_NODE
;
129 // Impossible to happen
130 return BGP_IPV4_NODE
;
133 /* Utility function to get address family from current node. */
134 afi_t
bgp_node_afi(struct vty
*vty
)
142 case BGP_FLOWSPECV6_NODE
:
155 /* Utility function to get subsequent address family from current
157 safi_t
bgp_node_safi(struct vty
*vty
)
163 safi
= SAFI_MPLS_VPN
;
167 safi
= SAFI_MULTICAST
;
174 safi
= SAFI_LABELED_UNICAST
;
176 case BGP_FLOWSPECV4_NODE
:
177 case BGP_FLOWSPECV6_NODE
:
178 safi
= SAFI_FLOWSPEC
;
188 * Converts an AFI in string form to afi_t
190 * @param afi string, one of
194 * @return the corresponding afi_t
196 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
198 afi_t afi
= AFI_MAX
; /* unknown */
199 if (strmatch(afi_str
, "ipv4"))
201 else if (strmatch(afi_str
, "ipv6"))
203 else if (strmatch(afi_str
, "l2vpn"))
208 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
212 if (argv_find(argv
, argc
, "ipv4", index
)) {
216 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
220 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
228 /* supports <unicast|multicast|vpn|labeled-unicast> */
229 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
231 safi_t safi
= SAFI_MAX
; /* unknown */
232 if (strmatch(safi_str
, "multicast"))
233 safi
= SAFI_MULTICAST
;
234 else if (strmatch(safi_str
, "unicast"))
236 else if (strmatch(safi_str
, "vpn"))
237 safi
= SAFI_MPLS_VPN
;
238 else if (strmatch(safi_str
, "evpn"))
240 else if (strmatch(safi_str
, "labeled-unicast"))
241 safi
= SAFI_LABELED_UNICAST
;
242 else if (strmatch(safi_str
, "flowspec"))
243 safi
= SAFI_FLOWSPEC
;
247 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
251 if (argv_find(argv
, argc
, "unicast", index
)) {
254 *safi
= SAFI_UNICAST
;
255 } else if (argv_find(argv
, argc
, "multicast", index
)) {
258 *safi
= SAFI_MULTICAST
;
259 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
262 *safi
= SAFI_LABELED_UNICAST
;
263 } else if (argv_find(argv
, argc
, "vpn", index
)) {
266 *safi
= SAFI_MPLS_VPN
;
267 } else if (argv_find(argv
, argc
, "evpn", index
)) {
271 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
274 *safi
= SAFI_FLOWSPEC
;
280 * bgp_vty_find_and_parse_afi_safi_bgp
282 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
283 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
284 * to appropriate values for the calling function. This is to allow the
285 * calling function to make decisions appropriate for the show command
286 * that is being parsed.
288 * The show commands are generally of the form:
289 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
290 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
292 * Since we use argv_find if the show command in particular doesn't have:
294 * [<view|vrf> VIEWVRFNAME]
295 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
296 * The command parsing should still be ok.
298 * vty -> The vty for the command so we can output some useful data in
299 * the event of a parse error in the vrf.
300 * argv -> The command tokens
301 * argc -> How many command tokens we have
302 * idx -> The current place in the command, generally should be 0 for this
304 * afi -> The parsed afi if it was included in the show command, returned here
305 * safi -> The parsed safi if it was included in the show command, returned here
306 * bgp -> Pointer to the bgp data structure we need to fill in.
307 * use_json -> json is configured or not
309 * The function returns the correct location in the parse tree for the
312 * Returns 0 for failure to parse correctly, else the idx position of where
313 * it found the last token.
315 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
316 struct cmd_token
**argv
, int argc
,
317 int *idx
, afi_t
*afi
, safi_t
*safi
,
318 struct bgp
**bgp
, bool use_json
)
320 char *vrf_name
= NULL
;
326 if (argv_find(argv
, argc
, "ip", idx
))
329 if (argv_find(argv
, argc
, "view", idx
))
330 vrf_name
= argv
[*idx
+ 1]->arg
;
331 else if (argv_find(argv
, argc
, "vrf", idx
)) {
332 vrf_name
= argv
[*idx
+ 1]->arg
;
333 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
337 if (strmatch(vrf_name
, "all"))
340 *bgp
= bgp_lookup_by_name(vrf_name
);
343 json_object
*json
= NULL
;
344 json
= json_object_new_object();
345 json_object_string_add(
347 "View/Vrf is unknown");
349 json_object_to_json_string_ext(json
,
350 JSON_C_TO_STRING_PRETTY
));
351 json_object_free(json
);
354 vty_out(vty
, "View/Vrf %s is unknown\n",
361 *bgp
= bgp_get_default();
364 json_object
*json
= NULL
;
365 json
= json_object_new_object();
366 json_object_string_add(
368 "Default BGP instance not found");
370 json_object_to_json_string_ext(json
,
371 JSON_C_TO_STRING_PRETTY
));
372 json_object_free(json
);
376 "Default BGP instance not found\n");
382 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
383 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
389 static int peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
391 struct interface
*ifp
= NULL
;
393 if (su
->sa
.sa_family
== AF_INET
)
394 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
395 else if (su
->sa
.sa_family
== AF_INET6
)
396 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
397 su
->sin6
.sin6_scope_id
,
406 /* Utility function for looking up peer from VTY. */
407 /* This is used only for configuration, so disallow if attempted on
408 * a dynamic neighbor.
410 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
412 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
421 ret
= str2sockunion(ip_str
, &su
);
423 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
425 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
428 "%% Malformed address or name: %s\n",
434 peer
= peer_lookup(bgp
, &su
);
437 "%% Specify remote-as or peer-group commands first\n");
440 if (peer_dynamic_neighbor(peer
)) {
442 "%% Operation not allowed on a dynamic neighbor\n");
449 /* Utility function for looking up peer or peer group. */
450 /* This is used only for configuration, so disallow if attempted on
451 * a dynamic neighbor.
453 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
455 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
458 struct peer
*peer
= NULL
;
459 struct peer_group
*group
= NULL
;
465 ret
= str2sockunion(peer_str
, &su
);
467 /* IP address, locate peer. */
468 peer
= peer_lookup(bgp
, &su
);
470 /* Not IP, could match either peer configured on interface or a
472 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
474 group
= peer_group_lookup(bgp
, peer_str
);
478 if (peer_dynamic_neighbor(peer
)) {
480 "%% Operation not allowed on a dynamic neighbor\n");
490 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
495 int bgp_vty_return(struct vty
*vty
, int ret
)
497 const char *str
= NULL
;
500 case BGP_ERR_INVALID_VALUE
:
501 str
= "Invalid value";
503 case BGP_ERR_INVALID_FLAG
:
504 str
= "Invalid flag";
506 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
507 str
= "Peer-group has been shutdown. Activate the peer-group first";
509 case BGP_ERR_PEER_FLAG_CONFLICT
:
510 str
= "Can't set override-capability and strict-capability-match at the same time";
512 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
513 str
= "Specify remote-as or peer-group remote AS first";
515 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
516 str
= "Cannot change the peer-group. Deconfigure first";
518 case BGP_ERR_PEER_GROUP_MISMATCH
:
519 str
= "Peer is not a member of this peer-group";
521 case BGP_ERR_PEER_FILTER_CONFLICT
:
522 str
= "Prefix/distribute list can not co-exist";
524 case BGP_ERR_NOT_INTERNAL_PEER
:
525 str
= "Invalid command. Not an internal neighbor";
527 case BGP_ERR_REMOVE_PRIVATE_AS
:
528 str
= "remove-private-AS cannot be configured for IBGP peers";
530 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
531 str
= "Local-AS allowed only for EBGP peers";
533 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
534 str
= "Cannot have local-as same as BGP AS number";
536 case BGP_ERR_TCPSIG_FAILED
:
537 str
= "Error while applying TCP-Sig to session(s)";
539 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
540 str
= "ebgp-multihop and ttl-security cannot be configured together";
542 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
543 str
= "ttl-security only allowed for EBGP peers";
545 case BGP_ERR_AS_OVERRIDE
:
546 str
= "as-override cannot be configured for IBGP peers";
548 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
549 str
= "Invalid limit for number of dynamic neighbors";
551 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
552 str
= "Dynamic neighbor listen range already exists";
554 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
555 str
= "Operation not allowed on a dynamic neighbor";
557 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
558 str
= "Operation not allowed on a directly connected neighbor";
560 case BGP_ERR_PEER_SAFI_CONFLICT
:
561 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
565 vty_out(vty
, "%% %s\n", str
);
566 return CMD_WARNING_CONFIG_FAILED
;
571 /* BGP clear sort. */
580 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
581 safi_t safi
, int error
)
584 case BGP_ERR_AF_UNCONFIGURED
:
586 "%%BGP: Enable %s address family for the neighbor %s\n",
587 afi_safi_print(afi
, safi
), peer
->host
);
589 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
591 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
599 /* `clear ip bgp' functions. */
600 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
601 enum clear_sort sort
, enum bgp_clear_type stype
,
607 struct listnode
*node
, *nnode
;
609 /* Clear all neighbors. */
611 * Pass along pointer to next node to peer_clear() when walking all
612 * nodes on the BGP instance as that may get freed if it is a
615 if (sort
== clear_all
) {
616 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
617 if (!peer
->afc
[afi
][safi
])
620 if (stype
== BGP_CLEAR_SOFT_NONE
)
621 ret
= peer_clear(peer
, &nnode
);
623 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
626 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
631 /* This is to apply read-only mode on this clear. */
632 if (stype
== BGP_CLEAR_SOFT_NONE
)
633 bgp
->update_delay_over
= 0;
636 vty_out(vty
, "%%BGP: No %s peer configured\n",
637 afi_safi_print(afi
, safi
));
642 /* Clear specified neighbor. */
643 if (sort
== clear_peer
) {
646 /* Make sockunion for lookup. */
647 ret
= str2sockunion(arg
, &su
);
649 peer
= peer_lookup_by_conf_if(bgp
, arg
);
651 peer
= peer_lookup_by_hostname(bgp
, arg
);
654 "Malformed address or name: %s\n",
660 peer
= peer_lookup(bgp
, &su
);
663 "%%BGP: Unknown neighbor - \"%s\"\n",
669 if (!peer
->afc
[afi
][safi
])
670 ret
= BGP_ERR_AF_UNCONFIGURED
;
671 else if (stype
== BGP_CLEAR_SOFT_NONE
)
672 ret
= peer_clear(peer
, NULL
);
674 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
677 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
682 /* Clear all neighbors belonging to a specific peer-group. */
683 if (sort
== clear_group
) {
684 struct peer_group
*group
;
686 group
= peer_group_lookup(bgp
, arg
);
688 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
692 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
693 if (!peer
->afc
[afi
][safi
])
696 if (stype
== BGP_CLEAR_SOFT_NONE
)
697 ret
= peer_clear(peer
, NULL
);
699 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
702 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
709 "%%BGP: No %s peer belonging to peer-group %s is configured\n",
710 afi_safi_print(afi
, safi
), arg
);
715 /* Clear all external (eBGP) neighbors. */
716 if (sort
== clear_external
) {
717 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
718 if (peer
->sort
== BGP_PEER_IBGP
)
721 if (!peer
->afc
[afi
][safi
])
724 if (stype
== BGP_CLEAR_SOFT_NONE
)
725 ret
= peer_clear(peer
, &nnode
);
727 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
730 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
737 "%%BGP: No external %s peer is configured\n",
738 afi_safi_print(afi
, safi
));
743 /* Clear all neighbors belonging to a specific AS. */
744 if (sort
== clear_as
) {
745 as_t as
= strtoul(arg
, NULL
, 10);
747 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
751 if (!peer
->afc
[afi
][safi
])
752 ret
= BGP_ERR_AF_UNCONFIGURED
;
753 else if (stype
== BGP_CLEAR_SOFT_NONE
)
754 ret
= peer_clear(peer
, &nnode
);
756 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
759 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
766 "%%BGP: No %s peer is configured with AS %s\n",
767 afi_safi_print(afi
, safi
), arg
);
775 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
776 safi_t safi
, enum clear_sort sort
,
777 enum bgp_clear_type stype
, const char *arg
)
781 /* BGP structure lookup. */
783 bgp
= bgp_lookup_by_name(name
);
785 vty_out(vty
, "Can't find BGP instance %s\n", name
);
789 bgp
= bgp_get_default();
791 vty_out(vty
, "No BGP process is configured\n");
796 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
799 /* clear soft inbound */
800 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
805 FOREACH_AFI_SAFI (afi
, safi
)
806 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
807 BGP_CLEAR_SOFT_IN
, NULL
);
810 /* clear soft outbound */
811 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
816 FOREACH_AFI_SAFI (afi
, safi
)
817 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
818 BGP_CLEAR_SOFT_OUT
, NULL
);
822 #ifndef VTYSH_EXTRACT_PL
823 #include "bgpd/bgp_vty_clippy.c"
826 DEFUN_HIDDEN (bgp_local_mac
,
828 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
831 "VxLAN Network Identifier\n"
835 "mac-mobility sequence\n"
845 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
846 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
847 vty_out(vty
, "%% Malformed MAC address\n");
850 memset(&ip
, 0, sizeof(ip
));
851 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
853 bgp
= bgp_get_default();
855 vty_out(vty
, "Default BGP instance is not there\n");
859 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
);
861 vty_out(vty
, "Internal error\n");
868 DEFUN_HIDDEN (no_bgp_local_mac
,
869 no_bgp_local_mac_cmd
,
870 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
874 "VxLAN Network Identifier\n"
885 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
886 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
887 vty_out(vty
, "%% Malformed MAC address\n");
890 memset(&ip
, 0, sizeof(ip
));
892 bgp
= bgp_get_default();
894 vty_out(vty
, "Default BGP instance is not there\n");
898 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
900 vty_out(vty
, "Internal error\n");
907 DEFUN (no_synchronization
,
908 no_synchronization_cmd
,
909 "no synchronization",
911 "Perform IGP synchronization\n")
916 DEFUN (no_auto_summary
,
920 "Enable automatic network number summarization\n")
925 /* "router bgp" commands. */
926 DEFUN_NOSH (router_bgp
,
928 "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
932 BGP_INSTANCE_HELP_STR
)
935 int idx_view_vrf
= 3;
941 const char *name
= NULL
;
942 enum bgp_instance_type inst_type
;
944 // "router bgp" without an ASN
946 // Pending: Make VRF option available for ASN less config
947 bgp
= bgp_get_default();
950 vty_out(vty
, "%% No BGP process is configured\n");
951 return CMD_WARNING_CONFIG_FAILED
;
954 if (listcount(bm
->bgp
) > 1) {
955 vty_out(vty
, "%% Please specify ASN and VRF\n");
956 return CMD_WARNING_CONFIG_FAILED
;
962 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
964 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
966 name
= argv
[idx_vrf
]->arg
;
968 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
969 if (strmatch(name
, VRF_DEFAULT_NAME
))
972 inst_type
= BGP_INSTANCE_TYPE_VRF
;
973 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
974 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
977 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
978 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
980 ret
= bgp_get(&bgp
, &as
, name
, inst_type
);
982 case BGP_ERR_AS_MISMATCH
:
983 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
984 return CMD_WARNING_CONFIG_FAILED
;
985 case BGP_ERR_INSTANCE_MISMATCH
:
987 "BGP instance name and AS number mismatch\n");
989 "BGP instance is already running; AS is %u\n",
991 return CMD_WARNING_CONFIG_FAILED
;
995 * If we just instantiated the default instance, complete
996 * any pending VRF-VPN leaking that was configured via
997 * earlier "router bgp X vrf FOO" blocks.
999 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1000 vpn_leak_postchange_all();
1002 /* Pending: handle when user tries to change a view to vrf n vv.
1006 /* unset the auto created flag as the user config is now present */
1007 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1008 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1013 /* "no router bgp" commands. */
1014 DEFUN (no_router_bgp
,
1016 "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
1021 BGP_INSTANCE_HELP_STR
)
1027 const char *name
= NULL
;
1029 // "no router bgp" without an ASN
1031 // Pending: Make VRF option available for ASN less config
1032 bgp
= bgp_get_default();
1035 vty_out(vty
, "%% No BGP process is configured\n");
1036 return CMD_WARNING_CONFIG_FAILED
;
1039 if (listcount(bm
->bgp
) > 1) {
1040 vty_out(vty
, "%% Please specify ASN and VRF\n");
1041 return CMD_WARNING_CONFIG_FAILED
;
1045 vty_out(vty
, "%% Please unconfigure l3vni %u",
1047 return CMD_WARNING_CONFIG_FAILED
;
1050 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1053 name
= argv
[idx_vrf
]->arg
;
1055 /* Lookup bgp structure. */
1056 bgp
= bgp_lookup(as
, name
);
1058 vty_out(vty
, "%% Can't find BGP instance\n");
1059 return CMD_WARNING_CONFIG_FAILED
;
1063 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1065 return CMD_WARNING_CONFIG_FAILED
;
1068 /* Cannot delete default instance if vrf instances exist */
1069 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1070 struct listnode
*node
;
1071 struct bgp
*tmp_bgp
;
1073 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1074 if (tmp_bgp
->inst_type
1075 == BGP_INSTANCE_TYPE_VRF
) {
1077 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1078 return CMD_WARNING_CONFIG_FAILED
;
1090 /* BGP router-id. */
1092 DEFPY (bgp_router_id
,
1094 "bgp router-id A.B.C.D",
1096 "Override configured router identifier\n"
1097 "Manually configured router identifier\n")
1099 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1100 bgp_router_id_static_set(bgp
, router_id
);
1104 DEFPY (no_bgp_router_id
,
1105 no_bgp_router_id_cmd
,
1106 "no bgp router-id [A.B.C.D]",
1109 "Override configured router identifier\n"
1110 "Manually configured router identifier\n")
1112 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1114 if (router_id_str
) {
1115 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1116 vty_out(vty
, "%% BGP router-id doesn't match\n");
1117 return CMD_WARNING_CONFIG_FAILED
;
1121 router_id
.s_addr
= 0;
1122 bgp_router_id_static_set(bgp
, router_id
);
1128 /* BGP Cluster ID. */
1129 DEFUN (bgp_cluster_id
,
1131 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1133 "Configure Route-Reflector Cluster-id\n"
1134 "Route-Reflector Cluster-id in IP address format\n"
1135 "Route-Reflector Cluster-id as 32 bit quantity\n")
1137 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1140 struct in_addr cluster
;
1142 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1144 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1145 return CMD_WARNING_CONFIG_FAILED
;
1148 bgp_cluster_id_set(bgp
, &cluster
);
1149 bgp_clear_star_soft_out(vty
, bgp
->name
);
1154 DEFUN (no_bgp_cluster_id
,
1155 no_bgp_cluster_id_cmd
,
1156 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1159 "Configure Route-Reflector Cluster-id\n"
1160 "Route-Reflector Cluster-id in IP address format\n"
1161 "Route-Reflector Cluster-id as 32 bit quantity\n")
1163 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1164 bgp_cluster_id_unset(bgp
);
1165 bgp_clear_star_soft_out(vty
, bgp
->name
);
1170 DEFUN (bgp_confederation_identifier
,
1171 bgp_confederation_identifier_cmd
,
1172 "bgp confederation identifier (1-4294967295)",
1173 "BGP specific commands\n"
1174 "AS confederation parameters\n"
1176 "Set routing domain confederation AS\n")
1178 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1182 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1184 bgp_confederation_id_set(bgp
, as
);
1189 DEFUN (no_bgp_confederation_identifier
,
1190 no_bgp_confederation_identifier_cmd
,
1191 "no bgp confederation identifier [(1-4294967295)]",
1193 "BGP specific commands\n"
1194 "AS confederation parameters\n"
1196 "Set routing domain confederation AS\n")
1198 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1199 bgp_confederation_id_unset(bgp
);
1204 DEFUN (bgp_confederation_peers
,
1205 bgp_confederation_peers_cmd
,
1206 "bgp confederation peers (1-4294967295)...",
1207 "BGP specific commands\n"
1208 "AS confederation parameters\n"
1209 "Peer ASs in BGP confederation\n"
1212 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1217 for (i
= idx_asn
; i
< argc
; i
++) {
1218 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1220 if (bgp
->as
== as
) {
1222 "%% Local member-AS not allowed in confed peer list\n");
1226 bgp_confederation_peers_add(bgp
, as
);
1231 DEFUN (no_bgp_confederation_peers
,
1232 no_bgp_confederation_peers_cmd
,
1233 "no bgp confederation peers (1-4294967295)...",
1235 "BGP specific commands\n"
1236 "AS confederation parameters\n"
1237 "Peer ASs in BGP confederation\n"
1240 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1245 for (i
= idx_asn
; i
< argc
; i
++) {
1246 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1248 bgp_confederation_peers_remove(bgp
, as
);
1254 * Central routine for maximum-paths configuration.
1255 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1256 * @set: 1 for setting values, 0 for removing the max-paths config.
1258 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1259 const char *mpaths
, uint16_t options
,
1262 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1263 uint16_t maxpaths
= 0;
1268 afi
= bgp_node_afi(vty
);
1269 safi
= bgp_node_safi(vty
);
1272 maxpaths
= strtol(mpaths
, NULL
, 10);
1273 if (maxpaths
> multipath_num
) {
1275 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1276 maxpaths
, multipath_num
);
1277 return CMD_WARNING_CONFIG_FAILED
;
1279 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1282 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1286 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1287 (set
== 1) ? "" : "un",
1288 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1289 maxpaths
, afi
, safi
);
1290 return CMD_WARNING_CONFIG_FAILED
;
1293 bgp_recalculate_all_bestpaths(bgp
);
1298 DEFUN (bgp_maxmed_admin
,
1299 bgp_maxmed_admin_cmd
,
1300 "bgp max-med administrative ",
1302 "Advertise routes with max-med\n"
1303 "Administratively applied, for an indefinite period\n")
1305 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1307 bgp
->v_maxmed_admin
= 1;
1308 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1310 bgp_maxmed_update(bgp
);
1315 DEFUN (bgp_maxmed_admin_medv
,
1316 bgp_maxmed_admin_medv_cmd
,
1317 "bgp max-med administrative (0-4294967295)",
1319 "Advertise routes with max-med\n"
1320 "Administratively applied, for an indefinite period\n"
1321 "Max MED value to be used\n")
1323 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1326 bgp
->v_maxmed_admin
= 1;
1327 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1329 bgp_maxmed_update(bgp
);
1334 DEFUN (no_bgp_maxmed_admin
,
1335 no_bgp_maxmed_admin_cmd
,
1336 "no bgp max-med administrative [(0-4294967295)]",
1339 "Advertise routes with max-med\n"
1340 "Administratively applied, for an indefinite period\n"
1341 "Max MED value to be used\n")
1343 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1344 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1345 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1346 bgp_maxmed_update(bgp
);
1351 DEFUN (bgp_maxmed_onstartup
,
1352 bgp_maxmed_onstartup_cmd
,
1353 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1355 "Advertise routes with max-med\n"
1356 "Effective on a startup\n"
1357 "Time (seconds) period for max-med\n"
1358 "Max MED value to be used\n")
1360 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1363 argv_find(argv
, argc
, "(5-86400)", &idx
);
1364 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1365 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1366 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1368 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1370 bgp_maxmed_update(bgp
);
1375 DEFUN (no_bgp_maxmed_onstartup
,
1376 no_bgp_maxmed_onstartup_cmd
,
1377 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1380 "Advertise routes with max-med\n"
1381 "Effective on a startup\n"
1382 "Time (seconds) period for max-med\n"
1383 "Max MED value to be used\n")
1385 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1387 /* Cancel max-med onstartup if its on */
1388 if (bgp
->t_maxmed_onstartup
) {
1389 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1390 bgp
->maxmed_onstartup_over
= 1;
1393 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1394 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1396 bgp_maxmed_update(bgp
);
1401 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1404 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1405 uint16_t update_delay
;
1406 uint16_t establish_wait
;
1408 update_delay
= strtoul(delay
, NULL
, 10);
1410 if (!wait
) /* update-delay <delay> */
1412 bgp
->v_update_delay
= update_delay
;
1413 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1417 /* update-delay <delay> <establish-wait> */
1418 establish_wait
= atoi(wait
);
1419 if (update_delay
< establish_wait
) {
1421 "%%Failed: update-delay less than the establish-wait!\n");
1422 return CMD_WARNING_CONFIG_FAILED
;
1425 bgp
->v_update_delay
= update_delay
;
1426 bgp
->v_establish_wait
= establish_wait
;
1431 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1433 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1435 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1436 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1441 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1443 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1444 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1445 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1446 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1452 /* Update-delay configuration */
1453 DEFUN (bgp_update_delay
,
1454 bgp_update_delay_cmd
,
1455 "update-delay (0-3600)",
1456 "Force initial delay for best-path and updates\n"
1460 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1463 DEFUN (bgp_update_delay_establish_wait
,
1464 bgp_update_delay_establish_wait_cmd
,
1465 "update-delay (0-3600) (1-3600)",
1466 "Force initial delay for best-path and updates\n"
1471 int idx_number_2
= 2;
1472 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1473 argv
[idx_number_2
]->arg
);
1476 /* Update-delay deconfiguration */
1477 DEFUN (no_bgp_update_delay
,
1478 no_bgp_update_delay_cmd
,
1479 "no update-delay [(0-3600) [(1-3600)]]",
1481 "Force initial delay for best-path and updates\n"
1485 return bgp_update_delay_deconfig_vty(vty
);
1489 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1492 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1495 uint32_t quanta
= strtoul(num
, NULL
, 10);
1496 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
,
1497 memory_order_relaxed
);
1499 atomic_store_explicit(&bgp
->wpkt_quanta
, BGP_WRITE_PACKET_MAX
,
1500 memory_order_relaxed
);
1506 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1509 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1512 uint32_t quanta
= strtoul(num
, NULL
, 10);
1513 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
,
1514 memory_order_relaxed
);
1516 atomic_store_explicit(&bgp
->rpkt_quanta
, BGP_READ_PACKET_MAX
,
1517 memory_order_relaxed
);
1523 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1526 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1527 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1528 vty_out(vty
, " write-quanta %d\n", quanta
);
1531 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1534 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1535 if (quanta
!= BGP_READ_PACKET_MAX
)
1536 vty_out(vty
, " read-quanta %d\n", quanta
);
1539 /* Packet quanta configuration */
1540 DEFUN (bgp_wpkt_quanta
,
1541 bgp_wpkt_quanta_cmd
,
1542 "write-quanta (1-10)",
1543 "How many packets to write to peer socket per run\n"
1544 "Number of packets\n")
1547 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1550 DEFUN (no_bgp_wpkt_quanta
,
1551 no_bgp_wpkt_quanta_cmd
,
1552 "no write-quanta (1-10)",
1554 "How many packets to write to peer socket per I/O cycle\n"
1555 "Number of packets\n")
1558 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1561 DEFUN (bgp_rpkt_quanta
,
1562 bgp_rpkt_quanta_cmd
,
1563 "read-quanta (1-10)",
1564 "How many packets to read from peer socket per I/O cycle\n"
1565 "Number of packets\n")
1568 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1571 DEFUN (no_bgp_rpkt_quanta
,
1572 no_bgp_rpkt_quanta_cmd
,
1573 "no read-quanta (1-10)",
1575 "How many packets to read from peer socket per I/O cycle\n"
1576 "Number of packets\n")
1579 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1582 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1584 if (!bgp
->heuristic_coalesce
)
1585 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1589 DEFUN (bgp_coalesce_time
,
1590 bgp_coalesce_time_cmd
,
1591 "coalesce-time (0-4294967295)",
1592 "Subgroup coalesce timer\n"
1593 "Subgroup coalesce timer value (in ms)\n")
1595 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1598 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1599 bgp
->heuristic_coalesce
= false;
1600 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1604 DEFUN (no_bgp_coalesce_time
,
1605 no_bgp_coalesce_time_cmd
,
1606 "no coalesce-time (0-4294967295)",
1608 "Subgroup coalesce timer\n"
1609 "Subgroup coalesce timer value (in ms)\n")
1611 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1613 bgp
->heuristic_coalesce
= true;
1614 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1618 /* Maximum-paths configuration */
1619 DEFUN (bgp_maxpaths
,
1621 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1622 "Forward packets over multiple paths\n"
1623 "Number of paths\n")
1626 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1627 argv
[idx_number
]->arg
, 0, 1);
1630 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1631 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1632 "Forward packets over multiple paths\n"
1633 "Number of paths\n")
1635 DEFUN (bgp_maxpaths_ibgp
,
1636 bgp_maxpaths_ibgp_cmd
,
1637 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1638 "Forward packets over multiple paths\n"
1640 "Number of paths\n")
1643 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1644 argv
[idx_number
]->arg
, 0, 1);
1647 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1648 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1649 "Forward packets over multiple paths\n"
1651 "Number of paths\n")
1653 DEFUN (bgp_maxpaths_ibgp_cluster
,
1654 bgp_maxpaths_ibgp_cluster_cmd
,
1655 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1656 "Forward packets over multiple paths\n"
1659 "Match the cluster length\n")
1662 return bgp_maxpaths_config_vty(
1663 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1664 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1667 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1668 "maximum-paths ibgp " CMD_RANGE_STR(
1669 1, MULTIPATH_NUM
) " equal-cluster-length",
1670 "Forward packets over multiple paths\n"
1673 "Match the cluster length\n")
1675 DEFUN (no_bgp_maxpaths
,
1676 no_bgp_maxpaths_cmd
,
1677 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1679 "Forward packets over multiple paths\n"
1680 "Number of paths\n")
1682 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1685 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1686 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1687 "Forward packets over multiple paths\n"
1688 "Number of paths\n")
1690 DEFUN (no_bgp_maxpaths_ibgp
,
1691 no_bgp_maxpaths_ibgp_cmd
,
1692 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1694 "Forward packets over multiple paths\n"
1697 "Match the cluster length\n")
1699 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1702 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1703 "no maximum-paths ibgp [" CMD_RANGE_STR(
1704 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1706 "Forward packets over multiple paths\n"
1709 "Match the cluster length\n")
1711 void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1714 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1715 vty_out(vty
, " maximum-paths %d\n",
1716 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1719 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1720 vty_out(vty
, " maximum-paths ibgp %d",
1721 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1722 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1723 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1724 vty_out(vty
, " equal-cluster-length");
1733 "timers bgp (0-65535) (0-65535)",
1734 "Adjust routing timers\n"
1736 "Keepalive interval\n"
1739 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1741 int idx_number_2
= 3;
1742 unsigned long keepalive
= 0;
1743 unsigned long holdtime
= 0;
1745 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1746 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1748 /* Holdtime value check. */
1749 if (holdtime
< 3 && holdtime
!= 0) {
1751 "%% hold time value must be either 0 or greater than 3\n");
1752 return CMD_WARNING_CONFIG_FAILED
;
1755 bgp_timers_set(bgp
, keepalive
, holdtime
);
1760 DEFUN (no_bgp_timers
,
1762 "no timers bgp [(0-65535) (0-65535)]",
1764 "Adjust routing timers\n"
1766 "Keepalive interval\n"
1769 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1770 bgp_timers_unset(bgp
);
1776 DEFUN (bgp_client_to_client_reflection
,
1777 bgp_client_to_client_reflection_cmd
,
1778 "bgp client-to-client reflection",
1779 "BGP specific commands\n"
1780 "Configure client to client route reflection\n"
1781 "reflection of routes allowed\n")
1783 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1784 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1785 bgp_clear_star_soft_out(vty
, bgp
->name
);
1790 DEFUN (no_bgp_client_to_client_reflection
,
1791 no_bgp_client_to_client_reflection_cmd
,
1792 "no bgp client-to-client reflection",
1794 "BGP specific commands\n"
1795 "Configure client to client route reflection\n"
1796 "reflection of routes allowed\n")
1798 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1799 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1800 bgp_clear_star_soft_out(vty
, bgp
->name
);
1805 /* "bgp always-compare-med" configuration. */
1806 DEFUN (bgp_always_compare_med
,
1807 bgp_always_compare_med_cmd
,
1808 "bgp always-compare-med",
1809 "BGP specific commands\n"
1810 "Allow comparing MED from different neighbors\n")
1812 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1813 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1814 bgp_recalculate_all_bestpaths(bgp
);
1819 DEFUN (no_bgp_always_compare_med
,
1820 no_bgp_always_compare_med_cmd
,
1821 "no bgp always-compare-med",
1823 "BGP specific commands\n"
1824 "Allow comparing MED from different neighbors\n")
1826 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1827 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1828 bgp_recalculate_all_bestpaths(bgp
);
1834 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
1835 "bgp ebgp-requires-policy",
1836 "BGP specific commands\n"
1837 "Require in and out policy for eBGP peers (RFC8212)\n")
1839 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1840 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_ENABLED
;
1844 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
1845 "no bgp ebgp-requires-policy",
1847 "BGP specific commands\n"
1848 "Require in and out policy for eBGP peers (RFC8212)\n")
1850 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1851 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_DISABLED
;
1856 /* "bgp deterministic-med" configuration. */
1857 DEFUN (bgp_deterministic_med
,
1858 bgp_deterministic_med_cmd
,
1859 "bgp deterministic-med",
1860 "BGP specific commands\n"
1861 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1863 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1865 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1866 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1867 bgp_recalculate_all_bestpaths(bgp
);
1873 DEFUN (no_bgp_deterministic_med
,
1874 no_bgp_deterministic_med_cmd
,
1875 "no bgp deterministic-med",
1877 "BGP specific commands\n"
1878 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1880 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1881 int bestpath_per_as_used
;
1885 struct listnode
*node
, *nnode
;
1887 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1888 bestpath_per_as_used
= 0;
1890 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1891 FOREACH_AFI_SAFI (afi
, safi
)
1892 if (bgp_addpath_dmed_required(
1893 peer
->addpath_type
[afi
][safi
])) {
1894 bestpath_per_as_used
= 1;
1898 if (bestpath_per_as_used
)
1902 if (bestpath_per_as_used
) {
1904 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
1905 return CMD_WARNING_CONFIG_FAILED
;
1907 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1908 bgp_recalculate_all_bestpaths(bgp
);
1915 /* "bgp graceful-restart" configuration. */
1916 DEFUN (bgp_graceful_restart
,
1917 bgp_graceful_restart_cmd
,
1918 "bgp graceful-restart",
1919 "BGP specific commands\n"
1920 "Graceful restart capability parameters\n")
1922 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1923 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1927 DEFUN (no_bgp_graceful_restart
,
1928 no_bgp_graceful_restart_cmd
,
1929 "no bgp graceful-restart",
1931 "BGP specific commands\n"
1932 "Graceful restart capability parameters\n")
1934 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1935 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1939 DEFUN (bgp_graceful_restart_stalepath_time
,
1940 bgp_graceful_restart_stalepath_time_cmd
,
1941 "bgp graceful-restart stalepath-time (1-4095)",
1942 "BGP specific commands\n"
1943 "Graceful restart capability parameters\n"
1944 "Set the max time to hold onto restarting peer's stale paths\n"
1945 "Delay value (seconds)\n")
1947 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1951 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1952 bgp
->stalepath_time
= stalepath
;
1956 DEFUN (bgp_graceful_restart_restart_time
,
1957 bgp_graceful_restart_restart_time_cmd
,
1958 "bgp graceful-restart restart-time (1-4095)",
1959 "BGP specific commands\n"
1960 "Graceful restart capability parameters\n"
1961 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1962 "Delay value (seconds)\n")
1964 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1968 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1969 bgp
->restart_time
= restart
;
1973 DEFUN (no_bgp_graceful_restart_stalepath_time
,
1974 no_bgp_graceful_restart_stalepath_time_cmd
,
1975 "no bgp graceful-restart stalepath-time [(1-4095)]",
1977 "BGP specific commands\n"
1978 "Graceful restart capability parameters\n"
1979 "Set the max time to hold onto restarting peer's stale paths\n"
1980 "Delay value (seconds)\n")
1982 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1984 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
1988 DEFUN (no_bgp_graceful_restart_restart_time
,
1989 no_bgp_graceful_restart_restart_time_cmd
,
1990 "no bgp graceful-restart restart-time [(1-4095)]",
1992 "BGP specific commands\n"
1993 "Graceful restart capability parameters\n"
1994 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1995 "Delay value (seconds)\n")
1997 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1999 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2003 DEFUN (bgp_graceful_restart_preserve_fw
,
2004 bgp_graceful_restart_preserve_fw_cmd
,
2005 "bgp graceful-restart preserve-fw-state",
2006 "BGP specific commands\n"
2007 "Graceful restart capability parameters\n"
2008 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2010 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2011 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2015 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2016 no_bgp_graceful_restart_preserve_fw_cmd
,
2017 "no bgp graceful-restart preserve-fw-state",
2019 "BGP specific commands\n"
2020 "Graceful restart capability parameters\n"
2021 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2023 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2024 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2028 /* "bgp graceful-shutdown" configuration */
2029 DEFUN (bgp_graceful_shutdown
,
2030 bgp_graceful_shutdown_cmd
,
2031 "bgp graceful-shutdown",
2033 "Graceful shutdown parameters\n")
2035 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2037 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2038 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2039 bgp_static_redo_import_check(bgp
);
2040 bgp_redistribute_redo(bgp
);
2041 bgp_clear_star_soft_out(vty
, bgp
->name
);
2042 bgp_clear_star_soft_in(vty
, bgp
->name
);
2048 DEFUN (no_bgp_graceful_shutdown
,
2049 no_bgp_graceful_shutdown_cmd
,
2050 "no bgp graceful-shutdown",
2053 "Graceful shutdown parameters\n")
2055 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2057 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2058 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2059 bgp_static_redo_import_check(bgp
);
2060 bgp_redistribute_redo(bgp
);
2061 bgp_clear_star_soft_out(vty
, bgp
->name
);
2062 bgp_clear_star_soft_in(vty
, bgp
->name
);
2068 /* "bgp fast-external-failover" configuration. */
2069 DEFUN (bgp_fast_external_failover
,
2070 bgp_fast_external_failover_cmd
,
2071 "bgp fast-external-failover",
2073 "Immediately reset session if a link to a directly connected external peer goes down\n")
2075 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2076 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2080 DEFUN (no_bgp_fast_external_failover
,
2081 no_bgp_fast_external_failover_cmd
,
2082 "no bgp fast-external-failover",
2085 "Immediately reset session if a link to a directly connected external peer goes down\n")
2087 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2088 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2092 /* "bgp bestpath compare-routerid" configuration. */
2093 DEFUN (bgp_bestpath_compare_router_id
,
2094 bgp_bestpath_compare_router_id_cmd
,
2095 "bgp bestpath compare-routerid",
2096 "BGP specific commands\n"
2097 "Change the default bestpath selection\n"
2098 "Compare router-id for identical EBGP paths\n")
2100 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2101 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2102 bgp_recalculate_all_bestpaths(bgp
);
2107 DEFUN (no_bgp_bestpath_compare_router_id
,
2108 no_bgp_bestpath_compare_router_id_cmd
,
2109 "no bgp bestpath compare-routerid",
2111 "BGP specific commands\n"
2112 "Change the default bestpath selection\n"
2113 "Compare router-id for identical EBGP paths\n")
2115 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2116 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2117 bgp_recalculate_all_bestpaths(bgp
);
2122 /* "bgp bestpath as-path ignore" configuration. */
2123 DEFUN (bgp_bestpath_aspath_ignore
,
2124 bgp_bestpath_aspath_ignore_cmd
,
2125 "bgp bestpath as-path ignore",
2126 "BGP specific commands\n"
2127 "Change the default bestpath selection\n"
2128 "AS-path attribute\n"
2129 "Ignore as-path length in selecting a route\n")
2131 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2132 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2133 bgp_recalculate_all_bestpaths(bgp
);
2138 DEFUN (no_bgp_bestpath_aspath_ignore
,
2139 no_bgp_bestpath_aspath_ignore_cmd
,
2140 "no bgp bestpath as-path ignore",
2142 "BGP specific commands\n"
2143 "Change the default bestpath selection\n"
2144 "AS-path attribute\n"
2145 "Ignore as-path length in selecting a route\n")
2147 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2148 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2149 bgp_recalculate_all_bestpaths(bgp
);
2154 /* "bgp bestpath as-path confed" configuration. */
2155 DEFUN (bgp_bestpath_aspath_confed
,
2156 bgp_bestpath_aspath_confed_cmd
,
2157 "bgp bestpath as-path confed",
2158 "BGP specific commands\n"
2159 "Change the default bestpath selection\n"
2160 "AS-path attribute\n"
2161 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2163 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2164 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2165 bgp_recalculate_all_bestpaths(bgp
);
2170 DEFUN (no_bgp_bestpath_aspath_confed
,
2171 no_bgp_bestpath_aspath_confed_cmd
,
2172 "no bgp bestpath as-path confed",
2174 "BGP specific commands\n"
2175 "Change the default bestpath selection\n"
2176 "AS-path attribute\n"
2177 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2179 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2180 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2181 bgp_recalculate_all_bestpaths(bgp
);
2186 /* "bgp bestpath as-path multipath-relax" configuration. */
2187 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2188 bgp_bestpath_aspath_multipath_relax_cmd
,
2189 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2190 "BGP specific commands\n"
2191 "Change the default bestpath selection\n"
2192 "AS-path attribute\n"
2193 "Allow load sharing across routes that have different AS paths (but same length)\n"
2194 "Generate an AS_SET\n"
2195 "Do not generate an AS_SET\n")
2197 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2199 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2201 /* no-as-set is now the default behavior so we can silently
2203 if (argv_find(argv
, argc
, "as-set", &idx
))
2204 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2206 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2208 bgp_recalculate_all_bestpaths(bgp
);
2213 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2214 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2215 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2217 "BGP specific commands\n"
2218 "Change the default bestpath selection\n"
2219 "AS-path attribute\n"
2220 "Allow load sharing across routes that have different AS paths (but same length)\n"
2221 "Generate an AS_SET\n"
2222 "Do not generate an AS_SET\n")
2224 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2225 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2226 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2227 bgp_recalculate_all_bestpaths(bgp
);
2232 /* "bgp log-neighbor-changes" configuration. */
2233 DEFUN (bgp_log_neighbor_changes
,
2234 bgp_log_neighbor_changes_cmd
,
2235 "bgp log-neighbor-changes",
2236 "BGP specific commands\n"
2237 "Log neighbor up/down and reset reason\n")
2239 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2240 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2244 DEFUN (no_bgp_log_neighbor_changes
,
2245 no_bgp_log_neighbor_changes_cmd
,
2246 "no bgp log-neighbor-changes",
2248 "BGP specific commands\n"
2249 "Log neighbor up/down and reset reason\n")
2251 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2252 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2256 /* "bgp bestpath med" configuration. */
2257 DEFUN (bgp_bestpath_med
,
2258 bgp_bestpath_med_cmd
,
2259 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2260 "BGP specific commands\n"
2261 "Change the default bestpath selection\n"
2263 "Compare MED among confederation paths\n"
2264 "Treat missing MED as the least preferred one\n"
2265 "Treat missing MED as the least preferred one\n"
2266 "Compare MED among confederation paths\n")
2268 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2271 if (argv_find(argv
, argc
, "confed", &idx
))
2272 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2274 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2275 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2277 bgp_recalculate_all_bestpaths(bgp
);
2282 DEFUN (no_bgp_bestpath_med
,
2283 no_bgp_bestpath_med_cmd
,
2284 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2286 "BGP specific commands\n"
2287 "Change the default bestpath selection\n"
2289 "Compare MED among confederation paths\n"
2290 "Treat missing MED as the least preferred one\n"
2291 "Treat missing MED as the least preferred one\n"
2292 "Compare MED among confederation paths\n")
2294 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2297 if (argv_find(argv
, argc
, "confed", &idx
))
2298 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2300 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2301 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2303 bgp_recalculate_all_bestpaths(bgp
);
2308 /* "no bgp default ipv4-unicast". */
2309 DEFUN (no_bgp_default_ipv4_unicast
,
2310 no_bgp_default_ipv4_unicast_cmd
,
2311 "no bgp default ipv4-unicast",
2313 "BGP specific commands\n"
2314 "Configure BGP defaults\n"
2315 "Activate ipv4-unicast for a peer by default\n")
2317 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2318 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2322 DEFUN (bgp_default_ipv4_unicast
,
2323 bgp_default_ipv4_unicast_cmd
,
2324 "bgp default ipv4-unicast",
2325 "BGP specific commands\n"
2326 "Configure BGP defaults\n"
2327 "Activate ipv4-unicast for a peer by default\n")
2329 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2330 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2334 /* Display hostname in certain command outputs */
2335 DEFUN (bgp_default_show_hostname
,
2336 bgp_default_show_hostname_cmd
,
2337 "bgp default show-hostname",
2338 "BGP specific commands\n"
2339 "Configure BGP defaults\n"
2340 "Show hostname in certain command outputs\n")
2342 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2343 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2347 DEFUN (no_bgp_default_show_hostname
,
2348 no_bgp_default_show_hostname_cmd
,
2349 "no bgp default show-hostname",
2351 "BGP specific commands\n"
2352 "Configure BGP defaults\n"
2353 "Show hostname in certain command outputs\n")
2355 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2356 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2360 /* "bgp network import-check" configuration. */
2361 DEFUN (bgp_network_import_check
,
2362 bgp_network_import_check_cmd
,
2363 "bgp network import-check",
2364 "BGP specific commands\n"
2365 "BGP network command\n"
2366 "Check BGP network route exists in IGP\n")
2368 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2369 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2370 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2371 bgp_static_redo_import_check(bgp
);
2377 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2378 "bgp network import-check exact",
2379 "BGP specific commands\n"
2380 "BGP network command\n"
2381 "Check BGP network route exists in IGP\n"
2382 "Match route precisely\n")
2384 DEFUN (no_bgp_network_import_check
,
2385 no_bgp_network_import_check_cmd
,
2386 "no bgp network import-check",
2388 "BGP specific commands\n"
2389 "BGP network command\n"
2390 "Check BGP network route exists in IGP\n")
2392 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2393 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2394 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2395 bgp_static_redo_import_check(bgp
);
2401 DEFUN (bgp_default_local_preference
,
2402 bgp_default_local_preference_cmd
,
2403 "bgp default local-preference (0-4294967295)",
2404 "BGP specific commands\n"
2405 "Configure BGP defaults\n"
2406 "local preference (higher=more preferred)\n"
2407 "Configure default local preference value\n")
2409 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2411 uint32_t local_pref
;
2413 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2415 bgp_default_local_preference_set(bgp
, local_pref
);
2416 bgp_clear_star_soft_in(vty
, bgp
->name
);
2421 DEFUN (no_bgp_default_local_preference
,
2422 no_bgp_default_local_preference_cmd
,
2423 "no bgp default local-preference [(0-4294967295)]",
2425 "BGP specific commands\n"
2426 "Configure BGP defaults\n"
2427 "local preference (higher=more preferred)\n"
2428 "Configure default local preference value\n")
2430 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2431 bgp_default_local_preference_unset(bgp
);
2432 bgp_clear_star_soft_in(vty
, bgp
->name
);
2438 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2439 bgp_default_subgroup_pkt_queue_max_cmd
,
2440 "bgp default subgroup-pkt-queue-max (20-100)",
2441 "BGP specific commands\n"
2442 "Configure BGP defaults\n"
2443 "subgroup-pkt-queue-max\n"
2444 "Configure subgroup packet queue max\n")
2446 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2450 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2452 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2457 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2458 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2459 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2461 "BGP specific commands\n"
2462 "Configure BGP defaults\n"
2463 "subgroup-pkt-queue-max\n"
2464 "Configure subgroup packet queue max\n")
2466 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2467 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2472 DEFUN (bgp_rr_allow_outbound_policy
,
2473 bgp_rr_allow_outbound_policy_cmd
,
2474 "bgp route-reflector allow-outbound-policy",
2475 "BGP specific commands\n"
2476 "Allow modifications made by out route-map\n"
2477 "on ibgp neighbors\n")
2479 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2481 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2482 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2483 update_group_announce_rrclients(bgp
);
2484 bgp_clear_star_soft_out(vty
, bgp
->name
);
2490 DEFUN (no_bgp_rr_allow_outbound_policy
,
2491 no_bgp_rr_allow_outbound_policy_cmd
,
2492 "no bgp route-reflector allow-outbound-policy",
2494 "BGP specific commands\n"
2495 "Allow modifications made by out route-map\n"
2496 "on ibgp neighbors\n")
2498 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2500 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2501 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2502 update_group_announce_rrclients(bgp
);
2503 bgp_clear_star_soft_out(vty
, bgp
->name
);
2509 DEFUN (bgp_listen_limit
,
2510 bgp_listen_limit_cmd
,
2511 "bgp listen limit (1-5000)",
2512 "BGP specific commands\n"
2513 "Configure BGP defaults\n"
2514 "maximum number of BGP Dynamic Neighbors that can be created\n"
2515 "Configure Dynamic Neighbors listen limit value\n")
2517 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2521 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2523 bgp_listen_limit_set(bgp
, listen_limit
);
2528 DEFUN (no_bgp_listen_limit
,
2529 no_bgp_listen_limit_cmd
,
2530 "no bgp listen limit [(1-5000)]",
2531 "BGP specific commands\n"
2532 "Configure BGP defaults\n"
2533 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2534 "Configure Dynamic Neighbors listen limit value to default\n"
2535 "Configure Dynamic Neighbors listen limit value\n")
2537 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2538 bgp_listen_limit_unset(bgp
);
2544 * Check if this listen range is already configured. Check for exact
2545 * match or overlap based on input.
2547 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2548 struct prefix
*range
, int exact
)
2550 struct listnode
*node
, *nnode
;
2551 struct listnode
*node1
, *nnode1
;
2552 struct peer_group
*group
;
2557 afi
= family2afi(range
->family
);
2558 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2559 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2562 match
= prefix_same(range
, lr
);
2564 match
= (prefix_match(range
, lr
)
2565 || prefix_match(lr
, range
));
2574 DEFUN (bgp_listen_range
,
2575 bgp_listen_range_cmd
,
2576 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
2577 "BGP specific commands\n"
2578 "Configure BGP dynamic neighbors listen range\n"
2579 "Configure BGP dynamic neighbors listen range\n"
2581 "Member of the peer-group\n"
2582 "Peer-group name\n")
2584 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2585 struct prefix range
;
2586 struct peer_group
*group
, *existing_group
;
2591 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2592 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2593 char *prefix
= argv
[idx
]->arg
;
2594 argv_find(argv
, argc
, "PGNAME", &idx
);
2595 char *peergroup
= argv
[idx
]->arg
;
2597 /* Convert IP prefix string to struct prefix. */
2598 ret
= str2prefix(prefix
, &range
);
2600 vty_out(vty
, "%% Malformed listen range\n");
2601 return CMD_WARNING_CONFIG_FAILED
;
2604 afi
= family2afi(range
.family
);
2606 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2608 "%% Malformed listen range (link-local address)\n");
2609 return CMD_WARNING_CONFIG_FAILED
;
2614 /* Check if same listen range is already configured. */
2615 existing_group
= listen_range_exists(bgp
, &range
, 1);
2616 if (existing_group
) {
2617 if (strcmp(existing_group
->name
, peergroup
) == 0)
2621 "%% Same listen range is attached to peer-group %s\n",
2622 existing_group
->name
);
2623 return CMD_WARNING_CONFIG_FAILED
;
2627 /* Check if an overlapping listen range exists. */
2628 if (listen_range_exists(bgp
, &range
, 0)) {
2630 "%% Listen range overlaps with existing listen range\n");
2631 return CMD_WARNING_CONFIG_FAILED
;
2634 group
= peer_group_lookup(bgp
, peergroup
);
2636 vty_out(vty
, "%% Configure the peer-group first\n");
2637 return CMD_WARNING_CONFIG_FAILED
;
2640 ret
= peer_group_listen_range_add(group
, &range
);
2641 return bgp_vty_return(vty
, ret
);
2644 DEFUN (no_bgp_listen_range
,
2645 no_bgp_listen_range_cmd
,
2646 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
2648 "BGP specific commands\n"
2649 "Unconfigure BGP dynamic neighbors listen range\n"
2650 "Unconfigure BGP dynamic neighbors listen range\n"
2652 "Member of the peer-group\n"
2653 "Peer-group name\n")
2655 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2656 struct prefix range
;
2657 struct peer_group
*group
;
2662 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2663 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2664 char *prefix
= argv
[idx
]->arg
;
2665 argv_find(argv
, argc
, "WORD", &idx
);
2666 char *peergroup
= argv
[idx
]->arg
;
2668 /* Convert IP prefix string to struct prefix. */
2669 ret
= str2prefix(prefix
, &range
);
2671 vty_out(vty
, "%% Malformed listen range\n");
2672 return CMD_WARNING_CONFIG_FAILED
;
2675 afi
= family2afi(range
.family
);
2677 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2679 "%% Malformed listen range (link-local address)\n");
2680 return CMD_WARNING_CONFIG_FAILED
;
2685 group
= peer_group_lookup(bgp
, peergroup
);
2687 vty_out(vty
, "%% Peer-group does not exist\n");
2688 return CMD_WARNING_CONFIG_FAILED
;
2691 ret
= peer_group_listen_range_del(group
, &range
);
2692 return bgp_vty_return(vty
, ret
);
2695 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2697 struct peer_group
*group
;
2698 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2699 struct prefix
*range
;
2701 char buf
[PREFIX2STR_BUFFER
];
2703 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2704 vty_out(vty
, " bgp listen limit %d\n",
2705 bgp
->dynamic_neighbors_limit
);
2707 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2708 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2709 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2711 prefix2str(range
, buf
, sizeof(buf
));
2713 " bgp listen range %s peer-group %s\n",
2721 DEFUN (bgp_disable_connected_route_check
,
2722 bgp_disable_connected_route_check_cmd
,
2723 "bgp disable-ebgp-connected-route-check",
2724 "BGP specific commands\n"
2725 "Disable checking if nexthop is connected on ebgp sessions\n")
2727 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2728 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2729 bgp_clear_star_soft_in(vty
, bgp
->name
);
2734 DEFUN (no_bgp_disable_connected_route_check
,
2735 no_bgp_disable_connected_route_check_cmd
,
2736 "no bgp disable-ebgp-connected-route-check",
2738 "BGP specific commands\n"
2739 "Disable checking if nexthop is connected on ebgp sessions\n")
2741 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2742 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2743 bgp_clear_star_soft_in(vty
, bgp
->name
);
2749 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2750 const char *as_str
, afi_t afi
, safi_t safi
)
2752 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2755 int as_type
= AS_SPECIFIED
;
2758 if (as_str
[0] == 'i') {
2760 as_type
= AS_INTERNAL
;
2761 } else if (as_str
[0] == 'e') {
2763 as_type
= AS_EXTERNAL
;
2765 /* Get AS number. */
2766 as
= strtoul(as_str
, NULL
, 10);
2769 /* If peer is peer group or interface peer, call proper function. */
2770 ret
= str2sockunion(peer_str
, &su
);
2774 /* Check if existing interface peer */
2775 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
2777 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2780 /* if not interface peer, check peer-group settings */
2781 if (ret
< 0 && !peer
) {
2782 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2785 "%% Create the peer-group or interface first\n");
2786 return CMD_WARNING_CONFIG_FAILED
;
2791 if (peer_address_self_check(bgp
, &su
)) {
2793 "%% Can not configure the local system as neighbor\n");
2794 return CMD_WARNING_CONFIG_FAILED
;
2796 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2799 /* This peer belongs to peer group. */
2801 case BGP_ERR_PEER_GROUP_MEMBER
:
2803 "%% Peer-group member cannot override remote-as of peer-group\n");
2804 return CMD_WARNING_CONFIG_FAILED
;
2805 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2807 "%% Peer-group members must be all internal or all external\n");
2808 return CMD_WARNING_CONFIG_FAILED
;
2810 return bgp_vty_return(vty
, ret
);
2813 DEFUN (bgp_default_shutdown
,
2814 bgp_default_shutdown_cmd
,
2815 "[no] bgp default shutdown",
2818 "Configure BGP defaults\n"
2819 "Apply administrative shutdown to newly configured peers\n")
2821 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2822 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2826 DEFUN (neighbor_remote_as
,
2827 neighbor_remote_as_cmd
,
2828 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2831 "Specify a BGP neighbor\n"
2833 "Internal BGP peer\n"
2834 "External BGP peer\n")
2837 int idx_remote_as
= 3;
2838 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2839 argv
[idx_remote_as
]->arg
, AFI_IP
,
2843 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2844 afi_t afi
, safi_t safi
, int v6only
,
2845 const char *peer_group_name
,
2848 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2850 int as_type
= AS_UNSPECIFIED
;
2852 struct peer_group
*group
;
2856 group
= peer_group_lookup(bgp
, conf_if
);
2859 vty_out(vty
, "%% Name conflict with peer-group \n");
2860 return CMD_WARNING_CONFIG_FAILED
;
2864 if (as_str
[0] == 'i') {
2865 as_type
= AS_INTERNAL
;
2866 } else if (as_str
[0] == 'e') {
2867 as_type
= AS_EXTERNAL
;
2869 /* Get AS number. */
2870 as
= strtoul(as_str
, NULL
, 10);
2871 as_type
= AS_SPECIFIED
;
2875 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2878 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
2881 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2882 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2883 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2884 as_type
, 0, 0, NULL
);
2886 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2887 as_type
, afi
, safi
, NULL
);
2890 vty_out(vty
, "%% BGP failed to create peer\n");
2891 return CMD_WARNING_CONFIG_FAILED
;
2895 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2897 /* Request zebra to initiate IPv6 RAs on this interface. We do
2899 * any unnumbered peer in order to not worry about run-time
2901 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2903 * gets deleted later etc.)
2906 bgp_zebra_initiate_radv(bgp
, peer
);
2909 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2910 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2912 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2914 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2916 /* v6only flag changed. Reset bgp seesion */
2917 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2918 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2919 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2920 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2922 bgp_session_reset(peer
);
2925 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
2926 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
2927 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
2928 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
2931 if (peer_group_name
) {
2932 group
= peer_group_lookup(bgp
, peer_group_name
);
2934 vty_out(vty
, "%% Configure the peer-group first\n");
2935 return CMD_WARNING_CONFIG_FAILED
;
2938 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
2941 return bgp_vty_return(vty
, ret
);
2944 DEFUN (neighbor_interface_config
,
2945 neighbor_interface_config_cmd
,
2946 "neighbor WORD interface [peer-group PGNAME]",
2948 "Interface name or neighbor tag\n"
2949 "Enable BGP on interface\n"
2950 "Member of the peer-group\n"
2951 "Peer-group name\n")
2954 int idx_peer_group_word
= 4;
2956 if (argc
> idx_peer_group_word
)
2957 return peer_conf_interface_get(
2958 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
2959 argv
[idx_peer_group_word
]->arg
, NULL
);
2961 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2962 SAFI_UNICAST
, 0, NULL
, NULL
);
2965 DEFUN (neighbor_interface_config_v6only
,
2966 neighbor_interface_config_v6only_cmd
,
2967 "neighbor WORD interface v6only [peer-group PGNAME]",
2969 "Interface name or neighbor tag\n"
2970 "Enable BGP on interface\n"
2971 "Enable BGP with v6 link-local only\n"
2972 "Member of the peer-group\n"
2973 "Peer-group name\n")
2976 int idx_peer_group_word
= 5;
2978 if (argc
> idx_peer_group_word
)
2979 return peer_conf_interface_get(
2980 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
2981 argv
[idx_peer_group_word
]->arg
, NULL
);
2983 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2984 SAFI_UNICAST
, 1, NULL
, NULL
);
2988 DEFUN (neighbor_interface_config_remote_as
,
2989 neighbor_interface_config_remote_as_cmd
,
2990 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
2992 "Interface name or neighbor tag\n"
2993 "Enable BGP on interface\n"
2994 "Specify a BGP neighbor\n"
2996 "Internal BGP peer\n"
2997 "External BGP peer\n")
3000 int idx_remote_as
= 4;
3001 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3002 SAFI_UNICAST
, 0, NULL
,
3003 argv
[idx_remote_as
]->arg
);
3006 DEFUN (neighbor_interface_v6only_config_remote_as
,
3007 neighbor_interface_v6only_config_remote_as_cmd
,
3008 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
3010 "Interface name or neighbor tag\n"
3011 "Enable BGP with v6 link-local only\n"
3012 "Enable BGP on interface\n"
3013 "Specify a BGP neighbor\n"
3015 "Internal BGP peer\n"
3016 "External BGP peer\n")
3019 int idx_remote_as
= 5;
3020 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3021 SAFI_UNICAST
, 1, NULL
,
3022 argv
[idx_remote_as
]->arg
);
3025 DEFUN (neighbor_peer_group
,
3026 neighbor_peer_group_cmd
,
3027 "neighbor WORD peer-group",
3029 "Interface name or neighbor tag\n"
3030 "Configure peer-group\n")
3032 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3035 struct peer_group
*group
;
3037 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3039 vty_out(vty
, "%% Name conflict with interface: \n");
3040 return CMD_WARNING_CONFIG_FAILED
;
3043 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
3045 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
3046 return CMD_WARNING_CONFIG_FAILED
;
3054 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3058 "Specify a BGP neighbor\n"
3060 "Internal BGP peer\n"
3061 "External BGP peer\n")
3063 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3067 struct peer_group
*group
;
3071 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3073 /* look up for neighbor by interface name config. */
3074 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3076 /* Request zebra to terminate IPv6 RAs on this
3079 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3084 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3086 peer_group_delete(group
);
3088 vty_out(vty
, "%% Create the peer-group first\n");
3089 return CMD_WARNING_CONFIG_FAILED
;
3092 peer
= peer_lookup(bgp
, &su
);
3094 if (peer_dynamic_neighbor(peer
)) {
3096 "%% Operation not allowed on a dynamic neighbor\n");
3097 return CMD_WARNING_CONFIG_FAILED
;
3100 other
= peer
->doppelganger
;
3102 if (other
&& other
->status
!= Deleted
)
3110 DEFUN (no_neighbor_interface_config
,
3111 no_neighbor_interface_config_cmd
,
3112 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
3116 "Configure BGP on interface\n"
3117 "Enable BGP with v6 link-local only\n"
3118 "Member of the peer-group\n"
3120 "Specify a BGP neighbor\n"
3122 "Internal BGP peer\n"
3123 "External BGP peer\n")
3125 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3129 /* look up for neighbor by interface name config. */
3130 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3132 /* Request zebra to terminate IPv6 RAs on this interface. */
3134 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3137 vty_out(vty
, "%% Create the bgp interface first\n");
3138 return CMD_WARNING_CONFIG_FAILED
;
3143 DEFUN (no_neighbor_peer_group
,
3144 no_neighbor_peer_group_cmd
,
3145 "no neighbor WORD peer-group",
3149 "Configure peer-group\n")
3151 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3153 struct peer_group
*group
;
3155 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3157 peer_group_delete(group
);
3159 vty_out(vty
, "%% Create the peer-group first\n");
3160 return CMD_WARNING_CONFIG_FAILED
;
3165 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3166 no_neighbor_interface_peer_group_remote_as_cmd
,
3167 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3170 "Interface name or neighbor tag\n"
3171 "Specify a BGP neighbor\n"
3173 "Internal BGP peer\n"
3174 "External BGP peer\n")
3176 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3178 struct peer_group
*group
;
3181 /* look up for neighbor by interface name config. */
3182 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3184 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
3188 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3190 peer_group_remote_as_delete(group
);
3192 vty_out(vty
, "%% Create the peer-group or interface first\n");
3193 return CMD_WARNING_CONFIG_FAILED
;
3198 DEFUN (neighbor_local_as
,
3199 neighbor_local_as_cmd
,
3200 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3203 "Specify a local-as number\n"
3204 "AS number used as local AS\n")
3212 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3214 return CMD_WARNING_CONFIG_FAILED
;
3216 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3217 ret
= peer_local_as_set(peer
, as
, 0, 0);
3218 return bgp_vty_return(vty
, ret
);
3221 DEFUN (neighbor_local_as_no_prepend
,
3222 neighbor_local_as_no_prepend_cmd
,
3223 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3226 "Specify a local-as number\n"
3227 "AS number used as local AS\n"
3228 "Do not prepend local-as to updates from ebgp peers\n")
3236 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3238 return CMD_WARNING_CONFIG_FAILED
;
3240 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3241 ret
= peer_local_as_set(peer
, as
, 1, 0);
3242 return bgp_vty_return(vty
, ret
);
3245 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3246 neighbor_local_as_no_prepend_replace_as_cmd
,
3247 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3250 "Specify a local-as number\n"
3251 "AS number used as local AS\n"
3252 "Do not prepend local-as to updates from ebgp peers\n"
3253 "Do not prepend local-as to updates from ibgp peers\n")
3261 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3263 return CMD_WARNING_CONFIG_FAILED
;
3265 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3266 ret
= peer_local_as_set(peer
, as
, 1, 1);
3267 return bgp_vty_return(vty
, ret
);
3270 DEFUN (no_neighbor_local_as
,
3271 no_neighbor_local_as_cmd
,
3272 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3276 "Specify a local-as number\n"
3277 "AS number used as local AS\n"
3278 "Do not prepend local-as to updates from ebgp peers\n"
3279 "Do not prepend local-as to updates from ibgp peers\n")
3285 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3287 return CMD_WARNING_CONFIG_FAILED
;
3289 ret
= peer_local_as_unset(peer
);
3290 return bgp_vty_return(vty
, ret
);
3294 DEFUN (neighbor_solo
,
3296 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3299 "Solo peer - part of its own update group\n")
3305 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3307 return CMD_WARNING_CONFIG_FAILED
;
3309 ret
= update_group_adjust_soloness(peer
, 1);
3310 return bgp_vty_return(vty
, ret
);
3313 DEFUN (no_neighbor_solo
,
3314 no_neighbor_solo_cmd
,
3315 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3319 "Solo peer - part of its own update group\n")
3325 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3327 return CMD_WARNING_CONFIG_FAILED
;
3329 ret
= update_group_adjust_soloness(peer
, 0);
3330 return bgp_vty_return(vty
, ret
);
3333 DEFUN (neighbor_password
,
3334 neighbor_password_cmd
,
3335 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3346 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3348 return CMD_WARNING_CONFIG_FAILED
;
3350 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3351 return bgp_vty_return(vty
, ret
);
3354 DEFUN (no_neighbor_password
,
3355 no_neighbor_password_cmd
,
3356 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3367 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3369 return CMD_WARNING_CONFIG_FAILED
;
3371 ret
= peer_password_unset(peer
);
3372 return bgp_vty_return(vty
, ret
);
3375 DEFUN (neighbor_activate
,
3376 neighbor_activate_cmd
,
3377 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3380 "Enable the Address Family for this Neighbor\n")
3386 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3388 return CMD_WARNING_CONFIG_FAILED
;
3390 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3391 return bgp_vty_return(vty
, ret
);
3394 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3395 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3396 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3397 "Enable the Address Family for this Neighbor\n")
3399 DEFUN (no_neighbor_activate
,
3400 no_neighbor_activate_cmd
,
3401 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3405 "Enable the Address Family for this Neighbor\n")
3412 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3414 return CMD_WARNING_CONFIG_FAILED
;
3416 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3417 return bgp_vty_return(vty
, ret
);
3420 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3421 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3422 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3423 "Enable the Address Family for this Neighbor\n")
3425 DEFUN (neighbor_set_peer_group
,
3426 neighbor_set_peer_group_cmd
,
3427 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3430 "Member of the peer-group\n"
3431 "Peer-group name\n")
3433 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3440 struct peer_group
*group
;
3442 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3444 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3446 vty_out(vty
, "%% Malformed address or name: %s\n",
3447 argv
[idx_peer
]->arg
);
3448 return CMD_WARNING_CONFIG_FAILED
;
3451 if (peer_address_self_check(bgp
, &su
)) {
3453 "%% Can not configure the local system as neighbor\n");
3454 return CMD_WARNING_CONFIG_FAILED
;
3457 /* Disallow for dynamic neighbor. */
3458 peer
= peer_lookup(bgp
, &su
);
3459 if (peer
&& peer_dynamic_neighbor(peer
)) {
3461 "%% Operation not allowed on a dynamic neighbor\n");
3462 return CMD_WARNING_CONFIG_FAILED
;
3466 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3468 vty_out(vty
, "%% Configure the peer-group first\n");
3469 return CMD_WARNING_CONFIG_FAILED
;
3472 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3474 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3476 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3478 return CMD_WARNING_CONFIG_FAILED
;
3481 return bgp_vty_return(vty
, ret
);
3484 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3485 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3486 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3487 "Member of the peer-group\n"
3488 "Peer-group name\n")
3490 DEFUN (no_neighbor_set_peer_group
,
3491 no_neighbor_set_peer_group_cmd
,
3492 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3496 "Member of the peer-group\n"
3497 "Peer-group name\n")
3499 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3504 struct peer_group
*group
;
3506 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3508 return CMD_WARNING_CONFIG_FAILED
;
3510 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3512 vty_out(vty
, "%% Configure the peer-group first\n");
3513 return CMD_WARNING_CONFIG_FAILED
;
3516 ret
= peer_delete(peer
);
3518 return bgp_vty_return(vty
, ret
);
3521 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3522 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3523 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3524 "Member of the peer-group\n"
3525 "Peer-group name\n")
3527 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3528 uint32_t flag
, int set
)
3533 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3535 return CMD_WARNING_CONFIG_FAILED
;
3538 * If 'neighbor <interface>', then this is for directly connected peers,
3539 * we should not accept disable-connected-check.
3541 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3543 "%s is directly connected peer, cannot accept disable-"
3544 "connected-check\n",
3546 return CMD_WARNING_CONFIG_FAILED
;
3549 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3550 peer_tx_shutdown_message_unset(peer
);
3553 ret
= peer_flag_set(peer
, flag
);
3555 ret
= peer_flag_unset(peer
, flag
);
3557 return bgp_vty_return(vty
, ret
);
3560 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3562 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3565 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3568 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3571 /* neighbor passive. */
3572 DEFUN (neighbor_passive
,
3573 neighbor_passive_cmd
,
3574 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3577 "Don't send open messages to this neighbor\n")
3580 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3583 DEFUN (no_neighbor_passive
,
3584 no_neighbor_passive_cmd
,
3585 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3589 "Don't send open messages to this neighbor\n")
3592 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3595 /* neighbor shutdown. */
3596 DEFUN (neighbor_shutdown_msg
,
3597 neighbor_shutdown_msg_cmd
,
3598 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3601 "Administratively shut down this neighbor\n"
3602 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3603 "Shutdown message\n")
3609 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3613 return CMD_WARNING_CONFIG_FAILED
;
3614 message
= argv_concat(argv
, argc
, 4);
3615 peer_tx_shutdown_message_set(peer
, message
);
3616 XFREE(MTYPE_TMP
, message
);
3619 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3622 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3623 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3624 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3625 "Administratively shut down this neighbor\n")
3627 DEFUN (no_neighbor_shutdown_msg
,
3628 no_neighbor_shutdown_msg_cmd
,
3629 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3633 "Administratively shut down this neighbor\n"
3634 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3635 "Shutdown message\n")
3639 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3640 PEER_FLAG_SHUTDOWN
);
3643 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3644 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3645 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3646 "Administratively shut down this neighbor\n")
3648 /* neighbor capability dynamic. */
3649 DEFUN (neighbor_capability_dynamic
,
3650 neighbor_capability_dynamic_cmd
,
3651 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3654 "Advertise capability to the peer\n"
3655 "Advertise dynamic capability to this neighbor\n")
3658 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3659 PEER_FLAG_DYNAMIC_CAPABILITY
);
3662 DEFUN (no_neighbor_capability_dynamic
,
3663 no_neighbor_capability_dynamic_cmd
,
3664 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3668 "Advertise capability to the peer\n"
3669 "Advertise dynamic capability to this neighbor\n")
3672 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3673 PEER_FLAG_DYNAMIC_CAPABILITY
);
3676 /* neighbor dont-capability-negotiate */
3677 DEFUN (neighbor_dont_capability_negotiate
,
3678 neighbor_dont_capability_negotiate_cmd
,
3679 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3682 "Do not perform capability negotiation\n")
3685 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3686 PEER_FLAG_DONT_CAPABILITY
);
3689 DEFUN (no_neighbor_dont_capability_negotiate
,
3690 no_neighbor_dont_capability_negotiate_cmd
,
3691 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3695 "Do not perform capability negotiation\n")
3698 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3699 PEER_FLAG_DONT_CAPABILITY
);
3702 /* neighbor capability extended next hop encoding */
3703 DEFUN (neighbor_capability_enhe
,
3704 neighbor_capability_enhe_cmd
,
3705 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3708 "Advertise capability to the peer\n"
3709 "Advertise extended next-hop capability to the peer\n")
3712 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3713 PEER_FLAG_CAPABILITY_ENHE
);
3716 DEFUN (no_neighbor_capability_enhe
,
3717 no_neighbor_capability_enhe_cmd
,
3718 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3722 "Advertise capability to the peer\n"
3723 "Advertise extended next-hop capability to the peer\n")
3726 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3727 PEER_FLAG_CAPABILITY_ENHE
);
3730 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3731 afi_t afi
, safi_t safi
, uint32_t flag
,
3737 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3739 return CMD_WARNING_CONFIG_FAILED
;
3742 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3744 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3746 return bgp_vty_return(vty
, ret
);
3749 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3750 afi_t afi
, safi_t safi
, uint32_t flag
)
3752 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3755 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3756 afi_t afi
, safi_t safi
, uint32_t flag
)
3758 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3761 /* neighbor capability orf prefix-list. */
3762 DEFUN (neighbor_capability_orf_prefix
,
3763 neighbor_capability_orf_prefix_cmd
,
3764 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3767 "Advertise capability to the peer\n"
3768 "Advertise ORF capability to the peer\n"
3769 "Advertise prefixlist ORF capability to this neighbor\n"
3770 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3771 "Capability to RECEIVE the ORF from this neighbor\n"
3772 "Capability to SEND the ORF to this neighbor\n")
3775 int idx_send_recv
= 5;
3778 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3779 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3780 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3781 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3782 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3783 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3785 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3786 return CMD_WARNING_CONFIG_FAILED
;
3789 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3790 bgp_node_safi(vty
), flag
);
3794 neighbor_capability_orf_prefix
,
3795 neighbor_capability_orf_prefix_hidden_cmd
,
3796 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3797 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3798 "Advertise capability to the peer\n"
3799 "Advertise ORF capability to the peer\n"
3800 "Advertise prefixlist ORF capability to this neighbor\n"
3801 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3802 "Capability to RECEIVE the ORF from this neighbor\n"
3803 "Capability to SEND the ORF to this neighbor\n")
3805 DEFUN (no_neighbor_capability_orf_prefix
,
3806 no_neighbor_capability_orf_prefix_cmd
,
3807 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3811 "Advertise capability to the peer\n"
3812 "Advertise ORF capability to the peer\n"
3813 "Advertise prefixlist ORF capability to this neighbor\n"
3814 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3815 "Capability to RECEIVE the ORF from this neighbor\n"
3816 "Capability to SEND the ORF to this neighbor\n")
3819 int idx_send_recv
= 6;
3822 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3823 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3824 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3825 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3826 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3827 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3829 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3830 return CMD_WARNING_CONFIG_FAILED
;
3833 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3834 bgp_node_afi(vty
), bgp_node_safi(vty
),
3839 no_neighbor_capability_orf_prefix
,
3840 no_neighbor_capability_orf_prefix_hidden_cmd
,
3841 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3842 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3843 "Advertise capability to the peer\n"
3844 "Advertise ORF capability to the peer\n"
3845 "Advertise prefixlist ORF capability to this neighbor\n"
3846 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3847 "Capability to RECEIVE the ORF from this neighbor\n"
3848 "Capability to SEND the ORF to this neighbor\n")
3850 /* neighbor next-hop-self. */
3851 DEFUN (neighbor_nexthop_self
,
3852 neighbor_nexthop_self_cmd
,
3853 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3856 "Disable the next hop calculation for this neighbor\n")
3859 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3860 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3863 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3864 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3865 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3866 "Disable the next hop calculation for this neighbor\n")
3868 /* neighbor next-hop-self. */
3869 DEFUN (neighbor_nexthop_self_force
,
3870 neighbor_nexthop_self_force_cmd
,
3871 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3874 "Disable the next hop calculation for this neighbor\n"
3875 "Set the next hop to self for reflected routes\n")
3878 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3880 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3883 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3884 neighbor_nexthop_self_force_hidden_cmd
,
3885 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3886 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3887 "Disable the next hop calculation for this neighbor\n"
3888 "Set the next hop to self for reflected routes\n")
3890 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3891 neighbor_nexthop_self_all_hidden_cmd
,
3892 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
3893 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3894 "Disable the next hop calculation for this neighbor\n"
3895 "Set the next hop to self for reflected routes\n")
3897 DEFUN (no_neighbor_nexthop_self
,
3898 no_neighbor_nexthop_self_cmd
,
3899 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3903 "Disable the next hop calculation for this neighbor\n")
3906 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3907 bgp_node_afi(vty
), bgp_node_safi(vty
),
3908 PEER_FLAG_NEXTHOP_SELF
);
3911 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3912 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3913 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3914 "Disable the next hop calculation for this neighbor\n")
3916 DEFUN (no_neighbor_nexthop_self_force
,
3917 no_neighbor_nexthop_self_force_cmd
,
3918 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3922 "Disable the next hop calculation for this neighbor\n"
3923 "Set the next hop to self for reflected routes\n")
3926 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3927 bgp_node_afi(vty
), bgp_node_safi(vty
),
3928 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3931 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3932 no_neighbor_nexthop_self_force_hidden_cmd
,
3933 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3934 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3935 "Disable the next hop calculation for this neighbor\n"
3936 "Set the next hop to self for reflected routes\n")
3938 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3939 no_neighbor_nexthop_self_all_hidden_cmd
,
3940 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
3941 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3942 "Disable the next hop calculation for this neighbor\n"
3943 "Set the next hop to self for reflected routes\n")
3945 /* neighbor as-override */
3946 DEFUN (neighbor_as_override
,
3947 neighbor_as_override_cmd
,
3948 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3951 "Override ASNs in outbound updates if aspath equals remote-as\n")
3954 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3955 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
3958 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
3959 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3960 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3961 "Override ASNs in outbound updates if aspath equals remote-as\n")
3963 DEFUN (no_neighbor_as_override
,
3964 no_neighbor_as_override_cmd
,
3965 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3969 "Override ASNs in outbound updates if aspath equals remote-as\n")
3972 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3973 bgp_node_afi(vty
), bgp_node_safi(vty
),
3974 PEER_FLAG_AS_OVERRIDE
);
3977 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
3978 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3979 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3980 "Override ASNs in outbound updates if aspath equals remote-as\n")
3982 /* neighbor remove-private-AS. */
3983 DEFUN (neighbor_remove_private_as
,
3984 neighbor_remove_private_as_cmd
,
3985 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3988 "Remove private ASNs in outbound updates\n")
3991 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3993 PEER_FLAG_REMOVE_PRIVATE_AS
);
3996 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
3997 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3998 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3999 "Remove private ASNs in outbound updates\n")
4001 DEFUN (neighbor_remove_private_as_all
,
4002 neighbor_remove_private_as_all_cmd
,
4003 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4006 "Remove private ASNs in outbound updates\n"
4007 "Apply to all AS numbers\n")
4010 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4012 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4015 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
4016 neighbor_remove_private_as_all_hidden_cmd
,
4017 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4018 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4019 "Remove private ASNs in outbound updates\n"
4020 "Apply to all AS numbers")
4022 DEFUN (neighbor_remove_private_as_replace_as
,
4023 neighbor_remove_private_as_replace_as_cmd
,
4024 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4027 "Remove private ASNs in outbound updates\n"
4028 "Replace private ASNs with our ASN in outbound updates\n")
4031 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4033 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4036 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
4037 neighbor_remove_private_as_replace_as_hidden_cmd
,
4038 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4039 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4040 "Remove private ASNs in outbound updates\n"
4041 "Replace private ASNs with our ASN in outbound updates\n")
4043 DEFUN (neighbor_remove_private_as_all_replace_as
,
4044 neighbor_remove_private_as_all_replace_as_cmd
,
4045 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4048 "Remove private ASNs in outbound updates\n"
4049 "Apply to all AS numbers\n"
4050 "Replace private ASNs with our ASN in outbound updates\n")
4053 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4055 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4059 neighbor_remove_private_as_all_replace_as
,
4060 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4061 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4062 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4063 "Remove private ASNs in outbound updates\n"
4064 "Apply to all AS numbers\n"
4065 "Replace private ASNs with our ASN in outbound updates\n")
4067 DEFUN (no_neighbor_remove_private_as
,
4068 no_neighbor_remove_private_as_cmd
,
4069 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4073 "Remove private ASNs in outbound updates\n")
4076 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4077 bgp_node_afi(vty
), bgp_node_safi(vty
),
4078 PEER_FLAG_REMOVE_PRIVATE_AS
);
4081 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4082 no_neighbor_remove_private_as_hidden_cmd
,
4083 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4084 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4085 "Remove private ASNs in outbound updates\n")
4087 DEFUN (no_neighbor_remove_private_as_all
,
4088 no_neighbor_remove_private_as_all_cmd
,
4089 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4093 "Remove private ASNs in outbound updates\n"
4094 "Apply to all AS numbers\n")
4097 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4098 bgp_node_afi(vty
), bgp_node_safi(vty
),
4099 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4102 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4103 no_neighbor_remove_private_as_all_hidden_cmd
,
4104 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4105 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4106 "Remove private ASNs in outbound updates\n"
4107 "Apply to all AS numbers\n")
4109 DEFUN (no_neighbor_remove_private_as_replace_as
,
4110 no_neighbor_remove_private_as_replace_as_cmd
,
4111 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4115 "Remove private ASNs in outbound updates\n"
4116 "Replace private ASNs with our ASN in outbound updates\n")
4119 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4120 bgp_node_afi(vty
), bgp_node_safi(vty
),
4121 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4124 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4125 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4126 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4127 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4128 "Remove private ASNs in outbound updates\n"
4129 "Replace private ASNs with our ASN in outbound updates\n")
4131 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4132 no_neighbor_remove_private_as_all_replace_as_cmd
,
4133 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4137 "Remove private ASNs in outbound updates\n"
4138 "Apply to all AS numbers\n"
4139 "Replace private ASNs with our ASN in outbound updates\n")
4142 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4143 bgp_node_afi(vty
), bgp_node_safi(vty
),
4144 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4148 no_neighbor_remove_private_as_all_replace_as
,
4149 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4150 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4151 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4152 "Remove private ASNs in outbound updates\n"
4153 "Apply to all AS numbers\n"
4154 "Replace private ASNs with our ASN in outbound updates\n")
4157 /* neighbor send-community. */
4158 DEFUN (neighbor_send_community
,
4159 neighbor_send_community_cmd
,
4160 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4163 "Send Community attribute to this neighbor\n")
4167 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4169 PEER_FLAG_SEND_COMMUNITY
);
4172 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4173 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4174 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4175 "Send Community attribute to this neighbor\n")
4177 DEFUN (no_neighbor_send_community
,
4178 no_neighbor_send_community_cmd
,
4179 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4183 "Send Community attribute to this neighbor\n")
4187 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4188 bgp_node_afi(vty
), bgp_node_safi(vty
),
4189 PEER_FLAG_SEND_COMMUNITY
);
4192 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4193 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4194 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4195 "Send Community attribute to this neighbor\n")
4197 /* neighbor send-community extended. */
4198 DEFUN (neighbor_send_community_type
,
4199 neighbor_send_community_type_cmd
,
4200 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4203 "Send Community attribute to this neighbor\n"
4204 "Send Standard and Extended Community attributes\n"
4205 "Send Standard, Large and Extended Community attributes\n"
4206 "Send Extended Community attributes\n"
4207 "Send Standard Community attributes\n"
4208 "Send Large Community attributes\n")
4212 const char *type
= argv
[argc
- 1]->text
;
4214 if (strmatch(type
, "standard")) {
4215 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4216 } else if (strmatch(type
, "extended")) {
4217 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4218 } else if (strmatch(type
, "large")) {
4219 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4220 } else if (strmatch(type
, "both")) {
4221 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4222 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4223 } else { /* if (strmatch(type, "all")) */
4224 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4225 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4226 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4229 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4230 bgp_node_safi(vty
), flag
);
4234 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4235 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4236 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4237 "Send Community attribute to this neighbor\n"
4238 "Send Standard and Extended Community attributes\n"
4239 "Send Standard, Large and Extended Community attributes\n"
4240 "Send Extended Community attributes\n"
4241 "Send Standard Community attributes\n"
4242 "Send Large Community attributes\n")
4244 DEFUN (no_neighbor_send_community_type
,
4245 no_neighbor_send_community_type_cmd
,
4246 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4250 "Send Community attribute to this neighbor\n"
4251 "Send Standard and Extended Community attributes\n"
4252 "Send Standard, Large and Extended Community attributes\n"
4253 "Send Extended Community attributes\n"
4254 "Send Standard Community attributes\n"
4255 "Send Large Community attributes\n")
4259 const char *type
= argv
[argc
- 1]->text
;
4261 if (strmatch(type
, "standard")) {
4262 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4263 } else if (strmatch(type
, "extended")) {
4264 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4265 } else if (strmatch(type
, "large")) {
4266 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4267 } else if (strmatch(type
, "both")) {
4268 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4269 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4270 } else { /* if (strmatch(type, "all")) */
4271 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4272 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4273 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4276 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4277 bgp_node_afi(vty
), bgp_node_safi(vty
),
4282 no_neighbor_send_community_type
,
4283 no_neighbor_send_community_type_hidden_cmd
,
4284 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4285 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4286 "Send Community attribute to this neighbor\n"
4287 "Send Standard and Extended Community attributes\n"
4288 "Send Standard, Large and Extended Community attributes\n"
4289 "Send Extended Community attributes\n"
4290 "Send Standard Community attributes\n"
4291 "Send Large Community attributes\n")
4293 /* neighbor soft-reconfig. */
4294 DEFUN (neighbor_soft_reconfiguration
,
4295 neighbor_soft_reconfiguration_cmd
,
4296 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4299 "Per neighbor soft reconfiguration\n"
4300 "Allow inbound soft reconfiguration for this neighbor\n")
4303 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4305 PEER_FLAG_SOFT_RECONFIG
);
4308 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4309 neighbor_soft_reconfiguration_hidden_cmd
,
4310 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4311 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4312 "Per neighbor soft reconfiguration\n"
4313 "Allow inbound soft reconfiguration for this neighbor\n")
4315 DEFUN (no_neighbor_soft_reconfiguration
,
4316 no_neighbor_soft_reconfiguration_cmd
,
4317 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4321 "Per neighbor soft reconfiguration\n"
4322 "Allow inbound soft reconfiguration for this neighbor\n")
4325 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4326 bgp_node_afi(vty
), bgp_node_safi(vty
),
4327 PEER_FLAG_SOFT_RECONFIG
);
4330 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4331 no_neighbor_soft_reconfiguration_hidden_cmd
,
4332 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4333 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4334 "Per neighbor soft reconfiguration\n"
4335 "Allow inbound soft reconfiguration for this neighbor\n")
4337 DEFUN (neighbor_route_reflector_client
,
4338 neighbor_route_reflector_client_cmd
,
4339 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4342 "Configure a neighbor as Route Reflector client\n")
4348 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4350 return CMD_WARNING_CONFIG_FAILED
;
4352 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4354 PEER_FLAG_REFLECTOR_CLIENT
);
4357 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4358 neighbor_route_reflector_client_hidden_cmd
,
4359 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4360 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4361 "Configure a neighbor as Route Reflector client\n")
4363 DEFUN (no_neighbor_route_reflector_client
,
4364 no_neighbor_route_reflector_client_cmd
,
4365 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4369 "Configure a neighbor as Route Reflector client\n")
4372 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4373 bgp_node_afi(vty
), bgp_node_safi(vty
),
4374 PEER_FLAG_REFLECTOR_CLIENT
);
4377 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4378 no_neighbor_route_reflector_client_hidden_cmd
,
4379 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4380 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4381 "Configure a neighbor as Route Reflector client\n")
4383 /* neighbor route-server-client. */
4384 DEFUN (neighbor_route_server_client
,
4385 neighbor_route_server_client_cmd
,
4386 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4389 "Configure a neighbor as Route Server client\n")
4394 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4396 return CMD_WARNING_CONFIG_FAILED
;
4397 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4399 PEER_FLAG_RSERVER_CLIENT
);
4402 ALIAS_HIDDEN(neighbor_route_server_client
,
4403 neighbor_route_server_client_hidden_cmd
,
4404 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4405 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4406 "Configure a neighbor as Route Server client\n")
4408 DEFUN (no_neighbor_route_server_client
,
4409 no_neighbor_route_server_client_cmd
,
4410 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4414 "Configure a neighbor as Route Server client\n")
4417 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4418 bgp_node_afi(vty
), bgp_node_safi(vty
),
4419 PEER_FLAG_RSERVER_CLIENT
);
4422 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4423 no_neighbor_route_server_client_hidden_cmd
,
4424 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4425 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4426 "Configure a neighbor as Route Server client\n")
4428 DEFUN (neighbor_nexthop_local_unchanged
,
4429 neighbor_nexthop_local_unchanged_cmd
,
4430 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4433 "Configure treatment of outgoing link-local nexthop attribute\n"
4434 "Leave link-local nexthop unchanged for this peer\n")
4437 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4439 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4442 DEFUN (no_neighbor_nexthop_local_unchanged
,
4443 no_neighbor_nexthop_local_unchanged_cmd
,
4444 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4448 "Configure treatment of outgoing link-local-nexthop attribute\n"
4449 "Leave link-local nexthop unchanged for this peer\n")
4452 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4453 bgp_node_afi(vty
), bgp_node_safi(vty
),
4454 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4457 DEFUN (neighbor_attr_unchanged
,
4458 neighbor_attr_unchanged_cmd
,
4459 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4462 "BGP attribute is propagated unchanged to this neighbor\n"
4463 "As-path attribute\n"
4464 "Nexthop attribute\n"
4468 char *peer_str
= argv
[1]->arg
;
4471 afi_t afi
= bgp_node_afi(vty
);
4472 safi_t safi
= bgp_node_safi(vty
);
4474 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4476 return CMD_WARNING_CONFIG_FAILED
;
4478 if (argv_find(argv
, argc
, "as-path", &idx
))
4479 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4481 if (argv_find(argv
, argc
, "next-hop", &idx
))
4482 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4484 if (argv_find(argv
, argc
, "med", &idx
))
4485 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4487 /* no flags means all of them! */
4489 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4490 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4491 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4493 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4494 && peer_af_flag_check(peer
, afi
, safi
,
4495 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4496 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4497 PEER_FLAG_AS_PATH_UNCHANGED
);
4500 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4501 && peer_af_flag_check(peer
, afi
, safi
,
4502 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4503 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4504 PEER_FLAG_NEXTHOP_UNCHANGED
);
4507 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4508 && peer_af_flag_check(peer
, afi
, safi
,
4509 PEER_FLAG_MED_UNCHANGED
)) {
4510 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4511 PEER_FLAG_MED_UNCHANGED
);
4515 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4519 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4520 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4521 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4522 "BGP attribute is propagated unchanged to this neighbor\n"
4523 "As-path attribute\n"
4524 "Nexthop attribute\n"
4527 DEFUN (no_neighbor_attr_unchanged
,
4528 no_neighbor_attr_unchanged_cmd
,
4529 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4533 "BGP attribute is propagated unchanged to this neighbor\n"
4534 "As-path attribute\n"
4535 "Nexthop attribute\n"
4539 char *peer
= argv
[2]->arg
;
4542 if (argv_find(argv
, argc
, "as-path", &idx
))
4543 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4545 if (argv_find(argv
, argc
, "next-hop", &idx
))
4546 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4548 if (argv_find(argv
, argc
, "med", &idx
))
4549 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4551 if (!flags
) // no flags means all of them!
4553 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4554 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4555 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4558 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4559 bgp_node_safi(vty
), flags
);
4563 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4564 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4565 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4566 "BGP attribute is propagated unchanged to this neighbor\n"
4567 "As-path attribute\n"
4568 "Nexthop attribute\n"
4571 /* EBGP multihop configuration. */
4572 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4573 const char *ttl_str
)
4578 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4580 return CMD_WARNING_CONFIG_FAILED
;
4583 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4588 ttl
= strtoul(ttl_str
, NULL
, 10);
4590 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4593 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4597 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4599 return CMD_WARNING_CONFIG_FAILED
;
4601 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4604 /* neighbor ebgp-multihop. */
4605 DEFUN (neighbor_ebgp_multihop
,
4606 neighbor_ebgp_multihop_cmd
,
4607 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4610 "Allow EBGP neighbors not on directly connected networks\n")
4613 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4616 DEFUN (neighbor_ebgp_multihop_ttl
,
4617 neighbor_ebgp_multihop_ttl_cmd
,
4618 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4621 "Allow EBGP neighbors not on directly connected networks\n"
4622 "maximum hop count\n")
4626 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4627 argv
[idx_number
]->arg
);
4630 DEFUN (no_neighbor_ebgp_multihop
,
4631 no_neighbor_ebgp_multihop_cmd
,
4632 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4636 "Allow EBGP neighbors not on directly connected networks\n"
4637 "maximum hop count\n")
4640 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4644 /* disable-connected-check */
4645 DEFUN (neighbor_disable_connected_check
,
4646 neighbor_disable_connected_check_cmd
,
4647 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4650 "one-hop away EBGP peer using loopback address\n"
4651 "Enforce EBGP neighbors perform multihop\n")
4654 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4655 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4658 DEFUN (no_neighbor_disable_connected_check
,
4659 no_neighbor_disable_connected_check_cmd
,
4660 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4664 "one-hop away EBGP peer using loopback address\n"
4665 "Enforce EBGP neighbors perform multihop\n")
4668 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4669 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4673 /* enforce-first-as */
4674 DEFUN (neighbor_enforce_first_as
,
4675 neighbor_enforce_first_as_cmd
,
4676 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4679 "Enforce the first AS for EBGP routes\n")
4683 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4684 PEER_FLAG_ENFORCE_FIRST_AS
);
4687 DEFUN (no_neighbor_enforce_first_as
,
4688 no_neighbor_enforce_first_as_cmd
,
4689 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4693 "Enforce the first AS for EBGP routes\n")
4697 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4698 PEER_FLAG_ENFORCE_FIRST_AS
);
4702 DEFUN (neighbor_description
,
4703 neighbor_description_cmd
,
4704 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4707 "Neighbor specific description\n"
4708 "Up to 80 characters describing this neighbor\n")
4715 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4717 return CMD_WARNING_CONFIG_FAILED
;
4719 str
= argv_concat(argv
, argc
, idx_line
);
4721 peer_description_set(peer
, str
);
4723 XFREE(MTYPE_TMP
, str
);
4728 DEFUN (no_neighbor_description
,
4729 no_neighbor_description_cmd
,
4730 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4734 "Neighbor specific description\n")
4739 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4741 return CMD_WARNING_CONFIG_FAILED
;
4743 peer_description_unset(peer
);
4748 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4749 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4750 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4751 "Neighbor specific description\n"
4752 "Up to 80 characters describing this neighbor\n")
4754 /* Neighbor update-source. */
4755 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4756 const char *source_str
)
4762 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4764 return CMD_WARNING_CONFIG_FAILED
;
4770 if (str2sockunion(source_str
, &su
) == 0)
4771 peer_update_source_addr_set(peer
, &su
);
4773 if (str2prefix(source_str
, &p
)) {
4775 "%% Invalid update-source, remove prefix length \n");
4776 return CMD_WARNING_CONFIG_FAILED
;
4778 peer_update_source_if_set(peer
, source_str
);
4781 peer_update_source_unset(peer
);
4786 #define BGP_UPDATE_SOURCE_HELP_STR \
4789 "Interface name (requires zebra to be running)\n"
4791 DEFUN (neighbor_update_source
,
4792 neighbor_update_source_cmd
,
4793 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4796 "Source of routing updates\n"
4797 BGP_UPDATE_SOURCE_HELP_STR
)
4801 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4802 argv
[idx_peer_2
]->arg
);
4805 DEFUN (no_neighbor_update_source
,
4806 no_neighbor_update_source_cmd
,
4807 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4811 "Source of routing updates\n"
4812 BGP_UPDATE_SOURCE_HELP_STR
)
4815 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4818 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4819 afi_t afi
, safi_t safi
,
4820 const char *rmap
, int set
)
4824 struct route_map
*route_map
;
4826 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4828 return CMD_WARNING_CONFIG_FAILED
;
4831 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
4832 ret
= peer_default_originate_set(peer
, afi
, safi
,
4835 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4837 return bgp_vty_return(vty
, ret
);
4840 /* neighbor default-originate. */
4841 DEFUN (neighbor_default_originate
,
4842 neighbor_default_originate_cmd
,
4843 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4846 "Originate default route to this neighbor\n")
4849 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4851 bgp_node_safi(vty
), NULL
, 1);
4854 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4855 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4856 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4857 "Originate default route to this neighbor\n")
4859 DEFUN (neighbor_default_originate_rmap
,
4860 neighbor_default_originate_rmap_cmd
,
4861 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4864 "Originate default route to this neighbor\n"
4865 "Route-map to specify criteria to originate default\n"
4870 return peer_default_originate_set_vty(
4871 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4872 argv
[idx_word
]->arg
, 1);
4876 neighbor_default_originate_rmap
,
4877 neighbor_default_originate_rmap_hidden_cmd
,
4878 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4879 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4880 "Originate default route to this neighbor\n"
4881 "Route-map to specify criteria to originate default\n"
4884 DEFUN (no_neighbor_default_originate
,
4885 no_neighbor_default_originate_cmd
,
4886 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4890 "Originate default route to this neighbor\n"
4891 "Route-map to specify criteria to originate default\n"
4895 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4897 bgp_node_safi(vty
), NULL
, 0);
4901 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4902 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4903 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4904 "Originate default route to this neighbor\n"
4905 "Route-map to specify criteria to originate default\n"
4909 /* Set neighbor's BGP port. */
4910 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4911 const char *port_str
)
4917 peer
= peer_lookup_vty(vty
, ip_str
);
4919 return CMD_WARNING_CONFIG_FAILED
;
4922 sp
= getservbyname("bgp", "tcp");
4923 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
4925 port
= strtoul(port_str
, NULL
, 10);
4928 peer_port_set(peer
, port
);
4933 /* Set specified peer's BGP port. */
4934 DEFUN (neighbor_port
,
4936 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
4939 "Neighbor's BGP port\n"
4940 "TCP port number\n")
4944 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
4945 argv
[idx_number
]->arg
);
4948 DEFUN (no_neighbor_port
,
4949 no_neighbor_port_cmd
,
4950 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
4954 "Neighbor's BGP port\n"
4955 "TCP port number\n")
4958 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
4962 /* neighbor weight. */
4963 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4964 safi_t safi
, const char *weight_str
)
4968 unsigned long weight
;
4970 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4972 return CMD_WARNING_CONFIG_FAILED
;
4974 weight
= strtoul(weight_str
, NULL
, 10);
4976 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
4977 return bgp_vty_return(vty
, ret
);
4980 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4986 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4988 return CMD_WARNING_CONFIG_FAILED
;
4990 ret
= peer_weight_unset(peer
, afi
, safi
);
4991 return bgp_vty_return(vty
, ret
);
4994 DEFUN (neighbor_weight
,
4995 neighbor_weight_cmd
,
4996 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4999 "Set default weight for routes from this neighbor\n"
5004 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5005 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
5008 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
5009 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5010 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5011 "Set default weight for routes from this neighbor\n"
5014 DEFUN (no_neighbor_weight
,
5015 no_neighbor_weight_cmd
,
5016 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5020 "Set default weight for routes from this neighbor\n"
5024 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
5025 bgp_node_afi(vty
), bgp_node_safi(vty
));
5028 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
5029 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5030 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5031 "Set default weight for routes from this neighbor\n"
5035 /* Override capability negotiation. */
5036 DEFUN (neighbor_override_capability
,
5037 neighbor_override_capability_cmd
,
5038 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5041 "Override capability negotiation result\n")
5044 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5045 PEER_FLAG_OVERRIDE_CAPABILITY
);
5048 DEFUN (no_neighbor_override_capability
,
5049 no_neighbor_override_capability_cmd
,
5050 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5054 "Override capability negotiation result\n")
5057 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5058 PEER_FLAG_OVERRIDE_CAPABILITY
);
5061 DEFUN (neighbor_strict_capability
,
5062 neighbor_strict_capability_cmd
,
5063 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5066 "Strict capability negotiation match\n")
5070 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5071 PEER_FLAG_STRICT_CAP_MATCH
);
5074 DEFUN (no_neighbor_strict_capability
,
5075 no_neighbor_strict_capability_cmd
,
5076 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5080 "Strict capability negotiation match\n")
5084 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5085 PEER_FLAG_STRICT_CAP_MATCH
);
5088 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5089 const char *keep_str
, const char *hold_str
)
5096 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5098 return CMD_WARNING_CONFIG_FAILED
;
5100 keepalive
= strtoul(keep_str
, NULL
, 10);
5101 holdtime
= strtoul(hold_str
, NULL
, 10);
5103 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5105 return bgp_vty_return(vty
, ret
);
5108 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5113 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5115 return CMD_WARNING_CONFIG_FAILED
;
5117 ret
= peer_timers_unset(peer
);
5119 return bgp_vty_return(vty
, ret
);
5122 DEFUN (neighbor_timers
,
5123 neighbor_timers_cmd
,
5124 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5127 "BGP per neighbor timers\n"
5128 "Keepalive interval\n"
5133 int idx_number_2
= 4;
5134 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5135 argv
[idx_number
]->arg
,
5136 argv
[idx_number_2
]->arg
);
5139 DEFUN (no_neighbor_timers
,
5140 no_neighbor_timers_cmd
,
5141 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5145 "BGP per neighbor timers\n"
5146 "Keepalive interval\n"
5150 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5154 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5155 const char *time_str
)
5161 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5163 return CMD_WARNING_CONFIG_FAILED
;
5165 connect
= strtoul(time_str
, NULL
, 10);
5167 ret
= peer_timers_connect_set(peer
, connect
);
5169 return bgp_vty_return(vty
, ret
);
5172 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5177 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5179 return CMD_WARNING_CONFIG_FAILED
;
5181 ret
= peer_timers_connect_unset(peer
);
5183 return bgp_vty_return(vty
, ret
);
5186 DEFUN (neighbor_timers_connect
,
5187 neighbor_timers_connect_cmd
,
5188 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5191 "BGP per neighbor timers\n"
5192 "BGP connect timer\n"
5197 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5198 argv
[idx_number
]->arg
);
5201 DEFUN (no_neighbor_timers_connect
,
5202 no_neighbor_timers_connect_cmd
,
5203 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5207 "BGP per neighbor timers\n"
5208 "BGP connect timer\n"
5212 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5216 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5217 const char *time_str
, int set
)
5221 uint32_t routeadv
= 0;
5223 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5225 return CMD_WARNING_CONFIG_FAILED
;
5228 routeadv
= strtoul(time_str
, NULL
, 10);
5231 ret
= peer_advertise_interval_set(peer
, routeadv
);
5233 ret
= peer_advertise_interval_unset(peer
);
5235 return bgp_vty_return(vty
, ret
);
5238 DEFUN (neighbor_advertise_interval
,
5239 neighbor_advertise_interval_cmd
,
5240 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5243 "Minimum interval between sending BGP routing updates\n"
5244 "time in seconds\n")
5248 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5249 argv
[idx_number
]->arg
, 1);
5252 DEFUN (no_neighbor_advertise_interval
,
5253 no_neighbor_advertise_interval_cmd
,
5254 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5258 "Minimum interval between sending BGP routing updates\n"
5259 "time in seconds\n")
5262 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5266 /* Time to wait before processing route-map updates */
5267 DEFUN (bgp_set_route_map_delay_timer
,
5268 bgp_set_route_map_delay_timer_cmd
,
5269 "bgp route-map delay-timer (0-600)",
5271 "BGP route-map delay timer\n"
5272 "Time in secs to wait before processing route-map changes\n"
5273 "0 disables the timer, no route updates happen when route-maps change\n")
5276 uint32_t rmap_delay_timer
;
5278 if (argv
[idx_number
]->arg
) {
5279 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5280 bm
->rmap_update_timer
= rmap_delay_timer
;
5282 /* if the dynamic update handling is being disabled, and a timer
5284 * running, stop the timer and act as if the timer has already
5287 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5288 BGP_TIMER_OFF(bm
->t_rmap_update
);
5289 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5294 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5295 return CMD_WARNING_CONFIG_FAILED
;
5299 DEFUN (no_bgp_set_route_map_delay_timer
,
5300 no_bgp_set_route_map_delay_timer_cmd
,
5301 "no bgp route-map delay-timer [(0-600)]",
5304 "Default BGP route-map delay timer\n"
5305 "Reset to default time to wait for processing route-map changes\n"
5306 "0 disables the timer, no route updates happen when route-maps change\n")
5309 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5315 /* neighbor interface */
5316 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5321 peer
= peer_lookup_vty(vty
, ip_str
);
5322 if (!peer
|| peer
->conf_if
) {
5323 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5324 return CMD_WARNING_CONFIG_FAILED
;
5328 peer_interface_set(peer
, str
);
5330 peer_interface_unset(peer
);
5335 DEFUN (neighbor_interface
,
5336 neighbor_interface_cmd
,
5337 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5345 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5348 DEFUN (no_neighbor_interface
,
5349 no_neighbor_interface_cmd
,
5350 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5358 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5361 DEFUN (neighbor_distribute_list
,
5362 neighbor_distribute_list_cmd
,
5363 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5366 "Filter updates to/from this neighbor\n"
5367 "IP access-list number\n"
5368 "IP access-list number (expanded range)\n"
5369 "IP Access-list name\n"
5370 "Filter incoming updates\n"
5371 "Filter outgoing updates\n")
5378 const char *pstr
= argv
[idx_peer
]->arg
;
5379 const char *acl
= argv
[idx_acl
]->arg
;
5380 const char *inout
= argv
[argc
- 1]->text
;
5382 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5384 return CMD_WARNING_CONFIG_FAILED
;
5386 /* Check filter direction. */
5387 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5388 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5391 return bgp_vty_return(vty
, ret
);
5395 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5396 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5397 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5398 "Filter updates to/from this neighbor\n"
5399 "IP access-list number\n"
5400 "IP access-list number (expanded range)\n"
5401 "IP Access-list name\n"
5402 "Filter incoming updates\n"
5403 "Filter outgoing updates\n")
5405 DEFUN (no_neighbor_distribute_list
,
5406 no_neighbor_distribute_list_cmd
,
5407 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5411 "Filter updates to/from this neighbor\n"
5412 "IP access-list number\n"
5413 "IP access-list number (expanded range)\n"
5414 "IP Access-list name\n"
5415 "Filter incoming updates\n"
5416 "Filter outgoing updates\n")
5422 const char *pstr
= argv
[idx_peer
]->arg
;
5423 const char *inout
= argv
[argc
- 1]->text
;
5425 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5427 return CMD_WARNING_CONFIG_FAILED
;
5429 /* Check filter direction. */
5430 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5431 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5434 return bgp_vty_return(vty
, ret
);
5438 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5439 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5440 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5441 "Filter updates to/from this neighbor\n"
5442 "IP access-list number\n"
5443 "IP access-list number (expanded range)\n"
5444 "IP Access-list name\n"
5445 "Filter incoming updates\n"
5446 "Filter outgoing updates\n")
5448 /* Set prefix list to the peer. */
5449 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5450 afi_t afi
, safi_t safi
,
5451 const char *name_str
,
5452 const char *direct_str
)
5455 int direct
= FILTER_IN
;
5458 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5460 return CMD_WARNING_CONFIG_FAILED
;
5462 /* Check filter direction. */
5463 if (strncmp(direct_str
, "i", 1) == 0)
5465 else if (strncmp(direct_str
, "o", 1) == 0)
5466 direct
= FILTER_OUT
;
5468 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5470 return bgp_vty_return(vty
, ret
);
5473 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5474 afi_t afi
, safi_t safi
,
5475 const char *direct_str
)
5479 int direct
= FILTER_IN
;
5481 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5483 return CMD_WARNING_CONFIG_FAILED
;
5485 /* Check filter direction. */
5486 if (strncmp(direct_str
, "i", 1) == 0)
5488 else if (strncmp(direct_str
, "o", 1) == 0)
5489 direct
= FILTER_OUT
;
5491 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5493 return bgp_vty_return(vty
, ret
);
5496 DEFUN (neighbor_prefix_list
,
5497 neighbor_prefix_list_cmd
,
5498 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5501 "Filter updates to/from this neighbor\n"
5502 "Name of a prefix list\n"
5503 "Filter incoming updates\n"
5504 "Filter outgoing updates\n")
5509 return peer_prefix_list_set_vty(
5510 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5511 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5514 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5515 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5516 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5517 "Filter updates to/from this neighbor\n"
5518 "Name of a prefix list\n"
5519 "Filter incoming updates\n"
5520 "Filter outgoing updates\n")
5522 DEFUN (no_neighbor_prefix_list
,
5523 no_neighbor_prefix_list_cmd
,
5524 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5528 "Filter updates to/from this neighbor\n"
5529 "Name of a prefix list\n"
5530 "Filter incoming updates\n"
5531 "Filter outgoing updates\n")
5535 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5536 bgp_node_afi(vty
), bgp_node_safi(vty
),
5537 argv
[idx_in_out
]->arg
);
5540 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5541 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5542 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5543 "Filter updates to/from this neighbor\n"
5544 "Name of a prefix list\n"
5545 "Filter incoming updates\n"
5546 "Filter outgoing updates\n")
5548 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5549 safi_t safi
, const char *name_str
,
5550 const char *direct_str
)
5554 int direct
= FILTER_IN
;
5556 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5558 return CMD_WARNING_CONFIG_FAILED
;
5560 /* Check filter direction. */
5561 if (strncmp(direct_str
, "i", 1) == 0)
5563 else if (strncmp(direct_str
, "o", 1) == 0)
5564 direct
= FILTER_OUT
;
5566 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5568 return bgp_vty_return(vty
, ret
);
5571 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5572 safi_t safi
, const char *direct_str
)
5576 int direct
= FILTER_IN
;
5578 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5580 return CMD_WARNING_CONFIG_FAILED
;
5582 /* Check filter direction. */
5583 if (strncmp(direct_str
, "i", 1) == 0)
5585 else if (strncmp(direct_str
, "o", 1) == 0)
5586 direct
= FILTER_OUT
;
5588 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5590 return bgp_vty_return(vty
, ret
);
5593 DEFUN (neighbor_filter_list
,
5594 neighbor_filter_list_cmd
,
5595 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5598 "Establish BGP filters\n"
5599 "AS path access-list name\n"
5600 "Filter incoming routes\n"
5601 "Filter outgoing routes\n")
5606 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5607 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5608 argv
[idx_in_out
]->arg
);
5611 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5612 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5613 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5614 "Establish BGP filters\n"
5615 "AS path access-list name\n"
5616 "Filter incoming routes\n"
5617 "Filter outgoing routes\n")
5619 DEFUN (no_neighbor_filter_list
,
5620 no_neighbor_filter_list_cmd
,
5621 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5625 "Establish BGP filters\n"
5626 "AS path access-list name\n"
5627 "Filter incoming routes\n"
5628 "Filter outgoing routes\n")
5632 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5633 bgp_node_afi(vty
), bgp_node_safi(vty
),
5634 argv
[idx_in_out
]->arg
);
5637 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5638 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5639 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5640 "Establish BGP filters\n"
5641 "AS path access-list name\n"
5642 "Filter incoming routes\n"
5643 "Filter outgoing routes\n")
5645 /* Set route-map to the peer. */
5646 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5647 afi_t afi
, safi_t safi
, const char *name_str
,
5648 const char *direct_str
)
5652 int direct
= RMAP_IN
;
5653 struct route_map
*route_map
;
5655 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5657 return CMD_WARNING_CONFIG_FAILED
;
5659 /* Check filter direction. */
5660 if (strncmp(direct_str
, "in", 2) == 0)
5662 else if (strncmp(direct_str
, "o", 1) == 0)
5665 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5666 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
5668 return bgp_vty_return(vty
, ret
);
5671 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5672 afi_t afi
, safi_t safi
,
5673 const char *direct_str
)
5677 int direct
= RMAP_IN
;
5679 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5681 return CMD_WARNING_CONFIG_FAILED
;
5683 /* Check filter direction. */
5684 if (strncmp(direct_str
, "in", 2) == 0)
5686 else if (strncmp(direct_str
, "o", 1) == 0)
5689 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5691 return bgp_vty_return(vty
, ret
);
5694 DEFUN (neighbor_route_map
,
5695 neighbor_route_map_cmd
,
5696 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5699 "Apply route map to neighbor\n"
5700 "Name of route map\n"
5701 "Apply map to incoming routes\n"
5702 "Apply map to outbound routes\n")
5707 return peer_route_map_set_vty(
5708 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5709 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5712 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5713 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5714 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5715 "Apply route map to neighbor\n"
5716 "Name of route map\n"
5717 "Apply map to incoming routes\n"
5718 "Apply map to outbound routes\n")
5720 DEFUN (no_neighbor_route_map
,
5721 no_neighbor_route_map_cmd
,
5722 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5726 "Apply route map to neighbor\n"
5727 "Name of route map\n"
5728 "Apply map to incoming routes\n"
5729 "Apply map to outbound routes\n")
5733 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5734 bgp_node_afi(vty
), bgp_node_safi(vty
),
5735 argv
[idx_in_out
]->arg
);
5738 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5739 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5740 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5741 "Apply route map to neighbor\n"
5742 "Name of route map\n"
5743 "Apply map to incoming routes\n"
5744 "Apply map to outbound routes\n")
5746 /* Set unsuppress-map to the peer. */
5747 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5748 afi_t afi
, safi_t safi
,
5749 const char *name_str
)
5753 struct route_map
*route_map
;
5755 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5757 return CMD_WARNING_CONFIG_FAILED
;
5759 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5760 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
5762 return bgp_vty_return(vty
, ret
);
5765 /* Unset route-map from the peer. */
5766 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5767 afi_t afi
, safi_t safi
)
5772 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5774 return CMD_WARNING_CONFIG_FAILED
;
5776 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5778 return bgp_vty_return(vty
, ret
);
5781 DEFUN (neighbor_unsuppress_map
,
5782 neighbor_unsuppress_map_cmd
,
5783 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5786 "Route-map to selectively unsuppress suppressed routes\n"
5787 "Name of route map\n")
5791 return peer_unsuppress_map_set_vty(
5792 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5793 argv
[idx_word
]->arg
);
5796 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5797 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5798 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5799 "Route-map to selectively unsuppress suppressed routes\n"
5800 "Name of route map\n")
5802 DEFUN (no_neighbor_unsuppress_map
,
5803 no_neighbor_unsuppress_map_cmd
,
5804 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5808 "Route-map to selectively unsuppress suppressed routes\n"
5809 "Name of route map\n")
5812 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5814 bgp_node_safi(vty
));
5817 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5818 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5819 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5820 "Route-map to selectively unsuppress suppressed routes\n"
5821 "Name of route map\n")
5823 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5824 afi_t afi
, safi_t safi
,
5825 const char *num_str
,
5826 const char *threshold_str
, int warning
,
5827 const char *restart_str
)
5835 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5837 return CMD_WARNING_CONFIG_FAILED
;
5839 max
= strtoul(num_str
, NULL
, 10);
5841 threshold
= atoi(threshold_str
);
5843 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5846 restart
= atoi(restart_str
);
5850 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5853 return bgp_vty_return(vty
, ret
);
5856 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5857 afi_t afi
, safi_t safi
)
5862 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5864 return CMD_WARNING_CONFIG_FAILED
;
5866 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5868 return bgp_vty_return(vty
, ret
);
5871 /* Maximum number of prefix configuration. prefix count is different
5872 for each peer configuration. So this configuration can be set for
5873 each peer configuration. */
5874 DEFUN (neighbor_maximum_prefix
,
5875 neighbor_maximum_prefix_cmd
,
5876 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5879 "Maximum number of prefix accept from this peer\n"
5880 "maximum no. of prefix limit\n")
5884 return peer_maximum_prefix_set_vty(
5885 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5886 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5889 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5890 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5891 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5892 "Maximum number of prefix accept from this peer\n"
5893 "maximum no. of prefix limit\n")
5895 DEFUN (neighbor_maximum_prefix_threshold
,
5896 neighbor_maximum_prefix_threshold_cmd
,
5897 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5900 "Maximum number of prefix accept from this peer\n"
5901 "maximum no. of prefix limit\n"
5902 "Threshold value (%) at which to generate a warning msg\n")
5906 int idx_number_2
= 4;
5907 return peer_maximum_prefix_set_vty(
5908 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5909 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5913 neighbor_maximum_prefix_threshold
,
5914 neighbor_maximum_prefix_threshold_hidden_cmd
,
5915 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5916 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5917 "Maximum number of prefix accept from this peer\n"
5918 "maximum no. of prefix limit\n"
5919 "Threshold value (%) at which to generate a warning msg\n")
5921 DEFUN (neighbor_maximum_prefix_warning
,
5922 neighbor_maximum_prefix_warning_cmd
,
5923 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5926 "Maximum number of prefix accept from this peer\n"
5927 "maximum no. of prefix limit\n"
5928 "Only give warning message when limit is exceeded\n")
5932 return peer_maximum_prefix_set_vty(
5933 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5934 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
5938 neighbor_maximum_prefix_warning
,
5939 neighbor_maximum_prefix_warning_hidden_cmd
,
5940 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5941 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5942 "Maximum number of prefix accept from this peer\n"
5943 "maximum no. of prefix limit\n"
5944 "Only give warning message when limit is exceeded\n")
5946 DEFUN (neighbor_maximum_prefix_threshold_warning
,
5947 neighbor_maximum_prefix_threshold_warning_cmd
,
5948 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5951 "Maximum number of prefix accept from this peer\n"
5952 "maximum no. of prefix limit\n"
5953 "Threshold value (%) at which to generate a warning msg\n"
5954 "Only give warning message when limit is exceeded\n")
5958 int idx_number_2
= 4;
5959 return peer_maximum_prefix_set_vty(
5960 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5961 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
5965 neighbor_maximum_prefix_threshold_warning
,
5966 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
5967 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5968 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5969 "Maximum number of prefix accept from this peer\n"
5970 "maximum no. of prefix limit\n"
5971 "Threshold value (%) at which to generate a warning msg\n"
5972 "Only give warning message when limit is exceeded\n")
5974 DEFUN (neighbor_maximum_prefix_restart
,
5975 neighbor_maximum_prefix_restart_cmd
,
5976 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5979 "Maximum number of prefix accept from this peer\n"
5980 "maximum no. of prefix limit\n"
5981 "Restart bgp connection after limit is exceeded\n"
5982 "Restart interval in minutes\n")
5986 int idx_number_2
= 5;
5987 return peer_maximum_prefix_set_vty(
5988 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5989 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
5993 neighbor_maximum_prefix_restart
,
5994 neighbor_maximum_prefix_restart_hidden_cmd
,
5995 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5996 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5997 "Maximum number of prefix accept from this peer\n"
5998 "maximum no. of prefix limit\n"
5999 "Restart bgp connection after limit is exceeded\n"
6000 "Restart interval in minutes\n")
6002 DEFUN (neighbor_maximum_prefix_threshold_restart
,
6003 neighbor_maximum_prefix_threshold_restart_cmd
,
6004 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6007 "Maximum number of prefixes to accept from this peer\n"
6008 "maximum no. of prefix limit\n"
6009 "Threshold value (%) at which to generate a warning msg\n"
6010 "Restart bgp connection after limit is exceeded\n"
6011 "Restart interval in minutes\n")
6015 int idx_number_2
= 4;
6016 int idx_number_3
= 6;
6017 return peer_maximum_prefix_set_vty(
6018 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6019 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
6020 argv
[idx_number_3
]->arg
);
6024 neighbor_maximum_prefix_threshold_restart
,
6025 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
6026 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6027 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6028 "Maximum number of prefixes to accept from this peer\n"
6029 "maximum no. of prefix limit\n"
6030 "Threshold value (%) at which to generate a warning msg\n"
6031 "Restart bgp connection after limit is exceeded\n"
6032 "Restart interval in minutes\n")
6034 DEFUN (no_neighbor_maximum_prefix
,
6035 no_neighbor_maximum_prefix_cmd
,
6036 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6040 "Maximum number of prefixes to accept from this peer\n"
6041 "maximum no. of prefix limit\n"
6042 "Threshold value (%) at which to generate a warning msg\n"
6043 "Restart bgp connection after limit is exceeded\n"
6044 "Restart interval in minutes\n"
6045 "Only give warning message when limit is exceeded\n")
6048 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
6050 bgp_node_safi(vty
));
6054 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
6055 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6056 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6057 "Maximum number of prefixes to accept from this peer\n"
6058 "maximum no. of prefix limit\n"
6059 "Threshold value (%) at which to generate a warning msg\n"
6060 "Restart bgp connection after limit is exceeded\n"
6061 "Restart interval in minutes\n"
6062 "Only give warning message when limit is exceeded\n")
6065 /* "neighbor allowas-in" */
6066 DEFUN (neighbor_allowas_in
,
6067 neighbor_allowas_in_cmd
,
6068 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6071 "Accept as-path with my AS present in it\n"
6072 "Number of occurences of AS number\n"
6073 "Only accept my AS in the as-path if the route was originated in my AS\n")
6076 int idx_number_origin
= 3;
6082 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6084 return CMD_WARNING_CONFIG_FAILED
;
6086 if (argc
<= idx_number_origin
)
6089 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6092 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6095 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6098 return bgp_vty_return(vty
, ret
);
6102 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6103 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6104 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6105 "Accept as-path with my AS present in it\n"
6106 "Number of occurences of AS number\n"
6107 "Only accept my AS in the as-path if the route was originated in my AS\n")
6109 DEFUN (no_neighbor_allowas_in
,
6110 no_neighbor_allowas_in_cmd
,
6111 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6115 "allow local ASN appears in aspath attribute\n"
6116 "Number of occurences of AS number\n"
6117 "Only accept my AS in the as-path if the route was originated in my AS\n")
6123 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6125 return CMD_WARNING_CONFIG_FAILED
;
6127 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6128 bgp_node_safi(vty
));
6130 return bgp_vty_return(vty
, ret
);
6134 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6135 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6136 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6137 "allow local ASN appears in aspath attribute\n"
6138 "Number of occurences of AS number\n"
6139 "Only accept my AS in the as-path if the route was originated in my AS\n")
6141 DEFUN (neighbor_ttl_security
,
6142 neighbor_ttl_security_cmd
,
6143 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6146 "BGP ttl-security parameters\n"
6147 "Specify the maximum number of hops to the BGP peer\n"
6148 "Number of hops to BGP peer\n")
6155 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6157 return CMD_WARNING_CONFIG_FAILED
;
6159 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6162 * If 'neighbor swpX', then this is for directly connected peers,
6163 * we should not accept a ttl-security hops value greater than 1.
6165 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6167 "%s is directly connected peer, hops cannot exceed 1\n",
6168 argv
[idx_peer
]->arg
);
6169 return CMD_WARNING_CONFIG_FAILED
;
6172 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6175 DEFUN (no_neighbor_ttl_security
,
6176 no_neighbor_ttl_security_cmd
,
6177 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6181 "BGP ttl-security parameters\n"
6182 "Specify the maximum number of hops to the BGP peer\n"
6183 "Number of hops to BGP peer\n")
6188 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6190 return CMD_WARNING_CONFIG_FAILED
;
6192 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6195 DEFUN (neighbor_addpath_tx_all_paths
,
6196 neighbor_addpath_tx_all_paths_cmd
,
6197 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6200 "Use addpath to advertise all paths to a neighbor\n")
6205 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6207 return CMD_WARNING_CONFIG_FAILED
;
6209 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6214 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6215 neighbor_addpath_tx_all_paths_hidden_cmd
,
6216 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6217 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6218 "Use addpath to advertise all paths to a neighbor\n")
6220 DEFUN (no_neighbor_addpath_tx_all_paths
,
6221 no_neighbor_addpath_tx_all_paths_cmd
,
6222 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6226 "Use addpath to advertise all paths to a neighbor\n")
6231 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6233 return CMD_WARNING_CONFIG_FAILED
;
6235 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6236 != BGP_ADDPATH_ALL
) {
6238 "%% Peer not currently configured to transmit all paths.");
6239 return CMD_WARNING_CONFIG_FAILED
;
6242 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6248 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6249 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6250 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6251 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6252 "Use addpath to advertise all paths to a neighbor\n")
6254 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6255 neighbor_addpath_tx_bestpath_per_as_cmd
,
6256 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6259 "Use addpath to advertise the bestpath per each neighboring AS\n")
6264 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6266 return CMD_WARNING_CONFIG_FAILED
;
6268 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6269 BGP_ADDPATH_BEST_PER_AS
);
6274 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6275 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6276 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6277 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6278 "Use addpath to advertise the bestpath per each neighboring AS\n")
6280 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6281 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6282 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6286 "Use addpath to advertise the bestpath per each neighboring AS\n")
6291 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6293 return CMD_WARNING_CONFIG_FAILED
;
6295 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6296 != BGP_ADDPATH_BEST_PER_AS
) {
6298 "%% Peer not currently configured to transmit all best path per as.");
6299 return CMD_WARNING_CONFIG_FAILED
;
6302 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6308 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6309 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6310 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6311 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6312 "Use addpath to advertise the bestpath per each neighboring AS\n")
6314 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6315 struct ecommunity
**list
)
6317 struct ecommunity
*ecom
= NULL
;
6318 struct ecommunity
*ecomadd
;
6320 for (; argc
; --argc
, ++argv
) {
6322 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6323 ECOMMUNITY_ROUTE_TARGET
, 0);
6325 vty_out(vty
, "Malformed community-list value\n");
6327 ecommunity_free(&ecom
);
6328 return CMD_WARNING_CONFIG_FAILED
;
6332 ecommunity_merge(ecom
, ecomadd
);
6333 ecommunity_free(&ecomadd
);
6340 ecommunity_free(&*list
);
6348 * v2vimport is true if we are handling a `import vrf ...` command
6350 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6354 switch (vty
->node
) {
6363 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6368 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6369 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6370 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6371 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6373 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6377 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6378 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6379 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6380 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6382 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6389 DEFPY (af_rd_vpn_export
,
6390 af_rd_vpn_export_cmd
,
6391 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6393 "Specify route distinguisher\n"
6394 "Between current address-family and vpn\n"
6395 "For routes leaked from current address-family to vpn\n"
6396 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6398 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6399 struct prefix_rd prd
;
6405 if (argv_find(argv
, argc
, "no", &idx
))
6409 ret
= str2prefix_rd(rd_str
, &prd
);
6411 vty_out(vty
, "%% Malformed rd\n");
6412 return CMD_WARNING_CONFIG_FAILED
;
6416 afi
= vpn_policy_getafi(vty
, bgp
, false);
6418 return CMD_WARNING_CONFIG_FAILED
;
6421 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6423 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6424 bgp_get_default(), bgp
);
6427 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6428 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6429 BGP_VPN_POLICY_TOVPN_RD_SET
);
6431 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6432 BGP_VPN_POLICY_TOVPN_RD_SET
);
6435 /* post-change: re-export vpn routes */
6436 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6437 bgp_get_default(), bgp
);
6442 ALIAS (af_rd_vpn_export
,
6443 af_no_rd_vpn_export_cmd
,
6446 "Specify route distinguisher\n"
6447 "Between current address-family and vpn\n"
6448 "For routes leaked from current address-family to vpn\n")
6450 DEFPY (af_label_vpn_export
,
6451 af_label_vpn_export_cmd
,
6452 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6454 "label value for VRF\n"
6455 "Between current address-family and vpn\n"
6456 "For routes leaked from current address-family to vpn\n"
6457 "Label Value <0-1048575>\n"
6458 "Automatically assign a label\n")
6460 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6461 mpls_label_t label
= MPLS_LABEL_NONE
;
6466 if (argv_find(argv
, argc
, "no", &idx
))
6469 /* If "no ...", squash trailing parameter */
6475 label
= label_val
; /* parser should force unsigned */
6478 afi
= vpn_policy_getafi(vty
, bgp
, false);
6480 return CMD_WARNING_CONFIG_FAILED
;
6483 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6484 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6489 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6491 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6492 bgp_get_default(), bgp
);
6494 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6495 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6497 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6500 * label has previously been automatically
6501 * assigned by labelpool: release it
6503 * NB if tovpn_label == MPLS_LABEL_NONE it
6504 * means the automatic assignment is in flight
6505 * and therefore the labelpool callback must
6506 * detect that the auto label is not needed.
6509 bgp_lp_release(LP_TYPE_VRF
,
6510 &bgp
->vpn_policy
[afi
],
6511 bgp
->vpn_policy
[afi
].tovpn_label
);
6513 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6514 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6517 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6519 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6520 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6521 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6522 vpn_leak_label_callback
);
6525 /* post-change: re-export vpn routes */
6526 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6527 bgp_get_default(), bgp
);
6532 ALIAS (af_label_vpn_export
,
6533 af_no_label_vpn_export_cmd
,
6534 "no label vpn export",
6536 "label value for VRF\n"
6537 "Between current address-family and vpn\n"
6538 "For routes leaked from current address-family to vpn\n")
6540 DEFPY (af_nexthop_vpn_export
,
6541 af_nexthop_vpn_export_cmd
,
6542 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6544 "Specify next hop to use for VRF advertised prefixes\n"
6545 "Between current address-family and vpn\n"
6546 "For routes leaked from current address-family to vpn\n"
6550 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6556 if (argv_find(argv
, argc
, "no", &idx
))
6560 if (!sockunion2hostprefix(nexthop_str
, &p
))
6561 return CMD_WARNING_CONFIG_FAILED
;
6564 afi
= vpn_policy_getafi(vty
, bgp
, false);
6566 return CMD_WARNING_CONFIG_FAILED
;
6569 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6571 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6572 bgp_get_default(), bgp
);
6575 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6576 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6577 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6579 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6580 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6583 /* post-change: re-export vpn routes */
6584 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6585 bgp_get_default(), bgp
);
6590 ALIAS (af_nexthop_vpn_export
,
6591 af_no_nexthop_vpn_export_cmd
,
6592 "no nexthop vpn export",
6594 "Specify next hop to use for VRF advertised prefixes\n"
6595 "Between current address-family and vpn\n"
6596 "For routes leaked from current address-family to vpn\n")
6598 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6600 if (!strcmp(dstr
, "import")) {
6601 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6602 } else if (!strcmp(dstr
, "export")) {
6603 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6604 } else if (!strcmp(dstr
, "both")) {
6605 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6606 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6608 vty_out(vty
, "%% direction parse error\n");
6609 return CMD_WARNING_CONFIG_FAILED
;
6614 DEFPY (af_rt_vpn_imexport
,
6615 af_rt_vpn_imexport_cmd
,
6616 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6618 "Specify route target list\n"
6619 "Specify route target list\n"
6620 "Between current address-family and vpn\n"
6621 "For routes leaked from vpn to current address-family: match any\n"
6622 "For routes leaked from current address-family to vpn: set\n"
6623 "both import: match any and export: set\n"
6624 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6626 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6628 struct ecommunity
*ecom
= NULL
;
6629 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6630 vpn_policy_direction_t dir
;
6635 if (argv_find(argv
, argc
, "no", &idx
))
6638 afi
= vpn_policy_getafi(vty
, bgp
, false);
6640 return CMD_WARNING_CONFIG_FAILED
;
6642 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6643 if (ret
!= CMD_SUCCESS
)
6647 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6648 vty_out(vty
, "%% Missing RTLIST\n");
6649 return CMD_WARNING_CONFIG_FAILED
;
6651 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6652 if (ret
!= CMD_SUCCESS
) {
6657 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6661 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6664 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6666 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6667 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6668 ecommunity_dup(ecom
);
6670 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6672 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6673 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6676 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6680 ecommunity_free(&ecom
);
6685 ALIAS (af_rt_vpn_imexport
,
6686 af_no_rt_vpn_imexport_cmd
,
6687 "no <rt|route-target> vpn <import|export|both>$direction_str",
6689 "Specify route target list\n"
6690 "Specify route target list\n"
6691 "Between current address-family and vpn\n"
6692 "For routes leaked from vpn to current address-family\n"
6693 "For routes leaked from current address-family to vpn\n"
6694 "both import and export\n")
6696 DEFPY (af_route_map_vpn_imexport
,
6697 af_route_map_vpn_imexport_cmd
,
6698 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6699 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6701 "Specify route map\n"
6702 "Between current address-family and vpn\n"
6703 "For routes leaked from vpn to current address-family\n"
6704 "For routes leaked from current address-family to vpn\n"
6705 "name of route-map\n")
6707 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6709 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6710 vpn_policy_direction_t dir
;
6715 if (argv_find(argv
, argc
, "no", &idx
))
6718 afi
= vpn_policy_getafi(vty
, bgp
, false);
6720 return CMD_WARNING_CONFIG_FAILED
;
6722 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6723 if (ret
!= CMD_SUCCESS
)
6726 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6730 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6733 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6734 XFREE(MTYPE_ROUTE_MAP_NAME
,
6735 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6736 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6737 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6738 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6739 route_map_lookup_warn_noexist(vty
, rmap_str
);
6740 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6743 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6744 XFREE(MTYPE_ROUTE_MAP_NAME
,
6745 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6746 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6747 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6750 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6756 ALIAS (af_route_map_vpn_imexport
,
6757 af_no_route_map_vpn_imexport_cmd
,
6758 "no route-map vpn <import|export>$direction_str",
6760 "Specify route map\n"
6761 "Between current address-family and vpn\n"
6762 "For routes leaked from vpn to current address-family\n"
6763 "For routes leaked from current address-family to vpn\n")
6765 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6766 "[no] import vrf route-map RMAP$rmap_str",
6768 "Import routes from another VRF\n"
6769 "Vrf routes being filtered\n"
6770 "Specify route map\n"
6771 "name of route-map\n")
6773 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6774 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6778 struct bgp
*bgp_default
;
6780 if (argv_find(argv
, argc
, "no", &idx
))
6783 afi
= vpn_policy_getafi(vty
, bgp
, true);
6785 return CMD_WARNING_CONFIG_FAILED
;
6787 bgp_default
= bgp_get_default();
6792 /* Auto-create assuming the same AS */
6793 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6794 BGP_INSTANCE_TYPE_DEFAULT
);
6798 "VRF default is not configured as a bgp instance\n");
6803 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6806 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6807 XFREE(MTYPE_ROUTE_MAP_NAME
,
6808 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6809 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6810 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6811 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6812 route_map_lookup_warn_noexist(vty
, rmap_str
);
6813 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6816 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6817 XFREE(MTYPE_ROUTE_MAP_NAME
,
6818 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6819 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6820 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6823 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6828 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6829 "no import vrf route-map",
6831 "Import routes from another VRF\n"
6832 "Vrf routes being filtered\n"
6833 "Specify route map\n")
6835 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
6836 "[no] import vrf VIEWVRFNAME$import_name",
6838 "Import routes from another VRF\n"
6839 "VRF to import from\n"
6840 "The name of the VRF\n")
6842 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6843 struct listnode
*node
;
6844 struct bgp
*vrf_bgp
, *bgp_default
;
6847 bool remove
= false;
6850 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
6854 if (import_name
== NULL
) {
6855 vty_out(vty
, "%% Missing import name\n");
6859 if (argv_find(argv
, argc
, "no", &idx
))
6862 afi
= vpn_policy_getafi(vty
, bgp
, true);
6864 return CMD_WARNING_CONFIG_FAILED
;
6866 safi
= bgp_node_safi(vty
);
6868 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
6869 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
6870 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
6871 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
6872 remove
? "unimport" : "import", import_name
);
6876 bgp_default
= bgp_get_default();
6878 /* Auto-create assuming the same AS */
6879 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6880 BGP_INSTANCE_TYPE_DEFAULT
);
6884 "VRF default is not configured as a bgp instance\n");
6889 vrf_bgp
= bgp_lookup_by_name(import_name
);
6891 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
6892 vrf_bgp
= bgp_default
;
6894 /* Auto-create assuming the same AS */
6895 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
6899 "VRF %s is not configured as a bgp instance\n",
6906 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6908 /* Already importing from "import_vrf"? */
6909 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
6911 if (strcmp(vname
, import_name
) == 0)
6915 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6921 /* This command is valid only in a bgp vrf instance or the default instance */
6922 DEFPY (bgp_imexport_vpn
,
6923 bgp_imexport_vpn_cmd
,
6924 "[no] <import|export>$direction_str vpn",
6926 "Import routes to this address-family\n"
6927 "Export routes from this address-family\n"
6928 "to/from default instance VPN RIB\n")
6930 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6937 vpn_policy_direction_t dir
;
6939 if (argv_find(argv
, argc
, "no", &idx
))
6942 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
6943 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
6945 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
6946 return CMD_WARNING_CONFIG_FAILED
;
6949 afi
= bgp_node_afi(vty
);
6950 safi
= bgp_node_safi(vty
);
6951 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
6952 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
6953 return CMD_WARNING_CONFIG_FAILED
;
6956 if (!strcmp(direction_str
, "import")) {
6957 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
6958 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6959 } else if (!strcmp(direction_str
, "export")) {
6960 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
6961 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
6963 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
6964 return CMD_WARNING_CONFIG_FAILED
;
6967 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6970 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6971 if (!previous_state
) {
6972 /* trigger export current vrf */
6973 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6976 if (previous_state
) {
6977 /* trigger un-export current vrf */
6978 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6980 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6986 DEFPY (af_routetarget_import
,
6987 af_routetarget_import_cmd
,
6988 "[no] <rt|route-target> redirect import RTLIST...",
6990 "Specify route target list\n"
6991 "Specify route target list\n"
6992 "Flow-spec redirect type route target\n"
6993 "Import routes to this address-family\n"
6994 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6996 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6998 struct ecommunity
*ecom
= NULL
;
7003 if (argv_find(argv
, argc
, "no", &idx
))
7006 afi
= vpn_policy_getafi(vty
, bgp
, false);
7008 return CMD_WARNING_CONFIG_FAILED
;
7011 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7012 vty_out(vty
, "%% Missing RTLIST\n");
7013 return CMD_WARNING_CONFIG_FAILED
;
7015 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7016 if (ret
!= CMD_SUCCESS
)
7021 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7022 ecommunity_free(&bgp
->vpn_policy
[afi
]
7023 .import_redirect_rtlist
);
7024 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
7025 ecommunity_dup(ecom
);
7027 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7028 ecommunity_free(&bgp
->vpn_policy
[afi
]
7029 .import_redirect_rtlist
);
7030 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
7034 ecommunity_free(&ecom
);
7039 DEFUN_NOSH (address_family_ipv4_safi
,
7040 address_family_ipv4_safi_cmd
,
7041 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7042 "Enter Address Family command mode\n"
7044 BGP_SAFI_WITH_LABEL_HELP_STR
)
7048 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7049 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7050 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7051 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7052 && safi
!= SAFI_EVPN
) {
7054 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7055 return CMD_WARNING_CONFIG_FAILED
;
7057 vty
->node
= bgp_node_type(AFI_IP
, safi
);
7059 vty
->node
= BGP_IPV4_NODE
;
7064 DEFUN_NOSH (address_family_ipv6_safi
,
7065 address_family_ipv6_safi_cmd
,
7066 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7067 "Enter Address Family command mode\n"
7069 BGP_SAFI_WITH_LABEL_HELP_STR
)
7072 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7073 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7074 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7075 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7076 && safi
!= SAFI_EVPN
) {
7078 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7079 return CMD_WARNING_CONFIG_FAILED
;
7081 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
7083 vty
->node
= BGP_IPV6_NODE
;
7088 #ifdef KEEP_OLD_VPN_COMMANDS
7089 DEFUN_NOSH (address_family_vpnv4
,
7090 address_family_vpnv4_cmd
,
7091 "address-family vpnv4 [unicast]",
7092 "Enter Address Family command mode\n"
7094 "Address Family modifier\n")
7096 vty
->node
= BGP_VPNV4_NODE
;
7100 DEFUN_NOSH (address_family_vpnv6
,
7101 address_family_vpnv6_cmd
,
7102 "address-family vpnv6 [unicast]",
7103 "Enter Address Family command mode\n"
7105 "Address Family modifier\n")
7107 vty
->node
= BGP_VPNV6_NODE
;
7110 #endif /* KEEP_OLD_VPN_COMMANDS */
7112 DEFUN_NOSH (address_family_evpn
,
7113 address_family_evpn_cmd
,
7114 "address-family l2vpn evpn",
7115 "Enter Address Family command mode\n"
7117 "Address Family modifier\n")
7119 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7120 vty
->node
= BGP_EVPN_NODE
;
7124 DEFUN_NOSH (exit_address_family
,
7125 exit_address_family_cmd
,
7126 "exit-address-family",
7127 "Exit from Address Family configuration mode\n")
7129 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7130 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7131 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7132 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7133 || vty
->node
== BGP_EVPN_NODE
7134 || vty
->node
== BGP_FLOWSPECV4_NODE
7135 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7136 vty
->node
= BGP_NODE
;
7140 /* Recalculate bestpath and re-advertise a prefix */
7141 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7142 const char *ip_str
, afi_t afi
, safi_t safi
,
7143 struct prefix_rd
*prd
)
7146 struct prefix match
;
7147 struct bgp_node
*rn
;
7148 struct bgp_node
*rm
;
7150 struct bgp_table
*table
;
7151 struct bgp_table
*rib
;
7153 /* BGP structure lookup. */
7155 bgp
= bgp_lookup_by_name(view_name
);
7157 vty_out(vty
, "%% Can't find BGP instance %s\n",
7162 bgp
= bgp_get_default();
7164 vty_out(vty
, "%% No BGP process is configured\n");
7169 /* Check IP address argument. */
7170 ret
= str2prefix(ip_str
, &match
);
7172 vty_out(vty
, "%% address is malformed\n");
7176 match
.family
= afi2family(afi
);
7177 rib
= bgp
->rib
[afi
][safi
];
7179 if (safi
== SAFI_MPLS_VPN
) {
7180 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7181 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7184 table
= bgp_node_get_bgp_table_info(rn
);
7185 if (table
!= NULL
) {
7187 if ((rm
= bgp_node_match(table
, &match
))
7190 == match
.prefixlen
) {
7192 BGP_NODE_USER_CLEAR
);
7193 bgp_process(bgp
, rm
, afi
, safi
);
7195 bgp_unlock_node(rm
);
7200 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7201 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7202 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7203 bgp_process(bgp
, rn
, afi
, safi
);
7205 bgp_unlock_node(rn
);
7212 /* one clear bgp command to rule them all */
7213 DEFUN (clear_ip_bgp_all
,
7214 clear_ip_bgp_all_cmd
,
7215 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out>]",
7219 BGP_INSTANCE_HELP_STR
7222 BGP_SAFI_WITH_LABEL_HELP_STR
7223 "Address Family modifier\n"
7225 "BGP neighbor address to clear\n"
7226 "BGP IPv6 neighbor to clear\n"
7227 "BGP neighbor on interface to clear\n"
7228 "Clear peers with the AS number\n"
7229 "Clear all external peers\n"
7230 "Clear all members of peer-group\n"
7231 "BGP peer-group name\n"
7236 "Push out prefix-list ORF and do inbound soft reconfig\n"
7241 afi_t afi
= AFI_IP6
;
7242 safi_t safi
= SAFI_UNICAST
;
7243 enum clear_sort clr_sort
= clear_peer
;
7244 enum bgp_clear_type clr_type
;
7245 char *clr_arg
= NULL
;
7249 /* clear [ip] bgp */
7250 if (argv_find(argv
, argc
, "ip", &idx
))
7253 /* [<vrf> VIEWVRFNAME] */
7254 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7255 vrf
= argv
[idx
+ 1]->arg
;
7257 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7259 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7260 /* [<view> VIEWVRFNAME] */
7261 vrf
= argv
[idx
+ 1]->arg
;
7264 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7265 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7266 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7268 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
7269 if (argv_find(argv
, argc
, "*", &idx
)) {
7270 clr_sort
= clear_all
;
7271 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7272 clr_sort
= clear_peer
;
7273 clr_arg
= argv
[idx
]->arg
;
7274 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7275 clr_sort
= clear_peer
;
7276 clr_arg
= argv
[idx
]->arg
;
7277 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7278 clr_sort
= clear_group
;
7280 clr_arg
= argv
[idx
]->arg
;
7281 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
7282 clr_sort
= clear_peer
;
7283 clr_arg
= argv
[idx
]->arg
;
7284 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7285 clr_sort
= clear_as
;
7286 clr_arg
= argv
[idx
]->arg
;
7287 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7288 clr_sort
= clear_external
;
7291 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7292 if (argv_find(argv
, argc
, "soft", &idx
)) {
7293 if (argv_find(argv
, argc
, "in", &idx
)
7294 || argv_find(argv
, argc
, "out", &idx
))
7295 clr_type
= strmatch(argv
[idx
]->text
, "in")
7297 : BGP_CLEAR_SOFT_OUT
;
7299 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7300 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7301 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7302 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7303 : BGP_CLEAR_SOFT_IN
;
7304 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7305 clr_type
= BGP_CLEAR_SOFT_OUT
;
7307 clr_type
= BGP_CLEAR_SOFT_NONE
;
7309 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7312 DEFUN (clear_ip_bgp_prefix
,
7313 clear_ip_bgp_prefix_cmd
,
7314 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7318 BGP_INSTANCE_HELP_STR
7319 "Clear bestpath and re-advertise\n"
7323 char *prefix
= NULL
;
7327 /* [<view|vrf> VIEWVRFNAME] */
7328 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7329 vrf
= argv
[idx
+ 1]->arg
;
7331 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7333 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7334 /* [<view> VIEWVRFNAME] */
7335 vrf
= argv
[idx
+ 1]->arg
;
7339 prefix
= argv
[argc
- 1]->arg
;
7341 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7344 DEFUN (clear_bgp_ipv6_safi_prefix
,
7345 clear_bgp_ipv6_safi_prefix_cmd
,
7346 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7352 "Clear bestpath and re-advertise\n"
7356 int idx_ipv6_prefix
= 0;
7357 safi_t safi
= SAFI_UNICAST
;
7358 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7359 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7361 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7362 return bgp_clear_prefix(
7363 vty
, NULL
, prefix
, AFI_IP6
,
7367 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7368 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7369 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7373 BGP_INSTANCE_HELP_STR
7376 "Clear bestpath and re-advertise\n"
7380 int idx_vrfview
= 0;
7381 int idx_ipv6_prefix
= 0;
7382 safi_t safi
= SAFI_UNICAST
;
7383 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7384 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7385 char *vrfview
= NULL
;
7387 /* [<view|vrf> VIEWVRFNAME] */
7388 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
7389 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7390 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
7392 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
7393 /* [<view> VIEWVRFNAME] */
7394 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7396 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7398 return bgp_clear_prefix(
7399 vty
, vrfview
, prefix
,
7400 AFI_IP6
, safi
, NULL
);
7403 DEFUN (show_bgp_views
,
7405 "show [ip] bgp views",
7409 "Show the defined BGP views\n")
7411 struct list
*inst
= bm
->bgp
;
7412 struct listnode
*node
;
7415 vty_out(vty
, "Defined BGP views:\n");
7416 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7418 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7420 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7427 DEFUN (show_bgp_vrfs
,
7429 "show [ip] bgp vrfs [json]",
7436 char buf
[ETHER_ADDR_STRLEN
];
7437 struct list
*inst
= bm
->bgp
;
7438 struct listnode
*node
;
7440 bool uj
= use_json(argc
, argv
);
7441 json_object
*json
= NULL
;
7442 json_object
*json_vrfs
= NULL
;
7446 json
= json_object_new_object();
7447 json_vrfs
= json_object_new_object();
7450 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7451 const char *name
, *type
;
7453 struct listnode
*node2
, *nnode2
;
7454 int peers_cfg
, peers_estb
;
7455 json_object
*json_vrf
= NULL
;
7458 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7462 if (!uj
&& count
== 1) {
7464 "%4s %-5s %-16s %9s %10s %-37s\n",
7465 "Type", "Id", "routerId", "#PeersVfg",
7466 "#PeersEstb", "Name");
7467 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
7468 "L3-VNI", "RouterMAC", "Interface");
7471 peers_cfg
= peers_estb
= 0;
7473 json_vrf
= json_object_new_object();
7476 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
7477 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7480 if (peer
->status
== Established
)
7484 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7485 name
= VRF_DEFAULT_NAME
;
7494 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7496 : (int64_t)bgp
->vrf_id
;
7497 json_object_string_add(json_vrf
, "type", type
);
7498 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7499 json_object_string_add(json_vrf
, "routerId",
7500 inet_ntoa(bgp
->router_id
));
7501 json_object_int_add(json_vrf
, "numConfiguredPeers",
7503 json_object_int_add(json_vrf
, "numEstablishedPeers",
7506 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7507 json_object_string_add(
7509 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7510 json_object_string_add(json_vrf
, "interface",
7511 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
7513 json_object_object_add(json_vrfs
, name
, json_vrf
);
7516 "%4s %-5d %-16s %-9u %-10u %-37s\n",
7518 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7520 inet_ntoa(bgp
->router_id
), peers_cfg
,
7522 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
7524 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
7525 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
7531 json_object_object_add(json
, "vrfs", json_vrfs
);
7533 json_object_int_add(json
, "totalVrfs", count
);
7535 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7536 json
, JSON_C_TO_STRING_PRETTY
));
7537 json_object_free(json
);
7541 "\nTotal number of VRFs (including default): %d\n",
7548 DEFUN (show_bgp_mac_hash
,
7549 show_bgp_mac_hash_cmd
,
7550 "show bgp mac hash",
7554 "Mac Address database\n")
7556 bgp_mac_dump_table(vty
);
7561 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
7563 struct vty
*vty
= (struct vty
*)args
;
7564 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
7566 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7570 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7572 vty_out(vty
, "self nexthop database:\n");
7573 bgp_nexthop_show_address_hash(vty
, bgp
);
7575 vty_out(vty
, "Tunnel-ip database:\n");
7576 hash_iterate(bgp
->tip_hash
,
7577 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
7581 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7582 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7583 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7584 "martian next-hops\n"
7585 "martian next-hop database\n")
7587 struct bgp
*bgp
= NULL
;
7591 /* [<vrf> VIEWVRFNAME] */
7592 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7593 name
= argv
[idx
+ 1]->arg
;
7594 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7596 } else if (argv_find(argv
, argc
, "view", &idx
))
7597 /* [<view> VIEWVRFNAME] */
7598 name
= argv
[idx
+ 1]->arg
;
7600 bgp
= bgp_lookup_by_name(name
);
7602 bgp
= bgp_get_default();
7605 vty_out(vty
, "%% No BGP process is configured\n");
7608 bgp_show_martian_nexthops(vty
, bgp
);
7613 DEFUN (show_bgp_memory
,
7614 show_bgp_memory_cmd
,
7615 "show [ip] bgp memory",
7619 "Global BGP memory statistics\n")
7621 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7622 unsigned long count
;
7624 /* RIB related usage stats */
7625 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7626 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7627 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7628 count
* sizeof(struct bgp_node
)));
7630 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7631 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7632 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7633 count
* sizeof(struct bgp_path_info
)));
7634 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7635 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7638 memstrbuf
, sizeof(memstrbuf
),
7639 count
* sizeof(struct bgp_path_info_extra
)));
7641 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7642 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7643 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7644 count
* sizeof(struct bgp_static
)));
7646 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7647 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7648 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7649 count
* sizeof(struct bpacket
)));
7652 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7653 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7654 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7655 count
* sizeof(struct bgp_adj_in
)));
7656 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7657 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7658 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7659 count
* sizeof(struct bgp_adj_out
)));
7661 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7662 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7664 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7665 count
* sizeof(struct bgp_nexthop_cache
)));
7667 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7668 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7670 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7671 count
* sizeof(struct bgp_damp_info
)));
7674 count
= attr_count();
7675 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7676 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7677 count
* sizeof(struct attr
)));
7679 if ((count
= attr_unknown_count()))
7680 vty_out(vty
, "%ld unknown attributes\n", count
);
7682 /* AS_PATH attributes */
7683 count
= aspath_count();
7684 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7685 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7686 count
* sizeof(struct aspath
)));
7688 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7689 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7690 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7691 count
* sizeof(struct assegment
)));
7693 /* Other attributes */
7694 if ((count
= community_count()))
7695 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7696 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7697 count
* sizeof(struct community
)));
7698 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7699 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7700 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7701 count
* sizeof(struct ecommunity
)));
7702 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7704 "%ld BGP large-community entries, using %s of memory\n",
7705 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7706 count
* sizeof(struct lcommunity
)));
7708 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7709 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7710 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7711 count
* sizeof(struct cluster_list
)));
7713 /* Peer related usage */
7714 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7715 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7716 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7717 count
* sizeof(struct peer
)));
7719 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7720 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7721 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7722 count
* sizeof(struct peer_group
)));
7725 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7726 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7727 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7728 count
* sizeof(regex_t
)));
7732 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7734 json_object
*bestpath
= json_object_new_object();
7736 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7737 json_object_string_add(bestpath
, "asPath", "ignore");
7739 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7740 json_object_string_add(bestpath
, "asPath", "confed");
7742 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7743 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7744 json_object_string_add(bestpath
, "multiPathRelax",
7747 json_object_string_add(bestpath
, "multiPathRelax",
7750 json_object_string_add(bestpath
, "multiPathRelax", "false");
7752 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7753 json_object_string_add(bestpath
, "compareRouterId", "true");
7754 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7755 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7756 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7757 json_object_string_add(bestpath
, "med", "confed");
7758 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7759 json_object_string_add(bestpath
, "med",
7760 "missing-as-worst");
7762 json_object_string_add(bestpath
, "med", "true");
7765 json_object_object_add(json
, "bestPath", bestpath
);
7768 /* Show BGP peer's summary information. */
7769 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7770 bool use_json
, json_object
*json
)
7773 struct listnode
*node
, *nnode
;
7774 unsigned int count
= 0, dn_count
= 0;
7775 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7776 char neighbor_buf
[VTY_BUFSIZ
];
7777 int neighbor_col_default_width
= 16;
7779 int max_neighbor_width
= 0;
7781 json_object
*json_peer
= NULL
;
7782 json_object
*json_peers
= NULL
;
7783 struct peer_af
*paf
;
7785 /* labeled-unicast routes are installed in the unicast table so in order
7787 * display the correct PfxRcd value we must look at SAFI_UNICAST
7789 if (safi
== SAFI_LABELED_UNICAST
)
7790 pfx_rcd_safi
= SAFI_UNICAST
;
7792 pfx_rcd_safi
= safi
;
7796 json
= json_object_new_object();
7798 json_peers
= json_object_new_object();
7800 /* Loop over all neighbors that will be displayed to determine
7802 * characters are needed for the Neighbor column
7804 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7805 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7808 if (peer
->afc
[afi
][safi
]) {
7809 memset(dn_flag
, '\0', sizeof(dn_flag
));
7810 if (peer_dynamic_neighbor(peer
))
7814 && bgp_flag_check(bgp
,
7815 BGP_FLAG_SHOW_HOSTNAME
))
7816 sprintf(neighbor_buf
, "%s%s(%s) ",
7817 dn_flag
, peer
->hostname
,
7820 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7823 len
= strlen(neighbor_buf
);
7825 if (len
> max_neighbor_width
)
7826 max_neighbor_width
= len
;
7830 /* Originally we displayed the Neighbor column as 16
7831 * characters wide so make that the default
7833 if (max_neighbor_width
< neighbor_col_default_width
)
7834 max_neighbor_width
= neighbor_col_default_width
;
7837 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7838 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7841 if (!peer
->afc
[afi
][safi
])
7846 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7849 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7851 : (int64_t)bgp
->vrf_id
;
7853 /* Usage summary and header */
7855 json_object_string_add(
7857 inet_ntoa(bgp
->router_id
));
7858 json_object_int_add(json
, "as", bgp
->as
);
7859 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7860 json_object_string_add(
7863 == BGP_INSTANCE_TYPE_DEFAULT
)
7868 "BGP router identifier %s, local AS number %u vrf-id %d",
7869 inet_ntoa(bgp
->router_id
), bgp
->as
,
7870 bgp
->vrf_id
== VRF_UNKNOWN
7872 : (int)bgp
->vrf_id
);
7876 if (bgp_update_delay_configured(bgp
)) {
7878 json_object_int_add(
7879 json
, "updateDelayLimit",
7880 bgp
->v_update_delay
);
7882 if (bgp
->v_update_delay
7883 != bgp
->v_establish_wait
)
7884 json_object_int_add(
7886 "updateDelayEstablishWait",
7887 bgp
->v_establish_wait
);
7889 if (bgp_update_delay_active(bgp
)) {
7890 json_object_string_add(
7892 "updateDelayFirstNeighbor",
7893 bgp
->update_delay_begin_time
);
7894 json_object_boolean_true_add(
7896 "updateDelayInProgress");
7898 if (bgp
->update_delay_over
) {
7899 json_object_string_add(
7901 "updateDelayFirstNeighbor",
7902 bgp
->update_delay_begin_time
);
7903 json_object_string_add(
7905 "updateDelayBestpathResumed",
7906 bgp
->update_delay_end_time
);
7907 json_object_string_add(
7909 "updateDelayZebraUpdateResume",
7910 bgp
->update_delay_zebra_resume_time
);
7911 json_object_string_add(
7913 "updateDelayPeerUpdateResume",
7914 bgp
->update_delay_peers_resume_time
);
7919 "Read-only mode update-delay limit: %d seconds\n",
7920 bgp
->v_update_delay
);
7921 if (bgp
->v_update_delay
7922 != bgp
->v_establish_wait
)
7924 " Establish wait: %d seconds\n",
7925 bgp
->v_establish_wait
);
7927 if (bgp_update_delay_active(bgp
)) {
7929 " First neighbor established: %s\n",
7930 bgp
->update_delay_begin_time
);
7932 " Delay in progress\n");
7934 if (bgp
->update_delay_over
) {
7936 " First neighbor established: %s\n",
7937 bgp
->update_delay_begin_time
);
7939 " Best-paths resumed: %s\n",
7940 bgp
->update_delay_end_time
);
7942 " zebra update resumed: %s\n",
7943 bgp
->update_delay_zebra_resume_time
);
7945 " peers update resumed: %s\n",
7946 bgp
->update_delay_peers_resume_time
);
7953 if (bgp_maxmed_onstartup_configured(bgp
)
7954 && bgp
->maxmed_active
)
7955 json_object_boolean_true_add(
7956 json
, "maxMedOnStartup");
7957 if (bgp
->v_maxmed_admin
)
7958 json_object_boolean_true_add(
7959 json
, "maxMedAdministrative");
7961 json_object_int_add(
7962 json
, "tableVersion",
7963 bgp_table_version(bgp
->rib
[afi
][safi
]));
7965 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7966 json_object_int_add(json
, "ribCount", ents
);
7967 json_object_int_add(
7969 ents
* sizeof(struct bgp_node
));
7971 ents
= bgp
->af_peer_count
[afi
][safi
];
7972 json_object_int_add(json
, "peerCount", ents
);
7973 json_object_int_add(json
, "peerMemory",
7974 ents
* sizeof(struct peer
));
7976 if ((ents
= listcount(bgp
->group
))) {
7977 json_object_int_add(
7978 json
, "peerGroupCount", ents
);
7979 json_object_int_add(
7980 json
, "peerGroupMemory",
7981 ents
* sizeof(struct
7985 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7986 BGP_CONFIG_DAMPENING
))
7987 json_object_boolean_true_add(
7988 json
, "dampeningEnabled");
7990 if (bgp_maxmed_onstartup_configured(bgp
)
7991 && bgp
->maxmed_active
)
7993 "Max-med on-startup active\n");
7994 if (bgp
->v_maxmed_admin
)
7996 "Max-med administrative active\n");
7998 vty_out(vty
, "BGP table version %" PRIu64
"\n",
7999 bgp_table_version(bgp
->rib
[afi
][safi
]));
8001 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8003 "RIB entries %ld, using %s of memory\n",
8005 mtype_memstr(memstrbuf
,
8007 ents
* sizeof(struct
8010 /* Peer related usage */
8011 ents
= bgp
->af_peer_count
[afi
][safi
];
8012 vty_out(vty
, "Peers %ld, using %s of memory\n",
8015 memstrbuf
, sizeof(memstrbuf
),
8016 ents
* sizeof(struct peer
)));
8018 if ((ents
= listcount(bgp
->group
)))
8020 "Peer groups %ld, using %s of memory\n",
8025 ents
* sizeof(struct
8028 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8029 BGP_CONFIG_DAMPENING
))
8030 vty_out(vty
, "Dampening enabled.\n");
8033 /* Subtract 8 here because 'Neighbor' is
8035 vty_out(vty
, "Neighbor");
8036 vty_out(vty
, "%*s", max_neighbor_width
- 8,
8039 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
8046 json_peer
= json_object_new_object();
8048 if (peer_dynamic_neighbor(peer
)) {
8050 json_object_boolean_true_add(json_peer
,
8055 json_object_string_add(json_peer
, "hostname",
8058 if (peer
->domainname
)
8059 json_object_string_add(json_peer
, "domainname",
8062 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
8063 json_object_int_add(json_peer
, "version", 4);
8064 json_object_int_add(json_peer
, "msgRcvd",
8065 PEER_TOTAL_RX(peer
));
8066 json_object_int_add(json_peer
, "msgSent",
8067 PEER_TOTAL_TX(peer
));
8069 json_object_int_add(json_peer
, "tableVersion",
8070 peer
->version
[afi
][safi
]);
8071 json_object_int_add(json_peer
, "outq",
8073 json_object_int_add(json_peer
, "inq", 0);
8074 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8075 use_json
, json_peer
);
8078 * Adding "pfxRcd" field to match with the corresponding
8079 * CLI. "prefixReceivedCount" will be deprecated in
8082 json_object_int_add(json_peer
, "prefixReceivedCount",
8083 peer
->pcount
[afi
][pfx_rcd_safi
]);
8084 json_object_int_add(json_peer
, "pfxRcd",
8085 peer
->pcount
[afi
][pfx_rcd_safi
]);
8087 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
8088 if (paf
&& PAF_SUBGRP(paf
))
8089 json_object_int_add(json_peer
,
8091 (PAF_SUBGRP(paf
))->scount
);
8093 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8094 json_object_string_add(json_peer
, "state",
8096 else if (peer
->afc_recv
[afi
][safi
])
8097 json_object_string_add(
8099 lookup_msg(bgp_status_msg
, peer
->status
,
8101 else if (CHECK_FLAG(peer
->sflags
,
8102 PEER_STATUS_PREFIX_OVERFLOW
))
8103 json_object_string_add(json_peer
, "state",
8106 json_object_string_add(
8108 lookup_msg(bgp_status_msg
, peer
->status
,
8112 json_object_string_add(json_peer
, "idType",
8114 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8115 json_object_string_add(json_peer
, "idType",
8117 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8118 json_object_string_add(json_peer
, "idType",
8121 json_object_object_add(json_peers
, peer
->host
,
8124 memset(dn_flag
, '\0', sizeof(dn_flag
));
8125 if (peer_dynamic_neighbor(peer
)) {
8131 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8132 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8133 peer
->hostname
, peer
->host
);
8135 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8137 /* pad the neighbor column with spaces */
8138 if (len
< max_neighbor_width
)
8139 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8142 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8143 peer
->as
, PEER_TOTAL_RX(peer
),
8144 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8145 0, peer
->obuf
->count
,
8146 peer_uptime(peer
->uptime
, timebuf
,
8147 BGP_UPTIME_LEN
, 0, NULL
));
8149 if (peer
->status
== Established
)
8150 if (peer
->afc_recv
[afi
][safi
])
8151 vty_out(vty
, " %12ld",
8155 vty_out(vty
, " NoNeg");
8157 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8158 vty_out(vty
, " Idle (Admin)");
8159 else if (CHECK_FLAG(
8161 PEER_STATUS_PREFIX_OVERFLOW
))
8162 vty_out(vty
, " Idle (PfxCt)");
8164 vty_out(vty
, " %12s",
8165 lookup_msg(bgp_status_msg
,
8166 peer
->status
, NULL
));
8173 json_object_object_add(json
, "peers", json_peers
);
8175 json_object_int_add(json
, "totalPeers", count
);
8176 json_object_int_add(json
, "dynamicPeers", dn_count
);
8178 bgp_show_bestpath_json(bgp
, json
);
8180 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8181 json
, JSON_C_TO_STRING_PRETTY
));
8182 json_object_free(json
);
8185 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8187 vty_out(vty
, "No %s neighbor is configured\n",
8188 afi_safi_print(afi
, safi
));
8192 vty_out(vty
, "* - dynamic neighbor\n");
8193 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8194 dn_count
, bgp
->dynamic_neighbors_limit
);
8201 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8202 int safi
, bool use_json
,
8206 int afi_wildcard
= (afi
== AFI_MAX
);
8207 int safi_wildcard
= (safi
== SAFI_MAX
);
8208 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8209 bool nbr_output
= false;
8211 if (use_json
&& is_wildcard
)
8212 vty_out(vty
, "{\n");
8214 afi
= 1; /* AFI_IP */
8215 while (afi
< AFI_MAX
) {
8217 safi
= 1; /* SAFI_UNICAST */
8218 while (safi
< SAFI_MAX
) {
8219 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8223 * So limit output to those afi/safi
8225 * actualy have something interesting in
8229 json
= json_object_new_object();
8232 vty_out(vty
, ",\n");
8236 vty_out(vty
, "\"%s\":",
8240 vty_out(vty
, "\n%s Summary:\n",
8245 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
8257 if (use_json
&& is_wildcard
)
8258 vty_out(vty
, "}\n");
8259 else if (!nbr_output
) {
8261 vty_out(vty
, "{}\n");
8263 vty_out(vty
, "%% No BGP neighbors found\n");
8267 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8268 safi_t safi
, bool use_json
)
8270 struct listnode
*node
, *nnode
;
8272 json_object
*json
= NULL
;
8274 bool nbr_output
= false;
8277 vty_out(vty
, "{\n");
8279 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8282 json
= json_object_new_object();
8285 vty_out(vty
, ",\n");
8289 vty_out(vty
, "\"%s\":",
8290 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8294 vty_out(vty
, "\nInstance %s:\n",
8295 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8299 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
8303 vty_out(vty
, "}\n");
8304 else if (!nbr_output
)
8305 vty_out(vty
, "%% BGP instance not found\n");
8308 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8309 safi_t safi
, bool use_json
)
8314 if (strmatch(name
, "all")) {
8315 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8319 bgp
= bgp_lookup_by_name(name
);
8323 vty_out(vty
, "{}\n");
8326 "%% BGP instance not found\n");
8330 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
8336 bgp
= bgp_get_default();
8339 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
8342 vty_out(vty
, "{}\n");
8344 vty_out(vty
, "%% BGP instance not found\n");
8351 /* `show [ip] bgp summary' commands. */
8352 DEFUN (show_ip_bgp_summary
,
8353 show_ip_bgp_summary_cmd
,
8354 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8358 BGP_INSTANCE_HELP_STR
8360 BGP_SAFI_WITH_LABEL_HELP_STR
8361 "Summary of BGP neighbor status\n"
8365 afi_t afi
= AFI_MAX
;
8366 safi_t safi
= SAFI_MAX
;
8371 if (argv_find(argv
, argc
, "ip", &idx
))
8373 /* [<vrf> VIEWVRFNAME] */
8374 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8375 vrf
= argv
[idx
+ 1]->arg
;
8376 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8378 } else if (argv_find(argv
, argc
, "view", &idx
))
8379 /* [<view> VIEWVRFNAME] */
8380 vrf
= argv
[idx
+ 1]->arg
;
8381 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8382 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8383 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8386 bool uj
= use_json(argc
, argv
);
8388 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8391 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8393 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8394 return "IPv4 Unicast";
8395 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8396 return "IPv4 Multicast";
8397 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8398 return "IPv4 Labeled Unicast";
8399 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8401 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8402 return "IPv4 Encap";
8403 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8404 return "IPv4 Flowspec";
8405 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8406 return "IPv6 Unicast";
8407 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8408 return "IPv6 Multicast";
8409 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8410 return "IPv6 Labeled Unicast";
8411 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8413 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8414 return "IPv6 Encap";
8415 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8416 return "IPv6 Flowspec";
8417 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8418 return "L2VPN EVPN";
8424 * Please note that we have intentionally camelCased
8425 * the return strings here. So if you want
8426 * to use this function, please ensure you
8427 * are doing this within json output
8429 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8431 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8432 return "ipv4Unicast";
8433 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8434 return "ipv4Multicast";
8435 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8436 return "ipv4LabeledUnicast";
8437 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8439 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8441 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8442 return "ipv4Flowspec";
8443 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8444 return "ipv6Unicast";
8445 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8446 return "ipv6Multicast";
8447 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8448 return "ipv6LabeledUnicast";
8449 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8451 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8453 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8454 return "ipv6Flowspec";
8455 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8461 /* Show BGP peer's information. */
8462 enum show_type
{ show_all
, show_peer
, show_ipv4_all
, show_ipv6_all
, show_ipv4_peer
, show_ipv6_peer
};
8464 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8465 afi_t afi
, safi_t safi
,
8466 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8467 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8468 bool use_json
, json_object
*json_pref
)
8471 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8472 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8474 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8475 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8476 json_object_string_add(json_pref
, "sendMode",
8477 "advertisedAndReceived");
8478 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8479 json_object_string_add(json_pref
, "sendMode",
8481 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8482 json_object_string_add(json_pref
, "sendMode",
8485 vty_out(vty
, " Send-mode: ");
8486 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8487 vty_out(vty
, "advertised");
8488 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8489 vty_out(vty
, "%sreceived",
8490 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8499 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8500 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8502 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8503 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8504 json_object_string_add(json_pref
, "recvMode",
8505 "advertisedAndReceived");
8506 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8507 json_object_string_add(json_pref
, "recvMode",
8509 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8510 json_object_string_add(json_pref
, "recvMode",
8513 vty_out(vty
, " Receive-mode: ");
8514 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8515 vty_out(vty
, "advertised");
8516 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8517 vty_out(vty
, "%sreceived",
8518 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8527 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8528 safi_t safi
, bool use_json
,
8529 json_object
*json_neigh
)
8531 struct bgp_filter
*filter
;
8532 struct peer_af
*paf
;
8533 char orf_pfx_name
[BUFSIZ
];
8535 json_object
*json_af
= NULL
;
8536 json_object
*json_prefA
= NULL
;
8537 json_object
*json_prefB
= NULL
;
8538 json_object
*json_addr
= NULL
;
8541 json_addr
= json_object_new_object();
8542 json_af
= json_object_new_object();
8543 filter
= &p
->filter
[afi
][safi
];
8545 if (peer_group_active(p
))
8546 json_object_string_add(json_addr
, "peerGroupMember",
8549 paf
= peer_af_find(p
, afi
, safi
);
8550 if (paf
&& PAF_SUBGRP(paf
)) {
8551 json_object_int_add(json_addr
, "updateGroupId",
8552 PAF_UPDGRP(paf
)->id
);
8553 json_object_int_add(json_addr
, "subGroupId",
8554 PAF_SUBGRP(paf
)->id
);
8555 json_object_int_add(json_addr
, "packetQueueLength",
8556 bpacket_queue_virtual_length(paf
));
8559 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8560 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8561 PEER_CAP_ORF_PREFIX_SM_RCV
)
8562 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8563 PEER_CAP_ORF_PREFIX_RM_ADV
)
8564 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8565 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8566 json_object_int_add(json_af
, "orfType",
8568 json_prefA
= json_object_new_object();
8569 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8570 PEER_CAP_ORF_PREFIX_SM_ADV
,
8571 PEER_CAP_ORF_PREFIX_RM_ADV
,
8572 PEER_CAP_ORF_PREFIX_SM_RCV
,
8573 PEER_CAP_ORF_PREFIX_RM_RCV
,
8574 use_json
, json_prefA
);
8575 json_object_object_add(json_af
, "orfPrefixList",
8579 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8580 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8581 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8582 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8583 PEER_CAP_ORF_PREFIX_RM_ADV
)
8584 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8585 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8586 json_object_int_add(json_af
, "orfOldType",
8587 ORF_TYPE_PREFIX_OLD
);
8588 json_prefB
= json_object_new_object();
8589 bgp_show_peer_afi_orf_cap(
8590 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8591 PEER_CAP_ORF_PREFIX_RM_ADV
,
8592 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8593 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8595 json_object_object_add(json_af
, "orfOldPrefixList",
8599 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8600 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8601 PEER_CAP_ORF_PREFIX_SM_RCV
)
8602 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8603 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8604 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8605 PEER_CAP_ORF_PREFIX_RM_ADV
)
8606 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8607 PEER_CAP_ORF_PREFIX_RM_RCV
)
8608 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8609 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8610 json_object_object_add(json_addr
, "afDependentCap",
8613 json_object_free(json_af
);
8615 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8616 orf_pfx_count
= prefix_bgp_show_prefix_list(
8617 NULL
, afi
, orf_pfx_name
, use_json
);
8619 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8620 PEER_STATUS_ORF_PREFIX_SEND
)
8622 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8623 PEER_STATUS_ORF_PREFIX_SEND
))
8624 json_object_boolean_true_add(json_neigh
,
8627 json_object_int_add(json_addr
, "orfRecvCounter",
8630 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8631 PEER_STATUS_ORF_WAIT_REFRESH
))
8632 json_object_string_add(
8633 json_addr
, "orfFirstUpdate",
8634 "deferredUntilORFOrRouteRefreshRecvd");
8636 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8637 PEER_FLAG_REFLECTOR_CLIENT
))
8638 json_object_boolean_true_add(json_addr
,
8639 "routeReflectorClient");
8640 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8641 PEER_FLAG_RSERVER_CLIENT
))
8642 json_object_boolean_true_add(json_addr
,
8643 "routeServerClient");
8644 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8645 json_object_boolean_true_add(json_addr
,
8646 "inboundSoftConfigPermit");
8648 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8649 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8650 json_object_boolean_true_add(
8652 "privateAsNumsAllReplacedInUpdatesToNbr");
8653 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8654 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8655 json_object_boolean_true_add(
8657 "privateAsNumsReplacedInUpdatesToNbr");
8658 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8659 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8660 json_object_boolean_true_add(
8662 "privateAsNumsAllRemovedInUpdatesToNbr");
8663 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8664 PEER_FLAG_REMOVE_PRIVATE_AS
))
8665 json_object_boolean_true_add(
8667 "privateAsNumsRemovedInUpdatesToNbr");
8669 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8670 json_object_boolean_true_add(
8672 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8675 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8676 json_object_string_add(json_addr
,
8677 "overrideASNsInOutboundUpdates",
8678 "ifAspathEqualRemoteAs");
8680 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8681 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8682 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8683 json_object_boolean_true_add(json_addr
,
8684 "routerAlwaysNextHop");
8685 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8686 PEER_FLAG_AS_PATH_UNCHANGED
))
8687 json_object_boolean_true_add(
8688 json_addr
, "unchangedAsPathPropogatedToNbr");
8689 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8690 PEER_FLAG_NEXTHOP_UNCHANGED
))
8691 json_object_boolean_true_add(
8692 json_addr
, "unchangedNextHopPropogatedToNbr");
8693 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8694 json_object_boolean_true_add(
8695 json_addr
, "unchangedMedPropogatedToNbr");
8696 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8697 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8698 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8699 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8700 PEER_FLAG_SEND_COMMUNITY
)
8701 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8702 PEER_FLAG_SEND_EXT_COMMUNITY
))
8703 json_object_string_add(json_addr
,
8704 "commAttriSentToNbr",
8705 "extendedAndStandard");
8706 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8707 PEER_FLAG_SEND_EXT_COMMUNITY
))
8708 json_object_string_add(json_addr
,
8709 "commAttriSentToNbr",
8712 json_object_string_add(json_addr
,
8713 "commAttriSentToNbr",
8716 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8717 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8718 if (p
->default_rmap
[afi
][safi
].name
)
8719 json_object_string_add(
8720 json_addr
, "defaultRouteMap",
8721 p
->default_rmap
[afi
][safi
].name
);
8723 if (paf
&& PAF_SUBGRP(paf
)
8724 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8725 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8726 json_object_boolean_true_add(json_addr
,
8729 json_object_boolean_true_add(json_addr
,
8733 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8734 if (is_evpn_enabled())
8735 json_object_boolean_true_add(
8736 json_addr
, "advertiseAllVnis");
8739 if (filter
->plist
[FILTER_IN
].name
8740 || filter
->dlist
[FILTER_IN
].name
8741 || filter
->aslist
[FILTER_IN
].name
8742 || filter
->map
[RMAP_IN
].name
)
8743 json_object_boolean_true_add(json_addr
,
8744 "inboundPathPolicyConfig");
8745 if (filter
->plist
[FILTER_OUT
].name
8746 || filter
->dlist
[FILTER_OUT
].name
8747 || filter
->aslist
[FILTER_OUT
].name
8748 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8749 json_object_boolean_true_add(
8750 json_addr
, "outboundPathPolicyConfig");
8753 if (filter
->plist
[FILTER_IN
].name
)
8754 json_object_string_add(json_addr
,
8755 "incomingUpdatePrefixFilterList",
8756 filter
->plist
[FILTER_IN
].name
);
8757 if (filter
->plist
[FILTER_OUT
].name
)
8758 json_object_string_add(json_addr
,
8759 "outgoingUpdatePrefixFilterList",
8760 filter
->plist
[FILTER_OUT
].name
);
8762 /* distribute-list */
8763 if (filter
->dlist
[FILTER_IN
].name
)
8764 json_object_string_add(
8765 json_addr
, "incomingUpdateNetworkFilterList",
8766 filter
->dlist
[FILTER_IN
].name
);
8767 if (filter
->dlist
[FILTER_OUT
].name
)
8768 json_object_string_add(
8769 json_addr
, "outgoingUpdateNetworkFilterList",
8770 filter
->dlist
[FILTER_OUT
].name
);
8773 if (filter
->aslist
[FILTER_IN
].name
)
8774 json_object_string_add(json_addr
,
8775 "incomingUpdateAsPathFilterList",
8776 filter
->aslist
[FILTER_IN
].name
);
8777 if (filter
->aslist
[FILTER_OUT
].name
)
8778 json_object_string_add(json_addr
,
8779 "outgoingUpdateAsPathFilterList",
8780 filter
->aslist
[FILTER_OUT
].name
);
8783 if (filter
->map
[RMAP_IN
].name
)
8784 json_object_string_add(
8785 json_addr
, "routeMapForIncomingAdvertisements",
8786 filter
->map
[RMAP_IN
].name
);
8787 if (filter
->map
[RMAP_OUT
].name
)
8788 json_object_string_add(
8789 json_addr
, "routeMapForOutgoingAdvertisements",
8790 filter
->map
[RMAP_OUT
].name
);
8792 /* ebgp-requires-policy (inbound) */
8793 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8794 && !bgp_inbound_policy_exists(p
, filter
))
8795 json_object_string_add(
8796 json_addr
, "inboundEbgpRequiresPolicy",
8797 "Inbound updates discarded due to missing policy");
8799 /* ebgp-requires-policy (outbound) */
8800 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8801 && (!bgp_outbound_policy_exists(p
, filter
)))
8802 json_object_string_add(
8803 json_addr
, "outboundEbgpRequiresPolicy",
8804 "Outbound updates discarded due to missing policy");
8806 /* unsuppress-map */
8807 if (filter
->usmap
.name
)
8808 json_object_string_add(json_addr
,
8809 "selectiveUnsuppressRouteMap",
8810 filter
->usmap
.name
);
8812 /* Receive prefix count */
8813 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8814 p
->pcount
[afi
][safi
]);
8815 if (paf
&& PAF_SUBGRP(paf
))
8816 json_object_int_add(json_addr
, "sentPrefixCounter",
8817 (PAF_SUBGRP(paf
))->scount
);
8819 /* Maximum prefix */
8820 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8821 json_object_int_add(json_addr
, "prefixAllowedMax",
8822 p
->pmax
[afi
][safi
]);
8823 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8824 PEER_FLAG_MAX_PREFIX_WARNING
))
8825 json_object_boolean_true_add(
8826 json_addr
, "prefixAllowedMaxWarning");
8827 json_object_int_add(json_addr
,
8828 "prefixAllowedWarningThresh",
8829 p
->pmax_threshold
[afi
][safi
]);
8830 if (p
->pmax_restart
[afi
][safi
])
8831 json_object_int_add(
8833 "prefixAllowedRestartIntervalMsecs",
8834 p
->pmax_restart
[afi
][safi
] * 60000);
8836 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8840 filter
= &p
->filter
[afi
][safi
];
8842 vty_out(vty
, " For address family: %s\n",
8843 afi_safi_print(afi
, safi
));
8845 if (peer_group_active(p
))
8846 vty_out(vty
, " %s peer-group member\n",
8849 paf
= peer_af_find(p
, afi
, safi
);
8850 if (paf
&& PAF_SUBGRP(paf
)) {
8851 vty_out(vty
, " Update group %" PRIu64
8852 ", subgroup %" PRIu64
"\n",
8853 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8854 vty_out(vty
, " Packet Queue length %d\n",
8855 bpacket_queue_virtual_length(paf
));
8857 vty_out(vty
, " Not part of any update group\n");
8859 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8860 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8861 PEER_CAP_ORF_PREFIX_SM_RCV
)
8862 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8863 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8864 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8865 PEER_CAP_ORF_PREFIX_RM_ADV
)
8866 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8867 PEER_CAP_ORF_PREFIX_RM_RCV
)
8868 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8869 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8870 vty_out(vty
, " AF-dependant capabilities:\n");
8872 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8873 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8874 PEER_CAP_ORF_PREFIX_SM_RCV
)
8875 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8876 PEER_CAP_ORF_PREFIX_RM_ADV
)
8877 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8878 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8880 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8882 bgp_show_peer_afi_orf_cap(
8883 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8884 PEER_CAP_ORF_PREFIX_RM_ADV
,
8885 PEER_CAP_ORF_PREFIX_SM_RCV
,
8886 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8888 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8889 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8890 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8891 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8892 PEER_CAP_ORF_PREFIX_RM_ADV
)
8893 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8894 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8896 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8897 ORF_TYPE_PREFIX_OLD
);
8898 bgp_show_peer_afi_orf_cap(
8899 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8900 PEER_CAP_ORF_PREFIX_RM_ADV
,
8901 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8902 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8905 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8906 orf_pfx_count
= prefix_bgp_show_prefix_list(
8907 NULL
, afi
, orf_pfx_name
, use_json
);
8909 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8910 PEER_STATUS_ORF_PREFIX_SEND
)
8912 vty_out(vty
, " Outbound Route Filter (ORF):");
8913 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8914 PEER_STATUS_ORF_PREFIX_SEND
))
8915 vty_out(vty
, " sent;");
8917 vty_out(vty
, " received (%d entries)",
8921 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8922 PEER_STATUS_ORF_WAIT_REFRESH
))
8924 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
8926 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8927 PEER_FLAG_REFLECTOR_CLIENT
))
8928 vty_out(vty
, " Route-Reflector Client\n");
8929 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8930 PEER_FLAG_RSERVER_CLIENT
))
8931 vty_out(vty
, " Route-Server Client\n");
8932 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8934 " Inbound soft reconfiguration allowed\n");
8936 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8937 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8939 " Private AS numbers (all) replaced in updates to this neighbor\n");
8940 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8941 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8943 " Private AS numbers replaced in updates to this neighbor\n");
8944 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8945 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8947 " Private AS numbers (all) removed in updates to this neighbor\n");
8948 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8949 PEER_FLAG_REMOVE_PRIVATE_AS
))
8951 " Private AS numbers removed in updates to this neighbor\n");
8953 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8954 vty_out(vty
, " %s\n",
8955 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8956 ->human_description
);
8958 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8960 " Override ASNs in outbound updates if aspath equals remote-as\n");
8962 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8963 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8964 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8965 vty_out(vty
, " NEXT_HOP is always this router\n");
8966 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8967 PEER_FLAG_AS_PATH_UNCHANGED
))
8969 " AS_PATH is propagated unchanged to this neighbor\n");
8970 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8971 PEER_FLAG_NEXTHOP_UNCHANGED
))
8973 " NEXT_HOP is propagated unchanged to this neighbor\n");
8974 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8976 " MED is propagated unchanged to this neighbor\n");
8977 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8978 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8979 PEER_FLAG_SEND_EXT_COMMUNITY
)
8980 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8981 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
8983 " Community attribute sent to this neighbor");
8984 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8985 PEER_FLAG_SEND_COMMUNITY
)
8986 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8987 PEER_FLAG_SEND_EXT_COMMUNITY
)
8988 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8989 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8990 vty_out(vty
, "(all)\n");
8991 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8992 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8993 vty_out(vty
, "(large)\n");
8994 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8995 PEER_FLAG_SEND_EXT_COMMUNITY
))
8996 vty_out(vty
, "(extended)\n");
8998 vty_out(vty
, "(standard)\n");
9000 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9001 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9002 vty_out(vty
, " Default information originate,");
9004 if (p
->default_rmap
[afi
][safi
].name
)
9005 vty_out(vty
, " default route-map %s%s,",
9006 p
->default_rmap
[afi
][safi
].map
? "*"
9008 p
->default_rmap
[afi
][safi
].name
);
9009 if (paf
&& PAF_SUBGRP(paf
)
9010 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9011 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9012 vty_out(vty
, " default sent\n");
9014 vty_out(vty
, " default not sent\n");
9017 /* advertise-vni-all */
9018 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9019 if (is_evpn_enabled())
9020 vty_out(vty
, " advertise-all-vni\n");
9023 if (filter
->plist
[FILTER_IN
].name
9024 || filter
->dlist
[FILTER_IN
].name
9025 || filter
->aslist
[FILTER_IN
].name
9026 || filter
->map
[RMAP_IN
].name
)
9027 vty_out(vty
, " Inbound path policy configured\n");
9028 if (filter
->plist
[FILTER_OUT
].name
9029 || filter
->dlist
[FILTER_OUT
].name
9030 || filter
->aslist
[FILTER_OUT
].name
9031 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9032 vty_out(vty
, " Outbound path policy configured\n");
9035 if (filter
->plist
[FILTER_IN
].name
)
9037 " Incoming update prefix filter list is %s%s\n",
9038 filter
->plist
[FILTER_IN
].plist
? "*" : "",
9039 filter
->plist
[FILTER_IN
].name
);
9040 if (filter
->plist
[FILTER_OUT
].name
)
9042 " Outgoing update prefix filter list is %s%s\n",
9043 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
9044 filter
->plist
[FILTER_OUT
].name
);
9046 /* distribute-list */
9047 if (filter
->dlist
[FILTER_IN
].name
)
9049 " Incoming update network filter list is %s%s\n",
9050 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
9051 filter
->dlist
[FILTER_IN
].name
);
9052 if (filter
->dlist
[FILTER_OUT
].name
)
9054 " Outgoing update network filter list is %s%s\n",
9055 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
9056 filter
->dlist
[FILTER_OUT
].name
);
9059 if (filter
->aslist
[FILTER_IN
].name
)
9061 " Incoming update AS path filter list is %s%s\n",
9062 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
9063 filter
->aslist
[FILTER_IN
].name
);
9064 if (filter
->aslist
[FILTER_OUT
].name
)
9066 " Outgoing update AS path filter list is %s%s\n",
9067 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
9068 filter
->aslist
[FILTER_OUT
].name
);
9071 if (filter
->map
[RMAP_IN
].name
)
9073 " Route map for incoming advertisements is %s%s\n",
9074 filter
->map
[RMAP_IN
].map
? "*" : "",
9075 filter
->map
[RMAP_IN
].name
);
9076 if (filter
->map
[RMAP_OUT
].name
)
9078 " Route map for outgoing advertisements is %s%s\n",
9079 filter
->map
[RMAP_OUT
].map
? "*" : "",
9080 filter
->map
[RMAP_OUT
].name
);
9082 /* ebgp-requires-policy (inbound) */
9083 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9084 && !bgp_inbound_policy_exists(p
, filter
))
9086 " Inbound updates discarded due to missing policy\n");
9088 /* ebgp-requires-policy (outbound) */
9089 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9090 && !bgp_outbound_policy_exists(p
, filter
))
9092 " Outbound updates discarded due to missing policy\n");
9094 /* unsuppress-map */
9095 if (filter
->usmap
.name
)
9097 " Route map for selective unsuppress is %s%s\n",
9098 filter
->usmap
.map
? "*" : "",
9099 filter
->usmap
.name
);
9101 /* Receive prefix count */
9102 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
9104 /* Maximum prefix */
9105 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9106 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
9108 CHECK_FLAG(p
->af_flags
[afi
][safi
],
9109 PEER_FLAG_MAX_PREFIX_WARNING
)
9112 vty_out(vty
, " Threshold for warning message %d%%",
9113 p
->pmax_threshold
[afi
][safi
]);
9114 if (p
->pmax_restart
[afi
][safi
])
9115 vty_out(vty
, ", restart interval %d min",
9116 p
->pmax_restart
[afi
][safi
]);
9124 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
9128 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
9129 char timebuf
[BGP_UPTIME_LEN
];
9131 const char *subcode_str
;
9132 const char *code_str
;
9137 json_object
*json_neigh
= NULL
;
9143 json_neigh
= json_object_new_object();
9145 memset(dn_flag
, '\0', sizeof(dn_flag
));
9146 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9150 if (p
->conf_if
) /* Configured interface name. */
9151 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9152 BGP_PEER_SU_UNSPEC(p
)
9154 : sockunion2str(&p
->su
, buf
,
9156 else /* Configured IP address. */
9157 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9162 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9163 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9165 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9166 json_object_string_add(
9167 json_neigh
, "bgpNeighborAddr",
9168 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9170 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9172 if (p
->change_local_as
)
9173 json_object_int_add(json_neigh
, "localAs",
9174 p
->change_local_as
);
9176 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9178 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9179 json_object_boolean_true_add(json_neigh
,
9180 "localAsNoPrepend");
9182 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9183 json_object_boolean_true_add(json_neigh
,
9184 "localAsReplaceAs");
9186 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9187 || (p
->as_type
== AS_INTERNAL
))
9188 vty_out(vty
, "remote AS %u, ", p
->as
);
9190 vty_out(vty
, "remote AS Unspecified, ");
9191 vty_out(vty
, "local AS %u%s%s, ",
9192 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9193 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9196 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9200 /* peer type internal or confed-internal */
9201 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
9203 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9204 json_object_boolean_true_add(
9205 json_neigh
, "nbrConfedInternalLink");
9207 json_object_boolean_true_add(json_neigh
,
9210 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9211 vty_out(vty
, "confed-internal link\n");
9213 vty_out(vty
, "internal link\n");
9215 /* peer type external or confed-external */
9216 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
9218 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9219 json_object_boolean_true_add(
9220 json_neigh
, "nbrConfedExternalLink");
9222 json_object_boolean_true_add(json_neigh
,
9225 if (bgp_confederation_peers_check(bgp
, p
->as
))
9226 vty_out(vty
, "confed-external link\n");
9228 vty_out(vty
, "external link\n");
9232 json_object_boolean_true_add(json_neigh
,
9233 "nbrUnspecifiedLink");
9235 vty_out(vty
, "unspecified link\n");
9241 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9243 vty_out(vty
, " Description: %s\n", p
->desc
);
9249 json_object_string_add(json_neigh
, "hostname",
9253 json_object_string_add(json_neigh
, "domainname",
9256 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9257 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9260 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9267 json_object_string_add(json_neigh
, "peerGroup",
9271 struct prefix prefix
, *range
= NULL
;
9273 sockunion2hostprefix(&(p
->su
), &prefix
);
9274 range
= peer_group_lookup_dynamic_neighbor_range(
9278 prefix2str(range
, buf1
, sizeof(buf1
));
9279 json_object_string_add(
9281 "peerSubnetRangeGroup", buf1
);
9286 " Member of peer-group %s for session parameters\n",
9290 struct prefix prefix
, *range
= NULL
;
9292 sockunion2hostprefix(&(p
->su
), &prefix
);
9293 range
= peer_group_lookup_dynamic_neighbor_range(
9297 prefix2str(range
, buf1
, sizeof(buf1
));
9299 " Belongs to the subnet range group: %s\n",
9307 /* Administrative shutdown. */
9308 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9309 json_object_boolean_true_add(json_neigh
,
9313 json_object_int_add(json_neigh
, "bgpVersion", 4);
9314 json_object_string_add(
9315 json_neigh
, "remoteRouterId",
9316 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9317 json_object_string_add(
9318 json_neigh
, "localRouterId",
9319 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9323 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9324 && bgp_confederation_peers_check(bgp
, p
->as
))
9325 json_object_boolean_true_add(json_neigh
,
9329 json_object_string_add(
9330 json_neigh
, "bgpState",
9331 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9333 if (p
->status
== Established
) {
9336 uptime
= bgp_clock();
9337 uptime
-= p
->uptime
;
9338 epoch_tbuf
= time(NULL
) - uptime
;
9340 #if CONFDATE > 20200101
9342 "bgpTimerUp should be deprecated and can be removed now");
9345 * bgpTimerUp was miliseconds that was accurate
9346 * up to 1 day, then the value returned
9347 * became garbage. So in order to provide
9348 * some level of backwards compatability,
9349 * we still provde the data, but now
9350 * we are returning the correct value
9351 * and also adding a new bgpTimerUpMsec
9352 * which will allow us to deprecate
9355 json_object_int_add(json_neigh
, "bgpTimerUp",
9357 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9359 json_object_string_add(json_neigh
, "bgpTimerUpString",
9360 peer_uptime(p
->uptime
, timebuf
,
9363 json_object_int_add(json_neigh
,
9364 "bgpTimerUpEstablishedEpoch",
9368 else if (p
->status
== Active
) {
9369 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9370 json_object_string_add(json_neigh
, "bgpStateIs",
9372 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9373 json_object_string_add(json_neigh
, "bgpStateIs",
9381 uptime
= bgp_clock();
9382 uptime
-= p
->readtime
;
9383 tm
= gmtime(&uptime
);
9384 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9385 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9386 + (tm
->tm_hour
* 3600000));
9388 uptime
= bgp_clock();
9389 uptime
-= p
->last_write
;
9390 tm
= gmtime(&uptime
);
9391 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9392 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9393 + (tm
->tm_hour
* 3600000));
9395 uptime
= bgp_clock();
9396 uptime
-= p
->update_time
;
9397 tm
= gmtime(&uptime
);
9398 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9399 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9400 + (tm
->tm_hour
* 3600000));
9402 /* Configured timer values. */
9403 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9404 p
->v_holdtime
* 1000);
9405 json_object_int_add(json_neigh
,
9406 "bgpTimerKeepAliveIntervalMsecs",
9407 p
->v_keepalive
* 1000);
9408 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9409 json_object_int_add(json_neigh
,
9410 "bgpTimerConfiguredHoldTimeMsecs",
9411 p
->holdtime
* 1000);
9412 json_object_int_add(
9414 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9415 p
->keepalive
* 1000);
9416 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9417 || (bgp
->default_keepalive
9418 != BGP_DEFAULT_KEEPALIVE
)) {
9419 json_object_int_add(json_neigh
,
9420 "bgpTimerConfiguredHoldTimeMsecs",
9421 bgp
->default_holdtime
);
9422 json_object_int_add(
9424 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9425 bgp
->default_keepalive
);
9428 /* Administrative shutdown. */
9429 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9430 vty_out(vty
, " Administratively shut down\n");
9433 vty_out(vty
, " BGP version 4");
9434 vty_out(vty
, ", remote router ID %s",
9435 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9436 vty_out(vty
, ", local router ID %s\n",
9437 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9441 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9442 && bgp_confederation_peers_check(bgp
, p
->as
))
9444 " Neighbor under common administration\n");
9447 vty_out(vty
, " BGP state = %s",
9448 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9450 if (p
->status
== Established
)
9451 vty_out(vty
, ", up for %8s",
9452 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9455 else if (p
->status
== Active
) {
9456 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9457 vty_out(vty
, " (passive)");
9458 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9459 vty_out(vty
, " (NSF passive)");
9464 vty_out(vty
, " Last read %s",
9465 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9467 vty_out(vty
, ", Last write %s\n",
9468 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9471 /* Configured timer values. */
9473 " Hold time is %d, keepalive interval is %d seconds\n",
9474 p
->v_holdtime
, p
->v_keepalive
);
9475 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9476 vty_out(vty
, " Configured hold time is %d",
9478 vty_out(vty
, ", keepalive interval is %d seconds\n",
9480 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9481 || (bgp
->default_keepalive
9482 != BGP_DEFAULT_KEEPALIVE
)) {
9483 vty_out(vty
, " Configured hold time is %d",
9484 bgp
->default_holdtime
);
9485 vty_out(vty
, ", keepalive interval is %d seconds\n",
9486 bgp
->default_keepalive
);
9490 if (p
->status
== Established
) {
9491 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9492 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9493 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9494 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9495 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9496 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9497 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9498 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9499 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9500 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9501 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9502 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9503 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9504 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9505 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9506 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9507 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9508 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9509 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9510 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9512 json_object
*json_cap
= NULL
;
9514 json_cap
= json_object_new_object();
9517 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9518 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9519 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9520 && CHECK_FLAG(p
->cap
,
9522 json_object_string_add(
9523 json_cap
, "4byteAs",
9524 "advertisedAndReceived");
9525 else if (CHECK_FLAG(p
->cap
,
9527 json_object_string_add(
9528 json_cap
, "4byteAs",
9530 else if (CHECK_FLAG(p
->cap
,
9532 json_object_string_add(
9533 json_cap
, "4byteAs",
9538 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9539 || CHECK_FLAG(p
->cap
,
9540 PEER_CAP_ADDPATH_ADV
)) {
9541 json_object
*json_add
= NULL
;
9542 const char *print_store
;
9544 json_add
= json_object_new_object();
9546 FOREACH_AFI_SAFI (afi
, safi
) {
9547 json_object
*json_sub
= NULL
;
9549 json_object_new_object();
9550 print_store
= afi_safi_print(
9556 PEER_CAP_ADDPATH_AF_TX_ADV
)
9560 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9565 PEER_CAP_ADDPATH_AF_TX_ADV
)
9570 PEER_CAP_ADDPATH_AF_TX_RCV
))
9571 json_object_boolean_true_add(
9573 "txAdvertisedAndReceived");
9579 PEER_CAP_ADDPATH_AF_TX_ADV
))
9580 json_object_boolean_true_add(
9588 PEER_CAP_ADDPATH_AF_TX_RCV
))
9589 json_object_boolean_true_add(
9597 PEER_CAP_ADDPATH_AF_RX_ADV
)
9601 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9606 PEER_CAP_ADDPATH_AF_RX_ADV
)
9611 PEER_CAP_ADDPATH_AF_RX_RCV
))
9612 json_object_boolean_true_add(
9614 "rxAdvertisedAndReceived");
9620 PEER_CAP_ADDPATH_AF_RX_ADV
))
9621 json_object_boolean_true_add(
9629 PEER_CAP_ADDPATH_AF_RX_RCV
))
9630 json_object_boolean_true_add(
9638 PEER_CAP_ADDPATH_AF_TX_ADV
)
9642 PEER_CAP_ADDPATH_AF_TX_RCV
)
9646 PEER_CAP_ADDPATH_AF_RX_ADV
)
9650 PEER_CAP_ADDPATH_AF_RX_RCV
))
9651 json_object_object_add(
9660 json_object_object_add(
9661 json_cap
, "addPath", json_add
);
9665 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9666 || CHECK_FLAG(p
->cap
,
9667 PEER_CAP_DYNAMIC_ADV
)) {
9668 if (CHECK_FLAG(p
->cap
,
9669 PEER_CAP_DYNAMIC_ADV
)
9670 && CHECK_FLAG(p
->cap
,
9671 PEER_CAP_DYNAMIC_RCV
))
9672 json_object_string_add(
9673 json_cap
, "dynamic",
9674 "advertisedAndReceived");
9675 else if (CHECK_FLAG(
9677 PEER_CAP_DYNAMIC_ADV
))
9678 json_object_string_add(
9679 json_cap
, "dynamic",
9681 else if (CHECK_FLAG(
9683 PEER_CAP_DYNAMIC_RCV
))
9684 json_object_string_add(
9685 json_cap
, "dynamic",
9689 /* Extended nexthop */
9690 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9691 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9692 json_object
*json_nxt
= NULL
;
9693 const char *print_store
;
9696 if (CHECK_FLAG(p
->cap
,
9698 && CHECK_FLAG(p
->cap
,
9700 json_object_string_add(
9703 "advertisedAndReceived");
9704 else if (CHECK_FLAG(p
->cap
,
9706 json_object_string_add(
9710 else if (CHECK_FLAG(p
->cap
,
9712 json_object_string_add(
9717 if (CHECK_FLAG(p
->cap
,
9718 PEER_CAP_ENHE_RCV
)) {
9720 json_object_new_object();
9722 for (safi
= SAFI_UNICAST
;
9723 safi
< SAFI_MAX
; safi
++) {
9728 PEER_CAP_ENHE_AF_RCV
)) {
9729 print_store
= afi_safi_print(
9732 json_object_string_add(
9735 "recieved"); /* misspelled for compatibility */
9738 json_object_object_add(
9740 "extendedNexthopFamililesByPeer",
9746 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9747 || CHECK_FLAG(p
->cap
,
9748 PEER_CAP_REFRESH_NEW_RCV
)
9749 || CHECK_FLAG(p
->cap
,
9750 PEER_CAP_REFRESH_OLD_RCV
)) {
9751 if (CHECK_FLAG(p
->cap
,
9752 PEER_CAP_REFRESH_ADV
)
9755 PEER_CAP_REFRESH_NEW_RCV
)
9758 PEER_CAP_REFRESH_OLD_RCV
))) {
9761 PEER_CAP_REFRESH_OLD_RCV
)
9764 PEER_CAP_REFRESH_NEW_RCV
))
9765 json_object_string_add(
9768 "advertisedAndReceivedOldNew");
9772 PEER_CAP_REFRESH_OLD_RCV
))
9773 json_object_string_add(
9776 "advertisedAndReceivedOld");
9778 json_object_string_add(
9781 "advertisedAndReceivedNew");
9786 PEER_CAP_REFRESH_ADV
))
9787 json_object_string_add(
9794 PEER_CAP_REFRESH_NEW_RCV
)
9797 PEER_CAP_REFRESH_OLD_RCV
))
9798 json_object_string_add(
9804 /* Multiprotocol Extensions */
9805 json_object
*json_multi
= NULL
;
9806 json_multi
= json_object_new_object();
9808 FOREACH_AFI_SAFI (afi
, safi
) {
9809 if (p
->afc_adv
[afi
][safi
]
9810 || p
->afc_recv
[afi
][safi
]) {
9811 json_object
*json_exten
= NULL
;
9813 json_object_new_object();
9815 if (p
->afc_adv
[afi
][safi
]
9816 && p
->afc_recv
[afi
][safi
])
9817 json_object_boolean_true_add(
9819 "advertisedAndReceived");
9820 else if (p
->afc_adv
[afi
][safi
])
9821 json_object_boolean_true_add(
9824 else if (p
->afc_recv
[afi
][safi
])
9825 json_object_boolean_true_add(
9829 json_object_object_add(
9836 json_object_object_add(
9837 json_cap
, "multiprotocolExtensions",
9840 /* Hostname capabilities */
9841 json_object
*json_hname
= NULL
;
9843 json_hname
= json_object_new_object();
9845 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9846 json_object_string_add(
9847 json_hname
, "advHostName",
9848 bgp
->peer_self
->hostname
9852 json_object_string_add(
9853 json_hname
, "advDomainName",
9854 bgp
->peer_self
->domainname
9861 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9862 json_object_string_add(
9863 json_hname
, "rcvHostName",
9864 p
->hostname
? p
->hostname
9866 json_object_string_add(
9867 json_hname
, "rcvDomainName",
9868 p
->domainname
? p
->domainname
9872 json_object_object_add(json_cap
, "hostName",
9875 /* Gracefull Restart */
9876 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9877 || CHECK_FLAG(p
->cap
,
9878 PEER_CAP_RESTART_ADV
)) {
9879 if (CHECK_FLAG(p
->cap
,
9880 PEER_CAP_RESTART_ADV
)
9881 && CHECK_FLAG(p
->cap
,
9882 PEER_CAP_RESTART_RCV
))
9883 json_object_string_add(
9886 "advertisedAndReceived");
9887 else if (CHECK_FLAG(
9889 PEER_CAP_RESTART_ADV
))
9890 json_object_string_add(
9892 "gracefulRestartCapability",
9894 else if (CHECK_FLAG(
9896 PEER_CAP_RESTART_RCV
))
9897 json_object_string_add(
9899 "gracefulRestartCapability",
9902 if (CHECK_FLAG(p
->cap
,
9903 PEER_CAP_RESTART_RCV
)) {
9904 int restart_af_count
= 0;
9905 json_object
*json_restart
=
9908 json_object_new_object();
9910 json_object_int_add(
9912 "gracefulRestartRemoteTimerMsecs",
9913 p
->v_gr_restart
* 1000);
9915 FOREACH_AFI_SAFI (afi
, safi
) {
9920 PEER_CAP_RESTART_AF_RCV
)) {
9925 json_object_new_object();
9931 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
9932 json_object_boolean_true_add(
9936 json_object_object_add(
9944 if (!restart_af_count
) {
9945 json_object_string_add(
9947 "addressFamiliesByPeer",
9952 json_object_object_add(
9954 "addressFamiliesByPeer",
9958 json_object_object_add(json_neigh
,
9959 "neighborCapabilities",
9962 vty_out(vty
, " Neighbor capabilities:\n");
9965 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9966 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9967 vty_out(vty
, " 4 Byte AS:");
9968 if (CHECK_FLAG(p
->cap
,
9970 vty_out(vty
, " advertised");
9971 if (CHECK_FLAG(p
->cap
,
9973 vty_out(vty
, " %sreceived",
9983 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9984 || CHECK_FLAG(p
->cap
,
9985 PEER_CAP_ADDPATH_ADV
)) {
9986 vty_out(vty
, " AddPath:\n");
9988 FOREACH_AFI_SAFI (afi
, safi
) {
9992 PEER_CAP_ADDPATH_AF_TX_ADV
)
9996 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
10007 PEER_CAP_ADDPATH_AF_TX_ADV
))
10018 PEER_CAP_ADDPATH_AF_TX_RCV
))
10025 PEER_CAP_ADDPATH_AF_TX_ADV
)
10029 vty_out(vty
, "\n");
10035 PEER_CAP_ADDPATH_AF_RX_ADV
)
10039 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
10050 PEER_CAP_ADDPATH_AF_RX_ADV
))
10061 PEER_CAP_ADDPATH_AF_RX_RCV
))
10068 PEER_CAP_ADDPATH_AF_RX_ADV
)
10072 vty_out(vty
, "\n");
10078 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10079 || CHECK_FLAG(p
->cap
,
10080 PEER_CAP_DYNAMIC_ADV
)) {
10081 vty_out(vty
, " Dynamic:");
10082 if (CHECK_FLAG(p
->cap
,
10083 PEER_CAP_DYNAMIC_ADV
))
10084 vty_out(vty
, " advertised");
10085 if (CHECK_FLAG(p
->cap
,
10086 PEER_CAP_DYNAMIC_RCV
))
10087 vty_out(vty
, " %sreceived",
10090 PEER_CAP_DYNAMIC_ADV
)
10093 vty_out(vty
, "\n");
10096 /* Extended nexthop */
10097 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10098 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10099 vty_out(vty
, " Extended nexthop:");
10100 if (CHECK_FLAG(p
->cap
,
10101 PEER_CAP_ENHE_ADV
))
10102 vty_out(vty
, " advertised");
10103 if (CHECK_FLAG(p
->cap
,
10104 PEER_CAP_ENHE_RCV
))
10105 vty_out(vty
, " %sreceived",
10111 vty_out(vty
, "\n");
10113 if (CHECK_FLAG(p
->cap
,
10114 PEER_CAP_ENHE_RCV
)) {
10116 " Address families by peer:\n ");
10117 for (safi
= SAFI_UNICAST
;
10118 safi
< SAFI_MAX
; safi
++)
10123 PEER_CAP_ENHE_AF_RCV
))
10132 /* Route Refresh */
10133 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10134 || CHECK_FLAG(p
->cap
,
10135 PEER_CAP_REFRESH_NEW_RCV
)
10136 || CHECK_FLAG(p
->cap
,
10137 PEER_CAP_REFRESH_OLD_RCV
)) {
10138 vty_out(vty
, " Route refresh:");
10139 if (CHECK_FLAG(p
->cap
,
10140 PEER_CAP_REFRESH_ADV
))
10141 vty_out(vty
, " advertised");
10142 if (CHECK_FLAG(p
->cap
,
10143 PEER_CAP_REFRESH_NEW_RCV
)
10146 PEER_CAP_REFRESH_OLD_RCV
))
10147 vty_out(vty
, " %sreceived(%s)",
10150 PEER_CAP_REFRESH_ADV
)
10155 PEER_CAP_REFRESH_OLD_RCV
)
10158 PEER_CAP_REFRESH_NEW_RCV
))
10162 PEER_CAP_REFRESH_OLD_RCV
)
10166 vty_out(vty
, "\n");
10169 /* Multiprotocol Extensions */
10170 FOREACH_AFI_SAFI (afi
, safi
)
10171 if (p
->afc_adv
[afi
][safi
]
10172 || p
->afc_recv
[afi
][safi
]) {
10174 " Address Family %s:",
10175 afi_safi_print(afi
,
10177 if (p
->afc_adv
[afi
][safi
])
10180 if (p
->afc_recv
[afi
][safi
])
10187 vty_out(vty
, "\n");
10190 /* Hostname capability */
10191 vty_out(vty
, " Hostname Capability:");
10193 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10195 " advertised (name: %s,domain name: %s)",
10196 bgp
->peer_self
->hostname
10200 bgp
->peer_self
->domainname
10205 vty_out(vty
, " not advertised");
10208 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10210 " received (name: %s,domain name: %s)",
10211 p
->hostname
? p
->hostname
10213 p
->domainname
? p
->domainname
10216 vty_out(vty
, " not received");
10219 vty_out(vty
, "\n");
10221 /* Gracefull Restart */
10222 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10223 || CHECK_FLAG(p
->cap
,
10224 PEER_CAP_RESTART_ADV
)) {
10226 " Graceful Restart Capabilty:");
10227 if (CHECK_FLAG(p
->cap
,
10228 PEER_CAP_RESTART_ADV
))
10229 vty_out(vty
, " advertised");
10230 if (CHECK_FLAG(p
->cap
,
10231 PEER_CAP_RESTART_RCV
))
10232 vty_out(vty
, " %sreceived",
10235 PEER_CAP_RESTART_ADV
)
10238 vty_out(vty
, "\n");
10240 if (CHECK_FLAG(p
->cap
,
10241 PEER_CAP_RESTART_RCV
)) {
10242 int restart_af_count
= 0;
10245 " Remote Restart timer is %d seconds\n",
10248 " Address families by peer:\n ");
10250 FOREACH_AFI_SAFI (afi
, safi
)
10255 PEER_CAP_RESTART_AF_RCV
)) {
10268 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10270 : "not preserved");
10271 restart_af_count
++;
10273 if (!restart_af_count
)
10274 vty_out(vty
, "none");
10275 vty_out(vty
, "\n");
10282 /* graceful restart information */
10283 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10284 || p
->t_gr_stale
) {
10285 json_object
*json_grace
= NULL
;
10286 json_object
*json_grace_send
= NULL
;
10287 json_object
*json_grace_recv
= NULL
;
10288 int eor_send_af_count
= 0;
10289 int eor_receive_af_count
= 0;
10292 json_grace
= json_object_new_object();
10293 json_grace_send
= json_object_new_object();
10294 json_grace_recv
= json_object_new_object();
10296 if (p
->status
== Established
) {
10297 FOREACH_AFI_SAFI (afi
, safi
) {
10298 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10299 PEER_STATUS_EOR_SEND
)) {
10300 json_object_boolean_true_add(
10302 afi_safi_print(afi
,
10304 eor_send_af_count
++;
10307 FOREACH_AFI_SAFI (afi
, safi
) {
10309 p
->af_sflags
[afi
][safi
],
10310 PEER_STATUS_EOR_RECEIVED
)) {
10311 json_object_boolean_true_add(
10313 afi_safi_print(afi
,
10315 eor_receive_af_count
++;
10320 json_object_object_add(json_grace
, "endOfRibSend",
10322 json_object_object_add(json_grace
, "endOfRibRecv",
10325 if (p
->t_gr_restart
)
10326 json_object_int_add(json_grace
,
10327 "gracefulRestartTimerMsecs",
10328 thread_timer_remain_second(
10333 json_object_int_add(
10335 "gracefulStalepathTimerMsecs",
10336 thread_timer_remain_second(
10340 json_object_object_add(
10341 json_neigh
, "gracefulRestartInfo", json_grace
);
10343 vty_out(vty
, " Graceful restart information:\n");
10344 if (p
->status
== Established
) {
10345 vty_out(vty
, " End-of-RIB send: ");
10346 FOREACH_AFI_SAFI (afi
, safi
) {
10347 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10348 PEER_STATUS_EOR_SEND
)) {
10349 vty_out(vty
, "%s%s",
10350 eor_send_af_count
? ", "
10352 afi_safi_print(afi
,
10354 eor_send_af_count
++;
10357 vty_out(vty
, "\n");
10358 vty_out(vty
, " End-of-RIB received: ");
10359 FOREACH_AFI_SAFI (afi
, safi
) {
10361 p
->af_sflags
[afi
][safi
],
10362 PEER_STATUS_EOR_RECEIVED
)) {
10363 vty_out(vty
, "%s%s",
10364 eor_receive_af_count
10367 afi_safi_print(afi
,
10369 eor_receive_af_count
++;
10372 vty_out(vty
, "\n");
10375 if (p
->t_gr_restart
)
10377 " The remaining time of restart timer is %ld\n",
10378 thread_timer_remain_second(
10383 " The remaining time of stalepath timer is %ld\n",
10384 thread_timer_remain_second(
10389 json_object
*json_stat
= NULL
;
10390 json_stat
= json_object_new_object();
10391 /* Packet counts. */
10392 json_object_int_add(json_stat
, "depthInq", 0);
10393 json_object_int_add(json_stat
, "depthOutq",
10394 (unsigned long)p
->obuf
->count
);
10395 json_object_int_add(json_stat
, "opensSent",
10396 atomic_load_explicit(&p
->open_out
,
10397 memory_order_relaxed
));
10398 json_object_int_add(json_stat
, "opensRecv",
10399 atomic_load_explicit(&p
->open_in
,
10400 memory_order_relaxed
));
10401 json_object_int_add(json_stat
, "notificationsSent",
10402 atomic_load_explicit(&p
->notify_out
,
10403 memory_order_relaxed
));
10404 json_object_int_add(json_stat
, "notificationsRecv",
10405 atomic_load_explicit(&p
->notify_in
,
10406 memory_order_relaxed
));
10407 json_object_int_add(json_stat
, "updatesSent",
10408 atomic_load_explicit(&p
->update_out
,
10409 memory_order_relaxed
));
10410 json_object_int_add(json_stat
, "updatesRecv",
10411 atomic_load_explicit(&p
->update_in
,
10412 memory_order_relaxed
));
10413 json_object_int_add(json_stat
, "keepalivesSent",
10414 atomic_load_explicit(&p
->keepalive_out
,
10415 memory_order_relaxed
));
10416 json_object_int_add(json_stat
, "keepalivesRecv",
10417 atomic_load_explicit(&p
->keepalive_in
,
10418 memory_order_relaxed
));
10419 json_object_int_add(json_stat
, "routeRefreshSent",
10420 atomic_load_explicit(&p
->refresh_out
,
10421 memory_order_relaxed
));
10422 json_object_int_add(json_stat
, "routeRefreshRecv",
10423 atomic_load_explicit(&p
->refresh_in
,
10424 memory_order_relaxed
));
10425 json_object_int_add(json_stat
, "capabilitySent",
10426 atomic_load_explicit(&p
->dynamic_cap_out
,
10427 memory_order_relaxed
));
10428 json_object_int_add(json_stat
, "capabilityRecv",
10429 atomic_load_explicit(&p
->dynamic_cap_in
,
10430 memory_order_relaxed
));
10431 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10432 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10433 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10435 /* Packet counts. */
10436 vty_out(vty
, " Message statistics:\n");
10437 vty_out(vty
, " Inq depth is 0\n");
10438 vty_out(vty
, " Outq depth is %lu\n",
10439 (unsigned long)p
->obuf
->count
);
10440 vty_out(vty
, " Sent Rcvd\n");
10441 vty_out(vty
, " Opens: %10d %10d\n",
10442 atomic_load_explicit(&p
->open_out
,
10443 memory_order_relaxed
),
10444 atomic_load_explicit(&p
->open_in
,
10445 memory_order_relaxed
));
10446 vty_out(vty
, " Notifications: %10d %10d\n",
10447 atomic_load_explicit(&p
->notify_out
,
10448 memory_order_relaxed
),
10449 atomic_load_explicit(&p
->notify_in
,
10450 memory_order_relaxed
));
10451 vty_out(vty
, " Updates: %10d %10d\n",
10452 atomic_load_explicit(&p
->update_out
,
10453 memory_order_relaxed
),
10454 atomic_load_explicit(&p
->update_in
,
10455 memory_order_relaxed
));
10456 vty_out(vty
, " Keepalives: %10d %10d\n",
10457 atomic_load_explicit(&p
->keepalive_out
,
10458 memory_order_relaxed
),
10459 atomic_load_explicit(&p
->keepalive_in
,
10460 memory_order_relaxed
));
10461 vty_out(vty
, " Route Refresh: %10d %10d\n",
10462 atomic_load_explicit(&p
->refresh_out
,
10463 memory_order_relaxed
),
10464 atomic_load_explicit(&p
->refresh_in
,
10465 memory_order_relaxed
));
10466 vty_out(vty
, " Capability: %10d %10d\n",
10467 atomic_load_explicit(&p
->dynamic_cap_out
,
10468 memory_order_relaxed
),
10469 atomic_load_explicit(&p
->dynamic_cap_in
,
10470 memory_order_relaxed
));
10471 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10476 /* advertisement-interval */
10477 json_object_int_add(json_neigh
,
10478 "minBtwnAdvertisementRunsTimerMsecs",
10479 p
->v_routeadv
* 1000);
10481 /* Update-source. */
10482 if (p
->update_if
|| p
->update_source
) {
10484 json_object_string_add(json_neigh
,
10487 else if (p
->update_source
)
10488 json_object_string_add(
10489 json_neigh
, "updateSource",
10490 sockunion2str(p
->update_source
, buf1
,
10494 /* advertisement-interval */
10496 " Minimum time between advertisement runs is %d seconds\n",
10499 /* Update-source. */
10500 if (p
->update_if
|| p
->update_source
) {
10501 vty_out(vty
, " Update source is ");
10503 vty_out(vty
, "%s", p
->update_if
);
10504 else if (p
->update_source
)
10506 sockunion2str(p
->update_source
, buf1
,
10508 vty_out(vty
, "\n");
10511 vty_out(vty
, "\n");
10514 /* Address Family Information */
10515 json_object
*json_hold
= NULL
;
10518 json_hold
= json_object_new_object();
10520 FOREACH_AFI_SAFI (afi
, safi
)
10521 if (p
->afc
[afi
][safi
])
10522 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10526 json_object_object_add(json_neigh
, "addressFamilyInfo",
10528 json_object_int_add(json_neigh
, "connectionsEstablished",
10530 json_object_int_add(json_neigh
, "connectionsDropped",
10533 vty_out(vty
, " Connections established %d; dropped %d\n",
10534 p
->established
, p
->dropped
);
10536 if (!p
->last_reset
) {
10538 json_object_string_add(json_neigh
, "lastReset",
10541 vty_out(vty
, " Last reset never\n");
10547 uptime
= bgp_clock();
10548 uptime
-= p
->resettime
;
10549 tm
= gmtime(&uptime
);
10550 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10551 (tm
->tm_sec
* 1000)
10552 + (tm
->tm_min
* 60000)
10553 + (tm
->tm_hour
* 3600000));
10554 json_object_string_add(
10555 json_neigh
, "lastResetDueTo",
10556 peer_down_str
[(int)p
->last_reset
]);
10557 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10558 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10559 char errorcodesubcode_hexstr
[5];
10560 char errorcodesubcode_str
[256];
10562 code_str
= bgp_notify_code_str(p
->notify
.code
);
10563 subcode_str
= bgp_notify_subcode_str(
10564 p
->notify
.code
, p
->notify
.subcode
);
10566 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10567 p
->notify
.code
, p
->notify
.subcode
);
10568 json_object_string_add(json_neigh
,
10569 "lastErrorCodeSubcode",
10570 errorcodesubcode_hexstr
);
10571 snprintf(errorcodesubcode_str
, 255, "%s%s",
10572 code_str
, subcode_str
);
10573 json_object_string_add(json_neigh
,
10574 "lastNotificationReason",
10575 errorcodesubcode_str
);
10576 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10577 && p
->notify
.code
== BGP_NOTIFY_CEASE
10578 && (p
->notify
.subcode
10579 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10580 || p
->notify
.subcode
10581 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10582 && p
->notify
.length
) {
10584 const char *msg_str
;
10586 msg_str
= bgp_notify_admin_message(
10587 msgbuf
, sizeof(msgbuf
),
10588 (uint8_t *)p
->notify
.data
,
10591 json_object_string_add(
10593 "lastShutdownDescription",
10598 vty_out(vty
, " Last reset %s, ",
10599 peer_uptime(p
->resettime
, timebuf
,
10600 BGP_UPTIME_LEN
, 0, NULL
));
10602 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10603 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10604 code_str
= bgp_notify_code_str(p
->notify
.code
);
10605 subcode_str
= bgp_notify_subcode_str(
10606 p
->notify
.code
, p
->notify
.subcode
);
10607 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10608 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10611 code_str
, subcode_str
);
10612 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10613 && p
->notify
.code
== BGP_NOTIFY_CEASE
10614 && (p
->notify
.subcode
10615 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10616 || p
->notify
.subcode
10617 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10618 && p
->notify
.length
) {
10620 const char *msg_str
;
10622 msg_str
= bgp_notify_admin_message(
10623 msgbuf
, sizeof(msgbuf
),
10624 (uint8_t *)p
->notify
.data
,
10628 " Message: \"%s\"\n",
10632 vty_out(vty
, "due to %s\n",
10633 peer_down_str
[(int)p
->last_reset
]);
10636 if (p
->last_reset_cause_size
) {
10637 msg
= p
->last_reset_cause
;
10639 " Message received that caused BGP to send a NOTIFICATION:\n ");
10640 for (i
= 1; i
<= p
->last_reset_cause_size
;
10642 vty_out(vty
, "%02X", *msg
++);
10644 if (i
!= p
->last_reset_cause_size
) {
10646 vty_out(vty
, "\n ");
10647 } else if (i
% 4 == 0) {
10652 vty_out(vty
, "\n");
10657 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10659 json_object_boolean_true_add(json_neigh
,
10660 "prefixesConfigExceedMax");
10663 " Peer had exceeded the max. no. of prefixes configured.\n");
10665 if (p
->t_pmax_restart
) {
10667 json_object_boolean_true_add(
10668 json_neigh
, "reducePrefixNumFrom");
10669 json_object_int_add(json_neigh
,
10670 "restartInTimerMsec",
10671 thread_timer_remain_second(
10676 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10677 p
->host
, thread_timer_remain_second(
10678 p
->t_pmax_restart
));
10681 json_object_boolean_true_add(
10683 "reducePrefixNumAndClearIpBgp");
10686 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10691 /* EBGP Multihop and GTSM */
10692 if (p
->sort
!= BGP_PEER_IBGP
) {
10694 if (p
->gtsm_hops
> 0)
10695 json_object_int_add(json_neigh
,
10696 "externalBgpNbrMaxHopsAway",
10698 else if (p
->ttl
> 1)
10699 json_object_int_add(json_neigh
,
10700 "externalBgpNbrMaxHopsAway",
10703 if (p
->gtsm_hops
> 0)
10705 " External BGP neighbor may be up to %d hops away.\n",
10707 else if (p
->ttl
> 1)
10709 " External BGP neighbor may be up to %d hops away.\n",
10713 if (p
->gtsm_hops
> 0) {
10715 json_object_int_add(json_neigh
,
10716 "internalBgpNbrMaxHopsAway",
10720 " Internal BGP neighbor may be up to %d hops away.\n",
10725 /* Local address. */
10728 json_object_string_add(json_neigh
, "hostLocal",
10729 sockunion2str(p
->su_local
, buf1
,
10731 json_object_int_add(json_neigh
, "portLocal",
10732 ntohs(p
->su_local
->sin
.sin_port
));
10734 vty_out(vty
, "Local host: %s, Local port: %d\n",
10735 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10736 ntohs(p
->su_local
->sin
.sin_port
));
10739 /* Remote address. */
10740 if (p
->su_remote
) {
10742 json_object_string_add(json_neigh
, "hostForeign",
10743 sockunion2str(p
->su_remote
, buf1
,
10745 json_object_int_add(json_neigh
, "portForeign",
10746 ntohs(p
->su_remote
->sin
.sin_port
));
10748 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10749 sockunion2str(p
->su_remote
, buf1
,
10751 ntohs(p
->su_remote
->sin
.sin_port
));
10754 /* Nexthop display. */
10757 json_object_string_add(json_neigh
, "nexthop",
10759 &p
->nexthop
.v4
, buf1
,
10761 json_object_string_add(json_neigh
, "nexthopGlobal",
10762 inet_ntop(AF_INET6
,
10763 &p
->nexthop
.v6_global
,
10764 buf1
, sizeof(buf1
)));
10765 json_object_string_add(json_neigh
, "nexthopLocal",
10766 inet_ntop(AF_INET6
,
10767 &p
->nexthop
.v6_local
,
10768 buf1
, sizeof(buf1
)));
10769 if (p
->shared_network
)
10770 json_object_string_add(json_neigh
,
10774 json_object_string_add(json_neigh
,
10776 "nonSharedNetwork");
10778 vty_out(vty
, "Nexthop: %s\n",
10779 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10781 vty_out(vty
, "Nexthop global: %s\n",
10782 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10784 vty_out(vty
, "Nexthop local: %s\n",
10785 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10787 vty_out(vty
, "BGP connection: %s\n",
10788 p
->shared_network
? "shared network"
10789 : "non shared network");
10793 /* Timer information. */
10795 json_object_int_add(json_neigh
, "connectRetryTimer",
10797 if (p
->status
== Established
&& p
->rtt
)
10798 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10801 json_object_int_add(
10802 json_neigh
, "nextStartTimerDueInMsecs",
10803 thread_timer_remain_second(p
->t_start
) * 1000);
10805 json_object_int_add(
10806 json_neigh
, "nextConnectTimerDueInMsecs",
10807 thread_timer_remain_second(p
->t_connect
)
10809 if (p
->t_routeadv
) {
10810 json_object_int_add(json_neigh
, "mraiInterval",
10812 json_object_int_add(
10813 json_neigh
, "mraiTimerExpireInMsecs",
10814 thread_timer_remain_second(p
->t_routeadv
)
10818 json_object_int_add(json_neigh
, "authenticationEnabled",
10822 json_object_string_add(json_neigh
, "readThread", "on");
10824 json_object_string_add(json_neigh
, "readThread", "off");
10826 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10827 json_object_string_add(json_neigh
, "writeThread", "on");
10829 json_object_string_add(json_neigh
, "writeThread",
10832 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10834 if (p
->status
== Established
&& p
->rtt
)
10835 vty_out(vty
, "Estimated round trip time: %d ms\n",
10838 vty_out(vty
, "Next start timer due in %ld seconds\n",
10839 thread_timer_remain_second(p
->t_start
));
10841 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10842 thread_timer_remain_second(p
->t_connect
));
10845 "MRAI (interval %u) timer expires in %ld seconds\n",
10847 thread_timer_remain_second(p
->t_routeadv
));
10849 vty_out(vty
, "Peer Authentication Enabled\n");
10851 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
10852 p
->t_read
? "on" : "off",
10853 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10858 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10859 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10860 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10863 vty_out(vty
, "\n");
10865 /* BFD information. */
10866 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10869 if (p
->conf_if
) /* Configured interface name. */
10870 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10871 else /* Configured IP address. */
10872 json_object_object_add(json
, p
->host
, json_neigh
);
10876 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10877 enum show_type type
, union sockunion
*su
,
10878 const char *conf_if
, bool use_json
,
10881 struct listnode
*node
, *nnode
;
10884 bool nbr_output
= false;
10885 afi_t afi
= AFI_MAX
;
10886 safi_t safi
= SAFI_MAX
;
10888 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
10890 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
10894 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10895 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10900 bgp_show_peer(vty
, peer
, use_json
, json
);
10906 && !strcmp(peer
->conf_if
, conf_if
))
10908 && !strcmp(peer
->hostname
, conf_if
))) {
10910 bgp_show_peer(vty
, peer
, use_json
,
10914 if (sockunion_same(&peer
->su
, su
)) {
10916 bgp_show_peer(vty
, peer
, use_json
,
10921 case show_ipv4_peer
:
10922 case show_ipv6_peer
:
10923 FOREACH_SAFI (safi
) {
10924 if (peer
->afc
[afi
][safi
]) {
10927 && !strcmp(peer
->conf_if
, conf_if
))
10929 && !strcmp(peer
->hostname
, conf_if
))) {
10931 bgp_show_peer(vty
, peer
, use_json
,
10936 if (sockunion_same(&peer
->su
, su
)) {
10938 bgp_show_peer(vty
, peer
, use_json
,
10946 case show_ipv4_all
:
10947 case show_ipv6_all
:
10948 FOREACH_SAFI (safi
) {
10949 if (peer
->afc
[afi
][safi
]) {
10950 bgp_show_peer(vty
, peer
, use_json
, json
);
10959 if ((type
== show_peer
|| type
== show_ipv4_peer
||
10960 type
== show_ipv6_peer
) && !find
) {
10962 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
10964 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
10967 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
10968 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
10969 vty_out(vty
, "%% No BGP neighbors found\n");
10972 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10973 json
, JSON_C_TO_STRING_PRETTY
));
10975 vty_out(vty
, "\n");
10978 return CMD_SUCCESS
;
10981 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
10982 enum show_type type
,
10983 const char *ip_str
,
10986 struct listnode
*node
, *nnode
;
10988 union sockunion su
;
10989 json_object
*json
= NULL
;
10990 int ret
, is_first
= 1;
10991 bool nbr_output
= false;
10994 vty_out(vty
, "{\n");
10996 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
10999 if (!(json
= json_object_new_object())) {
11001 EC_BGP_JSON_MEM_ERROR
,
11002 "Unable to allocate memory for JSON object");
11004 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
11008 json_object_int_add(json
, "vrfId",
11009 (bgp
->vrf_id
== VRF_UNKNOWN
)
11011 : (int64_t)bgp
->vrf_id
);
11012 json_object_string_add(
11014 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11019 vty_out(vty
, ",\n");
11023 vty_out(vty
, "\"%s\":",
11024 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11028 vty_out(vty
, "\nInstance %s:\n",
11029 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11034 if (type
== show_peer
|| type
== show_ipv4_peer
||
11035 type
== show_ipv6_peer
) {
11036 ret
= str2sockunion(ip_str
, &su
);
11038 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11041 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11044 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
11047 json_object_free(json
);
11051 vty_out(vty
, "}\n");
11052 json_object_free(json
);
11054 else if (!nbr_output
)
11055 vty_out(vty
, "%% BGP instance not found\n");
11058 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
11059 enum show_type type
, const char *ip_str
,
11064 union sockunion su
;
11065 json_object
*json
= NULL
;
11068 if (strmatch(name
, "all")) {
11069 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
11071 return CMD_SUCCESS
;
11073 bgp
= bgp_lookup_by_name(name
);
11076 json
= json_object_new_object();
11077 vty_out(vty
, "%s\n",
11078 json_object_to_json_string_ext(
11080 JSON_C_TO_STRING_PRETTY
));
11081 json_object_free(json
);
11084 "%% BGP instance not found\n");
11086 return CMD_WARNING
;
11090 bgp
= bgp_get_default();
11094 json
= json_object_new_object();
11096 ret
= str2sockunion(ip_str
, &su
);
11098 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11101 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11104 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
11107 json_object_free(json
);
11110 vty_out(vty
, "{}\n");
11112 vty_out(vty
, "%% BGP instance not found\n");
11115 return CMD_SUCCESS
;
11118 /* "show [ip] bgp neighbors" commands. */
11119 DEFUN (show_ip_bgp_neighbors
,
11120 show_ip_bgp_neighbors_cmd
,
11121 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
11125 BGP_INSTANCE_HELP_STR
11128 "Detailed information on TCP and BGP neighbor connections\n"
11129 "Neighbor to display information about\n"
11130 "Neighbor to display information about\n"
11131 "Neighbor on BGP configured interface\n"
11135 char *sh_arg
= NULL
;
11136 enum show_type sh_type
;
11137 afi_t afi
= AFI_MAX
;
11139 bool uj
= use_json(argc
, argv
);
11143 /* [<vrf> VIEWVRFNAME] */
11144 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11145 vrf
= argv
[idx
+ 1]->arg
;
11146 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11148 } else if (argv_find(argv
, argc
, "view", &idx
))
11149 /* [<view> VIEWVRFNAME] */
11150 vrf
= argv
[idx
+ 1]->arg
;
11154 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
11155 sh_type
= show_ipv4_all
;
11157 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
11158 sh_type
= show_ipv6_all
;
11161 sh_type
= show_all
;
11164 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
11165 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
11166 || argv_find(argv
, argc
, "WORD", &idx
)) {
11167 sh_type
= show_peer
;
11168 sh_arg
= argv
[idx
]->arg
;
11171 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
11172 sh_type
= show_ipv4_peer
;
11173 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
11174 sh_type
= show_ipv6_peer
;
11177 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
11180 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
11181 paths' and `show ip mbgp paths'. Those functions results are the
11183 DEFUN (show_ip_bgp_paths
,
11184 show_ip_bgp_paths_cmd
,
11185 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
11190 "Path information\n")
11192 vty_out(vty
, "Address Refcnt Path\n");
11193 aspath_print_all_vty(vty
);
11194 return CMD_SUCCESS
;
11199 static void community_show_all_iterator(struct hash_bucket
*bucket
,
11202 struct community
*com
;
11204 com
= (struct community
*)bucket
->data
;
11205 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
11206 community_str(com
, false));
11209 /* Show BGP's community internal data. */
11210 DEFUN (show_ip_bgp_community_info
,
11211 show_ip_bgp_community_info_cmd
,
11212 "show [ip] bgp community-info",
11216 "List all bgp community information\n")
11218 vty_out(vty
, "Address Refcnt Community\n");
11220 hash_iterate(community_hash(),
11221 (void (*)(struct hash_bucket
*,
11222 void *))community_show_all_iterator
,
11225 return CMD_SUCCESS
;
11228 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
11231 struct lcommunity
*lcom
;
11233 lcom
= (struct lcommunity
*)bucket
->data
;
11234 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11235 lcommunity_str(lcom
, false));
11238 /* Show BGP's community internal data. */
11239 DEFUN (show_ip_bgp_lcommunity_info
,
11240 show_ip_bgp_lcommunity_info_cmd
,
11241 "show ip bgp large-community-info",
11245 "List all bgp large-community information\n")
11247 vty_out(vty
, "Address Refcnt Large-community\n");
11249 hash_iterate(lcommunity_hash(),
11250 (void (*)(struct hash_bucket
*,
11251 void *))lcommunity_show_all_iterator
,
11254 return CMD_SUCCESS
;
11258 DEFUN (show_ip_bgp_attr_info
,
11259 show_ip_bgp_attr_info_cmd
,
11260 "show [ip] bgp attribute-info",
11264 "List all bgp attribute information\n")
11266 attr_show_all(vty
);
11267 return CMD_SUCCESS
;
11270 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
11271 afi_t afi
, safi_t safi
,
11272 bool use_json
, json_object
*json
)
11275 struct listnode
*node
;
11277 char buf1
[INET6_ADDRSTRLEN
];
11279 vpn_policy_direction_t dir
;
11282 json_object
*json_import_vrfs
= NULL
;
11283 json_object
*json_export_vrfs
= NULL
;
11285 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11288 vty_out(vty
, "%s\n",
11289 json_object_to_json_string_ext(
11291 JSON_C_TO_STRING_PRETTY
));
11292 json_object_free(json
);
11294 return CMD_WARNING
;
11297 /* Provide context for the block */
11298 json_object_string_add(json
, "vrf", name
? name
: "default");
11299 json_object_string_add(json
, "afiSafi",
11300 afi_safi_print(afi
, safi
));
11302 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11303 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11304 json_object_string_add(json
, "importFromVrfs", "none");
11305 json_object_string_add(json
, "importRts", "none");
11307 json_import_vrfs
= json_object_new_array();
11309 for (ALL_LIST_ELEMENTS_RO(
11310 bgp
->vpn_policy
[afi
].import_vrf
,
11312 json_object_array_add(json_import_vrfs
,
11313 json_object_new_string(vname
));
11315 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11316 ecom_str
= ecommunity_ecom2str(
11317 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11318 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11319 json_object_object_add(json
, "importFromVrfs",
11321 json_object_string_add(json
, "importRts", ecom_str
);
11323 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11326 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11327 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11328 json_object_string_add(json
, "exportToVrfs", "none");
11329 json_object_string_add(json
, "routeDistinguisher",
11331 json_object_string_add(json
, "exportRts", "none");
11333 json_export_vrfs
= json_object_new_array();
11335 for (ALL_LIST_ELEMENTS_RO(
11336 bgp
->vpn_policy
[afi
].export_vrf
,
11338 json_object_array_add(json_export_vrfs
,
11339 json_object_new_string(vname
));
11340 json_object_object_add(json
, "exportToVrfs",
11342 json_object_string_add(json
, "routeDistinguisher",
11343 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11344 buf1
, RD_ADDRSTRLEN
));
11346 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11347 ecom_str
= ecommunity_ecom2str(
11348 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11349 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11350 json_object_string_add(json
, "exportRts", ecom_str
);
11352 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11356 vty_out(vty
, "%s\n",
11357 json_object_to_json_string_ext(json
,
11358 JSON_C_TO_STRING_PRETTY
));
11359 json_object_free(json
);
11362 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11365 vty_out(vty
, "%% No such BGP instance exist\n");
11366 return CMD_WARNING
;
11369 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11370 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11372 "This VRF is not importing %s routes from any other VRF\n",
11373 afi_safi_print(afi
, safi
));
11376 "This VRF is importing %s routes from the following VRFs:\n",
11377 afi_safi_print(afi
, safi
));
11379 for (ALL_LIST_ELEMENTS_RO(
11380 bgp
->vpn_policy
[afi
].import_vrf
,
11382 vty_out(vty
, " %s\n", vname
);
11384 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11385 ecom_str
= ecommunity_ecom2str(
11386 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11387 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11388 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11390 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11393 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11394 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11396 "This VRF is not exporting %s routes to any other VRF\n",
11397 afi_safi_print(afi
, safi
));
11400 "This VRF is exporting %s routes to the following VRFs:\n",
11401 afi_safi_print(afi
, safi
));
11403 for (ALL_LIST_ELEMENTS_RO(
11404 bgp
->vpn_policy
[afi
].export_vrf
,
11406 vty_out(vty
, " %s\n", vname
);
11408 vty_out(vty
, "RD: %s\n",
11409 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11410 buf1
, RD_ADDRSTRLEN
));
11412 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11413 ecom_str
= ecommunity_ecom2str(
11414 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11415 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11416 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11417 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11421 return CMD_SUCCESS
;
11424 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
11425 safi_t safi
, bool use_json
)
11427 struct listnode
*node
, *nnode
;
11429 char *vrf_name
= NULL
;
11430 json_object
*json
= NULL
;
11431 json_object
*json_vrf
= NULL
;
11432 json_object
*json_vrfs
= NULL
;
11435 json
= json_object_new_object();
11436 json_vrfs
= json_object_new_object();
11439 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11441 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
11442 vrf_name
= bgp
->name
;
11445 json_vrf
= json_object_new_object();
11447 vty_out(vty
, "\nInstance %s:\n",
11448 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11449 ? VRF_DEFAULT_NAME
: bgp
->name
);
11451 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
11453 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11454 json_object_object_add(json_vrfs
,
11455 VRF_DEFAULT_NAME
, json_vrf
);
11457 json_object_object_add(json_vrfs
, vrf_name
,
11463 json_object_object_add(json
, "vrfs", json_vrfs
);
11464 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
11465 JSON_C_TO_STRING_PRETTY
));
11466 json_object_free(json
);
11469 return CMD_SUCCESS
;
11472 /* "show [ip] bgp route-leak" command. */
11473 DEFUN (show_ip_bgp_route_leak
,
11474 show_ip_bgp_route_leak_cmd
,
11475 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11479 BGP_INSTANCE_HELP_STR
11482 "Route leaking information\n"
11486 afi_t afi
= AFI_MAX
;
11487 safi_t safi
= SAFI_MAX
;
11489 bool uj
= use_json(argc
, argv
);
11491 json_object
*json
= NULL
;
11493 /* show [ip] bgp */
11494 if (argv_find(argv
, argc
, "ip", &idx
)) {
11496 safi
= SAFI_UNICAST
;
11498 /* [vrf VIEWVRFNAME] */
11499 if (argv_find(argv
, argc
, "view", &idx
)) {
11501 "%% This command is not applicable to BGP views\n");
11502 return CMD_WARNING
;
11505 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11506 vrf
= argv
[idx
+ 1]->arg
;
11507 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11510 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11511 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11512 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11515 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11517 "%% This command is applicable only for unicast ipv4|ipv6\n");
11518 return CMD_WARNING
;
11521 if (vrf
&& strmatch(vrf
, "all"))
11522 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
11525 json
= json_object_new_object();
11527 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
11530 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11533 struct listnode
*node
, *nnode
;
11536 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11537 vty_out(vty
, "\nInstance %s:\n",
11538 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11541 update_group_show(bgp
, afi
, safi
, vty
, 0);
11545 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11546 int safi
, uint64_t subgrp_id
)
11551 if (strmatch(name
, "all")) {
11552 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11553 return CMD_SUCCESS
;
11555 bgp
= bgp_lookup_by_name(name
);
11558 bgp
= bgp_get_default();
11562 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11563 return CMD_SUCCESS
;
11566 DEFUN (show_ip_bgp_updgrps
,
11567 show_ip_bgp_updgrps_cmd
,
11568 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11572 BGP_INSTANCE_HELP_STR
11574 BGP_SAFI_WITH_LABEL_HELP_STR
11575 "Detailed info about dynamic update groups\n"
11576 "Specific subgroup to display detailed info for\n")
11579 afi_t afi
= AFI_IP6
;
11580 safi_t safi
= SAFI_UNICAST
;
11581 uint64_t subgrp_id
= 0;
11585 /* show [ip] bgp */
11586 if (argv_find(argv
, argc
, "ip", &idx
))
11588 /* [<vrf> VIEWVRFNAME] */
11589 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11590 vrf
= argv
[idx
+ 1]->arg
;
11591 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11593 } else if (argv_find(argv
, argc
, "view", &idx
))
11594 /* [<view> VIEWVRFNAME] */
11595 vrf
= argv
[idx
+ 1]->arg
;
11596 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11597 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11598 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11601 /* get subgroup id, if provided */
11603 if (argv
[idx
]->type
== VARIABLE_TKN
)
11604 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11606 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11609 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11610 show_bgp_instance_all_ipv6_updgrps_cmd
,
11611 "show [ip] bgp <view|vrf> all update-groups",
11615 BGP_INSTANCE_ALL_HELP_STR
11616 "Detailed info about dynamic update groups\n")
11618 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11619 return CMD_SUCCESS
;
11622 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
11623 show_bgp_l2vpn_evpn_updgrps_cmd
,
11624 "show [ip] bgp l2vpn evpn update-groups",
11628 "l2vpn address family\n"
11629 "evpn sub-address family\n"
11630 "Detailed info about dynamic update groups\n")
11633 uint64_t subgrp_id
= 0;
11635 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
11636 return CMD_SUCCESS
;
11639 DEFUN (show_bgp_updgrps_stats
,
11640 show_bgp_updgrps_stats_cmd
,
11641 "show [ip] bgp update-groups statistics",
11645 "Detailed info about dynamic update groups\n"
11650 bgp
= bgp_get_default();
11652 update_group_show_stats(bgp
, vty
);
11654 return CMD_SUCCESS
;
11657 DEFUN (show_bgp_instance_updgrps_stats
,
11658 show_bgp_instance_updgrps_stats_cmd
,
11659 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11663 BGP_INSTANCE_HELP_STR
11664 "Detailed info about dynamic update groups\n"
11670 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11672 update_group_show_stats(bgp
, vty
);
11674 return CMD_SUCCESS
;
11677 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11678 afi_t afi
, safi_t safi
,
11679 const char *what
, uint64_t subgrp_id
)
11684 bgp
= bgp_lookup_by_name(name
);
11686 bgp
= bgp_get_default();
11689 if (!strcmp(what
, "advertise-queue"))
11690 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11692 else if (!strcmp(what
, "advertised-routes"))
11693 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11695 else if (!strcmp(what
, "packet-queue"))
11696 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11701 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11702 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11703 "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",
11704 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11706 "Detailed info about dynamic update groups\n"
11707 "Specific subgroup to display info for\n"
11708 "Advertisement queue\n"
11709 "Announced routes\n"
11712 uint64_t subgrp_id
= 0;
11716 subgrp_id
= strtoull(sgid
, NULL
, 10);
11721 afiz
= bgp_vty_afi_from_str(afi
);
11725 afiz
= bgp_vty_afi_from_str(afi
);
11726 if (afiz
!= AFI_IP
)
11728 "%% Cannot specify both 'ip' and 'ipv6'\n");
11729 return CMD_WARNING
;
11732 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11734 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11735 return CMD_SUCCESS
;
11738 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11740 struct listnode
*node
, *nnode
;
11741 struct prefix
*range
;
11744 char buf
[PREFIX2STR_BUFFER
];
11747 const char *peer_status
;
11748 const char *af_str
;
11753 conf
= group
->conf
;
11755 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11756 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11757 group
->name
, conf
->as
);
11758 } else if (conf
->as_type
== AS_INTERNAL
) {
11759 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11760 group
->name
, group
->bgp
->as
);
11762 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11765 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11766 vty_out(vty
, " Peer-group type is internal\n");
11768 vty_out(vty
, " Peer-group type is external\n");
11770 /* Display AFs configured. */
11771 vty_out(vty
, " Configured address-families:");
11772 FOREACH_AFI_SAFI (afi
, safi
) {
11773 if (conf
->afc
[afi
][safi
]) {
11775 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11779 vty_out(vty
, " none\n");
11781 vty_out(vty
, "\n");
11783 /* Display listen ranges (for dynamic neighbors), if any */
11784 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11787 else if (afi
== AFI_IP6
)
11791 lr_count
= listcount(group
->listen_range
[afi
]);
11793 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11797 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11799 prefix2str(range
, buf
, sizeof(buf
));
11800 vty_out(vty
, " %s\n", buf
);
11805 /* Display group members and their status */
11806 if (listcount(group
->peer
)) {
11807 vty_out(vty
, " Peer-group members:\n");
11808 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11809 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11810 peer_status
= "Idle (Admin)";
11811 else if (CHECK_FLAG(peer
->sflags
,
11812 PEER_STATUS_PREFIX_OVERFLOW
))
11813 peer_status
= "Idle (PfxCt)";
11815 peer_status
= lookup_msg(bgp_status_msg
,
11816 peer
->status
, NULL
);
11818 dynamic
= peer_dynamic_neighbor(peer
);
11819 vty_out(vty
, " %s %s %s \n", peer
->host
,
11820 dynamic
? "(dynamic)" : "", peer_status
);
11824 return CMD_SUCCESS
;
11827 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11828 const char *group_name
)
11831 struct listnode
*node
, *nnode
;
11832 struct peer_group
*group
;
11833 bool found
= false;
11835 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11838 vty_out(vty
, "%% BGP instance not found\n");
11839 return CMD_WARNING
;
11842 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11844 if (strmatch(group
->name
, group_name
)) {
11845 bgp_show_one_peer_group(vty
, group
);
11850 bgp_show_one_peer_group(vty
, group
);
11854 if (group_name
&& !found
)
11855 vty_out(vty
, "%% No such peer-group\n");
11857 return CMD_SUCCESS
;
11860 DEFUN (show_ip_bgp_peer_groups
,
11861 show_ip_bgp_peer_groups_cmd
,
11862 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11866 BGP_INSTANCE_HELP_STR
11867 "Detailed information on BGP peer groups\n"
11868 "Peer group name\n")
11873 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11875 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11877 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11881 /* Redistribute VTY commands. */
11883 DEFUN (bgp_redistribute_ipv4
,
11884 bgp_redistribute_ipv4_cmd
,
11885 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11886 "Redistribute information from another routing protocol\n"
11887 FRR_IP_REDIST_HELP_STR_BGPD
)
11889 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11890 int idx_protocol
= 1;
11893 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11895 vty_out(vty
, "%% Invalid route type\n");
11896 return CMD_WARNING_CONFIG_FAILED
;
11899 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11900 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
11904 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11905 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11906 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11908 DEFUN (bgp_redistribute_ipv4_rmap
,
11909 bgp_redistribute_ipv4_rmap_cmd
,
11910 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11911 "Redistribute information from another routing protocol\n"
11912 FRR_IP_REDIST_HELP_STR_BGPD
11913 "Route map reference\n"
11914 "Pointer to route-map entries\n")
11916 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11917 int idx_protocol
= 1;
11920 struct bgp_redist
*red
;
11922 struct route_map
*route_map
= route_map_lookup_warn_noexist(
11923 vty
, argv
[idx_word
]->arg
);
11925 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11927 vty_out(vty
, "%% Invalid route type\n");
11928 return CMD_WARNING_CONFIG_FAILED
;
11931 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11933 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
11934 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11938 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
11939 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11940 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11941 "Route map reference\n"
11942 "Pointer to route-map entries\n")
11944 DEFUN (bgp_redistribute_ipv4_metric
,
11945 bgp_redistribute_ipv4_metric_cmd
,
11946 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11947 "Redistribute information from another routing protocol\n"
11948 FRR_IP_REDIST_HELP_STR_BGPD
11949 "Metric for redistributed routes\n"
11950 "Default metric\n")
11952 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11953 int idx_protocol
= 1;
11954 int idx_number
= 3;
11957 struct bgp_redist
*red
;
11960 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11962 vty_out(vty
, "%% Invalid route type\n");
11963 return CMD_WARNING_CONFIG_FAILED
;
11965 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11967 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11968 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11969 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11973 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
11974 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11975 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11976 "Metric for redistributed routes\n"
11977 "Default metric\n")
11979 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
11980 bgp_redistribute_ipv4_rmap_metric_cmd
,
11981 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11982 "Redistribute information from another routing protocol\n"
11983 FRR_IP_REDIST_HELP_STR_BGPD
11984 "Route map reference\n"
11985 "Pointer to route-map entries\n"
11986 "Metric for redistributed routes\n"
11987 "Default metric\n")
11989 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11990 int idx_protocol
= 1;
11992 int idx_number
= 5;
11995 struct bgp_redist
*red
;
11997 struct route_map
*route_map
=
11998 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12000 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12002 vty_out(vty
, "%% Invalid route type\n");
12003 return CMD_WARNING_CONFIG_FAILED
;
12005 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12007 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12009 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12010 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12011 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12015 bgp_redistribute_ipv4_rmap_metric
,
12016 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
12017 "redistribute " FRR_IP_REDIST_STR_BGPD
12018 " route-map WORD metric (0-4294967295)",
12019 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12020 "Route map reference\n"
12021 "Pointer to route-map entries\n"
12022 "Metric for redistributed routes\n"
12023 "Default metric\n")
12025 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
12026 bgp_redistribute_ipv4_metric_rmap_cmd
,
12027 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12028 "Redistribute information from another routing protocol\n"
12029 FRR_IP_REDIST_HELP_STR_BGPD
12030 "Metric for redistributed routes\n"
12032 "Route map reference\n"
12033 "Pointer to route-map entries\n")
12035 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12036 int idx_protocol
= 1;
12037 int idx_number
= 3;
12041 struct bgp_redist
*red
;
12043 struct route_map
*route_map
=
12044 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12046 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12048 vty_out(vty
, "%% Invalid route type\n");
12049 return CMD_WARNING_CONFIG_FAILED
;
12051 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12053 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12054 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12056 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12057 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12061 bgp_redistribute_ipv4_metric_rmap
,
12062 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
12063 "redistribute " FRR_IP_REDIST_STR_BGPD
12064 " metric (0-4294967295) route-map WORD",
12065 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12066 "Metric for redistributed routes\n"
12068 "Route map reference\n"
12069 "Pointer to route-map entries\n")
12071 DEFUN (bgp_redistribute_ipv4_ospf
,
12072 bgp_redistribute_ipv4_ospf_cmd
,
12073 "redistribute <ospf|table> (1-65535)",
12074 "Redistribute information from another routing protocol\n"
12075 "Open Shortest Path First (OSPFv2)\n"
12076 "Non-main Kernel Routing Table\n"
12077 "Instance ID/Table ID\n")
12079 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12080 int idx_ospf_table
= 1;
12081 int idx_number
= 2;
12082 unsigned short instance
;
12083 unsigned short protocol
;
12085 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12087 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12088 protocol
= ZEBRA_ROUTE_OSPF
;
12090 protocol
= ZEBRA_ROUTE_TABLE
;
12092 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12093 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
12096 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
12097 "redistribute <ospf|table> (1-65535)",
12098 "Redistribute information from another routing protocol\n"
12099 "Open Shortest Path First (OSPFv2)\n"
12100 "Non-main Kernel Routing Table\n"
12101 "Instance ID/Table ID\n")
12103 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
12104 bgp_redistribute_ipv4_ospf_rmap_cmd
,
12105 "redistribute <ospf|table> (1-65535) route-map WORD",
12106 "Redistribute information from another routing protocol\n"
12107 "Open Shortest Path First (OSPFv2)\n"
12108 "Non-main Kernel Routing Table\n"
12109 "Instance ID/Table ID\n"
12110 "Route map reference\n"
12111 "Pointer to route-map entries\n")
12113 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12114 int idx_ospf_table
= 1;
12115 int idx_number
= 2;
12117 struct bgp_redist
*red
;
12118 unsigned short instance
;
12121 struct route_map
*route_map
=
12122 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12124 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12125 protocol
= ZEBRA_ROUTE_OSPF
;
12127 protocol
= ZEBRA_ROUTE_TABLE
;
12129 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12130 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12132 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12133 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12136 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
12137 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
12138 "redistribute <ospf|table> (1-65535) route-map WORD",
12139 "Redistribute information from another routing protocol\n"
12140 "Open Shortest Path First (OSPFv2)\n"
12141 "Non-main Kernel Routing Table\n"
12142 "Instance ID/Table ID\n"
12143 "Route map reference\n"
12144 "Pointer to route-map entries\n")
12146 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
12147 bgp_redistribute_ipv4_ospf_metric_cmd
,
12148 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12149 "Redistribute information from another routing protocol\n"
12150 "Open Shortest Path First (OSPFv2)\n"
12151 "Non-main Kernel Routing Table\n"
12152 "Instance ID/Table ID\n"
12153 "Metric for redistributed routes\n"
12154 "Default metric\n")
12156 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12157 int idx_ospf_table
= 1;
12158 int idx_number
= 2;
12159 int idx_number_2
= 4;
12161 struct bgp_redist
*red
;
12162 unsigned short instance
;
12166 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12167 protocol
= ZEBRA_ROUTE_OSPF
;
12169 protocol
= ZEBRA_ROUTE_TABLE
;
12171 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12172 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12174 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12175 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12177 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12180 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
12181 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
12182 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12183 "Redistribute information from another routing protocol\n"
12184 "Open Shortest Path First (OSPFv2)\n"
12185 "Non-main Kernel Routing Table\n"
12186 "Instance ID/Table ID\n"
12187 "Metric for redistributed routes\n"
12188 "Default metric\n")
12190 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
12191 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
12192 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12193 "Redistribute information from another routing protocol\n"
12194 "Open Shortest Path First (OSPFv2)\n"
12195 "Non-main Kernel Routing Table\n"
12196 "Instance ID/Table ID\n"
12197 "Route map reference\n"
12198 "Pointer to route-map entries\n"
12199 "Metric for redistributed routes\n"
12200 "Default metric\n")
12202 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12203 int idx_ospf_table
= 1;
12204 int idx_number
= 2;
12206 int idx_number_2
= 6;
12208 struct bgp_redist
*red
;
12209 unsigned short instance
;
12212 struct route_map
*route_map
=
12213 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12215 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12216 protocol
= ZEBRA_ROUTE_OSPF
;
12218 protocol
= ZEBRA_ROUTE_TABLE
;
12220 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12221 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12223 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12225 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12226 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12228 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12232 bgp_redistribute_ipv4_ospf_rmap_metric
,
12233 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
12234 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12235 "Redistribute information from another routing protocol\n"
12236 "Open Shortest Path First (OSPFv2)\n"
12237 "Non-main Kernel Routing Table\n"
12238 "Instance ID/Table ID\n"
12239 "Route map reference\n"
12240 "Pointer to route-map entries\n"
12241 "Metric for redistributed routes\n"
12242 "Default metric\n")
12244 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
12245 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
12246 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12247 "Redistribute information from another routing protocol\n"
12248 "Open Shortest Path First (OSPFv2)\n"
12249 "Non-main Kernel Routing Table\n"
12250 "Instance ID/Table ID\n"
12251 "Metric for redistributed routes\n"
12253 "Route map reference\n"
12254 "Pointer to route-map entries\n")
12256 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12257 int idx_ospf_table
= 1;
12258 int idx_number
= 2;
12259 int idx_number_2
= 4;
12262 struct bgp_redist
*red
;
12263 unsigned short instance
;
12266 struct route_map
*route_map
=
12267 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12269 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12270 protocol
= ZEBRA_ROUTE_OSPF
;
12272 protocol
= ZEBRA_ROUTE_TABLE
;
12274 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12275 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12277 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12278 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12281 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12282 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12286 bgp_redistribute_ipv4_ospf_metric_rmap
,
12287 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
12288 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12289 "Redistribute information from another routing protocol\n"
12290 "Open Shortest Path First (OSPFv2)\n"
12291 "Non-main Kernel Routing Table\n"
12292 "Instance ID/Table ID\n"
12293 "Metric for redistributed routes\n"
12295 "Route map reference\n"
12296 "Pointer to route-map entries\n")
12298 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12299 no_bgp_redistribute_ipv4_ospf_cmd
,
12300 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12302 "Redistribute information from another routing protocol\n"
12303 "Open Shortest Path First (OSPFv2)\n"
12304 "Non-main Kernel Routing Table\n"
12305 "Instance ID/Table ID\n"
12306 "Metric for redistributed routes\n"
12308 "Route map reference\n"
12309 "Pointer to route-map entries\n")
12311 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12312 int idx_ospf_table
= 2;
12313 int idx_number
= 3;
12314 unsigned short instance
;
12317 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12318 protocol
= ZEBRA_ROUTE_OSPF
;
12320 protocol
= ZEBRA_ROUTE_TABLE
;
12322 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12323 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12327 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12328 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12330 "Redistribute information from another routing protocol\n"
12331 "Open Shortest Path First (OSPFv2)\n"
12332 "Non-main Kernel Routing Table\n"
12333 "Instance ID/Table ID\n"
12334 "Metric for redistributed routes\n"
12336 "Route map reference\n"
12337 "Pointer to route-map entries\n")
12339 DEFUN (no_bgp_redistribute_ipv4
,
12340 no_bgp_redistribute_ipv4_cmd
,
12341 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12343 "Redistribute information from another routing protocol\n"
12344 FRR_IP_REDIST_HELP_STR_BGPD
12345 "Metric for redistributed routes\n"
12347 "Route map reference\n"
12348 "Pointer to route-map entries\n")
12350 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12351 int idx_protocol
= 2;
12354 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12356 vty_out(vty
, "%% Invalid route type\n");
12357 return CMD_WARNING_CONFIG_FAILED
;
12359 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12363 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12364 "no redistribute " FRR_IP_REDIST_STR_BGPD
12365 " [metric (0-4294967295)] [route-map WORD]",
12367 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12368 "Metric for redistributed routes\n"
12370 "Route map reference\n"
12371 "Pointer to route-map entries\n")
12373 DEFUN (bgp_redistribute_ipv6
,
12374 bgp_redistribute_ipv6_cmd
,
12375 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12376 "Redistribute information from another routing protocol\n"
12377 FRR_IP6_REDIST_HELP_STR_BGPD
)
12379 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12380 int idx_protocol
= 1;
12383 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12385 vty_out(vty
, "%% Invalid route type\n");
12386 return CMD_WARNING_CONFIG_FAILED
;
12389 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12390 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12393 DEFUN (bgp_redistribute_ipv6_rmap
,
12394 bgp_redistribute_ipv6_rmap_cmd
,
12395 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12396 "Redistribute information from another routing protocol\n"
12397 FRR_IP6_REDIST_HELP_STR_BGPD
12398 "Route map reference\n"
12399 "Pointer to route-map entries\n")
12401 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12402 int idx_protocol
= 1;
12405 struct bgp_redist
*red
;
12407 struct route_map
*route_map
=
12408 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12410 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12412 vty_out(vty
, "%% Invalid route type\n");
12413 return CMD_WARNING_CONFIG_FAILED
;
12416 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12418 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12419 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12422 DEFUN (bgp_redistribute_ipv6_metric
,
12423 bgp_redistribute_ipv6_metric_cmd
,
12424 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12425 "Redistribute information from another routing protocol\n"
12426 FRR_IP6_REDIST_HELP_STR_BGPD
12427 "Metric for redistributed routes\n"
12428 "Default metric\n")
12430 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12431 int idx_protocol
= 1;
12432 int idx_number
= 3;
12435 struct bgp_redist
*red
;
12438 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12440 vty_out(vty
, "%% Invalid route type\n");
12441 return CMD_WARNING_CONFIG_FAILED
;
12443 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12445 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12446 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12447 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12450 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12451 bgp_redistribute_ipv6_rmap_metric_cmd
,
12452 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12453 "Redistribute information from another routing protocol\n"
12454 FRR_IP6_REDIST_HELP_STR_BGPD
12455 "Route map reference\n"
12456 "Pointer to route-map entries\n"
12457 "Metric for redistributed routes\n"
12458 "Default metric\n")
12460 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12461 int idx_protocol
= 1;
12463 int idx_number
= 5;
12466 struct bgp_redist
*red
;
12468 struct route_map
*route_map
=
12469 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12471 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12473 vty_out(vty
, "%% Invalid route type\n");
12474 return CMD_WARNING_CONFIG_FAILED
;
12476 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12478 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12480 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12481 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12483 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12486 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12487 bgp_redistribute_ipv6_metric_rmap_cmd
,
12488 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12489 "Redistribute information from another routing protocol\n"
12490 FRR_IP6_REDIST_HELP_STR_BGPD
12491 "Metric for redistributed routes\n"
12493 "Route map reference\n"
12494 "Pointer to route-map entries\n")
12496 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12497 int idx_protocol
= 1;
12498 int idx_number
= 3;
12502 struct bgp_redist
*red
;
12504 struct route_map
*route_map
=
12505 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12507 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12509 vty_out(vty
, "%% Invalid route type\n");
12510 return CMD_WARNING_CONFIG_FAILED
;
12512 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12514 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12515 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12518 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12519 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12522 DEFUN (no_bgp_redistribute_ipv6
,
12523 no_bgp_redistribute_ipv6_cmd
,
12524 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12526 "Redistribute information from another routing protocol\n"
12527 FRR_IP6_REDIST_HELP_STR_BGPD
12528 "Metric for redistributed routes\n"
12530 "Route map reference\n"
12531 "Pointer to route-map entries\n")
12533 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12534 int idx_protocol
= 2;
12537 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12539 vty_out(vty
, "%% Invalid route type\n");
12540 return CMD_WARNING_CONFIG_FAILED
;
12543 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12546 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12551 /* Unicast redistribution only. */
12552 if (safi
!= SAFI_UNICAST
)
12555 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12556 /* Redistribute BGP does not make sense. */
12557 if (i
!= ZEBRA_ROUTE_BGP
) {
12558 struct list
*red_list
;
12559 struct listnode
*node
;
12560 struct bgp_redist
*red
;
12562 red_list
= bgp
->redist
[afi
][i
];
12566 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12567 /* "redistribute" configuration. */
12568 vty_out(vty
, " redistribute %s",
12569 zebra_route_string(i
));
12571 vty_out(vty
, " %d", red
->instance
);
12572 if (red
->redist_metric_flag
)
12573 vty_out(vty
, " metric %u",
12574 red
->redist_metric
);
12575 if (red
->rmap
.name
)
12576 vty_out(vty
, " route-map %s",
12578 vty_out(vty
, "\n");
12584 /* This is part of the address-family block (unicast only) */
12585 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12590 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12591 if (listcount(bgp
->vpn_policy
[afi
].import_vrf
))
12592 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12593 bgp
->vpn_policy
[afi
]
12594 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12596 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
12597 bgp
->vpn_policy
[afi
]
12598 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12600 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12601 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12602 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12603 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12606 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12607 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12609 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12612 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12613 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12614 bgp
->vpn_policy
[afi
].tovpn_label
);
12617 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12618 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12619 char buf
[RD_ADDRSTRLEN
];
12620 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12621 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12624 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12625 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12627 char buf
[PREFIX_STRLEN
];
12628 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12629 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12632 vty_out(vty
, "%*snexthop vpn export %s\n",
12636 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12637 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12639 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12640 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12642 char *b
= ecommunity_ecom2str(
12643 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12644 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12645 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12646 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12648 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12649 char *b
= ecommunity_ecom2str(
12650 bgp
->vpn_policy
[afi
]
12651 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12652 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12653 ECOMMUNITY_ROUTE_TARGET
);
12654 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12655 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12657 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12658 char *b
= ecommunity_ecom2str(
12659 bgp
->vpn_policy
[afi
]
12660 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12661 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12662 ECOMMUNITY_ROUTE_TARGET
);
12663 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12664 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12668 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12669 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12670 bgp
->vpn_policy
[afi
]
12671 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12673 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12674 char *b
= ecommunity_ecom2str(
12675 bgp
->vpn_policy
[afi
]
12676 .import_redirect_rtlist
,
12677 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12678 ECOMMUNITY_ROUTE_TARGET
);
12680 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12681 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12686 /* BGP node structure. */
12687 static struct cmd_node bgp_node
= {
12688 BGP_NODE
, "%s(config-router)# ", 1,
12691 static struct cmd_node bgp_ipv4_unicast_node
= {
12692 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12695 static struct cmd_node bgp_ipv4_multicast_node
= {
12696 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12699 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12700 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12703 static struct cmd_node bgp_ipv6_unicast_node
= {
12704 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12707 static struct cmd_node bgp_ipv6_multicast_node
= {
12708 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12711 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12712 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12715 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12716 "%s(config-router-af)# ", 1};
12718 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12719 "%s(config-router-af-vpnv6)# ", 1};
12721 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12722 "%s(config-router-evpn)# ", 1};
12724 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12725 "%s(config-router-af-vni)# ", 1};
12727 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12728 "%s(config-router-af)# ", 1};
12730 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12731 "%s(config-router-af-vpnv6)# ", 1};
12733 static void community_list_vty(void);
12735 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12739 struct listnode
*lnbgp
, *lnpeer
;
12741 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12742 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12743 /* only provide suggestions on the appropriate input
12745 * they'll otherwise show up multiple times */
12746 enum cmd_token_type match_type
;
12747 char *name
= peer
->host
;
12749 if (peer
->conf_if
) {
12750 match_type
= VARIABLE_TKN
;
12751 name
= peer
->conf_if
;
12752 } else if (strchr(peer
->host
, ':'))
12753 match_type
= IPV6_TKN
;
12755 match_type
= IPV4_TKN
;
12757 if (token
->type
!= match_type
)
12760 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12765 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12766 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12767 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12768 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12769 {.completions
= NULL
}};
12771 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12774 struct peer_group
*group
;
12775 struct listnode
*lnbgp
, *lnpeer
;
12777 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12778 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12779 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12784 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12785 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12786 {.completions
= NULL
} };
12788 void bgp_vty_init(void)
12790 cmd_variable_handler_register(bgp_var_neighbor
);
12791 cmd_variable_handler_register(bgp_var_peergroup
);
12793 /* Install bgp top node. */
12794 install_node(&bgp_node
, bgp_config_write
);
12795 install_node(&bgp_ipv4_unicast_node
, NULL
);
12796 install_node(&bgp_ipv4_multicast_node
, NULL
);
12797 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12798 install_node(&bgp_ipv6_unicast_node
, NULL
);
12799 install_node(&bgp_ipv6_multicast_node
, NULL
);
12800 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12801 install_node(&bgp_vpnv4_node
, NULL
);
12802 install_node(&bgp_vpnv6_node
, NULL
);
12803 install_node(&bgp_evpn_node
, NULL
);
12804 install_node(&bgp_evpn_vni_node
, NULL
);
12805 install_node(&bgp_flowspecv4_node
, NULL
);
12806 install_node(&bgp_flowspecv6_node
, NULL
);
12808 /* Install default VTY commands to new nodes. */
12809 install_default(BGP_NODE
);
12810 install_default(BGP_IPV4_NODE
);
12811 install_default(BGP_IPV4M_NODE
);
12812 install_default(BGP_IPV4L_NODE
);
12813 install_default(BGP_IPV6_NODE
);
12814 install_default(BGP_IPV6M_NODE
);
12815 install_default(BGP_IPV6L_NODE
);
12816 install_default(BGP_VPNV4_NODE
);
12817 install_default(BGP_VPNV6_NODE
);
12818 install_default(BGP_FLOWSPECV4_NODE
);
12819 install_default(BGP_FLOWSPECV6_NODE
);
12820 install_default(BGP_EVPN_NODE
);
12821 install_default(BGP_EVPN_VNI_NODE
);
12823 /* "bgp local-mac" hidden commands. */
12824 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
12825 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
12827 /* bgp route-map delay-timer commands. */
12828 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12829 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12831 /* Dummy commands (Currently not supported) */
12832 install_element(BGP_NODE
, &no_synchronization_cmd
);
12833 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12835 /* "router bgp" commands. */
12836 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12838 /* "no router bgp" commands. */
12839 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12841 /* "bgp router-id" commands. */
12842 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12843 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12845 /* "bgp cluster-id" commands. */
12846 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12847 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12849 /* "bgp confederation" commands. */
12850 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12851 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12853 /* "bgp confederation peers" commands. */
12854 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12855 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12857 /* bgp max-med command */
12858 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12859 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12860 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12861 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12862 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12864 /* bgp disable-ebgp-connected-nh-check */
12865 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12866 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12868 /* bgp update-delay command */
12869 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12870 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12871 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12873 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12874 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12875 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12876 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12878 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12879 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12881 /* "maximum-paths" commands. */
12882 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12883 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12884 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12885 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12886 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12887 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12888 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12889 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12890 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12891 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12892 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12893 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12894 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12895 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12896 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12898 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12899 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12900 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12901 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12902 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12904 /* "timers bgp" commands. */
12905 install_element(BGP_NODE
, &bgp_timers_cmd
);
12906 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12908 /* route-map delay-timer commands - per instance for backwards compat.
12910 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12911 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12913 /* "bgp client-to-client reflection" commands */
12914 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
12915 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
12917 /* "bgp always-compare-med" commands */
12918 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
12919 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
12921 /* bgp ebgp-requires-policy */
12922 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
12923 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
12925 /* "bgp deterministic-med" commands */
12926 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
12927 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
12929 /* "bgp graceful-restart" commands */
12930 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
12931 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
12932 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
12933 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
12934 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
12935 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
12937 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
12938 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
12940 /* "bgp graceful-shutdown" commands */
12941 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
12942 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
12944 /* "bgp fast-external-failover" commands */
12945 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
12946 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
12948 /* "bgp bestpath compare-routerid" commands */
12949 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
12950 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
12952 /* "bgp bestpath as-path ignore" commands */
12953 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
12954 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
12956 /* "bgp bestpath as-path confed" commands */
12957 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
12958 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
12960 /* "bgp bestpath as-path multipath-relax" commands */
12961 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
12962 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
12964 /* "bgp log-neighbor-changes" commands */
12965 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
12966 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
12968 /* "bgp bestpath med" commands */
12969 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
12970 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
12972 /* "no bgp default ipv4-unicast" commands. */
12973 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
12974 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
12976 /* "bgp network import-check" commands. */
12977 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
12978 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
12979 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
12981 /* "bgp default local-preference" commands. */
12982 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
12983 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
12985 /* bgp default show-hostname */
12986 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
12987 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
12989 /* "bgp default subgroup-pkt-queue-max" commands. */
12990 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
12991 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
12993 /* bgp ibgp-allow-policy-mods command */
12994 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
12995 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
12997 /* "bgp listen limit" commands. */
12998 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
12999 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
13001 /* "bgp listen range" commands. */
13002 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
13003 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
13005 /* "bgp default shutdown" command */
13006 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
13008 /* "neighbor remote-as" commands. */
13009 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
13010 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
13011 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
13012 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
13013 install_element(BGP_NODE
,
13014 &neighbor_interface_v6only_config_remote_as_cmd
);
13015 install_element(BGP_NODE
, &no_neighbor_cmd
);
13016 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
13018 /* "neighbor peer-group" commands. */
13019 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
13020 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
13021 install_element(BGP_NODE
,
13022 &no_neighbor_interface_peer_group_remote_as_cmd
);
13024 /* "neighbor local-as" commands. */
13025 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
13026 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
13027 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
13028 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
13030 /* "neighbor solo" commands. */
13031 install_element(BGP_NODE
, &neighbor_solo_cmd
);
13032 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
13034 /* "neighbor password" commands. */
13035 install_element(BGP_NODE
, &neighbor_password_cmd
);
13036 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
13038 /* "neighbor activate" commands. */
13039 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
13040 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
13041 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
13042 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
13043 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
13044 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
13045 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
13046 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
13047 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
13048 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
13049 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
13050 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
13052 /* "no neighbor activate" commands. */
13053 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
13054 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
13055 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
13056 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
13057 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
13058 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
13059 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
13060 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
13061 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
13062 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
13063 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
13064 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
13066 /* "neighbor peer-group" set commands. */
13067 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
13068 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13069 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13070 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13071 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13072 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13073 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13074 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13075 install_element(BGP_FLOWSPECV4_NODE
,
13076 &neighbor_set_peer_group_hidden_cmd
);
13077 install_element(BGP_FLOWSPECV6_NODE
,
13078 &neighbor_set_peer_group_hidden_cmd
);
13080 /* "no neighbor peer-group unset" commands. */
13081 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
13082 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13083 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13084 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13085 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13086 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13087 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13088 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13089 install_element(BGP_FLOWSPECV4_NODE
,
13090 &no_neighbor_set_peer_group_hidden_cmd
);
13091 install_element(BGP_FLOWSPECV6_NODE
,
13092 &no_neighbor_set_peer_group_hidden_cmd
);
13094 /* "neighbor softreconfiguration inbound" commands.*/
13095 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
13096 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
13097 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13098 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13099 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13100 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13101 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13102 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13103 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13104 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13105 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13106 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13107 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13108 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13109 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13110 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13111 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13112 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13113 install_element(BGP_FLOWSPECV4_NODE
,
13114 &neighbor_soft_reconfiguration_cmd
);
13115 install_element(BGP_FLOWSPECV4_NODE
,
13116 &no_neighbor_soft_reconfiguration_cmd
);
13117 install_element(BGP_FLOWSPECV6_NODE
,
13118 &neighbor_soft_reconfiguration_cmd
);
13119 install_element(BGP_FLOWSPECV6_NODE
,
13120 &no_neighbor_soft_reconfiguration_cmd
);
13121 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
13122 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13124 /* "neighbor attribute-unchanged" commands. */
13125 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
13126 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
13127 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
13128 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13129 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
13130 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13131 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
13132 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13133 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
13134 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13135 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
13136 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13137 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
13138 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13139 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
13140 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13141 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
13142 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13144 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
13145 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
13147 /* "nexthop-local unchanged" commands */
13148 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
13149 install_element(BGP_IPV6_NODE
,
13150 &no_neighbor_nexthop_local_unchanged_cmd
);
13152 /* "neighbor next-hop-self" commands. */
13153 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
13154 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
13155 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
13156 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13157 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
13158 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
13159 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
13160 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
13161 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
13162 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13163 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
13164 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
13165 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
13166 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
13167 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
13168 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13169 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
13170 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13171 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
13172 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
13174 /* "neighbor next-hop-self force" commands. */
13175 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
13176 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
13177 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13178 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
13179 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13180 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13181 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
13182 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13183 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
13184 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13185 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13186 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13187 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
13188 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13189 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
13190 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13191 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13192 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13193 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13194 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13196 /* "neighbor as-override" commands. */
13197 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
13198 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
13199 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
13200 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
13201 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
13202 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
13203 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
13204 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
13205 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
13206 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
13207 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
13208 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
13209 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
13210 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
13211 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
13212 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
13213 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
13214 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
13216 /* "neighbor remove-private-AS" commands. */
13217 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
13218 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
13219 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
13220 install_element(BGP_NODE
,
13221 &no_neighbor_remove_private_as_all_hidden_cmd
);
13222 install_element(BGP_NODE
,
13223 &neighbor_remove_private_as_replace_as_hidden_cmd
);
13224 install_element(BGP_NODE
,
13225 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
13226 install_element(BGP_NODE
,
13227 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13230 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13231 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
13232 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13233 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13234 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13235 install_element(BGP_IPV4_NODE
,
13236 &neighbor_remove_private_as_replace_as_cmd
);
13237 install_element(BGP_IPV4_NODE
,
13238 &no_neighbor_remove_private_as_replace_as_cmd
);
13239 install_element(BGP_IPV4_NODE
,
13240 &neighbor_remove_private_as_all_replace_as_cmd
);
13241 install_element(BGP_IPV4_NODE
,
13242 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13243 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
13244 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
13245 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
13246 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13247 install_element(BGP_IPV4M_NODE
,
13248 &neighbor_remove_private_as_replace_as_cmd
);
13249 install_element(BGP_IPV4M_NODE
,
13250 &no_neighbor_remove_private_as_replace_as_cmd
);
13251 install_element(BGP_IPV4M_NODE
,
13252 &neighbor_remove_private_as_all_replace_as_cmd
);
13253 install_element(BGP_IPV4M_NODE
,
13254 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13255 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
13256 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
13257 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
13258 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13259 install_element(BGP_IPV4L_NODE
,
13260 &neighbor_remove_private_as_replace_as_cmd
);
13261 install_element(BGP_IPV4L_NODE
,
13262 &no_neighbor_remove_private_as_replace_as_cmd
);
13263 install_element(BGP_IPV4L_NODE
,
13264 &neighbor_remove_private_as_all_replace_as_cmd
);
13265 install_element(BGP_IPV4L_NODE
,
13266 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13267 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
13268 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13269 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13270 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13271 install_element(BGP_IPV6_NODE
,
13272 &neighbor_remove_private_as_replace_as_cmd
);
13273 install_element(BGP_IPV6_NODE
,
13274 &no_neighbor_remove_private_as_replace_as_cmd
);
13275 install_element(BGP_IPV6_NODE
,
13276 &neighbor_remove_private_as_all_replace_as_cmd
);
13277 install_element(BGP_IPV6_NODE
,
13278 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13279 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
13280 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
13281 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
13282 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13283 install_element(BGP_IPV6M_NODE
,
13284 &neighbor_remove_private_as_replace_as_cmd
);
13285 install_element(BGP_IPV6M_NODE
,
13286 &no_neighbor_remove_private_as_replace_as_cmd
);
13287 install_element(BGP_IPV6M_NODE
,
13288 &neighbor_remove_private_as_all_replace_as_cmd
);
13289 install_element(BGP_IPV6M_NODE
,
13290 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13291 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
13292 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
13293 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
13294 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13295 install_element(BGP_IPV6L_NODE
,
13296 &neighbor_remove_private_as_replace_as_cmd
);
13297 install_element(BGP_IPV6L_NODE
,
13298 &no_neighbor_remove_private_as_replace_as_cmd
);
13299 install_element(BGP_IPV6L_NODE
,
13300 &neighbor_remove_private_as_all_replace_as_cmd
);
13301 install_element(BGP_IPV6L_NODE
,
13302 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13303 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
13304 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13305 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13306 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13307 install_element(BGP_VPNV4_NODE
,
13308 &neighbor_remove_private_as_replace_as_cmd
);
13309 install_element(BGP_VPNV4_NODE
,
13310 &no_neighbor_remove_private_as_replace_as_cmd
);
13311 install_element(BGP_VPNV4_NODE
,
13312 &neighbor_remove_private_as_all_replace_as_cmd
);
13313 install_element(BGP_VPNV4_NODE
,
13314 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13315 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
13316 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13317 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13318 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13319 install_element(BGP_VPNV6_NODE
,
13320 &neighbor_remove_private_as_replace_as_cmd
);
13321 install_element(BGP_VPNV6_NODE
,
13322 &no_neighbor_remove_private_as_replace_as_cmd
);
13323 install_element(BGP_VPNV6_NODE
,
13324 &neighbor_remove_private_as_all_replace_as_cmd
);
13325 install_element(BGP_VPNV6_NODE
,
13326 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13328 /* "neighbor send-community" commands.*/
13329 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
13330 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
13331 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
13332 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
13333 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
13334 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
13335 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
13336 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
13337 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
13338 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
13339 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
13340 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
13341 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
13342 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
13343 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
13344 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
13345 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
13346 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
13347 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
13348 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
13349 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
13350 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
13351 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
13352 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
13353 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
13354 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
13355 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
13356 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
13357 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
13358 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
13359 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
13360 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
13361 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
13362 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
13363 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
13364 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
13366 /* "neighbor route-reflector" commands.*/
13367 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
13368 install_element(BGP_NODE
,
13369 &no_neighbor_route_reflector_client_hidden_cmd
);
13370 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
13371 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
13372 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
13373 install_element(BGP_IPV4M_NODE
,
13374 &no_neighbor_route_reflector_client_cmd
);
13375 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
13376 install_element(BGP_IPV4L_NODE
,
13377 &no_neighbor_route_reflector_client_cmd
);
13378 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
13379 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
13380 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
13381 install_element(BGP_IPV6M_NODE
,
13382 &no_neighbor_route_reflector_client_cmd
);
13383 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
13384 install_element(BGP_IPV6L_NODE
,
13385 &no_neighbor_route_reflector_client_cmd
);
13386 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
13387 install_element(BGP_VPNV4_NODE
,
13388 &no_neighbor_route_reflector_client_cmd
);
13389 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
13390 install_element(BGP_VPNV6_NODE
,
13391 &no_neighbor_route_reflector_client_cmd
);
13392 install_element(BGP_FLOWSPECV4_NODE
,
13393 &neighbor_route_reflector_client_cmd
);
13394 install_element(BGP_FLOWSPECV4_NODE
,
13395 &no_neighbor_route_reflector_client_cmd
);
13396 install_element(BGP_FLOWSPECV6_NODE
,
13397 &neighbor_route_reflector_client_cmd
);
13398 install_element(BGP_FLOWSPECV6_NODE
,
13399 &no_neighbor_route_reflector_client_cmd
);
13400 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
13401 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
13403 /* "neighbor route-server" commands.*/
13404 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
13405 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
13406 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
13407 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
13408 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
13409 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
13410 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
13411 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
13412 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
13413 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
13414 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
13415 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
13416 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
13417 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
13418 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
13419 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
13420 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
13421 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
13422 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
13423 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
13424 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
13425 install_element(BGP_FLOWSPECV4_NODE
,
13426 &no_neighbor_route_server_client_cmd
);
13427 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
13428 install_element(BGP_FLOWSPECV6_NODE
,
13429 &no_neighbor_route_server_client_cmd
);
13431 /* "neighbor addpath-tx-all-paths" commands.*/
13432 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
13433 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
13434 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13435 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13436 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13437 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13438 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13439 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13440 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13441 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13442 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13443 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13444 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13445 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13446 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13447 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13448 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13449 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13451 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
13452 install_element(BGP_NODE
,
13453 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13454 install_element(BGP_NODE
,
13455 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13456 install_element(BGP_IPV4_NODE
,
13457 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13458 install_element(BGP_IPV4_NODE
,
13459 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13460 install_element(BGP_IPV4M_NODE
,
13461 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13462 install_element(BGP_IPV4M_NODE
,
13463 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13464 install_element(BGP_IPV4L_NODE
,
13465 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13466 install_element(BGP_IPV4L_NODE
,
13467 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13468 install_element(BGP_IPV6_NODE
,
13469 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13470 install_element(BGP_IPV6_NODE
,
13471 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13472 install_element(BGP_IPV6M_NODE
,
13473 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13474 install_element(BGP_IPV6M_NODE
,
13475 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13476 install_element(BGP_IPV6L_NODE
,
13477 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13478 install_element(BGP_IPV6L_NODE
,
13479 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13480 install_element(BGP_VPNV4_NODE
,
13481 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13482 install_element(BGP_VPNV4_NODE
,
13483 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13484 install_element(BGP_VPNV6_NODE
,
13485 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13486 install_element(BGP_VPNV6_NODE
,
13487 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13489 /* "neighbor passive" commands. */
13490 install_element(BGP_NODE
, &neighbor_passive_cmd
);
13491 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13494 /* "neighbor shutdown" commands. */
13495 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13496 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13497 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13498 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13500 /* "neighbor capability extended-nexthop" commands.*/
13501 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13502 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13504 /* "neighbor capability orf prefix-list" commands.*/
13505 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13506 install_element(BGP_NODE
,
13507 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13508 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13509 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13510 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13511 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13512 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13513 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13514 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13515 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13516 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13517 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13518 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13519 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13521 /* "neighbor capability dynamic" commands.*/
13522 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13523 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13525 /* "neighbor dont-capability-negotiate" commands. */
13526 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13527 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13529 /* "neighbor ebgp-multihop" commands. */
13530 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13531 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13532 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13534 /* "neighbor disable-connected-check" commands. */
13535 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13536 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13538 /* "neighbor enforce-first-as" commands. */
13539 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13540 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13542 /* "neighbor description" commands. */
13543 install_element(BGP_NODE
, &neighbor_description_cmd
);
13544 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13545 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13547 /* "neighbor update-source" commands. "*/
13548 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13549 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13551 /* "neighbor default-originate" commands. */
13552 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13553 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13554 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13555 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13556 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13557 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13558 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13559 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13560 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13561 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13562 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13563 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13564 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13565 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13566 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13567 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13568 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13569 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13570 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13571 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13572 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13574 /* "neighbor port" commands. */
13575 install_element(BGP_NODE
, &neighbor_port_cmd
);
13576 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13578 /* "neighbor weight" commands. */
13579 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13580 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13582 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13583 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13584 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13585 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13586 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13587 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13588 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13589 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13590 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13591 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13592 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13593 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13594 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13595 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13596 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13597 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13599 /* "neighbor override-capability" commands. */
13600 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13601 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13603 /* "neighbor strict-capability-match" commands. */
13604 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13605 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13607 /* "neighbor timers" commands. */
13608 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13609 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13611 /* "neighbor timers connect" commands. */
13612 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13613 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13615 /* "neighbor advertisement-interval" commands. */
13616 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13617 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13619 /* "neighbor interface" commands. */
13620 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13621 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13623 /* "neighbor distribute" commands. */
13624 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13625 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13626 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13627 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13628 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13629 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13630 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13631 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13632 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13633 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13634 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13635 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13636 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13637 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13638 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13639 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13640 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13641 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13643 /* "neighbor prefix-list" commands. */
13644 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13645 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13646 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13647 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13648 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13649 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13650 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13651 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13652 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13653 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13654 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13655 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13656 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13657 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13658 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13659 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13660 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13661 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13662 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13663 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13664 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13665 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13667 /* "neighbor filter-list" commands. */
13668 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13669 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13670 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13671 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13672 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13673 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13674 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13675 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13676 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13677 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13678 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13679 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13680 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13681 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13682 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13683 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13684 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13685 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13686 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13687 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13688 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13689 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13691 /* "neighbor route-map" commands. */
13692 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13693 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13694 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13695 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13696 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13697 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13698 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13699 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13700 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13701 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13702 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13703 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13704 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13705 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13706 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13707 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13708 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13709 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13710 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13711 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13712 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13713 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13714 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13715 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13717 /* "neighbor unsuppress-map" commands. */
13718 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13719 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13720 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13721 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13722 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13723 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13724 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13725 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13726 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13727 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13728 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13729 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13730 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13731 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13732 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13733 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13734 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13735 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13737 /* "neighbor maximum-prefix" commands. */
13738 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13739 install_element(BGP_NODE
,
13740 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13741 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13742 install_element(BGP_NODE
,
13743 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13744 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13745 install_element(BGP_NODE
,
13746 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13747 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13748 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13749 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13750 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13751 install_element(BGP_IPV4_NODE
,
13752 &neighbor_maximum_prefix_threshold_warning_cmd
);
13753 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13754 install_element(BGP_IPV4_NODE
,
13755 &neighbor_maximum_prefix_threshold_restart_cmd
);
13756 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13757 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13758 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13759 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13760 install_element(BGP_IPV4M_NODE
,
13761 &neighbor_maximum_prefix_threshold_warning_cmd
);
13762 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13763 install_element(BGP_IPV4M_NODE
,
13764 &neighbor_maximum_prefix_threshold_restart_cmd
);
13765 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13766 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13767 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13768 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13769 install_element(BGP_IPV4L_NODE
,
13770 &neighbor_maximum_prefix_threshold_warning_cmd
);
13771 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13772 install_element(BGP_IPV4L_NODE
,
13773 &neighbor_maximum_prefix_threshold_restart_cmd
);
13774 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13775 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13776 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13777 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13778 install_element(BGP_IPV6_NODE
,
13779 &neighbor_maximum_prefix_threshold_warning_cmd
);
13780 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13781 install_element(BGP_IPV6_NODE
,
13782 &neighbor_maximum_prefix_threshold_restart_cmd
);
13783 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13784 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13785 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13786 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13787 install_element(BGP_IPV6M_NODE
,
13788 &neighbor_maximum_prefix_threshold_warning_cmd
);
13789 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13790 install_element(BGP_IPV6M_NODE
,
13791 &neighbor_maximum_prefix_threshold_restart_cmd
);
13792 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13793 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13794 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13795 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13796 install_element(BGP_IPV6L_NODE
,
13797 &neighbor_maximum_prefix_threshold_warning_cmd
);
13798 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13799 install_element(BGP_IPV6L_NODE
,
13800 &neighbor_maximum_prefix_threshold_restart_cmd
);
13801 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13802 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13803 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13804 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13805 install_element(BGP_VPNV4_NODE
,
13806 &neighbor_maximum_prefix_threshold_warning_cmd
);
13807 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13808 install_element(BGP_VPNV4_NODE
,
13809 &neighbor_maximum_prefix_threshold_restart_cmd
);
13810 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13811 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13812 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13813 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13814 install_element(BGP_VPNV6_NODE
,
13815 &neighbor_maximum_prefix_threshold_warning_cmd
);
13816 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13817 install_element(BGP_VPNV6_NODE
,
13818 &neighbor_maximum_prefix_threshold_restart_cmd
);
13819 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13821 /* "neighbor allowas-in" */
13822 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13823 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13824 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13825 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13826 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13827 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13828 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13829 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13830 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13831 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13832 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13833 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13834 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13835 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13836 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13837 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13838 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13839 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13840 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13841 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13843 /* address-family commands. */
13844 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13845 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13846 #ifdef KEEP_OLD_VPN_COMMANDS
13847 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13848 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13849 #endif /* KEEP_OLD_VPN_COMMANDS */
13851 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13853 /* "exit-address-family" command. */
13854 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13855 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13856 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13857 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13858 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13859 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13860 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13861 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13862 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13863 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13864 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13866 /* "clear ip bgp commands" */
13867 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13869 /* clear ip bgp prefix */
13870 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13871 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13872 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13874 /* "show [ip] bgp summary" commands. */
13875 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13876 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
13877 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13878 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13879 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13880 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13881 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
13883 /* "show [ip] bgp neighbors" commands. */
13884 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
13886 /* "show [ip] bgp peer-group" commands. */
13887 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
13889 /* "show [ip] bgp paths" commands. */
13890 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
13892 /* "show [ip] bgp community" commands. */
13893 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
13895 /* "show ip bgp large-community" commands. */
13896 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
13897 /* "show [ip] bgp attribute-info" commands. */
13898 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
13899 /* "show [ip] bgp route-leak" command */
13900 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
13902 /* "redistribute" commands. */
13903 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
13904 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
13905 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
13906 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
13907 install_element(BGP_NODE
,
13908 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
13909 install_element(BGP_NODE
,
13910 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
13911 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
13912 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
13913 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
13914 install_element(BGP_NODE
,
13915 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
13916 install_element(BGP_NODE
,
13917 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
13918 install_element(BGP_NODE
,
13919 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
13920 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
13921 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
13922 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
13923 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
13924 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
13925 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
13926 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
13927 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
13928 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
13929 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
13930 install_element(BGP_IPV4_NODE
,
13931 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
13932 install_element(BGP_IPV4_NODE
,
13933 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
13934 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
13935 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
13936 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
13937 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
13938 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
13939 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
13941 /* import|export vpn [route-map WORD] */
13942 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
13943 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
13945 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
13946 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
13948 /* ttl_security commands */
13949 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
13950 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
13952 /* "show [ip] bgp memory" commands. */
13953 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
13955 /* "show bgp martian next-hop" */
13956 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
13958 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
13960 /* "show [ip] bgp views" commands. */
13961 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
13963 /* "show [ip] bgp vrfs" commands. */
13964 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
13966 /* Community-list. */
13967 community_list_vty();
13969 /* vpn-policy commands */
13970 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
13971 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
13972 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
13973 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
13974 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
13975 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
13976 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
13977 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
13978 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
13979 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
13980 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
13981 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
13983 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
13984 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
13986 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
13987 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
13988 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
13989 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
13990 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
13991 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
13992 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
13993 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
13994 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13995 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13996 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
13997 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
14000 #include "memory.h"
14001 #include "bgp_regex.h"
14002 #include "bgp_clist.h"
14003 #include "bgp_ecommunity.h"
14005 /* VTY functions. */
14007 /* Direction value to string conversion. */
14008 static const char *community_direct_str(int direct
)
14011 case COMMUNITY_DENY
:
14013 case COMMUNITY_PERMIT
:
14020 /* Display error string. */
14021 static void community_list_perror(struct vty
*vty
, int ret
)
14024 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
14025 vty_out(vty
, "%% Can't find community-list\n");
14027 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
14028 vty_out(vty
, "%% Malformed community-list value\n");
14030 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
14032 "%% Community name conflict, previously defined as standard community\n");
14034 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
14036 "%% Community name conflict, previously defined as expanded community\n");
14041 /* "community-list" keyword help string. */
14042 #define COMMUNITY_LIST_STR "Add a community list entry\n"
14044 /*community-list standard */
14045 DEFUN (community_list_standard
,
14046 bgp_community_list_standard_cmd
,
14047 "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14050 "Community list number (standard)\n"
14051 "Add an standard community-list entry\n"
14052 "Community list name\n"
14053 "Specify community to reject\n"
14054 "Specify community to accept\n"
14057 char *cl_name_or_number
= NULL
;
14059 int style
= COMMUNITY_LIST_STANDARD
;
14063 if (argv_find(argv
, argc
, "ip", &idx
)) {
14064 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14065 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14066 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14067 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14070 argv_find(argv
, argc
, "(1-99)", &idx
);
14071 argv_find(argv
, argc
, "WORD", &idx
);
14072 cl_name_or_number
= argv
[idx
]->arg
;
14073 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14075 argv_find(argv
, argc
, "AA:NN", &idx
);
14076 char *str
= argv_concat(argv
, argc
, idx
);
14078 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14081 XFREE(MTYPE_TMP
, str
);
14084 /* Display error string. */
14085 community_list_perror(vty
, ret
);
14086 return CMD_WARNING_CONFIG_FAILED
;
14089 return CMD_SUCCESS
;
14092 #if CONFDATE > 20191005
14093 CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command")
14095 ALIAS (community_list_standard
,
14096 ip_community_list_standard_cmd
,
14097 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14100 "Community list number (standard)\n"
14101 "Add an standard community-list entry\n"
14102 "Community list name\n"
14103 "Specify community to reject\n"
14104 "Specify community to accept\n"
14107 DEFUN (no_community_list_standard_all
,
14108 no_bgp_community_list_standard_all_cmd
,
14109 "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14113 "Community list number (standard)\n"
14114 "Add an standard community-list entry\n"
14115 "Community list name\n"
14116 "Specify community to reject\n"
14117 "Specify community to accept\n"
14120 char *cl_name_or_number
= NULL
;
14123 int style
= COMMUNITY_LIST_STANDARD
;
14127 if (argv_find(argv
, argc
, "ip", &idx
)) {
14128 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
14129 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14130 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14131 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used");
14134 argv_find(argv
, argc
, "permit", &idx
);
14135 argv_find(argv
, argc
, "deny", &idx
);
14138 direct
= argv_find(argv
, argc
, "permit", &idx
)
14143 argv_find(argv
, argc
, "AA:NN", &idx
);
14144 str
= argv_concat(argv
, argc
, idx
);
14148 argv_find(argv
, argc
, "(1-99)", &idx
);
14149 argv_find(argv
, argc
, "WORD", &idx
);
14150 cl_name_or_number
= argv
[idx
]->arg
;
14152 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14155 XFREE(MTYPE_TMP
, str
);
14158 community_list_perror(vty
, ret
);
14159 return CMD_WARNING_CONFIG_FAILED
;
14162 return CMD_SUCCESS
;
14164 ALIAS (no_community_list_standard_all
,
14165 no_ip_community_list_standard_all_cmd
,
14166 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14170 "Community list number (standard)\n"
14171 "Add an standard community-list entry\n"
14172 "Community list name\n"
14173 "Specify community to reject\n"
14174 "Specify community to accept\n"
14177 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
14178 "no bgp community-list <(1-99)|standard WORD>",
14179 NO_STR BGP_STR COMMUNITY_LIST_STR
14180 "Community list number (standard)\n"
14181 "Add an standard community-list entry\n"
14182 "Community list name\n")
14184 ALIAS(no_community_list_standard_all
, no_ip_community_list_standard_all_list_cmd
,
14185 "no ip community-list <(1-99)|standard WORD>",
14186 NO_STR BGP_STR COMMUNITY_LIST_STR
14187 "Community list number (standard)\n"
14188 "Add an standard community-list entry\n"
14189 "Community list name\n")
14191 /*community-list expanded */
14192 DEFUN (community_list_expanded_all
,
14193 bgp_community_list_expanded_all_cmd
,
14194 "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14197 "Community list number (expanded)\n"
14198 "Add an expanded community-list entry\n"
14199 "Community list name\n"
14200 "Specify community to reject\n"
14201 "Specify community to accept\n"
14204 char *cl_name_or_number
= NULL
;
14206 int style
= COMMUNITY_LIST_EXPANDED
;
14209 if (argv_find(argv
, argc
, "ip", &idx
)) {
14210 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14211 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14212 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14213 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14215 argv_find(argv
, argc
, "(100-500)", &idx
);
14216 argv_find(argv
, argc
, "WORD", &idx
);
14217 cl_name_or_number
= argv
[idx
]->arg
;
14218 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14220 argv_find(argv
, argc
, "AA:NN", &idx
);
14221 char *str
= argv_concat(argv
, argc
, idx
);
14223 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14226 XFREE(MTYPE_TMP
, str
);
14229 /* Display error string. */
14230 community_list_perror(vty
, ret
);
14231 return CMD_WARNING_CONFIG_FAILED
;
14234 return CMD_SUCCESS
;
14237 ALIAS (community_list_expanded_all
,
14238 ip_community_list_expanded_all_cmd
,
14239 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14242 "Community list number (expanded)\n"
14243 "Add an expanded community-list entry\n"
14244 "Community list name\n"
14245 "Specify community to reject\n"
14246 "Specify community to accept\n"
14249 DEFUN (no_community_list_expanded_all
,
14250 no_bgp_community_list_expanded_all_cmd
,
14251 "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14255 "Community list number (expanded)\n"
14256 "Add an expanded community-list entry\n"
14257 "Community list name\n"
14258 "Specify community to reject\n"
14259 "Specify community to accept\n"
14262 char *cl_name_or_number
= NULL
;
14265 int style
= COMMUNITY_LIST_EXPANDED
;
14268 if (argv_find(argv
, argc
, "ip", &idx
)) {
14269 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14270 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14271 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14272 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14276 argv_find(argv
, argc
, "permit", &idx
);
14277 argv_find(argv
, argc
, "deny", &idx
);
14280 direct
= argv_find(argv
, argc
, "permit", &idx
)
14285 argv_find(argv
, argc
, "AA:NN", &idx
);
14286 str
= argv_concat(argv
, argc
, idx
);
14290 argv_find(argv
, argc
, "(100-500)", &idx
);
14291 argv_find(argv
, argc
, "WORD", &idx
);
14292 cl_name_or_number
= argv
[idx
]->arg
;
14294 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14297 XFREE(MTYPE_TMP
, str
);
14300 community_list_perror(vty
, ret
);
14301 return CMD_WARNING_CONFIG_FAILED
;
14304 return CMD_SUCCESS
;
14307 ALIAS (no_community_list_expanded_all
,
14308 no_ip_community_list_expanded_all_cmd
,
14309 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14313 "Community list number (expanded)\n"
14314 "Add an expanded community-list entry\n"
14315 "Community list name\n"
14316 "Specify community to reject\n"
14317 "Specify community to accept\n"
14320 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
14321 "no bgp community-list <(100-500)|expanded WORD>",
14322 NO_STR IP_STR COMMUNITY_LIST_STR
14323 "Community list number (expanded)\n"
14324 "Add an expanded community-list entry\n"
14325 "Community list name\n")
14327 ALIAS(no_community_list_expanded_all
, no_ip_community_list_expanded_all_list_cmd
,
14328 "no ip community-list <(100-500)|expanded WORD>",
14329 NO_STR IP_STR COMMUNITY_LIST_STR
14330 "Community list number (expanded)\n"
14331 "Add an expanded community-list entry\n"
14332 "Community list name\n")
14334 /* Return configuration string of community-list entry. */
14335 static const char *community_list_config_str(struct community_entry
*entry
)
14342 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
14343 str
= community_str(entry
->u
.com
, false);
14344 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
14345 str
= lcommunity_str(entry
->u
.lcom
, false);
14347 str
= entry
->config
;
14352 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
14354 struct community_entry
*entry
;
14356 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14357 if (entry
== list
->head
) {
14358 if (all_digit(list
->name
))
14359 vty_out(vty
, "Community %s list %s\n",
14360 entry
->style
== COMMUNITY_LIST_STANDARD
14362 : "(expanded) access",
14365 vty_out(vty
, "Named Community %s list %s\n",
14366 entry
->style
== COMMUNITY_LIST_STANDARD
14372 vty_out(vty
, " %s\n",
14373 community_direct_str(entry
->direct
));
14375 vty_out(vty
, " %s %s\n",
14376 community_direct_str(entry
->direct
),
14377 community_list_config_str(entry
));
14381 DEFUN (show_community_list
,
14382 show_bgp_community_list_cmd
,
14383 "show bgp community-list",
14386 "List community-list\n")
14388 struct community_list
*list
;
14389 struct community_list_master
*cm
;
14392 if (argv_find(argv
, argc
, "ip", &idx
)) {
14393 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14394 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14395 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14396 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14398 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14400 return CMD_SUCCESS
;
14402 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14403 community_list_show(vty
, list
);
14405 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14406 community_list_show(vty
, list
);
14408 return CMD_SUCCESS
;
14411 ALIAS (show_community_list
,
14412 show_ip_community_list_cmd
,
14413 "show ip community-list",
14416 "List community-list\n")
14418 DEFUN (show_community_list_arg
,
14419 show_bgp_community_list_arg_cmd
,
14420 "show bgp community-list <(1-500)|WORD>",
14423 "List community-list\n"
14424 "Community-list number\n"
14425 "Community-list name\n")
14427 int idx_comm_list
= 3;
14428 struct community_list
*list
;
14431 if (argv_find(argv
, argc
, "ip", &idx
)) {
14432 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14433 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14434 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14435 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14437 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
14438 COMMUNITY_LIST_MASTER
);
14440 vty_out(vty
, "%% Can't find community-list\n");
14441 return CMD_WARNING
;
14444 community_list_show(vty
, list
);
14446 return CMD_SUCCESS
;
14449 ALIAS (show_community_list_arg
,
14450 show_ip_community_list_arg_cmd
,
14451 "show ip community-list <(1-500)|WORD>",
14454 "List community-list\n"
14455 "Community-list number\n"
14456 "Community-list name\n")
14459 * Large Community code.
14461 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
14462 struct cmd_token
**argv
, int style
,
14463 int reject_all_digit_name
)
14471 if (argv_find(argv
, argc
, "ip", &idx
)) {
14472 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14473 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14474 vty_out(vty
, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14475 zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14477 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14480 /* All digit name check. */
14482 argv_find(argv
, argc
, "WORD", &idx
);
14483 argv_find(argv
, argc
, "(1-99)", &idx
);
14484 argv_find(argv
, argc
, "(100-500)", &idx
);
14485 cl_name
= argv
[idx
]->arg
;
14486 if (reject_all_digit_name
&& all_digit(cl_name
)) {
14487 vty_out(vty
, "%% Community name cannot have all digits\n");
14488 return CMD_WARNING_CONFIG_FAILED
;
14492 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
14493 argv_find(argv
, argc
, "LINE", &idx
);
14494 /* Concat community string argument. */
14496 str
= argv_concat(argv
, argc
, idx
);
14500 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
14502 /* Free temporary community list string allocated by
14504 XFREE(MTYPE_TMP
, str
);
14507 community_list_perror(vty
, ret
);
14508 return CMD_WARNING_CONFIG_FAILED
;
14510 return CMD_SUCCESS
;
14513 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
14514 struct cmd_token
**argv
, int style
)
14521 if (argv_find(argv
, argc
, "ip", &idx
)) {
14522 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14523 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14524 vty_out(vty
, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14525 zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14527 argv_find(argv
, argc
, "permit", &idx
);
14528 argv_find(argv
, argc
, "deny", &idx
);
14531 /* Check the list direct. */
14532 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
14533 direct
= COMMUNITY_PERMIT
;
14535 direct
= COMMUNITY_DENY
;
14538 argv_find(argv
, argc
, "LINE", &idx
);
14539 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
14540 /* Concat community string argument. */
14541 str
= argv_concat(argv
, argc
, idx
);
14545 argv_find(argv
, argc
, "(1-99)", &idx
);
14546 argv_find(argv
, argc
, "(100-500)", &idx
);
14547 argv_find(argv
, argc
, "WORD", &idx
);
14549 /* Unset community list. */
14550 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
14553 /* Free temporary community list string allocated by
14555 XFREE(MTYPE_TMP
, str
);
14558 community_list_perror(vty
, ret
);
14559 return CMD_WARNING_CONFIG_FAILED
;
14562 return CMD_SUCCESS
;
14565 /* "large-community-list" keyword help string. */
14566 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
14567 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
14569 #if CONFDATE > 20191005
14570 CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command")
14572 DEFUN (lcommunity_list_standard
,
14573 bgp_lcommunity_list_standard_cmd
,
14574 "bgp large-community-list (1-99) <deny|permit>",
14576 LCOMMUNITY_LIST_STR
14577 "Large Community list number (standard)\n"
14578 "Specify large community to reject\n"
14579 "Specify large community to accept\n")
14581 return lcommunity_list_set_vty(vty
, argc
, argv
,
14582 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14585 ALIAS (lcommunity_list_standard
,
14586 ip_lcommunity_list_standard_cmd
,
14587 "ip large-community-list (1-99) <deny|permit>",
14589 LCOMMUNITY_LIST_STR
14590 "Large Community list number (standard)\n"
14591 "Specify large community to reject\n"
14592 "Specify large community to accept\n")
14594 DEFUN (lcommunity_list_standard1
,
14595 bgp_lcommunity_list_standard1_cmd
,
14596 "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...",
14598 LCOMMUNITY_LIST_STR
14599 "Large Community list number (standard)\n"
14600 "Specify large community to reject\n"
14601 "Specify large community to accept\n"
14602 LCOMMUNITY_VAL_STR
)
14604 return lcommunity_list_set_vty(vty
, argc
, argv
,
14605 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14608 ALIAS (lcommunity_list_standard1
,
14609 ip_lcommunity_list_standard1_cmd
,
14610 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
14612 LCOMMUNITY_LIST_STR
14613 "Large Community list number (standard)\n"
14614 "Specify large community to reject\n"
14615 "Specify large community to accept\n"
14616 LCOMMUNITY_VAL_STR
)
14618 DEFUN (lcommunity_list_expanded
,
14619 bgp_lcommunity_list_expanded_cmd
,
14620 "bgp large-community-list (100-500) <deny|permit> LINE...",
14622 LCOMMUNITY_LIST_STR
14623 "Large Community list number (expanded)\n"
14624 "Specify large community to reject\n"
14625 "Specify large community to accept\n"
14626 "An ordered list as a regular-expression\n")
14628 return lcommunity_list_set_vty(vty
, argc
, argv
,
14629 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
14632 ALIAS (lcommunity_list_expanded
,
14633 ip_lcommunity_list_expanded_cmd
,
14634 "ip large-community-list (100-500) <deny|permit> LINE...",
14636 LCOMMUNITY_LIST_STR
14637 "Large Community list number (expanded)\n"
14638 "Specify large community to reject\n"
14639 "Specify large community to accept\n"
14640 "An ordered list as a regular-expression\n")
14642 DEFUN (lcommunity_list_name_standard
,
14643 bgp_lcommunity_list_name_standard_cmd
,
14644 "bgp large-community-list standard WORD <deny|permit>",
14646 LCOMMUNITY_LIST_STR
14647 "Specify standard large-community-list\n"
14648 "Large Community list name\n"
14649 "Specify large community to reject\n"
14650 "Specify large community to accept\n")
14652 return lcommunity_list_set_vty(vty
, argc
, argv
,
14653 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14656 ALIAS (lcommunity_list_name_standard
,
14657 ip_lcommunity_list_name_standard_cmd
,
14658 "ip large-community-list standard WORD <deny|permit>",
14660 LCOMMUNITY_LIST_STR
14661 "Specify standard large-community-list\n"
14662 "Large Community list name\n"
14663 "Specify large community to reject\n"
14664 "Specify large community to accept\n")
14666 DEFUN (lcommunity_list_name_standard1
,
14667 bgp_lcommunity_list_name_standard1_cmd
,
14668 "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
14670 LCOMMUNITY_LIST_STR
14671 "Specify standard large-community-list\n"
14672 "Large Community list name\n"
14673 "Specify large community to reject\n"
14674 "Specify large community to accept\n"
14675 LCOMMUNITY_VAL_STR
)
14677 return lcommunity_list_set_vty(vty
, argc
, argv
,
14678 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14681 ALIAS (lcommunity_list_name_standard1
,
14682 ip_lcommunity_list_name_standard1_cmd
,
14683 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
14685 LCOMMUNITY_LIST_STR
14686 "Specify standard large-community-list\n"
14687 "Large Community list name\n"
14688 "Specify large community to reject\n"
14689 "Specify large community to accept\n"
14690 LCOMMUNITY_VAL_STR
)
14692 DEFUN (lcommunity_list_name_expanded
,
14693 bgp_lcommunity_list_name_expanded_cmd
,
14694 "bgp large-community-list expanded WORD <deny|permit> LINE...",
14696 LCOMMUNITY_LIST_STR
14697 "Specify expanded large-community-list\n"
14698 "Large Community list name\n"
14699 "Specify large community to reject\n"
14700 "Specify large community to accept\n"
14701 "An ordered list as a regular-expression\n")
14703 return lcommunity_list_set_vty(vty
, argc
, argv
,
14704 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
14707 ALIAS (lcommunity_list_name_expanded
,
14708 ip_lcommunity_list_name_expanded_cmd
,
14709 "ip large-community-list expanded WORD <deny|permit> LINE...",
14711 LCOMMUNITY_LIST_STR
14712 "Specify expanded large-community-list\n"
14713 "Large Community list name\n"
14714 "Specify large community to reject\n"
14715 "Specify large community to accept\n"
14716 "An ordered list as a regular-expression\n")
14718 DEFUN (no_lcommunity_list_standard_all
,
14719 no_bgp_lcommunity_list_standard_all_cmd
,
14720 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
14723 LCOMMUNITY_LIST_STR
14724 "Large Community list number (standard)\n"
14725 "Large Community list number (expanded)\n"
14726 "Large Community list name\n")
14728 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14729 LARGE_COMMUNITY_LIST_STANDARD
);
14732 ALIAS (no_lcommunity_list_standard_all
,
14733 no_ip_lcommunity_list_standard_all_cmd
,
14734 "no ip large-community-list <(1-99)|(100-500)|WORD>",
14737 LCOMMUNITY_LIST_STR
14738 "Large Community list number (standard)\n"
14739 "Large Community list number (expanded)\n"
14740 "Large Community list name\n")
14742 DEFUN (no_lcommunity_list_name_expanded_all
,
14743 no_bgp_lcommunity_list_name_expanded_all_cmd
,
14744 "no bgp large-community-list expanded WORD",
14747 LCOMMUNITY_LIST_STR
14748 "Specify expanded large-community-list\n"
14749 "Large Community list name\n")
14751 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14752 LARGE_COMMUNITY_LIST_EXPANDED
);
14755 ALIAS (no_lcommunity_list_name_expanded_all
,
14756 no_ip_lcommunity_list_name_expanded_all_cmd
,
14757 "no ip large-community-list expanded WORD",
14760 LCOMMUNITY_LIST_STR
14761 "Specify expanded large-community-list\n"
14762 "Large Community list name\n")
14764 DEFUN (no_lcommunity_list_standard
,
14765 no_bgp_lcommunity_list_standard_cmd
,
14766 "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
14769 LCOMMUNITY_LIST_STR
14770 "Large Community list number (standard)\n"
14771 "Specify large community to reject\n"
14772 "Specify large community to accept\n"
14773 LCOMMUNITY_VAL_STR
)
14775 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14776 LARGE_COMMUNITY_LIST_STANDARD
);
14779 ALIAS (no_lcommunity_list_standard
,
14780 no_ip_lcommunity_list_standard_cmd
,
14781 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
14784 LCOMMUNITY_LIST_STR
14785 "Large Community list number (standard)\n"
14786 "Specify large community to reject\n"
14787 "Specify large community to accept\n"
14788 LCOMMUNITY_VAL_STR
)
14790 DEFUN (no_lcommunity_list_expanded
,
14791 no_bgp_lcommunity_list_expanded_cmd
,
14792 "no bgp large-community-list (100-500) <deny|permit> LINE...",
14795 LCOMMUNITY_LIST_STR
14796 "Large Community list number (expanded)\n"
14797 "Specify large community to reject\n"
14798 "Specify large community to accept\n"
14799 "An ordered list as a regular-expression\n")
14801 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14802 LARGE_COMMUNITY_LIST_EXPANDED
);
14805 ALIAS (no_lcommunity_list_expanded
,
14806 no_ip_lcommunity_list_expanded_cmd
,
14807 "no ip large-community-list (100-500) <deny|permit> LINE...",
14810 LCOMMUNITY_LIST_STR
14811 "Large Community list number (expanded)\n"
14812 "Specify large community to reject\n"
14813 "Specify large community to accept\n"
14814 "An ordered list as a regular-expression\n")
14816 DEFUN (no_lcommunity_list_name_standard
,
14817 no_bgp_lcommunity_list_name_standard_cmd
,
14818 "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
14821 LCOMMUNITY_LIST_STR
14822 "Specify standard large-community-list\n"
14823 "Large Community list name\n"
14824 "Specify large community to reject\n"
14825 "Specify large community to accept\n"
14826 LCOMMUNITY_VAL_STR
)
14828 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14829 LARGE_COMMUNITY_LIST_STANDARD
);
14832 ALIAS (no_lcommunity_list_name_standard
,
14833 no_ip_lcommunity_list_name_standard_cmd
,
14834 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
14837 LCOMMUNITY_LIST_STR
14838 "Specify standard large-community-list\n"
14839 "Large Community list name\n"
14840 "Specify large community to reject\n"
14841 "Specify large community to accept\n"
14842 LCOMMUNITY_VAL_STR
)
14844 DEFUN (no_lcommunity_list_name_expanded
,
14845 no_bgp_lcommunity_list_name_expanded_cmd
,
14846 "no bgp large-community-list expanded WORD <deny|permit> LINE...",
14849 LCOMMUNITY_LIST_STR
14850 "Specify expanded large-community-list\n"
14851 "Large community list name\n"
14852 "Specify large community to reject\n"
14853 "Specify large community to accept\n"
14854 "An ordered list as a regular-expression\n")
14856 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14857 LARGE_COMMUNITY_LIST_EXPANDED
);
14860 ALIAS (no_lcommunity_list_name_expanded
,
14861 no_ip_lcommunity_list_name_expanded_cmd
,
14862 "no ip large-community-list expanded WORD <deny|permit> LINE...",
14865 LCOMMUNITY_LIST_STR
14866 "Specify expanded large-community-list\n"
14867 "Large community list name\n"
14868 "Specify large community to reject\n"
14869 "Specify large community to accept\n"
14870 "An ordered list as a regular-expression\n")
14872 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14874 struct community_entry
*entry
;
14876 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14877 if (entry
== list
->head
) {
14878 if (all_digit(list
->name
))
14879 vty_out(vty
, "Large community %s list %s\n",
14881 LARGE_COMMUNITY_LIST_STANDARD
14883 : "(expanded) access",
14887 "Named large community %s list %s\n",
14889 LARGE_COMMUNITY_LIST_STANDARD
14895 vty_out(vty
, " %s\n",
14896 community_direct_str(entry
->direct
));
14898 vty_out(vty
, " %s %s\n",
14899 community_direct_str(entry
->direct
),
14900 community_list_config_str(entry
));
14904 DEFUN (show_lcommunity_list
,
14905 show_bgp_lcommunity_list_cmd
,
14906 "show bgp large-community-list",
14909 "List large-community list\n")
14911 struct community_list
*list
;
14912 struct community_list_master
*cm
;
14915 if (argv_find(argv
, argc
, "ip", &idx
)) {
14916 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14917 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14918 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
14919 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
14922 cm
= community_list_master_lookup(bgp_clist
,
14923 LARGE_COMMUNITY_LIST_MASTER
);
14925 return CMD_SUCCESS
;
14927 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14928 lcommunity_list_show(vty
, list
);
14930 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14931 lcommunity_list_show(vty
, list
);
14933 return CMD_SUCCESS
;
14936 ALIAS (show_lcommunity_list
,
14937 show_ip_lcommunity_list_cmd
,
14938 "show ip large-community-list",
14941 "List large-community list\n")
14943 DEFUN (show_lcommunity_list_arg
,
14944 show_bgp_lcommunity_list_arg_cmd
,
14945 "show bgp large-community-list <(1-500)|WORD>",
14948 "List large-community list\n"
14949 "large-community-list number\n"
14950 "large-community-list name\n")
14952 struct community_list
*list
;
14955 if (argv_find(argv
, argc
, "ip", &idx
)) {
14956 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14957 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14958 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
14959 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
14962 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
14963 LARGE_COMMUNITY_LIST_MASTER
);
14965 vty_out(vty
, "%% Can't find extcommunity-list\n");
14966 return CMD_WARNING
;
14969 lcommunity_list_show(vty
, list
);
14971 return CMD_SUCCESS
;
14974 ALIAS (show_lcommunity_list_arg
,
14975 show_ip_lcommunity_list_arg_cmd
,
14976 "show ip large-community-list <(1-500)|WORD>",
14979 "List large-community list\n"
14980 "large-community-list number\n"
14981 "large-community-list name\n")
14983 /* "extcommunity-list" keyword help string. */
14984 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
14985 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
14987 DEFUN (extcommunity_list_standard
,
14988 bgp_extcommunity_list_standard_cmd
,
14989 "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14991 EXTCOMMUNITY_LIST_STR
14992 "Extended Community list number (standard)\n"
14993 "Specify standard extcommunity-list\n"
14994 "Community list name\n"
14995 "Specify community to reject\n"
14996 "Specify community to accept\n"
14997 EXTCOMMUNITY_VAL_STR
)
14999 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15001 char *cl_number_or_name
= NULL
;
15004 if (argv_find(argv
, argc
, "ip", &idx
)) {
15005 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15006 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15007 vty_out(vty
, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15008 zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15010 argv_find(argv
, argc
, "(1-99)", &idx
);
15011 argv_find(argv
, argc
, "WORD", &idx
);
15012 cl_number_or_name
= argv
[idx
]->arg
;
15013 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15015 argv_find(argv
, argc
, "AA:NN", &idx
);
15016 char *str
= argv_concat(argv
, argc
, idx
);
15018 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15021 XFREE(MTYPE_TMP
, str
);
15024 community_list_perror(vty
, ret
);
15025 return CMD_WARNING_CONFIG_FAILED
;
15028 return CMD_SUCCESS
;
15031 #if CONFDATE > 20191005
15032 CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command")
15034 ALIAS (extcommunity_list_standard
,
15035 ip_extcommunity_list_standard_cmd
,
15036 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15038 EXTCOMMUNITY_LIST_STR
15039 "Extended Community list number (standard)\n"
15040 "Specify standard extcommunity-list\n"
15041 "Community list name\n"
15042 "Specify community to reject\n"
15043 "Specify community to accept\n"
15044 EXTCOMMUNITY_VAL_STR
)
15046 DEFUN (extcommunity_list_name_expanded
,
15047 bgp_extcommunity_list_name_expanded_cmd
,
15048 "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15050 EXTCOMMUNITY_LIST_STR
15051 "Extended Community list number (expanded)\n"
15052 "Specify expanded extcommunity-list\n"
15053 "Extended Community list name\n"
15054 "Specify community to reject\n"
15055 "Specify community to accept\n"
15056 "An ordered list as a regular-expression\n")
15058 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15060 char *cl_number_or_name
= NULL
;
15063 if (argv_find(argv
, argc
, "ip", &idx
)) {
15064 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15065 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15066 vty_out(vty
, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15067 zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15070 argv_find(argv
, argc
, "(100-500)", &idx
);
15071 argv_find(argv
, argc
, "WORD", &idx
);
15072 cl_number_or_name
= argv
[idx
]->arg
;
15073 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15075 argv_find(argv
, argc
, "LINE", &idx
);
15076 char *str
= argv_concat(argv
, argc
, idx
);
15078 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15081 XFREE(MTYPE_TMP
, str
);
15084 community_list_perror(vty
, ret
);
15085 return CMD_WARNING_CONFIG_FAILED
;
15088 return CMD_SUCCESS
;
15091 ALIAS (extcommunity_list_name_expanded
,
15092 ip_extcommunity_list_name_expanded_cmd
,
15093 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15095 EXTCOMMUNITY_LIST_STR
15096 "Extended Community list number (expanded)\n"
15097 "Specify expanded extcommunity-list\n"
15098 "Extended Community list name\n"
15099 "Specify community to reject\n"
15100 "Specify community to accept\n"
15101 "An ordered list as a regular-expression\n")
15103 DEFUN (no_extcommunity_list_standard_all
,
15104 no_bgp_extcommunity_list_standard_all_cmd
,
15105 "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15108 EXTCOMMUNITY_LIST_STR
15109 "Extended Community list number (standard)\n"
15110 "Specify standard extcommunity-list\n"
15111 "Community list name\n"
15112 "Specify community to reject\n"
15113 "Specify community to accept\n"
15114 EXTCOMMUNITY_VAL_STR
)
15116 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15118 char *cl_number_or_name
= NULL
;
15122 if (argv_find(argv
, argc
, "ip", &idx
)) {
15123 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15124 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15125 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15126 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15130 argv_find(argv
, argc
, "permit", &idx
);
15131 argv_find(argv
, argc
, "deny", &idx
);
15134 direct
= argv_find(argv
, argc
, "permit", &idx
)
15139 argv_find(argv
, argc
, "AA:NN", &idx
);
15140 str
= argv_concat(argv
, argc
, idx
);
15144 argv_find(argv
, argc
, "(1-99)", &idx
);
15145 argv_find(argv
, argc
, "WORD", &idx
);
15146 cl_number_or_name
= argv
[idx
]->arg
;
15148 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15151 XFREE(MTYPE_TMP
, str
);
15154 community_list_perror(vty
, ret
);
15155 return CMD_WARNING_CONFIG_FAILED
;
15158 return CMD_SUCCESS
;
15161 ALIAS (no_extcommunity_list_standard_all
,
15162 no_ip_extcommunity_list_standard_all_cmd
,
15163 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15166 EXTCOMMUNITY_LIST_STR
15167 "Extended Community list number (standard)\n"
15168 "Specify standard extcommunity-list\n"
15169 "Community list name\n"
15170 "Specify community to reject\n"
15171 "Specify community to accept\n"
15172 EXTCOMMUNITY_VAL_STR
)
15174 ALIAS(no_extcommunity_list_standard_all
,
15175 no_bgp_extcommunity_list_standard_all_list_cmd
,
15176 "no bgp extcommunity-list <(1-99)|standard WORD>",
15177 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15178 "Extended Community list number (standard)\n"
15179 "Specify standard extcommunity-list\n"
15180 "Community list name\n")
15182 ALIAS(no_extcommunity_list_standard_all
,
15183 no_ip_extcommunity_list_standard_all_list_cmd
,
15184 "no ip extcommunity-list <(1-99)|standard WORD>",
15185 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15186 "Extended Community list number (standard)\n"
15187 "Specify standard extcommunity-list\n"
15188 "Community list name\n")
15190 DEFUN (no_extcommunity_list_expanded_all
,
15191 no_bgp_extcommunity_list_expanded_all_cmd
,
15192 "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15195 EXTCOMMUNITY_LIST_STR
15196 "Extended Community list number (expanded)\n"
15197 "Specify expanded extcommunity-list\n"
15198 "Extended Community list name\n"
15199 "Specify community to reject\n"
15200 "Specify community to accept\n"
15201 "An ordered list as a regular-expression\n")
15203 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15205 char *cl_number_or_name
= NULL
;
15209 if (argv_find(argv
, argc
, "ip", &idx
)) {
15210 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15211 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15212 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15213 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15217 argv_find(argv
, argc
, "permit", &idx
);
15218 argv_find(argv
, argc
, "deny", &idx
);
15221 direct
= argv_find(argv
, argc
, "permit", &idx
)
15226 argv_find(argv
, argc
, "LINE", &idx
);
15227 str
= argv_concat(argv
, argc
, idx
);
15231 argv_find(argv
, argc
, "(100-500)", &idx
);
15232 argv_find(argv
, argc
, "WORD", &idx
);
15233 cl_number_or_name
= argv
[idx
]->arg
;
15235 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15238 XFREE(MTYPE_TMP
, str
);
15241 community_list_perror(vty
, ret
);
15242 return CMD_WARNING_CONFIG_FAILED
;
15245 return CMD_SUCCESS
;
15248 ALIAS (no_extcommunity_list_expanded_all
,
15249 no_ip_extcommunity_list_expanded_all_cmd
,
15250 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15253 EXTCOMMUNITY_LIST_STR
15254 "Extended Community list number (expanded)\n"
15255 "Specify expanded extcommunity-list\n"
15256 "Extended Community list name\n"
15257 "Specify community to reject\n"
15258 "Specify community to accept\n"
15259 "An ordered list as a regular-expression\n")
15261 ALIAS(no_extcommunity_list_expanded_all
,
15262 no_ip_extcommunity_list_expanded_all_list_cmd
,
15263 "no ip extcommunity-list <(100-500)|expanded WORD>",
15264 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15265 "Extended Community list number (expanded)\n"
15266 "Specify expanded extcommunity-list\n"
15267 "Extended Community list name\n")
15269 ALIAS(no_extcommunity_list_expanded_all
,
15270 no_bgp_extcommunity_list_expanded_all_list_cmd
,
15271 "no bgp extcommunity-list <(100-500)|expanded WORD>",
15272 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15273 "Extended Community list number (expanded)\n"
15274 "Specify expanded extcommunity-list\n"
15275 "Extended Community list name\n")
15277 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
15279 struct community_entry
*entry
;
15281 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15282 if (entry
== list
->head
) {
15283 if (all_digit(list
->name
))
15284 vty_out(vty
, "Extended community %s list %s\n",
15285 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15287 : "(expanded) access",
15291 "Named extended community %s list %s\n",
15292 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15298 vty_out(vty
, " %s\n",
15299 community_direct_str(entry
->direct
));
15301 vty_out(vty
, " %s %s\n",
15302 community_direct_str(entry
->direct
),
15303 community_list_config_str(entry
));
15307 DEFUN (show_extcommunity_list
,
15308 show_bgp_extcommunity_list_cmd
,
15309 "show bgp extcommunity-list",
15312 "List extended-community list\n")
15314 struct community_list
*list
;
15315 struct community_list_master
*cm
;
15318 if (argv_find(argv
, argc
, "ip", &idx
)) {
15319 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15320 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15321 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15322 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15324 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15326 return CMD_SUCCESS
;
15328 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15329 extcommunity_list_show(vty
, list
);
15331 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15332 extcommunity_list_show(vty
, list
);
15334 return CMD_SUCCESS
;
15337 ALIAS (show_extcommunity_list
,
15338 show_ip_extcommunity_list_cmd
,
15339 "show ip extcommunity-list",
15342 "List extended-community list\n")
15344 DEFUN (show_extcommunity_list_arg
,
15345 show_bgp_extcommunity_list_arg_cmd
,
15346 "show bgp extcommunity-list <(1-500)|WORD>",
15349 "List extended-community list\n"
15350 "Extcommunity-list number\n"
15351 "Extcommunity-list name\n")
15353 int idx_comm_list
= 3;
15354 struct community_list
*list
;
15357 if (argv_find(argv
, argc
, "ip", &idx
)) {
15358 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15359 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15360 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15361 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15363 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
15364 EXTCOMMUNITY_LIST_MASTER
);
15366 vty_out(vty
, "%% Can't find extcommunity-list\n");
15367 return CMD_WARNING
;
15370 extcommunity_list_show(vty
, list
);
15372 return CMD_SUCCESS
;
15375 ALIAS (show_extcommunity_list_arg
,
15376 show_ip_extcommunity_list_arg_cmd
,
15377 "show ip extcommunity-list <(1-500)|WORD>",
15380 "List extended-community list\n"
15381 "Extcommunity-list number\n"
15382 "Extcommunity-list name\n")
15384 /* Display community-list and extcommunity-list configuration. */
15385 static int community_list_config_write(struct vty
*vty
)
15387 struct community_list
*list
;
15388 struct community_entry
*entry
;
15389 struct community_list_master
*cm
;
15392 /* Community-list. */
15393 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
15395 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15396 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15397 vty_out(vty
, "bgp community-list %s %s %s\n", list
->name
,
15398 community_direct_str(entry
->direct
),
15399 community_list_config_str(entry
));
15402 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15403 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15404 vty_out(vty
, "bgp community-list %s %s %s %s\n",
15405 entry
->style
== COMMUNITY_LIST_STANDARD
15408 list
->name
, community_direct_str(entry
->direct
),
15409 community_list_config_str(entry
));
15413 /* Extcommunity-list. */
15414 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15416 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15417 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15418 vty_out(vty
, "bgp extcommunity-list %s %s %s\n",
15419 list
->name
, community_direct_str(entry
->direct
),
15420 community_list_config_str(entry
));
15423 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15424 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15425 vty_out(vty
, "bgp extcommunity-list %s %s %s %s\n",
15426 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15429 list
->name
, community_direct_str(entry
->direct
),
15430 community_list_config_str(entry
));
15435 /* lcommunity-list. */
15436 cm
= community_list_master_lookup(bgp_clist
,
15437 LARGE_COMMUNITY_LIST_MASTER
);
15439 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15440 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15441 vty_out(vty
, "bgp large-community-list %s %s %s\n",
15442 list
->name
, community_direct_str(entry
->direct
),
15443 community_list_config_str(entry
));
15446 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15447 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15448 vty_out(vty
, "bgp large-community-list %s %s %s %s\n",
15449 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
15452 list
->name
, community_direct_str(entry
->direct
),
15453 community_list_config_str(entry
));
15460 static struct cmd_node community_list_node
= {
15461 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
15464 static void community_list_vty(void)
15466 install_node(&community_list_node
, community_list_config_write
);
15468 /* Community-list. */
15469 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
15470 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
15471 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
15472 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
15473 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
15474 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
15475 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
15476 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
15477 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
15478 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
15479 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
15480 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_list_cmd
);
15481 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
15482 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_list_cmd
);
15483 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
15484 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
15486 /* Extcommunity-list. */
15487 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
15488 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
15489 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
15490 install_element(CONFIG_NODE
,
15491 &no_bgp_extcommunity_list_standard_all_list_cmd
);
15492 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
15493 install_element(CONFIG_NODE
,
15494 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
15495 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
15496 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
15497 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
15498 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
15499 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
15500 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_list_cmd
);
15501 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
15502 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_list_cmd
);
15503 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
15504 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
15506 /* Large Community List */
15507 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
15508 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard1_cmd
);
15509 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
15510 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
15511 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard1_cmd
);
15512 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
15513 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_all_cmd
);
15514 install_element(CONFIG_NODE
,
15515 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
15516 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
15517 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
15518 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
15519 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
15520 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
15521 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
15522 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
15523 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
15524 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
15525 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
15526 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
15527 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
15528 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
15529 install_element(CONFIG_NODE
,
15530 &no_ip_lcommunity_list_name_expanded_all_cmd
);
15531 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
15532 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
15533 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
15534 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
15535 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
15536 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);