2 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33 #include "memory_vty.h"
39 #include "bgpd/bgpd.h"
40 #include "bgpd/bgp_advertise.h"
41 #include "bgpd/bgp_attr.h"
42 #include "bgpd/bgp_aspath.h"
43 #include "bgpd/bgp_community.h"
44 #include "bgpd/bgp_ecommunity.h"
45 #include "bgpd/bgp_lcommunity.h"
46 #include "bgpd/bgp_damp.h"
47 #include "bgpd/bgp_debug.h"
48 #include "bgpd/bgp_fsm.h"
49 #include "bgpd/bgp_nexthop.h"
50 #include "bgpd/bgp_open.h"
51 #include "bgpd/bgp_regex.h"
52 #include "bgpd/bgp_route.h"
53 #include "bgpd/bgp_mplsvpn.h"
54 #include "bgpd/bgp_zebra.h"
55 #include "bgpd/bgp_table.h"
56 #include "bgpd/bgp_vty.h"
57 #include "bgpd/bgp_mpath.h"
58 #include "bgpd/bgp_packet.h"
59 #include "bgpd/bgp_updgrp.h"
60 #include "bgpd/bgp_bfd.h"
61 #include "bgpd/bgp_io.h"
62 #include "bgpd/bgp_evpn.h"
64 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
65 struct prefix
*range
, int exact
);
67 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
76 return BGP_IPV4M_NODE
;
78 case SAFI_LABELED_UNICAST
:
79 return BGP_IPV4L_NODE
;
82 return BGP_VPNV4_NODE
;
85 return BGP_FLOWSPECV4_NODE
;
98 return BGP_IPV6M_NODE
;
100 case SAFI_LABELED_UNICAST
:
101 return BGP_IPV6L_NODE
;
104 return BGP_VPNV6_NODE
;
107 return BGP_FLOWSPECV6_NODE
;
110 return BGP_IPV4_NODE
;
115 return BGP_EVPN_NODE
;
118 // We should never be here but to clarify the switch statement..
119 return BGP_IPV4_NODE
;
123 // Impossible to happen
124 return BGP_IPV4_NODE
;
127 /* Utility function to get address family from current node. */
128 afi_t
bgp_node_afi(struct vty
*vty
)
136 case BGP_FLOWSPECV6_NODE
:
149 /* Utility function to get subsequent address family from current
151 safi_t
bgp_node_safi(struct vty
*vty
)
157 safi
= SAFI_MPLS_VPN
;
161 safi
= SAFI_MULTICAST
;
168 safi
= SAFI_LABELED_UNICAST
;
170 case BGP_FLOWSPECV4_NODE
:
171 case BGP_FLOWSPECV6_NODE
:
172 safi
= SAFI_FLOWSPEC
;
182 * Converts an AFI in string form to afi_t
184 * @param afi string, one of
188 * @return the corresponding afi_t
190 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
192 afi_t afi
= AFI_MAX
; /* unknown */
193 if (strmatch(afi_str
, "ipv4"))
195 else if (strmatch(afi_str
, "ipv6"))
197 else if (strmatch(afi_str
, "l2vpn"))
202 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
206 if (argv_find(argv
, argc
, "ipv4", index
)) {
210 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
218 /* supports <unicast|multicast|vpn|labeled-unicast> */
219 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
221 safi_t safi
= SAFI_MAX
; /* unknown */
222 if (strmatch(safi_str
, "multicast"))
223 safi
= SAFI_MULTICAST
;
224 else if (strmatch(safi_str
, "unicast"))
226 else if (strmatch(safi_str
, "vpn"))
227 safi
= SAFI_MPLS_VPN
;
228 else if (strmatch(safi_str
, "evpn"))
230 else if (strmatch(safi_str
, "labeled-unicast"))
231 safi
= SAFI_LABELED_UNICAST
;
232 else if (strmatch(safi_str
, "flowspec"))
233 safi
= SAFI_FLOWSPEC
;
237 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
241 if (argv_find(argv
, argc
, "unicast", index
)) {
244 *safi
= SAFI_UNICAST
;
245 } else if (argv_find(argv
, argc
, "multicast", index
)) {
248 *safi
= SAFI_MULTICAST
;
249 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
252 *safi
= SAFI_LABELED_UNICAST
;
253 } else if (argv_find(argv
, argc
, "vpn", index
)) {
256 *safi
= SAFI_MPLS_VPN
;
257 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
260 *safi
= SAFI_FLOWSPEC
;
266 * bgp_vty_find_and_parse_afi_safi_bgp
268 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
269 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
270 * to appropriate values for the calling function. This is to allow the
271 * calling function to make decisions appropriate for the show command
272 * that is being parsed.
274 * The show commands are generally of the form:
275 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
276 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
278 * Since we use argv_find if the show command in particular doesn't have:
280 * [<view|vrf> VIEWVRFNAME]
281 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
282 * The command parsing should still be ok.
284 * vty -> The vty for the command so we can output some useful data in
285 * the event of a parse error in the vrf.
286 * argv -> The command tokens
287 * argc -> How many command tokens we have
288 * idx -> The current place in the command, generally should be 0 for this
290 * afi -> The parsed afi if it was included in the show command, returned here
291 * safi -> The parsed safi if it was included in the show command, returned here
292 * bgp -> Pointer to the bgp data structure we need to fill in.
294 * The function returns the correct location in the parse tree for the
297 * Returns 0 for failure to parse correctly, else the idx position of where
298 * it found the last token.
300 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
301 struct cmd_token
**argv
, int argc
,
302 int *idx
, afi_t
*afi
, safi_t
*safi
,
305 char *vrf_name
= NULL
;
311 if (argv_find(argv
, argc
, "ip", idx
))
314 if (argv_find(argv
, argc
, "view", idx
)
315 || argv_find(argv
, argc
, "vrf", idx
)) {
316 vrf_name
= argv
[*idx
+ 1]->arg
;
318 if (strmatch(vrf_name
, "all"))
321 *bgp
= bgp_lookup_by_name(vrf_name
);
324 "View/Vrf specified is unknown: %s\n",
331 *bgp
= bgp_get_default();
333 vty_out(vty
, "Unable to find default BGP instance\n");
339 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
340 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
346 static int peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
348 struct interface
*ifp
= NULL
;
350 if (su
->sa
.sa_family
== AF_INET
)
351 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
352 else if (su
->sa
.sa_family
== AF_INET6
)
353 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
354 su
->sin6
.sin6_scope_id
,
363 /* Utility function for looking up peer from VTY. */
364 /* This is used only for configuration, so disallow if attempted on
365 * a dynamic neighbor.
367 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
369 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
378 ret
= str2sockunion(ip_str
, &su
);
380 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
382 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
385 "%% Malformed address or name: %s\n",
391 peer
= peer_lookup(bgp
, &su
);
394 "%% Specify remote-as or peer-group commands first\n");
397 if (peer_dynamic_neighbor(peer
)) {
399 "%% Operation not allowed on a dynamic neighbor\n");
406 /* Utility function for looking up peer or peer group. */
407 /* This is used only for configuration, so disallow if attempted on
408 * a dynamic neighbor.
410 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
412 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
415 struct peer
*peer
= NULL
;
416 struct peer_group
*group
= NULL
;
422 ret
= str2sockunion(peer_str
, &su
);
424 /* IP address, locate peer. */
425 peer
= peer_lookup(bgp
, &su
);
427 /* Not IP, could match either peer configured on interface or a
429 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
431 group
= peer_group_lookup(bgp
, peer_str
);
435 if (peer_dynamic_neighbor(peer
)) {
437 "%% Operation not allowed on a dynamic neighbor\n");
447 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
452 int bgp_vty_return(struct vty
*vty
, int ret
)
454 const char *str
= NULL
;
457 case BGP_ERR_INVALID_VALUE
:
458 str
= "Invalid value";
460 case BGP_ERR_INVALID_FLAG
:
461 str
= "Invalid flag";
463 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
464 str
= "Peer-group has been shutdown. Activate the peer-group first";
466 case BGP_ERR_PEER_FLAG_CONFLICT
:
467 str
= "Can't set override-capability and strict-capability-match at the same time";
469 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
470 str
= "Specify remote-as or peer-group remote AS first";
472 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
473 str
= "Cannot change the peer-group. Deconfigure first";
475 case BGP_ERR_PEER_GROUP_MISMATCH
:
476 str
= "Peer is not a member of this peer-group";
478 case BGP_ERR_PEER_FILTER_CONFLICT
:
479 str
= "Prefix/distribute list can not co-exist";
481 case BGP_ERR_NOT_INTERNAL_PEER
:
482 str
= "Invalid command. Not an internal neighbor";
484 case BGP_ERR_REMOVE_PRIVATE_AS
:
485 str
= "remove-private-AS cannot be configured for IBGP peers";
487 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
488 str
= "Local-AS allowed only for EBGP peers";
490 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
491 str
= "Cannot have local-as same as BGP AS number";
493 case BGP_ERR_TCPSIG_FAILED
:
494 str
= "Error while applying TCP-Sig to session(s)";
496 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
497 str
= "ebgp-multihop and ttl-security cannot be configured together";
499 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
500 str
= "ttl-security only allowed for EBGP peers";
502 case BGP_ERR_AS_OVERRIDE
:
503 str
= "as-override cannot be configured for IBGP peers";
505 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
506 str
= "Invalid limit for number of dynamic neighbors";
508 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
509 str
= "Dynamic neighbor listen range already exists";
511 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
512 str
= "Operation not allowed on a dynamic neighbor";
514 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
515 str
= "Operation not allowed on a directly connected neighbor";
517 case BGP_ERR_PEER_SAFI_CONFLICT
:
518 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
522 vty_out(vty
, "%% %s\n", str
);
523 return CMD_WARNING_CONFIG_FAILED
;
528 /* BGP clear sort. */
537 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
538 safi_t safi
, int error
)
541 case BGP_ERR_AF_UNCONFIGURED
:
543 "%%BGP: Enable %s address family for the neighbor %s\n",
544 afi_safi_print(afi
, safi
), peer
->host
);
546 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
548 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
556 /* `clear ip bgp' functions. */
557 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
558 enum clear_sort sort
, enum bgp_clear_type stype
,
564 struct listnode
*node
, *nnode
;
566 /* Clear all neighbors. */
568 * Pass along pointer to next node to peer_clear() when walking all
569 * nodes on the BGP instance as that may get freed if it is a
572 if (sort
== clear_all
) {
573 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
574 if (!peer
->afc
[afi
][safi
])
577 if (stype
== BGP_CLEAR_SOFT_NONE
)
578 ret
= peer_clear(peer
, &nnode
);
580 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
583 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
588 /* This is to apply read-only mode on this clear. */
589 if (stype
== BGP_CLEAR_SOFT_NONE
)
590 bgp
->update_delay_over
= 0;
593 vty_out(vty
, "%%BGP: No %s peer configured",
594 afi_safi_print(afi
, safi
));
599 /* Clear specified neighbor. */
600 if (sort
== clear_peer
) {
603 /* Make sockunion for lookup. */
604 ret
= str2sockunion(arg
, &su
);
606 peer
= peer_lookup_by_conf_if(bgp
, arg
);
608 peer
= peer_lookup_by_hostname(bgp
, arg
);
611 "Malformed address or name: %s\n",
617 peer
= peer_lookup(bgp
, &su
);
620 "%%BGP: Unknown neighbor - \"%s\"\n",
626 if (!peer
->afc
[afi
][safi
])
627 ret
= BGP_ERR_AF_UNCONFIGURED
;
628 else if (stype
== BGP_CLEAR_SOFT_NONE
)
629 ret
= peer_clear(peer
, NULL
);
631 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
634 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
639 /* Clear all neighbors belonging to a specific peer-group. */
640 if (sort
== clear_group
) {
641 struct peer_group
*group
;
643 group
= peer_group_lookup(bgp
, arg
);
645 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
649 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
650 if (!peer
->afc
[afi
][safi
])
653 if (stype
== BGP_CLEAR_SOFT_NONE
)
654 ret
= peer_clear(peer
, NULL
);
656 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
659 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
666 "%%BGP: No %s peer belonging to peer-group %s is configured\n",
667 afi_safi_print(afi
, safi
), arg
);
672 /* Clear all external (eBGP) neighbors. */
673 if (sort
== clear_external
) {
674 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
675 if (peer
->sort
== BGP_PEER_IBGP
)
678 if (!peer
->afc
[afi
][safi
])
681 if (stype
== BGP_CLEAR_SOFT_NONE
)
682 ret
= peer_clear(peer
, &nnode
);
684 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
687 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
694 "%%BGP: No external %s peer is configured\n",
695 afi_safi_print(afi
, safi
));
700 /* Clear all neighbors belonging to a specific AS. */
701 if (sort
== clear_as
) {
702 as_t as
= strtoul(arg
, NULL
, 10);
704 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
708 if (!peer
->afc
[afi
][safi
])
709 ret
= BGP_ERR_AF_UNCONFIGURED
;
710 else if (stype
== BGP_CLEAR_SOFT_NONE
)
711 ret
= peer_clear(peer
, &nnode
);
713 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
716 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
723 "%%BGP: No %s peer is configured with AS %s\n",
724 afi_safi_print(afi
, safi
), arg
);
732 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
733 safi_t safi
, enum clear_sort sort
,
734 enum bgp_clear_type stype
, const char *arg
)
738 /* BGP structure lookup. */
740 bgp
= bgp_lookup_by_name(name
);
742 vty_out(vty
, "Can't find BGP instance %s\n", name
);
746 bgp
= bgp_get_default();
748 vty_out(vty
, "No BGP process is configured\n");
753 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
756 /* clear soft inbound */
757 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
759 bgp_clear_vty(vty
, name
, AFI_IP
, SAFI_UNICAST
, clear_all
,
760 BGP_CLEAR_SOFT_IN
, NULL
);
761 bgp_clear_vty(vty
, name
, AFI_IP6
, SAFI_UNICAST
, clear_all
,
762 BGP_CLEAR_SOFT_IN
, NULL
);
765 /* clear soft outbound */
766 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
768 bgp_clear_vty(vty
, name
, AFI_IP
, SAFI_UNICAST
, clear_all
,
769 BGP_CLEAR_SOFT_OUT
, NULL
);
770 bgp_clear_vty(vty
, name
, AFI_IP6
, SAFI_UNICAST
, clear_all
,
771 BGP_CLEAR_SOFT_OUT
, NULL
);
775 #ifndef VTYSH_EXTRACT_PL
776 #include "bgpd/bgp_vty_clippy.c"
779 /* BGP global configuration. */
780 #if (CONFDATE > 20190601)
781 CPP_NOTICE("bgpd: time to remove deprecated bgp multiple-instance")
782 CPP_NOTICE("This includes BGP_OPT_MULTIPLE_INSTANCE")
784 DEFUN_HIDDEN (bgp_multiple_instance_func
,
785 bgp_multiple_instance_cmd
,
786 "bgp multiple-instance",
788 "Enable bgp multiple instance\n")
790 bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE
);
794 DEFUN_HIDDEN (no_bgp_multiple_instance
,
795 no_bgp_multiple_instance_cmd
,
796 "no bgp multiple-instance",
799 "BGP multiple instance\n")
803 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
804 vty_out(vty
, "if you are using this please let the developers know\n");
805 zlog_warn("Deprecated option: `bgp multiple-instance` being used");
806 ret
= bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE
);
808 vty_out(vty
, "%% There are more than two BGP instances\n");
809 return CMD_WARNING_CONFIG_FAILED
;
814 #if (CONFDATE > 20190601)
815 CPP_NOTICE("bgpd: time to remove deprecated cli bgp config-type cisco")
816 CPP_NOTICE("This includes BGP_OPT_CISCO_CONFIG")
818 DEFUN_HIDDEN (bgp_config_type
,
820 "bgp config-type <cisco|zebra>",
822 "Configuration type\n"
827 if (argv_find(argv
, argc
, "cisco", &idx
)) {
828 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
829 vty_out(vty
, "if you are using this please let the developers know!\n");
830 zlog_warn("Deprecated option: `bgp config-type cisco` being used");
831 bgp_option_set(BGP_OPT_CONFIG_CISCO
);
833 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
838 DEFUN_HIDDEN (no_bgp_config_type
,
839 no_bgp_config_type_cmd
,
840 "no bgp config-type [<cisco|zebra>]",
843 "Display configuration type\n"
847 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
852 DEFUN (no_synchronization
,
853 no_synchronization_cmd
,
854 "no synchronization",
856 "Perform IGP synchronization\n")
861 DEFUN (no_auto_summary
,
865 "Enable automatic network number summarization\n")
870 /* "router bgp" commands. */
871 DEFUN_NOSH (router_bgp
,
873 "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
877 BGP_INSTANCE_HELP_STR
)
880 int idx_view_vrf
= 3;
885 const char *name
= NULL
;
886 enum bgp_instance_type inst_type
;
888 // "router bgp" without an ASN
890 // Pending: Make VRF option available for ASN less config
891 bgp
= bgp_get_default();
894 vty_out(vty
, "%% No BGP process is configured\n");
895 return CMD_WARNING_CONFIG_FAILED
;
898 if (listcount(bm
->bgp
) > 1) {
899 vty_out(vty
, "%% Please specify ASN and VRF\n");
900 return CMD_WARNING_CONFIG_FAILED
;
906 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
908 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
910 name
= argv
[idx_vrf
]->arg
;
912 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf"))
913 inst_type
= BGP_INSTANCE_TYPE_VRF
;
914 else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
915 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
918 ret
= bgp_get(&bgp
, &as
, name
, inst_type
);
920 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET
:
922 "Please specify 'bgp multiple-instance' first\n");
923 return CMD_WARNING_CONFIG_FAILED
;
924 case BGP_ERR_AS_MISMATCH
:
925 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
926 return CMD_WARNING_CONFIG_FAILED
;
927 case BGP_ERR_INSTANCE_MISMATCH
:
929 "BGP instance name and AS number mismatch\n");
931 "BGP instance is already running; AS is %u\n",
933 return CMD_WARNING_CONFIG_FAILED
;
937 * If we just instantiated the default instance, complete
938 * any pending VRF-VPN leaking that was configured via
939 * earlier "router bgp X vrf FOO" blocks.
941 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
942 vpn_leak_postchange_all();
944 /* Pending: handle when user tries to change a view to vrf n vv.
948 /* unset the auto created flag as the user config is now present */
949 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
950 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
955 /* "no router bgp" commands. */
956 DEFUN (no_router_bgp
,
958 "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
963 BGP_INSTANCE_HELP_STR
)
969 const char *name
= NULL
;
971 // "no router bgp" without an ASN
973 // Pending: Make VRF option available for ASN less config
974 bgp
= bgp_get_default();
977 vty_out(vty
, "%% No BGP process is configured\n");
978 return CMD_WARNING_CONFIG_FAILED
;
981 if (listcount(bm
->bgp
) > 1) {
982 vty_out(vty
, "%% Please specify ASN and VRF\n");
983 return CMD_WARNING_CONFIG_FAILED
;
987 vty_out(vty
, "%% Please unconfigure l3vni %u",
989 return CMD_WARNING_CONFIG_FAILED
;
992 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
995 name
= argv
[idx_vrf
]->arg
;
997 /* Lookup bgp structure. */
998 bgp
= bgp_lookup(as
, name
);
1000 vty_out(vty
, "%% Can't find BGP instance\n");
1001 return CMD_WARNING_CONFIG_FAILED
;
1005 vty_out(vty
, "%% Please unconfigure l3vni %u",
1007 return CMD_WARNING_CONFIG_FAILED
;
1017 /* BGP router-id. */
1019 DEFPY (bgp_router_id
,
1021 "bgp router-id A.B.C.D",
1023 "Override configured router identifier\n"
1024 "Manually configured router identifier\n")
1026 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1027 bgp_router_id_static_set(bgp
, router_id
);
1031 DEFPY (no_bgp_router_id
,
1032 no_bgp_router_id_cmd
,
1033 "no bgp router-id [A.B.C.D]",
1036 "Override configured router identifier\n"
1037 "Manually configured router identifier\n")
1039 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1041 if (router_id_str
) {
1042 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1043 vty_out(vty
, "%% BGP router-id doesn't match\n");
1044 return CMD_WARNING_CONFIG_FAILED
;
1048 router_id
.s_addr
= 0;
1049 bgp_router_id_static_set(bgp
, router_id
);
1055 /* BGP Cluster ID. */
1056 DEFUN (bgp_cluster_id
,
1058 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1060 "Configure Route-Reflector Cluster-id\n"
1061 "Route-Reflector Cluster-id in IP address format\n"
1062 "Route-Reflector Cluster-id as 32 bit quantity\n")
1064 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1067 struct in_addr cluster
;
1069 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1071 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1072 return CMD_WARNING_CONFIG_FAILED
;
1075 bgp_cluster_id_set(bgp
, &cluster
);
1076 bgp_clear_star_soft_out(vty
, bgp
->name
);
1081 DEFUN (no_bgp_cluster_id
,
1082 no_bgp_cluster_id_cmd
,
1083 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1086 "Configure Route-Reflector Cluster-id\n"
1087 "Route-Reflector Cluster-id in IP address format\n"
1088 "Route-Reflector Cluster-id as 32 bit quantity\n")
1090 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1091 bgp_cluster_id_unset(bgp
);
1092 bgp_clear_star_soft_out(vty
, bgp
->name
);
1097 DEFUN (bgp_confederation_identifier
,
1098 bgp_confederation_identifier_cmd
,
1099 "bgp confederation identifier (1-4294967295)",
1100 "BGP specific commands\n"
1101 "AS confederation parameters\n"
1103 "Set routing domain confederation AS\n")
1105 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1109 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1111 bgp_confederation_id_set(bgp
, as
);
1116 DEFUN (no_bgp_confederation_identifier
,
1117 no_bgp_confederation_identifier_cmd
,
1118 "no bgp confederation identifier [(1-4294967295)]",
1120 "BGP specific commands\n"
1121 "AS confederation parameters\n"
1123 "Set routing domain confederation AS\n")
1125 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1126 bgp_confederation_id_unset(bgp
);
1131 DEFUN (bgp_confederation_peers
,
1132 bgp_confederation_peers_cmd
,
1133 "bgp confederation peers (1-4294967295)...",
1134 "BGP specific commands\n"
1135 "AS confederation parameters\n"
1136 "Peer ASs in BGP confederation\n"
1139 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1144 for (i
= idx_asn
; i
< argc
; i
++) {
1145 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1147 if (bgp
->as
== as
) {
1149 "%% Local member-AS not allowed in confed peer list\n");
1153 bgp_confederation_peers_add(bgp
, as
);
1158 DEFUN (no_bgp_confederation_peers
,
1159 no_bgp_confederation_peers_cmd
,
1160 "no bgp confederation peers (1-4294967295)...",
1162 "BGP specific commands\n"
1163 "AS confederation parameters\n"
1164 "Peer ASs in BGP confederation\n"
1167 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1172 for (i
= idx_asn
; i
< argc
; i
++) {
1173 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1175 bgp_confederation_peers_remove(bgp
, as
);
1181 * Central routine for maximum-paths configuration.
1182 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1183 * @set: 1 for setting values, 0 for removing the max-paths config.
1185 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1186 const char *mpaths
, uint16_t options
,
1189 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1190 uint16_t maxpaths
= 0;
1195 afi
= bgp_node_afi(vty
);
1196 safi
= bgp_node_safi(vty
);
1199 maxpaths
= strtol(mpaths
, NULL
, 10);
1200 if (maxpaths
> multipath_num
) {
1202 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1203 maxpaths
, multipath_num
);
1204 return CMD_WARNING_CONFIG_FAILED
;
1206 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1209 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1213 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1214 (set
== 1) ? "" : "un",
1215 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1216 maxpaths
, afi
, safi
);
1217 return CMD_WARNING_CONFIG_FAILED
;
1220 bgp_recalculate_all_bestpaths(bgp
);
1225 DEFUN (bgp_maxmed_admin
,
1226 bgp_maxmed_admin_cmd
,
1227 "bgp max-med administrative ",
1229 "Advertise routes with max-med\n"
1230 "Administratively applied, for an indefinite period\n")
1232 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1234 bgp
->v_maxmed_admin
= 1;
1235 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1237 bgp_maxmed_update(bgp
);
1242 DEFUN (bgp_maxmed_admin_medv
,
1243 bgp_maxmed_admin_medv_cmd
,
1244 "bgp max-med administrative (0-4294967295)",
1246 "Advertise routes with max-med\n"
1247 "Administratively applied, for an indefinite period\n"
1248 "Max MED value to be used\n")
1250 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1253 bgp
->v_maxmed_admin
= 1;
1254 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1256 bgp_maxmed_update(bgp
);
1261 DEFUN (no_bgp_maxmed_admin
,
1262 no_bgp_maxmed_admin_cmd
,
1263 "no bgp max-med administrative [(0-4294967295)]",
1266 "Advertise routes with max-med\n"
1267 "Administratively applied, for an indefinite period\n"
1268 "Max MED value to be used\n")
1270 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1271 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1272 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1273 bgp_maxmed_update(bgp
);
1278 DEFUN (bgp_maxmed_onstartup
,
1279 bgp_maxmed_onstartup_cmd
,
1280 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1282 "Advertise routes with max-med\n"
1283 "Effective on a startup\n"
1284 "Time (seconds) period for max-med\n"
1285 "Max MED value to be used\n")
1287 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1290 argv_find(argv
, argc
, "(5-86400)", &idx
);
1291 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1292 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1293 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1295 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1297 bgp_maxmed_update(bgp
);
1302 DEFUN (no_bgp_maxmed_onstartup
,
1303 no_bgp_maxmed_onstartup_cmd
,
1304 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1307 "Advertise routes with max-med\n"
1308 "Effective on a startup\n"
1309 "Time (seconds) period for max-med\n"
1310 "Max MED value to be used\n")
1312 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1314 /* Cancel max-med onstartup if its on */
1315 if (bgp
->t_maxmed_onstartup
) {
1316 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1317 bgp
->maxmed_onstartup_over
= 1;
1320 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1321 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1323 bgp_maxmed_update(bgp
);
1328 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1331 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1332 uint16_t update_delay
;
1333 uint16_t establish_wait
;
1335 update_delay
= strtoul(delay
, NULL
, 10);
1337 if (!wait
) /* update-delay <delay> */
1339 bgp
->v_update_delay
= update_delay
;
1340 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1344 /* update-delay <delay> <establish-wait> */
1345 establish_wait
= atoi(wait
);
1346 if (update_delay
< establish_wait
) {
1348 "%%Failed: update-delay less than the establish-wait!\n");
1349 return CMD_WARNING_CONFIG_FAILED
;
1352 bgp
->v_update_delay
= update_delay
;
1353 bgp
->v_establish_wait
= establish_wait
;
1358 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1360 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1362 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1363 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1368 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1370 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1371 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1372 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1373 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1379 /* Update-delay configuration */
1380 DEFUN (bgp_update_delay
,
1381 bgp_update_delay_cmd
,
1382 "update-delay (0-3600)",
1383 "Force initial delay for best-path and updates\n"
1387 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1390 DEFUN (bgp_update_delay_establish_wait
,
1391 bgp_update_delay_establish_wait_cmd
,
1392 "update-delay (0-3600) (1-3600)",
1393 "Force initial delay for best-path and updates\n"
1398 int idx_number_2
= 2;
1399 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1400 argv
[idx_number_2
]->arg
);
1403 /* Update-delay deconfiguration */
1404 DEFUN (no_bgp_update_delay
,
1405 no_bgp_update_delay_cmd
,
1406 "no update-delay [(0-3600) [(1-3600)]]",
1408 "Force initial delay for best-path and updates\n"
1412 return bgp_update_delay_deconfig_vty(vty
);
1416 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1419 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1422 uint32_t quanta
= strtoul(num
, NULL
, 10);
1423 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
,
1424 memory_order_relaxed
);
1426 atomic_store_explicit(&bgp
->wpkt_quanta
, BGP_WRITE_PACKET_MAX
,
1427 memory_order_relaxed
);
1433 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1436 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1439 uint32_t quanta
= strtoul(num
, NULL
, 10);
1440 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
,
1441 memory_order_relaxed
);
1443 atomic_store_explicit(&bgp
->rpkt_quanta
, BGP_READ_PACKET_MAX
,
1444 memory_order_relaxed
);
1450 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1453 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1454 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1455 vty_out(vty
, " write-quanta %d\n", quanta
);
1458 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1461 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1462 if (quanta
!= BGP_READ_PACKET_MAX
)
1463 vty_out(vty
, " read-quanta %d\n", quanta
);
1466 /* Packet quanta configuration */
1467 DEFUN (bgp_wpkt_quanta
,
1468 bgp_wpkt_quanta_cmd
,
1469 "write-quanta (1-10)",
1470 "How many packets to write to peer socket per run\n"
1471 "Number of packets\n")
1474 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1477 DEFUN (no_bgp_wpkt_quanta
,
1478 no_bgp_wpkt_quanta_cmd
,
1479 "no write-quanta (1-10)",
1481 "How many packets to write to peer socket per I/O cycle\n"
1482 "Number of packets\n")
1485 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1488 DEFUN (bgp_rpkt_quanta
,
1489 bgp_rpkt_quanta_cmd
,
1490 "read-quanta (1-10)",
1491 "How many packets to read from peer socket per I/O cycle\n"
1492 "Number of packets\n")
1495 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1498 DEFUN (no_bgp_rpkt_quanta
,
1499 no_bgp_rpkt_quanta_cmd
,
1500 "no read-quanta (1-10)",
1502 "How many packets to read from peer socket per I/O cycle\n"
1503 "Number of packets\n")
1506 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1509 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1511 if (!bgp
->heuristic_coalesce
)
1512 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1516 DEFUN (bgp_coalesce_time
,
1517 bgp_coalesce_time_cmd
,
1518 "coalesce-time (0-4294967295)",
1519 "Subgroup coalesce timer\n"
1520 "Subgroup coalesce timer value (in ms)\n")
1522 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1525 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1526 bgp
->heuristic_coalesce
= false;
1527 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1531 DEFUN (no_bgp_coalesce_time
,
1532 no_bgp_coalesce_time_cmd
,
1533 "no coalesce-time (0-4294967295)",
1535 "Subgroup coalesce timer\n"
1536 "Subgroup coalesce timer value (in ms)\n")
1538 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1540 bgp
->heuristic_coalesce
= true;
1541 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1545 /* Maximum-paths configuration */
1546 DEFUN (bgp_maxpaths
,
1548 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1549 "Forward packets over multiple paths\n"
1550 "Number of paths\n")
1553 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1554 argv
[idx_number
]->arg
, 0, 1);
1557 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1558 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1559 "Forward packets over multiple paths\n"
1560 "Number of paths\n")
1562 DEFUN (bgp_maxpaths_ibgp
,
1563 bgp_maxpaths_ibgp_cmd
,
1564 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1565 "Forward packets over multiple paths\n"
1567 "Number of paths\n")
1570 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1571 argv
[idx_number
]->arg
, 0, 1);
1574 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1575 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1576 "Forward packets over multiple paths\n"
1578 "Number of paths\n")
1580 DEFUN (bgp_maxpaths_ibgp_cluster
,
1581 bgp_maxpaths_ibgp_cluster_cmd
,
1582 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1583 "Forward packets over multiple paths\n"
1586 "Match the cluster length\n")
1589 return bgp_maxpaths_config_vty(
1590 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1591 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1594 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1595 "maximum-paths ibgp " CMD_RANGE_STR(
1596 1, MULTIPATH_NUM
) " equal-cluster-length",
1597 "Forward packets over multiple paths\n"
1600 "Match the cluster length\n")
1602 DEFUN (no_bgp_maxpaths
,
1603 no_bgp_maxpaths_cmd
,
1604 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1606 "Forward packets over multiple paths\n"
1607 "Number of paths\n")
1609 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1612 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1613 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1614 "Forward packets over multiple paths\n"
1615 "Number of paths\n")
1617 DEFUN (no_bgp_maxpaths_ibgp
,
1618 no_bgp_maxpaths_ibgp_cmd
,
1619 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1621 "Forward packets over multiple paths\n"
1624 "Match the cluster length\n")
1626 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1629 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1630 "no maximum-paths ibgp [" CMD_RANGE_STR(
1631 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1633 "Forward packets over multiple paths\n"
1636 "Match the cluster length\n")
1638 void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1641 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1642 vty_out(vty
, " maximum-paths %d\n",
1643 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1646 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1647 vty_out(vty
, " maximum-paths ibgp %d",
1648 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1649 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1650 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1651 vty_out(vty
, " equal-cluster-length");
1660 "timers bgp (0-65535) (0-65535)",
1661 "Adjust routing timers\n"
1663 "Keepalive interval\n"
1666 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1668 int idx_number_2
= 3;
1669 unsigned long keepalive
= 0;
1670 unsigned long holdtime
= 0;
1672 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1673 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1675 /* Holdtime value check. */
1676 if (holdtime
< 3 && holdtime
!= 0) {
1678 "%% hold time value must be either 0 or greater than 3\n");
1679 return CMD_WARNING_CONFIG_FAILED
;
1682 bgp_timers_set(bgp
, keepalive
, holdtime
);
1687 DEFUN (no_bgp_timers
,
1689 "no timers bgp [(0-65535) (0-65535)]",
1691 "Adjust routing timers\n"
1693 "Keepalive interval\n"
1696 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1697 bgp_timers_unset(bgp
);
1703 DEFUN (bgp_client_to_client_reflection
,
1704 bgp_client_to_client_reflection_cmd
,
1705 "bgp client-to-client reflection",
1706 "BGP specific commands\n"
1707 "Configure client to client route reflection\n"
1708 "reflection of routes allowed\n")
1710 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1711 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1712 bgp_clear_star_soft_out(vty
, bgp
->name
);
1717 DEFUN (no_bgp_client_to_client_reflection
,
1718 no_bgp_client_to_client_reflection_cmd
,
1719 "no bgp client-to-client reflection",
1721 "BGP specific commands\n"
1722 "Configure client to client route reflection\n"
1723 "reflection of routes allowed\n")
1725 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1726 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1727 bgp_clear_star_soft_out(vty
, bgp
->name
);
1732 /* "bgp always-compare-med" configuration. */
1733 DEFUN (bgp_always_compare_med
,
1734 bgp_always_compare_med_cmd
,
1735 "bgp always-compare-med",
1736 "BGP specific commands\n"
1737 "Allow comparing MED from different neighbors\n")
1739 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1740 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1741 bgp_recalculate_all_bestpaths(bgp
);
1746 DEFUN (no_bgp_always_compare_med
,
1747 no_bgp_always_compare_med_cmd
,
1748 "no bgp always-compare-med",
1750 "BGP specific commands\n"
1751 "Allow comparing MED from different neighbors\n")
1753 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1754 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1755 bgp_recalculate_all_bestpaths(bgp
);
1760 /* "bgp deterministic-med" configuration. */
1761 DEFUN (bgp_deterministic_med
,
1762 bgp_deterministic_med_cmd
,
1763 "bgp deterministic-med",
1764 "BGP specific commands\n"
1765 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1767 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1769 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1770 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1771 bgp_recalculate_all_bestpaths(bgp
);
1777 DEFUN (no_bgp_deterministic_med
,
1778 no_bgp_deterministic_med_cmd
,
1779 "no bgp deterministic-med",
1781 "BGP specific commands\n"
1782 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1784 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1785 int bestpath_per_as_used
;
1789 struct listnode
*node
, *nnode
;
1791 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1792 bestpath_per_as_used
= 0;
1794 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1795 FOREACH_AFI_SAFI (afi
, safi
)
1797 peer
->af_flags
[afi
][safi
],
1798 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
)) {
1799 bestpath_per_as_used
= 1;
1803 if (bestpath_per_as_used
)
1807 if (bestpath_per_as_used
) {
1809 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
1810 return CMD_WARNING_CONFIG_FAILED
;
1812 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1813 bgp_recalculate_all_bestpaths(bgp
);
1820 /* "bgp graceful-restart" configuration. */
1821 DEFUN (bgp_graceful_restart
,
1822 bgp_graceful_restart_cmd
,
1823 "bgp graceful-restart",
1824 "BGP specific commands\n"
1825 "Graceful restart capability parameters\n")
1827 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1828 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1832 DEFUN (no_bgp_graceful_restart
,
1833 no_bgp_graceful_restart_cmd
,
1834 "no bgp graceful-restart",
1836 "BGP specific commands\n"
1837 "Graceful restart capability parameters\n")
1839 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1840 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1844 DEFUN (bgp_graceful_restart_stalepath_time
,
1845 bgp_graceful_restart_stalepath_time_cmd
,
1846 "bgp graceful-restart stalepath-time (1-3600)",
1847 "BGP specific commands\n"
1848 "Graceful restart capability parameters\n"
1849 "Set the max time to hold onto restarting peer's stale paths\n"
1850 "Delay value (seconds)\n")
1852 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1856 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1857 bgp
->stalepath_time
= stalepath
;
1861 DEFUN (bgp_graceful_restart_restart_time
,
1862 bgp_graceful_restart_restart_time_cmd
,
1863 "bgp graceful-restart restart-time (1-3600)",
1864 "BGP specific commands\n"
1865 "Graceful restart capability parameters\n"
1866 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1867 "Delay value (seconds)\n")
1869 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1873 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1874 bgp
->restart_time
= restart
;
1878 DEFUN (no_bgp_graceful_restart_stalepath_time
,
1879 no_bgp_graceful_restart_stalepath_time_cmd
,
1880 "no bgp graceful-restart stalepath-time [(1-3600)]",
1882 "BGP specific commands\n"
1883 "Graceful restart capability parameters\n"
1884 "Set the max time to hold onto restarting peer's stale paths\n"
1885 "Delay value (seconds)\n")
1887 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1889 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
1893 DEFUN (no_bgp_graceful_restart_restart_time
,
1894 no_bgp_graceful_restart_restart_time_cmd
,
1895 "no bgp graceful-restart restart-time [(1-3600)]",
1897 "BGP specific commands\n"
1898 "Graceful restart capability parameters\n"
1899 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1900 "Delay value (seconds)\n")
1902 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1904 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
1908 DEFUN (bgp_graceful_restart_preserve_fw
,
1909 bgp_graceful_restart_preserve_fw_cmd
,
1910 "bgp graceful-restart preserve-fw-state",
1911 "BGP specific commands\n"
1912 "Graceful restart capability parameters\n"
1913 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
1915 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1916 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
1920 DEFUN (no_bgp_graceful_restart_preserve_fw
,
1921 no_bgp_graceful_restart_preserve_fw_cmd
,
1922 "no bgp graceful-restart preserve-fw-state",
1924 "BGP specific commands\n"
1925 "Graceful restart capability parameters\n"
1926 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
1928 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1929 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
1933 static void bgp_redistribute_redo(struct bgp
*bgp
)
1937 struct list
*red_list
;
1938 struct listnode
*node
;
1939 struct bgp_redist
*red
;
1941 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
1942 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
1944 red_list
= bgp
->redist
[afi
][i
];
1948 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
1949 bgp_redistribute_resend(bgp
, afi
, i
,
1956 /* "bgp graceful-shutdown" configuration */
1957 DEFUN (bgp_graceful_shutdown
,
1958 bgp_graceful_shutdown_cmd
,
1959 "bgp graceful-shutdown",
1961 "Graceful shutdown parameters\n")
1963 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1965 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
1966 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
1967 bgp_static_redo_import_check(bgp
);
1968 bgp_redistribute_redo(bgp
);
1969 bgp_clear_star_soft_out(vty
, bgp
->name
);
1970 bgp_clear_star_soft_in(vty
, bgp
->name
);
1976 DEFUN (no_bgp_graceful_shutdown
,
1977 no_bgp_graceful_shutdown_cmd
,
1978 "no bgp graceful-shutdown",
1981 "Graceful shutdown parameters\n")
1983 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1985 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
1986 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
1987 bgp_static_redo_import_check(bgp
);
1988 bgp_redistribute_redo(bgp
);
1989 bgp_clear_star_soft_out(vty
, bgp
->name
);
1990 bgp_clear_star_soft_in(vty
, bgp
->name
);
1996 /* "bgp fast-external-failover" configuration. */
1997 DEFUN (bgp_fast_external_failover
,
1998 bgp_fast_external_failover_cmd
,
1999 "bgp fast-external-failover",
2001 "Immediately reset session if a link to a directly connected external peer goes down\n")
2003 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2004 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2008 DEFUN (no_bgp_fast_external_failover
,
2009 no_bgp_fast_external_failover_cmd
,
2010 "no bgp fast-external-failover",
2013 "Immediately reset session if a link to a directly connected external peer goes down\n")
2015 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2016 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2020 /* "bgp enforce-first-as" configuration. */
2021 #if CONFDATE > 20180517
2022 CPP_NOTICE("bgpd: remove deprecated '[no] bgp enforce-first-as' commands")
2025 DEFUN_HIDDEN (bgp_enforce_first_as
,
2026 bgp_enforce_first_as_cmd
,
2027 "[no] bgp enforce-first-as",
2030 "Enforce the first AS for EBGP routes\n")
2032 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2034 if (strmatch(argv
[0]->text
, "no"))
2035 bgp_flag_unset(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2037 bgp_flag_set(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2042 /* "bgp bestpath compare-routerid" configuration. */
2043 DEFUN (bgp_bestpath_compare_router_id
,
2044 bgp_bestpath_compare_router_id_cmd
,
2045 "bgp bestpath compare-routerid",
2046 "BGP specific commands\n"
2047 "Change the default bestpath selection\n"
2048 "Compare router-id for identical EBGP paths\n")
2050 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2051 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2052 bgp_recalculate_all_bestpaths(bgp
);
2057 DEFUN (no_bgp_bestpath_compare_router_id
,
2058 no_bgp_bestpath_compare_router_id_cmd
,
2059 "no bgp bestpath compare-routerid",
2061 "BGP specific commands\n"
2062 "Change the default bestpath selection\n"
2063 "Compare router-id for identical EBGP paths\n")
2065 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2066 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2067 bgp_recalculate_all_bestpaths(bgp
);
2072 /* "bgp bestpath as-path ignore" configuration. */
2073 DEFUN (bgp_bestpath_aspath_ignore
,
2074 bgp_bestpath_aspath_ignore_cmd
,
2075 "bgp bestpath as-path ignore",
2076 "BGP specific commands\n"
2077 "Change the default bestpath selection\n"
2078 "AS-path attribute\n"
2079 "Ignore as-path length in selecting a route\n")
2081 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2082 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2083 bgp_recalculate_all_bestpaths(bgp
);
2088 DEFUN (no_bgp_bestpath_aspath_ignore
,
2089 no_bgp_bestpath_aspath_ignore_cmd
,
2090 "no bgp bestpath as-path ignore",
2092 "BGP specific commands\n"
2093 "Change the default bestpath selection\n"
2094 "AS-path attribute\n"
2095 "Ignore as-path length in selecting a route\n")
2097 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2098 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2099 bgp_recalculate_all_bestpaths(bgp
);
2104 /* "bgp bestpath as-path confed" configuration. */
2105 DEFUN (bgp_bestpath_aspath_confed
,
2106 bgp_bestpath_aspath_confed_cmd
,
2107 "bgp bestpath as-path confed",
2108 "BGP specific commands\n"
2109 "Change the default bestpath selection\n"
2110 "AS-path attribute\n"
2111 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2113 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2114 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2115 bgp_recalculate_all_bestpaths(bgp
);
2120 DEFUN (no_bgp_bestpath_aspath_confed
,
2121 no_bgp_bestpath_aspath_confed_cmd
,
2122 "no bgp bestpath as-path confed",
2124 "BGP specific commands\n"
2125 "Change the default bestpath selection\n"
2126 "AS-path attribute\n"
2127 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2129 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2130 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2131 bgp_recalculate_all_bestpaths(bgp
);
2136 /* "bgp bestpath as-path multipath-relax" configuration. */
2137 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2138 bgp_bestpath_aspath_multipath_relax_cmd
,
2139 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2140 "BGP specific commands\n"
2141 "Change the default bestpath selection\n"
2142 "AS-path attribute\n"
2143 "Allow load sharing across routes that have different AS paths (but same length)\n"
2144 "Generate an AS_SET\n"
2145 "Do not generate an AS_SET\n")
2147 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2149 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2151 /* no-as-set is now the default behavior so we can silently
2153 if (argv_find(argv
, argc
, "as-set", &idx
))
2154 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2156 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2158 bgp_recalculate_all_bestpaths(bgp
);
2163 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2164 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2165 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2167 "BGP specific commands\n"
2168 "Change the default bestpath selection\n"
2169 "AS-path attribute\n"
2170 "Allow load sharing across routes that have different AS paths (but same length)\n"
2171 "Generate an AS_SET\n"
2172 "Do not generate an AS_SET\n")
2174 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2175 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2176 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2177 bgp_recalculate_all_bestpaths(bgp
);
2182 /* "bgp log-neighbor-changes" configuration. */
2183 DEFUN (bgp_log_neighbor_changes
,
2184 bgp_log_neighbor_changes_cmd
,
2185 "bgp log-neighbor-changes",
2186 "BGP specific commands\n"
2187 "Log neighbor up/down and reset reason\n")
2189 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2190 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2194 DEFUN (no_bgp_log_neighbor_changes
,
2195 no_bgp_log_neighbor_changes_cmd
,
2196 "no bgp log-neighbor-changes",
2198 "BGP specific commands\n"
2199 "Log neighbor up/down and reset reason\n")
2201 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2202 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2206 /* "bgp bestpath med" configuration. */
2207 DEFUN (bgp_bestpath_med
,
2208 bgp_bestpath_med_cmd
,
2209 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2210 "BGP specific commands\n"
2211 "Change the default bestpath selection\n"
2213 "Compare MED among confederation paths\n"
2214 "Treat missing MED as the least preferred one\n"
2215 "Treat missing MED as the least preferred one\n"
2216 "Compare MED among confederation paths\n")
2218 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2221 if (argv_find(argv
, argc
, "confed", &idx
))
2222 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2224 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2225 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2227 bgp_recalculate_all_bestpaths(bgp
);
2232 DEFUN (no_bgp_bestpath_med
,
2233 no_bgp_bestpath_med_cmd
,
2234 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2236 "BGP specific commands\n"
2237 "Change the default bestpath selection\n"
2239 "Compare MED among confederation paths\n"
2240 "Treat missing MED as the least preferred one\n"
2241 "Treat missing MED as the least preferred one\n"
2242 "Compare MED among confederation paths\n")
2244 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2247 if (argv_find(argv
, argc
, "confed", &idx
))
2248 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2250 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2251 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2253 bgp_recalculate_all_bestpaths(bgp
);
2258 /* "no bgp default ipv4-unicast". */
2259 DEFUN (no_bgp_default_ipv4_unicast
,
2260 no_bgp_default_ipv4_unicast_cmd
,
2261 "no bgp default ipv4-unicast",
2263 "BGP specific commands\n"
2264 "Configure BGP defaults\n"
2265 "Activate ipv4-unicast for a peer by default\n")
2267 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2268 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2272 DEFUN (bgp_default_ipv4_unicast
,
2273 bgp_default_ipv4_unicast_cmd
,
2274 "bgp default ipv4-unicast",
2275 "BGP specific commands\n"
2276 "Configure BGP defaults\n"
2277 "Activate ipv4-unicast for a peer by default\n")
2279 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2280 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2284 /* Display hostname in certain command outputs */
2285 DEFUN (bgp_default_show_hostname
,
2286 bgp_default_show_hostname_cmd
,
2287 "bgp default show-hostname",
2288 "BGP specific commands\n"
2289 "Configure BGP defaults\n"
2290 "Show hostname in certain command ouputs\n")
2292 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2293 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2297 DEFUN (no_bgp_default_show_hostname
,
2298 no_bgp_default_show_hostname_cmd
,
2299 "no bgp default show-hostname",
2301 "BGP specific commands\n"
2302 "Configure BGP defaults\n"
2303 "Show hostname in certain command ouputs\n")
2305 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2306 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2310 /* "bgp network import-check" configuration. */
2311 DEFUN (bgp_network_import_check
,
2312 bgp_network_import_check_cmd
,
2313 "bgp network import-check",
2314 "BGP specific commands\n"
2315 "BGP network command\n"
2316 "Check BGP network route exists in IGP\n")
2318 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2319 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2320 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2321 bgp_static_redo_import_check(bgp
);
2327 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2328 "bgp network import-check exact",
2329 "BGP specific commands\n"
2330 "BGP network command\n"
2331 "Check BGP network route exists in IGP\n"
2332 "Match route precisely\n")
2334 DEFUN (no_bgp_network_import_check
,
2335 no_bgp_network_import_check_cmd
,
2336 "no bgp network import-check",
2338 "BGP specific commands\n"
2339 "BGP network command\n"
2340 "Check BGP network route exists in IGP\n")
2342 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2343 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2344 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2345 bgp_static_redo_import_check(bgp
);
2351 DEFUN (bgp_default_local_preference
,
2352 bgp_default_local_preference_cmd
,
2353 "bgp default local-preference (0-4294967295)",
2354 "BGP specific commands\n"
2355 "Configure BGP defaults\n"
2356 "local preference (higher=more preferred)\n"
2357 "Configure default local preference value\n")
2359 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2361 uint32_t local_pref
;
2363 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2365 bgp_default_local_preference_set(bgp
, local_pref
);
2366 bgp_clear_star_soft_in(vty
, bgp
->name
);
2371 DEFUN (no_bgp_default_local_preference
,
2372 no_bgp_default_local_preference_cmd
,
2373 "no bgp default local-preference [(0-4294967295)]",
2375 "BGP specific commands\n"
2376 "Configure BGP defaults\n"
2377 "local preference (higher=more preferred)\n"
2378 "Configure default local preference value\n")
2380 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2381 bgp_default_local_preference_unset(bgp
);
2382 bgp_clear_star_soft_in(vty
, bgp
->name
);
2388 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2389 bgp_default_subgroup_pkt_queue_max_cmd
,
2390 "bgp default subgroup-pkt-queue-max (20-100)",
2391 "BGP specific commands\n"
2392 "Configure BGP defaults\n"
2393 "subgroup-pkt-queue-max\n"
2394 "Configure subgroup packet queue max\n")
2396 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2400 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2402 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2407 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2408 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2409 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2411 "BGP specific commands\n"
2412 "Configure BGP defaults\n"
2413 "subgroup-pkt-queue-max\n"
2414 "Configure subgroup packet queue max\n")
2416 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2417 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2422 DEFUN (bgp_rr_allow_outbound_policy
,
2423 bgp_rr_allow_outbound_policy_cmd
,
2424 "bgp route-reflector allow-outbound-policy",
2425 "BGP specific commands\n"
2426 "Allow modifications made by out route-map\n"
2427 "on ibgp neighbors\n")
2429 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2431 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2432 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2433 update_group_announce_rrclients(bgp
);
2434 bgp_clear_star_soft_out(vty
, bgp
->name
);
2440 DEFUN (no_bgp_rr_allow_outbound_policy
,
2441 no_bgp_rr_allow_outbound_policy_cmd
,
2442 "no bgp route-reflector allow-outbound-policy",
2444 "BGP specific commands\n"
2445 "Allow modifications made by out route-map\n"
2446 "on ibgp neighbors\n")
2448 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2450 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2451 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2452 update_group_announce_rrclients(bgp
);
2453 bgp_clear_star_soft_out(vty
, bgp
->name
);
2459 DEFUN (bgp_listen_limit
,
2460 bgp_listen_limit_cmd
,
2461 "bgp listen limit (1-5000)",
2462 "BGP specific commands\n"
2463 "Configure BGP defaults\n"
2464 "maximum number of BGP Dynamic Neighbors that can be created\n"
2465 "Configure Dynamic Neighbors listen limit value\n")
2467 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2471 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2473 bgp_listen_limit_set(bgp
, listen_limit
);
2478 DEFUN (no_bgp_listen_limit
,
2479 no_bgp_listen_limit_cmd
,
2480 "no bgp listen limit [(1-5000)]",
2481 "BGP specific commands\n"
2482 "Configure BGP defaults\n"
2483 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2484 "Configure Dynamic Neighbors listen limit value to default\n"
2485 "Configure Dynamic Neighbors listen limit value\n")
2487 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2488 bgp_listen_limit_unset(bgp
);
2494 * Check if this listen range is already configured. Check for exact
2495 * match or overlap based on input.
2497 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2498 struct prefix
*range
, int exact
)
2500 struct listnode
*node
, *nnode
;
2501 struct listnode
*node1
, *nnode1
;
2502 struct peer_group
*group
;
2507 afi
= family2afi(range
->family
);
2508 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2509 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2512 match
= prefix_same(range
, lr
);
2514 match
= (prefix_match(range
, lr
)
2515 || prefix_match(lr
, range
));
2524 DEFUN (bgp_listen_range
,
2525 bgp_listen_range_cmd
,
2526 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2527 "BGP specific commands\n"
2528 "Configure BGP dynamic neighbors listen range\n"
2529 "Configure BGP dynamic neighbors listen range\n"
2531 "Member of the peer-group\n"
2532 "Peer-group name\n")
2534 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2535 struct prefix range
;
2536 struct peer_group
*group
, *existing_group
;
2541 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2542 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2543 char *prefix
= argv
[idx
]->arg
;
2544 argv_find(argv
, argc
, "WORD", &idx
);
2545 char *peergroup
= argv
[idx
]->arg
;
2547 /* Convert IP prefix string to struct prefix. */
2548 ret
= str2prefix(prefix
, &range
);
2550 vty_out(vty
, "%% Malformed listen range\n");
2551 return CMD_WARNING_CONFIG_FAILED
;
2554 afi
= family2afi(range
.family
);
2556 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2558 "%% Malformed listen range (link-local address)\n");
2559 return CMD_WARNING_CONFIG_FAILED
;
2564 /* Check if same listen range is already configured. */
2565 existing_group
= listen_range_exists(bgp
, &range
, 1);
2566 if (existing_group
) {
2567 if (strcmp(existing_group
->name
, peergroup
) == 0)
2571 "%% Same listen range is attached to peer-group %s\n",
2572 existing_group
->name
);
2573 return CMD_WARNING_CONFIG_FAILED
;
2577 /* Check if an overlapping listen range exists. */
2578 if (listen_range_exists(bgp
, &range
, 0)) {
2580 "%% Listen range overlaps with existing listen range\n");
2581 return CMD_WARNING_CONFIG_FAILED
;
2584 group
= peer_group_lookup(bgp
, peergroup
);
2586 vty_out(vty
, "%% Configure the peer-group first\n");
2587 return CMD_WARNING_CONFIG_FAILED
;
2590 ret
= peer_group_listen_range_add(group
, &range
);
2591 return bgp_vty_return(vty
, ret
);
2594 DEFUN (no_bgp_listen_range
,
2595 no_bgp_listen_range_cmd
,
2596 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2598 "BGP specific commands\n"
2599 "Unconfigure BGP dynamic neighbors listen range\n"
2600 "Unconfigure BGP dynamic neighbors listen range\n"
2602 "Member of the peer-group\n"
2603 "Peer-group name\n")
2605 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2606 struct prefix range
;
2607 struct peer_group
*group
;
2612 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2613 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2614 char *prefix
= argv
[idx
]->arg
;
2615 argv_find(argv
, argc
, "WORD", &idx
);
2616 char *peergroup
= argv
[idx
]->arg
;
2618 /* Convert IP prefix string to struct prefix. */
2619 ret
= str2prefix(prefix
, &range
);
2621 vty_out(vty
, "%% Malformed listen range\n");
2622 return CMD_WARNING_CONFIG_FAILED
;
2625 afi
= family2afi(range
.family
);
2627 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2629 "%% Malformed listen range (link-local address)\n");
2630 return CMD_WARNING_CONFIG_FAILED
;
2635 group
= peer_group_lookup(bgp
, peergroup
);
2637 vty_out(vty
, "%% Peer-group does not exist\n");
2638 return CMD_WARNING_CONFIG_FAILED
;
2641 ret
= peer_group_listen_range_del(group
, &range
);
2642 return bgp_vty_return(vty
, ret
);
2645 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2647 struct peer_group
*group
;
2648 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2649 struct prefix
*range
;
2651 char buf
[PREFIX2STR_BUFFER
];
2653 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2654 vty_out(vty
, " bgp listen limit %d\n",
2655 bgp
->dynamic_neighbors_limit
);
2657 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2658 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2659 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2661 prefix2str(range
, buf
, sizeof(buf
));
2663 " bgp listen range %s peer-group %s\n",
2671 DEFUN (bgp_disable_connected_route_check
,
2672 bgp_disable_connected_route_check_cmd
,
2673 "bgp disable-ebgp-connected-route-check",
2674 "BGP specific commands\n"
2675 "Disable checking if nexthop is connected on ebgp sessions\n")
2677 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2678 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2679 bgp_clear_star_soft_in(vty
, bgp
->name
);
2684 DEFUN (no_bgp_disable_connected_route_check
,
2685 no_bgp_disable_connected_route_check_cmd
,
2686 "no bgp disable-ebgp-connected-route-check",
2688 "BGP specific commands\n"
2689 "Disable checking if nexthop is connected on ebgp sessions\n")
2691 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2692 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2693 bgp_clear_star_soft_in(vty
, bgp
->name
);
2699 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2700 const char *as_str
, afi_t afi
, safi_t safi
)
2702 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2705 int as_type
= AS_SPECIFIED
;
2708 if (as_str
[0] == 'i') {
2710 as_type
= AS_INTERNAL
;
2711 } else if (as_str
[0] == 'e') {
2713 as_type
= AS_EXTERNAL
;
2715 /* Get AS number. */
2716 as
= strtoul(as_str
, NULL
, 10);
2719 /* If peer is peer group, call proper function. */
2720 ret
= str2sockunion(peer_str
, &su
);
2722 /* Check for peer by interface */
2723 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2726 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2729 "%% Create the peer-group or interface first\n");
2730 return CMD_WARNING_CONFIG_FAILED
;
2735 if (peer_address_self_check(bgp
, &su
)) {
2737 "%% Can not configure the local system as neighbor\n");
2738 return CMD_WARNING_CONFIG_FAILED
;
2740 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2743 /* This peer belongs to peer group. */
2745 case BGP_ERR_PEER_GROUP_MEMBER
:
2747 "%% Peer-group AS %u. Cannot configure remote-as for member\n",
2749 return CMD_WARNING_CONFIG_FAILED
;
2750 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2752 "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n",
2754 return CMD_WARNING_CONFIG_FAILED
;
2756 return bgp_vty_return(vty
, ret
);
2759 DEFUN (bgp_default_shutdown
,
2760 bgp_default_shutdown_cmd
,
2761 "[no] bgp default shutdown",
2764 "Configure BGP defaults\n"
2765 "Apply administrative shutdown to newly configured peers\n")
2767 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2768 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2772 DEFUN (neighbor_remote_as
,
2773 neighbor_remote_as_cmd
,
2774 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2777 "Specify a BGP neighbor\n"
2779 "Internal BGP peer\n"
2780 "External BGP peer\n")
2783 int idx_remote_as
= 3;
2784 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2785 argv
[idx_remote_as
]->arg
, AFI_IP
,
2789 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2790 afi_t afi
, safi_t safi
, int v6only
,
2791 const char *peer_group_name
,
2794 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2796 int as_type
= AS_UNSPECIFIED
;
2798 struct peer_group
*group
;
2802 group
= peer_group_lookup(bgp
, conf_if
);
2805 vty_out(vty
, "%% Name conflict with peer-group \n");
2806 return CMD_WARNING_CONFIG_FAILED
;
2810 if (as_str
[0] == 'i') {
2811 as_type
= AS_INTERNAL
;
2812 } else if (as_str
[0] == 'e') {
2813 as_type
= AS_EXTERNAL
;
2815 /* Get AS number. */
2816 as
= strtoul(as_str
, NULL
, 10);
2817 as_type
= AS_SPECIFIED
;
2821 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2824 ret
= peer_remote_as(bgp
, &su
, conf_if
, &as
, as_type
,
2827 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2828 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2829 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2830 as_type
, 0, 0, NULL
);
2832 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2833 as_type
, afi
, safi
, NULL
);
2836 vty_out(vty
, "%% BGP failed to create peer\n");
2837 return CMD_WARNING_CONFIG_FAILED
;
2841 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2843 /* Request zebra to initiate IPv6 RAs on this interface. We do
2845 * any unnumbered peer in order to not worry about run-time
2847 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2849 * gets deleted later etc.)
2852 bgp_zebra_initiate_radv(bgp
, peer
);
2855 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2856 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2858 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2860 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2862 /* v6only flag changed. Reset bgp seesion */
2863 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2864 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2865 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2866 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2868 bgp_session_reset(peer
);
2871 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
2872 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
2873 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
2874 UNSET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
2877 if (peer_group_name
) {
2878 group
= peer_group_lookup(bgp
, peer_group_name
);
2880 vty_out(vty
, "%% Configure the peer-group first\n");
2881 return CMD_WARNING_CONFIG_FAILED
;
2884 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
2887 return bgp_vty_return(vty
, ret
);
2890 DEFUN (neighbor_interface_config
,
2891 neighbor_interface_config_cmd
,
2892 "neighbor WORD interface [peer-group WORD]",
2894 "Interface name or neighbor tag\n"
2895 "Enable BGP on interface\n"
2896 "Member of the peer-group\n"
2897 "Peer-group name\n")
2900 int idx_peer_group_word
= 4;
2902 if (argc
> idx_peer_group_word
)
2903 return peer_conf_interface_get(
2904 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
2905 argv
[idx_peer_group_word
]->arg
, NULL
);
2907 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2908 SAFI_UNICAST
, 0, NULL
, NULL
);
2911 DEFUN (neighbor_interface_config_v6only
,
2912 neighbor_interface_config_v6only_cmd
,
2913 "neighbor WORD interface v6only [peer-group WORD]",
2915 "Interface name or neighbor tag\n"
2916 "Enable BGP on interface\n"
2917 "Enable BGP with v6 link-local only\n"
2918 "Member of the peer-group\n"
2919 "Peer-group name\n")
2922 int idx_peer_group_word
= 5;
2924 if (argc
> idx_peer_group_word
)
2925 return peer_conf_interface_get(
2926 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
2927 argv
[idx_peer_group_word
]->arg
, NULL
);
2929 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2930 SAFI_UNICAST
, 1, NULL
, NULL
);
2934 DEFUN (neighbor_interface_config_remote_as
,
2935 neighbor_interface_config_remote_as_cmd
,
2936 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
2938 "Interface name or neighbor tag\n"
2939 "Enable BGP on interface\n"
2940 "Specify a BGP neighbor\n"
2942 "Internal BGP peer\n"
2943 "External BGP peer\n")
2946 int idx_remote_as
= 4;
2947 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2948 SAFI_UNICAST
, 0, NULL
,
2949 argv
[idx_remote_as
]->arg
);
2952 DEFUN (neighbor_interface_v6only_config_remote_as
,
2953 neighbor_interface_v6only_config_remote_as_cmd
,
2954 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
2956 "Interface name or neighbor tag\n"
2957 "Enable BGP with v6 link-local only\n"
2958 "Enable BGP on interface\n"
2959 "Specify a BGP neighbor\n"
2961 "Internal BGP peer\n"
2962 "External BGP peer\n")
2965 int idx_remote_as
= 5;
2966 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2967 SAFI_UNICAST
, 1, NULL
,
2968 argv
[idx_remote_as
]->arg
);
2971 DEFUN (neighbor_peer_group
,
2972 neighbor_peer_group_cmd
,
2973 "neighbor WORD peer-group",
2975 "Interface name or neighbor tag\n"
2976 "Configure peer-group\n")
2978 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2981 struct peer_group
*group
;
2983 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
2985 vty_out(vty
, "%% Name conflict with interface: \n");
2986 return CMD_WARNING_CONFIG_FAILED
;
2989 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
2991 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
2992 return CMD_WARNING_CONFIG_FAILED
;
3000 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3004 "Specify a BGP neighbor\n"
3006 "Internal BGP peer\n"
3007 "External BGP peer\n")
3009 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3013 struct peer_group
*group
;
3017 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3019 /* look up for neighbor by interface name config. */
3020 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3022 /* Request zebra to terminate IPv6 RAs on this
3025 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3030 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3032 peer_group_delete(group
);
3034 vty_out(vty
, "%% Create the peer-group first\n");
3035 return CMD_WARNING_CONFIG_FAILED
;
3038 peer
= peer_lookup(bgp
, &su
);
3040 if (peer_dynamic_neighbor(peer
)) {
3042 "%% Operation not allowed on a dynamic neighbor\n");
3043 return CMD_WARNING_CONFIG_FAILED
;
3046 other
= peer
->doppelganger
;
3048 if (other
&& other
->status
!= Deleted
)
3056 DEFUN (no_neighbor_interface_config
,
3057 no_neighbor_interface_config_cmd
,
3058 "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]",
3062 "Configure BGP on interface\n"
3063 "Enable BGP with v6 link-local only\n"
3064 "Member of the peer-group\n"
3066 "Specify a BGP neighbor\n"
3068 "Internal BGP peer\n"
3069 "External BGP peer\n")
3071 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3075 /* look up for neighbor by interface name config. */
3076 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3078 /* Request zebra to terminate IPv6 RAs on this interface. */
3080 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3083 vty_out(vty
, "%% Create the bgp interface first\n");
3084 return CMD_WARNING_CONFIG_FAILED
;
3089 DEFUN (no_neighbor_peer_group
,
3090 no_neighbor_peer_group_cmd
,
3091 "no neighbor WORD peer-group",
3095 "Configure peer-group\n")
3097 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3099 struct peer_group
*group
;
3101 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3103 peer_group_delete(group
);
3105 vty_out(vty
, "%% Create the peer-group first\n");
3106 return CMD_WARNING_CONFIG_FAILED
;
3111 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3112 no_neighbor_interface_peer_group_remote_as_cmd
,
3113 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3116 "Interface name or neighbor tag\n"
3117 "Specify a BGP neighbor\n"
3119 "Internal BGP peer\n"
3120 "External BGP peer\n")
3122 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3124 struct peer_group
*group
;
3127 /* look up for neighbor by interface name config. */
3128 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3130 peer_as_change(peer
, 0, AS_SPECIFIED
);
3134 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3136 peer_group_remote_as_delete(group
);
3138 vty_out(vty
, "%% Create the peer-group or interface first\n");
3139 return CMD_WARNING_CONFIG_FAILED
;
3144 DEFUN (neighbor_local_as
,
3145 neighbor_local_as_cmd
,
3146 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3149 "Specify a local-as number\n"
3150 "AS number used as local AS\n")
3158 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3160 return CMD_WARNING_CONFIG_FAILED
;
3162 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3163 ret
= peer_local_as_set(peer
, as
, 0, 0);
3164 return bgp_vty_return(vty
, ret
);
3167 DEFUN (neighbor_local_as_no_prepend
,
3168 neighbor_local_as_no_prepend_cmd
,
3169 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3172 "Specify a local-as number\n"
3173 "AS number used as local AS\n"
3174 "Do not prepend local-as to updates from ebgp peers\n")
3182 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3184 return CMD_WARNING_CONFIG_FAILED
;
3186 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3187 ret
= peer_local_as_set(peer
, as
, 1, 0);
3188 return bgp_vty_return(vty
, ret
);
3191 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3192 neighbor_local_as_no_prepend_replace_as_cmd
,
3193 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3196 "Specify a local-as number\n"
3197 "AS number used as local AS\n"
3198 "Do not prepend local-as to updates from ebgp peers\n"
3199 "Do not prepend local-as to updates from ibgp peers\n")
3207 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3209 return CMD_WARNING_CONFIG_FAILED
;
3211 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3212 ret
= peer_local_as_set(peer
, as
, 1, 1);
3213 return bgp_vty_return(vty
, ret
);
3216 DEFUN (no_neighbor_local_as
,
3217 no_neighbor_local_as_cmd
,
3218 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3222 "Specify a local-as number\n"
3223 "AS number used as local AS\n"
3224 "Do not prepend local-as to updates from ebgp peers\n"
3225 "Do not prepend local-as to updates from ibgp peers\n")
3231 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3233 return CMD_WARNING_CONFIG_FAILED
;
3235 ret
= peer_local_as_unset(peer
);
3236 return bgp_vty_return(vty
, ret
);
3240 DEFUN (neighbor_solo
,
3242 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3245 "Solo peer - part of its own update group\n")
3251 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3253 return CMD_WARNING_CONFIG_FAILED
;
3255 ret
= update_group_adjust_soloness(peer
, 1);
3256 return bgp_vty_return(vty
, ret
);
3259 DEFUN (no_neighbor_solo
,
3260 no_neighbor_solo_cmd
,
3261 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3265 "Solo peer - part of its own update group\n")
3271 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3273 return CMD_WARNING_CONFIG_FAILED
;
3275 ret
= update_group_adjust_soloness(peer
, 0);
3276 return bgp_vty_return(vty
, ret
);
3279 DEFUN (neighbor_password
,
3280 neighbor_password_cmd
,
3281 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3292 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3294 return CMD_WARNING_CONFIG_FAILED
;
3296 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3297 return bgp_vty_return(vty
, ret
);
3300 DEFUN (no_neighbor_password
,
3301 no_neighbor_password_cmd
,
3302 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3313 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3315 return CMD_WARNING_CONFIG_FAILED
;
3317 ret
= peer_password_unset(peer
);
3318 return bgp_vty_return(vty
, ret
);
3321 DEFUN (neighbor_activate
,
3322 neighbor_activate_cmd
,
3323 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3326 "Enable the Address Family for this Neighbor\n")
3332 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3334 return CMD_WARNING_CONFIG_FAILED
;
3336 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3337 return bgp_vty_return(vty
, ret
);
3340 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3341 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3342 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3343 "Enable the Address Family for this Neighbor\n")
3345 DEFUN (no_neighbor_activate
,
3346 no_neighbor_activate_cmd
,
3347 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3351 "Enable the Address Family for this Neighbor\n")
3358 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3360 return CMD_WARNING_CONFIG_FAILED
;
3362 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3363 return bgp_vty_return(vty
, ret
);
3366 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3367 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3368 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3369 "Enable the Address Family for this Neighbor\n")
3371 DEFUN (neighbor_set_peer_group
,
3372 neighbor_set_peer_group_cmd
,
3373 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3376 "Member of the peer-group\n"
3377 "Peer-group name\n")
3379 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3386 struct peer_group
*group
;
3388 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3390 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3392 vty_out(vty
, "%% Malformed address or name: %s\n",
3393 argv
[idx_peer
]->arg
);
3394 return CMD_WARNING_CONFIG_FAILED
;
3397 if (peer_address_self_check(bgp
, &su
)) {
3399 "%% Can not configure the local system as neighbor\n");
3400 return CMD_WARNING_CONFIG_FAILED
;
3403 /* Disallow for dynamic neighbor. */
3404 peer
= peer_lookup(bgp
, &su
);
3405 if (peer
&& peer_dynamic_neighbor(peer
)) {
3407 "%% Operation not allowed on a dynamic neighbor\n");
3408 return CMD_WARNING_CONFIG_FAILED
;
3412 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3414 vty_out(vty
, "%% Configure the peer-group first\n");
3415 return CMD_WARNING_CONFIG_FAILED
;
3418 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3420 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3422 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3424 return CMD_WARNING_CONFIG_FAILED
;
3427 return bgp_vty_return(vty
, ret
);
3430 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3431 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3432 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3433 "Member of the peer-group\n"
3434 "Peer-group name\n")
3436 DEFUN (no_neighbor_set_peer_group
,
3437 no_neighbor_set_peer_group_cmd
,
3438 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3442 "Member of the peer-group\n"
3443 "Peer-group name\n")
3445 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3450 struct peer_group
*group
;
3452 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3454 return CMD_WARNING_CONFIG_FAILED
;
3456 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3458 vty_out(vty
, "%% Configure the peer-group first\n");
3459 return CMD_WARNING_CONFIG_FAILED
;
3462 ret
= peer_delete(peer
);
3464 return bgp_vty_return(vty
, ret
);
3467 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3468 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3469 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3470 "Member of the peer-group\n"
3471 "Peer-group name\n")
3473 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3474 uint32_t flag
, int set
)
3479 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3481 return CMD_WARNING_CONFIG_FAILED
;
3484 * If 'neighbor <interface>', then this is for directly connected peers,
3485 * we should not accept disable-connected-check.
3487 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3489 "%s is directly connected peer, cannot accept disable-"
3490 "connected-check\n",
3492 return CMD_WARNING_CONFIG_FAILED
;
3495 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3496 peer_tx_shutdown_message_unset(peer
);
3499 ret
= peer_flag_set(peer
, flag
);
3501 ret
= peer_flag_unset(peer
, flag
);
3503 return bgp_vty_return(vty
, ret
);
3506 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3508 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3511 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3514 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3517 /* neighbor passive. */
3518 DEFUN (neighbor_passive
,
3519 neighbor_passive_cmd
,
3520 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3523 "Don't send open messages to this neighbor\n")
3526 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3529 DEFUN (no_neighbor_passive
,
3530 no_neighbor_passive_cmd
,
3531 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3535 "Don't send open messages to this neighbor\n")
3538 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3541 /* neighbor shutdown. */
3542 DEFUN (neighbor_shutdown_msg
,
3543 neighbor_shutdown_msg_cmd
,
3544 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3547 "Administratively shut down this neighbor\n"
3548 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3549 "Shutdown message\n")
3555 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3559 return CMD_WARNING_CONFIG_FAILED
;
3560 message
= argv_concat(argv
, argc
, 4);
3561 peer_tx_shutdown_message_set(peer
, message
);
3562 XFREE(MTYPE_TMP
, message
);
3565 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3568 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3569 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3570 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3571 "Administratively shut down this neighbor\n")
3573 DEFUN (no_neighbor_shutdown_msg
,
3574 no_neighbor_shutdown_msg_cmd
,
3575 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3579 "Administratively shut down this neighbor\n"
3580 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3581 "Shutdown message\n")
3585 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3586 PEER_FLAG_SHUTDOWN
);
3589 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3590 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3591 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3592 "Administratively shut down this neighbor\n")
3594 /* neighbor capability dynamic. */
3595 DEFUN (neighbor_capability_dynamic
,
3596 neighbor_capability_dynamic_cmd
,
3597 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3600 "Advertise capability to the peer\n"
3601 "Advertise dynamic capability to this neighbor\n")
3604 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3605 PEER_FLAG_DYNAMIC_CAPABILITY
);
3608 DEFUN (no_neighbor_capability_dynamic
,
3609 no_neighbor_capability_dynamic_cmd
,
3610 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3614 "Advertise capability to the peer\n"
3615 "Advertise dynamic capability to this neighbor\n")
3618 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3619 PEER_FLAG_DYNAMIC_CAPABILITY
);
3622 /* neighbor dont-capability-negotiate */
3623 DEFUN (neighbor_dont_capability_negotiate
,
3624 neighbor_dont_capability_negotiate_cmd
,
3625 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3628 "Do not perform capability negotiation\n")
3631 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3632 PEER_FLAG_DONT_CAPABILITY
);
3635 DEFUN (no_neighbor_dont_capability_negotiate
,
3636 no_neighbor_dont_capability_negotiate_cmd
,
3637 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3641 "Do not perform capability negotiation\n")
3644 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3645 PEER_FLAG_DONT_CAPABILITY
);
3648 /* neighbor capability extended next hop encoding */
3649 DEFUN (neighbor_capability_enhe
,
3650 neighbor_capability_enhe_cmd
,
3651 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3654 "Advertise capability to the peer\n"
3655 "Advertise extended next-hop capability to the peer\n")
3658 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3659 PEER_FLAG_CAPABILITY_ENHE
);
3662 DEFUN (no_neighbor_capability_enhe
,
3663 no_neighbor_capability_enhe_cmd
,
3664 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3668 "Advertise capability to the peer\n"
3669 "Advertise extended next-hop capability to the peer\n")
3672 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3673 PEER_FLAG_CAPABILITY_ENHE
);
3676 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3677 afi_t afi
, safi_t safi
, uint32_t flag
,
3683 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3685 return CMD_WARNING_CONFIG_FAILED
;
3688 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3690 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3692 return bgp_vty_return(vty
, ret
);
3695 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3696 afi_t afi
, safi_t safi
, uint32_t flag
)
3698 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3701 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3702 afi_t afi
, safi_t safi
, uint32_t flag
)
3704 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3707 /* neighbor capability orf prefix-list. */
3708 DEFUN (neighbor_capability_orf_prefix
,
3709 neighbor_capability_orf_prefix_cmd
,
3710 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3713 "Advertise capability to the peer\n"
3714 "Advertise ORF capability to the peer\n"
3715 "Advertise prefixlist ORF capability to this neighbor\n"
3716 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3717 "Capability to RECEIVE the ORF from this neighbor\n"
3718 "Capability to SEND the ORF to this neighbor\n")
3721 int idx_send_recv
= 5;
3724 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3725 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3726 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3727 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3728 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3729 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3731 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3732 return CMD_WARNING_CONFIG_FAILED
;
3735 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3736 bgp_node_safi(vty
), flag
);
3740 neighbor_capability_orf_prefix
,
3741 neighbor_capability_orf_prefix_hidden_cmd
,
3742 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3743 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3744 "Advertise capability to the peer\n"
3745 "Advertise ORF capability to the peer\n"
3746 "Advertise prefixlist ORF capability to this neighbor\n"
3747 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3748 "Capability to RECEIVE the ORF from this neighbor\n"
3749 "Capability to SEND the ORF to this neighbor\n")
3751 DEFUN (no_neighbor_capability_orf_prefix
,
3752 no_neighbor_capability_orf_prefix_cmd
,
3753 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3757 "Advertise capability to the peer\n"
3758 "Advertise ORF capability to the peer\n"
3759 "Advertise prefixlist ORF capability to this neighbor\n"
3760 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3761 "Capability to RECEIVE the ORF from this neighbor\n"
3762 "Capability to SEND the ORF to this neighbor\n")
3765 int idx_send_recv
= 6;
3768 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3769 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3770 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3771 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3772 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3773 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3775 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3776 return CMD_WARNING_CONFIG_FAILED
;
3779 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3780 bgp_node_afi(vty
), bgp_node_safi(vty
),
3785 no_neighbor_capability_orf_prefix
,
3786 no_neighbor_capability_orf_prefix_hidden_cmd
,
3787 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3788 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3789 "Advertise capability to the peer\n"
3790 "Advertise ORF capability to the peer\n"
3791 "Advertise prefixlist ORF capability to this neighbor\n"
3792 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3793 "Capability to RECEIVE the ORF from this neighbor\n"
3794 "Capability to SEND the ORF to this neighbor\n")
3796 /* neighbor next-hop-self. */
3797 DEFUN (neighbor_nexthop_self
,
3798 neighbor_nexthop_self_cmd
,
3799 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3802 "Disable the next hop calculation for this neighbor\n")
3805 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3806 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3809 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3810 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3811 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3812 "Disable the next hop calculation for this neighbor\n")
3814 /* neighbor next-hop-self. */
3815 DEFUN (neighbor_nexthop_self_force
,
3816 neighbor_nexthop_self_force_cmd
,
3817 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3820 "Disable the next hop calculation for this neighbor\n"
3821 "Set the next hop to self for reflected routes\n")
3824 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3826 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3829 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3830 neighbor_nexthop_self_force_hidden_cmd
,
3831 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3832 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3833 "Disable the next hop calculation for this neighbor\n"
3834 "Set the next hop to self for reflected routes\n")
3836 DEFUN (no_neighbor_nexthop_self
,
3837 no_neighbor_nexthop_self_cmd
,
3838 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3842 "Disable the next hop calculation for this neighbor\n")
3845 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3846 bgp_node_afi(vty
), bgp_node_safi(vty
),
3847 PEER_FLAG_NEXTHOP_SELF
);
3850 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3851 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3852 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3853 "Disable the next hop calculation for this neighbor\n")
3855 DEFUN (no_neighbor_nexthop_self_force
,
3856 no_neighbor_nexthop_self_force_cmd
,
3857 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3861 "Disable the next hop calculation for this neighbor\n"
3862 "Set the next hop to self for reflected routes\n")
3865 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3866 bgp_node_afi(vty
), bgp_node_safi(vty
),
3867 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3870 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3871 no_neighbor_nexthop_self_force_hidden_cmd
,
3872 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3873 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3874 "Disable the next hop calculation for this neighbor\n"
3875 "Set the next hop to self for reflected routes\n")
3877 /* neighbor as-override */
3878 DEFUN (neighbor_as_override
,
3879 neighbor_as_override_cmd
,
3880 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3883 "Override ASNs in outbound updates if aspath equals remote-as\n")
3886 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3887 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
3890 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
3891 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3892 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3893 "Override ASNs in outbound updates if aspath equals remote-as\n")
3895 DEFUN (no_neighbor_as_override
,
3896 no_neighbor_as_override_cmd
,
3897 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3901 "Override ASNs in outbound updates if aspath equals remote-as\n")
3904 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3905 bgp_node_afi(vty
), bgp_node_safi(vty
),
3906 PEER_FLAG_AS_OVERRIDE
);
3909 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
3910 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3911 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3912 "Override ASNs in outbound updates if aspath equals remote-as\n")
3914 /* neighbor remove-private-AS. */
3915 DEFUN (neighbor_remove_private_as
,
3916 neighbor_remove_private_as_cmd
,
3917 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3920 "Remove private ASNs in outbound updates\n")
3923 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3925 PEER_FLAG_REMOVE_PRIVATE_AS
);
3928 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
3929 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3930 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3931 "Remove private ASNs in outbound updates\n")
3933 DEFUN (neighbor_remove_private_as_all
,
3934 neighbor_remove_private_as_all_cmd
,
3935 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3938 "Remove private ASNs in outbound updates\n"
3939 "Apply to all AS numbers\n")
3942 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3944 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
3947 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
3948 neighbor_remove_private_as_all_hidden_cmd
,
3949 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3950 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3951 "Remove private ASNs in outbound updates\n"
3952 "Apply to all AS numbers")
3954 DEFUN (neighbor_remove_private_as_replace_as
,
3955 neighbor_remove_private_as_replace_as_cmd
,
3956 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3959 "Remove private ASNs in outbound updates\n"
3960 "Replace private ASNs with our ASN in outbound updates\n")
3963 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3965 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
3968 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
3969 neighbor_remove_private_as_replace_as_hidden_cmd
,
3970 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3971 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3972 "Remove private ASNs in outbound updates\n"
3973 "Replace private ASNs with our ASN in outbound updates\n")
3975 DEFUN (neighbor_remove_private_as_all_replace_as
,
3976 neighbor_remove_private_as_all_replace_as_cmd
,
3977 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3980 "Remove private ASNs in outbound updates\n"
3981 "Apply to all AS numbers\n"
3982 "Replace private ASNs with our ASN in outbound updates\n")
3985 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3987 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
3991 neighbor_remove_private_as_all_replace_as
,
3992 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
3993 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3994 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3995 "Remove private ASNs in outbound updates\n"
3996 "Apply to all AS numbers\n"
3997 "Replace private ASNs with our ASN in outbound updates\n")
3999 DEFUN (no_neighbor_remove_private_as
,
4000 no_neighbor_remove_private_as_cmd
,
4001 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4005 "Remove private ASNs in outbound updates\n")
4008 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4009 bgp_node_afi(vty
), bgp_node_safi(vty
),
4010 PEER_FLAG_REMOVE_PRIVATE_AS
);
4013 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4014 no_neighbor_remove_private_as_hidden_cmd
,
4015 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4016 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4017 "Remove private ASNs in outbound updates\n")
4019 DEFUN (no_neighbor_remove_private_as_all
,
4020 no_neighbor_remove_private_as_all_cmd
,
4021 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4025 "Remove private ASNs in outbound updates\n"
4026 "Apply to all AS numbers\n")
4029 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4030 bgp_node_afi(vty
), bgp_node_safi(vty
),
4031 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4034 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4035 no_neighbor_remove_private_as_all_hidden_cmd
,
4036 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4037 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4038 "Remove private ASNs in outbound updates\n"
4039 "Apply to all AS numbers\n")
4041 DEFUN (no_neighbor_remove_private_as_replace_as
,
4042 no_neighbor_remove_private_as_replace_as_cmd
,
4043 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4047 "Remove private ASNs in outbound updates\n"
4048 "Replace private ASNs with our ASN in outbound updates\n")
4051 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4052 bgp_node_afi(vty
), bgp_node_safi(vty
),
4053 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4056 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4057 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4058 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4059 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4060 "Remove private ASNs in outbound updates\n"
4061 "Replace private ASNs with our ASN in outbound updates\n")
4063 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4064 no_neighbor_remove_private_as_all_replace_as_cmd
,
4065 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4069 "Remove private ASNs in outbound updates\n"
4070 "Apply to all AS numbers\n"
4071 "Replace private ASNs with our ASN in outbound updates\n")
4074 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4075 bgp_node_afi(vty
), bgp_node_safi(vty
),
4076 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4080 no_neighbor_remove_private_as_all_replace_as
,
4081 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4082 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4083 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4084 "Remove private ASNs in outbound updates\n"
4085 "Apply to all AS numbers\n"
4086 "Replace private ASNs with our ASN in outbound updates\n")
4089 /* neighbor send-community. */
4090 DEFUN (neighbor_send_community
,
4091 neighbor_send_community_cmd
,
4092 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4095 "Send Community attribute to this neighbor\n")
4099 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4101 PEER_FLAG_SEND_COMMUNITY
);
4104 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4105 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4106 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4107 "Send Community attribute to this neighbor\n")
4109 DEFUN (no_neighbor_send_community
,
4110 no_neighbor_send_community_cmd
,
4111 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4115 "Send Community attribute to this neighbor\n")
4119 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4120 bgp_node_afi(vty
), bgp_node_safi(vty
),
4121 PEER_FLAG_SEND_COMMUNITY
);
4124 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4125 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4126 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4127 "Send Community attribute to this neighbor\n")
4129 /* neighbor send-community extended. */
4130 DEFUN (neighbor_send_community_type
,
4131 neighbor_send_community_type_cmd
,
4132 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4135 "Send Community attribute to this neighbor\n"
4136 "Send Standard and Extended Community attributes\n"
4137 "Send Standard, Large and Extended Community attributes\n"
4138 "Send Extended Community attributes\n"
4139 "Send Standard Community attributes\n"
4140 "Send Large Community attributes\n")
4144 const char *type
= argv
[argc
- 1]->text
;
4146 if (strmatch(type
, "standard")) {
4147 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4148 } else if (strmatch(type
, "extended")) {
4149 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4150 } else if (strmatch(type
, "large")) {
4151 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4152 } else if (strmatch(type
, "both")) {
4153 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4154 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4155 } else { /* if (strmatch(type, "all")) */
4156 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4157 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4158 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4161 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4162 bgp_node_safi(vty
), flag
);
4166 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4167 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4168 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4169 "Send Community attribute to this neighbor\n"
4170 "Send Standard and Extended Community attributes\n"
4171 "Send Standard, Large and Extended Community attributes\n"
4172 "Send Extended Community attributes\n"
4173 "Send Standard Community attributes\n"
4174 "Send Large Community attributes\n")
4176 DEFUN (no_neighbor_send_community_type
,
4177 no_neighbor_send_community_type_cmd
,
4178 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4182 "Send Community attribute to this neighbor\n"
4183 "Send Standard and Extended Community attributes\n"
4184 "Send Standard, Large and Extended Community attributes\n"
4185 "Send Extended Community attributes\n"
4186 "Send Standard Community attributes\n"
4187 "Send Large Community attributes\n")
4191 const char *type
= argv
[argc
- 1]->text
;
4193 if (strmatch(type
, "standard")) {
4194 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4195 } else if (strmatch(type
, "extended")) {
4196 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4197 } else if (strmatch(type
, "large")) {
4198 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4199 } else if (strmatch(type
, "both")) {
4200 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4201 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4202 } else { /* if (strmatch(type, "all")) */
4203 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4204 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4205 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4208 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4209 bgp_node_afi(vty
), bgp_node_safi(vty
),
4214 no_neighbor_send_community_type
,
4215 no_neighbor_send_community_type_hidden_cmd
,
4216 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4217 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4218 "Send Community attribute to this neighbor\n"
4219 "Send Standard and Extended Community attributes\n"
4220 "Send Standard, Large and Extended Community attributes\n"
4221 "Send Extended Community attributes\n"
4222 "Send Standard Community attributes\n"
4223 "Send Large Community attributes\n")
4225 /* neighbor soft-reconfig. */
4226 DEFUN (neighbor_soft_reconfiguration
,
4227 neighbor_soft_reconfiguration_cmd
,
4228 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4231 "Per neighbor soft reconfiguration\n"
4232 "Allow inbound soft reconfiguration for this neighbor\n")
4235 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4237 PEER_FLAG_SOFT_RECONFIG
);
4240 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4241 neighbor_soft_reconfiguration_hidden_cmd
,
4242 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4243 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4244 "Per neighbor soft reconfiguration\n"
4245 "Allow inbound soft reconfiguration for this neighbor\n")
4247 DEFUN (no_neighbor_soft_reconfiguration
,
4248 no_neighbor_soft_reconfiguration_cmd
,
4249 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4253 "Per neighbor soft reconfiguration\n"
4254 "Allow inbound soft reconfiguration for this neighbor\n")
4257 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4258 bgp_node_afi(vty
), bgp_node_safi(vty
),
4259 PEER_FLAG_SOFT_RECONFIG
);
4262 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4263 no_neighbor_soft_reconfiguration_hidden_cmd
,
4264 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4265 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4266 "Per neighbor soft reconfiguration\n"
4267 "Allow inbound soft reconfiguration for this neighbor\n")
4269 DEFUN (neighbor_route_reflector_client
,
4270 neighbor_route_reflector_client_cmd
,
4271 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4274 "Configure a neighbor as Route Reflector client\n")
4280 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4282 return CMD_WARNING_CONFIG_FAILED
;
4284 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4286 PEER_FLAG_REFLECTOR_CLIENT
);
4289 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4290 neighbor_route_reflector_client_hidden_cmd
,
4291 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4292 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4293 "Configure a neighbor as Route Reflector client\n")
4295 DEFUN (no_neighbor_route_reflector_client
,
4296 no_neighbor_route_reflector_client_cmd
,
4297 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4301 "Configure a neighbor as Route Reflector client\n")
4304 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4305 bgp_node_afi(vty
), bgp_node_safi(vty
),
4306 PEER_FLAG_REFLECTOR_CLIENT
);
4309 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4310 no_neighbor_route_reflector_client_hidden_cmd
,
4311 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4312 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4313 "Configure a neighbor as Route Reflector client\n")
4315 /* neighbor route-server-client. */
4316 DEFUN (neighbor_route_server_client
,
4317 neighbor_route_server_client_cmd
,
4318 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4321 "Configure a neighbor as Route Server client\n")
4326 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4328 return CMD_WARNING_CONFIG_FAILED
;
4329 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4331 PEER_FLAG_RSERVER_CLIENT
);
4334 ALIAS_HIDDEN(neighbor_route_server_client
,
4335 neighbor_route_server_client_hidden_cmd
,
4336 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4337 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4338 "Configure a neighbor as Route Server client\n")
4340 DEFUN (no_neighbor_route_server_client
,
4341 no_neighbor_route_server_client_cmd
,
4342 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4346 "Configure a neighbor as Route Server client\n")
4349 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4350 bgp_node_afi(vty
), bgp_node_safi(vty
),
4351 PEER_FLAG_RSERVER_CLIENT
);
4354 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4355 no_neighbor_route_server_client_hidden_cmd
,
4356 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4357 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4358 "Configure a neighbor as Route Server client\n")
4360 DEFUN (neighbor_nexthop_local_unchanged
,
4361 neighbor_nexthop_local_unchanged_cmd
,
4362 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4365 "Configure treatment of outgoing link-local nexthop attribute\n"
4366 "Leave link-local nexthop unchanged for this peer\n")
4369 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4371 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4374 DEFUN (no_neighbor_nexthop_local_unchanged
,
4375 no_neighbor_nexthop_local_unchanged_cmd
,
4376 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4380 "Configure treatment of outgoing link-local-nexthop attribute\n"
4381 "Leave link-local nexthop unchanged for this peer\n")
4384 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4385 bgp_node_afi(vty
), bgp_node_safi(vty
),
4386 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4389 DEFUN (neighbor_attr_unchanged
,
4390 neighbor_attr_unchanged_cmd
,
4391 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4394 "BGP attribute is propagated unchanged to this neighbor\n"
4395 "As-path attribute\n"
4396 "Nexthop attribute\n"
4400 char *peer_str
= argv
[1]->arg
;
4403 afi_t afi
= bgp_node_afi(vty
);
4404 safi_t safi
= bgp_node_safi(vty
);
4406 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4408 return CMD_WARNING_CONFIG_FAILED
;
4410 if (argv_find(argv
, argc
, "as-path", &idx
))
4411 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4413 if (argv_find(argv
, argc
, "next-hop", &idx
))
4414 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4416 if (argv_find(argv
, argc
, "med", &idx
))
4417 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4419 /* no flags means all of them! */
4421 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4422 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4423 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4425 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4426 && peer_af_flag_check(peer
, afi
, safi
,
4427 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4428 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4429 PEER_FLAG_AS_PATH_UNCHANGED
);
4432 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4433 && peer_af_flag_check(peer
, afi
, safi
,
4434 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4435 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4436 PEER_FLAG_NEXTHOP_UNCHANGED
);
4439 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4440 && peer_af_flag_check(peer
, afi
, safi
,
4441 PEER_FLAG_MED_UNCHANGED
)) {
4442 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4443 PEER_FLAG_MED_UNCHANGED
);
4447 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4451 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4452 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4453 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4454 "BGP attribute is propagated unchanged to this neighbor\n"
4455 "As-path attribute\n"
4456 "Nexthop attribute\n"
4459 DEFUN (no_neighbor_attr_unchanged
,
4460 no_neighbor_attr_unchanged_cmd
,
4461 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4465 "BGP attribute is propagated unchanged to this neighbor\n"
4466 "As-path attribute\n"
4467 "Nexthop attribute\n"
4471 char *peer
= argv
[2]->arg
;
4474 if (argv_find(argv
, argc
, "as-path", &idx
))
4475 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4477 if (argv_find(argv
, argc
, "next-hop", &idx
))
4478 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4480 if (argv_find(argv
, argc
, "med", &idx
))
4481 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4483 if (!flags
) // no flags means all of them!
4485 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4486 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4487 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4490 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4491 bgp_node_safi(vty
), flags
);
4495 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4496 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4497 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4498 "BGP attribute is propagated unchanged to this neighbor\n"
4499 "As-path attribute\n"
4500 "Nexthop attribute\n"
4503 /* EBGP multihop configuration. */
4504 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4505 const char *ttl_str
)
4510 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4512 return CMD_WARNING_CONFIG_FAILED
;
4515 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4520 ttl
= strtoul(ttl_str
, NULL
, 10);
4522 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4525 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4529 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4531 return CMD_WARNING_CONFIG_FAILED
;
4533 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4536 /* neighbor ebgp-multihop. */
4537 DEFUN (neighbor_ebgp_multihop
,
4538 neighbor_ebgp_multihop_cmd
,
4539 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4542 "Allow EBGP neighbors not on directly connected networks\n")
4545 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4548 DEFUN (neighbor_ebgp_multihop_ttl
,
4549 neighbor_ebgp_multihop_ttl_cmd
,
4550 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4553 "Allow EBGP neighbors not on directly connected networks\n"
4554 "maximum hop count\n")
4558 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4559 argv
[idx_number
]->arg
);
4562 DEFUN (no_neighbor_ebgp_multihop
,
4563 no_neighbor_ebgp_multihop_cmd
,
4564 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4568 "Allow EBGP neighbors not on directly connected networks\n"
4569 "maximum hop count\n")
4572 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4576 /* disable-connected-check */
4577 DEFUN (neighbor_disable_connected_check
,
4578 neighbor_disable_connected_check_cmd
,
4579 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4582 "one-hop away EBGP peer using loopback address\n"
4583 "Enforce EBGP neighbors perform multihop\n")
4586 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4587 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4590 DEFUN (no_neighbor_disable_connected_check
,
4591 no_neighbor_disable_connected_check_cmd
,
4592 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4596 "one-hop away EBGP peer using loopback address\n"
4597 "Enforce EBGP neighbors perform multihop\n")
4600 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4601 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4605 /* enforce-first-as */
4606 DEFUN (neighbor_enforce_first_as
,
4607 neighbor_enforce_first_as_cmd
,
4608 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4611 "Enforce the first AS for EBGP routes\n")
4615 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4616 PEER_FLAG_ENFORCE_FIRST_AS
);
4619 DEFUN (no_neighbor_enforce_first_as
,
4620 no_neighbor_enforce_first_as_cmd
,
4621 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4625 "Enforce the first AS for EBGP routes\n")
4629 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4630 PEER_FLAG_ENFORCE_FIRST_AS
);
4634 DEFUN (neighbor_description
,
4635 neighbor_description_cmd
,
4636 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4639 "Neighbor specific description\n"
4640 "Up to 80 characters describing this neighbor\n")
4647 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4649 return CMD_WARNING_CONFIG_FAILED
;
4651 str
= argv_concat(argv
, argc
, idx_line
);
4653 peer_description_set(peer
, str
);
4655 XFREE(MTYPE_TMP
, str
);
4660 DEFUN (no_neighbor_description
,
4661 no_neighbor_description_cmd
,
4662 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4666 "Neighbor specific description\n")
4671 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4673 return CMD_WARNING_CONFIG_FAILED
;
4675 peer_description_unset(peer
);
4680 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4681 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4682 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4683 "Neighbor specific description\n"
4684 "Up to 80 characters describing this neighbor\n")
4686 /* Neighbor update-source. */
4687 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4688 const char *source_str
)
4694 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4696 return CMD_WARNING_CONFIG_FAILED
;
4702 if (str2sockunion(source_str
, &su
) == 0)
4703 peer_update_source_addr_set(peer
, &su
);
4705 if (str2prefix(source_str
, &p
)) {
4707 "%% Invalid update-source, remove prefix length \n");
4708 return CMD_WARNING_CONFIG_FAILED
;
4710 peer_update_source_if_set(peer
, source_str
);
4713 peer_update_source_unset(peer
);
4718 #define BGP_UPDATE_SOURCE_HELP_STR \
4721 "Interface name (requires zebra to be running)\n"
4723 DEFUN (neighbor_update_source
,
4724 neighbor_update_source_cmd
,
4725 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4728 "Source of routing updates\n"
4729 BGP_UPDATE_SOURCE_HELP_STR
)
4733 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4734 argv
[idx_peer_2
]->arg
);
4737 DEFUN (no_neighbor_update_source
,
4738 no_neighbor_update_source_cmd
,
4739 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4743 "Source of routing updates\n"
4744 BGP_UPDATE_SOURCE_HELP_STR
)
4747 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4750 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4751 afi_t afi
, safi_t safi
,
4752 const char *rmap
, int set
)
4757 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4759 return CMD_WARNING_CONFIG_FAILED
;
4762 ret
= peer_default_originate_set(peer
, afi
, safi
, rmap
);
4764 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4766 return bgp_vty_return(vty
, ret
);
4769 /* neighbor default-originate. */
4770 DEFUN (neighbor_default_originate
,
4771 neighbor_default_originate_cmd
,
4772 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4775 "Originate default route to this neighbor\n")
4778 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4780 bgp_node_safi(vty
), NULL
, 1);
4783 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4784 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4785 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4786 "Originate default route to this neighbor\n")
4788 DEFUN (neighbor_default_originate_rmap
,
4789 neighbor_default_originate_rmap_cmd
,
4790 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4793 "Originate default route to this neighbor\n"
4794 "Route-map to specify criteria to originate default\n"
4799 return peer_default_originate_set_vty(
4800 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4801 argv
[idx_word
]->arg
, 1);
4805 neighbor_default_originate_rmap
,
4806 neighbor_default_originate_rmap_hidden_cmd
,
4807 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4808 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4809 "Originate default route to this neighbor\n"
4810 "Route-map to specify criteria to originate default\n"
4813 DEFUN (no_neighbor_default_originate
,
4814 no_neighbor_default_originate_cmd
,
4815 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4819 "Originate default route to this neighbor\n"
4820 "Route-map to specify criteria to originate default\n"
4824 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4826 bgp_node_safi(vty
), NULL
, 0);
4830 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4831 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4832 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4833 "Originate default route to this neighbor\n"
4834 "Route-map to specify criteria to originate default\n"
4838 /* Set neighbor's BGP port. */
4839 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4840 const char *port_str
)
4846 peer
= peer_lookup_vty(vty
, ip_str
);
4848 return CMD_WARNING_CONFIG_FAILED
;
4851 sp
= getservbyname("bgp", "tcp");
4852 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
4854 port
= strtoul(port_str
, NULL
, 10);
4857 peer_port_set(peer
, port
);
4862 /* Set specified peer's BGP port. */
4863 DEFUN (neighbor_port
,
4865 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
4868 "Neighbor's BGP port\n"
4869 "TCP port number\n")
4873 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
4874 argv
[idx_number
]->arg
);
4877 DEFUN (no_neighbor_port
,
4878 no_neighbor_port_cmd
,
4879 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
4883 "Neighbor's BGP port\n"
4884 "TCP port number\n")
4887 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
4891 /* neighbor weight. */
4892 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4893 safi_t safi
, const char *weight_str
)
4897 unsigned long weight
;
4899 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4901 return CMD_WARNING_CONFIG_FAILED
;
4903 weight
= strtoul(weight_str
, NULL
, 10);
4905 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
4906 return bgp_vty_return(vty
, ret
);
4909 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4915 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4917 return CMD_WARNING_CONFIG_FAILED
;
4919 ret
= peer_weight_unset(peer
, afi
, safi
);
4920 return bgp_vty_return(vty
, ret
);
4923 DEFUN (neighbor_weight
,
4924 neighbor_weight_cmd
,
4925 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4928 "Set default weight for routes from this neighbor\n"
4933 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4934 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
4937 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
4938 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4939 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4940 "Set default weight for routes from this neighbor\n"
4943 DEFUN (no_neighbor_weight
,
4944 no_neighbor_weight_cmd
,
4945 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4949 "Set default weight for routes from this neighbor\n"
4953 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
4954 bgp_node_afi(vty
), bgp_node_safi(vty
));
4957 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
4958 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4959 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4960 "Set default weight for routes from this neighbor\n"
4964 /* Override capability negotiation. */
4965 DEFUN (neighbor_override_capability
,
4966 neighbor_override_capability_cmd
,
4967 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4970 "Override capability negotiation result\n")
4973 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4974 PEER_FLAG_OVERRIDE_CAPABILITY
);
4977 DEFUN (no_neighbor_override_capability
,
4978 no_neighbor_override_capability_cmd
,
4979 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4983 "Override capability negotiation result\n")
4986 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4987 PEER_FLAG_OVERRIDE_CAPABILITY
);
4990 DEFUN (neighbor_strict_capability
,
4991 neighbor_strict_capability_cmd
,
4992 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
4995 "Strict capability negotiation match\n")
4999 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5000 PEER_FLAG_STRICT_CAP_MATCH
);
5003 DEFUN (no_neighbor_strict_capability
,
5004 no_neighbor_strict_capability_cmd
,
5005 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5009 "Strict capability negotiation match\n")
5013 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5014 PEER_FLAG_STRICT_CAP_MATCH
);
5017 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5018 const char *keep_str
, const char *hold_str
)
5025 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5027 return CMD_WARNING_CONFIG_FAILED
;
5029 keepalive
= strtoul(keep_str
, NULL
, 10);
5030 holdtime
= strtoul(hold_str
, NULL
, 10);
5032 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5034 return bgp_vty_return(vty
, ret
);
5037 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5042 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5044 return CMD_WARNING_CONFIG_FAILED
;
5046 ret
= peer_timers_unset(peer
);
5048 return bgp_vty_return(vty
, ret
);
5051 DEFUN (neighbor_timers
,
5052 neighbor_timers_cmd
,
5053 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5056 "BGP per neighbor timers\n"
5057 "Keepalive interval\n"
5062 int idx_number_2
= 4;
5063 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5064 argv
[idx_number
]->arg
,
5065 argv
[idx_number_2
]->arg
);
5068 DEFUN (no_neighbor_timers
,
5069 no_neighbor_timers_cmd
,
5070 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5074 "BGP per neighbor timers\n"
5075 "Keepalive interval\n"
5079 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5083 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5084 const char *time_str
)
5090 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5092 return CMD_WARNING_CONFIG_FAILED
;
5094 connect
= strtoul(time_str
, NULL
, 10);
5096 ret
= peer_timers_connect_set(peer
, connect
);
5098 return bgp_vty_return(vty
, ret
);
5101 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5106 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5108 return CMD_WARNING_CONFIG_FAILED
;
5110 ret
= peer_timers_connect_unset(peer
);
5112 return bgp_vty_return(vty
, ret
);
5115 DEFUN (neighbor_timers_connect
,
5116 neighbor_timers_connect_cmd
,
5117 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5120 "BGP per neighbor timers\n"
5121 "BGP connect timer\n"
5126 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5127 argv
[idx_number
]->arg
);
5130 DEFUN (no_neighbor_timers_connect
,
5131 no_neighbor_timers_connect_cmd
,
5132 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5136 "BGP per neighbor timers\n"
5137 "BGP connect timer\n"
5141 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5145 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5146 const char *time_str
, int set
)
5150 uint32_t routeadv
= 0;
5152 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5154 return CMD_WARNING_CONFIG_FAILED
;
5157 routeadv
= strtoul(time_str
, NULL
, 10);
5160 ret
= peer_advertise_interval_set(peer
, routeadv
);
5162 ret
= peer_advertise_interval_unset(peer
);
5164 return bgp_vty_return(vty
, ret
);
5167 DEFUN (neighbor_advertise_interval
,
5168 neighbor_advertise_interval_cmd
,
5169 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5172 "Minimum interval between sending BGP routing updates\n"
5173 "time in seconds\n")
5177 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5178 argv
[idx_number
]->arg
, 1);
5181 DEFUN (no_neighbor_advertise_interval
,
5182 no_neighbor_advertise_interval_cmd
,
5183 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5187 "Minimum interval between sending BGP routing updates\n"
5188 "time in seconds\n")
5191 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5195 /* Time to wait before processing route-map updates */
5196 DEFUN (bgp_set_route_map_delay_timer
,
5197 bgp_set_route_map_delay_timer_cmd
,
5198 "bgp route-map delay-timer (0-600)",
5200 "BGP route-map delay timer\n"
5201 "Time in secs to wait before processing route-map changes\n"
5202 "0 disables the timer, no route updates happen when route-maps change\n")
5205 uint32_t rmap_delay_timer
;
5207 if (argv
[idx_number
]->arg
) {
5208 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5209 bm
->rmap_update_timer
= rmap_delay_timer
;
5211 /* if the dynamic update handling is being disabled, and a timer
5213 * running, stop the timer and act as if the timer has already
5216 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5217 BGP_TIMER_OFF(bm
->t_rmap_update
);
5218 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5223 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5224 return CMD_WARNING_CONFIG_FAILED
;
5228 DEFUN (no_bgp_set_route_map_delay_timer
,
5229 no_bgp_set_route_map_delay_timer_cmd
,
5230 "no bgp route-map delay-timer [(0-600)]",
5233 "Default BGP route-map delay timer\n"
5234 "Reset to default time to wait for processing route-map changes\n"
5235 "0 disables the timer, no route updates happen when route-maps change\n")
5238 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5244 /* neighbor interface */
5245 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5250 peer
= peer_lookup_vty(vty
, ip_str
);
5251 if (!peer
|| peer
->conf_if
) {
5252 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5253 return CMD_WARNING_CONFIG_FAILED
;
5257 peer_interface_set(peer
, str
);
5259 peer_interface_unset(peer
);
5264 DEFUN (neighbor_interface
,
5265 neighbor_interface_cmd
,
5266 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5274 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5277 DEFUN (no_neighbor_interface
,
5278 no_neighbor_interface_cmd
,
5279 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5287 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5290 DEFUN (neighbor_distribute_list
,
5291 neighbor_distribute_list_cmd
,
5292 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5295 "Filter updates to/from this neighbor\n"
5296 "IP access-list number\n"
5297 "IP access-list number (expanded range)\n"
5298 "IP Access-list name\n"
5299 "Filter incoming updates\n"
5300 "Filter outgoing updates\n")
5307 const char *pstr
= argv
[idx_peer
]->arg
;
5308 const char *acl
= argv
[idx_acl
]->arg
;
5309 const char *inout
= argv
[argc
- 1]->text
;
5311 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5313 return CMD_WARNING_CONFIG_FAILED
;
5315 /* Check filter direction. */
5316 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5317 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5320 return bgp_vty_return(vty
, ret
);
5324 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5325 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5326 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5327 "Filter updates to/from this neighbor\n"
5328 "IP access-list number\n"
5329 "IP access-list number (expanded range)\n"
5330 "IP Access-list name\n"
5331 "Filter incoming updates\n"
5332 "Filter outgoing updates\n")
5334 DEFUN (no_neighbor_distribute_list
,
5335 no_neighbor_distribute_list_cmd
,
5336 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5340 "Filter updates to/from this neighbor\n"
5341 "IP access-list number\n"
5342 "IP access-list number (expanded range)\n"
5343 "IP Access-list name\n"
5344 "Filter incoming updates\n"
5345 "Filter outgoing updates\n")
5351 const char *pstr
= argv
[idx_peer
]->arg
;
5352 const char *inout
= argv
[argc
- 1]->text
;
5354 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5356 return CMD_WARNING_CONFIG_FAILED
;
5358 /* Check filter direction. */
5359 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5360 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5363 return bgp_vty_return(vty
, ret
);
5367 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5368 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5369 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5370 "Filter updates to/from this neighbor\n"
5371 "IP access-list number\n"
5372 "IP access-list number (expanded range)\n"
5373 "IP Access-list name\n"
5374 "Filter incoming updates\n"
5375 "Filter outgoing updates\n")
5377 /* Set prefix list to the peer. */
5378 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5379 afi_t afi
, safi_t safi
,
5380 const char *name_str
,
5381 const char *direct_str
)
5384 int direct
= FILTER_IN
;
5387 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5389 return CMD_WARNING_CONFIG_FAILED
;
5391 /* Check filter direction. */
5392 if (strncmp(direct_str
, "i", 1) == 0)
5394 else if (strncmp(direct_str
, "o", 1) == 0)
5395 direct
= FILTER_OUT
;
5397 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5399 return bgp_vty_return(vty
, ret
);
5402 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5403 afi_t afi
, safi_t safi
,
5404 const char *direct_str
)
5408 int direct
= FILTER_IN
;
5410 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5412 return CMD_WARNING_CONFIG_FAILED
;
5414 /* Check filter direction. */
5415 if (strncmp(direct_str
, "i", 1) == 0)
5417 else if (strncmp(direct_str
, "o", 1) == 0)
5418 direct
= FILTER_OUT
;
5420 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5422 return bgp_vty_return(vty
, ret
);
5425 DEFUN (neighbor_prefix_list
,
5426 neighbor_prefix_list_cmd
,
5427 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5430 "Filter updates to/from this neighbor\n"
5431 "Name of a prefix list\n"
5432 "Filter incoming updates\n"
5433 "Filter outgoing updates\n")
5438 return peer_prefix_list_set_vty(
5439 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5440 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5443 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5444 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5445 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5446 "Filter updates to/from this neighbor\n"
5447 "Name of a prefix list\n"
5448 "Filter incoming updates\n"
5449 "Filter outgoing updates\n")
5451 DEFUN (no_neighbor_prefix_list
,
5452 no_neighbor_prefix_list_cmd
,
5453 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5457 "Filter updates to/from this neighbor\n"
5458 "Name of a prefix list\n"
5459 "Filter incoming updates\n"
5460 "Filter outgoing updates\n")
5464 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5465 bgp_node_afi(vty
), bgp_node_safi(vty
),
5466 argv
[idx_in_out
]->arg
);
5469 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5470 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5471 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5472 "Filter updates to/from this neighbor\n"
5473 "Name of a prefix list\n"
5474 "Filter incoming updates\n"
5475 "Filter outgoing updates\n")
5477 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5478 safi_t safi
, const char *name_str
,
5479 const char *direct_str
)
5483 int direct
= FILTER_IN
;
5485 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5487 return CMD_WARNING_CONFIG_FAILED
;
5489 /* Check filter direction. */
5490 if (strncmp(direct_str
, "i", 1) == 0)
5492 else if (strncmp(direct_str
, "o", 1) == 0)
5493 direct
= FILTER_OUT
;
5495 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5497 return bgp_vty_return(vty
, ret
);
5500 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5501 safi_t safi
, const char *direct_str
)
5505 int direct
= FILTER_IN
;
5507 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5509 return CMD_WARNING_CONFIG_FAILED
;
5511 /* Check filter direction. */
5512 if (strncmp(direct_str
, "i", 1) == 0)
5514 else if (strncmp(direct_str
, "o", 1) == 0)
5515 direct
= FILTER_OUT
;
5517 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5519 return bgp_vty_return(vty
, ret
);
5522 DEFUN (neighbor_filter_list
,
5523 neighbor_filter_list_cmd
,
5524 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5527 "Establish BGP filters\n"
5528 "AS path access-list name\n"
5529 "Filter incoming routes\n"
5530 "Filter outgoing routes\n")
5535 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5536 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5537 argv
[idx_in_out
]->arg
);
5540 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5541 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5542 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5543 "Establish BGP filters\n"
5544 "AS path access-list name\n"
5545 "Filter incoming routes\n"
5546 "Filter outgoing routes\n")
5548 DEFUN (no_neighbor_filter_list
,
5549 no_neighbor_filter_list_cmd
,
5550 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5554 "Establish BGP filters\n"
5555 "AS path access-list name\n"
5556 "Filter incoming routes\n"
5557 "Filter outgoing routes\n")
5561 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5562 bgp_node_afi(vty
), bgp_node_safi(vty
),
5563 argv
[idx_in_out
]->arg
);
5566 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5567 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5568 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5569 "Establish BGP filters\n"
5570 "AS path access-list name\n"
5571 "Filter incoming routes\n"
5572 "Filter outgoing routes\n")
5574 /* Set route-map to the peer. */
5575 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5576 afi_t afi
, safi_t safi
, const char *name_str
,
5577 const char *direct_str
)
5581 int direct
= RMAP_IN
;
5583 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5585 return CMD_WARNING_CONFIG_FAILED
;
5587 /* Check filter direction. */
5588 if (strncmp(direct_str
, "in", 2) == 0)
5590 else if (strncmp(direct_str
, "o", 1) == 0)
5593 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
);
5595 return bgp_vty_return(vty
, ret
);
5598 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5599 afi_t afi
, safi_t safi
,
5600 const char *direct_str
)
5604 int direct
= RMAP_IN
;
5606 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5608 return CMD_WARNING_CONFIG_FAILED
;
5610 /* Check filter direction. */
5611 if (strncmp(direct_str
, "in", 2) == 0)
5613 else if (strncmp(direct_str
, "o", 1) == 0)
5616 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5618 return bgp_vty_return(vty
, ret
);
5621 DEFUN (neighbor_route_map
,
5622 neighbor_route_map_cmd
,
5623 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5626 "Apply route map to neighbor\n"
5627 "Name of route map\n"
5628 "Apply map to incoming routes\n"
5629 "Apply map to outbound routes\n")
5634 return peer_route_map_set_vty(
5635 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5636 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5639 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5640 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5641 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5642 "Apply route map to neighbor\n"
5643 "Name of route map\n"
5644 "Apply map to incoming routes\n"
5645 "Apply map to outbound routes\n")
5647 DEFUN (no_neighbor_route_map
,
5648 no_neighbor_route_map_cmd
,
5649 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5653 "Apply route map to neighbor\n"
5654 "Name of route map\n"
5655 "Apply map to incoming routes\n"
5656 "Apply map to outbound routes\n")
5660 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5661 bgp_node_afi(vty
), bgp_node_safi(vty
),
5662 argv
[idx_in_out
]->arg
);
5665 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5666 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5667 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5668 "Apply route map to neighbor\n"
5669 "Name of route map\n"
5670 "Apply map to incoming routes\n"
5671 "Apply map to outbound routes\n")
5673 /* Set unsuppress-map to the peer. */
5674 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5675 afi_t afi
, safi_t safi
,
5676 const char *name_str
)
5681 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5683 return CMD_WARNING_CONFIG_FAILED
;
5685 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
);
5687 return bgp_vty_return(vty
, ret
);
5690 /* Unset route-map from the peer. */
5691 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5692 afi_t afi
, safi_t safi
)
5697 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5699 return CMD_WARNING_CONFIG_FAILED
;
5701 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5703 return bgp_vty_return(vty
, ret
);
5706 DEFUN (neighbor_unsuppress_map
,
5707 neighbor_unsuppress_map_cmd
,
5708 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5711 "Route-map to selectively unsuppress suppressed routes\n"
5712 "Name of route map\n")
5716 return peer_unsuppress_map_set_vty(
5717 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5718 argv
[idx_word
]->arg
);
5721 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5722 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5723 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5724 "Route-map to selectively unsuppress suppressed routes\n"
5725 "Name of route map\n")
5727 DEFUN (no_neighbor_unsuppress_map
,
5728 no_neighbor_unsuppress_map_cmd
,
5729 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5733 "Route-map to selectively unsuppress suppressed routes\n"
5734 "Name of route map\n")
5737 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5739 bgp_node_safi(vty
));
5742 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5743 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5744 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5745 "Route-map to selectively unsuppress suppressed routes\n"
5746 "Name of route map\n")
5748 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5749 afi_t afi
, safi_t safi
,
5750 const char *num_str
,
5751 const char *threshold_str
, int warning
,
5752 const char *restart_str
)
5760 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5762 return CMD_WARNING_CONFIG_FAILED
;
5764 max
= strtoul(num_str
, NULL
, 10);
5766 threshold
= atoi(threshold_str
);
5768 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5771 restart
= atoi(restart_str
);
5775 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5778 return bgp_vty_return(vty
, ret
);
5781 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5782 afi_t afi
, safi_t safi
)
5787 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5789 return CMD_WARNING_CONFIG_FAILED
;
5791 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5793 return bgp_vty_return(vty
, ret
);
5796 /* Maximum number of prefix configuration. prefix count is different
5797 for each peer configuration. So this configuration can be set for
5798 each peer configuration. */
5799 DEFUN (neighbor_maximum_prefix
,
5800 neighbor_maximum_prefix_cmd
,
5801 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5804 "Maximum number of prefix accept from this peer\n"
5805 "maximum no. of prefix limit\n")
5809 return peer_maximum_prefix_set_vty(
5810 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5811 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5814 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5815 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5816 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5817 "Maximum number of prefix accept from this peer\n"
5818 "maximum no. of prefix limit\n")
5820 DEFUN (neighbor_maximum_prefix_threshold
,
5821 neighbor_maximum_prefix_threshold_cmd
,
5822 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5825 "Maximum number of prefix accept from this peer\n"
5826 "maximum no. of prefix limit\n"
5827 "Threshold value (%) at which to generate a warning msg\n")
5831 int idx_number_2
= 4;
5832 return peer_maximum_prefix_set_vty(
5833 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5834 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5838 neighbor_maximum_prefix_threshold
,
5839 neighbor_maximum_prefix_threshold_hidden_cmd
,
5840 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5841 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5842 "Maximum number of prefix accept from this peer\n"
5843 "maximum no. of prefix limit\n"
5844 "Threshold value (%) at which to generate a warning msg\n")
5846 DEFUN (neighbor_maximum_prefix_warning
,
5847 neighbor_maximum_prefix_warning_cmd
,
5848 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5851 "Maximum number of prefix accept from this peer\n"
5852 "maximum no. of prefix limit\n"
5853 "Only give warning message when limit is exceeded\n")
5857 return peer_maximum_prefix_set_vty(
5858 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5859 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
5863 neighbor_maximum_prefix_warning
,
5864 neighbor_maximum_prefix_warning_hidden_cmd
,
5865 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5866 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5867 "Maximum number of prefix accept from this peer\n"
5868 "maximum no. of prefix limit\n"
5869 "Only give warning message when limit is exceeded\n")
5871 DEFUN (neighbor_maximum_prefix_threshold_warning
,
5872 neighbor_maximum_prefix_threshold_warning_cmd
,
5873 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5876 "Maximum number of prefix accept from this peer\n"
5877 "maximum no. of prefix limit\n"
5878 "Threshold value (%) at which to generate a warning msg\n"
5879 "Only give warning message when limit is exceeded\n")
5883 int idx_number_2
= 4;
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
, argv
[idx_number_2
]->arg
, 1, NULL
);
5890 neighbor_maximum_prefix_threshold_warning
,
5891 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
5892 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5893 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5894 "Maximum number of prefix accept from this peer\n"
5895 "maximum no. of prefix limit\n"
5896 "Threshold value (%) at which to generate a warning msg\n"
5897 "Only give warning message when limit is exceeded\n")
5899 DEFUN (neighbor_maximum_prefix_restart
,
5900 neighbor_maximum_prefix_restart_cmd
,
5901 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5904 "Maximum number of prefix accept from this peer\n"
5905 "maximum no. of prefix limit\n"
5906 "Restart bgp connection after limit is exceeded\n"
5907 "Restart interval in minutes\n")
5911 int idx_number_2
= 5;
5912 return peer_maximum_prefix_set_vty(
5913 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5914 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
5918 neighbor_maximum_prefix_restart
,
5919 neighbor_maximum_prefix_restart_hidden_cmd
,
5920 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5921 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5922 "Maximum number of prefix accept from this peer\n"
5923 "maximum no. of prefix limit\n"
5924 "Restart bgp connection after limit is exceeded\n"
5925 "Restart interval in minutes\n")
5927 DEFUN (neighbor_maximum_prefix_threshold_restart
,
5928 neighbor_maximum_prefix_threshold_restart_cmd
,
5929 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5932 "Maximum number of prefixes to accept from this peer\n"
5933 "maximum no. of prefix limit\n"
5934 "Threshold value (%) at which to generate a warning msg\n"
5935 "Restart bgp connection after limit is exceeded\n"
5936 "Restart interval in minutes\n")
5940 int idx_number_2
= 4;
5941 int idx_number_3
= 6;
5942 return peer_maximum_prefix_set_vty(
5943 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5944 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
5945 argv
[idx_number_3
]->arg
);
5949 neighbor_maximum_prefix_threshold_restart
,
5950 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
5951 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5952 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5953 "Maximum number of prefixes to accept from this peer\n"
5954 "maximum no. of prefix limit\n"
5955 "Threshold value (%) at which to generate a warning msg\n"
5956 "Restart bgp connection after limit is exceeded\n"
5957 "Restart interval in minutes\n")
5959 DEFUN (no_neighbor_maximum_prefix
,
5960 no_neighbor_maximum_prefix_cmd
,
5961 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5965 "Maximum number of prefixes to accept from this peer\n"
5966 "maximum no. of prefix limit\n"
5967 "Threshold value (%) at which to generate a warning msg\n"
5968 "Restart bgp connection after limit is exceeded\n"
5969 "Restart interval in minutes\n"
5970 "Only give warning message when limit is exceeded\n")
5973 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
5975 bgp_node_safi(vty
));
5979 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
5980 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5981 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5982 "Maximum number of prefixes to accept from this peer\n"
5983 "maximum no. of prefix limit\n"
5984 "Threshold value (%) at which to generate a warning msg\n"
5985 "Restart bgp connection after limit is exceeded\n"
5986 "Restart interval in minutes\n"
5987 "Only give warning message when limit is exceeded\n")
5990 /* "neighbor allowas-in" */
5991 DEFUN (neighbor_allowas_in
,
5992 neighbor_allowas_in_cmd
,
5993 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5996 "Accept as-path with my AS present in it\n"
5997 "Number of occurances of AS number\n"
5998 "Only accept my AS in the as-path if the route was originated in my AS\n")
6001 int idx_number_origin
= 3;
6007 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6009 return CMD_WARNING_CONFIG_FAILED
;
6011 if (argc
<= idx_number_origin
)
6014 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6017 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6020 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6023 return bgp_vty_return(vty
, ret
);
6027 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6028 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6029 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6030 "Accept as-path with my AS present in it\n"
6031 "Number of occurances of AS number\n"
6032 "Only accept my AS in the as-path if the route was originated in my AS\n")
6034 DEFUN (no_neighbor_allowas_in
,
6035 no_neighbor_allowas_in_cmd
,
6036 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6040 "allow local ASN appears in aspath attribute\n"
6041 "Number of occurances of AS number\n"
6042 "Only accept my AS in the as-path if the route was originated in my AS\n")
6048 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6050 return CMD_WARNING_CONFIG_FAILED
;
6052 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6053 bgp_node_safi(vty
));
6055 return bgp_vty_return(vty
, ret
);
6059 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6060 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6061 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6062 "allow local ASN appears in aspath attribute\n"
6063 "Number of occurances of AS number\n"
6064 "Only accept my AS in the as-path if the route was originated in my AS\n")
6066 DEFUN (neighbor_ttl_security
,
6067 neighbor_ttl_security_cmd
,
6068 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6071 "BGP ttl-security parameters\n"
6072 "Specify the maximum number of hops to the BGP peer\n"
6073 "Number of hops to BGP peer\n")
6080 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6082 return CMD_WARNING_CONFIG_FAILED
;
6084 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6087 * If 'neighbor swpX', then this is for directly connected peers,
6088 * we should not accept a ttl-security hops value greater than 1.
6090 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6092 "%s is directly connected peer, hops cannot exceed 1\n",
6093 argv
[idx_peer
]->arg
);
6094 return CMD_WARNING_CONFIG_FAILED
;
6097 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6100 DEFUN (no_neighbor_ttl_security
,
6101 no_neighbor_ttl_security_cmd
,
6102 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6106 "BGP ttl-security parameters\n"
6107 "Specify the maximum number of hops to the BGP peer\n"
6108 "Number of hops to BGP peer\n")
6113 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6115 return CMD_WARNING_CONFIG_FAILED
;
6117 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6120 DEFUN (neighbor_addpath_tx_all_paths
,
6121 neighbor_addpath_tx_all_paths_cmd
,
6122 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6125 "Use addpath to advertise all paths to a neighbor\n")
6130 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6132 return CMD_WARNING_CONFIG_FAILED
;
6134 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6136 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
6139 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6140 neighbor_addpath_tx_all_paths_hidden_cmd
,
6141 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6142 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6143 "Use addpath to advertise all paths to a neighbor\n")
6145 DEFUN (no_neighbor_addpath_tx_all_paths
,
6146 no_neighbor_addpath_tx_all_paths_cmd
,
6147 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6151 "Use addpath to advertise all paths to a neighbor\n")
6154 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6155 bgp_node_afi(vty
), bgp_node_safi(vty
),
6156 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
6159 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6160 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6161 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6162 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6163 "Use addpath to advertise all paths to a neighbor\n")
6165 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6166 neighbor_addpath_tx_bestpath_per_as_cmd
,
6167 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6170 "Use addpath to advertise the bestpath per each neighboring AS\n")
6175 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6177 return CMD_WARNING_CONFIG_FAILED
;
6179 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6181 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
6184 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6185 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6186 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6187 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6188 "Use addpath to advertise the bestpath per each neighboring AS\n")
6190 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6191 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6192 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6196 "Use addpath to advertise the bestpath per each neighboring AS\n")
6199 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6200 bgp_node_afi(vty
), bgp_node_safi(vty
),
6201 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
6204 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6205 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6206 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6207 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6208 "Use addpath to advertise the bestpath per each neighboring AS\n")
6210 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6211 struct ecommunity
**list
)
6213 struct ecommunity
*ecom
= NULL
;
6214 struct ecommunity
*ecomadd
;
6216 for (; argc
; --argc
, ++argv
) {
6218 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6219 ECOMMUNITY_ROUTE_TARGET
, 0);
6221 vty_out(vty
, "Malformed community-list value\n");
6223 ecommunity_free(&ecom
);
6224 return CMD_WARNING_CONFIG_FAILED
;
6228 ecommunity_merge(ecom
, ecomadd
);
6229 ecommunity_free(&ecomadd
);
6236 ecommunity_free(&*list
);
6244 * v2vimport is true if we are handling a `import vrf ...` command
6246 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6250 switch (vty
->node
) {
6259 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6264 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6265 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6266 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6267 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6269 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6273 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6274 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6275 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6276 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6278 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6285 DEFPY (af_rd_vpn_export
,
6286 af_rd_vpn_export_cmd
,
6287 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6289 "Specify route distinguisher\n"
6290 "Between current address-family and vpn\n"
6291 "For routes leaked from current address-family to vpn\n"
6292 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6294 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6295 struct prefix_rd prd
;
6301 if (argv_find(argv
, argc
, "no", &idx
))
6305 ret
= str2prefix_rd(rd_str
, &prd
);
6307 vty_out(vty
, "%% Malformed rd\n");
6308 return CMD_WARNING_CONFIG_FAILED
;
6312 afi
= vpn_policy_getafi(vty
, bgp
, false);
6314 return CMD_WARNING_CONFIG_FAILED
;
6317 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6319 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6320 bgp_get_default(), bgp
);
6323 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6324 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6325 BGP_VPN_POLICY_TOVPN_RD_SET
);
6327 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6328 BGP_VPN_POLICY_TOVPN_RD_SET
);
6331 /* post-change: re-export vpn routes */
6332 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6333 bgp_get_default(), bgp
);
6338 ALIAS (af_rd_vpn_export
,
6339 af_no_rd_vpn_export_cmd
,
6342 "Specify route distinguisher\n"
6343 "Between current address-family and vpn\n"
6344 "For routes leaked from current address-family to vpn\n")
6346 DEFPY (af_label_vpn_export
,
6347 af_label_vpn_export_cmd
,
6348 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6350 "label value for VRF\n"
6351 "Between current address-family and vpn\n"
6352 "For routes leaked from current address-family to vpn\n"
6353 "Label Value <0-1048575>\n"
6354 "Automatically assign a label\n")
6356 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6357 mpls_label_t label
= MPLS_LABEL_NONE
;
6362 if (argv_find(argv
, argc
, "no", &idx
))
6365 /* If "no ...", squash trailing parameter */
6371 label
= label_val
; /* parser should force unsigned */
6374 afi
= vpn_policy_getafi(vty
, bgp
, false);
6376 return CMD_WARNING_CONFIG_FAILED
;
6379 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6380 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6385 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6387 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6388 bgp_get_default(), bgp
);
6390 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6391 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6393 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6396 * label has previously been automatically
6397 * assigned by labelpool: release it
6399 * NB if tovpn_label == MPLS_LABEL_NONE it
6400 * means the automatic assignment is in flight
6401 * and therefore the labelpool callback must
6402 * detect that the auto label is not needed.
6405 bgp_lp_release(LP_TYPE_VRF
,
6406 &bgp
->vpn_policy
[afi
],
6407 bgp
->vpn_policy
[afi
].tovpn_label
);
6409 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6410 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6413 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6415 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6416 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6417 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6418 vpn_leak_label_callback
);
6421 /* post-change: re-export vpn routes */
6422 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6423 bgp_get_default(), bgp
);
6428 ALIAS (af_label_vpn_export
,
6429 af_no_label_vpn_export_cmd
,
6430 "no label vpn export",
6432 "label value for VRF\n"
6433 "Between current address-family and vpn\n"
6434 "For routes leaked from current address-family to vpn\n")
6436 DEFPY (af_nexthop_vpn_export
,
6437 af_nexthop_vpn_export_cmd
,
6438 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6440 "Specify next hop to use for VRF advertised prefixes\n"
6441 "Between current address-family and vpn\n"
6442 "For routes leaked from current address-family to vpn\n"
6446 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6452 if (argv_find(argv
, argc
, "no", &idx
))
6456 if (!sockunion2hostprefix(nexthop_str
, &p
))
6457 return CMD_WARNING_CONFIG_FAILED
;
6460 afi
= vpn_policy_getafi(vty
, bgp
, false);
6462 return CMD_WARNING_CONFIG_FAILED
;
6465 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6467 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6468 bgp_get_default(), bgp
);
6471 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6472 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6473 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6475 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6476 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6479 /* post-change: re-export vpn routes */
6480 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6481 bgp_get_default(), bgp
);
6486 ALIAS (af_nexthop_vpn_export
,
6487 af_no_nexthop_vpn_export_cmd
,
6488 "no nexthop vpn export",
6490 "Specify next hop to use for VRF advertised prefixes\n"
6491 "Between current address-family and vpn\n"
6492 "For routes leaked from current address-family to vpn\n")
6494 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6496 if (!strcmp(dstr
, "import")) {
6497 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6498 } else if (!strcmp(dstr
, "export")) {
6499 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6500 } else if (!strcmp(dstr
, "both")) {
6501 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6502 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6504 vty_out(vty
, "%% direction parse error\n");
6505 return CMD_WARNING_CONFIG_FAILED
;
6510 DEFPY (af_rt_vpn_imexport
,
6511 af_rt_vpn_imexport_cmd
,
6512 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6514 "Specify route target list\n"
6515 "Specify route target list\n"
6516 "Between current address-family and vpn\n"
6517 "For routes leaked from vpn to current address-family: match any\n"
6518 "For routes leaked from current address-family to vpn: set\n"
6519 "both import: match any and export: set\n"
6520 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6522 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6524 struct ecommunity
*ecom
= NULL
;
6525 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6526 vpn_policy_direction_t dir
;
6531 if (argv_find(argv
, argc
, "no", &idx
))
6534 afi
= vpn_policy_getafi(vty
, bgp
, false);
6536 return CMD_WARNING_CONFIG_FAILED
;
6538 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6539 if (ret
!= CMD_SUCCESS
)
6543 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6544 vty_out(vty
, "%% Missing RTLIST\n");
6545 return CMD_WARNING_CONFIG_FAILED
;
6547 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6548 if (ret
!= CMD_SUCCESS
) {
6553 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6557 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6560 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6562 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6563 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6564 ecommunity_dup(ecom
);
6566 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6568 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6569 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6572 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6576 ecommunity_free(&ecom
);
6581 ALIAS (af_rt_vpn_imexport
,
6582 af_no_rt_vpn_imexport_cmd
,
6583 "no <rt|route-target> vpn <import|export|both>$direction_str",
6585 "Specify route target list\n"
6586 "Specify route target list\n"
6587 "Between current address-family and vpn\n"
6588 "For routes leaked from vpn to current address-family\n"
6589 "For routes leaked from current address-family to vpn\n"
6590 "both import and export\n")
6592 DEFPY (af_route_map_vpn_imexport
,
6593 af_route_map_vpn_imexport_cmd
,
6594 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6595 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6597 "Specify route map\n"
6598 "Between current address-family and vpn\n"
6599 "For routes leaked from vpn to current address-family\n"
6600 "For routes leaked from current address-family to vpn\n"
6601 "name of route-map\n")
6603 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6605 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6606 vpn_policy_direction_t dir
;
6611 if (argv_find(argv
, argc
, "no", &idx
))
6614 afi
= vpn_policy_getafi(vty
, bgp
, false);
6616 return CMD_WARNING_CONFIG_FAILED
;
6618 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6619 if (ret
!= CMD_SUCCESS
)
6622 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6626 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6629 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6630 XFREE(MTYPE_ROUTE_MAP_NAME
,
6631 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6632 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6633 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6634 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6635 route_map_lookup_by_name(rmap_str
);
6636 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6639 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6640 XFREE(MTYPE_ROUTE_MAP_NAME
,
6641 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6642 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6643 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6646 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6652 ALIAS (af_route_map_vpn_imexport
,
6653 af_no_route_map_vpn_imexport_cmd
,
6654 "no route-map vpn <import|export>$direction_str",
6656 "Specify route map\n"
6657 "Between current address-family and vpn\n"
6658 "For routes leaked from vpn to current address-family\n"
6659 "For routes leaked from current address-family to vpn\n")
6661 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6662 "[no] import vrf route-map RMAP$rmap_str",
6664 "Import routes from another VRF\n"
6665 "Vrf routes being filtered\n"
6666 "Specify route map\n"
6667 "name of route-map\n")
6669 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6670 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6674 struct bgp
*bgp_default
;
6676 if (argv_find(argv
, argc
, "no", &idx
))
6679 afi
= vpn_policy_getafi(vty
, bgp
, true);
6681 return CMD_WARNING_CONFIG_FAILED
;
6683 bgp_default
= bgp_get_default();
6688 /* Auto-create assuming the same AS */
6689 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6690 BGP_INSTANCE_TYPE_DEFAULT
);
6694 "VRF default is not configured as a bgp instance\n");
6699 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6702 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6703 XFREE(MTYPE_ROUTE_MAP_NAME
,
6704 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6705 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6706 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6707 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6708 route_map_lookup_by_name(rmap_str
);
6709 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6712 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6713 XFREE(MTYPE_ROUTE_MAP_NAME
,
6714 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6715 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6716 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6719 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6724 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6725 "no import vrf route-map",
6727 "Import routes from another VRF\n"
6728 "Vrf routes being filtered\n"
6729 "Specify route map\n")
6731 DEFPY (bgp_imexport_vrf
,
6732 bgp_imexport_vrf_cmd
,
6733 "[no] import vrf NAME$import_name",
6735 "Import routes from another VRF\n"
6736 "VRF to import from\n"
6737 "The name of the VRF\n")
6739 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6740 struct listnode
*node
;
6741 struct bgp
*vrf_bgp
, *bgp_default
;
6744 bool remove
= false;
6747 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
6751 if (import_name
== NULL
) {
6752 vty_out(vty
, "%% Missing import name\n");
6756 if (argv_find(argv
, argc
, "no", &idx
))
6759 afi
= vpn_policy_getafi(vty
, bgp
, true);
6761 return CMD_WARNING_CONFIG_FAILED
;
6763 safi
= bgp_node_safi(vty
);
6765 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
6766 && (strcmp(import_name
, BGP_DEFAULT_NAME
) == 0))
6767 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
6768 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
6769 remove
? "unimport" : "import", import_name
);
6773 bgp_default
= bgp_get_default();
6775 /* Auto-create assuming the same AS */
6776 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6777 BGP_INSTANCE_TYPE_DEFAULT
);
6781 "VRF default is not configured as a bgp instance\n");
6786 vrf_bgp
= bgp_lookup_by_name(import_name
);
6788 if (strcmp(import_name
, BGP_DEFAULT_NAME
) == 0)
6789 vrf_bgp
= bgp_default
;
6791 /* Auto-create assuming the same AS */
6792 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
6796 "VRF %s is not configured as a bgp instance\n",
6803 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6805 /* Already importing from "import_vrf"? */
6806 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
6808 if (strcmp(vname
, import_name
) == 0)
6812 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6818 /* This command is valid only in a bgp vrf instance or the default instance */
6819 DEFPY (bgp_imexport_vpn
,
6820 bgp_imexport_vpn_cmd
,
6821 "[no] <import|export>$direction_str vpn",
6823 "Import routes to this address-family\n"
6824 "Export routes from this address-family\n"
6825 "to/from default instance VPN RIB\n")
6827 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6834 vpn_policy_direction_t dir
;
6836 if (argv_find(argv
, argc
, "no", &idx
))
6839 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
6840 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
6842 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
6843 return CMD_WARNING_CONFIG_FAILED
;
6846 afi
= bgp_node_afi(vty
);
6847 safi
= bgp_node_safi(vty
);
6848 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
6849 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
6850 return CMD_WARNING_CONFIG_FAILED
;
6853 if (!strcmp(direction_str
, "import")) {
6854 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
6855 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6856 } else if (!strcmp(direction_str
, "export")) {
6857 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
6858 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
6860 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
6861 return CMD_WARNING_CONFIG_FAILED
;
6864 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6867 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6868 if (!previous_state
) {
6869 /* trigger export current vrf */
6870 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6873 if (previous_state
) {
6874 /* trigger un-export current vrf */
6875 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6877 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6883 DEFPY (af_routetarget_import
,
6884 af_routetarget_import_cmd
,
6885 "[no] <rt|route-target> redirect import RTLIST...",
6887 "Specify route target list\n"
6888 "Specify route target list\n"
6889 "Flow-spec redirect type route target\n"
6890 "Import routes to this address-family\n"
6891 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6893 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6895 struct ecommunity
*ecom
= NULL
;
6900 if (argv_find(argv
, argc
, "no", &idx
))
6903 afi
= vpn_policy_getafi(vty
, bgp
, false);
6905 return CMD_WARNING_CONFIG_FAILED
;
6908 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6909 vty_out(vty
, "%% Missing RTLIST\n");
6910 return CMD_WARNING_CONFIG_FAILED
;
6912 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6913 if (ret
!= CMD_SUCCESS
)
6918 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
6919 ecommunity_free(&bgp
->vpn_policy
[afi
]
6920 .import_redirect_rtlist
);
6921 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
6922 ecommunity_dup(ecom
);
6924 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
6925 ecommunity_free(&bgp
->vpn_policy
[afi
]
6926 .import_redirect_rtlist
);
6927 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
6931 ecommunity_free(&ecom
);
6936 DEFUN_NOSH (address_family_ipv4_safi
,
6937 address_family_ipv4_safi_cmd
,
6938 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
6939 "Enter Address Family command mode\n"
6941 BGP_SAFI_WITH_LABEL_HELP_STR
)
6945 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6946 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6947 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
6948 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
6949 && safi
!= SAFI_EVPN
) {
6951 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
6952 return CMD_WARNING_CONFIG_FAILED
;
6954 vty
->node
= bgp_node_type(AFI_IP
, safi
);
6956 vty
->node
= BGP_IPV4_NODE
;
6961 DEFUN_NOSH (address_family_ipv6_safi
,
6962 address_family_ipv6_safi_cmd
,
6963 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
6964 "Enter Address Family command mode\n"
6966 BGP_SAFI_WITH_LABEL_HELP_STR
)
6969 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6970 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6971 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
6972 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
6973 && safi
!= SAFI_EVPN
) {
6975 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
6976 return CMD_WARNING_CONFIG_FAILED
;
6978 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
6980 vty
->node
= BGP_IPV6_NODE
;
6985 #ifdef KEEP_OLD_VPN_COMMANDS
6986 DEFUN_NOSH (address_family_vpnv4
,
6987 address_family_vpnv4_cmd
,
6988 "address-family vpnv4 [unicast]",
6989 "Enter Address Family command mode\n"
6991 "Address Family modifier\n")
6993 vty
->node
= BGP_VPNV4_NODE
;
6997 DEFUN_NOSH (address_family_vpnv6
,
6998 address_family_vpnv6_cmd
,
6999 "address-family vpnv6 [unicast]",
7000 "Enter Address Family command mode\n"
7002 "Address Family modifier\n")
7004 vty
->node
= BGP_VPNV6_NODE
;
7009 DEFUN_NOSH (address_family_evpn
,
7010 address_family_evpn_cmd
,
7011 "address-family l2vpn evpn",
7012 "Enter Address Family command mode\n"
7014 "Address Family modifier\n")
7016 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7017 vty
->node
= BGP_EVPN_NODE
;
7021 DEFUN_NOSH (exit_address_family
,
7022 exit_address_family_cmd
,
7023 "exit-address-family",
7024 "Exit from Address Family configuration mode\n")
7026 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7027 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7028 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7029 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7030 || vty
->node
== BGP_EVPN_NODE
7031 || vty
->node
== BGP_FLOWSPECV4_NODE
7032 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7033 vty
->node
= BGP_NODE
;
7037 /* Recalculate bestpath and re-advertise a prefix */
7038 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7039 const char *ip_str
, afi_t afi
, safi_t safi
,
7040 struct prefix_rd
*prd
)
7043 struct prefix match
;
7044 struct bgp_node
*rn
;
7045 struct bgp_node
*rm
;
7047 struct bgp_table
*table
;
7048 struct bgp_table
*rib
;
7050 /* BGP structure lookup. */
7052 bgp
= bgp_lookup_by_name(view_name
);
7054 vty_out(vty
, "%% Can't find BGP instance %s\n",
7059 bgp
= bgp_get_default();
7061 vty_out(vty
, "%% No BGP process is configured\n");
7066 /* Check IP address argument. */
7067 ret
= str2prefix(ip_str
, &match
);
7069 vty_out(vty
, "%% address is malformed\n");
7073 match
.family
= afi2family(afi
);
7074 rib
= bgp
->rib
[afi
][safi
];
7076 if (safi
== SAFI_MPLS_VPN
) {
7077 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7078 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7081 if ((table
= rn
->info
) != NULL
) {
7082 if ((rm
= bgp_node_match(table
, &match
))
7085 == match
.prefixlen
) {
7087 BGP_NODE_USER_CLEAR
);
7088 bgp_process(bgp
, rm
, afi
, safi
);
7090 bgp_unlock_node(rm
);
7095 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7096 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7097 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7098 bgp_process(bgp
, rn
, afi
, safi
);
7100 bgp_unlock_node(rn
);
7107 /* one clear bgp command to rule them all */
7108 DEFUN (clear_ip_bgp_all
,
7109 clear_ip_bgp_all_cmd
,
7110 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> [<soft [<in|out>]|in [prefix-filter]|out>]",
7114 BGP_INSTANCE_HELP_STR
7116 BGP_SAFI_WITH_LABEL_HELP_STR
7118 "BGP neighbor address to clear\n"
7119 "BGP IPv6 neighbor to clear\n"
7120 "BGP neighbor on interface to clear\n"
7121 "Clear peers with the AS number\n"
7122 "Clear all external peers\n"
7123 "Clear all members of peer-group\n"
7124 "BGP peer-group name\n"
7129 "Push out prefix-list ORF and do inbound soft reconfig\n"
7134 afi_t afi
= AFI_IP6
;
7135 safi_t safi
= SAFI_UNICAST
;
7136 enum clear_sort clr_sort
= clear_peer
;
7137 enum bgp_clear_type clr_type
;
7138 char *clr_arg
= NULL
;
7142 /* clear [ip] bgp */
7143 if (argv_find(argv
, argc
, "ip", &idx
))
7146 /* [<view|vrf> VIEWVRFNAME] */
7147 if (argv_find(argv
, argc
, "view", &idx
)
7148 || argv_find(argv
, argc
, "vrf", &idx
)) {
7149 vrf
= argv
[idx
+ 1]->arg
;
7153 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7154 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7155 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7157 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */
7158 if (argv_find(argv
, argc
, "*", &idx
)) {
7159 clr_sort
= clear_all
;
7160 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7161 clr_sort
= clear_peer
;
7162 clr_arg
= argv
[idx
]->arg
;
7163 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7164 clr_sort
= clear_peer
;
7165 clr_arg
= argv
[idx
]->arg
;
7166 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7167 clr_sort
= clear_group
;
7169 clr_arg
= argv
[idx
]->arg
;
7170 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7171 clr_sort
= clear_peer
;
7172 clr_arg
= argv
[idx
]->arg
;
7173 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7174 clr_sort
= clear_as
;
7175 clr_arg
= argv
[idx
]->arg
;
7176 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7177 clr_sort
= clear_external
;
7180 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7181 if (argv_find(argv
, argc
, "soft", &idx
)) {
7182 if (argv_find(argv
, argc
, "in", &idx
)
7183 || argv_find(argv
, argc
, "out", &idx
))
7184 clr_type
= strmatch(argv
[idx
]->text
, "in")
7186 : BGP_CLEAR_SOFT_OUT
;
7188 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7189 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7190 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7191 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7192 : BGP_CLEAR_SOFT_IN
;
7193 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7194 clr_type
= BGP_CLEAR_SOFT_OUT
;
7196 clr_type
= BGP_CLEAR_SOFT_NONE
;
7198 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7201 DEFUN (clear_ip_bgp_prefix
,
7202 clear_ip_bgp_prefix_cmd
,
7203 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7207 BGP_INSTANCE_HELP_STR
7208 "Clear bestpath and re-advertise\n"
7212 char *prefix
= NULL
;
7216 /* [<view|vrf> VIEWVRFNAME] */
7217 if (argv_find(argv
, argc
, "VIEWVRFNAME", &idx
))
7218 vrf
= argv
[idx
]->arg
;
7220 prefix
= argv
[argc
- 1]->arg
;
7222 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7225 DEFUN (clear_bgp_ipv6_safi_prefix
,
7226 clear_bgp_ipv6_safi_prefix_cmd
,
7227 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7233 "Clear bestpath and re-advertise\n"
7237 int idx_ipv6_prefix
= 0;
7238 safi_t safi
= SAFI_UNICAST
;
7239 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7240 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7242 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7243 return bgp_clear_prefix(
7244 vty
, NULL
, prefix
, AFI_IP6
,
7248 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7249 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7250 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7254 BGP_INSTANCE_HELP_STR
7257 "Clear bestpath and re-advertise\n"
7262 int idx_ipv6_prefix
= 0;
7263 safi_t safi
= SAFI_UNICAST
;
7264 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7265 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7266 /* [<view|vrf> VIEWVRFNAME] */
7267 char *vrfview
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx_word
) ?
7268 argv
[idx_word
]->arg
: NULL
;
7270 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7272 return bgp_clear_prefix(
7273 vty
, vrfview
, prefix
,
7274 AFI_IP6
, safi
, NULL
);
7277 DEFUN (show_bgp_views
,
7279 "show [ip] bgp views",
7283 "Show the defined BGP views\n")
7285 struct list
*inst
= bm
->bgp
;
7286 struct listnode
*node
;
7289 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7290 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7294 vty_out(vty
, "Defined BGP views:\n");
7295 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7297 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7299 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7306 DEFUN (show_bgp_vrfs
,
7308 "show [ip] bgp vrfs [json]",
7315 char buf
[ETHER_ADDR_STRLEN
];
7316 struct list
*inst
= bm
->bgp
;
7317 struct listnode
*node
;
7319 uint8_t uj
= use_json(argc
, argv
);
7320 json_object
*json
= NULL
;
7321 json_object
*json_vrfs
= NULL
;
7324 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7325 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7330 json
= json_object_new_object();
7331 json_vrfs
= json_object_new_object();
7334 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7335 const char *name
, *type
;
7337 struct listnode
*node
, *nnode
;
7338 int peers_cfg
, peers_estb
;
7339 json_object
*json_vrf
= NULL
;
7342 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7346 if (!uj
&& count
== 1)
7348 "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n",
7349 "Type", "Id", "routerId", "#PeersVfg",
7350 "#PeersEstb", "Name", "L3-VNI", "Rmac");
7352 peers_cfg
= peers_estb
= 0;
7354 json_vrf
= json_object_new_object();
7357 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7358 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7361 if (peer
->status
== Established
)
7365 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7375 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7377 : (int64_t)bgp
->vrf_id
;
7378 json_object_string_add(json_vrf
, "type", type
);
7379 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7380 json_object_string_add(json_vrf
, "routerId",
7381 inet_ntoa(bgp
->router_id
));
7382 json_object_int_add(json_vrf
, "numConfiguredPeers",
7384 json_object_int_add(json_vrf
, "numEstablishedPeers",
7387 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7388 json_object_string_add(
7390 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7391 json_object_object_add(json_vrfs
, name
, json_vrf
);
7394 "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n",
7396 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7398 inet_ntoa(bgp
->router_id
), peers_cfg
,
7399 peers_estb
, name
, bgp
->l3vni
,
7400 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7404 json_object_object_add(json
, "vrfs", json_vrfs
);
7406 json_object_int_add(json
, "totalVrfs", count
);
7408 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7409 json
, JSON_C_TO_STRING_PRETTY
));
7410 json_object_free(json
);
7414 "\nTotal number of VRFs (including default): %d\n",
7421 static void show_address_entry(struct hash_backet
*backet
, void *args
)
7423 struct vty
*vty
= (struct vty
*)args
;
7424 struct bgp_addr
*addr
= (struct bgp_addr
*)backet
->data
;
7426 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(addr
->addr
),
7430 static void show_tip_entry(struct hash_backet
*backet
, void *args
)
7432 struct vty
*vty
= (struct vty
*)args
;
7433 struct tip_addr
*tip
= (struct tip_addr
*)backet
->data
;
7435 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7439 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7441 vty_out(vty
, "self nexthop database:\n");
7442 hash_iterate(bgp
->address_hash
,
7443 (void (*)(struct hash_backet
*, void *))show_address_entry
,
7446 vty_out(vty
, "Tunnel-ip database:\n");
7447 hash_iterate(bgp
->tip_hash
,
7448 (void (*)(struct hash_backet
*, void *))show_tip_entry
,
7452 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7453 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7454 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7455 "martian next-hops\n"
7456 "martian next-hop database\n")
7458 struct bgp
*bgp
= NULL
;
7461 if (argv_find(argv
, argc
, "view", &idx
)
7462 || argv_find(argv
, argc
, "vrf", &idx
))
7463 bgp
= bgp_lookup_by_name(argv
[idx
+ 1]->arg
);
7465 bgp
= bgp_get_default();
7468 vty_out(vty
, "%% No BGP process is configured\n");
7471 bgp_show_martian_nexthops(vty
, bgp
);
7476 DEFUN (show_bgp_memory
,
7477 show_bgp_memory_cmd
,
7478 "show [ip] bgp memory",
7482 "Global BGP memory statistics\n")
7484 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7485 unsigned long count
;
7487 /* RIB related usage stats */
7488 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7489 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7490 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7491 count
* sizeof(struct bgp_node
)));
7493 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7494 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7495 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7496 count
* sizeof(struct bgp_info
)));
7497 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7498 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7500 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7501 count
* sizeof(struct bgp_info_extra
)));
7503 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7504 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7505 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7506 count
* sizeof(struct bgp_static
)));
7508 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7509 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7510 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7511 count
* sizeof(struct bpacket
)));
7514 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7515 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7516 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7517 count
* sizeof(struct bgp_adj_in
)));
7518 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7519 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7520 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7521 count
* sizeof(struct bgp_adj_out
)));
7523 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7524 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7526 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7527 count
* sizeof(struct bgp_nexthop_cache
)));
7529 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7530 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7532 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7533 count
* sizeof(struct bgp_damp_info
)));
7536 count
= attr_count();
7537 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7538 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7539 count
* sizeof(struct attr
)));
7541 if ((count
= attr_unknown_count()))
7542 vty_out(vty
, "%ld unknown attributes\n", count
);
7544 /* AS_PATH attributes */
7545 count
= aspath_count();
7546 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7547 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7548 count
* sizeof(struct aspath
)));
7550 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7551 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7552 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7553 count
* sizeof(struct assegment
)));
7555 /* Other attributes */
7556 if ((count
= community_count()))
7557 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7558 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7559 count
* sizeof(struct community
)));
7560 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7561 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7562 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7563 count
* sizeof(struct ecommunity
)));
7564 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7566 "%ld BGP large-community entries, using %s of memory\n",
7567 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7568 count
* sizeof(struct lcommunity
)));
7570 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7571 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7572 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7573 count
* sizeof(struct cluster_list
)));
7575 /* Peer related usage */
7576 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7577 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7578 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7579 count
* sizeof(struct peer
)));
7581 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7582 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7583 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7584 count
* sizeof(struct peer_group
)));
7587 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
7588 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
7589 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7590 count
* sizeof(struct hash
)));
7591 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
7592 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
7593 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7594 count
* sizeof(struct hash_backet
)));
7595 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7596 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7597 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7598 count
* sizeof(regex_t
)));
7602 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7604 json_object
*bestpath
= json_object_new_object();
7606 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7607 json_object_string_add(bestpath
, "asPath", "ignore");
7609 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7610 json_object_string_add(bestpath
, "asPath", "confed");
7612 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7613 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7614 json_object_string_add(bestpath
, "multiPathRelax",
7617 json_object_string_add(bestpath
, "multiPathRelax",
7620 json_object_string_add(bestpath
, "multiPathRelax", "false");
7622 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7623 json_object_string_add(bestpath
, "compareRouterId", "true");
7624 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7625 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7626 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7627 json_object_string_add(bestpath
, "med", "confed");
7628 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7629 json_object_string_add(bestpath
, "med",
7630 "missing-as-worst");
7632 json_object_string_add(bestpath
, "med", "true");
7635 json_object_object_add(json
, "bestPath", bestpath
);
7638 /* Show BGP peer's summary information. */
7639 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7640 uint8_t use_json
, json_object
*json
)
7643 struct listnode
*node
, *nnode
;
7644 unsigned int count
= 0, dn_count
= 0;
7645 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7646 char neighbor_buf
[VTY_BUFSIZ
];
7647 int neighbor_col_default_width
= 16;
7649 int max_neighbor_width
= 0;
7651 json_object
*json_peer
= NULL
;
7652 json_object
*json_peers
= NULL
;
7654 /* labeled-unicast routes are installed in the unicast table so in order
7656 * display the correct PfxRcd value we must look at SAFI_UNICAST
7658 if (safi
== SAFI_LABELED_UNICAST
)
7659 pfx_rcd_safi
= SAFI_UNICAST
;
7661 pfx_rcd_safi
= safi
;
7665 json
= json_object_new_object();
7667 json_peers
= json_object_new_object();
7669 /* Loop over all neighbors that will be displayed to determine
7671 * characters are needed for the Neighbor column
7673 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7674 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7677 if (peer
->afc
[afi
][safi
]) {
7678 memset(dn_flag
, '\0', sizeof(dn_flag
));
7679 if (peer_dynamic_neighbor(peer
))
7683 && bgp_flag_check(bgp
,
7684 BGP_FLAG_SHOW_HOSTNAME
))
7685 sprintf(neighbor_buf
, "%s%s(%s) ",
7686 dn_flag
, peer
->hostname
,
7689 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7692 len
= strlen(neighbor_buf
);
7694 if (len
> max_neighbor_width
)
7695 max_neighbor_width
= len
;
7699 /* Originally we displayed the Neighbor column as 16
7700 * characters wide so make that the default
7702 if (max_neighbor_width
< neighbor_col_default_width
)
7703 max_neighbor_width
= neighbor_col_default_width
;
7706 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7707 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7710 if (!peer
->afc
[afi
][safi
])
7715 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7718 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7720 : (int64_t)bgp
->vrf_id
;
7722 /* Usage summary and header */
7724 json_object_string_add(
7726 inet_ntoa(bgp
->router_id
));
7727 json_object_int_add(json
, "as", bgp
->as
);
7728 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7729 json_object_string_add(
7732 == BGP_INSTANCE_TYPE_DEFAULT
)
7737 "BGP router identifier %s, local AS number %u vrf-id %d",
7738 inet_ntoa(bgp
->router_id
), bgp
->as
,
7739 bgp
->vrf_id
== VRF_UNKNOWN
7741 : (int)bgp
->vrf_id
);
7745 if (bgp_update_delay_configured(bgp
)) {
7747 json_object_int_add(
7748 json
, "updateDelayLimit",
7749 bgp
->v_update_delay
);
7751 if (bgp
->v_update_delay
7752 != bgp
->v_establish_wait
)
7753 json_object_int_add(
7755 "updateDelayEstablishWait",
7756 bgp
->v_establish_wait
);
7758 if (bgp_update_delay_active(bgp
)) {
7759 json_object_string_add(
7761 "updateDelayFirstNeighbor",
7762 bgp
->update_delay_begin_time
);
7763 json_object_boolean_true_add(
7765 "updateDelayInProgress");
7767 if (bgp
->update_delay_over
) {
7768 json_object_string_add(
7770 "updateDelayFirstNeighbor",
7771 bgp
->update_delay_begin_time
);
7772 json_object_string_add(
7774 "updateDelayBestpathResumed",
7775 bgp
->update_delay_end_time
);
7776 json_object_string_add(
7778 "updateDelayZebraUpdateResume",
7779 bgp
->update_delay_zebra_resume_time
);
7780 json_object_string_add(
7782 "updateDelayPeerUpdateResume",
7783 bgp
->update_delay_peers_resume_time
);
7788 "Read-only mode update-delay limit: %d seconds\n",
7789 bgp
->v_update_delay
);
7790 if (bgp
->v_update_delay
7791 != bgp
->v_establish_wait
)
7793 " Establish wait: %d seconds\n",
7794 bgp
->v_establish_wait
);
7796 if (bgp_update_delay_active(bgp
)) {
7798 " First neighbor established: %s\n",
7799 bgp
->update_delay_begin_time
);
7801 " Delay in progress\n");
7803 if (bgp
->update_delay_over
) {
7805 " First neighbor established: %s\n",
7806 bgp
->update_delay_begin_time
);
7808 " Best-paths resumed: %s\n",
7809 bgp
->update_delay_end_time
);
7811 " zebra update resumed: %s\n",
7812 bgp
->update_delay_zebra_resume_time
);
7814 " peers update resumed: %s\n",
7815 bgp
->update_delay_peers_resume_time
);
7822 if (bgp_maxmed_onstartup_configured(bgp
)
7823 && bgp
->maxmed_active
)
7824 json_object_boolean_true_add(
7825 json
, "maxMedOnStartup");
7826 if (bgp
->v_maxmed_admin
)
7827 json_object_boolean_true_add(
7828 json
, "maxMedAdministrative");
7830 json_object_int_add(
7831 json
, "tableVersion",
7832 bgp_table_version(bgp
->rib
[afi
][safi
]));
7834 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7835 json_object_int_add(json
, "ribCount", ents
);
7836 json_object_int_add(
7838 ents
* sizeof(struct bgp_node
));
7840 ents
= listcount(bgp
->peer
);
7841 json_object_int_add(json
, "peerCount", ents
);
7842 json_object_int_add(json
, "peerMemory",
7843 ents
* sizeof(struct peer
));
7845 if ((ents
= listcount(bgp
->group
))) {
7846 json_object_int_add(
7847 json
, "peerGroupCount", ents
);
7848 json_object_int_add(
7849 json
, "peerGroupMemory",
7850 ents
* sizeof(struct
7854 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7855 BGP_CONFIG_DAMPENING
))
7856 json_object_boolean_true_add(
7857 json
, "dampeningEnabled");
7859 if (bgp_maxmed_onstartup_configured(bgp
)
7860 && bgp
->maxmed_active
)
7862 "Max-med on-startup active\n");
7863 if (bgp
->v_maxmed_admin
)
7865 "Max-med administrative active\n");
7867 vty_out(vty
, "BGP table version %" PRIu64
"\n",
7868 bgp_table_version(bgp
->rib
[afi
][safi
]));
7870 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7872 "RIB entries %ld, using %s of memory\n",
7874 mtype_memstr(memstrbuf
,
7876 ents
* sizeof(struct
7879 /* Peer related usage */
7880 ents
= listcount(bgp
->peer
);
7881 vty_out(vty
, "Peers %ld, using %s of memory\n",
7884 memstrbuf
, sizeof(memstrbuf
),
7885 ents
* sizeof(struct peer
)));
7887 if ((ents
= listcount(bgp
->group
)))
7889 "Peer groups %ld, using %s of memory\n",
7894 ents
* sizeof(struct
7897 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7898 BGP_CONFIG_DAMPENING
))
7899 vty_out(vty
, "Dampening enabled.\n");
7902 /* Subtract 8 here because 'Neighbor' is
7904 vty_out(vty
, "Neighbor");
7905 vty_out(vty
, "%*s", max_neighbor_width
- 8,
7908 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
7915 json_peer
= json_object_new_object();
7917 if (peer_dynamic_neighbor(peer
)) {
7919 json_object_boolean_true_add(json_peer
,
7924 json_object_string_add(json_peer
, "hostname",
7927 if (peer
->domainname
)
7928 json_object_string_add(json_peer
, "domainname",
7931 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
7932 json_object_int_add(json_peer
, "version", 4);
7933 json_object_int_add(json_peer
, "msgRcvd",
7934 PEER_TOTAL_RX(peer
));
7935 json_object_int_add(json_peer
, "msgSent",
7936 PEER_TOTAL_TX(peer
));
7938 json_object_int_add(json_peer
, "tableVersion",
7939 peer
->version
[afi
][safi
]);
7940 json_object_int_add(json_peer
, "outq",
7942 json_object_int_add(json_peer
, "inq", 0);
7943 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
7944 use_json
, json_peer
);
7945 json_object_int_add(json_peer
, "prefixReceivedCount",
7946 peer
->pcount
[afi
][pfx_rcd_safi
]);
7948 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
7949 json_object_string_add(json_peer
, "state",
7951 else if (peer
->afc_recv
[afi
][safi
])
7952 json_object_string_add(
7954 lookup_msg(bgp_status_msg
, peer
->status
,
7956 else if (CHECK_FLAG(peer
->sflags
,
7957 PEER_STATUS_PREFIX_OVERFLOW
))
7958 json_object_string_add(json_peer
, "state",
7961 json_object_string_add(
7963 lookup_msg(bgp_status_msg
, peer
->status
,
7967 json_object_string_add(json_peer
, "idType",
7969 else if (peer
->su
.sa
.sa_family
== AF_INET
)
7970 json_object_string_add(json_peer
, "idType",
7972 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
7973 json_object_string_add(json_peer
, "idType",
7976 json_object_object_add(json_peers
, peer
->host
,
7979 memset(dn_flag
, '\0', sizeof(dn_flag
));
7980 if (peer_dynamic_neighbor(peer
)) {
7986 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7987 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
7988 peer
->hostname
, peer
->host
);
7990 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
7992 /* pad the neighbor column with spaces */
7993 if (len
< max_neighbor_width
)
7994 vty_out(vty
, "%*s", max_neighbor_width
- len
,
7997 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
7998 peer
->as
, PEER_TOTAL_RX(peer
),
7999 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8000 0, peer
->obuf
->count
,
8001 peer_uptime(peer
->uptime
, timebuf
,
8002 BGP_UPTIME_LEN
, 0, NULL
));
8004 if (peer
->status
== Established
)
8005 if (peer
->afc_recv
[afi
][safi
])
8006 vty_out(vty
, " %12ld",
8010 vty_out(vty
, " NoNeg");
8012 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8013 vty_out(vty
, " Idle (Admin)");
8014 else if (CHECK_FLAG(
8016 PEER_STATUS_PREFIX_OVERFLOW
))
8017 vty_out(vty
, " Idle (PfxCt)");
8019 vty_out(vty
, " %12s",
8020 lookup_msg(bgp_status_msg
,
8021 peer
->status
, NULL
));
8028 json_object_object_add(json
, "peers", json_peers
);
8030 json_object_int_add(json
, "totalPeers", count
);
8031 json_object_int_add(json
, "dynamicPeers", dn_count
);
8033 bgp_show_bestpath_json(bgp
, json
);
8035 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8036 json
, JSON_C_TO_STRING_PRETTY
));
8037 json_object_free(json
);
8040 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8042 vty_out(vty
, "No %s neighbor is configured\n",
8043 afi_safi_print(afi
, safi
));
8047 vty_out(vty
, "* - dynamic neighbor\n");
8048 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8049 dn_count
, bgp
->dynamic_neighbors_limit
);
8056 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8057 int safi
, uint8_t use_json
,
8061 int afi_wildcard
= (afi
== AFI_MAX
);
8062 int safi_wildcard
= (safi
== SAFI_MAX
);
8063 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8064 bool json_output
= false;
8066 if (use_json
&& is_wildcard
)
8067 vty_out(vty
, "{\n");
8069 afi
= 1; /* AFI_IP */
8070 while (afi
< AFI_MAX
) {
8072 safi
= 1; /* SAFI_UNICAST */
8073 while (safi
< SAFI_MAX
) {
8074 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8078 * So limit output to those afi/safi
8080 * actualy have something interesting in
8084 json
= json_object_new_object();
8087 vty_out(vty
, ",\n");
8091 vty_out(vty
, "\"%s\":",
8095 vty_out(vty
, "\n%s Summary:\n",
8100 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
8112 if (use_json
&& is_wildcard
)
8113 vty_out(vty
, "}\n");
8114 else if (use_json
&& !json_output
)
8115 vty_out(vty
, "{}\n");
8118 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8119 safi_t safi
, uint8_t use_json
)
8121 struct listnode
*node
, *nnode
;
8123 json_object
*json
= NULL
;
8127 vty_out(vty
, "{\n");
8129 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8131 json
= json_object_new_object();
8134 vty_out(vty
, ",\n");
8138 vty_out(vty
, "\"%s\":",
8139 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8143 vty_out(vty
, "\nInstance %s:\n",
8144 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8148 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
8152 vty_out(vty
, "}\n");
8155 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8156 safi_t safi
, uint8_t use_json
)
8161 if (strmatch(name
, "all")) {
8162 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8166 bgp
= bgp_lookup_by_name(name
);
8170 vty_out(vty
, "{}\n");
8173 "%% No such BGP instance exist\n");
8177 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
8183 bgp
= bgp_get_default();
8186 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
8191 /* `show [ip] bgp summary' commands. */
8192 DEFUN (show_ip_bgp_summary
,
8193 show_ip_bgp_summary_cmd
,
8194 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8198 BGP_INSTANCE_HELP_STR
8200 BGP_SAFI_WITH_LABEL_HELP_STR
8201 "Summary of BGP neighbor status\n"
8205 afi_t afi
= AFI_MAX
;
8206 safi_t safi
= SAFI_MAX
;
8211 if (argv_find(argv
, argc
, "ip", &idx
))
8213 /* [<view|vrf> VIEWVRFNAME] */
8214 if (argv_find(argv
, argc
, "view", &idx
)
8215 || argv_find(argv
, argc
, "vrf", &idx
))
8216 vrf
= argv
[++idx
]->arg
;
8217 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8218 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8219 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8222 int uj
= use_json(argc
, argv
);
8224 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8227 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8229 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8230 return "IPv4 Unicast";
8231 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8232 return "IPv4 Multicast";
8233 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8234 return "IPv4 Labeled Unicast";
8235 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8237 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8238 return "IPv4 Encap";
8239 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8240 return "IPv4 Flowspec";
8241 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8242 return "IPv6 Unicast";
8243 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8244 return "IPv6 Multicast";
8245 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8246 return "IPv6 Labeled Unicast";
8247 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8249 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8250 return "IPv6 Encap";
8251 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8252 return "IPv6 Flowspec";
8253 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8254 return "L2VPN EVPN";
8260 * Please note that we have intentionally camelCased
8261 * the return strings here. So if you want
8262 * to use this function, please ensure you
8263 * are doing this within json output
8265 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8267 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8268 return "ipv4Unicast";
8269 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8270 return "ipv4Multicast";
8271 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8272 return "ipv4LabeledUnicast";
8273 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8275 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8277 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8278 return "ipv4Flowspec";
8279 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8280 return "ipv6Unicast";
8281 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8282 return "ipv6Multicast";
8283 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8284 return "ipv6LabeledUnicast";
8285 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8287 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8289 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8290 return "ipv6Flowspec";
8291 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8297 /* Show BGP peer's information. */
8298 enum show_type
{ show_all
, show_peer
};
8300 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8301 afi_t afi
, safi_t safi
,
8302 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8303 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8304 uint8_t use_json
, json_object
*json_pref
)
8307 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8308 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8310 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8311 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8312 json_object_string_add(json_pref
, "sendMode",
8313 "advertisedAndReceived");
8314 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8315 json_object_string_add(json_pref
, "sendMode",
8317 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8318 json_object_string_add(json_pref
, "sendMode",
8321 vty_out(vty
, " Send-mode: ");
8322 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8323 vty_out(vty
, "advertised");
8324 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8325 vty_out(vty
, "%sreceived",
8326 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8335 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8336 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8338 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8339 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8340 json_object_string_add(json_pref
, "recvMode",
8341 "advertisedAndReceived");
8342 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8343 json_object_string_add(json_pref
, "recvMode",
8345 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8346 json_object_string_add(json_pref
, "recvMode",
8349 vty_out(vty
, " Receive-mode: ");
8350 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8351 vty_out(vty
, "advertised");
8352 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8353 vty_out(vty
, "%sreceived",
8354 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8363 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8364 safi_t safi
, uint8_t use_json
,
8365 json_object
*json_neigh
)
8367 struct bgp_filter
*filter
;
8368 struct peer_af
*paf
;
8369 char orf_pfx_name
[BUFSIZ
];
8371 json_object
*json_af
= NULL
;
8372 json_object
*json_prefA
= NULL
;
8373 json_object
*json_prefB
= NULL
;
8374 json_object
*json_addr
= NULL
;
8377 json_addr
= json_object_new_object();
8378 json_af
= json_object_new_object();
8379 filter
= &p
->filter
[afi
][safi
];
8381 if (peer_group_active(p
))
8382 json_object_string_add(json_addr
, "peerGroupMember",
8385 paf
= peer_af_find(p
, afi
, safi
);
8386 if (paf
&& PAF_SUBGRP(paf
)) {
8387 json_object_int_add(json_addr
, "updateGroupId",
8388 PAF_UPDGRP(paf
)->id
);
8389 json_object_int_add(json_addr
, "subGroupId",
8390 PAF_SUBGRP(paf
)->id
);
8391 json_object_int_add(json_addr
, "packetQueueLength",
8392 bpacket_queue_virtual_length(paf
));
8395 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8396 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8397 PEER_CAP_ORF_PREFIX_SM_RCV
)
8398 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8399 PEER_CAP_ORF_PREFIX_RM_ADV
)
8400 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8401 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8402 json_object_int_add(json_af
, "orfType",
8404 json_prefA
= json_object_new_object();
8405 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8406 PEER_CAP_ORF_PREFIX_SM_ADV
,
8407 PEER_CAP_ORF_PREFIX_RM_ADV
,
8408 PEER_CAP_ORF_PREFIX_SM_RCV
,
8409 PEER_CAP_ORF_PREFIX_RM_RCV
,
8410 use_json
, json_prefA
);
8411 json_object_object_add(json_af
, "orfPrefixList",
8415 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8416 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8417 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8418 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8419 PEER_CAP_ORF_PREFIX_RM_ADV
)
8420 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8421 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8422 json_object_int_add(json_af
, "orfOldType",
8423 ORF_TYPE_PREFIX_OLD
);
8424 json_prefB
= json_object_new_object();
8425 bgp_show_peer_afi_orf_cap(
8426 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8427 PEER_CAP_ORF_PREFIX_RM_ADV
,
8428 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8429 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8431 json_object_object_add(json_af
, "orfOldPrefixList",
8435 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8436 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8437 PEER_CAP_ORF_PREFIX_SM_RCV
)
8438 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8439 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8440 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8441 PEER_CAP_ORF_PREFIX_RM_ADV
)
8442 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8443 PEER_CAP_ORF_PREFIX_RM_RCV
)
8444 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8445 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8446 json_object_object_add(json_addr
, "afDependentCap",
8449 json_object_free(json_af
);
8451 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8452 orf_pfx_count
= prefix_bgp_show_prefix_list(
8453 NULL
, afi
, orf_pfx_name
, use_json
);
8455 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8456 PEER_STATUS_ORF_PREFIX_SEND
)
8458 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8459 PEER_STATUS_ORF_PREFIX_SEND
))
8460 json_object_boolean_true_add(json_neigh
,
8463 json_object_int_add(json_addr
, "orfRecvCounter",
8466 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8467 PEER_STATUS_ORF_WAIT_REFRESH
))
8468 json_object_string_add(
8469 json_addr
, "orfFirstUpdate",
8470 "deferredUntilORFOrRouteRefreshRecvd");
8472 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8473 PEER_FLAG_REFLECTOR_CLIENT
))
8474 json_object_boolean_true_add(json_addr
,
8475 "routeReflectorClient");
8476 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8477 PEER_FLAG_RSERVER_CLIENT
))
8478 json_object_boolean_true_add(json_addr
,
8479 "routeServerClient");
8480 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8481 json_object_boolean_true_add(json_addr
,
8482 "inboundSoftConfigPermit");
8484 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8485 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8486 json_object_boolean_true_add(
8488 "privateAsNumsAllReplacedInUpdatesToNbr");
8489 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8490 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8491 json_object_boolean_true_add(
8493 "privateAsNumsReplacedInUpdatesToNbr");
8494 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8495 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8496 json_object_boolean_true_add(
8498 "privateAsNumsAllRemovedInUpdatesToNbr");
8499 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8500 PEER_FLAG_REMOVE_PRIVATE_AS
))
8501 json_object_boolean_true_add(
8503 "privateAsNumsRemovedInUpdatesToNbr");
8505 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8506 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
8507 json_object_boolean_true_add(json_addr
,
8508 "addpathTxAllPaths");
8510 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8511 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
8512 json_object_boolean_true_add(json_addr
,
8513 "addpathTxBestpathPerAS");
8515 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8516 json_object_string_add(json_addr
,
8517 "overrideASNsInOutboundUpdates",
8518 "ifAspathEqualRemoteAs");
8520 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8521 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8522 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8523 json_object_boolean_true_add(json_addr
,
8524 "routerAlwaysNextHop");
8525 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8526 PEER_FLAG_AS_PATH_UNCHANGED
))
8527 json_object_boolean_true_add(
8528 json_addr
, "unchangedAsPathPropogatedToNbr");
8529 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8530 PEER_FLAG_NEXTHOP_UNCHANGED
))
8531 json_object_boolean_true_add(
8532 json_addr
, "unchangedNextHopPropogatedToNbr");
8533 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8534 json_object_boolean_true_add(
8535 json_addr
, "unchangedMedPropogatedToNbr");
8536 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8537 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8538 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8539 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8540 PEER_FLAG_SEND_COMMUNITY
)
8541 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8542 PEER_FLAG_SEND_EXT_COMMUNITY
))
8543 json_object_string_add(json_addr
,
8544 "commAttriSentToNbr",
8545 "extendedAndStandard");
8546 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8547 PEER_FLAG_SEND_EXT_COMMUNITY
))
8548 json_object_string_add(json_addr
,
8549 "commAttriSentToNbr",
8552 json_object_string_add(json_addr
,
8553 "commAttriSentToNbr",
8556 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8557 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8558 if (p
->default_rmap
[afi
][safi
].name
)
8559 json_object_string_add(
8560 json_addr
, "defaultRouteMap",
8561 p
->default_rmap
[afi
][safi
].name
);
8563 if (paf
&& PAF_SUBGRP(paf
)
8564 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8565 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8566 json_object_boolean_true_add(json_addr
,
8569 json_object_boolean_true_add(json_addr
,
8573 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8574 if (is_evpn_enabled())
8575 json_object_boolean_true_add(
8576 json_addr
, "advertiseAllVnis");
8579 if (filter
->plist
[FILTER_IN
].name
8580 || filter
->dlist
[FILTER_IN
].name
8581 || filter
->aslist
[FILTER_IN
].name
8582 || filter
->map
[RMAP_IN
].name
)
8583 json_object_boolean_true_add(json_addr
,
8584 "inboundPathPolicyConfig");
8585 if (filter
->plist
[FILTER_OUT
].name
8586 || filter
->dlist
[FILTER_OUT
].name
8587 || filter
->aslist
[FILTER_OUT
].name
8588 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8589 json_object_boolean_true_add(
8590 json_addr
, "outboundPathPolicyConfig");
8593 if (filter
->plist
[FILTER_IN
].name
)
8594 json_object_string_add(json_addr
,
8595 "incomingUpdatePrefixFilterList",
8596 filter
->plist
[FILTER_IN
].name
);
8597 if (filter
->plist
[FILTER_OUT
].name
)
8598 json_object_string_add(json_addr
,
8599 "outgoingUpdatePrefixFilterList",
8600 filter
->plist
[FILTER_OUT
].name
);
8602 /* distribute-list */
8603 if (filter
->dlist
[FILTER_IN
].name
)
8604 json_object_string_add(
8605 json_addr
, "incomingUpdateNetworkFilterList",
8606 filter
->dlist
[FILTER_IN
].name
);
8607 if (filter
->dlist
[FILTER_OUT
].name
)
8608 json_object_string_add(
8609 json_addr
, "outgoingUpdateNetworkFilterList",
8610 filter
->dlist
[FILTER_OUT
].name
);
8613 if (filter
->aslist
[FILTER_IN
].name
)
8614 json_object_string_add(json_addr
,
8615 "incomingUpdateAsPathFilterList",
8616 filter
->aslist
[FILTER_IN
].name
);
8617 if (filter
->aslist
[FILTER_OUT
].name
)
8618 json_object_string_add(json_addr
,
8619 "outgoingUpdateAsPathFilterList",
8620 filter
->aslist
[FILTER_OUT
].name
);
8623 if (filter
->map
[RMAP_IN
].name
)
8624 json_object_string_add(
8625 json_addr
, "routeMapForIncomingAdvertisements",
8626 filter
->map
[RMAP_IN
].name
);
8627 if (filter
->map
[RMAP_OUT
].name
)
8628 json_object_string_add(
8629 json_addr
, "routeMapForOutgoingAdvertisements",
8630 filter
->map
[RMAP_OUT
].name
);
8632 /* unsuppress-map */
8633 if (filter
->usmap
.name
)
8634 json_object_string_add(json_addr
,
8635 "selectiveUnsuppressRouteMap",
8636 filter
->usmap
.name
);
8638 /* Receive prefix count */
8639 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8640 p
->pcount
[afi
][safi
]);
8642 /* Maximum prefix */
8643 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8644 json_object_int_add(json_addr
, "prefixAllowedMax",
8645 p
->pmax
[afi
][safi
]);
8646 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8647 PEER_FLAG_MAX_PREFIX_WARNING
))
8648 json_object_boolean_true_add(
8649 json_addr
, "prefixAllowedMaxWarning");
8650 json_object_int_add(json_addr
,
8651 "prefixAllowedWarningThresh",
8652 p
->pmax_threshold
[afi
][safi
]);
8653 if (p
->pmax_restart
[afi
][safi
])
8654 json_object_int_add(
8656 "prefixAllowedRestartIntervalMsecs",
8657 p
->pmax_restart
[afi
][safi
] * 60000);
8659 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8663 filter
= &p
->filter
[afi
][safi
];
8665 vty_out(vty
, " For address family: %s\n",
8666 afi_safi_print(afi
, safi
));
8668 if (peer_group_active(p
))
8669 vty_out(vty
, " %s peer-group member\n",
8672 paf
= peer_af_find(p
, afi
, safi
);
8673 if (paf
&& PAF_SUBGRP(paf
)) {
8674 vty_out(vty
, " Update group %" PRIu64
8675 ", subgroup %" PRIu64
"\n",
8676 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8677 vty_out(vty
, " Packet Queue length %d\n",
8678 bpacket_queue_virtual_length(paf
));
8680 vty_out(vty
, " Not part of any update group\n");
8682 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8683 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8684 PEER_CAP_ORF_PREFIX_SM_RCV
)
8685 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8686 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8687 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8688 PEER_CAP_ORF_PREFIX_RM_ADV
)
8689 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8690 PEER_CAP_ORF_PREFIX_RM_RCV
)
8691 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8692 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8693 vty_out(vty
, " AF-dependant capabilities:\n");
8695 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8696 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8697 PEER_CAP_ORF_PREFIX_SM_RCV
)
8698 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8699 PEER_CAP_ORF_PREFIX_RM_ADV
)
8700 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8701 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8703 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8705 bgp_show_peer_afi_orf_cap(
8706 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8707 PEER_CAP_ORF_PREFIX_RM_ADV
,
8708 PEER_CAP_ORF_PREFIX_SM_RCV
,
8709 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8711 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8712 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8713 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8714 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8715 PEER_CAP_ORF_PREFIX_RM_ADV
)
8716 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8717 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8719 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8720 ORF_TYPE_PREFIX_OLD
);
8721 bgp_show_peer_afi_orf_cap(
8722 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8723 PEER_CAP_ORF_PREFIX_RM_ADV
,
8724 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8725 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8728 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8729 orf_pfx_count
= prefix_bgp_show_prefix_list(
8730 NULL
, afi
, orf_pfx_name
, use_json
);
8732 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8733 PEER_STATUS_ORF_PREFIX_SEND
)
8735 vty_out(vty
, " Outbound Route Filter (ORF):");
8736 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8737 PEER_STATUS_ORF_PREFIX_SEND
))
8738 vty_out(vty
, " sent;");
8740 vty_out(vty
, " received (%d entries)",
8744 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8745 PEER_STATUS_ORF_WAIT_REFRESH
))
8747 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
8749 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8750 PEER_FLAG_REFLECTOR_CLIENT
))
8751 vty_out(vty
, " Route-Reflector Client\n");
8752 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8753 PEER_FLAG_RSERVER_CLIENT
))
8754 vty_out(vty
, " Route-Server Client\n");
8755 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8757 " Inbound soft reconfiguration allowed\n");
8759 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8760 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8762 " Private AS numbers (all) replaced in updates to this neighbor\n");
8763 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8764 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8766 " Private AS numbers replaced in updates to this neighbor\n");
8767 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8768 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8770 " Private AS numbers (all) removed in updates to this neighbor\n");
8771 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8772 PEER_FLAG_REMOVE_PRIVATE_AS
))
8774 " Private AS numbers removed in updates to this neighbor\n");
8776 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8777 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
8778 vty_out(vty
, " Advertise all paths via addpath\n");
8780 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8781 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
8783 " Advertise bestpath per AS via addpath\n");
8785 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8787 " Override ASNs in outbound updates if aspath equals remote-as\n");
8789 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8790 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8791 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8792 vty_out(vty
, " NEXT_HOP is always this router\n");
8793 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8794 PEER_FLAG_AS_PATH_UNCHANGED
))
8796 " AS_PATH is propagated unchanged to this neighbor\n");
8797 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8798 PEER_FLAG_NEXTHOP_UNCHANGED
))
8800 " NEXT_HOP is propagated unchanged to this neighbor\n");
8801 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8803 " MED is propagated unchanged to this neighbor\n");
8804 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8805 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8806 PEER_FLAG_SEND_EXT_COMMUNITY
)
8807 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8808 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
8810 " Community attribute sent to this neighbor");
8811 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8812 PEER_FLAG_SEND_COMMUNITY
)
8813 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8814 PEER_FLAG_SEND_EXT_COMMUNITY
)
8815 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8816 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8817 vty_out(vty
, "(all)\n");
8818 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8819 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8820 vty_out(vty
, "(large)\n");
8821 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8822 PEER_FLAG_SEND_EXT_COMMUNITY
))
8823 vty_out(vty
, "(extended)\n");
8825 vty_out(vty
, "(standard)\n");
8827 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8828 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8829 vty_out(vty
, " Default information originate,");
8831 if (p
->default_rmap
[afi
][safi
].name
)
8832 vty_out(vty
, " default route-map %s%s,",
8833 p
->default_rmap
[afi
][safi
].map
? "*"
8835 p
->default_rmap
[afi
][safi
].name
);
8836 if (paf
&& PAF_SUBGRP(paf
)
8837 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8838 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8839 vty_out(vty
, " default sent\n");
8841 vty_out(vty
, " default not sent\n");
8844 /* advertise-vni-all */
8845 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8846 if (is_evpn_enabled())
8847 vty_out(vty
, " advertise-all-vni\n");
8850 if (filter
->plist
[FILTER_IN
].name
8851 || filter
->dlist
[FILTER_IN
].name
8852 || filter
->aslist
[FILTER_IN
].name
8853 || filter
->map
[RMAP_IN
].name
)
8854 vty_out(vty
, " Inbound path policy configured\n");
8855 if (filter
->plist
[FILTER_OUT
].name
8856 || filter
->dlist
[FILTER_OUT
].name
8857 || filter
->aslist
[FILTER_OUT
].name
8858 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8859 vty_out(vty
, " Outbound path policy configured\n");
8862 if (filter
->plist
[FILTER_IN
].name
)
8864 " Incoming update prefix filter list is %s%s\n",
8865 filter
->plist
[FILTER_IN
].plist
? "*" : "",
8866 filter
->plist
[FILTER_IN
].name
);
8867 if (filter
->plist
[FILTER_OUT
].name
)
8869 " Outgoing update prefix filter list is %s%s\n",
8870 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
8871 filter
->plist
[FILTER_OUT
].name
);
8873 /* distribute-list */
8874 if (filter
->dlist
[FILTER_IN
].name
)
8876 " Incoming update network filter list is %s%s\n",
8877 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
8878 filter
->dlist
[FILTER_IN
].name
);
8879 if (filter
->dlist
[FILTER_OUT
].name
)
8881 " Outgoing update network filter list is %s%s\n",
8882 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
8883 filter
->dlist
[FILTER_OUT
].name
);
8886 if (filter
->aslist
[FILTER_IN
].name
)
8888 " Incoming update AS path filter list is %s%s\n",
8889 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
8890 filter
->aslist
[FILTER_IN
].name
);
8891 if (filter
->aslist
[FILTER_OUT
].name
)
8893 " Outgoing update AS path filter list is %s%s\n",
8894 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
8895 filter
->aslist
[FILTER_OUT
].name
);
8898 if (filter
->map
[RMAP_IN
].name
)
8900 " Route map for incoming advertisements is %s%s\n",
8901 filter
->map
[RMAP_IN
].map
? "*" : "",
8902 filter
->map
[RMAP_IN
].name
);
8903 if (filter
->map
[RMAP_OUT
].name
)
8905 " Route map for outgoing advertisements is %s%s\n",
8906 filter
->map
[RMAP_OUT
].map
? "*" : "",
8907 filter
->map
[RMAP_OUT
].name
);
8909 /* unsuppress-map */
8910 if (filter
->usmap
.name
)
8912 " Route map for selective unsuppress is %s%s\n",
8913 filter
->usmap
.map
? "*" : "",
8914 filter
->usmap
.name
);
8916 /* Receive prefix count */
8917 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
8919 /* Maximum prefix */
8920 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8921 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
8923 CHECK_FLAG(p
->af_flags
[afi
][safi
],
8924 PEER_FLAG_MAX_PREFIX_WARNING
)
8927 vty_out(vty
, " Threshold for warning message %d%%",
8928 p
->pmax_threshold
[afi
][safi
]);
8929 if (p
->pmax_restart
[afi
][safi
])
8930 vty_out(vty
, ", restart interval %d min",
8931 p
->pmax_restart
[afi
][safi
]);
8939 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, uint8_t use_json
,
8943 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
8944 char timebuf
[BGP_UPTIME_LEN
];
8946 const char *subcode_str
;
8947 const char *code_str
;
8952 json_object
*json_neigh
= NULL
;
8958 json_neigh
= json_object_new_object();
8960 memset(dn_flag
, '\0', sizeof(dn_flag
));
8961 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
8965 if (p
->conf_if
) /* Configured interface name. */
8966 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
8967 BGP_PEER_SU_UNSPEC(p
)
8969 : sockunion2str(&p
->su
, buf
,
8971 else /* Configured IP address. */
8972 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
8977 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
8978 json_object_string_add(json_neigh
, "bgpNeighborAddr",
8980 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
8981 json_object_string_add(
8982 json_neigh
, "bgpNeighborAddr",
8983 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
8985 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
8987 if (p
->change_local_as
)
8988 json_object_int_add(json_neigh
, "localAs",
8989 p
->change_local_as
);
8991 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
8993 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
8994 json_object_boolean_true_add(json_neigh
,
8995 "localAsNoPrepend");
8997 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
8998 json_object_boolean_true_add(json_neigh
,
8999 "localAsReplaceAs");
9001 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9002 || (p
->as_type
== AS_INTERNAL
))
9003 vty_out(vty
, "remote AS %u, ", p
->as
);
9005 vty_out(vty
, "remote AS Unspecified, ");
9006 vty_out(vty
, "local AS %u%s%s, ",
9007 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9008 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9011 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9015 /* peer type internal, external, confed-internal or confed-external */
9016 if (p
->as
== p
->local_as
) {
9018 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9019 json_object_boolean_true_add(
9020 json_neigh
, "nbrConfedInternalLink");
9022 json_object_boolean_true_add(json_neigh
,
9025 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9026 vty_out(vty
, "confed-internal link\n");
9028 vty_out(vty
, "internal link\n");
9032 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9033 json_object_boolean_true_add(
9034 json_neigh
, "nbrConfedExternalLink");
9036 json_object_boolean_true_add(json_neigh
,
9039 if (bgp_confederation_peers_check(bgp
, p
->as
))
9040 vty_out(vty
, "confed-external link\n");
9042 vty_out(vty
, "external link\n");
9049 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9051 vty_out(vty
, " Description: %s\n", p
->desc
);
9057 json_object_string_add(json_neigh
, "hostname",
9061 json_object_string_add(json_neigh
, "domainname",
9064 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9065 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9068 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9075 json_object_string_add(json_neigh
, "peerGroup",
9079 struct prefix prefix
, *range
= NULL
;
9081 sockunion2hostprefix(&(p
->su
), &prefix
);
9082 range
= peer_group_lookup_dynamic_neighbor_range(
9086 prefix2str(range
, buf1
, sizeof(buf1
));
9087 json_object_string_add(
9089 "peerSubnetRangeGroup", buf1
);
9094 " Member of peer-group %s for session parameters\n",
9098 struct prefix prefix
, *range
= NULL
;
9100 sockunion2hostprefix(&(p
->su
), &prefix
);
9101 range
= peer_group_lookup_dynamic_neighbor_range(
9105 prefix2str(range
, buf1
, sizeof(buf1
));
9107 " Belongs to the subnet range group: %s\n",
9115 /* Administrative shutdown. */
9116 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9117 json_object_boolean_true_add(json_neigh
,
9121 json_object_int_add(json_neigh
, "bgpVersion", 4);
9122 json_object_string_add(
9123 json_neigh
, "remoteRouterId",
9124 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9125 json_object_string_add(
9126 json_neigh
, "localRouterId",
9127 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9131 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9132 && bgp_confederation_peers_check(bgp
, p
->as
))
9133 json_object_boolean_true_add(json_neigh
,
9137 json_object_string_add(
9138 json_neigh
, "bgpState",
9139 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9141 if (p
->status
== Established
) {
9144 uptime
= bgp_clock();
9145 uptime
-= p
->uptime
;
9146 epoch_tbuf
= time(NULL
) - uptime
;
9148 #if CONFDATE > 20200101
9150 "bgpTimerUp should be deprecated and can be removed now");
9153 * bgpTimerUp was miliseconds that was accurate
9154 * up to 1 day, then the value returned
9155 * became garbage. So in order to provide
9156 * some level of backwards compatability,
9157 * we still provde the data, but now
9158 * we are returning the correct value
9159 * and also adding a new bgpTimerUpMsec
9160 * which will allow us to deprecate
9163 json_object_int_add(json_neigh
, "bgpTimerUp",
9165 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9167 json_object_string_add(json_neigh
, "bgpTimerUpString",
9168 peer_uptime(p
->uptime
, timebuf
,
9171 json_object_int_add(json_neigh
,
9172 "bgpTimerUpEstablishedEpoch",
9176 else if (p
->status
== Active
) {
9177 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9178 json_object_string_add(json_neigh
, "bgpStateIs",
9180 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9181 json_object_string_add(json_neigh
, "bgpStateIs",
9189 uptime
= bgp_clock();
9190 uptime
-= p
->readtime
;
9191 tm
= gmtime(&uptime
);
9192 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9193 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9194 + (tm
->tm_hour
* 3600000));
9196 uptime
= bgp_clock();
9197 uptime
-= p
->last_write
;
9198 tm
= gmtime(&uptime
);
9199 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9200 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9201 + (tm
->tm_hour
* 3600000));
9203 uptime
= bgp_clock();
9204 uptime
-= p
->update_time
;
9205 tm
= gmtime(&uptime
);
9206 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9207 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9208 + (tm
->tm_hour
* 3600000));
9210 /* Configured timer values. */
9211 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9212 p
->v_holdtime
* 1000);
9213 json_object_int_add(json_neigh
,
9214 "bgpTimerKeepAliveIntervalMsecs",
9215 p
->v_keepalive
* 1000);
9216 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9217 json_object_int_add(json_neigh
,
9218 "bgpTimerConfiguredHoldTimeMsecs",
9219 p
->holdtime
* 1000);
9220 json_object_int_add(
9222 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9223 p
->keepalive
* 1000);
9224 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9225 || (bgp
->default_keepalive
9226 != BGP_DEFAULT_KEEPALIVE
)) {
9227 json_object_int_add(json_neigh
,
9228 "bgpTimerConfiguredHoldTimeMsecs",
9229 bgp
->default_holdtime
);
9230 json_object_int_add(
9232 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9233 bgp
->default_keepalive
);
9236 /* Administrative shutdown. */
9237 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9238 vty_out(vty
, " Administratively shut down\n");
9241 vty_out(vty
, " BGP version 4");
9242 vty_out(vty
, ", remote router ID %s\n",
9243 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9246 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9247 && bgp_confederation_peers_check(bgp
, p
->as
))
9249 " Neighbor under common administration\n");
9252 vty_out(vty
, " BGP state = %s",
9253 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9255 if (p
->status
== Established
)
9256 vty_out(vty
, ", up for %8s",
9257 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9260 else if (p
->status
== Active
) {
9261 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9262 vty_out(vty
, " (passive)");
9263 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9264 vty_out(vty
, " (NSF passive)");
9269 vty_out(vty
, " Last read %s",
9270 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9272 vty_out(vty
, ", Last write %s\n",
9273 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9276 /* Configured timer values. */
9278 " Hold time is %d, keepalive interval is %d seconds\n",
9279 p
->v_holdtime
, p
->v_keepalive
);
9280 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9281 vty_out(vty
, " Configured hold time is %d",
9283 vty_out(vty
, ", keepalive interval is %d seconds\n",
9285 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9286 || (bgp
->default_keepalive
9287 != BGP_DEFAULT_KEEPALIVE
)) {
9288 vty_out(vty
, " Configured hold time is %d",
9289 bgp
->default_holdtime
);
9290 vty_out(vty
, ", keepalive interval is %d seconds\n",
9291 bgp
->default_keepalive
);
9295 if (p
->status
== Established
) {
9296 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9297 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9298 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9299 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9300 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9301 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9302 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9303 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9304 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9305 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9306 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9307 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9308 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9309 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9310 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9311 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9312 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9313 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9314 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9315 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9317 json_object
*json_cap
= NULL
;
9319 json_cap
= json_object_new_object();
9322 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9323 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9324 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9325 && CHECK_FLAG(p
->cap
,
9327 json_object_string_add(
9328 json_cap
, "4byteAs",
9329 "advertisedAndReceived");
9330 else if (CHECK_FLAG(p
->cap
,
9332 json_object_string_add(
9333 json_cap
, "4byteAs",
9335 else if (CHECK_FLAG(p
->cap
,
9337 json_object_string_add(
9338 json_cap
, "4byteAs",
9343 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9344 || CHECK_FLAG(p
->cap
,
9345 PEER_CAP_ADDPATH_ADV
)) {
9346 json_object
*json_add
= NULL
;
9347 const char *print_store
;
9349 json_add
= json_object_new_object();
9351 FOREACH_AFI_SAFI (afi
, safi
) {
9352 json_object
*json_sub
= NULL
;
9354 json_object_new_object();
9355 print_store
= afi_safi_print(
9361 PEER_CAP_ADDPATH_AF_TX_ADV
)
9365 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9370 PEER_CAP_ADDPATH_AF_TX_ADV
)
9375 PEER_CAP_ADDPATH_AF_TX_RCV
))
9376 json_object_boolean_true_add(
9378 "txAdvertisedAndReceived");
9384 PEER_CAP_ADDPATH_AF_TX_ADV
))
9385 json_object_boolean_true_add(
9393 PEER_CAP_ADDPATH_AF_TX_RCV
))
9394 json_object_boolean_true_add(
9402 PEER_CAP_ADDPATH_AF_RX_ADV
)
9406 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9411 PEER_CAP_ADDPATH_AF_RX_ADV
)
9416 PEER_CAP_ADDPATH_AF_RX_RCV
))
9417 json_object_boolean_true_add(
9419 "rxAdvertisedAndReceived");
9425 PEER_CAP_ADDPATH_AF_RX_ADV
))
9426 json_object_boolean_true_add(
9434 PEER_CAP_ADDPATH_AF_RX_RCV
))
9435 json_object_boolean_true_add(
9443 PEER_CAP_ADDPATH_AF_TX_ADV
)
9447 PEER_CAP_ADDPATH_AF_TX_RCV
)
9451 PEER_CAP_ADDPATH_AF_RX_ADV
)
9455 PEER_CAP_ADDPATH_AF_RX_RCV
))
9456 json_object_object_add(
9465 json_object_object_add(
9466 json_cap
, "addPath", json_add
);
9470 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9471 || CHECK_FLAG(p
->cap
,
9472 PEER_CAP_DYNAMIC_ADV
)) {
9473 if (CHECK_FLAG(p
->cap
,
9474 PEER_CAP_DYNAMIC_ADV
)
9475 && CHECK_FLAG(p
->cap
,
9476 PEER_CAP_DYNAMIC_RCV
))
9477 json_object_string_add(
9478 json_cap
, "dynamic",
9479 "advertisedAndReceived");
9480 else if (CHECK_FLAG(
9482 PEER_CAP_DYNAMIC_ADV
))
9483 json_object_string_add(
9484 json_cap
, "dynamic",
9486 else if (CHECK_FLAG(
9488 PEER_CAP_DYNAMIC_RCV
))
9489 json_object_string_add(
9490 json_cap
, "dynamic",
9494 /* Extended nexthop */
9495 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9496 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9497 json_object
*json_nxt
= NULL
;
9498 const char *print_store
;
9501 if (CHECK_FLAG(p
->cap
,
9503 && CHECK_FLAG(p
->cap
,
9505 json_object_string_add(
9508 "advertisedAndReceived");
9509 else if (CHECK_FLAG(p
->cap
,
9511 json_object_string_add(
9515 else if (CHECK_FLAG(p
->cap
,
9517 json_object_string_add(
9522 if (CHECK_FLAG(p
->cap
,
9523 PEER_CAP_ENHE_RCV
)) {
9525 json_object_new_object();
9527 for (safi
= SAFI_UNICAST
;
9528 safi
< SAFI_MAX
; safi
++) {
9533 PEER_CAP_ENHE_AF_RCV
)) {
9534 print_store
= afi_safi_print(
9537 json_object_string_add(
9543 json_object_object_add(
9545 "extendedNexthopFamililesByPeer",
9551 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9552 || CHECK_FLAG(p
->cap
,
9553 PEER_CAP_REFRESH_NEW_RCV
)
9554 || CHECK_FLAG(p
->cap
,
9555 PEER_CAP_REFRESH_OLD_RCV
)) {
9556 if (CHECK_FLAG(p
->cap
,
9557 PEER_CAP_REFRESH_ADV
)
9560 PEER_CAP_REFRESH_NEW_RCV
)
9563 PEER_CAP_REFRESH_OLD_RCV
))) {
9566 PEER_CAP_REFRESH_OLD_RCV
)
9569 PEER_CAP_REFRESH_NEW_RCV
))
9570 json_object_string_add(
9573 "advertisedAndReceivedOldNew");
9577 PEER_CAP_REFRESH_OLD_RCV
))
9578 json_object_string_add(
9581 "advertisedAndReceivedOld");
9583 json_object_string_add(
9586 "advertisedAndReceivedNew");
9591 PEER_CAP_REFRESH_ADV
))
9592 json_object_string_add(
9599 PEER_CAP_REFRESH_NEW_RCV
)
9602 PEER_CAP_REFRESH_OLD_RCV
))
9603 json_object_string_add(
9609 /* Multiprotocol Extensions */
9610 json_object
*json_multi
= NULL
;
9611 json_multi
= json_object_new_object();
9613 FOREACH_AFI_SAFI (afi
, safi
) {
9614 if (p
->afc_adv
[afi
][safi
]
9615 || p
->afc_recv
[afi
][safi
]) {
9616 json_object
*json_exten
= NULL
;
9618 json_object_new_object();
9620 if (p
->afc_adv
[afi
][safi
]
9621 && p
->afc_recv
[afi
][safi
])
9622 json_object_boolean_true_add(
9624 "advertisedAndReceived");
9625 else if (p
->afc_adv
[afi
][safi
])
9626 json_object_boolean_true_add(
9629 else if (p
->afc_recv
[afi
][safi
])
9630 json_object_boolean_true_add(
9634 json_object_object_add(
9641 json_object_object_add(
9642 json_cap
, "multiprotocolExtensions",
9645 /* Hostname capabilities */
9646 json_object
*json_hname
= NULL
;
9648 json_hname
= json_object_new_object();
9650 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9651 json_object_string_add(
9652 json_hname
, "advHostName",
9653 bgp
->peer_self
->hostname
9657 json_object_string_add(
9658 json_hname
, "advDomainName",
9659 bgp
->peer_self
->domainname
9666 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9667 json_object_string_add(
9668 json_hname
, "rcvHostName",
9669 p
->hostname
? p
->hostname
9671 json_object_string_add(
9672 json_hname
, "rcvDomainName",
9673 p
->domainname
? p
->domainname
9677 json_object_object_add(json_cap
, "hostName",
9680 /* Gracefull Restart */
9681 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9682 || CHECK_FLAG(p
->cap
,
9683 PEER_CAP_RESTART_ADV
)) {
9684 if (CHECK_FLAG(p
->cap
,
9685 PEER_CAP_RESTART_ADV
)
9686 && CHECK_FLAG(p
->cap
,
9687 PEER_CAP_RESTART_RCV
))
9688 json_object_string_add(
9691 "advertisedAndReceived");
9692 else if (CHECK_FLAG(
9694 PEER_CAP_RESTART_ADV
))
9695 json_object_string_add(
9697 "gracefulRestartCapability",
9699 else if (CHECK_FLAG(
9701 PEER_CAP_RESTART_RCV
))
9702 json_object_string_add(
9704 "gracefulRestartCapability",
9707 if (CHECK_FLAG(p
->cap
,
9708 PEER_CAP_RESTART_RCV
)) {
9709 int restart_af_count
= 0;
9710 json_object
*json_restart
=
9713 json_object_new_object();
9715 json_object_int_add(
9717 "gracefulRestartRemoteTimerMsecs",
9718 p
->v_gr_restart
* 1000);
9720 FOREACH_AFI_SAFI (afi
, safi
) {
9725 PEER_CAP_RESTART_AF_RCV
)) {
9730 json_object_new_object();
9736 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
9737 json_object_boolean_true_add(
9741 json_object_object_add(
9749 if (!restart_af_count
) {
9750 json_object_string_add(
9752 "addressFamiliesByPeer",
9757 json_object_object_add(
9759 "addressFamiliesByPeer",
9763 json_object_object_add(json_neigh
,
9764 "neighborCapabilities",
9767 vty_out(vty
, " Neighbor capabilities:\n");
9770 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9771 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9772 vty_out(vty
, " 4 Byte AS:");
9773 if (CHECK_FLAG(p
->cap
,
9775 vty_out(vty
, " advertised");
9776 if (CHECK_FLAG(p
->cap
,
9778 vty_out(vty
, " %sreceived",
9788 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9789 || CHECK_FLAG(p
->cap
,
9790 PEER_CAP_ADDPATH_ADV
)) {
9791 vty_out(vty
, " AddPath:\n");
9793 FOREACH_AFI_SAFI (afi
, safi
) {
9797 PEER_CAP_ADDPATH_AF_TX_ADV
)
9801 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9812 PEER_CAP_ADDPATH_AF_TX_ADV
))
9823 PEER_CAP_ADDPATH_AF_TX_RCV
))
9830 PEER_CAP_ADDPATH_AF_TX_ADV
)
9840 PEER_CAP_ADDPATH_AF_RX_ADV
)
9844 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9855 PEER_CAP_ADDPATH_AF_RX_ADV
))
9866 PEER_CAP_ADDPATH_AF_RX_RCV
))
9873 PEER_CAP_ADDPATH_AF_RX_ADV
)
9883 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9884 || CHECK_FLAG(p
->cap
,
9885 PEER_CAP_DYNAMIC_ADV
)) {
9886 vty_out(vty
, " Dynamic:");
9887 if (CHECK_FLAG(p
->cap
,
9888 PEER_CAP_DYNAMIC_ADV
))
9889 vty_out(vty
, " advertised");
9890 if (CHECK_FLAG(p
->cap
,
9891 PEER_CAP_DYNAMIC_RCV
))
9892 vty_out(vty
, " %sreceived",
9895 PEER_CAP_DYNAMIC_ADV
)
9901 /* Extended nexthop */
9902 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9903 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9904 vty_out(vty
, " Extended nexthop:");
9905 if (CHECK_FLAG(p
->cap
,
9907 vty_out(vty
, " advertised");
9908 if (CHECK_FLAG(p
->cap
,
9910 vty_out(vty
, " %sreceived",
9918 if (CHECK_FLAG(p
->cap
,
9919 PEER_CAP_ENHE_RCV
)) {
9921 " Address families by peer:\n ");
9922 for (safi
= SAFI_UNICAST
;
9923 safi
< SAFI_MAX
; safi
++)
9928 PEER_CAP_ENHE_AF_RCV
))
9938 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9939 || CHECK_FLAG(p
->cap
,
9940 PEER_CAP_REFRESH_NEW_RCV
)
9941 || CHECK_FLAG(p
->cap
,
9942 PEER_CAP_REFRESH_OLD_RCV
)) {
9943 vty_out(vty
, " Route refresh:");
9944 if (CHECK_FLAG(p
->cap
,
9945 PEER_CAP_REFRESH_ADV
))
9946 vty_out(vty
, " advertised");
9947 if (CHECK_FLAG(p
->cap
,
9948 PEER_CAP_REFRESH_NEW_RCV
)
9951 PEER_CAP_REFRESH_OLD_RCV
))
9952 vty_out(vty
, " %sreceived(%s)",
9955 PEER_CAP_REFRESH_ADV
)
9960 PEER_CAP_REFRESH_OLD_RCV
)
9963 PEER_CAP_REFRESH_NEW_RCV
))
9967 PEER_CAP_REFRESH_OLD_RCV
)
9974 /* Multiprotocol Extensions */
9975 FOREACH_AFI_SAFI (afi
, safi
)
9976 if (p
->afc_adv
[afi
][safi
]
9977 || p
->afc_recv
[afi
][safi
]) {
9979 " Address Family %s:",
9982 if (p
->afc_adv
[afi
][safi
])
9985 if (p
->afc_recv
[afi
][safi
])
9995 /* Hostname capability */
9996 vty_out(vty
, " Hostname Capability:");
9998 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10000 " advertised (name: %s,domain name: %s)",
10001 bgp
->peer_self
->hostname
10005 bgp
->peer_self
->domainname
10010 vty_out(vty
, " not advertised");
10013 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10015 " received (name: %s,domain name: %s)",
10016 p
->hostname
? p
->hostname
10018 p
->domainname
? p
->domainname
10021 vty_out(vty
, " not received");
10024 vty_out(vty
, "\n");
10026 /* Gracefull Restart */
10027 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10028 || CHECK_FLAG(p
->cap
,
10029 PEER_CAP_RESTART_ADV
)) {
10031 " Graceful Restart Capabilty:");
10032 if (CHECK_FLAG(p
->cap
,
10033 PEER_CAP_RESTART_ADV
))
10034 vty_out(vty
, " advertised");
10035 if (CHECK_FLAG(p
->cap
,
10036 PEER_CAP_RESTART_RCV
))
10037 vty_out(vty
, " %sreceived",
10040 PEER_CAP_RESTART_ADV
)
10043 vty_out(vty
, "\n");
10045 if (CHECK_FLAG(p
->cap
,
10046 PEER_CAP_RESTART_RCV
)) {
10047 int restart_af_count
= 0;
10050 " Remote Restart timer is %d seconds\n",
10053 " Address families by peer:\n ");
10055 FOREACH_AFI_SAFI (afi
, safi
)
10060 PEER_CAP_RESTART_AF_RCV
)) {
10073 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10075 : "not preserved");
10076 restart_af_count
++;
10078 if (!restart_af_count
)
10079 vty_out(vty
, "none");
10080 vty_out(vty
, "\n");
10087 /* graceful restart information */
10088 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10089 || p
->t_gr_stale
) {
10090 json_object
*json_grace
= NULL
;
10091 json_object
*json_grace_send
= NULL
;
10092 json_object
*json_grace_recv
= NULL
;
10093 int eor_send_af_count
= 0;
10094 int eor_receive_af_count
= 0;
10097 json_grace
= json_object_new_object();
10098 json_grace_send
= json_object_new_object();
10099 json_grace_recv
= json_object_new_object();
10101 if (p
->status
== Established
) {
10102 FOREACH_AFI_SAFI (afi
, safi
) {
10103 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10104 PEER_STATUS_EOR_SEND
)) {
10105 json_object_boolean_true_add(
10107 afi_safi_print(afi
,
10109 eor_send_af_count
++;
10112 FOREACH_AFI_SAFI (afi
, safi
) {
10114 p
->af_sflags
[afi
][safi
],
10115 PEER_STATUS_EOR_RECEIVED
)) {
10116 json_object_boolean_true_add(
10118 afi_safi_print(afi
,
10120 eor_receive_af_count
++;
10125 json_object_object_add(json_grace
, "endOfRibSend",
10127 json_object_object_add(json_grace
, "endOfRibRecv",
10130 if (p
->t_gr_restart
)
10131 json_object_int_add(json_grace
,
10132 "gracefulRestartTimerMsecs",
10133 thread_timer_remain_second(
10138 json_object_int_add(
10140 "gracefulStalepathTimerMsecs",
10141 thread_timer_remain_second(
10145 json_object_object_add(
10146 json_neigh
, "gracefulRestartInfo", json_grace
);
10148 vty_out(vty
, " Graceful restart informations:\n");
10149 if (p
->status
== Established
) {
10150 vty_out(vty
, " End-of-RIB send: ");
10151 FOREACH_AFI_SAFI (afi
, safi
) {
10152 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10153 PEER_STATUS_EOR_SEND
)) {
10154 vty_out(vty
, "%s%s",
10155 eor_send_af_count
? ", "
10157 afi_safi_print(afi
,
10159 eor_send_af_count
++;
10162 vty_out(vty
, "\n");
10163 vty_out(vty
, " End-of-RIB received: ");
10164 FOREACH_AFI_SAFI (afi
, safi
) {
10166 p
->af_sflags
[afi
][safi
],
10167 PEER_STATUS_EOR_RECEIVED
)) {
10168 vty_out(vty
, "%s%s",
10169 eor_receive_af_count
10172 afi_safi_print(afi
,
10174 eor_receive_af_count
++;
10177 vty_out(vty
, "\n");
10180 if (p
->t_gr_restart
)
10182 " The remaining time of restart timer is %ld\n",
10183 thread_timer_remain_second(
10188 " The remaining time of stalepath timer is %ld\n",
10189 thread_timer_remain_second(
10194 json_object
*json_stat
= NULL
;
10195 json_stat
= json_object_new_object();
10196 /* Packet counts. */
10197 json_object_int_add(json_stat
, "depthInq", 0);
10198 json_object_int_add(json_stat
, "depthOutq",
10199 (unsigned long)p
->obuf
->count
);
10200 json_object_int_add(json_stat
, "opensSent",
10201 atomic_load_explicit(&p
->open_out
,
10202 memory_order_relaxed
));
10203 json_object_int_add(json_stat
, "opensRecv",
10204 atomic_load_explicit(&p
->open_in
,
10205 memory_order_relaxed
));
10206 json_object_int_add(json_stat
, "notificationsSent",
10207 atomic_load_explicit(&p
->notify_out
,
10208 memory_order_relaxed
));
10209 json_object_int_add(json_stat
, "notificationsRecv",
10210 atomic_load_explicit(&p
->notify_in
,
10211 memory_order_relaxed
));
10212 json_object_int_add(json_stat
, "updatesSent",
10213 atomic_load_explicit(&p
->update_out
,
10214 memory_order_relaxed
));
10215 json_object_int_add(json_stat
, "updatesRecv",
10216 atomic_load_explicit(&p
->update_in
,
10217 memory_order_relaxed
));
10218 json_object_int_add(json_stat
, "keepalivesSent",
10219 atomic_load_explicit(&p
->keepalive_out
,
10220 memory_order_relaxed
));
10221 json_object_int_add(json_stat
, "keepalivesRecv",
10222 atomic_load_explicit(&p
->keepalive_in
,
10223 memory_order_relaxed
));
10224 json_object_int_add(json_stat
, "routeRefreshSent",
10225 atomic_load_explicit(&p
->refresh_out
,
10226 memory_order_relaxed
));
10227 json_object_int_add(json_stat
, "routeRefreshRecv",
10228 atomic_load_explicit(&p
->refresh_in
,
10229 memory_order_relaxed
));
10230 json_object_int_add(json_stat
, "capabilitySent",
10231 atomic_load_explicit(&p
->dynamic_cap_out
,
10232 memory_order_relaxed
));
10233 json_object_int_add(json_stat
, "capabilityRecv",
10234 atomic_load_explicit(&p
->dynamic_cap_in
,
10235 memory_order_relaxed
));
10236 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10237 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10238 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10240 /* Packet counts. */
10241 vty_out(vty
, " Message statistics:\n");
10242 vty_out(vty
, " Inq depth is 0\n");
10243 vty_out(vty
, " Outq depth is %lu\n",
10244 (unsigned long)p
->obuf
->count
);
10245 vty_out(vty
, " Sent Rcvd\n");
10246 vty_out(vty
, " Opens: %10d %10d\n",
10247 atomic_load_explicit(&p
->open_out
,
10248 memory_order_relaxed
),
10249 atomic_load_explicit(&p
->open_in
,
10250 memory_order_relaxed
));
10251 vty_out(vty
, " Notifications: %10d %10d\n",
10252 atomic_load_explicit(&p
->notify_out
,
10253 memory_order_relaxed
),
10254 atomic_load_explicit(&p
->notify_in
,
10255 memory_order_relaxed
));
10256 vty_out(vty
, " Updates: %10d %10d\n",
10257 atomic_load_explicit(&p
->update_out
,
10258 memory_order_relaxed
),
10259 atomic_load_explicit(&p
->update_in
,
10260 memory_order_relaxed
));
10261 vty_out(vty
, " Keepalives: %10d %10d\n",
10262 atomic_load_explicit(&p
->keepalive_out
,
10263 memory_order_relaxed
),
10264 atomic_load_explicit(&p
->keepalive_in
,
10265 memory_order_relaxed
));
10266 vty_out(vty
, " Route Refresh: %10d %10d\n",
10267 atomic_load_explicit(&p
->refresh_out
,
10268 memory_order_relaxed
),
10269 atomic_load_explicit(&p
->refresh_in
,
10270 memory_order_relaxed
));
10271 vty_out(vty
, " Capability: %10d %10d\n",
10272 atomic_load_explicit(&p
->dynamic_cap_out
,
10273 memory_order_relaxed
),
10274 atomic_load_explicit(&p
->dynamic_cap_in
,
10275 memory_order_relaxed
));
10276 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10281 /* advertisement-interval */
10282 json_object_int_add(json_neigh
,
10283 "minBtwnAdvertisementRunsTimerMsecs",
10284 p
->v_routeadv
* 1000);
10286 /* Update-source. */
10287 if (p
->update_if
|| p
->update_source
) {
10289 json_object_string_add(json_neigh
,
10292 else if (p
->update_source
)
10293 json_object_string_add(
10294 json_neigh
, "updateSource",
10295 sockunion2str(p
->update_source
, buf1
,
10299 /* advertisement-interval */
10301 " Minimum time between advertisement runs is %d seconds\n",
10304 /* Update-source. */
10305 if (p
->update_if
|| p
->update_source
) {
10306 vty_out(vty
, " Update source is ");
10308 vty_out(vty
, "%s", p
->update_if
);
10309 else if (p
->update_source
)
10311 sockunion2str(p
->update_source
, buf1
,
10313 vty_out(vty
, "\n");
10316 vty_out(vty
, "\n");
10319 /* Address Family Information */
10320 json_object
*json_hold
= NULL
;
10323 json_hold
= json_object_new_object();
10325 FOREACH_AFI_SAFI (afi
, safi
)
10326 if (p
->afc
[afi
][safi
])
10327 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10331 json_object_object_add(json_neigh
, "addressFamilyInfo",
10333 json_object_int_add(json_neigh
, "connectionsEstablished",
10335 json_object_int_add(json_neigh
, "connectionsDropped",
10338 vty_out(vty
, " Connections established %d; dropped %d\n",
10339 p
->established
, p
->dropped
);
10341 if (!p
->last_reset
) {
10343 json_object_string_add(json_neigh
, "lastReset",
10346 vty_out(vty
, " Last reset never\n");
10352 uptime
= bgp_clock();
10353 uptime
-= p
->resettime
;
10354 tm
= gmtime(&uptime
);
10355 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10356 (tm
->tm_sec
* 1000)
10357 + (tm
->tm_min
* 60000)
10358 + (tm
->tm_hour
* 3600000));
10359 json_object_string_add(
10360 json_neigh
, "lastResetDueTo",
10361 peer_down_str
[(int)p
->last_reset
]);
10362 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10363 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10364 char errorcodesubcode_hexstr
[5];
10365 char errorcodesubcode_str
[256];
10367 code_str
= bgp_notify_code_str(p
->notify
.code
);
10368 subcode_str
= bgp_notify_subcode_str(
10369 p
->notify
.code
, p
->notify
.subcode
);
10371 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10372 p
->notify
.code
, p
->notify
.subcode
);
10373 json_object_string_add(json_neigh
,
10374 "lastErrorCodeSubcode",
10375 errorcodesubcode_hexstr
);
10376 snprintf(errorcodesubcode_str
, 255, "%s%s",
10377 code_str
, subcode_str
);
10378 json_object_string_add(json_neigh
,
10379 "lastNotificationReason",
10380 errorcodesubcode_str
);
10381 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10382 && p
->notify
.code
== BGP_NOTIFY_CEASE
10383 && (p
->notify
.subcode
10384 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10385 || p
->notify
.subcode
10386 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10387 && p
->notify
.length
) {
10389 const char *msg_str
;
10391 msg_str
= bgp_notify_admin_message(
10392 msgbuf
, sizeof(msgbuf
),
10393 (uint8_t *)p
->notify
.data
,
10396 json_object_string_add(
10398 "lastShutdownDescription",
10403 vty_out(vty
, " Last reset %s, ",
10404 peer_uptime(p
->resettime
, timebuf
,
10405 BGP_UPTIME_LEN
, 0, NULL
));
10407 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10408 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10409 code_str
= bgp_notify_code_str(p
->notify
.code
);
10410 subcode_str
= bgp_notify_subcode_str(
10411 p
->notify
.code
, p
->notify
.subcode
);
10412 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10413 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10416 code_str
, subcode_str
);
10417 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10418 && p
->notify
.code
== BGP_NOTIFY_CEASE
10419 && (p
->notify
.subcode
10420 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10421 || p
->notify
.subcode
10422 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10423 && p
->notify
.length
) {
10425 const char *msg_str
;
10427 msg_str
= bgp_notify_admin_message(
10428 msgbuf
, sizeof(msgbuf
),
10429 (uint8_t *)p
->notify
.data
,
10433 " Message: \"%s\"\n",
10437 vty_out(vty
, "due to %s\n",
10438 peer_down_str
[(int)p
->last_reset
]);
10441 if (p
->last_reset_cause_size
) {
10442 msg
= p
->last_reset_cause
;
10444 " Message received that caused BGP to send a NOTIFICATION:\n ");
10445 for (i
= 1; i
<= p
->last_reset_cause_size
;
10447 vty_out(vty
, "%02X", *msg
++);
10449 if (i
!= p
->last_reset_cause_size
) {
10451 vty_out(vty
, "\n ");
10452 } else if (i
% 4 == 0) {
10457 vty_out(vty
, "\n");
10462 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10464 json_object_boolean_true_add(json_neigh
,
10465 "prefixesConfigExceedMax");
10468 " Peer had exceeded the max. no. of prefixes configured.\n");
10470 if (p
->t_pmax_restart
) {
10472 json_object_boolean_true_add(
10473 json_neigh
, "reducePrefixNumFrom");
10474 json_object_int_add(json_neigh
,
10475 "restartInTimerMsec",
10476 thread_timer_remain_second(
10481 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10482 p
->host
, thread_timer_remain_second(
10483 p
->t_pmax_restart
));
10486 json_object_boolean_true_add(
10488 "reducePrefixNumAndClearIpBgp");
10491 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10496 /* EBGP Multihop and GTSM */
10497 if (p
->sort
!= BGP_PEER_IBGP
) {
10499 if (p
->gtsm_hops
> 0)
10500 json_object_int_add(json_neigh
,
10501 "externalBgpNbrMaxHopsAway",
10503 else if (p
->ttl
> 1)
10504 json_object_int_add(json_neigh
,
10505 "externalBgpNbrMaxHopsAway",
10508 if (p
->gtsm_hops
> 0)
10510 " External BGP neighbor may be up to %d hops away.\n",
10512 else if (p
->ttl
> 1)
10514 " External BGP neighbor may be up to %d hops away.\n",
10518 if (p
->gtsm_hops
> 0) {
10520 json_object_int_add(json_neigh
,
10521 "internalBgpNbrMaxHopsAway",
10525 " Internal BGP neighbor may be up to %d hops away.\n",
10530 /* Local address. */
10533 json_object_string_add(json_neigh
, "hostLocal",
10534 sockunion2str(p
->su_local
, buf1
,
10536 json_object_int_add(json_neigh
, "portLocal",
10537 ntohs(p
->su_local
->sin
.sin_port
));
10539 vty_out(vty
, "Local host: %s, Local port: %d\n",
10540 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10541 ntohs(p
->su_local
->sin
.sin_port
));
10544 /* Remote address. */
10545 if (p
->su_remote
) {
10547 json_object_string_add(json_neigh
, "hostForeign",
10548 sockunion2str(p
->su_remote
, buf1
,
10550 json_object_int_add(json_neigh
, "portForeign",
10551 ntohs(p
->su_remote
->sin
.sin_port
));
10553 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10554 sockunion2str(p
->su_remote
, buf1
,
10556 ntohs(p
->su_remote
->sin
.sin_port
));
10559 /* Nexthop display. */
10562 json_object_string_add(json_neigh
, "nexthop",
10564 &p
->nexthop
.v4
, buf1
,
10566 json_object_string_add(json_neigh
, "nexthopGlobal",
10567 inet_ntop(AF_INET6
,
10568 &p
->nexthop
.v6_global
,
10569 buf1
, sizeof(buf1
)));
10570 json_object_string_add(json_neigh
, "nexthopLocal",
10571 inet_ntop(AF_INET6
,
10572 &p
->nexthop
.v6_local
,
10573 buf1
, sizeof(buf1
)));
10574 if (p
->shared_network
)
10575 json_object_string_add(json_neigh
,
10579 json_object_string_add(json_neigh
,
10581 "nonSharedNetwork");
10583 vty_out(vty
, "Nexthop: %s\n",
10584 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10586 vty_out(vty
, "Nexthop global: %s\n",
10587 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10589 vty_out(vty
, "Nexthop local: %s\n",
10590 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10592 vty_out(vty
, "BGP connection: %s\n",
10593 p
->shared_network
? "shared network"
10594 : "non shared network");
10598 /* Timer information. */
10600 json_object_int_add(json_neigh
, "connectRetryTimer",
10602 if (p
->status
== Established
&& p
->rtt
)
10603 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10606 json_object_int_add(
10607 json_neigh
, "nextStartTimerDueInMsecs",
10608 thread_timer_remain_second(p
->t_start
) * 1000);
10610 json_object_int_add(
10611 json_neigh
, "nextConnectTimerDueInMsecs",
10612 thread_timer_remain_second(p
->t_connect
)
10614 if (p
->t_routeadv
) {
10615 json_object_int_add(json_neigh
, "mraiInterval",
10617 json_object_int_add(
10618 json_neigh
, "mraiTimerExpireInMsecs",
10619 thread_timer_remain_second(p
->t_routeadv
)
10623 json_object_int_add(json_neigh
, "authenticationEnabled",
10627 json_object_string_add(json_neigh
, "readThread", "on");
10629 json_object_string_add(json_neigh
, "readThread", "off");
10631 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10632 json_object_string_add(json_neigh
, "writeThread", "on");
10634 json_object_string_add(json_neigh
, "writeThread",
10637 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10639 if (p
->status
== Established
&& p
->rtt
)
10640 vty_out(vty
, "Estimated round trip time: %d ms\n",
10643 vty_out(vty
, "Next start timer due in %ld seconds\n",
10644 thread_timer_remain_second(p
->t_start
));
10646 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10647 thread_timer_remain_second(p
->t_connect
));
10650 "MRAI (interval %u) timer expires in %ld seconds\n",
10652 thread_timer_remain_second(p
->t_routeadv
));
10654 vty_out(vty
, "Peer Authentication Enabled\n");
10656 vty_out(vty
, "Read thread: %s Write thread: %s\n",
10657 p
->t_read
? "on" : "off",
10658 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10663 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10664 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10665 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10668 vty_out(vty
, "\n");
10670 /* BFD information. */
10671 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10674 if (p
->conf_if
) /* Configured interface name. */
10675 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10676 else /* Configured IP address. */
10677 json_object_object_add(json
, p
->host
, json_neigh
);
10681 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10682 enum show_type type
, union sockunion
*su
,
10683 const char *conf_if
, uint8_t use_json
,
10686 struct listnode
*node
, *nnode
;
10690 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10691 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10696 bgp_show_peer(vty
, peer
, use_json
, json
);
10701 && !strcmp(peer
->conf_if
, conf_if
))
10703 && !strcmp(peer
->hostname
, conf_if
))) {
10705 bgp_show_peer(vty
, peer
, use_json
,
10709 if (sockunion_same(&peer
->su
, su
)) {
10711 bgp_show_peer(vty
, peer
, use_json
,
10719 if (type
== show_peer
&& !find
) {
10721 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
10723 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
10727 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10728 json
, JSON_C_TO_STRING_PRETTY
));
10729 json_object_free(json
);
10731 vty_out(vty
, "\n");
10734 return CMD_SUCCESS
;
10737 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
10738 enum show_type type
,
10739 const char *ip_str
,
10742 struct listnode
*node
, *nnode
;
10744 union sockunion su
;
10745 json_object
*json
= NULL
;
10746 int ret
, is_first
= 1;
10749 vty_out(vty
, "{\n");
10751 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
10753 if (!(json
= json_object_new_object())) {
10755 "Unable to allocate memory for JSON object");
10757 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
10761 json_object_int_add(json
, "vrfId",
10762 (bgp
->vrf_id
== VRF_UNKNOWN
)
10764 : (int64_t)bgp
->vrf_id
);
10765 json_object_string_add(
10767 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10772 vty_out(vty
, ",\n");
10776 vty_out(vty
, "\"%s\":",
10777 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10781 vty_out(vty
, "\nInstance %s:\n",
10782 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10787 if (type
== show_peer
) {
10788 ret
= str2sockunion(ip_str
, &su
);
10790 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10793 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10796 bgp_show_neighbor(vty
, bgp
, show_all
, NULL
, NULL
,
10802 vty_out(vty
, "}\n");
10805 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
10806 enum show_type type
, const char *ip_str
,
10811 union sockunion su
;
10812 json_object
*json
= NULL
;
10815 if (strmatch(name
, "all")) {
10816 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
10818 return CMD_SUCCESS
;
10820 bgp
= bgp_lookup_by_name(name
);
10823 json
= json_object_new_object();
10824 json_object_boolean_true_add(
10825 json
, "bgpNoSuchInstance");
10826 vty_out(vty
, "%s\n",
10827 json_object_to_json_string_ext(
10829 JSON_C_TO_STRING_PRETTY
));
10830 json_object_free(json
);
10833 "%% No such BGP instance exist\n");
10835 return CMD_WARNING
;
10839 bgp
= bgp_get_default();
10843 json
= json_object_new_object();
10845 ret
= str2sockunion(ip_str
, &su
);
10847 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10850 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10853 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
10856 json_object_free(json
);
10859 return CMD_SUCCESS
;
10862 /* "show [ip] bgp neighbors" commands. */
10863 DEFUN (show_ip_bgp_neighbors
,
10864 show_ip_bgp_neighbors_cmd
,
10865 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
10869 BGP_INSTANCE_HELP_STR
10872 "Detailed information on TCP and BGP neighbor connections\n"
10873 "Neighbor to display information about\n"
10874 "Neighbor to display information about\n"
10875 "Neighbor on BGP configured interface\n"
10879 char *sh_arg
= NULL
;
10880 enum show_type sh_type
;
10882 uint8_t uj
= use_json(argc
, argv
);
10886 if (argv_find(argv
, argc
, "view", &idx
)
10887 || argv_find(argv
, argc
, "vrf", &idx
))
10888 vrf
= argv
[idx
+ 1]->arg
;
10891 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
10892 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
10893 || argv_find(argv
, argc
, "WORD", &idx
)) {
10894 sh_type
= show_peer
;
10895 sh_arg
= argv
[idx
]->arg
;
10897 sh_type
= show_all
;
10899 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
10902 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
10903 paths' and `show ip mbgp paths'. Those functions results are the
10905 DEFUN (show_ip_bgp_paths
,
10906 show_ip_bgp_paths_cmd
,
10907 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
10912 "Path information\n")
10914 vty_out(vty
, "Address Refcnt Path\n");
10915 aspath_print_all_vty(vty
);
10916 return CMD_SUCCESS
;
10921 static void community_show_all_iterator(struct hash_backet
*backet
,
10924 struct community
*com
;
10926 com
= (struct community
*)backet
->data
;
10927 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
10928 community_str(com
, false));
10931 /* Show BGP's community internal data. */
10932 DEFUN (show_ip_bgp_community_info
,
10933 show_ip_bgp_community_info_cmd
,
10934 "show [ip] bgp community-info",
10938 "List all bgp community information\n")
10940 vty_out(vty
, "Address Refcnt Community\n");
10942 hash_iterate(community_hash(),
10943 (void (*)(struct hash_backet
*,
10944 void *))community_show_all_iterator
,
10947 return CMD_SUCCESS
;
10950 static void lcommunity_show_all_iterator(struct hash_backet
*backet
,
10953 struct lcommunity
*lcom
;
10955 lcom
= (struct lcommunity
*)backet
->data
;
10956 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
10957 lcommunity_str(lcom
, false));
10960 /* Show BGP's community internal data. */
10961 DEFUN (show_ip_bgp_lcommunity_info
,
10962 show_ip_bgp_lcommunity_info_cmd
,
10963 "show ip bgp large-community-info",
10967 "List all bgp large-community information\n")
10969 vty_out(vty
, "Address Refcnt Large-community\n");
10971 hash_iterate(lcommunity_hash(),
10972 (void (*)(struct hash_backet
*,
10973 void *))lcommunity_show_all_iterator
,
10976 return CMD_SUCCESS
;
10980 DEFUN (show_ip_bgp_attr_info
,
10981 show_ip_bgp_attr_info_cmd
,
10982 "show [ip] bgp attribute-info",
10986 "List all bgp attribute information\n")
10988 attr_show_all(vty
);
10989 return CMD_SUCCESS
;
10992 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
10993 afi_t afi
, safi_t safi
)
10996 struct listnode
*node
;
10998 char buf1
[INET6_ADDRSTRLEN
];
11000 vpn_policy_direction_t dir
;
11003 bgp
= bgp_lookup_by_name(name
);
11005 vty_out(vty
, "%% No such BGP instance exist\n");
11006 return CMD_WARNING
;
11009 bgp
= bgp_get_default();
11012 "%% Default BGP instance does not exist\n");
11013 return CMD_WARNING
;
11017 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11018 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11020 "This VRF is not importing %s routes from any other VRF\n",
11021 afi_safi_print(afi
, safi
));
11024 "This VRF is importing %s routes from the following VRFs:\n",
11025 afi_safi_print(afi
, safi
));
11026 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
11028 vty_out(vty
, " %s\n", vname
);
11030 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11031 ecom_str
= ecommunity_ecom2str(
11032 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11033 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11034 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11035 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11038 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11039 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11041 "This VRF is not exporting %s routes to any other VRF\n",
11042 afi_safi_print(afi
, safi
));
11045 "This VRF is exporting %s routes to the following VRFs:\n",
11046 afi_safi_print(afi
, safi
));
11047 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].export_vrf
, node
,
11049 vty_out(vty
, " %s\n", vname
);
11051 vty_out(vty
, "RD: %s\n",
11052 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11053 buf1
, RD_ADDRSTRLEN
));
11054 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11055 ecom_str
= ecommunity_ecom2str(
11056 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11057 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11058 vty_out(vty
, "Emport RT: %s\n", ecom_str
);
11059 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11062 return CMD_SUCCESS
;
11065 /* "show [ip] bgp route-leak" command. */
11066 DEFUN (show_ip_bgp_route_leak
,
11067 show_ip_bgp_route_leak_cmd
,
11068 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak",
11072 BGP_INSTANCE_HELP_STR
11075 "Route leaking information\n")
11078 afi_t afi
= AFI_MAX
;
11079 safi_t safi
= SAFI_MAX
;
11083 /* show [ip] bgp */
11084 if (argv_find(argv
, argc
, "ip", &idx
)) {
11086 safi
= SAFI_UNICAST
;
11088 /* [vrf VIEWVRFNAME] */
11089 if (argv_find(argv
, argc
, "view", &idx
)) {
11091 "%% This command is not applicable to BGP views\n");
11092 return CMD_WARNING
;
11095 if (argv_find(argv
, argc
, "vrf", &idx
))
11096 vrf
= argv
[++idx
]->arg
;
11097 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11098 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11099 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11102 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11104 "%% This command is applicable only for unicast ipv4|ipv6\n");
11105 return CMD_WARNING
;
11108 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
);
11111 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11114 struct listnode
*node
, *nnode
;
11117 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11118 vty_out(vty
, "\nInstance %s:\n",
11119 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11122 update_group_show(bgp
, afi
, safi
, vty
, 0);
11126 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11127 int safi
, uint64_t subgrp_id
)
11132 if (strmatch(name
, "all")) {
11133 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11134 return CMD_SUCCESS
;
11136 bgp
= bgp_lookup_by_name(name
);
11139 bgp
= bgp_get_default();
11143 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11144 return CMD_SUCCESS
;
11147 DEFUN (show_ip_bgp_updgrps
,
11148 show_ip_bgp_updgrps_cmd
,
11149 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11153 BGP_INSTANCE_HELP_STR
11155 BGP_SAFI_WITH_LABEL_HELP_STR
11156 "Detailed info about dynamic update groups\n"
11157 "Specific subgroup to display detailed info for\n")
11160 afi_t afi
= AFI_IP6
;
11161 safi_t safi
= SAFI_UNICAST
;
11162 uint64_t subgrp_id
= 0;
11166 /* show [ip] bgp */
11167 if (argv_find(argv
, argc
, "ip", &idx
))
11169 /* [<view|vrf> VIEWVRFNAME] */
11170 if (argv_find(argv
, argc
, "view", &idx
)
11171 || argv_find(argv
, argc
, "vrf", &idx
))
11172 vrf
= argv
[++idx
]->arg
;
11173 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11174 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11175 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11178 /* get subgroup id, if provided */
11180 if (argv
[idx
]->type
== VARIABLE_TKN
)
11181 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11183 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11186 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11187 show_bgp_instance_all_ipv6_updgrps_cmd
,
11188 "show [ip] bgp <view|vrf> all update-groups",
11192 BGP_INSTANCE_ALL_HELP_STR
11193 "Detailed info about dynamic update groups\n")
11195 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11196 return CMD_SUCCESS
;
11199 DEFUN (show_bgp_updgrps_stats
,
11200 show_bgp_updgrps_stats_cmd
,
11201 "show [ip] bgp update-groups statistics",
11205 "Detailed info about dynamic update groups\n"
11210 bgp
= bgp_get_default();
11212 update_group_show_stats(bgp
, vty
);
11214 return CMD_SUCCESS
;
11217 DEFUN (show_bgp_instance_updgrps_stats
,
11218 show_bgp_instance_updgrps_stats_cmd
,
11219 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11223 BGP_INSTANCE_HELP_STR
11224 "Detailed info about dynamic update groups\n"
11230 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11232 update_group_show_stats(bgp
, vty
);
11234 return CMD_SUCCESS
;
11237 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11238 afi_t afi
, safi_t safi
,
11239 const char *what
, uint64_t subgrp_id
)
11244 bgp
= bgp_lookup_by_name(name
);
11246 bgp
= bgp_get_default();
11249 if (!strcmp(what
, "advertise-queue"))
11250 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11252 else if (!strcmp(what
, "advertised-routes"))
11253 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11255 else if (!strcmp(what
, "packet-queue"))
11256 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11261 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11262 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11263 "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",
11264 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11266 "Detailed info about dynamic update groups\n"
11267 "Specific subgroup to display info for\n"
11268 "Advertisement queue\n"
11269 "Announced routes\n"
11272 uint64_t subgrp_id
= 0;
11276 subgrp_id
= strtoull(sgid
, NULL
, 10);
11281 afiz
= bgp_vty_afi_from_str(afi
);
11285 afiz
= bgp_vty_afi_from_str(afi
);
11286 if (afiz
!= AFI_IP
)
11288 "%% Cannot specify both 'ip' and 'ipv6'\n");
11289 return CMD_WARNING
;
11292 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11294 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11295 return CMD_SUCCESS
;
11298 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11300 struct listnode
*node
, *nnode
;
11301 struct prefix
*range
;
11304 char buf
[PREFIX2STR_BUFFER
];
11307 const char *peer_status
;
11308 const char *af_str
;
11313 conf
= group
->conf
;
11315 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11316 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
11318 } else if (conf
->as_type
== AS_INTERNAL
) {
11319 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
11322 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11325 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11326 vty_out(vty
, " Peer-group type is internal\n");
11328 vty_out(vty
, " Peer-group type is external\n");
11330 /* Display AFs configured. */
11331 vty_out(vty
, " Configured address-families:");
11332 FOREACH_AFI_SAFI (afi
, safi
) {
11333 if (conf
->afc
[afi
][safi
]) {
11335 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11339 vty_out(vty
, " none\n");
11341 vty_out(vty
, "\n");
11343 /* Display listen ranges (for dynamic neighbors), if any */
11344 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11347 else if (afi
== AFI_IP6
)
11351 lr_count
= listcount(group
->listen_range
[afi
]);
11353 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11357 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11359 prefix2str(range
, buf
, sizeof(buf
));
11360 vty_out(vty
, " %s\n", buf
);
11365 /* Display group members and their status */
11366 if (listcount(group
->peer
)) {
11367 vty_out(vty
, " Peer-group members:\n");
11368 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11369 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11370 peer_status
= "Idle (Admin)";
11371 else if (CHECK_FLAG(peer
->sflags
,
11372 PEER_STATUS_PREFIX_OVERFLOW
))
11373 peer_status
= "Idle (PfxCt)";
11375 peer_status
= lookup_msg(bgp_status_msg
,
11376 peer
->status
, NULL
);
11378 dynamic
= peer_dynamic_neighbor(peer
);
11379 vty_out(vty
, " %s %s %s \n", peer
->host
,
11380 dynamic
? "(dynamic)" : "", peer_status
);
11384 return CMD_SUCCESS
;
11387 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11388 const char *group_name
)
11391 struct listnode
*node
, *nnode
;
11392 struct peer_group
*group
;
11393 bool found
= false;
11395 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11398 vty_out(vty
, "%% No such BGP instance exists\n");
11399 return CMD_WARNING
;
11402 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11404 if (strmatch(group
->name
, group_name
)) {
11405 bgp_show_one_peer_group(vty
, group
);
11410 bgp_show_one_peer_group(vty
, group
);
11414 if (group_name
&& !found
)
11415 vty_out(vty
, "%% No such peer-group\n");
11417 return CMD_SUCCESS
;
11420 DEFUN (show_ip_bgp_peer_groups
,
11421 show_ip_bgp_peer_groups_cmd
,
11422 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11426 BGP_INSTANCE_HELP_STR
11427 "Detailed information on BGP peer groups\n"
11428 "Peer group name\n")
11433 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11435 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11437 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11441 /* Redistribute VTY commands. */
11443 DEFUN (bgp_redistribute_ipv4
,
11444 bgp_redistribute_ipv4_cmd
,
11445 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11446 "Redistribute information from another routing protocol\n"
11447 FRR_IP_REDIST_HELP_STR_BGPD
)
11449 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11450 int idx_protocol
= 1;
11453 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11455 vty_out(vty
, "%% Invalid route type\n");
11456 return CMD_WARNING_CONFIG_FAILED
;
11459 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11460 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11464 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11465 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11466 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11468 DEFUN (bgp_redistribute_ipv4_rmap
,
11469 bgp_redistribute_ipv4_rmap_cmd
,
11470 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11471 "Redistribute information from another routing protocol\n"
11472 FRR_IP_REDIST_HELP_STR_BGPD
11473 "Route map reference\n"
11474 "Pointer to route-map entries\n")
11476 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11477 int idx_protocol
= 1;
11480 struct bgp_redist
*red
;
11482 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11484 vty_out(vty
, "%% Invalid route type\n");
11485 return CMD_WARNING_CONFIG_FAILED
;
11488 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11489 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11490 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11494 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
11495 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11496 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11497 "Route map reference\n"
11498 "Pointer to route-map entries\n")
11500 DEFUN (bgp_redistribute_ipv4_metric
,
11501 bgp_redistribute_ipv4_metric_cmd
,
11502 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11503 "Redistribute information from another routing protocol\n"
11504 FRR_IP_REDIST_HELP_STR_BGPD
11505 "Metric for redistributed routes\n"
11506 "Default metric\n")
11508 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11509 int idx_protocol
= 1;
11510 int idx_number
= 3;
11513 struct bgp_redist
*red
;
11515 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11517 vty_out(vty
, "%% Invalid route type\n");
11518 return CMD_WARNING_CONFIG_FAILED
;
11520 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11522 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11523 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11524 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11528 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
11529 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11530 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11531 "Metric for redistributed routes\n"
11532 "Default metric\n")
11534 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
11535 bgp_redistribute_ipv4_rmap_metric_cmd
,
11536 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11537 "Redistribute information from another routing protocol\n"
11538 FRR_IP_REDIST_HELP_STR_BGPD
11539 "Route map reference\n"
11540 "Pointer to route-map entries\n"
11541 "Metric for redistributed routes\n"
11542 "Default metric\n")
11544 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11545 int idx_protocol
= 1;
11547 int idx_number
= 5;
11550 struct bgp_redist
*red
;
11552 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11554 vty_out(vty
, "%% Invalid route type\n");
11555 return CMD_WARNING_CONFIG_FAILED
;
11557 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11559 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11560 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11561 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11562 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11566 bgp_redistribute_ipv4_rmap_metric
,
11567 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
11568 "redistribute " FRR_IP_REDIST_STR_BGPD
11569 " route-map WORD metric (0-4294967295)",
11570 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11571 "Route map reference\n"
11572 "Pointer to route-map entries\n"
11573 "Metric for redistributed routes\n"
11574 "Default metric\n")
11576 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
11577 bgp_redistribute_ipv4_metric_rmap_cmd
,
11578 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
11579 "Redistribute information from another routing protocol\n"
11580 FRR_IP_REDIST_HELP_STR_BGPD
11581 "Metric for redistributed routes\n"
11583 "Route map reference\n"
11584 "Pointer to route-map entries\n")
11586 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11587 int idx_protocol
= 1;
11588 int idx_number
= 3;
11592 struct bgp_redist
*red
;
11594 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11596 vty_out(vty
, "%% Invalid route type\n");
11597 return CMD_WARNING_CONFIG_FAILED
;
11599 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11601 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11602 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11603 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11604 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11608 bgp_redistribute_ipv4_metric_rmap
,
11609 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
11610 "redistribute " FRR_IP_REDIST_STR_BGPD
11611 " metric (0-4294967295) route-map WORD",
11612 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11613 "Metric for redistributed routes\n"
11615 "Route map reference\n"
11616 "Pointer to route-map entries\n")
11618 DEFUN (bgp_redistribute_ipv4_ospf
,
11619 bgp_redistribute_ipv4_ospf_cmd
,
11620 "redistribute <ospf|table> (1-65535)",
11621 "Redistribute information from another routing protocol\n"
11622 "Open Shortest Path First (OSPFv2)\n"
11623 "Non-main Kernel Routing Table\n"
11624 "Instance ID/Table ID\n")
11626 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11627 int idx_ospf_table
= 1;
11628 int idx_number
= 2;
11629 unsigned short instance
;
11630 unsigned short protocol
;
11632 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11634 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11635 protocol
= ZEBRA_ROUTE_OSPF
;
11637 protocol
= ZEBRA_ROUTE_TABLE
;
11639 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11640 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11643 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
11644 "redistribute <ospf|table> (1-65535)",
11645 "Redistribute information from another routing protocol\n"
11646 "Open Shortest Path First (OSPFv2)\n"
11647 "Non-main Kernel Routing Table\n"
11648 "Instance ID/Table ID\n")
11650 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
11651 bgp_redistribute_ipv4_ospf_rmap_cmd
,
11652 "redistribute <ospf|table> (1-65535) route-map WORD",
11653 "Redistribute information from another routing protocol\n"
11654 "Open Shortest Path First (OSPFv2)\n"
11655 "Non-main Kernel Routing Table\n"
11656 "Instance ID/Table ID\n"
11657 "Route map reference\n"
11658 "Pointer to route-map entries\n")
11660 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11661 int idx_ospf_table
= 1;
11662 int idx_number
= 2;
11664 struct bgp_redist
*red
;
11665 unsigned short instance
;
11668 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11669 protocol
= ZEBRA_ROUTE_OSPF
;
11671 protocol
= ZEBRA_ROUTE_TABLE
;
11673 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11674 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11675 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11676 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11679 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
11680 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
11681 "redistribute <ospf|table> (1-65535) route-map WORD",
11682 "Redistribute information from another routing protocol\n"
11683 "Open Shortest Path First (OSPFv2)\n"
11684 "Non-main Kernel Routing Table\n"
11685 "Instance ID/Table ID\n"
11686 "Route map reference\n"
11687 "Pointer to route-map entries\n")
11689 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
11690 bgp_redistribute_ipv4_ospf_metric_cmd
,
11691 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
11692 "Redistribute information from another routing protocol\n"
11693 "Open Shortest Path First (OSPFv2)\n"
11694 "Non-main Kernel Routing Table\n"
11695 "Instance ID/Table ID\n"
11696 "Metric for redistributed routes\n"
11697 "Default metric\n")
11699 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11700 int idx_ospf_table
= 1;
11701 int idx_number
= 2;
11702 int idx_number_2
= 4;
11704 struct bgp_redist
*red
;
11705 unsigned short instance
;
11708 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11709 protocol
= ZEBRA_ROUTE_OSPF
;
11711 protocol
= ZEBRA_ROUTE_TABLE
;
11713 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11714 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11716 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11717 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11718 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11721 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
11722 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
11723 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
11724 "Redistribute information from another routing protocol\n"
11725 "Open Shortest Path First (OSPFv2)\n"
11726 "Non-main Kernel Routing Table\n"
11727 "Instance ID/Table ID\n"
11728 "Metric for redistributed routes\n"
11729 "Default metric\n")
11731 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
11732 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
11733 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
11734 "Redistribute information from another routing protocol\n"
11735 "Open Shortest Path First (OSPFv2)\n"
11736 "Non-main Kernel Routing Table\n"
11737 "Instance ID/Table ID\n"
11738 "Route map reference\n"
11739 "Pointer to route-map entries\n"
11740 "Metric for redistributed routes\n"
11741 "Default metric\n")
11743 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11744 int idx_ospf_table
= 1;
11745 int idx_number
= 2;
11747 int idx_number_2
= 6;
11749 struct bgp_redist
*red
;
11750 unsigned short instance
;
11753 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11754 protocol
= ZEBRA_ROUTE_OSPF
;
11756 protocol
= ZEBRA_ROUTE_TABLE
;
11758 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11759 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11761 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11762 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11763 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11764 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11768 bgp_redistribute_ipv4_ospf_rmap_metric
,
11769 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
11770 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
11771 "Redistribute information from another routing protocol\n"
11772 "Open Shortest Path First (OSPFv2)\n"
11773 "Non-main Kernel Routing Table\n"
11774 "Instance ID/Table ID\n"
11775 "Route map reference\n"
11776 "Pointer to route-map entries\n"
11777 "Metric for redistributed routes\n"
11778 "Default metric\n")
11780 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
11781 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
11782 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
11783 "Redistribute information from another routing protocol\n"
11784 "Open Shortest Path First (OSPFv2)\n"
11785 "Non-main Kernel Routing Table\n"
11786 "Instance ID/Table ID\n"
11787 "Metric for redistributed routes\n"
11789 "Route map reference\n"
11790 "Pointer to route-map entries\n")
11792 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11793 int idx_ospf_table
= 1;
11794 int idx_number
= 2;
11795 int idx_number_2
= 4;
11798 struct bgp_redist
*red
;
11799 unsigned short instance
;
11802 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11803 protocol
= ZEBRA_ROUTE_OSPF
;
11805 protocol
= ZEBRA_ROUTE_TABLE
;
11807 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11808 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11810 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11811 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11812 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11813 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11817 bgp_redistribute_ipv4_ospf_metric_rmap
,
11818 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
11819 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
11820 "Redistribute information from another routing protocol\n"
11821 "Open Shortest Path First (OSPFv2)\n"
11822 "Non-main Kernel Routing Table\n"
11823 "Instance ID/Table ID\n"
11824 "Metric for redistributed routes\n"
11826 "Route map reference\n"
11827 "Pointer to route-map entries\n")
11829 DEFUN (no_bgp_redistribute_ipv4_ospf
,
11830 no_bgp_redistribute_ipv4_ospf_cmd
,
11831 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
11833 "Redistribute information from another routing protocol\n"
11834 "Open Shortest Path First (OSPFv2)\n"
11835 "Non-main Kernel Routing Table\n"
11836 "Instance ID/Table ID\n"
11837 "Metric for redistributed routes\n"
11839 "Route map reference\n"
11840 "Pointer to route-map entries\n")
11842 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11843 int idx_ospf_table
= 2;
11844 int idx_number
= 3;
11845 unsigned short instance
;
11848 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11849 protocol
= ZEBRA_ROUTE_OSPF
;
11851 protocol
= ZEBRA_ROUTE_TABLE
;
11853 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11854 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
11858 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
11859 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
11861 "Redistribute information from another routing protocol\n"
11862 "Open Shortest Path First (OSPFv2)\n"
11863 "Non-main Kernel Routing Table\n"
11864 "Instance ID/Table ID\n"
11865 "Metric for redistributed routes\n"
11867 "Route map reference\n"
11868 "Pointer to route-map entries\n")
11870 DEFUN (no_bgp_redistribute_ipv4
,
11871 no_bgp_redistribute_ipv4_cmd
,
11872 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
11874 "Redistribute information from another routing protocol\n"
11875 FRR_IP_REDIST_HELP_STR_BGPD
11876 "Metric for redistributed routes\n"
11878 "Route map reference\n"
11879 "Pointer to route-map entries\n")
11881 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11882 int idx_protocol
= 2;
11885 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11887 vty_out(vty
, "%% Invalid route type\n");
11888 return CMD_WARNING_CONFIG_FAILED
;
11890 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
11894 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
11895 "no redistribute " FRR_IP_REDIST_STR_BGPD
11896 " [metric (0-4294967295)] [route-map WORD]",
11898 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11899 "Metric for redistributed routes\n"
11901 "Route map reference\n"
11902 "Pointer to route-map entries\n")
11904 DEFUN (bgp_redistribute_ipv6
,
11905 bgp_redistribute_ipv6_cmd
,
11906 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
11907 "Redistribute information from another routing protocol\n"
11908 FRR_IP6_REDIST_HELP_STR_BGPD
)
11910 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11911 int idx_protocol
= 1;
11914 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11916 vty_out(vty
, "%% Invalid route type\n");
11917 return CMD_WARNING_CONFIG_FAILED
;
11920 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11921 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11924 DEFUN (bgp_redistribute_ipv6_rmap
,
11925 bgp_redistribute_ipv6_rmap_cmd
,
11926 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
11927 "Redistribute information from another routing protocol\n"
11928 FRR_IP6_REDIST_HELP_STR_BGPD
11929 "Route map reference\n"
11930 "Pointer to route-map entries\n")
11932 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11933 int idx_protocol
= 1;
11936 struct bgp_redist
*red
;
11938 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11940 vty_out(vty
, "%% Invalid route type\n");
11941 return CMD_WARNING_CONFIG_FAILED
;
11944 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11945 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11946 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11949 DEFUN (bgp_redistribute_ipv6_metric
,
11950 bgp_redistribute_ipv6_metric_cmd
,
11951 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
11952 "Redistribute information from another routing protocol\n"
11953 FRR_IP6_REDIST_HELP_STR_BGPD
11954 "Metric for redistributed routes\n"
11955 "Default metric\n")
11957 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11958 int idx_protocol
= 1;
11959 int idx_number
= 3;
11962 struct bgp_redist
*red
;
11964 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11966 vty_out(vty
, "%% Invalid route type\n");
11967 return CMD_WARNING_CONFIG_FAILED
;
11969 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11971 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11972 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
11973 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11976 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
11977 bgp_redistribute_ipv6_rmap_metric_cmd
,
11978 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11979 "Redistribute information from another routing protocol\n"
11980 FRR_IP6_REDIST_HELP_STR_BGPD
11981 "Route map reference\n"
11982 "Pointer to route-map entries\n"
11983 "Metric for redistributed routes\n"
11984 "Default metric\n")
11986 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11987 int idx_protocol
= 1;
11989 int idx_number
= 5;
11992 struct bgp_redist
*red
;
11994 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11996 vty_out(vty
, "%% Invalid route type\n");
11997 return CMD_WARNING_CONFIG_FAILED
;
11999 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12001 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12002 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
12003 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12004 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
12007 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12008 bgp_redistribute_ipv6_metric_rmap_cmd
,
12009 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12010 "Redistribute information from another routing protocol\n"
12011 FRR_IP6_REDIST_HELP_STR_BGPD
12012 "Metric for redistributed routes\n"
12014 "Route map reference\n"
12015 "Pointer to route-map entries\n")
12017 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12018 int idx_protocol
= 1;
12019 int idx_number
= 3;
12023 struct bgp_redist
*red
;
12025 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12027 vty_out(vty
, "%% Invalid route type\n");
12028 return CMD_WARNING_CONFIG_FAILED
;
12030 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12032 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12033 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
, metric
);
12034 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
12035 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
12038 DEFUN (no_bgp_redistribute_ipv6
,
12039 no_bgp_redistribute_ipv6_cmd
,
12040 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12042 "Redistribute information from another routing protocol\n"
12043 FRR_IP6_REDIST_HELP_STR_BGPD
12044 "Metric for redistributed routes\n"
12046 "Route map reference\n"
12047 "Pointer to route-map entries\n")
12049 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12050 int idx_protocol
= 2;
12053 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12055 vty_out(vty
, "%% Invalid route type\n");
12056 return CMD_WARNING_CONFIG_FAILED
;
12059 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12062 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12067 /* Unicast redistribution only. */
12068 if (safi
!= SAFI_UNICAST
)
12071 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12072 /* Redistribute BGP does not make sense. */
12073 if (i
!= ZEBRA_ROUTE_BGP
) {
12074 struct list
*red_list
;
12075 struct listnode
*node
;
12076 struct bgp_redist
*red
;
12078 red_list
= bgp
->redist
[afi
][i
];
12082 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12083 /* "redistribute" configuration. */
12084 vty_out(vty
, " redistribute %s",
12085 zebra_route_string(i
));
12087 vty_out(vty
, " %d", red
->instance
);
12088 if (red
->redist_metric_flag
)
12089 vty_out(vty
, " metric %u",
12090 red
->redist_metric
);
12091 if (red
->rmap
.name
)
12092 vty_out(vty
, " route-map %s",
12094 vty_out(vty
, "\n");
12100 /* This is part of the address-family block (unicast only) */
12101 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12106 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
])
12107 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12108 bgp
->vpn_policy
[afi
]
12109 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12111 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12112 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12113 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12114 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12117 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12118 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12120 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12123 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12124 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12125 bgp
->vpn_policy
[afi
].tovpn_label
);
12128 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12129 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12130 char buf
[RD_ADDRSTRLEN
];
12131 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12132 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12135 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12136 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12138 char buf
[PREFIX_STRLEN
];
12139 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12140 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12143 vty_out(vty
, "%*snexthop vpn export %s\n",
12147 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12148 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12150 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12151 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12153 char *b
= ecommunity_ecom2str(
12154 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12155 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12156 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12157 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12159 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12160 char *b
= ecommunity_ecom2str(
12161 bgp
->vpn_policy
[afi
]
12162 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12163 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12164 ECOMMUNITY_ROUTE_TARGET
);
12165 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12166 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12168 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12169 char *b
= ecommunity_ecom2str(
12170 bgp
->vpn_policy
[afi
]
12171 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12172 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12173 ECOMMUNITY_ROUTE_TARGET
);
12174 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12175 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12179 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12180 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12181 bgp
->vpn_policy
[afi
]
12182 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12184 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12185 char *b
= ecommunity_ecom2str(
12186 bgp
->vpn_policy
[afi
]
12187 .import_redirect_rtlist
,
12188 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12189 ECOMMUNITY_ROUTE_TARGET
);
12191 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12192 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12197 /* BGP node structure. */
12198 static struct cmd_node bgp_node
= {
12199 BGP_NODE
, "%s(config-router)# ", 1,
12202 static struct cmd_node bgp_ipv4_unicast_node
= {
12203 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12206 static struct cmd_node bgp_ipv4_multicast_node
= {
12207 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12210 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12211 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12214 static struct cmd_node bgp_ipv6_unicast_node
= {
12215 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12218 static struct cmd_node bgp_ipv6_multicast_node
= {
12219 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12222 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12223 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12226 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12227 "%s(config-router-af)# ", 1};
12229 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12230 "%s(config-router-af-vpnv6)# ", 1};
12232 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12233 "%s(config-router-evpn)# ", 1};
12235 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12236 "%s(config-router-af-vni)# ", 1};
12238 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12239 "%s(config-router-af)# ", 1};
12241 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12242 "%s(config-router-af-vpnv6)# ", 1};
12244 static void community_list_vty(void);
12246 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12250 struct listnode
*lnbgp
, *lnpeer
;
12252 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12253 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12254 /* only provide suggestions on the appropriate input
12256 * they'll otherwise show up multiple times */
12257 enum cmd_token_type match_type
;
12258 char *name
= peer
->host
;
12260 if (peer
->conf_if
) {
12261 match_type
= VARIABLE_TKN
;
12262 name
= peer
->conf_if
;
12263 } else if (strchr(peer
->host
, ':'))
12264 match_type
= IPV6_TKN
;
12266 match_type
= IPV4_TKN
;
12268 if (token
->type
!= match_type
)
12271 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12276 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12277 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12278 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12279 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12280 {.completions
= NULL
}};
12282 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12285 struct peer_group
*group
;
12286 struct listnode
*lnbgp
, *lnpeer
;
12288 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12289 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12290 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12295 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12296 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12297 {.completions
= NULL
} };
12299 void bgp_vty_init(void)
12301 cmd_variable_handler_register(bgp_var_neighbor
);
12302 cmd_variable_handler_register(bgp_var_peergroup
);
12304 /* Install bgp top node. */
12305 install_node(&bgp_node
, bgp_config_write
);
12306 install_node(&bgp_ipv4_unicast_node
, NULL
);
12307 install_node(&bgp_ipv4_multicast_node
, NULL
);
12308 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12309 install_node(&bgp_ipv6_unicast_node
, NULL
);
12310 install_node(&bgp_ipv6_multicast_node
, NULL
);
12311 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12312 install_node(&bgp_vpnv4_node
, NULL
);
12313 install_node(&bgp_vpnv6_node
, NULL
);
12314 install_node(&bgp_evpn_node
, NULL
);
12315 install_node(&bgp_evpn_vni_node
, NULL
);
12316 install_node(&bgp_flowspecv4_node
, NULL
);
12317 install_node(&bgp_flowspecv6_node
, NULL
);
12319 /* Install default VTY commands to new nodes. */
12320 install_default(BGP_NODE
);
12321 install_default(BGP_IPV4_NODE
);
12322 install_default(BGP_IPV4M_NODE
);
12323 install_default(BGP_IPV4L_NODE
);
12324 install_default(BGP_IPV6_NODE
);
12325 install_default(BGP_IPV6M_NODE
);
12326 install_default(BGP_IPV6L_NODE
);
12327 install_default(BGP_VPNV4_NODE
);
12328 install_default(BGP_VPNV6_NODE
);
12329 install_default(BGP_FLOWSPECV4_NODE
);
12330 install_default(BGP_FLOWSPECV6_NODE
);
12331 install_default(BGP_EVPN_NODE
);
12332 install_default(BGP_EVPN_VNI_NODE
);
12334 /* "bgp multiple-instance" commands. */
12335 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
12336 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
12338 /* "bgp config-type" commands. */
12339 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
12340 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
12342 /* bgp route-map delay-timer commands. */
12343 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12344 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12346 /* Dummy commands (Currently not supported) */
12347 install_element(BGP_NODE
, &no_synchronization_cmd
);
12348 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12350 /* "router bgp" commands. */
12351 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12353 /* "no router bgp" commands. */
12354 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12356 /* "bgp router-id" commands. */
12357 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12358 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12360 /* "bgp cluster-id" commands. */
12361 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12362 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12364 /* "bgp confederation" commands. */
12365 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12366 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12368 /* "bgp confederation peers" commands. */
12369 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12370 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12372 /* bgp max-med command */
12373 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12374 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12375 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12376 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12377 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12379 /* bgp disable-ebgp-connected-nh-check */
12380 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12381 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12383 /* bgp update-delay command */
12384 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12385 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12386 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12388 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12389 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12390 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12391 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12393 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12394 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12396 /* "maximum-paths" commands. */
12397 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12398 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12399 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12400 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12401 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12402 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12403 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12404 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12405 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12406 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12407 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12408 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12409 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12410 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12411 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12413 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12414 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12415 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12416 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12417 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12419 /* "timers bgp" commands. */
12420 install_element(BGP_NODE
, &bgp_timers_cmd
);
12421 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12423 /* route-map delay-timer commands - per instance for backwards compat.
12425 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12426 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12428 /* "bgp client-to-client reflection" commands */
12429 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
12430 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
12432 /* "bgp always-compare-med" commands */
12433 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
12434 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
12436 /* "bgp deterministic-med" commands */
12437 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
12438 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
12440 /* "bgp graceful-restart" commands */
12441 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
12442 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
12443 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
12444 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
12445 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
12446 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
12448 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
12449 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
12451 /* "bgp graceful-shutdown" commands */
12452 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
12453 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
12455 /* "bgp fast-external-failover" commands */
12456 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
12457 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
12459 /* "bgp enforce-first-as" commands */
12460 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
12462 /* "bgp bestpath compare-routerid" commands */
12463 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
12464 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
12466 /* "bgp bestpath as-path ignore" commands */
12467 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
12468 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
12470 /* "bgp bestpath as-path confed" commands */
12471 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
12472 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
12474 /* "bgp bestpath as-path multipath-relax" commands */
12475 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
12476 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
12478 /* "bgp log-neighbor-changes" commands */
12479 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
12480 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
12482 /* "bgp bestpath med" commands */
12483 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
12484 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
12486 /* "no bgp default ipv4-unicast" commands. */
12487 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
12488 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
12490 /* "bgp network import-check" commands. */
12491 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
12492 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
12493 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
12495 /* "bgp default local-preference" commands. */
12496 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
12497 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
12499 /* bgp default show-hostname */
12500 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
12501 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
12503 /* "bgp default subgroup-pkt-queue-max" commands. */
12504 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
12505 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
12507 /* bgp ibgp-allow-policy-mods command */
12508 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
12509 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
12511 /* "bgp listen limit" commands. */
12512 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
12513 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
12515 /* "bgp listen range" commands. */
12516 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
12517 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
12519 /* "bgp default shutdown" command */
12520 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
12522 /* "neighbor remote-as" commands. */
12523 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
12524 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
12525 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
12526 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
12527 install_element(BGP_NODE
,
12528 &neighbor_interface_v6only_config_remote_as_cmd
);
12529 install_element(BGP_NODE
, &no_neighbor_cmd
);
12530 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
12532 /* "neighbor peer-group" commands. */
12533 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
12534 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
12535 install_element(BGP_NODE
,
12536 &no_neighbor_interface_peer_group_remote_as_cmd
);
12538 /* "neighbor local-as" commands. */
12539 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
12540 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
12541 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
12542 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
12544 /* "neighbor solo" commands. */
12545 install_element(BGP_NODE
, &neighbor_solo_cmd
);
12546 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
12548 /* "neighbor password" commands. */
12549 install_element(BGP_NODE
, &neighbor_password_cmd
);
12550 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
12552 /* "neighbor activate" commands. */
12553 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
12554 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
12555 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
12556 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
12557 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
12558 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
12559 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
12560 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
12561 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
12562 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
12563 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
12564 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
12566 /* "no neighbor activate" commands. */
12567 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
12568 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
12569 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
12570 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
12571 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
12572 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
12573 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
12574 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
12575 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
12576 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
12577 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
12578 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
12580 /* "neighbor peer-group" set commands. */
12581 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
12582 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12583 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12584 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12585 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12586 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12587 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12588 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12589 install_element(BGP_FLOWSPECV4_NODE
,
12590 &neighbor_set_peer_group_hidden_cmd
);
12591 install_element(BGP_FLOWSPECV6_NODE
,
12592 &neighbor_set_peer_group_hidden_cmd
);
12594 /* "no neighbor peer-group unset" commands. */
12595 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
12596 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12597 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12598 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12599 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12600 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12601 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12602 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12603 install_element(BGP_FLOWSPECV4_NODE
,
12604 &no_neighbor_set_peer_group_hidden_cmd
);
12605 install_element(BGP_FLOWSPECV6_NODE
,
12606 &no_neighbor_set_peer_group_hidden_cmd
);
12608 /* "neighbor softreconfiguration inbound" commands.*/
12609 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
12610 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
12611 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12612 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12613 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12614 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12615 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12616 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12617 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12618 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12619 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12620 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12621 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12622 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12623 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12624 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12625 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12626 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12627 install_element(BGP_FLOWSPECV4_NODE
,
12628 &neighbor_soft_reconfiguration_cmd
);
12629 install_element(BGP_FLOWSPECV4_NODE
,
12630 &no_neighbor_soft_reconfiguration_cmd
);
12631 install_element(BGP_FLOWSPECV6_NODE
,
12632 &neighbor_soft_reconfiguration_cmd
);
12633 install_element(BGP_FLOWSPECV6_NODE
,
12634 &no_neighbor_soft_reconfiguration_cmd
);
12636 /* "neighbor attribute-unchanged" commands. */
12637 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
12638 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
12639 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
12640 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
12641 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
12642 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
12643 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
12644 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
12645 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
12646 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
12647 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
12648 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
12649 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
12650 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
12651 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
12652 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
12653 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
12654 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
12656 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
12657 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
12659 /* "nexthop-local unchanged" commands */
12660 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
12661 install_element(BGP_IPV6_NODE
,
12662 &no_neighbor_nexthop_local_unchanged_cmd
);
12664 /* "neighbor next-hop-self" commands. */
12665 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
12666 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
12667 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
12668 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
12669 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
12670 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
12671 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
12672 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
12673 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
12674 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
12675 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
12676 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
12677 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
12678 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
12679 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
12680 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
12681 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
12682 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
12683 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
12684 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
12686 /* "neighbor next-hop-self force" commands. */
12687 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
12688 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
12689 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
12690 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12691 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
12692 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12693 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
12694 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12695 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
12696 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12697 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
12698 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12699 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
12700 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12701 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
12702 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12703 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
12704 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12706 /* "neighbor as-override" commands. */
12707 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
12708 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
12709 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
12710 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
12711 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
12712 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
12713 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
12714 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
12715 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
12716 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
12717 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
12718 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
12719 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
12720 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
12721 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
12722 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
12723 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
12724 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
12726 /* "neighbor remove-private-AS" commands. */
12727 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
12728 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
12729 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
12730 install_element(BGP_NODE
,
12731 &no_neighbor_remove_private_as_all_hidden_cmd
);
12732 install_element(BGP_NODE
,
12733 &neighbor_remove_private_as_replace_as_hidden_cmd
);
12734 install_element(BGP_NODE
,
12735 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
12736 install_element(BGP_NODE
,
12737 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
12740 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
12741 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
12742 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
12743 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
12744 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12745 install_element(BGP_IPV4_NODE
,
12746 &neighbor_remove_private_as_replace_as_cmd
);
12747 install_element(BGP_IPV4_NODE
,
12748 &no_neighbor_remove_private_as_replace_as_cmd
);
12749 install_element(BGP_IPV4_NODE
,
12750 &neighbor_remove_private_as_all_replace_as_cmd
);
12751 install_element(BGP_IPV4_NODE
,
12752 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12753 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
12754 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
12755 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
12756 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12757 install_element(BGP_IPV4M_NODE
,
12758 &neighbor_remove_private_as_replace_as_cmd
);
12759 install_element(BGP_IPV4M_NODE
,
12760 &no_neighbor_remove_private_as_replace_as_cmd
);
12761 install_element(BGP_IPV4M_NODE
,
12762 &neighbor_remove_private_as_all_replace_as_cmd
);
12763 install_element(BGP_IPV4M_NODE
,
12764 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12765 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
12766 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
12767 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
12768 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12769 install_element(BGP_IPV4L_NODE
,
12770 &neighbor_remove_private_as_replace_as_cmd
);
12771 install_element(BGP_IPV4L_NODE
,
12772 &no_neighbor_remove_private_as_replace_as_cmd
);
12773 install_element(BGP_IPV4L_NODE
,
12774 &neighbor_remove_private_as_all_replace_as_cmd
);
12775 install_element(BGP_IPV4L_NODE
,
12776 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12777 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
12778 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
12779 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
12780 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12781 install_element(BGP_IPV6_NODE
,
12782 &neighbor_remove_private_as_replace_as_cmd
);
12783 install_element(BGP_IPV6_NODE
,
12784 &no_neighbor_remove_private_as_replace_as_cmd
);
12785 install_element(BGP_IPV6_NODE
,
12786 &neighbor_remove_private_as_all_replace_as_cmd
);
12787 install_element(BGP_IPV6_NODE
,
12788 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12789 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
12790 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
12791 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
12792 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12793 install_element(BGP_IPV6M_NODE
,
12794 &neighbor_remove_private_as_replace_as_cmd
);
12795 install_element(BGP_IPV6M_NODE
,
12796 &no_neighbor_remove_private_as_replace_as_cmd
);
12797 install_element(BGP_IPV6M_NODE
,
12798 &neighbor_remove_private_as_all_replace_as_cmd
);
12799 install_element(BGP_IPV6M_NODE
,
12800 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12801 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
12802 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
12803 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
12804 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12805 install_element(BGP_IPV6L_NODE
,
12806 &neighbor_remove_private_as_replace_as_cmd
);
12807 install_element(BGP_IPV6L_NODE
,
12808 &no_neighbor_remove_private_as_replace_as_cmd
);
12809 install_element(BGP_IPV6L_NODE
,
12810 &neighbor_remove_private_as_all_replace_as_cmd
);
12811 install_element(BGP_IPV6L_NODE
,
12812 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12813 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
12814 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
12815 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
12816 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12817 install_element(BGP_VPNV4_NODE
,
12818 &neighbor_remove_private_as_replace_as_cmd
);
12819 install_element(BGP_VPNV4_NODE
,
12820 &no_neighbor_remove_private_as_replace_as_cmd
);
12821 install_element(BGP_VPNV4_NODE
,
12822 &neighbor_remove_private_as_all_replace_as_cmd
);
12823 install_element(BGP_VPNV4_NODE
,
12824 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12825 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
12826 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
12827 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
12828 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12829 install_element(BGP_VPNV6_NODE
,
12830 &neighbor_remove_private_as_replace_as_cmd
);
12831 install_element(BGP_VPNV6_NODE
,
12832 &no_neighbor_remove_private_as_replace_as_cmd
);
12833 install_element(BGP_VPNV6_NODE
,
12834 &neighbor_remove_private_as_all_replace_as_cmd
);
12835 install_element(BGP_VPNV6_NODE
,
12836 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12838 /* "neighbor send-community" commands.*/
12839 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
12840 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
12841 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
12842 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
12843 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
12844 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
12845 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
12846 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
12847 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
12848 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
12849 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
12850 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
12851 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
12852 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
12853 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
12854 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
12855 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
12856 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
12857 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
12858 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
12859 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
12860 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
12861 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
12862 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
12863 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
12864 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
12865 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
12866 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
12867 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
12868 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
12869 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
12870 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
12871 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
12872 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
12873 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
12874 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
12876 /* "neighbor route-reflector" commands.*/
12877 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
12878 install_element(BGP_NODE
,
12879 &no_neighbor_route_reflector_client_hidden_cmd
);
12880 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
12881 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
12882 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
12883 install_element(BGP_IPV4M_NODE
,
12884 &no_neighbor_route_reflector_client_cmd
);
12885 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
12886 install_element(BGP_IPV4L_NODE
,
12887 &no_neighbor_route_reflector_client_cmd
);
12888 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
12889 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
12890 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
12891 install_element(BGP_IPV6M_NODE
,
12892 &no_neighbor_route_reflector_client_cmd
);
12893 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
12894 install_element(BGP_IPV6L_NODE
,
12895 &no_neighbor_route_reflector_client_cmd
);
12896 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
12897 install_element(BGP_VPNV4_NODE
,
12898 &no_neighbor_route_reflector_client_cmd
);
12899 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
12900 install_element(BGP_VPNV6_NODE
,
12901 &no_neighbor_route_reflector_client_cmd
);
12902 install_element(BGP_FLOWSPECV4_NODE
,
12903 &neighbor_route_reflector_client_cmd
);
12904 install_element(BGP_FLOWSPECV4_NODE
,
12905 &no_neighbor_route_reflector_client_cmd
);
12906 install_element(BGP_FLOWSPECV6_NODE
,
12907 &neighbor_route_reflector_client_cmd
);
12908 install_element(BGP_FLOWSPECV6_NODE
,
12909 &no_neighbor_route_reflector_client_cmd
);
12910 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
12911 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
12913 /* "neighbor route-server" commands.*/
12914 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
12915 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
12916 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
12917 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
12918 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
12919 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
12920 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
12921 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
12922 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
12923 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
12924 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
12925 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
12926 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
12927 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
12928 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
12929 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
12930 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
12931 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
12932 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
12933 install_element(BGP_FLOWSPECV4_NODE
,
12934 &no_neighbor_route_server_client_cmd
);
12935 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
12936 install_element(BGP_FLOWSPECV6_NODE
,
12937 &no_neighbor_route_server_client_cmd
);
12939 /* "neighbor addpath-tx-all-paths" commands.*/
12940 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
12941 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
12942 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12943 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12944 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12945 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12946 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12947 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12948 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12949 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12950 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12951 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12952 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12953 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12954 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12955 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12956 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12957 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12959 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
12960 install_element(BGP_NODE
,
12961 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
12962 install_element(BGP_NODE
,
12963 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
12964 install_element(BGP_IPV4_NODE
,
12965 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12966 install_element(BGP_IPV4_NODE
,
12967 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12968 install_element(BGP_IPV4M_NODE
,
12969 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12970 install_element(BGP_IPV4M_NODE
,
12971 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12972 install_element(BGP_IPV4L_NODE
,
12973 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12974 install_element(BGP_IPV4L_NODE
,
12975 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12976 install_element(BGP_IPV6_NODE
,
12977 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12978 install_element(BGP_IPV6_NODE
,
12979 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12980 install_element(BGP_IPV6M_NODE
,
12981 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12982 install_element(BGP_IPV6M_NODE
,
12983 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12984 install_element(BGP_IPV6L_NODE
,
12985 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12986 install_element(BGP_IPV6L_NODE
,
12987 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12988 install_element(BGP_VPNV4_NODE
,
12989 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12990 install_element(BGP_VPNV4_NODE
,
12991 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12992 install_element(BGP_VPNV6_NODE
,
12993 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12994 install_element(BGP_VPNV6_NODE
,
12995 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12997 /* "neighbor passive" commands. */
12998 install_element(BGP_NODE
, &neighbor_passive_cmd
);
12999 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13002 /* "neighbor shutdown" commands. */
13003 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13004 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13005 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13006 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13008 /* "neighbor capability extended-nexthop" commands.*/
13009 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13010 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13012 /* "neighbor capability orf prefix-list" commands.*/
13013 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13014 install_element(BGP_NODE
,
13015 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13016 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13017 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13018 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13019 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13020 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13021 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13022 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13023 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13024 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13025 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13026 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13027 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13029 /* "neighbor capability dynamic" commands.*/
13030 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13031 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13033 /* "neighbor dont-capability-negotiate" commands. */
13034 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13035 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13037 /* "neighbor ebgp-multihop" commands. */
13038 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13039 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13040 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13042 /* "neighbor disable-connected-check" commands. */
13043 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13044 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13046 /* "neighbor enforce-first-as" commands. */
13047 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13048 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13050 /* "neighbor description" commands. */
13051 install_element(BGP_NODE
, &neighbor_description_cmd
);
13052 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13053 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13055 /* "neighbor update-source" commands. "*/
13056 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13057 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13059 /* "neighbor default-originate" commands. */
13060 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13061 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13062 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13063 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13064 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13065 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13066 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13067 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13068 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13069 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13070 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13071 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13072 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13073 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13074 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13075 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13076 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13077 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13078 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13079 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13080 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13082 /* "neighbor port" commands. */
13083 install_element(BGP_NODE
, &neighbor_port_cmd
);
13084 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13086 /* "neighbor weight" commands. */
13087 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13088 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13090 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13091 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13092 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13093 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13094 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13095 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13096 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13097 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13098 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13099 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13100 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13101 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13102 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13103 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13104 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13105 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13107 /* "neighbor override-capability" commands. */
13108 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13109 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13111 /* "neighbor strict-capability-match" commands. */
13112 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13113 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13115 /* "neighbor timers" commands. */
13116 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13117 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13119 /* "neighbor timers connect" commands. */
13120 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13121 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13123 /* "neighbor advertisement-interval" commands. */
13124 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13125 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13127 /* "neighbor interface" commands. */
13128 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13129 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13131 /* "neighbor distribute" commands. */
13132 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13133 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13134 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13135 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13136 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13137 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13138 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13139 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13140 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13141 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13142 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13143 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13144 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13145 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13146 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13147 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13148 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13149 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13151 /* "neighbor prefix-list" commands. */
13152 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13153 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13154 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13155 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13156 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13157 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13158 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13159 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13160 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13161 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13162 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13163 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13164 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13165 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13166 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13167 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13168 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13169 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13170 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13171 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13172 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13173 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13175 /* "neighbor filter-list" commands. */
13176 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13177 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13178 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13179 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13180 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13181 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13182 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13183 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13184 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13185 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13186 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13187 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13188 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13189 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13190 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13191 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13192 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13193 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13194 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13195 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13196 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13197 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13199 /* "neighbor route-map" commands. */
13200 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13201 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13202 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13203 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13204 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13205 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13206 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13207 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13208 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13209 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13210 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13211 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13212 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13213 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13214 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13215 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13216 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13217 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13218 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13219 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13220 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13221 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13222 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13223 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13225 /* "neighbor unsuppress-map" commands. */
13226 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13227 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13228 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13229 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13230 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13231 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13232 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13233 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13234 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13235 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13236 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13237 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13238 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13239 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13240 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13241 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13242 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13243 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13245 /* "neighbor maximum-prefix" commands. */
13246 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13247 install_element(BGP_NODE
,
13248 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13249 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13250 install_element(BGP_NODE
,
13251 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13252 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13253 install_element(BGP_NODE
,
13254 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13255 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13256 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13257 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13258 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13259 install_element(BGP_IPV4_NODE
,
13260 &neighbor_maximum_prefix_threshold_warning_cmd
);
13261 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13262 install_element(BGP_IPV4_NODE
,
13263 &neighbor_maximum_prefix_threshold_restart_cmd
);
13264 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13265 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13266 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13267 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13268 install_element(BGP_IPV4M_NODE
,
13269 &neighbor_maximum_prefix_threshold_warning_cmd
);
13270 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13271 install_element(BGP_IPV4M_NODE
,
13272 &neighbor_maximum_prefix_threshold_restart_cmd
);
13273 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13274 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13275 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13276 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13277 install_element(BGP_IPV4L_NODE
,
13278 &neighbor_maximum_prefix_threshold_warning_cmd
);
13279 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13280 install_element(BGP_IPV4L_NODE
,
13281 &neighbor_maximum_prefix_threshold_restart_cmd
);
13282 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13283 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13284 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13285 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13286 install_element(BGP_IPV6_NODE
,
13287 &neighbor_maximum_prefix_threshold_warning_cmd
);
13288 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13289 install_element(BGP_IPV6_NODE
,
13290 &neighbor_maximum_prefix_threshold_restart_cmd
);
13291 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13292 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13293 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13294 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13295 install_element(BGP_IPV6M_NODE
,
13296 &neighbor_maximum_prefix_threshold_warning_cmd
);
13297 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13298 install_element(BGP_IPV6M_NODE
,
13299 &neighbor_maximum_prefix_threshold_restart_cmd
);
13300 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13301 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13302 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13303 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13304 install_element(BGP_IPV6L_NODE
,
13305 &neighbor_maximum_prefix_threshold_warning_cmd
);
13306 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13307 install_element(BGP_IPV6L_NODE
,
13308 &neighbor_maximum_prefix_threshold_restart_cmd
);
13309 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13310 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13311 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13312 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13313 install_element(BGP_VPNV4_NODE
,
13314 &neighbor_maximum_prefix_threshold_warning_cmd
);
13315 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13316 install_element(BGP_VPNV4_NODE
,
13317 &neighbor_maximum_prefix_threshold_restart_cmd
);
13318 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13319 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13320 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13321 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13322 install_element(BGP_VPNV6_NODE
,
13323 &neighbor_maximum_prefix_threshold_warning_cmd
);
13324 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13325 install_element(BGP_VPNV6_NODE
,
13326 &neighbor_maximum_prefix_threshold_restart_cmd
);
13327 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13329 /* "neighbor allowas-in" */
13330 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13331 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13332 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13333 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13334 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13335 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13336 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13337 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13338 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13339 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13340 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13341 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13342 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13343 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13344 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13345 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13346 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13347 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13348 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13349 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13351 /* address-family commands. */
13352 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13353 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13354 #ifdef KEEP_OLD_VPN_COMMANDS
13355 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13356 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13357 #endif /* KEEP_OLD_VPN_COMMANDS */
13359 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13361 /* "exit-address-family" command. */
13362 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13363 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13364 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13365 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13366 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13367 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13368 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13369 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13370 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13371 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13372 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13374 /* "clear ip bgp commands" */
13375 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13377 /* clear ip bgp prefix */
13378 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13379 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13380 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13382 /* "show [ip] bgp summary" commands. */
13383 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13384 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13385 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13386 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13387 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13388 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
13390 /* "show [ip] bgp neighbors" commands. */
13391 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
13393 /* "show [ip] bgp peer-group" commands. */
13394 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
13396 /* "show [ip] bgp paths" commands. */
13397 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
13399 /* "show [ip] bgp community" commands. */
13400 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
13402 /* "show ip bgp large-community" commands. */
13403 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
13404 /* "show [ip] bgp attribute-info" commands. */
13405 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
13406 /* "show [ip] bgp route-leak" command */
13407 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
13409 /* "redistribute" commands. */
13410 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
13411 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
13412 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
13413 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
13414 install_element(BGP_NODE
,
13415 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
13416 install_element(BGP_NODE
,
13417 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
13418 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
13419 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
13420 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
13421 install_element(BGP_NODE
,
13422 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
13423 install_element(BGP_NODE
,
13424 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
13425 install_element(BGP_NODE
,
13426 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
13427 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
13428 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
13429 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
13430 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
13431 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
13432 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
13433 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
13434 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
13435 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
13436 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
13437 install_element(BGP_IPV4_NODE
,
13438 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
13439 install_element(BGP_IPV4_NODE
,
13440 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
13441 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
13442 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
13443 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
13444 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
13445 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
13446 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
13448 /* import|export vpn [route-map WORD] */
13449 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
13450 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
13452 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
13453 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
13455 /* ttl_security commands */
13456 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
13457 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
13459 /* "show [ip] bgp memory" commands. */
13460 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
13462 /* "show bgp martian next-hop" */
13463 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
13465 /* "show [ip] bgp views" commands. */
13466 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
13468 /* "show [ip] bgp vrfs" commands. */
13469 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
13471 /* Community-list. */
13472 community_list_vty();
13474 /* vpn-policy commands */
13475 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
13476 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
13477 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
13478 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
13479 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
13480 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
13481 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
13482 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
13483 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
13484 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
13485 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
13486 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
13488 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
13489 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
13491 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
13492 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
13493 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
13494 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
13495 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
13496 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
13497 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
13498 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
13499 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13500 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13501 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
13502 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
13505 #include "memory.h"
13506 #include "bgp_regex.h"
13507 #include "bgp_clist.h"
13508 #include "bgp_ecommunity.h"
13510 /* VTY functions. */
13512 /* Direction value to string conversion. */
13513 static const char *community_direct_str(int direct
)
13516 case COMMUNITY_DENY
:
13518 case COMMUNITY_PERMIT
:
13525 /* Display error string. */
13526 static void community_list_perror(struct vty
*vty
, int ret
)
13529 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
13530 vty_out(vty
, "%% Can't find community-list\n");
13532 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
13533 vty_out(vty
, "%% Malformed community-list value\n");
13535 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
13537 "%% Community name conflict, previously defined as standard community\n");
13539 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
13541 "%% Community name conflict, previously defined as expanded community\n");
13546 /* "community-list" keyword help string. */
13547 #define COMMUNITY_LIST_STR "Add a community list entry\n"
13549 /* ip community-list standard */
13550 DEFUN (ip_community_list_standard
,
13551 ip_community_list_standard_cmd
,
13552 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13555 "Community list number (standard)\n"
13556 "Add an standard community-list entry\n"
13557 "Community list name\n"
13558 "Specify community to reject\n"
13559 "Specify community to accept\n"
13562 char *cl_name_or_number
= NULL
;
13564 int style
= COMMUNITY_LIST_STANDARD
;
13567 argv_find(argv
, argc
, "(1-99)", &idx
);
13568 argv_find(argv
, argc
, "WORD", &idx
);
13569 cl_name_or_number
= argv
[idx
]->arg
;
13570 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13572 argv_find(argv
, argc
, "AA:NN", &idx
);
13573 char *str
= argv_concat(argv
, argc
, idx
);
13575 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
13578 XFREE(MTYPE_TMP
, str
);
13581 /* Display error string. */
13582 community_list_perror(vty
, ret
);
13583 return CMD_WARNING_CONFIG_FAILED
;
13586 return CMD_SUCCESS
;
13589 DEFUN (no_ip_community_list_standard_all
,
13590 no_ip_community_list_standard_all_cmd
,
13591 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13595 "Community list number (standard)\n"
13596 "Add an standard community-list entry\n"
13597 "Community list name\n"
13598 "Specify community to reject\n"
13599 "Specify community to accept\n"
13602 char *cl_name_or_number
= NULL
;
13604 int style
= COMMUNITY_LIST_STANDARD
;
13607 argv_find(argv
, argc
, "(1-99)", &idx
);
13608 argv_find(argv
, argc
, "WORD", &idx
);
13609 cl_name_or_number
= argv
[idx
]->arg
;
13610 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13612 argv_find(argv
, argc
, "AA:NN", &idx
);
13613 char *str
= argv_concat(argv
, argc
, idx
);
13615 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
13618 XFREE(MTYPE_TMP
, str
);
13621 community_list_perror(vty
, ret
);
13622 return CMD_WARNING_CONFIG_FAILED
;
13625 return CMD_SUCCESS
;
13628 /* ip community-list expanded */
13629 DEFUN (ip_community_list_expanded_all
,
13630 ip_community_list_expanded_all_cmd
,
13631 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13634 "Community list number (expanded)\n"
13635 "Add an expanded community-list entry\n"
13636 "Community list name\n"
13637 "Specify community to reject\n"
13638 "Specify community to accept\n"
13641 char *cl_name_or_number
= NULL
;
13643 int style
= COMMUNITY_LIST_EXPANDED
;
13646 argv_find(argv
, argc
, "(100-500)", &idx
);
13647 argv_find(argv
, argc
, "WORD", &idx
);
13648 cl_name_or_number
= argv
[idx
]->arg
;
13649 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13651 argv_find(argv
, argc
, "AA:NN", &idx
);
13652 char *str
= argv_concat(argv
, argc
, idx
);
13654 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
13657 XFREE(MTYPE_TMP
, str
);
13660 /* Display error string. */
13661 community_list_perror(vty
, ret
);
13662 return CMD_WARNING_CONFIG_FAILED
;
13665 return CMD_SUCCESS
;
13668 DEFUN (no_ip_community_list_expanded_all
,
13669 no_ip_community_list_expanded_all_cmd
,
13670 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13674 "Community list number (expanded)\n"
13675 "Add an expanded community-list entry\n"
13676 "Community list name\n"
13677 "Specify community to reject\n"
13678 "Specify community to accept\n"
13681 char *cl_name_or_number
= NULL
;
13683 int style
= COMMUNITY_LIST_EXPANDED
;
13686 argv_find(argv
, argc
, "(100-500)", &idx
);
13687 argv_find(argv
, argc
, "WORD", &idx
);
13688 cl_name_or_number
= argv
[idx
]->arg
;
13689 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13691 argv_find(argv
, argc
, "AA:NN", &idx
);
13692 char *str
= argv_concat(argv
, argc
, idx
);
13694 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
13697 XFREE(MTYPE_TMP
, str
);
13700 community_list_perror(vty
, ret
);
13701 return CMD_WARNING_CONFIG_FAILED
;
13704 return CMD_SUCCESS
;
13707 /* Return configuration string of community-list entry. */
13708 static const char *community_list_config_str(struct community_entry
*entry
)
13715 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
13716 str
= community_str(entry
->u
.com
, false);
13717 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
13718 str
= lcommunity_str(entry
->u
.lcom
, false);
13720 str
= entry
->config
;
13725 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
13727 struct community_entry
*entry
;
13729 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13730 if (entry
== list
->head
) {
13731 if (all_digit(list
->name
))
13732 vty_out(vty
, "Community %s list %s\n",
13733 entry
->style
== COMMUNITY_LIST_STANDARD
13735 : "(expanded) access",
13738 vty_out(vty
, "Named Community %s list %s\n",
13739 entry
->style
== COMMUNITY_LIST_STANDARD
13745 vty_out(vty
, " %s\n",
13746 community_direct_str(entry
->direct
));
13748 vty_out(vty
, " %s %s\n",
13749 community_direct_str(entry
->direct
),
13750 community_list_config_str(entry
));
13754 DEFUN (show_ip_community_list
,
13755 show_ip_community_list_cmd
,
13756 "show ip community-list",
13759 "List community-list\n")
13761 struct community_list
*list
;
13762 struct community_list_master
*cm
;
13764 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
13766 return CMD_SUCCESS
;
13768 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13769 community_list_show(vty
, list
);
13771 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13772 community_list_show(vty
, list
);
13774 return CMD_SUCCESS
;
13777 DEFUN (show_ip_community_list_arg
,
13778 show_ip_community_list_arg_cmd
,
13779 "show ip community-list <(1-500)|WORD>",
13782 "List community-list\n"
13783 "Community-list number\n"
13784 "Community-list name\n")
13786 int idx_comm_list
= 3;
13787 struct community_list
*list
;
13789 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
13790 COMMUNITY_LIST_MASTER
);
13792 vty_out(vty
, "%% Can't find community-list\n");
13793 return CMD_WARNING
;
13796 community_list_show(vty
, list
);
13798 return CMD_SUCCESS
;
13802 * Large Community code.
13804 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
13805 struct cmd_token
**argv
, int style
,
13806 int reject_all_digit_name
)
13814 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13817 /* All digit name check. */
13819 argv_find(argv
, argc
, "WORD", &idx
);
13820 argv_find(argv
, argc
, "(1-99)", &idx
);
13821 argv_find(argv
, argc
, "(100-500)", &idx
);
13822 cl_name
= argv
[idx
]->arg
;
13823 if (reject_all_digit_name
&& all_digit(cl_name
)) {
13824 vty_out(vty
, "%% Community name cannot have all digits\n");
13825 return CMD_WARNING_CONFIG_FAILED
;
13829 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
13830 argv_find(argv
, argc
, "LINE", &idx
);
13831 /* Concat community string argument. */
13833 str
= argv_concat(argv
, argc
, idx
);
13837 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
13839 /* Free temporary community list string allocated by
13842 XFREE(MTYPE_TMP
, str
);
13845 community_list_perror(vty
, ret
);
13846 return CMD_WARNING_CONFIG_FAILED
;
13848 return CMD_SUCCESS
;
13851 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
13852 struct cmd_token
**argv
, int style
)
13859 argv_find(argv
, argc
, "permit", &idx
);
13860 argv_find(argv
, argc
, "deny", &idx
);
13863 /* Check the list direct. */
13864 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
13865 direct
= COMMUNITY_PERMIT
;
13867 direct
= COMMUNITY_DENY
;
13870 argv_find(argv
, argc
, "LINE", &idx
);
13871 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
13872 /* Concat community string argument. */
13873 str
= argv_concat(argv
, argc
, idx
);
13877 argv_find(argv
, argc
, "(1-99)", &idx
);
13878 argv_find(argv
, argc
, "(100-500)", &idx
);
13879 argv_find(argv
, argc
, "WORD", &idx
);
13881 /* Unset community list. */
13882 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
13885 /* Free temporary community list string allocated by
13888 XFREE(MTYPE_TMP
, str
);
13891 community_list_perror(vty
, ret
);
13892 return CMD_WARNING_CONFIG_FAILED
;
13895 return CMD_SUCCESS
;
13898 /* "large-community-list" keyword help string. */
13899 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
13900 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
13902 DEFUN (ip_lcommunity_list_standard
,
13903 ip_lcommunity_list_standard_cmd
,
13904 "ip large-community-list (1-99) <deny|permit>",
13906 LCOMMUNITY_LIST_STR
13907 "Large Community list number (standard)\n"
13908 "Specify large community to reject\n"
13909 "Specify large community to accept\n")
13911 return lcommunity_list_set_vty(vty
, argc
, argv
,
13912 LARGE_COMMUNITY_LIST_STANDARD
, 0);
13915 DEFUN (ip_lcommunity_list_standard1
,
13916 ip_lcommunity_list_standard1_cmd
,
13917 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
13919 LCOMMUNITY_LIST_STR
13920 "Large Community list number (standard)\n"
13921 "Specify large community to reject\n"
13922 "Specify large community to accept\n"
13923 LCOMMUNITY_VAL_STR
)
13925 return lcommunity_list_set_vty(vty
, argc
, argv
,
13926 LARGE_COMMUNITY_LIST_STANDARD
, 0);
13929 DEFUN (ip_lcommunity_list_expanded
,
13930 ip_lcommunity_list_expanded_cmd
,
13931 "ip large-community-list (100-500) <deny|permit> LINE...",
13933 LCOMMUNITY_LIST_STR
13934 "Large Community list number (expanded)\n"
13935 "Specify large community to reject\n"
13936 "Specify large community to accept\n"
13937 "An ordered list as a regular-expression\n")
13939 return lcommunity_list_set_vty(vty
, argc
, argv
,
13940 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
13943 DEFUN (ip_lcommunity_list_name_standard
,
13944 ip_lcommunity_list_name_standard_cmd
,
13945 "ip large-community-list standard WORD <deny|permit>",
13947 LCOMMUNITY_LIST_STR
13948 "Specify standard large-community-list\n"
13949 "Large Community list name\n"
13950 "Specify large community to reject\n"
13951 "Specify large community to accept\n")
13953 return lcommunity_list_set_vty(vty
, argc
, argv
,
13954 LARGE_COMMUNITY_LIST_STANDARD
, 1);
13957 DEFUN (ip_lcommunity_list_name_standard1
,
13958 ip_lcommunity_list_name_standard1_cmd
,
13959 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
13961 LCOMMUNITY_LIST_STR
13962 "Specify standard large-community-list\n"
13963 "Large Community list name\n"
13964 "Specify large community to reject\n"
13965 "Specify large community to accept\n"
13966 LCOMMUNITY_VAL_STR
)
13968 return lcommunity_list_set_vty(vty
, argc
, argv
,
13969 LARGE_COMMUNITY_LIST_STANDARD
, 1);
13972 DEFUN (ip_lcommunity_list_name_expanded
,
13973 ip_lcommunity_list_name_expanded_cmd
,
13974 "ip large-community-list expanded WORD <deny|permit> LINE...",
13976 LCOMMUNITY_LIST_STR
13977 "Specify expanded large-community-list\n"
13978 "Large Community list name\n"
13979 "Specify large community to reject\n"
13980 "Specify large community to accept\n"
13981 "An ordered list as a regular-expression\n")
13983 return lcommunity_list_set_vty(vty
, argc
, argv
,
13984 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
13987 DEFUN (no_ip_lcommunity_list_standard_all
,
13988 no_ip_lcommunity_list_standard_all_cmd
,
13989 "no ip large-community-list <(1-99)|(100-500)|WORD>",
13992 LCOMMUNITY_LIST_STR
13993 "Large Community list number (standard)\n"
13994 "Large Community list number (expanded)\n"
13995 "Large Community list name\n")
13997 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13998 LARGE_COMMUNITY_LIST_STANDARD
);
14001 DEFUN (no_ip_lcommunity_list_name_expanded_all
,
14002 no_ip_lcommunity_list_name_expanded_all_cmd
,
14003 "no ip large-community-list expanded WORD",
14006 LCOMMUNITY_LIST_STR
14007 "Specify expanded large-community-list\n"
14008 "Large Community list name\n")
14010 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14011 LARGE_COMMUNITY_LIST_EXPANDED
);
14014 DEFUN (no_ip_lcommunity_list_standard
,
14015 no_ip_lcommunity_list_standard_cmd
,
14016 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
14019 LCOMMUNITY_LIST_STR
14020 "Large Community list number (standard)\n"
14021 "Specify large community to reject\n"
14022 "Specify large community to accept\n"
14023 LCOMMUNITY_VAL_STR
)
14025 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14026 LARGE_COMMUNITY_LIST_STANDARD
);
14029 DEFUN (no_ip_lcommunity_list_expanded
,
14030 no_ip_lcommunity_list_expanded_cmd
,
14031 "no ip large-community-list (100-500) <deny|permit> LINE...",
14034 LCOMMUNITY_LIST_STR
14035 "Large Community list number (expanded)\n"
14036 "Specify large community to reject\n"
14037 "Specify large community to accept\n"
14038 "An ordered list as a regular-expression\n")
14040 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14041 LARGE_COMMUNITY_LIST_EXPANDED
);
14044 DEFUN (no_ip_lcommunity_list_name_standard
,
14045 no_ip_lcommunity_list_name_standard_cmd
,
14046 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
14049 LCOMMUNITY_LIST_STR
14050 "Specify standard large-community-list\n"
14051 "Large Community list name\n"
14052 "Specify large community to reject\n"
14053 "Specify large community to accept\n"
14054 LCOMMUNITY_VAL_STR
)
14056 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14057 LARGE_COMMUNITY_LIST_STANDARD
);
14060 DEFUN (no_ip_lcommunity_list_name_expanded
,
14061 no_ip_lcommunity_list_name_expanded_cmd
,
14062 "no ip large-community-list expanded WORD <deny|permit> LINE...",
14065 LCOMMUNITY_LIST_STR
14066 "Specify expanded large-community-list\n"
14067 "Large community list name\n"
14068 "Specify large community to reject\n"
14069 "Specify large community to accept\n"
14070 "An ordered list as a regular-expression\n")
14072 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14073 LARGE_COMMUNITY_LIST_EXPANDED
);
14076 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14078 struct community_entry
*entry
;
14080 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14081 if (entry
== list
->head
) {
14082 if (all_digit(list
->name
))
14083 vty_out(vty
, "Large community %s list %s\n",
14084 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14086 : "(expanded) access",
14090 "Named large community %s list %s\n",
14091 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14097 vty_out(vty
, " %s\n",
14098 community_direct_str(entry
->direct
));
14100 vty_out(vty
, " %s %s\n",
14101 community_direct_str(entry
->direct
),
14102 community_list_config_str(entry
));
14106 DEFUN (show_ip_lcommunity_list
,
14107 show_ip_lcommunity_list_cmd
,
14108 "show ip large-community-list",
14111 "List large-community list\n")
14113 struct community_list
*list
;
14114 struct community_list_master
*cm
;
14116 cm
= community_list_master_lookup(bgp_clist
,
14117 LARGE_COMMUNITY_LIST_MASTER
);
14119 return CMD_SUCCESS
;
14121 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14122 lcommunity_list_show(vty
, list
);
14124 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14125 lcommunity_list_show(vty
, list
);
14127 return CMD_SUCCESS
;
14130 DEFUN (show_ip_lcommunity_list_arg
,
14131 show_ip_lcommunity_list_arg_cmd
,
14132 "show ip large-community-list <(1-500)|WORD>",
14135 "List large-community list\n"
14136 "large-community-list number\n"
14137 "large-community-list name\n")
14139 struct community_list
*list
;
14141 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
,
14142 LARGE_COMMUNITY_LIST_MASTER
);
14144 vty_out(vty
, "%% Can't find extcommunity-list\n");
14145 return CMD_WARNING
;
14148 lcommunity_list_show(vty
, list
);
14150 return CMD_SUCCESS
;
14153 /* "extcommunity-list" keyword help string. */
14154 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
14155 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
14157 DEFUN (ip_extcommunity_list_standard
,
14158 ip_extcommunity_list_standard_cmd
,
14159 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14161 EXTCOMMUNITY_LIST_STR
14162 "Extended Community list number (standard)\n"
14163 "Specify standard extcommunity-list\n"
14164 "Community list name\n"
14165 "Specify community to reject\n"
14166 "Specify community to accept\n"
14167 EXTCOMMUNITY_VAL_STR
)
14169 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14171 char *cl_number_or_name
= NULL
;
14174 argv_find(argv
, argc
, "(1-99)", &idx
);
14175 argv_find(argv
, argc
, "WORD", &idx
);
14176 cl_number_or_name
= argv
[idx
]->arg
;
14177 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14179 argv_find(argv
, argc
, "AA:NN", &idx
);
14180 char *str
= argv_concat(argv
, argc
, idx
);
14182 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14185 XFREE(MTYPE_TMP
, str
);
14188 community_list_perror(vty
, ret
);
14189 return CMD_WARNING_CONFIG_FAILED
;
14192 return CMD_SUCCESS
;
14195 DEFUN (ip_extcommunity_list_name_expanded
,
14196 ip_extcommunity_list_name_expanded_cmd
,
14197 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14199 EXTCOMMUNITY_LIST_STR
14200 "Extended Community list number (expanded)\n"
14201 "Specify expanded extcommunity-list\n"
14202 "Extended Community list name\n"
14203 "Specify community to reject\n"
14204 "Specify community to accept\n"
14205 "An ordered list as a regular-expression\n")
14207 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
14209 char *cl_number_or_name
= NULL
;
14212 argv_find(argv
, argc
, "(100-500)", &idx
);
14213 argv_find(argv
, argc
, "WORD", &idx
);
14214 cl_number_or_name
= argv
[idx
]->arg
;
14215 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14217 argv_find(argv
, argc
, "LINE", &idx
);
14218 char *str
= argv_concat(argv
, argc
, idx
);
14220 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14223 XFREE(MTYPE_TMP
, str
);
14226 community_list_perror(vty
, ret
);
14227 return CMD_WARNING_CONFIG_FAILED
;
14230 return CMD_SUCCESS
;
14233 DEFUN (no_ip_extcommunity_list_standard_all
,
14234 no_ip_extcommunity_list_standard_all_cmd
,
14235 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14238 EXTCOMMUNITY_LIST_STR
14239 "Extended Community list number (standard)\n"
14240 "Specify standard extcommunity-list\n"
14241 "Community list name\n"
14242 "Specify community to reject\n"
14243 "Specify community to accept\n"
14244 EXTCOMMUNITY_VAL_STR
)
14246 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14248 char *cl_number_or_name
= NULL
;
14251 argv_find(argv
, argc
, "(1-99)", &idx
);
14252 argv_find(argv
, argc
, "WORD", &idx
);
14253 cl_number_or_name
= argv
[idx
]->arg
;
14254 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14256 argv_find(argv
, argc
, "AA:NN", &idx
);
14257 char *str
= argv_concat(argv
, argc
, idx
);
14259 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
14262 XFREE(MTYPE_TMP
, str
);
14265 community_list_perror(vty
, ret
);
14266 return CMD_WARNING_CONFIG_FAILED
;
14269 return CMD_SUCCESS
;
14272 DEFUN (no_ip_extcommunity_list_expanded_all
,
14273 no_ip_extcommunity_list_expanded_all_cmd
,
14274 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14277 EXTCOMMUNITY_LIST_STR
14278 "Extended Community list number (expanded)\n"
14279 "Specify expanded extcommunity-list\n"
14280 "Extended Community list name\n"
14281 "Specify community to reject\n"
14282 "Specify community to accept\n"
14283 "An ordered list as a regular-expression\n")
14285 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
14287 char *cl_number_or_name
= NULL
;
14290 argv_find(argv
, argc
, "(100-500)", &idx
);
14291 argv_find(argv
, argc
, "WORD", &idx
);
14292 cl_number_or_name
= argv
[idx
]->arg
;
14293 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14295 argv_find(argv
, argc
, "LINE", &idx
);
14296 char *str
= argv_concat(argv
, argc
, idx
);
14298 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
14301 XFREE(MTYPE_TMP
, str
);
14304 community_list_perror(vty
, ret
);
14305 return CMD_WARNING_CONFIG_FAILED
;
14308 return CMD_SUCCESS
;
14311 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14313 struct community_entry
*entry
;
14315 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14316 if (entry
== list
->head
) {
14317 if (all_digit(list
->name
))
14318 vty_out(vty
, "Extended community %s list %s\n",
14319 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14321 : "(expanded) access",
14325 "Named extended community %s list %s\n",
14326 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14332 vty_out(vty
, " %s\n",
14333 community_direct_str(entry
->direct
));
14335 vty_out(vty
, " %s %s\n",
14336 community_direct_str(entry
->direct
),
14337 community_list_config_str(entry
));
14341 DEFUN (show_ip_extcommunity_list
,
14342 show_ip_extcommunity_list_cmd
,
14343 "show ip extcommunity-list",
14346 "List extended-community list\n")
14348 struct community_list
*list
;
14349 struct community_list_master
*cm
;
14351 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
14353 return CMD_SUCCESS
;
14355 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14356 extcommunity_list_show(vty
, list
);
14358 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14359 extcommunity_list_show(vty
, list
);
14361 return CMD_SUCCESS
;
14364 DEFUN (show_ip_extcommunity_list_arg
,
14365 show_ip_extcommunity_list_arg_cmd
,
14366 "show ip extcommunity-list <(1-500)|WORD>",
14369 "List extended-community list\n"
14370 "Extcommunity-list number\n"
14371 "Extcommunity-list name\n")
14373 int idx_comm_list
= 3;
14374 struct community_list
*list
;
14376 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
14377 EXTCOMMUNITY_LIST_MASTER
);
14379 vty_out(vty
, "%% Can't find extcommunity-list\n");
14380 return CMD_WARNING
;
14383 extcommunity_list_show(vty
, list
);
14385 return CMD_SUCCESS
;
14388 /* Display community-list and extcommunity-list configuration. */
14389 static int community_list_config_write(struct vty
*vty
)
14391 struct community_list
*list
;
14392 struct community_entry
*entry
;
14393 struct community_list_master
*cm
;
14396 /* Community-list. */
14397 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14399 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14400 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14401 vty_out(vty
, "ip community-list %s %s %s\n", list
->name
,
14402 community_direct_str(entry
->direct
),
14403 community_list_config_str(entry
));
14406 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14407 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14408 vty_out(vty
, "ip community-list %s %s %s %s\n",
14409 entry
->style
== COMMUNITY_LIST_STANDARD
14412 list
->name
, community_direct_str(entry
->direct
),
14413 community_list_config_str(entry
));
14417 /* Extcommunity-list. */
14418 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
14420 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14421 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14422 vty_out(vty
, "ip extcommunity-list %s %s %s\n",
14423 list
->name
, community_direct_str(entry
->direct
),
14424 community_list_config_str(entry
));
14427 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14428 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14429 vty_out(vty
, "ip extcommunity-list %s %s %s %s\n",
14430 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14433 list
->name
, community_direct_str(entry
->direct
),
14434 community_list_config_str(entry
));
14439 /* lcommunity-list. */
14440 cm
= community_list_master_lookup(bgp_clist
,
14441 LARGE_COMMUNITY_LIST_MASTER
);
14443 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14444 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14445 vty_out(vty
, "ip large-community-list %s %s %s\n",
14446 list
->name
, community_direct_str(entry
->direct
),
14447 community_list_config_str(entry
));
14450 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14451 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14452 vty_out(vty
, "ip large-community-list %s %s %s %s\n",
14453 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
14456 list
->name
, community_direct_str(entry
->direct
),
14457 community_list_config_str(entry
));
14464 static struct cmd_node community_list_node
= {
14465 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
14468 static void community_list_vty(void)
14470 install_node(&community_list_node
, community_list_config_write
);
14472 /* Community-list. */
14473 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
14474 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
14475 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
14476 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
14477 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
14478 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
14480 /* Extcommunity-list. */
14481 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
14482 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
14483 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
14484 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
14485 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
14486 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
14488 /* Large Community List */
14489 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
14490 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
14491 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
14492 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
14493 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
14494 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
14495 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
14496 install_element(CONFIG_NODE
,
14497 &no_ip_lcommunity_list_name_expanded_all_cmd
);
14498 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
14499 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
14500 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
14501 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
14502 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
14503 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);