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)$instasn [<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 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1003 bgp_vpn_leak_export(bgp
);
1004 /* Pending: handle when user tries to change a view to vrf n vv.
1008 /* unset the auto created flag as the user config is now present */
1009 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1010 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1015 /* "no router bgp" commands. */
1016 DEFUN (no_router_bgp
,
1018 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1023 BGP_INSTANCE_HELP_STR
)
1029 const char *name
= NULL
;
1031 // "no router bgp" without an ASN
1033 // Pending: Make VRF option available for ASN less config
1034 bgp
= bgp_get_default();
1037 vty_out(vty
, "%% No BGP process is configured\n");
1038 return CMD_WARNING_CONFIG_FAILED
;
1041 if (listcount(bm
->bgp
) > 1) {
1042 vty_out(vty
, "%% Please specify ASN and VRF\n");
1043 return CMD_WARNING_CONFIG_FAILED
;
1047 vty_out(vty
, "%% Please unconfigure l3vni %u",
1049 return CMD_WARNING_CONFIG_FAILED
;
1052 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1055 name
= argv
[idx_vrf
]->arg
;
1057 /* Lookup bgp structure. */
1058 bgp
= bgp_lookup(as
, name
);
1060 vty_out(vty
, "%% Can't find BGP instance\n");
1061 return CMD_WARNING_CONFIG_FAILED
;
1065 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1067 return CMD_WARNING_CONFIG_FAILED
;
1070 /* Cannot delete default instance if vrf instances exist */
1071 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1072 struct listnode
*node
;
1073 struct bgp
*tmp_bgp
;
1075 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1076 if (tmp_bgp
->inst_type
1077 == BGP_INSTANCE_TYPE_VRF
) {
1079 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1080 return CMD_WARNING_CONFIG_FAILED
;
1086 if (bgp_vpn_leak_unimport(bgp
, vty
))
1087 return CMD_WARNING_CONFIG_FAILED
;
1095 /* BGP router-id. */
1097 DEFPY (bgp_router_id
,
1099 "bgp router-id A.B.C.D",
1101 "Override configured router identifier\n"
1102 "Manually configured router identifier\n")
1104 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1105 bgp_router_id_static_set(bgp
, router_id
);
1109 DEFPY (no_bgp_router_id
,
1110 no_bgp_router_id_cmd
,
1111 "no bgp router-id [A.B.C.D]",
1114 "Override configured router identifier\n"
1115 "Manually configured router identifier\n")
1117 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1119 if (router_id_str
) {
1120 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1121 vty_out(vty
, "%% BGP router-id doesn't match\n");
1122 return CMD_WARNING_CONFIG_FAILED
;
1126 router_id
.s_addr
= 0;
1127 bgp_router_id_static_set(bgp
, router_id
);
1133 /* BGP Cluster ID. */
1134 DEFUN (bgp_cluster_id
,
1136 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1138 "Configure Route-Reflector Cluster-id\n"
1139 "Route-Reflector Cluster-id in IP address format\n"
1140 "Route-Reflector Cluster-id as 32 bit quantity\n")
1142 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1145 struct in_addr cluster
;
1147 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1149 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1150 return CMD_WARNING_CONFIG_FAILED
;
1153 bgp_cluster_id_set(bgp
, &cluster
);
1154 bgp_clear_star_soft_out(vty
, bgp
->name
);
1159 DEFUN (no_bgp_cluster_id
,
1160 no_bgp_cluster_id_cmd
,
1161 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1164 "Configure Route-Reflector Cluster-id\n"
1165 "Route-Reflector Cluster-id in IP address format\n"
1166 "Route-Reflector Cluster-id as 32 bit quantity\n")
1168 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1169 bgp_cluster_id_unset(bgp
);
1170 bgp_clear_star_soft_out(vty
, bgp
->name
);
1175 DEFUN (bgp_confederation_identifier
,
1176 bgp_confederation_identifier_cmd
,
1177 "bgp confederation identifier (1-4294967295)",
1178 "BGP specific commands\n"
1179 "AS confederation parameters\n"
1181 "Set routing domain confederation AS\n")
1183 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1187 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1189 bgp_confederation_id_set(bgp
, as
);
1194 DEFUN (no_bgp_confederation_identifier
,
1195 no_bgp_confederation_identifier_cmd
,
1196 "no bgp confederation identifier [(1-4294967295)]",
1198 "BGP specific commands\n"
1199 "AS confederation parameters\n"
1201 "Set routing domain confederation AS\n")
1203 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1204 bgp_confederation_id_unset(bgp
);
1209 DEFUN (bgp_confederation_peers
,
1210 bgp_confederation_peers_cmd
,
1211 "bgp confederation peers (1-4294967295)...",
1212 "BGP specific commands\n"
1213 "AS confederation parameters\n"
1214 "Peer ASs in BGP confederation\n"
1217 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1222 for (i
= idx_asn
; i
< argc
; i
++) {
1223 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1225 if (bgp
->as
== as
) {
1227 "%% Local member-AS not allowed in confed peer list\n");
1231 bgp_confederation_peers_add(bgp
, as
);
1236 DEFUN (no_bgp_confederation_peers
,
1237 no_bgp_confederation_peers_cmd
,
1238 "no bgp confederation peers (1-4294967295)...",
1240 "BGP specific commands\n"
1241 "AS confederation parameters\n"
1242 "Peer ASs in BGP confederation\n"
1245 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1250 for (i
= idx_asn
; i
< argc
; i
++) {
1251 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1253 bgp_confederation_peers_remove(bgp
, as
);
1259 * Central routine for maximum-paths configuration.
1260 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1261 * @set: 1 for setting values, 0 for removing the max-paths config.
1263 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1264 const char *mpaths
, uint16_t options
,
1267 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1268 uint16_t maxpaths
= 0;
1273 afi
= bgp_node_afi(vty
);
1274 safi
= bgp_node_safi(vty
);
1277 maxpaths
= strtol(mpaths
, NULL
, 10);
1278 if (maxpaths
> multipath_num
) {
1280 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1281 maxpaths
, multipath_num
);
1282 return CMD_WARNING_CONFIG_FAILED
;
1284 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1287 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1291 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1292 (set
== 1) ? "" : "un",
1293 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1294 maxpaths
, afi
, safi
);
1295 return CMD_WARNING_CONFIG_FAILED
;
1298 bgp_recalculate_all_bestpaths(bgp
);
1303 DEFUN (bgp_maxmed_admin
,
1304 bgp_maxmed_admin_cmd
,
1305 "bgp max-med administrative ",
1307 "Advertise routes with max-med\n"
1308 "Administratively applied, for an indefinite period\n")
1310 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1312 bgp
->v_maxmed_admin
= 1;
1313 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1315 bgp_maxmed_update(bgp
);
1320 DEFUN (bgp_maxmed_admin_medv
,
1321 bgp_maxmed_admin_medv_cmd
,
1322 "bgp max-med administrative (0-4294967295)",
1324 "Advertise routes with max-med\n"
1325 "Administratively applied, for an indefinite period\n"
1326 "Max MED value to be used\n")
1328 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1331 bgp
->v_maxmed_admin
= 1;
1332 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1334 bgp_maxmed_update(bgp
);
1339 DEFUN (no_bgp_maxmed_admin
,
1340 no_bgp_maxmed_admin_cmd
,
1341 "no bgp max-med administrative [(0-4294967295)]",
1344 "Advertise routes with max-med\n"
1345 "Administratively applied, for an indefinite period\n"
1346 "Max MED value to be used\n")
1348 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1349 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1350 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1351 bgp_maxmed_update(bgp
);
1356 DEFUN (bgp_maxmed_onstartup
,
1357 bgp_maxmed_onstartup_cmd
,
1358 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1360 "Advertise routes with max-med\n"
1361 "Effective on a startup\n"
1362 "Time (seconds) period for max-med\n"
1363 "Max MED value to be used\n")
1365 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1368 argv_find(argv
, argc
, "(5-86400)", &idx
);
1369 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1370 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1371 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1373 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1375 bgp_maxmed_update(bgp
);
1380 DEFUN (no_bgp_maxmed_onstartup
,
1381 no_bgp_maxmed_onstartup_cmd
,
1382 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1385 "Advertise routes with max-med\n"
1386 "Effective on a startup\n"
1387 "Time (seconds) period for max-med\n"
1388 "Max MED value to be used\n")
1390 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1392 /* Cancel max-med onstartup if its on */
1393 if (bgp
->t_maxmed_onstartup
) {
1394 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1395 bgp
->maxmed_onstartup_over
= 1;
1398 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1399 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1401 bgp_maxmed_update(bgp
);
1406 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1409 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1410 uint16_t update_delay
;
1411 uint16_t establish_wait
;
1413 update_delay
= strtoul(delay
, NULL
, 10);
1415 if (!wait
) /* update-delay <delay> */
1417 bgp
->v_update_delay
= update_delay
;
1418 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1422 /* update-delay <delay> <establish-wait> */
1423 establish_wait
= atoi(wait
);
1424 if (update_delay
< establish_wait
) {
1426 "%%Failed: update-delay less than the establish-wait!\n");
1427 return CMD_WARNING_CONFIG_FAILED
;
1430 bgp
->v_update_delay
= update_delay
;
1431 bgp
->v_establish_wait
= establish_wait
;
1436 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1438 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1440 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1441 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1446 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1448 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1449 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1450 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1451 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1457 /* Update-delay configuration */
1458 DEFUN (bgp_update_delay
,
1459 bgp_update_delay_cmd
,
1460 "update-delay (0-3600)",
1461 "Force initial delay for best-path and updates\n"
1465 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1468 DEFUN (bgp_update_delay_establish_wait
,
1469 bgp_update_delay_establish_wait_cmd
,
1470 "update-delay (0-3600) (1-3600)",
1471 "Force initial delay for best-path and updates\n"
1476 int idx_number_2
= 2;
1477 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1478 argv
[idx_number_2
]->arg
);
1481 /* Update-delay deconfiguration */
1482 DEFUN (no_bgp_update_delay
,
1483 no_bgp_update_delay_cmd
,
1484 "no update-delay [(0-3600) [(1-3600)]]",
1486 "Force initial delay for best-path and updates\n"
1490 return bgp_update_delay_deconfig_vty(vty
);
1494 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1497 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1500 uint32_t quanta
= strtoul(num
, NULL
, 10);
1501 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
,
1502 memory_order_relaxed
);
1504 atomic_store_explicit(&bgp
->wpkt_quanta
, BGP_WRITE_PACKET_MAX
,
1505 memory_order_relaxed
);
1511 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1514 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1517 uint32_t quanta
= strtoul(num
, NULL
, 10);
1518 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
,
1519 memory_order_relaxed
);
1521 atomic_store_explicit(&bgp
->rpkt_quanta
, BGP_READ_PACKET_MAX
,
1522 memory_order_relaxed
);
1528 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1531 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1532 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1533 vty_out(vty
, " write-quanta %d\n", quanta
);
1536 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1539 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1540 if (quanta
!= BGP_READ_PACKET_MAX
)
1541 vty_out(vty
, " read-quanta %d\n", quanta
);
1544 /* Packet quanta configuration */
1545 DEFUN (bgp_wpkt_quanta
,
1546 bgp_wpkt_quanta_cmd
,
1547 "write-quanta (1-10)",
1548 "How many packets to write to peer socket per run\n"
1549 "Number of packets\n")
1552 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1555 DEFUN (no_bgp_wpkt_quanta
,
1556 no_bgp_wpkt_quanta_cmd
,
1557 "no write-quanta (1-10)",
1559 "How many packets to write to peer socket per I/O cycle\n"
1560 "Number of packets\n")
1563 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1566 DEFUN (bgp_rpkt_quanta
,
1567 bgp_rpkt_quanta_cmd
,
1568 "read-quanta (1-10)",
1569 "How many packets to read from peer socket per I/O cycle\n"
1570 "Number of packets\n")
1573 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1576 DEFUN (no_bgp_rpkt_quanta
,
1577 no_bgp_rpkt_quanta_cmd
,
1578 "no read-quanta (1-10)",
1580 "How many packets to read from peer socket per I/O cycle\n"
1581 "Number of packets\n")
1584 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1587 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1589 if (!bgp
->heuristic_coalesce
)
1590 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1594 DEFUN (bgp_coalesce_time
,
1595 bgp_coalesce_time_cmd
,
1596 "coalesce-time (0-4294967295)",
1597 "Subgroup coalesce timer\n"
1598 "Subgroup coalesce timer value (in ms)\n")
1600 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1603 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1604 bgp
->heuristic_coalesce
= false;
1605 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1609 DEFUN (no_bgp_coalesce_time
,
1610 no_bgp_coalesce_time_cmd
,
1611 "no coalesce-time (0-4294967295)",
1613 "Subgroup coalesce timer\n"
1614 "Subgroup coalesce timer value (in ms)\n")
1616 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1618 bgp
->heuristic_coalesce
= true;
1619 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1623 /* Maximum-paths configuration */
1624 DEFUN (bgp_maxpaths
,
1626 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1627 "Forward packets over multiple paths\n"
1628 "Number of paths\n")
1631 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1632 argv
[idx_number
]->arg
, 0, 1);
1635 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1636 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1637 "Forward packets over multiple paths\n"
1638 "Number of paths\n")
1640 DEFUN (bgp_maxpaths_ibgp
,
1641 bgp_maxpaths_ibgp_cmd
,
1642 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1643 "Forward packets over multiple paths\n"
1645 "Number of paths\n")
1648 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1649 argv
[idx_number
]->arg
, 0, 1);
1652 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1653 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1654 "Forward packets over multiple paths\n"
1656 "Number of paths\n")
1658 DEFUN (bgp_maxpaths_ibgp_cluster
,
1659 bgp_maxpaths_ibgp_cluster_cmd
,
1660 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1661 "Forward packets over multiple paths\n"
1664 "Match the cluster length\n")
1667 return bgp_maxpaths_config_vty(
1668 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1669 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1672 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1673 "maximum-paths ibgp " CMD_RANGE_STR(
1674 1, MULTIPATH_NUM
) " equal-cluster-length",
1675 "Forward packets over multiple paths\n"
1678 "Match the cluster length\n")
1680 DEFUN (no_bgp_maxpaths
,
1681 no_bgp_maxpaths_cmd
,
1682 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1684 "Forward packets over multiple paths\n"
1685 "Number of paths\n")
1687 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1690 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1691 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1692 "Forward packets over multiple paths\n"
1693 "Number of paths\n")
1695 DEFUN (no_bgp_maxpaths_ibgp
,
1696 no_bgp_maxpaths_ibgp_cmd
,
1697 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1699 "Forward packets over multiple paths\n"
1702 "Match the cluster length\n")
1704 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1707 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1708 "no maximum-paths ibgp [" CMD_RANGE_STR(
1709 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1711 "Forward packets over multiple paths\n"
1714 "Match the cluster length\n")
1716 void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1719 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1720 vty_out(vty
, " maximum-paths %d\n",
1721 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1724 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1725 vty_out(vty
, " maximum-paths ibgp %d",
1726 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1727 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1728 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1729 vty_out(vty
, " equal-cluster-length");
1738 "timers bgp (0-65535) (0-65535)",
1739 "Adjust routing timers\n"
1741 "Keepalive interval\n"
1744 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1746 int idx_number_2
= 3;
1747 unsigned long keepalive
= 0;
1748 unsigned long holdtime
= 0;
1750 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1751 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1753 /* Holdtime value check. */
1754 if (holdtime
< 3 && holdtime
!= 0) {
1756 "%% hold time value must be either 0 or greater than 3\n");
1757 return CMD_WARNING_CONFIG_FAILED
;
1760 bgp_timers_set(bgp
, keepalive
, holdtime
);
1765 DEFUN (no_bgp_timers
,
1767 "no timers bgp [(0-65535) (0-65535)]",
1769 "Adjust routing timers\n"
1771 "Keepalive interval\n"
1774 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1775 bgp_timers_unset(bgp
);
1781 DEFUN (bgp_client_to_client_reflection
,
1782 bgp_client_to_client_reflection_cmd
,
1783 "bgp client-to-client reflection",
1784 "BGP specific commands\n"
1785 "Configure client to client route reflection\n"
1786 "reflection of routes allowed\n")
1788 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1789 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1790 bgp_clear_star_soft_out(vty
, bgp
->name
);
1795 DEFUN (no_bgp_client_to_client_reflection
,
1796 no_bgp_client_to_client_reflection_cmd
,
1797 "no bgp client-to-client reflection",
1799 "BGP specific commands\n"
1800 "Configure client to client route reflection\n"
1801 "reflection of routes allowed\n")
1803 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1804 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1805 bgp_clear_star_soft_out(vty
, bgp
->name
);
1810 /* "bgp always-compare-med" configuration. */
1811 DEFUN (bgp_always_compare_med
,
1812 bgp_always_compare_med_cmd
,
1813 "bgp always-compare-med",
1814 "BGP specific commands\n"
1815 "Allow comparing MED from different neighbors\n")
1817 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1818 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1819 bgp_recalculate_all_bestpaths(bgp
);
1824 DEFUN (no_bgp_always_compare_med
,
1825 no_bgp_always_compare_med_cmd
,
1826 "no bgp always-compare-med",
1828 "BGP specific commands\n"
1829 "Allow comparing MED from different neighbors\n")
1831 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1832 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1833 bgp_recalculate_all_bestpaths(bgp
);
1839 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
1840 "bgp ebgp-requires-policy",
1841 "BGP specific commands\n"
1842 "Require in and out policy for eBGP peers (RFC8212)\n")
1844 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1845 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_ENABLED
;
1849 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
1850 "no bgp ebgp-requires-policy",
1852 "BGP specific commands\n"
1853 "Require in and out policy for eBGP peers (RFC8212)\n")
1855 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1856 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_DISABLED
;
1861 /* "bgp deterministic-med" configuration. */
1862 DEFUN (bgp_deterministic_med
,
1863 bgp_deterministic_med_cmd
,
1864 "bgp deterministic-med",
1865 "BGP specific commands\n"
1866 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1868 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1870 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1871 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1872 bgp_recalculate_all_bestpaths(bgp
);
1878 DEFUN (no_bgp_deterministic_med
,
1879 no_bgp_deterministic_med_cmd
,
1880 "no bgp deterministic-med",
1882 "BGP specific commands\n"
1883 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1885 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1886 int bestpath_per_as_used
;
1890 struct listnode
*node
, *nnode
;
1892 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1893 bestpath_per_as_used
= 0;
1895 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1896 FOREACH_AFI_SAFI (afi
, safi
)
1897 if (bgp_addpath_dmed_required(
1898 peer
->addpath_type
[afi
][safi
])) {
1899 bestpath_per_as_used
= 1;
1903 if (bestpath_per_as_used
)
1907 if (bestpath_per_as_used
) {
1909 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
1910 return CMD_WARNING_CONFIG_FAILED
;
1912 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1913 bgp_recalculate_all_bestpaths(bgp
);
1920 /* "bgp graceful-restart" configuration. */
1921 DEFUN (bgp_graceful_restart
,
1922 bgp_graceful_restart_cmd
,
1923 "bgp graceful-restart",
1924 "BGP specific commands\n"
1925 "Graceful restart capability parameters\n")
1927 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1928 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1932 DEFUN (no_bgp_graceful_restart
,
1933 no_bgp_graceful_restart_cmd
,
1934 "no bgp graceful-restart",
1936 "BGP specific commands\n"
1937 "Graceful restart capability parameters\n")
1939 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1940 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1944 DEFUN (bgp_graceful_restart_stalepath_time
,
1945 bgp_graceful_restart_stalepath_time_cmd
,
1946 "bgp graceful-restart stalepath-time (1-4095)",
1947 "BGP specific commands\n"
1948 "Graceful restart capability parameters\n"
1949 "Set the max time to hold onto restarting peer's stale paths\n"
1950 "Delay value (seconds)\n")
1952 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1956 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1957 bgp
->stalepath_time
= stalepath
;
1961 DEFUN (bgp_graceful_restart_restart_time
,
1962 bgp_graceful_restart_restart_time_cmd
,
1963 "bgp graceful-restart restart-time (1-4095)",
1964 "BGP specific commands\n"
1965 "Graceful restart capability parameters\n"
1966 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1967 "Delay value (seconds)\n")
1969 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1973 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1974 bgp
->restart_time
= restart
;
1978 DEFUN (no_bgp_graceful_restart_stalepath_time
,
1979 no_bgp_graceful_restart_stalepath_time_cmd
,
1980 "no bgp graceful-restart stalepath-time [(1-4095)]",
1982 "BGP specific commands\n"
1983 "Graceful restart capability parameters\n"
1984 "Set the max time to hold onto restarting peer's stale paths\n"
1985 "Delay value (seconds)\n")
1987 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1989 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
1993 DEFUN (no_bgp_graceful_restart_restart_time
,
1994 no_bgp_graceful_restart_restart_time_cmd
,
1995 "no bgp graceful-restart restart-time [(1-4095)]",
1997 "BGP specific commands\n"
1998 "Graceful restart capability parameters\n"
1999 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2000 "Delay value (seconds)\n")
2002 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2004 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2008 DEFUN (bgp_graceful_restart_preserve_fw
,
2009 bgp_graceful_restart_preserve_fw_cmd
,
2010 "bgp graceful-restart preserve-fw-state",
2011 "BGP specific commands\n"
2012 "Graceful restart capability parameters\n"
2013 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2015 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2016 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2020 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2021 no_bgp_graceful_restart_preserve_fw_cmd
,
2022 "no bgp graceful-restart preserve-fw-state",
2024 "BGP specific commands\n"
2025 "Graceful restart capability parameters\n"
2026 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2028 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2029 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2033 /* "bgp graceful-shutdown" configuration */
2034 DEFUN (bgp_graceful_shutdown
,
2035 bgp_graceful_shutdown_cmd
,
2036 "bgp graceful-shutdown",
2038 "Graceful shutdown parameters\n")
2040 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2042 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2043 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2044 bgp_static_redo_import_check(bgp
);
2045 bgp_redistribute_redo(bgp
);
2046 bgp_clear_star_soft_out(vty
, bgp
->name
);
2047 bgp_clear_star_soft_in(vty
, bgp
->name
);
2053 DEFUN (no_bgp_graceful_shutdown
,
2054 no_bgp_graceful_shutdown_cmd
,
2055 "no bgp graceful-shutdown",
2058 "Graceful shutdown parameters\n")
2060 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2062 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2063 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2064 bgp_static_redo_import_check(bgp
);
2065 bgp_redistribute_redo(bgp
);
2066 bgp_clear_star_soft_out(vty
, bgp
->name
);
2067 bgp_clear_star_soft_in(vty
, bgp
->name
);
2073 /* "bgp fast-external-failover" configuration. */
2074 DEFUN (bgp_fast_external_failover
,
2075 bgp_fast_external_failover_cmd
,
2076 "bgp fast-external-failover",
2078 "Immediately reset session if a link to a directly connected external peer goes down\n")
2080 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2081 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2085 DEFUN (no_bgp_fast_external_failover
,
2086 no_bgp_fast_external_failover_cmd
,
2087 "no bgp fast-external-failover",
2090 "Immediately reset session if a link to a directly connected external peer goes down\n")
2092 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2093 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2097 /* "bgp bestpath compare-routerid" configuration. */
2098 DEFUN (bgp_bestpath_compare_router_id
,
2099 bgp_bestpath_compare_router_id_cmd
,
2100 "bgp bestpath compare-routerid",
2101 "BGP specific commands\n"
2102 "Change the default bestpath selection\n"
2103 "Compare router-id for identical EBGP paths\n")
2105 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2106 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2107 bgp_recalculate_all_bestpaths(bgp
);
2112 DEFUN (no_bgp_bestpath_compare_router_id
,
2113 no_bgp_bestpath_compare_router_id_cmd
,
2114 "no bgp bestpath compare-routerid",
2116 "BGP specific commands\n"
2117 "Change the default bestpath selection\n"
2118 "Compare router-id for identical EBGP paths\n")
2120 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2121 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2122 bgp_recalculate_all_bestpaths(bgp
);
2127 /* "bgp bestpath as-path ignore" configuration. */
2128 DEFUN (bgp_bestpath_aspath_ignore
,
2129 bgp_bestpath_aspath_ignore_cmd
,
2130 "bgp bestpath as-path ignore",
2131 "BGP specific commands\n"
2132 "Change the default bestpath selection\n"
2133 "AS-path attribute\n"
2134 "Ignore as-path length in selecting a route\n")
2136 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2137 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2138 bgp_recalculate_all_bestpaths(bgp
);
2143 DEFUN (no_bgp_bestpath_aspath_ignore
,
2144 no_bgp_bestpath_aspath_ignore_cmd
,
2145 "no bgp bestpath as-path ignore",
2147 "BGP specific commands\n"
2148 "Change the default bestpath selection\n"
2149 "AS-path attribute\n"
2150 "Ignore as-path length in selecting a route\n")
2152 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2153 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2154 bgp_recalculate_all_bestpaths(bgp
);
2159 /* "bgp bestpath as-path confed" configuration. */
2160 DEFUN (bgp_bestpath_aspath_confed
,
2161 bgp_bestpath_aspath_confed_cmd
,
2162 "bgp bestpath as-path confed",
2163 "BGP specific commands\n"
2164 "Change the default bestpath selection\n"
2165 "AS-path attribute\n"
2166 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2168 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2169 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2170 bgp_recalculate_all_bestpaths(bgp
);
2175 DEFUN (no_bgp_bestpath_aspath_confed
,
2176 no_bgp_bestpath_aspath_confed_cmd
,
2177 "no bgp bestpath as-path confed",
2179 "BGP specific commands\n"
2180 "Change the default bestpath selection\n"
2181 "AS-path attribute\n"
2182 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2184 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2185 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2186 bgp_recalculate_all_bestpaths(bgp
);
2191 /* "bgp bestpath as-path multipath-relax" configuration. */
2192 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2193 bgp_bestpath_aspath_multipath_relax_cmd
,
2194 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2195 "BGP specific commands\n"
2196 "Change the default bestpath selection\n"
2197 "AS-path attribute\n"
2198 "Allow load sharing across routes that have different AS paths (but same length)\n"
2199 "Generate an AS_SET\n"
2200 "Do not generate an AS_SET\n")
2202 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2204 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2206 /* no-as-set is now the default behavior so we can silently
2208 if (argv_find(argv
, argc
, "as-set", &idx
))
2209 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2211 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2213 bgp_recalculate_all_bestpaths(bgp
);
2218 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2219 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2220 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2222 "BGP specific commands\n"
2223 "Change the default bestpath selection\n"
2224 "AS-path attribute\n"
2225 "Allow load sharing across routes that have different AS paths (but same length)\n"
2226 "Generate an AS_SET\n"
2227 "Do not generate an AS_SET\n")
2229 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2230 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2231 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2232 bgp_recalculate_all_bestpaths(bgp
);
2237 /* "bgp log-neighbor-changes" configuration. */
2238 DEFUN (bgp_log_neighbor_changes
,
2239 bgp_log_neighbor_changes_cmd
,
2240 "bgp log-neighbor-changes",
2241 "BGP specific commands\n"
2242 "Log neighbor up/down and reset reason\n")
2244 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2245 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2249 DEFUN (no_bgp_log_neighbor_changes
,
2250 no_bgp_log_neighbor_changes_cmd
,
2251 "no bgp log-neighbor-changes",
2253 "BGP specific commands\n"
2254 "Log neighbor up/down and reset reason\n")
2256 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2257 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2261 /* "bgp bestpath med" configuration. */
2262 DEFUN (bgp_bestpath_med
,
2263 bgp_bestpath_med_cmd
,
2264 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2265 "BGP specific commands\n"
2266 "Change the default bestpath selection\n"
2268 "Compare MED among confederation paths\n"
2269 "Treat missing MED as the least preferred one\n"
2270 "Treat missing MED as the least preferred one\n"
2271 "Compare MED among confederation paths\n")
2273 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2276 if (argv_find(argv
, argc
, "confed", &idx
))
2277 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2279 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2280 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2282 bgp_recalculate_all_bestpaths(bgp
);
2287 DEFUN (no_bgp_bestpath_med
,
2288 no_bgp_bestpath_med_cmd
,
2289 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2291 "BGP specific commands\n"
2292 "Change the default bestpath selection\n"
2294 "Compare MED among confederation paths\n"
2295 "Treat missing MED as the least preferred one\n"
2296 "Treat missing MED as the least preferred one\n"
2297 "Compare MED among confederation paths\n")
2299 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2302 if (argv_find(argv
, argc
, "confed", &idx
))
2303 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2305 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2306 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2308 bgp_recalculate_all_bestpaths(bgp
);
2313 /* "no bgp default ipv4-unicast". */
2314 DEFUN (no_bgp_default_ipv4_unicast
,
2315 no_bgp_default_ipv4_unicast_cmd
,
2316 "no bgp default ipv4-unicast",
2318 "BGP specific commands\n"
2319 "Configure BGP defaults\n"
2320 "Activate ipv4-unicast for a peer by default\n")
2322 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2323 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2327 DEFUN (bgp_default_ipv4_unicast
,
2328 bgp_default_ipv4_unicast_cmd
,
2329 "bgp default ipv4-unicast",
2330 "BGP specific commands\n"
2331 "Configure BGP defaults\n"
2332 "Activate ipv4-unicast for a peer by default\n")
2334 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2335 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2339 /* Display hostname in certain command outputs */
2340 DEFUN (bgp_default_show_hostname
,
2341 bgp_default_show_hostname_cmd
,
2342 "bgp default show-hostname",
2343 "BGP specific commands\n"
2344 "Configure BGP defaults\n"
2345 "Show hostname in certain command outputs\n")
2347 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2348 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2352 DEFUN (no_bgp_default_show_hostname
,
2353 no_bgp_default_show_hostname_cmd
,
2354 "no bgp default show-hostname",
2356 "BGP specific commands\n"
2357 "Configure BGP defaults\n"
2358 "Show hostname in certain command outputs\n")
2360 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2361 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2365 /* "bgp network import-check" configuration. */
2366 DEFUN (bgp_network_import_check
,
2367 bgp_network_import_check_cmd
,
2368 "bgp network import-check",
2369 "BGP specific commands\n"
2370 "BGP network command\n"
2371 "Check BGP network route exists in IGP\n")
2373 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2374 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2375 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2376 bgp_static_redo_import_check(bgp
);
2382 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2383 "bgp network import-check exact",
2384 "BGP specific commands\n"
2385 "BGP network command\n"
2386 "Check BGP network route exists in IGP\n"
2387 "Match route precisely\n")
2389 DEFUN (no_bgp_network_import_check
,
2390 no_bgp_network_import_check_cmd
,
2391 "no bgp network import-check",
2393 "BGP specific commands\n"
2394 "BGP network command\n"
2395 "Check BGP network route exists in IGP\n")
2397 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2398 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2399 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2400 bgp_static_redo_import_check(bgp
);
2406 DEFUN (bgp_default_local_preference
,
2407 bgp_default_local_preference_cmd
,
2408 "bgp default local-preference (0-4294967295)",
2409 "BGP specific commands\n"
2410 "Configure BGP defaults\n"
2411 "local preference (higher=more preferred)\n"
2412 "Configure default local preference value\n")
2414 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2416 uint32_t local_pref
;
2418 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2420 bgp_default_local_preference_set(bgp
, local_pref
);
2421 bgp_clear_star_soft_in(vty
, bgp
->name
);
2426 DEFUN (no_bgp_default_local_preference
,
2427 no_bgp_default_local_preference_cmd
,
2428 "no bgp default local-preference [(0-4294967295)]",
2430 "BGP specific commands\n"
2431 "Configure BGP defaults\n"
2432 "local preference (higher=more preferred)\n"
2433 "Configure default local preference value\n")
2435 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2436 bgp_default_local_preference_unset(bgp
);
2437 bgp_clear_star_soft_in(vty
, bgp
->name
);
2443 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2444 bgp_default_subgroup_pkt_queue_max_cmd
,
2445 "bgp default subgroup-pkt-queue-max (20-100)",
2446 "BGP specific commands\n"
2447 "Configure BGP defaults\n"
2448 "subgroup-pkt-queue-max\n"
2449 "Configure subgroup packet queue max\n")
2451 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2455 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2457 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2462 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2463 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2464 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2466 "BGP specific commands\n"
2467 "Configure BGP defaults\n"
2468 "subgroup-pkt-queue-max\n"
2469 "Configure subgroup packet queue max\n")
2471 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2472 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2477 DEFUN (bgp_rr_allow_outbound_policy
,
2478 bgp_rr_allow_outbound_policy_cmd
,
2479 "bgp route-reflector allow-outbound-policy",
2480 "BGP specific commands\n"
2481 "Allow modifications made by out route-map\n"
2482 "on ibgp neighbors\n")
2484 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2486 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2487 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2488 update_group_announce_rrclients(bgp
);
2489 bgp_clear_star_soft_out(vty
, bgp
->name
);
2495 DEFUN (no_bgp_rr_allow_outbound_policy
,
2496 no_bgp_rr_allow_outbound_policy_cmd
,
2497 "no bgp route-reflector allow-outbound-policy",
2499 "BGP specific commands\n"
2500 "Allow modifications made by out route-map\n"
2501 "on ibgp neighbors\n")
2503 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2505 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2506 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2507 update_group_announce_rrclients(bgp
);
2508 bgp_clear_star_soft_out(vty
, bgp
->name
);
2514 DEFUN (bgp_listen_limit
,
2515 bgp_listen_limit_cmd
,
2516 "bgp listen limit (1-5000)",
2517 "BGP specific commands\n"
2518 "Configure BGP defaults\n"
2519 "maximum number of BGP Dynamic Neighbors that can be created\n"
2520 "Configure Dynamic Neighbors listen limit value\n")
2522 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2526 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2528 bgp_listen_limit_set(bgp
, listen_limit
);
2533 DEFUN (no_bgp_listen_limit
,
2534 no_bgp_listen_limit_cmd
,
2535 "no bgp listen limit [(1-5000)]",
2536 "BGP specific commands\n"
2537 "Configure BGP defaults\n"
2538 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2539 "Configure Dynamic Neighbors listen limit value to default\n"
2540 "Configure Dynamic Neighbors listen limit value\n")
2542 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2543 bgp_listen_limit_unset(bgp
);
2549 * Check if this listen range is already configured. Check for exact
2550 * match or overlap based on input.
2552 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2553 struct prefix
*range
, int exact
)
2555 struct listnode
*node
, *nnode
;
2556 struct listnode
*node1
, *nnode1
;
2557 struct peer_group
*group
;
2562 afi
= family2afi(range
->family
);
2563 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2564 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2567 match
= prefix_same(range
, lr
);
2569 match
= (prefix_match(range
, lr
)
2570 || prefix_match(lr
, range
));
2579 DEFUN (bgp_listen_range
,
2580 bgp_listen_range_cmd
,
2581 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
2582 "BGP specific commands\n"
2583 "Configure BGP dynamic neighbors listen range\n"
2584 "Configure BGP dynamic neighbors listen range\n"
2586 "Member of the peer-group\n"
2587 "Peer-group name\n")
2589 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2590 struct prefix range
;
2591 struct peer_group
*group
, *existing_group
;
2596 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2597 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2598 char *prefix
= argv
[idx
]->arg
;
2599 argv_find(argv
, argc
, "PGNAME", &idx
);
2600 char *peergroup
= argv
[idx
]->arg
;
2602 /* Convert IP prefix string to struct prefix. */
2603 ret
= str2prefix(prefix
, &range
);
2605 vty_out(vty
, "%% Malformed listen range\n");
2606 return CMD_WARNING_CONFIG_FAILED
;
2609 afi
= family2afi(range
.family
);
2611 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2613 "%% Malformed listen range (link-local address)\n");
2614 return CMD_WARNING_CONFIG_FAILED
;
2619 /* Check if same listen range is already configured. */
2620 existing_group
= listen_range_exists(bgp
, &range
, 1);
2621 if (existing_group
) {
2622 if (strcmp(existing_group
->name
, peergroup
) == 0)
2626 "%% Same listen range is attached to peer-group %s\n",
2627 existing_group
->name
);
2628 return CMD_WARNING_CONFIG_FAILED
;
2632 /* Check if an overlapping listen range exists. */
2633 if (listen_range_exists(bgp
, &range
, 0)) {
2635 "%% Listen range overlaps with existing listen range\n");
2636 return CMD_WARNING_CONFIG_FAILED
;
2639 group
= peer_group_lookup(bgp
, peergroup
);
2641 vty_out(vty
, "%% Configure the peer-group first\n");
2642 return CMD_WARNING_CONFIG_FAILED
;
2645 ret
= peer_group_listen_range_add(group
, &range
);
2646 return bgp_vty_return(vty
, ret
);
2649 DEFUN (no_bgp_listen_range
,
2650 no_bgp_listen_range_cmd
,
2651 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
2653 "BGP specific commands\n"
2654 "Unconfigure BGP dynamic neighbors listen range\n"
2655 "Unconfigure BGP dynamic neighbors listen range\n"
2657 "Member of the peer-group\n"
2658 "Peer-group name\n")
2660 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2661 struct prefix range
;
2662 struct peer_group
*group
;
2667 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2668 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2669 char *prefix
= argv
[idx
]->arg
;
2670 argv_find(argv
, argc
, "WORD", &idx
);
2671 char *peergroup
= argv
[idx
]->arg
;
2673 /* Convert IP prefix string to struct prefix. */
2674 ret
= str2prefix(prefix
, &range
);
2676 vty_out(vty
, "%% Malformed listen range\n");
2677 return CMD_WARNING_CONFIG_FAILED
;
2680 afi
= family2afi(range
.family
);
2682 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2684 "%% Malformed listen range (link-local address)\n");
2685 return CMD_WARNING_CONFIG_FAILED
;
2690 group
= peer_group_lookup(bgp
, peergroup
);
2692 vty_out(vty
, "%% Peer-group does not exist\n");
2693 return CMD_WARNING_CONFIG_FAILED
;
2696 ret
= peer_group_listen_range_del(group
, &range
);
2697 return bgp_vty_return(vty
, ret
);
2700 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2702 struct peer_group
*group
;
2703 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2704 struct prefix
*range
;
2706 char buf
[PREFIX2STR_BUFFER
];
2708 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2709 vty_out(vty
, " bgp listen limit %d\n",
2710 bgp
->dynamic_neighbors_limit
);
2712 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2713 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2714 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2716 prefix2str(range
, buf
, sizeof(buf
));
2718 " bgp listen range %s peer-group %s\n",
2726 DEFUN (bgp_disable_connected_route_check
,
2727 bgp_disable_connected_route_check_cmd
,
2728 "bgp disable-ebgp-connected-route-check",
2729 "BGP specific commands\n"
2730 "Disable checking if nexthop is connected on ebgp sessions\n")
2732 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2733 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2734 bgp_clear_star_soft_in(vty
, bgp
->name
);
2739 DEFUN (no_bgp_disable_connected_route_check
,
2740 no_bgp_disable_connected_route_check_cmd
,
2741 "no bgp disable-ebgp-connected-route-check",
2743 "BGP specific commands\n"
2744 "Disable checking if nexthop is connected on ebgp sessions\n")
2746 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2747 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2748 bgp_clear_star_soft_in(vty
, bgp
->name
);
2754 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2755 const char *as_str
, afi_t afi
, safi_t safi
)
2757 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2760 int as_type
= AS_SPECIFIED
;
2763 if (as_str
[0] == 'i') {
2765 as_type
= AS_INTERNAL
;
2766 } else if (as_str
[0] == 'e') {
2768 as_type
= AS_EXTERNAL
;
2770 /* Get AS number. */
2771 as
= strtoul(as_str
, NULL
, 10);
2774 /* If peer is peer group or interface peer, call proper function. */
2775 ret
= str2sockunion(peer_str
, &su
);
2779 /* Check if existing interface peer */
2780 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
2782 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2785 /* if not interface peer, check peer-group settings */
2786 if (ret
< 0 && !peer
) {
2787 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2790 "%% Create the peer-group or interface first\n");
2791 return CMD_WARNING_CONFIG_FAILED
;
2796 if (peer_address_self_check(bgp
, &su
)) {
2798 "%% Can not configure the local system as neighbor\n");
2799 return CMD_WARNING_CONFIG_FAILED
;
2801 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2804 /* This peer belongs to peer group. */
2806 case BGP_ERR_PEER_GROUP_MEMBER
:
2808 "%% Peer-group member cannot override remote-as of peer-group\n");
2809 return CMD_WARNING_CONFIG_FAILED
;
2810 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2812 "%% Peer-group members must be all internal or all external\n");
2813 return CMD_WARNING_CONFIG_FAILED
;
2815 return bgp_vty_return(vty
, ret
);
2818 DEFUN (bgp_default_shutdown
,
2819 bgp_default_shutdown_cmd
,
2820 "[no] bgp default shutdown",
2823 "Configure BGP defaults\n"
2824 "Apply administrative shutdown to newly configured peers\n")
2826 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2827 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2831 DEFUN (neighbor_remote_as
,
2832 neighbor_remote_as_cmd
,
2833 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2836 "Specify a BGP neighbor\n"
2838 "Internal BGP peer\n"
2839 "External BGP peer\n")
2842 int idx_remote_as
= 3;
2843 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2844 argv
[idx_remote_as
]->arg
, AFI_IP
,
2848 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2849 afi_t afi
, safi_t safi
, int v6only
,
2850 const char *peer_group_name
,
2853 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2855 int as_type
= AS_UNSPECIFIED
;
2857 struct peer_group
*group
;
2861 group
= peer_group_lookup(bgp
, conf_if
);
2864 vty_out(vty
, "%% Name conflict with peer-group \n");
2865 return CMD_WARNING_CONFIG_FAILED
;
2869 if (as_str
[0] == 'i') {
2870 as_type
= AS_INTERNAL
;
2871 } else if (as_str
[0] == 'e') {
2872 as_type
= AS_EXTERNAL
;
2874 /* Get AS number. */
2875 as
= strtoul(as_str
, NULL
, 10);
2876 as_type
= AS_SPECIFIED
;
2880 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2883 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
2886 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2887 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2888 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2889 as_type
, 0, 0, NULL
);
2891 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2892 as_type
, afi
, safi
, NULL
);
2895 vty_out(vty
, "%% BGP failed to create peer\n");
2896 return CMD_WARNING_CONFIG_FAILED
;
2900 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2902 /* Request zebra to initiate IPv6 RAs on this interface. We do
2904 * any unnumbered peer in order to not worry about run-time
2906 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2908 * gets deleted later etc.)
2911 bgp_zebra_initiate_radv(bgp
, peer
);
2914 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2915 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2917 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2919 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2921 /* v6only flag changed. Reset bgp seesion */
2922 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2923 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2924 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2925 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2927 bgp_session_reset(peer
);
2930 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
2931 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
2932 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
2933 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
2936 if (peer_group_name
) {
2937 group
= peer_group_lookup(bgp
, peer_group_name
);
2939 vty_out(vty
, "%% Configure the peer-group first\n");
2940 return CMD_WARNING_CONFIG_FAILED
;
2943 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
2946 return bgp_vty_return(vty
, ret
);
2949 DEFUN (neighbor_interface_config
,
2950 neighbor_interface_config_cmd
,
2951 "neighbor WORD interface [peer-group PGNAME]",
2953 "Interface name or neighbor tag\n"
2954 "Enable BGP on interface\n"
2955 "Member of the peer-group\n"
2956 "Peer-group name\n")
2959 int idx_peer_group_word
= 4;
2961 if (argc
> idx_peer_group_word
)
2962 return peer_conf_interface_get(
2963 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
2964 argv
[idx_peer_group_word
]->arg
, NULL
);
2966 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2967 SAFI_UNICAST
, 0, NULL
, NULL
);
2970 DEFUN (neighbor_interface_config_v6only
,
2971 neighbor_interface_config_v6only_cmd
,
2972 "neighbor WORD interface v6only [peer-group PGNAME]",
2974 "Interface name or neighbor tag\n"
2975 "Enable BGP on interface\n"
2976 "Enable BGP with v6 link-local only\n"
2977 "Member of the peer-group\n"
2978 "Peer-group name\n")
2981 int idx_peer_group_word
= 5;
2983 if (argc
> idx_peer_group_word
)
2984 return peer_conf_interface_get(
2985 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
2986 argv
[idx_peer_group_word
]->arg
, NULL
);
2988 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2989 SAFI_UNICAST
, 1, NULL
, NULL
);
2993 DEFUN (neighbor_interface_config_remote_as
,
2994 neighbor_interface_config_remote_as_cmd
,
2995 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
2997 "Interface name or neighbor tag\n"
2998 "Enable BGP on interface\n"
2999 "Specify a BGP neighbor\n"
3001 "Internal BGP peer\n"
3002 "External BGP peer\n")
3005 int idx_remote_as
= 4;
3006 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3007 SAFI_UNICAST
, 0, NULL
,
3008 argv
[idx_remote_as
]->arg
);
3011 DEFUN (neighbor_interface_v6only_config_remote_as
,
3012 neighbor_interface_v6only_config_remote_as_cmd
,
3013 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
3015 "Interface name or neighbor tag\n"
3016 "Enable BGP with v6 link-local only\n"
3017 "Enable BGP on interface\n"
3018 "Specify a BGP neighbor\n"
3020 "Internal BGP peer\n"
3021 "External BGP peer\n")
3024 int idx_remote_as
= 5;
3025 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3026 SAFI_UNICAST
, 1, NULL
,
3027 argv
[idx_remote_as
]->arg
);
3030 DEFUN (neighbor_peer_group
,
3031 neighbor_peer_group_cmd
,
3032 "neighbor WORD peer-group",
3034 "Interface name or neighbor tag\n"
3035 "Configure peer-group\n")
3037 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3040 struct peer_group
*group
;
3042 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3044 vty_out(vty
, "%% Name conflict with interface: \n");
3045 return CMD_WARNING_CONFIG_FAILED
;
3048 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
3050 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
3051 return CMD_WARNING_CONFIG_FAILED
;
3059 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3063 "Specify a BGP neighbor\n"
3065 "Internal BGP peer\n"
3066 "External BGP peer\n")
3068 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3072 struct peer_group
*group
;
3076 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3078 /* look up for neighbor by interface name config. */
3079 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3081 /* Request zebra to terminate IPv6 RAs on this
3084 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3089 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3091 peer_group_delete(group
);
3093 vty_out(vty
, "%% Create the peer-group first\n");
3094 return CMD_WARNING_CONFIG_FAILED
;
3097 peer
= peer_lookup(bgp
, &su
);
3099 if (peer_dynamic_neighbor(peer
)) {
3101 "%% Operation not allowed on a dynamic neighbor\n");
3102 return CMD_WARNING_CONFIG_FAILED
;
3105 other
= peer
->doppelganger
;
3107 if (other
&& other
->status
!= Deleted
)
3115 DEFUN (no_neighbor_interface_config
,
3116 no_neighbor_interface_config_cmd
,
3117 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
3121 "Configure BGP on interface\n"
3122 "Enable BGP with v6 link-local only\n"
3123 "Member of the peer-group\n"
3125 "Specify a BGP neighbor\n"
3127 "Internal BGP peer\n"
3128 "External BGP peer\n")
3130 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3134 /* look up for neighbor by interface name config. */
3135 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3137 /* Request zebra to terminate IPv6 RAs on this interface. */
3139 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3142 vty_out(vty
, "%% Create the bgp interface first\n");
3143 return CMD_WARNING_CONFIG_FAILED
;
3148 DEFUN (no_neighbor_peer_group
,
3149 no_neighbor_peer_group_cmd
,
3150 "no neighbor WORD peer-group",
3154 "Configure peer-group\n")
3156 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3158 struct peer_group
*group
;
3160 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3162 peer_group_delete(group
);
3164 vty_out(vty
, "%% Create the peer-group first\n");
3165 return CMD_WARNING_CONFIG_FAILED
;
3170 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3171 no_neighbor_interface_peer_group_remote_as_cmd
,
3172 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3175 "Interface name or neighbor tag\n"
3176 "Specify a BGP neighbor\n"
3178 "Internal BGP peer\n"
3179 "External BGP peer\n")
3181 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3183 struct peer_group
*group
;
3186 /* look up for neighbor by interface name config. */
3187 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3189 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
3193 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3195 peer_group_remote_as_delete(group
);
3197 vty_out(vty
, "%% Create the peer-group or interface first\n");
3198 return CMD_WARNING_CONFIG_FAILED
;
3203 DEFUN (neighbor_local_as
,
3204 neighbor_local_as_cmd
,
3205 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3208 "Specify a local-as number\n"
3209 "AS number used as local AS\n")
3217 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3219 return CMD_WARNING_CONFIG_FAILED
;
3221 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3222 ret
= peer_local_as_set(peer
, as
, 0, 0);
3223 return bgp_vty_return(vty
, ret
);
3226 DEFUN (neighbor_local_as_no_prepend
,
3227 neighbor_local_as_no_prepend_cmd
,
3228 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3231 "Specify a local-as number\n"
3232 "AS number used as local AS\n"
3233 "Do not prepend local-as to updates from ebgp peers\n")
3241 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3243 return CMD_WARNING_CONFIG_FAILED
;
3245 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3246 ret
= peer_local_as_set(peer
, as
, 1, 0);
3247 return bgp_vty_return(vty
, ret
);
3250 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3251 neighbor_local_as_no_prepend_replace_as_cmd
,
3252 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3255 "Specify a local-as number\n"
3256 "AS number used as local AS\n"
3257 "Do not prepend local-as to updates from ebgp peers\n"
3258 "Do not prepend local-as to updates from ibgp peers\n")
3266 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3268 return CMD_WARNING_CONFIG_FAILED
;
3270 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3271 ret
= peer_local_as_set(peer
, as
, 1, 1);
3272 return bgp_vty_return(vty
, ret
);
3275 DEFUN (no_neighbor_local_as
,
3276 no_neighbor_local_as_cmd
,
3277 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3281 "Specify a local-as number\n"
3282 "AS number used as local AS\n"
3283 "Do not prepend local-as to updates from ebgp peers\n"
3284 "Do not prepend local-as to updates from ibgp peers\n")
3290 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3292 return CMD_WARNING_CONFIG_FAILED
;
3294 ret
= peer_local_as_unset(peer
);
3295 return bgp_vty_return(vty
, ret
);
3299 DEFUN (neighbor_solo
,
3301 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3304 "Solo peer - part of its own update group\n")
3310 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3312 return CMD_WARNING_CONFIG_FAILED
;
3314 ret
= update_group_adjust_soloness(peer
, 1);
3315 return bgp_vty_return(vty
, ret
);
3318 DEFUN (no_neighbor_solo
,
3319 no_neighbor_solo_cmd
,
3320 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3324 "Solo peer - part of its own update group\n")
3330 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3332 return CMD_WARNING_CONFIG_FAILED
;
3334 ret
= update_group_adjust_soloness(peer
, 0);
3335 return bgp_vty_return(vty
, ret
);
3338 DEFUN (neighbor_password
,
3339 neighbor_password_cmd
,
3340 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3351 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3353 return CMD_WARNING_CONFIG_FAILED
;
3355 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3356 return bgp_vty_return(vty
, ret
);
3359 DEFUN (no_neighbor_password
,
3360 no_neighbor_password_cmd
,
3361 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3372 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3374 return CMD_WARNING_CONFIG_FAILED
;
3376 ret
= peer_password_unset(peer
);
3377 return bgp_vty_return(vty
, ret
);
3380 DEFUN (neighbor_activate
,
3381 neighbor_activate_cmd
,
3382 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3385 "Enable the Address Family for this Neighbor\n")
3391 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3393 return CMD_WARNING_CONFIG_FAILED
;
3395 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3396 return bgp_vty_return(vty
, ret
);
3399 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3400 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3401 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3402 "Enable the Address Family for this Neighbor\n")
3404 DEFUN (no_neighbor_activate
,
3405 no_neighbor_activate_cmd
,
3406 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3410 "Enable the Address Family for this Neighbor\n")
3417 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3419 return CMD_WARNING_CONFIG_FAILED
;
3421 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3422 return bgp_vty_return(vty
, ret
);
3425 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3426 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3427 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3428 "Enable the Address Family for this Neighbor\n")
3430 DEFUN (neighbor_set_peer_group
,
3431 neighbor_set_peer_group_cmd
,
3432 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3435 "Member of the peer-group\n"
3436 "Peer-group name\n")
3438 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3445 struct peer_group
*group
;
3447 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3449 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3451 vty_out(vty
, "%% Malformed address or name: %s\n",
3452 argv
[idx_peer
]->arg
);
3453 return CMD_WARNING_CONFIG_FAILED
;
3456 if (peer_address_self_check(bgp
, &su
)) {
3458 "%% Can not configure the local system as neighbor\n");
3459 return CMD_WARNING_CONFIG_FAILED
;
3462 /* Disallow for dynamic neighbor. */
3463 peer
= peer_lookup(bgp
, &su
);
3464 if (peer
&& peer_dynamic_neighbor(peer
)) {
3466 "%% Operation not allowed on a dynamic neighbor\n");
3467 return CMD_WARNING_CONFIG_FAILED
;
3471 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3473 vty_out(vty
, "%% Configure the peer-group first\n");
3474 return CMD_WARNING_CONFIG_FAILED
;
3477 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3479 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3481 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3483 return CMD_WARNING_CONFIG_FAILED
;
3486 return bgp_vty_return(vty
, ret
);
3489 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3490 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3491 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3492 "Member of the peer-group\n"
3493 "Peer-group name\n")
3495 DEFUN (no_neighbor_set_peer_group
,
3496 no_neighbor_set_peer_group_cmd
,
3497 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3501 "Member of the peer-group\n"
3502 "Peer-group name\n")
3504 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3509 struct peer_group
*group
;
3511 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3513 return CMD_WARNING_CONFIG_FAILED
;
3515 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3517 vty_out(vty
, "%% Configure the peer-group first\n");
3518 return CMD_WARNING_CONFIG_FAILED
;
3521 ret
= peer_delete(peer
);
3523 return bgp_vty_return(vty
, ret
);
3526 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3527 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3528 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3529 "Member of the peer-group\n"
3530 "Peer-group name\n")
3532 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3533 uint32_t flag
, int set
)
3538 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3540 return CMD_WARNING_CONFIG_FAILED
;
3543 * If 'neighbor <interface>', then this is for directly connected peers,
3544 * we should not accept disable-connected-check.
3546 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3548 "%s is directly connected peer, cannot accept disable-"
3549 "connected-check\n",
3551 return CMD_WARNING_CONFIG_FAILED
;
3554 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3555 peer_tx_shutdown_message_unset(peer
);
3558 ret
= peer_flag_set(peer
, flag
);
3560 ret
= peer_flag_unset(peer
, flag
);
3562 return bgp_vty_return(vty
, ret
);
3565 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3567 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3570 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3573 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3576 /* neighbor passive. */
3577 DEFUN (neighbor_passive
,
3578 neighbor_passive_cmd
,
3579 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3582 "Don't send open messages to this neighbor\n")
3585 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3588 DEFUN (no_neighbor_passive
,
3589 no_neighbor_passive_cmd
,
3590 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3594 "Don't send open messages to this neighbor\n")
3597 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3600 /* neighbor shutdown. */
3601 DEFUN (neighbor_shutdown_msg
,
3602 neighbor_shutdown_msg_cmd
,
3603 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3606 "Administratively shut down this neighbor\n"
3607 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3608 "Shutdown message\n")
3614 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3618 return CMD_WARNING_CONFIG_FAILED
;
3619 message
= argv_concat(argv
, argc
, 4);
3620 peer_tx_shutdown_message_set(peer
, message
);
3621 XFREE(MTYPE_TMP
, message
);
3624 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3627 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3628 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3629 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3630 "Administratively shut down this neighbor\n")
3632 DEFUN (no_neighbor_shutdown_msg
,
3633 no_neighbor_shutdown_msg_cmd
,
3634 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3638 "Administratively shut down this neighbor\n"
3639 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3640 "Shutdown message\n")
3644 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3645 PEER_FLAG_SHUTDOWN
);
3648 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3649 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3650 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3651 "Administratively shut down this neighbor\n")
3653 /* neighbor capability dynamic. */
3654 DEFUN (neighbor_capability_dynamic
,
3655 neighbor_capability_dynamic_cmd
,
3656 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3659 "Advertise capability to the peer\n"
3660 "Advertise dynamic capability to this neighbor\n")
3663 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3664 PEER_FLAG_DYNAMIC_CAPABILITY
);
3667 DEFUN (no_neighbor_capability_dynamic
,
3668 no_neighbor_capability_dynamic_cmd
,
3669 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3673 "Advertise capability to the peer\n"
3674 "Advertise dynamic capability to this neighbor\n")
3677 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3678 PEER_FLAG_DYNAMIC_CAPABILITY
);
3681 /* neighbor dont-capability-negotiate */
3682 DEFUN (neighbor_dont_capability_negotiate
,
3683 neighbor_dont_capability_negotiate_cmd
,
3684 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3687 "Do not perform capability negotiation\n")
3690 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3691 PEER_FLAG_DONT_CAPABILITY
);
3694 DEFUN (no_neighbor_dont_capability_negotiate
,
3695 no_neighbor_dont_capability_negotiate_cmd
,
3696 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3700 "Do not perform capability negotiation\n")
3703 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3704 PEER_FLAG_DONT_CAPABILITY
);
3707 /* neighbor capability extended next hop encoding */
3708 DEFUN (neighbor_capability_enhe
,
3709 neighbor_capability_enhe_cmd
,
3710 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3713 "Advertise capability to the peer\n"
3714 "Advertise extended next-hop capability to the peer\n")
3717 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3718 PEER_FLAG_CAPABILITY_ENHE
);
3721 DEFUN (no_neighbor_capability_enhe
,
3722 no_neighbor_capability_enhe_cmd
,
3723 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3727 "Advertise capability to the peer\n"
3728 "Advertise extended next-hop capability to the peer\n")
3731 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3732 PEER_FLAG_CAPABILITY_ENHE
);
3735 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3736 afi_t afi
, safi_t safi
, uint32_t flag
,
3742 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3744 return CMD_WARNING_CONFIG_FAILED
;
3747 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3749 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3751 return bgp_vty_return(vty
, ret
);
3754 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3755 afi_t afi
, safi_t safi
, uint32_t flag
)
3757 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3760 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3761 afi_t afi
, safi_t safi
, uint32_t flag
)
3763 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3766 /* neighbor capability orf prefix-list. */
3767 DEFUN (neighbor_capability_orf_prefix
,
3768 neighbor_capability_orf_prefix_cmd
,
3769 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3772 "Advertise capability to the peer\n"
3773 "Advertise ORF capability to the peer\n"
3774 "Advertise prefixlist ORF capability to this neighbor\n"
3775 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3776 "Capability to RECEIVE the ORF from this neighbor\n"
3777 "Capability to SEND the ORF to this neighbor\n")
3780 int idx_send_recv
= 5;
3783 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3784 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3785 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3786 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3787 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3788 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3790 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3791 return CMD_WARNING_CONFIG_FAILED
;
3794 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3795 bgp_node_safi(vty
), flag
);
3799 neighbor_capability_orf_prefix
,
3800 neighbor_capability_orf_prefix_hidden_cmd
,
3801 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3802 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3803 "Advertise capability to the peer\n"
3804 "Advertise ORF capability to the peer\n"
3805 "Advertise prefixlist ORF capability to this neighbor\n"
3806 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3807 "Capability to RECEIVE the ORF from this neighbor\n"
3808 "Capability to SEND the ORF to this neighbor\n")
3810 DEFUN (no_neighbor_capability_orf_prefix
,
3811 no_neighbor_capability_orf_prefix_cmd
,
3812 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3816 "Advertise capability to the peer\n"
3817 "Advertise ORF capability to the peer\n"
3818 "Advertise prefixlist ORF capability to this neighbor\n"
3819 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3820 "Capability to RECEIVE the ORF from this neighbor\n"
3821 "Capability to SEND the ORF to this neighbor\n")
3824 int idx_send_recv
= 6;
3827 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3828 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3829 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3830 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3831 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3832 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3834 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3835 return CMD_WARNING_CONFIG_FAILED
;
3838 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3839 bgp_node_afi(vty
), bgp_node_safi(vty
),
3844 no_neighbor_capability_orf_prefix
,
3845 no_neighbor_capability_orf_prefix_hidden_cmd
,
3846 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3847 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3848 "Advertise capability to the peer\n"
3849 "Advertise ORF capability to the peer\n"
3850 "Advertise prefixlist ORF capability to this neighbor\n"
3851 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3852 "Capability to RECEIVE the ORF from this neighbor\n"
3853 "Capability to SEND the ORF to this neighbor\n")
3855 /* neighbor next-hop-self. */
3856 DEFUN (neighbor_nexthop_self
,
3857 neighbor_nexthop_self_cmd
,
3858 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3861 "Disable the next hop calculation for this neighbor\n")
3864 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3865 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3868 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3869 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3870 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3871 "Disable the next hop calculation for this neighbor\n")
3873 /* neighbor next-hop-self. */
3874 DEFUN (neighbor_nexthop_self_force
,
3875 neighbor_nexthop_self_force_cmd
,
3876 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3879 "Disable the next hop calculation for this neighbor\n"
3880 "Set the next hop to self for reflected routes\n")
3883 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3885 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3888 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3889 neighbor_nexthop_self_force_hidden_cmd
,
3890 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3891 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3892 "Disable the next hop calculation for this neighbor\n"
3893 "Set the next hop to self for reflected routes\n")
3895 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3896 neighbor_nexthop_self_all_hidden_cmd
,
3897 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
3898 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3899 "Disable the next hop calculation for this neighbor\n"
3900 "Set the next hop to self for reflected routes\n")
3902 DEFUN (no_neighbor_nexthop_self
,
3903 no_neighbor_nexthop_self_cmd
,
3904 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3908 "Disable the next hop calculation for this neighbor\n")
3911 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3912 bgp_node_afi(vty
), bgp_node_safi(vty
),
3913 PEER_FLAG_NEXTHOP_SELF
);
3916 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3917 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3918 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3919 "Disable the next hop calculation for this neighbor\n")
3921 DEFUN (no_neighbor_nexthop_self_force
,
3922 no_neighbor_nexthop_self_force_cmd
,
3923 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3927 "Disable the next hop calculation for this neighbor\n"
3928 "Set the next hop to self for reflected routes\n")
3931 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3932 bgp_node_afi(vty
), bgp_node_safi(vty
),
3933 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3936 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3937 no_neighbor_nexthop_self_force_hidden_cmd
,
3938 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3939 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3940 "Disable the next hop calculation for this neighbor\n"
3941 "Set the next hop to self for reflected routes\n")
3943 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3944 no_neighbor_nexthop_self_all_hidden_cmd
,
3945 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
3946 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3947 "Disable the next hop calculation for this neighbor\n"
3948 "Set the next hop to self for reflected routes\n")
3950 /* neighbor as-override */
3951 DEFUN (neighbor_as_override
,
3952 neighbor_as_override_cmd
,
3953 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3956 "Override ASNs in outbound updates if aspath equals remote-as\n")
3959 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3960 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
3963 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
3964 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3965 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3966 "Override ASNs in outbound updates if aspath equals remote-as\n")
3968 DEFUN (no_neighbor_as_override
,
3969 no_neighbor_as_override_cmd
,
3970 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3974 "Override ASNs in outbound updates if aspath equals remote-as\n")
3977 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3978 bgp_node_afi(vty
), bgp_node_safi(vty
),
3979 PEER_FLAG_AS_OVERRIDE
);
3982 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
3983 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3984 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3985 "Override ASNs in outbound updates if aspath equals remote-as\n")
3987 /* neighbor remove-private-AS. */
3988 DEFUN (neighbor_remove_private_as
,
3989 neighbor_remove_private_as_cmd
,
3990 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3993 "Remove private ASNs in outbound updates\n")
3996 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3998 PEER_FLAG_REMOVE_PRIVATE_AS
);
4001 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
4002 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4003 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4004 "Remove private ASNs in outbound updates\n")
4006 DEFUN (neighbor_remove_private_as_all
,
4007 neighbor_remove_private_as_all_cmd
,
4008 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4011 "Remove private ASNs in outbound updates\n"
4012 "Apply to all AS numbers\n")
4015 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4017 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4020 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
4021 neighbor_remove_private_as_all_hidden_cmd
,
4022 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4023 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4024 "Remove private ASNs in outbound updates\n"
4025 "Apply to all AS numbers")
4027 DEFUN (neighbor_remove_private_as_replace_as
,
4028 neighbor_remove_private_as_replace_as_cmd
,
4029 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4032 "Remove private ASNs in outbound updates\n"
4033 "Replace private ASNs with our ASN in outbound updates\n")
4036 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4038 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4041 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
4042 neighbor_remove_private_as_replace_as_hidden_cmd
,
4043 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4044 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4045 "Remove private ASNs in outbound updates\n"
4046 "Replace private ASNs with our ASN in outbound updates\n")
4048 DEFUN (neighbor_remove_private_as_all_replace_as
,
4049 neighbor_remove_private_as_all_replace_as_cmd
,
4050 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4053 "Remove private ASNs in outbound updates\n"
4054 "Apply to all AS numbers\n"
4055 "Replace private ASNs with our ASN in outbound updates\n")
4058 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4060 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4064 neighbor_remove_private_as_all_replace_as
,
4065 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4066 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4067 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4068 "Remove private ASNs in outbound updates\n"
4069 "Apply to all AS numbers\n"
4070 "Replace private ASNs with our ASN in outbound updates\n")
4072 DEFUN (no_neighbor_remove_private_as
,
4073 no_neighbor_remove_private_as_cmd
,
4074 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4078 "Remove private ASNs in outbound updates\n")
4081 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4082 bgp_node_afi(vty
), bgp_node_safi(vty
),
4083 PEER_FLAG_REMOVE_PRIVATE_AS
);
4086 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4087 no_neighbor_remove_private_as_hidden_cmd
,
4088 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4089 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4090 "Remove private ASNs in outbound updates\n")
4092 DEFUN (no_neighbor_remove_private_as_all
,
4093 no_neighbor_remove_private_as_all_cmd
,
4094 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4098 "Remove private ASNs in outbound updates\n"
4099 "Apply to all AS numbers\n")
4102 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4103 bgp_node_afi(vty
), bgp_node_safi(vty
),
4104 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4107 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4108 no_neighbor_remove_private_as_all_hidden_cmd
,
4109 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4110 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4111 "Remove private ASNs in outbound updates\n"
4112 "Apply to all AS numbers\n")
4114 DEFUN (no_neighbor_remove_private_as_replace_as
,
4115 no_neighbor_remove_private_as_replace_as_cmd
,
4116 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4120 "Remove private ASNs in outbound updates\n"
4121 "Replace private ASNs with our ASN in outbound updates\n")
4124 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4125 bgp_node_afi(vty
), bgp_node_safi(vty
),
4126 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4129 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4130 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4131 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4132 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4133 "Remove private ASNs in outbound updates\n"
4134 "Replace private ASNs with our ASN in outbound updates\n")
4136 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4137 no_neighbor_remove_private_as_all_replace_as_cmd
,
4138 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4142 "Remove private ASNs in outbound updates\n"
4143 "Apply to all AS numbers\n"
4144 "Replace private ASNs with our ASN in outbound updates\n")
4147 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4148 bgp_node_afi(vty
), bgp_node_safi(vty
),
4149 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4153 no_neighbor_remove_private_as_all_replace_as
,
4154 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4155 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4156 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4157 "Remove private ASNs in outbound updates\n"
4158 "Apply to all AS numbers\n"
4159 "Replace private ASNs with our ASN in outbound updates\n")
4162 /* neighbor send-community. */
4163 DEFUN (neighbor_send_community
,
4164 neighbor_send_community_cmd
,
4165 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4168 "Send Community attribute to this neighbor\n")
4172 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4174 PEER_FLAG_SEND_COMMUNITY
);
4177 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4178 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4179 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4180 "Send Community attribute to this neighbor\n")
4182 DEFUN (no_neighbor_send_community
,
4183 no_neighbor_send_community_cmd
,
4184 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4188 "Send Community attribute to this neighbor\n")
4192 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4193 bgp_node_afi(vty
), bgp_node_safi(vty
),
4194 PEER_FLAG_SEND_COMMUNITY
);
4197 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4198 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4199 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4200 "Send Community attribute to this neighbor\n")
4202 /* neighbor send-community extended. */
4203 DEFUN (neighbor_send_community_type
,
4204 neighbor_send_community_type_cmd
,
4205 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4208 "Send Community attribute to this neighbor\n"
4209 "Send Standard and Extended Community attributes\n"
4210 "Send Standard, Large and Extended Community attributes\n"
4211 "Send Extended Community attributes\n"
4212 "Send Standard Community attributes\n"
4213 "Send Large Community attributes\n")
4217 const char *type
= argv
[argc
- 1]->text
;
4219 if (strmatch(type
, "standard")) {
4220 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4221 } else if (strmatch(type
, "extended")) {
4222 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4223 } else if (strmatch(type
, "large")) {
4224 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4225 } else if (strmatch(type
, "both")) {
4226 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4227 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4228 } else { /* if (strmatch(type, "all")) */
4229 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4230 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4231 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4234 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4235 bgp_node_safi(vty
), flag
);
4239 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4240 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4241 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4242 "Send Community attribute to this neighbor\n"
4243 "Send Standard and Extended Community attributes\n"
4244 "Send Standard, Large and Extended Community attributes\n"
4245 "Send Extended Community attributes\n"
4246 "Send Standard Community attributes\n"
4247 "Send Large Community attributes\n")
4249 DEFUN (no_neighbor_send_community_type
,
4250 no_neighbor_send_community_type_cmd
,
4251 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4255 "Send Community attribute to this neighbor\n"
4256 "Send Standard and Extended Community attributes\n"
4257 "Send Standard, Large and Extended Community attributes\n"
4258 "Send Extended Community attributes\n"
4259 "Send Standard Community attributes\n"
4260 "Send Large Community attributes\n")
4264 const char *type
= argv
[argc
- 1]->text
;
4266 if (strmatch(type
, "standard")) {
4267 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4268 } else if (strmatch(type
, "extended")) {
4269 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4270 } else if (strmatch(type
, "large")) {
4271 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4272 } else if (strmatch(type
, "both")) {
4273 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4274 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4275 } else { /* if (strmatch(type, "all")) */
4276 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4277 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4278 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4281 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4282 bgp_node_afi(vty
), bgp_node_safi(vty
),
4287 no_neighbor_send_community_type
,
4288 no_neighbor_send_community_type_hidden_cmd
,
4289 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4290 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4291 "Send Community attribute to this neighbor\n"
4292 "Send Standard and Extended Community attributes\n"
4293 "Send Standard, Large and Extended Community attributes\n"
4294 "Send Extended Community attributes\n"
4295 "Send Standard Community attributes\n"
4296 "Send Large Community attributes\n")
4298 /* neighbor soft-reconfig. */
4299 DEFUN (neighbor_soft_reconfiguration
,
4300 neighbor_soft_reconfiguration_cmd
,
4301 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4304 "Per neighbor soft reconfiguration\n"
4305 "Allow inbound soft reconfiguration for this neighbor\n")
4308 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4310 PEER_FLAG_SOFT_RECONFIG
);
4313 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4314 neighbor_soft_reconfiguration_hidden_cmd
,
4315 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4316 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4317 "Per neighbor soft reconfiguration\n"
4318 "Allow inbound soft reconfiguration for this neighbor\n")
4320 DEFUN (no_neighbor_soft_reconfiguration
,
4321 no_neighbor_soft_reconfiguration_cmd
,
4322 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4326 "Per neighbor soft reconfiguration\n"
4327 "Allow inbound soft reconfiguration for this neighbor\n")
4330 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4331 bgp_node_afi(vty
), bgp_node_safi(vty
),
4332 PEER_FLAG_SOFT_RECONFIG
);
4335 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4336 no_neighbor_soft_reconfiguration_hidden_cmd
,
4337 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4338 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4339 "Per neighbor soft reconfiguration\n"
4340 "Allow inbound soft reconfiguration for this neighbor\n")
4342 DEFUN (neighbor_route_reflector_client
,
4343 neighbor_route_reflector_client_cmd
,
4344 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4347 "Configure a neighbor as Route Reflector client\n")
4353 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4355 return CMD_WARNING_CONFIG_FAILED
;
4357 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4359 PEER_FLAG_REFLECTOR_CLIENT
);
4362 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4363 neighbor_route_reflector_client_hidden_cmd
,
4364 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4365 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4366 "Configure a neighbor as Route Reflector client\n")
4368 DEFUN (no_neighbor_route_reflector_client
,
4369 no_neighbor_route_reflector_client_cmd
,
4370 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4374 "Configure a neighbor as Route Reflector client\n")
4377 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4378 bgp_node_afi(vty
), bgp_node_safi(vty
),
4379 PEER_FLAG_REFLECTOR_CLIENT
);
4382 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4383 no_neighbor_route_reflector_client_hidden_cmd
,
4384 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4385 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4386 "Configure a neighbor as Route Reflector client\n")
4388 /* neighbor route-server-client. */
4389 DEFUN (neighbor_route_server_client
,
4390 neighbor_route_server_client_cmd
,
4391 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4394 "Configure a neighbor as Route Server client\n")
4399 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4401 return CMD_WARNING_CONFIG_FAILED
;
4402 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4404 PEER_FLAG_RSERVER_CLIENT
);
4407 ALIAS_HIDDEN(neighbor_route_server_client
,
4408 neighbor_route_server_client_hidden_cmd
,
4409 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4410 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4411 "Configure a neighbor as Route Server client\n")
4413 DEFUN (no_neighbor_route_server_client
,
4414 no_neighbor_route_server_client_cmd
,
4415 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4419 "Configure a neighbor as Route Server client\n")
4422 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4423 bgp_node_afi(vty
), bgp_node_safi(vty
),
4424 PEER_FLAG_RSERVER_CLIENT
);
4427 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4428 no_neighbor_route_server_client_hidden_cmd
,
4429 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4430 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4431 "Configure a neighbor as Route Server client\n")
4433 DEFUN (neighbor_nexthop_local_unchanged
,
4434 neighbor_nexthop_local_unchanged_cmd
,
4435 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4438 "Configure treatment of outgoing link-local nexthop attribute\n"
4439 "Leave link-local nexthop unchanged for this peer\n")
4442 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4444 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4447 DEFUN (no_neighbor_nexthop_local_unchanged
,
4448 no_neighbor_nexthop_local_unchanged_cmd
,
4449 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4453 "Configure treatment of outgoing link-local-nexthop attribute\n"
4454 "Leave link-local nexthop unchanged for this peer\n")
4457 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4458 bgp_node_afi(vty
), bgp_node_safi(vty
),
4459 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4462 DEFUN (neighbor_attr_unchanged
,
4463 neighbor_attr_unchanged_cmd
,
4464 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4467 "BGP attribute is propagated unchanged to this neighbor\n"
4468 "As-path attribute\n"
4469 "Nexthop attribute\n"
4473 char *peer_str
= argv
[1]->arg
;
4476 afi_t afi
= bgp_node_afi(vty
);
4477 safi_t safi
= bgp_node_safi(vty
);
4479 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4481 return CMD_WARNING_CONFIG_FAILED
;
4483 if (argv_find(argv
, argc
, "as-path", &idx
))
4484 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4486 if (argv_find(argv
, argc
, "next-hop", &idx
))
4487 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4489 if (argv_find(argv
, argc
, "med", &idx
))
4490 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4492 /* no flags means all of them! */
4494 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4495 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4496 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4498 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4499 && peer_af_flag_check(peer
, afi
, safi
,
4500 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4501 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4502 PEER_FLAG_AS_PATH_UNCHANGED
);
4505 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4506 && peer_af_flag_check(peer
, afi
, safi
,
4507 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4508 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4509 PEER_FLAG_NEXTHOP_UNCHANGED
);
4512 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4513 && peer_af_flag_check(peer
, afi
, safi
,
4514 PEER_FLAG_MED_UNCHANGED
)) {
4515 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4516 PEER_FLAG_MED_UNCHANGED
);
4520 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4524 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4525 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4526 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4527 "BGP attribute is propagated unchanged to this neighbor\n"
4528 "As-path attribute\n"
4529 "Nexthop attribute\n"
4532 DEFUN (no_neighbor_attr_unchanged
,
4533 no_neighbor_attr_unchanged_cmd
,
4534 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4538 "BGP attribute is propagated unchanged to this neighbor\n"
4539 "As-path attribute\n"
4540 "Nexthop attribute\n"
4544 char *peer
= argv
[2]->arg
;
4547 if (argv_find(argv
, argc
, "as-path", &idx
))
4548 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4550 if (argv_find(argv
, argc
, "next-hop", &idx
))
4551 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4553 if (argv_find(argv
, argc
, "med", &idx
))
4554 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4556 if (!flags
) // no flags means all of them!
4558 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4559 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4560 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4563 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4564 bgp_node_safi(vty
), flags
);
4568 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4569 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4570 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4571 "BGP attribute is propagated unchanged to this neighbor\n"
4572 "As-path attribute\n"
4573 "Nexthop attribute\n"
4576 /* EBGP multihop configuration. */
4577 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4578 const char *ttl_str
)
4583 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4585 return CMD_WARNING_CONFIG_FAILED
;
4588 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4593 ttl
= strtoul(ttl_str
, NULL
, 10);
4595 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4598 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4602 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4604 return CMD_WARNING_CONFIG_FAILED
;
4606 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4609 /* neighbor ebgp-multihop. */
4610 DEFUN (neighbor_ebgp_multihop
,
4611 neighbor_ebgp_multihop_cmd
,
4612 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4615 "Allow EBGP neighbors not on directly connected networks\n")
4618 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4621 DEFUN (neighbor_ebgp_multihop_ttl
,
4622 neighbor_ebgp_multihop_ttl_cmd
,
4623 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4626 "Allow EBGP neighbors not on directly connected networks\n"
4627 "maximum hop count\n")
4631 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4632 argv
[idx_number
]->arg
);
4635 DEFUN (no_neighbor_ebgp_multihop
,
4636 no_neighbor_ebgp_multihop_cmd
,
4637 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4641 "Allow EBGP neighbors not on directly connected networks\n"
4642 "maximum hop count\n")
4645 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4649 /* disable-connected-check */
4650 DEFUN (neighbor_disable_connected_check
,
4651 neighbor_disable_connected_check_cmd
,
4652 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4655 "one-hop away EBGP peer using loopback address\n"
4656 "Enforce EBGP neighbors perform multihop\n")
4659 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4660 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4663 DEFUN (no_neighbor_disable_connected_check
,
4664 no_neighbor_disable_connected_check_cmd
,
4665 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4669 "one-hop away EBGP peer using loopback address\n"
4670 "Enforce EBGP neighbors perform multihop\n")
4673 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4674 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4678 /* enforce-first-as */
4679 DEFUN (neighbor_enforce_first_as
,
4680 neighbor_enforce_first_as_cmd
,
4681 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4684 "Enforce the first AS for EBGP routes\n")
4688 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4689 PEER_FLAG_ENFORCE_FIRST_AS
);
4692 DEFUN (no_neighbor_enforce_first_as
,
4693 no_neighbor_enforce_first_as_cmd
,
4694 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4698 "Enforce the first AS for EBGP routes\n")
4702 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4703 PEER_FLAG_ENFORCE_FIRST_AS
);
4707 DEFUN (neighbor_description
,
4708 neighbor_description_cmd
,
4709 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4712 "Neighbor specific description\n"
4713 "Up to 80 characters describing this neighbor\n")
4720 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4722 return CMD_WARNING_CONFIG_FAILED
;
4724 str
= argv_concat(argv
, argc
, idx_line
);
4726 peer_description_set(peer
, str
);
4728 XFREE(MTYPE_TMP
, str
);
4733 DEFUN (no_neighbor_description
,
4734 no_neighbor_description_cmd
,
4735 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4739 "Neighbor specific description\n")
4744 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4746 return CMD_WARNING_CONFIG_FAILED
;
4748 peer_description_unset(peer
);
4753 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4754 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4755 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4756 "Neighbor specific description\n"
4757 "Up to 80 characters describing this neighbor\n")
4759 /* Neighbor update-source. */
4760 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4761 const char *source_str
)
4767 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4769 return CMD_WARNING_CONFIG_FAILED
;
4775 if (str2sockunion(source_str
, &su
) == 0)
4776 peer_update_source_addr_set(peer
, &su
);
4778 if (str2prefix(source_str
, &p
)) {
4780 "%% Invalid update-source, remove prefix length \n");
4781 return CMD_WARNING_CONFIG_FAILED
;
4783 peer_update_source_if_set(peer
, source_str
);
4786 peer_update_source_unset(peer
);
4791 #define BGP_UPDATE_SOURCE_HELP_STR \
4794 "Interface name (requires zebra to be running)\n"
4796 DEFUN (neighbor_update_source
,
4797 neighbor_update_source_cmd
,
4798 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4801 "Source of routing updates\n"
4802 BGP_UPDATE_SOURCE_HELP_STR
)
4806 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4807 argv
[idx_peer_2
]->arg
);
4810 DEFUN (no_neighbor_update_source
,
4811 no_neighbor_update_source_cmd
,
4812 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4816 "Source of routing updates\n"
4817 BGP_UPDATE_SOURCE_HELP_STR
)
4820 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4823 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4824 afi_t afi
, safi_t safi
,
4825 const char *rmap
, int set
)
4829 struct route_map
*route_map
= NULL
;
4831 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4833 return CMD_WARNING_CONFIG_FAILED
;
4837 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
4838 ret
= peer_default_originate_set(peer
, afi
, safi
,
4841 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4843 return bgp_vty_return(vty
, ret
);
4846 /* neighbor default-originate. */
4847 DEFUN (neighbor_default_originate
,
4848 neighbor_default_originate_cmd
,
4849 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4852 "Originate default route to this neighbor\n")
4855 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4857 bgp_node_safi(vty
), NULL
, 1);
4860 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4861 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4862 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4863 "Originate default route to this neighbor\n")
4865 DEFUN (neighbor_default_originate_rmap
,
4866 neighbor_default_originate_rmap_cmd
,
4867 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4870 "Originate default route to this neighbor\n"
4871 "Route-map to specify criteria to originate default\n"
4876 return peer_default_originate_set_vty(
4877 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4878 argv
[idx_word
]->arg
, 1);
4882 neighbor_default_originate_rmap
,
4883 neighbor_default_originate_rmap_hidden_cmd
,
4884 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4885 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4886 "Originate default route to this neighbor\n"
4887 "Route-map to specify criteria to originate default\n"
4890 DEFUN (no_neighbor_default_originate
,
4891 no_neighbor_default_originate_cmd
,
4892 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4896 "Originate default route to this neighbor\n"
4897 "Route-map to specify criteria to originate default\n"
4901 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4903 bgp_node_safi(vty
), NULL
, 0);
4907 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4908 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4909 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4910 "Originate default route to this neighbor\n"
4911 "Route-map to specify criteria to originate default\n"
4915 /* Set neighbor's BGP port. */
4916 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4917 const char *port_str
)
4923 peer
= peer_lookup_vty(vty
, ip_str
);
4925 return CMD_WARNING_CONFIG_FAILED
;
4928 sp
= getservbyname("bgp", "tcp");
4929 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
4931 port
= strtoul(port_str
, NULL
, 10);
4934 peer_port_set(peer
, port
);
4939 /* Set specified peer's BGP port. */
4940 DEFUN (neighbor_port
,
4942 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
4945 "Neighbor's BGP port\n"
4946 "TCP port number\n")
4950 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
4951 argv
[idx_number
]->arg
);
4954 DEFUN (no_neighbor_port
,
4955 no_neighbor_port_cmd
,
4956 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
4960 "Neighbor's BGP port\n"
4961 "TCP port number\n")
4964 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
4968 /* neighbor weight. */
4969 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4970 safi_t safi
, const char *weight_str
)
4974 unsigned long weight
;
4976 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4978 return CMD_WARNING_CONFIG_FAILED
;
4980 weight
= strtoul(weight_str
, NULL
, 10);
4982 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
4983 return bgp_vty_return(vty
, ret
);
4986 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4992 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4994 return CMD_WARNING_CONFIG_FAILED
;
4996 ret
= peer_weight_unset(peer
, afi
, safi
);
4997 return bgp_vty_return(vty
, ret
);
5000 DEFUN (neighbor_weight
,
5001 neighbor_weight_cmd
,
5002 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5005 "Set default weight for routes from this neighbor\n"
5010 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5011 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
5014 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
5015 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5016 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5017 "Set default weight for routes from this neighbor\n"
5020 DEFUN (no_neighbor_weight
,
5021 no_neighbor_weight_cmd
,
5022 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5026 "Set default weight for routes from this neighbor\n"
5030 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
5031 bgp_node_afi(vty
), bgp_node_safi(vty
));
5034 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
5035 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5036 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5037 "Set default weight for routes from this neighbor\n"
5041 /* Override capability negotiation. */
5042 DEFUN (neighbor_override_capability
,
5043 neighbor_override_capability_cmd
,
5044 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5047 "Override capability negotiation result\n")
5050 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5051 PEER_FLAG_OVERRIDE_CAPABILITY
);
5054 DEFUN (no_neighbor_override_capability
,
5055 no_neighbor_override_capability_cmd
,
5056 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5060 "Override capability negotiation result\n")
5063 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5064 PEER_FLAG_OVERRIDE_CAPABILITY
);
5067 DEFUN (neighbor_strict_capability
,
5068 neighbor_strict_capability_cmd
,
5069 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5072 "Strict capability negotiation match\n")
5076 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5077 PEER_FLAG_STRICT_CAP_MATCH
);
5080 DEFUN (no_neighbor_strict_capability
,
5081 no_neighbor_strict_capability_cmd
,
5082 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5086 "Strict capability negotiation match\n")
5090 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5091 PEER_FLAG_STRICT_CAP_MATCH
);
5094 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5095 const char *keep_str
, const char *hold_str
)
5102 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5104 return CMD_WARNING_CONFIG_FAILED
;
5106 keepalive
= strtoul(keep_str
, NULL
, 10);
5107 holdtime
= strtoul(hold_str
, NULL
, 10);
5109 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5111 return bgp_vty_return(vty
, ret
);
5114 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5119 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5121 return CMD_WARNING_CONFIG_FAILED
;
5123 ret
= peer_timers_unset(peer
);
5125 return bgp_vty_return(vty
, ret
);
5128 DEFUN (neighbor_timers
,
5129 neighbor_timers_cmd
,
5130 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5133 "BGP per neighbor timers\n"
5134 "Keepalive interval\n"
5139 int idx_number_2
= 4;
5140 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5141 argv
[idx_number
]->arg
,
5142 argv
[idx_number_2
]->arg
);
5145 DEFUN (no_neighbor_timers
,
5146 no_neighbor_timers_cmd
,
5147 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5151 "BGP per neighbor timers\n"
5152 "Keepalive interval\n"
5156 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5160 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5161 const char *time_str
)
5167 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5169 return CMD_WARNING_CONFIG_FAILED
;
5171 connect
= strtoul(time_str
, NULL
, 10);
5173 ret
= peer_timers_connect_set(peer
, connect
);
5175 return bgp_vty_return(vty
, ret
);
5178 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5183 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5185 return CMD_WARNING_CONFIG_FAILED
;
5187 ret
= peer_timers_connect_unset(peer
);
5189 return bgp_vty_return(vty
, ret
);
5192 DEFUN (neighbor_timers_connect
,
5193 neighbor_timers_connect_cmd
,
5194 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5197 "BGP per neighbor timers\n"
5198 "BGP connect timer\n"
5203 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5204 argv
[idx_number
]->arg
);
5207 DEFUN (no_neighbor_timers_connect
,
5208 no_neighbor_timers_connect_cmd
,
5209 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5213 "BGP per neighbor timers\n"
5214 "BGP connect timer\n"
5218 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5222 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5223 const char *time_str
, int set
)
5227 uint32_t routeadv
= 0;
5229 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5231 return CMD_WARNING_CONFIG_FAILED
;
5234 routeadv
= strtoul(time_str
, NULL
, 10);
5237 ret
= peer_advertise_interval_set(peer
, routeadv
);
5239 ret
= peer_advertise_interval_unset(peer
);
5241 return bgp_vty_return(vty
, ret
);
5244 DEFUN (neighbor_advertise_interval
,
5245 neighbor_advertise_interval_cmd
,
5246 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5249 "Minimum interval between sending BGP routing updates\n"
5250 "time in seconds\n")
5254 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5255 argv
[idx_number
]->arg
, 1);
5258 DEFUN (no_neighbor_advertise_interval
,
5259 no_neighbor_advertise_interval_cmd
,
5260 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5264 "Minimum interval between sending BGP routing updates\n"
5265 "time in seconds\n")
5268 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5272 /* Time to wait before processing route-map updates */
5273 DEFUN (bgp_set_route_map_delay_timer
,
5274 bgp_set_route_map_delay_timer_cmd
,
5275 "bgp route-map delay-timer (0-600)",
5277 "BGP route-map delay timer\n"
5278 "Time in secs to wait before processing route-map changes\n"
5279 "0 disables the timer, no route updates happen when route-maps change\n")
5282 uint32_t rmap_delay_timer
;
5284 if (argv
[idx_number
]->arg
) {
5285 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5286 bm
->rmap_update_timer
= rmap_delay_timer
;
5288 /* if the dynamic update handling is being disabled, and a timer
5290 * running, stop the timer and act as if the timer has already
5293 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5294 BGP_TIMER_OFF(bm
->t_rmap_update
);
5295 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5300 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5301 return CMD_WARNING_CONFIG_FAILED
;
5305 DEFUN (no_bgp_set_route_map_delay_timer
,
5306 no_bgp_set_route_map_delay_timer_cmd
,
5307 "no bgp route-map delay-timer [(0-600)]",
5310 "Default BGP route-map delay timer\n"
5311 "Reset to default time to wait for processing route-map changes\n"
5312 "0 disables the timer, no route updates happen when route-maps change\n")
5315 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5321 /* neighbor interface */
5322 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5327 peer
= peer_lookup_vty(vty
, ip_str
);
5328 if (!peer
|| peer
->conf_if
) {
5329 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5330 return CMD_WARNING_CONFIG_FAILED
;
5334 peer_interface_set(peer
, str
);
5336 peer_interface_unset(peer
);
5341 DEFUN (neighbor_interface
,
5342 neighbor_interface_cmd
,
5343 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5351 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5354 DEFUN (no_neighbor_interface
,
5355 no_neighbor_interface_cmd
,
5356 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5364 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5367 DEFUN (neighbor_distribute_list
,
5368 neighbor_distribute_list_cmd
,
5369 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5372 "Filter updates to/from this neighbor\n"
5373 "IP access-list number\n"
5374 "IP access-list number (expanded range)\n"
5375 "IP Access-list name\n"
5376 "Filter incoming updates\n"
5377 "Filter outgoing updates\n")
5384 const char *pstr
= argv
[idx_peer
]->arg
;
5385 const char *acl
= argv
[idx_acl
]->arg
;
5386 const char *inout
= argv
[argc
- 1]->text
;
5388 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5390 return CMD_WARNING_CONFIG_FAILED
;
5392 /* Check filter direction. */
5393 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5394 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5397 return bgp_vty_return(vty
, ret
);
5401 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5402 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5403 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5404 "Filter updates to/from this neighbor\n"
5405 "IP access-list number\n"
5406 "IP access-list number (expanded range)\n"
5407 "IP Access-list name\n"
5408 "Filter incoming updates\n"
5409 "Filter outgoing updates\n")
5411 DEFUN (no_neighbor_distribute_list
,
5412 no_neighbor_distribute_list_cmd
,
5413 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5417 "Filter updates to/from this neighbor\n"
5418 "IP access-list number\n"
5419 "IP access-list number (expanded range)\n"
5420 "IP Access-list name\n"
5421 "Filter incoming updates\n"
5422 "Filter outgoing updates\n")
5428 const char *pstr
= argv
[idx_peer
]->arg
;
5429 const char *inout
= argv
[argc
- 1]->text
;
5431 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5433 return CMD_WARNING_CONFIG_FAILED
;
5435 /* Check filter direction. */
5436 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5437 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5440 return bgp_vty_return(vty
, ret
);
5444 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5445 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5446 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5447 "Filter updates to/from this neighbor\n"
5448 "IP access-list number\n"
5449 "IP access-list number (expanded range)\n"
5450 "IP Access-list name\n"
5451 "Filter incoming updates\n"
5452 "Filter outgoing updates\n")
5454 /* Set prefix list to the peer. */
5455 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5456 afi_t afi
, safi_t safi
,
5457 const char *name_str
,
5458 const char *direct_str
)
5461 int direct
= FILTER_IN
;
5464 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5466 return CMD_WARNING_CONFIG_FAILED
;
5468 /* Check filter direction. */
5469 if (strncmp(direct_str
, "i", 1) == 0)
5471 else if (strncmp(direct_str
, "o", 1) == 0)
5472 direct
= FILTER_OUT
;
5474 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5476 return bgp_vty_return(vty
, ret
);
5479 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5480 afi_t afi
, safi_t safi
,
5481 const char *direct_str
)
5485 int direct
= FILTER_IN
;
5487 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5489 return CMD_WARNING_CONFIG_FAILED
;
5491 /* Check filter direction. */
5492 if (strncmp(direct_str
, "i", 1) == 0)
5494 else if (strncmp(direct_str
, "o", 1) == 0)
5495 direct
= FILTER_OUT
;
5497 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5499 return bgp_vty_return(vty
, ret
);
5502 DEFUN (neighbor_prefix_list
,
5503 neighbor_prefix_list_cmd
,
5504 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5507 "Filter updates to/from this neighbor\n"
5508 "Name of a prefix list\n"
5509 "Filter incoming updates\n"
5510 "Filter outgoing updates\n")
5515 return peer_prefix_list_set_vty(
5516 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5517 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5520 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5521 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5522 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5523 "Filter updates to/from this neighbor\n"
5524 "Name of a prefix list\n"
5525 "Filter incoming updates\n"
5526 "Filter outgoing updates\n")
5528 DEFUN (no_neighbor_prefix_list
,
5529 no_neighbor_prefix_list_cmd
,
5530 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5534 "Filter updates to/from this neighbor\n"
5535 "Name of a prefix list\n"
5536 "Filter incoming updates\n"
5537 "Filter outgoing updates\n")
5541 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5542 bgp_node_afi(vty
), bgp_node_safi(vty
),
5543 argv
[idx_in_out
]->arg
);
5546 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5547 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5548 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5549 "Filter updates to/from this neighbor\n"
5550 "Name of a prefix list\n"
5551 "Filter incoming updates\n"
5552 "Filter outgoing updates\n")
5554 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5555 safi_t safi
, const char *name_str
,
5556 const char *direct_str
)
5560 int direct
= FILTER_IN
;
5562 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5564 return CMD_WARNING_CONFIG_FAILED
;
5566 /* Check filter direction. */
5567 if (strncmp(direct_str
, "i", 1) == 0)
5569 else if (strncmp(direct_str
, "o", 1) == 0)
5570 direct
= FILTER_OUT
;
5572 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5574 return bgp_vty_return(vty
, ret
);
5577 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5578 safi_t safi
, const char *direct_str
)
5582 int direct
= FILTER_IN
;
5584 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5586 return CMD_WARNING_CONFIG_FAILED
;
5588 /* Check filter direction. */
5589 if (strncmp(direct_str
, "i", 1) == 0)
5591 else if (strncmp(direct_str
, "o", 1) == 0)
5592 direct
= FILTER_OUT
;
5594 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5596 return bgp_vty_return(vty
, ret
);
5599 DEFUN (neighbor_filter_list
,
5600 neighbor_filter_list_cmd
,
5601 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5604 "Establish BGP filters\n"
5605 "AS path access-list name\n"
5606 "Filter incoming routes\n"
5607 "Filter outgoing routes\n")
5612 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5613 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5614 argv
[idx_in_out
]->arg
);
5617 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5618 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5619 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5620 "Establish BGP filters\n"
5621 "AS path access-list name\n"
5622 "Filter incoming routes\n"
5623 "Filter outgoing routes\n")
5625 DEFUN (no_neighbor_filter_list
,
5626 no_neighbor_filter_list_cmd
,
5627 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5631 "Establish BGP filters\n"
5632 "AS path access-list name\n"
5633 "Filter incoming routes\n"
5634 "Filter outgoing routes\n")
5638 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5639 bgp_node_afi(vty
), bgp_node_safi(vty
),
5640 argv
[idx_in_out
]->arg
);
5643 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5644 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5645 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5646 "Establish BGP filters\n"
5647 "AS path access-list name\n"
5648 "Filter incoming routes\n"
5649 "Filter outgoing routes\n")
5651 /* Set route-map to the peer. */
5652 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5653 afi_t afi
, safi_t safi
, const char *name_str
,
5654 const char *direct_str
)
5658 int direct
= RMAP_IN
;
5659 struct route_map
*route_map
;
5661 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5663 return CMD_WARNING_CONFIG_FAILED
;
5665 /* Check filter direction. */
5666 if (strncmp(direct_str
, "in", 2) == 0)
5668 else if (strncmp(direct_str
, "o", 1) == 0)
5671 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5672 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
5674 return bgp_vty_return(vty
, ret
);
5677 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5678 afi_t afi
, safi_t safi
,
5679 const char *direct_str
)
5683 int direct
= RMAP_IN
;
5685 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5687 return CMD_WARNING_CONFIG_FAILED
;
5689 /* Check filter direction. */
5690 if (strncmp(direct_str
, "in", 2) == 0)
5692 else if (strncmp(direct_str
, "o", 1) == 0)
5695 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5697 return bgp_vty_return(vty
, ret
);
5700 DEFUN (neighbor_route_map
,
5701 neighbor_route_map_cmd
,
5702 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5705 "Apply route map to neighbor\n"
5706 "Name of route map\n"
5707 "Apply map to incoming routes\n"
5708 "Apply map to outbound routes\n")
5713 return peer_route_map_set_vty(
5714 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5715 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5718 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5719 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5720 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5721 "Apply route map to neighbor\n"
5722 "Name of route map\n"
5723 "Apply map to incoming routes\n"
5724 "Apply map to outbound routes\n")
5726 DEFUN (no_neighbor_route_map
,
5727 no_neighbor_route_map_cmd
,
5728 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5732 "Apply route map to neighbor\n"
5733 "Name of route map\n"
5734 "Apply map to incoming routes\n"
5735 "Apply map to outbound routes\n")
5739 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5740 bgp_node_afi(vty
), bgp_node_safi(vty
),
5741 argv
[idx_in_out
]->arg
);
5744 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5745 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5746 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5747 "Apply route map to neighbor\n"
5748 "Name of route map\n"
5749 "Apply map to incoming routes\n"
5750 "Apply map to outbound routes\n")
5752 /* Set unsuppress-map to the peer. */
5753 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5754 afi_t afi
, safi_t safi
,
5755 const char *name_str
)
5759 struct route_map
*route_map
;
5761 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5763 return CMD_WARNING_CONFIG_FAILED
;
5765 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5766 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
5768 return bgp_vty_return(vty
, ret
);
5771 /* Unset route-map from the peer. */
5772 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5773 afi_t afi
, safi_t safi
)
5778 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5780 return CMD_WARNING_CONFIG_FAILED
;
5782 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5784 return bgp_vty_return(vty
, ret
);
5787 DEFUN (neighbor_unsuppress_map
,
5788 neighbor_unsuppress_map_cmd
,
5789 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5792 "Route-map to selectively unsuppress suppressed routes\n"
5793 "Name of route map\n")
5797 return peer_unsuppress_map_set_vty(
5798 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5799 argv
[idx_word
]->arg
);
5802 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5803 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5804 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5805 "Route-map to selectively unsuppress suppressed routes\n"
5806 "Name of route map\n")
5808 DEFUN (no_neighbor_unsuppress_map
,
5809 no_neighbor_unsuppress_map_cmd
,
5810 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5814 "Route-map to selectively unsuppress suppressed routes\n"
5815 "Name of route map\n")
5818 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5820 bgp_node_safi(vty
));
5823 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5824 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5825 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5826 "Route-map to selectively unsuppress suppressed routes\n"
5827 "Name of route map\n")
5829 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5830 afi_t afi
, safi_t safi
,
5831 const char *num_str
,
5832 const char *threshold_str
, int warning
,
5833 const char *restart_str
)
5841 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5843 return CMD_WARNING_CONFIG_FAILED
;
5845 max
= strtoul(num_str
, NULL
, 10);
5847 threshold
= atoi(threshold_str
);
5849 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5852 restart
= atoi(restart_str
);
5856 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5859 return bgp_vty_return(vty
, ret
);
5862 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5863 afi_t afi
, safi_t safi
)
5868 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5870 return CMD_WARNING_CONFIG_FAILED
;
5872 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5874 return bgp_vty_return(vty
, ret
);
5877 /* Maximum number of prefix configuration. prefix count is different
5878 for each peer configuration. So this configuration can be set for
5879 each peer configuration. */
5880 DEFUN (neighbor_maximum_prefix
,
5881 neighbor_maximum_prefix_cmd
,
5882 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5885 "Maximum number of prefix accept from this peer\n"
5886 "maximum no. of prefix limit\n")
5890 return peer_maximum_prefix_set_vty(
5891 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5892 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5895 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5896 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5897 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5898 "Maximum number of prefix accept from this peer\n"
5899 "maximum no. of prefix limit\n")
5901 DEFUN (neighbor_maximum_prefix_threshold
,
5902 neighbor_maximum_prefix_threshold_cmd
,
5903 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5906 "Maximum number of prefix accept from this peer\n"
5907 "maximum no. of prefix limit\n"
5908 "Threshold value (%) at which to generate a warning msg\n")
5912 int idx_number_2
= 4;
5913 return peer_maximum_prefix_set_vty(
5914 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5915 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5919 neighbor_maximum_prefix_threshold
,
5920 neighbor_maximum_prefix_threshold_hidden_cmd
,
5921 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5922 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5923 "Maximum number of prefix accept from this peer\n"
5924 "maximum no. of prefix limit\n"
5925 "Threshold value (%) at which to generate a warning msg\n")
5927 DEFUN (neighbor_maximum_prefix_warning
,
5928 neighbor_maximum_prefix_warning_cmd
,
5929 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5932 "Maximum number of prefix accept from this peer\n"
5933 "maximum no. of prefix limit\n"
5934 "Only give warning message when limit is exceeded\n")
5938 return peer_maximum_prefix_set_vty(
5939 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5940 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
5944 neighbor_maximum_prefix_warning
,
5945 neighbor_maximum_prefix_warning_hidden_cmd
,
5946 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5947 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5948 "Maximum number of prefix accept from this peer\n"
5949 "maximum no. of prefix limit\n"
5950 "Only give warning message when limit is exceeded\n")
5952 DEFUN (neighbor_maximum_prefix_threshold_warning
,
5953 neighbor_maximum_prefix_threshold_warning_cmd
,
5954 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5957 "Maximum number of prefix accept from this peer\n"
5958 "maximum no. of prefix limit\n"
5959 "Threshold value (%) at which to generate a warning msg\n"
5960 "Only give warning message when limit is exceeded\n")
5964 int idx_number_2
= 4;
5965 return peer_maximum_prefix_set_vty(
5966 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5967 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
5971 neighbor_maximum_prefix_threshold_warning
,
5972 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
5973 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5974 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5975 "Maximum number of prefix accept from this peer\n"
5976 "maximum no. of prefix limit\n"
5977 "Threshold value (%) at which to generate a warning msg\n"
5978 "Only give warning message when limit is exceeded\n")
5980 DEFUN (neighbor_maximum_prefix_restart
,
5981 neighbor_maximum_prefix_restart_cmd
,
5982 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5985 "Maximum number of prefix accept from this peer\n"
5986 "maximum no. of prefix limit\n"
5987 "Restart bgp connection after limit is exceeded\n"
5988 "Restart interval in minutes\n")
5992 int idx_number_2
= 5;
5993 return peer_maximum_prefix_set_vty(
5994 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5995 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
5999 neighbor_maximum_prefix_restart
,
6000 neighbor_maximum_prefix_restart_hidden_cmd
,
6001 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6002 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6003 "Maximum number of prefix accept from this peer\n"
6004 "maximum no. of prefix limit\n"
6005 "Restart bgp connection after limit is exceeded\n"
6006 "Restart interval in minutes\n")
6008 DEFUN (neighbor_maximum_prefix_threshold_restart
,
6009 neighbor_maximum_prefix_threshold_restart_cmd
,
6010 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6013 "Maximum number of prefixes to accept from this peer\n"
6014 "maximum no. of prefix limit\n"
6015 "Threshold value (%) at which to generate a warning msg\n"
6016 "Restart bgp connection after limit is exceeded\n"
6017 "Restart interval in minutes\n")
6021 int idx_number_2
= 4;
6022 int idx_number_3
= 6;
6023 return peer_maximum_prefix_set_vty(
6024 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6025 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
6026 argv
[idx_number_3
]->arg
);
6030 neighbor_maximum_prefix_threshold_restart
,
6031 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
6032 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6033 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6034 "Maximum number of prefixes to accept from this peer\n"
6035 "maximum no. of prefix limit\n"
6036 "Threshold value (%) at which to generate a warning msg\n"
6037 "Restart bgp connection after limit is exceeded\n"
6038 "Restart interval in minutes\n")
6040 DEFUN (no_neighbor_maximum_prefix
,
6041 no_neighbor_maximum_prefix_cmd
,
6042 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6046 "Maximum number of prefixes to accept from this peer\n"
6047 "maximum no. of prefix limit\n"
6048 "Threshold value (%) at which to generate a warning msg\n"
6049 "Restart bgp connection after limit is exceeded\n"
6050 "Restart interval in minutes\n"
6051 "Only give warning message when limit is exceeded\n")
6054 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
6056 bgp_node_safi(vty
));
6060 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
6061 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6062 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6063 "Maximum number of prefixes to accept from this peer\n"
6064 "maximum no. of prefix limit\n"
6065 "Threshold value (%) at which to generate a warning msg\n"
6066 "Restart bgp connection after limit is exceeded\n"
6067 "Restart interval in minutes\n"
6068 "Only give warning message when limit is exceeded\n")
6071 /* "neighbor allowas-in" */
6072 DEFUN (neighbor_allowas_in
,
6073 neighbor_allowas_in_cmd
,
6074 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6077 "Accept as-path with my AS present in it\n"
6078 "Number of occurences of AS number\n"
6079 "Only accept my AS in the as-path if the route was originated in my AS\n")
6082 int idx_number_origin
= 3;
6088 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6090 return CMD_WARNING_CONFIG_FAILED
;
6092 if (argc
<= idx_number_origin
)
6095 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6098 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6101 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6104 return bgp_vty_return(vty
, ret
);
6108 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6109 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6110 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6111 "Accept as-path with my AS present in it\n"
6112 "Number of occurences of AS number\n"
6113 "Only accept my AS in the as-path if the route was originated in my AS\n")
6115 DEFUN (no_neighbor_allowas_in
,
6116 no_neighbor_allowas_in_cmd
,
6117 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6121 "allow local ASN appears in aspath attribute\n"
6122 "Number of occurences of AS number\n"
6123 "Only accept my AS in the as-path if the route was originated in my AS\n")
6129 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6131 return CMD_WARNING_CONFIG_FAILED
;
6133 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6134 bgp_node_safi(vty
));
6136 return bgp_vty_return(vty
, ret
);
6140 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6141 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6142 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6143 "allow local ASN appears in aspath attribute\n"
6144 "Number of occurences of AS number\n"
6145 "Only accept my AS in the as-path if the route was originated in my AS\n")
6147 DEFUN (neighbor_ttl_security
,
6148 neighbor_ttl_security_cmd
,
6149 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6152 "BGP ttl-security parameters\n"
6153 "Specify the maximum number of hops to the BGP peer\n"
6154 "Number of hops to BGP peer\n")
6161 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6163 return CMD_WARNING_CONFIG_FAILED
;
6165 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6168 * If 'neighbor swpX', then this is for directly connected peers,
6169 * we should not accept a ttl-security hops value greater than 1.
6171 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6173 "%s is directly connected peer, hops cannot exceed 1\n",
6174 argv
[idx_peer
]->arg
);
6175 return CMD_WARNING_CONFIG_FAILED
;
6178 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6181 DEFUN (no_neighbor_ttl_security
,
6182 no_neighbor_ttl_security_cmd
,
6183 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6187 "BGP ttl-security parameters\n"
6188 "Specify the maximum number of hops to the BGP peer\n"
6189 "Number of hops to BGP peer\n")
6194 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6196 return CMD_WARNING_CONFIG_FAILED
;
6198 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6201 DEFUN (neighbor_addpath_tx_all_paths
,
6202 neighbor_addpath_tx_all_paths_cmd
,
6203 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6206 "Use addpath to advertise all paths to a neighbor\n")
6211 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6213 return CMD_WARNING_CONFIG_FAILED
;
6215 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6220 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6221 neighbor_addpath_tx_all_paths_hidden_cmd
,
6222 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6223 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6224 "Use addpath to advertise all paths to a neighbor\n")
6226 DEFUN (no_neighbor_addpath_tx_all_paths
,
6227 no_neighbor_addpath_tx_all_paths_cmd
,
6228 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6232 "Use addpath to advertise all paths to a neighbor\n")
6237 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6239 return CMD_WARNING_CONFIG_FAILED
;
6241 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6242 != BGP_ADDPATH_ALL
) {
6244 "%% Peer not currently configured to transmit all paths.");
6245 return CMD_WARNING_CONFIG_FAILED
;
6248 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6254 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6255 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6256 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6257 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6258 "Use addpath to advertise all paths to a neighbor\n")
6260 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6261 neighbor_addpath_tx_bestpath_per_as_cmd
,
6262 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6265 "Use addpath to advertise the bestpath per each neighboring AS\n")
6270 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6272 return CMD_WARNING_CONFIG_FAILED
;
6274 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6275 BGP_ADDPATH_BEST_PER_AS
);
6280 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6281 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6282 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6283 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6284 "Use addpath to advertise the bestpath per each neighboring AS\n")
6286 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6287 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6288 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6292 "Use addpath to advertise the bestpath per each neighboring AS\n")
6297 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6299 return CMD_WARNING_CONFIG_FAILED
;
6301 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6302 != BGP_ADDPATH_BEST_PER_AS
) {
6304 "%% Peer not currently configured to transmit all best path per as.");
6305 return CMD_WARNING_CONFIG_FAILED
;
6308 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6314 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6315 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6316 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6317 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6318 "Use addpath to advertise the bestpath per each neighboring AS\n")
6320 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6321 struct ecommunity
**list
)
6323 struct ecommunity
*ecom
= NULL
;
6324 struct ecommunity
*ecomadd
;
6326 for (; argc
; --argc
, ++argv
) {
6328 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6329 ECOMMUNITY_ROUTE_TARGET
, 0);
6331 vty_out(vty
, "Malformed community-list value\n");
6333 ecommunity_free(&ecom
);
6334 return CMD_WARNING_CONFIG_FAILED
;
6338 ecommunity_merge(ecom
, ecomadd
);
6339 ecommunity_free(&ecomadd
);
6346 ecommunity_free(&*list
);
6354 * v2vimport is true if we are handling a `import vrf ...` command
6356 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6360 switch (vty
->node
) {
6369 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6374 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6375 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6376 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6377 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6379 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6383 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6384 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6385 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6386 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6388 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6395 DEFPY (af_rd_vpn_export
,
6396 af_rd_vpn_export_cmd
,
6397 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6399 "Specify route distinguisher\n"
6400 "Between current address-family and vpn\n"
6401 "For routes leaked from current address-family to vpn\n"
6402 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6404 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6405 struct prefix_rd prd
;
6411 if (argv_find(argv
, argc
, "no", &idx
))
6415 ret
= str2prefix_rd(rd_str
, &prd
);
6417 vty_out(vty
, "%% Malformed rd\n");
6418 return CMD_WARNING_CONFIG_FAILED
;
6422 afi
= vpn_policy_getafi(vty
, bgp
, false);
6424 return CMD_WARNING_CONFIG_FAILED
;
6427 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6429 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6430 bgp_get_default(), bgp
);
6433 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6434 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6435 BGP_VPN_POLICY_TOVPN_RD_SET
);
6437 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6438 BGP_VPN_POLICY_TOVPN_RD_SET
);
6441 /* post-change: re-export vpn routes */
6442 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6443 bgp_get_default(), bgp
);
6448 ALIAS (af_rd_vpn_export
,
6449 af_no_rd_vpn_export_cmd
,
6452 "Specify route distinguisher\n"
6453 "Between current address-family and vpn\n"
6454 "For routes leaked from current address-family to vpn\n")
6456 DEFPY (af_label_vpn_export
,
6457 af_label_vpn_export_cmd
,
6458 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6460 "label value for VRF\n"
6461 "Between current address-family and vpn\n"
6462 "For routes leaked from current address-family to vpn\n"
6463 "Label Value <0-1048575>\n"
6464 "Automatically assign a label\n")
6466 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6467 mpls_label_t label
= MPLS_LABEL_NONE
;
6472 if (argv_find(argv
, argc
, "no", &idx
))
6475 /* If "no ...", squash trailing parameter */
6481 label
= label_val
; /* parser should force unsigned */
6484 afi
= vpn_policy_getafi(vty
, bgp
, false);
6486 return CMD_WARNING_CONFIG_FAILED
;
6489 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6490 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6495 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6497 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6498 bgp_get_default(), bgp
);
6500 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6501 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6503 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6506 * label has previously been automatically
6507 * assigned by labelpool: release it
6509 * NB if tovpn_label == MPLS_LABEL_NONE it
6510 * means the automatic assignment is in flight
6511 * and therefore the labelpool callback must
6512 * detect that the auto label is not needed.
6515 bgp_lp_release(LP_TYPE_VRF
,
6516 &bgp
->vpn_policy
[afi
],
6517 bgp
->vpn_policy
[afi
].tovpn_label
);
6519 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6520 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6523 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6525 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6526 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6527 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6528 vpn_leak_label_callback
);
6531 /* post-change: re-export vpn routes */
6532 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6533 bgp_get_default(), bgp
);
6538 ALIAS (af_label_vpn_export
,
6539 af_no_label_vpn_export_cmd
,
6540 "no label vpn export",
6542 "label value for VRF\n"
6543 "Between current address-family and vpn\n"
6544 "For routes leaked from current address-family to vpn\n")
6546 DEFPY (af_nexthop_vpn_export
,
6547 af_nexthop_vpn_export_cmd
,
6548 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6550 "Specify next hop to use for VRF advertised prefixes\n"
6551 "Between current address-family and vpn\n"
6552 "For routes leaked from current address-family to vpn\n"
6556 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6562 if (argv_find(argv
, argc
, "no", &idx
))
6566 if (!sockunion2hostprefix(nexthop_str
, &p
))
6567 return CMD_WARNING_CONFIG_FAILED
;
6570 afi
= vpn_policy_getafi(vty
, bgp
, false);
6572 return CMD_WARNING_CONFIG_FAILED
;
6575 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6577 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6578 bgp_get_default(), bgp
);
6581 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6582 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6583 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6585 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6586 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6589 /* post-change: re-export vpn routes */
6590 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6591 bgp_get_default(), bgp
);
6596 ALIAS (af_nexthop_vpn_export
,
6597 af_no_nexthop_vpn_export_cmd
,
6598 "no nexthop vpn export",
6600 "Specify next hop to use for VRF advertised prefixes\n"
6601 "Between current address-family and vpn\n"
6602 "For routes leaked from current address-family to vpn\n")
6604 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6606 if (!strcmp(dstr
, "import")) {
6607 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6608 } else if (!strcmp(dstr
, "export")) {
6609 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6610 } else if (!strcmp(dstr
, "both")) {
6611 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6612 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6614 vty_out(vty
, "%% direction parse error\n");
6615 return CMD_WARNING_CONFIG_FAILED
;
6620 DEFPY (af_rt_vpn_imexport
,
6621 af_rt_vpn_imexport_cmd
,
6622 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6624 "Specify route target list\n"
6625 "Specify route target list\n"
6626 "Between current address-family and vpn\n"
6627 "For routes leaked from vpn to current address-family: match any\n"
6628 "For routes leaked from current address-family to vpn: set\n"
6629 "both import: match any and export: set\n"
6630 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6632 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6634 struct ecommunity
*ecom
= NULL
;
6635 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6636 vpn_policy_direction_t dir
;
6641 if (argv_find(argv
, argc
, "no", &idx
))
6644 afi
= vpn_policy_getafi(vty
, bgp
, false);
6646 return CMD_WARNING_CONFIG_FAILED
;
6648 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6649 if (ret
!= CMD_SUCCESS
)
6653 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6654 vty_out(vty
, "%% Missing RTLIST\n");
6655 return CMD_WARNING_CONFIG_FAILED
;
6657 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6658 if (ret
!= CMD_SUCCESS
) {
6663 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6667 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6670 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6672 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6673 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6674 ecommunity_dup(ecom
);
6676 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6678 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6679 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6682 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6686 ecommunity_free(&ecom
);
6691 ALIAS (af_rt_vpn_imexport
,
6692 af_no_rt_vpn_imexport_cmd
,
6693 "no <rt|route-target> vpn <import|export|both>$direction_str",
6695 "Specify route target list\n"
6696 "Specify route target list\n"
6697 "Between current address-family and vpn\n"
6698 "For routes leaked from vpn to current address-family\n"
6699 "For routes leaked from current address-family to vpn\n"
6700 "both import and export\n")
6702 DEFPY (af_route_map_vpn_imexport
,
6703 af_route_map_vpn_imexport_cmd
,
6704 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6705 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6707 "Specify route map\n"
6708 "Between current address-family and vpn\n"
6709 "For routes leaked from vpn to current address-family\n"
6710 "For routes leaked from current address-family to vpn\n"
6711 "name of route-map\n")
6713 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6715 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6716 vpn_policy_direction_t dir
;
6721 if (argv_find(argv
, argc
, "no", &idx
))
6724 afi
= vpn_policy_getafi(vty
, bgp
, false);
6726 return CMD_WARNING_CONFIG_FAILED
;
6728 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6729 if (ret
!= CMD_SUCCESS
)
6732 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6736 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6739 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6740 XFREE(MTYPE_ROUTE_MAP_NAME
,
6741 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6742 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6743 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6744 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6745 route_map_lookup_warn_noexist(vty
, rmap_str
);
6746 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6749 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6750 XFREE(MTYPE_ROUTE_MAP_NAME
,
6751 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6752 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6753 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6756 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6762 ALIAS (af_route_map_vpn_imexport
,
6763 af_no_route_map_vpn_imexport_cmd
,
6764 "no route-map vpn <import|export>$direction_str",
6766 "Specify route map\n"
6767 "Between current address-family and vpn\n"
6768 "For routes leaked from vpn to current address-family\n"
6769 "For routes leaked from current address-family to vpn\n")
6771 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6772 "[no] import vrf route-map RMAP$rmap_str",
6774 "Import routes from another VRF\n"
6775 "Vrf routes being filtered\n"
6776 "Specify route map\n"
6777 "name of route-map\n")
6779 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6780 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6784 struct bgp
*bgp_default
;
6786 if (argv_find(argv
, argc
, "no", &idx
))
6789 afi
= vpn_policy_getafi(vty
, bgp
, true);
6791 return CMD_WARNING_CONFIG_FAILED
;
6793 bgp_default
= bgp_get_default();
6798 /* Auto-create assuming the same AS */
6799 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6800 BGP_INSTANCE_TYPE_DEFAULT
);
6804 "VRF default is not configured as a bgp instance\n");
6809 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6812 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6813 XFREE(MTYPE_ROUTE_MAP_NAME
,
6814 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6815 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6816 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6817 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6818 route_map_lookup_warn_noexist(vty
, rmap_str
);
6819 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6822 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6823 XFREE(MTYPE_ROUTE_MAP_NAME
,
6824 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6825 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6826 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6829 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6834 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6835 "no import vrf route-map",
6837 "Import routes from another VRF\n"
6838 "Vrf routes being filtered\n"
6839 "Specify route map\n")
6841 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
6842 "[no] import vrf VIEWVRFNAME$import_name",
6844 "Import routes from another VRF\n"
6845 "VRF to import from\n"
6846 "The name of the VRF\n")
6848 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6849 struct listnode
*node
;
6850 struct bgp
*vrf_bgp
, *bgp_default
;
6853 bool remove
= false;
6856 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
6860 if (import_name
== NULL
) {
6861 vty_out(vty
, "%% Missing import name\n");
6865 if (argv_find(argv
, argc
, "no", &idx
))
6868 afi
= vpn_policy_getafi(vty
, bgp
, true);
6870 return CMD_WARNING_CONFIG_FAILED
;
6872 safi
= bgp_node_safi(vty
);
6874 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
6875 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
6876 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
6877 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
6878 remove
? "unimport" : "import", import_name
);
6882 bgp_default
= bgp_get_default();
6884 /* Auto-create assuming the same AS */
6885 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6886 BGP_INSTANCE_TYPE_DEFAULT
);
6890 "VRF default is not configured as a bgp instance\n");
6895 vrf_bgp
= bgp_lookup_by_name(import_name
);
6897 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
6898 vrf_bgp
= bgp_default
;
6900 /* Auto-create assuming the same AS */
6901 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
6905 "VRF %s is not configured as a bgp instance\n",
6912 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6914 /* Already importing from "import_vrf"? */
6915 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
6917 if (strcmp(vname
, import_name
) == 0)
6921 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6927 /* This command is valid only in a bgp vrf instance or the default instance */
6928 DEFPY (bgp_imexport_vpn
,
6929 bgp_imexport_vpn_cmd
,
6930 "[no] <import|export>$direction_str vpn",
6932 "Import routes to this address-family\n"
6933 "Export routes from this address-family\n"
6934 "to/from default instance VPN RIB\n")
6936 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6943 vpn_policy_direction_t dir
;
6945 if (argv_find(argv
, argc
, "no", &idx
))
6948 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
6949 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
6951 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
6952 return CMD_WARNING_CONFIG_FAILED
;
6955 afi
= bgp_node_afi(vty
);
6956 safi
= bgp_node_safi(vty
);
6957 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
6958 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
6959 return CMD_WARNING_CONFIG_FAILED
;
6962 if (!strcmp(direction_str
, "import")) {
6963 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
6964 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6965 } else if (!strcmp(direction_str
, "export")) {
6966 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
6967 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
6969 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
6970 return CMD_WARNING_CONFIG_FAILED
;
6973 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6976 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6977 if (!previous_state
) {
6978 /* trigger export current vrf */
6979 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6982 if (previous_state
) {
6983 /* trigger un-export current vrf */
6984 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6986 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6992 DEFPY (af_routetarget_import
,
6993 af_routetarget_import_cmd
,
6994 "[no] <rt|route-target> redirect import RTLIST...",
6996 "Specify route target list\n"
6997 "Specify route target list\n"
6998 "Flow-spec redirect type route target\n"
6999 "Import routes to this address-family\n"
7000 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
7002 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7004 struct ecommunity
*ecom
= NULL
;
7009 if (argv_find(argv
, argc
, "no", &idx
))
7012 afi
= vpn_policy_getafi(vty
, bgp
, false);
7014 return CMD_WARNING_CONFIG_FAILED
;
7017 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7018 vty_out(vty
, "%% Missing RTLIST\n");
7019 return CMD_WARNING_CONFIG_FAILED
;
7021 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7022 if (ret
!= CMD_SUCCESS
)
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
=
7031 ecommunity_dup(ecom
);
7033 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7034 ecommunity_free(&bgp
->vpn_policy
[afi
]
7035 .import_redirect_rtlist
);
7036 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
7040 ecommunity_free(&ecom
);
7045 DEFUN_NOSH (address_family_ipv4_safi
,
7046 address_family_ipv4_safi_cmd
,
7047 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7048 "Enter Address Family command mode\n"
7050 BGP_SAFI_WITH_LABEL_HELP_STR
)
7054 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7055 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7056 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7057 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7058 && safi
!= SAFI_EVPN
) {
7060 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7061 return CMD_WARNING_CONFIG_FAILED
;
7063 vty
->node
= bgp_node_type(AFI_IP
, safi
);
7065 vty
->node
= BGP_IPV4_NODE
;
7070 DEFUN_NOSH (address_family_ipv6_safi
,
7071 address_family_ipv6_safi_cmd
,
7072 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7073 "Enter Address Family command mode\n"
7075 BGP_SAFI_WITH_LABEL_HELP_STR
)
7078 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7079 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7080 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7081 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7082 && safi
!= SAFI_EVPN
) {
7084 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7085 return CMD_WARNING_CONFIG_FAILED
;
7087 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
7089 vty
->node
= BGP_IPV6_NODE
;
7094 #ifdef KEEP_OLD_VPN_COMMANDS
7095 DEFUN_NOSH (address_family_vpnv4
,
7096 address_family_vpnv4_cmd
,
7097 "address-family vpnv4 [unicast]",
7098 "Enter Address Family command mode\n"
7100 "Address Family modifier\n")
7102 vty
->node
= BGP_VPNV4_NODE
;
7106 DEFUN_NOSH (address_family_vpnv6
,
7107 address_family_vpnv6_cmd
,
7108 "address-family vpnv6 [unicast]",
7109 "Enter Address Family command mode\n"
7111 "Address Family modifier\n")
7113 vty
->node
= BGP_VPNV6_NODE
;
7116 #endif /* KEEP_OLD_VPN_COMMANDS */
7118 DEFUN_NOSH (address_family_evpn
,
7119 address_family_evpn_cmd
,
7120 "address-family l2vpn evpn",
7121 "Enter Address Family command mode\n"
7123 "Address Family modifier\n")
7125 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7126 vty
->node
= BGP_EVPN_NODE
;
7130 DEFUN_NOSH (exit_address_family
,
7131 exit_address_family_cmd
,
7132 "exit-address-family",
7133 "Exit from Address Family configuration mode\n")
7135 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7136 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7137 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7138 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7139 || vty
->node
== BGP_EVPN_NODE
7140 || vty
->node
== BGP_FLOWSPECV4_NODE
7141 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7142 vty
->node
= BGP_NODE
;
7146 /* Recalculate bestpath and re-advertise a prefix */
7147 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7148 const char *ip_str
, afi_t afi
, safi_t safi
,
7149 struct prefix_rd
*prd
)
7152 struct prefix match
;
7153 struct bgp_node
*rn
;
7154 struct bgp_node
*rm
;
7156 struct bgp_table
*table
;
7157 struct bgp_table
*rib
;
7159 /* BGP structure lookup. */
7161 bgp
= bgp_lookup_by_name(view_name
);
7163 vty_out(vty
, "%% Can't find BGP instance %s\n",
7168 bgp
= bgp_get_default();
7170 vty_out(vty
, "%% No BGP process is configured\n");
7175 /* Check IP address argument. */
7176 ret
= str2prefix(ip_str
, &match
);
7178 vty_out(vty
, "%% address is malformed\n");
7182 match
.family
= afi2family(afi
);
7183 rib
= bgp
->rib
[afi
][safi
];
7185 if (safi
== SAFI_MPLS_VPN
) {
7186 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7187 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7190 table
= bgp_node_get_bgp_table_info(rn
);
7191 if (table
!= NULL
) {
7193 if ((rm
= bgp_node_match(table
, &match
))
7196 == match
.prefixlen
) {
7198 BGP_NODE_USER_CLEAR
);
7199 bgp_process(bgp
, rm
, afi
, safi
);
7201 bgp_unlock_node(rm
);
7206 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7207 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7208 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7209 bgp_process(bgp
, rn
, afi
, safi
);
7211 bgp_unlock_node(rn
);
7218 /* one clear bgp command to rule them all */
7219 DEFUN (clear_ip_bgp_all
,
7220 clear_ip_bgp_all_cmd
,
7221 "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>]",
7225 BGP_INSTANCE_HELP_STR
7228 BGP_SAFI_WITH_LABEL_HELP_STR
7229 "Address Family modifier\n"
7231 "BGP neighbor address to clear\n"
7232 "BGP IPv6 neighbor to clear\n"
7233 "BGP neighbor on interface to clear\n"
7234 "Clear peers with the AS number\n"
7235 "Clear all external peers\n"
7236 "Clear all members of peer-group\n"
7237 "BGP peer-group name\n"
7242 "Push out prefix-list ORF and do inbound soft reconfig\n"
7247 afi_t afi
= AFI_IP6
;
7248 safi_t safi
= SAFI_UNICAST
;
7249 enum clear_sort clr_sort
= clear_peer
;
7250 enum bgp_clear_type clr_type
;
7251 char *clr_arg
= NULL
;
7255 /* clear [ip] bgp */
7256 if (argv_find(argv
, argc
, "ip", &idx
))
7259 /* [<vrf> VIEWVRFNAME] */
7260 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7261 vrf
= argv
[idx
+ 1]->arg
;
7263 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7265 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7266 /* [<view> VIEWVRFNAME] */
7267 vrf
= argv
[idx
+ 1]->arg
;
7270 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7271 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7272 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7274 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
7275 if (argv_find(argv
, argc
, "*", &idx
)) {
7276 clr_sort
= clear_all
;
7277 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7278 clr_sort
= clear_peer
;
7279 clr_arg
= argv
[idx
]->arg
;
7280 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7281 clr_sort
= clear_peer
;
7282 clr_arg
= argv
[idx
]->arg
;
7283 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7284 clr_sort
= clear_group
;
7286 clr_arg
= argv
[idx
]->arg
;
7287 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
7288 clr_sort
= clear_peer
;
7289 clr_arg
= argv
[idx
]->arg
;
7290 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7291 clr_sort
= clear_peer
;
7292 clr_arg
= argv
[idx
]->arg
;
7293 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7294 clr_sort
= clear_as
;
7295 clr_arg
= argv
[idx
]->arg
;
7296 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7297 clr_sort
= clear_external
;
7300 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7301 if (argv_find(argv
, argc
, "soft", &idx
)) {
7302 if (argv_find(argv
, argc
, "in", &idx
)
7303 || argv_find(argv
, argc
, "out", &idx
))
7304 clr_type
= strmatch(argv
[idx
]->text
, "in")
7306 : BGP_CLEAR_SOFT_OUT
;
7308 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7309 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7310 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7311 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7312 : BGP_CLEAR_SOFT_IN
;
7313 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7314 clr_type
= BGP_CLEAR_SOFT_OUT
;
7316 clr_type
= BGP_CLEAR_SOFT_NONE
;
7318 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7321 DEFUN (clear_ip_bgp_prefix
,
7322 clear_ip_bgp_prefix_cmd
,
7323 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7327 BGP_INSTANCE_HELP_STR
7328 "Clear bestpath and re-advertise\n"
7332 char *prefix
= NULL
;
7336 /* [<view|vrf> VIEWVRFNAME] */
7337 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7338 vrf
= argv
[idx
+ 1]->arg
;
7340 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7342 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7343 /* [<view> VIEWVRFNAME] */
7344 vrf
= argv
[idx
+ 1]->arg
;
7348 prefix
= argv
[argc
- 1]->arg
;
7350 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7353 DEFUN (clear_bgp_ipv6_safi_prefix
,
7354 clear_bgp_ipv6_safi_prefix_cmd
,
7355 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7361 "Clear bestpath and re-advertise\n"
7365 int idx_ipv6_prefix
= 0;
7366 safi_t safi
= SAFI_UNICAST
;
7367 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7368 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7370 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7371 return bgp_clear_prefix(
7372 vty
, NULL
, prefix
, AFI_IP6
,
7376 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7377 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7378 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7382 BGP_INSTANCE_HELP_STR
7385 "Clear bestpath and re-advertise\n"
7389 int idx_vrfview
= 0;
7390 int idx_ipv6_prefix
= 0;
7391 safi_t safi
= SAFI_UNICAST
;
7392 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7393 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7394 char *vrfview
= NULL
;
7396 /* [<view|vrf> VIEWVRFNAME] */
7397 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
7398 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7399 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
7401 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
7402 /* [<view> VIEWVRFNAME] */
7403 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7405 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7407 return bgp_clear_prefix(
7408 vty
, vrfview
, prefix
,
7409 AFI_IP6
, safi
, NULL
);
7412 DEFUN (show_bgp_views
,
7414 "show [ip] bgp views",
7418 "Show the defined BGP views\n")
7420 struct list
*inst
= bm
->bgp
;
7421 struct listnode
*node
;
7424 vty_out(vty
, "Defined BGP views:\n");
7425 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7427 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7429 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7436 DEFUN (show_bgp_vrfs
,
7438 "show [ip] bgp vrfs [json]",
7445 char buf
[ETHER_ADDR_STRLEN
];
7446 struct list
*inst
= bm
->bgp
;
7447 struct listnode
*node
;
7449 bool uj
= use_json(argc
, argv
);
7450 json_object
*json
= NULL
;
7451 json_object
*json_vrfs
= NULL
;
7455 json
= json_object_new_object();
7456 json_vrfs
= json_object_new_object();
7459 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7460 const char *name
, *type
;
7462 struct listnode
*node2
, *nnode2
;
7463 int peers_cfg
, peers_estb
;
7464 json_object
*json_vrf
= NULL
;
7467 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7471 if (!uj
&& count
== 1) {
7473 "%4s %-5s %-16s %9s %10s %-37s\n",
7474 "Type", "Id", "routerId", "#PeersVfg",
7475 "#PeersEstb", "Name");
7476 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
7477 "L3-VNI", "RouterMAC", "Interface");
7480 peers_cfg
= peers_estb
= 0;
7482 json_vrf
= json_object_new_object();
7485 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
7486 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7489 if (peer
->status
== Established
)
7493 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7494 name
= VRF_DEFAULT_NAME
;
7503 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7505 : (int64_t)bgp
->vrf_id
;
7506 json_object_string_add(json_vrf
, "type", type
);
7507 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7508 json_object_string_add(json_vrf
, "routerId",
7509 inet_ntoa(bgp
->router_id
));
7510 json_object_int_add(json_vrf
, "numConfiguredPeers",
7512 json_object_int_add(json_vrf
, "numEstablishedPeers",
7515 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7516 json_object_string_add(
7518 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7519 json_object_string_add(json_vrf
, "interface",
7520 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
7522 json_object_object_add(json_vrfs
, name
, json_vrf
);
7525 "%4s %-5d %-16s %-9u %-10u %-37s\n",
7527 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7529 inet_ntoa(bgp
->router_id
), peers_cfg
,
7531 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
7533 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
7534 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
7540 json_object_object_add(json
, "vrfs", json_vrfs
);
7542 json_object_int_add(json
, "totalVrfs", count
);
7544 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7545 json
, JSON_C_TO_STRING_PRETTY
));
7546 json_object_free(json
);
7550 "\nTotal number of VRFs (including default): %d\n",
7557 DEFUN (show_bgp_mac_hash
,
7558 show_bgp_mac_hash_cmd
,
7559 "show bgp mac hash",
7563 "Mac Address database\n")
7565 bgp_mac_dump_table(vty
);
7570 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
7572 struct vty
*vty
= (struct vty
*)args
;
7573 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
7575 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7579 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7581 vty_out(vty
, "self nexthop database:\n");
7582 bgp_nexthop_show_address_hash(vty
, bgp
);
7584 vty_out(vty
, "Tunnel-ip database:\n");
7585 hash_iterate(bgp
->tip_hash
,
7586 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
7590 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7591 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7592 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7593 "martian next-hops\n"
7594 "martian next-hop database\n")
7596 struct bgp
*bgp
= NULL
;
7600 /* [<vrf> VIEWVRFNAME] */
7601 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7602 name
= argv
[idx
+ 1]->arg
;
7603 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7605 } else if (argv_find(argv
, argc
, "view", &idx
))
7606 /* [<view> VIEWVRFNAME] */
7607 name
= argv
[idx
+ 1]->arg
;
7609 bgp
= bgp_lookup_by_name(name
);
7611 bgp
= bgp_get_default();
7614 vty_out(vty
, "%% No BGP process is configured\n");
7617 bgp_show_martian_nexthops(vty
, bgp
);
7622 DEFUN (show_bgp_memory
,
7623 show_bgp_memory_cmd
,
7624 "show [ip] bgp memory",
7628 "Global BGP memory statistics\n")
7630 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7631 unsigned long count
;
7633 /* RIB related usage stats */
7634 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7635 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7636 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7637 count
* sizeof(struct bgp_node
)));
7639 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7640 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7641 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7642 count
* sizeof(struct bgp_path_info
)));
7643 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7644 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7647 memstrbuf
, sizeof(memstrbuf
),
7648 count
* sizeof(struct bgp_path_info_extra
)));
7650 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7651 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7652 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7653 count
* sizeof(struct bgp_static
)));
7655 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7656 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7657 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7658 count
* sizeof(struct bpacket
)));
7661 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7662 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7663 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7664 count
* sizeof(struct bgp_adj_in
)));
7665 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7666 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7667 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7668 count
* sizeof(struct bgp_adj_out
)));
7670 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7671 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7673 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7674 count
* sizeof(struct bgp_nexthop_cache
)));
7676 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7677 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7679 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7680 count
* sizeof(struct bgp_damp_info
)));
7683 count
= attr_count();
7684 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7685 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7686 count
* sizeof(struct attr
)));
7688 if ((count
= attr_unknown_count()))
7689 vty_out(vty
, "%ld unknown attributes\n", count
);
7691 /* AS_PATH attributes */
7692 count
= aspath_count();
7693 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7694 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7695 count
* sizeof(struct aspath
)));
7697 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7698 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7699 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7700 count
* sizeof(struct assegment
)));
7702 /* Other attributes */
7703 if ((count
= community_count()))
7704 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7705 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7706 count
* sizeof(struct community
)));
7707 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7708 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7709 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7710 count
* sizeof(struct ecommunity
)));
7711 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7713 "%ld BGP large-community entries, using %s of memory\n",
7714 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7715 count
* sizeof(struct lcommunity
)));
7717 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7718 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7719 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7720 count
* sizeof(struct cluster_list
)));
7722 /* Peer related usage */
7723 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7724 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7725 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7726 count
* sizeof(struct peer
)));
7728 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7729 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7730 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7731 count
* sizeof(struct peer_group
)));
7734 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7735 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7736 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7737 count
* sizeof(regex_t
)));
7741 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7743 json_object
*bestpath
= json_object_new_object();
7745 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7746 json_object_string_add(bestpath
, "asPath", "ignore");
7748 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7749 json_object_string_add(bestpath
, "asPath", "confed");
7751 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7752 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7753 json_object_string_add(bestpath
, "multiPathRelax",
7756 json_object_string_add(bestpath
, "multiPathRelax",
7759 json_object_string_add(bestpath
, "multiPathRelax", "false");
7761 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7762 json_object_string_add(bestpath
, "compareRouterId", "true");
7763 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7764 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7765 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7766 json_object_string_add(bestpath
, "med", "confed");
7767 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7768 json_object_string_add(bestpath
, "med",
7769 "missing-as-worst");
7771 json_object_string_add(bestpath
, "med", "true");
7774 json_object_object_add(json
, "bestPath", bestpath
);
7777 /* Show BGP peer's summary information. */
7778 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7779 bool use_json
, json_object
*json
)
7782 struct listnode
*node
, *nnode
;
7783 unsigned int count
= 0, dn_count
= 0;
7784 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7785 char neighbor_buf
[VTY_BUFSIZ
];
7786 int neighbor_col_default_width
= 16;
7788 int max_neighbor_width
= 0;
7790 json_object
*json_peer
= NULL
;
7791 json_object
*json_peers
= NULL
;
7792 struct peer_af
*paf
;
7794 /* labeled-unicast routes are installed in the unicast table so in order
7796 * display the correct PfxRcd value we must look at SAFI_UNICAST
7798 if (safi
== SAFI_LABELED_UNICAST
)
7799 pfx_rcd_safi
= SAFI_UNICAST
;
7801 pfx_rcd_safi
= safi
;
7805 json
= json_object_new_object();
7807 json_peers
= json_object_new_object();
7809 /* Loop over all neighbors that will be displayed to determine
7811 * characters are needed for the Neighbor column
7813 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7814 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7817 if (peer
->afc
[afi
][safi
]) {
7818 memset(dn_flag
, '\0', sizeof(dn_flag
));
7819 if (peer_dynamic_neighbor(peer
))
7823 && bgp_flag_check(bgp
,
7824 BGP_FLAG_SHOW_HOSTNAME
))
7825 sprintf(neighbor_buf
, "%s%s(%s) ",
7826 dn_flag
, peer
->hostname
,
7829 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7832 len
= strlen(neighbor_buf
);
7834 if (len
> max_neighbor_width
)
7835 max_neighbor_width
= len
;
7839 /* Originally we displayed the Neighbor column as 16
7840 * characters wide so make that the default
7842 if (max_neighbor_width
< neighbor_col_default_width
)
7843 max_neighbor_width
= neighbor_col_default_width
;
7846 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7847 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7850 if (!peer
->afc
[afi
][safi
])
7855 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7858 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7860 : (int64_t)bgp
->vrf_id
;
7862 /* Usage summary and header */
7864 json_object_string_add(
7866 inet_ntoa(bgp
->router_id
));
7867 json_object_int_add(json
, "as", bgp
->as
);
7868 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7869 json_object_string_add(
7872 == BGP_INSTANCE_TYPE_DEFAULT
)
7877 "BGP router identifier %s, local AS number %u vrf-id %d",
7878 inet_ntoa(bgp
->router_id
), bgp
->as
,
7879 bgp
->vrf_id
== VRF_UNKNOWN
7881 : (int)bgp
->vrf_id
);
7885 if (bgp_update_delay_configured(bgp
)) {
7887 json_object_int_add(
7888 json
, "updateDelayLimit",
7889 bgp
->v_update_delay
);
7891 if (bgp
->v_update_delay
7892 != bgp
->v_establish_wait
)
7893 json_object_int_add(
7895 "updateDelayEstablishWait",
7896 bgp
->v_establish_wait
);
7898 if (bgp_update_delay_active(bgp
)) {
7899 json_object_string_add(
7901 "updateDelayFirstNeighbor",
7902 bgp
->update_delay_begin_time
);
7903 json_object_boolean_true_add(
7905 "updateDelayInProgress");
7907 if (bgp
->update_delay_over
) {
7908 json_object_string_add(
7910 "updateDelayFirstNeighbor",
7911 bgp
->update_delay_begin_time
);
7912 json_object_string_add(
7914 "updateDelayBestpathResumed",
7915 bgp
->update_delay_end_time
);
7916 json_object_string_add(
7918 "updateDelayZebraUpdateResume",
7919 bgp
->update_delay_zebra_resume_time
);
7920 json_object_string_add(
7922 "updateDelayPeerUpdateResume",
7923 bgp
->update_delay_peers_resume_time
);
7928 "Read-only mode update-delay limit: %d seconds\n",
7929 bgp
->v_update_delay
);
7930 if (bgp
->v_update_delay
7931 != bgp
->v_establish_wait
)
7933 " Establish wait: %d seconds\n",
7934 bgp
->v_establish_wait
);
7936 if (bgp_update_delay_active(bgp
)) {
7938 " First neighbor established: %s\n",
7939 bgp
->update_delay_begin_time
);
7941 " Delay in progress\n");
7943 if (bgp
->update_delay_over
) {
7945 " First neighbor established: %s\n",
7946 bgp
->update_delay_begin_time
);
7948 " Best-paths resumed: %s\n",
7949 bgp
->update_delay_end_time
);
7951 " zebra update resumed: %s\n",
7952 bgp
->update_delay_zebra_resume_time
);
7954 " peers update resumed: %s\n",
7955 bgp
->update_delay_peers_resume_time
);
7962 if (bgp_maxmed_onstartup_configured(bgp
)
7963 && bgp
->maxmed_active
)
7964 json_object_boolean_true_add(
7965 json
, "maxMedOnStartup");
7966 if (bgp
->v_maxmed_admin
)
7967 json_object_boolean_true_add(
7968 json
, "maxMedAdministrative");
7970 json_object_int_add(
7971 json
, "tableVersion",
7972 bgp_table_version(bgp
->rib
[afi
][safi
]));
7974 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7975 json_object_int_add(json
, "ribCount", ents
);
7976 json_object_int_add(
7978 ents
* sizeof(struct bgp_node
));
7980 ents
= bgp
->af_peer_count
[afi
][safi
];
7981 json_object_int_add(json
, "peerCount", ents
);
7982 json_object_int_add(json
, "peerMemory",
7983 ents
* sizeof(struct peer
));
7985 if ((ents
= listcount(bgp
->group
))) {
7986 json_object_int_add(
7987 json
, "peerGroupCount", ents
);
7988 json_object_int_add(
7989 json
, "peerGroupMemory",
7990 ents
* sizeof(struct
7994 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7995 BGP_CONFIG_DAMPENING
))
7996 json_object_boolean_true_add(
7997 json
, "dampeningEnabled");
7999 if (bgp_maxmed_onstartup_configured(bgp
)
8000 && bgp
->maxmed_active
)
8002 "Max-med on-startup active\n");
8003 if (bgp
->v_maxmed_admin
)
8005 "Max-med administrative active\n");
8007 vty_out(vty
, "BGP table version %" PRIu64
"\n",
8008 bgp_table_version(bgp
->rib
[afi
][safi
]));
8010 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8012 "RIB entries %ld, using %s of memory\n",
8014 mtype_memstr(memstrbuf
,
8016 ents
* sizeof(struct
8019 /* Peer related usage */
8020 ents
= bgp
->af_peer_count
[afi
][safi
];
8021 vty_out(vty
, "Peers %ld, using %s of memory\n",
8024 memstrbuf
, sizeof(memstrbuf
),
8025 ents
* sizeof(struct peer
)));
8027 if ((ents
= listcount(bgp
->group
)))
8029 "Peer groups %ld, using %s of memory\n",
8034 ents
* sizeof(struct
8037 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8038 BGP_CONFIG_DAMPENING
))
8039 vty_out(vty
, "Dampening enabled.\n");
8042 /* Subtract 8 here because 'Neighbor' is
8044 vty_out(vty
, "Neighbor");
8045 vty_out(vty
, "%*s", max_neighbor_width
- 8,
8048 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
8055 json_peer
= json_object_new_object();
8057 if (peer_dynamic_neighbor(peer
)) {
8059 json_object_boolean_true_add(json_peer
,
8064 json_object_string_add(json_peer
, "hostname",
8067 if (peer
->domainname
)
8068 json_object_string_add(json_peer
, "domainname",
8071 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
8072 json_object_int_add(json_peer
, "version", 4);
8073 json_object_int_add(json_peer
, "msgRcvd",
8074 PEER_TOTAL_RX(peer
));
8075 json_object_int_add(json_peer
, "msgSent",
8076 PEER_TOTAL_TX(peer
));
8078 json_object_int_add(json_peer
, "tableVersion",
8079 peer
->version
[afi
][safi
]);
8080 json_object_int_add(json_peer
, "outq",
8082 json_object_int_add(json_peer
, "inq", 0);
8083 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8084 use_json
, json_peer
);
8087 * Adding "pfxRcd" field to match with the corresponding
8088 * CLI. "prefixReceivedCount" will be deprecated in
8091 json_object_int_add(json_peer
, "prefixReceivedCount",
8092 peer
->pcount
[afi
][pfx_rcd_safi
]);
8093 json_object_int_add(json_peer
, "pfxRcd",
8094 peer
->pcount
[afi
][pfx_rcd_safi
]);
8096 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
8097 if (paf
&& PAF_SUBGRP(paf
))
8098 json_object_int_add(json_peer
,
8100 (PAF_SUBGRP(paf
))->scount
);
8102 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8103 json_object_string_add(json_peer
, "state",
8105 else if (peer
->afc_recv
[afi
][safi
])
8106 json_object_string_add(
8108 lookup_msg(bgp_status_msg
, peer
->status
,
8110 else if (CHECK_FLAG(peer
->sflags
,
8111 PEER_STATUS_PREFIX_OVERFLOW
))
8112 json_object_string_add(json_peer
, "state",
8115 json_object_string_add(
8117 lookup_msg(bgp_status_msg
, peer
->status
,
8121 json_object_string_add(json_peer
, "idType",
8123 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8124 json_object_string_add(json_peer
, "idType",
8126 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8127 json_object_string_add(json_peer
, "idType",
8130 json_object_object_add(json_peers
, peer
->host
,
8133 memset(dn_flag
, '\0', sizeof(dn_flag
));
8134 if (peer_dynamic_neighbor(peer
)) {
8140 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8141 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8142 peer
->hostname
, peer
->host
);
8144 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8146 /* pad the neighbor column with spaces */
8147 if (len
< max_neighbor_width
)
8148 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8151 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8152 peer
->as
, PEER_TOTAL_RX(peer
),
8153 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8154 0, peer
->obuf
->count
,
8155 peer_uptime(peer
->uptime
, timebuf
,
8156 BGP_UPTIME_LEN
, 0, NULL
));
8158 if (peer
->status
== Established
)
8159 if (peer
->afc_recv
[afi
][safi
])
8160 vty_out(vty
, " %12ld",
8164 vty_out(vty
, " NoNeg");
8166 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8167 vty_out(vty
, " Idle (Admin)");
8168 else if (CHECK_FLAG(
8170 PEER_STATUS_PREFIX_OVERFLOW
))
8171 vty_out(vty
, " Idle (PfxCt)");
8173 vty_out(vty
, " %12s",
8174 lookup_msg(bgp_status_msg
,
8175 peer
->status
, NULL
));
8182 json_object_object_add(json
, "peers", json_peers
);
8184 json_object_int_add(json
, "totalPeers", count
);
8185 json_object_int_add(json
, "dynamicPeers", dn_count
);
8187 bgp_show_bestpath_json(bgp
, json
);
8189 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8190 json
, JSON_C_TO_STRING_PRETTY
));
8191 json_object_free(json
);
8194 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8196 vty_out(vty
, "No %s neighbor is configured\n",
8197 afi_safi_print(afi
, safi
));
8201 vty_out(vty
, "* - dynamic neighbor\n");
8202 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8203 dn_count
, bgp
->dynamic_neighbors_limit
);
8210 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8211 int safi
, bool use_json
,
8215 int afi_wildcard
= (afi
== AFI_MAX
);
8216 int safi_wildcard
= (safi
== SAFI_MAX
);
8217 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8218 bool nbr_output
= false;
8220 if (use_json
&& is_wildcard
)
8221 vty_out(vty
, "{\n");
8223 afi
= 1; /* AFI_IP */
8224 while (afi
< AFI_MAX
) {
8226 safi
= 1; /* SAFI_UNICAST */
8227 while (safi
< SAFI_MAX
) {
8228 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8232 * So limit output to those afi/safi
8234 * actualy have something interesting in
8238 json
= json_object_new_object();
8241 vty_out(vty
, ",\n");
8245 vty_out(vty
, "\"%s\":",
8249 vty_out(vty
, "\n%s Summary:\n",
8254 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
8266 if (use_json
&& is_wildcard
)
8267 vty_out(vty
, "}\n");
8268 else if (!nbr_output
) {
8270 vty_out(vty
, "{}\n");
8272 vty_out(vty
, "%% No BGP neighbors found\n");
8276 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8277 safi_t safi
, bool use_json
)
8279 struct listnode
*node
, *nnode
;
8281 json_object
*json
= NULL
;
8283 bool nbr_output
= false;
8286 vty_out(vty
, "{\n");
8288 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8291 json
= json_object_new_object();
8294 vty_out(vty
, ",\n");
8298 vty_out(vty
, "\"%s\":",
8299 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8303 vty_out(vty
, "\nInstance %s:\n",
8304 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8308 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
8312 vty_out(vty
, "}\n");
8313 else if (!nbr_output
)
8314 vty_out(vty
, "%% BGP instance not found\n");
8317 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8318 safi_t safi
, bool use_json
)
8323 if (strmatch(name
, "all")) {
8324 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8328 bgp
= bgp_lookup_by_name(name
);
8332 vty_out(vty
, "{}\n");
8335 "%% BGP instance not found\n");
8339 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
8345 bgp
= bgp_get_default();
8348 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
8351 vty_out(vty
, "{}\n");
8353 vty_out(vty
, "%% BGP instance not found\n");
8360 /* `show [ip] bgp summary' commands. */
8361 DEFUN (show_ip_bgp_summary
,
8362 show_ip_bgp_summary_cmd
,
8363 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8367 BGP_INSTANCE_HELP_STR
8369 BGP_SAFI_WITH_LABEL_HELP_STR
8370 "Summary of BGP neighbor status\n"
8374 afi_t afi
= AFI_MAX
;
8375 safi_t safi
= SAFI_MAX
;
8380 if (argv_find(argv
, argc
, "ip", &idx
))
8382 /* [<vrf> VIEWVRFNAME] */
8383 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8384 vrf
= argv
[idx
+ 1]->arg
;
8385 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8387 } else if (argv_find(argv
, argc
, "view", &idx
))
8388 /* [<view> VIEWVRFNAME] */
8389 vrf
= argv
[idx
+ 1]->arg
;
8390 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8391 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8392 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8395 bool uj
= use_json(argc
, argv
);
8397 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8400 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8402 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8403 return "IPv4 Unicast";
8404 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8405 return "IPv4 Multicast";
8406 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8407 return "IPv4 Labeled Unicast";
8408 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8410 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8411 return "IPv4 Encap";
8412 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8413 return "IPv4 Flowspec";
8414 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8415 return "IPv6 Unicast";
8416 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8417 return "IPv6 Multicast";
8418 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8419 return "IPv6 Labeled Unicast";
8420 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8422 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8423 return "IPv6 Encap";
8424 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8425 return "IPv6 Flowspec";
8426 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8427 return "L2VPN EVPN";
8433 * Please note that we have intentionally camelCased
8434 * the return strings here. So if you want
8435 * to use this function, please ensure you
8436 * are doing this within json output
8438 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8440 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8441 return "ipv4Unicast";
8442 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8443 return "ipv4Multicast";
8444 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8445 return "ipv4LabeledUnicast";
8446 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8448 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8450 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8451 return "ipv4Flowspec";
8452 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8453 return "ipv6Unicast";
8454 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8455 return "ipv6Multicast";
8456 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8457 return "ipv6LabeledUnicast";
8458 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8460 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8462 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8463 return "ipv6Flowspec";
8464 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8470 /* Show BGP peer's information. */
8471 enum show_type
{ show_all
, show_peer
, show_ipv4_all
, show_ipv6_all
, show_ipv4_peer
, show_ipv6_peer
};
8473 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8474 afi_t afi
, safi_t safi
,
8475 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8476 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8477 bool use_json
, json_object
*json_pref
)
8480 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8481 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8483 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8484 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8485 json_object_string_add(json_pref
, "sendMode",
8486 "advertisedAndReceived");
8487 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8488 json_object_string_add(json_pref
, "sendMode",
8490 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8491 json_object_string_add(json_pref
, "sendMode",
8494 vty_out(vty
, " Send-mode: ");
8495 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8496 vty_out(vty
, "advertised");
8497 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8498 vty_out(vty
, "%sreceived",
8499 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8508 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8509 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8511 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8512 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8513 json_object_string_add(json_pref
, "recvMode",
8514 "advertisedAndReceived");
8515 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8516 json_object_string_add(json_pref
, "recvMode",
8518 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8519 json_object_string_add(json_pref
, "recvMode",
8522 vty_out(vty
, " Receive-mode: ");
8523 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8524 vty_out(vty
, "advertised");
8525 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8526 vty_out(vty
, "%sreceived",
8527 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8536 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8537 safi_t safi
, bool use_json
,
8538 json_object
*json_neigh
)
8540 struct bgp_filter
*filter
;
8541 struct peer_af
*paf
;
8542 char orf_pfx_name
[BUFSIZ
];
8544 json_object
*json_af
= NULL
;
8545 json_object
*json_prefA
= NULL
;
8546 json_object
*json_prefB
= NULL
;
8547 json_object
*json_addr
= NULL
;
8550 json_addr
= json_object_new_object();
8551 json_af
= json_object_new_object();
8552 filter
= &p
->filter
[afi
][safi
];
8554 if (peer_group_active(p
))
8555 json_object_string_add(json_addr
, "peerGroupMember",
8558 paf
= peer_af_find(p
, afi
, safi
);
8559 if (paf
&& PAF_SUBGRP(paf
)) {
8560 json_object_int_add(json_addr
, "updateGroupId",
8561 PAF_UPDGRP(paf
)->id
);
8562 json_object_int_add(json_addr
, "subGroupId",
8563 PAF_SUBGRP(paf
)->id
);
8564 json_object_int_add(json_addr
, "packetQueueLength",
8565 bpacket_queue_virtual_length(paf
));
8568 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8569 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8570 PEER_CAP_ORF_PREFIX_SM_RCV
)
8571 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8572 PEER_CAP_ORF_PREFIX_RM_ADV
)
8573 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8574 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8575 json_object_int_add(json_af
, "orfType",
8577 json_prefA
= json_object_new_object();
8578 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8579 PEER_CAP_ORF_PREFIX_SM_ADV
,
8580 PEER_CAP_ORF_PREFIX_RM_ADV
,
8581 PEER_CAP_ORF_PREFIX_SM_RCV
,
8582 PEER_CAP_ORF_PREFIX_RM_RCV
,
8583 use_json
, json_prefA
);
8584 json_object_object_add(json_af
, "orfPrefixList",
8588 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8589 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8590 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8591 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8592 PEER_CAP_ORF_PREFIX_RM_ADV
)
8593 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8594 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8595 json_object_int_add(json_af
, "orfOldType",
8596 ORF_TYPE_PREFIX_OLD
);
8597 json_prefB
= json_object_new_object();
8598 bgp_show_peer_afi_orf_cap(
8599 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8600 PEER_CAP_ORF_PREFIX_RM_ADV
,
8601 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8602 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8604 json_object_object_add(json_af
, "orfOldPrefixList",
8608 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8609 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8610 PEER_CAP_ORF_PREFIX_SM_RCV
)
8611 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8612 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8613 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8614 PEER_CAP_ORF_PREFIX_RM_ADV
)
8615 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8616 PEER_CAP_ORF_PREFIX_RM_RCV
)
8617 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8618 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8619 json_object_object_add(json_addr
, "afDependentCap",
8622 json_object_free(json_af
);
8624 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8625 orf_pfx_count
= prefix_bgp_show_prefix_list(
8626 NULL
, afi
, orf_pfx_name
, use_json
);
8628 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8629 PEER_STATUS_ORF_PREFIX_SEND
)
8631 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8632 PEER_STATUS_ORF_PREFIX_SEND
))
8633 json_object_boolean_true_add(json_neigh
,
8636 json_object_int_add(json_addr
, "orfRecvCounter",
8639 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8640 PEER_STATUS_ORF_WAIT_REFRESH
))
8641 json_object_string_add(
8642 json_addr
, "orfFirstUpdate",
8643 "deferredUntilORFOrRouteRefreshRecvd");
8645 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8646 PEER_FLAG_REFLECTOR_CLIENT
))
8647 json_object_boolean_true_add(json_addr
,
8648 "routeReflectorClient");
8649 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8650 PEER_FLAG_RSERVER_CLIENT
))
8651 json_object_boolean_true_add(json_addr
,
8652 "routeServerClient");
8653 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8654 json_object_boolean_true_add(json_addr
,
8655 "inboundSoftConfigPermit");
8657 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8658 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8659 json_object_boolean_true_add(
8661 "privateAsNumsAllReplacedInUpdatesToNbr");
8662 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8663 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8664 json_object_boolean_true_add(
8666 "privateAsNumsReplacedInUpdatesToNbr");
8667 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8668 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8669 json_object_boolean_true_add(
8671 "privateAsNumsAllRemovedInUpdatesToNbr");
8672 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8673 PEER_FLAG_REMOVE_PRIVATE_AS
))
8674 json_object_boolean_true_add(
8676 "privateAsNumsRemovedInUpdatesToNbr");
8678 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8679 json_object_boolean_true_add(
8681 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8684 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8685 json_object_string_add(json_addr
,
8686 "overrideASNsInOutboundUpdates",
8687 "ifAspathEqualRemoteAs");
8689 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8690 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8691 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8692 json_object_boolean_true_add(json_addr
,
8693 "routerAlwaysNextHop");
8694 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8695 PEER_FLAG_AS_PATH_UNCHANGED
))
8696 json_object_boolean_true_add(
8697 json_addr
, "unchangedAsPathPropogatedToNbr");
8698 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8699 PEER_FLAG_NEXTHOP_UNCHANGED
))
8700 json_object_boolean_true_add(
8701 json_addr
, "unchangedNextHopPropogatedToNbr");
8702 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8703 json_object_boolean_true_add(
8704 json_addr
, "unchangedMedPropogatedToNbr");
8705 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8706 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8707 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8708 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8709 PEER_FLAG_SEND_COMMUNITY
)
8710 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8711 PEER_FLAG_SEND_EXT_COMMUNITY
))
8712 json_object_string_add(json_addr
,
8713 "commAttriSentToNbr",
8714 "extendedAndStandard");
8715 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8716 PEER_FLAG_SEND_EXT_COMMUNITY
))
8717 json_object_string_add(json_addr
,
8718 "commAttriSentToNbr",
8721 json_object_string_add(json_addr
,
8722 "commAttriSentToNbr",
8725 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8726 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8727 if (p
->default_rmap
[afi
][safi
].name
)
8728 json_object_string_add(
8729 json_addr
, "defaultRouteMap",
8730 p
->default_rmap
[afi
][safi
].name
);
8732 if (paf
&& PAF_SUBGRP(paf
)
8733 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8734 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8735 json_object_boolean_true_add(json_addr
,
8738 json_object_boolean_true_add(json_addr
,
8742 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8743 if (is_evpn_enabled())
8744 json_object_boolean_true_add(
8745 json_addr
, "advertiseAllVnis");
8748 if (filter
->plist
[FILTER_IN
].name
8749 || filter
->dlist
[FILTER_IN
].name
8750 || filter
->aslist
[FILTER_IN
].name
8751 || filter
->map
[RMAP_IN
].name
)
8752 json_object_boolean_true_add(json_addr
,
8753 "inboundPathPolicyConfig");
8754 if (filter
->plist
[FILTER_OUT
].name
8755 || filter
->dlist
[FILTER_OUT
].name
8756 || filter
->aslist
[FILTER_OUT
].name
8757 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8758 json_object_boolean_true_add(
8759 json_addr
, "outboundPathPolicyConfig");
8762 if (filter
->plist
[FILTER_IN
].name
)
8763 json_object_string_add(json_addr
,
8764 "incomingUpdatePrefixFilterList",
8765 filter
->plist
[FILTER_IN
].name
);
8766 if (filter
->plist
[FILTER_OUT
].name
)
8767 json_object_string_add(json_addr
,
8768 "outgoingUpdatePrefixFilterList",
8769 filter
->plist
[FILTER_OUT
].name
);
8771 /* distribute-list */
8772 if (filter
->dlist
[FILTER_IN
].name
)
8773 json_object_string_add(
8774 json_addr
, "incomingUpdateNetworkFilterList",
8775 filter
->dlist
[FILTER_IN
].name
);
8776 if (filter
->dlist
[FILTER_OUT
].name
)
8777 json_object_string_add(
8778 json_addr
, "outgoingUpdateNetworkFilterList",
8779 filter
->dlist
[FILTER_OUT
].name
);
8782 if (filter
->aslist
[FILTER_IN
].name
)
8783 json_object_string_add(json_addr
,
8784 "incomingUpdateAsPathFilterList",
8785 filter
->aslist
[FILTER_IN
].name
);
8786 if (filter
->aslist
[FILTER_OUT
].name
)
8787 json_object_string_add(json_addr
,
8788 "outgoingUpdateAsPathFilterList",
8789 filter
->aslist
[FILTER_OUT
].name
);
8792 if (filter
->map
[RMAP_IN
].name
)
8793 json_object_string_add(
8794 json_addr
, "routeMapForIncomingAdvertisements",
8795 filter
->map
[RMAP_IN
].name
);
8796 if (filter
->map
[RMAP_OUT
].name
)
8797 json_object_string_add(
8798 json_addr
, "routeMapForOutgoingAdvertisements",
8799 filter
->map
[RMAP_OUT
].name
);
8801 /* ebgp-requires-policy (inbound) */
8802 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8803 && !bgp_inbound_policy_exists(p
, filter
))
8804 json_object_string_add(
8805 json_addr
, "inboundEbgpRequiresPolicy",
8806 "Inbound updates discarded due to missing policy");
8808 /* ebgp-requires-policy (outbound) */
8809 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8810 && (!bgp_outbound_policy_exists(p
, filter
)))
8811 json_object_string_add(
8812 json_addr
, "outboundEbgpRequiresPolicy",
8813 "Outbound updates discarded due to missing policy");
8815 /* unsuppress-map */
8816 if (filter
->usmap
.name
)
8817 json_object_string_add(json_addr
,
8818 "selectiveUnsuppressRouteMap",
8819 filter
->usmap
.name
);
8821 /* Receive prefix count */
8822 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8823 p
->pcount
[afi
][safi
]);
8824 if (paf
&& PAF_SUBGRP(paf
))
8825 json_object_int_add(json_addr
, "sentPrefixCounter",
8826 (PAF_SUBGRP(paf
))->scount
);
8828 /* Maximum prefix */
8829 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8830 json_object_int_add(json_addr
, "prefixAllowedMax",
8831 p
->pmax
[afi
][safi
]);
8832 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8833 PEER_FLAG_MAX_PREFIX_WARNING
))
8834 json_object_boolean_true_add(
8835 json_addr
, "prefixAllowedMaxWarning");
8836 json_object_int_add(json_addr
,
8837 "prefixAllowedWarningThresh",
8838 p
->pmax_threshold
[afi
][safi
]);
8839 if (p
->pmax_restart
[afi
][safi
])
8840 json_object_int_add(
8842 "prefixAllowedRestartIntervalMsecs",
8843 p
->pmax_restart
[afi
][safi
] * 60000);
8845 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8849 filter
= &p
->filter
[afi
][safi
];
8851 vty_out(vty
, " For address family: %s\n",
8852 afi_safi_print(afi
, safi
));
8854 if (peer_group_active(p
))
8855 vty_out(vty
, " %s peer-group member\n",
8858 paf
= peer_af_find(p
, afi
, safi
);
8859 if (paf
&& PAF_SUBGRP(paf
)) {
8860 vty_out(vty
, " Update group %" PRIu64
8861 ", subgroup %" PRIu64
"\n",
8862 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8863 vty_out(vty
, " Packet Queue length %d\n",
8864 bpacket_queue_virtual_length(paf
));
8866 vty_out(vty
, " Not part of any update group\n");
8868 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8869 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8870 PEER_CAP_ORF_PREFIX_SM_RCV
)
8871 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8872 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8873 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8874 PEER_CAP_ORF_PREFIX_RM_ADV
)
8875 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8876 PEER_CAP_ORF_PREFIX_RM_RCV
)
8877 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8878 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8879 vty_out(vty
, " AF-dependant capabilities:\n");
8881 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8882 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8883 PEER_CAP_ORF_PREFIX_SM_RCV
)
8884 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8885 PEER_CAP_ORF_PREFIX_RM_ADV
)
8886 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8887 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8889 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8891 bgp_show_peer_afi_orf_cap(
8892 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8893 PEER_CAP_ORF_PREFIX_RM_ADV
,
8894 PEER_CAP_ORF_PREFIX_SM_RCV
,
8895 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8897 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8898 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8899 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8900 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8901 PEER_CAP_ORF_PREFIX_RM_ADV
)
8902 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8903 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8905 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8906 ORF_TYPE_PREFIX_OLD
);
8907 bgp_show_peer_afi_orf_cap(
8908 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8909 PEER_CAP_ORF_PREFIX_RM_ADV
,
8910 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8911 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8914 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8915 orf_pfx_count
= prefix_bgp_show_prefix_list(
8916 NULL
, afi
, orf_pfx_name
, use_json
);
8918 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8919 PEER_STATUS_ORF_PREFIX_SEND
)
8921 vty_out(vty
, " Outbound Route Filter (ORF):");
8922 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8923 PEER_STATUS_ORF_PREFIX_SEND
))
8924 vty_out(vty
, " sent;");
8926 vty_out(vty
, " received (%d entries)",
8930 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8931 PEER_STATUS_ORF_WAIT_REFRESH
))
8933 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
8935 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8936 PEER_FLAG_REFLECTOR_CLIENT
))
8937 vty_out(vty
, " Route-Reflector Client\n");
8938 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8939 PEER_FLAG_RSERVER_CLIENT
))
8940 vty_out(vty
, " Route-Server Client\n");
8941 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8943 " Inbound soft reconfiguration allowed\n");
8945 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8946 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8948 " Private AS numbers (all) replaced in updates to this neighbor\n");
8949 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8950 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8952 " Private AS numbers replaced in updates to this neighbor\n");
8953 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8954 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8956 " Private AS numbers (all) removed in updates to this neighbor\n");
8957 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8958 PEER_FLAG_REMOVE_PRIVATE_AS
))
8960 " Private AS numbers removed in updates to this neighbor\n");
8962 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8963 vty_out(vty
, " %s\n",
8964 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8965 ->human_description
);
8967 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8969 " Override ASNs in outbound updates if aspath equals remote-as\n");
8971 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8972 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8973 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8974 vty_out(vty
, " NEXT_HOP is always this router\n");
8975 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8976 PEER_FLAG_AS_PATH_UNCHANGED
))
8978 " AS_PATH is propagated unchanged to this neighbor\n");
8979 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8980 PEER_FLAG_NEXTHOP_UNCHANGED
))
8982 " NEXT_HOP is propagated unchanged to this neighbor\n");
8983 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8985 " MED is propagated unchanged to this neighbor\n");
8986 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8987 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8988 PEER_FLAG_SEND_EXT_COMMUNITY
)
8989 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8990 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
8992 " Community attribute sent to this neighbor");
8993 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8994 PEER_FLAG_SEND_COMMUNITY
)
8995 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8996 PEER_FLAG_SEND_EXT_COMMUNITY
)
8997 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8998 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8999 vty_out(vty
, "(all)\n");
9000 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9001 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9002 vty_out(vty
, "(large)\n");
9003 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9004 PEER_FLAG_SEND_EXT_COMMUNITY
))
9005 vty_out(vty
, "(extended)\n");
9007 vty_out(vty
, "(standard)\n");
9009 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9010 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9011 vty_out(vty
, " Default information originate,");
9013 if (p
->default_rmap
[afi
][safi
].name
)
9014 vty_out(vty
, " default route-map %s%s,",
9015 p
->default_rmap
[afi
][safi
].map
? "*"
9017 p
->default_rmap
[afi
][safi
].name
);
9018 if (paf
&& PAF_SUBGRP(paf
)
9019 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9020 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9021 vty_out(vty
, " default sent\n");
9023 vty_out(vty
, " default not sent\n");
9026 /* advertise-vni-all */
9027 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9028 if (is_evpn_enabled())
9029 vty_out(vty
, " advertise-all-vni\n");
9032 if (filter
->plist
[FILTER_IN
].name
9033 || filter
->dlist
[FILTER_IN
].name
9034 || filter
->aslist
[FILTER_IN
].name
9035 || filter
->map
[RMAP_IN
].name
)
9036 vty_out(vty
, " Inbound path policy configured\n");
9037 if (filter
->plist
[FILTER_OUT
].name
9038 || filter
->dlist
[FILTER_OUT
].name
9039 || filter
->aslist
[FILTER_OUT
].name
9040 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9041 vty_out(vty
, " Outbound path policy configured\n");
9044 if (filter
->plist
[FILTER_IN
].name
)
9046 " Incoming update prefix filter list is %s%s\n",
9047 filter
->plist
[FILTER_IN
].plist
? "*" : "",
9048 filter
->plist
[FILTER_IN
].name
);
9049 if (filter
->plist
[FILTER_OUT
].name
)
9051 " Outgoing update prefix filter list is %s%s\n",
9052 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
9053 filter
->plist
[FILTER_OUT
].name
);
9055 /* distribute-list */
9056 if (filter
->dlist
[FILTER_IN
].name
)
9058 " Incoming update network filter list is %s%s\n",
9059 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
9060 filter
->dlist
[FILTER_IN
].name
);
9061 if (filter
->dlist
[FILTER_OUT
].name
)
9063 " Outgoing update network filter list is %s%s\n",
9064 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
9065 filter
->dlist
[FILTER_OUT
].name
);
9068 if (filter
->aslist
[FILTER_IN
].name
)
9070 " Incoming update AS path filter list is %s%s\n",
9071 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
9072 filter
->aslist
[FILTER_IN
].name
);
9073 if (filter
->aslist
[FILTER_OUT
].name
)
9075 " Outgoing update AS path filter list is %s%s\n",
9076 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
9077 filter
->aslist
[FILTER_OUT
].name
);
9080 if (filter
->map
[RMAP_IN
].name
)
9082 " Route map for incoming advertisements is %s%s\n",
9083 filter
->map
[RMAP_IN
].map
? "*" : "",
9084 filter
->map
[RMAP_IN
].name
);
9085 if (filter
->map
[RMAP_OUT
].name
)
9087 " Route map for outgoing advertisements is %s%s\n",
9088 filter
->map
[RMAP_OUT
].map
? "*" : "",
9089 filter
->map
[RMAP_OUT
].name
);
9091 /* ebgp-requires-policy (inbound) */
9092 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9093 && !bgp_inbound_policy_exists(p
, filter
))
9095 " Inbound updates discarded due to missing policy\n");
9097 /* ebgp-requires-policy (outbound) */
9098 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9099 && !bgp_outbound_policy_exists(p
, filter
))
9101 " Outbound updates discarded due to missing policy\n");
9103 /* unsuppress-map */
9104 if (filter
->usmap
.name
)
9106 " Route map for selective unsuppress is %s%s\n",
9107 filter
->usmap
.map
? "*" : "",
9108 filter
->usmap
.name
);
9110 /* Receive prefix count */
9111 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
9113 /* Maximum prefix */
9114 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9115 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
9117 CHECK_FLAG(p
->af_flags
[afi
][safi
],
9118 PEER_FLAG_MAX_PREFIX_WARNING
)
9121 vty_out(vty
, " Threshold for warning message %d%%",
9122 p
->pmax_threshold
[afi
][safi
]);
9123 if (p
->pmax_restart
[afi
][safi
])
9124 vty_out(vty
, ", restart interval %d min",
9125 p
->pmax_restart
[afi
][safi
]);
9133 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
9137 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
9138 char timebuf
[BGP_UPTIME_LEN
];
9140 const char *subcode_str
;
9141 const char *code_str
;
9146 json_object
*json_neigh
= NULL
;
9152 json_neigh
= json_object_new_object();
9154 memset(dn_flag
, '\0', sizeof(dn_flag
));
9155 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9159 if (p
->conf_if
) /* Configured interface name. */
9160 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9161 BGP_PEER_SU_UNSPEC(p
)
9163 : sockunion2str(&p
->su
, buf
,
9165 else /* Configured IP address. */
9166 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9171 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9172 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9174 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9175 json_object_string_add(
9176 json_neigh
, "bgpNeighborAddr",
9177 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9179 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9181 if (p
->change_local_as
)
9182 json_object_int_add(json_neigh
, "localAs",
9183 p
->change_local_as
);
9185 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9187 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9188 json_object_boolean_true_add(json_neigh
,
9189 "localAsNoPrepend");
9191 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9192 json_object_boolean_true_add(json_neigh
,
9193 "localAsReplaceAs");
9195 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9196 || (p
->as_type
== AS_INTERNAL
))
9197 vty_out(vty
, "remote AS %u, ", p
->as
);
9199 vty_out(vty
, "remote AS Unspecified, ");
9200 vty_out(vty
, "local AS %u%s%s, ",
9201 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9202 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9205 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9209 /* peer type internal or confed-internal */
9210 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
9212 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9213 json_object_boolean_true_add(
9214 json_neigh
, "nbrConfedInternalLink");
9216 json_object_boolean_true_add(json_neigh
,
9219 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9220 vty_out(vty
, "confed-internal link\n");
9222 vty_out(vty
, "internal link\n");
9224 /* peer type external or confed-external */
9225 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
9227 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9228 json_object_boolean_true_add(
9229 json_neigh
, "nbrConfedExternalLink");
9231 json_object_boolean_true_add(json_neigh
,
9234 if (bgp_confederation_peers_check(bgp
, p
->as
))
9235 vty_out(vty
, "confed-external link\n");
9237 vty_out(vty
, "external link\n");
9241 json_object_boolean_true_add(json_neigh
,
9242 "nbrUnspecifiedLink");
9244 vty_out(vty
, "unspecified link\n");
9250 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9252 vty_out(vty
, " Description: %s\n", p
->desc
);
9258 json_object_string_add(json_neigh
, "hostname",
9262 json_object_string_add(json_neigh
, "domainname",
9265 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9266 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9269 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9276 json_object_string_add(json_neigh
, "peerGroup",
9280 struct prefix prefix
, *range
= NULL
;
9282 sockunion2hostprefix(&(p
->su
), &prefix
);
9283 range
= peer_group_lookup_dynamic_neighbor_range(
9287 prefix2str(range
, buf1
, sizeof(buf1
));
9288 json_object_string_add(
9290 "peerSubnetRangeGroup", buf1
);
9295 " Member of peer-group %s for session parameters\n",
9299 struct prefix prefix
, *range
= NULL
;
9301 sockunion2hostprefix(&(p
->su
), &prefix
);
9302 range
= peer_group_lookup_dynamic_neighbor_range(
9306 prefix2str(range
, buf1
, sizeof(buf1
));
9308 " Belongs to the subnet range group: %s\n",
9316 /* Administrative shutdown. */
9317 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9318 json_object_boolean_true_add(json_neigh
,
9322 json_object_int_add(json_neigh
, "bgpVersion", 4);
9323 json_object_string_add(
9324 json_neigh
, "remoteRouterId",
9325 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9326 json_object_string_add(
9327 json_neigh
, "localRouterId",
9328 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9332 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9333 && bgp_confederation_peers_check(bgp
, p
->as
))
9334 json_object_boolean_true_add(json_neigh
,
9338 json_object_string_add(
9339 json_neigh
, "bgpState",
9340 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9342 if (p
->status
== Established
) {
9345 uptime
= bgp_clock();
9346 uptime
-= p
->uptime
;
9347 epoch_tbuf
= time(NULL
) - uptime
;
9349 #if CONFDATE > 20200101
9351 "bgpTimerUp should be deprecated and can be removed now");
9354 * bgpTimerUp was miliseconds that was accurate
9355 * up to 1 day, then the value returned
9356 * became garbage. So in order to provide
9357 * some level of backwards compatability,
9358 * we still provde the data, but now
9359 * we are returning the correct value
9360 * and also adding a new bgpTimerUpMsec
9361 * which will allow us to deprecate
9364 json_object_int_add(json_neigh
, "bgpTimerUp",
9366 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9368 json_object_string_add(json_neigh
, "bgpTimerUpString",
9369 peer_uptime(p
->uptime
, timebuf
,
9372 json_object_int_add(json_neigh
,
9373 "bgpTimerUpEstablishedEpoch",
9377 else if (p
->status
== Active
) {
9378 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9379 json_object_string_add(json_neigh
, "bgpStateIs",
9381 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9382 json_object_string_add(json_neigh
, "bgpStateIs",
9390 uptime
= bgp_clock();
9391 uptime
-= p
->readtime
;
9392 tm
= gmtime(&uptime
);
9393 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9394 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9395 + (tm
->tm_hour
* 3600000));
9397 uptime
= bgp_clock();
9398 uptime
-= p
->last_write
;
9399 tm
= gmtime(&uptime
);
9400 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9401 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9402 + (tm
->tm_hour
* 3600000));
9404 uptime
= bgp_clock();
9405 uptime
-= p
->update_time
;
9406 tm
= gmtime(&uptime
);
9407 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9408 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9409 + (tm
->tm_hour
* 3600000));
9411 /* Configured timer values. */
9412 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9413 p
->v_holdtime
* 1000);
9414 json_object_int_add(json_neigh
,
9415 "bgpTimerKeepAliveIntervalMsecs",
9416 p
->v_keepalive
* 1000);
9417 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9418 json_object_int_add(json_neigh
,
9419 "bgpTimerConfiguredHoldTimeMsecs",
9420 p
->holdtime
* 1000);
9421 json_object_int_add(
9423 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9424 p
->keepalive
* 1000);
9425 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9426 || (bgp
->default_keepalive
9427 != BGP_DEFAULT_KEEPALIVE
)) {
9428 json_object_int_add(json_neigh
,
9429 "bgpTimerConfiguredHoldTimeMsecs",
9430 bgp
->default_holdtime
);
9431 json_object_int_add(
9433 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9434 bgp
->default_keepalive
);
9437 /* Administrative shutdown. */
9438 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9439 vty_out(vty
, " Administratively shut down\n");
9442 vty_out(vty
, " BGP version 4");
9443 vty_out(vty
, ", remote router ID %s",
9444 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9445 vty_out(vty
, ", local router ID %s\n",
9446 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9450 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9451 && bgp_confederation_peers_check(bgp
, p
->as
))
9453 " Neighbor under common administration\n");
9456 vty_out(vty
, " BGP state = %s",
9457 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9459 if (p
->status
== Established
)
9460 vty_out(vty
, ", up for %8s",
9461 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9464 else if (p
->status
== Active
) {
9465 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9466 vty_out(vty
, " (passive)");
9467 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9468 vty_out(vty
, " (NSF passive)");
9473 vty_out(vty
, " Last read %s",
9474 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9476 vty_out(vty
, ", Last write %s\n",
9477 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9480 /* Configured timer values. */
9482 " Hold time is %d, keepalive interval is %d seconds\n",
9483 p
->v_holdtime
, p
->v_keepalive
);
9484 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9485 vty_out(vty
, " Configured hold time is %d",
9487 vty_out(vty
, ", keepalive interval is %d seconds\n",
9489 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9490 || (bgp
->default_keepalive
9491 != BGP_DEFAULT_KEEPALIVE
)) {
9492 vty_out(vty
, " Configured hold time is %d",
9493 bgp
->default_holdtime
);
9494 vty_out(vty
, ", keepalive interval is %d seconds\n",
9495 bgp
->default_keepalive
);
9499 if (p
->status
== Established
) {
9500 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9501 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9502 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9503 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9504 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9505 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9506 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9507 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9508 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9509 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9510 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9511 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9512 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9513 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9514 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9515 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9516 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9517 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9518 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9519 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9521 json_object
*json_cap
= NULL
;
9523 json_cap
= json_object_new_object();
9526 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9527 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9528 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9529 && CHECK_FLAG(p
->cap
,
9531 json_object_string_add(
9532 json_cap
, "4byteAs",
9533 "advertisedAndReceived");
9534 else if (CHECK_FLAG(p
->cap
,
9536 json_object_string_add(
9537 json_cap
, "4byteAs",
9539 else if (CHECK_FLAG(p
->cap
,
9541 json_object_string_add(
9542 json_cap
, "4byteAs",
9547 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9548 || CHECK_FLAG(p
->cap
,
9549 PEER_CAP_ADDPATH_ADV
)) {
9550 json_object
*json_add
= NULL
;
9551 const char *print_store
;
9553 json_add
= json_object_new_object();
9555 FOREACH_AFI_SAFI (afi
, safi
) {
9556 json_object
*json_sub
= NULL
;
9558 json_object_new_object();
9559 print_store
= afi_safi_print(
9565 PEER_CAP_ADDPATH_AF_TX_ADV
)
9569 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9574 PEER_CAP_ADDPATH_AF_TX_ADV
)
9579 PEER_CAP_ADDPATH_AF_TX_RCV
))
9580 json_object_boolean_true_add(
9582 "txAdvertisedAndReceived");
9588 PEER_CAP_ADDPATH_AF_TX_ADV
))
9589 json_object_boolean_true_add(
9597 PEER_CAP_ADDPATH_AF_TX_RCV
))
9598 json_object_boolean_true_add(
9606 PEER_CAP_ADDPATH_AF_RX_ADV
)
9610 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9615 PEER_CAP_ADDPATH_AF_RX_ADV
)
9620 PEER_CAP_ADDPATH_AF_RX_RCV
))
9621 json_object_boolean_true_add(
9623 "rxAdvertisedAndReceived");
9629 PEER_CAP_ADDPATH_AF_RX_ADV
))
9630 json_object_boolean_true_add(
9638 PEER_CAP_ADDPATH_AF_RX_RCV
))
9639 json_object_boolean_true_add(
9647 PEER_CAP_ADDPATH_AF_TX_ADV
)
9651 PEER_CAP_ADDPATH_AF_TX_RCV
)
9655 PEER_CAP_ADDPATH_AF_RX_ADV
)
9659 PEER_CAP_ADDPATH_AF_RX_RCV
))
9660 json_object_object_add(
9669 json_object_object_add(
9670 json_cap
, "addPath", json_add
);
9674 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9675 || CHECK_FLAG(p
->cap
,
9676 PEER_CAP_DYNAMIC_ADV
)) {
9677 if (CHECK_FLAG(p
->cap
,
9678 PEER_CAP_DYNAMIC_ADV
)
9679 && CHECK_FLAG(p
->cap
,
9680 PEER_CAP_DYNAMIC_RCV
))
9681 json_object_string_add(
9682 json_cap
, "dynamic",
9683 "advertisedAndReceived");
9684 else if (CHECK_FLAG(
9686 PEER_CAP_DYNAMIC_ADV
))
9687 json_object_string_add(
9688 json_cap
, "dynamic",
9690 else if (CHECK_FLAG(
9692 PEER_CAP_DYNAMIC_RCV
))
9693 json_object_string_add(
9694 json_cap
, "dynamic",
9698 /* Extended nexthop */
9699 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9700 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9701 json_object
*json_nxt
= NULL
;
9702 const char *print_store
;
9705 if (CHECK_FLAG(p
->cap
,
9707 && CHECK_FLAG(p
->cap
,
9709 json_object_string_add(
9712 "advertisedAndReceived");
9713 else if (CHECK_FLAG(p
->cap
,
9715 json_object_string_add(
9719 else if (CHECK_FLAG(p
->cap
,
9721 json_object_string_add(
9726 if (CHECK_FLAG(p
->cap
,
9727 PEER_CAP_ENHE_RCV
)) {
9729 json_object_new_object();
9731 for (safi
= SAFI_UNICAST
;
9732 safi
< SAFI_MAX
; safi
++) {
9737 PEER_CAP_ENHE_AF_RCV
)) {
9738 print_store
= afi_safi_print(
9741 json_object_string_add(
9744 "recieved"); /* misspelled for compatibility */
9747 json_object_object_add(
9749 "extendedNexthopFamililesByPeer",
9755 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9756 || CHECK_FLAG(p
->cap
,
9757 PEER_CAP_REFRESH_NEW_RCV
)
9758 || CHECK_FLAG(p
->cap
,
9759 PEER_CAP_REFRESH_OLD_RCV
)) {
9760 if (CHECK_FLAG(p
->cap
,
9761 PEER_CAP_REFRESH_ADV
)
9764 PEER_CAP_REFRESH_NEW_RCV
)
9767 PEER_CAP_REFRESH_OLD_RCV
))) {
9770 PEER_CAP_REFRESH_OLD_RCV
)
9773 PEER_CAP_REFRESH_NEW_RCV
))
9774 json_object_string_add(
9777 "advertisedAndReceivedOldNew");
9781 PEER_CAP_REFRESH_OLD_RCV
))
9782 json_object_string_add(
9785 "advertisedAndReceivedOld");
9787 json_object_string_add(
9790 "advertisedAndReceivedNew");
9795 PEER_CAP_REFRESH_ADV
))
9796 json_object_string_add(
9803 PEER_CAP_REFRESH_NEW_RCV
)
9806 PEER_CAP_REFRESH_OLD_RCV
))
9807 json_object_string_add(
9813 /* Multiprotocol Extensions */
9814 json_object
*json_multi
= NULL
;
9815 json_multi
= json_object_new_object();
9817 FOREACH_AFI_SAFI (afi
, safi
) {
9818 if (p
->afc_adv
[afi
][safi
]
9819 || p
->afc_recv
[afi
][safi
]) {
9820 json_object
*json_exten
= NULL
;
9822 json_object_new_object();
9824 if (p
->afc_adv
[afi
][safi
]
9825 && p
->afc_recv
[afi
][safi
])
9826 json_object_boolean_true_add(
9828 "advertisedAndReceived");
9829 else if (p
->afc_adv
[afi
][safi
])
9830 json_object_boolean_true_add(
9833 else if (p
->afc_recv
[afi
][safi
])
9834 json_object_boolean_true_add(
9838 json_object_object_add(
9845 json_object_object_add(
9846 json_cap
, "multiprotocolExtensions",
9849 /* Hostname capabilities */
9850 json_object
*json_hname
= NULL
;
9852 json_hname
= json_object_new_object();
9854 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9855 json_object_string_add(
9856 json_hname
, "advHostName",
9857 bgp
->peer_self
->hostname
9861 json_object_string_add(
9862 json_hname
, "advDomainName",
9863 bgp
->peer_self
->domainname
9870 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9871 json_object_string_add(
9872 json_hname
, "rcvHostName",
9873 p
->hostname
? p
->hostname
9875 json_object_string_add(
9876 json_hname
, "rcvDomainName",
9877 p
->domainname
? p
->domainname
9881 json_object_object_add(json_cap
, "hostName",
9884 /* Gracefull Restart */
9885 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9886 || CHECK_FLAG(p
->cap
,
9887 PEER_CAP_RESTART_ADV
)) {
9888 if (CHECK_FLAG(p
->cap
,
9889 PEER_CAP_RESTART_ADV
)
9890 && CHECK_FLAG(p
->cap
,
9891 PEER_CAP_RESTART_RCV
))
9892 json_object_string_add(
9895 "advertisedAndReceived");
9896 else if (CHECK_FLAG(
9898 PEER_CAP_RESTART_ADV
))
9899 json_object_string_add(
9901 "gracefulRestartCapability",
9903 else if (CHECK_FLAG(
9905 PEER_CAP_RESTART_RCV
))
9906 json_object_string_add(
9908 "gracefulRestartCapability",
9911 if (CHECK_FLAG(p
->cap
,
9912 PEER_CAP_RESTART_RCV
)) {
9913 int restart_af_count
= 0;
9914 json_object
*json_restart
=
9917 json_object_new_object();
9919 json_object_int_add(
9921 "gracefulRestartRemoteTimerMsecs",
9922 p
->v_gr_restart
* 1000);
9924 FOREACH_AFI_SAFI (afi
, safi
) {
9929 PEER_CAP_RESTART_AF_RCV
)) {
9934 json_object_new_object();
9940 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
9941 json_object_boolean_true_add(
9945 json_object_object_add(
9953 if (!restart_af_count
) {
9954 json_object_string_add(
9956 "addressFamiliesByPeer",
9961 json_object_object_add(
9963 "addressFamiliesByPeer",
9967 json_object_object_add(json_neigh
,
9968 "neighborCapabilities",
9971 vty_out(vty
, " Neighbor capabilities:\n");
9974 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9975 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9976 vty_out(vty
, " 4 Byte AS:");
9977 if (CHECK_FLAG(p
->cap
,
9979 vty_out(vty
, " advertised");
9980 if (CHECK_FLAG(p
->cap
,
9982 vty_out(vty
, " %sreceived",
9992 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9993 || CHECK_FLAG(p
->cap
,
9994 PEER_CAP_ADDPATH_ADV
)) {
9995 vty_out(vty
, " AddPath:\n");
9997 FOREACH_AFI_SAFI (afi
, safi
) {
10001 PEER_CAP_ADDPATH_AF_TX_ADV
)
10005 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
10016 PEER_CAP_ADDPATH_AF_TX_ADV
))
10027 PEER_CAP_ADDPATH_AF_TX_RCV
))
10034 PEER_CAP_ADDPATH_AF_TX_ADV
)
10038 vty_out(vty
, "\n");
10044 PEER_CAP_ADDPATH_AF_RX_ADV
)
10048 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
10059 PEER_CAP_ADDPATH_AF_RX_ADV
))
10070 PEER_CAP_ADDPATH_AF_RX_RCV
))
10077 PEER_CAP_ADDPATH_AF_RX_ADV
)
10081 vty_out(vty
, "\n");
10087 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10088 || CHECK_FLAG(p
->cap
,
10089 PEER_CAP_DYNAMIC_ADV
)) {
10090 vty_out(vty
, " Dynamic:");
10091 if (CHECK_FLAG(p
->cap
,
10092 PEER_CAP_DYNAMIC_ADV
))
10093 vty_out(vty
, " advertised");
10094 if (CHECK_FLAG(p
->cap
,
10095 PEER_CAP_DYNAMIC_RCV
))
10096 vty_out(vty
, " %sreceived",
10099 PEER_CAP_DYNAMIC_ADV
)
10102 vty_out(vty
, "\n");
10105 /* Extended nexthop */
10106 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10107 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10108 vty_out(vty
, " Extended nexthop:");
10109 if (CHECK_FLAG(p
->cap
,
10110 PEER_CAP_ENHE_ADV
))
10111 vty_out(vty
, " advertised");
10112 if (CHECK_FLAG(p
->cap
,
10113 PEER_CAP_ENHE_RCV
))
10114 vty_out(vty
, " %sreceived",
10120 vty_out(vty
, "\n");
10122 if (CHECK_FLAG(p
->cap
,
10123 PEER_CAP_ENHE_RCV
)) {
10125 " Address families by peer:\n ");
10126 for (safi
= SAFI_UNICAST
;
10127 safi
< SAFI_MAX
; safi
++)
10132 PEER_CAP_ENHE_AF_RCV
))
10141 /* Route Refresh */
10142 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10143 || CHECK_FLAG(p
->cap
,
10144 PEER_CAP_REFRESH_NEW_RCV
)
10145 || CHECK_FLAG(p
->cap
,
10146 PEER_CAP_REFRESH_OLD_RCV
)) {
10147 vty_out(vty
, " Route refresh:");
10148 if (CHECK_FLAG(p
->cap
,
10149 PEER_CAP_REFRESH_ADV
))
10150 vty_out(vty
, " advertised");
10151 if (CHECK_FLAG(p
->cap
,
10152 PEER_CAP_REFRESH_NEW_RCV
)
10155 PEER_CAP_REFRESH_OLD_RCV
))
10156 vty_out(vty
, " %sreceived(%s)",
10159 PEER_CAP_REFRESH_ADV
)
10164 PEER_CAP_REFRESH_OLD_RCV
)
10167 PEER_CAP_REFRESH_NEW_RCV
))
10171 PEER_CAP_REFRESH_OLD_RCV
)
10175 vty_out(vty
, "\n");
10178 /* Multiprotocol Extensions */
10179 FOREACH_AFI_SAFI (afi
, safi
)
10180 if (p
->afc_adv
[afi
][safi
]
10181 || p
->afc_recv
[afi
][safi
]) {
10183 " Address Family %s:",
10184 afi_safi_print(afi
,
10186 if (p
->afc_adv
[afi
][safi
])
10189 if (p
->afc_recv
[afi
][safi
])
10196 vty_out(vty
, "\n");
10199 /* Hostname capability */
10200 vty_out(vty
, " Hostname Capability:");
10202 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10204 " advertised (name: %s,domain name: %s)",
10205 bgp
->peer_self
->hostname
10209 bgp
->peer_self
->domainname
10214 vty_out(vty
, " not advertised");
10217 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10219 " received (name: %s,domain name: %s)",
10220 p
->hostname
? p
->hostname
10222 p
->domainname
? p
->domainname
10225 vty_out(vty
, " not received");
10228 vty_out(vty
, "\n");
10230 /* Gracefull Restart */
10231 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10232 || CHECK_FLAG(p
->cap
,
10233 PEER_CAP_RESTART_ADV
)) {
10235 " Graceful Restart Capabilty:");
10236 if (CHECK_FLAG(p
->cap
,
10237 PEER_CAP_RESTART_ADV
))
10238 vty_out(vty
, " advertised");
10239 if (CHECK_FLAG(p
->cap
,
10240 PEER_CAP_RESTART_RCV
))
10241 vty_out(vty
, " %sreceived",
10244 PEER_CAP_RESTART_ADV
)
10247 vty_out(vty
, "\n");
10249 if (CHECK_FLAG(p
->cap
,
10250 PEER_CAP_RESTART_RCV
)) {
10251 int restart_af_count
= 0;
10254 " Remote Restart timer is %d seconds\n",
10257 " Address families by peer:\n ");
10259 FOREACH_AFI_SAFI (afi
, safi
)
10264 PEER_CAP_RESTART_AF_RCV
)) {
10277 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10279 : "not preserved");
10280 restart_af_count
++;
10282 if (!restart_af_count
)
10283 vty_out(vty
, "none");
10284 vty_out(vty
, "\n");
10291 /* graceful restart information */
10292 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10293 || p
->t_gr_stale
) {
10294 json_object
*json_grace
= NULL
;
10295 json_object
*json_grace_send
= NULL
;
10296 json_object
*json_grace_recv
= NULL
;
10297 int eor_send_af_count
= 0;
10298 int eor_receive_af_count
= 0;
10301 json_grace
= json_object_new_object();
10302 json_grace_send
= json_object_new_object();
10303 json_grace_recv
= json_object_new_object();
10305 if (p
->status
== Established
) {
10306 FOREACH_AFI_SAFI (afi
, safi
) {
10307 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10308 PEER_STATUS_EOR_SEND
)) {
10309 json_object_boolean_true_add(
10311 afi_safi_print(afi
,
10313 eor_send_af_count
++;
10316 FOREACH_AFI_SAFI (afi
, safi
) {
10318 p
->af_sflags
[afi
][safi
],
10319 PEER_STATUS_EOR_RECEIVED
)) {
10320 json_object_boolean_true_add(
10322 afi_safi_print(afi
,
10324 eor_receive_af_count
++;
10329 json_object_object_add(json_grace
, "endOfRibSend",
10331 json_object_object_add(json_grace
, "endOfRibRecv",
10334 if (p
->t_gr_restart
)
10335 json_object_int_add(json_grace
,
10336 "gracefulRestartTimerMsecs",
10337 thread_timer_remain_second(
10342 json_object_int_add(
10344 "gracefulStalepathTimerMsecs",
10345 thread_timer_remain_second(
10349 json_object_object_add(
10350 json_neigh
, "gracefulRestartInfo", json_grace
);
10352 vty_out(vty
, " Graceful restart information:\n");
10353 if (p
->status
== Established
) {
10354 vty_out(vty
, " End-of-RIB send: ");
10355 FOREACH_AFI_SAFI (afi
, safi
) {
10356 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10357 PEER_STATUS_EOR_SEND
)) {
10358 vty_out(vty
, "%s%s",
10359 eor_send_af_count
? ", "
10361 afi_safi_print(afi
,
10363 eor_send_af_count
++;
10366 vty_out(vty
, "\n");
10367 vty_out(vty
, " End-of-RIB received: ");
10368 FOREACH_AFI_SAFI (afi
, safi
) {
10370 p
->af_sflags
[afi
][safi
],
10371 PEER_STATUS_EOR_RECEIVED
)) {
10372 vty_out(vty
, "%s%s",
10373 eor_receive_af_count
10376 afi_safi_print(afi
,
10378 eor_receive_af_count
++;
10381 vty_out(vty
, "\n");
10384 if (p
->t_gr_restart
)
10386 " The remaining time of restart timer is %ld\n",
10387 thread_timer_remain_second(
10392 " The remaining time of stalepath timer is %ld\n",
10393 thread_timer_remain_second(
10398 json_object
*json_stat
= NULL
;
10399 json_stat
= json_object_new_object();
10400 /* Packet counts. */
10401 json_object_int_add(json_stat
, "depthInq", 0);
10402 json_object_int_add(json_stat
, "depthOutq",
10403 (unsigned long)p
->obuf
->count
);
10404 json_object_int_add(json_stat
, "opensSent",
10405 atomic_load_explicit(&p
->open_out
,
10406 memory_order_relaxed
));
10407 json_object_int_add(json_stat
, "opensRecv",
10408 atomic_load_explicit(&p
->open_in
,
10409 memory_order_relaxed
));
10410 json_object_int_add(json_stat
, "notificationsSent",
10411 atomic_load_explicit(&p
->notify_out
,
10412 memory_order_relaxed
));
10413 json_object_int_add(json_stat
, "notificationsRecv",
10414 atomic_load_explicit(&p
->notify_in
,
10415 memory_order_relaxed
));
10416 json_object_int_add(json_stat
, "updatesSent",
10417 atomic_load_explicit(&p
->update_out
,
10418 memory_order_relaxed
));
10419 json_object_int_add(json_stat
, "updatesRecv",
10420 atomic_load_explicit(&p
->update_in
,
10421 memory_order_relaxed
));
10422 json_object_int_add(json_stat
, "keepalivesSent",
10423 atomic_load_explicit(&p
->keepalive_out
,
10424 memory_order_relaxed
));
10425 json_object_int_add(json_stat
, "keepalivesRecv",
10426 atomic_load_explicit(&p
->keepalive_in
,
10427 memory_order_relaxed
));
10428 json_object_int_add(json_stat
, "routeRefreshSent",
10429 atomic_load_explicit(&p
->refresh_out
,
10430 memory_order_relaxed
));
10431 json_object_int_add(json_stat
, "routeRefreshRecv",
10432 atomic_load_explicit(&p
->refresh_in
,
10433 memory_order_relaxed
));
10434 json_object_int_add(json_stat
, "capabilitySent",
10435 atomic_load_explicit(&p
->dynamic_cap_out
,
10436 memory_order_relaxed
));
10437 json_object_int_add(json_stat
, "capabilityRecv",
10438 atomic_load_explicit(&p
->dynamic_cap_in
,
10439 memory_order_relaxed
));
10440 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10441 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10442 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10444 /* Packet counts. */
10445 vty_out(vty
, " Message statistics:\n");
10446 vty_out(vty
, " Inq depth is 0\n");
10447 vty_out(vty
, " Outq depth is %lu\n",
10448 (unsigned long)p
->obuf
->count
);
10449 vty_out(vty
, " Sent Rcvd\n");
10450 vty_out(vty
, " Opens: %10d %10d\n",
10451 atomic_load_explicit(&p
->open_out
,
10452 memory_order_relaxed
),
10453 atomic_load_explicit(&p
->open_in
,
10454 memory_order_relaxed
));
10455 vty_out(vty
, " Notifications: %10d %10d\n",
10456 atomic_load_explicit(&p
->notify_out
,
10457 memory_order_relaxed
),
10458 atomic_load_explicit(&p
->notify_in
,
10459 memory_order_relaxed
));
10460 vty_out(vty
, " Updates: %10d %10d\n",
10461 atomic_load_explicit(&p
->update_out
,
10462 memory_order_relaxed
),
10463 atomic_load_explicit(&p
->update_in
,
10464 memory_order_relaxed
));
10465 vty_out(vty
, " Keepalives: %10d %10d\n",
10466 atomic_load_explicit(&p
->keepalive_out
,
10467 memory_order_relaxed
),
10468 atomic_load_explicit(&p
->keepalive_in
,
10469 memory_order_relaxed
));
10470 vty_out(vty
, " Route Refresh: %10d %10d\n",
10471 atomic_load_explicit(&p
->refresh_out
,
10472 memory_order_relaxed
),
10473 atomic_load_explicit(&p
->refresh_in
,
10474 memory_order_relaxed
));
10475 vty_out(vty
, " Capability: %10d %10d\n",
10476 atomic_load_explicit(&p
->dynamic_cap_out
,
10477 memory_order_relaxed
),
10478 atomic_load_explicit(&p
->dynamic_cap_in
,
10479 memory_order_relaxed
));
10480 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10485 /* advertisement-interval */
10486 json_object_int_add(json_neigh
,
10487 "minBtwnAdvertisementRunsTimerMsecs",
10488 p
->v_routeadv
* 1000);
10490 /* Update-source. */
10491 if (p
->update_if
|| p
->update_source
) {
10493 json_object_string_add(json_neigh
,
10496 else if (p
->update_source
)
10497 json_object_string_add(
10498 json_neigh
, "updateSource",
10499 sockunion2str(p
->update_source
, buf1
,
10503 /* advertisement-interval */
10505 " Minimum time between advertisement runs is %d seconds\n",
10508 /* Update-source. */
10509 if (p
->update_if
|| p
->update_source
) {
10510 vty_out(vty
, " Update source is ");
10512 vty_out(vty
, "%s", p
->update_if
);
10513 else if (p
->update_source
)
10515 sockunion2str(p
->update_source
, buf1
,
10517 vty_out(vty
, "\n");
10520 vty_out(vty
, "\n");
10523 /* Address Family Information */
10524 json_object
*json_hold
= NULL
;
10527 json_hold
= json_object_new_object();
10529 FOREACH_AFI_SAFI (afi
, safi
)
10530 if (p
->afc
[afi
][safi
])
10531 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10535 json_object_object_add(json_neigh
, "addressFamilyInfo",
10537 json_object_int_add(json_neigh
, "connectionsEstablished",
10539 json_object_int_add(json_neigh
, "connectionsDropped",
10542 vty_out(vty
, " Connections established %d; dropped %d\n",
10543 p
->established
, p
->dropped
);
10545 if (!p
->last_reset
) {
10547 json_object_string_add(json_neigh
, "lastReset",
10550 vty_out(vty
, " Last reset never\n");
10556 uptime
= bgp_clock();
10557 uptime
-= p
->resettime
;
10558 tm
= gmtime(&uptime
);
10559 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10560 (tm
->tm_sec
* 1000)
10561 + (tm
->tm_min
* 60000)
10562 + (tm
->tm_hour
* 3600000));
10563 json_object_string_add(
10564 json_neigh
, "lastResetDueTo",
10565 peer_down_str
[(int)p
->last_reset
]);
10566 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10567 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10568 char errorcodesubcode_hexstr
[5];
10569 char errorcodesubcode_str
[256];
10571 code_str
= bgp_notify_code_str(p
->notify
.code
);
10572 subcode_str
= bgp_notify_subcode_str(
10573 p
->notify
.code
, p
->notify
.subcode
);
10575 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10576 p
->notify
.code
, p
->notify
.subcode
);
10577 json_object_string_add(json_neigh
,
10578 "lastErrorCodeSubcode",
10579 errorcodesubcode_hexstr
);
10580 snprintf(errorcodesubcode_str
, 255, "%s%s",
10581 code_str
, subcode_str
);
10582 json_object_string_add(json_neigh
,
10583 "lastNotificationReason",
10584 errorcodesubcode_str
);
10585 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10586 && p
->notify
.code
== BGP_NOTIFY_CEASE
10587 && (p
->notify
.subcode
10588 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10589 || p
->notify
.subcode
10590 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10591 && p
->notify
.length
) {
10593 const char *msg_str
;
10595 msg_str
= bgp_notify_admin_message(
10596 msgbuf
, sizeof(msgbuf
),
10597 (uint8_t *)p
->notify
.data
,
10600 json_object_string_add(
10602 "lastShutdownDescription",
10607 vty_out(vty
, " Last reset %s, ",
10608 peer_uptime(p
->resettime
, timebuf
,
10609 BGP_UPTIME_LEN
, 0, NULL
));
10611 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10612 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10613 code_str
= bgp_notify_code_str(p
->notify
.code
);
10614 subcode_str
= bgp_notify_subcode_str(
10615 p
->notify
.code
, p
->notify
.subcode
);
10616 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10617 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10620 code_str
, subcode_str
);
10621 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10622 && p
->notify
.code
== BGP_NOTIFY_CEASE
10623 && (p
->notify
.subcode
10624 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10625 || p
->notify
.subcode
10626 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10627 && p
->notify
.length
) {
10629 const char *msg_str
;
10631 msg_str
= bgp_notify_admin_message(
10632 msgbuf
, sizeof(msgbuf
),
10633 (uint8_t *)p
->notify
.data
,
10637 " Message: \"%s\"\n",
10641 vty_out(vty
, "due to %s\n",
10642 peer_down_str
[(int)p
->last_reset
]);
10645 if (p
->last_reset_cause_size
) {
10646 msg
= p
->last_reset_cause
;
10648 " Message received that caused BGP to send a NOTIFICATION:\n ");
10649 for (i
= 1; i
<= p
->last_reset_cause_size
;
10651 vty_out(vty
, "%02X", *msg
++);
10653 if (i
!= p
->last_reset_cause_size
) {
10655 vty_out(vty
, "\n ");
10656 } else if (i
% 4 == 0) {
10661 vty_out(vty
, "\n");
10666 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10668 json_object_boolean_true_add(json_neigh
,
10669 "prefixesConfigExceedMax");
10672 " Peer had exceeded the max. no. of prefixes configured.\n");
10674 if (p
->t_pmax_restart
) {
10676 json_object_boolean_true_add(
10677 json_neigh
, "reducePrefixNumFrom");
10678 json_object_int_add(json_neigh
,
10679 "restartInTimerMsec",
10680 thread_timer_remain_second(
10685 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10686 p
->host
, thread_timer_remain_second(
10687 p
->t_pmax_restart
));
10690 json_object_boolean_true_add(
10692 "reducePrefixNumAndClearIpBgp");
10695 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10700 /* EBGP Multihop and GTSM */
10701 if (p
->sort
!= BGP_PEER_IBGP
) {
10703 if (p
->gtsm_hops
> 0)
10704 json_object_int_add(json_neigh
,
10705 "externalBgpNbrMaxHopsAway",
10707 else if (p
->ttl
> 1)
10708 json_object_int_add(json_neigh
,
10709 "externalBgpNbrMaxHopsAway",
10712 if (p
->gtsm_hops
> 0)
10714 " External BGP neighbor may be up to %d hops away.\n",
10716 else if (p
->ttl
> 1)
10718 " External BGP neighbor may be up to %d hops away.\n",
10722 if (p
->gtsm_hops
> 0) {
10724 json_object_int_add(json_neigh
,
10725 "internalBgpNbrMaxHopsAway",
10729 " Internal BGP neighbor may be up to %d hops away.\n",
10734 /* Local address. */
10737 json_object_string_add(json_neigh
, "hostLocal",
10738 sockunion2str(p
->su_local
, buf1
,
10740 json_object_int_add(json_neigh
, "portLocal",
10741 ntohs(p
->su_local
->sin
.sin_port
));
10743 vty_out(vty
, "Local host: %s, Local port: %d\n",
10744 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10745 ntohs(p
->su_local
->sin
.sin_port
));
10748 /* Remote address. */
10749 if (p
->su_remote
) {
10751 json_object_string_add(json_neigh
, "hostForeign",
10752 sockunion2str(p
->su_remote
, buf1
,
10754 json_object_int_add(json_neigh
, "portForeign",
10755 ntohs(p
->su_remote
->sin
.sin_port
));
10757 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10758 sockunion2str(p
->su_remote
, buf1
,
10760 ntohs(p
->su_remote
->sin
.sin_port
));
10763 /* Nexthop display. */
10766 json_object_string_add(json_neigh
, "nexthop",
10768 &p
->nexthop
.v4
, buf1
,
10770 json_object_string_add(json_neigh
, "nexthopGlobal",
10771 inet_ntop(AF_INET6
,
10772 &p
->nexthop
.v6_global
,
10773 buf1
, sizeof(buf1
)));
10774 json_object_string_add(json_neigh
, "nexthopLocal",
10775 inet_ntop(AF_INET6
,
10776 &p
->nexthop
.v6_local
,
10777 buf1
, sizeof(buf1
)));
10778 if (p
->shared_network
)
10779 json_object_string_add(json_neigh
,
10783 json_object_string_add(json_neigh
,
10785 "nonSharedNetwork");
10787 vty_out(vty
, "Nexthop: %s\n",
10788 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10790 vty_out(vty
, "Nexthop global: %s\n",
10791 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10793 vty_out(vty
, "Nexthop local: %s\n",
10794 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10796 vty_out(vty
, "BGP connection: %s\n",
10797 p
->shared_network
? "shared network"
10798 : "non shared network");
10802 /* Timer information. */
10804 json_object_int_add(json_neigh
, "connectRetryTimer",
10806 if (p
->status
== Established
&& p
->rtt
)
10807 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10810 json_object_int_add(
10811 json_neigh
, "nextStartTimerDueInMsecs",
10812 thread_timer_remain_second(p
->t_start
) * 1000);
10814 json_object_int_add(
10815 json_neigh
, "nextConnectTimerDueInMsecs",
10816 thread_timer_remain_second(p
->t_connect
)
10818 if (p
->t_routeadv
) {
10819 json_object_int_add(json_neigh
, "mraiInterval",
10821 json_object_int_add(
10822 json_neigh
, "mraiTimerExpireInMsecs",
10823 thread_timer_remain_second(p
->t_routeadv
)
10827 json_object_int_add(json_neigh
, "authenticationEnabled",
10831 json_object_string_add(json_neigh
, "readThread", "on");
10833 json_object_string_add(json_neigh
, "readThread", "off");
10835 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10836 json_object_string_add(json_neigh
, "writeThread", "on");
10838 json_object_string_add(json_neigh
, "writeThread",
10841 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10843 if (p
->status
== Established
&& p
->rtt
)
10844 vty_out(vty
, "Estimated round trip time: %d ms\n",
10847 vty_out(vty
, "Next start timer due in %ld seconds\n",
10848 thread_timer_remain_second(p
->t_start
));
10850 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10851 thread_timer_remain_second(p
->t_connect
));
10854 "MRAI (interval %u) timer expires in %ld seconds\n",
10856 thread_timer_remain_second(p
->t_routeadv
));
10858 vty_out(vty
, "Peer Authentication Enabled\n");
10860 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
10861 p
->t_read
? "on" : "off",
10862 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10867 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10868 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10869 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10872 vty_out(vty
, "\n");
10874 /* BFD information. */
10875 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10878 if (p
->conf_if
) /* Configured interface name. */
10879 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10880 else /* Configured IP address. */
10881 json_object_object_add(json
, p
->host
, json_neigh
);
10885 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10886 enum show_type type
, union sockunion
*su
,
10887 const char *conf_if
, bool use_json
,
10890 struct listnode
*node
, *nnode
;
10893 bool nbr_output
= false;
10894 afi_t afi
= AFI_MAX
;
10895 safi_t safi
= SAFI_MAX
;
10897 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
10899 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
10903 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10904 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10909 bgp_show_peer(vty
, peer
, use_json
, json
);
10915 && !strcmp(peer
->conf_if
, conf_if
))
10917 && !strcmp(peer
->hostname
, conf_if
))) {
10919 bgp_show_peer(vty
, peer
, use_json
,
10923 if (sockunion_same(&peer
->su
, su
)) {
10925 bgp_show_peer(vty
, peer
, use_json
,
10930 case show_ipv4_peer
:
10931 case show_ipv6_peer
:
10932 FOREACH_SAFI (safi
) {
10933 if (peer
->afc
[afi
][safi
]) {
10936 && !strcmp(peer
->conf_if
, conf_if
))
10938 && !strcmp(peer
->hostname
, conf_if
))) {
10940 bgp_show_peer(vty
, peer
, use_json
,
10945 if (sockunion_same(&peer
->su
, su
)) {
10947 bgp_show_peer(vty
, peer
, use_json
,
10955 case show_ipv4_all
:
10956 case show_ipv6_all
:
10957 FOREACH_SAFI (safi
) {
10958 if (peer
->afc
[afi
][safi
]) {
10959 bgp_show_peer(vty
, peer
, use_json
, json
);
10968 if ((type
== show_peer
|| type
== show_ipv4_peer
||
10969 type
== show_ipv6_peer
) && !find
) {
10971 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
10973 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
10976 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
10977 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
10978 vty_out(vty
, "%% No BGP neighbors found\n");
10981 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10982 json
, JSON_C_TO_STRING_PRETTY
));
10984 vty_out(vty
, "\n");
10987 return CMD_SUCCESS
;
10990 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
10991 enum show_type type
,
10992 const char *ip_str
,
10995 struct listnode
*node
, *nnode
;
10997 union sockunion su
;
10998 json_object
*json
= NULL
;
10999 int ret
, is_first
= 1;
11000 bool nbr_output
= false;
11003 vty_out(vty
, "{\n");
11005 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11008 if (!(json
= json_object_new_object())) {
11010 EC_BGP_JSON_MEM_ERROR
,
11011 "Unable to allocate memory for JSON object");
11013 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
11017 json_object_int_add(json
, "vrfId",
11018 (bgp
->vrf_id
== VRF_UNKNOWN
)
11020 : (int64_t)bgp
->vrf_id
);
11021 json_object_string_add(
11023 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11028 vty_out(vty
, ",\n");
11032 vty_out(vty
, "\"%s\":",
11033 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11037 vty_out(vty
, "\nInstance %s:\n",
11038 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11043 if (type
== show_peer
|| type
== show_ipv4_peer
||
11044 type
== show_ipv6_peer
) {
11045 ret
= str2sockunion(ip_str
, &su
);
11047 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11050 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11053 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
11056 json_object_free(json
);
11060 vty_out(vty
, "}\n");
11061 json_object_free(json
);
11063 else if (!nbr_output
)
11064 vty_out(vty
, "%% BGP instance not found\n");
11067 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
11068 enum show_type type
, const char *ip_str
,
11073 union sockunion su
;
11074 json_object
*json
= NULL
;
11077 if (strmatch(name
, "all")) {
11078 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
11080 return CMD_SUCCESS
;
11082 bgp
= bgp_lookup_by_name(name
);
11085 json
= json_object_new_object();
11086 vty_out(vty
, "%s\n",
11087 json_object_to_json_string_ext(
11089 JSON_C_TO_STRING_PRETTY
));
11090 json_object_free(json
);
11093 "%% BGP instance not found\n");
11095 return CMD_WARNING
;
11099 bgp
= bgp_get_default();
11103 json
= json_object_new_object();
11105 ret
= str2sockunion(ip_str
, &su
);
11107 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11110 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11113 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
11116 json_object_free(json
);
11119 vty_out(vty
, "{}\n");
11121 vty_out(vty
, "%% BGP instance not found\n");
11124 return CMD_SUCCESS
;
11127 /* "show [ip] bgp neighbors" commands. */
11128 DEFUN (show_ip_bgp_neighbors
,
11129 show_ip_bgp_neighbors_cmd
,
11130 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
11134 BGP_INSTANCE_HELP_STR
11137 "Detailed information on TCP and BGP neighbor connections\n"
11138 "Neighbor to display information about\n"
11139 "Neighbor to display information about\n"
11140 "Neighbor on BGP configured interface\n"
11144 char *sh_arg
= NULL
;
11145 enum show_type sh_type
;
11146 afi_t afi
= AFI_MAX
;
11148 bool uj
= use_json(argc
, argv
);
11152 /* [<vrf> VIEWVRFNAME] */
11153 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11154 vrf
= argv
[idx
+ 1]->arg
;
11155 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11157 } else if (argv_find(argv
, argc
, "view", &idx
))
11158 /* [<view> VIEWVRFNAME] */
11159 vrf
= argv
[idx
+ 1]->arg
;
11163 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
11164 sh_type
= show_ipv4_all
;
11166 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
11167 sh_type
= show_ipv6_all
;
11170 sh_type
= show_all
;
11173 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
11174 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
11175 || argv_find(argv
, argc
, "WORD", &idx
)) {
11176 sh_type
= show_peer
;
11177 sh_arg
= argv
[idx
]->arg
;
11180 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
11181 sh_type
= show_ipv4_peer
;
11182 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
11183 sh_type
= show_ipv6_peer
;
11186 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
11189 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
11190 paths' and `show ip mbgp paths'. Those functions results are the
11192 DEFUN (show_ip_bgp_paths
,
11193 show_ip_bgp_paths_cmd
,
11194 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
11199 "Path information\n")
11201 vty_out(vty
, "Address Refcnt Path\n");
11202 aspath_print_all_vty(vty
);
11203 return CMD_SUCCESS
;
11208 static void community_show_all_iterator(struct hash_bucket
*bucket
,
11211 struct community
*com
;
11213 com
= (struct community
*)bucket
->data
;
11214 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
11215 community_str(com
, false));
11218 /* Show BGP's community internal data. */
11219 DEFUN (show_ip_bgp_community_info
,
11220 show_ip_bgp_community_info_cmd
,
11221 "show [ip] bgp community-info",
11225 "List all bgp community information\n")
11227 vty_out(vty
, "Address Refcnt Community\n");
11229 hash_iterate(community_hash(),
11230 (void (*)(struct hash_bucket
*,
11231 void *))community_show_all_iterator
,
11234 return CMD_SUCCESS
;
11237 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
11240 struct lcommunity
*lcom
;
11242 lcom
= (struct lcommunity
*)bucket
->data
;
11243 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11244 lcommunity_str(lcom
, false));
11247 /* Show BGP's community internal data. */
11248 DEFUN (show_ip_bgp_lcommunity_info
,
11249 show_ip_bgp_lcommunity_info_cmd
,
11250 "show ip bgp large-community-info",
11254 "List all bgp large-community information\n")
11256 vty_out(vty
, "Address Refcnt Large-community\n");
11258 hash_iterate(lcommunity_hash(),
11259 (void (*)(struct hash_bucket
*,
11260 void *))lcommunity_show_all_iterator
,
11263 return CMD_SUCCESS
;
11267 DEFUN (show_ip_bgp_attr_info
,
11268 show_ip_bgp_attr_info_cmd
,
11269 "show [ip] bgp attribute-info",
11273 "List all bgp attribute information\n")
11275 attr_show_all(vty
);
11276 return CMD_SUCCESS
;
11279 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
11280 afi_t afi
, safi_t safi
,
11281 bool use_json
, json_object
*json
)
11284 struct listnode
*node
;
11286 char buf1
[INET6_ADDRSTRLEN
];
11288 vpn_policy_direction_t dir
;
11291 json_object
*json_import_vrfs
= NULL
;
11292 json_object
*json_export_vrfs
= NULL
;
11294 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11297 vty_out(vty
, "%s\n",
11298 json_object_to_json_string_ext(
11300 JSON_C_TO_STRING_PRETTY
));
11301 json_object_free(json
);
11303 return CMD_WARNING
;
11306 /* Provide context for the block */
11307 json_object_string_add(json
, "vrf", name
? name
: "default");
11308 json_object_string_add(json
, "afiSafi",
11309 afi_safi_print(afi
, safi
));
11311 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11312 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11313 json_object_string_add(json
, "importFromVrfs", "none");
11314 json_object_string_add(json
, "importRts", "none");
11316 json_import_vrfs
= json_object_new_array();
11318 for (ALL_LIST_ELEMENTS_RO(
11319 bgp
->vpn_policy
[afi
].import_vrf
,
11321 json_object_array_add(json_import_vrfs
,
11322 json_object_new_string(vname
));
11324 json_object_object_add(json
, "importFromVrfs",
11326 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11327 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11328 ecom_str
= ecommunity_ecom2str(
11329 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11330 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11331 json_object_string_add(json
, "importRts",
11333 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11335 json_object_string_add(json
, "importRts",
11339 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11340 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11341 json_object_string_add(json
, "exportToVrfs", "none");
11342 json_object_string_add(json
, "routeDistinguisher",
11344 json_object_string_add(json
, "exportRts", "none");
11346 json_export_vrfs
= json_object_new_array();
11348 for (ALL_LIST_ELEMENTS_RO(
11349 bgp
->vpn_policy
[afi
].export_vrf
,
11351 json_object_array_add(json_export_vrfs
,
11352 json_object_new_string(vname
));
11353 json_object_object_add(json
, "exportToVrfs",
11355 json_object_string_add(json
, "routeDistinguisher",
11356 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11357 buf1
, RD_ADDRSTRLEN
));
11359 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11360 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11361 ecom_str
= ecommunity_ecom2str(
11362 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11363 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11364 json_object_string_add(json
, "exportRts",
11366 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11368 json_object_string_add(json
, "exportRts",
11373 vty_out(vty
, "%s\n",
11374 json_object_to_json_string_ext(json
,
11375 JSON_C_TO_STRING_PRETTY
));
11376 json_object_free(json
);
11379 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11382 vty_out(vty
, "%% No such BGP instance exist\n");
11383 return CMD_WARNING
;
11386 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11387 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11389 "This VRF is not importing %s routes from any other VRF\n",
11390 afi_safi_print(afi
, safi
));
11393 "This VRF is importing %s routes from the following VRFs:\n",
11394 afi_safi_print(afi
, safi
));
11396 for (ALL_LIST_ELEMENTS_RO(
11397 bgp
->vpn_policy
[afi
].import_vrf
,
11399 vty_out(vty
, " %s\n", vname
);
11401 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11403 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11404 ecom_str
= ecommunity_ecom2str(
11405 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11406 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11407 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11409 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11411 vty_out(vty
, "Import RT(s):\n");
11414 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11415 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11417 "This VRF is not exporting %s routes to any other VRF\n",
11418 afi_safi_print(afi
, safi
));
11421 "This VRF is exporting %s routes to the following VRFs:\n",
11422 afi_safi_print(afi
, safi
));
11424 for (ALL_LIST_ELEMENTS_RO(
11425 bgp
->vpn_policy
[afi
].export_vrf
,
11427 vty_out(vty
, " %s\n", vname
);
11429 vty_out(vty
, "RD: %s\n",
11430 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11431 buf1
, RD_ADDRSTRLEN
));
11433 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11434 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11435 ecom_str
= ecommunity_ecom2str(
11436 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11437 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11438 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11439 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11441 vty_out(vty
, "Import RT(s):\n");
11445 return CMD_SUCCESS
;
11448 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
11449 safi_t safi
, bool use_json
)
11451 struct listnode
*node
, *nnode
;
11453 char *vrf_name
= NULL
;
11454 json_object
*json
= NULL
;
11455 json_object
*json_vrf
= NULL
;
11456 json_object
*json_vrfs
= NULL
;
11459 json
= json_object_new_object();
11460 json_vrfs
= json_object_new_object();
11463 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11465 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
11466 vrf_name
= bgp
->name
;
11469 json_vrf
= json_object_new_object();
11471 vty_out(vty
, "\nInstance %s:\n",
11472 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11473 ? VRF_DEFAULT_NAME
: bgp
->name
);
11475 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
11477 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11478 json_object_object_add(json_vrfs
,
11479 VRF_DEFAULT_NAME
, json_vrf
);
11481 json_object_object_add(json_vrfs
, vrf_name
,
11487 json_object_object_add(json
, "vrfs", json_vrfs
);
11488 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
11489 JSON_C_TO_STRING_PRETTY
));
11490 json_object_free(json
);
11493 return CMD_SUCCESS
;
11496 /* "show [ip] bgp route-leak" command. */
11497 DEFUN (show_ip_bgp_route_leak
,
11498 show_ip_bgp_route_leak_cmd
,
11499 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11503 BGP_INSTANCE_HELP_STR
11506 "Route leaking information\n"
11510 afi_t afi
= AFI_MAX
;
11511 safi_t safi
= SAFI_MAX
;
11513 bool uj
= use_json(argc
, argv
);
11515 json_object
*json
= NULL
;
11517 /* show [ip] bgp */
11518 if (argv_find(argv
, argc
, "ip", &idx
)) {
11520 safi
= SAFI_UNICAST
;
11522 /* [vrf VIEWVRFNAME] */
11523 if (argv_find(argv
, argc
, "view", &idx
)) {
11525 "%% This command is not applicable to BGP views\n");
11526 return CMD_WARNING
;
11529 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11530 vrf
= argv
[idx
+ 1]->arg
;
11531 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11534 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11535 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11536 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11539 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11541 "%% This command is applicable only for unicast ipv4|ipv6\n");
11542 return CMD_WARNING
;
11545 if (vrf
&& strmatch(vrf
, "all"))
11546 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
11549 json
= json_object_new_object();
11551 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
11554 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11557 struct listnode
*node
, *nnode
;
11560 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11561 vty_out(vty
, "\nInstance %s:\n",
11562 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11565 update_group_show(bgp
, afi
, safi
, vty
, 0);
11569 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11570 int safi
, uint64_t subgrp_id
)
11575 if (strmatch(name
, "all")) {
11576 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11577 return CMD_SUCCESS
;
11579 bgp
= bgp_lookup_by_name(name
);
11582 bgp
= bgp_get_default();
11586 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11587 return CMD_SUCCESS
;
11590 DEFUN (show_ip_bgp_updgrps
,
11591 show_ip_bgp_updgrps_cmd
,
11592 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11596 BGP_INSTANCE_HELP_STR
11598 BGP_SAFI_WITH_LABEL_HELP_STR
11599 "Detailed info about dynamic update groups\n"
11600 "Specific subgroup to display detailed info for\n")
11603 afi_t afi
= AFI_IP6
;
11604 safi_t safi
= SAFI_UNICAST
;
11605 uint64_t subgrp_id
= 0;
11609 /* show [ip] bgp */
11610 if (argv_find(argv
, argc
, "ip", &idx
))
11612 /* [<vrf> VIEWVRFNAME] */
11613 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11614 vrf
= argv
[idx
+ 1]->arg
;
11615 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11617 } else if (argv_find(argv
, argc
, "view", &idx
))
11618 /* [<view> VIEWVRFNAME] */
11619 vrf
= argv
[idx
+ 1]->arg
;
11620 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11621 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11622 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11625 /* get subgroup id, if provided */
11627 if (argv
[idx
]->type
== VARIABLE_TKN
)
11628 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11630 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11633 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11634 show_bgp_instance_all_ipv6_updgrps_cmd
,
11635 "show [ip] bgp <view|vrf> all update-groups",
11639 BGP_INSTANCE_ALL_HELP_STR
11640 "Detailed info about dynamic update groups\n")
11642 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11643 return CMD_SUCCESS
;
11646 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
11647 show_bgp_l2vpn_evpn_updgrps_cmd
,
11648 "show [ip] bgp l2vpn evpn update-groups",
11652 "l2vpn address family\n"
11653 "evpn sub-address family\n"
11654 "Detailed info about dynamic update groups\n")
11657 uint64_t subgrp_id
= 0;
11659 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
11660 return CMD_SUCCESS
;
11663 DEFUN (show_bgp_updgrps_stats
,
11664 show_bgp_updgrps_stats_cmd
,
11665 "show [ip] bgp update-groups statistics",
11669 "Detailed info about dynamic update groups\n"
11674 bgp
= bgp_get_default();
11676 update_group_show_stats(bgp
, vty
);
11678 return CMD_SUCCESS
;
11681 DEFUN (show_bgp_instance_updgrps_stats
,
11682 show_bgp_instance_updgrps_stats_cmd
,
11683 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11687 BGP_INSTANCE_HELP_STR
11688 "Detailed info about dynamic update groups\n"
11694 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11696 update_group_show_stats(bgp
, vty
);
11698 return CMD_SUCCESS
;
11701 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11702 afi_t afi
, safi_t safi
,
11703 const char *what
, uint64_t subgrp_id
)
11708 bgp
= bgp_lookup_by_name(name
);
11710 bgp
= bgp_get_default();
11713 if (!strcmp(what
, "advertise-queue"))
11714 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11716 else if (!strcmp(what
, "advertised-routes"))
11717 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11719 else if (!strcmp(what
, "packet-queue"))
11720 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11725 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11726 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11727 "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",
11728 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11730 "Detailed info about dynamic update groups\n"
11731 "Specific subgroup to display info for\n"
11732 "Advertisement queue\n"
11733 "Announced routes\n"
11736 uint64_t subgrp_id
= 0;
11740 subgrp_id
= strtoull(sgid
, NULL
, 10);
11745 afiz
= bgp_vty_afi_from_str(afi
);
11749 afiz
= bgp_vty_afi_from_str(afi
);
11750 if (afiz
!= AFI_IP
)
11752 "%% Cannot specify both 'ip' and 'ipv6'\n");
11753 return CMD_WARNING
;
11756 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11758 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11759 return CMD_SUCCESS
;
11762 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11764 struct listnode
*node
, *nnode
;
11765 struct prefix
*range
;
11768 char buf
[PREFIX2STR_BUFFER
];
11771 const char *peer_status
;
11772 const char *af_str
;
11777 conf
= group
->conf
;
11779 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11780 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11781 group
->name
, conf
->as
);
11782 } else if (conf
->as_type
== AS_INTERNAL
) {
11783 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11784 group
->name
, group
->bgp
->as
);
11786 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11789 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11790 vty_out(vty
, " Peer-group type is internal\n");
11792 vty_out(vty
, " Peer-group type is external\n");
11794 /* Display AFs configured. */
11795 vty_out(vty
, " Configured address-families:");
11796 FOREACH_AFI_SAFI (afi
, safi
) {
11797 if (conf
->afc
[afi
][safi
]) {
11799 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11803 vty_out(vty
, " none\n");
11805 vty_out(vty
, "\n");
11807 /* Display listen ranges (for dynamic neighbors), if any */
11808 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11811 else if (afi
== AFI_IP6
)
11815 lr_count
= listcount(group
->listen_range
[afi
]);
11817 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11821 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11823 prefix2str(range
, buf
, sizeof(buf
));
11824 vty_out(vty
, " %s\n", buf
);
11829 /* Display group members and their status */
11830 if (listcount(group
->peer
)) {
11831 vty_out(vty
, " Peer-group members:\n");
11832 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11833 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11834 peer_status
= "Idle (Admin)";
11835 else if (CHECK_FLAG(peer
->sflags
,
11836 PEER_STATUS_PREFIX_OVERFLOW
))
11837 peer_status
= "Idle (PfxCt)";
11839 peer_status
= lookup_msg(bgp_status_msg
,
11840 peer
->status
, NULL
);
11842 dynamic
= peer_dynamic_neighbor(peer
);
11843 vty_out(vty
, " %s %s %s \n", peer
->host
,
11844 dynamic
? "(dynamic)" : "", peer_status
);
11848 return CMD_SUCCESS
;
11851 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11852 const char *group_name
)
11855 struct listnode
*node
, *nnode
;
11856 struct peer_group
*group
;
11857 bool found
= false;
11859 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11862 vty_out(vty
, "%% BGP instance not found\n");
11863 return CMD_WARNING
;
11866 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11868 if (strmatch(group
->name
, group_name
)) {
11869 bgp_show_one_peer_group(vty
, group
);
11874 bgp_show_one_peer_group(vty
, group
);
11878 if (group_name
&& !found
)
11879 vty_out(vty
, "%% No such peer-group\n");
11881 return CMD_SUCCESS
;
11884 DEFUN (show_ip_bgp_peer_groups
,
11885 show_ip_bgp_peer_groups_cmd
,
11886 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11890 BGP_INSTANCE_HELP_STR
11891 "Detailed information on BGP peer groups\n"
11892 "Peer group name\n")
11897 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11899 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11901 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11905 /* Redistribute VTY commands. */
11907 DEFUN (bgp_redistribute_ipv4
,
11908 bgp_redistribute_ipv4_cmd
,
11909 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11910 "Redistribute information from another routing protocol\n"
11911 FRR_IP_REDIST_HELP_STR_BGPD
)
11913 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11914 int idx_protocol
= 1;
11917 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11919 vty_out(vty
, "%% Invalid route type\n");
11920 return CMD_WARNING_CONFIG_FAILED
;
11923 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11924 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
11928 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11929 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11930 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11932 DEFUN (bgp_redistribute_ipv4_rmap
,
11933 bgp_redistribute_ipv4_rmap_cmd
,
11934 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11935 "Redistribute information from another routing protocol\n"
11936 FRR_IP_REDIST_HELP_STR_BGPD
11937 "Route map reference\n"
11938 "Pointer to route-map entries\n")
11940 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11941 int idx_protocol
= 1;
11944 struct bgp_redist
*red
;
11946 struct route_map
*route_map
= route_map_lookup_warn_noexist(
11947 vty
, argv
[idx_word
]->arg
);
11949 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11951 vty_out(vty
, "%% Invalid route type\n");
11952 return CMD_WARNING_CONFIG_FAILED
;
11955 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11957 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
11958 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11962 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
11963 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11964 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11965 "Route map reference\n"
11966 "Pointer to route-map entries\n")
11968 DEFUN (bgp_redistribute_ipv4_metric
,
11969 bgp_redistribute_ipv4_metric_cmd
,
11970 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11971 "Redistribute information from another routing protocol\n"
11972 FRR_IP_REDIST_HELP_STR_BGPD
11973 "Metric for redistributed routes\n"
11974 "Default metric\n")
11976 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11977 int idx_protocol
= 1;
11978 int idx_number
= 3;
11981 struct bgp_redist
*red
;
11984 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11986 vty_out(vty
, "%% Invalid route type\n");
11987 return CMD_WARNING_CONFIG_FAILED
;
11989 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11991 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11992 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11993 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11997 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
11998 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11999 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12000 "Metric for redistributed routes\n"
12001 "Default metric\n")
12003 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
12004 bgp_redistribute_ipv4_rmap_metric_cmd
,
12005 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12006 "Redistribute information from another routing protocol\n"
12007 FRR_IP_REDIST_HELP_STR_BGPD
12008 "Route map reference\n"
12009 "Pointer to route-map entries\n"
12010 "Metric for redistributed routes\n"
12011 "Default metric\n")
12013 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12014 int idx_protocol
= 1;
12016 int idx_number
= 5;
12019 struct bgp_redist
*red
;
12021 struct route_map
*route_map
=
12022 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12024 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12026 vty_out(vty
, "%% Invalid route type\n");
12027 return CMD_WARNING_CONFIG_FAILED
;
12029 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12031 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12033 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12034 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12035 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12039 bgp_redistribute_ipv4_rmap_metric
,
12040 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
12041 "redistribute " FRR_IP_REDIST_STR_BGPD
12042 " route-map WORD metric (0-4294967295)",
12043 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12044 "Route map reference\n"
12045 "Pointer to route-map entries\n"
12046 "Metric for redistributed routes\n"
12047 "Default metric\n")
12049 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
12050 bgp_redistribute_ipv4_metric_rmap_cmd
,
12051 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12052 "Redistribute information from another routing protocol\n"
12053 FRR_IP_REDIST_HELP_STR_BGPD
12054 "Metric for redistributed routes\n"
12056 "Route map reference\n"
12057 "Pointer to route-map entries\n")
12059 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12060 int idx_protocol
= 1;
12061 int idx_number
= 3;
12065 struct bgp_redist
*red
;
12067 struct route_map
*route_map
=
12068 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12070 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12072 vty_out(vty
, "%% Invalid route type\n");
12073 return CMD_WARNING_CONFIG_FAILED
;
12075 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12077 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12078 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12080 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12081 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12085 bgp_redistribute_ipv4_metric_rmap
,
12086 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
12087 "redistribute " FRR_IP_REDIST_STR_BGPD
12088 " metric (0-4294967295) route-map WORD",
12089 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12090 "Metric for redistributed routes\n"
12092 "Route map reference\n"
12093 "Pointer to route-map entries\n")
12095 DEFUN (bgp_redistribute_ipv4_ospf
,
12096 bgp_redistribute_ipv4_ospf_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 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12104 int idx_ospf_table
= 1;
12105 int idx_number
= 2;
12106 unsigned short instance
;
12107 unsigned short protocol
;
12109 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12111 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12112 protocol
= ZEBRA_ROUTE_OSPF
;
12114 protocol
= ZEBRA_ROUTE_TABLE
;
12116 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12117 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
12120 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
12121 "redistribute <ospf|table> (1-65535)",
12122 "Redistribute information from another routing protocol\n"
12123 "Open Shortest Path First (OSPFv2)\n"
12124 "Non-main Kernel Routing Table\n"
12125 "Instance ID/Table ID\n")
12127 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
12128 bgp_redistribute_ipv4_ospf_rmap_cmd
,
12129 "redistribute <ospf|table> (1-65535) route-map WORD",
12130 "Redistribute information from another routing protocol\n"
12131 "Open Shortest Path First (OSPFv2)\n"
12132 "Non-main Kernel Routing Table\n"
12133 "Instance ID/Table ID\n"
12134 "Route map reference\n"
12135 "Pointer to route-map entries\n")
12137 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12138 int idx_ospf_table
= 1;
12139 int idx_number
= 2;
12141 struct bgp_redist
*red
;
12142 unsigned short instance
;
12145 struct route_map
*route_map
=
12146 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12148 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12149 protocol
= ZEBRA_ROUTE_OSPF
;
12151 protocol
= ZEBRA_ROUTE_TABLE
;
12153 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12154 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12156 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12157 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12160 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
12161 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
12162 "redistribute <ospf|table> (1-65535) route-map WORD",
12163 "Redistribute information from another routing protocol\n"
12164 "Open Shortest Path First (OSPFv2)\n"
12165 "Non-main Kernel Routing Table\n"
12166 "Instance ID/Table ID\n"
12167 "Route map reference\n"
12168 "Pointer to route-map entries\n")
12170 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
12171 bgp_redistribute_ipv4_ospf_metric_cmd
,
12172 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12173 "Redistribute information from another routing protocol\n"
12174 "Open Shortest Path First (OSPFv2)\n"
12175 "Non-main Kernel Routing Table\n"
12176 "Instance ID/Table ID\n"
12177 "Metric for redistributed routes\n"
12178 "Default metric\n")
12180 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12181 int idx_ospf_table
= 1;
12182 int idx_number
= 2;
12183 int idx_number_2
= 4;
12185 struct bgp_redist
*red
;
12186 unsigned short instance
;
12190 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12191 protocol
= ZEBRA_ROUTE_OSPF
;
12193 protocol
= ZEBRA_ROUTE_TABLE
;
12195 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12196 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12198 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12199 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12201 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12204 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
12205 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
12206 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12207 "Redistribute information from another routing protocol\n"
12208 "Open Shortest Path First (OSPFv2)\n"
12209 "Non-main Kernel Routing Table\n"
12210 "Instance ID/Table ID\n"
12211 "Metric for redistributed routes\n"
12212 "Default metric\n")
12214 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
12215 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
12216 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12217 "Redistribute information from another routing protocol\n"
12218 "Open Shortest Path First (OSPFv2)\n"
12219 "Non-main Kernel Routing Table\n"
12220 "Instance ID/Table ID\n"
12221 "Route map reference\n"
12222 "Pointer to route-map entries\n"
12223 "Metric for redistributed routes\n"
12224 "Default metric\n")
12226 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12227 int idx_ospf_table
= 1;
12228 int idx_number
= 2;
12230 int idx_number_2
= 6;
12232 struct bgp_redist
*red
;
12233 unsigned short instance
;
12236 struct route_map
*route_map
=
12237 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12239 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12240 protocol
= ZEBRA_ROUTE_OSPF
;
12242 protocol
= ZEBRA_ROUTE_TABLE
;
12244 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12245 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12247 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12249 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12250 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12252 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12256 bgp_redistribute_ipv4_ospf_rmap_metric
,
12257 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
12258 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12259 "Redistribute information from another routing protocol\n"
12260 "Open Shortest Path First (OSPFv2)\n"
12261 "Non-main Kernel Routing Table\n"
12262 "Instance ID/Table ID\n"
12263 "Route map reference\n"
12264 "Pointer to route-map entries\n"
12265 "Metric for redistributed routes\n"
12266 "Default metric\n")
12268 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
12269 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
12270 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12271 "Redistribute information from another routing protocol\n"
12272 "Open Shortest Path First (OSPFv2)\n"
12273 "Non-main Kernel Routing Table\n"
12274 "Instance ID/Table ID\n"
12275 "Metric for redistributed routes\n"
12277 "Route map reference\n"
12278 "Pointer to route-map entries\n")
12280 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12281 int idx_ospf_table
= 1;
12282 int idx_number
= 2;
12283 int idx_number_2
= 4;
12286 struct bgp_redist
*red
;
12287 unsigned short instance
;
12290 struct route_map
*route_map
=
12291 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12293 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12294 protocol
= ZEBRA_ROUTE_OSPF
;
12296 protocol
= ZEBRA_ROUTE_TABLE
;
12298 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12299 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12301 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12302 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12305 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12306 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12310 bgp_redistribute_ipv4_ospf_metric_rmap
,
12311 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
12312 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12313 "Redistribute information from another routing protocol\n"
12314 "Open Shortest Path First (OSPFv2)\n"
12315 "Non-main Kernel Routing Table\n"
12316 "Instance ID/Table ID\n"
12317 "Metric for redistributed routes\n"
12319 "Route map reference\n"
12320 "Pointer to route-map entries\n")
12322 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12323 no_bgp_redistribute_ipv4_ospf_cmd
,
12324 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
12326 "Redistribute information from another routing protocol\n"
12327 "Open Shortest Path First (OSPFv2)\n"
12328 "Non-main Kernel Routing Table\n"
12329 "Instance ID/Table ID\n"
12330 "Metric for redistributed routes\n"
12332 "Route map reference\n"
12333 "Pointer to route-map entries\n")
12335 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12336 int idx_ospf_table
= 2;
12337 int idx_number
= 3;
12338 unsigned short instance
;
12341 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12342 protocol
= ZEBRA_ROUTE_OSPF
;
12344 protocol
= ZEBRA_ROUTE_TABLE
;
12346 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12347 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12351 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12352 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
12354 "Redistribute information from another routing protocol\n"
12355 "Open Shortest Path First (OSPFv2)\n"
12356 "Non-main Kernel Routing Table\n"
12357 "Instance ID/Table ID\n"
12358 "Metric for redistributed routes\n"
12360 "Route map reference\n"
12361 "Pointer to route-map entries\n")
12363 DEFUN (no_bgp_redistribute_ipv4
,
12364 no_bgp_redistribute_ipv4_cmd
,
12365 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
12367 "Redistribute information from another routing protocol\n"
12368 FRR_IP_REDIST_HELP_STR_BGPD
12369 "Metric for redistributed routes\n"
12371 "Route map reference\n"
12372 "Pointer to route-map entries\n")
12374 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12375 int idx_protocol
= 2;
12378 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12380 vty_out(vty
, "%% Invalid route type\n");
12381 return CMD_WARNING_CONFIG_FAILED
;
12383 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12387 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12388 "no redistribute " FRR_IP_REDIST_STR_BGPD
12389 " [{metric (0-4294967295)|route-map WORD}]",
12391 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12392 "Metric for redistributed routes\n"
12394 "Route map reference\n"
12395 "Pointer to route-map entries\n")
12397 DEFUN (bgp_redistribute_ipv6
,
12398 bgp_redistribute_ipv6_cmd
,
12399 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12400 "Redistribute information from another routing protocol\n"
12401 FRR_IP6_REDIST_HELP_STR_BGPD
)
12403 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12404 int idx_protocol
= 1;
12407 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12409 vty_out(vty
, "%% Invalid route type\n");
12410 return CMD_WARNING_CONFIG_FAILED
;
12413 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12414 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12417 DEFUN (bgp_redistribute_ipv6_rmap
,
12418 bgp_redistribute_ipv6_rmap_cmd
,
12419 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12420 "Redistribute information from another routing protocol\n"
12421 FRR_IP6_REDIST_HELP_STR_BGPD
12422 "Route map reference\n"
12423 "Pointer to route-map entries\n")
12425 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12426 int idx_protocol
= 1;
12429 struct bgp_redist
*red
;
12431 struct route_map
*route_map
=
12432 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12434 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12436 vty_out(vty
, "%% Invalid route type\n");
12437 return CMD_WARNING_CONFIG_FAILED
;
12440 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12442 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12443 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12446 DEFUN (bgp_redistribute_ipv6_metric
,
12447 bgp_redistribute_ipv6_metric_cmd
,
12448 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12449 "Redistribute information from another routing protocol\n"
12450 FRR_IP6_REDIST_HELP_STR_BGPD
12451 "Metric for redistributed routes\n"
12452 "Default metric\n")
12454 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12455 int idx_protocol
= 1;
12456 int idx_number
= 3;
12459 struct bgp_redist
*red
;
12462 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12464 vty_out(vty
, "%% Invalid route type\n");
12465 return CMD_WARNING_CONFIG_FAILED
;
12467 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12469 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12470 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12471 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12474 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12475 bgp_redistribute_ipv6_rmap_metric_cmd
,
12476 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12477 "Redistribute information from another routing protocol\n"
12478 FRR_IP6_REDIST_HELP_STR_BGPD
12479 "Route map reference\n"
12480 "Pointer to route-map entries\n"
12481 "Metric for redistributed routes\n"
12482 "Default metric\n")
12484 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12485 int idx_protocol
= 1;
12487 int idx_number
= 5;
12490 struct bgp_redist
*red
;
12492 struct route_map
*route_map
=
12493 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12495 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12497 vty_out(vty
, "%% Invalid route type\n");
12498 return CMD_WARNING_CONFIG_FAILED
;
12500 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12502 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12504 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12505 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12507 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12510 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12511 bgp_redistribute_ipv6_metric_rmap_cmd
,
12512 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12513 "Redistribute information from another routing protocol\n"
12514 FRR_IP6_REDIST_HELP_STR_BGPD
12515 "Metric for redistributed routes\n"
12517 "Route map reference\n"
12518 "Pointer to route-map entries\n")
12520 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12521 int idx_protocol
= 1;
12522 int idx_number
= 3;
12526 struct bgp_redist
*red
;
12528 struct route_map
*route_map
=
12529 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12531 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12533 vty_out(vty
, "%% Invalid route type\n");
12534 return CMD_WARNING_CONFIG_FAILED
;
12536 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12538 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12539 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12542 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12543 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12546 DEFUN (no_bgp_redistribute_ipv6
,
12547 no_bgp_redistribute_ipv6_cmd
,
12548 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
12550 "Redistribute information from another routing protocol\n"
12551 FRR_IP6_REDIST_HELP_STR_BGPD
12552 "Metric for redistributed routes\n"
12554 "Route map reference\n"
12555 "Pointer to route-map entries\n")
12557 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12558 int idx_protocol
= 2;
12561 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12563 vty_out(vty
, "%% Invalid route type\n");
12564 return CMD_WARNING_CONFIG_FAILED
;
12567 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12570 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12575 /* Unicast redistribution only. */
12576 if (safi
!= SAFI_UNICAST
)
12579 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12580 /* Redistribute BGP does not make sense. */
12581 if (i
!= ZEBRA_ROUTE_BGP
) {
12582 struct list
*red_list
;
12583 struct listnode
*node
;
12584 struct bgp_redist
*red
;
12586 red_list
= bgp
->redist
[afi
][i
];
12590 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12591 /* "redistribute" configuration. */
12592 vty_out(vty
, " redistribute %s",
12593 zebra_route_string(i
));
12595 vty_out(vty
, " %d", red
->instance
);
12596 if (red
->redist_metric_flag
)
12597 vty_out(vty
, " metric %u",
12598 red
->redist_metric
);
12599 if (red
->rmap
.name
)
12600 vty_out(vty
, " route-map %s",
12602 vty_out(vty
, "\n");
12608 /* This is part of the address-family block (unicast only) */
12609 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12614 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12615 if (listcount(bgp
->vpn_policy
[afi
].import_vrf
))
12616 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12617 bgp
->vpn_policy
[afi
]
12618 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12620 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
12621 bgp
->vpn_policy
[afi
]
12622 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12624 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12625 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12626 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12627 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12630 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12631 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12633 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12636 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12637 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12638 bgp
->vpn_policy
[afi
].tovpn_label
);
12641 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12642 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12643 char buf
[RD_ADDRSTRLEN
];
12644 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12645 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12648 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12649 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12651 char buf
[PREFIX_STRLEN
];
12652 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12653 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12656 vty_out(vty
, "%*snexthop vpn export %s\n",
12660 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12661 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12663 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12664 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12666 char *b
= ecommunity_ecom2str(
12667 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12668 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12669 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12670 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12672 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12673 char *b
= ecommunity_ecom2str(
12674 bgp
->vpn_policy
[afi
]
12675 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12676 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12677 ECOMMUNITY_ROUTE_TARGET
);
12678 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12679 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12681 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12682 char *b
= ecommunity_ecom2str(
12683 bgp
->vpn_policy
[afi
]
12684 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12685 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12686 ECOMMUNITY_ROUTE_TARGET
);
12687 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12688 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12692 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12693 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12694 bgp
->vpn_policy
[afi
]
12695 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12697 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12698 char *b
= ecommunity_ecom2str(
12699 bgp
->vpn_policy
[afi
]
12700 .import_redirect_rtlist
,
12701 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12702 ECOMMUNITY_ROUTE_TARGET
);
12704 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12705 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12710 /* BGP node structure. */
12711 static struct cmd_node bgp_node
= {
12712 BGP_NODE
, "%s(config-router)# ", 1,
12715 static struct cmd_node bgp_ipv4_unicast_node
= {
12716 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12719 static struct cmd_node bgp_ipv4_multicast_node
= {
12720 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12723 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12724 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12727 static struct cmd_node bgp_ipv6_unicast_node
= {
12728 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12731 static struct cmd_node bgp_ipv6_multicast_node
= {
12732 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12735 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12736 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12739 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12740 "%s(config-router-af)# ", 1};
12742 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12743 "%s(config-router-af-vpnv6)# ", 1};
12745 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12746 "%s(config-router-evpn)# ", 1};
12748 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12749 "%s(config-router-af-vni)# ", 1};
12751 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12752 "%s(config-router-af)# ", 1};
12754 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12755 "%s(config-router-af-vpnv6)# ", 1};
12757 static void community_list_vty(void);
12759 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12763 struct listnode
*lnbgp
, *lnpeer
;
12765 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12766 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12767 /* only provide suggestions on the appropriate input
12769 * they'll otherwise show up multiple times */
12770 enum cmd_token_type match_type
;
12771 char *name
= peer
->host
;
12773 if (peer
->conf_if
) {
12774 match_type
= VARIABLE_TKN
;
12775 name
= peer
->conf_if
;
12776 } else if (strchr(peer
->host
, ':'))
12777 match_type
= IPV6_TKN
;
12779 match_type
= IPV4_TKN
;
12781 if (token
->type
!= match_type
)
12784 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12789 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12790 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12791 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12792 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12793 {.completions
= NULL
}};
12795 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12798 struct peer_group
*group
;
12799 struct listnode
*lnbgp
, *lnpeer
;
12801 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12802 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12803 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12808 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12809 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12810 {.completions
= NULL
} };
12812 void bgp_vty_init(void)
12814 cmd_variable_handler_register(bgp_var_neighbor
);
12815 cmd_variable_handler_register(bgp_var_peergroup
);
12817 /* Install bgp top node. */
12818 install_node(&bgp_node
, bgp_config_write
);
12819 install_node(&bgp_ipv4_unicast_node
, NULL
);
12820 install_node(&bgp_ipv4_multicast_node
, NULL
);
12821 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12822 install_node(&bgp_ipv6_unicast_node
, NULL
);
12823 install_node(&bgp_ipv6_multicast_node
, NULL
);
12824 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12825 install_node(&bgp_vpnv4_node
, NULL
);
12826 install_node(&bgp_vpnv6_node
, NULL
);
12827 install_node(&bgp_evpn_node
, NULL
);
12828 install_node(&bgp_evpn_vni_node
, NULL
);
12829 install_node(&bgp_flowspecv4_node
, NULL
);
12830 install_node(&bgp_flowspecv6_node
, NULL
);
12832 /* Install default VTY commands to new nodes. */
12833 install_default(BGP_NODE
);
12834 install_default(BGP_IPV4_NODE
);
12835 install_default(BGP_IPV4M_NODE
);
12836 install_default(BGP_IPV4L_NODE
);
12837 install_default(BGP_IPV6_NODE
);
12838 install_default(BGP_IPV6M_NODE
);
12839 install_default(BGP_IPV6L_NODE
);
12840 install_default(BGP_VPNV4_NODE
);
12841 install_default(BGP_VPNV6_NODE
);
12842 install_default(BGP_FLOWSPECV4_NODE
);
12843 install_default(BGP_FLOWSPECV6_NODE
);
12844 install_default(BGP_EVPN_NODE
);
12845 install_default(BGP_EVPN_VNI_NODE
);
12847 /* "bgp local-mac" hidden commands. */
12848 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
12849 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
12851 /* bgp route-map delay-timer commands. */
12852 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12853 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12855 /* Dummy commands (Currently not supported) */
12856 install_element(BGP_NODE
, &no_synchronization_cmd
);
12857 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12859 /* "router bgp" commands. */
12860 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12862 /* "no router bgp" commands. */
12863 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12865 /* "bgp router-id" commands. */
12866 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12867 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12869 /* "bgp cluster-id" commands. */
12870 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12871 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12873 /* "bgp confederation" commands. */
12874 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12875 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12877 /* "bgp confederation peers" commands. */
12878 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12879 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12881 /* bgp max-med command */
12882 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12883 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12884 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12885 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12886 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12888 /* bgp disable-ebgp-connected-nh-check */
12889 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12890 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12892 /* bgp update-delay command */
12893 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12894 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12895 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12897 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12898 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12899 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12900 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12902 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12903 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12905 /* "maximum-paths" commands. */
12906 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12907 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12908 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12909 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12910 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12911 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12912 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12913 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12914 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12915 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12916 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12917 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12918 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12919 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12920 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12922 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12923 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12924 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12925 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12926 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12928 /* "timers bgp" commands. */
12929 install_element(BGP_NODE
, &bgp_timers_cmd
);
12930 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12932 /* route-map delay-timer commands - per instance for backwards compat.
12934 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12935 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12937 /* "bgp client-to-client reflection" commands */
12938 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
12939 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
12941 /* "bgp always-compare-med" commands */
12942 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
12943 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
12945 /* bgp ebgp-requires-policy */
12946 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
12947 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
12949 /* "bgp deterministic-med" commands */
12950 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
12951 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
12953 /* "bgp graceful-restart" commands */
12954 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
12955 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
12956 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
12957 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
12958 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
12959 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
12961 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
12962 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
12964 /* "bgp graceful-shutdown" commands */
12965 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
12966 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
12968 /* "bgp fast-external-failover" commands */
12969 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
12970 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
12972 /* "bgp bestpath compare-routerid" commands */
12973 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
12974 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
12976 /* "bgp bestpath as-path ignore" commands */
12977 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
12978 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
12980 /* "bgp bestpath as-path confed" commands */
12981 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
12982 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
12984 /* "bgp bestpath as-path multipath-relax" commands */
12985 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
12986 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
12988 /* "bgp log-neighbor-changes" commands */
12989 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
12990 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
12992 /* "bgp bestpath med" commands */
12993 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
12994 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
12996 /* "no bgp default ipv4-unicast" commands. */
12997 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
12998 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
13000 /* "bgp network import-check" commands. */
13001 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
13002 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
13003 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
13005 /* "bgp default local-preference" commands. */
13006 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
13007 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
13009 /* bgp default show-hostname */
13010 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
13011 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
13013 /* "bgp default subgroup-pkt-queue-max" commands. */
13014 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
13015 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
13017 /* bgp ibgp-allow-policy-mods command */
13018 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
13019 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
13021 /* "bgp listen limit" commands. */
13022 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
13023 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
13025 /* "bgp listen range" commands. */
13026 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
13027 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
13029 /* "bgp default shutdown" command */
13030 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
13032 /* "neighbor remote-as" commands. */
13033 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
13034 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
13035 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
13036 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
13037 install_element(BGP_NODE
,
13038 &neighbor_interface_v6only_config_remote_as_cmd
);
13039 install_element(BGP_NODE
, &no_neighbor_cmd
);
13040 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
13042 /* "neighbor peer-group" commands. */
13043 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
13044 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
13045 install_element(BGP_NODE
,
13046 &no_neighbor_interface_peer_group_remote_as_cmd
);
13048 /* "neighbor local-as" commands. */
13049 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
13050 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
13051 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
13052 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
13054 /* "neighbor solo" commands. */
13055 install_element(BGP_NODE
, &neighbor_solo_cmd
);
13056 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
13058 /* "neighbor password" commands. */
13059 install_element(BGP_NODE
, &neighbor_password_cmd
);
13060 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
13062 /* "neighbor activate" commands. */
13063 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
13064 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
13065 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
13066 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
13067 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
13068 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
13069 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
13070 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
13071 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
13072 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
13073 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
13074 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
13076 /* "no neighbor activate" commands. */
13077 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
13078 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
13079 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
13080 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
13081 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
13082 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
13083 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
13084 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
13085 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
13086 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
13087 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
13088 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
13090 /* "neighbor peer-group" set commands. */
13091 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
13092 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13093 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13094 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13095 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13096 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13097 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13098 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13099 install_element(BGP_FLOWSPECV4_NODE
,
13100 &neighbor_set_peer_group_hidden_cmd
);
13101 install_element(BGP_FLOWSPECV6_NODE
,
13102 &neighbor_set_peer_group_hidden_cmd
);
13104 /* "no neighbor peer-group unset" commands. */
13105 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
13106 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13107 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13108 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13109 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13110 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13111 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13112 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13113 install_element(BGP_FLOWSPECV4_NODE
,
13114 &no_neighbor_set_peer_group_hidden_cmd
);
13115 install_element(BGP_FLOWSPECV6_NODE
,
13116 &no_neighbor_set_peer_group_hidden_cmd
);
13118 /* "neighbor softreconfiguration inbound" commands.*/
13119 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
13120 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
13121 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13122 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13123 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13124 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13125 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13126 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13127 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13128 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13129 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13130 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13131 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13132 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13133 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13134 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13135 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13136 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13137 install_element(BGP_FLOWSPECV4_NODE
,
13138 &neighbor_soft_reconfiguration_cmd
);
13139 install_element(BGP_FLOWSPECV4_NODE
,
13140 &no_neighbor_soft_reconfiguration_cmd
);
13141 install_element(BGP_FLOWSPECV6_NODE
,
13142 &neighbor_soft_reconfiguration_cmd
);
13143 install_element(BGP_FLOWSPECV6_NODE
,
13144 &no_neighbor_soft_reconfiguration_cmd
);
13145 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
13146 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13148 /* "neighbor attribute-unchanged" commands. */
13149 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
13150 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
13151 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
13152 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13153 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
13154 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13155 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
13156 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13157 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
13158 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13159 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
13160 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13161 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
13162 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13163 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
13164 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13165 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
13166 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13168 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
13169 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
13171 /* "nexthop-local unchanged" commands */
13172 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
13173 install_element(BGP_IPV6_NODE
,
13174 &no_neighbor_nexthop_local_unchanged_cmd
);
13176 /* "neighbor next-hop-self" commands. */
13177 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
13178 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
13179 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
13180 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13181 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
13182 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
13183 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
13184 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
13185 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
13186 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13187 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
13188 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
13189 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
13190 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
13191 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
13192 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13193 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
13194 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13195 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
13196 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
13198 /* "neighbor next-hop-self force" commands. */
13199 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
13200 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
13201 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13202 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
13203 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13204 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13205 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
13206 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13207 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
13208 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13209 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13210 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13211 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
13212 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13213 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
13214 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13215 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13216 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13217 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13218 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13220 /* "neighbor as-override" commands. */
13221 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
13222 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
13223 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
13224 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
13225 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
13226 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
13227 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
13228 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
13229 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
13230 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
13231 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
13232 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
13233 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
13234 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
13235 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
13236 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
13237 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
13238 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
13240 /* "neighbor remove-private-AS" commands. */
13241 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
13242 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
13243 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
13244 install_element(BGP_NODE
,
13245 &no_neighbor_remove_private_as_all_hidden_cmd
);
13246 install_element(BGP_NODE
,
13247 &neighbor_remove_private_as_replace_as_hidden_cmd
);
13248 install_element(BGP_NODE
,
13249 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
13250 install_element(BGP_NODE
,
13251 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13254 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13255 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
13256 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13257 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13258 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13259 install_element(BGP_IPV4_NODE
,
13260 &neighbor_remove_private_as_replace_as_cmd
);
13261 install_element(BGP_IPV4_NODE
,
13262 &no_neighbor_remove_private_as_replace_as_cmd
);
13263 install_element(BGP_IPV4_NODE
,
13264 &neighbor_remove_private_as_all_replace_as_cmd
);
13265 install_element(BGP_IPV4_NODE
,
13266 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13267 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
13268 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
13269 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
13270 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13271 install_element(BGP_IPV4M_NODE
,
13272 &neighbor_remove_private_as_replace_as_cmd
);
13273 install_element(BGP_IPV4M_NODE
,
13274 &no_neighbor_remove_private_as_replace_as_cmd
);
13275 install_element(BGP_IPV4M_NODE
,
13276 &neighbor_remove_private_as_all_replace_as_cmd
);
13277 install_element(BGP_IPV4M_NODE
,
13278 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13279 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
13280 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
13281 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
13282 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13283 install_element(BGP_IPV4L_NODE
,
13284 &neighbor_remove_private_as_replace_as_cmd
);
13285 install_element(BGP_IPV4L_NODE
,
13286 &no_neighbor_remove_private_as_replace_as_cmd
);
13287 install_element(BGP_IPV4L_NODE
,
13288 &neighbor_remove_private_as_all_replace_as_cmd
);
13289 install_element(BGP_IPV4L_NODE
,
13290 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13291 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
13292 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13293 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13294 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13295 install_element(BGP_IPV6_NODE
,
13296 &neighbor_remove_private_as_replace_as_cmd
);
13297 install_element(BGP_IPV6_NODE
,
13298 &no_neighbor_remove_private_as_replace_as_cmd
);
13299 install_element(BGP_IPV6_NODE
,
13300 &neighbor_remove_private_as_all_replace_as_cmd
);
13301 install_element(BGP_IPV6_NODE
,
13302 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13303 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
13304 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
13305 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
13306 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13307 install_element(BGP_IPV6M_NODE
,
13308 &neighbor_remove_private_as_replace_as_cmd
);
13309 install_element(BGP_IPV6M_NODE
,
13310 &no_neighbor_remove_private_as_replace_as_cmd
);
13311 install_element(BGP_IPV6M_NODE
,
13312 &neighbor_remove_private_as_all_replace_as_cmd
);
13313 install_element(BGP_IPV6M_NODE
,
13314 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13315 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
13316 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
13317 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
13318 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13319 install_element(BGP_IPV6L_NODE
,
13320 &neighbor_remove_private_as_replace_as_cmd
);
13321 install_element(BGP_IPV6L_NODE
,
13322 &no_neighbor_remove_private_as_replace_as_cmd
);
13323 install_element(BGP_IPV6L_NODE
,
13324 &neighbor_remove_private_as_all_replace_as_cmd
);
13325 install_element(BGP_IPV6L_NODE
,
13326 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13327 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
13328 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13329 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13330 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13331 install_element(BGP_VPNV4_NODE
,
13332 &neighbor_remove_private_as_replace_as_cmd
);
13333 install_element(BGP_VPNV4_NODE
,
13334 &no_neighbor_remove_private_as_replace_as_cmd
);
13335 install_element(BGP_VPNV4_NODE
,
13336 &neighbor_remove_private_as_all_replace_as_cmd
);
13337 install_element(BGP_VPNV4_NODE
,
13338 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13339 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
13340 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13341 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13342 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13343 install_element(BGP_VPNV6_NODE
,
13344 &neighbor_remove_private_as_replace_as_cmd
);
13345 install_element(BGP_VPNV6_NODE
,
13346 &no_neighbor_remove_private_as_replace_as_cmd
);
13347 install_element(BGP_VPNV6_NODE
,
13348 &neighbor_remove_private_as_all_replace_as_cmd
);
13349 install_element(BGP_VPNV6_NODE
,
13350 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13352 /* "neighbor send-community" commands.*/
13353 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
13354 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
13355 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
13356 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
13357 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
13358 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
13359 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
13360 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
13361 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
13362 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
13363 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
13364 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
13365 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
13366 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
13367 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
13368 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
13369 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
13370 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
13371 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
13372 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
13373 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
13374 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
13375 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
13376 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
13377 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
13378 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
13379 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
13380 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
13381 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
13382 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
13383 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
13384 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
13385 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
13386 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
13387 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
13388 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
13390 /* "neighbor route-reflector" commands.*/
13391 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
13392 install_element(BGP_NODE
,
13393 &no_neighbor_route_reflector_client_hidden_cmd
);
13394 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
13395 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
13396 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
13397 install_element(BGP_IPV4M_NODE
,
13398 &no_neighbor_route_reflector_client_cmd
);
13399 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
13400 install_element(BGP_IPV4L_NODE
,
13401 &no_neighbor_route_reflector_client_cmd
);
13402 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
13403 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
13404 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
13405 install_element(BGP_IPV6M_NODE
,
13406 &no_neighbor_route_reflector_client_cmd
);
13407 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
13408 install_element(BGP_IPV6L_NODE
,
13409 &no_neighbor_route_reflector_client_cmd
);
13410 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
13411 install_element(BGP_VPNV4_NODE
,
13412 &no_neighbor_route_reflector_client_cmd
);
13413 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
13414 install_element(BGP_VPNV6_NODE
,
13415 &no_neighbor_route_reflector_client_cmd
);
13416 install_element(BGP_FLOWSPECV4_NODE
,
13417 &neighbor_route_reflector_client_cmd
);
13418 install_element(BGP_FLOWSPECV4_NODE
,
13419 &no_neighbor_route_reflector_client_cmd
);
13420 install_element(BGP_FLOWSPECV6_NODE
,
13421 &neighbor_route_reflector_client_cmd
);
13422 install_element(BGP_FLOWSPECV6_NODE
,
13423 &no_neighbor_route_reflector_client_cmd
);
13424 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
13425 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
13427 /* "neighbor route-server" commands.*/
13428 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
13429 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
13430 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
13431 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
13432 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
13433 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
13434 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
13435 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
13436 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
13437 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
13438 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
13439 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
13440 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
13441 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
13442 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
13443 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
13444 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
13445 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
13446 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
13447 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
13448 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
13449 install_element(BGP_FLOWSPECV4_NODE
,
13450 &no_neighbor_route_server_client_cmd
);
13451 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
13452 install_element(BGP_FLOWSPECV6_NODE
,
13453 &no_neighbor_route_server_client_cmd
);
13455 /* "neighbor addpath-tx-all-paths" commands.*/
13456 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
13457 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
13458 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13459 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13460 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13461 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13462 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13463 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13464 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13465 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13466 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13467 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13468 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13469 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13470 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13471 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13472 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13473 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13475 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
13476 install_element(BGP_NODE
,
13477 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13478 install_element(BGP_NODE
,
13479 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13480 install_element(BGP_IPV4_NODE
,
13481 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13482 install_element(BGP_IPV4_NODE
,
13483 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13484 install_element(BGP_IPV4M_NODE
,
13485 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13486 install_element(BGP_IPV4M_NODE
,
13487 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13488 install_element(BGP_IPV4L_NODE
,
13489 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13490 install_element(BGP_IPV4L_NODE
,
13491 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13492 install_element(BGP_IPV6_NODE
,
13493 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13494 install_element(BGP_IPV6_NODE
,
13495 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13496 install_element(BGP_IPV6M_NODE
,
13497 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13498 install_element(BGP_IPV6M_NODE
,
13499 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13500 install_element(BGP_IPV6L_NODE
,
13501 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13502 install_element(BGP_IPV6L_NODE
,
13503 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13504 install_element(BGP_VPNV4_NODE
,
13505 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13506 install_element(BGP_VPNV4_NODE
,
13507 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13508 install_element(BGP_VPNV6_NODE
,
13509 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13510 install_element(BGP_VPNV6_NODE
,
13511 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13513 /* "neighbor passive" commands. */
13514 install_element(BGP_NODE
, &neighbor_passive_cmd
);
13515 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13518 /* "neighbor shutdown" commands. */
13519 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13520 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13521 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13522 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13524 /* "neighbor capability extended-nexthop" commands.*/
13525 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13526 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13528 /* "neighbor capability orf prefix-list" commands.*/
13529 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13530 install_element(BGP_NODE
,
13531 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13532 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13533 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13534 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13535 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13536 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13537 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13538 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13539 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13540 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13541 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13542 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13543 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13545 /* "neighbor capability dynamic" commands.*/
13546 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13547 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13549 /* "neighbor dont-capability-negotiate" commands. */
13550 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13551 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13553 /* "neighbor ebgp-multihop" commands. */
13554 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13555 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13556 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13558 /* "neighbor disable-connected-check" commands. */
13559 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13560 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13562 /* "neighbor enforce-first-as" commands. */
13563 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13564 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13566 /* "neighbor description" commands. */
13567 install_element(BGP_NODE
, &neighbor_description_cmd
);
13568 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13569 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13571 /* "neighbor update-source" commands. "*/
13572 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13573 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13575 /* "neighbor default-originate" commands. */
13576 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13577 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13578 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13579 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13580 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13581 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13582 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13583 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13584 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13585 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13586 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13587 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13588 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13589 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13590 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13591 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13592 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13593 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13594 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13595 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13596 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13598 /* "neighbor port" commands. */
13599 install_element(BGP_NODE
, &neighbor_port_cmd
);
13600 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13602 /* "neighbor weight" commands. */
13603 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13604 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13606 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13607 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13608 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13609 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13610 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13611 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13612 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13613 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13614 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13615 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13616 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13617 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13618 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13619 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13620 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13621 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13623 /* "neighbor override-capability" commands. */
13624 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13625 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13627 /* "neighbor strict-capability-match" commands. */
13628 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13629 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13631 /* "neighbor timers" commands. */
13632 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13633 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13635 /* "neighbor timers connect" commands. */
13636 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13637 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13639 /* "neighbor advertisement-interval" commands. */
13640 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13641 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13643 /* "neighbor interface" commands. */
13644 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13645 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13647 /* "neighbor distribute" commands. */
13648 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13649 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13650 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13651 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13652 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13653 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13654 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13655 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13656 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13657 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13658 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13659 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13660 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13661 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13662 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13663 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13664 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13665 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13667 /* "neighbor prefix-list" commands. */
13668 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13669 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13670 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13671 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13672 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13673 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13674 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13675 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13676 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13677 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13678 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13679 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13680 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13681 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13682 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13683 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13684 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13685 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13686 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13687 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13688 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13689 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13691 /* "neighbor filter-list" commands. */
13692 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13693 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13694 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13695 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13696 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13697 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13698 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13699 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13700 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13701 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13702 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13703 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13704 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13705 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13706 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13707 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13708 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13709 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13710 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13711 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13712 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13713 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13715 /* "neighbor route-map" commands. */
13716 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13717 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13718 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13719 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13720 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13721 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13722 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13723 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13724 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13725 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13726 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13727 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13728 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13729 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13730 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13731 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13732 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13733 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13734 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13735 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13736 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13737 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13738 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13739 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13741 /* "neighbor unsuppress-map" commands. */
13742 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13743 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13744 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13745 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13746 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13747 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13748 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13749 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13750 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13751 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13752 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13753 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13754 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13755 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13756 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13757 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13758 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13759 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13761 /* "neighbor maximum-prefix" commands. */
13762 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13763 install_element(BGP_NODE
,
13764 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13765 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13766 install_element(BGP_NODE
,
13767 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13768 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13769 install_element(BGP_NODE
,
13770 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13771 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13772 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13773 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13774 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13775 install_element(BGP_IPV4_NODE
,
13776 &neighbor_maximum_prefix_threshold_warning_cmd
);
13777 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13778 install_element(BGP_IPV4_NODE
,
13779 &neighbor_maximum_prefix_threshold_restart_cmd
);
13780 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13781 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13782 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13783 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13784 install_element(BGP_IPV4M_NODE
,
13785 &neighbor_maximum_prefix_threshold_warning_cmd
);
13786 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13787 install_element(BGP_IPV4M_NODE
,
13788 &neighbor_maximum_prefix_threshold_restart_cmd
);
13789 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13790 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13791 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13792 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13793 install_element(BGP_IPV4L_NODE
,
13794 &neighbor_maximum_prefix_threshold_warning_cmd
);
13795 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13796 install_element(BGP_IPV4L_NODE
,
13797 &neighbor_maximum_prefix_threshold_restart_cmd
);
13798 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13799 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13800 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13801 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13802 install_element(BGP_IPV6_NODE
,
13803 &neighbor_maximum_prefix_threshold_warning_cmd
);
13804 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13805 install_element(BGP_IPV6_NODE
,
13806 &neighbor_maximum_prefix_threshold_restart_cmd
);
13807 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13808 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13809 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13810 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13811 install_element(BGP_IPV6M_NODE
,
13812 &neighbor_maximum_prefix_threshold_warning_cmd
);
13813 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13814 install_element(BGP_IPV6M_NODE
,
13815 &neighbor_maximum_prefix_threshold_restart_cmd
);
13816 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13817 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13818 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13819 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13820 install_element(BGP_IPV6L_NODE
,
13821 &neighbor_maximum_prefix_threshold_warning_cmd
);
13822 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13823 install_element(BGP_IPV6L_NODE
,
13824 &neighbor_maximum_prefix_threshold_restart_cmd
);
13825 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13826 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13827 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13828 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13829 install_element(BGP_VPNV4_NODE
,
13830 &neighbor_maximum_prefix_threshold_warning_cmd
);
13831 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13832 install_element(BGP_VPNV4_NODE
,
13833 &neighbor_maximum_prefix_threshold_restart_cmd
);
13834 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13835 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13836 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13837 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13838 install_element(BGP_VPNV6_NODE
,
13839 &neighbor_maximum_prefix_threshold_warning_cmd
);
13840 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13841 install_element(BGP_VPNV6_NODE
,
13842 &neighbor_maximum_prefix_threshold_restart_cmd
);
13843 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13845 /* "neighbor allowas-in" */
13846 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13847 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13848 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13849 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13850 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13851 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13852 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13853 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13854 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13855 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13856 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13857 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13858 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13859 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13860 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13861 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13862 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13863 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13864 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13865 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13867 /* address-family commands. */
13868 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13869 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13870 #ifdef KEEP_OLD_VPN_COMMANDS
13871 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13872 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13873 #endif /* KEEP_OLD_VPN_COMMANDS */
13875 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13877 /* "exit-address-family" command. */
13878 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13879 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13880 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13881 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13882 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13883 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13884 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13885 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13886 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13887 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13888 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13890 /* "clear ip bgp commands" */
13891 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13893 /* clear ip bgp prefix */
13894 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13895 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13896 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13898 /* "show [ip] bgp summary" commands. */
13899 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13900 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
13901 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13902 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13903 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13904 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13905 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
13907 /* "show [ip] bgp neighbors" commands. */
13908 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
13910 /* "show [ip] bgp peer-group" commands. */
13911 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
13913 /* "show [ip] bgp paths" commands. */
13914 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
13916 /* "show [ip] bgp community" commands. */
13917 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
13919 /* "show ip bgp large-community" commands. */
13920 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
13921 /* "show [ip] bgp attribute-info" commands. */
13922 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
13923 /* "show [ip] bgp route-leak" command */
13924 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
13926 /* "redistribute" commands. */
13927 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
13928 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
13929 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
13930 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
13931 install_element(BGP_NODE
,
13932 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
13933 install_element(BGP_NODE
,
13934 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
13935 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
13936 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
13937 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
13938 install_element(BGP_NODE
,
13939 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
13940 install_element(BGP_NODE
,
13941 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
13942 install_element(BGP_NODE
,
13943 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
13944 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
13945 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
13946 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
13947 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
13948 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
13949 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
13950 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
13951 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
13952 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
13953 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
13954 install_element(BGP_IPV4_NODE
,
13955 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
13956 install_element(BGP_IPV4_NODE
,
13957 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
13958 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
13959 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
13960 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
13961 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
13962 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
13963 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
13965 /* import|export vpn [route-map WORD] */
13966 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
13967 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
13969 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
13970 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
13972 /* ttl_security commands */
13973 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
13974 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
13976 /* "show [ip] bgp memory" commands. */
13977 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
13979 /* "show bgp martian next-hop" */
13980 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
13982 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
13984 /* "show [ip] bgp views" commands. */
13985 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
13987 /* "show [ip] bgp vrfs" commands. */
13988 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
13990 /* Community-list. */
13991 community_list_vty();
13993 /* vpn-policy commands */
13994 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
13995 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
13996 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
13997 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
13998 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
13999 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
14000 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
14001 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
14002 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
14003 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
14004 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
14005 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
14007 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
14008 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
14010 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
14011 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
14012 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
14013 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
14014 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
14015 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
14016 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
14017 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
14018 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14019 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14020 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
14021 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
14024 #include "memory.h"
14025 #include "bgp_regex.h"
14026 #include "bgp_clist.h"
14027 #include "bgp_ecommunity.h"
14029 /* VTY functions. */
14031 /* Direction value to string conversion. */
14032 static const char *community_direct_str(int direct
)
14035 case COMMUNITY_DENY
:
14037 case COMMUNITY_PERMIT
:
14044 /* Display error string. */
14045 static void community_list_perror(struct vty
*vty
, int ret
)
14048 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
14049 vty_out(vty
, "%% Can't find community-list\n");
14051 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
14052 vty_out(vty
, "%% Malformed community-list value\n");
14054 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
14056 "%% Community name conflict, previously defined as standard community\n");
14058 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
14060 "%% Community name conflict, previously defined as expanded community\n");
14065 /* "community-list" keyword help string. */
14066 #define COMMUNITY_LIST_STR "Add a community list entry\n"
14068 /*community-list standard */
14069 DEFUN (community_list_standard
,
14070 bgp_community_list_standard_cmd
,
14071 "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14074 "Community list number (standard)\n"
14075 "Add an standard community-list entry\n"
14076 "Community list name\n"
14077 "Specify community to reject\n"
14078 "Specify community to accept\n"
14081 char *cl_name_or_number
= NULL
;
14083 int style
= COMMUNITY_LIST_STANDARD
;
14087 if (argv_find(argv
, argc
, "ip", &idx
)) {
14088 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14089 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14090 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14091 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14094 argv_find(argv
, argc
, "(1-99)", &idx
);
14095 argv_find(argv
, argc
, "WORD", &idx
);
14096 cl_name_or_number
= argv
[idx
]->arg
;
14097 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14099 argv_find(argv
, argc
, "AA:NN", &idx
);
14100 char *str
= argv_concat(argv
, argc
, idx
);
14102 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14105 XFREE(MTYPE_TMP
, str
);
14108 /* Display error string. */
14109 community_list_perror(vty
, ret
);
14110 return CMD_WARNING_CONFIG_FAILED
;
14113 return CMD_SUCCESS
;
14116 #if CONFDATE > 20191005
14117 CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command")
14119 ALIAS (community_list_standard
,
14120 ip_community_list_standard_cmd
,
14121 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14124 "Community list number (standard)\n"
14125 "Add an standard community-list entry\n"
14126 "Community list name\n"
14127 "Specify community to reject\n"
14128 "Specify community to accept\n"
14131 DEFUN (no_community_list_standard_all
,
14132 no_bgp_community_list_standard_all_cmd
,
14133 "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14137 "Community list number (standard)\n"
14138 "Add an standard community-list entry\n"
14139 "Community list name\n"
14140 "Specify community to reject\n"
14141 "Specify community to accept\n"
14144 char *cl_name_or_number
= NULL
;
14147 int style
= COMMUNITY_LIST_STANDARD
;
14151 if (argv_find(argv
, argc
, "ip", &idx
)) {
14152 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
14153 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14154 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14155 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used");
14158 argv_find(argv
, argc
, "permit", &idx
);
14159 argv_find(argv
, argc
, "deny", &idx
);
14162 direct
= argv_find(argv
, argc
, "permit", &idx
)
14167 argv_find(argv
, argc
, "AA:NN", &idx
);
14168 str
= argv_concat(argv
, argc
, idx
);
14172 argv_find(argv
, argc
, "(1-99)", &idx
);
14173 argv_find(argv
, argc
, "WORD", &idx
);
14174 cl_name_or_number
= argv
[idx
]->arg
;
14176 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14179 XFREE(MTYPE_TMP
, str
);
14182 community_list_perror(vty
, ret
);
14183 return CMD_WARNING_CONFIG_FAILED
;
14186 return CMD_SUCCESS
;
14188 ALIAS (no_community_list_standard_all
,
14189 no_ip_community_list_standard_all_cmd
,
14190 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14194 "Community list number (standard)\n"
14195 "Add an standard community-list entry\n"
14196 "Community list name\n"
14197 "Specify community to reject\n"
14198 "Specify community to accept\n"
14201 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
14202 "no bgp community-list <(1-99)|standard WORD>",
14203 NO_STR BGP_STR COMMUNITY_LIST_STR
14204 "Community list number (standard)\n"
14205 "Add an standard community-list entry\n"
14206 "Community list name\n")
14208 ALIAS(no_community_list_standard_all
, no_ip_community_list_standard_all_list_cmd
,
14209 "no ip community-list <(1-99)|standard WORD>",
14210 NO_STR BGP_STR COMMUNITY_LIST_STR
14211 "Community list number (standard)\n"
14212 "Add an standard community-list entry\n"
14213 "Community list name\n")
14215 /*community-list expanded */
14216 DEFUN (community_list_expanded_all
,
14217 bgp_community_list_expanded_all_cmd
,
14218 "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14221 "Community list number (expanded)\n"
14222 "Add an expanded community-list entry\n"
14223 "Community list name\n"
14224 "Specify community to reject\n"
14225 "Specify community to accept\n"
14228 char *cl_name_or_number
= NULL
;
14230 int style
= COMMUNITY_LIST_EXPANDED
;
14233 if (argv_find(argv
, argc
, "ip", &idx
)) {
14234 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14235 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14236 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14237 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14239 argv_find(argv
, argc
, "(100-500)", &idx
);
14240 argv_find(argv
, argc
, "WORD", &idx
);
14241 cl_name_or_number
= argv
[idx
]->arg
;
14242 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14244 argv_find(argv
, argc
, "AA:NN", &idx
);
14245 char *str
= argv_concat(argv
, argc
, idx
);
14247 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14250 XFREE(MTYPE_TMP
, str
);
14253 /* Display error string. */
14254 community_list_perror(vty
, ret
);
14255 return CMD_WARNING_CONFIG_FAILED
;
14258 return CMD_SUCCESS
;
14261 ALIAS (community_list_expanded_all
,
14262 ip_community_list_expanded_all_cmd
,
14263 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14266 "Community list number (expanded)\n"
14267 "Add an expanded community-list entry\n"
14268 "Community list name\n"
14269 "Specify community to reject\n"
14270 "Specify community to accept\n"
14273 DEFUN (no_community_list_expanded_all
,
14274 no_bgp_community_list_expanded_all_cmd
,
14275 "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14279 "Community list number (expanded)\n"
14280 "Add an expanded community-list entry\n"
14281 "Community list name\n"
14282 "Specify community to reject\n"
14283 "Specify community to accept\n"
14286 char *cl_name_or_number
= NULL
;
14289 int style
= COMMUNITY_LIST_EXPANDED
;
14292 if (argv_find(argv
, argc
, "ip", &idx
)) {
14293 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14294 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14295 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14296 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14300 argv_find(argv
, argc
, "permit", &idx
);
14301 argv_find(argv
, argc
, "deny", &idx
);
14304 direct
= argv_find(argv
, argc
, "permit", &idx
)
14309 argv_find(argv
, argc
, "AA:NN", &idx
);
14310 str
= argv_concat(argv
, argc
, idx
);
14314 argv_find(argv
, argc
, "(100-500)", &idx
);
14315 argv_find(argv
, argc
, "WORD", &idx
);
14316 cl_name_or_number
= argv
[idx
]->arg
;
14318 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14321 XFREE(MTYPE_TMP
, str
);
14324 community_list_perror(vty
, ret
);
14325 return CMD_WARNING_CONFIG_FAILED
;
14328 return CMD_SUCCESS
;
14331 ALIAS (no_community_list_expanded_all
,
14332 no_ip_community_list_expanded_all_cmd
,
14333 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14337 "Community list number (expanded)\n"
14338 "Add an expanded community-list entry\n"
14339 "Community list name\n"
14340 "Specify community to reject\n"
14341 "Specify community to accept\n"
14344 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
14345 "no bgp community-list <(100-500)|expanded WORD>",
14346 NO_STR IP_STR COMMUNITY_LIST_STR
14347 "Community list number (expanded)\n"
14348 "Add an expanded community-list entry\n"
14349 "Community list name\n")
14351 ALIAS(no_community_list_expanded_all
, no_ip_community_list_expanded_all_list_cmd
,
14352 "no ip community-list <(100-500)|expanded WORD>",
14353 NO_STR IP_STR COMMUNITY_LIST_STR
14354 "Community list number (expanded)\n"
14355 "Add an expanded community-list entry\n"
14356 "Community list name\n")
14358 /* Return configuration string of community-list entry. */
14359 static const char *community_list_config_str(struct community_entry
*entry
)
14366 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
14367 str
= community_str(entry
->u
.com
, false);
14368 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
14369 str
= lcommunity_str(entry
->u
.lcom
, false);
14371 str
= entry
->config
;
14376 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
14378 struct community_entry
*entry
;
14380 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14381 if (entry
== list
->head
) {
14382 if (all_digit(list
->name
))
14383 vty_out(vty
, "Community %s list %s\n",
14384 entry
->style
== COMMUNITY_LIST_STANDARD
14386 : "(expanded) access",
14389 vty_out(vty
, "Named Community %s list %s\n",
14390 entry
->style
== COMMUNITY_LIST_STANDARD
14396 vty_out(vty
, " %s\n",
14397 community_direct_str(entry
->direct
));
14399 vty_out(vty
, " %s %s\n",
14400 community_direct_str(entry
->direct
),
14401 community_list_config_str(entry
));
14405 DEFUN (show_community_list
,
14406 show_bgp_community_list_cmd
,
14407 "show bgp community-list",
14410 "List community-list\n")
14412 struct community_list
*list
;
14413 struct community_list_master
*cm
;
14416 if (argv_find(argv
, argc
, "ip", &idx
)) {
14417 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14418 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14419 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14420 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14422 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14424 return CMD_SUCCESS
;
14426 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14427 community_list_show(vty
, list
);
14429 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14430 community_list_show(vty
, list
);
14432 return CMD_SUCCESS
;
14435 ALIAS (show_community_list
,
14436 show_ip_community_list_cmd
,
14437 "show ip community-list",
14440 "List community-list\n")
14442 DEFUN (show_community_list_arg
,
14443 show_bgp_community_list_arg_cmd
,
14444 "show bgp community-list <(1-500)|WORD>",
14447 "List community-list\n"
14448 "Community-list number\n"
14449 "Community-list name\n")
14451 int idx_comm_list
= 3;
14452 struct community_list
*list
;
14455 if (argv_find(argv
, argc
, "ip", &idx
)) {
14456 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14457 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14458 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14459 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14461 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
14462 COMMUNITY_LIST_MASTER
);
14464 vty_out(vty
, "%% Can't find community-list\n");
14465 return CMD_WARNING
;
14468 community_list_show(vty
, list
);
14470 return CMD_SUCCESS
;
14473 ALIAS (show_community_list_arg
,
14474 show_ip_community_list_arg_cmd
,
14475 "show ip community-list <(1-500)|WORD>",
14478 "List community-list\n"
14479 "Community-list number\n"
14480 "Community-list name\n")
14483 * Large Community code.
14485 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
14486 struct cmd_token
**argv
, int style
,
14487 int reject_all_digit_name
)
14495 if (argv_find(argv
, argc
, "ip", &idx
)) {
14496 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14497 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14498 vty_out(vty
, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14499 zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14501 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14504 /* All digit name check. */
14506 argv_find(argv
, argc
, "WORD", &idx
);
14507 argv_find(argv
, argc
, "(1-99)", &idx
);
14508 argv_find(argv
, argc
, "(100-500)", &idx
);
14509 cl_name
= argv
[idx
]->arg
;
14510 if (reject_all_digit_name
&& all_digit(cl_name
)) {
14511 vty_out(vty
, "%% Community name cannot have all digits\n");
14512 return CMD_WARNING_CONFIG_FAILED
;
14516 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
14517 argv_find(argv
, argc
, "LINE", &idx
);
14518 /* Concat community string argument. */
14520 str
= argv_concat(argv
, argc
, idx
);
14524 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
14526 /* Free temporary community list string allocated by
14528 XFREE(MTYPE_TMP
, str
);
14531 community_list_perror(vty
, ret
);
14532 return CMD_WARNING_CONFIG_FAILED
;
14534 return CMD_SUCCESS
;
14537 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
14538 struct cmd_token
**argv
, int style
)
14545 if (argv_find(argv
, argc
, "ip", &idx
)) {
14546 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14547 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14548 vty_out(vty
, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14549 zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14551 argv_find(argv
, argc
, "permit", &idx
);
14552 argv_find(argv
, argc
, "deny", &idx
);
14555 /* Check the list direct. */
14556 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
14557 direct
= COMMUNITY_PERMIT
;
14559 direct
= COMMUNITY_DENY
;
14562 argv_find(argv
, argc
, "LINE", &idx
);
14563 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
14564 /* Concat community string argument. */
14565 str
= argv_concat(argv
, argc
, idx
);
14569 argv_find(argv
, argc
, "(1-99)", &idx
);
14570 argv_find(argv
, argc
, "(100-500)", &idx
);
14571 argv_find(argv
, argc
, "WORD", &idx
);
14573 /* Unset community list. */
14574 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
14577 /* Free temporary community list string allocated by
14579 XFREE(MTYPE_TMP
, str
);
14582 community_list_perror(vty
, ret
);
14583 return CMD_WARNING_CONFIG_FAILED
;
14586 return CMD_SUCCESS
;
14589 /* "large-community-list" keyword help string. */
14590 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
14591 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
14593 #if CONFDATE > 20191005
14594 CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command")
14596 DEFUN (lcommunity_list_standard
,
14597 bgp_lcommunity_list_standard_cmd
,
14598 "bgp large-community-list (1-99) <deny|permit>",
14600 LCOMMUNITY_LIST_STR
14601 "Large Community list number (standard)\n"
14602 "Specify large community to reject\n"
14603 "Specify large community to accept\n")
14605 return lcommunity_list_set_vty(vty
, argc
, argv
,
14606 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14609 ALIAS (lcommunity_list_standard
,
14610 ip_lcommunity_list_standard_cmd
,
14611 "ip large-community-list (1-99) <deny|permit>",
14613 LCOMMUNITY_LIST_STR
14614 "Large Community list number (standard)\n"
14615 "Specify large community to reject\n"
14616 "Specify large community to accept\n")
14618 DEFUN (lcommunity_list_standard1
,
14619 bgp_lcommunity_list_standard1_cmd
,
14620 "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...",
14622 LCOMMUNITY_LIST_STR
14623 "Large Community list number (standard)\n"
14624 "Specify large community to reject\n"
14625 "Specify large community to accept\n"
14626 LCOMMUNITY_VAL_STR
)
14628 return lcommunity_list_set_vty(vty
, argc
, argv
,
14629 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14632 ALIAS (lcommunity_list_standard1
,
14633 ip_lcommunity_list_standard1_cmd
,
14634 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
14636 LCOMMUNITY_LIST_STR
14637 "Large Community list number (standard)\n"
14638 "Specify large community to reject\n"
14639 "Specify large community to accept\n"
14640 LCOMMUNITY_VAL_STR
)
14642 DEFUN (lcommunity_list_expanded
,
14643 bgp_lcommunity_list_expanded_cmd
,
14644 "bgp large-community-list (100-500) <deny|permit> LINE...",
14646 LCOMMUNITY_LIST_STR
14647 "Large Community list number (expanded)\n"
14648 "Specify large community to reject\n"
14649 "Specify large community to accept\n"
14650 "An ordered list as a regular-expression\n")
14652 return lcommunity_list_set_vty(vty
, argc
, argv
,
14653 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
14656 ALIAS (lcommunity_list_expanded
,
14657 ip_lcommunity_list_expanded_cmd
,
14658 "ip large-community-list (100-500) <deny|permit> LINE...",
14660 LCOMMUNITY_LIST_STR
14661 "Large Community list number (expanded)\n"
14662 "Specify large community to reject\n"
14663 "Specify large community to accept\n"
14664 "An ordered list as a regular-expression\n")
14666 DEFUN (lcommunity_list_name_standard
,
14667 bgp_lcommunity_list_name_standard_cmd
,
14668 "bgp large-community-list standard WORD <deny|permit>",
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")
14676 return lcommunity_list_set_vty(vty
, argc
, argv
,
14677 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14680 ALIAS (lcommunity_list_name_standard
,
14681 ip_lcommunity_list_name_standard_cmd
,
14682 "ip large-community-list standard WORD <deny|permit>",
14684 LCOMMUNITY_LIST_STR
14685 "Specify standard large-community-list\n"
14686 "Large Community list name\n"
14687 "Specify large community to reject\n"
14688 "Specify large community to accept\n")
14690 DEFUN (lcommunity_list_name_standard1
,
14691 bgp_lcommunity_list_name_standard1_cmd
,
14692 "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
14694 LCOMMUNITY_LIST_STR
14695 "Specify standard large-community-list\n"
14696 "Large Community list name\n"
14697 "Specify large community to reject\n"
14698 "Specify large community to accept\n"
14699 LCOMMUNITY_VAL_STR
)
14701 return lcommunity_list_set_vty(vty
, argc
, argv
,
14702 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14705 ALIAS (lcommunity_list_name_standard1
,
14706 ip_lcommunity_list_name_standard1_cmd
,
14707 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
14709 LCOMMUNITY_LIST_STR
14710 "Specify standard large-community-list\n"
14711 "Large Community list name\n"
14712 "Specify large community to reject\n"
14713 "Specify large community to accept\n"
14714 LCOMMUNITY_VAL_STR
)
14716 DEFUN (lcommunity_list_name_expanded
,
14717 bgp_lcommunity_list_name_expanded_cmd
,
14718 "bgp large-community-list expanded WORD <deny|permit> LINE...",
14720 LCOMMUNITY_LIST_STR
14721 "Specify expanded large-community-list\n"
14722 "Large Community list name\n"
14723 "Specify large community to reject\n"
14724 "Specify large community to accept\n"
14725 "An ordered list as a regular-expression\n")
14727 return lcommunity_list_set_vty(vty
, argc
, argv
,
14728 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
14731 ALIAS (lcommunity_list_name_expanded
,
14732 ip_lcommunity_list_name_expanded_cmd
,
14733 "ip large-community-list expanded WORD <deny|permit> LINE...",
14735 LCOMMUNITY_LIST_STR
14736 "Specify expanded large-community-list\n"
14737 "Large Community list name\n"
14738 "Specify large community to reject\n"
14739 "Specify large community to accept\n"
14740 "An ordered list as a regular-expression\n")
14742 DEFUN (no_lcommunity_list_standard_all
,
14743 no_bgp_lcommunity_list_standard_all_cmd
,
14744 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
14747 LCOMMUNITY_LIST_STR
14748 "Large Community list number (standard)\n"
14749 "Large Community list number (expanded)\n"
14750 "Large Community list name\n")
14752 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14753 LARGE_COMMUNITY_LIST_STANDARD
);
14756 ALIAS (no_lcommunity_list_standard_all
,
14757 no_ip_lcommunity_list_standard_all_cmd
,
14758 "no ip large-community-list <(1-99)|(100-500)|WORD>",
14761 LCOMMUNITY_LIST_STR
14762 "Large Community list number (standard)\n"
14763 "Large Community list number (expanded)\n"
14764 "Large Community list name\n")
14766 DEFUN (no_lcommunity_list_name_expanded_all
,
14767 no_bgp_lcommunity_list_name_expanded_all_cmd
,
14768 "no bgp large-community-list expanded WORD",
14771 LCOMMUNITY_LIST_STR
14772 "Specify expanded large-community-list\n"
14773 "Large Community list name\n")
14775 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14776 LARGE_COMMUNITY_LIST_EXPANDED
);
14779 ALIAS (no_lcommunity_list_name_expanded_all
,
14780 no_ip_lcommunity_list_name_expanded_all_cmd
,
14781 "no ip large-community-list expanded WORD",
14784 LCOMMUNITY_LIST_STR
14785 "Specify expanded large-community-list\n"
14786 "Large Community list name\n")
14788 DEFUN (no_lcommunity_list_standard
,
14789 no_bgp_lcommunity_list_standard_cmd
,
14790 "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
14793 LCOMMUNITY_LIST_STR
14794 "Large Community list number (standard)\n"
14795 "Specify large community to reject\n"
14796 "Specify large community to accept\n"
14797 LCOMMUNITY_VAL_STR
)
14799 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14800 LARGE_COMMUNITY_LIST_STANDARD
);
14803 ALIAS (no_lcommunity_list_standard
,
14804 no_ip_lcommunity_list_standard_cmd
,
14805 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
14808 LCOMMUNITY_LIST_STR
14809 "Large Community list number (standard)\n"
14810 "Specify large community to reject\n"
14811 "Specify large community to accept\n"
14812 LCOMMUNITY_VAL_STR
)
14814 DEFUN (no_lcommunity_list_expanded
,
14815 no_bgp_lcommunity_list_expanded_cmd
,
14816 "no bgp large-community-list (100-500) <deny|permit> LINE...",
14819 LCOMMUNITY_LIST_STR
14820 "Large Community list number (expanded)\n"
14821 "Specify large community to reject\n"
14822 "Specify large community to accept\n"
14823 "An ordered list as a regular-expression\n")
14825 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14826 LARGE_COMMUNITY_LIST_EXPANDED
);
14829 ALIAS (no_lcommunity_list_expanded
,
14830 no_ip_lcommunity_list_expanded_cmd
,
14831 "no ip large-community-list (100-500) <deny|permit> LINE...",
14834 LCOMMUNITY_LIST_STR
14835 "Large Community list number (expanded)\n"
14836 "Specify large community to reject\n"
14837 "Specify large community to accept\n"
14838 "An ordered list as a regular-expression\n")
14840 DEFUN (no_lcommunity_list_name_standard
,
14841 no_bgp_lcommunity_list_name_standard_cmd
,
14842 "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
14845 LCOMMUNITY_LIST_STR
14846 "Specify standard large-community-list\n"
14847 "Large Community list name\n"
14848 "Specify large community to reject\n"
14849 "Specify large community to accept\n"
14850 LCOMMUNITY_VAL_STR
)
14852 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14853 LARGE_COMMUNITY_LIST_STANDARD
);
14856 ALIAS (no_lcommunity_list_name_standard
,
14857 no_ip_lcommunity_list_name_standard_cmd
,
14858 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
14861 LCOMMUNITY_LIST_STR
14862 "Specify standard large-community-list\n"
14863 "Large Community list name\n"
14864 "Specify large community to reject\n"
14865 "Specify large community to accept\n"
14866 LCOMMUNITY_VAL_STR
)
14868 DEFUN (no_lcommunity_list_name_expanded
,
14869 no_bgp_lcommunity_list_name_expanded_cmd
,
14870 "no bgp large-community-list expanded WORD <deny|permit> LINE...",
14873 LCOMMUNITY_LIST_STR
14874 "Specify expanded large-community-list\n"
14875 "Large community list name\n"
14876 "Specify large community to reject\n"
14877 "Specify large community to accept\n"
14878 "An ordered list as a regular-expression\n")
14880 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14881 LARGE_COMMUNITY_LIST_EXPANDED
);
14884 ALIAS (no_lcommunity_list_name_expanded
,
14885 no_ip_lcommunity_list_name_expanded_cmd
,
14886 "no ip large-community-list expanded WORD <deny|permit> LINE...",
14889 LCOMMUNITY_LIST_STR
14890 "Specify expanded large-community-list\n"
14891 "Large community list name\n"
14892 "Specify large community to reject\n"
14893 "Specify large community to accept\n"
14894 "An ordered list as a regular-expression\n")
14896 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14898 struct community_entry
*entry
;
14900 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14901 if (entry
== list
->head
) {
14902 if (all_digit(list
->name
))
14903 vty_out(vty
, "Large community %s list %s\n",
14905 LARGE_COMMUNITY_LIST_STANDARD
14907 : "(expanded) access",
14911 "Named large community %s list %s\n",
14913 LARGE_COMMUNITY_LIST_STANDARD
14919 vty_out(vty
, " %s\n",
14920 community_direct_str(entry
->direct
));
14922 vty_out(vty
, " %s %s\n",
14923 community_direct_str(entry
->direct
),
14924 community_list_config_str(entry
));
14928 DEFUN (show_lcommunity_list
,
14929 show_bgp_lcommunity_list_cmd
,
14930 "show bgp large-community-list",
14933 "List large-community list\n")
14935 struct community_list
*list
;
14936 struct community_list_master
*cm
;
14939 if (argv_find(argv
, argc
, "ip", &idx
)) {
14940 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14941 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14942 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
14943 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
14946 cm
= community_list_master_lookup(bgp_clist
,
14947 LARGE_COMMUNITY_LIST_MASTER
);
14949 return CMD_SUCCESS
;
14951 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14952 lcommunity_list_show(vty
, list
);
14954 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14955 lcommunity_list_show(vty
, list
);
14957 return CMD_SUCCESS
;
14960 ALIAS (show_lcommunity_list
,
14961 show_ip_lcommunity_list_cmd
,
14962 "show ip large-community-list",
14965 "List large-community list\n")
14967 DEFUN (show_lcommunity_list_arg
,
14968 show_bgp_lcommunity_list_arg_cmd
,
14969 "show bgp large-community-list <(1-500)|WORD>",
14972 "List large-community list\n"
14973 "large-community-list number\n"
14974 "large-community-list name\n")
14976 struct community_list
*list
;
14979 if (argv_find(argv
, argc
, "ip", &idx
)) {
14980 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14981 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14982 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
14983 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
14986 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
14987 LARGE_COMMUNITY_LIST_MASTER
);
14989 vty_out(vty
, "%% Can't find extcommunity-list\n");
14990 return CMD_WARNING
;
14993 lcommunity_list_show(vty
, list
);
14995 return CMD_SUCCESS
;
14998 ALIAS (show_lcommunity_list_arg
,
14999 show_ip_lcommunity_list_arg_cmd
,
15000 "show ip large-community-list <(1-500)|WORD>",
15003 "List large-community list\n"
15004 "large-community-list number\n"
15005 "large-community-list name\n")
15007 /* "extcommunity-list" keyword help string. */
15008 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
15009 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
15011 DEFUN (extcommunity_list_standard
,
15012 bgp_extcommunity_list_standard_cmd
,
15013 "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15015 EXTCOMMUNITY_LIST_STR
15016 "Extended Community list number (standard)\n"
15017 "Specify standard extcommunity-list\n"
15018 "Community list name\n"
15019 "Specify community to reject\n"
15020 "Specify community to accept\n"
15021 EXTCOMMUNITY_VAL_STR
)
15023 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15025 char *cl_number_or_name
= NULL
;
15028 if (argv_find(argv
, argc
, "ip", &idx
)) {
15029 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15030 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15031 vty_out(vty
, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15032 zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15034 argv_find(argv
, argc
, "(1-99)", &idx
);
15035 argv_find(argv
, argc
, "WORD", &idx
);
15036 cl_number_or_name
= argv
[idx
]->arg
;
15037 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15039 argv_find(argv
, argc
, "AA:NN", &idx
);
15040 char *str
= argv_concat(argv
, argc
, idx
);
15042 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15045 XFREE(MTYPE_TMP
, str
);
15048 community_list_perror(vty
, ret
);
15049 return CMD_WARNING_CONFIG_FAILED
;
15052 return CMD_SUCCESS
;
15055 #if CONFDATE > 20191005
15056 CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command")
15058 ALIAS (extcommunity_list_standard
,
15059 ip_extcommunity_list_standard_cmd
,
15060 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15062 EXTCOMMUNITY_LIST_STR
15063 "Extended Community list number (standard)\n"
15064 "Specify standard extcommunity-list\n"
15065 "Community list name\n"
15066 "Specify community to reject\n"
15067 "Specify community to accept\n"
15068 EXTCOMMUNITY_VAL_STR
)
15070 DEFUN (extcommunity_list_name_expanded
,
15071 bgp_extcommunity_list_name_expanded_cmd
,
15072 "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15074 EXTCOMMUNITY_LIST_STR
15075 "Extended Community list number (expanded)\n"
15076 "Specify expanded extcommunity-list\n"
15077 "Extended Community list name\n"
15078 "Specify community to reject\n"
15079 "Specify community to accept\n"
15080 "An ordered list as a regular-expression\n")
15082 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15084 char *cl_number_or_name
= NULL
;
15087 if (argv_find(argv
, argc
, "ip", &idx
)) {
15088 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15089 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15090 vty_out(vty
, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15091 zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15094 argv_find(argv
, argc
, "(100-500)", &idx
);
15095 argv_find(argv
, argc
, "WORD", &idx
);
15096 cl_number_or_name
= argv
[idx
]->arg
;
15097 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15099 argv_find(argv
, argc
, "LINE", &idx
);
15100 char *str
= argv_concat(argv
, argc
, idx
);
15102 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15105 XFREE(MTYPE_TMP
, str
);
15108 community_list_perror(vty
, ret
);
15109 return CMD_WARNING_CONFIG_FAILED
;
15112 return CMD_SUCCESS
;
15115 ALIAS (extcommunity_list_name_expanded
,
15116 ip_extcommunity_list_name_expanded_cmd
,
15117 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15119 EXTCOMMUNITY_LIST_STR
15120 "Extended Community list number (expanded)\n"
15121 "Specify expanded extcommunity-list\n"
15122 "Extended Community list name\n"
15123 "Specify community to reject\n"
15124 "Specify community to accept\n"
15125 "An ordered list as a regular-expression\n")
15127 DEFUN (no_extcommunity_list_standard_all
,
15128 no_bgp_extcommunity_list_standard_all_cmd
,
15129 "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15132 EXTCOMMUNITY_LIST_STR
15133 "Extended Community list number (standard)\n"
15134 "Specify standard extcommunity-list\n"
15135 "Community list name\n"
15136 "Specify community to reject\n"
15137 "Specify community to accept\n"
15138 EXTCOMMUNITY_VAL_STR
)
15140 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15142 char *cl_number_or_name
= NULL
;
15146 if (argv_find(argv
, argc
, "ip", &idx
)) {
15147 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15148 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15149 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15150 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15154 argv_find(argv
, argc
, "permit", &idx
);
15155 argv_find(argv
, argc
, "deny", &idx
);
15158 direct
= argv_find(argv
, argc
, "permit", &idx
)
15163 argv_find(argv
, argc
, "AA:NN", &idx
);
15164 str
= argv_concat(argv
, argc
, idx
);
15168 argv_find(argv
, argc
, "(1-99)", &idx
);
15169 argv_find(argv
, argc
, "WORD", &idx
);
15170 cl_number_or_name
= argv
[idx
]->arg
;
15172 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15175 XFREE(MTYPE_TMP
, str
);
15178 community_list_perror(vty
, ret
);
15179 return CMD_WARNING_CONFIG_FAILED
;
15182 return CMD_SUCCESS
;
15185 ALIAS (no_extcommunity_list_standard_all
,
15186 no_ip_extcommunity_list_standard_all_cmd
,
15187 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15190 EXTCOMMUNITY_LIST_STR
15191 "Extended Community list number (standard)\n"
15192 "Specify standard extcommunity-list\n"
15193 "Community list name\n"
15194 "Specify community to reject\n"
15195 "Specify community to accept\n"
15196 EXTCOMMUNITY_VAL_STR
)
15198 ALIAS(no_extcommunity_list_standard_all
,
15199 no_bgp_extcommunity_list_standard_all_list_cmd
,
15200 "no bgp extcommunity-list <(1-99)|standard WORD>",
15201 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15202 "Extended Community list number (standard)\n"
15203 "Specify standard extcommunity-list\n"
15204 "Community list name\n")
15206 ALIAS(no_extcommunity_list_standard_all
,
15207 no_ip_extcommunity_list_standard_all_list_cmd
,
15208 "no ip extcommunity-list <(1-99)|standard WORD>",
15209 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15210 "Extended Community list number (standard)\n"
15211 "Specify standard extcommunity-list\n"
15212 "Community list name\n")
15214 DEFUN (no_extcommunity_list_expanded_all
,
15215 no_bgp_extcommunity_list_expanded_all_cmd
,
15216 "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15219 EXTCOMMUNITY_LIST_STR
15220 "Extended Community list number (expanded)\n"
15221 "Specify expanded extcommunity-list\n"
15222 "Extended Community list name\n"
15223 "Specify community to reject\n"
15224 "Specify community to accept\n"
15225 "An ordered list as a regular-expression\n")
15227 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15229 char *cl_number_or_name
= NULL
;
15233 if (argv_find(argv
, argc
, "ip", &idx
)) {
15234 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15235 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15236 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15237 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15241 argv_find(argv
, argc
, "permit", &idx
);
15242 argv_find(argv
, argc
, "deny", &idx
);
15245 direct
= argv_find(argv
, argc
, "permit", &idx
)
15250 argv_find(argv
, argc
, "LINE", &idx
);
15251 str
= argv_concat(argv
, argc
, idx
);
15255 argv_find(argv
, argc
, "(100-500)", &idx
);
15256 argv_find(argv
, argc
, "WORD", &idx
);
15257 cl_number_or_name
= argv
[idx
]->arg
;
15259 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15262 XFREE(MTYPE_TMP
, str
);
15265 community_list_perror(vty
, ret
);
15266 return CMD_WARNING_CONFIG_FAILED
;
15269 return CMD_SUCCESS
;
15272 ALIAS (no_extcommunity_list_expanded_all
,
15273 no_ip_extcommunity_list_expanded_all_cmd
,
15274 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15277 EXTCOMMUNITY_LIST_STR
15278 "Extended Community list number (expanded)\n"
15279 "Specify expanded extcommunity-list\n"
15280 "Extended Community list name\n"
15281 "Specify community to reject\n"
15282 "Specify community to accept\n"
15283 "An ordered list as a regular-expression\n")
15285 ALIAS(no_extcommunity_list_expanded_all
,
15286 no_ip_extcommunity_list_expanded_all_list_cmd
,
15287 "no ip extcommunity-list <(100-500)|expanded WORD>",
15288 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15289 "Extended Community list number (expanded)\n"
15290 "Specify expanded extcommunity-list\n"
15291 "Extended Community list name\n")
15293 ALIAS(no_extcommunity_list_expanded_all
,
15294 no_bgp_extcommunity_list_expanded_all_list_cmd
,
15295 "no bgp extcommunity-list <(100-500)|expanded WORD>",
15296 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15297 "Extended Community list number (expanded)\n"
15298 "Specify expanded extcommunity-list\n"
15299 "Extended Community list name\n")
15301 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
15303 struct community_entry
*entry
;
15305 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15306 if (entry
== list
->head
) {
15307 if (all_digit(list
->name
))
15308 vty_out(vty
, "Extended community %s list %s\n",
15309 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15311 : "(expanded) access",
15315 "Named extended community %s list %s\n",
15316 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15322 vty_out(vty
, " %s\n",
15323 community_direct_str(entry
->direct
));
15325 vty_out(vty
, " %s %s\n",
15326 community_direct_str(entry
->direct
),
15327 community_list_config_str(entry
));
15331 DEFUN (show_extcommunity_list
,
15332 show_bgp_extcommunity_list_cmd
,
15333 "show bgp extcommunity-list",
15336 "List extended-community list\n")
15338 struct community_list
*list
;
15339 struct community_list_master
*cm
;
15342 if (argv_find(argv
, argc
, "ip", &idx
)) {
15343 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15344 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15345 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15346 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15348 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15350 return CMD_SUCCESS
;
15352 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15353 extcommunity_list_show(vty
, list
);
15355 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15356 extcommunity_list_show(vty
, list
);
15358 return CMD_SUCCESS
;
15361 ALIAS (show_extcommunity_list
,
15362 show_ip_extcommunity_list_cmd
,
15363 "show ip extcommunity-list",
15366 "List extended-community list\n")
15368 DEFUN (show_extcommunity_list_arg
,
15369 show_bgp_extcommunity_list_arg_cmd
,
15370 "show bgp extcommunity-list <(1-500)|WORD>",
15373 "List extended-community list\n"
15374 "Extcommunity-list number\n"
15375 "Extcommunity-list name\n")
15377 int idx_comm_list
= 3;
15378 struct community_list
*list
;
15381 if (argv_find(argv
, argc
, "ip", &idx
)) {
15382 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15383 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15384 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15385 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15387 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
15388 EXTCOMMUNITY_LIST_MASTER
);
15390 vty_out(vty
, "%% Can't find extcommunity-list\n");
15391 return CMD_WARNING
;
15394 extcommunity_list_show(vty
, list
);
15396 return CMD_SUCCESS
;
15399 ALIAS (show_extcommunity_list_arg
,
15400 show_ip_extcommunity_list_arg_cmd
,
15401 "show ip extcommunity-list <(1-500)|WORD>",
15404 "List extended-community list\n"
15405 "Extcommunity-list number\n"
15406 "Extcommunity-list name\n")
15408 /* Display community-list and extcommunity-list configuration. */
15409 static int community_list_config_write(struct vty
*vty
)
15411 struct community_list
*list
;
15412 struct community_entry
*entry
;
15413 struct community_list_master
*cm
;
15416 /* Community-list. */
15417 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
15419 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15420 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15421 vty_out(vty
, "bgp community-list %s %s %s\n", list
->name
,
15422 community_direct_str(entry
->direct
),
15423 community_list_config_str(entry
));
15426 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15427 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15428 vty_out(vty
, "bgp community-list %s %s %s %s\n",
15429 entry
->style
== COMMUNITY_LIST_STANDARD
15432 list
->name
, community_direct_str(entry
->direct
),
15433 community_list_config_str(entry
));
15437 /* Extcommunity-list. */
15438 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15440 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15441 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15442 vty_out(vty
, "bgp extcommunity-list %s %s %s\n",
15443 list
->name
, community_direct_str(entry
->direct
),
15444 community_list_config_str(entry
));
15447 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15448 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15449 vty_out(vty
, "bgp extcommunity-list %s %s %s %s\n",
15450 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15453 list
->name
, community_direct_str(entry
->direct
),
15454 community_list_config_str(entry
));
15459 /* lcommunity-list. */
15460 cm
= community_list_master_lookup(bgp_clist
,
15461 LARGE_COMMUNITY_LIST_MASTER
);
15463 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15464 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15465 vty_out(vty
, "bgp large-community-list %s %s %s\n",
15466 list
->name
, community_direct_str(entry
->direct
),
15467 community_list_config_str(entry
));
15470 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15471 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15472 vty_out(vty
, "bgp large-community-list %s %s %s %s\n",
15473 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
15476 list
->name
, community_direct_str(entry
->direct
),
15477 community_list_config_str(entry
));
15484 static struct cmd_node community_list_node
= {
15485 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
15488 static void community_list_vty(void)
15490 install_node(&community_list_node
, community_list_config_write
);
15492 /* Community-list. */
15493 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
15494 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
15495 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
15496 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
15497 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
15498 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
15499 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
15500 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
15501 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
15502 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
15503 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
15504 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_list_cmd
);
15505 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
15506 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_list_cmd
);
15507 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
15508 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
15510 /* Extcommunity-list. */
15511 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
15512 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
15513 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
15514 install_element(CONFIG_NODE
,
15515 &no_bgp_extcommunity_list_standard_all_list_cmd
);
15516 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
15517 install_element(CONFIG_NODE
,
15518 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
15519 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
15520 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
15521 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
15522 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
15523 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
15524 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_list_cmd
);
15525 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
15526 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_list_cmd
);
15527 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
15528 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
15530 /* Large Community List */
15531 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
15532 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard1_cmd
);
15533 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
15534 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
15535 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard1_cmd
);
15536 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
15537 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_all_cmd
);
15538 install_element(CONFIG_NODE
,
15539 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
15540 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
15541 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
15542 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
15543 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
15544 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
15545 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
15546 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
15547 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
15548 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
15549 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
15550 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
15551 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
15552 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
15553 install_element(CONFIG_NODE
,
15554 &no_ip_lcommunity_list_name_expanded_all_cmd
);
15555 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
15556 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
15557 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
15558 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
15559 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
15560 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);