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
);
629 /* This is to apply read-only mode on this clear. */
630 if (stype
== BGP_CLEAR_SOFT_NONE
)
631 bgp
->update_delay_over
= 0;
636 /* Clear specified neighbor. */
637 if (sort
== clear_peer
) {
640 /* Make sockunion for lookup. */
641 ret
= str2sockunion(arg
, &su
);
643 peer
= peer_lookup_by_conf_if(bgp
, arg
);
645 peer
= peer_lookup_by_hostname(bgp
, arg
);
648 "Malformed address or name: %s\n",
654 peer
= peer_lookup(bgp
, &su
);
657 "%%BGP: Unknown neighbor - \"%s\"\n",
663 if (!peer
->afc
[afi
][safi
])
664 ret
= BGP_ERR_AF_UNCONFIGURED
;
665 else if (stype
== BGP_CLEAR_SOFT_NONE
)
666 ret
= peer_clear(peer
, NULL
);
668 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
671 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
676 /* Clear all neighbors belonging to a specific peer-group. */
677 if (sort
== clear_group
) {
678 struct peer_group
*group
;
680 group
= peer_group_lookup(bgp
, arg
);
682 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
686 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
687 if (!peer
->afc
[afi
][safi
])
690 if (stype
== BGP_CLEAR_SOFT_NONE
)
691 ret
= peer_clear(peer
, NULL
);
693 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
696 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
703 "%%BGP: No %s peer belonging to peer-group %s is configured\n",
704 afi_safi_print(afi
, safi
), arg
);
709 /* Clear all external (eBGP) neighbors. */
710 if (sort
== clear_external
) {
711 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
712 if (peer
->sort
== BGP_PEER_IBGP
)
715 if (!peer
->afc
[afi
][safi
])
718 if (stype
== BGP_CLEAR_SOFT_NONE
)
719 ret
= peer_clear(peer
, &nnode
);
721 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
724 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
731 "%%BGP: No external %s peer is configured\n",
732 afi_safi_print(afi
, safi
));
737 /* Clear all neighbors belonging to a specific AS. */
738 if (sort
== clear_as
) {
739 as_t as
= strtoul(arg
, NULL
, 10);
741 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
745 if (!peer
->afc
[afi
][safi
])
746 ret
= BGP_ERR_AF_UNCONFIGURED
;
747 else if (stype
== BGP_CLEAR_SOFT_NONE
)
748 ret
= peer_clear(peer
, &nnode
);
750 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
753 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
760 "%%BGP: No %s peer is configured with AS %s\n",
761 afi_safi_print(afi
, safi
), arg
);
769 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
770 safi_t safi
, enum clear_sort sort
,
771 enum bgp_clear_type stype
, const char *arg
)
775 /* BGP structure lookup. */
777 bgp
= bgp_lookup_by_name(name
);
779 vty_out(vty
, "Can't find BGP instance %s\n", name
);
783 bgp
= bgp_get_default();
785 vty_out(vty
, "No BGP process is configured\n");
790 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
793 /* clear soft inbound */
794 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
799 FOREACH_AFI_SAFI (afi
, safi
)
800 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
801 BGP_CLEAR_SOFT_IN
, NULL
);
804 /* clear soft outbound */
805 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
810 FOREACH_AFI_SAFI (afi
, safi
)
811 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
812 BGP_CLEAR_SOFT_OUT
, NULL
);
816 #ifndef VTYSH_EXTRACT_PL
817 #include "bgpd/bgp_vty_clippy.c"
820 DEFUN_HIDDEN (bgp_local_mac
,
822 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
825 "VxLAN Network Identifier\n"
829 "mac-mobility sequence\n"
839 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
840 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
841 vty_out(vty
, "%% Malformed MAC address\n");
844 memset(&ip
, 0, sizeof(ip
));
845 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
847 bgp
= bgp_get_default();
849 vty_out(vty
, "Default BGP instance is not there\n");
853 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
);
855 vty_out(vty
, "Internal error\n");
862 DEFUN_HIDDEN (no_bgp_local_mac
,
863 no_bgp_local_mac_cmd
,
864 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
868 "VxLAN Network Identifier\n"
879 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
880 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
881 vty_out(vty
, "%% Malformed MAC address\n");
884 memset(&ip
, 0, sizeof(ip
));
886 bgp
= bgp_get_default();
888 vty_out(vty
, "Default BGP instance is not there\n");
892 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
894 vty_out(vty
, "Internal error\n");
901 DEFUN (no_synchronization
,
902 no_synchronization_cmd
,
903 "no synchronization",
905 "Perform IGP synchronization\n")
910 DEFUN (no_auto_summary
,
914 "Enable automatic network number summarization\n")
919 /* "router bgp" commands. */
920 DEFUN_NOSH (router_bgp
,
922 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
926 BGP_INSTANCE_HELP_STR
)
929 int idx_view_vrf
= 3;
935 const char *name
= NULL
;
936 enum bgp_instance_type inst_type
;
938 // "router bgp" without an ASN
940 // Pending: Make VRF option available for ASN less config
941 bgp
= bgp_get_default();
944 vty_out(vty
, "%% No BGP process is configured\n");
945 return CMD_WARNING_CONFIG_FAILED
;
948 if (listcount(bm
->bgp
) > 1) {
949 vty_out(vty
, "%% Please specify ASN and VRF\n");
950 return CMD_WARNING_CONFIG_FAILED
;
956 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
958 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
960 name
= argv
[idx_vrf
]->arg
;
962 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
963 if (strmatch(name
, VRF_DEFAULT_NAME
))
966 inst_type
= BGP_INSTANCE_TYPE_VRF
;
967 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
968 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
971 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
972 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
974 ret
= bgp_get(&bgp
, &as
, name
, inst_type
);
976 case BGP_ERR_AS_MISMATCH
:
977 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
978 return CMD_WARNING_CONFIG_FAILED
;
979 case BGP_ERR_INSTANCE_MISMATCH
:
981 "BGP instance name and AS number mismatch\n");
983 "BGP instance is already running; AS is %u\n",
985 return CMD_WARNING_CONFIG_FAILED
;
989 * If we just instantiated the default instance, complete
990 * any pending VRF-VPN leaking that was configured via
991 * earlier "router bgp X vrf FOO" blocks.
993 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
994 vpn_leak_postchange_all();
996 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
997 bgp_vpn_leak_export(bgp
);
998 /* Pending: handle when user tries to change a view to vrf n vv.
1002 /* unset the auto created flag as the user config is now present */
1003 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1004 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1009 /* "no router bgp" commands. */
1010 DEFUN (no_router_bgp
,
1012 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1017 BGP_INSTANCE_HELP_STR
)
1023 const char *name
= NULL
;
1025 // "no router bgp" without an ASN
1027 // Pending: Make VRF option available for ASN less config
1028 bgp
= bgp_get_default();
1031 vty_out(vty
, "%% No BGP process is configured\n");
1032 return CMD_WARNING_CONFIG_FAILED
;
1035 if (listcount(bm
->bgp
) > 1) {
1036 vty_out(vty
, "%% Please specify ASN and VRF\n");
1037 return CMD_WARNING_CONFIG_FAILED
;
1041 vty_out(vty
, "%% Please unconfigure l3vni %u",
1043 return CMD_WARNING_CONFIG_FAILED
;
1046 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1049 name
= argv
[idx_vrf
]->arg
;
1051 /* Lookup bgp structure. */
1052 bgp
= bgp_lookup(as
, name
);
1054 vty_out(vty
, "%% Can't find BGP instance\n");
1055 return CMD_WARNING_CONFIG_FAILED
;
1059 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1061 return CMD_WARNING_CONFIG_FAILED
;
1064 /* Cannot delete default instance if vrf instances exist */
1065 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1066 struct listnode
*node
;
1067 struct bgp
*tmp_bgp
;
1069 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1070 if (tmp_bgp
->inst_type
1071 == BGP_INSTANCE_TYPE_VRF
) {
1073 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1074 return CMD_WARNING_CONFIG_FAILED
;
1080 if (bgp_vpn_leak_unimport(bgp
, vty
))
1081 return CMD_WARNING_CONFIG_FAILED
;
1089 /* BGP router-id. */
1091 DEFPY (bgp_router_id
,
1093 "bgp router-id A.B.C.D",
1095 "Override configured router identifier\n"
1096 "Manually configured router identifier\n")
1098 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1099 bgp_router_id_static_set(bgp
, router_id
);
1103 DEFPY (no_bgp_router_id
,
1104 no_bgp_router_id_cmd
,
1105 "no bgp router-id [A.B.C.D]",
1108 "Override configured router identifier\n"
1109 "Manually configured router identifier\n")
1111 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1113 if (router_id_str
) {
1114 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1115 vty_out(vty
, "%% BGP router-id doesn't match\n");
1116 return CMD_WARNING_CONFIG_FAILED
;
1120 router_id
.s_addr
= 0;
1121 bgp_router_id_static_set(bgp
, router_id
);
1127 /* BGP Cluster ID. */
1128 DEFUN (bgp_cluster_id
,
1130 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1132 "Configure Route-Reflector Cluster-id\n"
1133 "Route-Reflector Cluster-id in IP address format\n"
1134 "Route-Reflector Cluster-id as 32 bit quantity\n")
1136 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1139 struct in_addr cluster
;
1141 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1143 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1144 return CMD_WARNING_CONFIG_FAILED
;
1147 bgp_cluster_id_set(bgp
, &cluster
);
1148 bgp_clear_star_soft_out(vty
, bgp
->name
);
1153 DEFUN (no_bgp_cluster_id
,
1154 no_bgp_cluster_id_cmd
,
1155 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1158 "Configure Route-Reflector Cluster-id\n"
1159 "Route-Reflector Cluster-id in IP address format\n"
1160 "Route-Reflector Cluster-id as 32 bit quantity\n")
1162 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1163 bgp_cluster_id_unset(bgp
);
1164 bgp_clear_star_soft_out(vty
, bgp
->name
);
1169 DEFUN (bgp_confederation_identifier
,
1170 bgp_confederation_identifier_cmd
,
1171 "bgp confederation identifier (1-4294967295)",
1172 "BGP specific commands\n"
1173 "AS confederation parameters\n"
1175 "Set routing domain confederation AS\n")
1177 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1181 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1183 bgp_confederation_id_set(bgp
, as
);
1188 DEFUN (no_bgp_confederation_identifier
,
1189 no_bgp_confederation_identifier_cmd
,
1190 "no bgp confederation identifier [(1-4294967295)]",
1192 "BGP specific commands\n"
1193 "AS confederation parameters\n"
1195 "Set routing domain confederation AS\n")
1197 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1198 bgp_confederation_id_unset(bgp
);
1203 DEFUN (bgp_confederation_peers
,
1204 bgp_confederation_peers_cmd
,
1205 "bgp confederation peers (1-4294967295)...",
1206 "BGP specific commands\n"
1207 "AS confederation parameters\n"
1208 "Peer ASs in BGP confederation\n"
1211 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1216 for (i
= idx_asn
; i
< argc
; i
++) {
1217 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1219 if (bgp
->as
== as
) {
1221 "%% Local member-AS not allowed in confed peer list\n");
1225 bgp_confederation_peers_add(bgp
, as
);
1230 DEFUN (no_bgp_confederation_peers
,
1231 no_bgp_confederation_peers_cmd
,
1232 "no bgp confederation peers (1-4294967295)...",
1234 "BGP specific commands\n"
1235 "AS confederation parameters\n"
1236 "Peer ASs in BGP confederation\n"
1239 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1244 for (i
= idx_asn
; i
< argc
; i
++) {
1245 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1247 bgp_confederation_peers_remove(bgp
, as
);
1253 * Central routine for maximum-paths configuration.
1254 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1255 * @set: 1 for setting values, 0 for removing the max-paths config.
1257 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1258 const char *mpaths
, uint16_t options
,
1261 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1262 uint16_t maxpaths
= 0;
1267 afi
= bgp_node_afi(vty
);
1268 safi
= bgp_node_safi(vty
);
1271 maxpaths
= strtol(mpaths
, NULL
, 10);
1272 if (maxpaths
> multipath_num
) {
1274 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1275 maxpaths
, multipath_num
);
1276 return CMD_WARNING_CONFIG_FAILED
;
1278 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1281 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1285 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1286 (set
== 1) ? "" : "un",
1287 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1288 maxpaths
, afi
, safi
);
1289 return CMD_WARNING_CONFIG_FAILED
;
1292 bgp_recalculate_all_bestpaths(bgp
);
1297 DEFUN (bgp_maxmed_admin
,
1298 bgp_maxmed_admin_cmd
,
1299 "bgp max-med administrative ",
1301 "Advertise routes with max-med\n"
1302 "Administratively applied, for an indefinite period\n")
1304 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1306 bgp
->v_maxmed_admin
= 1;
1307 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1309 bgp_maxmed_update(bgp
);
1314 DEFUN (bgp_maxmed_admin_medv
,
1315 bgp_maxmed_admin_medv_cmd
,
1316 "bgp max-med administrative (0-4294967295)",
1318 "Advertise routes with max-med\n"
1319 "Administratively applied, for an indefinite period\n"
1320 "Max MED value to be used\n")
1322 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1325 bgp
->v_maxmed_admin
= 1;
1326 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1328 bgp_maxmed_update(bgp
);
1333 DEFUN (no_bgp_maxmed_admin
,
1334 no_bgp_maxmed_admin_cmd
,
1335 "no bgp max-med administrative [(0-4294967295)]",
1338 "Advertise routes with max-med\n"
1339 "Administratively applied, for an indefinite period\n"
1340 "Max MED value to be used\n")
1342 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1343 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1344 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1345 bgp_maxmed_update(bgp
);
1350 DEFUN (bgp_maxmed_onstartup
,
1351 bgp_maxmed_onstartup_cmd
,
1352 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1354 "Advertise routes with max-med\n"
1355 "Effective on a startup\n"
1356 "Time (seconds) period for max-med\n"
1357 "Max MED value to be used\n")
1359 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1362 argv_find(argv
, argc
, "(5-86400)", &idx
);
1363 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1364 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1365 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1367 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1369 bgp_maxmed_update(bgp
);
1374 DEFUN (no_bgp_maxmed_onstartup
,
1375 no_bgp_maxmed_onstartup_cmd
,
1376 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1379 "Advertise routes with max-med\n"
1380 "Effective on a startup\n"
1381 "Time (seconds) period for max-med\n"
1382 "Max MED value to be used\n")
1384 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1386 /* Cancel max-med onstartup if its on */
1387 if (bgp
->t_maxmed_onstartup
) {
1388 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1389 bgp
->maxmed_onstartup_over
= 1;
1392 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1393 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1395 bgp_maxmed_update(bgp
);
1400 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1403 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1404 uint16_t update_delay
;
1405 uint16_t establish_wait
;
1407 update_delay
= strtoul(delay
, NULL
, 10);
1409 if (!wait
) /* update-delay <delay> */
1411 bgp
->v_update_delay
= update_delay
;
1412 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1416 /* update-delay <delay> <establish-wait> */
1417 establish_wait
= atoi(wait
);
1418 if (update_delay
< establish_wait
) {
1420 "%%Failed: update-delay less than the establish-wait!\n");
1421 return CMD_WARNING_CONFIG_FAILED
;
1424 bgp
->v_update_delay
= update_delay
;
1425 bgp
->v_establish_wait
= establish_wait
;
1430 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1432 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1434 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1435 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1440 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1442 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1443 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1444 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1445 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1451 /* Update-delay configuration */
1452 DEFUN (bgp_update_delay
,
1453 bgp_update_delay_cmd
,
1454 "update-delay (0-3600)",
1455 "Force initial delay for best-path and updates\n"
1459 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1462 DEFUN (bgp_update_delay_establish_wait
,
1463 bgp_update_delay_establish_wait_cmd
,
1464 "update-delay (0-3600) (1-3600)",
1465 "Force initial delay for best-path and updates\n"
1470 int idx_number_2
= 2;
1471 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1472 argv
[idx_number_2
]->arg
);
1475 /* Update-delay deconfiguration */
1476 DEFUN (no_bgp_update_delay
,
1477 no_bgp_update_delay_cmd
,
1478 "no update-delay [(0-3600) [(1-3600)]]",
1480 "Force initial delay for best-path and updates\n"
1484 return bgp_update_delay_deconfig_vty(vty
);
1488 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1491 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1494 uint32_t quanta
= strtoul(num
, NULL
, 10);
1495 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
,
1496 memory_order_relaxed
);
1498 atomic_store_explicit(&bgp
->wpkt_quanta
, BGP_WRITE_PACKET_MAX
,
1499 memory_order_relaxed
);
1505 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1508 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1511 uint32_t quanta
= strtoul(num
, NULL
, 10);
1512 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
,
1513 memory_order_relaxed
);
1515 atomic_store_explicit(&bgp
->rpkt_quanta
, BGP_READ_PACKET_MAX
,
1516 memory_order_relaxed
);
1522 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1525 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1526 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1527 vty_out(vty
, " write-quanta %d\n", quanta
);
1530 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1533 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1534 if (quanta
!= BGP_READ_PACKET_MAX
)
1535 vty_out(vty
, " read-quanta %d\n", quanta
);
1538 /* Packet quanta configuration */
1539 DEFUN (bgp_wpkt_quanta
,
1540 bgp_wpkt_quanta_cmd
,
1541 "write-quanta (1-10)",
1542 "How many packets to write to peer socket per run\n"
1543 "Number of packets\n")
1546 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1549 DEFUN (no_bgp_wpkt_quanta
,
1550 no_bgp_wpkt_quanta_cmd
,
1551 "no write-quanta (1-10)",
1553 "How many packets to write to peer socket per I/O cycle\n"
1554 "Number of packets\n")
1557 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1560 DEFUN (bgp_rpkt_quanta
,
1561 bgp_rpkt_quanta_cmd
,
1562 "read-quanta (1-10)",
1563 "How many packets to read from peer socket per I/O cycle\n"
1564 "Number of packets\n")
1567 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1570 DEFUN (no_bgp_rpkt_quanta
,
1571 no_bgp_rpkt_quanta_cmd
,
1572 "no read-quanta (1-10)",
1574 "How many packets to read from peer socket per I/O cycle\n"
1575 "Number of packets\n")
1578 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1581 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1583 if (!bgp
->heuristic_coalesce
)
1584 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1588 DEFUN (bgp_coalesce_time
,
1589 bgp_coalesce_time_cmd
,
1590 "coalesce-time (0-4294967295)",
1591 "Subgroup coalesce timer\n"
1592 "Subgroup coalesce timer value (in ms)\n")
1594 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1597 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1598 bgp
->heuristic_coalesce
= false;
1599 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1603 DEFUN (no_bgp_coalesce_time
,
1604 no_bgp_coalesce_time_cmd
,
1605 "no coalesce-time (0-4294967295)",
1607 "Subgroup coalesce timer\n"
1608 "Subgroup coalesce timer value (in ms)\n")
1610 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1612 bgp
->heuristic_coalesce
= true;
1613 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1617 /* Maximum-paths configuration */
1618 DEFUN (bgp_maxpaths
,
1620 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1621 "Forward packets over multiple paths\n"
1622 "Number of paths\n")
1625 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1626 argv
[idx_number
]->arg
, 0, 1);
1629 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1630 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1631 "Forward packets over multiple paths\n"
1632 "Number of paths\n")
1634 DEFUN (bgp_maxpaths_ibgp
,
1635 bgp_maxpaths_ibgp_cmd
,
1636 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1637 "Forward packets over multiple paths\n"
1639 "Number of paths\n")
1642 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1643 argv
[idx_number
]->arg
, 0, 1);
1646 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1647 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1648 "Forward packets over multiple paths\n"
1650 "Number of paths\n")
1652 DEFUN (bgp_maxpaths_ibgp_cluster
,
1653 bgp_maxpaths_ibgp_cluster_cmd
,
1654 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1655 "Forward packets over multiple paths\n"
1658 "Match the cluster length\n")
1661 return bgp_maxpaths_config_vty(
1662 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1663 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1666 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1667 "maximum-paths ibgp " CMD_RANGE_STR(
1668 1, MULTIPATH_NUM
) " equal-cluster-length",
1669 "Forward packets over multiple paths\n"
1672 "Match the cluster length\n")
1674 DEFUN (no_bgp_maxpaths
,
1675 no_bgp_maxpaths_cmd
,
1676 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1678 "Forward packets over multiple paths\n"
1679 "Number of paths\n")
1681 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1684 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1685 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1686 "Forward packets over multiple paths\n"
1687 "Number of paths\n")
1689 DEFUN (no_bgp_maxpaths_ibgp
,
1690 no_bgp_maxpaths_ibgp_cmd
,
1691 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1693 "Forward packets over multiple paths\n"
1696 "Match the cluster length\n")
1698 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1701 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1702 "no maximum-paths ibgp [" CMD_RANGE_STR(
1703 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1705 "Forward packets over multiple paths\n"
1708 "Match the cluster length\n")
1710 void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1713 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1714 vty_out(vty
, " maximum-paths %d\n",
1715 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1718 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1719 vty_out(vty
, " maximum-paths ibgp %d",
1720 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1721 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1722 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1723 vty_out(vty
, " equal-cluster-length");
1732 "timers bgp (0-65535) (0-65535)",
1733 "Adjust routing timers\n"
1735 "Keepalive interval\n"
1738 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1740 int idx_number_2
= 3;
1741 unsigned long keepalive
= 0;
1742 unsigned long holdtime
= 0;
1744 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1745 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1747 /* Holdtime value check. */
1748 if (holdtime
< 3 && holdtime
!= 0) {
1750 "%% hold time value must be either 0 or greater than 3\n");
1751 return CMD_WARNING_CONFIG_FAILED
;
1754 bgp_timers_set(bgp
, keepalive
, holdtime
);
1759 DEFUN (no_bgp_timers
,
1761 "no timers bgp [(0-65535) (0-65535)]",
1763 "Adjust routing timers\n"
1765 "Keepalive interval\n"
1768 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1769 bgp_timers_unset(bgp
);
1775 DEFUN (bgp_client_to_client_reflection
,
1776 bgp_client_to_client_reflection_cmd
,
1777 "bgp client-to-client reflection",
1778 "BGP specific commands\n"
1779 "Configure client to client route reflection\n"
1780 "reflection of routes allowed\n")
1782 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1783 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1784 bgp_clear_star_soft_out(vty
, bgp
->name
);
1789 DEFUN (no_bgp_client_to_client_reflection
,
1790 no_bgp_client_to_client_reflection_cmd
,
1791 "no bgp client-to-client reflection",
1793 "BGP specific commands\n"
1794 "Configure client to client route reflection\n"
1795 "reflection of routes allowed\n")
1797 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1798 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1799 bgp_clear_star_soft_out(vty
, bgp
->name
);
1804 /* "bgp always-compare-med" configuration. */
1805 DEFUN (bgp_always_compare_med
,
1806 bgp_always_compare_med_cmd
,
1807 "bgp always-compare-med",
1808 "BGP specific commands\n"
1809 "Allow comparing MED from different neighbors\n")
1811 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1812 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1813 bgp_recalculate_all_bestpaths(bgp
);
1818 DEFUN (no_bgp_always_compare_med
,
1819 no_bgp_always_compare_med_cmd
,
1820 "no bgp always-compare-med",
1822 "BGP specific commands\n"
1823 "Allow comparing MED from different neighbors\n")
1825 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1826 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1827 bgp_recalculate_all_bestpaths(bgp
);
1833 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
1834 "bgp ebgp-requires-policy",
1835 "BGP specific commands\n"
1836 "Require in and out policy for eBGP peers (RFC8212)\n")
1838 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1839 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_ENABLED
;
1843 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
1844 "no bgp ebgp-requires-policy",
1846 "BGP specific commands\n"
1847 "Require in and out policy for eBGP peers (RFC8212)\n")
1849 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1850 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_DISABLED
;
1855 /* "bgp deterministic-med" configuration. */
1856 DEFUN (bgp_deterministic_med
,
1857 bgp_deterministic_med_cmd
,
1858 "bgp deterministic-med",
1859 "BGP specific commands\n"
1860 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1862 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1864 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1865 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1866 bgp_recalculate_all_bestpaths(bgp
);
1872 DEFUN (no_bgp_deterministic_med
,
1873 no_bgp_deterministic_med_cmd
,
1874 "no bgp deterministic-med",
1876 "BGP specific commands\n"
1877 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1879 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1880 int bestpath_per_as_used
;
1884 struct listnode
*node
, *nnode
;
1886 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1887 bestpath_per_as_used
= 0;
1889 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1890 FOREACH_AFI_SAFI (afi
, safi
)
1891 if (bgp_addpath_dmed_required(
1892 peer
->addpath_type
[afi
][safi
])) {
1893 bestpath_per_as_used
= 1;
1897 if (bestpath_per_as_used
)
1901 if (bestpath_per_as_used
) {
1903 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
1904 return CMD_WARNING_CONFIG_FAILED
;
1906 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1907 bgp_recalculate_all_bestpaths(bgp
);
1914 /* "bgp graceful-restart" configuration. */
1915 DEFUN (bgp_graceful_restart
,
1916 bgp_graceful_restart_cmd
,
1917 "bgp graceful-restart",
1918 "BGP specific commands\n"
1919 "Graceful restart capability parameters\n")
1921 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1922 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1926 DEFUN (no_bgp_graceful_restart
,
1927 no_bgp_graceful_restart_cmd
,
1928 "no bgp graceful-restart",
1930 "BGP specific commands\n"
1931 "Graceful restart capability parameters\n")
1933 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1934 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1938 DEFUN (bgp_graceful_restart_stalepath_time
,
1939 bgp_graceful_restart_stalepath_time_cmd
,
1940 "bgp graceful-restart stalepath-time (1-4095)",
1941 "BGP specific commands\n"
1942 "Graceful restart capability parameters\n"
1943 "Set the max time to hold onto restarting peer's stale paths\n"
1944 "Delay value (seconds)\n")
1946 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1950 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1951 bgp
->stalepath_time
= stalepath
;
1955 DEFUN (bgp_graceful_restart_restart_time
,
1956 bgp_graceful_restart_restart_time_cmd
,
1957 "bgp graceful-restart restart-time (1-4095)",
1958 "BGP specific commands\n"
1959 "Graceful restart capability parameters\n"
1960 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1961 "Delay value (seconds)\n")
1963 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1967 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1968 bgp
->restart_time
= restart
;
1972 DEFUN (no_bgp_graceful_restart_stalepath_time
,
1973 no_bgp_graceful_restart_stalepath_time_cmd
,
1974 "no bgp graceful-restart stalepath-time [(1-4095)]",
1976 "BGP specific commands\n"
1977 "Graceful restart capability parameters\n"
1978 "Set the max time to hold onto restarting peer's stale paths\n"
1979 "Delay value (seconds)\n")
1981 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1983 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
1987 DEFUN (no_bgp_graceful_restart_restart_time
,
1988 no_bgp_graceful_restart_restart_time_cmd
,
1989 "no bgp graceful-restart restart-time [(1-4095)]",
1991 "BGP specific commands\n"
1992 "Graceful restart capability parameters\n"
1993 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1994 "Delay value (seconds)\n")
1996 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1998 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2002 DEFUN (bgp_graceful_restart_preserve_fw
,
2003 bgp_graceful_restart_preserve_fw_cmd
,
2004 "bgp graceful-restart preserve-fw-state",
2005 "BGP specific commands\n"
2006 "Graceful restart capability parameters\n"
2007 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2009 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2010 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2014 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2015 no_bgp_graceful_restart_preserve_fw_cmd
,
2016 "no bgp graceful-restart preserve-fw-state",
2018 "BGP specific commands\n"
2019 "Graceful restart capability parameters\n"
2020 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2022 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2023 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2027 /* "bgp graceful-shutdown" configuration */
2028 DEFUN (bgp_graceful_shutdown
,
2029 bgp_graceful_shutdown_cmd
,
2030 "bgp graceful-shutdown",
2032 "Graceful shutdown parameters\n")
2034 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2036 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2037 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2038 bgp_static_redo_import_check(bgp
);
2039 bgp_redistribute_redo(bgp
);
2040 bgp_clear_star_soft_out(vty
, bgp
->name
);
2041 bgp_clear_star_soft_in(vty
, bgp
->name
);
2047 DEFUN (no_bgp_graceful_shutdown
,
2048 no_bgp_graceful_shutdown_cmd
,
2049 "no bgp graceful-shutdown",
2052 "Graceful shutdown parameters\n")
2054 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2056 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2057 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2058 bgp_static_redo_import_check(bgp
);
2059 bgp_redistribute_redo(bgp
);
2060 bgp_clear_star_soft_out(vty
, bgp
->name
);
2061 bgp_clear_star_soft_in(vty
, bgp
->name
);
2067 /* "bgp fast-external-failover" configuration. */
2068 DEFUN (bgp_fast_external_failover
,
2069 bgp_fast_external_failover_cmd
,
2070 "bgp fast-external-failover",
2072 "Immediately reset session if a link to a directly connected external peer goes down\n")
2074 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2075 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2079 DEFUN (no_bgp_fast_external_failover
,
2080 no_bgp_fast_external_failover_cmd
,
2081 "no bgp fast-external-failover",
2084 "Immediately reset session if a link to a directly connected external peer goes down\n")
2086 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2087 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2091 /* "bgp bestpath compare-routerid" configuration. */
2092 DEFUN (bgp_bestpath_compare_router_id
,
2093 bgp_bestpath_compare_router_id_cmd
,
2094 "bgp bestpath compare-routerid",
2095 "BGP specific commands\n"
2096 "Change the default bestpath selection\n"
2097 "Compare router-id for identical EBGP paths\n")
2099 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2100 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2101 bgp_recalculate_all_bestpaths(bgp
);
2106 DEFUN (no_bgp_bestpath_compare_router_id
,
2107 no_bgp_bestpath_compare_router_id_cmd
,
2108 "no bgp bestpath compare-routerid",
2110 "BGP specific commands\n"
2111 "Change the default bestpath selection\n"
2112 "Compare router-id for identical EBGP paths\n")
2114 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2115 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2116 bgp_recalculate_all_bestpaths(bgp
);
2121 /* "bgp bestpath as-path ignore" configuration. */
2122 DEFUN (bgp_bestpath_aspath_ignore
,
2123 bgp_bestpath_aspath_ignore_cmd
,
2124 "bgp bestpath as-path ignore",
2125 "BGP specific commands\n"
2126 "Change the default bestpath selection\n"
2127 "AS-path attribute\n"
2128 "Ignore as-path length in selecting a route\n")
2130 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2131 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2132 bgp_recalculate_all_bestpaths(bgp
);
2137 DEFUN (no_bgp_bestpath_aspath_ignore
,
2138 no_bgp_bestpath_aspath_ignore_cmd
,
2139 "no bgp bestpath as-path ignore",
2141 "BGP specific commands\n"
2142 "Change the default bestpath selection\n"
2143 "AS-path attribute\n"
2144 "Ignore as-path length in selecting a route\n")
2146 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2147 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2148 bgp_recalculate_all_bestpaths(bgp
);
2153 /* "bgp bestpath as-path confed" configuration. */
2154 DEFUN (bgp_bestpath_aspath_confed
,
2155 bgp_bestpath_aspath_confed_cmd
,
2156 "bgp bestpath as-path confed",
2157 "BGP specific commands\n"
2158 "Change the default bestpath selection\n"
2159 "AS-path attribute\n"
2160 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2162 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2163 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2164 bgp_recalculate_all_bestpaths(bgp
);
2169 DEFUN (no_bgp_bestpath_aspath_confed
,
2170 no_bgp_bestpath_aspath_confed_cmd
,
2171 "no bgp bestpath as-path confed",
2173 "BGP specific commands\n"
2174 "Change the default bestpath selection\n"
2175 "AS-path attribute\n"
2176 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2178 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2179 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2180 bgp_recalculate_all_bestpaths(bgp
);
2185 /* "bgp bestpath as-path multipath-relax" configuration. */
2186 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2187 bgp_bestpath_aspath_multipath_relax_cmd
,
2188 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2189 "BGP specific commands\n"
2190 "Change the default bestpath selection\n"
2191 "AS-path attribute\n"
2192 "Allow load sharing across routes that have different AS paths (but same length)\n"
2193 "Generate an AS_SET\n"
2194 "Do not generate an AS_SET\n")
2196 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2198 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2200 /* no-as-set is now the default behavior so we can silently
2202 if (argv_find(argv
, argc
, "as-set", &idx
))
2203 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2205 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2207 bgp_recalculate_all_bestpaths(bgp
);
2212 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2213 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2214 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2216 "BGP specific commands\n"
2217 "Change the default bestpath selection\n"
2218 "AS-path attribute\n"
2219 "Allow load sharing across routes that have different AS paths (but same length)\n"
2220 "Generate an AS_SET\n"
2221 "Do not generate an AS_SET\n")
2223 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2224 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2225 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2226 bgp_recalculate_all_bestpaths(bgp
);
2231 /* "bgp log-neighbor-changes" configuration. */
2232 DEFUN (bgp_log_neighbor_changes
,
2233 bgp_log_neighbor_changes_cmd
,
2234 "bgp log-neighbor-changes",
2235 "BGP specific commands\n"
2236 "Log neighbor up/down and reset reason\n")
2238 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2239 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2243 DEFUN (no_bgp_log_neighbor_changes
,
2244 no_bgp_log_neighbor_changes_cmd
,
2245 "no bgp log-neighbor-changes",
2247 "BGP specific commands\n"
2248 "Log neighbor up/down and reset reason\n")
2250 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2251 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2255 /* "bgp bestpath med" configuration. */
2256 DEFUN (bgp_bestpath_med
,
2257 bgp_bestpath_med_cmd
,
2258 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2259 "BGP specific commands\n"
2260 "Change the default bestpath selection\n"
2262 "Compare MED among confederation paths\n"
2263 "Treat missing MED as the least preferred one\n"
2264 "Treat missing MED as the least preferred one\n"
2265 "Compare MED among confederation paths\n")
2267 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2270 if (argv_find(argv
, argc
, "confed", &idx
))
2271 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2273 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2274 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2276 bgp_recalculate_all_bestpaths(bgp
);
2281 DEFUN (no_bgp_bestpath_med
,
2282 no_bgp_bestpath_med_cmd
,
2283 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2285 "BGP specific commands\n"
2286 "Change the default bestpath selection\n"
2288 "Compare MED among confederation paths\n"
2289 "Treat missing MED as the least preferred one\n"
2290 "Treat missing MED as the least preferred one\n"
2291 "Compare MED among confederation paths\n")
2293 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2296 if (argv_find(argv
, argc
, "confed", &idx
))
2297 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2299 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2300 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2302 bgp_recalculate_all_bestpaths(bgp
);
2307 /* "no bgp default ipv4-unicast". */
2308 DEFUN (no_bgp_default_ipv4_unicast
,
2309 no_bgp_default_ipv4_unicast_cmd
,
2310 "no bgp default ipv4-unicast",
2312 "BGP specific commands\n"
2313 "Configure BGP defaults\n"
2314 "Activate ipv4-unicast for a peer by default\n")
2316 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2317 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2321 DEFUN (bgp_default_ipv4_unicast
,
2322 bgp_default_ipv4_unicast_cmd
,
2323 "bgp default ipv4-unicast",
2324 "BGP specific commands\n"
2325 "Configure BGP defaults\n"
2326 "Activate ipv4-unicast for a peer by default\n")
2328 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2329 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2333 /* Display hostname in certain command outputs */
2334 DEFUN (bgp_default_show_hostname
,
2335 bgp_default_show_hostname_cmd
,
2336 "bgp default show-hostname",
2337 "BGP specific commands\n"
2338 "Configure BGP defaults\n"
2339 "Show hostname in certain command outputs\n")
2341 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2342 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2346 DEFUN (no_bgp_default_show_hostname
,
2347 no_bgp_default_show_hostname_cmd
,
2348 "no bgp default show-hostname",
2350 "BGP specific commands\n"
2351 "Configure BGP defaults\n"
2352 "Show hostname in certain command outputs\n")
2354 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2355 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2359 /* "bgp network import-check" configuration. */
2360 DEFUN (bgp_network_import_check
,
2361 bgp_network_import_check_cmd
,
2362 "bgp network import-check",
2363 "BGP specific commands\n"
2364 "BGP network command\n"
2365 "Check BGP network route exists in IGP\n")
2367 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2368 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2369 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2370 bgp_static_redo_import_check(bgp
);
2376 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2377 "bgp network import-check exact",
2378 "BGP specific commands\n"
2379 "BGP network command\n"
2380 "Check BGP network route exists in IGP\n"
2381 "Match route precisely\n")
2383 DEFUN (no_bgp_network_import_check
,
2384 no_bgp_network_import_check_cmd
,
2385 "no bgp network import-check",
2387 "BGP specific commands\n"
2388 "BGP network command\n"
2389 "Check BGP network route exists in IGP\n")
2391 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2392 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2393 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2394 bgp_static_redo_import_check(bgp
);
2400 DEFUN (bgp_default_local_preference
,
2401 bgp_default_local_preference_cmd
,
2402 "bgp default local-preference (0-4294967295)",
2403 "BGP specific commands\n"
2404 "Configure BGP defaults\n"
2405 "local preference (higher=more preferred)\n"
2406 "Configure default local preference value\n")
2408 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2410 uint32_t local_pref
;
2412 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2414 bgp_default_local_preference_set(bgp
, local_pref
);
2415 bgp_clear_star_soft_in(vty
, bgp
->name
);
2420 DEFUN (no_bgp_default_local_preference
,
2421 no_bgp_default_local_preference_cmd
,
2422 "no bgp default local-preference [(0-4294967295)]",
2424 "BGP specific commands\n"
2425 "Configure BGP defaults\n"
2426 "local preference (higher=more preferred)\n"
2427 "Configure default local preference value\n")
2429 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2430 bgp_default_local_preference_unset(bgp
);
2431 bgp_clear_star_soft_in(vty
, bgp
->name
);
2437 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2438 bgp_default_subgroup_pkt_queue_max_cmd
,
2439 "bgp default subgroup-pkt-queue-max (20-100)",
2440 "BGP specific commands\n"
2441 "Configure BGP defaults\n"
2442 "subgroup-pkt-queue-max\n"
2443 "Configure subgroup packet queue max\n")
2445 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2449 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2451 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2456 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2457 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2458 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2460 "BGP specific commands\n"
2461 "Configure BGP defaults\n"
2462 "subgroup-pkt-queue-max\n"
2463 "Configure subgroup packet queue max\n")
2465 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2466 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2471 DEFUN (bgp_rr_allow_outbound_policy
,
2472 bgp_rr_allow_outbound_policy_cmd
,
2473 "bgp route-reflector allow-outbound-policy",
2474 "BGP specific commands\n"
2475 "Allow modifications made by out route-map\n"
2476 "on ibgp neighbors\n")
2478 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2480 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2481 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2482 update_group_announce_rrclients(bgp
);
2483 bgp_clear_star_soft_out(vty
, bgp
->name
);
2489 DEFUN (no_bgp_rr_allow_outbound_policy
,
2490 no_bgp_rr_allow_outbound_policy_cmd
,
2491 "no bgp route-reflector allow-outbound-policy",
2493 "BGP specific commands\n"
2494 "Allow modifications made by out route-map\n"
2495 "on ibgp neighbors\n")
2497 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2499 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2500 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2501 update_group_announce_rrclients(bgp
);
2502 bgp_clear_star_soft_out(vty
, bgp
->name
);
2508 DEFUN (bgp_listen_limit
,
2509 bgp_listen_limit_cmd
,
2510 "bgp listen limit (1-5000)",
2511 "BGP specific commands\n"
2512 "Configure BGP defaults\n"
2513 "maximum number of BGP Dynamic Neighbors that can be created\n"
2514 "Configure Dynamic Neighbors listen limit value\n")
2516 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2520 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2522 bgp_listen_limit_set(bgp
, listen_limit
);
2527 DEFUN (no_bgp_listen_limit
,
2528 no_bgp_listen_limit_cmd
,
2529 "no bgp listen limit [(1-5000)]",
2530 "BGP specific commands\n"
2531 "Configure BGP defaults\n"
2532 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2533 "Configure Dynamic Neighbors listen limit value to default\n"
2534 "Configure Dynamic Neighbors listen limit value\n")
2536 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2537 bgp_listen_limit_unset(bgp
);
2543 * Check if this listen range is already configured. Check for exact
2544 * match or overlap based on input.
2546 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2547 struct prefix
*range
, int exact
)
2549 struct listnode
*node
, *nnode
;
2550 struct listnode
*node1
, *nnode1
;
2551 struct peer_group
*group
;
2556 afi
= family2afi(range
->family
);
2557 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2558 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2561 match
= prefix_same(range
, lr
);
2563 match
= (prefix_match(range
, lr
)
2564 || prefix_match(lr
, range
));
2573 DEFUN (bgp_listen_range
,
2574 bgp_listen_range_cmd
,
2575 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
2576 "BGP specific commands\n"
2577 "Configure BGP dynamic neighbors listen range\n"
2578 "Configure BGP dynamic neighbors listen range\n"
2580 "Member of the peer-group\n"
2581 "Peer-group name\n")
2583 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2584 struct prefix range
;
2585 struct peer_group
*group
, *existing_group
;
2590 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2591 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2592 char *prefix
= argv
[idx
]->arg
;
2593 argv_find(argv
, argc
, "PGNAME", &idx
);
2594 char *peergroup
= argv
[idx
]->arg
;
2596 /* Convert IP prefix string to struct prefix. */
2597 ret
= str2prefix(prefix
, &range
);
2599 vty_out(vty
, "%% Malformed listen range\n");
2600 return CMD_WARNING_CONFIG_FAILED
;
2603 afi
= family2afi(range
.family
);
2605 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2607 "%% Malformed listen range (link-local address)\n");
2608 return CMD_WARNING_CONFIG_FAILED
;
2613 /* Check if same listen range is already configured. */
2614 existing_group
= listen_range_exists(bgp
, &range
, 1);
2615 if (existing_group
) {
2616 if (strcmp(existing_group
->name
, peergroup
) == 0)
2620 "%% Same listen range is attached to peer-group %s\n",
2621 existing_group
->name
);
2622 return CMD_WARNING_CONFIG_FAILED
;
2626 /* Check if an overlapping listen range exists. */
2627 if (listen_range_exists(bgp
, &range
, 0)) {
2629 "%% Listen range overlaps with existing listen range\n");
2630 return CMD_WARNING_CONFIG_FAILED
;
2633 group
= peer_group_lookup(bgp
, peergroup
);
2635 vty_out(vty
, "%% Configure the peer-group first\n");
2636 return CMD_WARNING_CONFIG_FAILED
;
2639 ret
= peer_group_listen_range_add(group
, &range
);
2640 return bgp_vty_return(vty
, ret
);
2643 DEFUN (no_bgp_listen_range
,
2644 no_bgp_listen_range_cmd
,
2645 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
2647 "BGP specific commands\n"
2648 "Unconfigure BGP dynamic neighbors listen range\n"
2649 "Unconfigure BGP dynamic neighbors listen range\n"
2651 "Member of the peer-group\n"
2652 "Peer-group name\n")
2654 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2655 struct prefix range
;
2656 struct peer_group
*group
;
2661 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2662 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2663 char *prefix
= argv
[idx
]->arg
;
2664 argv_find(argv
, argc
, "WORD", &idx
);
2665 char *peergroup
= argv
[idx
]->arg
;
2667 /* Convert IP prefix string to struct prefix. */
2668 ret
= str2prefix(prefix
, &range
);
2670 vty_out(vty
, "%% Malformed listen range\n");
2671 return CMD_WARNING_CONFIG_FAILED
;
2674 afi
= family2afi(range
.family
);
2676 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2678 "%% Malformed listen range (link-local address)\n");
2679 return CMD_WARNING_CONFIG_FAILED
;
2684 group
= peer_group_lookup(bgp
, peergroup
);
2686 vty_out(vty
, "%% Peer-group does not exist\n");
2687 return CMD_WARNING_CONFIG_FAILED
;
2690 ret
= peer_group_listen_range_del(group
, &range
);
2691 return bgp_vty_return(vty
, ret
);
2694 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2696 struct peer_group
*group
;
2697 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2698 struct prefix
*range
;
2700 char buf
[PREFIX2STR_BUFFER
];
2702 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2703 vty_out(vty
, " bgp listen limit %d\n",
2704 bgp
->dynamic_neighbors_limit
);
2706 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2707 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2708 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2710 prefix2str(range
, buf
, sizeof(buf
));
2712 " bgp listen range %s peer-group %s\n",
2720 DEFUN (bgp_disable_connected_route_check
,
2721 bgp_disable_connected_route_check_cmd
,
2722 "bgp disable-ebgp-connected-route-check",
2723 "BGP specific commands\n"
2724 "Disable checking if nexthop is connected on ebgp sessions\n")
2726 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2727 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2728 bgp_clear_star_soft_in(vty
, bgp
->name
);
2733 DEFUN (no_bgp_disable_connected_route_check
,
2734 no_bgp_disable_connected_route_check_cmd
,
2735 "no bgp disable-ebgp-connected-route-check",
2737 "BGP specific commands\n"
2738 "Disable checking if nexthop is connected on ebgp sessions\n")
2740 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2741 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2742 bgp_clear_star_soft_in(vty
, bgp
->name
);
2748 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2749 const char *as_str
, afi_t afi
, safi_t safi
)
2751 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2754 int as_type
= AS_SPECIFIED
;
2757 if (as_str
[0] == 'i') {
2759 as_type
= AS_INTERNAL
;
2760 } else if (as_str
[0] == 'e') {
2762 as_type
= AS_EXTERNAL
;
2764 /* Get AS number. */
2765 as
= strtoul(as_str
, NULL
, 10);
2768 /* If peer is peer group or interface peer, call proper function. */
2769 ret
= str2sockunion(peer_str
, &su
);
2773 /* Check if existing interface peer */
2774 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
2776 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2779 /* if not interface peer, check peer-group settings */
2780 if (ret
< 0 && !peer
) {
2781 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2784 "%% Create the peer-group or interface first\n");
2785 return CMD_WARNING_CONFIG_FAILED
;
2790 if (peer_address_self_check(bgp
, &su
)) {
2792 "%% Can not configure the local system as neighbor\n");
2793 return CMD_WARNING_CONFIG_FAILED
;
2795 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2798 /* This peer belongs to peer group. */
2800 case BGP_ERR_PEER_GROUP_MEMBER
:
2802 "%% Peer-group member cannot override remote-as of peer-group\n");
2803 return CMD_WARNING_CONFIG_FAILED
;
2804 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2806 "%% Peer-group members must be all internal or all external\n");
2807 return CMD_WARNING_CONFIG_FAILED
;
2809 return bgp_vty_return(vty
, ret
);
2812 DEFUN (bgp_default_shutdown
,
2813 bgp_default_shutdown_cmd
,
2814 "[no] bgp default shutdown",
2817 "Configure BGP defaults\n"
2818 "Apply administrative shutdown to newly configured peers\n")
2820 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2821 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2825 DEFUN (neighbor_remote_as
,
2826 neighbor_remote_as_cmd
,
2827 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2830 "Specify a BGP neighbor\n"
2832 "Internal BGP peer\n"
2833 "External BGP peer\n")
2836 int idx_remote_as
= 3;
2837 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2838 argv
[idx_remote_as
]->arg
, AFI_IP
,
2842 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2843 afi_t afi
, safi_t safi
, int v6only
,
2844 const char *peer_group_name
,
2847 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2849 int as_type
= AS_UNSPECIFIED
;
2851 struct peer_group
*group
;
2855 group
= peer_group_lookup(bgp
, conf_if
);
2858 vty_out(vty
, "%% Name conflict with peer-group \n");
2859 return CMD_WARNING_CONFIG_FAILED
;
2863 if (as_str
[0] == 'i') {
2864 as_type
= AS_INTERNAL
;
2865 } else if (as_str
[0] == 'e') {
2866 as_type
= AS_EXTERNAL
;
2868 /* Get AS number. */
2869 as
= strtoul(as_str
, NULL
, 10);
2870 as_type
= AS_SPECIFIED
;
2874 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2877 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
2880 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2881 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2882 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2883 as_type
, 0, 0, NULL
);
2885 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2886 as_type
, afi
, safi
, NULL
);
2889 vty_out(vty
, "%% BGP failed to create peer\n");
2890 return CMD_WARNING_CONFIG_FAILED
;
2894 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2896 /* Request zebra to initiate IPv6 RAs on this interface. We do
2898 * any unnumbered peer in order to not worry about run-time
2900 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2902 * gets deleted later etc.)
2905 bgp_zebra_initiate_radv(bgp
, peer
);
2908 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2909 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2911 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2913 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2915 /* v6only flag changed. Reset bgp seesion */
2916 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2917 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2918 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2919 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2921 bgp_session_reset(peer
);
2924 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
2925 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
2926 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
2927 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
2930 if (peer_group_name
) {
2931 group
= peer_group_lookup(bgp
, peer_group_name
);
2933 vty_out(vty
, "%% Configure the peer-group first\n");
2934 return CMD_WARNING_CONFIG_FAILED
;
2937 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
2940 return bgp_vty_return(vty
, ret
);
2943 DEFUN (neighbor_interface_config
,
2944 neighbor_interface_config_cmd
,
2945 "neighbor WORD interface [peer-group PGNAME]",
2947 "Interface name or neighbor tag\n"
2948 "Enable BGP on interface\n"
2949 "Member of the peer-group\n"
2950 "Peer-group name\n")
2953 int idx_peer_group_word
= 4;
2955 if (argc
> idx_peer_group_word
)
2956 return peer_conf_interface_get(
2957 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
2958 argv
[idx_peer_group_word
]->arg
, NULL
);
2960 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2961 SAFI_UNICAST
, 0, NULL
, NULL
);
2964 DEFUN (neighbor_interface_config_v6only
,
2965 neighbor_interface_config_v6only_cmd
,
2966 "neighbor WORD interface v6only [peer-group PGNAME]",
2968 "Interface name or neighbor tag\n"
2969 "Enable BGP on interface\n"
2970 "Enable BGP with v6 link-local only\n"
2971 "Member of the peer-group\n"
2972 "Peer-group name\n")
2975 int idx_peer_group_word
= 5;
2977 if (argc
> idx_peer_group_word
)
2978 return peer_conf_interface_get(
2979 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
2980 argv
[idx_peer_group_word
]->arg
, NULL
);
2982 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2983 SAFI_UNICAST
, 1, NULL
, NULL
);
2987 DEFUN (neighbor_interface_config_remote_as
,
2988 neighbor_interface_config_remote_as_cmd
,
2989 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
2991 "Interface name or neighbor tag\n"
2992 "Enable BGP on interface\n"
2993 "Specify a BGP neighbor\n"
2995 "Internal BGP peer\n"
2996 "External BGP peer\n")
2999 int idx_remote_as
= 4;
3000 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3001 SAFI_UNICAST
, 0, NULL
,
3002 argv
[idx_remote_as
]->arg
);
3005 DEFUN (neighbor_interface_v6only_config_remote_as
,
3006 neighbor_interface_v6only_config_remote_as_cmd
,
3007 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
3009 "Interface name or neighbor tag\n"
3010 "Enable BGP with v6 link-local only\n"
3011 "Enable BGP on interface\n"
3012 "Specify a BGP neighbor\n"
3014 "Internal BGP peer\n"
3015 "External BGP peer\n")
3018 int idx_remote_as
= 5;
3019 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3020 SAFI_UNICAST
, 1, NULL
,
3021 argv
[idx_remote_as
]->arg
);
3024 DEFUN (neighbor_peer_group
,
3025 neighbor_peer_group_cmd
,
3026 "neighbor WORD peer-group",
3028 "Interface name or neighbor tag\n"
3029 "Configure peer-group\n")
3031 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3034 struct peer_group
*group
;
3036 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3038 vty_out(vty
, "%% Name conflict with interface: \n");
3039 return CMD_WARNING_CONFIG_FAILED
;
3042 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
3044 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
3045 return CMD_WARNING_CONFIG_FAILED
;
3053 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3057 "Specify a BGP neighbor\n"
3059 "Internal BGP peer\n"
3060 "External BGP peer\n")
3062 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3066 struct peer_group
*group
;
3070 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3072 /* look up for neighbor by interface name config. */
3073 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3075 /* Request zebra to terminate IPv6 RAs on this
3078 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3083 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3085 peer_group_delete(group
);
3087 vty_out(vty
, "%% Create the peer-group first\n");
3088 return CMD_WARNING_CONFIG_FAILED
;
3091 peer
= peer_lookup(bgp
, &su
);
3093 if (peer_dynamic_neighbor(peer
)) {
3095 "%% Operation not allowed on a dynamic neighbor\n");
3096 return CMD_WARNING_CONFIG_FAILED
;
3099 other
= peer
->doppelganger
;
3101 if (other
&& other
->status
!= Deleted
)
3109 DEFUN (no_neighbor_interface_config
,
3110 no_neighbor_interface_config_cmd
,
3111 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
3115 "Configure BGP on interface\n"
3116 "Enable BGP with v6 link-local only\n"
3117 "Member of the peer-group\n"
3119 "Specify a BGP neighbor\n"
3121 "Internal BGP peer\n"
3122 "External BGP peer\n")
3124 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3128 /* look up for neighbor by interface name config. */
3129 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3131 /* Request zebra to terminate IPv6 RAs on this interface. */
3133 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3136 vty_out(vty
, "%% Create the bgp interface first\n");
3137 return CMD_WARNING_CONFIG_FAILED
;
3142 DEFUN (no_neighbor_peer_group
,
3143 no_neighbor_peer_group_cmd
,
3144 "no neighbor WORD peer-group",
3148 "Configure peer-group\n")
3150 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3152 struct peer_group
*group
;
3154 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3156 peer_group_delete(group
);
3158 vty_out(vty
, "%% Create the peer-group first\n");
3159 return CMD_WARNING_CONFIG_FAILED
;
3164 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3165 no_neighbor_interface_peer_group_remote_as_cmd
,
3166 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3169 "Interface name or neighbor tag\n"
3170 "Specify a BGP neighbor\n"
3172 "Internal BGP peer\n"
3173 "External BGP peer\n")
3175 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3177 struct peer_group
*group
;
3180 /* look up for neighbor by interface name config. */
3181 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3183 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
3187 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3189 peer_group_remote_as_delete(group
);
3191 vty_out(vty
, "%% Create the peer-group or interface first\n");
3192 return CMD_WARNING_CONFIG_FAILED
;
3197 DEFUN (neighbor_local_as
,
3198 neighbor_local_as_cmd
,
3199 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3202 "Specify a local-as number\n"
3203 "AS number used as local AS\n")
3211 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3213 return CMD_WARNING_CONFIG_FAILED
;
3215 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3216 ret
= peer_local_as_set(peer
, as
, 0, 0);
3217 return bgp_vty_return(vty
, ret
);
3220 DEFUN (neighbor_local_as_no_prepend
,
3221 neighbor_local_as_no_prepend_cmd
,
3222 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3225 "Specify a local-as number\n"
3226 "AS number used as local AS\n"
3227 "Do not prepend local-as to updates from ebgp peers\n")
3235 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3237 return CMD_WARNING_CONFIG_FAILED
;
3239 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3240 ret
= peer_local_as_set(peer
, as
, 1, 0);
3241 return bgp_vty_return(vty
, ret
);
3244 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3245 neighbor_local_as_no_prepend_replace_as_cmd
,
3246 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3249 "Specify a local-as number\n"
3250 "AS number used as local AS\n"
3251 "Do not prepend local-as to updates from ebgp peers\n"
3252 "Do not prepend local-as to updates from ibgp peers\n")
3260 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3262 return CMD_WARNING_CONFIG_FAILED
;
3264 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3265 ret
= peer_local_as_set(peer
, as
, 1, 1);
3266 return bgp_vty_return(vty
, ret
);
3269 DEFUN (no_neighbor_local_as
,
3270 no_neighbor_local_as_cmd
,
3271 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3275 "Specify a local-as number\n"
3276 "AS number used as local AS\n"
3277 "Do not prepend local-as to updates from ebgp peers\n"
3278 "Do not prepend local-as to updates from ibgp peers\n")
3284 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3286 return CMD_WARNING_CONFIG_FAILED
;
3288 ret
= peer_local_as_unset(peer
);
3289 return bgp_vty_return(vty
, ret
);
3293 DEFUN (neighbor_solo
,
3295 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3298 "Solo peer - part of its own update group\n")
3304 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3306 return CMD_WARNING_CONFIG_FAILED
;
3308 ret
= update_group_adjust_soloness(peer
, 1);
3309 return bgp_vty_return(vty
, ret
);
3312 DEFUN (no_neighbor_solo
,
3313 no_neighbor_solo_cmd
,
3314 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3318 "Solo peer - part of its own update group\n")
3324 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3326 return CMD_WARNING_CONFIG_FAILED
;
3328 ret
= update_group_adjust_soloness(peer
, 0);
3329 return bgp_vty_return(vty
, ret
);
3332 DEFUN (neighbor_password
,
3333 neighbor_password_cmd
,
3334 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3345 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3347 return CMD_WARNING_CONFIG_FAILED
;
3349 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3350 return bgp_vty_return(vty
, ret
);
3353 DEFUN (no_neighbor_password
,
3354 no_neighbor_password_cmd
,
3355 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3366 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3368 return CMD_WARNING_CONFIG_FAILED
;
3370 ret
= peer_password_unset(peer
);
3371 return bgp_vty_return(vty
, ret
);
3374 DEFUN (neighbor_activate
,
3375 neighbor_activate_cmd
,
3376 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3379 "Enable the Address Family for this Neighbor\n")
3385 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3387 return CMD_WARNING_CONFIG_FAILED
;
3389 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3390 return bgp_vty_return(vty
, ret
);
3393 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3394 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3395 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3396 "Enable the Address Family for this Neighbor\n")
3398 DEFUN (no_neighbor_activate
,
3399 no_neighbor_activate_cmd
,
3400 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3404 "Enable the Address Family for this Neighbor\n")
3411 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3413 return CMD_WARNING_CONFIG_FAILED
;
3415 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3416 return bgp_vty_return(vty
, ret
);
3419 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3420 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3421 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3422 "Enable the Address Family for this Neighbor\n")
3424 DEFUN (neighbor_set_peer_group
,
3425 neighbor_set_peer_group_cmd
,
3426 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3429 "Member of the peer-group\n"
3430 "Peer-group name\n")
3432 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3439 struct peer_group
*group
;
3441 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3443 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3445 vty_out(vty
, "%% Malformed address or name: %s\n",
3446 argv
[idx_peer
]->arg
);
3447 return CMD_WARNING_CONFIG_FAILED
;
3450 if (peer_address_self_check(bgp
, &su
)) {
3452 "%% Can not configure the local system as neighbor\n");
3453 return CMD_WARNING_CONFIG_FAILED
;
3456 /* Disallow for dynamic neighbor. */
3457 peer
= peer_lookup(bgp
, &su
);
3458 if (peer
&& peer_dynamic_neighbor(peer
)) {
3460 "%% Operation not allowed on a dynamic neighbor\n");
3461 return CMD_WARNING_CONFIG_FAILED
;
3465 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3467 vty_out(vty
, "%% Configure the peer-group first\n");
3468 return CMD_WARNING_CONFIG_FAILED
;
3471 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3473 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3475 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3477 return CMD_WARNING_CONFIG_FAILED
;
3480 return bgp_vty_return(vty
, ret
);
3483 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3484 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3485 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3486 "Member of the peer-group\n"
3487 "Peer-group name\n")
3489 DEFUN (no_neighbor_set_peer_group
,
3490 no_neighbor_set_peer_group_cmd
,
3491 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3495 "Member of the peer-group\n"
3496 "Peer-group name\n")
3498 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3503 struct peer_group
*group
;
3505 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3507 return CMD_WARNING_CONFIG_FAILED
;
3509 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3511 vty_out(vty
, "%% Configure the peer-group first\n");
3512 return CMD_WARNING_CONFIG_FAILED
;
3515 ret
= peer_delete(peer
);
3517 return bgp_vty_return(vty
, ret
);
3520 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3521 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3522 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3523 "Member of the peer-group\n"
3524 "Peer-group name\n")
3526 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3527 uint32_t flag
, int set
)
3532 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3534 return CMD_WARNING_CONFIG_FAILED
;
3537 * If 'neighbor <interface>', then this is for directly connected peers,
3538 * we should not accept disable-connected-check.
3540 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3542 "%s is directly connected peer, cannot accept disable-"
3543 "connected-check\n",
3545 return CMD_WARNING_CONFIG_FAILED
;
3548 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3549 peer_tx_shutdown_message_unset(peer
);
3552 ret
= peer_flag_set(peer
, flag
);
3554 ret
= peer_flag_unset(peer
, flag
);
3556 return bgp_vty_return(vty
, ret
);
3559 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3561 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3564 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3567 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3570 /* neighbor passive. */
3571 DEFUN (neighbor_passive
,
3572 neighbor_passive_cmd
,
3573 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3576 "Don't send open messages to this neighbor\n")
3579 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3582 DEFUN (no_neighbor_passive
,
3583 no_neighbor_passive_cmd
,
3584 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3588 "Don't send open messages to this neighbor\n")
3591 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3594 /* neighbor shutdown. */
3595 DEFUN (neighbor_shutdown_msg
,
3596 neighbor_shutdown_msg_cmd
,
3597 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3600 "Administratively shut down this neighbor\n"
3601 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3602 "Shutdown message\n")
3608 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3612 return CMD_WARNING_CONFIG_FAILED
;
3613 message
= argv_concat(argv
, argc
, 4);
3614 peer_tx_shutdown_message_set(peer
, message
);
3615 XFREE(MTYPE_TMP
, message
);
3618 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3621 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3622 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3623 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3624 "Administratively shut down this neighbor\n")
3626 DEFUN (no_neighbor_shutdown_msg
,
3627 no_neighbor_shutdown_msg_cmd
,
3628 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3632 "Administratively shut down this neighbor\n"
3633 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3634 "Shutdown message\n")
3638 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3639 PEER_FLAG_SHUTDOWN
);
3642 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3643 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3644 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3645 "Administratively shut down this neighbor\n")
3647 /* neighbor capability dynamic. */
3648 DEFUN (neighbor_capability_dynamic
,
3649 neighbor_capability_dynamic_cmd
,
3650 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3653 "Advertise capability to the peer\n"
3654 "Advertise dynamic capability to this neighbor\n")
3657 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3658 PEER_FLAG_DYNAMIC_CAPABILITY
);
3661 DEFUN (no_neighbor_capability_dynamic
,
3662 no_neighbor_capability_dynamic_cmd
,
3663 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3667 "Advertise capability to the peer\n"
3668 "Advertise dynamic capability to this neighbor\n")
3671 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3672 PEER_FLAG_DYNAMIC_CAPABILITY
);
3675 /* neighbor dont-capability-negotiate */
3676 DEFUN (neighbor_dont_capability_negotiate
,
3677 neighbor_dont_capability_negotiate_cmd
,
3678 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3681 "Do not perform capability negotiation\n")
3684 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3685 PEER_FLAG_DONT_CAPABILITY
);
3688 DEFUN (no_neighbor_dont_capability_negotiate
,
3689 no_neighbor_dont_capability_negotiate_cmd
,
3690 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3694 "Do not perform capability negotiation\n")
3697 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3698 PEER_FLAG_DONT_CAPABILITY
);
3701 /* neighbor capability extended next hop encoding */
3702 DEFUN (neighbor_capability_enhe
,
3703 neighbor_capability_enhe_cmd
,
3704 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3707 "Advertise capability to the peer\n"
3708 "Advertise extended next-hop capability to the peer\n")
3711 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3712 PEER_FLAG_CAPABILITY_ENHE
);
3715 DEFUN (no_neighbor_capability_enhe
,
3716 no_neighbor_capability_enhe_cmd
,
3717 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3721 "Advertise capability to the peer\n"
3722 "Advertise extended next-hop capability to the peer\n")
3725 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3726 PEER_FLAG_CAPABILITY_ENHE
);
3729 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3730 afi_t afi
, safi_t safi
, uint32_t flag
,
3736 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3738 return CMD_WARNING_CONFIG_FAILED
;
3741 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3743 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3745 return bgp_vty_return(vty
, ret
);
3748 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3749 afi_t afi
, safi_t safi
, uint32_t flag
)
3751 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3754 static int peer_af_flag_unset_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
, 0);
3760 /* neighbor capability orf prefix-list. */
3761 DEFUN (neighbor_capability_orf_prefix
,
3762 neighbor_capability_orf_prefix_cmd
,
3763 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3766 "Advertise capability to the peer\n"
3767 "Advertise ORF capability to the peer\n"
3768 "Advertise prefixlist ORF capability to this neighbor\n"
3769 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3770 "Capability to RECEIVE the ORF from this neighbor\n"
3771 "Capability to SEND the ORF to this neighbor\n")
3774 int idx_send_recv
= 5;
3777 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3778 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3779 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3780 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3781 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3782 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3784 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3785 return CMD_WARNING_CONFIG_FAILED
;
3788 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3789 bgp_node_safi(vty
), flag
);
3793 neighbor_capability_orf_prefix
,
3794 neighbor_capability_orf_prefix_hidden_cmd
,
3795 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3796 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3797 "Advertise capability to the peer\n"
3798 "Advertise ORF capability to the peer\n"
3799 "Advertise prefixlist ORF capability to this neighbor\n"
3800 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3801 "Capability to RECEIVE the ORF from this neighbor\n"
3802 "Capability to SEND the ORF to this neighbor\n")
3804 DEFUN (no_neighbor_capability_orf_prefix
,
3805 no_neighbor_capability_orf_prefix_cmd
,
3806 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3810 "Advertise capability to the peer\n"
3811 "Advertise ORF capability to the peer\n"
3812 "Advertise prefixlist ORF capability to this neighbor\n"
3813 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3814 "Capability to RECEIVE the ORF from this neighbor\n"
3815 "Capability to SEND the ORF to this neighbor\n")
3818 int idx_send_recv
= 6;
3821 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3822 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3823 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3824 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3825 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3826 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3828 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3829 return CMD_WARNING_CONFIG_FAILED
;
3832 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3833 bgp_node_afi(vty
), bgp_node_safi(vty
),
3838 no_neighbor_capability_orf_prefix
,
3839 no_neighbor_capability_orf_prefix_hidden_cmd
,
3840 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3841 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3842 "Advertise capability to the peer\n"
3843 "Advertise ORF capability to the peer\n"
3844 "Advertise prefixlist ORF capability to this neighbor\n"
3845 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3846 "Capability to RECEIVE the ORF from this neighbor\n"
3847 "Capability to SEND the ORF to this neighbor\n")
3849 /* neighbor next-hop-self. */
3850 DEFUN (neighbor_nexthop_self
,
3851 neighbor_nexthop_self_cmd
,
3852 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3855 "Disable the next hop calculation for this neighbor\n")
3858 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3859 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3862 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3863 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3864 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3865 "Disable the next hop calculation for this neighbor\n")
3867 /* neighbor next-hop-self. */
3868 DEFUN (neighbor_nexthop_self_force
,
3869 neighbor_nexthop_self_force_cmd
,
3870 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3873 "Disable the next hop calculation for this neighbor\n"
3874 "Set the next hop to self for reflected routes\n")
3877 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3879 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3882 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3883 neighbor_nexthop_self_force_hidden_cmd
,
3884 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3885 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3886 "Disable the next hop calculation for this neighbor\n"
3887 "Set the next hop to self for reflected routes\n")
3889 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3890 neighbor_nexthop_self_all_hidden_cmd
,
3891 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
3892 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3893 "Disable the next hop calculation for this neighbor\n"
3894 "Set the next hop to self for reflected routes\n")
3896 DEFUN (no_neighbor_nexthop_self
,
3897 no_neighbor_nexthop_self_cmd
,
3898 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3902 "Disable the next hop calculation for this neighbor\n")
3905 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3906 bgp_node_afi(vty
), bgp_node_safi(vty
),
3907 PEER_FLAG_NEXTHOP_SELF
);
3910 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3911 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3912 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3913 "Disable the next hop calculation for this neighbor\n")
3915 DEFUN (no_neighbor_nexthop_self_force
,
3916 no_neighbor_nexthop_self_force_cmd
,
3917 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3921 "Disable the next hop calculation for this neighbor\n"
3922 "Set the next hop to self for reflected routes\n")
3925 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3926 bgp_node_afi(vty
), bgp_node_safi(vty
),
3927 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3930 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3931 no_neighbor_nexthop_self_force_hidden_cmd
,
3932 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3933 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3934 "Disable the next hop calculation for this neighbor\n"
3935 "Set the next hop to self for reflected routes\n")
3937 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3938 no_neighbor_nexthop_self_all_hidden_cmd
,
3939 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
3940 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3941 "Disable the next hop calculation for this neighbor\n"
3942 "Set the next hop to self for reflected routes\n")
3944 /* neighbor as-override */
3945 DEFUN (neighbor_as_override
,
3946 neighbor_as_override_cmd
,
3947 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3950 "Override ASNs in outbound updates if aspath equals remote-as\n")
3953 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3954 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
3957 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
3958 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3959 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3960 "Override ASNs in outbound updates if aspath equals remote-as\n")
3962 DEFUN (no_neighbor_as_override
,
3963 no_neighbor_as_override_cmd
,
3964 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3968 "Override ASNs in outbound updates if aspath equals remote-as\n")
3971 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3972 bgp_node_afi(vty
), bgp_node_safi(vty
),
3973 PEER_FLAG_AS_OVERRIDE
);
3976 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
3977 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3978 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3979 "Override ASNs in outbound updates if aspath equals remote-as\n")
3981 /* neighbor remove-private-AS. */
3982 DEFUN (neighbor_remove_private_as
,
3983 neighbor_remove_private_as_cmd
,
3984 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3987 "Remove private ASNs in outbound updates\n")
3990 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3992 PEER_FLAG_REMOVE_PRIVATE_AS
);
3995 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
3996 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3997 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3998 "Remove private ASNs in outbound updates\n")
4000 DEFUN (neighbor_remove_private_as_all
,
4001 neighbor_remove_private_as_all_cmd
,
4002 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4005 "Remove private ASNs in outbound updates\n"
4006 "Apply to all AS numbers\n")
4009 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4011 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4014 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
4015 neighbor_remove_private_as_all_hidden_cmd
,
4016 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4017 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4018 "Remove private ASNs in outbound updates\n"
4019 "Apply to all AS numbers")
4021 DEFUN (neighbor_remove_private_as_replace_as
,
4022 neighbor_remove_private_as_replace_as_cmd
,
4023 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4026 "Remove private ASNs in outbound updates\n"
4027 "Replace private ASNs with our ASN in outbound updates\n")
4030 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4032 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4035 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
4036 neighbor_remove_private_as_replace_as_hidden_cmd
,
4037 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4038 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4039 "Remove private ASNs in outbound updates\n"
4040 "Replace private ASNs with our ASN in outbound updates\n")
4042 DEFUN (neighbor_remove_private_as_all_replace_as
,
4043 neighbor_remove_private_as_all_replace_as_cmd
,
4044 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4047 "Remove private ASNs in outbound updates\n"
4048 "Apply to all AS numbers\n"
4049 "Replace private ASNs with our ASN in outbound updates\n")
4052 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4054 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4058 neighbor_remove_private_as_all_replace_as
,
4059 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4060 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4061 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4062 "Remove private ASNs in outbound updates\n"
4063 "Apply to all AS numbers\n"
4064 "Replace private ASNs with our ASN in outbound updates\n")
4066 DEFUN (no_neighbor_remove_private_as
,
4067 no_neighbor_remove_private_as_cmd
,
4068 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4072 "Remove private ASNs in outbound updates\n")
4075 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4076 bgp_node_afi(vty
), bgp_node_safi(vty
),
4077 PEER_FLAG_REMOVE_PRIVATE_AS
);
4080 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4081 no_neighbor_remove_private_as_hidden_cmd
,
4082 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4083 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4084 "Remove private ASNs in outbound updates\n")
4086 DEFUN (no_neighbor_remove_private_as_all
,
4087 no_neighbor_remove_private_as_all_cmd
,
4088 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4092 "Remove private ASNs in outbound updates\n"
4093 "Apply to all AS numbers\n")
4096 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4097 bgp_node_afi(vty
), bgp_node_safi(vty
),
4098 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4101 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4102 no_neighbor_remove_private_as_all_hidden_cmd
,
4103 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4104 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4105 "Remove private ASNs in outbound updates\n"
4106 "Apply to all AS numbers\n")
4108 DEFUN (no_neighbor_remove_private_as_replace_as
,
4109 no_neighbor_remove_private_as_replace_as_cmd
,
4110 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4114 "Remove private ASNs in outbound updates\n"
4115 "Replace private ASNs with our ASN in outbound updates\n")
4118 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4119 bgp_node_afi(vty
), bgp_node_safi(vty
),
4120 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4123 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4124 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4125 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4126 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4127 "Remove private ASNs in outbound updates\n"
4128 "Replace private ASNs with our ASN in outbound updates\n")
4130 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4131 no_neighbor_remove_private_as_all_replace_as_cmd
,
4132 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4136 "Remove private ASNs in outbound updates\n"
4137 "Apply to all AS numbers\n"
4138 "Replace private ASNs with our ASN in outbound updates\n")
4141 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4142 bgp_node_afi(vty
), bgp_node_safi(vty
),
4143 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4147 no_neighbor_remove_private_as_all_replace_as
,
4148 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4149 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4150 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4151 "Remove private ASNs in outbound updates\n"
4152 "Apply to all AS numbers\n"
4153 "Replace private ASNs with our ASN in outbound updates\n")
4156 /* neighbor send-community. */
4157 DEFUN (neighbor_send_community
,
4158 neighbor_send_community_cmd
,
4159 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4162 "Send Community attribute to this neighbor\n")
4166 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4168 PEER_FLAG_SEND_COMMUNITY
);
4171 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4172 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4173 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4174 "Send Community attribute to this neighbor\n")
4176 DEFUN (no_neighbor_send_community
,
4177 no_neighbor_send_community_cmd
,
4178 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4182 "Send Community attribute to this neighbor\n")
4186 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4187 bgp_node_afi(vty
), bgp_node_safi(vty
),
4188 PEER_FLAG_SEND_COMMUNITY
);
4191 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4192 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4193 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4194 "Send Community attribute to this neighbor\n")
4196 /* neighbor send-community extended. */
4197 DEFUN (neighbor_send_community_type
,
4198 neighbor_send_community_type_cmd
,
4199 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4202 "Send Community attribute to this neighbor\n"
4203 "Send Standard and Extended Community attributes\n"
4204 "Send Standard, Large and Extended Community attributes\n"
4205 "Send Extended Community attributes\n"
4206 "Send Standard Community attributes\n"
4207 "Send Large Community attributes\n")
4211 const char *type
= argv
[argc
- 1]->text
;
4213 if (strmatch(type
, "standard")) {
4214 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4215 } else if (strmatch(type
, "extended")) {
4216 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4217 } else if (strmatch(type
, "large")) {
4218 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4219 } else if (strmatch(type
, "both")) {
4220 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4221 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4222 } else { /* if (strmatch(type, "all")) */
4223 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4224 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4225 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4228 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4229 bgp_node_safi(vty
), flag
);
4233 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4234 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4235 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4236 "Send Community attribute to this neighbor\n"
4237 "Send Standard and Extended Community attributes\n"
4238 "Send Standard, Large and Extended Community attributes\n"
4239 "Send Extended Community attributes\n"
4240 "Send Standard Community attributes\n"
4241 "Send Large Community attributes\n")
4243 DEFUN (no_neighbor_send_community_type
,
4244 no_neighbor_send_community_type_cmd
,
4245 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4249 "Send Community attribute to this neighbor\n"
4250 "Send Standard and Extended Community attributes\n"
4251 "Send Standard, Large and Extended Community attributes\n"
4252 "Send Extended Community attributes\n"
4253 "Send Standard Community attributes\n"
4254 "Send Large Community attributes\n")
4258 const char *type
= argv
[argc
- 1]->text
;
4260 if (strmatch(type
, "standard")) {
4261 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4262 } else if (strmatch(type
, "extended")) {
4263 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4264 } else if (strmatch(type
, "large")) {
4265 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4266 } else if (strmatch(type
, "both")) {
4267 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4268 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4269 } else { /* if (strmatch(type, "all")) */
4270 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4271 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4272 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4275 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4276 bgp_node_afi(vty
), bgp_node_safi(vty
),
4281 no_neighbor_send_community_type
,
4282 no_neighbor_send_community_type_hidden_cmd
,
4283 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4284 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4285 "Send Community attribute to this neighbor\n"
4286 "Send Standard and Extended Community attributes\n"
4287 "Send Standard, Large and Extended Community attributes\n"
4288 "Send Extended Community attributes\n"
4289 "Send Standard Community attributes\n"
4290 "Send Large Community attributes\n")
4292 /* neighbor soft-reconfig. */
4293 DEFUN (neighbor_soft_reconfiguration
,
4294 neighbor_soft_reconfiguration_cmd
,
4295 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4298 "Per neighbor soft reconfiguration\n"
4299 "Allow inbound soft reconfiguration for this neighbor\n")
4302 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4304 PEER_FLAG_SOFT_RECONFIG
);
4307 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4308 neighbor_soft_reconfiguration_hidden_cmd
,
4309 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4310 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4311 "Per neighbor soft reconfiguration\n"
4312 "Allow inbound soft reconfiguration for this neighbor\n")
4314 DEFUN (no_neighbor_soft_reconfiguration
,
4315 no_neighbor_soft_reconfiguration_cmd
,
4316 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4320 "Per neighbor soft reconfiguration\n"
4321 "Allow inbound soft reconfiguration for this neighbor\n")
4324 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4325 bgp_node_afi(vty
), bgp_node_safi(vty
),
4326 PEER_FLAG_SOFT_RECONFIG
);
4329 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4330 no_neighbor_soft_reconfiguration_hidden_cmd
,
4331 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4332 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4333 "Per neighbor soft reconfiguration\n"
4334 "Allow inbound soft reconfiguration for this neighbor\n")
4336 DEFUN (neighbor_route_reflector_client
,
4337 neighbor_route_reflector_client_cmd
,
4338 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4341 "Configure a neighbor as Route Reflector client\n")
4347 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4349 return CMD_WARNING_CONFIG_FAILED
;
4351 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4353 PEER_FLAG_REFLECTOR_CLIENT
);
4356 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4357 neighbor_route_reflector_client_hidden_cmd
,
4358 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4359 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4360 "Configure a neighbor as Route Reflector client\n")
4362 DEFUN (no_neighbor_route_reflector_client
,
4363 no_neighbor_route_reflector_client_cmd
,
4364 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4368 "Configure a neighbor as Route Reflector client\n")
4371 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4372 bgp_node_afi(vty
), bgp_node_safi(vty
),
4373 PEER_FLAG_REFLECTOR_CLIENT
);
4376 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4377 no_neighbor_route_reflector_client_hidden_cmd
,
4378 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4379 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4380 "Configure a neighbor as Route Reflector client\n")
4382 /* neighbor route-server-client. */
4383 DEFUN (neighbor_route_server_client
,
4384 neighbor_route_server_client_cmd
,
4385 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4388 "Configure a neighbor as Route Server client\n")
4393 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4395 return CMD_WARNING_CONFIG_FAILED
;
4396 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4398 PEER_FLAG_RSERVER_CLIENT
);
4401 ALIAS_HIDDEN(neighbor_route_server_client
,
4402 neighbor_route_server_client_hidden_cmd
,
4403 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4404 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4405 "Configure a neighbor as Route Server client\n")
4407 DEFUN (no_neighbor_route_server_client
,
4408 no_neighbor_route_server_client_cmd
,
4409 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4413 "Configure a neighbor as Route Server client\n")
4416 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4417 bgp_node_afi(vty
), bgp_node_safi(vty
),
4418 PEER_FLAG_RSERVER_CLIENT
);
4421 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4422 no_neighbor_route_server_client_hidden_cmd
,
4423 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4424 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4425 "Configure a neighbor as Route Server client\n")
4427 DEFUN (neighbor_nexthop_local_unchanged
,
4428 neighbor_nexthop_local_unchanged_cmd
,
4429 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4432 "Configure treatment of outgoing link-local nexthop attribute\n"
4433 "Leave link-local nexthop unchanged for this peer\n")
4436 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4438 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4441 DEFUN (no_neighbor_nexthop_local_unchanged
,
4442 no_neighbor_nexthop_local_unchanged_cmd
,
4443 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4447 "Configure treatment of outgoing link-local-nexthop attribute\n"
4448 "Leave link-local nexthop unchanged for this peer\n")
4451 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4452 bgp_node_afi(vty
), bgp_node_safi(vty
),
4453 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4456 DEFUN (neighbor_attr_unchanged
,
4457 neighbor_attr_unchanged_cmd
,
4458 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4461 "BGP attribute is propagated unchanged to this neighbor\n"
4462 "As-path attribute\n"
4463 "Nexthop attribute\n"
4467 char *peer_str
= argv
[1]->arg
;
4470 afi_t afi
= bgp_node_afi(vty
);
4471 safi_t safi
= bgp_node_safi(vty
);
4473 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4475 return CMD_WARNING_CONFIG_FAILED
;
4477 if (argv_find(argv
, argc
, "as-path", &idx
))
4478 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4480 if (argv_find(argv
, argc
, "next-hop", &idx
))
4481 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4483 if (argv_find(argv
, argc
, "med", &idx
))
4484 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4486 /* no flags means all of them! */
4488 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4489 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4490 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4492 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4493 && peer_af_flag_check(peer
, afi
, safi
,
4494 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4495 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4496 PEER_FLAG_AS_PATH_UNCHANGED
);
4499 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4500 && peer_af_flag_check(peer
, afi
, safi
,
4501 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4502 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4503 PEER_FLAG_NEXTHOP_UNCHANGED
);
4506 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4507 && peer_af_flag_check(peer
, afi
, safi
,
4508 PEER_FLAG_MED_UNCHANGED
)) {
4509 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4510 PEER_FLAG_MED_UNCHANGED
);
4514 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4518 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4519 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4520 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4521 "BGP attribute is propagated unchanged to this neighbor\n"
4522 "As-path attribute\n"
4523 "Nexthop attribute\n"
4526 DEFUN (no_neighbor_attr_unchanged
,
4527 no_neighbor_attr_unchanged_cmd
,
4528 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4532 "BGP attribute is propagated unchanged to this neighbor\n"
4533 "As-path attribute\n"
4534 "Nexthop attribute\n"
4538 char *peer
= argv
[2]->arg
;
4541 if (argv_find(argv
, argc
, "as-path", &idx
))
4542 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4544 if (argv_find(argv
, argc
, "next-hop", &idx
))
4545 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4547 if (argv_find(argv
, argc
, "med", &idx
))
4548 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4550 if (!flags
) // no flags means all of them!
4552 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4553 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4554 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4557 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4558 bgp_node_safi(vty
), flags
);
4562 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4563 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4564 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4565 "BGP attribute is propagated unchanged to this neighbor\n"
4566 "As-path attribute\n"
4567 "Nexthop attribute\n"
4570 /* EBGP multihop configuration. */
4571 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4572 const char *ttl_str
)
4577 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4579 return CMD_WARNING_CONFIG_FAILED
;
4582 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4587 ttl
= strtoul(ttl_str
, NULL
, 10);
4589 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4592 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4596 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4598 return CMD_WARNING_CONFIG_FAILED
;
4600 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4603 /* neighbor ebgp-multihop. */
4604 DEFUN (neighbor_ebgp_multihop
,
4605 neighbor_ebgp_multihop_cmd
,
4606 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4609 "Allow EBGP neighbors not on directly connected networks\n")
4612 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4615 DEFUN (neighbor_ebgp_multihop_ttl
,
4616 neighbor_ebgp_multihop_ttl_cmd
,
4617 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4620 "Allow EBGP neighbors not on directly connected networks\n"
4621 "maximum hop count\n")
4625 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4626 argv
[idx_number
]->arg
);
4629 DEFUN (no_neighbor_ebgp_multihop
,
4630 no_neighbor_ebgp_multihop_cmd
,
4631 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4635 "Allow EBGP neighbors not on directly connected networks\n"
4636 "maximum hop count\n")
4639 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4643 /* disable-connected-check */
4644 DEFUN (neighbor_disable_connected_check
,
4645 neighbor_disable_connected_check_cmd
,
4646 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4649 "one-hop away EBGP peer using loopback address\n"
4650 "Enforce EBGP neighbors perform multihop\n")
4653 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4654 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4657 DEFUN (no_neighbor_disable_connected_check
,
4658 no_neighbor_disable_connected_check_cmd
,
4659 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4663 "one-hop away EBGP peer using loopback address\n"
4664 "Enforce EBGP neighbors perform multihop\n")
4667 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4668 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4672 /* enforce-first-as */
4673 DEFUN (neighbor_enforce_first_as
,
4674 neighbor_enforce_first_as_cmd
,
4675 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4678 "Enforce the first AS for EBGP routes\n")
4682 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4683 PEER_FLAG_ENFORCE_FIRST_AS
);
4686 DEFUN (no_neighbor_enforce_first_as
,
4687 no_neighbor_enforce_first_as_cmd
,
4688 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4692 "Enforce the first AS for EBGP routes\n")
4696 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4697 PEER_FLAG_ENFORCE_FIRST_AS
);
4701 DEFUN (neighbor_description
,
4702 neighbor_description_cmd
,
4703 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4706 "Neighbor specific description\n"
4707 "Up to 80 characters describing this neighbor\n")
4714 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4716 return CMD_WARNING_CONFIG_FAILED
;
4718 str
= argv_concat(argv
, argc
, idx_line
);
4720 peer_description_set(peer
, str
);
4722 XFREE(MTYPE_TMP
, str
);
4727 DEFUN (no_neighbor_description
,
4728 no_neighbor_description_cmd
,
4729 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4733 "Neighbor specific description\n")
4738 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4740 return CMD_WARNING_CONFIG_FAILED
;
4742 peer_description_unset(peer
);
4747 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4748 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4749 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4750 "Neighbor specific description\n"
4751 "Up to 80 characters describing this neighbor\n")
4753 /* Neighbor update-source. */
4754 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4755 const char *source_str
)
4761 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4763 return CMD_WARNING_CONFIG_FAILED
;
4769 if (str2sockunion(source_str
, &su
) == 0)
4770 peer_update_source_addr_set(peer
, &su
);
4772 if (str2prefix(source_str
, &p
)) {
4774 "%% Invalid update-source, remove prefix length \n");
4775 return CMD_WARNING_CONFIG_FAILED
;
4777 peer_update_source_if_set(peer
, source_str
);
4780 peer_update_source_unset(peer
);
4785 #define BGP_UPDATE_SOURCE_HELP_STR \
4788 "Interface name (requires zebra to be running)\n"
4790 DEFUN (neighbor_update_source
,
4791 neighbor_update_source_cmd
,
4792 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4795 "Source of routing updates\n"
4796 BGP_UPDATE_SOURCE_HELP_STR
)
4800 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4801 argv
[idx_peer_2
]->arg
);
4804 DEFUN (no_neighbor_update_source
,
4805 no_neighbor_update_source_cmd
,
4806 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4810 "Source of routing updates\n"
4811 BGP_UPDATE_SOURCE_HELP_STR
)
4814 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4817 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4818 afi_t afi
, safi_t safi
,
4819 const char *rmap
, int set
)
4823 struct route_map
*route_map
= NULL
;
4825 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4827 return CMD_WARNING_CONFIG_FAILED
;
4831 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
4832 ret
= peer_default_originate_set(peer
, afi
, safi
,
4835 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4837 return bgp_vty_return(vty
, ret
);
4840 /* neighbor default-originate. */
4841 DEFUN (neighbor_default_originate
,
4842 neighbor_default_originate_cmd
,
4843 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4846 "Originate default route to this neighbor\n")
4849 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4851 bgp_node_safi(vty
), NULL
, 1);
4854 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4855 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4856 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4857 "Originate default route to this neighbor\n")
4859 DEFUN (neighbor_default_originate_rmap
,
4860 neighbor_default_originate_rmap_cmd
,
4861 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4864 "Originate default route to this neighbor\n"
4865 "Route-map to specify criteria to originate default\n"
4870 return peer_default_originate_set_vty(
4871 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4872 argv
[idx_word
]->arg
, 1);
4876 neighbor_default_originate_rmap
,
4877 neighbor_default_originate_rmap_hidden_cmd
,
4878 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4879 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4880 "Originate default route to this neighbor\n"
4881 "Route-map to specify criteria to originate default\n"
4884 DEFUN (no_neighbor_default_originate
,
4885 no_neighbor_default_originate_cmd
,
4886 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4890 "Originate default route to this neighbor\n"
4891 "Route-map to specify criteria to originate default\n"
4895 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4897 bgp_node_safi(vty
), NULL
, 0);
4901 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4902 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4903 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4904 "Originate default route to this neighbor\n"
4905 "Route-map to specify criteria to originate default\n"
4909 /* Set neighbor's BGP port. */
4910 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4911 const char *port_str
)
4917 peer
= peer_lookup_vty(vty
, ip_str
);
4919 return CMD_WARNING_CONFIG_FAILED
;
4922 sp
= getservbyname("bgp", "tcp");
4923 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
4925 port
= strtoul(port_str
, NULL
, 10);
4928 peer_port_set(peer
, port
);
4933 /* Set specified peer's BGP port. */
4934 DEFUN (neighbor_port
,
4936 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
4939 "Neighbor's BGP port\n"
4940 "TCP port number\n")
4944 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
4945 argv
[idx_number
]->arg
);
4948 DEFUN (no_neighbor_port
,
4949 no_neighbor_port_cmd
,
4950 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
4954 "Neighbor's BGP port\n"
4955 "TCP port number\n")
4958 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
4962 /* neighbor weight. */
4963 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4964 safi_t safi
, const char *weight_str
)
4968 unsigned long weight
;
4970 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4972 return CMD_WARNING_CONFIG_FAILED
;
4974 weight
= strtoul(weight_str
, NULL
, 10);
4976 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
4977 return bgp_vty_return(vty
, ret
);
4980 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4986 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4988 return CMD_WARNING_CONFIG_FAILED
;
4990 ret
= peer_weight_unset(peer
, afi
, safi
);
4991 return bgp_vty_return(vty
, ret
);
4994 DEFUN (neighbor_weight
,
4995 neighbor_weight_cmd
,
4996 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4999 "Set default weight for routes from this neighbor\n"
5004 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5005 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
5008 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
5009 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5010 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5011 "Set default weight for routes from this neighbor\n"
5014 DEFUN (no_neighbor_weight
,
5015 no_neighbor_weight_cmd
,
5016 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5020 "Set default weight for routes from this neighbor\n"
5024 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
5025 bgp_node_afi(vty
), bgp_node_safi(vty
));
5028 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
5029 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5030 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5031 "Set default weight for routes from this neighbor\n"
5035 /* Override capability negotiation. */
5036 DEFUN (neighbor_override_capability
,
5037 neighbor_override_capability_cmd
,
5038 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5041 "Override capability negotiation result\n")
5044 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5045 PEER_FLAG_OVERRIDE_CAPABILITY
);
5048 DEFUN (no_neighbor_override_capability
,
5049 no_neighbor_override_capability_cmd
,
5050 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5054 "Override capability negotiation result\n")
5057 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5058 PEER_FLAG_OVERRIDE_CAPABILITY
);
5061 DEFUN (neighbor_strict_capability
,
5062 neighbor_strict_capability_cmd
,
5063 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5066 "Strict capability negotiation match\n")
5070 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5071 PEER_FLAG_STRICT_CAP_MATCH
);
5074 DEFUN (no_neighbor_strict_capability
,
5075 no_neighbor_strict_capability_cmd
,
5076 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5080 "Strict capability negotiation match\n")
5084 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5085 PEER_FLAG_STRICT_CAP_MATCH
);
5088 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5089 const char *keep_str
, const char *hold_str
)
5096 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5098 return CMD_WARNING_CONFIG_FAILED
;
5100 keepalive
= strtoul(keep_str
, NULL
, 10);
5101 holdtime
= strtoul(hold_str
, NULL
, 10);
5103 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5105 return bgp_vty_return(vty
, ret
);
5108 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5113 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5115 return CMD_WARNING_CONFIG_FAILED
;
5117 ret
= peer_timers_unset(peer
);
5119 return bgp_vty_return(vty
, ret
);
5122 DEFUN (neighbor_timers
,
5123 neighbor_timers_cmd
,
5124 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5127 "BGP per neighbor timers\n"
5128 "Keepalive interval\n"
5133 int idx_number_2
= 4;
5134 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5135 argv
[idx_number
]->arg
,
5136 argv
[idx_number_2
]->arg
);
5139 DEFUN (no_neighbor_timers
,
5140 no_neighbor_timers_cmd
,
5141 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5145 "BGP per neighbor timers\n"
5146 "Keepalive interval\n"
5150 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5154 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5155 const char *time_str
)
5161 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5163 return CMD_WARNING_CONFIG_FAILED
;
5165 connect
= strtoul(time_str
, NULL
, 10);
5167 ret
= peer_timers_connect_set(peer
, connect
);
5169 return bgp_vty_return(vty
, ret
);
5172 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5177 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5179 return CMD_WARNING_CONFIG_FAILED
;
5181 ret
= peer_timers_connect_unset(peer
);
5183 return bgp_vty_return(vty
, ret
);
5186 DEFUN (neighbor_timers_connect
,
5187 neighbor_timers_connect_cmd
,
5188 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5191 "BGP per neighbor timers\n"
5192 "BGP connect timer\n"
5197 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5198 argv
[idx_number
]->arg
);
5201 DEFUN (no_neighbor_timers_connect
,
5202 no_neighbor_timers_connect_cmd
,
5203 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5207 "BGP per neighbor timers\n"
5208 "BGP connect timer\n"
5212 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5216 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5217 const char *time_str
, int set
)
5221 uint32_t routeadv
= 0;
5223 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5225 return CMD_WARNING_CONFIG_FAILED
;
5228 routeadv
= strtoul(time_str
, NULL
, 10);
5231 ret
= peer_advertise_interval_set(peer
, routeadv
);
5233 ret
= peer_advertise_interval_unset(peer
);
5235 return bgp_vty_return(vty
, ret
);
5238 DEFUN (neighbor_advertise_interval
,
5239 neighbor_advertise_interval_cmd
,
5240 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5243 "Minimum interval between sending BGP routing updates\n"
5244 "time in seconds\n")
5248 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5249 argv
[idx_number
]->arg
, 1);
5252 DEFUN (no_neighbor_advertise_interval
,
5253 no_neighbor_advertise_interval_cmd
,
5254 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5258 "Minimum interval between sending BGP routing updates\n"
5259 "time in seconds\n")
5262 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5266 /* Time to wait before processing route-map updates */
5267 DEFUN (bgp_set_route_map_delay_timer
,
5268 bgp_set_route_map_delay_timer_cmd
,
5269 "bgp route-map delay-timer (0-600)",
5271 "BGP route-map delay timer\n"
5272 "Time in secs to wait before processing route-map changes\n"
5273 "0 disables the timer, no route updates happen when route-maps change\n")
5276 uint32_t rmap_delay_timer
;
5278 if (argv
[idx_number
]->arg
) {
5279 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5280 bm
->rmap_update_timer
= rmap_delay_timer
;
5282 /* if the dynamic update handling is being disabled, and a timer
5284 * running, stop the timer and act as if the timer has already
5287 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5288 BGP_TIMER_OFF(bm
->t_rmap_update
);
5289 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5294 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5295 return CMD_WARNING_CONFIG_FAILED
;
5299 DEFUN (no_bgp_set_route_map_delay_timer
,
5300 no_bgp_set_route_map_delay_timer_cmd
,
5301 "no bgp route-map delay-timer [(0-600)]",
5304 "Default BGP route-map delay timer\n"
5305 "Reset to default time to wait for processing route-map changes\n"
5306 "0 disables the timer, no route updates happen when route-maps change\n")
5309 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5315 /* neighbor interface */
5316 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5321 peer
= peer_lookup_vty(vty
, ip_str
);
5322 if (!peer
|| peer
->conf_if
) {
5323 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5324 return CMD_WARNING_CONFIG_FAILED
;
5328 peer_interface_set(peer
, str
);
5330 peer_interface_unset(peer
);
5335 DEFUN (neighbor_interface
,
5336 neighbor_interface_cmd
,
5337 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5345 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5348 DEFUN (no_neighbor_interface
,
5349 no_neighbor_interface_cmd
,
5350 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5358 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5361 DEFUN (neighbor_distribute_list
,
5362 neighbor_distribute_list_cmd
,
5363 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5366 "Filter updates to/from this neighbor\n"
5367 "IP access-list number\n"
5368 "IP access-list number (expanded range)\n"
5369 "IP Access-list name\n"
5370 "Filter incoming updates\n"
5371 "Filter outgoing updates\n")
5378 const char *pstr
= argv
[idx_peer
]->arg
;
5379 const char *acl
= argv
[idx_acl
]->arg
;
5380 const char *inout
= argv
[argc
- 1]->text
;
5382 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5384 return CMD_WARNING_CONFIG_FAILED
;
5386 /* Check filter direction. */
5387 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5388 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5391 return bgp_vty_return(vty
, ret
);
5395 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5396 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5397 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5398 "Filter updates to/from this neighbor\n"
5399 "IP access-list number\n"
5400 "IP access-list number (expanded range)\n"
5401 "IP Access-list name\n"
5402 "Filter incoming updates\n"
5403 "Filter outgoing updates\n")
5405 DEFUN (no_neighbor_distribute_list
,
5406 no_neighbor_distribute_list_cmd
,
5407 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5411 "Filter updates to/from this neighbor\n"
5412 "IP access-list number\n"
5413 "IP access-list number (expanded range)\n"
5414 "IP Access-list name\n"
5415 "Filter incoming updates\n"
5416 "Filter outgoing updates\n")
5422 const char *pstr
= argv
[idx_peer
]->arg
;
5423 const char *inout
= argv
[argc
- 1]->text
;
5425 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5427 return CMD_WARNING_CONFIG_FAILED
;
5429 /* Check filter direction. */
5430 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5431 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5434 return bgp_vty_return(vty
, ret
);
5438 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5439 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5440 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5441 "Filter updates to/from this neighbor\n"
5442 "IP access-list number\n"
5443 "IP access-list number (expanded range)\n"
5444 "IP Access-list name\n"
5445 "Filter incoming updates\n"
5446 "Filter outgoing updates\n")
5448 /* Set prefix list to the peer. */
5449 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5450 afi_t afi
, safi_t safi
,
5451 const char *name_str
,
5452 const char *direct_str
)
5455 int direct
= FILTER_IN
;
5458 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5460 return CMD_WARNING_CONFIG_FAILED
;
5462 /* Check filter direction. */
5463 if (strncmp(direct_str
, "i", 1) == 0)
5465 else if (strncmp(direct_str
, "o", 1) == 0)
5466 direct
= FILTER_OUT
;
5468 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5470 return bgp_vty_return(vty
, ret
);
5473 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5474 afi_t afi
, safi_t safi
,
5475 const char *direct_str
)
5479 int direct
= FILTER_IN
;
5481 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5483 return CMD_WARNING_CONFIG_FAILED
;
5485 /* Check filter direction. */
5486 if (strncmp(direct_str
, "i", 1) == 0)
5488 else if (strncmp(direct_str
, "o", 1) == 0)
5489 direct
= FILTER_OUT
;
5491 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5493 return bgp_vty_return(vty
, ret
);
5496 DEFUN (neighbor_prefix_list
,
5497 neighbor_prefix_list_cmd
,
5498 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5501 "Filter updates to/from this neighbor\n"
5502 "Name of a prefix list\n"
5503 "Filter incoming updates\n"
5504 "Filter outgoing updates\n")
5509 return peer_prefix_list_set_vty(
5510 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5511 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5514 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5515 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5516 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5517 "Filter updates to/from this neighbor\n"
5518 "Name of a prefix list\n"
5519 "Filter incoming updates\n"
5520 "Filter outgoing updates\n")
5522 DEFUN (no_neighbor_prefix_list
,
5523 no_neighbor_prefix_list_cmd
,
5524 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5528 "Filter updates to/from this neighbor\n"
5529 "Name of a prefix list\n"
5530 "Filter incoming updates\n"
5531 "Filter outgoing updates\n")
5535 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5536 bgp_node_afi(vty
), bgp_node_safi(vty
),
5537 argv
[idx_in_out
]->arg
);
5540 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5541 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5542 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5543 "Filter updates to/from this neighbor\n"
5544 "Name of a prefix list\n"
5545 "Filter incoming updates\n"
5546 "Filter outgoing updates\n")
5548 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5549 safi_t safi
, const char *name_str
,
5550 const char *direct_str
)
5554 int direct
= FILTER_IN
;
5556 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5558 return CMD_WARNING_CONFIG_FAILED
;
5560 /* Check filter direction. */
5561 if (strncmp(direct_str
, "i", 1) == 0)
5563 else if (strncmp(direct_str
, "o", 1) == 0)
5564 direct
= FILTER_OUT
;
5566 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5568 return bgp_vty_return(vty
, ret
);
5571 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5572 safi_t safi
, const char *direct_str
)
5576 int direct
= FILTER_IN
;
5578 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5580 return CMD_WARNING_CONFIG_FAILED
;
5582 /* Check filter direction. */
5583 if (strncmp(direct_str
, "i", 1) == 0)
5585 else if (strncmp(direct_str
, "o", 1) == 0)
5586 direct
= FILTER_OUT
;
5588 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5590 return bgp_vty_return(vty
, ret
);
5593 DEFUN (neighbor_filter_list
,
5594 neighbor_filter_list_cmd
,
5595 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5598 "Establish BGP filters\n"
5599 "AS path access-list name\n"
5600 "Filter incoming routes\n"
5601 "Filter outgoing routes\n")
5606 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5607 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5608 argv
[idx_in_out
]->arg
);
5611 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5612 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5613 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5614 "Establish BGP filters\n"
5615 "AS path access-list name\n"
5616 "Filter incoming routes\n"
5617 "Filter outgoing routes\n")
5619 DEFUN (no_neighbor_filter_list
,
5620 no_neighbor_filter_list_cmd
,
5621 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5625 "Establish BGP filters\n"
5626 "AS path access-list name\n"
5627 "Filter incoming routes\n"
5628 "Filter outgoing routes\n")
5632 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5633 bgp_node_afi(vty
), bgp_node_safi(vty
),
5634 argv
[idx_in_out
]->arg
);
5637 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5638 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5639 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5640 "Establish BGP filters\n"
5641 "AS path access-list name\n"
5642 "Filter incoming routes\n"
5643 "Filter outgoing routes\n")
5645 /* Set route-map to the peer. */
5646 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5647 afi_t afi
, safi_t safi
, const char *name_str
,
5648 const char *direct_str
)
5652 int direct
= RMAP_IN
;
5653 struct route_map
*route_map
;
5655 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5657 return CMD_WARNING_CONFIG_FAILED
;
5659 /* Check filter direction. */
5660 if (strncmp(direct_str
, "in", 2) == 0)
5662 else if (strncmp(direct_str
, "o", 1) == 0)
5665 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5666 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
5668 return bgp_vty_return(vty
, ret
);
5671 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5672 afi_t afi
, safi_t safi
,
5673 const char *direct_str
)
5677 int direct
= RMAP_IN
;
5679 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5681 return CMD_WARNING_CONFIG_FAILED
;
5683 /* Check filter direction. */
5684 if (strncmp(direct_str
, "in", 2) == 0)
5686 else if (strncmp(direct_str
, "o", 1) == 0)
5689 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5691 return bgp_vty_return(vty
, ret
);
5694 DEFUN (neighbor_route_map
,
5695 neighbor_route_map_cmd
,
5696 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5699 "Apply route map to neighbor\n"
5700 "Name of route map\n"
5701 "Apply map to incoming routes\n"
5702 "Apply map to outbound routes\n")
5707 return peer_route_map_set_vty(
5708 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5709 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5712 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5713 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5714 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5715 "Apply route map to neighbor\n"
5716 "Name of route map\n"
5717 "Apply map to incoming routes\n"
5718 "Apply map to outbound routes\n")
5720 DEFUN (no_neighbor_route_map
,
5721 no_neighbor_route_map_cmd
,
5722 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5726 "Apply route map to neighbor\n"
5727 "Name of route map\n"
5728 "Apply map to incoming routes\n"
5729 "Apply map to outbound routes\n")
5733 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5734 bgp_node_afi(vty
), bgp_node_safi(vty
),
5735 argv
[idx_in_out
]->arg
);
5738 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5739 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5740 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5741 "Apply route map to neighbor\n"
5742 "Name of route map\n"
5743 "Apply map to incoming routes\n"
5744 "Apply map to outbound routes\n")
5746 /* Set unsuppress-map to the peer. */
5747 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5748 afi_t afi
, safi_t safi
,
5749 const char *name_str
)
5753 struct route_map
*route_map
;
5755 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5757 return CMD_WARNING_CONFIG_FAILED
;
5759 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5760 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
5762 return bgp_vty_return(vty
, ret
);
5765 /* Unset route-map from the peer. */
5766 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5767 afi_t afi
, safi_t safi
)
5772 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5774 return CMD_WARNING_CONFIG_FAILED
;
5776 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5778 return bgp_vty_return(vty
, ret
);
5781 DEFUN (neighbor_unsuppress_map
,
5782 neighbor_unsuppress_map_cmd
,
5783 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5786 "Route-map to selectively unsuppress suppressed routes\n"
5787 "Name of route map\n")
5791 return peer_unsuppress_map_set_vty(
5792 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5793 argv
[idx_word
]->arg
);
5796 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5797 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5798 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5799 "Route-map to selectively unsuppress suppressed routes\n"
5800 "Name of route map\n")
5802 DEFUN (no_neighbor_unsuppress_map
,
5803 no_neighbor_unsuppress_map_cmd
,
5804 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5808 "Route-map to selectively unsuppress suppressed routes\n"
5809 "Name of route map\n")
5812 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5814 bgp_node_safi(vty
));
5817 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5818 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5819 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5820 "Route-map to selectively unsuppress suppressed routes\n"
5821 "Name of route map\n")
5823 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5824 afi_t afi
, safi_t safi
,
5825 const char *num_str
,
5826 const char *threshold_str
, int warning
,
5827 const char *restart_str
)
5835 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5837 return CMD_WARNING_CONFIG_FAILED
;
5839 max
= strtoul(num_str
, NULL
, 10);
5841 threshold
= atoi(threshold_str
);
5843 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5846 restart
= atoi(restart_str
);
5850 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5853 return bgp_vty_return(vty
, ret
);
5856 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5857 afi_t afi
, safi_t safi
)
5862 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5864 return CMD_WARNING_CONFIG_FAILED
;
5866 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5868 return bgp_vty_return(vty
, ret
);
5871 /* Maximum number of prefix configuration. prefix count is different
5872 for each peer configuration. So this configuration can be set for
5873 each peer configuration. */
5874 DEFUN (neighbor_maximum_prefix
,
5875 neighbor_maximum_prefix_cmd
,
5876 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5879 "Maximum number of prefix accept from this peer\n"
5880 "maximum no. of prefix limit\n")
5884 return peer_maximum_prefix_set_vty(
5885 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5886 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5889 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5890 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5891 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5892 "Maximum number of prefix accept from this peer\n"
5893 "maximum no. of prefix limit\n")
5895 DEFUN (neighbor_maximum_prefix_threshold
,
5896 neighbor_maximum_prefix_threshold_cmd
,
5897 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5900 "Maximum number of prefix accept from this peer\n"
5901 "maximum no. of prefix limit\n"
5902 "Threshold value (%) at which to generate a warning msg\n")
5906 int idx_number_2
= 4;
5907 return peer_maximum_prefix_set_vty(
5908 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5909 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5913 neighbor_maximum_prefix_threshold
,
5914 neighbor_maximum_prefix_threshold_hidden_cmd
,
5915 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5916 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5917 "Maximum number of prefix accept from this peer\n"
5918 "maximum no. of prefix limit\n"
5919 "Threshold value (%) at which to generate a warning msg\n")
5921 DEFUN (neighbor_maximum_prefix_warning
,
5922 neighbor_maximum_prefix_warning_cmd
,
5923 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5926 "Maximum number of prefix accept from this peer\n"
5927 "maximum no. of prefix limit\n"
5928 "Only give warning message when limit is exceeded\n")
5932 return peer_maximum_prefix_set_vty(
5933 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5934 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
5938 neighbor_maximum_prefix_warning
,
5939 neighbor_maximum_prefix_warning_hidden_cmd
,
5940 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5941 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5942 "Maximum number of prefix accept from this peer\n"
5943 "maximum no. of prefix limit\n"
5944 "Only give warning message when limit is exceeded\n")
5946 DEFUN (neighbor_maximum_prefix_threshold_warning
,
5947 neighbor_maximum_prefix_threshold_warning_cmd
,
5948 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5951 "Maximum number of prefix accept from this peer\n"
5952 "maximum no. of prefix limit\n"
5953 "Threshold value (%) at which to generate a warning msg\n"
5954 "Only give warning message when limit is exceeded\n")
5958 int idx_number_2
= 4;
5959 return peer_maximum_prefix_set_vty(
5960 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5961 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
5965 neighbor_maximum_prefix_threshold_warning
,
5966 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
5967 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5968 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5969 "Maximum number of prefix accept from this peer\n"
5970 "maximum no. of prefix limit\n"
5971 "Threshold value (%) at which to generate a warning msg\n"
5972 "Only give warning message when limit is exceeded\n")
5974 DEFUN (neighbor_maximum_prefix_restart
,
5975 neighbor_maximum_prefix_restart_cmd
,
5976 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5979 "Maximum number of prefix accept from this peer\n"
5980 "maximum no. of prefix limit\n"
5981 "Restart bgp connection after limit is exceeded\n"
5982 "Restart interval in minutes\n")
5986 int idx_number_2
= 5;
5987 return peer_maximum_prefix_set_vty(
5988 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5989 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
5993 neighbor_maximum_prefix_restart
,
5994 neighbor_maximum_prefix_restart_hidden_cmd
,
5995 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5996 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5997 "Maximum number of prefix accept from this peer\n"
5998 "maximum no. of prefix limit\n"
5999 "Restart bgp connection after limit is exceeded\n"
6000 "Restart interval in minutes\n")
6002 DEFUN (neighbor_maximum_prefix_threshold_restart
,
6003 neighbor_maximum_prefix_threshold_restart_cmd
,
6004 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6007 "Maximum number of prefixes to accept from this peer\n"
6008 "maximum no. of prefix limit\n"
6009 "Threshold value (%) at which to generate a warning msg\n"
6010 "Restart bgp connection after limit is exceeded\n"
6011 "Restart interval in minutes\n")
6015 int idx_number_2
= 4;
6016 int idx_number_3
= 6;
6017 return peer_maximum_prefix_set_vty(
6018 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6019 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
6020 argv
[idx_number_3
]->arg
);
6024 neighbor_maximum_prefix_threshold_restart
,
6025 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
6026 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6027 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6028 "Maximum number of prefixes to accept from this peer\n"
6029 "maximum no. of prefix limit\n"
6030 "Threshold value (%) at which to generate a warning msg\n"
6031 "Restart bgp connection after limit is exceeded\n"
6032 "Restart interval in minutes\n")
6034 DEFUN (no_neighbor_maximum_prefix
,
6035 no_neighbor_maximum_prefix_cmd
,
6036 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6040 "Maximum number of prefixes to accept from this peer\n"
6041 "maximum no. of prefix limit\n"
6042 "Threshold value (%) at which to generate a warning msg\n"
6043 "Restart bgp connection after limit is exceeded\n"
6044 "Restart interval in minutes\n"
6045 "Only give warning message when limit is exceeded\n")
6048 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
6050 bgp_node_safi(vty
));
6054 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
6055 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6056 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6057 "Maximum number of prefixes to accept from this peer\n"
6058 "maximum no. of prefix limit\n"
6059 "Threshold value (%) at which to generate a warning msg\n"
6060 "Restart bgp connection after limit is exceeded\n"
6061 "Restart interval in minutes\n"
6062 "Only give warning message when limit is exceeded\n")
6065 /* "neighbor allowas-in" */
6066 DEFUN (neighbor_allowas_in
,
6067 neighbor_allowas_in_cmd
,
6068 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6071 "Accept as-path with my AS present in it\n"
6072 "Number of occurrences of AS number\n"
6073 "Only accept my AS in the as-path if the route was originated in my AS\n")
6076 int idx_number_origin
= 3;
6082 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6084 return CMD_WARNING_CONFIG_FAILED
;
6086 if (argc
<= idx_number_origin
)
6089 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6092 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6095 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6098 return bgp_vty_return(vty
, ret
);
6102 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6103 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6104 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6105 "Accept as-path with my AS present in it\n"
6106 "Number of occurrences of AS number\n"
6107 "Only accept my AS in the as-path if the route was originated in my AS\n")
6109 DEFUN (no_neighbor_allowas_in
,
6110 no_neighbor_allowas_in_cmd
,
6111 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6115 "allow local ASN appears in aspath attribute\n"
6116 "Number of occurrences of AS number\n"
6117 "Only accept my AS in the as-path if the route was originated in my AS\n")
6123 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6125 return CMD_WARNING_CONFIG_FAILED
;
6127 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6128 bgp_node_safi(vty
));
6130 return bgp_vty_return(vty
, ret
);
6134 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6135 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6136 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6137 "allow local ASN appears in aspath attribute\n"
6138 "Number of occurrences of AS number\n"
6139 "Only accept my AS in the as-path if the route was originated in my AS\n")
6141 DEFUN (neighbor_ttl_security
,
6142 neighbor_ttl_security_cmd
,
6143 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6146 "BGP ttl-security parameters\n"
6147 "Specify the maximum number of hops to the BGP peer\n"
6148 "Number of hops to BGP peer\n")
6155 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6157 return CMD_WARNING_CONFIG_FAILED
;
6159 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6162 * If 'neighbor swpX', then this is for directly connected peers,
6163 * we should not accept a ttl-security hops value greater than 1.
6165 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6167 "%s is directly connected peer, hops cannot exceed 1\n",
6168 argv
[idx_peer
]->arg
);
6169 return CMD_WARNING_CONFIG_FAILED
;
6172 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6175 DEFUN (no_neighbor_ttl_security
,
6176 no_neighbor_ttl_security_cmd
,
6177 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6181 "BGP ttl-security parameters\n"
6182 "Specify the maximum number of hops to the BGP peer\n"
6183 "Number of hops to BGP peer\n")
6188 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6190 return CMD_WARNING_CONFIG_FAILED
;
6192 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6195 DEFUN (neighbor_addpath_tx_all_paths
,
6196 neighbor_addpath_tx_all_paths_cmd
,
6197 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6200 "Use addpath to advertise all paths to a neighbor\n")
6205 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6207 return CMD_WARNING_CONFIG_FAILED
;
6209 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6214 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6215 neighbor_addpath_tx_all_paths_hidden_cmd
,
6216 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6217 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6218 "Use addpath to advertise all paths to a neighbor\n")
6220 DEFUN (no_neighbor_addpath_tx_all_paths
,
6221 no_neighbor_addpath_tx_all_paths_cmd
,
6222 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6226 "Use addpath to advertise all paths to a neighbor\n")
6231 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6233 return CMD_WARNING_CONFIG_FAILED
;
6235 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6236 != BGP_ADDPATH_ALL
) {
6238 "%% Peer not currently configured to transmit all paths.");
6239 return CMD_WARNING_CONFIG_FAILED
;
6242 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6248 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6249 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6250 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6251 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6252 "Use addpath to advertise all paths to a neighbor\n")
6254 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6255 neighbor_addpath_tx_bestpath_per_as_cmd
,
6256 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6259 "Use addpath to advertise the bestpath per each neighboring AS\n")
6264 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6266 return CMD_WARNING_CONFIG_FAILED
;
6268 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6269 BGP_ADDPATH_BEST_PER_AS
);
6274 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6275 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6276 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6277 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6278 "Use addpath to advertise the bestpath per each neighboring AS\n")
6280 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6281 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6282 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6286 "Use addpath to advertise the bestpath per each neighboring AS\n")
6291 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6293 return CMD_WARNING_CONFIG_FAILED
;
6295 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6296 != BGP_ADDPATH_BEST_PER_AS
) {
6298 "%% Peer not currently configured to transmit all best path per as.");
6299 return CMD_WARNING_CONFIG_FAILED
;
6302 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6308 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6309 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6310 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6311 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6312 "Use addpath to advertise the bestpath per each neighboring AS\n")
6314 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6315 struct ecommunity
**list
)
6317 struct ecommunity
*ecom
= NULL
;
6318 struct ecommunity
*ecomadd
;
6320 for (; argc
; --argc
, ++argv
) {
6322 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6323 ECOMMUNITY_ROUTE_TARGET
, 0);
6325 vty_out(vty
, "Malformed community-list value\n");
6327 ecommunity_free(&ecom
);
6328 return CMD_WARNING_CONFIG_FAILED
;
6332 ecommunity_merge(ecom
, ecomadd
);
6333 ecommunity_free(&ecomadd
);
6340 ecommunity_free(&*list
);
6348 * v2vimport is true if we are handling a `import vrf ...` command
6350 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6354 switch (vty
->node
) {
6363 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6368 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6369 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6370 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6371 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6373 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6377 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6378 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6379 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6380 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6382 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6389 DEFPY (af_rd_vpn_export
,
6390 af_rd_vpn_export_cmd
,
6391 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6393 "Specify route distinguisher\n"
6394 "Between current address-family and vpn\n"
6395 "For routes leaked from current address-family to vpn\n"
6396 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6398 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6399 struct prefix_rd prd
;
6405 if (argv_find(argv
, argc
, "no", &idx
))
6409 ret
= str2prefix_rd(rd_str
, &prd
);
6411 vty_out(vty
, "%% Malformed rd\n");
6412 return CMD_WARNING_CONFIG_FAILED
;
6416 afi
= vpn_policy_getafi(vty
, bgp
, false);
6418 return CMD_WARNING_CONFIG_FAILED
;
6421 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6423 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6424 bgp_get_default(), bgp
);
6427 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6428 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6429 BGP_VPN_POLICY_TOVPN_RD_SET
);
6431 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6432 BGP_VPN_POLICY_TOVPN_RD_SET
);
6435 /* post-change: re-export vpn routes */
6436 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6437 bgp_get_default(), bgp
);
6442 ALIAS (af_rd_vpn_export
,
6443 af_no_rd_vpn_export_cmd
,
6446 "Specify route distinguisher\n"
6447 "Between current address-family and vpn\n"
6448 "For routes leaked from current address-family to vpn\n")
6450 DEFPY (af_label_vpn_export
,
6451 af_label_vpn_export_cmd
,
6452 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6454 "label value for VRF\n"
6455 "Between current address-family and vpn\n"
6456 "For routes leaked from current address-family to vpn\n"
6457 "Label Value <0-1048575>\n"
6458 "Automatically assign a label\n")
6460 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6461 mpls_label_t label
= MPLS_LABEL_NONE
;
6466 if (argv_find(argv
, argc
, "no", &idx
))
6469 /* If "no ...", squash trailing parameter */
6475 label
= label_val
; /* parser should force unsigned */
6478 afi
= vpn_policy_getafi(vty
, bgp
, false);
6480 return CMD_WARNING_CONFIG_FAILED
;
6483 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6484 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6489 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6491 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6492 bgp_get_default(), bgp
);
6494 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6495 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6497 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6500 * label has previously been automatically
6501 * assigned by labelpool: release it
6503 * NB if tovpn_label == MPLS_LABEL_NONE it
6504 * means the automatic assignment is in flight
6505 * and therefore the labelpool callback must
6506 * detect that the auto label is not needed.
6509 bgp_lp_release(LP_TYPE_VRF
,
6510 &bgp
->vpn_policy
[afi
],
6511 bgp
->vpn_policy
[afi
].tovpn_label
);
6513 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6514 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6517 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6519 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6520 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6521 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6522 vpn_leak_label_callback
);
6525 /* post-change: re-export vpn routes */
6526 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6527 bgp_get_default(), bgp
);
6532 ALIAS (af_label_vpn_export
,
6533 af_no_label_vpn_export_cmd
,
6534 "no label vpn export",
6536 "label value for VRF\n"
6537 "Between current address-family and vpn\n"
6538 "For routes leaked from current address-family to vpn\n")
6540 DEFPY (af_nexthop_vpn_export
,
6541 af_nexthop_vpn_export_cmd
,
6542 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6544 "Specify next hop to use for VRF advertised prefixes\n"
6545 "Between current address-family and vpn\n"
6546 "For routes leaked from current address-family to vpn\n"
6550 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6556 if (argv_find(argv
, argc
, "no", &idx
))
6560 if (!sockunion2hostprefix(nexthop_str
, &p
))
6561 return CMD_WARNING_CONFIG_FAILED
;
6564 afi
= vpn_policy_getafi(vty
, bgp
, false);
6566 return CMD_WARNING_CONFIG_FAILED
;
6569 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6571 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6572 bgp_get_default(), bgp
);
6575 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6576 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6577 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6579 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6580 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6583 /* post-change: re-export vpn routes */
6584 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6585 bgp_get_default(), bgp
);
6590 ALIAS (af_nexthop_vpn_export
,
6591 af_no_nexthop_vpn_export_cmd
,
6592 "no nexthop vpn export",
6594 "Specify next hop to use for VRF advertised prefixes\n"
6595 "Between current address-family and vpn\n"
6596 "For routes leaked from current address-family to vpn\n")
6598 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6600 if (!strcmp(dstr
, "import")) {
6601 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6602 } else if (!strcmp(dstr
, "export")) {
6603 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6604 } else if (!strcmp(dstr
, "both")) {
6605 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6606 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6608 vty_out(vty
, "%% direction parse error\n");
6609 return CMD_WARNING_CONFIG_FAILED
;
6614 DEFPY (af_rt_vpn_imexport
,
6615 af_rt_vpn_imexport_cmd
,
6616 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6618 "Specify route target list\n"
6619 "Specify route target list\n"
6620 "Between current address-family and vpn\n"
6621 "For routes leaked from vpn to current address-family: match any\n"
6622 "For routes leaked from current address-family to vpn: set\n"
6623 "both import: match any and export: set\n"
6624 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6626 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6628 struct ecommunity
*ecom
= NULL
;
6629 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6630 vpn_policy_direction_t dir
;
6635 if (argv_find(argv
, argc
, "no", &idx
))
6638 afi
= vpn_policy_getafi(vty
, bgp
, false);
6640 return CMD_WARNING_CONFIG_FAILED
;
6642 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6643 if (ret
!= CMD_SUCCESS
)
6647 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6648 vty_out(vty
, "%% Missing RTLIST\n");
6649 return CMD_WARNING_CONFIG_FAILED
;
6651 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6652 if (ret
!= CMD_SUCCESS
) {
6657 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6661 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6664 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6666 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6667 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6668 ecommunity_dup(ecom
);
6670 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6672 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6673 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6676 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6680 ecommunity_free(&ecom
);
6685 ALIAS (af_rt_vpn_imexport
,
6686 af_no_rt_vpn_imexport_cmd
,
6687 "no <rt|route-target> vpn <import|export|both>$direction_str",
6689 "Specify route target list\n"
6690 "Specify route target list\n"
6691 "Between current address-family and vpn\n"
6692 "For routes leaked from vpn to current address-family\n"
6693 "For routes leaked from current address-family to vpn\n"
6694 "both import and export\n")
6696 DEFPY (af_route_map_vpn_imexport
,
6697 af_route_map_vpn_imexport_cmd
,
6698 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6699 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6701 "Specify route map\n"
6702 "Between current address-family and vpn\n"
6703 "For routes leaked from vpn to current address-family\n"
6704 "For routes leaked from current address-family to vpn\n"
6705 "name of route-map\n")
6707 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6709 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6710 vpn_policy_direction_t dir
;
6715 if (argv_find(argv
, argc
, "no", &idx
))
6718 afi
= vpn_policy_getafi(vty
, bgp
, false);
6720 return CMD_WARNING_CONFIG_FAILED
;
6722 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6723 if (ret
!= CMD_SUCCESS
)
6726 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6730 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6733 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6734 XFREE(MTYPE_ROUTE_MAP_NAME
,
6735 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6736 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6737 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6738 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6739 route_map_lookup_warn_noexist(vty
, rmap_str
);
6740 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6743 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6744 XFREE(MTYPE_ROUTE_MAP_NAME
,
6745 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6746 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6747 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6750 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6756 ALIAS (af_route_map_vpn_imexport
,
6757 af_no_route_map_vpn_imexport_cmd
,
6758 "no route-map vpn <import|export>$direction_str",
6760 "Specify route map\n"
6761 "Between current address-family and vpn\n"
6762 "For routes leaked from vpn to current address-family\n"
6763 "For routes leaked from current address-family to vpn\n")
6765 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6766 "[no] import vrf route-map RMAP$rmap_str",
6768 "Import routes from another VRF\n"
6769 "Vrf routes being filtered\n"
6770 "Specify route map\n"
6771 "name of route-map\n")
6773 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6774 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6778 struct bgp
*bgp_default
;
6780 if (argv_find(argv
, argc
, "no", &idx
))
6783 afi
= vpn_policy_getafi(vty
, bgp
, true);
6785 return CMD_WARNING_CONFIG_FAILED
;
6787 bgp_default
= bgp_get_default();
6792 /* Auto-create assuming the same AS */
6793 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6794 BGP_INSTANCE_TYPE_DEFAULT
);
6798 "VRF default is not configured as a bgp instance\n");
6803 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6806 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6807 XFREE(MTYPE_ROUTE_MAP_NAME
,
6808 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6809 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6810 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6811 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6812 route_map_lookup_warn_noexist(vty
, rmap_str
);
6813 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6816 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6817 XFREE(MTYPE_ROUTE_MAP_NAME
,
6818 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6819 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6820 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6823 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6828 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6829 "no import vrf route-map",
6831 "Import routes from another VRF\n"
6832 "Vrf routes being filtered\n"
6833 "Specify route map\n")
6835 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
6836 "[no] import vrf VIEWVRFNAME$import_name",
6838 "Import routes from another VRF\n"
6839 "VRF to import from\n"
6840 "The name of the VRF\n")
6842 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6843 struct listnode
*node
;
6844 struct bgp
*vrf_bgp
, *bgp_default
;
6847 bool remove
= false;
6850 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
6854 if (import_name
== NULL
) {
6855 vty_out(vty
, "%% Missing import name\n");
6859 if (argv_find(argv
, argc
, "no", &idx
))
6862 afi
= vpn_policy_getafi(vty
, bgp
, true);
6864 return CMD_WARNING_CONFIG_FAILED
;
6866 safi
= bgp_node_safi(vty
);
6868 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
6869 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
6870 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
6871 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
6872 remove
? "unimport" : "import", import_name
);
6876 bgp_default
= bgp_get_default();
6878 /* Auto-create assuming the same AS */
6879 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6880 BGP_INSTANCE_TYPE_DEFAULT
);
6884 "VRF default is not configured as a bgp instance\n");
6889 vrf_bgp
= bgp_lookup_by_name(import_name
);
6891 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
6892 vrf_bgp
= bgp_default
;
6894 /* Auto-create assuming the same AS */
6895 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
6899 "VRF %s is not configured as a bgp instance\n",
6906 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6908 /* Already importing from "import_vrf"? */
6909 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
6911 if (strcmp(vname
, import_name
) == 0)
6915 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6921 /* This command is valid only in a bgp vrf instance or the default instance */
6922 DEFPY (bgp_imexport_vpn
,
6923 bgp_imexport_vpn_cmd
,
6924 "[no] <import|export>$direction_str vpn",
6926 "Import routes to this address-family\n"
6927 "Export routes from this address-family\n"
6928 "to/from default instance VPN RIB\n")
6930 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6937 vpn_policy_direction_t dir
;
6939 if (argv_find(argv
, argc
, "no", &idx
))
6942 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
6943 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
6945 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
6946 return CMD_WARNING_CONFIG_FAILED
;
6949 afi
= bgp_node_afi(vty
);
6950 safi
= bgp_node_safi(vty
);
6951 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
6952 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
6953 return CMD_WARNING_CONFIG_FAILED
;
6956 if (!strcmp(direction_str
, "import")) {
6957 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
6958 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6959 } else if (!strcmp(direction_str
, "export")) {
6960 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
6961 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
6963 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
6964 return CMD_WARNING_CONFIG_FAILED
;
6967 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6970 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6971 if (!previous_state
) {
6972 /* trigger export current vrf */
6973 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6976 if (previous_state
) {
6977 /* trigger un-export current vrf */
6978 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6980 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6986 DEFPY (af_routetarget_import
,
6987 af_routetarget_import_cmd
,
6988 "[no] <rt|route-target> redirect import RTLIST...",
6990 "Specify route target list\n"
6991 "Specify route target list\n"
6992 "Flow-spec redirect type route target\n"
6993 "Import routes to this address-family\n"
6994 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6996 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6998 struct ecommunity
*ecom
= NULL
;
7003 if (argv_find(argv
, argc
, "no", &idx
))
7006 afi
= vpn_policy_getafi(vty
, bgp
, false);
7008 return CMD_WARNING_CONFIG_FAILED
;
7011 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7012 vty_out(vty
, "%% Missing RTLIST\n");
7013 return CMD_WARNING_CONFIG_FAILED
;
7015 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7016 if (ret
!= CMD_SUCCESS
)
7021 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7022 ecommunity_free(&bgp
->vpn_policy
[afi
]
7023 .import_redirect_rtlist
);
7024 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
7025 ecommunity_dup(ecom
);
7027 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7028 ecommunity_free(&bgp
->vpn_policy
[afi
]
7029 .import_redirect_rtlist
);
7030 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
7034 ecommunity_free(&ecom
);
7039 DEFUN_NOSH (address_family_ipv4_safi
,
7040 address_family_ipv4_safi_cmd
,
7041 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7042 "Enter Address Family command mode\n"
7044 BGP_SAFI_WITH_LABEL_HELP_STR
)
7048 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7049 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7050 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7051 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7052 && safi
!= SAFI_EVPN
) {
7054 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7055 return CMD_WARNING_CONFIG_FAILED
;
7057 vty
->node
= bgp_node_type(AFI_IP
, safi
);
7059 vty
->node
= BGP_IPV4_NODE
;
7064 DEFUN_NOSH (address_family_ipv6_safi
,
7065 address_family_ipv6_safi_cmd
,
7066 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7067 "Enter Address Family command mode\n"
7069 BGP_SAFI_WITH_LABEL_HELP_STR
)
7072 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7073 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7074 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7075 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7076 && safi
!= SAFI_EVPN
) {
7078 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7079 return CMD_WARNING_CONFIG_FAILED
;
7081 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
7083 vty
->node
= BGP_IPV6_NODE
;
7088 #ifdef KEEP_OLD_VPN_COMMANDS
7089 DEFUN_NOSH (address_family_vpnv4
,
7090 address_family_vpnv4_cmd
,
7091 "address-family vpnv4 [unicast]",
7092 "Enter Address Family command mode\n"
7094 "Address Family modifier\n")
7096 vty
->node
= BGP_VPNV4_NODE
;
7100 DEFUN_NOSH (address_family_vpnv6
,
7101 address_family_vpnv6_cmd
,
7102 "address-family vpnv6 [unicast]",
7103 "Enter Address Family command mode\n"
7105 "Address Family modifier\n")
7107 vty
->node
= BGP_VPNV6_NODE
;
7110 #endif /* KEEP_OLD_VPN_COMMANDS */
7112 DEFUN_NOSH (address_family_evpn
,
7113 address_family_evpn_cmd
,
7114 "address-family l2vpn evpn",
7115 "Enter Address Family command mode\n"
7117 "Address Family modifier\n")
7119 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7120 vty
->node
= BGP_EVPN_NODE
;
7124 DEFUN_NOSH (exit_address_family
,
7125 exit_address_family_cmd
,
7126 "exit-address-family",
7127 "Exit from Address Family configuration mode\n")
7129 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7130 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7131 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7132 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7133 || vty
->node
== BGP_EVPN_NODE
7134 || vty
->node
== BGP_FLOWSPECV4_NODE
7135 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7136 vty
->node
= BGP_NODE
;
7140 /* Recalculate bestpath and re-advertise a prefix */
7141 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7142 const char *ip_str
, afi_t afi
, safi_t safi
,
7143 struct prefix_rd
*prd
)
7146 struct prefix match
;
7147 struct bgp_node
*rn
;
7148 struct bgp_node
*rm
;
7150 struct bgp_table
*table
;
7151 struct bgp_table
*rib
;
7153 /* BGP structure lookup. */
7155 bgp
= bgp_lookup_by_name(view_name
);
7157 vty_out(vty
, "%% Can't find BGP instance %s\n",
7162 bgp
= bgp_get_default();
7164 vty_out(vty
, "%% No BGP process is configured\n");
7169 /* Check IP address argument. */
7170 ret
= str2prefix(ip_str
, &match
);
7172 vty_out(vty
, "%% address is malformed\n");
7176 match
.family
= afi2family(afi
);
7177 rib
= bgp
->rib
[afi
][safi
];
7179 if (safi
== SAFI_MPLS_VPN
) {
7180 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7181 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7184 table
= bgp_node_get_bgp_table_info(rn
);
7185 if (table
!= NULL
) {
7187 if ((rm
= bgp_node_match(table
, &match
))
7190 == match
.prefixlen
) {
7192 BGP_NODE_USER_CLEAR
);
7193 bgp_process(bgp
, rm
, afi
, safi
);
7195 bgp_unlock_node(rm
);
7200 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7201 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7202 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7203 bgp_process(bgp
, rn
, afi
, safi
);
7205 bgp_unlock_node(rn
);
7212 /* one clear bgp command to rule them all */
7213 DEFUN (clear_ip_bgp_all
,
7214 clear_ip_bgp_all_cmd
,
7215 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out>]",
7219 BGP_INSTANCE_HELP_STR
7222 BGP_SAFI_WITH_LABEL_HELP_STR
7223 "Address Family modifier\n"
7225 "BGP neighbor address to clear\n"
7226 "BGP IPv6 neighbor to clear\n"
7227 "BGP neighbor on interface to clear\n"
7228 "Clear peers with the AS number\n"
7229 "Clear all external peers\n"
7230 "Clear all members of peer-group\n"
7231 "BGP peer-group name\n"
7236 "Push out prefix-list ORF and do inbound soft reconfig\n"
7241 afi_t afi
= AFI_IP6
;
7242 safi_t safi
= SAFI_UNICAST
;
7243 enum clear_sort clr_sort
= clear_peer
;
7244 enum bgp_clear_type clr_type
;
7245 char *clr_arg
= NULL
;
7249 /* clear [ip] bgp */
7250 if (argv_find(argv
, argc
, "ip", &idx
))
7253 /* [<vrf> VIEWVRFNAME] */
7254 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7255 vrf
= argv
[idx
+ 1]->arg
;
7257 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7259 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7260 /* [<view> VIEWVRFNAME] */
7261 vrf
= argv
[idx
+ 1]->arg
;
7264 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7265 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7266 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7268 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
7269 if (argv_find(argv
, argc
, "*", &idx
)) {
7270 clr_sort
= clear_all
;
7271 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7272 clr_sort
= clear_peer
;
7273 clr_arg
= argv
[idx
]->arg
;
7274 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7275 clr_sort
= clear_peer
;
7276 clr_arg
= argv
[idx
]->arg
;
7277 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7278 clr_sort
= clear_group
;
7280 clr_arg
= argv
[idx
]->arg
;
7281 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
7282 clr_sort
= clear_peer
;
7283 clr_arg
= argv
[idx
]->arg
;
7284 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7285 clr_sort
= clear_peer
;
7286 clr_arg
= argv
[idx
]->arg
;
7287 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7288 clr_sort
= clear_as
;
7289 clr_arg
= argv
[idx
]->arg
;
7290 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7291 clr_sort
= clear_external
;
7294 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7295 if (argv_find(argv
, argc
, "soft", &idx
)) {
7296 if (argv_find(argv
, argc
, "in", &idx
)
7297 || argv_find(argv
, argc
, "out", &idx
))
7298 clr_type
= strmatch(argv
[idx
]->text
, "in")
7300 : BGP_CLEAR_SOFT_OUT
;
7302 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7303 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7304 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7305 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7306 : BGP_CLEAR_SOFT_IN
;
7307 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7308 clr_type
= BGP_CLEAR_SOFT_OUT
;
7310 clr_type
= BGP_CLEAR_SOFT_NONE
;
7312 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7315 DEFUN (clear_ip_bgp_prefix
,
7316 clear_ip_bgp_prefix_cmd
,
7317 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7321 BGP_INSTANCE_HELP_STR
7322 "Clear bestpath and re-advertise\n"
7326 char *prefix
= NULL
;
7330 /* [<view|vrf> VIEWVRFNAME] */
7331 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7332 vrf
= argv
[idx
+ 1]->arg
;
7334 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7336 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7337 /* [<view> VIEWVRFNAME] */
7338 vrf
= argv
[idx
+ 1]->arg
;
7342 prefix
= argv
[argc
- 1]->arg
;
7344 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7347 DEFUN (clear_bgp_ipv6_safi_prefix
,
7348 clear_bgp_ipv6_safi_prefix_cmd
,
7349 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7355 "Clear bestpath and re-advertise\n"
7359 int idx_ipv6_prefix
= 0;
7360 safi_t safi
= SAFI_UNICAST
;
7361 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7362 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7364 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7365 return bgp_clear_prefix(
7366 vty
, NULL
, prefix
, AFI_IP6
,
7370 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7371 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7372 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7376 BGP_INSTANCE_HELP_STR
7379 "Clear bestpath and re-advertise\n"
7383 int idx_vrfview
= 0;
7384 int idx_ipv6_prefix
= 0;
7385 safi_t safi
= SAFI_UNICAST
;
7386 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7387 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7388 char *vrfview
= NULL
;
7390 /* [<view|vrf> VIEWVRFNAME] */
7391 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
7392 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7393 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
7395 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
7396 /* [<view> VIEWVRFNAME] */
7397 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7399 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7401 return bgp_clear_prefix(
7402 vty
, vrfview
, prefix
,
7403 AFI_IP6
, safi
, NULL
);
7406 DEFUN (show_bgp_views
,
7408 "show [ip] bgp views",
7412 "Show the defined BGP views\n")
7414 struct list
*inst
= bm
->bgp
;
7415 struct listnode
*node
;
7418 vty_out(vty
, "Defined BGP views:\n");
7419 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7421 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7423 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7430 DEFUN (show_bgp_vrfs
,
7432 "show [ip] bgp vrfs [json]",
7439 char buf
[ETHER_ADDR_STRLEN
];
7440 struct list
*inst
= bm
->bgp
;
7441 struct listnode
*node
;
7443 bool uj
= use_json(argc
, argv
);
7444 json_object
*json
= NULL
;
7445 json_object
*json_vrfs
= NULL
;
7449 json
= json_object_new_object();
7450 json_vrfs
= json_object_new_object();
7453 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7454 const char *name
, *type
;
7456 struct listnode
*node2
, *nnode2
;
7457 int peers_cfg
, peers_estb
;
7458 json_object
*json_vrf
= NULL
;
7461 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7465 if (!uj
&& count
== 1) {
7467 "%4s %-5s %-16s %9s %10s %-37s\n",
7468 "Type", "Id", "routerId", "#PeersVfg",
7469 "#PeersEstb", "Name");
7470 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
7471 "L3-VNI", "RouterMAC", "Interface");
7474 peers_cfg
= peers_estb
= 0;
7476 json_vrf
= json_object_new_object();
7479 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
7480 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7483 if (peer
->status
== Established
)
7487 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7488 name
= VRF_DEFAULT_NAME
;
7497 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7499 : (int64_t)bgp
->vrf_id
;
7500 json_object_string_add(json_vrf
, "type", type
);
7501 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7502 json_object_string_add(json_vrf
, "routerId",
7503 inet_ntoa(bgp
->router_id
));
7504 json_object_int_add(json_vrf
, "numConfiguredPeers",
7506 json_object_int_add(json_vrf
, "numEstablishedPeers",
7509 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7510 json_object_string_add(
7512 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7513 json_object_string_add(json_vrf
, "interface",
7514 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
7516 json_object_object_add(json_vrfs
, name
, json_vrf
);
7519 "%4s %-5d %-16s %-9u %-10u %-37s\n",
7521 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7523 inet_ntoa(bgp
->router_id
), peers_cfg
,
7525 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
7527 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
7528 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
7534 json_object_object_add(json
, "vrfs", json_vrfs
);
7536 json_object_int_add(json
, "totalVrfs", count
);
7538 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7539 json
, JSON_C_TO_STRING_PRETTY
));
7540 json_object_free(json
);
7544 "\nTotal number of VRFs (including default): %d\n",
7551 DEFUN (show_bgp_mac_hash
,
7552 show_bgp_mac_hash_cmd
,
7553 "show bgp mac hash",
7557 "Mac Address database\n")
7559 bgp_mac_dump_table(vty
);
7564 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
7566 struct vty
*vty
= (struct vty
*)args
;
7567 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
7569 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7573 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7575 vty_out(vty
, "self nexthop database:\n");
7576 bgp_nexthop_show_address_hash(vty
, bgp
);
7578 vty_out(vty
, "Tunnel-ip database:\n");
7579 hash_iterate(bgp
->tip_hash
,
7580 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
7584 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7585 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7586 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7587 "martian next-hops\n"
7588 "martian next-hop database\n")
7590 struct bgp
*bgp
= NULL
;
7594 /* [<vrf> VIEWVRFNAME] */
7595 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7596 name
= argv
[idx
+ 1]->arg
;
7597 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7599 } else if (argv_find(argv
, argc
, "view", &idx
))
7600 /* [<view> VIEWVRFNAME] */
7601 name
= argv
[idx
+ 1]->arg
;
7603 bgp
= bgp_lookup_by_name(name
);
7605 bgp
= bgp_get_default();
7608 vty_out(vty
, "%% No BGP process is configured\n");
7611 bgp_show_martian_nexthops(vty
, bgp
);
7616 DEFUN (show_bgp_memory
,
7617 show_bgp_memory_cmd
,
7618 "show [ip] bgp memory",
7622 "Global BGP memory statistics\n")
7624 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7625 unsigned long count
;
7627 /* RIB related usage stats */
7628 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7629 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7630 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7631 count
* sizeof(struct bgp_node
)));
7633 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7634 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7635 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7636 count
* sizeof(struct bgp_path_info
)));
7637 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7638 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7641 memstrbuf
, sizeof(memstrbuf
),
7642 count
* sizeof(struct bgp_path_info_extra
)));
7644 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7645 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7646 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7647 count
* sizeof(struct bgp_static
)));
7649 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7650 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7651 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7652 count
* sizeof(struct bpacket
)));
7655 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7656 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7657 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7658 count
* sizeof(struct bgp_adj_in
)));
7659 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7660 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7661 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7662 count
* sizeof(struct bgp_adj_out
)));
7664 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7665 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7667 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7668 count
* sizeof(struct bgp_nexthop_cache
)));
7670 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7671 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7673 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7674 count
* sizeof(struct bgp_damp_info
)));
7677 count
= attr_count();
7678 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7679 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7680 count
* sizeof(struct attr
)));
7682 if ((count
= attr_unknown_count()))
7683 vty_out(vty
, "%ld unknown attributes\n", count
);
7685 /* AS_PATH attributes */
7686 count
= aspath_count();
7687 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7688 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7689 count
* sizeof(struct aspath
)));
7691 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7692 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7693 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7694 count
* sizeof(struct assegment
)));
7696 /* Other attributes */
7697 if ((count
= community_count()))
7698 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7699 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7700 count
* sizeof(struct community
)));
7701 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7702 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7703 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7704 count
* sizeof(struct ecommunity
)));
7705 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7707 "%ld BGP large-community entries, using %s of memory\n",
7708 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7709 count
* sizeof(struct lcommunity
)));
7711 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7712 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7713 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7714 count
* sizeof(struct cluster_list
)));
7716 /* Peer related usage */
7717 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7718 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7719 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7720 count
* sizeof(struct peer
)));
7722 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7723 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7724 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7725 count
* sizeof(struct peer_group
)));
7728 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7729 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7730 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7731 count
* sizeof(regex_t
)));
7735 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7737 json_object
*bestpath
= json_object_new_object();
7739 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7740 json_object_string_add(bestpath
, "asPath", "ignore");
7742 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7743 json_object_string_add(bestpath
, "asPath", "confed");
7745 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7746 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7747 json_object_string_add(bestpath
, "multiPathRelax",
7750 json_object_string_add(bestpath
, "multiPathRelax",
7753 json_object_string_add(bestpath
, "multiPathRelax", "false");
7755 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7756 json_object_string_add(bestpath
, "compareRouterId", "true");
7757 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7758 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7759 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7760 json_object_string_add(bestpath
, "med", "confed");
7761 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7762 json_object_string_add(bestpath
, "med",
7763 "missing-as-worst");
7765 json_object_string_add(bestpath
, "med", "true");
7768 json_object_object_add(json
, "bestPath", bestpath
);
7771 /* Show BGP peer's summary information. */
7772 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7776 struct listnode
*node
, *nnode
;
7777 unsigned int count
= 0, dn_count
= 0;
7778 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7779 char neighbor_buf
[VTY_BUFSIZ
];
7780 int neighbor_col_default_width
= 16;
7782 int max_neighbor_width
= 0;
7784 json_object
*json
= NULL
;
7785 json_object
*json_peer
= NULL
;
7786 json_object
*json_peers
= NULL
;
7787 struct peer_af
*paf
;
7789 /* labeled-unicast routes are installed in the unicast table so in order
7791 * display the correct PfxRcd value we must look at SAFI_UNICAST
7793 if (safi
== SAFI_LABELED_UNICAST
)
7794 pfx_rcd_safi
= SAFI_UNICAST
;
7796 pfx_rcd_safi
= safi
;
7799 json
= json_object_new_object();
7800 json_peers
= json_object_new_object();
7802 /* Loop over all neighbors that will be displayed to determine
7804 * characters are needed for the Neighbor column
7806 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7807 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7810 if (peer
->afc
[afi
][safi
]) {
7811 memset(dn_flag
, '\0', sizeof(dn_flag
));
7812 if (peer_dynamic_neighbor(peer
))
7816 && bgp_flag_check(bgp
,
7817 BGP_FLAG_SHOW_HOSTNAME
))
7818 sprintf(neighbor_buf
, "%s%s(%s) ",
7819 dn_flag
, peer
->hostname
,
7822 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7825 len
= strlen(neighbor_buf
);
7827 if (len
> max_neighbor_width
)
7828 max_neighbor_width
= len
;
7832 /* Originally we displayed the Neighbor column as 16
7833 * characters wide so make that the default
7835 if (max_neighbor_width
< neighbor_col_default_width
)
7836 max_neighbor_width
= neighbor_col_default_width
;
7839 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7840 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7843 if (!peer
->afc
[afi
][safi
])
7848 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7851 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7853 : (int64_t)bgp
->vrf_id
;
7855 /* Usage summary and header */
7857 json_object_string_add(
7859 inet_ntoa(bgp
->router_id
));
7860 json_object_int_add(json
, "as", bgp
->as
);
7861 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7862 json_object_string_add(
7865 == BGP_INSTANCE_TYPE_DEFAULT
)
7870 "BGP router identifier %s, local AS number %u vrf-id %d",
7871 inet_ntoa(bgp
->router_id
), bgp
->as
,
7872 bgp
->vrf_id
== VRF_UNKNOWN
7874 : (int)bgp
->vrf_id
);
7878 if (bgp_update_delay_configured(bgp
)) {
7880 json_object_int_add(
7881 json
, "updateDelayLimit",
7882 bgp
->v_update_delay
);
7884 if (bgp
->v_update_delay
7885 != bgp
->v_establish_wait
)
7886 json_object_int_add(
7888 "updateDelayEstablishWait",
7889 bgp
->v_establish_wait
);
7891 if (bgp_update_delay_active(bgp
)) {
7892 json_object_string_add(
7894 "updateDelayFirstNeighbor",
7895 bgp
->update_delay_begin_time
);
7896 json_object_boolean_true_add(
7898 "updateDelayInProgress");
7900 if (bgp
->update_delay_over
) {
7901 json_object_string_add(
7903 "updateDelayFirstNeighbor",
7904 bgp
->update_delay_begin_time
);
7905 json_object_string_add(
7907 "updateDelayBestpathResumed",
7908 bgp
->update_delay_end_time
);
7909 json_object_string_add(
7911 "updateDelayZebraUpdateResume",
7912 bgp
->update_delay_zebra_resume_time
);
7913 json_object_string_add(
7915 "updateDelayPeerUpdateResume",
7916 bgp
->update_delay_peers_resume_time
);
7921 "Read-only mode update-delay limit: %d seconds\n",
7922 bgp
->v_update_delay
);
7923 if (bgp
->v_update_delay
7924 != bgp
->v_establish_wait
)
7926 " Establish wait: %d seconds\n",
7927 bgp
->v_establish_wait
);
7929 if (bgp_update_delay_active(bgp
)) {
7931 " First neighbor established: %s\n",
7932 bgp
->update_delay_begin_time
);
7934 " Delay in progress\n");
7936 if (bgp
->update_delay_over
) {
7938 " First neighbor established: %s\n",
7939 bgp
->update_delay_begin_time
);
7941 " Best-paths resumed: %s\n",
7942 bgp
->update_delay_end_time
);
7944 " zebra update resumed: %s\n",
7945 bgp
->update_delay_zebra_resume_time
);
7947 " peers update resumed: %s\n",
7948 bgp
->update_delay_peers_resume_time
);
7955 if (bgp_maxmed_onstartup_configured(bgp
)
7956 && bgp
->maxmed_active
)
7957 json_object_boolean_true_add(
7958 json
, "maxMedOnStartup");
7959 if (bgp
->v_maxmed_admin
)
7960 json_object_boolean_true_add(
7961 json
, "maxMedAdministrative");
7963 json_object_int_add(
7964 json
, "tableVersion",
7965 bgp_table_version(bgp
->rib
[afi
][safi
]));
7967 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7968 json_object_int_add(json
, "ribCount", ents
);
7969 json_object_int_add(
7971 ents
* sizeof(struct bgp_node
));
7973 ents
= bgp
->af_peer_count
[afi
][safi
];
7974 json_object_int_add(json
, "peerCount", ents
);
7975 json_object_int_add(json
, "peerMemory",
7976 ents
* sizeof(struct peer
));
7978 if ((ents
= listcount(bgp
->group
))) {
7979 json_object_int_add(
7980 json
, "peerGroupCount", ents
);
7981 json_object_int_add(
7982 json
, "peerGroupMemory",
7983 ents
* sizeof(struct
7987 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7988 BGP_CONFIG_DAMPENING
))
7989 json_object_boolean_true_add(
7990 json
, "dampeningEnabled");
7992 if (bgp_maxmed_onstartup_configured(bgp
)
7993 && bgp
->maxmed_active
)
7995 "Max-med on-startup active\n");
7996 if (bgp
->v_maxmed_admin
)
7998 "Max-med administrative active\n");
8000 vty_out(vty
, "BGP table version %" PRIu64
"\n",
8001 bgp_table_version(bgp
->rib
[afi
][safi
]));
8003 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8005 "RIB entries %ld, using %s of memory\n",
8007 mtype_memstr(memstrbuf
,
8009 ents
* sizeof(struct
8012 /* Peer related usage */
8013 ents
= bgp
->af_peer_count
[afi
][safi
];
8014 vty_out(vty
, "Peers %ld, using %s of memory\n",
8017 memstrbuf
, sizeof(memstrbuf
),
8018 ents
* sizeof(struct peer
)));
8020 if ((ents
= listcount(bgp
->group
)))
8022 "Peer groups %ld, using %s of memory\n",
8027 ents
* sizeof(struct
8030 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8031 BGP_CONFIG_DAMPENING
))
8032 vty_out(vty
, "Dampening enabled.\n");
8035 /* Subtract 8 here because 'Neighbor' is
8037 vty_out(vty
, "Neighbor");
8038 vty_out(vty
, "%*s", max_neighbor_width
- 8,
8041 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
8048 json_peer
= json_object_new_object();
8050 if (peer_dynamic_neighbor(peer
)) {
8052 json_object_boolean_true_add(json_peer
,
8057 json_object_string_add(json_peer
, "hostname",
8060 if (peer
->domainname
)
8061 json_object_string_add(json_peer
, "domainname",
8064 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
8065 json_object_int_add(json_peer
, "version", 4);
8066 json_object_int_add(json_peer
, "msgRcvd",
8067 PEER_TOTAL_RX(peer
));
8068 json_object_int_add(json_peer
, "msgSent",
8069 PEER_TOTAL_TX(peer
));
8071 json_object_int_add(json_peer
, "tableVersion",
8072 peer
->version
[afi
][safi
]);
8073 json_object_int_add(json_peer
, "outq",
8075 json_object_int_add(json_peer
, "inq", 0);
8076 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8077 use_json
, json_peer
);
8080 * Adding "pfxRcd" field to match with the corresponding
8081 * CLI. "prefixReceivedCount" will be deprecated in
8084 json_object_int_add(json_peer
, "prefixReceivedCount",
8085 peer
->pcount
[afi
][pfx_rcd_safi
]);
8086 json_object_int_add(json_peer
, "pfxRcd",
8087 peer
->pcount
[afi
][pfx_rcd_safi
]);
8089 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
8090 if (paf
&& PAF_SUBGRP(paf
))
8091 json_object_int_add(json_peer
,
8093 (PAF_SUBGRP(paf
))->scount
);
8095 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8096 json_object_string_add(json_peer
, "state",
8098 else if (peer
->afc_recv
[afi
][safi
])
8099 json_object_string_add(
8101 lookup_msg(bgp_status_msg
, peer
->status
,
8103 else if (CHECK_FLAG(peer
->sflags
,
8104 PEER_STATUS_PREFIX_OVERFLOW
))
8105 json_object_string_add(json_peer
, "state",
8108 json_object_string_add(
8110 lookup_msg(bgp_status_msg
, peer
->status
,
8114 json_object_string_add(json_peer
, "idType",
8116 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8117 json_object_string_add(json_peer
, "idType",
8119 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8120 json_object_string_add(json_peer
, "idType",
8123 json_object_object_add(json_peers
, peer
->host
,
8126 memset(dn_flag
, '\0', sizeof(dn_flag
));
8127 if (peer_dynamic_neighbor(peer
)) {
8133 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8134 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8135 peer
->hostname
, peer
->host
);
8137 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8139 /* pad the neighbor column with spaces */
8140 if (len
< max_neighbor_width
)
8141 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8144 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8145 peer
->as
, PEER_TOTAL_RX(peer
),
8146 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8147 0, peer
->obuf
->count
,
8148 peer_uptime(peer
->uptime
, timebuf
,
8149 BGP_UPTIME_LEN
, 0, NULL
));
8151 if (peer
->status
== Established
)
8152 if (peer
->afc_recv
[afi
][safi
])
8153 vty_out(vty
, " %12ld",
8157 vty_out(vty
, " NoNeg");
8159 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8160 vty_out(vty
, " Idle (Admin)");
8161 else if (CHECK_FLAG(
8163 PEER_STATUS_PREFIX_OVERFLOW
))
8164 vty_out(vty
, " Idle (PfxCt)");
8166 vty_out(vty
, " %12s",
8167 lookup_msg(bgp_status_msg
,
8168 peer
->status
, NULL
));
8175 json_object_object_add(json
, "peers", json_peers
);
8177 json_object_int_add(json
, "totalPeers", count
);
8178 json_object_int_add(json
, "dynamicPeers", dn_count
);
8180 bgp_show_bestpath_json(bgp
, json
);
8182 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8183 json
, JSON_C_TO_STRING_PRETTY
));
8184 json_object_free(json
);
8187 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8189 vty_out(vty
, "No %s neighbor is configured\n",
8190 afi_safi_print(afi
, safi
));
8194 vty_out(vty
, "* - dynamic neighbor\n");
8195 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8196 dn_count
, bgp
->dynamic_neighbors_limit
);
8203 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8204 int safi
, bool use_json
)
8207 int afi_wildcard
= (afi
== AFI_MAX
);
8208 int safi_wildcard
= (safi
== SAFI_MAX
);
8209 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8210 bool nbr_output
= false;
8212 if (use_json
&& is_wildcard
)
8213 vty_out(vty
, "{\n");
8215 afi
= 1; /* AFI_IP */
8216 while (afi
< AFI_MAX
) {
8218 safi
= 1; /* SAFI_UNICAST */
8219 while (safi
< SAFI_MAX
) {
8220 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8225 * So limit output to those afi/safi
8227 * actualy have something interesting in
8232 vty_out(vty
, ",\n");
8236 vty_out(vty
, "\"%s\":",
8240 vty_out(vty
, "\n%s Summary:\n",
8245 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
);
8256 if (use_json
&& is_wildcard
)
8257 vty_out(vty
, "}\n");
8258 else if (!nbr_output
) {
8260 vty_out(vty
, "{}\n");
8262 vty_out(vty
, "%% No BGP neighbors found\n");
8266 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8267 safi_t safi
, bool use_json
)
8269 struct listnode
*node
, *nnode
;
8272 bool nbr_output
= false;
8275 vty_out(vty
, "{\n");
8277 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8281 vty_out(vty
, ",\n");
8285 vty_out(vty
, "\"%s\":",
8286 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8290 vty_out(vty
, "\nInstance %s:\n",
8291 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8295 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
);
8299 vty_out(vty
, "}\n");
8300 else if (!nbr_output
)
8301 vty_out(vty
, "%% BGP instance not found\n");
8304 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8305 safi_t safi
, bool use_json
)
8310 if (strmatch(name
, "all")) {
8311 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8315 bgp
= bgp_lookup_by_name(name
);
8319 vty_out(vty
, "{}\n");
8322 "%% BGP instance not found\n");
8326 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
,
8332 bgp
= bgp_get_default();
8335 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
);
8338 vty_out(vty
, "{}\n");
8340 vty_out(vty
, "%% BGP instance not found\n");
8347 /* `show [ip] bgp summary' commands. */
8348 DEFUN (show_ip_bgp_summary
,
8349 show_ip_bgp_summary_cmd
,
8350 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8354 BGP_INSTANCE_HELP_STR
8356 BGP_SAFI_WITH_LABEL_HELP_STR
8357 "Summary of BGP neighbor status\n"
8361 afi_t afi
= AFI_MAX
;
8362 safi_t safi
= SAFI_MAX
;
8367 if (argv_find(argv
, argc
, "ip", &idx
))
8369 /* [<vrf> VIEWVRFNAME] */
8370 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8371 vrf
= argv
[idx
+ 1]->arg
;
8372 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8374 } else if (argv_find(argv
, argc
, "view", &idx
))
8375 /* [<view> VIEWVRFNAME] */
8376 vrf
= argv
[idx
+ 1]->arg
;
8377 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8378 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8379 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8382 bool uj
= use_json(argc
, argv
);
8384 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8387 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8389 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8390 return "IPv4 Unicast";
8391 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8392 return "IPv4 Multicast";
8393 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8394 return "IPv4 Labeled Unicast";
8395 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8397 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8398 return "IPv4 Encap";
8399 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8400 return "IPv4 Flowspec";
8401 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8402 return "IPv6 Unicast";
8403 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8404 return "IPv6 Multicast";
8405 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8406 return "IPv6 Labeled Unicast";
8407 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8409 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8410 return "IPv6 Encap";
8411 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8412 return "IPv6 Flowspec";
8413 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8414 return "L2VPN EVPN";
8420 * Please note that we have intentionally camelCased
8421 * the return strings here. So if you want
8422 * to use this function, please ensure you
8423 * are doing this within json output
8425 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8427 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8428 return "ipv4Unicast";
8429 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8430 return "ipv4Multicast";
8431 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8432 return "ipv4LabeledUnicast";
8433 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8435 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8437 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8438 return "ipv4Flowspec";
8439 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8440 return "ipv6Unicast";
8441 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8442 return "ipv6Multicast";
8443 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8444 return "ipv6LabeledUnicast";
8445 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8447 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8449 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8450 return "ipv6Flowspec";
8451 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8457 /* Show BGP peer's information. */
8458 enum show_type
{ show_all
, show_peer
, show_ipv4_all
, show_ipv6_all
, show_ipv4_peer
, show_ipv6_peer
};
8460 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8461 afi_t afi
, safi_t safi
,
8462 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8463 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8464 bool use_json
, json_object
*json_pref
)
8467 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8468 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8470 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8471 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8472 json_object_string_add(json_pref
, "sendMode",
8473 "advertisedAndReceived");
8474 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8475 json_object_string_add(json_pref
, "sendMode",
8477 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8478 json_object_string_add(json_pref
, "sendMode",
8481 vty_out(vty
, " Send-mode: ");
8482 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8483 vty_out(vty
, "advertised");
8484 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8485 vty_out(vty
, "%sreceived",
8486 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8495 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8496 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8498 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8499 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8500 json_object_string_add(json_pref
, "recvMode",
8501 "advertisedAndReceived");
8502 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8503 json_object_string_add(json_pref
, "recvMode",
8505 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8506 json_object_string_add(json_pref
, "recvMode",
8509 vty_out(vty
, " Receive-mode: ");
8510 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8511 vty_out(vty
, "advertised");
8512 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8513 vty_out(vty
, "%sreceived",
8514 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8523 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8524 safi_t safi
, bool use_json
,
8525 json_object
*json_neigh
)
8527 struct bgp_filter
*filter
;
8528 struct peer_af
*paf
;
8529 char orf_pfx_name
[BUFSIZ
];
8531 json_object
*json_af
= NULL
;
8532 json_object
*json_prefA
= NULL
;
8533 json_object
*json_prefB
= NULL
;
8534 json_object
*json_addr
= NULL
;
8537 json_addr
= json_object_new_object();
8538 json_af
= json_object_new_object();
8539 filter
= &p
->filter
[afi
][safi
];
8541 if (peer_group_active(p
))
8542 json_object_string_add(json_addr
, "peerGroupMember",
8545 paf
= peer_af_find(p
, afi
, safi
);
8546 if (paf
&& PAF_SUBGRP(paf
)) {
8547 json_object_int_add(json_addr
, "updateGroupId",
8548 PAF_UPDGRP(paf
)->id
);
8549 json_object_int_add(json_addr
, "subGroupId",
8550 PAF_SUBGRP(paf
)->id
);
8551 json_object_int_add(json_addr
, "packetQueueLength",
8552 bpacket_queue_virtual_length(paf
));
8555 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8556 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8557 PEER_CAP_ORF_PREFIX_SM_RCV
)
8558 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8559 PEER_CAP_ORF_PREFIX_RM_ADV
)
8560 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8561 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8562 json_object_int_add(json_af
, "orfType",
8564 json_prefA
= json_object_new_object();
8565 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8566 PEER_CAP_ORF_PREFIX_SM_ADV
,
8567 PEER_CAP_ORF_PREFIX_RM_ADV
,
8568 PEER_CAP_ORF_PREFIX_SM_RCV
,
8569 PEER_CAP_ORF_PREFIX_RM_RCV
,
8570 use_json
, json_prefA
);
8571 json_object_object_add(json_af
, "orfPrefixList",
8575 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8576 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8577 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8578 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8579 PEER_CAP_ORF_PREFIX_RM_ADV
)
8580 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8581 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8582 json_object_int_add(json_af
, "orfOldType",
8583 ORF_TYPE_PREFIX_OLD
);
8584 json_prefB
= json_object_new_object();
8585 bgp_show_peer_afi_orf_cap(
8586 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8587 PEER_CAP_ORF_PREFIX_RM_ADV
,
8588 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8589 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8591 json_object_object_add(json_af
, "orfOldPrefixList",
8595 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8596 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8597 PEER_CAP_ORF_PREFIX_SM_RCV
)
8598 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8599 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8600 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8601 PEER_CAP_ORF_PREFIX_RM_ADV
)
8602 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8603 PEER_CAP_ORF_PREFIX_RM_RCV
)
8604 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8605 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8606 json_object_object_add(json_addr
, "afDependentCap",
8609 json_object_free(json_af
);
8611 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8612 orf_pfx_count
= prefix_bgp_show_prefix_list(
8613 NULL
, afi
, orf_pfx_name
, use_json
);
8615 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8616 PEER_STATUS_ORF_PREFIX_SEND
)
8618 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8619 PEER_STATUS_ORF_PREFIX_SEND
))
8620 json_object_boolean_true_add(json_neigh
,
8623 json_object_int_add(json_addr
, "orfRecvCounter",
8626 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8627 PEER_STATUS_ORF_WAIT_REFRESH
))
8628 json_object_string_add(
8629 json_addr
, "orfFirstUpdate",
8630 "deferredUntilORFOrRouteRefreshRecvd");
8632 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8633 PEER_FLAG_REFLECTOR_CLIENT
))
8634 json_object_boolean_true_add(json_addr
,
8635 "routeReflectorClient");
8636 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8637 PEER_FLAG_RSERVER_CLIENT
))
8638 json_object_boolean_true_add(json_addr
,
8639 "routeServerClient");
8640 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8641 json_object_boolean_true_add(json_addr
,
8642 "inboundSoftConfigPermit");
8644 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8645 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8646 json_object_boolean_true_add(
8648 "privateAsNumsAllReplacedInUpdatesToNbr");
8649 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8650 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8651 json_object_boolean_true_add(
8653 "privateAsNumsReplacedInUpdatesToNbr");
8654 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8655 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8656 json_object_boolean_true_add(
8658 "privateAsNumsAllRemovedInUpdatesToNbr");
8659 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8660 PEER_FLAG_REMOVE_PRIVATE_AS
))
8661 json_object_boolean_true_add(
8663 "privateAsNumsRemovedInUpdatesToNbr");
8665 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8666 json_object_boolean_true_add(
8668 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8671 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8672 json_object_string_add(json_addr
,
8673 "overrideASNsInOutboundUpdates",
8674 "ifAspathEqualRemoteAs");
8676 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8677 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8678 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8679 json_object_boolean_true_add(json_addr
,
8680 "routerAlwaysNextHop");
8681 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8682 PEER_FLAG_AS_PATH_UNCHANGED
))
8683 json_object_boolean_true_add(
8684 json_addr
, "unchangedAsPathPropogatedToNbr");
8685 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8686 PEER_FLAG_NEXTHOP_UNCHANGED
))
8687 json_object_boolean_true_add(
8688 json_addr
, "unchangedNextHopPropogatedToNbr");
8689 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8690 json_object_boolean_true_add(
8691 json_addr
, "unchangedMedPropogatedToNbr");
8692 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8693 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8694 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8695 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8696 PEER_FLAG_SEND_COMMUNITY
)
8697 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8698 PEER_FLAG_SEND_EXT_COMMUNITY
))
8699 json_object_string_add(json_addr
,
8700 "commAttriSentToNbr",
8701 "extendedAndStandard");
8702 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8703 PEER_FLAG_SEND_EXT_COMMUNITY
))
8704 json_object_string_add(json_addr
,
8705 "commAttriSentToNbr",
8708 json_object_string_add(json_addr
,
8709 "commAttriSentToNbr",
8712 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8713 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8714 if (p
->default_rmap
[afi
][safi
].name
)
8715 json_object_string_add(
8716 json_addr
, "defaultRouteMap",
8717 p
->default_rmap
[afi
][safi
].name
);
8719 if (paf
&& PAF_SUBGRP(paf
)
8720 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8721 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8722 json_object_boolean_true_add(json_addr
,
8725 json_object_boolean_true_add(json_addr
,
8729 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8730 if (is_evpn_enabled())
8731 json_object_boolean_true_add(
8732 json_addr
, "advertiseAllVnis");
8735 if (filter
->plist
[FILTER_IN
].name
8736 || filter
->dlist
[FILTER_IN
].name
8737 || filter
->aslist
[FILTER_IN
].name
8738 || filter
->map
[RMAP_IN
].name
)
8739 json_object_boolean_true_add(json_addr
,
8740 "inboundPathPolicyConfig");
8741 if (filter
->plist
[FILTER_OUT
].name
8742 || filter
->dlist
[FILTER_OUT
].name
8743 || filter
->aslist
[FILTER_OUT
].name
8744 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8745 json_object_boolean_true_add(
8746 json_addr
, "outboundPathPolicyConfig");
8749 if (filter
->plist
[FILTER_IN
].name
)
8750 json_object_string_add(json_addr
,
8751 "incomingUpdatePrefixFilterList",
8752 filter
->plist
[FILTER_IN
].name
);
8753 if (filter
->plist
[FILTER_OUT
].name
)
8754 json_object_string_add(json_addr
,
8755 "outgoingUpdatePrefixFilterList",
8756 filter
->plist
[FILTER_OUT
].name
);
8758 /* distribute-list */
8759 if (filter
->dlist
[FILTER_IN
].name
)
8760 json_object_string_add(
8761 json_addr
, "incomingUpdateNetworkFilterList",
8762 filter
->dlist
[FILTER_IN
].name
);
8763 if (filter
->dlist
[FILTER_OUT
].name
)
8764 json_object_string_add(
8765 json_addr
, "outgoingUpdateNetworkFilterList",
8766 filter
->dlist
[FILTER_OUT
].name
);
8769 if (filter
->aslist
[FILTER_IN
].name
)
8770 json_object_string_add(json_addr
,
8771 "incomingUpdateAsPathFilterList",
8772 filter
->aslist
[FILTER_IN
].name
);
8773 if (filter
->aslist
[FILTER_OUT
].name
)
8774 json_object_string_add(json_addr
,
8775 "outgoingUpdateAsPathFilterList",
8776 filter
->aslist
[FILTER_OUT
].name
);
8779 if (filter
->map
[RMAP_IN
].name
)
8780 json_object_string_add(
8781 json_addr
, "routeMapForIncomingAdvertisements",
8782 filter
->map
[RMAP_IN
].name
);
8783 if (filter
->map
[RMAP_OUT
].name
)
8784 json_object_string_add(
8785 json_addr
, "routeMapForOutgoingAdvertisements",
8786 filter
->map
[RMAP_OUT
].name
);
8788 /* ebgp-requires-policy (inbound) */
8789 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8790 && !bgp_inbound_policy_exists(p
, filter
))
8791 json_object_string_add(
8792 json_addr
, "inboundEbgpRequiresPolicy",
8793 "Inbound updates discarded due to missing policy");
8795 /* ebgp-requires-policy (outbound) */
8796 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8797 && (!bgp_outbound_policy_exists(p
, filter
)))
8798 json_object_string_add(
8799 json_addr
, "outboundEbgpRequiresPolicy",
8800 "Outbound updates discarded due to missing policy");
8802 /* unsuppress-map */
8803 if (filter
->usmap
.name
)
8804 json_object_string_add(json_addr
,
8805 "selectiveUnsuppressRouteMap",
8806 filter
->usmap
.name
);
8808 /* Receive prefix count */
8809 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8810 p
->pcount
[afi
][safi
]);
8811 if (paf
&& PAF_SUBGRP(paf
))
8812 json_object_int_add(json_addr
, "sentPrefixCounter",
8813 (PAF_SUBGRP(paf
))->scount
);
8815 /* Maximum prefix */
8816 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8817 json_object_int_add(json_addr
, "prefixAllowedMax",
8818 p
->pmax
[afi
][safi
]);
8819 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8820 PEER_FLAG_MAX_PREFIX_WARNING
))
8821 json_object_boolean_true_add(
8822 json_addr
, "prefixAllowedMaxWarning");
8823 json_object_int_add(json_addr
,
8824 "prefixAllowedWarningThresh",
8825 p
->pmax_threshold
[afi
][safi
]);
8826 if (p
->pmax_restart
[afi
][safi
])
8827 json_object_int_add(
8829 "prefixAllowedRestartIntervalMsecs",
8830 p
->pmax_restart
[afi
][safi
] * 60000);
8832 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8836 filter
= &p
->filter
[afi
][safi
];
8838 vty_out(vty
, " For address family: %s\n",
8839 afi_safi_print(afi
, safi
));
8841 if (peer_group_active(p
))
8842 vty_out(vty
, " %s peer-group member\n",
8845 paf
= peer_af_find(p
, afi
, safi
);
8846 if (paf
&& PAF_SUBGRP(paf
)) {
8847 vty_out(vty
, " Update group %" PRIu64
8848 ", subgroup %" PRIu64
"\n",
8849 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8850 vty_out(vty
, " Packet Queue length %d\n",
8851 bpacket_queue_virtual_length(paf
));
8853 vty_out(vty
, " Not part of any update group\n");
8855 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8856 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8857 PEER_CAP_ORF_PREFIX_SM_RCV
)
8858 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8859 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8860 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8861 PEER_CAP_ORF_PREFIX_RM_ADV
)
8862 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8863 PEER_CAP_ORF_PREFIX_RM_RCV
)
8864 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8865 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8866 vty_out(vty
, " AF-dependant capabilities:\n");
8868 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8869 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8870 PEER_CAP_ORF_PREFIX_SM_RCV
)
8871 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8872 PEER_CAP_ORF_PREFIX_RM_ADV
)
8873 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8874 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8876 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8878 bgp_show_peer_afi_orf_cap(
8879 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8880 PEER_CAP_ORF_PREFIX_RM_ADV
,
8881 PEER_CAP_ORF_PREFIX_SM_RCV
,
8882 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8884 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8885 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8886 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8887 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8888 PEER_CAP_ORF_PREFIX_RM_ADV
)
8889 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8890 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8892 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8893 ORF_TYPE_PREFIX_OLD
);
8894 bgp_show_peer_afi_orf_cap(
8895 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8896 PEER_CAP_ORF_PREFIX_RM_ADV
,
8897 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8898 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8901 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8902 orf_pfx_count
= prefix_bgp_show_prefix_list(
8903 NULL
, afi
, orf_pfx_name
, use_json
);
8905 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8906 PEER_STATUS_ORF_PREFIX_SEND
)
8908 vty_out(vty
, " Outbound Route Filter (ORF):");
8909 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8910 PEER_STATUS_ORF_PREFIX_SEND
))
8911 vty_out(vty
, " sent;");
8913 vty_out(vty
, " received (%d entries)",
8917 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8918 PEER_STATUS_ORF_WAIT_REFRESH
))
8920 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
8922 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8923 PEER_FLAG_REFLECTOR_CLIENT
))
8924 vty_out(vty
, " Route-Reflector Client\n");
8925 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8926 PEER_FLAG_RSERVER_CLIENT
))
8927 vty_out(vty
, " Route-Server Client\n");
8928 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8930 " Inbound soft reconfiguration allowed\n");
8932 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8933 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8935 " Private AS numbers (all) replaced in updates to this neighbor\n");
8936 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8937 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8939 " Private AS numbers replaced in updates to this neighbor\n");
8940 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8941 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8943 " Private AS numbers (all) removed in updates to this neighbor\n");
8944 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8945 PEER_FLAG_REMOVE_PRIVATE_AS
))
8947 " Private AS numbers removed in updates to this neighbor\n");
8949 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8950 vty_out(vty
, " %s\n",
8951 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8952 ->human_description
);
8954 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8956 " Override ASNs in outbound updates if aspath equals remote-as\n");
8958 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8959 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8960 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8961 vty_out(vty
, " NEXT_HOP is always this router\n");
8962 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8963 PEER_FLAG_AS_PATH_UNCHANGED
))
8965 " AS_PATH is propagated unchanged to this neighbor\n");
8966 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8967 PEER_FLAG_NEXTHOP_UNCHANGED
))
8969 " NEXT_HOP is propagated unchanged to this neighbor\n");
8970 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8972 " MED is propagated unchanged to this neighbor\n");
8973 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8974 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8975 PEER_FLAG_SEND_EXT_COMMUNITY
)
8976 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8977 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
8979 " Community attribute sent to this neighbor");
8980 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8981 PEER_FLAG_SEND_COMMUNITY
)
8982 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8983 PEER_FLAG_SEND_EXT_COMMUNITY
)
8984 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8985 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8986 vty_out(vty
, "(all)\n");
8987 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8988 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8989 vty_out(vty
, "(large)\n");
8990 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8991 PEER_FLAG_SEND_EXT_COMMUNITY
))
8992 vty_out(vty
, "(extended)\n");
8994 vty_out(vty
, "(standard)\n");
8996 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8997 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8998 vty_out(vty
, " Default information originate,");
9000 if (p
->default_rmap
[afi
][safi
].name
)
9001 vty_out(vty
, " default route-map %s%s,",
9002 p
->default_rmap
[afi
][safi
].map
? "*"
9004 p
->default_rmap
[afi
][safi
].name
);
9005 if (paf
&& PAF_SUBGRP(paf
)
9006 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9007 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9008 vty_out(vty
, " default sent\n");
9010 vty_out(vty
, " default not sent\n");
9013 /* advertise-vni-all */
9014 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9015 if (is_evpn_enabled())
9016 vty_out(vty
, " advertise-all-vni\n");
9019 if (filter
->plist
[FILTER_IN
].name
9020 || filter
->dlist
[FILTER_IN
].name
9021 || filter
->aslist
[FILTER_IN
].name
9022 || filter
->map
[RMAP_IN
].name
)
9023 vty_out(vty
, " Inbound path policy configured\n");
9024 if (filter
->plist
[FILTER_OUT
].name
9025 || filter
->dlist
[FILTER_OUT
].name
9026 || filter
->aslist
[FILTER_OUT
].name
9027 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9028 vty_out(vty
, " Outbound path policy configured\n");
9031 if (filter
->plist
[FILTER_IN
].name
)
9033 " Incoming update prefix filter list is %s%s\n",
9034 filter
->plist
[FILTER_IN
].plist
? "*" : "",
9035 filter
->plist
[FILTER_IN
].name
);
9036 if (filter
->plist
[FILTER_OUT
].name
)
9038 " Outgoing update prefix filter list is %s%s\n",
9039 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
9040 filter
->plist
[FILTER_OUT
].name
);
9042 /* distribute-list */
9043 if (filter
->dlist
[FILTER_IN
].name
)
9045 " Incoming update network filter list is %s%s\n",
9046 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
9047 filter
->dlist
[FILTER_IN
].name
);
9048 if (filter
->dlist
[FILTER_OUT
].name
)
9050 " Outgoing update network filter list is %s%s\n",
9051 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
9052 filter
->dlist
[FILTER_OUT
].name
);
9055 if (filter
->aslist
[FILTER_IN
].name
)
9057 " Incoming update AS path filter list is %s%s\n",
9058 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
9059 filter
->aslist
[FILTER_IN
].name
);
9060 if (filter
->aslist
[FILTER_OUT
].name
)
9062 " Outgoing update AS path filter list is %s%s\n",
9063 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
9064 filter
->aslist
[FILTER_OUT
].name
);
9067 if (filter
->map
[RMAP_IN
].name
)
9069 " Route map for incoming advertisements is %s%s\n",
9070 filter
->map
[RMAP_IN
].map
? "*" : "",
9071 filter
->map
[RMAP_IN
].name
);
9072 if (filter
->map
[RMAP_OUT
].name
)
9074 " Route map for outgoing advertisements is %s%s\n",
9075 filter
->map
[RMAP_OUT
].map
? "*" : "",
9076 filter
->map
[RMAP_OUT
].name
);
9078 /* ebgp-requires-policy (inbound) */
9079 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9080 && !bgp_inbound_policy_exists(p
, filter
))
9082 " Inbound updates discarded due to missing policy\n");
9084 /* ebgp-requires-policy (outbound) */
9085 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9086 && !bgp_outbound_policy_exists(p
, filter
))
9088 " Outbound updates discarded due to missing policy\n");
9090 /* unsuppress-map */
9091 if (filter
->usmap
.name
)
9093 " Route map for selective unsuppress is %s%s\n",
9094 filter
->usmap
.map
? "*" : "",
9095 filter
->usmap
.name
);
9097 /* Receive prefix count */
9098 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
9100 /* Maximum prefix */
9101 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9102 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
9104 CHECK_FLAG(p
->af_flags
[afi
][safi
],
9105 PEER_FLAG_MAX_PREFIX_WARNING
)
9108 vty_out(vty
, " Threshold for warning message %d%%",
9109 p
->pmax_threshold
[afi
][safi
]);
9110 if (p
->pmax_restart
[afi
][safi
])
9111 vty_out(vty
, ", restart interval %d min",
9112 p
->pmax_restart
[afi
][safi
]);
9120 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
9124 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
9125 char timebuf
[BGP_UPTIME_LEN
];
9127 const char *subcode_str
;
9128 const char *code_str
;
9133 json_object
*json_neigh
= NULL
;
9139 json_neigh
= json_object_new_object();
9141 memset(dn_flag
, '\0', sizeof(dn_flag
));
9142 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9146 if (p
->conf_if
) /* Configured interface name. */
9147 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9148 BGP_PEER_SU_UNSPEC(p
)
9150 : sockunion2str(&p
->su
, buf
,
9152 else /* Configured IP address. */
9153 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9158 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9159 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9161 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9162 json_object_string_add(
9163 json_neigh
, "bgpNeighborAddr",
9164 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9166 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9168 if (p
->change_local_as
)
9169 json_object_int_add(json_neigh
, "localAs",
9170 p
->change_local_as
);
9172 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9174 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9175 json_object_boolean_true_add(json_neigh
,
9176 "localAsNoPrepend");
9178 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9179 json_object_boolean_true_add(json_neigh
,
9180 "localAsReplaceAs");
9182 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9183 || (p
->as_type
== AS_INTERNAL
))
9184 vty_out(vty
, "remote AS %u, ", p
->as
);
9186 vty_out(vty
, "remote AS Unspecified, ");
9187 vty_out(vty
, "local AS %u%s%s, ",
9188 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9189 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9192 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9196 /* peer type internal or confed-internal */
9197 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
9199 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9200 json_object_boolean_true_add(
9201 json_neigh
, "nbrConfedInternalLink");
9203 json_object_boolean_true_add(json_neigh
,
9206 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9207 vty_out(vty
, "confed-internal link\n");
9209 vty_out(vty
, "internal link\n");
9211 /* peer type external or confed-external */
9212 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
9214 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9215 json_object_boolean_true_add(
9216 json_neigh
, "nbrConfedExternalLink");
9218 json_object_boolean_true_add(json_neigh
,
9221 if (bgp_confederation_peers_check(bgp
, p
->as
))
9222 vty_out(vty
, "confed-external link\n");
9224 vty_out(vty
, "external link\n");
9228 json_object_boolean_true_add(json_neigh
,
9229 "nbrUnspecifiedLink");
9231 vty_out(vty
, "unspecified link\n");
9237 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9239 vty_out(vty
, " Description: %s\n", p
->desc
);
9245 json_object_string_add(json_neigh
, "hostname",
9249 json_object_string_add(json_neigh
, "domainname",
9252 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9253 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9256 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9263 json_object_string_add(json_neigh
, "peerGroup",
9267 struct prefix prefix
, *range
= NULL
;
9269 sockunion2hostprefix(&(p
->su
), &prefix
);
9270 range
= peer_group_lookup_dynamic_neighbor_range(
9274 prefix2str(range
, buf1
, sizeof(buf1
));
9275 json_object_string_add(
9277 "peerSubnetRangeGroup", buf1
);
9282 " Member of peer-group %s for session parameters\n",
9286 struct prefix prefix
, *range
= NULL
;
9288 sockunion2hostprefix(&(p
->su
), &prefix
);
9289 range
= peer_group_lookup_dynamic_neighbor_range(
9293 prefix2str(range
, buf1
, sizeof(buf1
));
9295 " Belongs to the subnet range group: %s\n",
9303 /* Administrative shutdown. */
9304 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9305 json_object_boolean_true_add(json_neigh
,
9309 json_object_int_add(json_neigh
, "bgpVersion", 4);
9310 json_object_string_add(
9311 json_neigh
, "remoteRouterId",
9312 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9313 json_object_string_add(
9314 json_neigh
, "localRouterId",
9315 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9319 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9320 && bgp_confederation_peers_check(bgp
, p
->as
))
9321 json_object_boolean_true_add(json_neigh
,
9325 json_object_string_add(
9326 json_neigh
, "bgpState",
9327 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9329 if (p
->status
== Established
) {
9332 uptime
= bgp_clock();
9333 uptime
-= p
->uptime
;
9334 epoch_tbuf
= time(NULL
) - uptime
;
9336 #if CONFDATE > 20200101
9338 "bgpTimerUp should be deprecated and can be removed now");
9341 * bgpTimerUp was miliseconds that was accurate
9342 * up to 1 day, then the value returned
9343 * became garbage. So in order to provide
9344 * some level of backwards compatability,
9345 * we still provde the data, but now
9346 * we are returning the correct value
9347 * and also adding a new bgpTimerUpMsec
9348 * which will allow us to deprecate
9351 json_object_int_add(json_neigh
, "bgpTimerUp",
9353 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9355 json_object_string_add(json_neigh
, "bgpTimerUpString",
9356 peer_uptime(p
->uptime
, timebuf
,
9359 json_object_int_add(json_neigh
,
9360 "bgpTimerUpEstablishedEpoch",
9364 else if (p
->status
== Active
) {
9365 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9366 json_object_string_add(json_neigh
, "bgpStateIs",
9368 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9369 json_object_string_add(json_neigh
, "bgpStateIs",
9377 uptime
= bgp_clock();
9378 uptime
-= p
->readtime
;
9379 tm
= gmtime(&uptime
);
9380 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9381 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9382 + (tm
->tm_hour
* 3600000));
9384 uptime
= bgp_clock();
9385 uptime
-= p
->last_write
;
9386 tm
= gmtime(&uptime
);
9387 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9388 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9389 + (tm
->tm_hour
* 3600000));
9391 uptime
= bgp_clock();
9392 uptime
-= p
->update_time
;
9393 tm
= gmtime(&uptime
);
9394 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9395 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9396 + (tm
->tm_hour
* 3600000));
9398 /* Configured timer values. */
9399 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9400 p
->v_holdtime
* 1000);
9401 json_object_int_add(json_neigh
,
9402 "bgpTimerKeepAliveIntervalMsecs",
9403 p
->v_keepalive
* 1000);
9404 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9405 json_object_int_add(json_neigh
,
9406 "bgpTimerConfiguredHoldTimeMsecs",
9407 p
->holdtime
* 1000);
9408 json_object_int_add(
9410 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9411 p
->keepalive
* 1000);
9412 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9413 || (bgp
->default_keepalive
9414 != BGP_DEFAULT_KEEPALIVE
)) {
9415 json_object_int_add(json_neigh
,
9416 "bgpTimerConfiguredHoldTimeMsecs",
9417 bgp
->default_holdtime
);
9418 json_object_int_add(
9420 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9421 bgp
->default_keepalive
);
9424 /* Administrative shutdown. */
9425 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9426 vty_out(vty
, " Administratively shut down\n");
9429 vty_out(vty
, " BGP version 4");
9430 vty_out(vty
, ", remote router ID %s",
9431 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9432 vty_out(vty
, ", local router ID %s\n",
9433 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9437 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9438 && bgp_confederation_peers_check(bgp
, p
->as
))
9440 " Neighbor under common administration\n");
9443 vty_out(vty
, " BGP state = %s",
9444 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9446 if (p
->status
== Established
)
9447 vty_out(vty
, ", up for %8s",
9448 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9451 else if (p
->status
== Active
) {
9452 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9453 vty_out(vty
, " (passive)");
9454 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9455 vty_out(vty
, " (NSF passive)");
9460 vty_out(vty
, " Last read %s",
9461 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9463 vty_out(vty
, ", Last write %s\n",
9464 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9467 /* Configured timer values. */
9469 " Hold time is %d, keepalive interval is %d seconds\n",
9470 p
->v_holdtime
, p
->v_keepalive
);
9471 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9472 vty_out(vty
, " Configured hold time is %d",
9474 vty_out(vty
, ", keepalive interval is %d seconds\n",
9476 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9477 || (bgp
->default_keepalive
9478 != BGP_DEFAULT_KEEPALIVE
)) {
9479 vty_out(vty
, " Configured hold time is %d",
9480 bgp
->default_holdtime
);
9481 vty_out(vty
, ", keepalive interval is %d seconds\n",
9482 bgp
->default_keepalive
);
9486 if (p
->status
== Established
) {
9487 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9488 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9489 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9490 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9491 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9492 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9493 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9494 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9495 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9496 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9497 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9498 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9499 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9500 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9501 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9502 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9503 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9504 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9505 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9506 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9508 json_object
*json_cap
= NULL
;
9510 json_cap
= json_object_new_object();
9513 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9514 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9515 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9516 && CHECK_FLAG(p
->cap
,
9518 json_object_string_add(
9519 json_cap
, "4byteAs",
9520 "advertisedAndReceived");
9521 else if (CHECK_FLAG(p
->cap
,
9523 json_object_string_add(
9524 json_cap
, "4byteAs",
9526 else if (CHECK_FLAG(p
->cap
,
9528 json_object_string_add(
9529 json_cap
, "4byteAs",
9534 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9535 || CHECK_FLAG(p
->cap
,
9536 PEER_CAP_ADDPATH_ADV
)) {
9537 json_object
*json_add
= NULL
;
9538 const char *print_store
;
9540 json_add
= json_object_new_object();
9542 FOREACH_AFI_SAFI (afi
, safi
) {
9543 json_object
*json_sub
= NULL
;
9545 json_object_new_object();
9546 print_store
= afi_safi_print(
9552 PEER_CAP_ADDPATH_AF_TX_ADV
)
9556 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9561 PEER_CAP_ADDPATH_AF_TX_ADV
)
9566 PEER_CAP_ADDPATH_AF_TX_RCV
))
9567 json_object_boolean_true_add(
9569 "txAdvertisedAndReceived");
9575 PEER_CAP_ADDPATH_AF_TX_ADV
))
9576 json_object_boolean_true_add(
9584 PEER_CAP_ADDPATH_AF_TX_RCV
))
9585 json_object_boolean_true_add(
9593 PEER_CAP_ADDPATH_AF_RX_ADV
)
9597 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9602 PEER_CAP_ADDPATH_AF_RX_ADV
)
9607 PEER_CAP_ADDPATH_AF_RX_RCV
))
9608 json_object_boolean_true_add(
9610 "rxAdvertisedAndReceived");
9616 PEER_CAP_ADDPATH_AF_RX_ADV
))
9617 json_object_boolean_true_add(
9625 PEER_CAP_ADDPATH_AF_RX_RCV
))
9626 json_object_boolean_true_add(
9634 PEER_CAP_ADDPATH_AF_TX_ADV
)
9638 PEER_CAP_ADDPATH_AF_TX_RCV
)
9642 PEER_CAP_ADDPATH_AF_RX_ADV
)
9646 PEER_CAP_ADDPATH_AF_RX_RCV
))
9647 json_object_object_add(
9656 json_object_object_add(
9657 json_cap
, "addPath", json_add
);
9661 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9662 || CHECK_FLAG(p
->cap
,
9663 PEER_CAP_DYNAMIC_ADV
)) {
9664 if (CHECK_FLAG(p
->cap
,
9665 PEER_CAP_DYNAMIC_ADV
)
9666 && CHECK_FLAG(p
->cap
,
9667 PEER_CAP_DYNAMIC_RCV
))
9668 json_object_string_add(
9669 json_cap
, "dynamic",
9670 "advertisedAndReceived");
9671 else if (CHECK_FLAG(
9673 PEER_CAP_DYNAMIC_ADV
))
9674 json_object_string_add(
9675 json_cap
, "dynamic",
9677 else if (CHECK_FLAG(
9679 PEER_CAP_DYNAMIC_RCV
))
9680 json_object_string_add(
9681 json_cap
, "dynamic",
9685 /* Extended nexthop */
9686 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9687 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9688 json_object
*json_nxt
= NULL
;
9689 const char *print_store
;
9692 if (CHECK_FLAG(p
->cap
,
9694 && CHECK_FLAG(p
->cap
,
9696 json_object_string_add(
9699 "advertisedAndReceived");
9700 else if (CHECK_FLAG(p
->cap
,
9702 json_object_string_add(
9706 else if (CHECK_FLAG(p
->cap
,
9708 json_object_string_add(
9713 if (CHECK_FLAG(p
->cap
,
9714 PEER_CAP_ENHE_RCV
)) {
9716 json_object_new_object();
9718 for (safi
= SAFI_UNICAST
;
9719 safi
< SAFI_MAX
; safi
++) {
9724 PEER_CAP_ENHE_AF_RCV
)) {
9725 print_store
= afi_safi_print(
9728 json_object_string_add(
9731 "recieved"); /* misspelled for compatibility */
9734 json_object_object_add(
9736 "extendedNexthopFamililesByPeer",
9742 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9743 || CHECK_FLAG(p
->cap
,
9744 PEER_CAP_REFRESH_NEW_RCV
)
9745 || CHECK_FLAG(p
->cap
,
9746 PEER_CAP_REFRESH_OLD_RCV
)) {
9747 if (CHECK_FLAG(p
->cap
,
9748 PEER_CAP_REFRESH_ADV
)
9751 PEER_CAP_REFRESH_NEW_RCV
)
9754 PEER_CAP_REFRESH_OLD_RCV
))) {
9757 PEER_CAP_REFRESH_OLD_RCV
)
9760 PEER_CAP_REFRESH_NEW_RCV
))
9761 json_object_string_add(
9764 "advertisedAndReceivedOldNew");
9768 PEER_CAP_REFRESH_OLD_RCV
))
9769 json_object_string_add(
9772 "advertisedAndReceivedOld");
9774 json_object_string_add(
9777 "advertisedAndReceivedNew");
9782 PEER_CAP_REFRESH_ADV
))
9783 json_object_string_add(
9790 PEER_CAP_REFRESH_NEW_RCV
)
9793 PEER_CAP_REFRESH_OLD_RCV
))
9794 json_object_string_add(
9800 /* Multiprotocol Extensions */
9801 json_object
*json_multi
= NULL
;
9802 json_multi
= json_object_new_object();
9804 FOREACH_AFI_SAFI (afi
, safi
) {
9805 if (p
->afc_adv
[afi
][safi
]
9806 || p
->afc_recv
[afi
][safi
]) {
9807 json_object
*json_exten
= NULL
;
9809 json_object_new_object();
9811 if (p
->afc_adv
[afi
][safi
]
9812 && p
->afc_recv
[afi
][safi
])
9813 json_object_boolean_true_add(
9815 "advertisedAndReceived");
9816 else if (p
->afc_adv
[afi
][safi
])
9817 json_object_boolean_true_add(
9820 else if (p
->afc_recv
[afi
][safi
])
9821 json_object_boolean_true_add(
9825 json_object_object_add(
9832 json_object_object_add(
9833 json_cap
, "multiprotocolExtensions",
9836 /* Hostname capabilities */
9837 json_object
*json_hname
= NULL
;
9839 json_hname
= json_object_new_object();
9841 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9842 json_object_string_add(
9843 json_hname
, "advHostName",
9844 bgp
->peer_self
->hostname
9848 json_object_string_add(
9849 json_hname
, "advDomainName",
9850 bgp
->peer_self
->domainname
9857 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9858 json_object_string_add(
9859 json_hname
, "rcvHostName",
9860 p
->hostname
? p
->hostname
9862 json_object_string_add(
9863 json_hname
, "rcvDomainName",
9864 p
->domainname
? p
->domainname
9868 json_object_object_add(json_cap
, "hostName",
9871 /* Gracefull Restart */
9872 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9873 || CHECK_FLAG(p
->cap
,
9874 PEER_CAP_RESTART_ADV
)) {
9875 if (CHECK_FLAG(p
->cap
,
9876 PEER_CAP_RESTART_ADV
)
9877 && CHECK_FLAG(p
->cap
,
9878 PEER_CAP_RESTART_RCV
))
9879 json_object_string_add(
9882 "advertisedAndReceived");
9883 else if (CHECK_FLAG(
9885 PEER_CAP_RESTART_ADV
))
9886 json_object_string_add(
9888 "gracefulRestartCapability",
9890 else if (CHECK_FLAG(
9892 PEER_CAP_RESTART_RCV
))
9893 json_object_string_add(
9895 "gracefulRestartCapability",
9898 if (CHECK_FLAG(p
->cap
,
9899 PEER_CAP_RESTART_RCV
)) {
9900 int restart_af_count
= 0;
9901 json_object
*json_restart
=
9904 json_object_new_object();
9906 json_object_int_add(
9908 "gracefulRestartRemoteTimerMsecs",
9909 p
->v_gr_restart
* 1000);
9911 FOREACH_AFI_SAFI (afi
, safi
) {
9916 PEER_CAP_RESTART_AF_RCV
)) {
9921 json_object_new_object();
9927 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
9928 json_object_boolean_true_add(
9932 json_object_object_add(
9940 if (!restart_af_count
) {
9941 json_object_string_add(
9943 "addressFamiliesByPeer",
9948 json_object_object_add(
9950 "addressFamiliesByPeer",
9954 json_object_object_add(json_neigh
,
9955 "neighborCapabilities",
9958 vty_out(vty
, " Neighbor capabilities:\n");
9961 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9962 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9963 vty_out(vty
, " 4 Byte AS:");
9964 if (CHECK_FLAG(p
->cap
,
9966 vty_out(vty
, " advertised");
9967 if (CHECK_FLAG(p
->cap
,
9969 vty_out(vty
, " %sreceived",
9979 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9980 || CHECK_FLAG(p
->cap
,
9981 PEER_CAP_ADDPATH_ADV
)) {
9982 vty_out(vty
, " AddPath:\n");
9984 FOREACH_AFI_SAFI (afi
, safi
) {
9988 PEER_CAP_ADDPATH_AF_TX_ADV
)
9992 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
10003 PEER_CAP_ADDPATH_AF_TX_ADV
))
10014 PEER_CAP_ADDPATH_AF_TX_RCV
))
10021 PEER_CAP_ADDPATH_AF_TX_ADV
)
10025 vty_out(vty
, "\n");
10031 PEER_CAP_ADDPATH_AF_RX_ADV
)
10035 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
10046 PEER_CAP_ADDPATH_AF_RX_ADV
))
10057 PEER_CAP_ADDPATH_AF_RX_RCV
))
10064 PEER_CAP_ADDPATH_AF_RX_ADV
)
10068 vty_out(vty
, "\n");
10074 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10075 || CHECK_FLAG(p
->cap
,
10076 PEER_CAP_DYNAMIC_ADV
)) {
10077 vty_out(vty
, " Dynamic:");
10078 if (CHECK_FLAG(p
->cap
,
10079 PEER_CAP_DYNAMIC_ADV
))
10080 vty_out(vty
, " advertised");
10081 if (CHECK_FLAG(p
->cap
,
10082 PEER_CAP_DYNAMIC_RCV
))
10083 vty_out(vty
, " %sreceived",
10086 PEER_CAP_DYNAMIC_ADV
)
10089 vty_out(vty
, "\n");
10092 /* Extended nexthop */
10093 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10094 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10095 vty_out(vty
, " Extended nexthop:");
10096 if (CHECK_FLAG(p
->cap
,
10097 PEER_CAP_ENHE_ADV
))
10098 vty_out(vty
, " advertised");
10099 if (CHECK_FLAG(p
->cap
,
10100 PEER_CAP_ENHE_RCV
))
10101 vty_out(vty
, " %sreceived",
10107 vty_out(vty
, "\n");
10109 if (CHECK_FLAG(p
->cap
,
10110 PEER_CAP_ENHE_RCV
)) {
10112 " Address families by peer:\n ");
10113 for (safi
= SAFI_UNICAST
;
10114 safi
< SAFI_MAX
; safi
++)
10119 PEER_CAP_ENHE_AF_RCV
))
10128 /* Route Refresh */
10129 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10130 || CHECK_FLAG(p
->cap
,
10131 PEER_CAP_REFRESH_NEW_RCV
)
10132 || CHECK_FLAG(p
->cap
,
10133 PEER_CAP_REFRESH_OLD_RCV
)) {
10134 vty_out(vty
, " Route refresh:");
10135 if (CHECK_FLAG(p
->cap
,
10136 PEER_CAP_REFRESH_ADV
))
10137 vty_out(vty
, " advertised");
10138 if (CHECK_FLAG(p
->cap
,
10139 PEER_CAP_REFRESH_NEW_RCV
)
10142 PEER_CAP_REFRESH_OLD_RCV
))
10143 vty_out(vty
, " %sreceived(%s)",
10146 PEER_CAP_REFRESH_ADV
)
10151 PEER_CAP_REFRESH_OLD_RCV
)
10154 PEER_CAP_REFRESH_NEW_RCV
))
10158 PEER_CAP_REFRESH_OLD_RCV
)
10162 vty_out(vty
, "\n");
10165 /* Multiprotocol Extensions */
10166 FOREACH_AFI_SAFI (afi
, safi
)
10167 if (p
->afc_adv
[afi
][safi
]
10168 || p
->afc_recv
[afi
][safi
]) {
10170 " Address Family %s:",
10171 afi_safi_print(afi
,
10173 if (p
->afc_adv
[afi
][safi
])
10176 if (p
->afc_recv
[afi
][safi
])
10183 vty_out(vty
, "\n");
10186 /* Hostname capability */
10187 vty_out(vty
, " Hostname Capability:");
10189 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10191 " advertised (name: %s,domain name: %s)",
10192 bgp
->peer_self
->hostname
10196 bgp
->peer_self
->domainname
10201 vty_out(vty
, " not advertised");
10204 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10206 " received (name: %s,domain name: %s)",
10207 p
->hostname
? p
->hostname
10209 p
->domainname
? p
->domainname
10212 vty_out(vty
, " not received");
10215 vty_out(vty
, "\n");
10217 /* Gracefull Restart */
10218 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10219 || CHECK_FLAG(p
->cap
,
10220 PEER_CAP_RESTART_ADV
)) {
10222 " Graceful Restart Capabilty:");
10223 if (CHECK_FLAG(p
->cap
,
10224 PEER_CAP_RESTART_ADV
))
10225 vty_out(vty
, " advertised");
10226 if (CHECK_FLAG(p
->cap
,
10227 PEER_CAP_RESTART_RCV
))
10228 vty_out(vty
, " %sreceived",
10231 PEER_CAP_RESTART_ADV
)
10234 vty_out(vty
, "\n");
10236 if (CHECK_FLAG(p
->cap
,
10237 PEER_CAP_RESTART_RCV
)) {
10238 int restart_af_count
= 0;
10241 " Remote Restart timer is %d seconds\n",
10244 " Address families by peer:\n ");
10246 FOREACH_AFI_SAFI (afi
, safi
)
10251 PEER_CAP_RESTART_AF_RCV
)) {
10264 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10266 : "not preserved");
10267 restart_af_count
++;
10269 if (!restart_af_count
)
10270 vty_out(vty
, "none");
10271 vty_out(vty
, "\n");
10278 /* graceful restart information */
10279 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10280 || p
->t_gr_stale
) {
10281 json_object
*json_grace
= NULL
;
10282 json_object
*json_grace_send
= NULL
;
10283 json_object
*json_grace_recv
= NULL
;
10284 int eor_send_af_count
= 0;
10285 int eor_receive_af_count
= 0;
10288 json_grace
= json_object_new_object();
10289 json_grace_send
= json_object_new_object();
10290 json_grace_recv
= json_object_new_object();
10292 if (p
->status
== Established
) {
10293 FOREACH_AFI_SAFI (afi
, safi
) {
10294 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10295 PEER_STATUS_EOR_SEND
)) {
10296 json_object_boolean_true_add(
10298 afi_safi_print(afi
,
10300 eor_send_af_count
++;
10303 FOREACH_AFI_SAFI (afi
, safi
) {
10305 p
->af_sflags
[afi
][safi
],
10306 PEER_STATUS_EOR_RECEIVED
)) {
10307 json_object_boolean_true_add(
10309 afi_safi_print(afi
,
10311 eor_receive_af_count
++;
10316 json_object_object_add(json_grace
, "endOfRibSend",
10318 json_object_object_add(json_grace
, "endOfRibRecv",
10321 if (p
->t_gr_restart
)
10322 json_object_int_add(json_grace
,
10323 "gracefulRestartTimerMsecs",
10324 thread_timer_remain_second(
10329 json_object_int_add(
10331 "gracefulStalepathTimerMsecs",
10332 thread_timer_remain_second(
10336 json_object_object_add(
10337 json_neigh
, "gracefulRestartInfo", json_grace
);
10339 vty_out(vty
, " Graceful restart information:\n");
10340 if (p
->status
== Established
) {
10341 vty_out(vty
, " End-of-RIB send: ");
10342 FOREACH_AFI_SAFI (afi
, safi
) {
10343 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10344 PEER_STATUS_EOR_SEND
)) {
10345 vty_out(vty
, "%s%s",
10346 eor_send_af_count
? ", "
10348 afi_safi_print(afi
,
10350 eor_send_af_count
++;
10353 vty_out(vty
, "\n");
10354 vty_out(vty
, " End-of-RIB received: ");
10355 FOREACH_AFI_SAFI (afi
, safi
) {
10357 p
->af_sflags
[afi
][safi
],
10358 PEER_STATUS_EOR_RECEIVED
)) {
10359 vty_out(vty
, "%s%s",
10360 eor_receive_af_count
10363 afi_safi_print(afi
,
10365 eor_receive_af_count
++;
10368 vty_out(vty
, "\n");
10371 if (p
->t_gr_restart
)
10373 " The remaining time of restart timer is %ld\n",
10374 thread_timer_remain_second(
10379 " The remaining time of stalepath timer is %ld\n",
10380 thread_timer_remain_second(
10385 json_object
*json_stat
= NULL
;
10386 json_stat
= json_object_new_object();
10387 /* Packet counts. */
10388 json_object_int_add(json_stat
, "depthInq", 0);
10389 json_object_int_add(json_stat
, "depthOutq",
10390 (unsigned long)p
->obuf
->count
);
10391 json_object_int_add(json_stat
, "opensSent",
10392 atomic_load_explicit(&p
->open_out
,
10393 memory_order_relaxed
));
10394 json_object_int_add(json_stat
, "opensRecv",
10395 atomic_load_explicit(&p
->open_in
,
10396 memory_order_relaxed
));
10397 json_object_int_add(json_stat
, "notificationsSent",
10398 atomic_load_explicit(&p
->notify_out
,
10399 memory_order_relaxed
));
10400 json_object_int_add(json_stat
, "notificationsRecv",
10401 atomic_load_explicit(&p
->notify_in
,
10402 memory_order_relaxed
));
10403 json_object_int_add(json_stat
, "updatesSent",
10404 atomic_load_explicit(&p
->update_out
,
10405 memory_order_relaxed
));
10406 json_object_int_add(json_stat
, "updatesRecv",
10407 atomic_load_explicit(&p
->update_in
,
10408 memory_order_relaxed
));
10409 json_object_int_add(json_stat
, "keepalivesSent",
10410 atomic_load_explicit(&p
->keepalive_out
,
10411 memory_order_relaxed
));
10412 json_object_int_add(json_stat
, "keepalivesRecv",
10413 atomic_load_explicit(&p
->keepalive_in
,
10414 memory_order_relaxed
));
10415 json_object_int_add(json_stat
, "routeRefreshSent",
10416 atomic_load_explicit(&p
->refresh_out
,
10417 memory_order_relaxed
));
10418 json_object_int_add(json_stat
, "routeRefreshRecv",
10419 atomic_load_explicit(&p
->refresh_in
,
10420 memory_order_relaxed
));
10421 json_object_int_add(json_stat
, "capabilitySent",
10422 atomic_load_explicit(&p
->dynamic_cap_out
,
10423 memory_order_relaxed
));
10424 json_object_int_add(json_stat
, "capabilityRecv",
10425 atomic_load_explicit(&p
->dynamic_cap_in
,
10426 memory_order_relaxed
));
10427 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10428 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10429 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10431 /* Packet counts. */
10432 vty_out(vty
, " Message statistics:\n");
10433 vty_out(vty
, " Inq depth is 0\n");
10434 vty_out(vty
, " Outq depth is %lu\n",
10435 (unsigned long)p
->obuf
->count
);
10436 vty_out(vty
, " Sent Rcvd\n");
10437 vty_out(vty
, " Opens: %10d %10d\n",
10438 atomic_load_explicit(&p
->open_out
,
10439 memory_order_relaxed
),
10440 atomic_load_explicit(&p
->open_in
,
10441 memory_order_relaxed
));
10442 vty_out(vty
, " Notifications: %10d %10d\n",
10443 atomic_load_explicit(&p
->notify_out
,
10444 memory_order_relaxed
),
10445 atomic_load_explicit(&p
->notify_in
,
10446 memory_order_relaxed
));
10447 vty_out(vty
, " Updates: %10d %10d\n",
10448 atomic_load_explicit(&p
->update_out
,
10449 memory_order_relaxed
),
10450 atomic_load_explicit(&p
->update_in
,
10451 memory_order_relaxed
));
10452 vty_out(vty
, " Keepalives: %10d %10d\n",
10453 atomic_load_explicit(&p
->keepalive_out
,
10454 memory_order_relaxed
),
10455 atomic_load_explicit(&p
->keepalive_in
,
10456 memory_order_relaxed
));
10457 vty_out(vty
, " Route Refresh: %10d %10d\n",
10458 atomic_load_explicit(&p
->refresh_out
,
10459 memory_order_relaxed
),
10460 atomic_load_explicit(&p
->refresh_in
,
10461 memory_order_relaxed
));
10462 vty_out(vty
, " Capability: %10d %10d\n",
10463 atomic_load_explicit(&p
->dynamic_cap_out
,
10464 memory_order_relaxed
),
10465 atomic_load_explicit(&p
->dynamic_cap_in
,
10466 memory_order_relaxed
));
10467 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10472 /* advertisement-interval */
10473 json_object_int_add(json_neigh
,
10474 "minBtwnAdvertisementRunsTimerMsecs",
10475 p
->v_routeadv
* 1000);
10477 /* Update-source. */
10478 if (p
->update_if
|| p
->update_source
) {
10480 json_object_string_add(json_neigh
,
10483 else if (p
->update_source
)
10484 json_object_string_add(
10485 json_neigh
, "updateSource",
10486 sockunion2str(p
->update_source
, buf1
,
10490 /* advertisement-interval */
10492 " Minimum time between advertisement runs is %d seconds\n",
10495 /* Update-source. */
10496 if (p
->update_if
|| p
->update_source
) {
10497 vty_out(vty
, " Update source is ");
10499 vty_out(vty
, "%s", p
->update_if
);
10500 else if (p
->update_source
)
10502 sockunion2str(p
->update_source
, buf1
,
10504 vty_out(vty
, "\n");
10507 vty_out(vty
, "\n");
10510 /* Address Family Information */
10511 json_object
*json_hold
= NULL
;
10514 json_hold
= json_object_new_object();
10516 FOREACH_AFI_SAFI (afi
, safi
)
10517 if (p
->afc
[afi
][safi
])
10518 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10522 json_object_object_add(json_neigh
, "addressFamilyInfo",
10524 json_object_int_add(json_neigh
, "connectionsEstablished",
10526 json_object_int_add(json_neigh
, "connectionsDropped",
10529 vty_out(vty
, " Connections established %d; dropped %d\n",
10530 p
->established
, p
->dropped
);
10532 if (!p
->last_reset
) {
10534 json_object_string_add(json_neigh
, "lastReset",
10537 vty_out(vty
, " Last reset never\n");
10543 uptime
= bgp_clock();
10544 uptime
-= p
->resettime
;
10545 tm
= gmtime(&uptime
);
10546 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10547 (tm
->tm_sec
* 1000)
10548 + (tm
->tm_min
* 60000)
10549 + (tm
->tm_hour
* 3600000));
10550 json_object_string_add(
10551 json_neigh
, "lastResetDueTo",
10552 peer_down_str
[(int)p
->last_reset
]);
10553 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10554 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10555 char errorcodesubcode_hexstr
[5];
10556 char errorcodesubcode_str
[256];
10558 code_str
= bgp_notify_code_str(p
->notify
.code
);
10559 subcode_str
= bgp_notify_subcode_str(
10560 p
->notify
.code
, p
->notify
.subcode
);
10562 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10563 p
->notify
.code
, p
->notify
.subcode
);
10564 json_object_string_add(json_neigh
,
10565 "lastErrorCodeSubcode",
10566 errorcodesubcode_hexstr
);
10567 snprintf(errorcodesubcode_str
, 255, "%s%s",
10568 code_str
, subcode_str
);
10569 json_object_string_add(json_neigh
,
10570 "lastNotificationReason",
10571 errorcodesubcode_str
);
10572 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10573 && p
->notify
.code
== BGP_NOTIFY_CEASE
10574 && (p
->notify
.subcode
10575 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10576 || p
->notify
.subcode
10577 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10578 && p
->notify
.length
) {
10580 const char *msg_str
;
10582 msg_str
= bgp_notify_admin_message(
10583 msgbuf
, sizeof(msgbuf
),
10584 (uint8_t *)p
->notify
.data
,
10587 json_object_string_add(
10589 "lastShutdownDescription",
10594 vty_out(vty
, " Last reset %s, ",
10595 peer_uptime(p
->resettime
, timebuf
,
10596 BGP_UPTIME_LEN
, 0, NULL
));
10598 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10599 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10600 code_str
= bgp_notify_code_str(p
->notify
.code
);
10601 subcode_str
= bgp_notify_subcode_str(
10602 p
->notify
.code
, p
->notify
.subcode
);
10603 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10604 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10607 code_str
, subcode_str
);
10608 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10609 && p
->notify
.code
== BGP_NOTIFY_CEASE
10610 && (p
->notify
.subcode
10611 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10612 || p
->notify
.subcode
10613 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10614 && p
->notify
.length
) {
10616 const char *msg_str
;
10618 msg_str
= bgp_notify_admin_message(
10619 msgbuf
, sizeof(msgbuf
),
10620 (uint8_t *)p
->notify
.data
,
10624 " Message: \"%s\"\n",
10628 vty_out(vty
, "due to %s\n",
10629 peer_down_str
[(int)p
->last_reset
]);
10632 if (p
->last_reset_cause_size
) {
10633 msg
= p
->last_reset_cause
;
10635 " Message received that caused BGP to send a NOTIFICATION:\n ");
10636 for (i
= 1; i
<= p
->last_reset_cause_size
;
10638 vty_out(vty
, "%02X", *msg
++);
10640 if (i
!= p
->last_reset_cause_size
) {
10642 vty_out(vty
, "\n ");
10643 } else if (i
% 4 == 0) {
10648 vty_out(vty
, "\n");
10653 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10655 json_object_boolean_true_add(json_neigh
,
10656 "prefixesConfigExceedMax");
10659 " Peer had exceeded the max. no. of prefixes configured.\n");
10661 if (p
->t_pmax_restart
) {
10663 json_object_boolean_true_add(
10664 json_neigh
, "reducePrefixNumFrom");
10665 json_object_int_add(json_neigh
,
10666 "restartInTimerMsec",
10667 thread_timer_remain_second(
10672 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10673 p
->host
, thread_timer_remain_second(
10674 p
->t_pmax_restart
));
10677 json_object_boolean_true_add(
10679 "reducePrefixNumAndClearIpBgp");
10682 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10687 /* EBGP Multihop and GTSM */
10688 if (p
->sort
!= BGP_PEER_IBGP
) {
10690 if (p
->gtsm_hops
> 0)
10691 json_object_int_add(json_neigh
,
10692 "externalBgpNbrMaxHopsAway",
10694 else if (p
->ttl
> 1)
10695 json_object_int_add(json_neigh
,
10696 "externalBgpNbrMaxHopsAway",
10699 if (p
->gtsm_hops
> 0)
10701 " External BGP neighbor may be up to %d hops away.\n",
10703 else if (p
->ttl
> 1)
10705 " External BGP neighbor may be up to %d hops away.\n",
10709 if (p
->gtsm_hops
> 0) {
10711 json_object_int_add(json_neigh
,
10712 "internalBgpNbrMaxHopsAway",
10716 " Internal BGP neighbor may be up to %d hops away.\n",
10721 /* Local address. */
10724 json_object_string_add(json_neigh
, "hostLocal",
10725 sockunion2str(p
->su_local
, buf1
,
10727 json_object_int_add(json_neigh
, "portLocal",
10728 ntohs(p
->su_local
->sin
.sin_port
));
10730 vty_out(vty
, "Local host: %s, Local port: %d\n",
10731 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10732 ntohs(p
->su_local
->sin
.sin_port
));
10735 /* Remote address. */
10736 if (p
->su_remote
) {
10738 json_object_string_add(json_neigh
, "hostForeign",
10739 sockunion2str(p
->su_remote
, buf1
,
10741 json_object_int_add(json_neigh
, "portForeign",
10742 ntohs(p
->su_remote
->sin
.sin_port
));
10744 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10745 sockunion2str(p
->su_remote
, buf1
,
10747 ntohs(p
->su_remote
->sin
.sin_port
));
10750 /* Nexthop display. */
10753 json_object_string_add(json_neigh
, "nexthop",
10755 &p
->nexthop
.v4
, buf1
,
10757 json_object_string_add(json_neigh
, "nexthopGlobal",
10758 inet_ntop(AF_INET6
,
10759 &p
->nexthop
.v6_global
,
10760 buf1
, sizeof(buf1
)));
10761 json_object_string_add(json_neigh
, "nexthopLocal",
10762 inet_ntop(AF_INET6
,
10763 &p
->nexthop
.v6_local
,
10764 buf1
, sizeof(buf1
)));
10765 if (p
->shared_network
)
10766 json_object_string_add(json_neigh
,
10770 json_object_string_add(json_neigh
,
10772 "nonSharedNetwork");
10774 vty_out(vty
, "Nexthop: %s\n",
10775 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10777 vty_out(vty
, "Nexthop global: %s\n",
10778 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10780 vty_out(vty
, "Nexthop local: %s\n",
10781 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10783 vty_out(vty
, "BGP connection: %s\n",
10784 p
->shared_network
? "shared network"
10785 : "non shared network");
10789 /* Timer information. */
10791 json_object_int_add(json_neigh
, "connectRetryTimer",
10793 if (p
->status
== Established
&& p
->rtt
)
10794 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10797 json_object_int_add(
10798 json_neigh
, "nextStartTimerDueInMsecs",
10799 thread_timer_remain_second(p
->t_start
) * 1000);
10801 json_object_int_add(
10802 json_neigh
, "nextConnectTimerDueInMsecs",
10803 thread_timer_remain_second(p
->t_connect
)
10805 if (p
->t_routeadv
) {
10806 json_object_int_add(json_neigh
, "mraiInterval",
10808 json_object_int_add(
10809 json_neigh
, "mraiTimerExpireInMsecs",
10810 thread_timer_remain_second(p
->t_routeadv
)
10814 json_object_int_add(json_neigh
, "authenticationEnabled",
10818 json_object_string_add(json_neigh
, "readThread", "on");
10820 json_object_string_add(json_neigh
, "readThread", "off");
10822 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10823 json_object_string_add(json_neigh
, "writeThread", "on");
10825 json_object_string_add(json_neigh
, "writeThread",
10828 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10830 if (p
->status
== Established
&& p
->rtt
)
10831 vty_out(vty
, "Estimated round trip time: %d ms\n",
10834 vty_out(vty
, "Next start timer due in %ld seconds\n",
10835 thread_timer_remain_second(p
->t_start
));
10837 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10838 thread_timer_remain_second(p
->t_connect
));
10841 "MRAI (interval %u) timer expires in %ld seconds\n",
10843 thread_timer_remain_second(p
->t_routeadv
));
10845 vty_out(vty
, "Peer Authentication Enabled\n");
10847 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
10848 p
->t_read
? "on" : "off",
10849 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10854 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10855 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10856 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10859 vty_out(vty
, "\n");
10861 /* BFD information. */
10862 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10865 if (p
->conf_if
) /* Configured interface name. */
10866 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10867 else /* Configured IP address. */
10868 json_object_object_add(json
, p
->host
, json_neigh
);
10872 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10873 enum show_type type
, union sockunion
*su
,
10874 const char *conf_if
, bool use_json
,
10877 struct listnode
*node
, *nnode
;
10880 bool nbr_output
= false;
10881 afi_t afi
= AFI_MAX
;
10882 safi_t safi
= SAFI_MAX
;
10884 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
10886 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
10890 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10891 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10896 bgp_show_peer(vty
, peer
, use_json
, json
);
10902 && !strcmp(peer
->conf_if
, conf_if
))
10904 && !strcmp(peer
->hostname
, conf_if
))) {
10906 bgp_show_peer(vty
, peer
, use_json
,
10910 if (sockunion_same(&peer
->su
, su
)) {
10912 bgp_show_peer(vty
, peer
, use_json
,
10917 case show_ipv4_peer
:
10918 case show_ipv6_peer
:
10919 FOREACH_SAFI (safi
) {
10920 if (peer
->afc
[afi
][safi
]) {
10923 && !strcmp(peer
->conf_if
, conf_if
))
10925 && !strcmp(peer
->hostname
, conf_if
))) {
10927 bgp_show_peer(vty
, peer
, use_json
,
10932 if (sockunion_same(&peer
->su
, su
)) {
10934 bgp_show_peer(vty
, peer
, use_json
,
10942 case show_ipv4_all
:
10943 case show_ipv6_all
:
10944 FOREACH_SAFI (safi
) {
10945 if (peer
->afc
[afi
][safi
]) {
10946 bgp_show_peer(vty
, peer
, use_json
, json
);
10955 if ((type
== show_peer
|| type
== show_ipv4_peer
||
10956 type
== show_ipv6_peer
) && !find
) {
10958 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
10960 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
10963 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
10964 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
10965 vty_out(vty
, "%% No BGP neighbors found\n");
10968 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10969 json
, JSON_C_TO_STRING_PRETTY
));
10971 vty_out(vty
, "\n");
10974 return CMD_SUCCESS
;
10977 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
10978 enum show_type type
,
10979 const char *ip_str
,
10982 struct listnode
*node
, *nnode
;
10984 union sockunion su
;
10985 json_object
*json
= NULL
;
10986 int ret
, is_first
= 1;
10987 bool nbr_output
= false;
10990 vty_out(vty
, "{\n");
10992 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
10995 if (!(json
= json_object_new_object())) {
10997 EC_BGP_JSON_MEM_ERROR
,
10998 "Unable to allocate memory for JSON object");
11000 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
11004 json_object_int_add(json
, "vrfId",
11005 (bgp
->vrf_id
== VRF_UNKNOWN
)
11007 : (int64_t)bgp
->vrf_id
);
11008 json_object_string_add(
11010 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11015 vty_out(vty
, ",\n");
11019 vty_out(vty
, "\"%s\":",
11020 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11024 vty_out(vty
, "\nInstance %s:\n",
11025 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11030 if (type
== show_peer
|| type
== show_ipv4_peer
||
11031 type
== show_ipv6_peer
) {
11032 ret
= str2sockunion(ip_str
, &su
);
11034 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11037 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11040 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
11043 json_object_free(json
);
11047 vty_out(vty
, "}\n");
11048 json_object_free(json
);
11050 else if (!nbr_output
)
11051 vty_out(vty
, "%% BGP instance not found\n");
11054 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
11055 enum show_type type
, const char *ip_str
,
11060 union sockunion su
;
11061 json_object
*json
= NULL
;
11064 if (strmatch(name
, "all")) {
11065 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
11067 return CMD_SUCCESS
;
11069 bgp
= bgp_lookup_by_name(name
);
11072 json
= json_object_new_object();
11073 vty_out(vty
, "%s\n",
11074 json_object_to_json_string_ext(
11076 JSON_C_TO_STRING_PRETTY
));
11077 json_object_free(json
);
11080 "%% BGP instance not found\n");
11082 return CMD_WARNING
;
11086 bgp
= bgp_get_default();
11090 json
= json_object_new_object();
11092 ret
= str2sockunion(ip_str
, &su
);
11094 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11097 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11100 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
11103 json_object_free(json
);
11106 vty_out(vty
, "{}\n");
11108 vty_out(vty
, "%% BGP instance not found\n");
11111 return CMD_SUCCESS
;
11114 /* "show [ip] bgp neighbors" commands. */
11115 DEFUN (show_ip_bgp_neighbors
,
11116 show_ip_bgp_neighbors_cmd
,
11117 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
11121 BGP_INSTANCE_HELP_STR
11124 "Detailed information on TCP and BGP neighbor connections\n"
11125 "Neighbor to display information about\n"
11126 "Neighbor to display information about\n"
11127 "Neighbor on BGP configured interface\n"
11131 char *sh_arg
= NULL
;
11132 enum show_type sh_type
;
11133 afi_t afi
= AFI_MAX
;
11135 bool uj
= use_json(argc
, argv
);
11139 /* [<vrf> VIEWVRFNAME] */
11140 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11141 vrf
= argv
[idx
+ 1]->arg
;
11142 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11144 } else if (argv_find(argv
, argc
, "view", &idx
))
11145 /* [<view> VIEWVRFNAME] */
11146 vrf
= argv
[idx
+ 1]->arg
;
11150 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
11151 sh_type
= show_ipv4_all
;
11153 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
11154 sh_type
= show_ipv6_all
;
11157 sh_type
= show_all
;
11160 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
11161 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
11162 || argv_find(argv
, argc
, "WORD", &idx
)) {
11163 sh_type
= show_peer
;
11164 sh_arg
= argv
[idx
]->arg
;
11167 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
11168 sh_type
= show_ipv4_peer
;
11169 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
11170 sh_type
= show_ipv6_peer
;
11173 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
11176 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
11177 paths' and `show ip mbgp paths'. Those functions results are the
11179 DEFUN (show_ip_bgp_paths
,
11180 show_ip_bgp_paths_cmd
,
11181 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
11186 "Path information\n")
11188 vty_out(vty
, "Address Refcnt Path\n");
11189 aspath_print_all_vty(vty
);
11190 return CMD_SUCCESS
;
11195 static void community_show_all_iterator(struct hash_bucket
*bucket
,
11198 struct community
*com
;
11200 com
= (struct community
*)bucket
->data
;
11201 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
11202 community_str(com
, false));
11205 /* Show BGP's community internal data. */
11206 DEFUN (show_ip_bgp_community_info
,
11207 show_ip_bgp_community_info_cmd
,
11208 "show [ip] bgp community-info",
11212 "List all bgp community information\n")
11214 vty_out(vty
, "Address Refcnt Community\n");
11216 hash_iterate(community_hash(),
11217 (void (*)(struct hash_bucket
*,
11218 void *))community_show_all_iterator
,
11221 return CMD_SUCCESS
;
11224 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
11227 struct lcommunity
*lcom
;
11229 lcom
= (struct lcommunity
*)bucket
->data
;
11230 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11231 lcommunity_str(lcom
, false));
11234 /* Show BGP's community internal data. */
11235 DEFUN (show_ip_bgp_lcommunity_info
,
11236 show_ip_bgp_lcommunity_info_cmd
,
11237 "show ip bgp large-community-info",
11241 "List all bgp large-community information\n")
11243 vty_out(vty
, "Address Refcnt Large-community\n");
11245 hash_iterate(lcommunity_hash(),
11246 (void (*)(struct hash_bucket
*,
11247 void *))lcommunity_show_all_iterator
,
11250 return CMD_SUCCESS
;
11254 DEFUN (show_ip_bgp_attr_info
,
11255 show_ip_bgp_attr_info_cmd
,
11256 "show [ip] bgp attribute-info",
11260 "List all bgp attribute information\n")
11262 attr_show_all(vty
);
11263 return CMD_SUCCESS
;
11266 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
11267 afi_t afi
, safi_t safi
,
11268 bool use_json
, json_object
*json
)
11271 struct listnode
*node
;
11273 char buf1
[INET6_ADDRSTRLEN
];
11275 vpn_policy_direction_t dir
;
11278 json_object
*json_import_vrfs
= NULL
;
11279 json_object
*json_export_vrfs
= NULL
;
11281 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11284 vty_out(vty
, "%s\n",
11285 json_object_to_json_string_ext(
11287 JSON_C_TO_STRING_PRETTY
));
11288 json_object_free(json
);
11290 return CMD_WARNING
;
11293 /* Provide context for the block */
11294 json_object_string_add(json
, "vrf", name
? name
: "default");
11295 json_object_string_add(json
, "afiSafi",
11296 afi_safi_print(afi
, safi
));
11298 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11299 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11300 json_object_string_add(json
, "importFromVrfs", "none");
11301 json_object_string_add(json
, "importRts", "none");
11303 json_import_vrfs
= json_object_new_array();
11305 for (ALL_LIST_ELEMENTS_RO(
11306 bgp
->vpn_policy
[afi
].import_vrf
,
11308 json_object_array_add(json_import_vrfs
,
11309 json_object_new_string(vname
));
11311 json_object_object_add(json
, "importFromVrfs",
11313 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11314 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11315 ecom_str
= ecommunity_ecom2str(
11316 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11317 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11318 json_object_string_add(json
, "importRts",
11320 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11322 json_object_string_add(json
, "importRts",
11326 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11327 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11328 json_object_string_add(json
, "exportToVrfs", "none");
11329 json_object_string_add(json
, "routeDistinguisher",
11331 json_object_string_add(json
, "exportRts", "none");
11333 json_export_vrfs
= json_object_new_array();
11335 for (ALL_LIST_ELEMENTS_RO(
11336 bgp
->vpn_policy
[afi
].export_vrf
,
11338 json_object_array_add(json_export_vrfs
,
11339 json_object_new_string(vname
));
11340 json_object_object_add(json
, "exportToVrfs",
11342 json_object_string_add(json
, "routeDistinguisher",
11343 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11344 buf1
, RD_ADDRSTRLEN
));
11346 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11347 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11348 ecom_str
= ecommunity_ecom2str(
11349 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11350 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11351 json_object_string_add(json
, "exportRts",
11353 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11355 json_object_string_add(json
, "exportRts",
11360 vty_out(vty
, "%s\n",
11361 json_object_to_json_string_ext(json
,
11362 JSON_C_TO_STRING_PRETTY
));
11363 json_object_free(json
);
11366 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11369 vty_out(vty
, "%% No such BGP instance exist\n");
11370 return CMD_WARNING
;
11373 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11374 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11376 "This VRF is not importing %s routes from any other VRF\n",
11377 afi_safi_print(afi
, safi
));
11380 "This VRF is importing %s routes from the following VRFs:\n",
11381 afi_safi_print(afi
, safi
));
11383 for (ALL_LIST_ELEMENTS_RO(
11384 bgp
->vpn_policy
[afi
].import_vrf
,
11386 vty_out(vty
, " %s\n", vname
);
11388 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11390 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11391 ecom_str
= ecommunity_ecom2str(
11392 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11393 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11394 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11396 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11398 vty_out(vty
, "Import RT(s):\n");
11401 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11402 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11404 "This VRF is not exporting %s routes to any other VRF\n",
11405 afi_safi_print(afi
, safi
));
11408 "This VRF is exporting %s routes to the following VRFs:\n",
11409 afi_safi_print(afi
, safi
));
11411 for (ALL_LIST_ELEMENTS_RO(
11412 bgp
->vpn_policy
[afi
].export_vrf
,
11414 vty_out(vty
, " %s\n", vname
);
11416 vty_out(vty
, "RD: %s\n",
11417 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11418 buf1
, RD_ADDRSTRLEN
));
11420 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11421 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11422 ecom_str
= ecommunity_ecom2str(
11423 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11424 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11425 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11426 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11428 vty_out(vty
, "Import RT(s):\n");
11432 return CMD_SUCCESS
;
11435 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
11436 safi_t safi
, bool use_json
)
11438 struct listnode
*node
, *nnode
;
11440 char *vrf_name
= NULL
;
11441 json_object
*json
= NULL
;
11442 json_object
*json_vrf
= NULL
;
11443 json_object
*json_vrfs
= NULL
;
11446 json
= json_object_new_object();
11447 json_vrfs
= json_object_new_object();
11450 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11452 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
11453 vrf_name
= bgp
->name
;
11456 json_vrf
= json_object_new_object();
11458 vty_out(vty
, "\nInstance %s:\n",
11459 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11460 ? VRF_DEFAULT_NAME
: bgp
->name
);
11462 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
11464 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11465 json_object_object_add(json_vrfs
,
11466 VRF_DEFAULT_NAME
, json_vrf
);
11468 json_object_object_add(json_vrfs
, vrf_name
,
11474 json_object_object_add(json
, "vrfs", json_vrfs
);
11475 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
11476 JSON_C_TO_STRING_PRETTY
));
11477 json_object_free(json
);
11480 return CMD_SUCCESS
;
11483 /* "show [ip] bgp route-leak" command. */
11484 DEFUN (show_ip_bgp_route_leak
,
11485 show_ip_bgp_route_leak_cmd
,
11486 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11490 BGP_INSTANCE_HELP_STR
11493 "Route leaking information\n"
11497 afi_t afi
= AFI_MAX
;
11498 safi_t safi
= SAFI_MAX
;
11500 bool uj
= use_json(argc
, argv
);
11502 json_object
*json
= NULL
;
11504 /* show [ip] bgp */
11505 if (argv_find(argv
, argc
, "ip", &idx
)) {
11507 safi
= SAFI_UNICAST
;
11509 /* [vrf VIEWVRFNAME] */
11510 if (argv_find(argv
, argc
, "view", &idx
)) {
11512 "%% This command is not applicable to BGP views\n");
11513 return CMD_WARNING
;
11516 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11517 vrf
= argv
[idx
+ 1]->arg
;
11518 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11521 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11522 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11523 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11526 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11528 "%% This command is applicable only for unicast ipv4|ipv6\n");
11529 return CMD_WARNING
;
11532 if (vrf
&& strmatch(vrf
, "all"))
11533 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
11536 json
= json_object_new_object();
11538 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
11541 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11544 struct listnode
*node
, *nnode
;
11547 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11548 vty_out(vty
, "\nInstance %s:\n",
11549 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11552 update_group_show(bgp
, afi
, safi
, vty
, 0);
11556 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11557 int safi
, uint64_t subgrp_id
)
11562 if (strmatch(name
, "all")) {
11563 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11564 return CMD_SUCCESS
;
11566 bgp
= bgp_lookup_by_name(name
);
11569 bgp
= bgp_get_default();
11573 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11574 return CMD_SUCCESS
;
11577 DEFUN (show_ip_bgp_updgrps
,
11578 show_ip_bgp_updgrps_cmd
,
11579 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11583 BGP_INSTANCE_HELP_STR
11585 BGP_SAFI_WITH_LABEL_HELP_STR
11586 "Detailed info about dynamic update groups\n"
11587 "Specific subgroup to display detailed info for\n")
11590 afi_t afi
= AFI_IP6
;
11591 safi_t safi
= SAFI_UNICAST
;
11592 uint64_t subgrp_id
= 0;
11596 /* show [ip] bgp */
11597 if (argv_find(argv
, argc
, "ip", &idx
))
11599 /* [<vrf> VIEWVRFNAME] */
11600 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11601 vrf
= argv
[idx
+ 1]->arg
;
11602 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11604 } else if (argv_find(argv
, argc
, "view", &idx
))
11605 /* [<view> VIEWVRFNAME] */
11606 vrf
= argv
[idx
+ 1]->arg
;
11607 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11608 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11609 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11612 /* get subgroup id, if provided */
11614 if (argv
[idx
]->type
== VARIABLE_TKN
)
11615 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11617 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11620 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11621 show_bgp_instance_all_ipv6_updgrps_cmd
,
11622 "show [ip] bgp <view|vrf> all update-groups",
11626 BGP_INSTANCE_ALL_HELP_STR
11627 "Detailed info about dynamic update groups\n")
11629 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11630 return CMD_SUCCESS
;
11633 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
11634 show_bgp_l2vpn_evpn_updgrps_cmd
,
11635 "show [ip] bgp l2vpn evpn update-groups",
11639 "l2vpn address family\n"
11640 "evpn sub-address family\n"
11641 "Detailed info about dynamic update groups\n")
11644 uint64_t subgrp_id
= 0;
11646 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
11647 return CMD_SUCCESS
;
11650 DEFUN (show_bgp_updgrps_stats
,
11651 show_bgp_updgrps_stats_cmd
,
11652 "show [ip] bgp update-groups statistics",
11656 "Detailed info about dynamic update groups\n"
11661 bgp
= bgp_get_default();
11663 update_group_show_stats(bgp
, vty
);
11665 return CMD_SUCCESS
;
11668 DEFUN (show_bgp_instance_updgrps_stats
,
11669 show_bgp_instance_updgrps_stats_cmd
,
11670 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11674 BGP_INSTANCE_HELP_STR
11675 "Detailed info about dynamic update groups\n"
11681 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11683 update_group_show_stats(bgp
, vty
);
11685 return CMD_SUCCESS
;
11688 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11689 afi_t afi
, safi_t safi
,
11690 const char *what
, uint64_t subgrp_id
)
11695 bgp
= bgp_lookup_by_name(name
);
11697 bgp
= bgp_get_default();
11700 if (!strcmp(what
, "advertise-queue"))
11701 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11703 else if (!strcmp(what
, "advertised-routes"))
11704 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11706 else if (!strcmp(what
, "packet-queue"))
11707 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11712 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11713 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11714 "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",
11715 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11717 "Detailed info about dynamic update groups\n"
11718 "Specific subgroup to display info for\n"
11719 "Advertisement queue\n"
11720 "Announced routes\n"
11723 uint64_t subgrp_id
= 0;
11727 subgrp_id
= strtoull(sgid
, NULL
, 10);
11732 afiz
= bgp_vty_afi_from_str(afi
);
11736 afiz
= bgp_vty_afi_from_str(afi
);
11737 if (afiz
!= AFI_IP
)
11739 "%% Cannot specify both 'ip' and 'ipv6'\n");
11740 return CMD_WARNING
;
11743 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11745 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11746 return CMD_SUCCESS
;
11749 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11751 struct listnode
*node
, *nnode
;
11752 struct prefix
*range
;
11755 char buf
[PREFIX2STR_BUFFER
];
11758 const char *peer_status
;
11759 const char *af_str
;
11764 conf
= group
->conf
;
11766 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11767 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11768 group
->name
, conf
->as
);
11769 } else if (conf
->as_type
== AS_INTERNAL
) {
11770 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11771 group
->name
, group
->bgp
->as
);
11773 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11776 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11777 vty_out(vty
, " Peer-group type is internal\n");
11779 vty_out(vty
, " Peer-group type is external\n");
11781 /* Display AFs configured. */
11782 vty_out(vty
, " Configured address-families:");
11783 FOREACH_AFI_SAFI (afi
, safi
) {
11784 if (conf
->afc
[afi
][safi
]) {
11786 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11790 vty_out(vty
, " none\n");
11792 vty_out(vty
, "\n");
11794 /* Display listen ranges (for dynamic neighbors), if any */
11795 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11798 else if (afi
== AFI_IP6
)
11802 lr_count
= listcount(group
->listen_range
[afi
]);
11804 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11808 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11810 prefix2str(range
, buf
, sizeof(buf
));
11811 vty_out(vty
, " %s\n", buf
);
11816 /* Display group members and their status */
11817 if (listcount(group
->peer
)) {
11818 vty_out(vty
, " Peer-group members:\n");
11819 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11820 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11821 peer_status
= "Idle (Admin)";
11822 else if (CHECK_FLAG(peer
->sflags
,
11823 PEER_STATUS_PREFIX_OVERFLOW
))
11824 peer_status
= "Idle (PfxCt)";
11826 peer_status
= lookup_msg(bgp_status_msg
,
11827 peer
->status
, NULL
);
11829 dynamic
= peer_dynamic_neighbor(peer
);
11830 vty_out(vty
, " %s %s %s \n", peer
->host
,
11831 dynamic
? "(dynamic)" : "", peer_status
);
11835 return CMD_SUCCESS
;
11838 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11839 const char *group_name
)
11842 struct listnode
*node
, *nnode
;
11843 struct peer_group
*group
;
11844 bool found
= false;
11846 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11849 vty_out(vty
, "%% BGP instance not found\n");
11850 return CMD_WARNING
;
11853 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11855 if (strmatch(group
->name
, group_name
)) {
11856 bgp_show_one_peer_group(vty
, group
);
11861 bgp_show_one_peer_group(vty
, group
);
11865 if (group_name
&& !found
)
11866 vty_out(vty
, "%% No such peer-group\n");
11868 return CMD_SUCCESS
;
11871 DEFUN (show_ip_bgp_peer_groups
,
11872 show_ip_bgp_peer_groups_cmd
,
11873 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11877 BGP_INSTANCE_HELP_STR
11878 "Detailed information on BGP peer groups\n"
11879 "Peer group name\n")
11884 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11886 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11888 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11892 /* Redistribute VTY commands. */
11894 DEFUN (bgp_redistribute_ipv4
,
11895 bgp_redistribute_ipv4_cmd
,
11896 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11897 "Redistribute information from another routing protocol\n"
11898 FRR_IP_REDIST_HELP_STR_BGPD
)
11900 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11901 int idx_protocol
= 1;
11904 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11906 vty_out(vty
, "%% Invalid route type\n");
11907 return CMD_WARNING_CONFIG_FAILED
;
11910 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11911 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
11915 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11916 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11917 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11919 DEFUN (bgp_redistribute_ipv4_rmap
,
11920 bgp_redistribute_ipv4_rmap_cmd
,
11921 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11922 "Redistribute information from another routing protocol\n"
11923 FRR_IP_REDIST_HELP_STR_BGPD
11924 "Route map reference\n"
11925 "Pointer to route-map entries\n")
11927 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11928 int idx_protocol
= 1;
11931 struct bgp_redist
*red
;
11933 struct route_map
*route_map
= route_map_lookup_warn_noexist(
11934 vty
, argv
[idx_word
]->arg
);
11936 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11938 vty_out(vty
, "%% Invalid route type\n");
11939 return CMD_WARNING_CONFIG_FAILED
;
11942 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11944 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
11945 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11949 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
11950 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11951 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11952 "Route map reference\n"
11953 "Pointer to route-map entries\n")
11955 DEFUN (bgp_redistribute_ipv4_metric
,
11956 bgp_redistribute_ipv4_metric_cmd
,
11957 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11958 "Redistribute information from another routing protocol\n"
11959 FRR_IP_REDIST_HELP_STR_BGPD
11960 "Metric for redistributed routes\n"
11961 "Default metric\n")
11963 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11964 int idx_protocol
= 1;
11965 int idx_number
= 3;
11968 struct bgp_redist
*red
;
11971 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11973 vty_out(vty
, "%% Invalid route type\n");
11974 return CMD_WARNING_CONFIG_FAILED
;
11976 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11978 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11979 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11980 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11984 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
11985 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11986 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11987 "Metric for redistributed routes\n"
11988 "Default metric\n")
11990 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
11991 bgp_redistribute_ipv4_rmap_metric_cmd
,
11992 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11993 "Redistribute information from another routing protocol\n"
11994 FRR_IP_REDIST_HELP_STR_BGPD
11995 "Route map reference\n"
11996 "Pointer to route-map entries\n"
11997 "Metric for redistributed routes\n"
11998 "Default metric\n")
12000 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12001 int idx_protocol
= 1;
12003 int idx_number
= 5;
12006 struct bgp_redist
*red
;
12008 struct route_map
*route_map
=
12009 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12011 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12013 vty_out(vty
, "%% Invalid route type\n");
12014 return CMD_WARNING_CONFIG_FAILED
;
12016 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12018 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12020 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12021 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12022 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12026 bgp_redistribute_ipv4_rmap_metric
,
12027 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
12028 "redistribute " FRR_IP_REDIST_STR_BGPD
12029 " route-map WORD metric (0-4294967295)",
12030 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12031 "Route map reference\n"
12032 "Pointer to route-map entries\n"
12033 "Metric for redistributed routes\n"
12034 "Default metric\n")
12036 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
12037 bgp_redistribute_ipv4_metric_rmap_cmd
,
12038 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12039 "Redistribute information from another routing protocol\n"
12040 FRR_IP_REDIST_HELP_STR_BGPD
12041 "Metric for redistributed routes\n"
12043 "Route map reference\n"
12044 "Pointer to route-map entries\n")
12046 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12047 int idx_protocol
= 1;
12048 int idx_number
= 3;
12052 struct bgp_redist
*red
;
12054 struct route_map
*route_map
=
12055 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12057 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12059 vty_out(vty
, "%% Invalid route type\n");
12060 return CMD_WARNING_CONFIG_FAILED
;
12062 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12064 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12065 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12067 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12068 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12072 bgp_redistribute_ipv4_metric_rmap
,
12073 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
12074 "redistribute " FRR_IP_REDIST_STR_BGPD
12075 " metric (0-4294967295) route-map WORD",
12076 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12077 "Metric for redistributed routes\n"
12079 "Route map reference\n"
12080 "Pointer to route-map entries\n")
12082 DEFUN (bgp_redistribute_ipv4_ospf
,
12083 bgp_redistribute_ipv4_ospf_cmd
,
12084 "redistribute <ospf|table> (1-65535)",
12085 "Redistribute information from another routing protocol\n"
12086 "Open Shortest Path First (OSPFv2)\n"
12087 "Non-main Kernel Routing Table\n"
12088 "Instance ID/Table ID\n")
12090 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12091 int idx_ospf_table
= 1;
12092 int idx_number
= 2;
12093 unsigned short instance
;
12094 unsigned short protocol
;
12096 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12098 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12099 protocol
= ZEBRA_ROUTE_OSPF
;
12101 protocol
= ZEBRA_ROUTE_TABLE
;
12103 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12104 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
12107 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
12108 "redistribute <ospf|table> (1-65535)",
12109 "Redistribute information from another routing protocol\n"
12110 "Open Shortest Path First (OSPFv2)\n"
12111 "Non-main Kernel Routing Table\n"
12112 "Instance ID/Table ID\n")
12114 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
12115 bgp_redistribute_ipv4_ospf_rmap_cmd
,
12116 "redistribute <ospf|table> (1-65535) route-map WORD",
12117 "Redistribute information from another routing protocol\n"
12118 "Open Shortest Path First (OSPFv2)\n"
12119 "Non-main Kernel Routing Table\n"
12120 "Instance ID/Table ID\n"
12121 "Route map reference\n"
12122 "Pointer to route-map entries\n")
12124 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12125 int idx_ospf_table
= 1;
12126 int idx_number
= 2;
12128 struct bgp_redist
*red
;
12129 unsigned short instance
;
12132 struct route_map
*route_map
=
12133 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12135 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12136 protocol
= ZEBRA_ROUTE_OSPF
;
12138 protocol
= ZEBRA_ROUTE_TABLE
;
12140 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12141 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12143 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12144 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12147 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
12148 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
12149 "redistribute <ospf|table> (1-65535) route-map WORD",
12150 "Redistribute information from another routing protocol\n"
12151 "Open Shortest Path First (OSPFv2)\n"
12152 "Non-main Kernel Routing Table\n"
12153 "Instance ID/Table ID\n"
12154 "Route map reference\n"
12155 "Pointer to route-map entries\n")
12157 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
12158 bgp_redistribute_ipv4_ospf_metric_cmd
,
12159 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
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 "Metric for redistributed routes\n"
12165 "Default metric\n")
12167 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12168 int idx_ospf_table
= 1;
12169 int idx_number
= 2;
12170 int idx_number_2
= 4;
12172 struct bgp_redist
*red
;
12173 unsigned short instance
;
12177 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12178 protocol
= ZEBRA_ROUTE_OSPF
;
12180 protocol
= ZEBRA_ROUTE_TABLE
;
12182 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12183 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12185 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12186 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12188 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12191 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
12192 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
12193 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12194 "Redistribute information from another routing protocol\n"
12195 "Open Shortest Path First (OSPFv2)\n"
12196 "Non-main Kernel Routing Table\n"
12197 "Instance ID/Table ID\n"
12198 "Metric for redistributed routes\n"
12199 "Default metric\n")
12201 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
12202 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
12203 "redistribute <ospf|table> (1-65535) route-map WORD 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 "Route map reference\n"
12209 "Pointer to route-map entries\n"
12210 "Metric for redistributed routes\n"
12211 "Default metric\n")
12213 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12214 int idx_ospf_table
= 1;
12215 int idx_number
= 2;
12217 int idx_number_2
= 6;
12219 struct bgp_redist
*red
;
12220 unsigned short instance
;
12223 struct route_map
*route_map
=
12224 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12226 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12227 protocol
= ZEBRA_ROUTE_OSPF
;
12229 protocol
= ZEBRA_ROUTE_TABLE
;
12231 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12232 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12234 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12236 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12237 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12239 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12243 bgp_redistribute_ipv4_ospf_rmap_metric
,
12244 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
12245 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12246 "Redistribute information from another routing protocol\n"
12247 "Open Shortest Path First (OSPFv2)\n"
12248 "Non-main Kernel Routing Table\n"
12249 "Instance ID/Table ID\n"
12250 "Route map reference\n"
12251 "Pointer to route-map entries\n"
12252 "Metric for redistributed routes\n"
12253 "Default metric\n")
12255 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
12256 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
12257 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12258 "Redistribute information from another routing protocol\n"
12259 "Open Shortest Path First (OSPFv2)\n"
12260 "Non-main Kernel Routing Table\n"
12261 "Instance ID/Table ID\n"
12262 "Metric for redistributed routes\n"
12264 "Route map reference\n"
12265 "Pointer to route-map entries\n")
12267 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12268 int idx_ospf_table
= 1;
12269 int idx_number
= 2;
12270 int idx_number_2
= 4;
12273 struct bgp_redist
*red
;
12274 unsigned short instance
;
12277 struct route_map
*route_map
=
12278 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12280 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12281 protocol
= ZEBRA_ROUTE_OSPF
;
12283 protocol
= ZEBRA_ROUTE_TABLE
;
12285 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12286 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12288 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12289 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12292 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12293 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12297 bgp_redistribute_ipv4_ospf_metric_rmap
,
12298 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
12299 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12300 "Redistribute information from another routing protocol\n"
12301 "Open Shortest Path First (OSPFv2)\n"
12302 "Non-main Kernel Routing Table\n"
12303 "Instance ID/Table ID\n"
12304 "Metric for redistributed routes\n"
12306 "Route map reference\n"
12307 "Pointer to route-map entries\n")
12309 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12310 no_bgp_redistribute_ipv4_ospf_cmd
,
12311 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
12313 "Redistribute information from another routing protocol\n"
12314 "Open Shortest Path First (OSPFv2)\n"
12315 "Non-main Kernel Routing Table\n"
12316 "Instance ID/Table ID\n"
12317 "Metric for redistributed routes\n"
12319 "Route map reference\n"
12320 "Pointer to route-map entries\n")
12322 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12323 int idx_ospf_table
= 2;
12324 int idx_number
= 3;
12325 unsigned short instance
;
12328 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12329 protocol
= ZEBRA_ROUTE_OSPF
;
12331 protocol
= ZEBRA_ROUTE_TABLE
;
12333 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12334 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12338 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12339 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
12341 "Redistribute information from another routing protocol\n"
12342 "Open Shortest Path First (OSPFv2)\n"
12343 "Non-main Kernel Routing Table\n"
12344 "Instance ID/Table ID\n"
12345 "Metric for redistributed routes\n"
12347 "Route map reference\n"
12348 "Pointer to route-map entries\n")
12350 DEFUN (no_bgp_redistribute_ipv4
,
12351 no_bgp_redistribute_ipv4_cmd
,
12352 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
12354 "Redistribute information from another routing protocol\n"
12355 FRR_IP_REDIST_HELP_STR_BGPD
12356 "Metric for redistributed routes\n"
12358 "Route map reference\n"
12359 "Pointer to route-map entries\n")
12361 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12362 int idx_protocol
= 2;
12365 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12367 vty_out(vty
, "%% Invalid route type\n");
12368 return CMD_WARNING_CONFIG_FAILED
;
12370 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12374 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12375 "no redistribute " FRR_IP_REDIST_STR_BGPD
12376 " [{metric (0-4294967295)|route-map WORD}]",
12378 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12379 "Metric for redistributed routes\n"
12381 "Route map reference\n"
12382 "Pointer to route-map entries\n")
12384 DEFUN (bgp_redistribute_ipv6
,
12385 bgp_redistribute_ipv6_cmd
,
12386 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12387 "Redistribute information from another routing protocol\n"
12388 FRR_IP6_REDIST_HELP_STR_BGPD
)
12390 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12391 int idx_protocol
= 1;
12394 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12396 vty_out(vty
, "%% Invalid route type\n");
12397 return CMD_WARNING_CONFIG_FAILED
;
12400 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12401 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12404 DEFUN (bgp_redistribute_ipv6_rmap
,
12405 bgp_redistribute_ipv6_rmap_cmd
,
12406 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12407 "Redistribute information from another routing protocol\n"
12408 FRR_IP6_REDIST_HELP_STR_BGPD
12409 "Route map reference\n"
12410 "Pointer to route-map entries\n")
12412 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12413 int idx_protocol
= 1;
12416 struct bgp_redist
*red
;
12418 struct route_map
*route_map
=
12419 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12421 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12423 vty_out(vty
, "%% Invalid route type\n");
12424 return CMD_WARNING_CONFIG_FAILED
;
12427 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12429 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12430 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12433 DEFUN (bgp_redistribute_ipv6_metric
,
12434 bgp_redistribute_ipv6_metric_cmd
,
12435 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12436 "Redistribute information from another routing protocol\n"
12437 FRR_IP6_REDIST_HELP_STR_BGPD
12438 "Metric for redistributed routes\n"
12439 "Default metric\n")
12441 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12442 int idx_protocol
= 1;
12443 int idx_number
= 3;
12446 struct bgp_redist
*red
;
12449 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12451 vty_out(vty
, "%% Invalid route type\n");
12452 return CMD_WARNING_CONFIG_FAILED
;
12454 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12456 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12457 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12458 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12461 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12462 bgp_redistribute_ipv6_rmap_metric_cmd
,
12463 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12464 "Redistribute information from another routing protocol\n"
12465 FRR_IP6_REDIST_HELP_STR_BGPD
12466 "Route map reference\n"
12467 "Pointer to route-map entries\n"
12468 "Metric for redistributed routes\n"
12469 "Default metric\n")
12471 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12472 int idx_protocol
= 1;
12474 int idx_number
= 5;
12477 struct bgp_redist
*red
;
12479 struct route_map
*route_map
=
12480 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12482 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12484 vty_out(vty
, "%% Invalid route type\n");
12485 return CMD_WARNING_CONFIG_FAILED
;
12487 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12489 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12491 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12492 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12494 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12497 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12498 bgp_redistribute_ipv6_metric_rmap_cmd
,
12499 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12500 "Redistribute information from another routing protocol\n"
12501 FRR_IP6_REDIST_HELP_STR_BGPD
12502 "Metric for redistributed routes\n"
12504 "Route map reference\n"
12505 "Pointer to route-map entries\n")
12507 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12508 int idx_protocol
= 1;
12509 int idx_number
= 3;
12513 struct bgp_redist
*red
;
12515 struct route_map
*route_map
=
12516 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12518 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12520 vty_out(vty
, "%% Invalid route type\n");
12521 return CMD_WARNING_CONFIG_FAILED
;
12523 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12525 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12526 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12529 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12530 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12533 DEFUN (no_bgp_redistribute_ipv6
,
12534 no_bgp_redistribute_ipv6_cmd
,
12535 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
12537 "Redistribute information from another routing protocol\n"
12538 FRR_IP6_REDIST_HELP_STR_BGPD
12539 "Metric for redistributed routes\n"
12541 "Route map reference\n"
12542 "Pointer to route-map entries\n")
12544 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12545 int idx_protocol
= 2;
12548 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12550 vty_out(vty
, "%% Invalid route type\n");
12551 return CMD_WARNING_CONFIG_FAILED
;
12554 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12557 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12562 /* Unicast redistribution only. */
12563 if (safi
!= SAFI_UNICAST
)
12566 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12567 /* Redistribute BGP does not make sense. */
12568 if (i
!= ZEBRA_ROUTE_BGP
) {
12569 struct list
*red_list
;
12570 struct listnode
*node
;
12571 struct bgp_redist
*red
;
12573 red_list
= bgp
->redist
[afi
][i
];
12577 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12578 /* "redistribute" configuration. */
12579 vty_out(vty
, " redistribute %s",
12580 zebra_route_string(i
));
12582 vty_out(vty
, " %d", red
->instance
);
12583 if (red
->redist_metric_flag
)
12584 vty_out(vty
, " metric %u",
12585 red
->redist_metric
);
12586 if (red
->rmap
.name
)
12587 vty_out(vty
, " route-map %s",
12589 vty_out(vty
, "\n");
12595 /* This is part of the address-family block (unicast only) */
12596 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12601 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12602 if (listcount(bgp
->vpn_policy
[afi
].import_vrf
))
12603 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12604 bgp
->vpn_policy
[afi
]
12605 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12607 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
12608 bgp
->vpn_policy
[afi
]
12609 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12611 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12612 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12613 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12614 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12617 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12618 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12620 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12623 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12624 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12625 bgp
->vpn_policy
[afi
].tovpn_label
);
12628 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12629 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12630 char buf
[RD_ADDRSTRLEN
];
12631 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12632 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12635 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12636 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12638 char buf
[PREFIX_STRLEN
];
12639 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12640 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12643 vty_out(vty
, "%*snexthop vpn export %s\n",
12647 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12648 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12650 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12651 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12653 char *b
= ecommunity_ecom2str(
12654 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12655 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12656 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12657 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12659 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12660 char *b
= ecommunity_ecom2str(
12661 bgp
->vpn_policy
[afi
]
12662 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12663 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12664 ECOMMUNITY_ROUTE_TARGET
);
12665 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12666 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12668 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12669 char *b
= ecommunity_ecom2str(
12670 bgp
->vpn_policy
[afi
]
12671 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12672 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12673 ECOMMUNITY_ROUTE_TARGET
);
12674 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12675 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12679 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12680 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12681 bgp
->vpn_policy
[afi
]
12682 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12684 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12685 char *b
= ecommunity_ecom2str(
12686 bgp
->vpn_policy
[afi
]
12687 .import_redirect_rtlist
,
12688 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12689 ECOMMUNITY_ROUTE_TARGET
);
12691 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12692 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12697 /* BGP node structure. */
12698 static struct cmd_node bgp_node
= {
12699 BGP_NODE
, "%s(config-router)# ", 1,
12702 static struct cmd_node bgp_ipv4_unicast_node
= {
12703 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12706 static struct cmd_node bgp_ipv4_multicast_node
= {
12707 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12710 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12711 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12714 static struct cmd_node bgp_ipv6_unicast_node
= {
12715 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12718 static struct cmd_node bgp_ipv6_multicast_node
= {
12719 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12722 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12723 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12726 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12727 "%s(config-router-af)# ", 1};
12729 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12730 "%s(config-router-af-vpnv6)# ", 1};
12732 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12733 "%s(config-router-evpn)# ", 1};
12735 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12736 "%s(config-router-af-vni)# ", 1};
12738 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12739 "%s(config-router-af)# ", 1};
12741 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12742 "%s(config-router-af-vpnv6)# ", 1};
12744 static void community_list_vty(void);
12746 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12750 struct listnode
*lnbgp
, *lnpeer
;
12752 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12753 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12754 /* only provide suggestions on the appropriate input
12756 * they'll otherwise show up multiple times */
12757 enum cmd_token_type match_type
;
12758 char *name
= peer
->host
;
12760 if (peer
->conf_if
) {
12761 match_type
= VARIABLE_TKN
;
12762 name
= peer
->conf_if
;
12763 } else if (strchr(peer
->host
, ':'))
12764 match_type
= IPV6_TKN
;
12766 match_type
= IPV4_TKN
;
12768 if (token
->type
!= match_type
)
12771 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12776 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12777 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12778 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12779 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12780 {.completions
= NULL
}};
12782 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12785 struct peer_group
*group
;
12786 struct listnode
*lnbgp
, *lnpeer
;
12788 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12789 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12790 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12795 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12796 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12797 {.completions
= NULL
} };
12799 void bgp_vty_init(void)
12801 cmd_variable_handler_register(bgp_var_neighbor
);
12802 cmd_variable_handler_register(bgp_var_peergroup
);
12804 /* Install bgp top node. */
12805 install_node(&bgp_node
, bgp_config_write
);
12806 install_node(&bgp_ipv4_unicast_node
, NULL
);
12807 install_node(&bgp_ipv4_multicast_node
, NULL
);
12808 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12809 install_node(&bgp_ipv6_unicast_node
, NULL
);
12810 install_node(&bgp_ipv6_multicast_node
, NULL
);
12811 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12812 install_node(&bgp_vpnv4_node
, NULL
);
12813 install_node(&bgp_vpnv6_node
, NULL
);
12814 install_node(&bgp_evpn_node
, NULL
);
12815 install_node(&bgp_evpn_vni_node
, NULL
);
12816 install_node(&bgp_flowspecv4_node
, NULL
);
12817 install_node(&bgp_flowspecv6_node
, NULL
);
12819 /* Install default VTY commands to new nodes. */
12820 install_default(BGP_NODE
);
12821 install_default(BGP_IPV4_NODE
);
12822 install_default(BGP_IPV4M_NODE
);
12823 install_default(BGP_IPV4L_NODE
);
12824 install_default(BGP_IPV6_NODE
);
12825 install_default(BGP_IPV6M_NODE
);
12826 install_default(BGP_IPV6L_NODE
);
12827 install_default(BGP_VPNV4_NODE
);
12828 install_default(BGP_VPNV6_NODE
);
12829 install_default(BGP_FLOWSPECV4_NODE
);
12830 install_default(BGP_FLOWSPECV6_NODE
);
12831 install_default(BGP_EVPN_NODE
);
12832 install_default(BGP_EVPN_VNI_NODE
);
12834 /* "bgp local-mac" hidden commands. */
12835 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
12836 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
12838 /* bgp route-map delay-timer commands. */
12839 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12840 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12842 /* Dummy commands (Currently not supported) */
12843 install_element(BGP_NODE
, &no_synchronization_cmd
);
12844 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12846 /* "router bgp" commands. */
12847 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12849 /* "no router bgp" commands. */
12850 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12852 /* "bgp router-id" commands. */
12853 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12854 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12856 /* "bgp cluster-id" commands. */
12857 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12858 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12860 /* "bgp confederation" commands. */
12861 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12862 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12864 /* "bgp confederation peers" commands. */
12865 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12866 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12868 /* bgp max-med command */
12869 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12870 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12871 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12872 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12873 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12875 /* bgp disable-ebgp-connected-nh-check */
12876 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12877 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12879 /* bgp update-delay command */
12880 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12881 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12882 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12884 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12885 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12886 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12887 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12889 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12890 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12892 /* "maximum-paths" commands. */
12893 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12894 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12895 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12896 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12897 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12898 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12899 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12900 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12901 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12902 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12903 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12904 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12905 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12906 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12907 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12909 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12910 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12911 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12912 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12913 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12915 /* "timers bgp" commands. */
12916 install_element(BGP_NODE
, &bgp_timers_cmd
);
12917 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12919 /* route-map delay-timer commands - per instance for backwards compat.
12921 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12922 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12924 /* "bgp client-to-client reflection" commands */
12925 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
12926 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
12928 /* "bgp always-compare-med" commands */
12929 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
12930 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
12932 /* bgp ebgp-requires-policy */
12933 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
12934 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
12936 /* "bgp deterministic-med" commands */
12937 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
12938 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
12940 /* "bgp graceful-restart" commands */
12941 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
12942 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
12943 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
12944 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
12945 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
12946 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
12948 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
12949 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
12951 /* "bgp graceful-shutdown" commands */
12952 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
12953 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
12955 /* "bgp fast-external-failover" commands */
12956 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
12957 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
12959 /* "bgp bestpath compare-routerid" commands */
12960 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
12961 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
12963 /* "bgp bestpath as-path ignore" commands */
12964 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
12965 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
12967 /* "bgp bestpath as-path confed" commands */
12968 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
12969 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
12971 /* "bgp bestpath as-path multipath-relax" commands */
12972 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
12973 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
12975 /* "bgp log-neighbor-changes" commands */
12976 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
12977 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
12979 /* "bgp bestpath med" commands */
12980 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
12981 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
12983 /* "no bgp default ipv4-unicast" commands. */
12984 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
12985 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
12987 /* "bgp network import-check" commands. */
12988 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
12989 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
12990 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
12992 /* "bgp default local-preference" commands. */
12993 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
12994 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
12996 /* bgp default show-hostname */
12997 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
12998 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
13000 /* "bgp default subgroup-pkt-queue-max" commands. */
13001 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
13002 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
13004 /* bgp ibgp-allow-policy-mods command */
13005 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
13006 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
13008 /* "bgp listen limit" commands. */
13009 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
13010 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
13012 /* "bgp listen range" commands. */
13013 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
13014 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
13016 /* "bgp default shutdown" command */
13017 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
13019 /* "neighbor remote-as" commands. */
13020 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
13021 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
13022 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
13023 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
13024 install_element(BGP_NODE
,
13025 &neighbor_interface_v6only_config_remote_as_cmd
);
13026 install_element(BGP_NODE
, &no_neighbor_cmd
);
13027 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
13029 /* "neighbor peer-group" commands. */
13030 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
13031 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
13032 install_element(BGP_NODE
,
13033 &no_neighbor_interface_peer_group_remote_as_cmd
);
13035 /* "neighbor local-as" commands. */
13036 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
13037 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
13038 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
13039 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
13041 /* "neighbor solo" commands. */
13042 install_element(BGP_NODE
, &neighbor_solo_cmd
);
13043 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
13045 /* "neighbor password" commands. */
13046 install_element(BGP_NODE
, &neighbor_password_cmd
);
13047 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
13049 /* "neighbor activate" commands. */
13050 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
13051 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
13052 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
13053 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
13054 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
13055 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
13056 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
13057 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
13058 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
13059 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
13060 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
13061 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
13063 /* "no neighbor activate" commands. */
13064 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
13065 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
13066 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
13067 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
13068 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
13069 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
13070 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
13071 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
13072 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
13073 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
13074 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
13075 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
13077 /* "neighbor peer-group" set commands. */
13078 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
13079 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13080 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13081 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13082 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13083 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13084 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13085 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13086 install_element(BGP_FLOWSPECV4_NODE
,
13087 &neighbor_set_peer_group_hidden_cmd
);
13088 install_element(BGP_FLOWSPECV6_NODE
,
13089 &neighbor_set_peer_group_hidden_cmd
);
13091 /* "no neighbor peer-group unset" commands. */
13092 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
13093 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13094 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13095 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13096 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13097 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13098 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13099 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13100 install_element(BGP_FLOWSPECV4_NODE
,
13101 &no_neighbor_set_peer_group_hidden_cmd
);
13102 install_element(BGP_FLOWSPECV6_NODE
,
13103 &no_neighbor_set_peer_group_hidden_cmd
);
13105 /* "neighbor softreconfiguration inbound" commands.*/
13106 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
13107 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
13108 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13109 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13110 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13111 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13112 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13113 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13114 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13115 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13116 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13117 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13118 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13119 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13120 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13121 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13122 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13123 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13124 install_element(BGP_FLOWSPECV4_NODE
,
13125 &neighbor_soft_reconfiguration_cmd
);
13126 install_element(BGP_FLOWSPECV4_NODE
,
13127 &no_neighbor_soft_reconfiguration_cmd
);
13128 install_element(BGP_FLOWSPECV6_NODE
,
13129 &neighbor_soft_reconfiguration_cmd
);
13130 install_element(BGP_FLOWSPECV6_NODE
,
13131 &no_neighbor_soft_reconfiguration_cmd
);
13132 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
13133 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13135 /* "neighbor attribute-unchanged" commands. */
13136 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
13137 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
13138 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
13139 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13140 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
13141 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13142 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
13143 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13144 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
13145 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13146 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
13147 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13148 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
13149 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13150 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
13151 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13152 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
13153 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13155 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
13156 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
13158 /* "nexthop-local unchanged" commands */
13159 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
13160 install_element(BGP_IPV6_NODE
,
13161 &no_neighbor_nexthop_local_unchanged_cmd
);
13163 /* "neighbor next-hop-self" commands. */
13164 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
13165 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
13166 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
13167 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13168 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
13169 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
13170 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
13171 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
13172 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
13173 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13174 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
13175 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
13176 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
13177 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
13178 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
13179 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13180 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
13181 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13182 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
13183 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
13185 /* "neighbor next-hop-self force" commands. */
13186 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
13187 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
13188 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13189 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
13190 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13191 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13192 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13193 install_element(BGP_IPV4_NODE
,
13194 &no_neighbor_nexthop_self_all_hidden_cmd
);
13195 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
13196 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13197 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13198 install_element(BGP_IPV4M_NODE
,
13199 &no_neighbor_nexthop_self_all_hidden_cmd
);
13200 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
13201 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13202 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13203 install_element(BGP_IPV4L_NODE
,
13204 &no_neighbor_nexthop_self_all_hidden_cmd
);
13205 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13206 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13207 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13208 install_element(BGP_IPV6_NODE
,
13209 &no_neighbor_nexthop_self_all_hidden_cmd
);
13210 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
13211 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13212 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13213 install_element(BGP_IPV6M_NODE
,
13214 &no_neighbor_nexthop_self_all_hidden_cmd
);
13215 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
13216 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13217 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13218 install_element(BGP_IPV6L_NODE
,
13219 &no_neighbor_nexthop_self_all_hidden_cmd
);
13220 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13221 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13222 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13223 install_element(BGP_VPNV4_NODE
,
13224 &no_neighbor_nexthop_self_all_hidden_cmd
);
13225 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13226 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13227 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13228 install_element(BGP_VPNV6_NODE
,
13229 &no_neighbor_nexthop_self_all_hidden_cmd
);
13231 /* "neighbor as-override" commands. */
13232 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
13233 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
13234 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
13235 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
13236 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
13237 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
13238 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
13239 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
13240 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
13241 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
13242 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
13243 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
13244 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
13245 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
13246 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
13247 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
13248 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
13249 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
13251 /* "neighbor remove-private-AS" commands. */
13252 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
13253 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
13254 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
13255 install_element(BGP_NODE
,
13256 &no_neighbor_remove_private_as_all_hidden_cmd
);
13257 install_element(BGP_NODE
,
13258 &neighbor_remove_private_as_replace_as_hidden_cmd
);
13259 install_element(BGP_NODE
,
13260 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
13261 install_element(BGP_NODE
,
13262 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13265 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13266 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
13267 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13268 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13269 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13270 install_element(BGP_IPV4_NODE
,
13271 &neighbor_remove_private_as_replace_as_cmd
);
13272 install_element(BGP_IPV4_NODE
,
13273 &no_neighbor_remove_private_as_replace_as_cmd
);
13274 install_element(BGP_IPV4_NODE
,
13275 &neighbor_remove_private_as_all_replace_as_cmd
);
13276 install_element(BGP_IPV4_NODE
,
13277 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13278 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
13279 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
13280 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
13281 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13282 install_element(BGP_IPV4M_NODE
,
13283 &neighbor_remove_private_as_replace_as_cmd
);
13284 install_element(BGP_IPV4M_NODE
,
13285 &no_neighbor_remove_private_as_replace_as_cmd
);
13286 install_element(BGP_IPV4M_NODE
,
13287 &neighbor_remove_private_as_all_replace_as_cmd
);
13288 install_element(BGP_IPV4M_NODE
,
13289 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13290 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
13291 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
13292 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
13293 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13294 install_element(BGP_IPV4L_NODE
,
13295 &neighbor_remove_private_as_replace_as_cmd
);
13296 install_element(BGP_IPV4L_NODE
,
13297 &no_neighbor_remove_private_as_replace_as_cmd
);
13298 install_element(BGP_IPV4L_NODE
,
13299 &neighbor_remove_private_as_all_replace_as_cmd
);
13300 install_element(BGP_IPV4L_NODE
,
13301 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13302 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
13303 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13304 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13305 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13306 install_element(BGP_IPV6_NODE
,
13307 &neighbor_remove_private_as_replace_as_cmd
);
13308 install_element(BGP_IPV6_NODE
,
13309 &no_neighbor_remove_private_as_replace_as_cmd
);
13310 install_element(BGP_IPV6_NODE
,
13311 &neighbor_remove_private_as_all_replace_as_cmd
);
13312 install_element(BGP_IPV6_NODE
,
13313 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13314 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
13315 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
13316 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
13317 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13318 install_element(BGP_IPV6M_NODE
,
13319 &neighbor_remove_private_as_replace_as_cmd
);
13320 install_element(BGP_IPV6M_NODE
,
13321 &no_neighbor_remove_private_as_replace_as_cmd
);
13322 install_element(BGP_IPV6M_NODE
,
13323 &neighbor_remove_private_as_all_replace_as_cmd
);
13324 install_element(BGP_IPV6M_NODE
,
13325 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13326 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
13327 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
13328 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
13329 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13330 install_element(BGP_IPV6L_NODE
,
13331 &neighbor_remove_private_as_replace_as_cmd
);
13332 install_element(BGP_IPV6L_NODE
,
13333 &no_neighbor_remove_private_as_replace_as_cmd
);
13334 install_element(BGP_IPV6L_NODE
,
13335 &neighbor_remove_private_as_all_replace_as_cmd
);
13336 install_element(BGP_IPV6L_NODE
,
13337 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13338 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
13339 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13340 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13341 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13342 install_element(BGP_VPNV4_NODE
,
13343 &neighbor_remove_private_as_replace_as_cmd
);
13344 install_element(BGP_VPNV4_NODE
,
13345 &no_neighbor_remove_private_as_replace_as_cmd
);
13346 install_element(BGP_VPNV4_NODE
,
13347 &neighbor_remove_private_as_all_replace_as_cmd
);
13348 install_element(BGP_VPNV4_NODE
,
13349 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13350 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
13351 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13352 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13353 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13354 install_element(BGP_VPNV6_NODE
,
13355 &neighbor_remove_private_as_replace_as_cmd
);
13356 install_element(BGP_VPNV6_NODE
,
13357 &no_neighbor_remove_private_as_replace_as_cmd
);
13358 install_element(BGP_VPNV6_NODE
,
13359 &neighbor_remove_private_as_all_replace_as_cmd
);
13360 install_element(BGP_VPNV6_NODE
,
13361 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13363 /* "neighbor send-community" commands.*/
13364 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
13365 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
13366 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
13367 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
13368 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
13369 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
13370 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
13371 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
13372 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
13373 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
13374 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
13375 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
13376 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
13377 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
13378 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
13379 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
13380 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
13381 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
13382 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
13383 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
13384 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
13385 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
13386 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
13387 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
13388 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
13389 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
13390 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
13391 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
13392 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
13393 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
13394 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
13395 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
13396 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
13397 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
13398 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
13399 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
13401 /* "neighbor route-reflector" commands.*/
13402 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
13403 install_element(BGP_NODE
,
13404 &no_neighbor_route_reflector_client_hidden_cmd
);
13405 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
13406 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
13407 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
13408 install_element(BGP_IPV4M_NODE
,
13409 &no_neighbor_route_reflector_client_cmd
);
13410 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
13411 install_element(BGP_IPV4L_NODE
,
13412 &no_neighbor_route_reflector_client_cmd
);
13413 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
13414 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
13415 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
13416 install_element(BGP_IPV6M_NODE
,
13417 &no_neighbor_route_reflector_client_cmd
);
13418 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
13419 install_element(BGP_IPV6L_NODE
,
13420 &no_neighbor_route_reflector_client_cmd
);
13421 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
13422 install_element(BGP_VPNV4_NODE
,
13423 &no_neighbor_route_reflector_client_cmd
);
13424 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
13425 install_element(BGP_VPNV6_NODE
,
13426 &no_neighbor_route_reflector_client_cmd
);
13427 install_element(BGP_FLOWSPECV4_NODE
,
13428 &neighbor_route_reflector_client_cmd
);
13429 install_element(BGP_FLOWSPECV4_NODE
,
13430 &no_neighbor_route_reflector_client_cmd
);
13431 install_element(BGP_FLOWSPECV6_NODE
,
13432 &neighbor_route_reflector_client_cmd
);
13433 install_element(BGP_FLOWSPECV6_NODE
,
13434 &no_neighbor_route_reflector_client_cmd
);
13435 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
13436 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
13438 /* "neighbor route-server" commands.*/
13439 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
13440 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
13441 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
13442 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
13443 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
13444 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
13445 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
13446 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
13447 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
13448 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
13449 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
13450 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
13451 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
13452 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
13453 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
13454 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
13455 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
13456 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
13457 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
13458 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
13459 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
13460 install_element(BGP_FLOWSPECV4_NODE
,
13461 &no_neighbor_route_server_client_cmd
);
13462 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
13463 install_element(BGP_FLOWSPECV6_NODE
,
13464 &no_neighbor_route_server_client_cmd
);
13466 /* "neighbor addpath-tx-all-paths" commands.*/
13467 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
13468 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
13469 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13470 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13471 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13472 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13473 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13474 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13475 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13476 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13477 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13478 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13479 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13480 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13481 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13482 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13483 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13484 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13486 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
13487 install_element(BGP_NODE
,
13488 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13489 install_element(BGP_NODE
,
13490 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13491 install_element(BGP_IPV4_NODE
,
13492 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13493 install_element(BGP_IPV4_NODE
,
13494 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13495 install_element(BGP_IPV4M_NODE
,
13496 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13497 install_element(BGP_IPV4M_NODE
,
13498 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13499 install_element(BGP_IPV4L_NODE
,
13500 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13501 install_element(BGP_IPV4L_NODE
,
13502 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13503 install_element(BGP_IPV6_NODE
,
13504 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13505 install_element(BGP_IPV6_NODE
,
13506 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13507 install_element(BGP_IPV6M_NODE
,
13508 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13509 install_element(BGP_IPV6M_NODE
,
13510 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13511 install_element(BGP_IPV6L_NODE
,
13512 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13513 install_element(BGP_IPV6L_NODE
,
13514 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13515 install_element(BGP_VPNV4_NODE
,
13516 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13517 install_element(BGP_VPNV4_NODE
,
13518 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13519 install_element(BGP_VPNV6_NODE
,
13520 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13521 install_element(BGP_VPNV6_NODE
,
13522 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13524 /* "neighbor passive" commands. */
13525 install_element(BGP_NODE
, &neighbor_passive_cmd
);
13526 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13529 /* "neighbor shutdown" commands. */
13530 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13531 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13532 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13533 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13535 /* "neighbor capability extended-nexthop" commands.*/
13536 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13537 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13539 /* "neighbor capability orf prefix-list" commands.*/
13540 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13541 install_element(BGP_NODE
,
13542 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13543 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13544 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13545 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13546 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13547 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13548 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13549 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13550 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13551 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13552 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13553 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13554 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13556 /* "neighbor capability dynamic" commands.*/
13557 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13558 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13560 /* "neighbor dont-capability-negotiate" commands. */
13561 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13562 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13564 /* "neighbor ebgp-multihop" commands. */
13565 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13566 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13567 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13569 /* "neighbor disable-connected-check" commands. */
13570 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13571 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13573 /* "neighbor enforce-first-as" commands. */
13574 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13575 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13577 /* "neighbor description" commands. */
13578 install_element(BGP_NODE
, &neighbor_description_cmd
);
13579 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13580 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13582 /* "neighbor update-source" commands. "*/
13583 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13584 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13586 /* "neighbor default-originate" commands. */
13587 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13588 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13589 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13590 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13591 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13592 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13593 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13594 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13595 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13596 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13597 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13598 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13599 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13600 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13601 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13602 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13603 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13604 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13605 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13606 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13607 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13609 /* "neighbor port" commands. */
13610 install_element(BGP_NODE
, &neighbor_port_cmd
);
13611 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13613 /* "neighbor weight" commands. */
13614 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13615 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13617 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13618 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13619 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13620 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13621 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13622 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13623 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13624 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13625 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13626 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13627 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13628 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13629 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13630 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13631 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13632 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13634 /* "neighbor override-capability" commands. */
13635 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13636 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13638 /* "neighbor strict-capability-match" commands. */
13639 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13640 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13642 /* "neighbor timers" commands. */
13643 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13644 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13646 /* "neighbor timers connect" commands. */
13647 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13648 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13650 /* "neighbor advertisement-interval" commands. */
13651 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13652 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13654 /* "neighbor interface" commands. */
13655 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13656 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13658 /* "neighbor distribute" commands. */
13659 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13660 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13661 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13662 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13663 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13664 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13665 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13666 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13667 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13668 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13669 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13670 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13671 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13672 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13673 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13674 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13675 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13676 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13678 /* "neighbor prefix-list" commands. */
13679 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13680 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13681 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13682 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13683 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13684 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13685 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13686 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13687 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13688 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13689 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13690 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13691 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13692 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13693 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13694 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13695 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13696 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13697 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13698 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13699 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13700 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13702 /* "neighbor filter-list" commands. */
13703 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13704 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13705 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13706 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13707 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13708 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13709 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13710 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13711 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13712 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13713 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13714 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13715 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13716 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13717 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13718 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13719 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13720 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13721 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13722 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13723 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13724 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13726 /* "neighbor route-map" commands. */
13727 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13728 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13729 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13730 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13731 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13732 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13733 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13734 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13735 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13736 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13737 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13738 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13739 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13740 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13741 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13742 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13743 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13744 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13745 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13746 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13747 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13748 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13749 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13750 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13752 /* "neighbor unsuppress-map" commands. */
13753 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13754 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13755 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13756 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13757 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13758 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13759 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13760 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13761 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13762 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13763 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13764 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13765 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13766 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13767 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13768 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13769 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13770 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13772 /* "neighbor maximum-prefix" commands. */
13773 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13774 install_element(BGP_NODE
,
13775 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13776 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13777 install_element(BGP_NODE
,
13778 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13779 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13780 install_element(BGP_NODE
,
13781 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13782 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13783 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13784 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13785 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13786 install_element(BGP_IPV4_NODE
,
13787 &neighbor_maximum_prefix_threshold_warning_cmd
);
13788 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13789 install_element(BGP_IPV4_NODE
,
13790 &neighbor_maximum_prefix_threshold_restart_cmd
);
13791 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13792 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13793 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13794 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13795 install_element(BGP_IPV4M_NODE
,
13796 &neighbor_maximum_prefix_threshold_warning_cmd
);
13797 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13798 install_element(BGP_IPV4M_NODE
,
13799 &neighbor_maximum_prefix_threshold_restart_cmd
);
13800 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13801 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13802 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13803 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13804 install_element(BGP_IPV4L_NODE
,
13805 &neighbor_maximum_prefix_threshold_warning_cmd
);
13806 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13807 install_element(BGP_IPV4L_NODE
,
13808 &neighbor_maximum_prefix_threshold_restart_cmd
);
13809 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13810 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13811 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13812 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13813 install_element(BGP_IPV6_NODE
,
13814 &neighbor_maximum_prefix_threshold_warning_cmd
);
13815 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13816 install_element(BGP_IPV6_NODE
,
13817 &neighbor_maximum_prefix_threshold_restart_cmd
);
13818 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13819 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13820 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13821 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13822 install_element(BGP_IPV6M_NODE
,
13823 &neighbor_maximum_prefix_threshold_warning_cmd
);
13824 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13825 install_element(BGP_IPV6M_NODE
,
13826 &neighbor_maximum_prefix_threshold_restart_cmd
);
13827 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13828 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13829 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13830 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13831 install_element(BGP_IPV6L_NODE
,
13832 &neighbor_maximum_prefix_threshold_warning_cmd
);
13833 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13834 install_element(BGP_IPV6L_NODE
,
13835 &neighbor_maximum_prefix_threshold_restart_cmd
);
13836 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13837 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13838 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13839 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13840 install_element(BGP_VPNV4_NODE
,
13841 &neighbor_maximum_prefix_threshold_warning_cmd
);
13842 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13843 install_element(BGP_VPNV4_NODE
,
13844 &neighbor_maximum_prefix_threshold_restart_cmd
);
13845 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13846 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13847 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13848 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13849 install_element(BGP_VPNV6_NODE
,
13850 &neighbor_maximum_prefix_threshold_warning_cmd
);
13851 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13852 install_element(BGP_VPNV6_NODE
,
13853 &neighbor_maximum_prefix_threshold_restart_cmd
);
13854 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13856 /* "neighbor allowas-in" */
13857 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13858 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13859 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13860 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13861 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13862 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13863 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13864 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13865 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13866 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13867 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13868 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13869 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13870 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13871 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13872 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13873 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13874 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13875 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13876 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13878 /* address-family commands. */
13879 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13880 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13881 #ifdef KEEP_OLD_VPN_COMMANDS
13882 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13883 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13884 #endif /* KEEP_OLD_VPN_COMMANDS */
13886 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13888 /* "exit-address-family" command. */
13889 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13890 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13891 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13892 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13893 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13894 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13895 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13896 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13897 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13898 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13899 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13901 /* "clear ip bgp commands" */
13902 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13904 /* clear ip bgp prefix */
13905 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13906 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13907 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13909 /* "show [ip] bgp summary" commands. */
13910 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13911 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
13912 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13913 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13914 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13915 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13916 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
13918 /* "show [ip] bgp neighbors" commands. */
13919 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
13921 /* "show [ip] bgp peer-group" commands. */
13922 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
13924 /* "show [ip] bgp paths" commands. */
13925 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
13927 /* "show [ip] bgp community" commands. */
13928 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
13930 /* "show ip bgp large-community" commands. */
13931 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
13932 /* "show [ip] bgp attribute-info" commands. */
13933 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
13934 /* "show [ip] bgp route-leak" command */
13935 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
13937 /* "redistribute" commands. */
13938 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
13939 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
13940 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
13941 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
13942 install_element(BGP_NODE
,
13943 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
13944 install_element(BGP_NODE
,
13945 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
13946 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
13947 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
13948 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
13949 install_element(BGP_NODE
,
13950 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
13951 install_element(BGP_NODE
,
13952 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
13953 install_element(BGP_NODE
,
13954 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
13955 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
13956 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
13957 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
13958 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
13959 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
13960 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
13961 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
13962 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
13963 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
13964 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
13965 install_element(BGP_IPV4_NODE
,
13966 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
13967 install_element(BGP_IPV4_NODE
,
13968 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
13969 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
13970 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
13971 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
13972 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
13973 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
13974 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
13976 /* import|export vpn [route-map WORD] */
13977 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
13978 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
13980 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
13981 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
13983 /* ttl_security commands */
13984 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
13985 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
13987 /* "show [ip] bgp memory" commands. */
13988 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
13990 /* "show bgp martian next-hop" */
13991 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
13993 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
13995 /* "show [ip] bgp views" commands. */
13996 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
13998 /* "show [ip] bgp vrfs" commands. */
13999 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
14001 /* Community-list. */
14002 community_list_vty();
14004 /* vpn-policy commands */
14005 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
14006 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
14007 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
14008 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
14009 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
14010 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
14011 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
14012 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
14013 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
14014 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
14015 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
14016 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
14018 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
14019 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
14021 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
14022 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
14023 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
14024 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
14025 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
14026 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
14027 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
14028 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
14029 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14030 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14031 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
14032 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
14035 #include "memory.h"
14036 #include "bgp_regex.h"
14037 #include "bgp_clist.h"
14038 #include "bgp_ecommunity.h"
14040 /* VTY functions. */
14042 /* Direction value to string conversion. */
14043 static const char *community_direct_str(int direct
)
14046 case COMMUNITY_DENY
:
14048 case COMMUNITY_PERMIT
:
14055 /* Display error string. */
14056 static void community_list_perror(struct vty
*vty
, int ret
)
14059 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
14060 vty_out(vty
, "%% Can't find community-list\n");
14062 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
14063 vty_out(vty
, "%% Malformed community-list value\n");
14065 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
14067 "%% Community name conflict, previously defined as standard community\n");
14069 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
14071 "%% Community name conflict, previously defined as expanded community\n");
14076 /* "community-list" keyword help string. */
14077 #define COMMUNITY_LIST_STR "Add a community list entry\n"
14079 /*community-list standard */
14080 DEFUN (community_list_standard
,
14081 bgp_community_list_standard_cmd
,
14082 "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14085 "Community list number (standard)\n"
14086 "Add an standard community-list entry\n"
14087 "Community list name\n"
14088 "Specify community to reject\n"
14089 "Specify community to accept\n"
14092 char *cl_name_or_number
= NULL
;
14094 int style
= COMMUNITY_LIST_STANDARD
;
14098 if (argv_find(argv
, argc
, "ip", &idx
)) {
14099 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14100 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14101 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14102 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14105 argv_find(argv
, argc
, "(1-99)", &idx
);
14106 argv_find(argv
, argc
, "WORD", &idx
);
14107 cl_name_or_number
= argv
[idx
]->arg
;
14108 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14110 argv_find(argv
, argc
, "AA:NN", &idx
);
14111 char *str
= argv_concat(argv
, argc
, idx
);
14113 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14116 XFREE(MTYPE_TMP
, str
);
14119 /* Display error string. */
14120 community_list_perror(vty
, ret
);
14121 return CMD_WARNING_CONFIG_FAILED
;
14124 return CMD_SUCCESS
;
14127 #if CONFDATE > 20191005
14128 CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command")
14130 ALIAS (community_list_standard
,
14131 ip_community_list_standard_cmd
,
14132 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14135 "Community list number (standard)\n"
14136 "Add an standard community-list entry\n"
14137 "Community list name\n"
14138 "Specify community to reject\n"
14139 "Specify community to accept\n"
14142 DEFUN (no_community_list_standard_all
,
14143 no_bgp_community_list_standard_all_cmd
,
14144 "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14148 "Community list number (standard)\n"
14149 "Add an standard community-list entry\n"
14150 "Community list name\n"
14151 "Specify community to reject\n"
14152 "Specify community to accept\n"
14155 char *cl_name_or_number
= NULL
;
14158 int style
= COMMUNITY_LIST_STANDARD
;
14162 if (argv_find(argv
, argc
, "ip", &idx
)) {
14163 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
14164 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14165 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14166 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used");
14169 argv_find(argv
, argc
, "permit", &idx
);
14170 argv_find(argv
, argc
, "deny", &idx
);
14173 direct
= argv_find(argv
, argc
, "permit", &idx
)
14178 argv_find(argv
, argc
, "AA:NN", &idx
);
14179 str
= argv_concat(argv
, argc
, idx
);
14183 argv_find(argv
, argc
, "(1-99)", &idx
);
14184 argv_find(argv
, argc
, "WORD", &idx
);
14185 cl_name_or_number
= argv
[idx
]->arg
;
14187 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14190 XFREE(MTYPE_TMP
, str
);
14193 community_list_perror(vty
, ret
);
14194 return CMD_WARNING_CONFIG_FAILED
;
14197 return CMD_SUCCESS
;
14199 ALIAS (no_community_list_standard_all
,
14200 no_ip_community_list_standard_all_cmd
,
14201 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14205 "Community list number (standard)\n"
14206 "Add an standard community-list entry\n"
14207 "Community list name\n"
14208 "Specify community to reject\n"
14209 "Specify community to accept\n"
14212 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
14213 "no bgp community-list <(1-99)|standard WORD>",
14214 NO_STR BGP_STR COMMUNITY_LIST_STR
14215 "Community list number (standard)\n"
14216 "Add an standard community-list entry\n"
14217 "Community list name\n")
14219 ALIAS(no_community_list_standard_all
, no_ip_community_list_standard_all_list_cmd
,
14220 "no ip community-list <(1-99)|standard WORD>",
14221 NO_STR BGP_STR COMMUNITY_LIST_STR
14222 "Community list number (standard)\n"
14223 "Add an standard community-list entry\n"
14224 "Community list name\n")
14226 /*community-list expanded */
14227 DEFUN (community_list_expanded_all
,
14228 bgp_community_list_expanded_all_cmd
,
14229 "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14232 "Community list number (expanded)\n"
14233 "Add an expanded community-list entry\n"
14234 "Community list name\n"
14235 "Specify community to reject\n"
14236 "Specify community to accept\n"
14239 char *cl_name_or_number
= NULL
;
14241 int style
= COMMUNITY_LIST_EXPANDED
;
14244 if (argv_find(argv
, argc
, "ip", &idx
)) {
14245 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14246 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14247 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14248 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14250 argv_find(argv
, argc
, "(100-500)", &idx
);
14251 argv_find(argv
, argc
, "WORD", &idx
);
14252 cl_name_or_number
= argv
[idx
]->arg
;
14253 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14255 argv_find(argv
, argc
, "AA:NN", &idx
);
14256 char *str
= argv_concat(argv
, argc
, idx
);
14258 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14261 XFREE(MTYPE_TMP
, str
);
14264 /* Display error string. */
14265 community_list_perror(vty
, ret
);
14266 return CMD_WARNING_CONFIG_FAILED
;
14269 return CMD_SUCCESS
;
14272 ALIAS (community_list_expanded_all
,
14273 ip_community_list_expanded_all_cmd
,
14274 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14277 "Community list number (expanded)\n"
14278 "Add an expanded community-list entry\n"
14279 "Community list name\n"
14280 "Specify community to reject\n"
14281 "Specify community to accept\n"
14284 DEFUN (no_community_list_expanded_all
,
14285 no_bgp_community_list_expanded_all_cmd
,
14286 "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14290 "Community list number (expanded)\n"
14291 "Add an expanded community-list entry\n"
14292 "Community list name\n"
14293 "Specify community to reject\n"
14294 "Specify community to accept\n"
14297 char *cl_name_or_number
= NULL
;
14300 int style
= COMMUNITY_LIST_EXPANDED
;
14303 if (argv_find(argv
, argc
, "ip", &idx
)) {
14304 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14305 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14306 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14307 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14311 argv_find(argv
, argc
, "permit", &idx
);
14312 argv_find(argv
, argc
, "deny", &idx
);
14315 direct
= argv_find(argv
, argc
, "permit", &idx
)
14320 argv_find(argv
, argc
, "AA:NN", &idx
);
14321 str
= argv_concat(argv
, argc
, idx
);
14325 argv_find(argv
, argc
, "(100-500)", &idx
);
14326 argv_find(argv
, argc
, "WORD", &idx
);
14327 cl_name_or_number
= argv
[idx
]->arg
;
14329 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14332 XFREE(MTYPE_TMP
, str
);
14335 community_list_perror(vty
, ret
);
14336 return CMD_WARNING_CONFIG_FAILED
;
14339 return CMD_SUCCESS
;
14342 ALIAS (no_community_list_expanded_all
,
14343 no_ip_community_list_expanded_all_cmd
,
14344 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14348 "Community list number (expanded)\n"
14349 "Add an expanded community-list entry\n"
14350 "Community list name\n"
14351 "Specify community to reject\n"
14352 "Specify community to accept\n"
14355 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
14356 "no bgp community-list <(100-500)|expanded WORD>",
14357 NO_STR IP_STR COMMUNITY_LIST_STR
14358 "Community list number (expanded)\n"
14359 "Add an expanded community-list entry\n"
14360 "Community list name\n")
14362 ALIAS(no_community_list_expanded_all
, no_ip_community_list_expanded_all_list_cmd
,
14363 "no ip community-list <(100-500)|expanded WORD>",
14364 NO_STR IP_STR COMMUNITY_LIST_STR
14365 "Community list number (expanded)\n"
14366 "Add an expanded community-list entry\n"
14367 "Community list name\n")
14369 /* Return configuration string of community-list entry. */
14370 static const char *community_list_config_str(struct community_entry
*entry
)
14377 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
14378 str
= community_str(entry
->u
.com
, false);
14379 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
14380 str
= lcommunity_str(entry
->u
.lcom
, false);
14382 str
= entry
->config
;
14387 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
14389 struct community_entry
*entry
;
14391 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14392 if (entry
== list
->head
) {
14393 if (all_digit(list
->name
))
14394 vty_out(vty
, "Community %s list %s\n",
14395 entry
->style
== COMMUNITY_LIST_STANDARD
14397 : "(expanded) access",
14400 vty_out(vty
, "Named Community %s list %s\n",
14401 entry
->style
== COMMUNITY_LIST_STANDARD
14407 vty_out(vty
, " %s\n",
14408 community_direct_str(entry
->direct
));
14410 vty_out(vty
, " %s %s\n",
14411 community_direct_str(entry
->direct
),
14412 community_list_config_str(entry
));
14416 DEFUN (show_community_list
,
14417 show_bgp_community_list_cmd
,
14418 "show bgp community-list",
14421 "List community-list\n")
14423 struct community_list
*list
;
14424 struct community_list_master
*cm
;
14427 if (argv_find(argv
, argc
, "ip", &idx
)) {
14428 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14429 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14430 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14431 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14433 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14435 return CMD_SUCCESS
;
14437 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14438 community_list_show(vty
, list
);
14440 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14441 community_list_show(vty
, list
);
14443 return CMD_SUCCESS
;
14446 ALIAS (show_community_list
,
14447 show_ip_community_list_cmd
,
14448 "show ip community-list",
14451 "List community-list\n")
14453 DEFUN (show_community_list_arg
,
14454 show_bgp_community_list_arg_cmd
,
14455 "show bgp community-list <(1-500)|WORD>",
14458 "List community-list\n"
14459 "Community-list number\n"
14460 "Community-list name\n")
14462 int idx_comm_list
= 3;
14463 struct community_list
*list
;
14466 if (argv_find(argv
, argc
, "ip", &idx
)) {
14467 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14468 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14469 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14470 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14472 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
14473 COMMUNITY_LIST_MASTER
);
14475 vty_out(vty
, "%% Can't find community-list\n");
14476 return CMD_WARNING
;
14479 community_list_show(vty
, list
);
14481 return CMD_SUCCESS
;
14484 ALIAS (show_community_list_arg
,
14485 show_ip_community_list_arg_cmd
,
14486 "show ip community-list <(1-500)|WORD>",
14489 "List community-list\n"
14490 "Community-list number\n"
14491 "Community-list name\n")
14494 * Large Community code.
14496 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
14497 struct cmd_token
**argv
, int style
,
14498 int reject_all_digit_name
)
14506 if (argv_find(argv
, argc
, "ip", &idx
)) {
14507 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14508 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14509 vty_out(vty
, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14510 zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14512 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14515 /* All digit name check. */
14517 argv_find(argv
, argc
, "WORD", &idx
);
14518 argv_find(argv
, argc
, "(1-99)", &idx
);
14519 argv_find(argv
, argc
, "(100-500)", &idx
);
14520 cl_name
= argv
[idx
]->arg
;
14521 if (reject_all_digit_name
&& all_digit(cl_name
)) {
14522 vty_out(vty
, "%% Community name cannot have all digits\n");
14523 return CMD_WARNING_CONFIG_FAILED
;
14527 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
14528 argv_find(argv
, argc
, "LINE", &idx
);
14529 /* Concat community string argument. */
14531 str
= argv_concat(argv
, argc
, idx
);
14535 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
14537 /* Free temporary community list string allocated by
14539 XFREE(MTYPE_TMP
, str
);
14542 community_list_perror(vty
, ret
);
14543 return CMD_WARNING_CONFIG_FAILED
;
14545 return CMD_SUCCESS
;
14548 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
14549 struct cmd_token
**argv
, int style
)
14556 if (argv_find(argv
, argc
, "ip", &idx
)) {
14557 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14558 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14559 vty_out(vty
, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14560 zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14562 argv_find(argv
, argc
, "permit", &idx
);
14563 argv_find(argv
, argc
, "deny", &idx
);
14566 /* Check the list direct. */
14567 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
14568 direct
= COMMUNITY_PERMIT
;
14570 direct
= COMMUNITY_DENY
;
14573 argv_find(argv
, argc
, "LINE", &idx
);
14574 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
14575 /* Concat community string argument. */
14576 str
= argv_concat(argv
, argc
, idx
);
14580 argv_find(argv
, argc
, "(1-99)", &idx
);
14581 argv_find(argv
, argc
, "(100-500)", &idx
);
14582 argv_find(argv
, argc
, "WORD", &idx
);
14584 /* Unset community list. */
14585 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
14588 /* Free temporary community list string allocated by
14590 XFREE(MTYPE_TMP
, str
);
14593 community_list_perror(vty
, ret
);
14594 return CMD_WARNING_CONFIG_FAILED
;
14597 return CMD_SUCCESS
;
14600 /* "large-community-list" keyword help string. */
14601 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
14602 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
14604 #if CONFDATE > 20191005
14605 CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command")
14607 DEFUN (lcommunity_list_standard
,
14608 bgp_lcommunity_list_standard_cmd
,
14609 "bgp large-community-list (1-99) <deny|permit>",
14611 LCOMMUNITY_LIST_STR
14612 "Large Community list number (standard)\n"
14613 "Specify large community to reject\n"
14614 "Specify large community to accept\n")
14616 return lcommunity_list_set_vty(vty
, argc
, argv
,
14617 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14620 ALIAS (lcommunity_list_standard
,
14621 ip_lcommunity_list_standard_cmd
,
14622 "ip large-community-list (1-99) <deny|permit>",
14624 LCOMMUNITY_LIST_STR
14625 "Large Community list number (standard)\n"
14626 "Specify large community to reject\n"
14627 "Specify large community to accept\n")
14629 DEFUN (lcommunity_list_standard1
,
14630 bgp_lcommunity_list_standard1_cmd
,
14631 "bgp 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 return lcommunity_list_set_vty(vty
, argc
, argv
,
14640 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14643 ALIAS (lcommunity_list_standard1
,
14644 ip_lcommunity_list_standard1_cmd
,
14645 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
14647 LCOMMUNITY_LIST_STR
14648 "Large Community list number (standard)\n"
14649 "Specify large community to reject\n"
14650 "Specify large community to accept\n"
14651 LCOMMUNITY_VAL_STR
)
14653 DEFUN (lcommunity_list_expanded
,
14654 bgp_lcommunity_list_expanded_cmd
,
14655 "bgp 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 return lcommunity_list_set_vty(vty
, argc
, argv
,
14664 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
14667 ALIAS (lcommunity_list_expanded
,
14668 ip_lcommunity_list_expanded_cmd
,
14669 "ip large-community-list (100-500) <deny|permit> LINE...",
14671 LCOMMUNITY_LIST_STR
14672 "Large Community list number (expanded)\n"
14673 "Specify large community to reject\n"
14674 "Specify large community to accept\n"
14675 "An ordered list as a regular-expression\n")
14677 DEFUN (lcommunity_list_name_standard
,
14678 bgp_lcommunity_list_name_standard_cmd
,
14679 "bgp 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 return lcommunity_list_set_vty(vty
, argc
, argv
,
14688 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14691 ALIAS (lcommunity_list_name_standard
,
14692 ip_lcommunity_list_name_standard_cmd
,
14693 "ip large-community-list standard WORD <deny|permit>",
14695 LCOMMUNITY_LIST_STR
14696 "Specify standard large-community-list\n"
14697 "Large Community list name\n"
14698 "Specify large community to reject\n"
14699 "Specify large community to accept\n")
14701 DEFUN (lcommunity_list_name_standard1
,
14702 bgp_lcommunity_list_name_standard1_cmd
,
14703 "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
14705 LCOMMUNITY_LIST_STR
14706 "Specify standard large-community-list\n"
14707 "Large Community list name\n"
14708 "Specify large community to reject\n"
14709 "Specify large community to accept\n"
14710 LCOMMUNITY_VAL_STR
)
14712 return lcommunity_list_set_vty(vty
, argc
, argv
,
14713 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14716 ALIAS (lcommunity_list_name_standard1
,
14717 ip_lcommunity_list_name_standard1_cmd
,
14718 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
14720 LCOMMUNITY_LIST_STR
14721 "Specify standard large-community-list\n"
14722 "Large Community list name\n"
14723 "Specify large community to reject\n"
14724 "Specify large community to accept\n"
14725 LCOMMUNITY_VAL_STR
)
14727 DEFUN (lcommunity_list_name_expanded
,
14728 bgp_lcommunity_list_name_expanded_cmd
,
14729 "bgp large-community-list expanded WORD <deny|permit> LINE...",
14731 LCOMMUNITY_LIST_STR
14732 "Specify expanded large-community-list\n"
14733 "Large Community list name\n"
14734 "Specify large community to reject\n"
14735 "Specify large community to accept\n"
14736 "An ordered list as a regular-expression\n")
14738 return lcommunity_list_set_vty(vty
, argc
, argv
,
14739 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
14742 ALIAS (lcommunity_list_name_expanded
,
14743 ip_lcommunity_list_name_expanded_cmd
,
14744 "ip large-community-list expanded WORD <deny|permit> LINE...",
14746 LCOMMUNITY_LIST_STR
14747 "Specify expanded large-community-list\n"
14748 "Large Community list name\n"
14749 "Specify large community to reject\n"
14750 "Specify large community to accept\n"
14751 "An ordered list as a regular-expression\n")
14753 DEFUN (no_lcommunity_list_standard_all
,
14754 no_bgp_lcommunity_list_standard_all_cmd
,
14755 "no bgp 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 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14764 LARGE_COMMUNITY_LIST_STANDARD
);
14767 ALIAS (no_lcommunity_list_standard_all
,
14768 no_ip_lcommunity_list_standard_all_cmd
,
14769 "no ip large-community-list <(1-99)|(100-500)|WORD>",
14772 LCOMMUNITY_LIST_STR
14773 "Large Community list number (standard)\n"
14774 "Large Community list number (expanded)\n"
14775 "Large Community list name\n")
14777 DEFUN (no_lcommunity_list_name_expanded_all
,
14778 no_bgp_lcommunity_list_name_expanded_all_cmd
,
14779 "no bgp large-community-list expanded WORD",
14782 LCOMMUNITY_LIST_STR
14783 "Specify expanded large-community-list\n"
14784 "Large Community list name\n")
14786 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14787 LARGE_COMMUNITY_LIST_EXPANDED
);
14790 ALIAS (no_lcommunity_list_name_expanded_all
,
14791 no_ip_lcommunity_list_name_expanded_all_cmd
,
14792 "no ip large-community-list expanded WORD",
14795 LCOMMUNITY_LIST_STR
14796 "Specify expanded large-community-list\n"
14797 "Large Community list name\n")
14799 DEFUN (no_lcommunity_list_standard
,
14800 no_bgp_lcommunity_list_standard_cmd
,
14801 "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
14804 LCOMMUNITY_LIST_STR
14805 "Large Community list number (standard)\n"
14806 "Specify large community to reject\n"
14807 "Specify large community to accept\n"
14808 LCOMMUNITY_VAL_STR
)
14810 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14811 LARGE_COMMUNITY_LIST_STANDARD
);
14814 ALIAS (no_lcommunity_list_standard
,
14815 no_ip_lcommunity_list_standard_cmd
,
14816 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
14819 LCOMMUNITY_LIST_STR
14820 "Large Community list number (standard)\n"
14821 "Specify large community to reject\n"
14822 "Specify large community to accept\n"
14823 LCOMMUNITY_VAL_STR
)
14825 DEFUN (no_lcommunity_list_expanded
,
14826 no_bgp_lcommunity_list_expanded_cmd
,
14827 "no bgp large-community-list (100-500) <deny|permit> LINE...",
14830 LCOMMUNITY_LIST_STR
14831 "Large Community list number (expanded)\n"
14832 "Specify large community to reject\n"
14833 "Specify large community to accept\n"
14834 "An ordered list as a regular-expression\n")
14836 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14837 LARGE_COMMUNITY_LIST_EXPANDED
);
14840 ALIAS (no_lcommunity_list_expanded
,
14841 no_ip_lcommunity_list_expanded_cmd
,
14842 "no ip large-community-list (100-500) <deny|permit> LINE...",
14845 LCOMMUNITY_LIST_STR
14846 "Large Community list number (expanded)\n"
14847 "Specify large community to reject\n"
14848 "Specify large community to accept\n"
14849 "An ordered list as a regular-expression\n")
14851 DEFUN (no_lcommunity_list_name_standard
,
14852 no_bgp_lcommunity_list_name_standard_cmd
,
14853 "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
14856 LCOMMUNITY_LIST_STR
14857 "Specify standard large-community-list\n"
14858 "Large Community list name\n"
14859 "Specify large community to reject\n"
14860 "Specify large community to accept\n"
14861 LCOMMUNITY_VAL_STR
)
14863 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14864 LARGE_COMMUNITY_LIST_STANDARD
);
14867 ALIAS (no_lcommunity_list_name_standard
,
14868 no_ip_lcommunity_list_name_standard_cmd
,
14869 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
14872 LCOMMUNITY_LIST_STR
14873 "Specify standard large-community-list\n"
14874 "Large Community list name\n"
14875 "Specify large community to reject\n"
14876 "Specify large community to accept\n"
14877 LCOMMUNITY_VAL_STR
)
14879 DEFUN (no_lcommunity_list_name_expanded
,
14880 no_bgp_lcommunity_list_name_expanded_cmd
,
14881 "no bgp large-community-list expanded WORD <deny|permit> LINE...",
14884 LCOMMUNITY_LIST_STR
14885 "Specify expanded large-community-list\n"
14886 "Large community list name\n"
14887 "Specify large community to reject\n"
14888 "Specify large community to accept\n"
14889 "An ordered list as a regular-expression\n")
14891 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14892 LARGE_COMMUNITY_LIST_EXPANDED
);
14895 ALIAS (no_lcommunity_list_name_expanded
,
14896 no_ip_lcommunity_list_name_expanded_cmd
,
14897 "no ip large-community-list expanded WORD <deny|permit> LINE...",
14900 LCOMMUNITY_LIST_STR
14901 "Specify expanded large-community-list\n"
14902 "Large community list name\n"
14903 "Specify large community to reject\n"
14904 "Specify large community to accept\n"
14905 "An ordered list as a regular-expression\n")
14907 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14909 struct community_entry
*entry
;
14911 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14912 if (entry
== list
->head
) {
14913 if (all_digit(list
->name
))
14914 vty_out(vty
, "Large community %s list %s\n",
14916 LARGE_COMMUNITY_LIST_STANDARD
14918 : "(expanded) access",
14922 "Named large community %s list %s\n",
14924 LARGE_COMMUNITY_LIST_STANDARD
14930 vty_out(vty
, " %s\n",
14931 community_direct_str(entry
->direct
));
14933 vty_out(vty
, " %s %s\n",
14934 community_direct_str(entry
->direct
),
14935 community_list_config_str(entry
));
14939 DEFUN (show_lcommunity_list
,
14940 show_bgp_lcommunity_list_cmd
,
14941 "show bgp large-community-list",
14944 "List large-community list\n")
14946 struct community_list
*list
;
14947 struct community_list_master
*cm
;
14950 if (argv_find(argv
, argc
, "ip", &idx
)) {
14951 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14952 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14953 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
14954 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
14957 cm
= community_list_master_lookup(bgp_clist
,
14958 LARGE_COMMUNITY_LIST_MASTER
);
14960 return CMD_SUCCESS
;
14962 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14963 lcommunity_list_show(vty
, list
);
14965 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14966 lcommunity_list_show(vty
, list
);
14968 return CMD_SUCCESS
;
14971 ALIAS (show_lcommunity_list
,
14972 show_ip_lcommunity_list_cmd
,
14973 "show ip large-community-list",
14976 "List large-community list\n")
14978 DEFUN (show_lcommunity_list_arg
,
14979 show_bgp_lcommunity_list_arg_cmd
,
14980 "show bgp large-community-list <(1-500)|WORD>",
14983 "List large-community list\n"
14984 "large-community-list number\n"
14985 "large-community-list name\n")
14987 struct community_list
*list
;
14990 if (argv_find(argv
, argc
, "ip", &idx
)) {
14991 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14992 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14993 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
14994 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
14997 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
14998 LARGE_COMMUNITY_LIST_MASTER
);
15000 vty_out(vty
, "%% Can't find extcommunity-list\n");
15001 return CMD_WARNING
;
15004 lcommunity_list_show(vty
, list
);
15006 return CMD_SUCCESS
;
15009 ALIAS (show_lcommunity_list_arg
,
15010 show_ip_lcommunity_list_arg_cmd
,
15011 "show ip large-community-list <(1-500)|WORD>",
15014 "List large-community list\n"
15015 "large-community-list number\n"
15016 "large-community-list name\n")
15018 /* "extcommunity-list" keyword help string. */
15019 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
15020 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
15022 DEFUN (extcommunity_list_standard
,
15023 bgp_extcommunity_list_standard_cmd
,
15024 "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15026 EXTCOMMUNITY_LIST_STR
15027 "Extended Community list number (standard)\n"
15028 "Specify standard extcommunity-list\n"
15029 "Community list name\n"
15030 "Specify community to reject\n"
15031 "Specify community to accept\n"
15032 EXTCOMMUNITY_VAL_STR
)
15034 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15036 char *cl_number_or_name
= NULL
;
15039 if (argv_find(argv
, argc
, "ip", &idx
)) {
15040 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15041 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15042 vty_out(vty
, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15043 zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15045 argv_find(argv
, argc
, "(1-99)", &idx
);
15046 argv_find(argv
, argc
, "WORD", &idx
);
15047 cl_number_or_name
= argv
[idx
]->arg
;
15048 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15050 argv_find(argv
, argc
, "AA:NN", &idx
);
15051 char *str
= argv_concat(argv
, argc
, idx
);
15053 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15056 XFREE(MTYPE_TMP
, str
);
15059 community_list_perror(vty
, ret
);
15060 return CMD_WARNING_CONFIG_FAILED
;
15063 return CMD_SUCCESS
;
15066 #if CONFDATE > 20191005
15067 CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command")
15069 ALIAS (extcommunity_list_standard
,
15070 ip_extcommunity_list_standard_cmd
,
15071 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15073 EXTCOMMUNITY_LIST_STR
15074 "Extended Community list number (standard)\n"
15075 "Specify standard extcommunity-list\n"
15076 "Community list name\n"
15077 "Specify community to reject\n"
15078 "Specify community to accept\n"
15079 EXTCOMMUNITY_VAL_STR
)
15081 DEFUN (extcommunity_list_name_expanded
,
15082 bgp_extcommunity_list_name_expanded_cmd
,
15083 "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15085 EXTCOMMUNITY_LIST_STR
15086 "Extended Community list number (expanded)\n"
15087 "Specify expanded extcommunity-list\n"
15088 "Extended Community list name\n"
15089 "Specify community to reject\n"
15090 "Specify community to accept\n"
15091 "An ordered list as a regular-expression\n")
15093 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15095 char *cl_number_or_name
= NULL
;
15098 if (argv_find(argv
, argc
, "ip", &idx
)) {
15099 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15100 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15101 vty_out(vty
, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15102 zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15105 argv_find(argv
, argc
, "(100-500)", &idx
);
15106 argv_find(argv
, argc
, "WORD", &idx
);
15107 cl_number_or_name
= argv
[idx
]->arg
;
15108 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15110 argv_find(argv
, argc
, "LINE", &idx
);
15111 char *str
= argv_concat(argv
, argc
, idx
);
15113 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15116 XFREE(MTYPE_TMP
, str
);
15119 community_list_perror(vty
, ret
);
15120 return CMD_WARNING_CONFIG_FAILED
;
15123 return CMD_SUCCESS
;
15126 ALIAS (extcommunity_list_name_expanded
,
15127 ip_extcommunity_list_name_expanded_cmd
,
15128 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15130 EXTCOMMUNITY_LIST_STR
15131 "Extended Community list number (expanded)\n"
15132 "Specify expanded extcommunity-list\n"
15133 "Extended Community list name\n"
15134 "Specify community to reject\n"
15135 "Specify community to accept\n"
15136 "An ordered list as a regular-expression\n")
15138 DEFUN (no_extcommunity_list_standard_all
,
15139 no_bgp_extcommunity_list_standard_all_cmd
,
15140 "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15143 EXTCOMMUNITY_LIST_STR
15144 "Extended Community list number (standard)\n"
15145 "Specify standard extcommunity-list\n"
15146 "Community list name\n"
15147 "Specify community to reject\n"
15148 "Specify community to accept\n"
15149 EXTCOMMUNITY_VAL_STR
)
15151 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15153 char *cl_number_or_name
= NULL
;
15157 if (argv_find(argv
, argc
, "ip", &idx
)) {
15158 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15159 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15160 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15161 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15165 argv_find(argv
, argc
, "permit", &idx
);
15166 argv_find(argv
, argc
, "deny", &idx
);
15169 direct
= argv_find(argv
, argc
, "permit", &idx
)
15174 argv_find(argv
, argc
, "AA:NN", &idx
);
15175 str
= argv_concat(argv
, argc
, idx
);
15179 argv_find(argv
, argc
, "(1-99)", &idx
);
15180 argv_find(argv
, argc
, "WORD", &idx
);
15181 cl_number_or_name
= argv
[idx
]->arg
;
15183 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15186 XFREE(MTYPE_TMP
, str
);
15189 community_list_perror(vty
, ret
);
15190 return CMD_WARNING_CONFIG_FAILED
;
15193 return CMD_SUCCESS
;
15196 ALIAS (no_extcommunity_list_standard_all
,
15197 no_ip_extcommunity_list_standard_all_cmd
,
15198 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15201 EXTCOMMUNITY_LIST_STR
15202 "Extended Community list number (standard)\n"
15203 "Specify standard extcommunity-list\n"
15204 "Community list name\n"
15205 "Specify community to reject\n"
15206 "Specify community to accept\n"
15207 EXTCOMMUNITY_VAL_STR
)
15209 ALIAS(no_extcommunity_list_standard_all
,
15210 no_bgp_extcommunity_list_standard_all_list_cmd
,
15211 "no bgp extcommunity-list <(1-99)|standard WORD>",
15212 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15213 "Extended Community list number (standard)\n"
15214 "Specify standard extcommunity-list\n"
15215 "Community list name\n")
15217 ALIAS(no_extcommunity_list_standard_all
,
15218 no_ip_extcommunity_list_standard_all_list_cmd
,
15219 "no ip extcommunity-list <(1-99)|standard WORD>",
15220 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15221 "Extended Community list number (standard)\n"
15222 "Specify standard extcommunity-list\n"
15223 "Community list name\n")
15225 DEFUN (no_extcommunity_list_expanded_all
,
15226 no_bgp_extcommunity_list_expanded_all_cmd
,
15227 "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15230 EXTCOMMUNITY_LIST_STR
15231 "Extended Community list number (expanded)\n"
15232 "Specify expanded extcommunity-list\n"
15233 "Extended Community list name\n"
15234 "Specify community to reject\n"
15235 "Specify community to accept\n"
15236 "An ordered list as a regular-expression\n")
15238 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15240 char *cl_number_or_name
= NULL
;
15244 if (argv_find(argv
, argc
, "ip", &idx
)) {
15245 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15246 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15247 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15248 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15252 argv_find(argv
, argc
, "permit", &idx
);
15253 argv_find(argv
, argc
, "deny", &idx
);
15256 direct
= argv_find(argv
, argc
, "permit", &idx
)
15261 argv_find(argv
, argc
, "LINE", &idx
);
15262 str
= argv_concat(argv
, argc
, idx
);
15266 argv_find(argv
, argc
, "(100-500)", &idx
);
15267 argv_find(argv
, argc
, "WORD", &idx
);
15268 cl_number_or_name
= argv
[idx
]->arg
;
15270 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15273 XFREE(MTYPE_TMP
, str
);
15276 community_list_perror(vty
, ret
);
15277 return CMD_WARNING_CONFIG_FAILED
;
15280 return CMD_SUCCESS
;
15283 ALIAS (no_extcommunity_list_expanded_all
,
15284 no_ip_extcommunity_list_expanded_all_cmd
,
15285 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15288 EXTCOMMUNITY_LIST_STR
15289 "Extended Community list number (expanded)\n"
15290 "Specify expanded extcommunity-list\n"
15291 "Extended Community list name\n"
15292 "Specify community to reject\n"
15293 "Specify community to accept\n"
15294 "An ordered list as a regular-expression\n")
15296 ALIAS(no_extcommunity_list_expanded_all
,
15297 no_ip_extcommunity_list_expanded_all_list_cmd
,
15298 "no ip extcommunity-list <(100-500)|expanded WORD>",
15299 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15300 "Extended Community list number (expanded)\n"
15301 "Specify expanded extcommunity-list\n"
15302 "Extended Community list name\n")
15304 ALIAS(no_extcommunity_list_expanded_all
,
15305 no_bgp_extcommunity_list_expanded_all_list_cmd
,
15306 "no bgp extcommunity-list <(100-500)|expanded WORD>",
15307 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15308 "Extended Community list number (expanded)\n"
15309 "Specify expanded extcommunity-list\n"
15310 "Extended Community list name\n")
15312 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
15314 struct community_entry
*entry
;
15316 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15317 if (entry
== list
->head
) {
15318 if (all_digit(list
->name
))
15319 vty_out(vty
, "Extended community %s list %s\n",
15320 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15322 : "(expanded) access",
15326 "Named extended community %s list %s\n",
15327 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15333 vty_out(vty
, " %s\n",
15334 community_direct_str(entry
->direct
));
15336 vty_out(vty
, " %s %s\n",
15337 community_direct_str(entry
->direct
),
15338 community_list_config_str(entry
));
15342 DEFUN (show_extcommunity_list
,
15343 show_bgp_extcommunity_list_cmd
,
15344 "show bgp extcommunity-list",
15347 "List extended-community list\n")
15349 struct community_list
*list
;
15350 struct community_list_master
*cm
;
15353 if (argv_find(argv
, argc
, "ip", &idx
)) {
15354 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15355 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15356 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15357 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15359 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15361 return CMD_SUCCESS
;
15363 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15364 extcommunity_list_show(vty
, list
);
15366 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15367 extcommunity_list_show(vty
, list
);
15369 return CMD_SUCCESS
;
15372 ALIAS (show_extcommunity_list
,
15373 show_ip_extcommunity_list_cmd
,
15374 "show ip extcommunity-list",
15377 "List extended-community list\n")
15379 DEFUN (show_extcommunity_list_arg
,
15380 show_bgp_extcommunity_list_arg_cmd
,
15381 "show bgp extcommunity-list <(1-500)|WORD>",
15384 "List extended-community list\n"
15385 "Extcommunity-list number\n"
15386 "Extcommunity-list name\n")
15388 int idx_comm_list
= 3;
15389 struct community_list
*list
;
15392 if (argv_find(argv
, argc
, "ip", &idx
)) {
15393 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15394 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15395 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15396 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15398 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
15399 EXTCOMMUNITY_LIST_MASTER
);
15401 vty_out(vty
, "%% Can't find extcommunity-list\n");
15402 return CMD_WARNING
;
15405 extcommunity_list_show(vty
, list
);
15407 return CMD_SUCCESS
;
15410 ALIAS (show_extcommunity_list_arg
,
15411 show_ip_extcommunity_list_arg_cmd
,
15412 "show ip extcommunity-list <(1-500)|WORD>",
15415 "List extended-community list\n"
15416 "Extcommunity-list number\n"
15417 "Extcommunity-list name\n")
15419 /* Display community-list and extcommunity-list configuration. */
15420 static int community_list_config_write(struct vty
*vty
)
15422 struct community_list
*list
;
15423 struct community_entry
*entry
;
15424 struct community_list_master
*cm
;
15427 /* Community-list. */
15428 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
15430 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15431 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15432 vty_out(vty
, "bgp community-list %s %s %s\n", list
->name
,
15433 community_direct_str(entry
->direct
),
15434 community_list_config_str(entry
));
15437 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15438 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15439 vty_out(vty
, "bgp community-list %s %s %s %s\n",
15440 entry
->style
== COMMUNITY_LIST_STANDARD
15443 list
->name
, community_direct_str(entry
->direct
),
15444 community_list_config_str(entry
));
15448 /* Extcommunity-list. */
15449 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15451 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15452 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15453 vty_out(vty
, "bgp extcommunity-list %s %s %s\n",
15454 list
->name
, community_direct_str(entry
->direct
),
15455 community_list_config_str(entry
));
15458 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15459 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15460 vty_out(vty
, "bgp extcommunity-list %s %s %s %s\n",
15461 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15464 list
->name
, community_direct_str(entry
->direct
),
15465 community_list_config_str(entry
));
15470 /* lcommunity-list. */
15471 cm
= community_list_master_lookup(bgp_clist
,
15472 LARGE_COMMUNITY_LIST_MASTER
);
15474 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15475 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15476 vty_out(vty
, "bgp large-community-list %s %s %s\n",
15477 list
->name
, community_direct_str(entry
->direct
),
15478 community_list_config_str(entry
));
15481 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15482 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15483 vty_out(vty
, "bgp large-community-list %s %s %s %s\n",
15484 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
15487 list
->name
, community_direct_str(entry
->direct
),
15488 community_list_config_str(entry
));
15495 static struct cmd_node community_list_node
= {
15496 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
15499 static void community_list_vty(void)
15501 install_node(&community_list_node
, community_list_config_write
);
15503 /* Community-list. */
15504 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
15505 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
15506 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
15507 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
15508 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
15509 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
15510 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
15511 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
15512 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
15513 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
15514 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
15515 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_list_cmd
);
15516 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
15517 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_list_cmd
);
15518 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
15519 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
15521 /* Extcommunity-list. */
15522 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
15523 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
15524 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
15525 install_element(CONFIG_NODE
,
15526 &no_bgp_extcommunity_list_standard_all_list_cmd
);
15527 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
15528 install_element(CONFIG_NODE
,
15529 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
15530 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
15531 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
15532 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
15533 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
15534 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
15535 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_list_cmd
);
15536 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
15537 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_list_cmd
);
15538 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
15539 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
15541 /* Large Community List */
15542 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
15543 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard1_cmd
);
15544 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
15545 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
15546 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard1_cmd
);
15547 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
15548 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_all_cmd
);
15549 install_element(CONFIG_NODE
,
15550 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
15551 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
15552 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
15553 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
15554 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
15555 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
15556 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
15557 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
15558 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
15559 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
15560 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
15561 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
15562 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
15563 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
15564 install_element(CONFIG_NODE
,
15565 &no_ip_lcommunity_list_name_expanded_all_cmd
);
15566 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
15567 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
15568 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
15569 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
15570 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
15571 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);