2 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "lib/zclient.h"
34 #include "memory_vty.h"
40 #include "bgpd/bgpd.h"
41 #include "bgpd/bgp_attr_evpn.h"
42 #include "bgpd/bgp_advertise.h"
43 #include "bgpd/bgp_attr.h"
44 #include "bgpd/bgp_aspath.h"
45 #include "bgpd/bgp_community.h"
46 #include "bgpd/bgp_ecommunity.h"
47 #include "bgpd/bgp_lcommunity.h"
48 #include "bgpd/bgp_damp.h"
49 #include "bgpd/bgp_debug.h"
50 #include "bgpd/bgp_errors.h"
51 #include "bgpd/bgp_fsm.h"
52 #include "bgpd/bgp_nexthop.h"
53 #include "bgpd/bgp_open.h"
54 #include "bgpd/bgp_regex.h"
55 #include "bgpd/bgp_route.h"
56 #include "bgpd/bgp_mplsvpn.h"
57 #include "bgpd/bgp_zebra.h"
58 #include "bgpd/bgp_table.h"
59 #include "bgpd/bgp_vty.h"
60 #include "bgpd/bgp_mpath.h"
61 #include "bgpd/bgp_packet.h"
62 #include "bgpd/bgp_updgrp.h"
63 #include "bgpd/bgp_bfd.h"
64 #include "bgpd/bgp_io.h"
65 #include "bgpd/bgp_evpn.h"
66 #include "bgpd/bgp_addpath.h"
67 #include "bgpd/bgp_mac.h"
69 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
70 struct prefix
*range
, int exact
);
72 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
81 return BGP_IPV4M_NODE
;
83 case SAFI_LABELED_UNICAST
:
84 return BGP_IPV4L_NODE
;
87 return BGP_VPNV4_NODE
;
90 return BGP_FLOWSPECV4_NODE
;
100 return BGP_IPV6_NODE
;
103 return BGP_IPV6M_NODE
;
105 case SAFI_LABELED_UNICAST
:
106 return BGP_IPV6L_NODE
;
109 return BGP_VPNV6_NODE
;
112 return BGP_FLOWSPECV6_NODE
;
115 return BGP_IPV4_NODE
;
120 return BGP_EVPN_NODE
;
124 // We should never be here but to clarify the switch statement..
125 return BGP_IPV4_NODE
;
129 // Impossible to happen
130 return BGP_IPV4_NODE
;
133 /* Utility function to get address family from current node. */
134 afi_t
bgp_node_afi(struct vty
*vty
)
142 case BGP_FLOWSPECV6_NODE
:
155 /* Utility function to get subsequent address family from current
157 safi_t
bgp_node_safi(struct vty
*vty
)
163 safi
= SAFI_MPLS_VPN
;
167 safi
= SAFI_MULTICAST
;
174 safi
= SAFI_LABELED_UNICAST
;
176 case BGP_FLOWSPECV4_NODE
:
177 case BGP_FLOWSPECV6_NODE
:
178 safi
= SAFI_FLOWSPEC
;
188 * Converts an AFI in string form to afi_t
190 * @param afi string, one of
194 * @return the corresponding afi_t
196 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
198 afi_t afi
= AFI_MAX
; /* unknown */
199 if (strmatch(afi_str
, "ipv4"))
201 else if (strmatch(afi_str
, "ipv6"))
203 else if (strmatch(afi_str
, "l2vpn"))
208 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
212 if (argv_find(argv
, argc
, "ipv4", index
)) {
216 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
220 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
228 /* supports <unicast|multicast|vpn|labeled-unicast> */
229 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
231 safi_t safi
= SAFI_MAX
; /* unknown */
232 if (strmatch(safi_str
, "multicast"))
233 safi
= SAFI_MULTICAST
;
234 else if (strmatch(safi_str
, "unicast"))
236 else if (strmatch(safi_str
, "vpn"))
237 safi
= SAFI_MPLS_VPN
;
238 else if (strmatch(safi_str
, "evpn"))
240 else if (strmatch(safi_str
, "labeled-unicast"))
241 safi
= SAFI_LABELED_UNICAST
;
242 else if (strmatch(safi_str
, "flowspec"))
243 safi
= SAFI_FLOWSPEC
;
247 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
251 if (argv_find(argv
, argc
, "unicast", index
)) {
254 *safi
= SAFI_UNICAST
;
255 } else if (argv_find(argv
, argc
, "multicast", index
)) {
258 *safi
= SAFI_MULTICAST
;
259 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
262 *safi
= SAFI_LABELED_UNICAST
;
263 } else if (argv_find(argv
, argc
, "vpn", index
)) {
266 *safi
= SAFI_MPLS_VPN
;
267 } else if (argv_find(argv
, argc
, "evpn", index
)) {
271 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
274 *safi
= SAFI_FLOWSPEC
;
280 * bgp_vty_find_and_parse_afi_safi_bgp
282 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
283 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
284 * to appropriate values for the calling function. This is to allow the
285 * calling function to make decisions appropriate for the show command
286 * that is being parsed.
288 * The show commands are generally of the form:
289 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
290 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
292 * Since we use argv_find if the show command in particular doesn't have:
294 * [<view|vrf> VIEWVRFNAME]
295 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
296 * The command parsing should still be ok.
298 * vty -> The vty for the command so we can output some useful data in
299 * the event of a parse error in the vrf.
300 * argv -> The command tokens
301 * argc -> How many command tokens we have
302 * idx -> The current place in the command, generally should be 0 for this
304 * afi -> The parsed afi if it was included in the show command, returned here
305 * safi -> The parsed safi if it was included in the show command, returned here
306 * bgp -> Pointer to the bgp data structure we need to fill in.
307 * use_json -> json is configured or not
309 * The function returns the correct location in the parse tree for the
312 * Returns 0 for failure to parse correctly, else the idx position of where
313 * it found the last token.
315 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
316 struct cmd_token
**argv
, int argc
,
317 int *idx
, afi_t
*afi
, safi_t
*safi
,
318 struct bgp
**bgp
, bool use_json
)
320 char *vrf_name
= NULL
;
326 if (argv_find(argv
, argc
, "ip", idx
))
329 if (argv_find(argv
, argc
, "view", idx
))
330 vrf_name
= argv
[*idx
+ 1]->arg
;
331 else if (argv_find(argv
, argc
, "vrf", idx
)) {
332 vrf_name
= argv
[*idx
+ 1]->arg
;
333 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
337 if (strmatch(vrf_name
, "all"))
340 *bgp
= bgp_lookup_by_name(vrf_name
);
343 json_object
*json
= NULL
;
344 json
= json_object_new_object();
345 json_object_string_add(
347 "View/Vrf is unknown");
349 json_object_to_json_string_ext(json
,
350 JSON_C_TO_STRING_PRETTY
));
351 json_object_free(json
);
354 vty_out(vty
, "View/Vrf %s is unknown\n",
361 *bgp
= bgp_get_default();
364 json_object
*json
= NULL
;
365 json
= json_object_new_object();
366 json_object_string_add(
368 "Default BGP instance not found");
370 json_object_to_json_string_ext(json
,
371 JSON_C_TO_STRING_PRETTY
));
372 json_object_free(json
);
376 "Default BGP instance not found\n");
382 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
383 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
389 static int peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
391 struct interface
*ifp
= NULL
;
393 if (su
->sa
.sa_family
== AF_INET
)
394 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
395 else if (su
->sa
.sa_family
== AF_INET6
)
396 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
397 su
->sin6
.sin6_scope_id
,
406 /* Utility function for looking up peer from VTY. */
407 /* This is used only for configuration, so disallow if attempted on
408 * a dynamic neighbor.
410 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
412 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
421 ret
= str2sockunion(ip_str
, &su
);
423 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
425 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
428 "%% Malformed address or name: %s\n",
434 peer
= peer_lookup(bgp
, &su
);
437 "%% Specify remote-as or peer-group commands first\n");
440 if (peer_dynamic_neighbor(peer
)) {
442 "%% Operation not allowed on a dynamic neighbor\n");
449 /* Utility function for looking up peer or peer group. */
450 /* This is used only for configuration, so disallow if attempted on
451 * a dynamic neighbor.
453 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
455 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
458 struct peer
*peer
= NULL
;
459 struct peer_group
*group
= NULL
;
465 ret
= str2sockunion(peer_str
, &su
);
467 /* IP address, locate peer. */
468 peer
= peer_lookup(bgp
, &su
);
470 /* Not IP, could match either peer configured on interface or a
472 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
474 group
= peer_group_lookup(bgp
, peer_str
);
478 if (peer_dynamic_neighbor(peer
)) {
480 "%% Operation not allowed on a dynamic neighbor\n");
490 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
495 int bgp_vty_return(struct vty
*vty
, int ret
)
497 const char *str
= NULL
;
500 case BGP_ERR_INVALID_VALUE
:
501 str
= "Invalid value";
503 case BGP_ERR_INVALID_FLAG
:
504 str
= "Invalid flag";
506 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
507 str
= "Peer-group has been shutdown. Activate the peer-group first";
509 case BGP_ERR_PEER_FLAG_CONFLICT
:
510 str
= "Can't set override-capability and strict-capability-match at the same time";
512 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
513 str
= "Specify remote-as or peer-group remote AS first";
515 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
516 str
= "Cannot change the peer-group. Deconfigure first";
518 case BGP_ERR_PEER_GROUP_MISMATCH
:
519 str
= "Peer is not a member of this peer-group";
521 case BGP_ERR_PEER_FILTER_CONFLICT
:
522 str
= "Prefix/distribute list can not co-exist";
524 case BGP_ERR_NOT_INTERNAL_PEER
:
525 str
= "Invalid command. Not an internal neighbor";
527 case BGP_ERR_REMOVE_PRIVATE_AS
:
528 str
= "remove-private-AS cannot be configured for IBGP peers";
530 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
531 str
= "Local-AS allowed only for EBGP peers";
533 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
534 str
= "Cannot have local-as same as BGP AS number";
536 case BGP_ERR_TCPSIG_FAILED
:
537 str
= "Error while applying TCP-Sig to session(s)";
539 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
540 str
= "ebgp-multihop and ttl-security cannot be configured together";
542 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
543 str
= "ttl-security only allowed for EBGP peers";
545 case BGP_ERR_AS_OVERRIDE
:
546 str
= "as-override cannot be configured for IBGP peers";
548 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
549 str
= "Invalid limit for number of dynamic neighbors";
551 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
552 str
= "Dynamic neighbor listen range already exists";
554 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
555 str
= "Operation not allowed on a dynamic neighbor";
557 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
558 str
= "Operation not allowed on a directly connected neighbor";
560 case BGP_ERR_PEER_SAFI_CONFLICT
:
561 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
565 vty_out(vty
, "%% %s\n", str
);
566 return CMD_WARNING_CONFIG_FAILED
;
571 /* BGP clear sort. */
580 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
581 safi_t safi
, int error
)
584 case BGP_ERR_AF_UNCONFIGURED
:
586 "%%BGP: Enable %s address family for the neighbor %s\n",
587 afi_safi_print(afi
, safi
), peer
->host
);
589 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
591 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
599 /* `clear ip bgp' functions. */
600 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
601 enum clear_sort sort
, enum bgp_clear_type stype
,
607 struct listnode
*node
, *nnode
;
609 /* Clear all neighbors. */
611 * Pass along pointer to next node to peer_clear() when walking all
612 * nodes on the BGP instance as that may get freed if it is a
615 if (sort
== clear_all
) {
616 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
617 if (!peer
->afc
[afi
][safi
])
620 if (stype
== BGP_CLEAR_SOFT_NONE
)
621 ret
= peer_clear(peer
, &nnode
);
623 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
626 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
631 /* This is to apply read-only mode on this clear. */
632 if (stype
== BGP_CLEAR_SOFT_NONE
)
633 bgp
->update_delay_over
= 0;
636 vty_out(vty
, "%%BGP: No %s peer configured\n",
637 afi_safi_print(afi
, safi
));
642 /* Clear specified neighbor. */
643 if (sort
== clear_peer
) {
646 /* Make sockunion for lookup. */
647 ret
= str2sockunion(arg
, &su
);
649 peer
= peer_lookup_by_conf_if(bgp
, arg
);
651 peer
= peer_lookup_by_hostname(bgp
, arg
);
654 "Malformed address or name: %s\n",
660 peer
= peer_lookup(bgp
, &su
);
663 "%%BGP: Unknown neighbor - \"%s\"\n",
669 if (!peer
->afc
[afi
][safi
])
670 ret
= BGP_ERR_AF_UNCONFIGURED
;
671 else if (stype
== BGP_CLEAR_SOFT_NONE
)
672 ret
= peer_clear(peer
, NULL
);
674 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
677 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
682 /* Clear all neighbors belonging to a specific peer-group. */
683 if (sort
== clear_group
) {
684 struct peer_group
*group
;
686 group
= peer_group_lookup(bgp
, arg
);
688 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
692 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
693 if (!peer
->afc
[afi
][safi
])
696 if (stype
== BGP_CLEAR_SOFT_NONE
)
697 ret
= peer_clear(peer
, NULL
);
699 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
702 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
709 "%%BGP: No %s peer belonging to peer-group %s is configured\n",
710 afi_safi_print(afi
, safi
), arg
);
715 /* Clear all external (eBGP) neighbors. */
716 if (sort
== clear_external
) {
717 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
718 if (peer
->sort
== BGP_PEER_IBGP
)
721 if (!peer
->afc
[afi
][safi
])
724 if (stype
== BGP_CLEAR_SOFT_NONE
)
725 ret
= peer_clear(peer
, &nnode
);
727 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
730 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
737 "%%BGP: No external %s peer is configured\n",
738 afi_safi_print(afi
, safi
));
743 /* Clear all neighbors belonging to a specific AS. */
744 if (sort
== clear_as
) {
745 as_t as
= strtoul(arg
, NULL
, 10);
747 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
751 if (!peer
->afc
[afi
][safi
])
752 ret
= BGP_ERR_AF_UNCONFIGURED
;
753 else if (stype
== BGP_CLEAR_SOFT_NONE
)
754 ret
= peer_clear(peer
, &nnode
);
756 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
759 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
766 "%%BGP: No %s peer is configured with AS %s\n",
767 afi_safi_print(afi
, safi
), arg
);
775 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
776 safi_t safi
, enum clear_sort sort
,
777 enum bgp_clear_type stype
, const char *arg
)
781 /* BGP structure lookup. */
783 bgp
= bgp_lookup_by_name(name
);
785 vty_out(vty
, "Can't find BGP instance %s\n", name
);
789 bgp
= bgp_get_default();
791 vty_out(vty
, "No BGP process is configured\n");
796 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
799 /* clear soft inbound */
800 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
805 FOREACH_AFI_SAFI (afi
, safi
)
806 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
807 BGP_CLEAR_SOFT_IN
, NULL
);
810 /* clear soft outbound */
811 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
816 FOREACH_AFI_SAFI (afi
, safi
)
817 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
818 BGP_CLEAR_SOFT_OUT
, NULL
);
822 #ifndef VTYSH_EXTRACT_PL
823 #include "bgpd/bgp_vty_clippy.c"
826 DEFUN_HIDDEN (bgp_local_mac
,
828 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
831 "VxLAN Network Identifier\n"
835 "mac-mobility sequence\n"
845 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
846 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
847 vty_out(vty
, "%% Malformed MAC address\n");
850 memset(&ip
, 0, sizeof(ip
));
851 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
853 bgp
= bgp_get_default();
855 vty_out(vty
, "Default BGP instance is not there\n");
859 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
);
861 vty_out(vty
, "Internal error\n");
868 DEFUN_HIDDEN (no_bgp_local_mac
,
869 no_bgp_local_mac_cmd
,
870 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
874 "VxLAN Network Identifier\n"
885 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
886 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
887 vty_out(vty
, "%% Malformed MAC address\n");
890 memset(&ip
, 0, sizeof(ip
));
892 bgp
= bgp_get_default();
894 vty_out(vty
, "Default BGP instance is not there\n");
898 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
900 vty_out(vty
, "Internal error\n");
907 DEFUN (no_synchronization
,
908 no_synchronization_cmd
,
909 "no synchronization",
911 "Perform IGP synchronization\n")
916 DEFUN (no_auto_summary
,
920 "Enable automatic network number summarization\n")
925 /* "router bgp" commands. */
926 DEFUN_NOSH (router_bgp
,
928 "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
932 BGP_INSTANCE_HELP_STR
)
935 int idx_view_vrf
= 3;
941 const char *name
= NULL
;
942 enum bgp_instance_type inst_type
;
944 // "router bgp" without an ASN
946 // Pending: Make VRF option available for ASN less config
947 bgp
= bgp_get_default();
950 vty_out(vty
, "%% No BGP process is configured\n");
951 return CMD_WARNING_CONFIG_FAILED
;
954 if (listcount(bm
->bgp
) > 1) {
955 vty_out(vty
, "%% Please specify ASN and VRF\n");
956 return CMD_WARNING_CONFIG_FAILED
;
962 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
964 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
966 name
= argv
[idx_vrf
]->arg
;
968 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
969 if (strmatch(name
, VRF_DEFAULT_NAME
))
972 inst_type
= BGP_INSTANCE_TYPE_VRF
;
973 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
974 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
977 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
978 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
980 ret
= bgp_get(&bgp
, &as
, name
, inst_type
);
982 case BGP_ERR_AS_MISMATCH
:
983 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
984 return CMD_WARNING_CONFIG_FAILED
;
985 case BGP_ERR_INSTANCE_MISMATCH
:
987 "BGP instance name and AS number mismatch\n");
989 "BGP instance is already running; AS is %u\n",
991 return CMD_WARNING_CONFIG_FAILED
;
995 * If we just instantiated the default instance, complete
996 * any pending VRF-VPN leaking that was configured via
997 * earlier "router bgp X vrf FOO" blocks.
999 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1000 vpn_leak_postchange_all();
1002 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) [<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
, "(1-4294967295)", &idx
)) {
7291 clr_sort
= clear_as
;
7292 clr_arg
= argv
[idx
]->arg
;
7293 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7294 clr_sort
= clear_external
;
7297 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7298 if (argv_find(argv
, argc
, "soft", &idx
)) {
7299 if (argv_find(argv
, argc
, "in", &idx
)
7300 || argv_find(argv
, argc
, "out", &idx
))
7301 clr_type
= strmatch(argv
[idx
]->text
, "in")
7303 : BGP_CLEAR_SOFT_OUT
;
7305 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7306 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7307 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7308 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7309 : BGP_CLEAR_SOFT_IN
;
7310 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7311 clr_type
= BGP_CLEAR_SOFT_OUT
;
7313 clr_type
= BGP_CLEAR_SOFT_NONE
;
7315 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7318 DEFUN (clear_ip_bgp_prefix
,
7319 clear_ip_bgp_prefix_cmd
,
7320 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7324 BGP_INSTANCE_HELP_STR
7325 "Clear bestpath and re-advertise\n"
7329 char *prefix
= NULL
;
7333 /* [<view|vrf> VIEWVRFNAME] */
7334 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7335 vrf
= argv
[idx
+ 1]->arg
;
7337 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7339 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7340 /* [<view> VIEWVRFNAME] */
7341 vrf
= argv
[idx
+ 1]->arg
;
7345 prefix
= argv
[argc
- 1]->arg
;
7347 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7350 DEFUN (clear_bgp_ipv6_safi_prefix
,
7351 clear_bgp_ipv6_safi_prefix_cmd
,
7352 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7358 "Clear bestpath and re-advertise\n"
7362 int idx_ipv6_prefix
= 0;
7363 safi_t safi
= SAFI_UNICAST
;
7364 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7365 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7367 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7368 return bgp_clear_prefix(
7369 vty
, NULL
, prefix
, AFI_IP6
,
7373 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7374 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7375 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7379 BGP_INSTANCE_HELP_STR
7382 "Clear bestpath and re-advertise\n"
7386 int idx_vrfview
= 0;
7387 int idx_ipv6_prefix
= 0;
7388 safi_t safi
= SAFI_UNICAST
;
7389 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7390 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7391 char *vrfview
= NULL
;
7393 /* [<view|vrf> VIEWVRFNAME] */
7394 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
7395 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7396 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
7398 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
7399 /* [<view> VIEWVRFNAME] */
7400 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7402 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7404 return bgp_clear_prefix(
7405 vty
, vrfview
, prefix
,
7406 AFI_IP6
, safi
, NULL
);
7409 DEFUN (show_bgp_views
,
7411 "show [ip] bgp views",
7415 "Show the defined BGP views\n")
7417 struct list
*inst
= bm
->bgp
;
7418 struct listnode
*node
;
7421 vty_out(vty
, "Defined BGP views:\n");
7422 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7424 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7426 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7433 DEFUN (show_bgp_vrfs
,
7435 "show [ip] bgp vrfs [json]",
7442 char buf
[ETHER_ADDR_STRLEN
];
7443 struct list
*inst
= bm
->bgp
;
7444 struct listnode
*node
;
7446 bool uj
= use_json(argc
, argv
);
7447 json_object
*json
= NULL
;
7448 json_object
*json_vrfs
= NULL
;
7452 json
= json_object_new_object();
7453 json_vrfs
= json_object_new_object();
7456 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7457 const char *name
, *type
;
7459 struct listnode
*node2
, *nnode2
;
7460 int peers_cfg
, peers_estb
;
7461 json_object
*json_vrf
= NULL
;
7464 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7468 if (!uj
&& count
== 1) {
7470 "%4s %-5s %-16s %9s %10s %-37s\n",
7471 "Type", "Id", "routerId", "#PeersVfg",
7472 "#PeersEstb", "Name");
7473 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
7474 "L3-VNI", "RouterMAC", "Interface");
7477 peers_cfg
= peers_estb
= 0;
7479 json_vrf
= json_object_new_object();
7482 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
7483 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7486 if (peer
->status
== Established
)
7490 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7491 name
= VRF_DEFAULT_NAME
;
7500 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7502 : (int64_t)bgp
->vrf_id
;
7503 json_object_string_add(json_vrf
, "type", type
);
7504 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7505 json_object_string_add(json_vrf
, "routerId",
7506 inet_ntoa(bgp
->router_id
));
7507 json_object_int_add(json_vrf
, "numConfiguredPeers",
7509 json_object_int_add(json_vrf
, "numEstablishedPeers",
7512 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7513 json_object_string_add(
7515 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7516 json_object_string_add(json_vrf
, "interface",
7517 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
7519 json_object_object_add(json_vrfs
, name
, json_vrf
);
7522 "%4s %-5d %-16s %-9u %-10u %-37s\n",
7524 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7526 inet_ntoa(bgp
->router_id
), peers_cfg
,
7528 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
7530 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
7531 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
7537 json_object_object_add(json
, "vrfs", json_vrfs
);
7539 json_object_int_add(json
, "totalVrfs", count
);
7541 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7542 json
, JSON_C_TO_STRING_PRETTY
));
7543 json_object_free(json
);
7547 "\nTotal number of VRFs (including default): %d\n",
7554 DEFUN (show_bgp_mac_hash
,
7555 show_bgp_mac_hash_cmd
,
7556 "show bgp mac hash",
7560 "Mac Address database\n")
7562 bgp_mac_dump_table(vty
);
7567 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
7569 struct vty
*vty
= (struct vty
*)args
;
7570 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
7572 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7576 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7578 vty_out(vty
, "self nexthop database:\n");
7579 bgp_nexthop_show_address_hash(vty
, bgp
);
7581 vty_out(vty
, "Tunnel-ip database:\n");
7582 hash_iterate(bgp
->tip_hash
,
7583 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
7587 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7588 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7589 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7590 "martian next-hops\n"
7591 "martian next-hop database\n")
7593 struct bgp
*bgp
= NULL
;
7597 /* [<vrf> VIEWVRFNAME] */
7598 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7599 name
= argv
[idx
+ 1]->arg
;
7600 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7602 } else if (argv_find(argv
, argc
, "view", &idx
))
7603 /* [<view> VIEWVRFNAME] */
7604 name
= argv
[idx
+ 1]->arg
;
7606 bgp
= bgp_lookup_by_name(name
);
7608 bgp
= bgp_get_default();
7611 vty_out(vty
, "%% No BGP process is configured\n");
7614 bgp_show_martian_nexthops(vty
, bgp
);
7619 DEFUN (show_bgp_memory
,
7620 show_bgp_memory_cmd
,
7621 "show [ip] bgp memory",
7625 "Global BGP memory statistics\n")
7627 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7628 unsigned long count
;
7630 /* RIB related usage stats */
7631 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7632 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7633 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7634 count
* sizeof(struct bgp_node
)));
7636 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7637 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7638 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7639 count
* sizeof(struct bgp_path_info
)));
7640 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7641 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7644 memstrbuf
, sizeof(memstrbuf
),
7645 count
* sizeof(struct bgp_path_info_extra
)));
7647 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7648 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7649 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7650 count
* sizeof(struct bgp_static
)));
7652 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7653 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7654 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7655 count
* sizeof(struct bpacket
)));
7658 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7659 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7660 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7661 count
* sizeof(struct bgp_adj_in
)));
7662 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7663 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7664 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7665 count
* sizeof(struct bgp_adj_out
)));
7667 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7668 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7670 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7671 count
* sizeof(struct bgp_nexthop_cache
)));
7673 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7674 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7676 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7677 count
* sizeof(struct bgp_damp_info
)));
7680 count
= attr_count();
7681 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7682 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7683 count
* sizeof(struct attr
)));
7685 if ((count
= attr_unknown_count()))
7686 vty_out(vty
, "%ld unknown attributes\n", count
);
7688 /* AS_PATH attributes */
7689 count
= aspath_count();
7690 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7691 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7692 count
* sizeof(struct aspath
)));
7694 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7695 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7696 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7697 count
* sizeof(struct assegment
)));
7699 /* Other attributes */
7700 if ((count
= community_count()))
7701 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7702 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7703 count
* sizeof(struct community
)));
7704 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7705 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7706 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7707 count
* sizeof(struct ecommunity
)));
7708 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7710 "%ld BGP large-community entries, using %s of memory\n",
7711 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7712 count
* sizeof(struct lcommunity
)));
7714 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7715 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7716 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7717 count
* sizeof(struct cluster_list
)));
7719 /* Peer related usage */
7720 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7721 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7722 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7723 count
* sizeof(struct peer
)));
7725 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7726 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7727 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7728 count
* sizeof(struct peer_group
)));
7731 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7732 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7733 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7734 count
* sizeof(regex_t
)));
7738 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7740 json_object
*bestpath
= json_object_new_object();
7742 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7743 json_object_string_add(bestpath
, "asPath", "ignore");
7745 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7746 json_object_string_add(bestpath
, "asPath", "confed");
7748 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7749 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7750 json_object_string_add(bestpath
, "multiPathRelax",
7753 json_object_string_add(bestpath
, "multiPathRelax",
7756 json_object_string_add(bestpath
, "multiPathRelax", "false");
7758 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7759 json_object_string_add(bestpath
, "compareRouterId", "true");
7760 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7761 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7762 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7763 json_object_string_add(bestpath
, "med", "confed");
7764 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7765 json_object_string_add(bestpath
, "med",
7766 "missing-as-worst");
7768 json_object_string_add(bestpath
, "med", "true");
7771 json_object_object_add(json
, "bestPath", bestpath
);
7774 /* Show BGP peer's summary information. */
7775 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7776 bool use_json
, json_object
*json
)
7779 struct listnode
*node
, *nnode
;
7780 unsigned int count
= 0, dn_count
= 0;
7781 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7782 char neighbor_buf
[VTY_BUFSIZ
];
7783 int neighbor_col_default_width
= 16;
7785 int max_neighbor_width
= 0;
7787 json_object
*json_peer
= NULL
;
7788 json_object
*json_peers
= NULL
;
7789 struct peer_af
*paf
;
7791 /* labeled-unicast routes are installed in the unicast table so in order
7793 * display the correct PfxRcd value we must look at SAFI_UNICAST
7795 if (safi
== SAFI_LABELED_UNICAST
)
7796 pfx_rcd_safi
= SAFI_UNICAST
;
7798 pfx_rcd_safi
= safi
;
7802 json
= json_object_new_object();
7804 json_peers
= json_object_new_object();
7806 /* Loop over all neighbors that will be displayed to determine
7808 * characters are needed for the Neighbor column
7810 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7811 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7814 if (peer
->afc
[afi
][safi
]) {
7815 memset(dn_flag
, '\0', sizeof(dn_flag
));
7816 if (peer_dynamic_neighbor(peer
))
7820 && bgp_flag_check(bgp
,
7821 BGP_FLAG_SHOW_HOSTNAME
))
7822 sprintf(neighbor_buf
, "%s%s(%s) ",
7823 dn_flag
, peer
->hostname
,
7826 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7829 len
= strlen(neighbor_buf
);
7831 if (len
> max_neighbor_width
)
7832 max_neighbor_width
= len
;
7836 /* Originally we displayed the Neighbor column as 16
7837 * characters wide so make that the default
7839 if (max_neighbor_width
< neighbor_col_default_width
)
7840 max_neighbor_width
= neighbor_col_default_width
;
7843 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7844 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7847 if (!peer
->afc
[afi
][safi
])
7852 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7855 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7857 : (int64_t)bgp
->vrf_id
;
7859 /* Usage summary and header */
7861 json_object_string_add(
7863 inet_ntoa(bgp
->router_id
));
7864 json_object_int_add(json
, "as", bgp
->as
);
7865 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7866 json_object_string_add(
7869 == BGP_INSTANCE_TYPE_DEFAULT
)
7874 "BGP router identifier %s, local AS number %u vrf-id %d",
7875 inet_ntoa(bgp
->router_id
), bgp
->as
,
7876 bgp
->vrf_id
== VRF_UNKNOWN
7878 : (int)bgp
->vrf_id
);
7882 if (bgp_update_delay_configured(bgp
)) {
7884 json_object_int_add(
7885 json
, "updateDelayLimit",
7886 bgp
->v_update_delay
);
7888 if (bgp
->v_update_delay
7889 != bgp
->v_establish_wait
)
7890 json_object_int_add(
7892 "updateDelayEstablishWait",
7893 bgp
->v_establish_wait
);
7895 if (bgp_update_delay_active(bgp
)) {
7896 json_object_string_add(
7898 "updateDelayFirstNeighbor",
7899 bgp
->update_delay_begin_time
);
7900 json_object_boolean_true_add(
7902 "updateDelayInProgress");
7904 if (bgp
->update_delay_over
) {
7905 json_object_string_add(
7907 "updateDelayFirstNeighbor",
7908 bgp
->update_delay_begin_time
);
7909 json_object_string_add(
7911 "updateDelayBestpathResumed",
7912 bgp
->update_delay_end_time
);
7913 json_object_string_add(
7915 "updateDelayZebraUpdateResume",
7916 bgp
->update_delay_zebra_resume_time
);
7917 json_object_string_add(
7919 "updateDelayPeerUpdateResume",
7920 bgp
->update_delay_peers_resume_time
);
7925 "Read-only mode update-delay limit: %d seconds\n",
7926 bgp
->v_update_delay
);
7927 if (bgp
->v_update_delay
7928 != bgp
->v_establish_wait
)
7930 " Establish wait: %d seconds\n",
7931 bgp
->v_establish_wait
);
7933 if (bgp_update_delay_active(bgp
)) {
7935 " First neighbor established: %s\n",
7936 bgp
->update_delay_begin_time
);
7938 " Delay in progress\n");
7940 if (bgp
->update_delay_over
) {
7942 " First neighbor established: %s\n",
7943 bgp
->update_delay_begin_time
);
7945 " Best-paths resumed: %s\n",
7946 bgp
->update_delay_end_time
);
7948 " zebra update resumed: %s\n",
7949 bgp
->update_delay_zebra_resume_time
);
7951 " peers update resumed: %s\n",
7952 bgp
->update_delay_peers_resume_time
);
7959 if (bgp_maxmed_onstartup_configured(bgp
)
7960 && bgp
->maxmed_active
)
7961 json_object_boolean_true_add(
7962 json
, "maxMedOnStartup");
7963 if (bgp
->v_maxmed_admin
)
7964 json_object_boolean_true_add(
7965 json
, "maxMedAdministrative");
7967 json_object_int_add(
7968 json
, "tableVersion",
7969 bgp_table_version(bgp
->rib
[afi
][safi
]));
7971 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7972 json_object_int_add(json
, "ribCount", ents
);
7973 json_object_int_add(
7975 ents
* sizeof(struct bgp_node
));
7977 ents
= bgp
->af_peer_count
[afi
][safi
];
7978 json_object_int_add(json
, "peerCount", ents
);
7979 json_object_int_add(json
, "peerMemory",
7980 ents
* sizeof(struct peer
));
7982 if ((ents
= listcount(bgp
->group
))) {
7983 json_object_int_add(
7984 json
, "peerGroupCount", ents
);
7985 json_object_int_add(
7986 json
, "peerGroupMemory",
7987 ents
* sizeof(struct
7991 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7992 BGP_CONFIG_DAMPENING
))
7993 json_object_boolean_true_add(
7994 json
, "dampeningEnabled");
7996 if (bgp_maxmed_onstartup_configured(bgp
)
7997 && bgp
->maxmed_active
)
7999 "Max-med on-startup active\n");
8000 if (bgp
->v_maxmed_admin
)
8002 "Max-med administrative active\n");
8004 vty_out(vty
, "BGP table version %" PRIu64
"\n",
8005 bgp_table_version(bgp
->rib
[afi
][safi
]));
8007 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8009 "RIB entries %ld, using %s of memory\n",
8011 mtype_memstr(memstrbuf
,
8013 ents
* sizeof(struct
8016 /* Peer related usage */
8017 ents
= bgp
->af_peer_count
[afi
][safi
];
8018 vty_out(vty
, "Peers %ld, using %s of memory\n",
8021 memstrbuf
, sizeof(memstrbuf
),
8022 ents
* sizeof(struct peer
)));
8024 if ((ents
= listcount(bgp
->group
)))
8026 "Peer groups %ld, using %s of memory\n",
8031 ents
* sizeof(struct
8034 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8035 BGP_CONFIG_DAMPENING
))
8036 vty_out(vty
, "Dampening enabled.\n");
8039 /* Subtract 8 here because 'Neighbor' is
8041 vty_out(vty
, "Neighbor");
8042 vty_out(vty
, "%*s", max_neighbor_width
- 8,
8045 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
8052 json_peer
= json_object_new_object();
8054 if (peer_dynamic_neighbor(peer
)) {
8056 json_object_boolean_true_add(json_peer
,
8061 json_object_string_add(json_peer
, "hostname",
8064 if (peer
->domainname
)
8065 json_object_string_add(json_peer
, "domainname",
8068 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
8069 json_object_int_add(json_peer
, "version", 4);
8070 json_object_int_add(json_peer
, "msgRcvd",
8071 PEER_TOTAL_RX(peer
));
8072 json_object_int_add(json_peer
, "msgSent",
8073 PEER_TOTAL_TX(peer
));
8075 json_object_int_add(json_peer
, "tableVersion",
8076 peer
->version
[afi
][safi
]);
8077 json_object_int_add(json_peer
, "outq",
8079 json_object_int_add(json_peer
, "inq", 0);
8080 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8081 use_json
, json_peer
);
8084 * Adding "pfxRcd" field to match with the corresponding
8085 * CLI. "prefixReceivedCount" will be deprecated in
8088 json_object_int_add(json_peer
, "prefixReceivedCount",
8089 peer
->pcount
[afi
][pfx_rcd_safi
]);
8090 json_object_int_add(json_peer
, "pfxRcd",
8091 peer
->pcount
[afi
][pfx_rcd_safi
]);
8093 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
8094 if (paf
&& PAF_SUBGRP(paf
))
8095 json_object_int_add(json_peer
,
8097 (PAF_SUBGRP(paf
))->scount
);
8099 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8100 json_object_string_add(json_peer
, "state",
8102 else if (peer
->afc_recv
[afi
][safi
])
8103 json_object_string_add(
8105 lookup_msg(bgp_status_msg
, peer
->status
,
8107 else if (CHECK_FLAG(peer
->sflags
,
8108 PEER_STATUS_PREFIX_OVERFLOW
))
8109 json_object_string_add(json_peer
, "state",
8112 json_object_string_add(
8114 lookup_msg(bgp_status_msg
, peer
->status
,
8118 json_object_string_add(json_peer
, "idType",
8120 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8121 json_object_string_add(json_peer
, "idType",
8123 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8124 json_object_string_add(json_peer
, "idType",
8127 json_object_object_add(json_peers
, peer
->host
,
8130 memset(dn_flag
, '\0', sizeof(dn_flag
));
8131 if (peer_dynamic_neighbor(peer
)) {
8137 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8138 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8139 peer
->hostname
, peer
->host
);
8141 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8143 /* pad the neighbor column with spaces */
8144 if (len
< max_neighbor_width
)
8145 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8148 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8149 peer
->as
, PEER_TOTAL_RX(peer
),
8150 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8151 0, peer
->obuf
->count
,
8152 peer_uptime(peer
->uptime
, timebuf
,
8153 BGP_UPTIME_LEN
, 0, NULL
));
8155 if (peer
->status
== Established
)
8156 if (peer
->afc_recv
[afi
][safi
])
8157 vty_out(vty
, " %12ld",
8161 vty_out(vty
, " NoNeg");
8163 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8164 vty_out(vty
, " Idle (Admin)");
8165 else if (CHECK_FLAG(
8167 PEER_STATUS_PREFIX_OVERFLOW
))
8168 vty_out(vty
, " Idle (PfxCt)");
8170 vty_out(vty
, " %12s",
8171 lookup_msg(bgp_status_msg
,
8172 peer
->status
, NULL
));
8179 json_object_object_add(json
, "peers", json_peers
);
8181 json_object_int_add(json
, "totalPeers", count
);
8182 json_object_int_add(json
, "dynamicPeers", dn_count
);
8184 bgp_show_bestpath_json(bgp
, json
);
8186 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8187 json
, JSON_C_TO_STRING_PRETTY
));
8188 json_object_free(json
);
8191 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8193 vty_out(vty
, "No %s neighbor is configured\n",
8194 afi_safi_print(afi
, safi
));
8198 vty_out(vty
, "* - dynamic neighbor\n");
8199 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8200 dn_count
, bgp
->dynamic_neighbors_limit
);
8207 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8208 int safi
, bool use_json
,
8212 int afi_wildcard
= (afi
== AFI_MAX
);
8213 int safi_wildcard
= (safi
== SAFI_MAX
);
8214 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8215 bool nbr_output
= false;
8217 if (use_json
&& is_wildcard
)
8218 vty_out(vty
, "{\n");
8220 afi
= 1; /* AFI_IP */
8221 while (afi
< AFI_MAX
) {
8223 safi
= 1; /* SAFI_UNICAST */
8224 while (safi
< SAFI_MAX
) {
8225 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8229 * So limit output to those afi/safi
8231 * actualy have something interesting in
8235 json
= json_object_new_object();
8238 vty_out(vty
, ",\n");
8242 vty_out(vty
, "\"%s\":",
8246 vty_out(vty
, "\n%s Summary:\n",
8251 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
8263 if (use_json
&& is_wildcard
)
8264 vty_out(vty
, "}\n");
8265 else if (!nbr_output
) {
8267 vty_out(vty
, "{}\n");
8269 vty_out(vty
, "%% No BGP neighbors found\n");
8273 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8274 safi_t safi
, bool use_json
)
8276 struct listnode
*node
, *nnode
;
8278 json_object
*json
= NULL
;
8280 bool nbr_output
= false;
8283 vty_out(vty
, "{\n");
8285 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8288 json
= json_object_new_object();
8291 vty_out(vty
, ",\n");
8295 vty_out(vty
, "\"%s\":",
8296 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8300 vty_out(vty
, "\nInstance %s:\n",
8301 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8305 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
8309 vty_out(vty
, "}\n");
8310 else if (!nbr_output
)
8311 vty_out(vty
, "%% BGP instance not found\n");
8314 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8315 safi_t safi
, bool use_json
)
8320 if (strmatch(name
, "all")) {
8321 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8325 bgp
= bgp_lookup_by_name(name
);
8329 vty_out(vty
, "{}\n");
8332 "%% BGP instance not found\n");
8336 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
8342 bgp
= bgp_get_default();
8345 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
8348 vty_out(vty
, "{}\n");
8350 vty_out(vty
, "%% BGP instance not found\n");
8357 /* `show [ip] bgp summary' commands. */
8358 DEFUN (show_ip_bgp_summary
,
8359 show_ip_bgp_summary_cmd
,
8360 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8364 BGP_INSTANCE_HELP_STR
8366 BGP_SAFI_WITH_LABEL_HELP_STR
8367 "Summary of BGP neighbor status\n"
8371 afi_t afi
= AFI_MAX
;
8372 safi_t safi
= SAFI_MAX
;
8377 if (argv_find(argv
, argc
, "ip", &idx
))
8379 /* [<vrf> VIEWVRFNAME] */
8380 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8381 vrf
= argv
[idx
+ 1]->arg
;
8382 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8384 } else if (argv_find(argv
, argc
, "view", &idx
))
8385 /* [<view> VIEWVRFNAME] */
8386 vrf
= argv
[idx
+ 1]->arg
;
8387 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8388 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8389 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8392 bool uj
= use_json(argc
, argv
);
8394 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8397 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8399 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8400 return "IPv4 Unicast";
8401 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8402 return "IPv4 Multicast";
8403 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8404 return "IPv4 Labeled Unicast";
8405 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8407 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8408 return "IPv4 Encap";
8409 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8410 return "IPv4 Flowspec";
8411 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8412 return "IPv6 Unicast";
8413 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8414 return "IPv6 Multicast";
8415 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8416 return "IPv6 Labeled Unicast";
8417 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8419 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8420 return "IPv6 Encap";
8421 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8422 return "IPv6 Flowspec";
8423 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8424 return "L2VPN EVPN";
8430 * Please note that we have intentionally camelCased
8431 * the return strings here. So if you want
8432 * to use this function, please ensure you
8433 * are doing this within json output
8435 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8437 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8438 return "ipv4Unicast";
8439 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8440 return "ipv4Multicast";
8441 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8442 return "ipv4LabeledUnicast";
8443 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8445 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8447 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8448 return "ipv4Flowspec";
8449 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8450 return "ipv6Unicast";
8451 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8452 return "ipv6Multicast";
8453 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8454 return "ipv6LabeledUnicast";
8455 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8457 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8459 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8460 return "ipv6Flowspec";
8461 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8467 /* Show BGP peer's information. */
8468 enum show_type
{ show_all
, show_peer
, show_ipv4_all
, show_ipv6_all
, show_ipv4_peer
, show_ipv6_peer
};
8470 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8471 afi_t afi
, safi_t safi
,
8472 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8473 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8474 bool use_json
, json_object
*json_pref
)
8477 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8478 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8480 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8481 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8482 json_object_string_add(json_pref
, "sendMode",
8483 "advertisedAndReceived");
8484 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8485 json_object_string_add(json_pref
, "sendMode",
8487 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8488 json_object_string_add(json_pref
, "sendMode",
8491 vty_out(vty
, " Send-mode: ");
8492 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8493 vty_out(vty
, "advertised");
8494 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8495 vty_out(vty
, "%sreceived",
8496 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8505 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8506 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8508 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8509 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8510 json_object_string_add(json_pref
, "recvMode",
8511 "advertisedAndReceived");
8512 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8513 json_object_string_add(json_pref
, "recvMode",
8515 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8516 json_object_string_add(json_pref
, "recvMode",
8519 vty_out(vty
, " Receive-mode: ");
8520 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8521 vty_out(vty
, "advertised");
8522 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8523 vty_out(vty
, "%sreceived",
8524 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8533 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8534 safi_t safi
, bool use_json
,
8535 json_object
*json_neigh
)
8537 struct bgp_filter
*filter
;
8538 struct peer_af
*paf
;
8539 char orf_pfx_name
[BUFSIZ
];
8541 json_object
*json_af
= NULL
;
8542 json_object
*json_prefA
= NULL
;
8543 json_object
*json_prefB
= NULL
;
8544 json_object
*json_addr
= NULL
;
8547 json_addr
= json_object_new_object();
8548 json_af
= json_object_new_object();
8549 filter
= &p
->filter
[afi
][safi
];
8551 if (peer_group_active(p
))
8552 json_object_string_add(json_addr
, "peerGroupMember",
8555 paf
= peer_af_find(p
, afi
, safi
);
8556 if (paf
&& PAF_SUBGRP(paf
)) {
8557 json_object_int_add(json_addr
, "updateGroupId",
8558 PAF_UPDGRP(paf
)->id
);
8559 json_object_int_add(json_addr
, "subGroupId",
8560 PAF_SUBGRP(paf
)->id
);
8561 json_object_int_add(json_addr
, "packetQueueLength",
8562 bpacket_queue_virtual_length(paf
));
8565 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8566 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8567 PEER_CAP_ORF_PREFIX_SM_RCV
)
8568 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8569 PEER_CAP_ORF_PREFIX_RM_ADV
)
8570 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8571 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8572 json_object_int_add(json_af
, "orfType",
8574 json_prefA
= json_object_new_object();
8575 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8576 PEER_CAP_ORF_PREFIX_SM_ADV
,
8577 PEER_CAP_ORF_PREFIX_RM_ADV
,
8578 PEER_CAP_ORF_PREFIX_SM_RCV
,
8579 PEER_CAP_ORF_PREFIX_RM_RCV
,
8580 use_json
, json_prefA
);
8581 json_object_object_add(json_af
, "orfPrefixList",
8585 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8586 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8587 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8588 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8589 PEER_CAP_ORF_PREFIX_RM_ADV
)
8590 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8591 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8592 json_object_int_add(json_af
, "orfOldType",
8593 ORF_TYPE_PREFIX_OLD
);
8594 json_prefB
= json_object_new_object();
8595 bgp_show_peer_afi_orf_cap(
8596 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8597 PEER_CAP_ORF_PREFIX_RM_ADV
,
8598 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8599 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8601 json_object_object_add(json_af
, "orfOldPrefixList",
8605 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8606 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8607 PEER_CAP_ORF_PREFIX_SM_RCV
)
8608 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8609 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8610 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8611 PEER_CAP_ORF_PREFIX_RM_ADV
)
8612 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8613 PEER_CAP_ORF_PREFIX_RM_RCV
)
8614 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8615 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8616 json_object_object_add(json_addr
, "afDependentCap",
8619 json_object_free(json_af
);
8621 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8622 orf_pfx_count
= prefix_bgp_show_prefix_list(
8623 NULL
, afi
, orf_pfx_name
, use_json
);
8625 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8626 PEER_STATUS_ORF_PREFIX_SEND
)
8628 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8629 PEER_STATUS_ORF_PREFIX_SEND
))
8630 json_object_boolean_true_add(json_neigh
,
8633 json_object_int_add(json_addr
, "orfRecvCounter",
8636 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8637 PEER_STATUS_ORF_WAIT_REFRESH
))
8638 json_object_string_add(
8639 json_addr
, "orfFirstUpdate",
8640 "deferredUntilORFOrRouteRefreshRecvd");
8642 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8643 PEER_FLAG_REFLECTOR_CLIENT
))
8644 json_object_boolean_true_add(json_addr
,
8645 "routeReflectorClient");
8646 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8647 PEER_FLAG_RSERVER_CLIENT
))
8648 json_object_boolean_true_add(json_addr
,
8649 "routeServerClient");
8650 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8651 json_object_boolean_true_add(json_addr
,
8652 "inboundSoftConfigPermit");
8654 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8655 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8656 json_object_boolean_true_add(
8658 "privateAsNumsAllReplacedInUpdatesToNbr");
8659 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8660 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8661 json_object_boolean_true_add(
8663 "privateAsNumsReplacedInUpdatesToNbr");
8664 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8665 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8666 json_object_boolean_true_add(
8668 "privateAsNumsAllRemovedInUpdatesToNbr");
8669 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8670 PEER_FLAG_REMOVE_PRIVATE_AS
))
8671 json_object_boolean_true_add(
8673 "privateAsNumsRemovedInUpdatesToNbr");
8675 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8676 json_object_boolean_true_add(
8678 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8681 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8682 json_object_string_add(json_addr
,
8683 "overrideASNsInOutboundUpdates",
8684 "ifAspathEqualRemoteAs");
8686 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8687 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8688 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8689 json_object_boolean_true_add(json_addr
,
8690 "routerAlwaysNextHop");
8691 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8692 PEER_FLAG_AS_PATH_UNCHANGED
))
8693 json_object_boolean_true_add(
8694 json_addr
, "unchangedAsPathPropogatedToNbr");
8695 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8696 PEER_FLAG_NEXTHOP_UNCHANGED
))
8697 json_object_boolean_true_add(
8698 json_addr
, "unchangedNextHopPropogatedToNbr");
8699 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8700 json_object_boolean_true_add(
8701 json_addr
, "unchangedMedPropogatedToNbr");
8702 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8703 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8704 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8705 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8706 PEER_FLAG_SEND_COMMUNITY
)
8707 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8708 PEER_FLAG_SEND_EXT_COMMUNITY
))
8709 json_object_string_add(json_addr
,
8710 "commAttriSentToNbr",
8711 "extendedAndStandard");
8712 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8713 PEER_FLAG_SEND_EXT_COMMUNITY
))
8714 json_object_string_add(json_addr
,
8715 "commAttriSentToNbr",
8718 json_object_string_add(json_addr
,
8719 "commAttriSentToNbr",
8722 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8723 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8724 if (p
->default_rmap
[afi
][safi
].name
)
8725 json_object_string_add(
8726 json_addr
, "defaultRouteMap",
8727 p
->default_rmap
[afi
][safi
].name
);
8729 if (paf
&& PAF_SUBGRP(paf
)
8730 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8731 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8732 json_object_boolean_true_add(json_addr
,
8735 json_object_boolean_true_add(json_addr
,
8739 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8740 if (is_evpn_enabled())
8741 json_object_boolean_true_add(
8742 json_addr
, "advertiseAllVnis");
8745 if (filter
->plist
[FILTER_IN
].name
8746 || filter
->dlist
[FILTER_IN
].name
8747 || filter
->aslist
[FILTER_IN
].name
8748 || filter
->map
[RMAP_IN
].name
)
8749 json_object_boolean_true_add(json_addr
,
8750 "inboundPathPolicyConfig");
8751 if (filter
->plist
[FILTER_OUT
].name
8752 || filter
->dlist
[FILTER_OUT
].name
8753 || filter
->aslist
[FILTER_OUT
].name
8754 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8755 json_object_boolean_true_add(
8756 json_addr
, "outboundPathPolicyConfig");
8759 if (filter
->plist
[FILTER_IN
].name
)
8760 json_object_string_add(json_addr
,
8761 "incomingUpdatePrefixFilterList",
8762 filter
->plist
[FILTER_IN
].name
);
8763 if (filter
->plist
[FILTER_OUT
].name
)
8764 json_object_string_add(json_addr
,
8765 "outgoingUpdatePrefixFilterList",
8766 filter
->plist
[FILTER_OUT
].name
);
8768 /* distribute-list */
8769 if (filter
->dlist
[FILTER_IN
].name
)
8770 json_object_string_add(
8771 json_addr
, "incomingUpdateNetworkFilterList",
8772 filter
->dlist
[FILTER_IN
].name
);
8773 if (filter
->dlist
[FILTER_OUT
].name
)
8774 json_object_string_add(
8775 json_addr
, "outgoingUpdateNetworkFilterList",
8776 filter
->dlist
[FILTER_OUT
].name
);
8779 if (filter
->aslist
[FILTER_IN
].name
)
8780 json_object_string_add(json_addr
,
8781 "incomingUpdateAsPathFilterList",
8782 filter
->aslist
[FILTER_IN
].name
);
8783 if (filter
->aslist
[FILTER_OUT
].name
)
8784 json_object_string_add(json_addr
,
8785 "outgoingUpdateAsPathFilterList",
8786 filter
->aslist
[FILTER_OUT
].name
);
8789 if (filter
->map
[RMAP_IN
].name
)
8790 json_object_string_add(
8791 json_addr
, "routeMapForIncomingAdvertisements",
8792 filter
->map
[RMAP_IN
].name
);
8793 if (filter
->map
[RMAP_OUT
].name
)
8794 json_object_string_add(
8795 json_addr
, "routeMapForOutgoingAdvertisements",
8796 filter
->map
[RMAP_OUT
].name
);
8798 /* ebgp-requires-policy (inbound) */
8799 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8800 && !bgp_inbound_policy_exists(p
, filter
))
8801 json_object_string_add(
8802 json_addr
, "inboundEbgpRequiresPolicy",
8803 "Inbound updates discarded due to missing policy");
8805 /* ebgp-requires-policy (outbound) */
8806 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8807 && (!bgp_outbound_policy_exists(p
, filter
)))
8808 json_object_string_add(
8809 json_addr
, "outboundEbgpRequiresPolicy",
8810 "Outbound updates discarded due to missing policy");
8812 /* unsuppress-map */
8813 if (filter
->usmap
.name
)
8814 json_object_string_add(json_addr
,
8815 "selectiveUnsuppressRouteMap",
8816 filter
->usmap
.name
);
8818 /* Receive prefix count */
8819 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8820 p
->pcount
[afi
][safi
]);
8821 if (paf
&& PAF_SUBGRP(paf
))
8822 json_object_int_add(json_addr
, "sentPrefixCounter",
8823 (PAF_SUBGRP(paf
))->scount
);
8825 /* Maximum prefix */
8826 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8827 json_object_int_add(json_addr
, "prefixAllowedMax",
8828 p
->pmax
[afi
][safi
]);
8829 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8830 PEER_FLAG_MAX_PREFIX_WARNING
))
8831 json_object_boolean_true_add(
8832 json_addr
, "prefixAllowedMaxWarning");
8833 json_object_int_add(json_addr
,
8834 "prefixAllowedWarningThresh",
8835 p
->pmax_threshold
[afi
][safi
]);
8836 if (p
->pmax_restart
[afi
][safi
])
8837 json_object_int_add(
8839 "prefixAllowedRestartIntervalMsecs",
8840 p
->pmax_restart
[afi
][safi
] * 60000);
8842 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8846 filter
= &p
->filter
[afi
][safi
];
8848 vty_out(vty
, " For address family: %s\n",
8849 afi_safi_print(afi
, safi
));
8851 if (peer_group_active(p
))
8852 vty_out(vty
, " %s peer-group member\n",
8855 paf
= peer_af_find(p
, afi
, safi
);
8856 if (paf
&& PAF_SUBGRP(paf
)) {
8857 vty_out(vty
, " Update group %" PRIu64
8858 ", subgroup %" PRIu64
"\n",
8859 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8860 vty_out(vty
, " Packet Queue length %d\n",
8861 bpacket_queue_virtual_length(paf
));
8863 vty_out(vty
, " Not part of any update group\n");
8865 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8866 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8867 PEER_CAP_ORF_PREFIX_SM_RCV
)
8868 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8869 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8870 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8871 PEER_CAP_ORF_PREFIX_RM_ADV
)
8872 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8873 PEER_CAP_ORF_PREFIX_RM_RCV
)
8874 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8875 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8876 vty_out(vty
, " AF-dependant capabilities:\n");
8878 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8879 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8880 PEER_CAP_ORF_PREFIX_SM_RCV
)
8881 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8882 PEER_CAP_ORF_PREFIX_RM_ADV
)
8883 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8884 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8886 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8888 bgp_show_peer_afi_orf_cap(
8889 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8890 PEER_CAP_ORF_PREFIX_RM_ADV
,
8891 PEER_CAP_ORF_PREFIX_SM_RCV
,
8892 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8894 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8895 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8896 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8897 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8898 PEER_CAP_ORF_PREFIX_RM_ADV
)
8899 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8900 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8902 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8903 ORF_TYPE_PREFIX_OLD
);
8904 bgp_show_peer_afi_orf_cap(
8905 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8906 PEER_CAP_ORF_PREFIX_RM_ADV
,
8907 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8908 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8911 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8912 orf_pfx_count
= prefix_bgp_show_prefix_list(
8913 NULL
, afi
, orf_pfx_name
, use_json
);
8915 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8916 PEER_STATUS_ORF_PREFIX_SEND
)
8918 vty_out(vty
, " Outbound Route Filter (ORF):");
8919 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8920 PEER_STATUS_ORF_PREFIX_SEND
))
8921 vty_out(vty
, " sent;");
8923 vty_out(vty
, " received (%d entries)",
8927 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8928 PEER_STATUS_ORF_WAIT_REFRESH
))
8930 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
8932 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8933 PEER_FLAG_REFLECTOR_CLIENT
))
8934 vty_out(vty
, " Route-Reflector Client\n");
8935 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8936 PEER_FLAG_RSERVER_CLIENT
))
8937 vty_out(vty
, " Route-Server Client\n");
8938 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8940 " Inbound soft reconfiguration allowed\n");
8942 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8943 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8945 " Private AS numbers (all) replaced in updates to this neighbor\n");
8946 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8947 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8949 " Private AS numbers replaced in updates to this neighbor\n");
8950 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8951 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8953 " Private AS numbers (all) removed in updates to this neighbor\n");
8954 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8955 PEER_FLAG_REMOVE_PRIVATE_AS
))
8957 " Private AS numbers removed in updates to this neighbor\n");
8959 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8960 vty_out(vty
, " %s\n",
8961 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8962 ->human_description
);
8964 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8966 " Override ASNs in outbound updates if aspath equals remote-as\n");
8968 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8969 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8970 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8971 vty_out(vty
, " NEXT_HOP is always this router\n");
8972 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8973 PEER_FLAG_AS_PATH_UNCHANGED
))
8975 " AS_PATH is propagated unchanged to this neighbor\n");
8976 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8977 PEER_FLAG_NEXTHOP_UNCHANGED
))
8979 " NEXT_HOP is propagated unchanged to this neighbor\n");
8980 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8982 " MED is propagated unchanged to this neighbor\n");
8983 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8984 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8985 PEER_FLAG_SEND_EXT_COMMUNITY
)
8986 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8987 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
8989 " Community attribute sent to this neighbor");
8990 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8991 PEER_FLAG_SEND_COMMUNITY
)
8992 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8993 PEER_FLAG_SEND_EXT_COMMUNITY
)
8994 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8995 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8996 vty_out(vty
, "(all)\n");
8997 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8998 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8999 vty_out(vty
, "(large)\n");
9000 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9001 PEER_FLAG_SEND_EXT_COMMUNITY
))
9002 vty_out(vty
, "(extended)\n");
9004 vty_out(vty
, "(standard)\n");
9006 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9007 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9008 vty_out(vty
, " Default information originate,");
9010 if (p
->default_rmap
[afi
][safi
].name
)
9011 vty_out(vty
, " default route-map %s%s,",
9012 p
->default_rmap
[afi
][safi
].map
? "*"
9014 p
->default_rmap
[afi
][safi
].name
);
9015 if (paf
&& PAF_SUBGRP(paf
)
9016 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9017 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9018 vty_out(vty
, " default sent\n");
9020 vty_out(vty
, " default not sent\n");
9023 /* advertise-vni-all */
9024 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9025 if (is_evpn_enabled())
9026 vty_out(vty
, " advertise-all-vni\n");
9029 if (filter
->plist
[FILTER_IN
].name
9030 || filter
->dlist
[FILTER_IN
].name
9031 || filter
->aslist
[FILTER_IN
].name
9032 || filter
->map
[RMAP_IN
].name
)
9033 vty_out(vty
, " Inbound path policy configured\n");
9034 if (filter
->plist
[FILTER_OUT
].name
9035 || filter
->dlist
[FILTER_OUT
].name
9036 || filter
->aslist
[FILTER_OUT
].name
9037 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9038 vty_out(vty
, " Outbound path policy configured\n");
9041 if (filter
->plist
[FILTER_IN
].name
)
9043 " Incoming update prefix filter list is %s%s\n",
9044 filter
->plist
[FILTER_IN
].plist
? "*" : "",
9045 filter
->plist
[FILTER_IN
].name
);
9046 if (filter
->plist
[FILTER_OUT
].name
)
9048 " Outgoing update prefix filter list is %s%s\n",
9049 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
9050 filter
->plist
[FILTER_OUT
].name
);
9052 /* distribute-list */
9053 if (filter
->dlist
[FILTER_IN
].name
)
9055 " Incoming update network filter list is %s%s\n",
9056 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
9057 filter
->dlist
[FILTER_IN
].name
);
9058 if (filter
->dlist
[FILTER_OUT
].name
)
9060 " Outgoing update network filter list is %s%s\n",
9061 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
9062 filter
->dlist
[FILTER_OUT
].name
);
9065 if (filter
->aslist
[FILTER_IN
].name
)
9067 " Incoming update AS path filter list is %s%s\n",
9068 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
9069 filter
->aslist
[FILTER_IN
].name
);
9070 if (filter
->aslist
[FILTER_OUT
].name
)
9072 " Outgoing update AS path filter list is %s%s\n",
9073 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
9074 filter
->aslist
[FILTER_OUT
].name
);
9077 if (filter
->map
[RMAP_IN
].name
)
9079 " Route map for incoming advertisements is %s%s\n",
9080 filter
->map
[RMAP_IN
].map
? "*" : "",
9081 filter
->map
[RMAP_IN
].name
);
9082 if (filter
->map
[RMAP_OUT
].name
)
9084 " Route map for outgoing advertisements is %s%s\n",
9085 filter
->map
[RMAP_OUT
].map
? "*" : "",
9086 filter
->map
[RMAP_OUT
].name
);
9088 /* ebgp-requires-policy (inbound) */
9089 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9090 && !bgp_inbound_policy_exists(p
, filter
))
9092 " Inbound updates discarded due to missing policy\n");
9094 /* ebgp-requires-policy (outbound) */
9095 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9096 && !bgp_outbound_policy_exists(p
, filter
))
9098 " Outbound updates discarded due to missing policy\n");
9100 /* unsuppress-map */
9101 if (filter
->usmap
.name
)
9103 " Route map for selective unsuppress is %s%s\n",
9104 filter
->usmap
.map
? "*" : "",
9105 filter
->usmap
.name
);
9107 /* Receive prefix count */
9108 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
9110 /* Maximum prefix */
9111 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9112 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
9114 CHECK_FLAG(p
->af_flags
[afi
][safi
],
9115 PEER_FLAG_MAX_PREFIX_WARNING
)
9118 vty_out(vty
, " Threshold for warning message %d%%",
9119 p
->pmax_threshold
[afi
][safi
]);
9120 if (p
->pmax_restart
[afi
][safi
])
9121 vty_out(vty
, ", restart interval %d min",
9122 p
->pmax_restart
[afi
][safi
]);
9130 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
9134 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
9135 char timebuf
[BGP_UPTIME_LEN
];
9137 const char *subcode_str
;
9138 const char *code_str
;
9143 json_object
*json_neigh
= NULL
;
9149 json_neigh
= json_object_new_object();
9151 memset(dn_flag
, '\0', sizeof(dn_flag
));
9152 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9156 if (p
->conf_if
) /* Configured interface name. */
9157 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9158 BGP_PEER_SU_UNSPEC(p
)
9160 : sockunion2str(&p
->su
, buf
,
9162 else /* Configured IP address. */
9163 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9168 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9169 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9171 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9172 json_object_string_add(
9173 json_neigh
, "bgpNeighborAddr",
9174 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9176 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9178 if (p
->change_local_as
)
9179 json_object_int_add(json_neigh
, "localAs",
9180 p
->change_local_as
);
9182 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9184 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9185 json_object_boolean_true_add(json_neigh
,
9186 "localAsNoPrepend");
9188 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9189 json_object_boolean_true_add(json_neigh
,
9190 "localAsReplaceAs");
9192 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9193 || (p
->as_type
== AS_INTERNAL
))
9194 vty_out(vty
, "remote AS %u, ", p
->as
);
9196 vty_out(vty
, "remote AS Unspecified, ");
9197 vty_out(vty
, "local AS %u%s%s, ",
9198 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9199 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9202 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9206 /* peer type internal or confed-internal */
9207 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
9209 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9210 json_object_boolean_true_add(
9211 json_neigh
, "nbrConfedInternalLink");
9213 json_object_boolean_true_add(json_neigh
,
9216 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9217 vty_out(vty
, "confed-internal link\n");
9219 vty_out(vty
, "internal link\n");
9221 /* peer type external or confed-external */
9222 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
9224 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9225 json_object_boolean_true_add(
9226 json_neigh
, "nbrConfedExternalLink");
9228 json_object_boolean_true_add(json_neigh
,
9231 if (bgp_confederation_peers_check(bgp
, p
->as
))
9232 vty_out(vty
, "confed-external link\n");
9234 vty_out(vty
, "external link\n");
9238 json_object_boolean_true_add(json_neigh
,
9239 "nbrUnspecifiedLink");
9241 vty_out(vty
, "unspecified link\n");
9247 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9249 vty_out(vty
, " Description: %s\n", p
->desc
);
9255 json_object_string_add(json_neigh
, "hostname",
9259 json_object_string_add(json_neigh
, "domainname",
9262 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9263 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9266 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9273 json_object_string_add(json_neigh
, "peerGroup",
9277 struct prefix prefix
, *range
= NULL
;
9279 sockunion2hostprefix(&(p
->su
), &prefix
);
9280 range
= peer_group_lookup_dynamic_neighbor_range(
9284 prefix2str(range
, buf1
, sizeof(buf1
));
9285 json_object_string_add(
9287 "peerSubnetRangeGroup", buf1
);
9292 " Member of peer-group %s for session parameters\n",
9296 struct prefix prefix
, *range
= NULL
;
9298 sockunion2hostprefix(&(p
->su
), &prefix
);
9299 range
= peer_group_lookup_dynamic_neighbor_range(
9303 prefix2str(range
, buf1
, sizeof(buf1
));
9305 " Belongs to the subnet range group: %s\n",
9313 /* Administrative shutdown. */
9314 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9315 json_object_boolean_true_add(json_neigh
,
9319 json_object_int_add(json_neigh
, "bgpVersion", 4);
9320 json_object_string_add(
9321 json_neigh
, "remoteRouterId",
9322 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9323 json_object_string_add(
9324 json_neigh
, "localRouterId",
9325 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9329 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9330 && bgp_confederation_peers_check(bgp
, p
->as
))
9331 json_object_boolean_true_add(json_neigh
,
9335 json_object_string_add(
9336 json_neigh
, "bgpState",
9337 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9339 if (p
->status
== Established
) {
9342 uptime
= bgp_clock();
9343 uptime
-= p
->uptime
;
9344 epoch_tbuf
= time(NULL
) - uptime
;
9346 #if CONFDATE > 20200101
9348 "bgpTimerUp should be deprecated and can be removed now");
9351 * bgpTimerUp was miliseconds that was accurate
9352 * up to 1 day, then the value returned
9353 * became garbage. So in order to provide
9354 * some level of backwards compatability,
9355 * we still provde the data, but now
9356 * we are returning the correct value
9357 * and also adding a new bgpTimerUpMsec
9358 * which will allow us to deprecate
9361 json_object_int_add(json_neigh
, "bgpTimerUp",
9363 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9365 json_object_string_add(json_neigh
, "bgpTimerUpString",
9366 peer_uptime(p
->uptime
, timebuf
,
9369 json_object_int_add(json_neigh
,
9370 "bgpTimerUpEstablishedEpoch",
9374 else if (p
->status
== Active
) {
9375 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9376 json_object_string_add(json_neigh
, "bgpStateIs",
9378 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9379 json_object_string_add(json_neigh
, "bgpStateIs",
9387 uptime
= bgp_clock();
9388 uptime
-= p
->readtime
;
9389 tm
= gmtime(&uptime
);
9390 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9391 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9392 + (tm
->tm_hour
* 3600000));
9394 uptime
= bgp_clock();
9395 uptime
-= p
->last_write
;
9396 tm
= gmtime(&uptime
);
9397 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9398 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9399 + (tm
->tm_hour
* 3600000));
9401 uptime
= bgp_clock();
9402 uptime
-= p
->update_time
;
9403 tm
= gmtime(&uptime
);
9404 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9405 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9406 + (tm
->tm_hour
* 3600000));
9408 /* Configured timer values. */
9409 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9410 p
->v_holdtime
* 1000);
9411 json_object_int_add(json_neigh
,
9412 "bgpTimerKeepAliveIntervalMsecs",
9413 p
->v_keepalive
* 1000);
9414 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9415 json_object_int_add(json_neigh
,
9416 "bgpTimerConfiguredHoldTimeMsecs",
9417 p
->holdtime
* 1000);
9418 json_object_int_add(
9420 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9421 p
->keepalive
* 1000);
9422 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9423 || (bgp
->default_keepalive
9424 != BGP_DEFAULT_KEEPALIVE
)) {
9425 json_object_int_add(json_neigh
,
9426 "bgpTimerConfiguredHoldTimeMsecs",
9427 bgp
->default_holdtime
);
9428 json_object_int_add(
9430 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9431 bgp
->default_keepalive
);
9434 /* Administrative shutdown. */
9435 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9436 vty_out(vty
, " Administratively shut down\n");
9439 vty_out(vty
, " BGP version 4");
9440 vty_out(vty
, ", remote router ID %s",
9441 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9442 vty_out(vty
, ", local router ID %s\n",
9443 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9447 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9448 && bgp_confederation_peers_check(bgp
, p
->as
))
9450 " Neighbor under common administration\n");
9453 vty_out(vty
, " BGP state = %s",
9454 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9456 if (p
->status
== Established
)
9457 vty_out(vty
, ", up for %8s",
9458 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9461 else if (p
->status
== Active
) {
9462 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9463 vty_out(vty
, " (passive)");
9464 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9465 vty_out(vty
, " (NSF passive)");
9470 vty_out(vty
, " Last read %s",
9471 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9473 vty_out(vty
, ", Last write %s\n",
9474 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9477 /* Configured timer values. */
9479 " Hold time is %d, keepalive interval is %d seconds\n",
9480 p
->v_holdtime
, p
->v_keepalive
);
9481 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9482 vty_out(vty
, " Configured hold time is %d",
9484 vty_out(vty
, ", keepalive interval is %d seconds\n",
9486 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9487 || (bgp
->default_keepalive
9488 != BGP_DEFAULT_KEEPALIVE
)) {
9489 vty_out(vty
, " Configured hold time is %d",
9490 bgp
->default_holdtime
);
9491 vty_out(vty
, ", keepalive interval is %d seconds\n",
9492 bgp
->default_keepalive
);
9496 if (p
->status
== Established
) {
9497 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9498 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9499 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9500 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9501 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9502 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9503 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9504 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9505 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9506 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9507 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9508 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9509 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9510 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9511 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9512 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9513 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9514 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9515 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9516 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9518 json_object
*json_cap
= NULL
;
9520 json_cap
= json_object_new_object();
9523 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9524 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9525 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9526 && CHECK_FLAG(p
->cap
,
9528 json_object_string_add(
9529 json_cap
, "4byteAs",
9530 "advertisedAndReceived");
9531 else if (CHECK_FLAG(p
->cap
,
9533 json_object_string_add(
9534 json_cap
, "4byteAs",
9536 else if (CHECK_FLAG(p
->cap
,
9538 json_object_string_add(
9539 json_cap
, "4byteAs",
9544 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9545 || CHECK_FLAG(p
->cap
,
9546 PEER_CAP_ADDPATH_ADV
)) {
9547 json_object
*json_add
= NULL
;
9548 const char *print_store
;
9550 json_add
= json_object_new_object();
9552 FOREACH_AFI_SAFI (afi
, safi
) {
9553 json_object
*json_sub
= NULL
;
9555 json_object_new_object();
9556 print_store
= afi_safi_print(
9562 PEER_CAP_ADDPATH_AF_TX_ADV
)
9566 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9571 PEER_CAP_ADDPATH_AF_TX_ADV
)
9576 PEER_CAP_ADDPATH_AF_TX_RCV
))
9577 json_object_boolean_true_add(
9579 "txAdvertisedAndReceived");
9585 PEER_CAP_ADDPATH_AF_TX_ADV
))
9586 json_object_boolean_true_add(
9594 PEER_CAP_ADDPATH_AF_TX_RCV
))
9595 json_object_boolean_true_add(
9603 PEER_CAP_ADDPATH_AF_RX_ADV
)
9607 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9612 PEER_CAP_ADDPATH_AF_RX_ADV
)
9617 PEER_CAP_ADDPATH_AF_RX_RCV
))
9618 json_object_boolean_true_add(
9620 "rxAdvertisedAndReceived");
9626 PEER_CAP_ADDPATH_AF_RX_ADV
))
9627 json_object_boolean_true_add(
9635 PEER_CAP_ADDPATH_AF_RX_RCV
))
9636 json_object_boolean_true_add(
9644 PEER_CAP_ADDPATH_AF_TX_ADV
)
9648 PEER_CAP_ADDPATH_AF_TX_RCV
)
9652 PEER_CAP_ADDPATH_AF_RX_ADV
)
9656 PEER_CAP_ADDPATH_AF_RX_RCV
))
9657 json_object_object_add(
9666 json_object_object_add(
9667 json_cap
, "addPath", json_add
);
9671 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9672 || CHECK_FLAG(p
->cap
,
9673 PEER_CAP_DYNAMIC_ADV
)) {
9674 if (CHECK_FLAG(p
->cap
,
9675 PEER_CAP_DYNAMIC_ADV
)
9676 && CHECK_FLAG(p
->cap
,
9677 PEER_CAP_DYNAMIC_RCV
))
9678 json_object_string_add(
9679 json_cap
, "dynamic",
9680 "advertisedAndReceived");
9681 else if (CHECK_FLAG(
9683 PEER_CAP_DYNAMIC_ADV
))
9684 json_object_string_add(
9685 json_cap
, "dynamic",
9687 else if (CHECK_FLAG(
9689 PEER_CAP_DYNAMIC_RCV
))
9690 json_object_string_add(
9691 json_cap
, "dynamic",
9695 /* Extended nexthop */
9696 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9697 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9698 json_object
*json_nxt
= NULL
;
9699 const char *print_store
;
9702 if (CHECK_FLAG(p
->cap
,
9704 && CHECK_FLAG(p
->cap
,
9706 json_object_string_add(
9709 "advertisedAndReceived");
9710 else if (CHECK_FLAG(p
->cap
,
9712 json_object_string_add(
9716 else if (CHECK_FLAG(p
->cap
,
9718 json_object_string_add(
9723 if (CHECK_FLAG(p
->cap
,
9724 PEER_CAP_ENHE_RCV
)) {
9726 json_object_new_object();
9728 for (safi
= SAFI_UNICAST
;
9729 safi
< SAFI_MAX
; safi
++) {
9734 PEER_CAP_ENHE_AF_RCV
)) {
9735 print_store
= afi_safi_print(
9738 json_object_string_add(
9741 "recieved"); /* misspelled for compatibility */
9744 json_object_object_add(
9746 "extendedNexthopFamililesByPeer",
9752 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9753 || CHECK_FLAG(p
->cap
,
9754 PEER_CAP_REFRESH_NEW_RCV
)
9755 || CHECK_FLAG(p
->cap
,
9756 PEER_CAP_REFRESH_OLD_RCV
)) {
9757 if (CHECK_FLAG(p
->cap
,
9758 PEER_CAP_REFRESH_ADV
)
9761 PEER_CAP_REFRESH_NEW_RCV
)
9764 PEER_CAP_REFRESH_OLD_RCV
))) {
9767 PEER_CAP_REFRESH_OLD_RCV
)
9770 PEER_CAP_REFRESH_NEW_RCV
))
9771 json_object_string_add(
9774 "advertisedAndReceivedOldNew");
9778 PEER_CAP_REFRESH_OLD_RCV
))
9779 json_object_string_add(
9782 "advertisedAndReceivedOld");
9784 json_object_string_add(
9787 "advertisedAndReceivedNew");
9792 PEER_CAP_REFRESH_ADV
))
9793 json_object_string_add(
9800 PEER_CAP_REFRESH_NEW_RCV
)
9803 PEER_CAP_REFRESH_OLD_RCV
))
9804 json_object_string_add(
9810 /* Multiprotocol Extensions */
9811 json_object
*json_multi
= NULL
;
9812 json_multi
= json_object_new_object();
9814 FOREACH_AFI_SAFI (afi
, safi
) {
9815 if (p
->afc_adv
[afi
][safi
]
9816 || p
->afc_recv
[afi
][safi
]) {
9817 json_object
*json_exten
= NULL
;
9819 json_object_new_object();
9821 if (p
->afc_adv
[afi
][safi
]
9822 && p
->afc_recv
[afi
][safi
])
9823 json_object_boolean_true_add(
9825 "advertisedAndReceived");
9826 else if (p
->afc_adv
[afi
][safi
])
9827 json_object_boolean_true_add(
9830 else if (p
->afc_recv
[afi
][safi
])
9831 json_object_boolean_true_add(
9835 json_object_object_add(
9842 json_object_object_add(
9843 json_cap
, "multiprotocolExtensions",
9846 /* Hostname capabilities */
9847 json_object
*json_hname
= NULL
;
9849 json_hname
= json_object_new_object();
9851 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9852 json_object_string_add(
9853 json_hname
, "advHostName",
9854 bgp
->peer_self
->hostname
9858 json_object_string_add(
9859 json_hname
, "advDomainName",
9860 bgp
->peer_self
->domainname
9867 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9868 json_object_string_add(
9869 json_hname
, "rcvHostName",
9870 p
->hostname
? p
->hostname
9872 json_object_string_add(
9873 json_hname
, "rcvDomainName",
9874 p
->domainname
? p
->domainname
9878 json_object_object_add(json_cap
, "hostName",
9881 /* Gracefull Restart */
9882 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9883 || CHECK_FLAG(p
->cap
,
9884 PEER_CAP_RESTART_ADV
)) {
9885 if (CHECK_FLAG(p
->cap
,
9886 PEER_CAP_RESTART_ADV
)
9887 && CHECK_FLAG(p
->cap
,
9888 PEER_CAP_RESTART_RCV
))
9889 json_object_string_add(
9892 "advertisedAndReceived");
9893 else if (CHECK_FLAG(
9895 PEER_CAP_RESTART_ADV
))
9896 json_object_string_add(
9898 "gracefulRestartCapability",
9900 else if (CHECK_FLAG(
9902 PEER_CAP_RESTART_RCV
))
9903 json_object_string_add(
9905 "gracefulRestartCapability",
9908 if (CHECK_FLAG(p
->cap
,
9909 PEER_CAP_RESTART_RCV
)) {
9910 int restart_af_count
= 0;
9911 json_object
*json_restart
=
9914 json_object_new_object();
9916 json_object_int_add(
9918 "gracefulRestartRemoteTimerMsecs",
9919 p
->v_gr_restart
* 1000);
9921 FOREACH_AFI_SAFI (afi
, safi
) {
9926 PEER_CAP_RESTART_AF_RCV
)) {
9931 json_object_new_object();
9937 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
9938 json_object_boolean_true_add(
9942 json_object_object_add(
9950 if (!restart_af_count
) {
9951 json_object_string_add(
9953 "addressFamiliesByPeer",
9958 json_object_object_add(
9960 "addressFamiliesByPeer",
9964 json_object_object_add(json_neigh
,
9965 "neighborCapabilities",
9968 vty_out(vty
, " Neighbor capabilities:\n");
9971 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9972 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9973 vty_out(vty
, " 4 Byte AS:");
9974 if (CHECK_FLAG(p
->cap
,
9976 vty_out(vty
, " advertised");
9977 if (CHECK_FLAG(p
->cap
,
9979 vty_out(vty
, " %sreceived",
9989 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9990 || CHECK_FLAG(p
->cap
,
9991 PEER_CAP_ADDPATH_ADV
)) {
9992 vty_out(vty
, " AddPath:\n");
9994 FOREACH_AFI_SAFI (afi
, safi
) {
9998 PEER_CAP_ADDPATH_AF_TX_ADV
)
10002 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
10013 PEER_CAP_ADDPATH_AF_TX_ADV
))
10024 PEER_CAP_ADDPATH_AF_TX_RCV
))
10031 PEER_CAP_ADDPATH_AF_TX_ADV
)
10035 vty_out(vty
, "\n");
10041 PEER_CAP_ADDPATH_AF_RX_ADV
)
10045 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
10056 PEER_CAP_ADDPATH_AF_RX_ADV
))
10067 PEER_CAP_ADDPATH_AF_RX_RCV
))
10074 PEER_CAP_ADDPATH_AF_RX_ADV
)
10078 vty_out(vty
, "\n");
10084 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10085 || CHECK_FLAG(p
->cap
,
10086 PEER_CAP_DYNAMIC_ADV
)) {
10087 vty_out(vty
, " Dynamic:");
10088 if (CHECK_FLAG(p
->cap
,
10089 PEER_CAP_DYNAMIC_ADV
))
10090 vty_out(vty
, " advertised");
10091 if (CHECK_FLAG(p
->cap
,
10092 PEER_CAP_DYNAMIC_RCV
))
10093 vty_out(vty
, " %sreceived",
10096 PEER_CAP_DYNAMIC_ADV
)
10099 vty_out(vty
, "\n");
10102 /* Extended nexthop */
10103 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10104 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10105 vty_out(vty
, " Extended nexthop:");
10106 if (CHECK_FLAG(p
->cap
,
10107 PEER_CAP_ENHE_ADV
))
10108 vty_out(vty
, " advertised");
10109 if (CHECK_FLAG(p
->cap
,
10110 PEER_CAP_ENHE_RCV
))
10111 vty_out(vty
, " %sreceived",
10117 vty_out(vty
, "\n");
10119 if (CHECK_FLAG(p
->cap
,
10120 PEER_CAP_ENHE_RCV
)) {
10122 " Address families by peer:\n ");
10123 for (safi
= SAFI_UNICAST
;
10124 safi
< SAFI_MAX
; safi
++)
10129 PEER_CAP_ENHE_AF_RCV
))
10138 /* Route Refresh */
10139 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10140 || CHECK_FLAG(p
->cap
,
10141 PEER_CAP_REFRESH_NEW_RCV
)
10142 || CHECK_FLAG(p
->cap
,
10143 PEER_CAP_REFRESH_OLD_RCV
)) {
10144 vty_out(vty
, " Route refresh:");
10145 if (CHECK_FLAG(p
->cap
,
10146 PEER_CAP_REFRESH_ADV
))
10147 vty_out(vty
, " advertised");
10148 if (CHECK_FLAG(p
->cap
,
10149 PEER_CAP_REFRESH_NEW_RCV
)
10152 PEER_CAP_REFRESH_OLD_RCV
))
10153 vty_out(vty
, " %sreceived(%s)",
10156 PEER_CAP_REFRESH_ADV
)
10161 PEER_CAP_REFRESH_OLD_RCV
)
10164 PEER_CAP_REFRESH_NEW_RCV
))
10168 PEER_CAP_REFRESH_OLD_RCV
)
10172 vty_out(vty
, "\n");
10175 /* Multiprotocol Extensions */
10176 FOREACH_AFI_SAFI (afi
, safi
)
10177 if (p
->afc_adv
[afi
][safi
]
10178 || p
->afc_recv
[afi
][safi
]) {
10180 " Address Family %s:",
10181 afi_safi_print(afi
,
10183 if (p
->afc_adv
[afi
][safi
])
10186 if (p
->afc_recv
[afi
][safi
])
10193 vty_out(vty
, "\n");
10196 /* Hostname capability */
10197 vty_out(vty
, " Hostname Capability:");
10199 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10201 " advertised (name: %s,domain name: %s)",
10202 bgp
->peer_self
->hostname
10206 bgp
->peer_self
->domainname
10211 vty_out(vty
, " not advertised");
10214 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10216 " received (name: %s,domain name: %s)",
10217 p
->hostname
? p
->hostname
10219 p
->domainname
? p
->domainname
10222 vty_out(vty
, " not received");
10225 vty_out(vty
, "\n");
10227 /* Gracefull Restart */
10228 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10229 || CHECK_FLAG(p
->cap
,
10230 PEER_CAP_RESTART_ADV
)) {
10232 " Graceful Restart Capabilty:");
10233 if (CHECK_FLAG(p
->cap
,
10234 PEER_CAP_RESTART_ADV
))
10235 vty_out(vty
, " advertised");
10236 if (CHECK_FLAG(p
->cap
,
10237 PEER_CAP_RESTART_RCV
))
10238 vty_out(vty
, " %sreceived",
10241 PEER_CAP_RESTART_ADV
)
10244 vty_out(vty
, "\n");
10246 if (CHECK_FLAG(p
->cap
,
10247 PEER_CAP_RESTART_RCV
)) {
10248 int restart_af_count
= 0;
10251 " Remote Restart timer is %d seconds\n",
10254 " Address families by peer:\n ");
10256 FOREACH_AFI_SAFI (afi
, safi
)
10261 PEER_CAP_RESTART_AF_RCV
)) {
10274 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10276 : "not preserved");
10277 restart_af_count
++;
10279 if (!restart_af_count
)
10280 vty_out(vty
, "none");
10281 vty_out(vty
, "\n");
10288 /* graceful restart information */
10289 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10290 || p
->t_gr_stale
) {
10291 json_object
*json_grace
= NULL
;
10292 json_object
*json_grace_send
= NULL
;
10293 json_object
*json_grace_recv
= NULL
;
10294 int eor_send_af_count
= 0;
10295 int eor_receive_af_count
= 0;
10298 json_grace
= json_object_new_object();
10299 json_grace_send
= json_object_new_object();
10300 json_grace_recv
= json_object_new_object();
10302 if (p
->status
== Established
) {
10303 FOREACH_AFI_SAFI (afi
, safi
) {
10304 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10305 PEER_STATUS_EOR_SEND
)) {
10306 json_object_boolean_true_add(
10308 afi_safi_print(afi
,
10310 eor_send_af_count
++;
10313 FOREACH_AFI_SAFI (afi
, safi
) {
10315 p
->af_sflags
[afi
][safi
],
10316 PEER_STATUS_EOR_RECEIVED
)) {
10317 json_object_boolean_true_add(
10319 afi_safi_print(afi
,
10321 eor_receive_af_count
++;
10326 json_object_object_add(json_grace
, "endOfRibSend",
10328 json_object_object_add(json_grace
, "endOfRibRecv",
10331 if (p
->t_gr_restart
)
10332 json_object_int_add(json_grace
,
10333 "gracefulRestartTimerMsecs",
10334 thread_timer_remain_second(
10339 json_object_int_add(
10341 "gracefulStalepathTimerMsecs",
10342 thread_timer_remain_second(
10346 json_object_object_add(
10347 json_neigh
, "gracefulRestartInfo", json_grace
);
10349 vty_out(vty
, " Graceful restart information:\n");
10350 if (p
->status
== Established
) {
10351 vty_out(vty
, " End-of-RIB send: ");
10352 FOREACH_AFI_SAFI (afi
, safi
) {
10353 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10354 PEER_STATUS_EOR_SEND
)) {
10355 vty_out(vty
, "%s%s",
10356 eor_send_af_count
? ", "
10358 afi_safi_print(afi
,
10360 eor_send_af_count
++;
10363 vty_out(vty
, "\n");
10364 vty_out(vty
, " End-of-RIB received: ");
10365 FOREACH_AFI_SAFI (afi
, safi
) {
10367 p
->af_sflags
[afi
][safi
],
10368 PEER_STATUS_EOR_RECEIVED
)) {
10369 vty_out(vty
, "%s%s",
10370 eor_receive_af_count
10373 afi_safi_print(afi
,
10375 eor_receive_af_count
++;
10378 vty_out(vty
, "\n");
10381 if (p
->t_gr_restart
)
10383 " The remaining time of restart timer is %ld\n",
10384 thread_timer_remain_second(
10389 " The remaining time of stalepath timer is %ld\n",
10390 thread_timer_remain_second(
10395 json_object
*json_stat
= NULL
;
10396 json_stat
= json_object_new_object();
10397 /* Packet counts. */
10398 json_object_int_add(json_stat
, "depthInq", 0);
10399 json_object_int_add(json_stat
, "depthOutq",
10400 (unsigned long)p
->obuf
->count
);
10401 json_object_int_add(json_stat
, "opensSent",
10402 atomic_load_explicit(&p
->open_out
,
10403 memory_order_relaxed
));
10404 json_object_int_add(json_stat
, "opensRecv",
10405 atomic_load_explicit(&p
->open_in
,
10406 memory_order_relaxed
));
10407 json_object_int_add(json_stat
, "notificationsSent",
10408 atomic_load_explicit(&p
->notify_out
,
10409 memory_order_relaxed
));
10410 json_object_int_add(json_stat
, "notificationsRecv",
10411 atomic_load_explicit(&p
->notify_in
,
10412 memory_order_relaxed
));
10413 json_object_int_add(json_stat
, "updatesSent",
10414 atomic_load_explicit(&p
->update_out
,
10415 memory_order_relaxed
));
10416 json_object_int_add(json_stat
, "updatesRecv",
10417 atomic_load_explicit(&p
->update_in
,
10418 memory_order_relaxed
));
10419 json_object_int_add(json_stat
, "keepalivesSent",
10420 atomic_load_explicit(&p
->keepalive_out
,
10421 memory_order_relaxed
));
10422 json_object_int_add(json_stat
, "keepalivesRecv",
10423 atomic_load_explicit(&p
->keepalive_in
,
10424 memory_order_relaxed
));
10425 json_object_int_add(json_stat
, "routeRefreshSent",
10426 atomic_load_explicit(&p
->refresh_out
,
10427 memory_order_relaxed
));
10428 json_object_int_add(json_stat
, "routeRefreshRecv",
10429 atomic_load_explicit(&p
->refresh_in
,
10430 memory_order_relaxed
));
10431 json_object_int_add(json_stat
, "capabilitySent",
10432 atomic_load_explicit(&p
->dynamic_cap_out
,
10433 memory_order_relaxed
));
10434 json_object_int_add(json_stat
, "capabilityRecv",
10435 atomic_load_explicit(&p
->dynamic_cap_in
,
10436 memory_order_relaxed
));
10437 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10438 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10439 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10441 /* Packet counts. */
10442 vty_out(vty
, " Message statistics:\n");
10443 vty_out(vty
, " Inq depth is 0\n");
10444 vty_out(vty
, " Outq depth is %lu\n",
10445 (unsigned long)p
->obuf
->count
);
10446 vty_out(vty
, " Sent Rcvd\n");
10447 vty_out(vty
, " Opens: %10d %10d\n",
10448 atomic_load_explicit(&p
->open_out
,
10449 memory_order_relaxed
),
10450 atomic_load_explicit(&p
->open_in
,
10451 memory_order_relaxed
));
10452 vty_out(vty
, " Notifications: %10d %10d\n",
10453 atomic_load_explicit(&p
->notify_out
,
10454 memory_order_relaxed
),
10455 atomic_load_explicit(&p
->notify_in
,
10456 memory_order_relaxed
));
10457 vty_out(vty
, " Updates: %10d %10d\n",
10458 atomic_load_explicit(&p
->update_out
,
10459 memory_order_relaxed
),
10460 atomic_load_explicit(&p
->update_in
,
10461 memory_order_relaxed
));
10462 vty_out(vty
, " Keepalives: %10d %10d\n",
10463 atomic_load_explicit(&p
->keepalive_out
,
10464 memory_order_relaxed
),
10465 atomic_load_explicit(&p
->keepalive_in
,
10466 memory_order_relaxed
));
10467 vty_out(vty
, " Route Refresh: %10d %10d\n",
10468 atomic_load_explicit(&p
->refresh_out
,
10469 memory_order_relaxed
),
10470 atomic_load_explicit(&p
->refresh_in
,
10471 memory_order_relaxed
));
10472 vty_out(vty
, " Capability: %10d %10d\n",
10473 atomic_load_explicit(&p
->dynamic_cap_out
,
10474 memory_order_relaxed
),
10475 atomic_load_explicit(&p
->dynamic_cap_in
,
10476 memory_order_relaxed
));
10477 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10482 /* advertisement-interval */
10483 json_object_int_add(json_neigh
,
10484 "minBtwnAdvertisementRunsTimerMsecs",
10485 p
->v_routeadv
* 1000);
10487 /* Update-source. */
10488 if (p
->update_if
|| p
->update_source
) {
10490 json_object_string_add(json_neigh
,
10493 else if (p
->update_source
)
10494 json_object_string_add(
10495 json_neigh
, "updateSource",
10496 sockunion2str(p
->update_source
, buf1
,
10500 /* advertisement-interval */
10502 " Minimum time between advertisement runs is %d seconds\n",
10505 /* Update-source. */
10506 if (p
->update_if
|| p
->update_source
) {
10507 vty_out(vty
, " Update source is ");
10509 vty_out(vty
, "%s", p
->update_if
);
10510 else if (p
->update_source
)
10512 sockunion2str(p
->update_source
, buf1
,
10514 vty_out(vty
, "\n");
10517 vty_out(vty
, "\n");
10520 /* Address Family Information */
10521 json_object
*json_hold
= NULL
;
10524 json_hold
= json_object_new_object();
10526 FOREACH_AFI_SAFI (afi
, safi
)
10527 if (p
->afc
[afi
][safi
])
10528 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10532 json_object_object_add(json_neigh
, "addressFamilyInfo",
10534 json_object_int_add(json_neigh
, "connectionsEstablished",
10536 json_object_int_add(json_neigh
, "connectionsDropped",
10539 vty_out(vty
, " Connections established %d; dropped %d\n",
10540 p
->established
, p
->dropped
);
10542 if (!p
->last_reset
) {
10544 json_object_string_add(json_neigh
, "lastReset",
10547 vty_out(vty
, " Last reset never\n");
10553 uptime
= bgp_clock();
10554 uptime
-= p
->resettime
;
10555 tm
= gmtime(&uptime
);
10556 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10557 (tm
->tm_sec
* 1000)
10558 + (tm
->tm_min
* 60000)
10559 + (tm
->tm_hour
* 3600000));
10560 json_object_string_add(
10561 json_neigh
, "lastResetDueTo",
10562 peer_down_str
[(int)p
->last_reset
]);
10563 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10564 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10565 char errorcodesubcode_hexstr
[5];
10566 char errorcodesubcode_str
[256];
10568 code_str
= bgp_notify_code_str(p
->notify
.code
);
10569 subcode_str
= bgp_notify_subcode_str(
10570 p
->notify
.code
, p
->notify
.subcode
);
10572 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10573 p
->notify
.code
, p
->notify
.subcode
);
10574 json_object_string_add(json_neigh
,
10575 "lastErrorCodeSubcode",
10576 errorcodesubcode_hexstr
);
10577 snprintf(errorcodesubcode_str
, 255, "%s%s",
10578 code_str
, subcode_str
);
10579 json_object_string_add(json_neigh
,
10580 "lastNotificationReason",
10581 errorcodesubcode_str
);
10582 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10583 && p
->notify
.code
== BGP_NOTIFY_CEASE
10584 && (p
->notify
.subcode
10585 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10586 || p
->notify
.subcode
10587 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10588 && p
->notify
.length
) {
10590 const char *msg_str
;
10592 msg_str
= bgp_notify_admin_message(
10593 msgbuf
, sizeof(msgbuf
),
10594 (uint8_t *)p
->notify
.data
,
10597 json_object_string_add(
10599 "lastShutdownDescription",
10604 vty_out(vty
, " Last reset %s, ",
10605 peer_uptime(p
->resettime
, timebuf
,
10606 BGP_UPTIME_LEN
, 0, NULL
));
10608 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10609 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10610 code_str
= bgp_notify_code_str(p
->notify
.code
);
10611 subcode_str
= bgp_notify_subcode_str(
10612 p
->notify
.code
, p
->notify
.subcode
);
10613 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10614 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10617 code_str
, subcode_str
);
10618 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10619 && p
->notify
.code
== BGP_NOTIFY_CEASE
10620 && (p
->notify
.subcode
10621 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10622 || p
->notify
.subcode
10623 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10624 && p
->notify
.length
) {
10626 const char *msg_str
;
10628 msg_str
= bgp_notify_admin_message(
10629 msgbuf
, sizeof(msgbuf
),
10630 (uint8_t *)p
->notify
.data
,
10634 " Message: \"%s\"\n",
10638 vty_out(vty
, "due to %s\n",
10639 peer_down_str
[(int)p
->last_reset
]);
10642 if (p
->last_reset_cause_size
) {
10643 msg
= p
->last_reset_cause
;
10645 " Message received that caused BGP to send a NOTIFICATION:\n ");
10646 for (i
= 1; i
<= p
->last_reset_cause_size
;
10648 vty_out(vty
, "%02X", *msg
++);
10650 if (i
!= p
->last_reset_cause_size
) {
10652 vty_out(vty
, "\n ");
10653 } else if (i
% 4 == 0) {
10658 vty_out(vty
, "\n");
10663 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10665 json_object_boolean_true_add(json_neigh
,
10666 "prefixesConfigExceedMax");
10669 " Peer had exceeded the max. no. of prefixes configured.\n");
10671 if (p
->t_pmax_restart
) {
10673 json_object_boolean_true_add(
10674 json_neigh
, "reducePrefixNumFrom");
10675 json_object_int_add(json_neigh
,
10676 "restartInTimerMsec",
10677 thread_timer_remain_second(
10682 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10683 p
->host
, thread_timer_remain_second(
10684 p
->t_pmax_restart
));
10687 json_object_boolean_true_add(
10689 "reducePrefixNumAndClearIpBgp");
10692 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10697 /* EBGP Multihop and GTSM */
10698 if (p
->sort
!= BGP_PEER_IBGP
) {
10700 if (p
->gtsm_hops
> 0)
10701 json_object_int_add(json_neigh
,
10702 "externalBgpNbrMaxHopsAway",
10704 else if (p
->ttl
> 1)
10705 json_object_int_add(json_neigh
,
10706 "externalBgpNbrMaxHopsAway",
10709 if (p
->gtsm_hops
> 0)
10711 " External BGP neighbor may be up to %d hops away.\n",
10713 else if (p
->ttl
> 1)
10715 " External BGP neighbor may be up to %d hops away.\n",
10719 if (p
->gtsm_hops
> 0) {
10721 json_object_int_add(json_neigh
,
10722 "internalBgpNbrMaxHopsAway",
10726 " Internal BGP neighbor may be up to %d hops away.\n",
10731 /* Local address. */
10734 json_object_string_add(json_neigh
, "hostLocal",
10735 sockunion2str(p
->su_local
, buf1
,
10737 json_object_int_add(json_neigh
, "portLocal",
10738 ntohs(p
->su_local
->sin
.sin_port
));
10740 vty_out(vty
, "Local host: %s, Local port: %d\n",
10741 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10742 ntohs(p
->su_local
->sin
.sin_port
));
10745 /* Remote address. */
10746 if (p
->su_remote
) {
10748 json_object_string_add(json_neigh
, "hostForeign",
10749 sockunion2str(p
->su_remote
, buf1
,
10751 json_object_int_add(json_neigh
, "portForeign",
10752 ntohs(p
->su_remote
->sin
.sin_port
));
10754 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10755 sockunion2str(p
->su_remote
, buf1
,
10757 ntohs(p
->su_remote
->sin
.sin_port
));
10760 /* Nexthop display. */
10763 json_object_string_add(json_neigh
, "nexthop",
10765 &p
->nexthop
.v4
, buf1
,
10767 json_object_string_add(json_neigh
, "nexthopGlobal",
10768 inet_ntop(AF_INET6
,
10769 &p
->nexthop
.v6_global
,
10770 buf1
, sizeof(buf1
)));
10771 json_object_string_add(json_neigh
, "nexthopLocal",
10772 inet_ntop(AF_INET6
,
10773 &p
->nexthop
.v6_local
,
10774 buf1
, sizeof(buf1
)));
10775 if (p
->shared_network
)
10776 json_object_string_add(json_neigh
,
10780 json_object_string_add(json_neigh
,
10782 "nonSharedNetwork");
10784 vty_out(vty
, "Nexthop: %s\n",
10785 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10787 vty_out(vty
, "Nexthop global: %s\n",
10788 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10790 vty_out(vty
, "Nexthop local: %s\n",
10791 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10793 vty_out(vty
, "BGP connection: %s\n",
10794 p
->shared_network
? "shared network"
10795 : "non shared network");
10799 /* Timer information. */
10801 json_object_int_add(json_neigh
, "connectRetryTimer",
10803 if (p
->status
== Established
&& p
->rtt
)
10804 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10807 json_object_int_add(
10808 json_neigh
, "nextStartTimerDueInMsecs",
10809 thread_timer_remain_second(p
->t_start
) * 1000);
10811 json_object_int_add(
10812 json_neigh
, "nextConnectTimerDueInMsecs",
10813 thread_timer_remain_second(p
->t_connect
)
10815 if (p
->t_routeadv
) {
10816 json_object_int_add(json_neigh
, "mraiInterval",
10818 json_object_int_add(
10819 json_neigh
, "mraiTimerExpireInMsecs",
10820 thread_timer_remain_second(p
->t_routeadv
)
10824 json_object_int_add(json_neigh
, "authenticationEnabled",
10828 json_object_string_add(json_neigh
, "readThread", "on");
10830 json_object_string_add(json_neigh
, "readThread", "off");
10832 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10833 json_object_string_add(json_neigh
, "writeThread", "on");
10835 json_object_string_add(json_neigh
, "writeThread",
10838 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10840 if (p
->status
== Established
&& p
->rtt
)
10841 vty_out(vty
, "Estimated round trip time: %d ms\n",
10844 vty_out(vty
, "Next start timer due in %ld seconds\n",
10845 thread_timer_remain_second(p
->t_start
));
10847 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10848 thread_timer_remain_second(p
->t_connect
));
10851 "MRAI (interval %u) timer expires in %ld seconds\n",
10853 thread_timer_remain_second(p
->t_routeadv
));
10855 vty_out(vty
, "Peer Authentication Enabled\n");
10857 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
10858 p
->t_read
? "on" : "off",
10859 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10864 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10865 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10866 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10869 vty_out(vty
, "\n");
10871 /* BFD information. */
10872 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10875 if (p
->conf_if
) /* Configured interface name. */
10876 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10877 else /* Configured IP address. */
10878 json_object_object_add(json
, p
->host
, json_neigh
);
10882 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10883 enum show_type type
, union sockunion
*su
,
10884 const char *conf_if
, bool use_json
,
10887 struct listnode
*node
, *nnode
;
10890 bool nbr_output
= false;
10891 afi_t afi
= AFI_MAX
;
10892 safi_t safi
= SAFI_MAX
;
10894 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
10896 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
10900 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10901 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10906 bgp_show_peer(vty
, peer
, use_json
, json
);
10912 && !strcmp(peer
->conf_if
, conf_if
))
10914 && !strcmp(peer
->hostname
, conf_if
))) {
10916 bgp_show_peer(vty
, peer
, use_json
,
10920 if (sockunion_same(&peer
->su
, su
)) {
10922 bgp_show_peer(vty
, peer
, use_json
,
10927 case show_ipv4_peer
:
10928 case show_ipv6_peer
:
10929 FOREACH_SAFI (safi
) {
10930 if (peer
->afc
[afi
][safi
]) {
10933 && !strcmp(peer
->conf_if
, conf_if
))
10935 && !strcmp(peer
->hostname
, conf_if
))) {
10937 bgp_show_peer(vty
, peer
, use_json
,
10942 if (sockunion_same(&peer
->su
, su
)) {
10944 bgp_show_peer(vty
, peer
, use_json
,
10952 case show_ipv4_all
:
10953 case show_ipv6_all
:
10954 FOREACH_SAFI (safi
) {
10955 if (peer
->afc
[afi
][safi
]) {
10956 bgp_show_peer(vty
, peer
, use_json
, json
);
10965 if ((type
== show_peer
|| type
== show_ipv4_peer
||
10966 type
== show_ipv6_peer
) && !find
) {
10968 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
10970 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
10973 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
10974 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
10975 vty_out(vty
, "%% No BGP neighbors found\n");
10978 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10979 json
, JSON_C_TO_STRING_PRETTY
));
10981 vty_out(vty
, "\n");
10984 return CMD_SUCCESS
;
10987 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
10988 enum show_type type
,
10989 const char *ip_str
,
10992 struct listnode
*node
, *nnode
;
10994 union sockunion su
;
10995 json_object
*json
= NULL
;
10996 int ret
, is_first
= 1;
10997 bool nbr_output
= false;
11000 vty_out(vty
, "{\n");
11002 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11005 if (!(json
= json_object_new_object())) {
11007 EC_BGP_JSON_MEM_ERROR
,
11008 "Unable to allocate memory for JSON object");
11010 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
11014 json_object_int_add(json
, "vrfId",
11015 (bgp
->vrf_id
== VRF_UNKNOWN
)
11017 : (int64_t)bgp
->vrf_id
);
11018 json_object_string_add(
11020 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11025 vty_out(vty
, ",\n");
11029 vty_out(vty
, "\"%s\":",
11030 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11034 vty_out(vty
, "\nInstance %s:\n",
11035 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11040 if (type
== show_peer
|| type
== show_ipv4_peer
||
11041 type
== show_ipv6_peer
) {
11042 ret
= str2sockunion(ip_str
, &su
);
11044 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11047 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11050 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
11053 json_object_free(json
);
11057 vty_out(vty
, "}\n");
11058 json_object_free(json
);
11060 else if (!nbr_output
)
11061 vty_out(vty
, "%% BGP instance not found\n");
11064 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
11065 enum show_type type
, const char *ip_str
,
11070 union sockunion su
;
11071 json_object
*json
= NULL
;
11074 if (strmatch(name
, "all")) {
11075 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
11077 return CMD_SUCCESS
;
11079 bgp
= bgp_lookup_by_name(name
);
11082 json
= json_object_new_object();
11083 vty_out(vty
, "%s\n",
11084 json_object_to_json_string_ext(
11086 JSON_C_TO_STRING_PRETTY
));
11087 json_object_free(json
);
11090 "%% BGP instance not found\n");
11092 return CMD_WARNING
;
11096 bgp
= bgp_get_default();
11100 json
= json_object_new_object();
11102 ret
= str2sockunion(ip_str
, &su
);
11104 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11107 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11110 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
11113 json_object_free(json
);
11116 vty_out(vty
, "{}\n");
11118 vty_out(vty
, "%% BGP instance not found\n");
11121 return CMD_SUCCESS
;
11124 /* "show [ip] bgp neighbors" commands. */
11125 DEFUN (show_ip_bgp_neighbors
,
11126 show_ip_bgp_neighbors_cmd
,
11127 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
11131 BGP_INSTANCE_HELP_STR
11134 "Detailed information on TCP and BGP neighbor connections\n"
11135 "Neighbor to display information about\n"
11136 "Neighbor to display information about\n"
11137 "Neighbor on BGP configured interface\n"
11141 char *sh_arg
= NULL
;
11142 enum show_type sh_type
;
11143 afi_t afi
= AFI_MAX
;
11145 bool uj
= use_json(argc
, argv
);
11149 /* [<vrf> VIEWVRFNAME] */
11150 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11151 vrf
= argv
[idx
+ 1]->arg
;
11152 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11154 } else if (argv_find(argv
, argc
, "view", &idx
))
11155 /* [<view> VIEWVRFNAME] */
11156 vrf
= argv
[idx
+ 1]->arg
;
11160 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
11161 sh_type
= show_ipv4_all
;
11163 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
11164 sh_type
= show_ipv6_all
;
11167 sh_type
= show_all
;
11170 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
11171 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
11172 || argv_find(argv
, argc
, "WORD", &idx
)) {
11173 sh_type
= show_peer
;
11174 sh_arg
= argv
[idx
]->arg
;
11177 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
11178 sh_type
= show_ipv4_peer
;
11179 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
11180 sh_type
= show_ipv6_peer
;
11183 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
11186 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
11187 paths' and `show ip mbgp paths'. Those functions results are the
11189 DEFUN (show_ip_bgp_paths
,
11190 show_ip_bgp_paths_cmd
,
11191 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
11196 "Path information\n")
11198 vty_out(vty
, "Address Refcnt Path\n");
11199 aspath_print_all_vty(vty
);
11200 return CMD_SUCCESS
;
11205 static void community_show_all_iterator(struct hash_bucket
*bucket
,
11208 struct community
*com
;
11210 com
= (struct community
*)bucket
->data
;
11211 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
11212 community_str(com
, false));
11215 /* Show BGP's community internal data. */
11216 DEFUN (show_ip_bgp_community_info
,
11217 show_ip_bgp_community_info_cmd
,
11218 "show [ip] bgp community-info",
11222 "List all bgp community information\n")
11224 vty_out(vty
, "Address Refcnt Community\n");
11226 hash_iterate(community_hash(),
11227 (void (*)(struct hash_bucket
*,
11228 void *))community_show_all_iterator
,
11231 return CMD_SUCCESS
;
11234 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
11237 struct lcommunity
*lcom
;
11239 lcom
= (struct lcommunity
*)bucket
->data
;
11240 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11241 lcommunity_str(lcom
, false));
11244 /* Show BGP's community internal data. */
11245 DEFUN (show_ip_bgp_lcommunity_info
,
11246 show_ip_bgp_lcommunity_info_cmd
,
11247 "show ip bgp large-community-info",
11251 "List all bgp large-community information\n")
11253 vty_out(vty
, "Address Refcnt Large-community\n");
11255 hash_iterate(lcommunity_hash(),
11256 (void (*)(struct hash_bucket
*,
11257 void *))lcommunity_show_all_iterator
,
11260 return CMD_SUCCESS
;
11264 DEFUN (show_ip_bgp_attr_info
,
11265 show_ip_bgp_attr_info_cmd
,
11266 "show [ip] bgp attribute-info",
11270 "List all bgp attribute information\n")
11272 attr_show_all(vty
);
11273 return CMD_SUCCESS
;
11276 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
11277 afi_t afi
, safi_t safi
,
11278 bool use_json
, json_object
*json
)
11281 struct listnode
*node
;
11283 char buf1
[INET6_ADDRSTRLEN
];
11285 vpn_policy_direction_t dir
;
11288 json_object
*json_import_vrfs
= NULL
;
11289 json_object
*json_export_vrfs
= NULL
;
11291 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11294 vty_out(vty
, "%s\n",
11295 json_object_to_json_string_ext(
11297 JSON_C_TO_STRING_PRETTY
));
11298 json_object_free(json
);
11300 return CMD_WARNING
;
11303 /* Provide context for the block */
11304 json_object_string_add(json
, "vrf", name
? name
: "default");
11305 json_object_string_add(json
, "afiSafi",
11306 afi_safi_print(afi
, safi
));
11308 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11309 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11310 json_object_string_add(json
, "importFromVrfs", "none");
11311 json_object_string_add(json
, "importRts", "none");
11313 json_import_vrfs
= json_object_new_array();
11315 for (ALL_LIST_ELEMENTS_RO(
11316 bgp
->vpn_policy
[afi
].import_vrf
,
11318 json_object_array_add(json_import_vrfs
,
11319 json_object_new_string(vname
));
11321 json_object_object_add(json
, "importFromVrfs",
11323 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11324 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11325 ecom_str
= ecommunity_ecom2str(
11326 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11327 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11328 json_object_string_add(json
, "importRts",
11330 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11332 json_object_string_add(json
, "importRts",
11336 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11337 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11338 json_object_string_add(json
, "exportToVrfs", "none");
11339 json_object_string_add(json
, "routeDistinguisher",
11341 json_object_string_add(json
, "exportRts", "none");
11343 json_export_vrfs
= json_object_new_array();
11345 for (ALL_LIST_ELEMENTS_RO(
11346 bgp
->vpn_policy
[afi
].export_vrf
,
11348 json_object_array_add(json_export_vrfs
,
11349 json_object_new_string(vname
));
11350 json_object_object_add(json
, "exportToVrfs",
11352 json_object_string_add(json
, "routeDistinguisher",
11353 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11354 buf1
, RD_ADDRSTRLEN
));
11356 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11357 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11358 ecom_str
= ecommunity_ecom2str(
11359 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11360 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11361 json_object_string_add(json
, "exportRts",
11363 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11365 json_object_string_add(json
, "exportRts",
11370 vty_out(vty
, "%s\n",
11371 json_object_to_json_string_ext(json
,
11372 JSON_C_TO_STRING_PRETTY
));
11373 json_object_free(json
);
11376 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11379 vty_out(vty
, "%% No such BGP instance exist\n");
11380 return CMD_WARNING
;
11383 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11384 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11386 "This VRF is not importing %s routes from any other VRF\n",
11387 afi_safi_print(afi
, safi
));
11390 "This VRF is importing %s routes from the following VRFs:\n",
11391 afi_safi_print(afi
, safi
));
11393 for (ALL_LIST_ELEMENTS_RO(
11394 bgp
->vpn_policy
[afi
].import_vrf
,
11396 vty_out(vty
, " %s\n", vname
);
11398 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11400 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11401 ecom_str
= ecommunity_ecom2str(
11402 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11403 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11404 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11406 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11408 vty_out(vty
, "Import RT(s):\n");
11411 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11412 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11414 "This VRF is not exporting %s routes to any other VRF\n",
11415 afi_safi_print(afi
, safi
));
11418 "This VRF is exporting %s routes to the following VRFs:\n",
11419 afi_safi_print(afi
, safi
));
11421 for (ALL_LIST_ELEMENTS_RO(
11422 bgp
->vpn_policy
[afi
].export_vrf
,
11424 vty_out(vty
, " %s\n", vname
);
11426 vty_out(vty
, "RD: %s\n",
11427 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11428 buf1
, RD_ADDRSTRLEN
));
11430 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11431 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11432 ecom_str
= ecommunity_ecom2str(
11433 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11434 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11435 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11436 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11438 vty_out(vty
, "Import RT(s):\n");
11442 return CMD_SUCCESS
;
11445 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
11446 safi_t safi
, bool use_json
)
11448 struct listnode
*node
, *nnode
;
11450 char *vrf_name
= NULL
;
11451 json_object
*json
= NULL
;
11452 json_object
*json_vrf
= NULL
;
11453 json_object
*json_vrfs
= NULL
;
11456 json
= json_object_new_object();
11457 json_vrfs
= json_object_new_object();
11460 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11462 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
11463 vrf_name
= bgp
->name
;
11466 json_vrf
= json_object_new_object();
11468 vty_out(vty
, "\nInstance %s:\n",
11469 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11470 ? VRF_DEFAULT_NAME
: bgp
->name
);
11472 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
11474 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11475 json_object_object_add(json_vrfs
,
11476 VRF_DEFAULT_NAME
, json_vrf
);
11478 json_object_object_add(json_vrfs
, vrf_name
,
11484 json_object_object_add(json
, "vrfs", json_vrfs
);
11485 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
11486 JSON_C_TO_STRING_PRETTY
));
11487 json_object_free(json
);
11490 return CMD_SUCCESS
;
11493 /* "show [ip] bgp route-leak" command. */
11494 DEFUN (show_ip_bgp_route_leak
,
11495 show_ip_bgp_route_leak_cmd
,
11496 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11500 BGP_INSTANCE_HELP_STR
11503 "Route leaking information\n"
11507 afi_t afi
= AFI_MAX
;
11508 safi_t safi
= SAFI_MAX
;
11510 bool uj
= use_json(argc
, argv
);
11512 json_object
*json
= NULL
;
11514 /* show [ip] bgp */
11515 if (argv_find(argv
, argc
, "ip", &idx
)) {
11517 safi
= SAFI_UNICAST
;
11519 /* [vrf VIEWVRFNAME] */
11520 if (argv_find(argv
, argc
, "view", &idx
)) {
11522 "%% This command is not applicable to BGP views\n");
11523 return CMD_WARNING
;
11526 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11527 vrf
= argv
[idx
+ 1]->arg
;
11528 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11531 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11532 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11533 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11536 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11538 "%% This command is applicable only for unicast ipv4|ipv6\n");
11539 return CMD_WARNING
;
11542 if (vrf
&& strmatch(vrf
, "all"))
11543 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
11546 json
= json_object_new_object();
11548 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
11551 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11554 struct listnode
*node
, *nnode
;
11557 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11558 vty_out(vty
, "\nInstance %s:\n",
11559 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11562 update_group_show(bgp
, afi
, safi
, vty
, 0);
11566 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11567 int safi
, uint64_t subgrp_id
)
11572 if (strmatch(name
, "all")) {
11573 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11574 return CMD_SUCCESS
;
11576 bgp
= bgp_lookup_by_name(name
);
11579 bgp
= bgp_get_default();
11583 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11584 return CMD_SUCCESS
;
11587 DEFUN (show_ip_bgp_updgrps
,
11588 show_ip_bgp_updgrps_cmd
,
11589 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11593 BGP_INSTANCE_HELP_STR
11595 BGP_SAFI_WITH_LABEL_HELP_STR
11596 "Detailed info about dynamic update groups\n"
11597 "Specific subgroup to display detailed info for\n")
11600 afi_t afi
= AFI_IP6
;
11601 safi_t safi
= SAFI_UNICAST
;
11602 uint64_t subgrp_id
= 0;
11606 /* show [ip] bgp */
11607 if (argv_find(argv
, argc
, "ip", &idx
))
11609 /* [<vrf> VIEWVRFNAME] */
11610 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11611 vrf
= argv
[idx
+ 1]->arg
;
11612 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11614 } else if (argv_find(argv
, argc
, "view", &idx
))
11615 /* [<view> VIEWVRFNAME] */
11616 vrf
= argv
[idx
+ 1]->arg
;
11617 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11618 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11619 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11622 /* get subgroup id, if provided */
11624 if (argv
[idx
]->type
== VARIABLE_TKN
)
11625 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11627 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11630 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11631 show_bgp_instance_all_ipv6_updgrps_cmd
,
11632 "show [ip] bgp <view|vrf> all update-groups",
11636 BGP_INSTANCE_ALL_HELP_STR
11637 "Detailed info about dynamic update groups\n")
11639 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11640 return CMD_SUCCESS
;
11643 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
11644 show_bgp_l2vpn_evpn_updgrps_cmd
,
11645 "show [ip] bgp l2vpn evpn update-groups",
11649 "l2vpn address family\n"
11650 "evpn sub-address family\n"
11651 "Detailed info about dynamic update groups\n")
11654 uint64_t subgrp_id
= 0;
11656 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
11657 return CMD_SUCCESS
;
11660 DEFUN (show_bgp_updgrps_stats
,
11661 show_bgp_updgrps_stats_cmd
,
11662 "show [ip] bgp update-groups statistics",
11666 "Detailed info about dynamic update groups\n"
11671 bgp
= bgp_get_default();
11673 update_group_show_stats(bgp
, vty
);
11675 return CMD_SUCCESS
;
11678 DEFUN (show_bgp_instance_updgrps_stats
,
11679 show_bgp_instance_updgrps_stats_cmd
,
11680 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11684 BGP_INSTANCE_HELP_STR
11685 "Detailed info about dynamic update groups\n"
11691 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11693 update_group_show_stats(bgp
, vty
);
11695 return CMD_SUCCESS
;
11698 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11699 afi_t afi
, safi_t safi
,
11700 const char *what
, uint64_t subgrp_id
)
11705 bgp
= bgp_lookup_by_name(name
);
11707 bgp
= bgp_get_default();
11710 if (!strcmp(what
, "advertise-queue"))
11711 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11713 else if (!strcmp(what
, "advertised-routes"))
11714 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11716 else if (!strcmp(what
, "packet-queue"))
11717 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11722 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11723 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11724 "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",
11725 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11727 "Detailed info about dynamic update groups\n"
11728 "Specific subgroup to display info for\n"
11729 "Advertisement queue\n"
11730 "Announced routes\n"
11733 uint64_t subgrp_id
= 0;
11737 subgrp_id
= strtoull(sgid
, NULL
, 10);
11742 afiz
= bgp_vty_afi_from_str(afi
);
11746 afiz
= bgp_vty_afi_from_str(afi
);
11747 if (afiz
!= AFI_IP
)
11749 "%% Cannot specify both 'ip' and 'ipv6'\n");
11750 return CMD_WARNING
;
11753 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11755 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11756 return CMD_SUCCESS
;
11759 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11761 struct listnode
*node
, *nnode
;
11762 struct prefix
*range
;
11765 char buf
[PREFIX2STR_BUFFER
];
11768 const char *peer_status
;
11769 const char *af_str
;
11774 conf
= group
->conf
;
11776 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11777 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11778 group
->name
, conf
->as
);
11779 } else if (conf
->as_type
== AS_INTERNAL
) {
11780 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11781 group
->name
, group
->bgp
->as
);
11783 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11786 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11787 vty_out(vty
, " Peer-group type is internal\n");
11789 vty_out(vty
, " Peer-group type is external\n");
11791 /* Display AFs configured. */
11792 vty_out(vty
, " Configured address-families:");
11793 FOREACH_AFI_SAFI (afi
, safi
) {
11794 if (conf
->afc
[afi
][safi
]) {
11796 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11800 vty_out(vty
, " none\n");
11802 vty_out(vty
, "\n");
11804 /* Display listen ranges (for dynamic neighbors), if any */
11805 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11808 else if (afi
== AFI_IP6
)
11812 lr_count
= listcount(group
->listen_range
[afi
]);
11814 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11818 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11820 prefix2str(range
, buf
, sizeof(buf
));
11821 vty_out(vty
, " %s\n", buf
);
11826 /* Display group members and their status */
11827 if (listcount(group
->peer
)) {
11828 vty_out(vty
, " Peer-group members:\n");
11829 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11830 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11831 peer_status
= "Idle (Admin)";
11832 else if (CHECK_FLAG(peer
->sflags
,
11833 PEER_STATUS_PREFIX_OVERFLOW
))
11834 peer_status
= "Idle (PfxCt)";
11836 peer_status
= lookup_msg(bgp_status_msg
,
11837 peer
->status
, NULL
);
11839 dynamic
= peer_dynamic_neighbor(peer
);
11840 vty_out(vty
, " %s %s %s \n", peer
->host
,
11841 dynamic
? "(dynamic)" : "", peer_status
);
11845 return CMD_SUCCESS
;
11848 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11849 const char *group_name
)
11852 struct listnode
*node
, *nnode
;
11853 struct peer_group
*group
;
11854 bool found
= false;
11856 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11859 vty_out(vty
, "%% BGP instance not found\n");
11860 return CMD_WARNING
;
11863 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11865 if (strmatch(group
->name
, group_name
)) {
11866 bgp_show_one_peer_group(vty
, group
);
11871 bgp_show_one_peer_group(vty
, group
);
11875 if (group_name
&& !found
)
11876 vty_out(vty
, "%% No such peer-group\n");
11878 return CMD_SUCCESS
;
11881 DEFUN (show_ip_bgp_peer_groups
,
11882 show_ip_bgp_peer_groups_cmd
,
11883 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11887 BGP_INSTANCE_HELP_STR
11888 "Detailed information on BGP peer groups\n"
11889 "Peer group name\n")
11894 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11896 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11898 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11902 /* Redistribute VTY commands. */
11904 DEFUN (bgp_redistribute_ipv4
,
11905 bgp_redistribute_ipv4_cmd
,
11906 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11907 "Redistribute information from another routing protocol\n"
11908 FRR_IP_REDIST_HELP_STR_BGPD
)
11910 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11911 int idx_protocol
= 1;
11914 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11916 vty_out(vty
, "%% Invalid route type\n");
11917 return CMD_WARNING_CONFIG_FAILED
;
11920 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11921 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
11925 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11926 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11927 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11929 DEFUN (bgp_redistribute_ipv4_rmap
,
11930 bgp_redistribute_ipv4_rmap_cmd
,
11931 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11932 "Redistribute information from another routing protocol\n"
11933 FRR_IP_REDIST_HELP_STR_BGPD
11934 "Route map reference\n"
11935 "Pointer to route-map entries\n")
11937 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11938 int idx_protocol
= 1;
11941 struct bgp_redist
*red
;
11943 struct route_map
*route_map
= route_map_lookup_warn_noexist(
11944 vty
, argv
[idx_word
]->arg
);
11946 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11948 vty_out(vty
, "%% Invalid route type\n");
11949 return CMD_WARNING_CONFIG_FAILED
;
11952 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11954 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
11955 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11959 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
11960 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11961 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11962 "Route map reference\n"
11963 "Pointer to route-map entries\n")
11965 DEFUN (bgp_redistribute_ipv4_metric
,
11966 bgp_redistribute_ipv4_metric_cmd
,
11967 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11968 "Redistribute information from another routing protocol\n"
11969 FRR_IP_REDIST_HELP_STR_BGPD
11970 "Metric for redistributed routes\n"
11971 "Default metric\n")
11973 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11974 int idx_protocol
= 1;
11975 int idx_number
= 3;
11978 struct bgp_redist
*red
;
11981 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11983 vty_out(vty
, "%% Invalid route type\n");
11984 return CMD_WARNING_CONFIG_FAILED
;
11986 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11988 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11989 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11990 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11994 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
11995 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11996 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11997 "Metric for redistributed routes\n"
11998 "Default metric\n")
12000 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
12001 bgp_redistribute_ipv4_rmap_metric_cmd
,
12002 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12003 "Redistribute information from another routing protocol\n"
12004 FRR_IP_REDIST_HELP_STR_BGPD
12005 "Route map reference\n"
12006 "Pointer to route-map entries\n"
12007 "Metric for redistributed routes\n"
12008 "Default metric\n")
12010 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12011 int idx_protocol
= 1;
12013 int idx_number
= 5;
12016 struct bgp_redist
*red
;
12018 struct route_map
*route_map
=
12019 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12021 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12023 vty_out(vty
, "%% Invalid route type\n");
12024 return CMD_WARNING_CONFIG_FAILED
;
12026 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12028 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12030 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12031 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12032 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12036 bgp_redistribute_ipv4_rmap_metric
,
12037 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
12038 "redistribute " FRR_IP_REDIST_STR_BGPD
12039 " route-map WORD metric (0-4294967295)",
12040 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12041 "Route map reference\n"
12042 "Pointer to route-map entries\n"
12043 "Metric for redistributed routes\n"
12044 "Default metric\n")
12046 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
12047 bgp_redistribute_ipv4_metric_rmap_cmd
,
12048 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12049 "Redistribute information from another routing protocol\n"
12050 FRR_IP_REDIST_HELP_STR_BGPD
12051 "Metric for redistributed routes\n"
12053 "Route map reference\n"
12054 "Pointer to route-map entries\n")
12056 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12057 int idx_protocol
= 1;
12058 int idx_number
= 3;
12062 struct bgp_redist
*red
;
12064 struct route_map
*route_map
=
12065 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12067 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12069 vty_out(vty
, "%% Invalid route type\n");
12070 return CMD_WARNING_CONFIG_FAILED
;
12072 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12074 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12075 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12077 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12078 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12082 bgp_redistribute_ipv4_metric_rmap
,
12083 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
12084 "redistribute " FRR_IP_REDIST_STR_BGPD
12085 " metric (0-4294967295) route-map WORD",
12086 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12087 "Metric for redistributed routes\n"
12089 "Route map reference\n"
12090 "Pointer to route-map entries\n")
12092 DEFUN (bgp_redistribute_ipv4_ospf
,
12093 bgp_redistribute_ipv4_ospf_cmd
,
12094 "redistribute <ospf|table> (1-65535)",
12095 "Redistribute information from another routing protocol\n"
12096 "Open Shortest Path First (OSPFv2)\n"
12097 "Non-main Kernel Routing Table\n"
12098 "Instance ID/Table ID\n")
12100 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12101 int idx_ospf_table
= 1;
12102 int idx_number
= 2;
12103 unsigned short instance
;
12104 unsigned short protocol
;
12106 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12108 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12109 protocol
= ZEBRA_ROUTE_OSPF
;
12111 protocol
= ZEBRA_ROUTE_TABLE
;
12113 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12114 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
12117 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
12118 "redistribute <ospf|table> (1-65535)",
12119 "Redistribute information from another routing protocol\n"
12120 "Open Shortest Path First (OSPFv2)\n"
12121 "Non-main Kernel Routing Table\n"
12122 "Instance ID/Table ID\n")
12124 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
12125 bgp_redistribute_ipv4_ospf_rmap_cmd
,
12126 "redistribute <ospf|table> (1-65535) route-map WORD",
12127 "Redistribute information from another routing protocol\n"
12128 "Open Shortest Path First (OSPFv2)\n"
12129 "Non-main Kernel Routing Table\n"
12130 "Instance ID/Table ID\n"
12131 "Route map reference\n"
12132 "Pointer to route-map entries\n")
12134 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12135 int idx_ospf_table
= 1;
12136 int idx_number
= 2;
12138 struct bgp_redist
*red
;
12139 unsigned short instance
;
12142 struct route_map
*route_map
=
12143 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12145 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12146 protocol
= ZEBRA_ROUTE_OSPF
;
12148 protocol
= ZEBRA_ROUTE_TABLE
;
12150 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12151 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12153 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12154 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12157 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
12158 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
12159 "redistribute <ospf|table> (1-65535) route-map WORD",
12160 "Redistribute information from another routing protocol\n"
12161 "Open Shortest Path First (OSPFv2)\n"
12162 "Non-main Kernel Routing Table\n"
12163 "Instance ID/Table ID\n"
12164 "Route map reference\n"
12165 "Pointer to route-map entries\n")
12167 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
12168 bgp_redistribute_ipv4_ospf_metric_cmd
,
12169 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12170 "Redistribute information from another routing protocol\n"
12171 "Open Shortest Path First (OSPFv2)\n"
12172 "Non-main Kernel Routing Table\n"
12173 "Instance ID/Table ID\n"
12174 "Metric for redistributed routes\n"
12175 "Default metric\n")
12177 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12178 int idx_ospf_table
= 1;
12179 int idx_number
= 2;
12180 int idx_number_2
= 4;
12182 struct bgp_redist
*red
;
12183 unsigned short instance
;
12187 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12188 protocol
= ZEBRA_ROUTE_OSPF
;
12190 protocol
= ZEBRA_ROUTE_TABLE
;
12192 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12193 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12195 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12196 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12198 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12201 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
12202 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
12203 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12204 "Redistribute information from another routing protocol\n"
12205 "Open Shortest Path First (OSPFv2)\n"
12206 "Non-main Kernel Routing Table\n"
12207 "Instance ID/Table ID\n"
12208 "Metric for redistributed routes\n"
12209 "Default metric\n")
12211 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
12212 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
12213 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12214 "Redistribute information from another routing protocol\n"
12215 "Open Shortest Path First (OSPFv2)\n"
12216 "Non-main Kernel Routing Table\n"
12217 "Instance ID/Table ID\n"
12218 "Route map reference\n"
12219 "Pointer to route-map entries\n"
12220 "Metric for redistributed routes\n"
12221 "Default metric\n")
12223 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12224 int idx_ospf_table
= 1;
12225 int idx_number
= 2;
12227 int idx_number_2
= 6;
12229 struct bgp_redist
*red
;
12230 unsigned short instance
;
12233 struct route_map
*route_map
=
12234 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12236 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12237 protocol
= ZEBRA_ROUTE_OSPF
;
12239 protocol
= ZEBRA_ROUTE_TABLE
;
12241 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12242 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12244 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12246 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12247 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12249 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12253 bgp_redistribute_ipv4_ospf_rmap_metric
,
12254 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
12255 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12256 "Redistribute information from another routing protocol\n"
12257 "Open Shortest Path First (OSPFv2)\n"
12258 "Non-main Kernel Routing Table\n"
12259 "Instance ID/Table ID\n"
12260 "Route map reference\n"
12261 "Pointer to route-map entries\n"
12262 "Metric for redistributed routes\n"
12263 "Default metric\n")
12265 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
12266 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
12267 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12268 "Redistribute information from another routing protocol\n"
12269 "Open Shortest Path First (OSPFv2)\n"
12270 "Non-main Kernel Routing Table\n"
12271 "Instance ID/Table ID\n"
12272 "Metric for redistributed routes\n"
12274 "Route map reference\n"
12275 "Pointer to route-map entries\n")
12277 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12278 int idx_ospf_table
= 1;
12279 int idx_number
= 2;
12280 int idx_number_2
= 4;
12283 struct bgp_redist
*red
;
12284 unsigned short instance
;
12287 struct route_map
*route_map
=
12288 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12290 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12291 protocol
= ZEBRA_ROUTE_OSPF
;
12293 protocol
= ZEBRA_ROUTE_TABLE
;
12295 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12296 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12298 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12299 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12302 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12303 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12307 bgp_redistribute_ipv4_ospf_metric_rmap
,
12308 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
12309 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12310 "Redistribute information from another routing protocol\n"
12311 "Open Shortest Path First (OSPFv2)\n"
12312 "Non-main Kernel Routing Table\n"
12313 "Instance ID/Table ID\n"
12314 "Metric for redistributed routes\n"
12316 "Route map reference\n"
12317 "Pointer to route-map entries\n")
12319 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12320 no_bgp_redistribute_ipv4_ospf_cmd
,
12321 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
12323 "Redistribute information from another routing protocol\n"
12324 "Open Shortest Path First (OSPFv2)\n"
12325 "Non-main Kernel Routing Table\n"
12326 "Instance ID/Table ID\n"
12327 "Metric for redistributed routes\n"
12329 "Route map reference\n"
12330 "Pointer to route-map entries\n")
12332 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12333 int idx_ospf_table
= 2;
12334 int idx_number
= 3;
12335 unsigned short instance
;
12338 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12339 protocol
= ZEBRA_ROUTE_OSPF
;
12341 protocol
= ZEBRA_ROUTE_TABLE
;
12343 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12344 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12348 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12349 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
12351 "Redistribute information from another routing protocol\n"
12352 "Open Shortest Path First (OSPFv2)\n"
12353 "Non-main Kernel Routing Table\n"
12354 "Instance ID/Table ID\n"
12355 "Metric for redistributed routes\n"
12357 "Route map reference\n"
12358 "Pointer to route-map entries\n")
12360 DEFUN (no_bgp_redistribute_ipv4
,
12361 no_bgp_redistribute_ipv4_cmd
,
12362 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
12364 "Redistribute information from another routing protocol\n"
12365 FRR_IP_REDIST_HELP_STR_BGPD
12366 "Metric for redistributed routes\n"
12368 "Route map reference\n"
12369 "Pointer to route-map entries\n")
12371 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12372 int idx_protocol
= 2;
12375 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12377 vty_out(vty
, "%% Invalid route type\n");
12378 return CMD_WARNING_CONFIG_FAILED
;
12380 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12384 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12385 "no redistribute " FRR_IP_REDIST_STR_BGPD
12386 " [{metric (0-4294967295)|route-map WORD}]",
12388 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12389 "Metric for redistributed routes\n"
12391 "Route map reference\n"
12392 "Pointer to route-map entries\n")
12394 DEFUN (bgp_redistribute_ipv6
,
12395 bgp_redistribute_ipv6_cmd
,
12396 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12397 "Redistribute information from another routing protocol\n"
12398 FRR_IP6_REDIST_HELP_STR_BGPD
)
12400 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12401 int idx_protocol
= 1;
12404 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12406 vty_out(vty
, "%% Invalid route type\n");
12407 return CMD_WARNING_CONFIG_FAILED
;
12410 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12411 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12414 DEFUN (bgp_redistribute_ipv6_rmap
,
12415 bgp_redistribute_ipv6_rmap_cmd
,
12416 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12417 "Redistribute information from another routing protocol\n"
12418 FRR_IP6_REDIST_HELP_STR_BGPD
12419 "Route map reference\n"
12420 "Pointer to route-map entries\n")
12422 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12423 int idx_protocol
= 1;
12426 struct bgp_redist
*red
;
12428 struct route_map
*route_map
=
12429 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12431 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12433 vty_out(vty
, "%% Invalid route type\n");
12434 return CMD_WARNING_CONFIG_FAILED
;
12437 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12439 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12440 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12443 DEFUN (bgp_redistribute_ipv6_metric
,
12444 bgp_redistribute_ipv6_metric_cmd
,
12445 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12446 "Redistribute information from another routing protocol\n"
12447 FRR_IP6_REDIST_HELP_STR_BGPD
12448 "Metric for redistributed routes\n"
12449 "Default metric\n")
12451 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12452 int idx_protocol
= 1;
12453 int idx_number
= 3;
12456 struct bgp_redist
*red
;
12459 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12461 vty_out(vty
, "%% Invalid route type\n");
12462 return CMD_WARNING_CONFIG_FAILED
;
12464 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12466 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12467 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12468 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12471 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12472 bgp_redistribute_ipv6_rmap_metric_cmd
,
12473 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12474 "Redistribute information from another routing protocol\n"
12475 FRR_IP6_REDIST_HELP_STR_BGPD
12476 "Route map reference\n"
12477 "Pointer to route-map entries\n"
12478 "Metric for redistributed routes\n"
12479 "Default metric\n")
12481 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12482 int idx_protocol
= 1;
12484 int idx_number
= 5;
12487 struct bgp_redist
*red
;
12489 struct route_map
*route_map
=
12490 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12492 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12494 vty_out(vty
, "%% Invalid route type\n");
12495 return CMD_WARNING_CONFIG_FAILED
;
12497 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12499 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12501 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12502 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12504 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12507 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12508 bgp_redistribute_ipv6_metric_rmap_cmd
,
12509 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12510 "Redistribute information from another routing protocol\n"
12511 FRR_IP6_REDIST_HELP_STR_BGPD
12512 "Metric for redistributed routes\n"
12514 "Route map reference\n"
12515 "Pointer to route-map entries\n")
12517 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12518 int idx_protocol
= 1;
12519 int idx_number
= 3;
12523 struct bgp_redist
*red
;
12525 struct route_map
*route_map
=
12526 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12528 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12530 vty_out(vty
, "%% Invalid route type\n");
12531 return CMD_WARNING_CONFIG_FAILED
;
12533 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12535 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12536 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12539 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12540 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12543 DEFUN (no_bgp_redistribute_ipv6
,
12544 no_bgp_redistribute_ipv6_cmd
,
12545 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
12547 "Redistribute information from another routing protocol\n"
12548 FRR_IP6_REDIST_HELP_STR_BGPD
12549 "Metric for redistributed routes\n"
12551 "Route map reference\n"
12552 "Pointer to route-map entries\n")
12554 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12555 int idx_protocol
= 2;
12558 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12560 vty_out(vty
, "%% Invalid route type\n");
12561 return CMD_WARNING_CONFIG_FAILED
;
12564 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12567 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12572 /* Unicast redistribution only. */
12573 if (safi
!= SAFI_UNICAST
)
12576 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12577 /* Redistribute BGP does not make sense. */
12578 if (i
!= ZEBRA_ROUTE_BGP
) {
12579 struct list
*red_list
;
12580 struct listnode
*node
;
12581 struct bgp_redist
*red
;
12583 red_list
= bgp
->redist
[afi
][i
];
12587 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12588 /* "redistribute" configuration. */
12589 vty_out(vty
, " redistribute %s",
12590 zebra_route_string(i
));
12592 vty_out(vty
, " %d", red
->instance
);
12593 if (red
->redist_metric_flag
)
12594 vty_out(vty
, " metric %u",
12595 red
->redist_metric
);
12596 if (red
->rmap
.name
)
12597 vty_out(vty
, " route-map %s",
12599 vty_out(vty
, "\n");
12605 /* This is part of the address-family block (unicast only) */
12606 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12611 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12612 if (listcount(bgp
->vpn_policy
[afi
].import_vrf
))
12613 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12614 bgp
->vpn_policy
[afi
]
12615 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12617 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
12618 bgp
->vpn_policy
[afi
]
12619 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12621 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12622 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12623 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12624 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12627 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12628 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12630 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12633 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12634 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12635 bgp
->vpn_policy
[afi
].tovpn_label
);
12638 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12639 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12640 char buf
[RD_ADDRSTRLEN
];
12641 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12642 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12645 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12646 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12648 char buf
[PREFIX_STRLEN
];
12649 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12650 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12653 vty_out(vty
, "%*snexthop vpn export %s\n",
12657 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12658 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12660 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12661 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12663 char *b
= ecommunity_ecom2str(
12664 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12665 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12666 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12667 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12669 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12670 char *b
= ecommunity_ecom2str(
12671 bgp
->vpn_policy
[afi
]
12672 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12673 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12674 ECOMMUNITY_ROUTE_TARGET
);
12675 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12676 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12678 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12679 char *b
= ecommunity_ecom2str(
12680 bgp
->vpn_policy
[afi
]
12681 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12682 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12683 ECOMMUNITY_ROUTE_TARGET
);
12684 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12685 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12689 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12690 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12691 bgp
->vpn_policy
[afi
]
12692 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12694 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12695 char *b
= ecommunity_ecom2str(
12696 bgp
->vpn_policy
[afi
]
12697 .import_redirect_rtlist
,
12698 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12699 ECOMMUNITY_ROUTE_TARGET
);
12701 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12702 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12707 /* BGP node structure. */
12708 static struct cmd_node bgp_node
= {
12709 BGP_NODE
, "%s(config-router)# ", 1,
12712 static struct cmd_node bgp_ipv4_unicast_node
= {
12713 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12716 static struct cmd_node bgp_ipv4_multicast_node
= {
12717 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12720 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12721 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12724 static struct cmd_node bgp_ipv6_unicast_node
= {
12725 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12728 static struct cmd_node bgp_ipv6_multicast_node
= {
12729 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12732 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12733 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12736 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12737 "%s(config-router-af)# ", 1};
12739 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12740 "%s(config-router-af-vpnv6)# ", 1};
12742 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12743 "%s(config-router-evpn)# ", 1};
12745 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12746 "%s(config-router-af-vni)# ", 1};
12748 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12749 "%s(config-router-af)# ", 1};
12751 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12752 "%s(config-router-af-vpnv6)# ", 1};
12754 static void community_list_vty(void);
12756 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12760 struct listnode
*lnbgp
, *lnpeer
;
12762 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12763 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12764 /* only provide suggestions on the appropriate input
12766 * they'll otherwise show up multiple times */
12767 enum cmd_token_type match_type
;
12768 char *name
= peer
->host
;
12770 if (peer
->conf_if
) {
12771 match_type
= VARIABLE_TKN
;
12772 name
= peer
->conf_if
;
12773 } else if (strchr(peer
->host
, ':'))
12774 match_type
= IPV6_TKN
;
12776 match_type
= IPV4_TKN
;
12778 if (token
->type
!= match_type
)
12781 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12786 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12787 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12788 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12789 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12790 {.completions
= NULL
}};
12792 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12795 struct peer_group
*group
;
12796 struct listnode
*lnbgp
, *lnpeer
;
12798 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12799 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12800 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12805 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12806 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12807 {.completions
= NULL
} };
12809 void bgp_vty_init(void)
12811 cmd_variable_handler_register(bgp_var_neighbor
);
12812 cmd_variable_handler_register(bgp_var_peergroup
);
12814 /* Install bgp top node. */
12815 install_node(&bgp_node
, bgp_config_write
);
12816 install_node(&bgp_ipv4_unicast_node
, NULL
);
12817 install_node(&bgp_ipv4_multicast_node
, NULL
);
12818 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12819 install_node(&bgp_ipv6_unicast_node
, NULL
);
12820 install_node(&bgp_ipv6_multicast_node
, NULL
);
12821 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12822 install_node(&bgp_vpnv4_node
, NULL
);
12823 install_node(&bgp_vpnv6_node
, NULL
);
12824 install_node(&bgp_evpn_node
, NULL
);
12825 install_node(&bgp_evpn_vni_node
, NULL
);
12826 install_node(&bgp_flowspecv4_node
, NULL
);
12827 install_node(&bgp_flowspecv6_node
, NULL
);
12829 /* Install default VTY commands to new nodes. */
12830 install_default(BGP_NODE
);
12831 install_default(BGP_IPV4_NODE
);
12832 install_default(BGP_IPV4M_NODE
);
12833 install_default(BGP_IPV4L_NODE
);
12834 install_default(BGP_IPV6_NODE
);
12835 install_default(BGP_IPV6M_NODE
);
12836 install_default(BGP_IPV6L_NODE
);
12837 install_default(BGP_VPNV4_NODE
);
12838 install_default(BGP_VPNV6_NODE
);
12839 install_default(BGP_FLOWSPECV4_NODE
);
12840 install_default(BGP_FLOWSPECV6_NODE
);
12841 install_default(BGP_EVPN_NODE
);
12842 install_default(BGP_EVPN_VNI_NODE
);
12844 /* "bgp local-mac" hidden commands. */
12845 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
12846 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
12848 /* bgp route-map delay-timer commands. */
12849 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12850 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12852 /* Dummy commands (Currently not supported) */
12853 install_element(BGP_NODE
, &no_synchronization_cmd
);
12854 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12856 /* "router bgp" commands. */
12857 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12859 /* "no router bgp" commands. */
12860 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12862 /* "bgp router-id" commands. */
12863 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12864 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12866 /* "bgp cluster-id" commands. */
12867 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12868 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12870 /* "bgp confederation" commands. */
12871 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12872 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12874 /* "bgp confederation peers" commands. */
12875 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12876 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12878 /* bgp max-med command */
12879 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12880 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12881 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12882 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12883 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12885 /* bgp disable-ebgp-connected-nh-check */
12886 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12887 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12889 /* bgp update-delay command */
12890 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12891 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12892 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12894 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12895 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12896 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12897 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12899 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12900 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12902 /* "maximum-paths" commands. */
12903 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12904 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12905 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12906 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12907 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12908 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12909 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12910 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12911 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12912 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12913 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12914 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12915 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12916 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12917 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12919 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12920 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12921 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12922 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12923 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12925 /* "timers bgp" commands. */
12926 install_element(BGP_NODE
, &bgp_timers_cmd
);
12927 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12929 /* route-map delay-timer commands - per instance for backwards compat.
12931 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12932 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12934 /* "bgp client-to-client reflection" commands */
12935 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
12936 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
12938 /* "bgp always-compare-med" commands */
12939 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
12940 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
12942 /* bgp ebgp-requires-policy */
12943 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
12944 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
12946 /* "bgp deterministic-med" commands */
12947 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
12948 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
12950 /* "bgp graceful-restart" commands */
12951 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
12952 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
12953 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
12954 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
12955 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
12956 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
12958 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
12959 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
12961 /* "bgp graceful-shutdown" commands */
12962 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
12963 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
12965 /* "bgp fast-external-failover" commands */
12966 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
12967 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
12969 /* "bgp bestpath compare-routerid" commands */
12970 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
12971 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
12973 /* "bgp bestpath as-path ignore" commands */
12974 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
12975 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
12977 /* "bgp bestpath as-path confed" commands */
12978 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
12979 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
12981 /* "bgp bestpath as-path multipath-relax" commands */
12982 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
12983 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
12985 /* "bgp log-neighbor-changes" commands */
12986 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
12987 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
12989 /* "bgp bestpath med" commands */
12990 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
12991 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
12993 /* "no bgp default ipv4-unicast" commands. */
12994 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
12995 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
12997 /* "bgp network import-check" commands. */
12998 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
12999 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
13000 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
13002 /* "bgp default local-preference" commands. */
13003 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
13004 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
13006 /* bgp default show-hostname */
13007 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
13008 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
13010 /* "bgp default subgroup-pkt-queue-max" commands. */
13011 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
13012 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
13014 /* bgp ibgp-allow-policy-mods command */
13015 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
13016 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
13018 /* "bgp listen limit" commands. */
13019 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
13020 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
13022 /* "bgp listen range" commands. */
13023 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
13024 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
13026 /* "bgp default shutdown" command */
13027 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
13029 /* "neighbor remote-as" commands. */
13030 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
13031 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
13032 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
13033 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
13034 install_element(BGP_NODE
,
13035 &neighbor_interface_v6only_config_remote_as_cmd
);
13036 install_element(BGP_NODE
, &no_neighbor_cmd
);
13037 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
13039 /* "neighbor peer-group" commands. */
13040 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
13041 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
13042 install_element(BGP_NODE
,
13043 &no_neighbor_interface_peer_group_remote_as_cmd
);
13045 /* "neighbor local-as" commands. */
13046 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
13047 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
13048 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
13049 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
13051 /* "neighbor solo" commands. */
13052 install_element(BGP_NODE
, &neighbor_solo_cmd
);
13053 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
13055 /* "neighbor password" commands. */
13056 install_element(BGP_NODE
, &neighbor_password_cmd
);
13057 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
13059 /* "neighbor activate" commands. */
13060 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
13061 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
13062 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
13063 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
13064 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
13065 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
13066 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
13067 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
13068 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
13069 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
13070 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
13071 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
13073 /* "no neighbor activate" commands. */
13074 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
13075 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
13076 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
13077 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
13078 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
13079 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
13080 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
13081 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
13082 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
13083 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
13084 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
13085 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
13087 /* "neighbor peer-group" set commands. */
13088 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
13089 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13090 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13091 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13092 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13093 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13094 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13095 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13096 install_element(BGP_FLOWSPECV4_NODE
,
13097 &neighbor_set_peer_group_hidden_cmd
);
13098 install_element(BGP_FLOWSPECV6_NODE
,
13099 &neighbor_set_peer_group_hidden_cmd
);
13101 /* "no neighbor peer-group unset" commands. */
13102 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
13103 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13104 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13105 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13106 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13107 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13108 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13109 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13110 install_element(BGP_FLOWSPECV4_NODE
,
13111 &no_neighbor_set_peer_group_hidden_cmd
);
13112 install_element(BGP_FLOWSPECV6_NODE
,
13113 &no_neighbor_set_peer_group_hidden_cmd
);
13115 /* "neighbor softreconfiguration inbound" commands.*/
13116 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
13117 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
13118 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13119 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13120 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13121 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13122 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13123 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13124 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13125 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13126 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13127 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13128 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13129 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13130 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13131 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13132 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13133 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13134 install_element(BGP_FLOWSPECV4_NODE
,
13135 &neighbor_soft_reconfiguration_cmd
);
13136 install_element(BGP_FLOWSPECV4_NODE
,
13137 &no_neighbor_soft_reconfiguration_cmd
);
13138 install_element(BGP_FLOWSPECV6_NODE
,
13139 &neighbor_soft_reconfiguration_cmd
);
13140 install_element(BGP_FLOWSPECV6_NODE
,
13141 &no_neighbor_soft_reconfiguration_cmd
);
13142 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
13143 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13145 /* "neighbor attribute-unchanged" commands. */
13146 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
13147 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
13148 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
13149 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13150 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
13151 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13152 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
13153 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13154 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
13155 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13156 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
13157 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13158 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
13159 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13160 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
13161 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13162 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
13163 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13165 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
13166 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
13168 /* "nexthop-local unchanged" commands */
13169 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
13170 install_element(BGP_IPV6_NODE
,
13171 &no_neighbor_nexthop_local_unchanged_cmd
);
13173 /* "neighbor next-hop-self" commands. */
13174 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
13175 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
13176 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
13177 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13178 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
13179 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
13180 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
13181 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
13182 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
13183 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13184 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
13185 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
13186 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
13187 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
13188 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
13189 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13190 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
13191 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13192 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
13193 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
13195 /* "neighbor next-hop-self force" commands. */
13196 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
13197 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
13198 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13199 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
13200 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13201 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13202 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
13203 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13204 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
13205 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13206 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13207 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13208 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
13209 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13210 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
13211 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13212 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13213 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13214 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13215 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13217 /* "neighbor as-override" commands. */
13218 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
13219 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
13220 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
13221 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
13222 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
13223 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
13224 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
13225 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
13226 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
13227 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
13228 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
13229 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
13230 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
13231 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
13232 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
13233 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
13234 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
13235 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
13237 /* "neighbor remove-private-AS" commands. */
13238 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
13239 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
13240 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
13241 install_element(BGP_NODE
,
13242 &no_neighbor_remove_private_as_all_hidden_cmd
);
13243 install_element(BGP_NODE
,
13244 &neighbor_remove_private_as_replace_as_hidden_cmd
);
13245 install_element(BGP_NODE
,
13246 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
13247 install_element(BGP_NODE
,
13248 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13251 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13252 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
13253 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13254 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13255 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13256 install_element(BGP_IPV4_NODE
,
13257 &neighbor_remove_private_as_replace_as_cmd
);
13258 install_element(BGP_IPV4_NODE
,
13259 &no_neighbor_remove_private_as_replace_as_cmd
);
13260 install_element(BGP_IPV4_NODE
,
13261 &neighbor_remove_private_as_all_replace_as_cmd
);
13262 install_element(BGP_IPV4_NODE
,
13263 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13264 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
13265 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
13266 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
13267 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13268 install_element(BGP_IPV4M_NODE
,
13269 &neighbor_remove_private_as_replace_as_cmd
);
13270 install_element(BGP_IPV4M_NODE
,
13271 &no_neighbor_remove_private_as_replace_as_cmd
);
13272 install_element(BGP_IPV4M_NODE
,
13273 &neighbor_remove_private_as_all_replace_as_cmd
);
13274 install_element(BGP_IPV4M_NODE
,
13275 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13276 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
13277 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
13278 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
13279 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13280 install_element(BGP_IPV4L_NODE
,
13281 &neighbor_remove_private_as_replace_as_cmd
);
13282 install_element(BGP_IPV4L_NODE
,
13283 &no_neighbor_remove_private_as_replace_as_cmd
);
13284 install_element(BGP_IPV4L_NODE
,
13285 &neighbor_remove_private_as_all_replace_as_cmd
);
13286 install_element(BGP_IPV4L_NODE
,
13287 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13288 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
13289 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13290 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13291 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13292 install_element(BGP_IPV6_NODE
,
13293 &neighbor_remove_private_as_replace_as_cmd
);
13294 install_element(BGP_IPV6_NODE
,
13295 &no_neighbor_remove_private_as_replace_as_cmd
);
13296 install_element(BGP_IPV6_NODE
,
13297 &neighbor_remove_private_as_all_replace_as_cmd
);
13298 install_element(BGP_IPV6_NODE
,
13299 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13300 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
13301 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
13302 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
13303 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13304 install_element(BGP_IPV6M_NODE
,
13305 &neighbor_remove_private_as_replace_as_cmd
);
13306 install_element(BGP_IPV6M_NODE
,
13307 &no_neighbor_remove_private_as_replace_as_cmd
);
13308 install_element(BGP_IPV6M_NODE
,
13309 &neighbor_remove_private_as_all_replace_as_cmd
);
13310 install_element(BGP_IPV6M_NODE
,
13311 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13312 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
13313 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
13314 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
13315 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13316 install_element(BGP_IPV6L_NODE
,
13317 &neighbor_remove_private_as_replace_as_cmd
);
13318 install_element(BGP_IPV6L_NODE
,
13319 &no_neighbor_remove_private_as_replace_as_cmd
);
13320 install_element(BGP_IPV6L_NODE
,
13321 &neighbor_remove_private_as_all_replace_as_cmd
);
13322 install_element(BGP_IPV6L_NODE
,
13323 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13324 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
13325 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13326 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13327 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13328 install_element(BGP_VPNV4_NODE
,
13329 &neighbor_remove_private_as_replace_as_cmd
);
13330 install_element(BGP_VPNV4_NODE
,
13331 &no_neighbor_remove_private_as_replace_as_cmd
);
13332 install_element(BGP_VPNV4_NODE
,
13333 &neighbor_remove_private_as_all_replace_as_cmd
);
13334 install_element(BGP_VPNV4_NODE
,
13335 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13336 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
13337 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13338 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13339 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13340 install_element(BGP_VPNV6_NODE
,
13341 &neighbor_remove_private_as_replace_as_cmd
);
13342 install_element(BGP_VPNV6_NODE
,
13343 &no_neighbor_remove_private_as_replace_as_cmd
);
13344 install_element(BGP_VPNV6_NODE
,
13345 &neighbor_remove_private_as_all_replace_as_cmd
);
13346 install_element(BGP_VPNV6_NODE
,
13347 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13349 /* "neighbor send-community" commands.*/
13350 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
13351 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
13352 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
13353 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
13354 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
13355 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
13356 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
13357 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
13358 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
13359 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
13360 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
13361 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
13362 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
13363 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
13364 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
13365 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
13366 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
13367 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
13368 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
13369 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
13370 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
13371 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
13372 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
13373 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
13374 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
13375 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
13376 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
13377 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
13378 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
13379 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
13380 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
13381 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
13382 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
13383 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
13384 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
13385 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
13387 /* "neighbor route-reflector" commands.*/
13388 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
13389 install_element(BGP_NODE
,
13390 &no_neighbor_route_reflector_client_hidden_cmd
);
13391 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
13392 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
13393 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
13394 install_element(BGP_IPV4M_NODE
,
13395 &no_neighbor_route_reflector_client_cmd
);
13396 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
13397 install_element(BGP_IPV4L_NODE
,
13398 &no_neighbor_route_reflector_client_cmd
);
13399 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
13400 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
13401 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
13402 install_element(BGP_IPV6M_NODE
,
13403 &no_neighbor_route_reflector_client_cmd
);
13404 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
13405 install_element(BGP_IPV6L_NODE
,
13406 &no_neighbor_route_reflector_client_cmd
);
13407 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
13408 install_element(BGP_VPNV4_NODE
,
13409 &no_neighbor_route_reflector_client_cmd
);
13410 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
13411 install_element(BGP_VPNV6_NODE
,
13412 &no_neighbor_route_reflector_client_cmd
);
13413 install_element(BGP_FLOWSPECV4_NODE
,
13414 &neighbor_route_reflector_client_cmd
);
13415 install_element(BGP_FLOWSPECV4_NODE
,
13416 &no_neighbor_route_reflector_client_cmd
);
13417 install_element(BGP_FLOWSPECV6_NODE
,
13418 &neighbor_route_reflector_client_cmd
);
13419 install_element(BGP_FLOWSPECV6_NODE
,
13420 &no_neighbor_route_reflector_client_cmd
);
13421 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
13422 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
13424 /* "neighbor route-server" commands.*/
13425 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
13426 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
13427 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
13428 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
13429 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
13430 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
13431 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
13432 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
13433 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
13434 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
13435 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
13436 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
13437 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
13438 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
13439 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
13440 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
13441 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
13442 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
13443 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
13444 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
13445 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
13446 install_element(BGP_FLOWSPECV4_NODE
,
13447 &no_neighbor_route_server_client_cmd
);
13448 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
13449 install_element(BGP_FLOWSPECV6_NODE
,
13450 &no_neighbor_route_server_client_cmd
);
13452 /* "neighbor addpath-tx-all-paths" commands.*/
13453 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
13454 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
13455 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13456 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13457 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13458 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13459 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13460 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13461 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13462 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13463 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13464 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13465 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13466 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13467 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13468 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13469 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13470 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13472 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
13473 install_element(BGP_NODE
,
13474 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13475 install_element(BGP_NODE
,
13476 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13477 install_element(BGP_IPV4_NODE
,
13478 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13479 install_element(BGP_IPV4_NODE
,
13480 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13481 install_element(BGP_IPV4M_NODE
,
13482 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13483 install_element(BGP_IPV4M_NODE
,
13484 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13485 install_element(BGP_IPV4L_NODE
,
13486 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13487 install_element(BGP_IPV4L_NODE
,
13488 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13489 install_element(BGP_IPV6_NODE
,
13490 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13491 install_element(BGP_IPV6_NODE
,
13492 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13493 install_element(BGP_IPV6M_NODE
,
13494 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13495 install_element(BGP_IPV6M_NODE
,
13496 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13497 install_element(BGP_IPV6L_NODE
,
13498 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13499 install_element(BGP_IPV6L_NODE
,
13500 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13501 install_element(BGP_VPNV4_NODE
,
13502 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13503 install_element(BGP_VPNV4_NODE
,
13504 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13505 install_element(BGP_VPNV6_NODE
,
13506 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13507 install_element(BGP_VPNV6_NODE
,
13508 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13510 /* "neighbor passive" commands. */
13511 install_element(BGP_NODE
, &neighbor_passive_cmd
);
13512 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13515 /* "neighbor shutdown" commands. */
13516 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13517 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13518 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13519 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13521 /* "neighbor capability extended-nexthop" commands.*/
13522 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13523 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13525 /* "neighbor capability orf prefix-list" commands.*/
13526 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13527 install_element(BGP_NODE
,
13528 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13529 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13530 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13531 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13532 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13533 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13534 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13535 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13536 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13537 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13538 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13539 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13540 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13542 /* "neighbor capability dynamic" commands.*/
13543 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13544 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13546 /* "neighbor dont-capability-negotiate" commands. */
13547 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13548 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13550 /* "neighbor ebgp-multihop" commands. */
13551 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13552 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13553 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13555 /* "neighbor disable-connected-check" commands. */
13556 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13557 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13559 /* "neighbor enforce-first-as" commands. */
13560 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13561 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13563 /* "neighbor description" commands. */
13564 install_element(BGP_NODE
, &neighbor_description_cmd
);
13565 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13566 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13568 /* "neighbor update-source" commands. "*/
13569 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13570 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13572 /* "neighbor default-originate" commands. */
13573 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13574 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13575 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13576 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13577 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13578 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13579 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13580 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13581 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13582 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13583 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13584 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13585 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13586 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13587 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13588 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13589 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13590 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13591 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13592 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13593 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13595 /* "neighbor port" commands. */
13596 install_element(BGP_NODE
, &neighbor_port_cmd
);
13597 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13599 /* "neighbor weight" commands. */
13600 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13601 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13603 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13604 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13605 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13606 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13607 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13608 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13609 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13610 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13611 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13612 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13613 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13614 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13615 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13616 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13617 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13618 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13620 /* "neighbor override-capability" commands. */
13621 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13622 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13624 /* "neighbor strict-capability-match" commands. */
13625 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13626 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13628 /* "neighbor timers" commands. */
13629 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13630 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13632 /* "neighbor timers connect" commands. */
13633 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13634 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13636 /* "neighbor advertisement-interval" commands. */
13637 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13638 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13640 /* "neighbor interface" commands. */
13641 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13642 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13644 /* "neighbor distribute" commands. */
13645 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13646 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13647 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13648 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13649 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13650 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13651 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13652 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13653 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13654 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13655 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13656 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13657 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13658 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13659 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13660 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13661 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13662 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13664 /* "neighbor prefix-list" commands. */
13665 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13666 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13667 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13668 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13669 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13670 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13671 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13672 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13673 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13674 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13675 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13676 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13677 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13678 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13679 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13680 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13681 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13682 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13683 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13684 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13685 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13686 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13688 /* "neighbor filter-list" commands. */
13689 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13690 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13691 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13692 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13693 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13694 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13695 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13696 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13697 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13698 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13699 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13700 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13701 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13702 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13703 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13704 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13705 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13706 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13707 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13708 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13709 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13710 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13712 /* "neighbor route-map" commands. */
13713 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13714 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13715 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13716 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13717 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13718 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13719 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13720 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13721 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13722 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13723 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13724 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13725 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13726 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13727 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13728 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13729 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13730 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13731 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13732 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13733 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13734 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13735 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13736 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13738 /* "neighbor unsuppress-map" commands. */
13739 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13740 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13741 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13742 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13743 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13744 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13745 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13746 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13747 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13748 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13749 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13750 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13751 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13752 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13753 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13754 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13755 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13756 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13758 /* "neighbor maximum-prefix" commands. */
13759 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13760 install_element(BGP_NODE
,
13761 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13762 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13763 install_element(BGP_NODE
,
13764 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13765 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13766 install_element(BGP_NODE
,
13767 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13768 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13769 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13770 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13771 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13772 install_element(BGP_IPV4_NODE
,
13773 &neighbor_maximum_prefix_threshold_warning_cmd
);
13774 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13775 install_element(BGP_IPV4_NODE
,
13776 &neighbor_maximum_prefix_threshold_restart_cmd
);
13777 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13778 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13779 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13780 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13781 install_element(BGP_IPV4M_NODE
,
13782 &neighbor_maximum_prefix_threshold_warning_cmd
);
13783 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13784 install_element(BGP_IPV4M_NODE
,
13785 &neighbor_maximum_prefix_threshold_restart_cmd
);
13786 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13787 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13788 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13789 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13790 install_element(BGP_IPV4L_NODE
,
13791 &neighbor_maximum_prefix_threshold_warning_cmd
);
13792 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13793 install_element(BGP_IPV4L_NODE
,
13794 &neighbor_maximum_prefix_threshold_restart_cmd
);
13795 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13796 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13797 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13798 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13799 install_element(BGP_IPV6_NODE
,
13800 &neighbor_maximum_prefix_threshold_warning_cmd
);
13801 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13802 install_element(BGP_IPV6_NODE
,
13803 &neighbor_maximum_prefix_threshold_restart_cmd
);
13804 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13805 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13806 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13807 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13808 install_element(BGP_IPV6M_NODE
,
13809 &neighbor_maximum_prefix_threshold_warning_cmd
);
13810 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13811 install_element(BGP_IPV6M_NODE
,
13812 &neighbor_maximum_prefix_threshold_restart_cmd
);
13813 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13814 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13815 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13816 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13817 install_element(BGP_IPV6L_NODE
,
13818 &neighbor_maximum_prefix_threshold_warning_cmd
);
13819 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13820 install_element(BGP_IPV6L_NODE
,
13821 &neighbor_maximum_prefix_threshold_restart_cmd
);
13822 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13823 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13824 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13825 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13826 install_element(BGP_VPNV4_NODE
,
13827 &neighbor_maximum_prefix_threshold_warning_cmd
);
13828 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13829 install_element(BGP_VPNV4_NODE
,
13830 &neighbor_maximum_prefix_threshold_restart_cmd
);
13831 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13832 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13833 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13834 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13835 install_element(BGP_VPNV6_NODE
,
13836 &neighbor_maximum_prefix_threshold_warning_cmd
);
13837 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13838 install_element(BGP_VPNV6_NODE
,
13839 &neighbor_maximum_prefix_threshold_restart_cmd
);
13840 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13842 /* "neighbor allowas-in" */
13843 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13844 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13845 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13846 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13847 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13848 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13849 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13850 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13851 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13852 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13853 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13854 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13855 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13856 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13857 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13858 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13859 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13860 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13861 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13862 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13864 /* address-family commands. */
13865 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13866 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13867 #ifdef KEEP_OLD_VPN_COMMANDS
13868 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13869 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13870 #endif /* KEEP_OLD_VPN_COMMANDS */
13872 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13874 /* "exit-address-family" command. */
13875 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13876 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13877 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13878 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13879 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13880 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13881 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13882 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13883 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13884 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13885 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13887 /* "clear ip bgp commands" */
13888 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13890 /* clear ip bgp prefix */
13891 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13892 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13893 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13895 /* "show [ip] bgp summary" commands. */
13896 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13897 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
13898 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13899 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13900 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13901 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13902 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
13904 /* "show [ip] bgp neighbors" commands. */
13905 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
13907 /* "show [ip] bgp peer-group" commands. */
13908 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
13910 /* "show [ip] bgp paths" commands. */
13911 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
13913 /* "show [ip] bgp community" commands. */
13914 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
13916 /* "show ip bgp large-community" commands. */
13917 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
13918 /* "show [ip] bgp attribute-info" commands. */
13919 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
13920 /* "show [ip] bgp route-leak" command */
13921 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
13923 /* "redistribute" commands. */
13924 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
13925 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
13926 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
13927 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
13928 install_element(BGP_NODE
,
13929 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
13930 install_element(BGP_NODE
,
13931 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
13932 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
13933 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
13934 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
13935 install_element(BGP_NODE
,
13936 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
13937 install_element(BGP_NODE
,
13938 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
13939 install_element(BGP_NODE
,
13940 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
13941 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
13942 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
13943 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
13944 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
13945 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
13946 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
13947 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
13948 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
13949 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
13950 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
13951 install_element(BGP_IPV4_NODE
,
13952 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
13953 install_element(BGP_IPV4_NODE
,
13954 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
13955 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
13956 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
13957 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
13958 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
13959 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
13960 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
13962 /* import|export vpn [route-map WORD] */
13963 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
13964 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
13966 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
13967 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
13969 /* ttl_security commands */
13970 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
13971 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
13973 /* "show [ip] bgp memory" commands. */
13974 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
13976 /* "show bgp martian next-hop" */
13977 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
13979 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
13981 /* "show [ip] bgp views" commands. */
13982 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
13984 /* "show [ip] bgp vrfs" commands. */
13985 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
13987 /* Community-list. */
13988 community_list_vty();
13990 /* vpn-policy commands */
13991 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
13992 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
13993 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
13994 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
13995 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
13996 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
13997 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
13998 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
13999 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
14000 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
14001 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
14002 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
14004 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
14005 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
14007 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
14008 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
14009 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
14010 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
14011 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
14012 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
14013 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
14014 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
14015 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14016 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14017 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
14018 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
14021 #include "memory.h"
14022 #include "bgp_regex.h"
14023 #include "bgp_clist.h"
14024 #include "bgp_ecommunity.h"
14026 /* VTY functions. */
14028 /* Direction value to string conversion. */
14029 static const char *community_direct_str(int direct
)
14032 case COMMUNITY_DENY
:
14034 case COMMUNITY_PERMIT
:
14041 /* Display error string. */
14042 static void community_list_perror(struct vty
*vty
, int ret
)
14045 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
14046 vty_out(vty
, "%% Can't find community-list\n");
14048 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
14049 vty_out(vty
, "%% Malformed community-list value\n");
14051 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
14053 "%% Community name conflict, previously defined as standard community\n");
14055 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
14057 "%% Community name conflict, previously defined as expanded community\n");
14062 /* "community-list" keyword help string. */
14063 #define COMMUNITY_LIST_STR "Add a community list entry\n"
14065 /*community-list standard */
14066 DEFUN (community_list_standard
,
14067 bgp_community_list_standard_cmd
,
14068 "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14071 "Community list number (standard)\n"
14072 "Add an standard community-list entry\n"
14073 "Community list name\n"
14074 "Specify community to reject\n"
14075 "Specify community to accept\n"
14078 char *cl_name_or_number
= NULL
;
14080 int style
= COMMUNITY_LIST_STANDARD
;
14084 if (argv_find(argv
, argc
, "ip", &idx
)) {
14085 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14086 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14087 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14088 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14091 argv_find(argv
, argc
, "(1-99)", &idx
);
14092 argv_find(argv
, argc
, "WORD", &idx
);
14093 cl_name_or_number
= argv
[idx
]->arg
;
14094 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14096 argv_find(argv
, argc
, "AA:NN", &idx
);
14097 char *str
= argv_concat(argv
, argc
, idx
);
14099 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14102 XFREE(MTYPE_TMP
, str
);
14105 /* Display error string. */
14106 community_list_perror(vty
, ret
);
14107 return CMD_WARNING_CONFIG_FAILED
;
14110 return CMD_SUCCESS
;
14113 #if CONFDATE > 20191005
14114 CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command")
14116 ALIAS (community_list_standard
,
14117 ip_community_list_standard_cmd
,
14118 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14121 "Community list number (standard)\n"
14122 "Add an standard community-list entry\n"
14123 "Community list name\n"
14124 "Specify community to reject\n"
14125 "Specify community to accept\n"
14128 DEFUN (no_community_list_standard_all
,
14129 no_bgp_community_list_standard_all_cmd
,
14130 "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14134 "Community list number (standard)\n"
14135 "Add an standard community-list entry\n"
14136 "Community list name\n"
14137 "Specify community to reject\n"
14138 "Specify community to accept\n"
14141 char *cl_name_or_number
= NULL
;
14144 int style
= COMMUNITY_LIST_STANDARD
;
14148 if (argv_find(argv
, argc
, "ip", &idx
)) {
14149 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
14150 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14151 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14152 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used");
14155 argv_find(argv
, argc
, "permit", &idx
);
14156 argv_find(argv
, argc
, "deny", &idx
);
14159 direct
= argv_find(argv
, argc
, "permit", &idx
)
14164 argv_find(argv
, argc
, "AA:NN", &idx
);
14165 str
= argv_concat(argv
, argc
, idx
);
14169 argv_find(argv
, argc
, "(1-99)", &idx
);
14170 argv_find(argv
, argc
, "WORD", &idx
);
14171 cl_name_or_number
= argv
[idx
]->arg
;
14173 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14176 XFREE(MTYPE_TMP
, str
);
14179 community_list_perror(vty
, ret
);
14180 return CMD_WARNING_CONFIG_FAILED
;
14183 return CMD_SUCCESS
;
14185 ALIAS (no_community_list_standard_all
,
14186 no_ip_community_list_standard_all_cmd
,
14187 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14191 "Community list number (standard)\n"
14192 "Add an standard community-list entry\n"
14193 "Community list name\n"
14194 "Specify community to reject\n"
14195 "Specify community to accept\n"
14198 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
14199 "no bgp community-list <(1-99)|standard WORD>",
14200 NO_STR BGP_STR COMMUNITY_LIST_STR
14201 "Community list number (standard)\n"
14202 "Add an standard community-list entry\n"
14203 "Community list name\n")
14205 ALIAS(no_community_list_standard_all
, no_ip_community_list_standard_all_list_cmd
,
14206 "no ip community-list <(1-99)|standard WORD>",
14207 NO_STR BGP_STR COMMUNITY_LIST_STR
14208 "Community list number (standard)\n"
14209 "Add an standard community-list entry\n"
14210 "Community list name\n")
14212 /*community-list expanded */
14213 DEFUN (community_list_expanded_all
,
14214 bgp_community_list_expanded_all_cmd
,
14215 "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14218 "Community list number (expanded)\n"
14219 "Add an expanded community-list entry\n"
14220 "Community list name\n"
14221 "Specify community to reject\n"
14222 "Specify community to accept\n"
14225 char *cl_name_or_number
= NULL
;
14227 int style
= COMMUNITY_LIST_EXPANDED
;
14230 if (argv_find(argv
, argc
, "ip", &idx
)) {
14231 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14232 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14233 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14234 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14236 argv_find(argv
, argc
, "(100-500)", &idx
);
14237 argv_find(argv
, argc
, "WORD", &idx
);
14238 cl_name_or_number
= argv
[idx
]->arg
;
14239 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14241 argv_find(argv
, argc
, "AA:NN", &idx
);
14242 char *str
= argv_concat(argv
, argc
, idx
);
14244 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14247 XFREE(MTYPE_TMP
, str
);
14250 /* Display error string. */
14251 community_list_perror(vty
, ret
);
14252 return CMD_WARNING_CONFIG_FAILED
;
14255 return CMD_SUCCESS
;
14258 ALIAS (community_list_expanded_all
,
14259 ip_community_list_expanded_all_cmd
,
14260 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14263 "Community list number (expanded)\n"
14264 "Add an expanded community-list entry\n"
14265 "Community list name\n"
14266 "Specify community to reject\n"
14267 "Specify community to accept\n"
14270 DEFUN (no_community_list_expanded_all
,
14271 no_bgp_community_list_expanded_all_cmd
,
14272 "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14276 "Community list number (expanded)\n"
14277 "Add an expanded community-list entry\n"
14278 "Community list name\n"
14279 "Specify community to reject\n"
14280 "Specify community to accept\n"
14283 char *cl_name_or_number
= NULL
;
14286 int style
= COMMUNITY_LIST_EXPANDED
;
14289 if (argv_find(argv
, argc
, "ip", &idx
)) {
14290 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14291 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14292 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14293 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14297 argv_find(argv
, argc
, "permit", &idx
);
14298 argv_find(argv
, argc
, "deny", &idx
);
14301 direct
= argv_find(argv
, argc
, "permit", &idx
)
14306 argv_find(argv
, argc
, "AA:NN", &idx
);
14307 str
= argv_concat(argv
, argc
, idx
);
14311 argv_find(argv
, argc
, "(100-500)", &idx
);
14312 argv_find(argv
, argc
, "WORD", &idx
);
14313 cl_name_or_number
= argv
[idx
]->arg
;
14315 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14318 XFREE(MTYPE_TMP
, str
);
14321 community_list_perror(vty
, ret
);
14322 return CMD_WARNING_CONFIG_FAILED
;
14325 return CMD_SUCCESS
;
14328 ALIAS (no_community_list_expanded_all
,
14329 no_ip_community_list_expanded_all_cmd
,
14330 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14334 "Community list number (expanded)\n"
14335 "Add an expanded community-list entry\n"
14336 "Community list name\n"
14337 "Specify community to reject\n"
14338 "Specify community to accept\n"
14341 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
14342 "no bgp community-list <(100-500)|expanded WORD>",
14343 NO_STR IP_STR COMMUNITY_LIST_STR
14344 "Community list number (expanded)\n"
14345 "Add an expanded community-list entry\n"
14346 "Community list name\n")
14348 ALIAS(no_community_list_expanded_all
, no_ip_community_list_expanded_all_list_cmd
,
14349 "no ip community-list <(100-500)|expanded WORD>",
14350 NO_STR IP_STR COMMUNITY_LIST_STR
14351 "Community list number (expanded)\n"
14352 "Add an expanded community-list entry\n"
14353 "Community list name\n")
14355 /* Return configuration string of community-list entry. */
14356 static const char *community_list_config_str(struct community_entry
*entry
)
14363 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
14364 str
= community_str(entry
->u
.com
, false);
14365 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
14366 str
= lcommunity_str(entry
->u
.lcom
, false);
14368 str
= entry
->config
;
14373 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
14375 struct community_entry
*entry
;
14377 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14378 if (entry
== list
->head
) {
14379 if (all_digit(list
->name
))
14380 vty_out(vty
, "Community %s list %s\n",
14381 entry
->style
== COMMUNITY_LIST_STANDARD
14383 : "(expanded) access",
14386 vty_out(vty
, "Named Community %s list %s\n",
14387 entry
->style
== COMMUNITY_LIST_STANDARD
14393 vty_out(vty
, " %s\n",
14394 community_direct_str(entry
->direct
));
14396 vty_out(vty
, " %s %s\n",
14397 community_direct_str(entry
->direct
),
14398 community_list_config_str(entry
));
14402 DEFUN (show_community_list
,
14403 show_bgp_community_list_cmd
,
14404 "show bgp community-list",
14407 "List community-list\n")
14409 struct community_list
*list
;
14410 struct community_list_master
*cm
;
14413 if (argv_find(argv
, argc
, "ip", &idx
)) {
14414 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14415 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14416 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14417 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14419 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14421 return CMD_SUCCESS
;
14423 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14424 community_list_show(vty
, list
);
14426 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14427 community_list_show(vty
, list
);
14429 return CMD_SUCCESS
;
14432 ALIAS (show_community_list
,
14433 show_ip_community_list_cmd
,
14434 "show ip community-list",
14437 "List community-list\n")
14439 DEFUN (show_community_list_arg
,
14440 show_bgp_community_list_arg_cmd
,
14441 "show bgp community-list <(1-500)|WORD>",
14444 "List community-list\n"
14445 "Community-list number\n"
14446 "Community-list name\n")
14448 int idx_comm_list
= 3;
14449 struct community_list
*list
;
14452 if (argv_find(argv
, argc
, "ip", &idx
)) {
14453 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14454 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14455 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14456 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14458 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
14459 COMMUNITY_LIST_MASTER
);
14461 vty_out(vty
, "%% Can't find community-list\n");
14462 return CMD_WARNING
;
14465 community_list_show(vty
, list
);
14467 return CMD_SUCCESS
;
14470 ALIAS (show_community_list_arg
,
14471 show_ip_community_list_arg_cmd
,
14472 "show ip community-list <(1-500)|WORD>",
14475 "List community-list\n"
14476 "Community-list number\n"
14477 "Community-list name\n")
14480 * Large Community code.
14482 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
14483 struct cmd_token
**argv
, int style
,
14484 int reject_all_digit_name
)
14492 if (argv_find(argv
, argc
, "ip", &idx
)) {
14493 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14494 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14495 vty_out(vty
, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14496 zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14498 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14501 /* All digit name check. */
14503 argv_find(argv
, argc
, "WORD", &idx
);
14504 argv_find(argv
, argc
, "(1-99)", &idx
);
14505 argv_find(argv
, argc
, "(100-500)", &idx
);
14506 cl_name
= argv
[idx
]->arg
;
14507 if (reject_all_digit_name
&& all_digit(cl_name
)) {
14508 vty_out(vty
, "%% Community name cannot have all digits\n");
14509 return CMD_WARNING_CONFIG_FAILED
;
14513 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
14514 argv_find(argv
, argc
, "LINE", &idx
);
14515 /* Concat community string argument. */
14517 str
= argv_concat(argv
, argc
, idx
);
14521 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
14523 /* Free temporary community list string allocated by
14525 XFREE(MTYPE_TMP
, str
);
14528 community_list_perror(vty
, ret
);
14529 return CMD_WARNING_CONFIG_FAILED
;
14531 return CMD_SUCCESS
;
14534 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
14535 struct cmd_token
**argv
, int style
)
14542 if (argv_find(argv
, argc
, "ip", &idx
)) {
14543 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14544 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14545 vty_out(vty
, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14546 zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14548 argv_find(argv
, argc
, "permit", &idx
);
14549 argv_find(argv
, argc
, "deny", &idx
);
14552 /* Check the list direct. */
14553 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
14554 direct
= COMMUNITY_PERMIT
;
14556 direct
= COMMUNITY_DENY
;
14559 argv_find(argv
, argc
, "LINE", &idx
);
14560 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
14561 /* Concat community string argument. */
14562 str
= argv_concat(argv
, argc
, idx
);
14566 argv_find(argv
, argc
, "(1-99)", &idx
);
14567 argv_find(argv
, argc
, "(100-500)", &idx
);
14568 argv_find(argv
, argc
, "WORD", &idx
);
14570 /* Unset community list. */
14571 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
14574 /* Free temporary community list string allocated by
14576 XFREE(MTYPE_TMP
, str
);
14579 community_list_perror(vty
, ret
);
14580 return CMD_WARNING_CONFIG_FAILED
;
14583 return CMD_SUCCESS
;
14586 /* "large-community-list" keyword help string. */
14587 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
14588 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
14590 #if CONFDATE > 20191005
14591 CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command")
14593 DEFUN (lcommunity_list_standard
,
14594 bgp_lcommunity_list_standard_cmd
,
14595 "bgp large-community-list (1-99) <deny|permit>",
14597 LCOMMUNITY_LIST_STR
14598 "Large Community list number (standard)\n"
14599 "Specify large community to reject\n"
14600 "Specify large community to accept\n")
14602 return lcommunity_list_set_vty(vty
, argc
, argv
,
14603 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14606 ALIAS (lcommunity_list_standard
,
14607 ip_lcommunity_list_standard_cmd
,
14608 "ip large-community-list (1-99) <deny|permit>",
14610 LCOMMUNITY_LIST_STR
14611 "Large Community list number (standard)\n"
14612 "Specify large community to reject\n"
14613 "Specify large community to accept\n")
14615 DEFUN (lcommunity_list_standard1
,
14616 bgp_lcommunity_list_standard1_cmd
,
14617 "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...",
14619 LCOMMUNITY_LIST_STR
14620 "Large Community list number (standard)\n"
14621 "Specify large community to reject\n"
14622 "Specify large community to accept\n"
14623 LCOMMUNITY_VAL_STR
)
14625 return lcommunity_list_set_vty(vty
, argc
, argv
,
14626 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14629 ALIAS (lcommunity_list_standard1
,
14630 ip_lcommunity_list_standard1_cmd
,
14631 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
14633 LCOMMUNITY_LIST_STR
14634 "Large Community list number (standard)\n"
14635 "Specify large community to reject\n"
14636 "Specify large community to accept\n"
14637 LCOMMUNITY_VAL_STR
)
14639 DEFUN (lcommunity_list_expanded
,
14640 bgp_lcommunity_list_expanded_cmd
,
14641 "bgp large-community-list (100-500) <deny|permit> LINE...",
14643 LCOMMUNITY_LIST_STR
14644 "Large Community list number (expanded)\n"
14645 "Specify large community to reject\n"
14646 "Specify large community to accept\n"
14647 "An ordered list as a regular-expression\n")
14649 return lcommunity_list_set_vty(vty
, argc
, argv
,
14650 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
14653 ALIAS (lcommunity_list_expanded
,
14654 ip_lcommunity_list_expanded_cmd
,
14655 "ip large-community-list (100-500) <deny|permit> LINE...",
14657 LCOMMUNITY_LIST_STR
14658 "Large Community list number (expanded)\n"
14659 "Specify large community to reject\n"
14660 "Specify large community to accept\n"
14661 "An ordered list as a regular-expression\n")
14663 DEFUN (lcommunity_list_name_standard
,
14664 bgp_lcommunity_list_name_standard_cmd
,
14665 "bgp large-community-list standard WORD <deny|permit>",
14667 LCOMMUNITY_LIST_STR
14668 "Specify standard large-community-list\n"
14669 "Large Community list name\n"
14670 "Specify large community to reject\n"
14671 "Specify large community to accept\n")
14673 return lcommunity_list_set_vty(vty
, argc
, argv
,
14674 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14677 ALIAS (lcommunity_list_name_standard
,
14678 ip_lcommunity_list_name_standard_cmd
,
14679 "ip large-community-list standard WORD <deny|permit>",
14681 LCOMMUNITY_LIST_STR
14682 "Specify standard large-community-list\n"
14683 "Large Community list name\n"
14684 "Specify large community to reject\n"
14685 "Specify large community to accept\n")
14687 DEFUN (lcommunity_list_name_standard1
,
14688 bgp_lcommunity_list_name_standard1_cmd
,
14689 "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
14691 LCOMMUNITY_LIST_STR
14692 "Specify standard large-community-list\n"
14693 "Large Community list name\n"
14694 "Specify large community to reject\n"
14695 "Specify large community to accept\n"
14696 LCOMMUNITY_VAL_STR
)
14698 return lcommunity_list_set_vty(vty
, argc
, argv
,
14699 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14702 ALIAS (lcommunity_list_name_standard1
,
14703 ip_lcommunity_list_name_standard1_cmd
,
14704 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
14706 LCOMMUNITY_LIST_STR
14707 "Specify standard large-community-list\n"
14708 "Large Community list name\n"
14709 "Specify large community to reject\n"
14710 "Specify large community to accept\n"
14711 LCOMMUNITY_VAL_STR
)
14713 DEFUN (lcommunity_list_name_expanded
,
14714 bgp_lcommunity_list_name_expanded_cmd
,
14715 "bgp large-community-list expanded WORD <deny|permit> LINE...",
14717 LCOMMUNITY_LIST_STR
14718 "Specify expanded large-community-list\n"
14719 "Large Community list name\n"
14720 "Specify large community to reject\n"
14721 "Specify large community to accept\n"
14722 "An ordered list as a regular-expression\n")
14724 return lcommunity_list_set_vty(vty
, argc
, argv
,
14725 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
14728 ALIAS (lcommunity_list_name_expanded
,
14729 ip_lcommunity_list_name_expanded_cmd
,
14730 "ip large-community-list expanded WORD <deny|permit> LINE...",
14732 LCOMMUNITY_LIST_STR
14733 "Specify expanded large-community-list\n"
14734 "Large Community list name\n"
14735 "Specify large community to reject\n"
14736 "Specify large community to accept\n"
14737 "An ordered list as a regular-expression\n")
14739 DEFUN (no_lcommunity_list_standard_all
,
14740 no_bgp_lcommunity_list_standard_all_cmd
,
14741 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
14744 LCOMMUNITY_LIST_STR
14745 "Large Community list number (standard)\n"
14746 "Large Community list number (expanded)\n"
14747 "Large Community list name\n")
14749 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14750 LARGE_COMMUNITY_LIST_STANDARD
);
14753 ALIAS (no_lcommunity_list_standard_all
,
14754 no_ip_lcommunity_list_standard_all_cmd
,
14755 "no ip large-community-list <(1-99)|(100-500)|WORD>",
14758 LCOMMUNITY_LIST_STR
14759 "Large Community list number (standard)\n"
14760 "Large Community list number (expanded)\n"
14761 "Large Community list name\n")
14763 DEFUN (no_lcommunity_list_name_expanded_all
,
14764 no_bgp_lcommunity_list_name_expanded_all_cmd
,
14765 "no bgp large-community-list expanded WORD",
14768 LCOMMUNITY_LIST_STR
14769 "Specify expanded large-community-list\n"
14770 "Large Community list name\n")
14772 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14773 LARGE_COMMUNITY_LIST_EXPANDED
);
14776 ALIAS (no_lcommunity_list_name_expanded_all
,
14777 no_ip_lcommunity_list_name_expanded_all_cmd
,
14778 "no ip large-community-list expanded WORD",
14781 LCOMMUNITY_LIST_STR
14782 "Specify expanded large-community-list\n"
14783 "Large Community list name\n")
14785 DEFUN (no_lcommunity_list_standard
,
14786 no_bgp_lcommunity_list_standard_cmd
,
14787 "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
14790 LCOMMUNITY_LIST_STR
14791 "Large Community list number (standard)\n"
14792 "Specify large community to reject\n"
14793 "Specify large community to accept\n"
14794 LCOMMUNITY_VAL_STR
)
14796 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14797 LARGE_COMMUNITY_LIST_STANDARD
);
14800 ALIAS (no_lcommunity_list_standard
,
14801 no_ip_lcommunity_list_standard_cmd
,
14802 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
14805 LCOMMUNITY_LIST_STR
14806 "Large Community list number (standard)\n"
14807 "Specify large community to reject\n"
14808 "Specify large community to accept\n"
14809 LCOMMUNITY_VAL_STR
)
14811 DEFUN (no_lcommunity_list_expanded
,
14812 no_bgp_lcommunity_list_expanded_cmd
,
14813 "no bgp large-community-list (100-500) <deny|permit> LINE...",
14816 LCOMMUNITY_LIST_STR
14817 "Large Community list number (expanded)\n"
14818 "Specify large community to reject\n"
14819 "Specify large community to accept\n"
14820 "An ordered list as a regular-expression\n")
14822 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14823 LARGE_COMMUNITY_LIST_EXPANDED
);
14826 ALIAS (no_lcommunity_list_expanded
,
14827 no_ip_lcommunity_list_expanded_cmd
,
14828 "no ip large-community-list (100-500) <deny|permit> LINE...",
14831 LCOMMUNITY_LIST_STR
14832 "Large Community list number (expanded)\n"
14833 "Specify large community to reject\n"
14834 "Specify large community to accept\n"
14835 "An ordered list as a regular-expression\n")
14837 DEFUN (no_lcommunity_list_name_standard
,
14838 no_bgp_lcommunity_list_name_standard_cmd
,
14839 "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
14842 LCOMMUNITY_LIST_STR
14843 "Specify standard large-community-list\n"
14844 "Large Community list name\n"
14845 "Specify large community to reject\n"
14846 "Specify large community to accept\n"
14847 LCOMMUNITY_VAL_STR
)
14849 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14850 LARGE_COMMUNITY_LIST_STANDARD
);
14853 ALIAS (no_lcommunity_list_name_standard
,
14854 no_ip_lcommunity_list_name_standard_cmd
,
14855 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
14858 LCOMMUNITY_LIST_STR
14859 "Specify standard large-community-list\n"
14860 "Large Community list name\n"
14861 "Specify large community to reject\n"
14862 "Specify large community to accept\n"
14863 LCOMMUNITY_VAL_STR
)
14865 DEFUN (no_lcommunity_list_name_expanded
,
14866 no_bgp_lcommunity_list_name_expanded_cmd
,
14867 "no bgp large-community-list expanded WORD <deny|permit> LINE...",
14870 LCOMMUNITY_LIST_STR
14871 "Specify expanded large-community-list\n"
14872 "Large community list name\n"
14873 "Specify large community to reject\n"
14874 "Specify large community to accept\n"
14875 "An ordered list as a regular-expression\n")
14877 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14878 LARGE_COMMUNITY_LIST_EXPANDED
);
14881 ALIAS (no_lcommunity_list_name_expanded
,
14882 no_ip_lcommunity_list_name_expanded_cmd
,
14883 "no ip large-community-list expanded WORD <deny|permit> LINE...",
14886 LCOMMUNITY_LIST_STR
14887 "Specify expanded large-community-list\n"
14888 "Large community list name\n"
14889 "Specify large community to reject\n"
14890 "Specify large community to accept\n"
14891 "An ordered list as a regular-expression\n")
14893 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14895 struct community_entry
*entry
;
14897 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14898 if (entry
== list
->head
) {
14899 if (all_digit(list
->name
))
14900 vty_out(vty
, "Large community %s list %s\n",
14902 LARGE_COMMUNITY_LIST_STANDARD
14904 : "(expanded) access",
14908 "Named large community %s list %s\n",
14910 LARGE_COMMUNITY_LIST_STANDARD
14916 vty_out(vty
, " %s\n",
14917 community_direct_str(entry
->direct
));
14919 vty_out(vty
, " %s %s\n",
14920 community_direct_str(entry
->direct
),
14921 community_list_config_str(entry
));
14925 DEFUN (show_lcommunity_list
,
14926 show_bgp_lcommunity_list_cmd
,
14927 "show bgp large-community-list",
14930 "List large-community list\n")
14932 struct community_list
*list
;
14933 struct community_list_master
*cm
;
14936 if (argv_find(argv
, argc
, "ip", &idx
)) {
14937 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14938 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14939 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
14940 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
14943 cm
= community_list_master_lookup(bgp_clist
,
14944 LARGE_COMMUNITY_LIST_MASTER
);
14946 return CMD_SUCCESS
;
14948 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14949 lcommunity_list_show(vty
, list
);
14951 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14952 lcommunity_list_show(vty
, list
);
14954 return CMD_SUCCESS
;
14957 ALIAS (show_lcommunity_list
,
14958 show_ip_lcommunity_list_cmd
,
14959 "show ip large-community-list",
14962 "List large-community list\n")
14964 DEFUN (show_lcommunity_list_arg
,
14965 show_bgp_lcommunity_list_arg_cmd
,
14966 "show bgp large-community-list <(1-500)|WORD>",
14969 "List large-community list\n"
14970 "large-community-list number\n"
14971 "large-community-list name\n")
14973 struct community_list
*list
;
14976 if (argv_find(argv
, argc
, "ip", &idx
)) {
14977 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14978 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14979 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
14980 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
14983 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
14984 LARGE_COMMUNITY_LIST_MASTER
);
14986 vty_out(vty
, "%% Can't find extcommunity-list\n");
14987 return CMD_WARNING
;
14990 lcommunity_list_show(vty
, list
);
14992 return CMD_SUCCESS
;
14995 ALIAS (show_lcommunity_list_arg
,
14996 show_ip_lcommunity_list_arg_cmd
,
14997 "show ip large-community-list <(1-500)|WORD>",
15000 "List large-community list\n"
15001 "large-community-list number\n"
15002 "large-community-list name\n")
15004 /* "extcommunity-list" keyword help string. */
15005 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
15006 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
15008 DEFUN (extcommunity_list_standard
,
15009 bgp_extcommunity_list_standard_cmd
,
15010 "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15012 EXTCOMMUNITY_LIST_STR
15013 "Extended Community list number (standard)\n"
15014 "Specify standard extcommunity-list\n"
15015 "Community list name\n"
15016 "Specify community to reject\n"
15017 "Specify community to accept\n"
15018 EXTCOMMUNITY_VAL_STR
)
15020 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15022 char *cl_number_or_name
= NULL
;
15025 if (argv_find(argv
, argc
, "ip", &idx
)) {
15026 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15027 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15028 vty_out(vty
, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15029 zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15031 argv_find(argv
, argc
, "(1-99)", &idx
);
15032 argv_find(argv
, argc
, "WORD", &idx
);
15033 cl_number_or_name
= argv
[idx
]->arg
;
15034 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15036 argv_find(argv
, argc
, "AA:NN", &idx
);
15037 char *str
= argv_concat(argv
, argc
, idx
);
15039 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15042 XFREE(MTYPE_TMP
, str
);
15045 community_list_perror(vty
, ret
);
15046 return CMD_WARNING_CONFIG_FAILED
;
15049 return CMD_SUCCESS
;
15052 #if CONFDATE > 20191005
15053 CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command")
15055 ALIAS (extcommunity_list_standard
,
15056 ip_extcommunity_list_standard_cmd
,
15057 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15059 EXTCOMMUNITY_LIST_STR
15060 "Extended Community list number (standard)\n"
15061 "Specify standard extcommunity-list\n"
15062 "Community list name\n"
15063 "Specify community to reject\n"
15064 "Specify community to accept\n"
15065 EXTCOMMUNITY_VAL_STR
)
15067 DEFUN (extcommunity_list_name_expanded
,
15068 bgp_extcommunity_list_name_expanded_cmd
,
15069 "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15071 EXTCOMMUNITY_LIST_STR
15072 "Extended Community list number (expanded)\n"
15073 "Specify expanded extcommunity-list\n"
15074 "Extended Community list name\n"
15075 "Specify community to reject\n"
15076 "Specify community to accept\n"
15077 "An ordered list as a regular-expression\n")
15079 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15081 char *cl_number_or_name
= NULL
;
15084 if (argv_find(argv
, argc
, "ip", &idx
)) {
15085 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15086 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15087 vty_out(vty
, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15088 zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15091 argv_find(argv
, argc
, "(100-500)", &idx
);
15092 argv_find(argv
, argc
, "WORD", &idx
);
15093 cl_number_or_name
= argv
[idx
]->arg
;
15094 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15096 argv_find(argv
, argc
, "LINE", &idx
);
15097 char *str
= argv_concat(argv
, argc
, idx
);
15099 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15102 XFREE(MTYPE_TMP
, str
);
15105 community_list_perror(vty
, ret
);
15106 return CMD_WARNING_CONFIG_FAILED
;
15109 return CMD_SUCCESS
;
15112 ALIAS (extcommunity_list_name_expanded
,
15113 ip_extcommunity_list_name_expanded_cmd
,
15114 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15116 EXTCOMMUNITY_LIST_STR
15117 "Extended Community list number (expanded)\n"
15118 "Specify expanded extcommunity-list\n"
15119 "Extended Community list name\n"
15120 "Specify community to reject\n"
15121 "Specify community to accept\n"
15122 "An ordered list as a regular-expression\n")
15124 DEFUN (no_extcommunity_list_standard_all
,
15125 no_bgp_extcommunity_list_standard_all_cmd
,
15126 "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15129 EXTCOMMUNITY_LIST_STR
15130 "Extended Community list number (standard)\n"
15131 "Specify standard extcommunity-list\n"
15132 "Community list name\n"
15133 "Specify community to reject\n"
15134 "Specify community to accept\n"
15135 EXTCOMMUNITY_VAL_STR
)
15137 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15139 char *cl_number_or_name
= NULL
;
15143 if (argv_find(argv
, argc
, "ip", &idx
)) {
15144 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15145 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15146 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15147 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15151 argv_find(argv
, argc
, "permit", &idx
);
15152 argv_find(argv
, argc
, "deny", &idx
);
15155 direct
= argv_find(argv
, argc
, "permit", &idx
)
15160 argv_find(argv
, argc
, "AA:NN", &idx
);
15161 str
= argv_concat(argv
, argc
, idx
);
15165 argv_find(argv
, argc
, "(1-99)", &idx
);
15166 argv_find(argv
, argc
, "WORD", &idx
);
15167 cl_number_or_name
= argv
[idx
]->arg
;
15169 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15172 XFREE(MTYPE_TMP
, str
);
15175 community_list_perror(vty
, ret
);
15176 return CMD_WARNING_CONFIG_FAILED
;
15179 return CMD_SUCCESS
;
15182 ALIAS (no_extcommunity_list_standard_all
,
15183 no_ip_extcommunity_list_standard_all_cmd
,
15184 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15187 EXTCOMMUNITY_LIST_STR
15188 "Extended Community list number (standard)\n"
15189 "Specify standard extcommunity-list\n"
15190 "Community list name\n"
15191 "Specify community to reject\n"
15192 "Specify community to accept\n"
15193 EXTCOMMUNITY_VAL_STR
)
15195 ALIAS(no_extcommunity_list_standard_all
,
15196 no_bgp_extcommunity_list_standard_all_list_cmd
,
15197 "no bgp extcommunity-list <(1-99)|standard WORD>",
15198 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15199 "Extended Community list number (standard)\n"
15200 "Specify standard extcommunity-list\n"
15201 "Community list name\n")
15203 ALIAS(no_extcommunity_list_standard_all
,
15204 no_ip_extcommunity_list_standard_all_list_cmd
,
15205 "no ip extcommunity-list <(1-99)|standard WORD>",
15206 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15207 "Extended Community list number (standard)\n"
15208 "Specify standard extcommunity-list\n"
15209 "Community list name\n")
15211 DEFUN (no_extcommunity_list_expanded_all
,
15212 no_bgp_extcommunity_list_expanded_all_cmd
,
15213 "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15216 EXTCOMMUNITY_LIST_STR
15217 "Extended Community list number (expanded)\n"
15218 "Specify expanded extcommunity-list\n"
15219 "Extended Community list name\n"
15220 "Specify community to reject\n"
15221 "Specify community to accept\n"
15222 "An ordered list as a regular-expression\n")
15224 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15226 char *cl_number_or_name
= NULL
;
15230 if (argv_find(argv
, argc
, "ip", &idx
)) {
15231 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15232 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15233 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15234 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15238 argv_find(argv
, argc
, "permit", &idx
);
15239 argv_find(argv
, argc
, "deny", &idx
);
15242 direct
= argv_find(argv
, argc
, "permit", &idx
)
15247 argv_find(argv
, argc
, "LINE", &idx
);
15248 str
= argv_concat(argv
, argc
, idx
);
15252 argv_find(argv
, argc
, "(100-500)", &idx
);
15253 argv_find(argv
, argc
, "WORD", &idx
);
15254 cl_number_or_name
= argv
[idx
]->arg
;
15256 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15259 XFREE(MTYPE_TMP
, str
);
15262 community_list_perror(vty
, ret
);
15263 return CMD_WARNING_CONFIG_FAILED
;
15266 return CMD_SUCCESS
;
15269 ALIAS (no_extcommunity_list_expanded_all
,
15270 no_ip_extcommunity_list_expanded_all_cmd
,
15271 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15274 EXTCOMMUNITY_LIST_STR
15275 "Extended Community list number (expanded)\n"
15276 "Specify expanded extcommunity-list\n"
15277 "Extended Community list name\n"
15278 "Specify community to reject\n"
15279 "Specify community to accept\n"
15280 "An ordered list as a regular-expression\n")
15282 ALIAS(no_extcommunity_list_expanded_all
,
15283 no_ip_extcommunity_list_expanded_all_list_cmd
,
15284 "no ip extcommunity-list <(100-500)|expanded WORD>",
15285 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15286 "Extended Community list number (expanded)\n"
15287 "Specify expanded extcommunity-list\n"
15288 "Extended Community list name\n")
15290 ALIAS(no_extcommunity_list_expanded_all
,
15291 no_bgp_extcommunity_list_expanded_all_list_cmd
,
15292 "no bgp extcommunity-list <(100-500)|expanded WORD>",
15293 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15294 "Extended Community list number (expanded)\n"
15295 "Specify expanded extcommunity-list\n"
15296 "Extended Community list name\n")
15298 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
15300 struct community_entry
*entry
;
15302 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15303 if (entry
== list
->head
) {
15304 if (all_digit(list
->name
))
15305 vty_out(vty
, "Extended community %s list %s\n",
15306 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15308 : "(expanded) access",
15312 "Named extended community %s list %s\n",
15313 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15319 vty_out(vty
, " %s\n",
15320 community_direct_str(entry
->direct
));
15322 vty_out(vty
, " %s %s\n",
15323 community_direct_str(entry
->direct
),
15324 community_list_config_str(entry
));
15328 DEFUN (show_extcommunity_list
,
15329 show_bgp_extcommunity_list_cmd
,
15330 "show bgp extcommunity-list",
15333 "List extended-community list\n")
15335 struct community_list
*list
;
15336 struct community_list_master
*cm
;
15339 if (argv_find(argv
, argc
, "ip", &idx
)) {
15340 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15341 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15342 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15343 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15345 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15347 return CMD_SUCCESS
;
15349 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15350 extcommunity_list_show(vty
, list
);
15352 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15353 extcommunity_list_show(vty
, list
);
15355 return CMD_SUCCESS
;
15358 ALIAS (show_extcommunity_list
,
15359 show_ip_extcommunity_list_cmd
,
15360 "show ip extcommunity-list",
15363 "List extended-community list\n")
15365 DEFUN (show_extcommunity_list_arg
,
15366 show_bgp_extcommunity_list_arg_cmd
,
15367 "show bgp extcommunity-list <(1-500)|WORD>",
15370 "List extended-community list\n"
15371 "Extcommunity-list number\n"
15372 "Extcommunity-list name\n")
15374 int idx_comm_list
= 3;
15375 struct community_list
*list
;
15378 if (argv_find(argv
, argc
, "ip", &idx
)) {
15379 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15380 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15381 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15382 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15384 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
15385 EXTCOMMUNITY_LIST_MASTER
);
15387 vty_out(vty
, "%% Can't find extcommunity-list\n");
15388 return CMD_WARNING
;
15391 extcommunity_list_show(vty
, list
);
15393 return CMD_SUCCESS
;
15396 ALIAS (show_extcommunity_list_arg
,
15397 show_ip_extcommunity_list_arg_cmd
,
15398 "show ip extcommunity-list <(1-500)|WORD>",
15401 "List extended-community list\n"
15402 "Extcommunity-list number\n"
15403 "Extcommunity-list name\n")
15405 /* Display community-list and extcommunity-list configuration. */
15406 static int community_list_config_write(struct vty
*vty
)
15408 struct community_list
*list
;
15409 struct community_entry
*entry
;
15410 struct community_list_master
*cm
;
15413 /* Community-list. */
15414 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
15416 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15417 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15418 vty_out(vty
, "bgp community-list %s %s %s\n", list
->name
,
15419 community_direct_str(entry
->direct
),
15420 community_list_config_str(entry
));
15423 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15424 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15425 vty_out(vty
, "bgp community-list %s %s %s %s\n",
15426 entry
->style
== COMMUNITY_LIST_STANDARD
15429 list
->name
, community_direct_str(entry
->direct
),
15430 community_list_config_str(entry
));
15434 /* Extcommunity-list. */
15435 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15437 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15438 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15439 vty_out(vty
, "bgp extcommunity-list %s %s %s\n",
15440 list
->name
, community_direct_str(entry
->direct
),
15441 community_list_config_str(entry
));
15444 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15445 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15446 vty_out(vty
, "bgp extcommunity-list %s %s %s %s\n",
15447 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15450 list
->name
, community_direct_str(entry
->direct
),
15451 community_list_config_str(entry
));
15456 /* lcommunity-list. */
15457 cm
= community_list_master_lookup(bgp_clist
,
15458 LARGE_COMMUNITY_LIST_MASTER
);
15460 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15461 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15462 vty_out(vty
, "bgp large-community-list %s %s %s\n",
15463 list
->name
, community_direct_str(entry
->direct
),
15464 community_list_config_str(entry
));
15467 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15468 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15469 vty_out(vty
, "bgp large-community-list %s %s %s %s\n",
15470 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
15473 list
->name
, community_direct_str(entry
->direct
),
15474 community_list_config_str(entry
));
15481 static struct cmd_node community_list_node
= {
15482 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
15485 static void community_list_vty(void)
15487 install_node(&community_list_node
, community_list_config_write
);
15489 /* Community-list. */
15490 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
15491 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
15492 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
15493 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
15494 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
15495 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
15496 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
15497 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
15498 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
15499 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
15500 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
15501 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_list_cmd
);
15502 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
15503 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_list_cmd
);
15504 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
15505 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
15507 /* Extcommunity-list. */
15508 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
15509 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
15510 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
15511 install_element(CONFIG_NODE
,
15512 &no_bgp_extcommunity_list_standard_all_list_cmd
);
15513 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
15514 install_element(CONFIG_NODE
,
15515 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
15516 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
15517 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
15518 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
15519 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
15520 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
15521 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_list_cmd
);
15522 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
15523 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_list_cmd
);
15524 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
15525 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
15527 /* Large Community List */
15528 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
15529 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard1_cmd
);
15530 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
15531 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
15532 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard1_cmd
);
15533 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
15534 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_all_cmd
);
15535 install_element(CONFIG_NODE
,
15536 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
15537 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
15538 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
15539 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
15540 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
15541 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
15542 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
15543 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
15544 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
15545 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
15546 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
15547 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
15548 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
15549 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
15550 install_element(CONFIG_NODE
,
15551 &no_ip_lcommunity_list_name_expanded_all_cmd
);
15552 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
15553 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
15554 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
15555 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
15556 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
15557 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);