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
))
7918 json_object_boolean_true_add(json_peer
,
7922 json_object_string_add(json_peer
, "hostname",
7925 if (peer
->domainname
)
7926 json_object_string_add(json_peer
, "domainname",
7929 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
7930 json_object_int_add(json_peer
, "version", 4);
7931 json_object_int_add(json_peer
, "msgRcvd",
7932 PEER_TOTAL_RX(peer
));
7933 json_object_int_add(json_peer
, "msgSent",
7934 PEER_TOTAL_TX(peer
));
7936 json_object_int_add(json_peer
, "tableVersion",
7937 peer
->version
[afi
][safi
]);
7938 json_object_int_add(json_peer
, "outq",
7940 json_object_int_add(json_peer
, "inq", 0);
7941 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
7942 use_json
, json_peer
);
7943 json_object_int_add(json_peer
, "prefixReceivedCount",
7944 peer
->pcount
[afi
][pfx_rcd_safi
]);
7946 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
7947 json_object_string_add(json_peer
, "state",
7949 else if (peer
->afc_recv
[afi
][safi
])
7950 json_object_string_add(
7952 lookup_msg(bgp_status_msg
, peer
->status
,
7954 else if (CHECK_FLAG(peer
->sflags
,
7955 PEER_STATUS_PREFIX_OVERFLOW
))
7956 json_object_string_add(json_peer
, "state",
7959 json_object_string_add(
7961 lookup_msg(bgp_status_msg
, peer
->status
,
7965 json_object_string_add(json_peer
, "idType",
7967 else if (peer
->su
.sa
.sa_family
== AF_INET
)
7968 json_object_string_add(json_peer
, "idType",
7970 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
7971 json_object_string_add(json_peer
, "idType",
7974 json_object_object_add(json_peers
, peer
->host
,
7977 memset(dn_flag
, '\0', sizeof(dn_flag
));
7978 if (peer_dynamic_neighbor(peer
)) {
7984 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7985 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
7986 peer
->hostname
, peer
->host
);
7988 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
7990 /* pad the neighbor column with spaces */
7991 if (len
< max_neighbor_width
)
7992 vty_out(vty
, "%*s", max_neighbor_width
- len
,
7995 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
7996 peer
->as
, PEER_TOTAL_RX(peer
),
7997 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
7998 0, peer
->obuf
->count
,
7999 peer_uptime(peer
->uptime
, timebuf
,
8000 BGP_UPTIME_LEN
, 0, NULL
));
8002 if (peer
->status
== Established
)
8003 if (peer
->afc_recv
[afi
][safi
])
8004 vty_out(vty
, " %12ld",
8008 vty_out(vty
, " NoNeg");
8010 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8011 vty_out(vty
, " Idle (Admin)");
8012 else if (CHECK_FLAG(
8014 PEER_STATUS_PREFIX_OVERFLOW
))
8015 vty_out(vty
, " Idle (PfxCt)");
8017 vty_out(vty
, " %12s",
8018 lookup_msg(bgp_status_msg
,
8019 peer
->status
, NULL
));
8026 json_object_object_add(json
, "peers", json_peers
);
8028 json_object_int_add(json
, "totalPeers", count
);
8029 json_object_int_add(json
, "dynamicPeers", dn_count
);
8031 bgp_show_bestpath_json(bgp
, json
);
8033 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8034 json
, JSON_C_TO_STRING_PRETTY
));
8035 json_object_free(json
);
8038 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8040 vty_out(vty
, "No %s neighbor is configured\n",
8041 afi_safi_print(afi
, safi
));
8045 vty_out(vty
, "* - dynamic neighbor\n");
8046 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8047 dn_count
, bgp
->dynamic_neighbors_limit
);
8054 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8055 int safi
, uint8_t use_json
,
8059 int afi_wildcard
= (afi
== AFI_MAX
);
8060 int safi_wildcard
= (safi
== SAFI_MAX
);
8061 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8062 bool json_output
= false;
8064 if (use_json
&& is_wildcard
)
8065 vty_out(vty
, "{\n");
8067 afi
= 1; /* AFI_IP */
8068 while (afi
< AFI_MAX
) {
8070 safi
= 1; /* SAFI_UNICAST */
8071 while (safi
< SAFI_MAX
) {
8072 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8076 * So limit output to those afi/safi
8078 * actualy have something interesting in
8082 json
= json_object_new_object();
8085 vty_out(vty
, ",\n");
8089 vty_out(vty
, "\"%s\":",
8093 vty_out(vty
, "\n%s Summary:\n",
8098 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
8110 if (use_json
&& is_wildcard
)
8111 vty_out(vty
, "}\n");
8112 else if (use_json
&& !json_output
)
8113 vty_out(vty
, "{}\n");
8116 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8117 safi_t safi
, uint8_t use_json
)
8119 struct listnode
*node
, *nnode
;
8121 json_object
*json
= NULL
;
8125 vty_out(vty
, "{\n");
8127 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8129 json
= json_object_new_object();
8132 vty_out(vty
, ",\n");
8136 vty_out(vty
, "\"%s\":",
8137 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8141 vty_out(vty
, "\nInstance %s:\n",
8142 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8146 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
8150 vty_out(vty
, "}\n");
8153 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8154 safi_t safi
, uint8_t use_json
)
8159 if (strmatch(name
, "all")) {
8160 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8164 bgp
= bgp_lookup_by_name(name
);
8168 vty_out(vty
, "{}\n");
8171 "%% No such BGP instance exist\n");
8175 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
8181 bgp
= bgp_get_default();
8184 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
8189 /* `show [ip] bgp summary' commands. */
8190 DEFUN (show_ip_bgp_summary
,
8191 show_ip_bgp_summary_cmd
,
8192 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8196 BGP_INSTANCE_HELP_STR
8198 BGP_SAFI_WITH_LABEL_HELP_STR
8199 "Summary of BGP neighbor status\n"
8203 afi_t afi
= AFI_MAX
;
8204 safi_t safi
= SAFI_MAX
;
8209 if (argv_find(argv
, argc
, "ip", &idx
))
8211 /* [<view|vrf> VIEWVRFNAME] */
8212 if (argv_find(argv
, argc
, "view", &idx
)
8213 || argv_find(argv
, argc
, "vrf", &idx
))
8214 vrf
= argv
[++idx
]->arg
;
8215 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8216 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8217 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8220 int uj
= use_json(argc
, argv
);
8222 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8225 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8227 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8228 return "IPv4 Unicast";
8229 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8230 return "IPv4 Multicast";
8231 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8232 return "IPv4 Labeled Unicast";
8233 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8235 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8236 return "IPv4 Encap";
8237 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8238 return "IPv4 Flowspec";
8239 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8240 return "IPv6 Unicast";
8241 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8242 return "IPv6 Multicast";
8243 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8244 return "IPv6 Labeled Unicast";
8245 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8247 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8248 return "IPv6 Encap";
8249 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8250 return "IPv6 Flowspec";
8251 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8252 return "L2VPN EVPN";
8258 * Please note that we have intentionally camelCased
8259 * the return strings here. So if you want
8260 * to use this function, please ensure you
8261 * are doing this within json output
8263 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8265 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8266 return "ipv4Unicast";
8267 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8268 return "ipv4Multicast";
8269 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8270 return "ipv4LabeledUnicast";
8271 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8273 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8275 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8276 return "ipv4Flowspec";
8277 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8278 return "ipv6Unicast";
8279 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8280 return "ipv6Multicast";
8281 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8282 return "ipv6LabeledUnicast";
8283 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8285 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8287 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8288 return "ipv6Flowspec";
8289 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8295 /* Show BGP peer's information. */
8296 enum show_type
{ show_all
, show_peer
};
8298 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8299 afi_t afi
, safi_t safi
,
8300 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8301 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8302 uint8_t use_json
, json_object
*json_pref
)
8305 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8306 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8308 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8309 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8310 json_object_string_add(json_pref
, "sendMode",
8311 "advertisedAndReceived");
8312 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8313 json_object_string_add(json_pref
, "sendMode",
8315 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8316 json_object_string_add(json_pref
, "sendMode",
8319 vty_out(vty
, " Send-mode: ");
8320 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8321 vty_out(vty
, "advertised");
8322 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8323 vty_out(vty
, "%sreceived",
8324 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8333 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8334 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8336 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8337 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8338 json_object_string_add(json_pref
, "recvMode",
8339 "advertisedAndReceived");
8340 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8341 json_object_string_add(json_pref
, "recvMode",
8343 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8344 json_object_string_add(json_pref
, "recvMode",
8347 vty_out(vty
, " Receive-mode: ");
8348 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8349 vty_out(vty
, "advertised");
8350 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8351 vty_out(vty
, "%sreceived",
8352 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8361 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8362 safi_t safi
, uint8_t use_json
,
8363 json_object
*json_neigh
)
8365 struct bgp_filter
*filter
;
8366 struct peer_af
*paf
;
8367 char orf_pfx_name
[BUFSIZ
];
8369 json_object
*json_af
= NULL
;
8370 json_object
*json_prefA
= NULL
;
8371 json_object
*json_prefB
= NULL
;
8372 json_object
*json_addr
= NULL
;
8375 json_addr
= json_object_new_object();
8376 json_af
= json_object_new_object();
8377 filter
= &p
->filter
[afi
][safi
];
8379 if (peer_group_active(p
))
8380 json_object_string_add(json_addr
, "peerGroupMember",
8383 paf
= peer_af_find(p
, afi
, safi
);
8384 if (paf
&& PAF_SUBGRP(paf
)) {
8385 json_object_int_add(json_addr
, "updateGroupId",
8386 PAF_UPDGRP(paf
)->id
);
8387 json_object_int_add(json_addr
, "subGroupId",
8388 PAF_SUBGRP(paf
)->id
);
8389 json_object_int_add(json_addr
, "packetQueueLength",
8390 bpacket_queue_virtual_length(paf
));
8393 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8394 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8395 PEER_CAP_ORF_PREFIX_SM_RCV
)
8396 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8397 PEER_CAP_ORF_PREFIX_RM_ADV
)
8398 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8399 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8400 json_object_int_add(json_af
, "orfType",
8402 json_prefA
= json_object_new_object();
8403 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8404 PEER_CAP_ORF_PREFIX_SM_ADV
,
8405 PEER_CAP_ORF_PREFIX_RM_ADV
,
8406 PEER_CAP_ORF_PREFIX_SM_RCV
,
8407 PEER_CAP_ORF_PREFIX_RM_RCV
,
8408 use_json
, json_prefA
);
8409 json_object_object_add(json_af
, "orfPrefixList",
8413 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8414 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8415 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8416 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8417 PEER_CAP_ORF_PREFIX_RM_ADV
)
8418 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8419 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8420 json_object_int_add(json_af
, "orfOldType",
8421 ORF_TYPE_PREFIX_OLD
);
8422 json_prefB
= json_object_new_object();
8423 bgp_show_peer_afi_orf_cap(
8424 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8425 PEER_CAP_ORF_PREFIX_RM_ADV
,
8426 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8427 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8429 json_object_object_add(json_af
, "orfOldPrefixList",
8433 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8434 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8435 PEER_CAP_ORF_PREFIX_SM_RCV
)
8436 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8437 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8438 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8439 PEER_CAP_ORF_PREFIX_RM_ADV
)
8440 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8441 PEER_CAP_ORF_PREFIX_RM_RCV
)
8442 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8443 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8444 json_object_object_add(json_addr
, "afDependentCap",
8447 json_object_free(json_af
);
8449 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8450 orf_pfx_count
= prefix_bgp_show_prefix_list(
8451 NULL
, afi
, orf_pfx_name
, use_json
);
8453 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8454 PEER_STATUS_ORF_PREFIX_SEND
)
8456 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8457 PEER_STATUS_ORF_PREFIX_SEND
))
8458 json_object_boolean_true_add(json_neigh
,
8461 json_object_int_add(json_addr
, "orfRecvCounter",
8464 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8465 PEER_STATUS_ORF_WAIT_REFRESH
))
8466 json_object_string_add(
8467 json_addr
, "orfFirstUpdate",
8468 "deferredUntilORFOrRouteRefreshRecvd");
8470 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8471 PEER_FLAG_REFLECTOR_CLIENT
))
8472 json_object_boolean_true_add(json_addr
,
8473 "routeReflectorClient");
8474 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8475 PEER_FLAG_RSERVER_CLIENT
))
8476 json_object_boolean_true_add(json_addr
,
8477 "routeServerClient");
8478 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8479 json_object_boolean_true_add(json_addr
,
8480 "inboundSoftConfigPermit");
8482 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8483 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8484 json_object_boolean_true_add(
8486 "privateAsNumsAllReplacedInUpdatesToNbr");
8487 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8488 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8489 json_object_boolean_true_add(
8491 "privateAsNumsReplacedInUpdatesToNbr");
8492 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8493 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8494 json_object_boolean_true_add(
8496 "privateAsNumsAllRemovedInUpdatesToNbr");
8497 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8498 PEER_FLAG_REMOVE_PRIVATE_AS
))
8499 json_object_boolean_true_add(
8501 "privateAsNumsRemovedInUpdatesToNbr");
8503 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8504 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
8505 json_object_boolean_true_add(json_addr
,
8506 "addpathTxAllPaths");
8508 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8509 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
8510 json_object_boolean_true_add(json_addr
,
8511 "addpathTxBestpathPerAS");
8513 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8514 json_object_string_add(json_addr
,
8515 "overrideASNsInOutboundUpdates",
8516 "ifAspathEqualRemoteAs");
8518 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8519 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8520 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8521 json_object_boolean_true_add(json_addr
,
8522 "routerAlwaysNextHop");
8523 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8524 PEER_FLAG_AS_PATH_UNCHANGED
))
8525 json_object_boolean_true_add(
8526 json_addr
, "unchangedAsPathPropogatedToNbr");
8527 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8528 PEER_FLAG_NEXTHOP_UNCHANGED
))
8529 json_object_boolean_true_add(
8530 json_addr
, "unchangedNextHopPropogatedToNbr");
8531 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8532 json_object_boolean_true_add(
8533 json_addr
, "unchangedMedPropogatedToNbr");
8534 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8535 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8536 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8537 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8538 PEER_FLAG_SEND_COMMUNITY
)
8539 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8540 PEER_FLAG_SEND_EXT_COMMUNITY
))
8541 json_object_string_add(json_addr
,
8542 "commAttriSentToNbr",
8543 "extendedAndStandard");
8544 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8545 PEER_FLAG_SEND_EXT_COMMUNITY
))
8546 json_object_string_add(json_addr
,
8547 "commAttriSentToNbr",
8550 json_object_string_add(json_addr
,
8551 "commAttriSentToNbr",
8554 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8555 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8556 if (p
->default_rmap
[afi
][safi
].name
)
8557 json_object_string_add(
8558 json_addr
, "defaultRouteMap",
8559 p
->default_rmap
[afi
][safi
].name
);
8561 if (paf
&& PAF_SUBGRP(paf
)
8562 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8563 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8564 json_object_boolean_true_add(json_addr
,
8567 json_object_boolean_true_add(json_addr
,
8571 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8572 if (is_evpn_enabled())
8573 json_object_boolean_true_add(
8574 json_addr
, "advertiseAllVnis");
8577 if (filter
->plist
[FILTER_IN
].name
8578 || filter
->dlist
[FILTER_IN
].name
8579 || filter
->aslist
[FILTER_IN
].name
8580 || filter
->map
[RMAP_IN
].name
)
8581 json_object_boolean_true_add(json_addr
,
8582 "inboundPathPolicyConfig");
8583 if (filter
->plist
[FILTER_OUT
].name
8584 || filter
->dlist
[FILTER_OUT
].name
8585 || filter
->aslist
[FILTER_OUT
].name
8586 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8587 json_object_boolean_true_add(
8588 json_addr
, "outboundPathPolicyConfig");
8591 if (filter
->plist
[FILTER_IN
].name
)
8592 json_object_string_add(json_addr
,
8593 "incomingUpdatePrefixFilterList",
8594 filter
->plist
[FILTER_IN
].name
);
8595 if (filter
->plist
[FILTER_OUT
].name
)
8596 json_object_string_add(json_addr
,
8597 "outgoingUpdatePrefixFilterList",
8598 filter
->plist
[FILTER_OUT
].name
);
8600 /* distribute-list */
8601 if (filter
->dlist
[FILTER_IN
].name
)
8602 json_object_string_add(
8603 json_addr
, "incomingUpdateNetworkFilterList",
8604 filter
->dlist
[FILTER_IN
].name
);
8605 if (filter
->dlist
[FILTER_OUT
].name
)
8606 json_object_string_add(
8607 json_addr
, "outgoingUpdateNetworkFilterList",
8608 filter
->dlist
[FILTER_OUT
].name
);
8611 if (filter
->aslist
[FILTER_IN
].name
)
8612 json_object_string_add(json_addr
,
8613 "incomingUpdateAsPathFilterList",
8614 filter
->aslist
[FILTER_IN
].name
);
8615 if (filter
->aslist
[FILTER_OUT
].name
)
8616 json_object_string_add(json_addr
,
8617 "outgoingUpdateAsPathFilterList",
8618 filter
->aslist
[FILTER_OUT
].name
);
8621 if (filter
->map
[RMAP_IN
].name
)
8622 json_object_string_add(
8623 json_addr
, "routeMapForIncomingAdvertisements",
8624 filter
->map
[RMAP_IN
].name
);
8625 if (filter
->map
[RMAP_OUT
].name
)
8626 json_object_string_add(
8627 json_addr
, "routeMapForOutgoingAdvertisements",
8628 filter
->map
[RMAP_OUT
].name
);
8630 /* unsuppress-map */
8631 if (filter
->usmap
.name
)
8632 json_object_string_add(json_addr
,
8633 "selectiveUnsuppressRouteMap",
8634 filter
->usmap
.name
);
8636 /* Receive prefix count */
8637 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8638 p
->pcount
[afi
][safi
]);
8640 /* Maximum prefix */
8641 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8642 json_object_int_add(json_addr
, "prefixAllowedMax",
8643 p
->pmax
[afi
][safi
]);
8644 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8645 PEER_FLAG_MAX_PREFIX_WARNING
))
8646 json_object_boolean_true_add(
8647 json_addr
, "prefixAllowedMaxWarning");
8648 json_object_int_add(json_addr
,
8649 "prefixAllowedWarningThresh",
8650 p
->pmax_threshold
[afi
][safi
]);
8651 if (p
->pmax_restart
[afi
][safi
])
8652 json_object_int_add(
8654 "prefixAllowedRestartIntervalMsecs",
8655 p
->pmax_restart
[afi
][safi
] * 60000);
8657 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8661 filter
= &p
->filter
[afi
][safi
];
8663 vty_out(vty
, " For address family: %s\n",
8664 afi_safi_print(afi
, safi
));
8666 if (peer_group_active(p
))
8667 vty_out(vty
, " %s peer-group member\n",
8670 paf
= peer_af_find(p
, afi
, safi
);
8671 if (paf
&& PAF_SUBGRP(paf
)) {
8672 vty_out(vty
, " Update group %" PRIu64
8673 ", subgroup %" PRIu64
"\n",
8674 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8675 vty_out(vty
, " Packet Queue length %d\n",
8676 bpacket_queue_virtual_length(paf
));
8678 vty_out(vty
, " Not part of any update group\n");
8680 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8681 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8682 PEER_CAP_ORF_PREFIX_SM_RCV
)
8683 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8684 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8685 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8686 PEER_CAP_ORF_PREFIX_RM_ADV
)
8687 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8688 PEER_CAP_ORF_PREFIX_RM_RCV
)
8689 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8690 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8691 vty_out(vty
, " AF-dependant capabilities:\n");
8693 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8694 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8695 PEER_CAP_ORF_PREFIX_SM_RCV
)
8696 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8697 PEER_CAP_ORF_PREFIX_RM_ADV
)
8698 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8699 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8701 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8703 bgp_show_peer_afi_orf_cap(
8704 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8705 PEER_CAP_ORF_PREFIX_RM_ADV
,
8706 PEER_CAP_ORF_PREFIX_SM_RCV
,
8707 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8709 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8710 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8711 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8712 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8713 PEER_CAP_ORF_PREFIX_RM_ADV
)
8714 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8715 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8717 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8718 ORF_TYPE_PREFIX_OLD
);
8719 bgp_show_peer_afi_orf_cap(
8720 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8721 PEER_CAP_ORF_PREFIX_RM_ADV
,
8722 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8723 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8726 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8727 orf_pfx_count
= prefix_bgp_show_prefix_list(
8728 NULL
, afi
, orf_pfx_name
, use_json
);
8730 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8731 PEER_STATUS_ORF_PREFIX_SEND
)
8733 vty_out(vty
, " Outbound Route Filter (ORF):");
8734 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8735 PEER_STATUS_ORF_PREFIX_SEND
))
8736 vty_out(vty
, " sent;");
8738 vty_out(vty
, " received (%d entries)",
8742 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8743 PEER_STATUS_ORF_WAIT_REFRESH
))
8745 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
8747 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8748 PEER_FLAG_REFLECTOR_CLIENT
))
8749 vty_out(vty
, " Route-Reflector Client\n");
8750 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8751 PEER_FLAG_RSERVER_CLIENT
))
8752 vty_out(vty
, " Route-Server Client\n");
8753 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8755 " Inbound soft reconfiguration allowed\n");
8757 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8758 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8760 " Private AS numbers (all) replaced in updates to this neighbor\n");
8761 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8762 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8764 " Private AS numbers replaced in updates to this neighbor\n");
8765 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8766 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8768 " Private AS numbers (all) removed in updates to this neighbor\n");
8769 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8770 PEER_FLAG_REMOVE_PRIVATE_AS
))
8772 " Private AS numbers removed in updates to this neighbor\n");
8774 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8775 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
8776 vty_out(vty
, " Advertise all paths via addpath\n");
8778 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8779 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
8781 " Advertise bestpath per AS via addpath\n");
8783 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8785 " Override ASNs in outbound updates if aspath equals remote-as\n");
8787 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8788 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8789 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8790 vty_out(vty
, " NEXT_HOP is always this router\n");
8791 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8792 PEER_FLAG_AS_PATH_UNCHANGED
))
8794 " AS_PATH is propagated unchanged to this neighbor\n");
8795 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8796 PEER_FLAG_NEXTHOP_UNCHANGED
))
8798 " NEXT_HOP is propagated unchanged to this neighbor\n");
8799 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8801 " MED is propagated unchanged to this neighbor\n");
8802 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8803 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8804 PEER_FLAG_SEND_EXT_COMMUNITY
)
8805 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8806 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
8808 " Community attribute sent to this neighbor");
8809 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8810 PEER_FLAG_SEND_COMMUNITY
)
8811 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8812 PEER_FLAG_SEND_EXT_COMMUNITY
)
8813 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8814 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8815 vty_out(vty
, "(all)\n");
8816 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8817 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8818 vty_out(vty
, "(large)\n");
8819 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8820 PEER_FLAG_SEND_EXT_COMMUNITY
))
8821 vty_out(vty
, "(extended)\n");
8823 vty_out(vty
, "(standard)\n");
8825 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8826 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8827 vty_out(vty
, " Default information originate,");
8829 if (p
->default_rmap
[afi
][safi
].name
)
8830 vty_out(vty
, " default route-map %s%s,",
8831 p
->default_rmap
[afi
][safi
].map
? "*"
8833 p
->default_rmap
[afi
][safi
].name
);
8834 if (paf
&& PAF_SUBGRP(paf
)
8835 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8836 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8837 vty_out(vty
, " default sent\n");
8839 vty_out(vty
, " default not sent\n");
8842 /* advertise-vni-all */
8843 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8844 if (is_evpn_enabled())
8845 vty_out(vty
, " advertise-all-vni\n");
8848 if (filter
->plist
[FILTER_IN
].name
8849 || filter
->dlist
[FILTER_IN
].name
8850 || filter
->aslist
[FILTER_IN
].name
8851 || filter
->map
[RMAP_IN
].name
)
8852 vty_out(vty
, " Inbound path policy configured\n");
8853 if (filter
->plist
[FILTER_OUT
].name
8854 || filter
->dlist
[FILTER_OUT
].name
8855 || filter
->aslist
[FILTER_OUT
].name
8856 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8857 vty_out(vty
, " Outbound path policy configured\n");
8860 if (filter
->plist
[FILTER_IN
].name
)
8862 " Incoming update prefix filter list is %s%s\n",
8863 filter
->plist
[FILTER_IN
].plist
? "*" : "",
8864 filter
->plist
[FILTER_IN
].name
);
8865 if (filter
->plist
[FILTER_OUT
].name
)
8867 " Outgoing update prefix filter list is %s%s\n",
8868 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
8869 filter
->plist
[FILTER_OUT
].name
);
8871 /* distribute-list */
8872 if (filter
->dlist
[FILTER_IN
].name
)
8874 " Incoming update network filter list is %s%s\n",
8875 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
8876 filter
->dlist
[FILTER_IN
].name
);
8877 if (filter
->dlist
[FILTER_OUT
].name
)
8879 " Outgoing update network filter list is %s%s\n",
8880 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
8881 filter
->dlist
[FILTER_OUT
].name
);
8884 if (filter
->aslist
[FILTER_IN
].name
)
8886 " Incoming update AS path filter list is %s%s\n",
8887 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
8888 filter
->aslist
[FILTER_IN
].name
);
8889 if (filter
->aslist
[FILTER_OUT
].name
)
8891 " Outgoing update AS path filter list is %s%s\n",
8892 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
8893 filter
->aslist
[FILTER_OUT
].name
);
8896 if (filter
->map
[RMAP_IN
].name
)
8898 " Route map for incoming advertisements is %s%s\n",
8899 filter
->map
[RMAP_IN
].map
? "*" : "",
8900 filter
->map
[RMAP_IN
].name
);
8901 if (filter
->map
[RMAP_OUT
].name
)
8903 " Route map for outgoing advertisements is %s%s\n",
8904 filter
->map
[RMAP_OUT
].map
? "*" : "",
8905 filter
->map
[RMAP_OUT
].name
);
8907 /* unsuppress-map */
8908 if (filter
->usmap
.name
)
8910 " Route map for selective unsuppress is %s%s\n",
8911 filter
->usmap
.map
? "*" : "",
8912 filter
->usmap
.name
);
8914 /* Receive prefix count */
8915 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
8917 /* Maximum prefix */
8918 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8919 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
8921 CHECK_FLAG(p
->af_flags
[afi
][safi
],
8922 PEER_FLAG_MAX_PREFIX_WARNING
)
8925 vty_out(vty
, " Threshold for warning message %d%%",
8926 p
->pmax_threshold
[afi
][safi
]);
8927 if (p
->pmax_restart
[afi
][safi
])
8928 vty_out(vty
, ", restart interval %d min",
8929 p
->pmax_restart
[afi
][safi
]);
8937 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, uint8_t use_json
,
8941 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
8942 char timebuf
[BGP_UPTIME_LEN
];
8944 const char *subcode_str
;
8945 const char *code_str
;
8950 json_object
*json_neigh
= NULL
;
8956 json_neigh
= json_object_new_object();
8958 memset(dn_flag
, '\0', sizeof(dn_flag
));
8959 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
8963 if (p
->conf_if
) /* Configured interface name. */
8964 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
8965 BGP_PEER_SU_UNSPEC(p
)
8967 : sockunion2str(&p
->su
, buf
,
8969 else /* Configured IP address. */
8970 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
8975 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
8976 json_object_string_add(json_neigh
, "bgpNeighborAddr",
8978 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
8979 json_object_string_add(
8980 json_neigh
, "bgpNeighborAddr",
8981 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
8983 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
8985 if (p
->change_local_as
)
8986 json_object_int_add(json_neigh
, "localAs",
8987 p
->change_local_as
);
8989 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
8991 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
8992 json_object_boolean_true_add(json_neigh
,
8993 "localAsNoPrepend");
8995 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
8996 json_object_boolean_true_add(json_neigh
,
8997 "localAsReplaceAs");
8999 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9000 || (p
->as_type
== AS_INTERNAL
))
9001 vty_out(vty
, "remote AS %u, ", p
->as
);
9003 vty_out(vty
, "remote AS Unspecified, ");
9004 vty_out(vty
, "local AS %u%s%s, ",
9005 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9006 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9009 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9013 /* peer type internal, external, confed-internal or confed-external */
9014 if (p
->as
== p
->local_as
) {
9016 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9017 json_object_boolean_true_add(
9018 json_neigh
, "nbrConfedInternalLink");
9020 json_object_boolean_true_add(json_neigh
,
9023 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9024 vty_out(vty
, "confed-internal link\n");
9026 vty_out(vty
, "internal link\n");
9030 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9031 json_object_boolean_true_add(
9032 json_neigh
, "nbrConfedExternalLink");
9034 json_object_boolean_true_add(json_neigh
,
9037 if (bgp_confederation_peers_check(bgp
, p
->as
))
9038 vty_out(vty
, "confed-external link\n");
9040 vty_out(vty
, "external link\n");
9047 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9049 vty_out(vty
, " Description: %s\n", p
->desc
);
9055 json_object_string_add(json_neigh
, "hostname",
9059 json_object_string_add(json_neigh
, "domainname",
9062 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9063 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9066 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9073 json_object_string_add(json_neigh
, "peerGroup",
9077 struct prefix prefix
, *range
= NULL
;
9079 sockunion2hostprefix(&(p
->su
), &prefix
);
9080 range
= peer_group_lookup_dynamic_neighbor_range(
9084 prefix2str(range
, buf1
, sizeof(buf1
));
9085 json_object_string_add(
9087 "peerSubnetRangeGroup", buf1
);
9092 " Member of peer-group %s for session parameters\n",
9096 struct prefix prefix
, *range
= NULL
;
9098 sockunion2hostprefix(&(p
->su
), &prefix
);
9099 range
= peer_group_lookup_dynamic_neighbor_range(
9103 prefix2str(range
, buf1
, sizeof(buf1
));
9105 " Belongs to the subnet range group: %s\n",
9113 /* Administrative shutdown. */
9114 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9115 json_object_boolean_true_add(json_neigh
,
9119 json_object_int_add(json_neigh
, "bgpVersion", 4);
9120 json_object_string_add(
9121 json_neigh
, "remoteRouterId",
9122 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9123 json_object_string_add(
9124 json_neigh
, "localRouterId",
9125 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9129 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9130 && bgp_confederation_peers_check(bgp
, p
->as
))
9131 json_object_boolean_true_add(json_neigh
,
9135 json_object_string_add(
9136 json_neigh
, "bgpState",
9137 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9139 if (p
->status
== Established
) {
9142 uptime
= bgp_clock();
9143 uptime
-= p
->uptime
;
9144 epoch_tbuf
= time(NULL
) - uptime
;
9146 #if CONFDATE > 20200101
9148 "bgpTimerUp should be deprecated and can be removed now");
9151 * bgpTimerUp was miliseconds that was accurate
9152 * up to 1 day, then the value returned
9153 * became garbage. So in order to provide
9154 * some level of backwards compatability,
9155 * we still provde the data, but now
9156 * we are returning the correct value
9157 * and also adding a new bgpTimerUpMsec
9158 * which will allow us to deprecate
9161 json_object_int_add(json_neigh
, "bgpTimerUp",
9163 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9165 json_object_string_add(json_neigh
, "bgpTimerUpString",
9166 peer_uptime(p
->uptime
, timebuf
,
9169 json_object_int_add(json_neigh
,
9170 "bgpTimerUpEstablishedEpoch",
9174 else if (p
->status
== Active
) {
9175 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9176 json_object_string_add(json_neigh
, "bgpStateIs",
9178 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9179 json_object_string_add(json_neigh
, "bgpStateIs",
9187 uptime
= bgp_clock();
9188 uptime
-= p
->readtime
;
9189 tm
= gmtime(&uptime
);
9190 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9191 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9192 + (tm
->tm_hour
* 3600000));
9194 uptime
= bgp_clock();
9195 uptime
-= p
->last_write
;
9196 tm
= gmtime(&uptime
);
9197 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9198 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9199 + (tm
->tm_hour
* 3600000));
9201 uptime
= bgp_clock();
9202 uptime
-= p
->update_time
;
9203 tm
= gmtime(&uptime
);
9204 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9205 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9206 + (tm
->tm_hour
* 3600000));
9208 /* Configured timer values. */
9209 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9210 p
->v_holdtime
* 1000);
9211 json_object_int_add(json_neigh
,
9212 "bgpTimerKeepAliveIntervalMsecs",
9213 p
->v_keepalive
* 1000);
9214 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9215 json_object_int_add(json_neigh
,
9216 "bgpTimerConfiguredHoldTimeMsecs",
9217 p
->holdtime
* 1000);
9218 json_object_int_add(
9220 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9221 p
->keepalive
* 1000);
9222 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9223 || (bgp
->default_keepalive
9224 != BGP_DEFAULT_KEEPALIVE
)) {
9225 json_object_int_add(json_neigh
,
9226 "bgpTimerConfiguredHoldTimeMsecs",
9227 bgp
->default_holdtime
);
9228 json_object_int_add(
9230 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9231 bgp
->default_keepalive
);
9234 /* Administrative shutdown. */
9235 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9236 vty_out(vty
, " Administratively shut down\n");
9239 vty_out(vty
, " BGP version 4");
9240 vty_out(vty
, ", remote router ID %s\n",
9241 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9244 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9245 && bgp_confederation_peers_check(bgp
, p
->as
))
9247 " Neighbor under common administration\n");
9250 vty_out(vty
, " BGP state = %s",
9251 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9253 if (p
->status
== Established
)
9254 vty_out(vty
, ", up for %8s",
9255 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9258 else if (p
->status
== Active
) {
9259 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9260 vty_out(vty
, " (passive)");
9261 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9262 vty_out(vty
, " (NSF passive)");
9267 vty_out(vty
, " Last read %s",
9268 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9270 vty_out(vty
, ", Last write %s\n",
9271 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9274 /* Configured timer values. */
9276 " Hold time is %d, keepalive interval is %d seconds\n",
9277 p
->v_holdtime
, p
->v_keepalive
);
9278 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9279 vty_out(vty
, " Configured hold time is %d",
9281 vty_out(vty
, ", keepalive interval is %d seconds\n",
9283 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9284 || (bgp
->default_keepalive
9285 != BGP_DEFAULT_KEEPALIVE
)) {
9286 vty_out(vty
, " Configured hold time is %d",
9287 bgp
->default_holdtime
);
9288 vty_out(vty
, ", keepalive interval is %d seconds\n",
9289 bgp
->default_keepalive
);
9293 if (p
->status
== Established
) {
9294 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9295 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9296 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9297 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9298 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9299 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9300 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9301 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9302 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9303 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9304 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9305 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9306 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9307 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9308 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9309 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9310 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9311 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9312 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9313 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9315 json_object
*json_cap
= NULL
;
9317 json_cap
= json_object_new_object();
9320 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9321 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9322 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9323 && CHECK_FLAG(p
->cap
,
9325 json_object_string_add(
9326 json_cap
, "4byteAs",
9327 "advertisedAndReceived");
9328 else if (CHECK_FLAG(p
->cap
,
9330 json_object_string_add(
9331 json_cap
, "4byteAs",
9333 else if (CHECK_FLAG(p
->cap
,
9335 json_object_string_add(
9336 json_cap
, "4byteAs",
9341 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9342 || CHECK_FLAG(p
->cap
,
9343 PEER_CAP_ADDPATH_ADV
)) {
9344 json_object
*json_add
= NULL
;
9345 const char *print_store
;
9347 json_add
= json_object_new_object();
9349 FOREACH_AFI_SAFI (afi
, safi
) {
9350 json_object
*json_sub
= NULL
;
9352 json_object_new_object();
9353 print_store
= afi_safi_print(
9359 PEER_CAP_ADDPATH_AF_TX_ADV
)
9363 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9368 PEER_CAP_ADDPATH_AF_TX_ADV
)
9373 PEER_CAP_ADDPATH_AF_TX_RCV
))
9374 json_object_boolean_true_add(
9376 "txAdvertisedAndReceived");
9382 PEER_CAP_ADDPATH_AF_TX_ADV
))
9383 json_object_boolean_true_add(
9391 PEER_CAP_ADDPATH_AF_TX_RCV
))
9392 json_object_boolean_true_add(
9400 PEER_CAP_ADDPATH_AF_RX_ADV
)
9404 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9409 PEER_CAP_ADDPATH_AF_RX_ADV
)
9414 PEER_CAP_ADDPATH_AF_RX_RCV
))
9415 json_object_boolean_true_add(
9417 "rxAdvertisedAndReceived");
9423 PEER_CAP_ADDPATH_AF_RX_ADV
))
9424 json_object_boolean_true_add(
9432 PEER_CAP_ADDPATH_AF_RX_RCV
))
9433 json_object_boolean_true_add(
9441 PEER_CAP_ADDPATH_AF_TX_ADV
)
9445 PEER_CAP_ADDPATH_AF_TX_RCV
)
9449 PEER_CAP_ADDPATH_AF_RX_ADV
)
9453 PEER_CAP_ADDPATH_AF_RX_RCV
))
9454 json_object_object_add(
9463 json_object_object_add(
9464 json_cap
, "addPath", json_add
);
9468 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9469 || CHECK_FLAG(p
->cap
,
9470 PEER_CAP_DYNAMIC_ADV
)) {
9471 if (CHECK_FLAG(p
->cap
,
9472 PEER_CAP_DYNAMIC_ADV
)
9473 && CHECK_FLAG(p
->cap
,
9474 PEER_CAP_DYNAMIC_RCV
))
9475 json_object_string_add(
9476 json_cap
, "dynamic",
9477 "advertisedAndReceived");
9478 else if (CHECK_FLAG(
9480 PEER_CAP_DYNAMIC_ADV
))
9481 json_object_string_add(
9482 json_cap
, "dynamic",
9484 else if (CHECK_FLAG(
9486 PEER_CAP_DYNAMIC_RCV
))
9487 json_object_string_add(
9488 json_cap
, "dynamic",
9492 /* Extended nexthop */
9493 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9494 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9495 json_object
*json_nxt
= NULL
;
9496 const char *print_store
;
9499 if (CHECK_FLAG(p
->cap
,
9501 && CHECK_FLAG(p
->cap
,
9503 json_object_string_add(
9506 "advertisedAndReceived");
9507 else if (CHECK_FLAG(p
->cap
,
9509 json_object_string_add(
9513 else if (CHECK_FLAG(p
->cap
,
9515 json_object_string_add(
9520 if (CHECK_FLAG(p
->cap
,
9521 PEER_CAP_ENHE_RCV
)) {
9523 json_object_new_object();
9525 for (safi
= SAFI_UNICAST
;
9526 safi
< SAFI_MAX
; safi
++) {
9531 PEER_CAP_ENHE_AF_RCV
)) {
9532 print_store
= afi_safi_print(
9535 json_object_string_add(
9541 json_object_object_add(
9543 "extendedNexthopFamililesByPeer",
9549 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9550 || CHECK_FLAG(p
->cap
,
9551 PEER_CAP_REFRESH_NEW_RCV
)
9552 || CHECK_FLAG(p
->cap
,
9553 PEER_CAP_REFRESH_OLD_RCV
)) {
9554 if (CHECK_FLAG(p
->cap
,
9555 PEER_CAP_REFRESH_ADV
)
9558 PEER_CAP_REFRESH_NEW_RCV
)
9561 PEER_CAP_REFRESH_OLD_RCV
))) {
9564 PEER_CAP_REFRESH_OLD_RCV
)
9567 PEER_CAP_REFRESH_NEW_RCV
))
9568 json_object_string_add(
9571 "advertisedAndReceivedOldNew");
9575 PEER_CAP_REFRESH_OLD_RCV
))
9576 json_object_string_add(
9579 "advertisedAndReceivedOld");
9581 json_object_string_add(
9584 "advertisedAndReceivedNew");
9589 PEER_CAP_REFRESH_ADV
))
9590 json_object_string_add(
9597 PEER_CAP_REFRESH_NEW_RCV
)
9600 PEER_CAP_REFRESH_OLD_RCV
))
9601 json_object_string_add(
9607 /* Multiprotocol Extensions */
9608 json_object
*json_multi
= NULL
;
9609 json_multi
= json_object_new_object();
9611 FOREACH_AFI_SAFI (afi
, safi
) {
9612 if (p
->afc_adv
[afi
][safi
]
9613 || p
->afc_recv
[afi
][safi
]) {
9614 json_object
*json_exten
= NULL
;
9616 json_object_new_object();
9618 if (p
->afc_adv
[afi
][safi
]
9619 && p
->afc_recv
[afi
][safi
])
9620 json_object_boolean_true_add(
9622 "advertisedAndReceived");
9623 else if (p
->afc_adv
[afi
][safi
])
9624 json_object_boolean_true_add(
9627 else if (p
->afc_recv
[afi
][safi
])
9628 json_object_boolean_true_add(
9632 json_object_object_add(
9639 json_object_object_add(
9640 json_cap
, "multiprotocolExtensions",
9643 /* Hostname capabilities */
9644 json_object
*json_hname
= NULL
;
9646 json_hname
= json_object_new_object();
9648 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9649 json_object_string_add(
9650 json_hname
, "advHostName",
9651 bgp
->peer_self
->hostname
9655 json_object_string_add(
9656 json_hname
, "advDomainName",
9657 bgp
->peer_self
->domainname
9664 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9665 json_object_string_add(
9666 json_hname
, "rcvHostName",
9667 p
->hostname
? p
->hostname
9669 json_object_string_add(
9670 json_hname
, "rcvDomainName",
9671 p
->domainname
? p
->domainname
9675 json_object_object_add(json_cap
, "hostName",
9678 /* Gracefull Restart */
9679 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9680 || CHECK_FLAG(p
->cap
,
9681 PEER_CAP_RESTART_ADV
)) {
9682 if (CHECK_FLAG(p
->cap
,
9683 PEER_CAP_RESTART_ADV
)
9684 && CHECK_FLAG(p
->cap
,
9685 PEER_CAP_RESTART_RCV
))
9686 json_object_string_add(
9689 "advertisedAndReceived");
9690 else if (CHECK_FLAG(
9692 PEER_CAP_RESTART_ADV
))
9693 json_object_string_add(
9695 "gracefulRestartCapability",
9697 else if (CHECK_FLAG(
9699 PEER_CAP_RESTART_RCV
))
9700 json_object_string_add(
9702 "gracefulRestartCapability",
9705 if (CHECK_FLAG(p
->cap
,
9706 PEER_CAP_RESTART_RCV
)) {
9707 int restart_af_count
= 0;
9708 json_object
*json_restart
=
9711 json_object_new_object();
9713 json_object_int_add(
9715 "gracefulRestartRemoteTimerMsecs",
9716 p
->v_gr_restart
* 1000);
9718 FOREACH_AFI_SAFI (afi
, safi
) {
9723 PEER_CAP_RESTART_AF_RCV
)) {
9728 json_object_new_object();
9734 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
9735 json_object_boolean_true_add(
9739 json_object_object_add(
9747 if (!restart_af_count
) {
9748 json_object_string_add(
9750 "addressFamiliesByPeer",
9755 json_object_object_add(
9757 "addressFamiliesByPeer",
9761 json_object_object_add(json_neigh
,
9762 "neighborCapabilities",
9765 vty_out(vty
, " Neighbor capabilities:\n");
9768 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9769 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9770 vty_out(vty
, " 4 Byte AS:");
9771 if (CHECK_FLAG(p
->cap
,
9773 vty_out(vty
, " advertised");
9774 if (CHECK_FLAG(p
->cap
,
9776 vty_out(vty
, " %sreceived",
9786 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9787 || CHECK_FLAG(p
->cap
,
9788 PEER_CAP_ADDPATH_ADV
)) {
9789 vty_out(vty
, " AddPath:\n");
9791 FOREACH_AFI_SAFI (afi
, safi
) {
9795 PEER_CAP_ADDPATH_AF_TX_ADV
)
9799 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9810 PEER_CAP_ADDPATH_AF_TX_ADV
))
9821 PEER_CAP_ADDPATH_AF_TX_RCV
))
9828 PEER_CAP_ADDPATH_AF_TX_ADV
)
9838 PEER_CAP_ADDPATH_AF_RX_ADV
)
9842 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9853 PEER_CAP_ADDPATH_AF_RX_ADV
))
9864 PEER_CAP_ADDPATH_AF_RX_RCV
))
9871 PEER_CAP_ADDPATH_AF_RX_ADV
)
9881 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9882 || CHECK_FLAG(p
->cap
,
9883 PEER_CAP_DYNAMIC_ADV
)) {
9884 vty_out(vty
, " Dynamic:");
9885 if (CHECK_FLAG(p
->cap
,
9886 PEER_CAP_DYNAMIC_ADV
))
9887 vty_out(vty
, " advertised");
9888 if (CHECK_FLAG(p
->cap
,
9889 PEER_CAP_DYNAMIC_RCV
))
9890 vty_out(vty
, " %sreceived",
9893 PEER_CAP_DYNAMIC_ADV
)
9899 /* Extended nexthop */
9900 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9901 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9902 vty_out(vty
, " Extended nexthop:");
9903 if (CHECK_FLAG(p
->cap
,
9905 vty_out(vty
, " advertised");
9906 if (CHECK_FLAG(p
->cap
,
9908 vty_out(vty
, " %sreceived",
9916 if (CHECK_FLAG(p
->cap
,
9917 PEER_CAP_ENHE_RCV
)) {
9919 " Address families by peer:\n ");
9920 for (safi
= SAFI_UNICAST
;
9921 safi
< SAFI_MAX
; safi
++)
9926 PEER_CAP_ENHE_AF_RCV
))
9936 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9937 || CHECK_FLAG(p
->cap
,
9938 PEER_CAP_REFRESH_NEW_RCV
)
9939 || CHECK_FLAG(p
->cap
,
9940 PEER_CAP_REFRESH_OLD_RCV
)) {
9941 vty_out(vty
, " Route refresh:");
9942 if (CHECK_FLAG(p
->cap
,
9943 PEER_CAP_REFRESH_ADV
))
9944 vty_out(vty
, " advertised");
9945 if (CHECK_FLAG(p
->cap
,
9946 PEER_CAP_REFRESH_NEW_RCV
)
9949 PEER_CAP_REFRESH_OLD_RCV
))
9950 vty_out(vty
, " %sreceived(%s)",
9953 PEER_CAP_REFRESH_ADV
)
9958 PEER_CAP_REFRESH_OLD_RCV
)
9961 PEER_CAP_REFRESH_NEW_RCV
))
9965 PEER_CAP_REFRESH_OLD_RCV
)
9972 /* Multiprotocol Extensions */
9973 FOREACH_AFI_SAFI (afi
, safi
)
9974 if (p
->afc_adv
[afi
][safi
]
9975 || p
->afc_recv
[afi
][safi
]) {
9977 " Address Family %s:",
9980 if (p
->afc_adv
[afi
][safi
])
9983 if (p
->afc_recv
[afi
][safi
])
9993 /* Hostname capability */
9994 vty_out(vty
, " Hostname Capability:");
9996 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9998 " advertised (name: %s,domain name: %s)",
9999 bgp
->peer_self
->hostname
10003 bgp
->peer_self
->domainname
10008 vty_out(vty
, " not advertised");
10011 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10013 " received (name: %s,domain name: %s)",
10014 p
->hostname
? p
->hostname
10016 p
->domainname
? p
->domainname
10019 vty_out(vty
, " not received");
10022 vty_out(vty
, "\n");
10024 /* Gracefull Restart */
10025 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10026 || CHECK_FLAG(p
->cap
,
10027 PEER_CAP_RESTART_ADV
)) {
10029 " Graceful Restart Capabilty:");
10030 if (CHECK_FLAG(p
->cap
,
10031 PEER_CAP_RESTART_ADV
))
10032 vty_out(vty
, " advertised");
10033 if (CHECK_FLAG(p
->cap
,
10034 PEER_CAP_RESTART_RCV
))
10035 vty_out(vty
, " %sreceived",
10038 PEER_CAP_RESTART_ADV
)
10041 vty_out(vty
, "\n");
10043 if (CHECK_FLAG(p
->cap
,
10044 PEER_CAP_RESTART_RCV
)) {
10045 int restart_af_count
= 0;
10048 " Remote Restart timer is %d seconds\n",
10051 " Address families by peer:\n ");
10053 FOREACH_AFI_SAFI (afi
, safi
)
10058 PEER_CAP_RESTART_AF_RCV
)) {
10071 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10073 : "not preserved");
10074 restart_af_count
++;
10076 if (!restart_af_count
)
10077 vty_out(vty
, "none");
10078 vty_out(vty
, "\n");
10085 /* graceful restart information */
10086 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10087 || p
->t_gr_stale
) {
10088 json_object
*json_grace
= NULL
;
10089 json_object
*json_grace_send
= NULL
;
10090 json_object
*json_grace_recv
= NULL
;
10091 int eor_send_af_count
= 0;
10092 int eor_receive_af_count
= 0;
10095 json_grace
= json_object_new_object();
10096 json_grace_send
= json_object_new_object();
10097 json_grace_recv
= json_object_new_object();
10099 if (p
->status
== Established
) {
10100 FOREACH_AFI_SAFI (afi
, safi
) {
10101 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10102 PEER_STATUS_EOR_SEND
)) {
10103 json_object_boolean_true_add(
10105 afi_safi_print(afi
,
10107 eor_send_af_count
++;
10110 FOREACH_AFI_SAFI (afi
, safi
) {
10112 p
->af_sflags
[afi
][safi
],
10113 PEER_STATUS_EOR_RECEIVED
)) {
10114 json_object_boolean_true_add(
10116 afi_safi_print(afi
,
10118 eor_receive_af_count
++;
10123 json_object_object_add(json_grace
, "endOfRibSend",
10125 json_object_object_add(json_grace
, "endOfRibRecv",
10128 if (p
->t_gr_restart
)
10129 json_object_int_add(json_grace
,
10130 "gracefulRestartTimerMsecs",
10131 thread_timer_remain_second(
10136 json_object_int_add(
10138 "gracefulStalepathTimerMsecs",
10139 thread_timer_remain_second(
10143 json_object_object_add(
10144 json_neigh
, "gracefulRestartInfo", json_grace
);
10146 vty_out(vty
, " Graceful restart informations:\n");
10147 if (p
->status
== Established
) {
10148 vty_out(vty
, " End-of-RIB send: ");
10149 FOREACH_AFI_SAFI (afi
, safi
) {
10150 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10151 PEER_STATUS_EOR_SEND
)) {
10152 vty_out(vty
, "%s%s",
10153 eor_send_af_count
? ", "
10155 afi_safi_print(afi
,
10157 eor_send_af_count
++;
10160 vty_out(vty
, "\n");
10161 vty_out(vty
, " End-of-RIB received: ");
10162 FOREACH_AFI_SAFI (afi
, safi
) {
10164 p
->af_sflags
[afi
][safi
],
10165 PEER_STATUS_EOR_RECEIVED
)) {
10166 vty_out(vty
, "%s%s",
10167 eor_receive_af_count
10170 afi_safi_print(afi
,
10172 eor_receive_af_count
++;
10175 vty_out(vty
, "\n");
10178 if (p
->t_gr_restart
)
10180 " The remaining time of restart timer is %ld\n",
10181 thread_timer_remain_second(
10186 " The remaining time of stalepath timer is %ld\n",
10187 thread_timer_remain_second(
10192 json_object
*json_stat
= NULL
;
10193 json_stat
= json_object_new_object();
10194 /* Packet counts. */
10195 json_object_int_add(json_stat
, "depthInq", 0);
10196 json_object_int_add(json_stat
, "depthOutq",
10197 (unsigned long)p
->obuf
->count
);
10198 json_object_int_add(json_stat
, "opensSent",
10199 atomic_load_explicit(&p
->open_out
,
10200 memory_order_relaxed
));
10201 json_object_int_add(json_stat
, "opensRecv",
10202 atomic_load_explicit(&p
->open_in
,
10203 memory_order_relaxed
));
10204 json_object_int_add(json_stat
, "notificationsSent",
10205 atomic_load_explicit(&p
->notify_out
,
10206 memory_order_relaxed
));
10207 json_object_int_add(json_stat
, "notificationsRecv",
10208 atomic_load_explicit(&p
->notify_in
,
10209 memory_order_relaxed
));
10210 json_object_int_add(json_stat
, "updatesSent",
10211 atomic_load_explicit(&p
->update_out
,
10212 memory_order_relaxed
));
10213 json_object_int_add(json_stat
, "updatesRecv",
10214 atomic_load_explicit(&p
->update_in
,
10215 memory_order_relaxed
));
10216 json_object_int_add(json_stat
, "keepalivesSent",
10217 atomic_load_explicit(&p
->keepalive_out
,
10218 memory_order_relaxed
));
10219 json_object_int_add(json_stat
, "keepalivesRecv",
10220 atomic_load_explicit(&p
->keepalive_in
,
10221 memory_order_relaxed
));
10222 json_object_int_add(json_stat
, "routeRefreshSent",
10223 atomic_load_explicit(&p
->refresh_out
,
10224 memory_order_relaxed
));
10225 json_object_int_add(json_stat
, "routeRefreshRecv",
10226 atomic_load_explicit(&p
->refresh_in
,
10227 memory_order_relaxed
));
10228 json_object_int_add(json_stat
, "capabilitySent",
10229 atomic_load_explicit(&p
->dynamic_cap_out
,
10230 memory_order_relaxed
));
10231 json_object_int_add(json_stat
, "capabilityRecv",
10232 atomic_load_explicit(&p
->dynamic_cap_in
,
10233 memory_order_relaxed
));
10234 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10235 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10236 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10238 /* Packet counts. */
10239 vty_out(vty
, " Message statistics:\n");
10240 vty_out(vty
, " Inq depth is 0\n");
10241 vty_out(vty
, " Outq depth is %lu\n",
10242 (unsigned long)p
->obuf
->count
);
10243 vty_out(vty
, " Sent Rcvd\n");
10244 vty_out(vty
, " Opens: %10d %10d\n",
10245 atomic_load_explicit(&p
->open_out
,
10246 memory_order_relaxed
),
10247 atomic_load_explicit(&p
->open_in
,
10248 memory_order_relaxed
));
10249 vty_out(vty
, " Notifications: %10d %10d\n",
10250 atomic_load_explicit(&p
->notify_out
,
10251 memory_order_relaxed
),
10252 atomic_load_explicit(&p
->notify_in
,
10253 memory_order_relaxed
));
10254 vty_out(vty
, " Updates: %10d %10d\n",
10255 atomic_load_explicit(&p
->update_out
,
10256 memory_order_relaxed
),
10257 atomic_load_explicit(&p
->update_in
,
10258 memory_order_relaxed
));
10259 vty_out(vty
, " Keepalives: %10d %10d\n",
10260 atomic_load_explicit(&p
->keepalive_out
,
10261 memory_order_relaxed
),
10262 atomic_load_explicit(&p
->keepalive_in
,
10263 memory_order_relaxed
));
10264 vty_out(vty
, " Route Refresh: %10d %10d\n",
10265 atomic_load_explicit(&p
->refresh_out
,
10266 memory_order_relaxed
),
10267 atomic_load_explicit(&p
->refresh_in
,
10268 memory_order_relaxed
));
10269 vty_out(vty
, " Capability: %10d %10d\n",
10270 atomic_load_explicit(&p
->dynamic_cap_out
,
10271 memory_order_relaxed
),
10272 atomic_load_explicit(&p
->dynamic_cap_in
,
10273 memory_order_relaxed
));
10274 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10279 /* advertisement-interval */
10280 json_object_int_add(json_neigh
,
10281 "minBtwnAdvertisementRunsTimerMsecs",
10282 p
->v_routeadv
* 1000);
10284 /* Update-source. */
10285 if (p
->update_if
|| p
->update_source
) {
10287 json_object_string_add(json_neigh
,
10290 else if (p
->update_source
)
10291 json_object_string_add(
10292 json_neigh
, "updateSource",
10293 sockunion2str(p
->update_source
, buf1
,
10297 /* advertisement-interval */
10299 " Minimum time between advertisement runs is %d seconds\n",
10302 /* Update-source. */
10303 if (p
->update_if
|| p
->update_source
) {
10304 vty_out(vty
, " Update source is ");
10306 vty_out(vty
, "%s", p
->update_if
);
10307 else if (p
->update_source
)
10309 sockunion2str(p
->update_source
, buf1
,
10311 vty_out(vty
, "\n");
10314 vty_out(vty
, "\n");
10317 /* Address Family Information */
10318 json_object
*json_hold
= NULL
;
10321 json_hold
= json_object_new_object();
10323 FOREACH_AFI_SAFI (afi
, safi
)
10324 if (p
->afc
[afi
][safi
])
10325 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10329 json_object_object_add(json_neigh
, "addressFamilyInfo",
10331 json_object_int_add(json_neigh
, "connectionsEstablished",
10333 json_object_int_add(json_neigh
, "connectionsDropped",
10336 vty_out(vty
, " Connections established %d; dropped %d\n",
10337 p
->established
, p
->dropped
);
10339 if (!p
->last_reset
) {
10341 json_object_string_add(json_neigh
, "lastReset",
10344 vty_out(vty
, " Last reset never\n");
10350 uptime
= bgp_clock();
10351 uptime
-= p
->resettime
;
10352 tm
= gmtime(&uptime
);
10353 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10354 (tm
->tm_sec
* 1000)
10355 + (tm
->tm_min
* 60000)
10356 + (tm
->tm_hour
* 3600000));
10357 json_object_string_add(
10358 json_neigh
, "lastResetDueTo",
10359 peer_down_str
[(int)p
->last_reset
]);
10360 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10361 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10362 char errorcodesubcode_hexstr
[5];
10363 char errorcodesubcode_str
[256];
10365 code_str
= bgp_notify_code_str(p
->notify
.code
);
10366 subcode_str
= bgp_notify_subcode_str(
10367 p
->notify
.code
, p
->notify
.subcode
);
10369 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10370 p
->notify
.code
, p
->notify
.subcode
);
10371 json_object_string_add(json_neigh
,
10372 "lastErrorCodeSubcode",
10373 errorcodesubcode_hexstr
);
10374 snprintf(errorcodesubcode_str
, 255, "%s%s",
10375 code_str
, subcode_str
);
10376 json_object_string_add(json_neigh
,
10377 "lastNotificationReason",
10378 errorcodesubcode_str
);
10379 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10380 && p
->notify
.code
== BGP_NOTIFY_CEASE
10381 && (p
->notify
.subcode
10382 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10383 || p
->notify
.subcode
10384 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10385 && p
->notify
.length
) {
10387 const char *msg_str
;
10389 msg_str
= bgp_notify_admin_message(
10390 msgbuf
, sizeof(msgbuf
),
10391 (uint8_t *)p
->notify
.data
,
10394 json_object_string_add(
10396 "lastShutdownDescription",
10401 vty_out(vty
, " Last reset %s, ",
10402 peer_uptime(p
->resettime
, timebuf
,
10403 BGP_UPTIME_LEN
, 0, NULL
));
10405 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10406 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10407 code_str
= bgp_notify_code_str(p
->notify
.code
);
10408 subcode_str
= bgp_notify_subcode_str(
10409 p
->notify
.code
, p
->notify
.subcode
);
10410 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10411 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10414 code_str
, subcode_str
);
10415 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10416 && p
->notify
.code
== BGP_NOTIFY_CEASE
10417 && (p
->notify
.subcode
10418 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10419 || p
->notify
.subcode
10420 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10421 && p
->notify
.length
) {
10423 const char *msg_str
;
10425 msg_str
= bgp_notify_admin_message(
10426 msgbuf
, sizeof(msgbuf
),
10427 (uint8_t *)p
->notify
.data
,
10431 " Message: \"%s\"\n",
10435 vty_out(vty
, "due to %s\n",
10436 peer_down_str
[(int)p
->last_reset
]);
10439 if (p
->last_reset_cause_size
) {
10440 msg
= p
->last_reset_cause
;
10442 " Message received that caused BGP to send a NOTIFICATION:\n ");
10443 for (i
= 1; i
<= p
->last_reset_cause_size
;
10445 vty_out(vty
, "%02X", *msg
++);
10447 if (i
!= p
->last_reset_cause_size
) {
10449 vty_out(vty
, "\n ");
10450 } else if (i
% 4 == 0) {
10455 vty_out(vty
, "\n");
10460 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10462 json_object_boolean_true_add(json_neigh
,
10463 "prefixesConfigExceedMax");
10466 " Peer had exceeded the max. no. of prefixes configured.\n");
10468 if (p
->t_pmax_restart
) {
10470 json_object_boolean_true_add(
10471 json_neigh
, "reducePrefixNumFrom");
10472 json_object_int_add(json_neigh
,
10473 "restartInTimerMsec",
10474 thread_timer_remain_second(
10479 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10480 p
->host
, thread_timer_remain_second(
10481 p
->t_pmax_restart
));
10484 json_object_boolean_true_add(
10486 "reducePrefixNumAndClearIpBgp");
10489 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10494 /* EBGP Multihop and GTSM */
10495 if (p
->sort
!= BGP_PEER_IBGP
) {
10497 if (p
->gtsm_hops
> 0)
10498 json_object_int_add(json_neigh
,
10499 "externalBgpNbrMaxHopsAway",
10501 else if (p
->ttl
> 1)
10502 json_object_int_add(json_neigh
,
10503 "externalBgpNbrMaxHopsAway",
10506 if (p
->gtsm_hops
> 0)
10508 " External BGP neighbor may be up to %d hops away.\n",
10510 else if (p
->ttl
> 1)
10512 " External BGP neighbor may be up to %d hops away.\n",
10516 if (p
->gtsm_hops
> 0) {
10518 json_object_int_add(json_neigh
,
10519 "internalBgpNbrMaxHopsAway",
10523 " Internal BGP neighbor may be up to %d hops away.\n",
10528 /* Local address. */
10531 json_object_string_add(json_neigh
, "hostLocal",
10532 sockunion2str(p
->su_local
, buf1
,
10534 json_object_int_add(json_neigh
, "portLocal",
10535 ntohs(p
->su_local
->sin
.sin_port
));
10537 vty_out(vty
, "Local host: %s, Local port: %d\n",
10538 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10539 ntohs(p
->su_local
->sin
.sin_port
));
10542 /* Remote address. */
10543 if (p
->su_remote
) {
10545 json_object_string_add(json_neigh
, "hostForeign",
10546 sockunion2str(p
->su_remote
, buf1
,
10548 json_object_int_add(json_neigh
, "portForeign",
10549 ntohs(p
->su_remote
->sin
.sin_port
));
10551 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10552 sockunion2str(p
->su_remote
, buf1
,
10554 ntohs(p
->su_remote
->sin
.sin_port
));
10557 /* Nexthop display. */
10560 json_object_string_add(json_neigh
, "nexthop",
10562 &p
->nexthop
.v4
, buf1
,
10564 json_object_string_add(json_neigh
, "nexthopGlobal",
10565 inet_ntop(AF_INET6
,
10566 &p
->nexthop
.v6_global
,
10567 buf1
, sizeof(buf1
)));
10568 json_object_string_add(json_neigh
, "nexthopLocal",
10569 inet_ntop(AF_INET6
,
10570 &p
->nexthop
.v6_local
,
10571 buf1
, sizeof(buf1
)));
10572 if (p
->shared_network
)
10573 json_object_string_add(json_neigh
,
10577 json_object_string_add(json_neigh
,
10579 "nonSharedNetwork");
10581 vty_out(vty
, "Nexthop: %s\n",
10582 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10584 vty_out(vty
, "Nexthop global: %s\n",
10585 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10587 vty_out(vty
, "Nexthop local: %s\n",
10588 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10590 vty_out(vty
, "BGP connection: %s\n",
10591 p
->shared_network
? "shared network"
10592 : "non shared network");
10596 /* Timer information. */
10598 json_object_int_add(json_neigh
, "connectRetryTimer",
10600 if (p
->status
== Established
&& p
->rtt
)
10601 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10604 json_object_int_add(
10605 json_neigh
, "nextStartTimerDueInMsecs",
10606 thread_timer_remain_second(p
->t_start
) * 1000);
10608 json_object_int_add(
10609 json_neigh
, "nextConnectTimerDueInMsecs",
10610 thread_timer_remain_second(p
->t_connect
)
10612 if (p
->t_routeadv
) {
10613 json_object_int_add(json_neigh
, "mraiInterval",
10615 json_object_int_add(
10616 json_neigh
, "mraiTimerExpireInMsecs",
10617 thread_timer_remain_second(p
->t_routeadv
)
10621 json_object_int_add(json_neigh
, "authenticationEnabled",
10625 json_object_string_add(json_neigh
, "readThread", "on");
10627 json_object_string_add(json_neigh
, "readThread", "off");
10629 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10630 json_object_string_add(json_neigh
, "writeThread", "on");
10632 json_object_string_add(json_neigh
, "writeThread",
10635 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10637 if (p
->status
== Established
&& p
->rtt
)
10638 vty_out(vty
, "Estimated round trip time: %d ms\n",
10641 vty_out(vty
, "Next start timer due in %ld seconds\n",
10642 thread_timer_remain_second(p
->t_start
));
10644 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10645 thread_timer_remain_second(p
->t_connect
));
10648 "MRAI (interval %u) timer expires in %ld seconds\n",
10650 thread_timer_remain_second(p
->t_routeadv
));
10652 vty_out(vty
, "Peer Authentication Enabled\n");
10654 vty_out(vty
, "Read thread: %s Write thread: %s\n",
10655 p
->t_read
? "on" : "off",
10656 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10661 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10662 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10663 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10666 vty_out(vty
, "\n");
10668 /* BFD information. */
10669 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10672 if (p
->conf_if
) /* Configured interface name. */
10673 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10674 else /* Configured IP address. */
10675 json_object_object_add(json
, p
->host
, json_neigh
);
10679 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10680 enum show_type type
, union sockunion
*su
,
10681 const char *conf_if
, uint8_t use_json
,
10684 struct listnode
*node
, *nnode
;
10688 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10689 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10694 bgp_show_peer(vty
, peer
, use_json
, json
);
10699 && !strcmp(peer
->conf_if
, conf_if
))
10701 && !strcmp(peer
->hostname
, conf_if
))) {
10703 bgp_show_peer(vty
, peer
, use_json
,
10707 if (sockunion_same(&peer
->su
, su
)) {
10709 bgp_show_peer(vty
, peer
, use_json
,
10717 if (type
== show_peer
&& !find
) {
10719 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
10721 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
10725 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10726 json
, JSON_C_TO_STRING_PRETTY
));
10727 json_object_free(json
);
10729 vty_out(vty
, "\n");
10732 return CMD_SUCCESS
;
10735 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
10736 enum show_type type
,
10737 const char *ip_str
,
10740 struct listnode
*node
, *nnode
;
10742 union sockunion su
;
10743 json_object
*json
= NULL
;
10744 int ret
, is_first
= 1;
10747 vty_out(vty
, "{\n");
10749 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
10751 if (!(json
= json_object_new_object())) {
10753 "Unable to allocate memory for JSON object");
10755 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
10759 json_object_int_add(json
, "vrfId",
10760 (bgp
->vrf_id
== VRF_UNKNOWN
)
10762 : (int64_t)bgp
->vrf_id
);
10763 json_object_string_add(
10765 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10770 vty_out(vty
, ",\n");
10774 vty_out(vty
, "\"%s\":",
10775 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10779 vty_out(vty
, "\nInstance %s:\n",
10780 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10785 if (type
== show_peer
) {
10786 ret
= str2sockunion(ip_str
, &su
);
10788 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10791 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10794 bgp_show_neighbor(vty
, bgp
, show_all
, NULL
, NULL
,
10800 vty_out(vty
, "}\n");
10803 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
10804 enum show_type type
, const char *ip_str
,
10809 union sockunion su
;
10810 json_object
*json
= NULL
;
10813 if (strmatch(name
, "all")) {
10814 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
10816 return CMD_SUCCESS
;
10818 bgp
= bgp_lookup_by_name(name
);
10821 json
= json_object_new_object();
10822 json_object_boolean_true_add(
10823 json
, "bgpNoSuchInstance");
10824 vty_out(vty
, "%s\n",
10825 json_object_to_json_string_ext(
10827 JSON_C_TO_STRING_PRETTY
));
10828 json_object_free(json
);
10831 "%% No such BGP instance exist\n");
10833 return CMD_WARNING
;
10837 bgp
= bgp_get_default();
10841 json
= json_object_new_object();
10843 ret
= str2sockunion(ip_str
, &su
);
10845 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10848 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10851 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
10854 json_object_free(json
);
10857 return CMD_SUCCESS
;
10860 /* "show [ip] bgp neighbors" commands. */
10861 DEFUN (show_ip_bgp_neighbors
,
10862 show_ip_bgp_neighbors_cmd
,
10863 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
10867 BGP_INSTANCE_HELP_STR
10870 "Detailed information on TCP and BGP neighbor connections\n"
10871 "Neighbor to display information about\n"
10872 "Neighbor to display information about\n"
10873 "Neighbor on BGP configured interface\n"
10877 char *sh_arg
= NULL
;
10878 enum show_type sh_type
;
10880 uint8_t uj
= use_json(argc
, argv
);
10884 if (argv_find(argv
, argc
, "view", &idx
)
10885 || argv_find(argv
, argc
, "vrf", &idx
))
10886 vrf
= argv
[idx
+ 1]->arg
;
10889 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
10890 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
10891 || argv_find(argv
, argc
, "WORD", &idx
)) {
10892 sh_type
= show_peer
;
10893 sh_arg
= argv
[idx
]->arg
;
10895 sh_type
= show_all
;
10897 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
10900 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
10901 paths' and `show ip mbgp paths'. Those functions results are the
10903 DEFUN (show_ip_bgp_paths
,
10904 show_ip_bgp_paths_cmd
,
10905 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
10910 "Path information\n")
10912 vty_out(vty
, "Address Refcnt Path\n");
10913 aspath_print_all_vty(vty
);
10914 return CMD_SUCCESS
;
10919 static void community_show_all_iterator(struct hash_backet
*backet
,
10922 struct community
*com
;
10924 com
= (struct community
*)backet
->data
;
10925 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
10926 community_str(com
, false));
10929 /* Show BGP's community internal data. */
10930 DEFUN (show_ip_bgp_community_info
,
10931 show_ip_bgp_community_info_cmd
,
10932 "show [ip] bgp community-info",
10936 "List all bgp community information\n")
10938 vty_out(vty
, "Address Refcnt Community\n");
10940 hash_iterate(community_hash(),
10941 (void (*)(struct hash_backet
*,
10942 void *))community_show_all_iterator
,
10945 return CMD_SUCCESS
;
10948 static void lcommunity_show_all_iterator(struct hash_backet
*backet
,
10951 struct lcommunity
*lcom
;
10953 lcom
= (struct lcommunity
*)backet
->data
;
10954 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
10955 lcommunity_str(lcom
, false));
10958 /* Show BGP's community internal data. */
10959 DEFUN (show_ip_bgp_lcommunity_info
,
10960 show_ip_bgp_lcommunity_info_cmd
,
10961 "show ip bgp large-community-info",
10965 "List all bgp large-community information\n")
10967 vty_out(vty
, "Address Refcnt Large-community\n");
10969 hash_iterate(lcommunity_hash(),
10970 (void (*)(struct hash_backet
*,
10971 void *))lcommunity_show_all_iterator
,
10974 return CMD_SUCCESS
;
10978 DEFUN (show_ip_bgp_attr_info
,
10979 show_ip_bgp_attr_info_cmd
,
10980 "show [ip] bgp attribute-info",
10984 "List all bgp attribute information\n")
10986 attr_show_all(vty
);
10987 return CMD_SUCCESS
;
10990 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
10991 afi_t afi
, safi_t safi
)
10994 struct listnode
*node
;
10996 char buf1
[INET6_ADDRSTRLEN
];
10998 vpn_policy_direction_t dir
;
11001 bgp
= bgp_lookup_by_name(name
);
11003 vty_out(vty
, "%% No such BGP instance exist\n");
11004 return CMD_WARNING
;
11007 bgp
= bgp_get_default();
11010 "%% Default BGP instance does not exist\n");
11011 return CMD_WARNING
;
11015 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11016 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11018 "This VRF is not importing %s routes from any other VRF\n",
11019 afi_safi_print(afi
, safi
));
11022 "This VRF is importing %s routes from the following VRFs:\n",
11023 afi_safi_print(afi
, safi
));
11024 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
11026 vty_out(vty
, " %s\n", vname
);
11028 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11029 ecom_str
= ecommunity_ecom2str(
11030 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11031 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11032 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11033 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11036 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11037 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11039 "This VRF is not exporting %s routes to any other VRF\n",
11040 afi_safi_print(afi
, safi
));
11043 "This VRF is exporting %s routes to the following VRFs:\n",
11044 afi_safi_print(afi
, safi
));
11045 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].export_vrf
, node
,
11047 vty_out(vty
, " %s\n", vname
);
11049 vty_out(vty
, "RD: %s\n",
11050 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11051 buf1
, RD_ADDRSTRLEN
));
11052 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11053 ecom_str
= ecommunity_ecom2str(
11054 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11055 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11056 vty_out(vty
, "Emport RT: %s\n", ecom_str
);
11057 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11060 return CMD_SUCCESS
;
11063 /* "show [ip] bgp route-leak" command. */
11064 DEFUN (show_ip_bgp_route_leak
,
11065 show_ip_bgp_route_leak_cmd
,
11066 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak",
11070 BGP_INSTANCE_HELP_STR
11073 "Route leaking information\n")
11076 afi_t afi
= AFI_MAX
;
11077 safi_t safi
= SAFI_MAX
;
11081 /* show [ip] bgp */
11082 if (argv_find(argv
, argc
, "ip", &idx
)) {
11084 safi
= SAFI_UNICAST
;
11086 /* [vrf VIEWVRFNAME] */
11087 if (argv_find(argv
, argc
, "view", &idx
)) {
11089 "%% This command is not applicable to BGP views\n");
11090 return CMD_WARNING
;
11093 if (argv_find(argv
, argc
, "vrf", &idx
))
11094 vrf
= argv
[++idx
]->arg
;
11095 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11096 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11097 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11100 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11102 "%% This command is applicable only for unicast ipv4|ipv6\n");
11103 return CMD_WARNING
;
11106 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
);
11109 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11112 struct listnode
*node
, *nnode
;
11115 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11116 vty_out(vty
, "\nInstance %s:\n",
11117 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11120 update_group_show(bgp
, afi
, safi
, vty
, 0);
11124 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11125 int safi
, uint64_t subgrp_id
)
11130 if (strmatch(name
, "all")) {
11131 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11132 return CMD_SUCCESS
;
11134 bgp
= bgp_lookup_by_name(name
);
11137 bgp
= bgp_get_default();
11141 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11142 return CMD_SUCCESS
;
11145 DEFUN (show_ip_bgp_updgrps
,
11146 show_ip_bgp_updgrps_cmd
,
11147 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11151 BGP_INSTANCE_HELP_STR
11153 BGP_SAFI_WITH_LABEL_HELP_STR
11154 "Detailed info about dynamic update groups\n"
11155 "Specific subgroup to display detailed info for\n")
11158 afi_t afi
= AFI_IP6
;
11159 safi_t safi
= SAFI_UNICAST
;
11160 uint64_t subgrp_id
= 0;
11164 /* show [ip] bgp */
11165 if (argv_find(argv
, argc
, "ip", &idx
))
11167 /* [<view|vrf> VIEWVRFNAME] */
11168 if (argv_find(argv
, argc
, "view", &idx
)
11169 || argv_find(argv
, argc
, "vrf", &idx
))
11170 vrf
= argv
[++idx
]->arg
;
11171 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11172 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11173 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11176 /* get subgroup id, if provided */
11178 if (argv
[idx
]->type
== VARIABLE_TKN
)
11179 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11181 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11184 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11185 show_bgp_instance_all_ipv6_updgrps_cmd
,
11186 "show [ip] bgp <view|vrf> all update-groups",
11190 BGP_INSTANCE_ALL_HELP_STR
11191 "Detailed info about dynamic update groups\n")
11193 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11194 return CMD_SUCCESS
;
11197 DEFUN (show_bgp_updgrps_stats
,
11198 show_bgp_updgrps_stats_cmd
,
11199 "show [ip] bgp update-groups statistics",
11203 "Detailed info about dynamic update groups\n"
11208 bgp
= bgp_get_default();
11210 update_group_show_stats(bgp
, vty
);
11212 return CMD_SUCCESS
;
11215 DEFUN (show_bgp_instance_updgrps_stats
,
11216 show_bgp_instance_updgrps_stats_cmd
,
11217 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11221 BGP_INSTANCE_HELP_STR
11222 "Detailed info about dynamic update groups\n"
11228 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11230 update_group_show_stats(bgp
, vty
);
11232 return CMD_SUCCESS
;
11235 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11236 afi_t afi
, safi_t safi
,
11237 const char *what
, uint64_t subgrp_id
)
11242 bgp
= bgp_lookup_by_name(name
);
11244 bgp
= bgp_get_default();
11247 if (!strcmp(what
, "advertise-queue"))
11248 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11250 else if (!strcmp(what
, "advertised-routes"))
11251 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11253 else if (!strcmp(what
, "packet-queue"))
11254 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11259 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11260 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11261 "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",
11262 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11264 "Detailed info about dynamic update groups\n"
11265 "Specific subgroup to display info for\n"
11266 "Advertisement queue\n"
11267 "Announced routes\n"
11270 uint64_t subgrp_id
= 0;
11274 subgrp_id
= strtoull(sgid
, NULL
, 10);
11279 afiz
= bgp_vty_afi_from_str(afi
);
11283 afiz
= bgp_vty_afi_from_str(afi
);
11284 if (afiz
!= AFI_IP
)
11286 "%% Cannot specify both 'ip' and 'ipv6'\n");
11287 return CMD_WARNING
;
11290 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11292 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11293 return CMD_SUCCESS
;
11296 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11298 struct listnode
*node
, *nnode
;
11299 struct prefix
*range
;
11302 char buf
[PREFIX2STR_BUFFER
];
11305 const char *peer_status
;
11306 const char *af_str
;
11311 conf
= group
->conf
;
11313 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11314 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
11316 } else if (conf
->as_type
== AS_INTERNAL
) {
11317 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
11320 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11323 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11324 vty_out(vty
, " Peer-group type is internal\n");
11326 vty_out(vty
, " Peer-group type is external\n");
11328 /* Display AFs configured. */
11329 vty_out(vty
, " Configured address-families:");
11330 FOREACH_AFI_SAFI (afi
, safi
) {
11331 if (conf
->afc
[afi
][safi
]) {
11333 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11337 vty_out(vty
, " none\n");
11339 vty_out(vty
, "\n");
11341 /* Display listen ranges (for dynamic neighbors), if any */
11342 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11345 else if (afi
== AFI_IP6
)
11349 lr_count
= listcount(group
->listen_range
[afi
]);
11351 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11355 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11357 prefix2str(range
, buf
, sizeof(buf
));
11358 vty_out(vty
, " %s\n", buf
);
11363 /* Display group members and their status */
11364 if (listcount(group
->peer
)) {
11365 vty_out(vty
, " Peer-group members:\n");
11366 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11367 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11368 peer_status
= "Idle (Admin)";
11369 else if (CHECK_FLAG(peer
->sflags
,
11370 PEER_STATUS_PREFIX_OVERFLOW
))
11371 peer_status
= "Idle (PfxCt)";
11373 peer_status
= lookup_msg(bgp_status_msg
,
11374 peer
->status
, NULL
);
11376 dynamic
= peer_dynamic_neighbor(peer
);
11377 vty_out(vty
, " %s %s %s \n", peer
->host
,
11378 dynamic
? "(dynamic)" : "", peer_status
);
11382 return CMD_SUCCESS
;
11385 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11386 const char *group_name
)
11389 struct listnode
*node
, *nnode
;
11390 struct peer_group
*group
;
11391 bool found
= false;
11393 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11396 vty_out(vty
, "%% No such BGP instance exists\n");
11397 return CMD_WARNING
;
11400 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11402 if (strmatch(group
->name
, group_name
)) {
11403 bgp_show_one_peer_group(vty
, group
);
11408 bgp_show_one_peer_group(vty
, group
);
11412 if (group_name
&& !found
)
11413 vty_out(vty
, "%% No such peer-group\n");
11415 return CMD_SUCCESS
;
11418 DEFUN (show_ip_bgp_peer_groups
,
11419 show_ip_bgp_peer_groups_cmd
,
11420 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11424 BGP_INSTANCE_HELP_STR
11425 "Detailed information on BGP peer groups\n"
11426 "Peer group name\n")
11431 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11433 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11435 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11439 /* Redistribute VTY commands. */
11441 DEFUN (bgp_redistribute_ipv4
,
11442 bgp_redistribute_ipv4_cmd
,
11443 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11444 "Redistribute information from another routing protocol\n"
11445 FRR_IP_REDIST_HELP_STR_BGPD
)
11447 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11448 int idx_protocol
= 1;
11451 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11453 vty_out(vty
, "%% Invalid route type\n");
11454 return CMD_WARNING_CONFIG_FAILED
;
11457 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11458 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11462 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11463 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11464 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11466 DEFUN (bgp_redistribute_ipv4_rmap
,
11467 bgp_redistribute_ipv4_rmap_cmd
,
11468 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11469 "Redistribute information from another routing protocol\n"
11470 FRR_IP_REDIST_HELP_STR_BGPD
11471 "Route map reference\n"
11472 "Pointer to route-map entries\n")
11474 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11475 int idx_protocol
= 1;
11478 struct bgp_redist
*red
;
11480 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11482 vty_out(vty
, "%% Invalid route type\n");
11483 return CMD_WARNING_CONFIG_FAILED
;
11486 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11487 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11488 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11492 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
11493 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11494 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11495 "Route map reference\n"
11496 "Pointer to route-map entries\n")
11498 DEFUN (bgp_redistribute_ipv4_metric
,
11499 bgp_redistribute_ipv4_metric_cmd
,
11500 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11501 "Redistribute information from another routing protocol\n"
11502 FRR_IP_REDIST_HELP_STR_BGPD
11503 "Metric for redistributed routes\n"
11504 "Default metric\n")
11506 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11507 int idx_protocol
= 1;
11508 int idx_number
= 3;
11511 struct bgp_redist
*red
;
11513 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11515 vty_out(vty
, "%% Invalid route type\n");
11516 return CMD_WARNING_CONFIG_FAILED
;
11518 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11520 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11521 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11522 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11526 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
11527 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11528 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11529 "Metric for redistributed routes\n"
11530 "Default metric\n")
11532 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
11533 bgp_redistribute_ipv4_rmap_metric_cmd
,
11534 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11535 "Redistribute information from another routing protocol\n"
11536 FRR_IP_REDIST_HELP_STR_BGPD
11537 "Route map reference\n"
11538 "Pointer to route-map entries\n"
11539 "Metric for redistributed routes\n"
11540 "Default metric\n")
11542 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11543 int idx_protocol
= 1;
11545 int idx_number
= 5;
11548 struct bgp_redist
*red
;
11550 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11552 vty_out(vty
, "%% Invalid route type\n");
11553 return CMD_WARNING_CONFIG_FAILED
;
11555 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11557 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11558 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11559 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11560 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11564 bgp_redistribute_ipv4_rmap_metric
,
11565 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
11566 "redistribute " FRR_IP_REDIST_STR_BGPD
11567 " route-map WORD metric (0-4294967295)",
11568 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11569 "Route map reference\n"
11570 "Pointer to route-map entries\n"
11571 "Metric for redistributed routes\n"
11572 "Default metric\n")
11574 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
11575 bgp_redistribute_ipv4_metric_rmap_cmd
,
11576 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
11577 "Redistribute information from another routing protocol\n"
11578 FRR_IP_REDIST_HELP_STR_BGPD
11579 "Metric for redistributed routes\n"
11581 "Route map reference\n"
11582 "Pointer to route-map entries\n")
11584 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11585 int idx_protocol
= 1;
11586 int idx_number
= 3;
11590 struct bgp_redist
*red
;
11592 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11594 vty_out(vty
, "%% Invalid route type\n");
11595 return CMD_WARNING_CONFIG_FAILED
;
11597 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11599 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11600 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11601 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11602 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11606 bgp_redistribute_ipv4_metric_rmap
,
11607 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
11608 "redistribute " FRR_IP_REDIST_STR_BGPD
11609 " metric (0-4294967295) route-map WORD",
11610 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11611 "Metric for redistributed routes\n"
11613 "Route map reference\n"
11614 "Pointer to route-map entries\n")
11616 DEFUN (bgp_redistribute_ipv4_ospf
,
11617 bgp_redistribute_ipv4_ospf_cmd
,
11618 "redistribute <ospf|table> (1-65535)",
11619 "Redistribute information from another routing protocol\n"
11620 "Open Shortest Path First (OSPFv2)\n"
11621 "Non-main Kernel Routing Table\n"
11622 "Instance ID/Table ID\n")
11624 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11625 int idx_ospf_table
= 1;
11626 int idx_number
= 2;
11627 unsigned short instance
;
11628 unsigned short protocol
;
11630 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11632 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11633 protocol
= ZEBRA_ROUTE_OSPF
;
11635 protocol
= ZEBRA_ROUTE_TABLE
;
11637 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11638 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11641 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
11642 "redistribute <ospf|table> (1-65535)",
11643 "Redistribute information from another routing protocol\n"
11644 "Open Shortest Path First (OSPFv2)\n"
11645 "Non-main Kernel Routing Table\n"
11646 "Instance ID/Table ID\n")
11648 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
11649 bgp_redistribute_ipv4_ospf_rmap_cmd
,
11650 "redistribute <ospf|table> (1-65535) route-map WORD",
11651 "Redistribute information from another routing protocol\n"
11652 "Open Shortest Path First (OSPFv2)\n"
11653 "Non-main Kernel Routing Table\n"
11654 "Instance ID/Table ID\n"
11655 "Route map reference\n"
11656 "Pointer to route-map entries\n")
11658 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11659 int idx_ospf_table
= 1;
11660 int idx_number
= 2;
11662 struct bgp_redist
*red
;
11663 unsigned short instance
;
11666 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11667 protocol
= ZEBRA_ROUTE_OSPF
;
11669 protocol
= ZEBRA_ROUTE_TABLE
;
11671 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11672 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11673 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11674 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11677 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
11678 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
11679 "redistribute <ospf|table> (1-65535) route-map WORD",
11680 "Redistribute information from another routing protocol\n"
11681 "Open Shortest Path First (OSPFv2)\n"
11682 "Non-main Kernel Routing Table\n"
11683 "Instance ID/Table ID\n"
11684 "Route map reference\n"
11685 "Pointer to route-map entries\n")
11687 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
11688 bgp_redistribute_ipv4_ospf_metric_cmd
,
11689 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
11690 "Redistribute information from another routing protocol\n"
11691 "Open Shortest Path First (OSPFv2)\n"
11692 "Non-main Kernel Routing Table\n"
11693 "Instance ID/Table ID\n"
11694 "Metric for redistributed routes\n"
11695 "Default metric\n")
11697 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11698 int idx_ospf_table
= 1;
11699 int idx_number
= 2;
11700 int idx_number_2
= 4;
11702 struct bgp_redist
*red
;
11703 unsigned short instance
;
11706 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11707 protocol
= ZEBRA_ROUTE_OSPF
;
11709 protocol
= ZEBRA_ROUTE_TABLE
;
11711 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11712 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11714 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11715 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11716 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11719 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
11720 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
11721 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
11722 "Redistribute information from another routing protocol\n"
11723 "Open Shortest Path First (OSPFv2)\n"
11724 "Non-main Kernel Routing Table\n"
11725 "Instance ID/Table ID\n"
11726 "Metric for redistributed routes\n"
11727 "Default metric\n")
11729 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
11730 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
11731 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
11732 "Redistribute information from another routing protocol\n"
11733 "Open Shortest Path First (OSPFv2)\n"
11734 "Non-main Kernel Routing Table\n"
11735 "Instance ID/Table ID\n"
11736 "Route map reference\n"
11737 "Pointer to route-map entries\n"
11738 "Metric for redistributed routes\n"
11739 "Default metric\n")
11741 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11742 int idx_ospf_table
= 1;
11743 int idx_number
= 2;
11745 int idx_number_2
= 6;
11747 struct bgp_redist
*red
;
11748 unsigned short instance
;
11751 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11752 protocol
= ZEBRA_ROUTE_OSPF
;
11754 protocol
= ZEBRA_ROUTE_TABLE
;
11756 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11757 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11759 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11760 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11761 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11762 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11766 bgp_redistribute_ipv4_ospf_rmap_metric
,
11767 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
11768 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
11769 "Redistribute information from another routing protocol\n"
11770 "Open Shortest Path First (OSPFv2)\n"
11771 "Non-main Kernel Routing Table\n"
11772 "Instance ID/Table ID\n"
11773 "Route map reference\n"
11774 "Pointer to route-map entries\n"
11775 "Metric for redistributed routes\n"
11776 "Default metric\n")
11778 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
11779 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
11780 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
11781 "Redistribute information from another routing protocol\n"
11782 "Open Shortest Path First (OSPFv2)\n"
11783 "Non-main Kernel Routing Table\n"
11784 "Instance ID/Table ID\n"
11785 "Metric for redistributed routes\n"
11787 "Route map reference\n"
11788 "Pointer to route-map entries\n")
11790 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11791 int idx_ospf_table
= 1;
11792 int idx_number
= 2;
11793 int idx_number_2
= 4;
11796 struct bgp_redist
*red
;
11797 unsigned short instance
;
11800 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11801 protocol
= ZEBRA_ROUTE_OSPF
;
11803 protocol
= ZEBRA_ROUTE_TABLE
;
11805 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11806 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11808 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11809 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11810 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11811 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11815 bgp_redistribute_ipv4_ospf_metric_rmap
,
11816 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
11817 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
11818 "Redistribute information from another routing protocol\n"
11819 "Open Shortest Path First (OSPFv2)\n"
11820 "Non-main Kernel Routing Table\n"
11821 "Instance ID/Table ID\n"
11822 "Metric for redistributed routes\n"
11824 "Route map reference\n"
11825 "Pointer to route-map entries\n")
11827 DEFUN (no_bgp_redistribute_ipv4_ospf
,
11828 no_bgp_redistribute_ipv4_ospf_cmd
,
11829 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
11831 "Redistribute information from another routing protocol\n"
11832 "Open Shortest Path First (OSPFv2)\n"
11833 "Non-main Kernel Routing Table\n"
11834 "Instance ID/Table ID\n"
11835 "Metric for redistributed routes\n"
11837 "Route map reference\n"
11838 "Pointer to route-map entries\n")
11840 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11841 int idx_ospf_table
= 2;
11842 int idx_number
= 3;
11843 unsigned short instance
;
11846 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11847 protocol
= ZEBRA_ROUTE_OSPF
;
11849 protocol
= ZEBRA_ROUTE_TABLE
;
11851 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11852 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
11856 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
11857 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
11859 "Redistribute information from another routing protocol\n"
11860 "Open Shortest Path First (OSPFv2)\n"
11861 "Non-main Kernel Routing Table\n"
11862 "Instance ID/Table ID\n"
11863 "Metric for redistributed routes\n"
11865 "Route map reference\n"
11866 "Pointer to route-map entries\n")
11868 DEFUN (no_bgp_redistribute_ipv4
,
11869 no_bgp_redistribute_ipv4_cmd
,
11870 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
11872 "Redistribute information from another routing protocol\n"
11873 FRR_IP_REDIST_HELP_STR_BGPD
11874 "Metric for redistributed routes\n"
11876 "Route map reference\n"
11877 "Pointer to route-map entries\n")
11879 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11880 int idx_protocol
= 2;
11883 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11885 vty_out(vty
, "%% Invalid route type\n");
11886 return CMD_WARNING_CONFIG_FAILED
;
11888 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
11892 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
11893 "no redistribute " FRR_IP_REDIST_STR_BGPD
11894 " [metric (0-4294967295)] [route-map WORD]",
11896 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11897 "Metric for redistributed routes\n"
11899 "Route map reference\n"
11900 "Pointer to route-map entries\n")
11902 DEFUN (bgp_redistribute_ipv6
,
11903 bgp_redistribute_ipv6_cmd
,
11904 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
11905 "Redistribute information from another routing protocol\n"
11906 FRR_IP6_REDIST_HELP_STR_BGPD
)
11908 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11909 int idx_protocol
= 1;
11912 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11914 vty_out(vty
, "%% Invalid route type\n");
11915 return CMD_WARNING_CONFIG_FAILED
;
11918 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11919 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11922 DEFUN (bgp_redistribute_ipv6_rmap
,
11923 bgp_redistribute_ipv6_rmap_cmd
,
11924 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
11925 "Redistribute information from another routing protocol\n"
11926 FRR_IP6_REDIST_HELP_STR_BGPD
11927 "Route map reference\n"
11928 "Pointer to route-map entries\n")
11930 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11931 int idx_protocol
= 1;
11934 struct bgp_redist
*red
;
11936 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11938 vty_out(vty
, "%% Invalid route type\n");
11939 return CMD_WARNING_CONFIG_FAILED
;
11942 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11943 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11944 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11947 DEFUN (bgp_redistribute_ipv6_metric
,
11948 bgp_redistribute_ipv6_metric_cmd
,
11949 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
11950 "Redistribute information from another routing protocol\n"
11951 FRR_IP6_REDIST_HELP_STR_BGPD
11952 "Metric for redistributed routes\n"
11953 "Default metric\n")
11955 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11956 int idx_protocol
= 1;
11957 int idx_number
= 3;
11960 struct bgp_redist
*red
;
11962 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11964 vty_out(vty
, "%% Invalid route type\n");
11965 return CMD_WARNING_CONFIG_FAILED
;
11967 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11969 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11970 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
11971 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11974 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
11975 bgp_redistribute_ipv6_rmap_metric_cmd
,
11976 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11977 "Redistribute information from another routing protocol\n"
11978 FRR_IP6_REDIST_HELP_STR_BGPD
11979 "Route map reference\n"
11980 "Pointer to route-map entries\n"
11981 "Metric for redistributed routes\n"
11982 "Default metric\n")
11984 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11985 int idx_protocol
= 1;
11987 int idx_number
= 5;
11990 struct bgp_redist
*red
;
11992 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11994 vty_out(vty
, "%% Invalid route type\n");
11995 return CMD_WARNING_CONFIG_FAILED
;
11997 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11999 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12000 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
12001 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12002 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
12005 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12006 bgp_redistribute_ipv6_metric_rmap_cmd
,
12007 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12008 "Redistribute information from another routing protocol\n"
12009 FRR_IP6_REDIST_HELP_STR_BGPD
12010 "Metric for redistributed routes\n"
12012 "Route map reference\n"
12013 "Pointer to route-map entries\n")
12015 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12016 int idx_protocol
= 1;
12017 int idx_number
= 3;
12021 struct bgp_redist
*red
;
12023 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12025 vty_out(vty
, "%% Invalid route type\n");
12026 return CMD_WARNING_CONFIG_FAILED
;
12028 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12030 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12031 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
, metric
);
12032 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
12033 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
12036 DEFUN (no_bgp_redistribute_ipv6
,
12037 no_bgp_redistribute_ipv6_cmd
,
12038 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12040 "Redistribute information from another routing protocol\n"
12041 FRR_IP6_REDIST_HELP_STR_BGPD
12042 "Metric for redistributed routes\n"
12044 "Route map reference\n"
12045 "Pointer to route-map entries\n")
12047 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12048 int idx_protocol
= 2;
12051 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12053 vty_out(vty
, "%% Invalid route type\n");
12054 return CMD_WARNING_CONFIG_FAILED
;
12057 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12060 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12065 /* Unicast redistribution only. */
12066 if (safi
!= SAFI_UNICAST
)
12069 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12070 /* Redistribute BGP does not make sense. */
12071 if (i
!= ZEBRA_ROUTE_BGP
) {
12072 struct list
*red_list
;
12073 struct listnode
*node
;
12074 struct bgp_redist
*red
;
12076 red_list
= bgp
->redist
[afi
][i
];
12080 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12081 /* "redistribute" configuration. */
12082 vty_out(vty
, " redistribute %s",
12083 zebra_route_string(i
));
12085 vty_out(vty
, " %d", red
->instance
);
12086 if (red
->redist_metric_flag
)
12087 vty_out(vty
, " metric %u",
12088 red
->redist_metric
);
12089 if (red
->rmap
.name
)
12090 vty_out(vty
, " route-map %s",
12092 vty_out(vty
, "\n");
12098 /* This is part of the address-family block (unicast only) */
12099 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12104 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
])
12105 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12106 bgp
->vpn_policy
[afi
]
12107 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12109 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12110 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12111 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12112 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12115 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12116 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12118 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12121 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12122 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12123 bgp
->vpn_policy
[afi
].tovpn_label
);
12126 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12127 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12128 char buf
[RD_ADDRSTRLEN
];
12129 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12130 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12133 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12134 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12136 char buf
[PREFIX_STRLEN
];
12137 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12138 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12141 vty_out(vty
, "%*snexthop vpn export %s\n",
12145 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12146 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12148 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12149 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12151 char *b
= ecommunity_ecom2str(
12152 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12153 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12154 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12155 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12157 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12158 char *b
= ecommunity_ecom2str(
12159 bgp
->vpn_policy
[afi
]
12160 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12161 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12162 ECOMMUNITY_ROUTE_TARGET
);
12163 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12164 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12166 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12167 char *b
= ecommunity_ecom2str(
12168 bgp
->vpn_policy
[afi
]
12169 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12170 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12171 ECOMMUNITY_ROUTE_TARGET
);
12172 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12173 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12177 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12178 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12179 bgp
->vpn_policy
[afi
]
12180 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12182 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12183 char *b
= ecommunity_ecom2str(
12184 bgp
->vpn_policy
[afi
]
12185 .import_redirect_rtlist
,
12186 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12187 ECOMMUNITY_ROUTE_TARGET
);
12189 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12190 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12195 /* BGP node structure. */
12196 static struct cmd_node bgp_node
= {
12197 BGP_NODE
, "%s(config-router)# ", 1,
12200 static struct cmd_node bgp_ipv4_unicast_node
= {
12201 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12204 static struct cmd_node bgp_ipv4_multicast_node
= {
12205 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12208 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12209 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12212 static struct cmd_node bgp_ipv6_unicast_node
= {
12213 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12216 static struct cmd_node bgp_ipv6_multicast_node
= {
12217 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12220 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12221 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12224 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12225 "%s(config-router-af)# ", 1};
12227 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12228 "%s(config-router-af-vpnv6)# ", 1};
12230 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12231 "%s(config-router-evpn)# ", 1};
12233 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12234 "%s(config-router-af-vni)# ", 1};
12236 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12237 "%s(config-router-af)# ", 1};
12239 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12240 "%s(config-router-af-vpnv6)# ", 1};
12242 static void community_list_vty(void);
12244 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12248 struct listnode
*lnbgp
, *lnpeer
;
12250 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12251 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12252 /* only provide suggestions on the appropriate input
12254 * they'll otherwise show up multiple times */
12255 enum cmd_token_type match_type
;
12256 char *name
= peer
->host
;
12258 if (peer
->conf_if
) {
12259 match_type
= VARIABLE_TKN
;
12260 name
= peer
->conf_if
;
12261 } else if (strchr(peer
->host
, ':'))
12262 match_type
= IPV6_TKN
;
12264 match_type
= IPV4_TKN
;
12266 if (token
->type
!= match_type
)
12269 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12274 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12275 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12276 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12277 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12278 {.completions
= NULL
}};
12280 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12283 struct peer_group
*group
;
12284 struct listnode
*lnbgp
, *lnpeer
;
12286 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12287 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12288 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12293 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12294 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12295 {.completions
= NULL
} };
12297 void bgp_vty_init(void)
12299 cmd_variable_handler_register(bgp_var_neighbor
);
12300 cmd_variable_handler_register(bgp_var_peergroup
);
12302 /* Install bgp top node. */
12303 install_node(&bgp_node
, bgp_config_write
);
12304 install_node(&bgp_ipv4_unicast_node
, NULL
);
12305 install_node(&bgp_ipv4_multicast_node
, NULL
);
12306 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12307 install_node(&bgp_ipv6_unicast_node
, NULL
);
12308 install_node(&bgp_ipv6_multicast_node
, NULL
);
12309 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12310 install_node(&bgp_vpnv4_node
, NULL
);
12311 install_node(&bgp_vpnv6_node
, NULL
);
12312 install_node(&bgp_evpn_node
, NULL
);
12313 install_node(&bgp_evpn_vni_node
, NULL
);
12314 install_node(&bgp_flowspecv4_node
, NULL
);
12315 install_node(&bgp_flowspecv6_node
, NULL
);
12317 /* Install default VTY commands to new nodes. */
12318 install_default(BGP_NODE
);
12319 install_default(BGP_IPV4_NODE
);
12320 install_default(BGP_IPV4M_NODE
);
12321 install_default(BGP_IPV4L_NODE
);
12322 install_default(BGP_IPV6_NODE
);
12323 install_default(BGP_IPV6M_NODE
);
12324 install_default(BGP_IPV6L_NODE
);
12325 install_default(BGP_VPNV4_NODE
);
12326 install_default(BGP_VPNV6_NODE
);
12327 install_default(BGP_FLOWSPECV4_NODE
);
12328 install_default(BGP_FLOWSPECV6_NODE
);
12329 install_default(BGP_EVPN_NODE
);
12330 install_default(BGP_EVPN_VNI_NODE
);
12332 /* "bgp multiple-instance" commands. */
12333 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
12334 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
12336 /* "bgp config-type" commands. */
12337 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
12338 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
12340 /* bgp route-map delay-timer commands. */
12341 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12342 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12344 /* Dummy commands (Currently not supported) */
12345 install_element(BGP_NODE
, &no_synchronization_cmd
);
12346 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12348 /* "router bgp" commands. */
12349 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12351 /* "no router bgp" commands. */
12352 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12354 /* "bgp router-id" commands. */
12355 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12356 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12358 /* "bgp cluster-id" commands. */
12359 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12360 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12362 /* "bgp confederation" commands. */
12363 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12364 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12366 /* "bgp confederation peers" commands. */
12367 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12368 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12370 /* bgp max-med command */
12371 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12372 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12373 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12374 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12375 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12377 /* bgp disable-ebgp-connected-nh-check */
12378 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12379 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12381 /* bgp update-delay command */
12382 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12383 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12384 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12386 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12387 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12388 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12389 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12391 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12392 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12394 /* "maximum-paths" commands. */
12395 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12396 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12397 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12398 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12399 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12400 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12401 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12402 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12403 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12404 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12405 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12406 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12407 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12408 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12409 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12411 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12412 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12413 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12414 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12415 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12417 /* "timers bgp" commands. */
12418 install_element(BGP_NODE
, &bgp_timers_cmd
);
12419 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12421 /* route-map delay-timer commands - per instance for backwards compat.
12423 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12424 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12426 /* "bgp client-to-client reflection" commands */
12427 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
12428 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
12430 /* "bgp always-compare-med" commands */
12431 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
12432 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
12434 /* "bgp deterministic-med" commands */
12435 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
12436 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
12438 /* "bgp graceful-restart" commands */
12439 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
12440 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
12441 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
12442 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
12443 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
12444 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
12446 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
12447 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
12449 /* "bgp graceful-shutdown" commands */
12450 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
12451 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
12453 /* "bgp fast-external-failover" commands */
12454 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
12455 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
12457 /* "bgp enforce-first-as" commands */
12458 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
12460 /* "bgp bestpath compare-routerid" commands */
12461 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
12462 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
12464 /* "bgp bestpath as-path ignore" commands */
12465 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
12466 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
12468 /* "bgp bestpath as-path confed" commands */
12469 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
12470 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
12472 /* "bgp bestpath as-path multipath-relax" commands */
12473 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
12474 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
12476 /* "bgp log-neighbor-changes" commands */
12477 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
12478 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
12480 /* "bgp bestpath med" commands */
12481 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
12482 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
12484 /* "no bgp default ipv4-unicast" commands. */
12485 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
12486 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
12488 /* "bgp network import-check" commands. */
12489 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
12490 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
12491 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
12493 /* "bgp default local-preference" commands. */
12494 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
12495 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
12497 /* bgp default show-hostname */
12498 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
12499 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
12501 /* "bgp default subgroup-pkt-queue-max" commands. */
12502 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
12503 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
12505 /* bgp ibgp-allow-policy-mods command */
12506 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
12507 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
12509 /* "bgp listen limit" commands. */
12510 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
12511 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
12513 /* "bgp listen range" commands. */
12514 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
12515 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
12517 /* "bgp default shutdown" command */
12518 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
12520 /* "neighbor remote-as" commands. */
12521 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
12522 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
12523 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
12524 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
12525 install_element(BGP_NODE
,
12526 &neighbor_interface_v6only_config_remote_as_cmd
);
12527 install_element(BGP_NODE
, &no_neighbor_cmd
);
12528 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
12530 /* "neighbor peer-group" commands. */
12531 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
12532 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
12533 install_element(BGP_NODE
,
12534 &no_neighbor_interface_peer_group_remote_as_cmd
);
12536 /* "neighbor local-as" commands. */
12537 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
12538 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
12539 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
12540 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
12542 /* "neighbor solo" commands. */
12543 install_element(BGP_NODE
, &neighbor_solo_cmd
);
12544 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
12546 /* "neighbor password" commands. */
12547 install_element(BGP_NODE
, &neighbor_password_cmd
);
12548 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
12550 /* "neighbor activate" commands. */
12551 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
12552 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
12553 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
12554 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
12555 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
12556 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
12557 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
12558 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
12559 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
12560 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
12561 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
12562 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
12564 /* "no neighbor activate" commands. */
12565 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
12566 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
12567 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
12568 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
12569 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
12570 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
12571 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
12572 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
12573 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
12574 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
12575 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
12576 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
12578 /* "neighbor peer-group" set commands. */
12579 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
12580 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12581 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12582 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12583 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12584 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12585 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12586 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12587 install_element(BGP_FLOWSPECV4_NODE
,
12588 &neighbor_set_peer_group_hidden_cmd
);
12589 install_element(BGP_FLOWSPECV6_NODE
,
12590 &neighbor_set_peer_group_hidden_cmd
);
12592 /* "no neighbor peer-group unset" commands. */
12593 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
12594 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12595 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12596 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12597 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12598 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12599 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12600 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12601 install_element(BGP_FLOWSPECV4_NODE
,
12602 &no_neighbor_set_peer_group_hidden_cmd
);
12603 install_element(BGP_FLOWSPECV6_NODE
,
12604 &no_neighbor_set_peer_group_hidden_cmd
);
12606 /* "neighbor softreconfiguration inbound" commands.*/
12607 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
12608 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
12609 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12610 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12611 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12612 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12613 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12614 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12615 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12616 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12617 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12618 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12619 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12620 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12621 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12622 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12623 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12624 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12625 install_element(BGP_FLOWSPECV4_NODE
,
12626 &neighbor_soft_reconfiguration_cmd
);
12627 install_element(BGP_FLOWSPECV4_NODE
,
12628 &no_neighbor_soft_reconfiguration_cmd
);
12629 install_element(BGP_FLOWSPECV6_NODE
,
12630 &neighbor_soft_reconfiguration_cmd
);
12631 install_element(BGP_FLOWSPECV6_NODE
,
12632 &no_neighbor_soft_reconfiguration_cmd
);
12634 /* "neighbor attribute-unchanged" commands. */
12635 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
12636 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
12637 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
12638 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
12639 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
12640 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
12641 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
12642 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
12643 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
12644 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
12645 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
12646 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
12647 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
12648 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
12649 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
12650 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
12651 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
12652 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
12654 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
12655 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
12657 /* "nexthop-local unchanged" commands */
12658 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
12659 install_element(BGP_IPV6_NODE
,
12660 &no_neighbor_nexthop_local_unchanged_cmd
);
12662 /* "neighbor next-hop-self" commands. */
12663 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
12664 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
12665 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
12666 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
12667 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
12668 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
12669 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
12670 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
12671 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
12672 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
12673 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
12674 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
12675 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
12676 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
12677 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
12678 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
12679 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
12680 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
12681 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
12682 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
12684 /* "neighbor next-hop-self force" commands. */
12685 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
12686 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
12687 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
12688 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12689 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
12690 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12691 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
12692 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12693 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
12694 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12695 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
12696 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12697 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
12698 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12699 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
12700 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12701 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
12702 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12704 /* "neighbor as-override" commands. */
12705 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
12706 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
12707 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
12708 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
12709 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
12710 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
12711 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
12712 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
12713 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
12714 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
12715 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
12716 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
12717 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
12718 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
12719 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
12720 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
12721 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
12722 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
12724 /* "neighbor remove-private-AS" commands. */
12725 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
12726 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
12727 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
12728 install_element(BGP_NODE
,
12729 &no_neighbor_remove_private_as_all_hidden_cmd
);
12730 install_element(BGP_NODE
,
12731 &neighbor_remove_private_as_replace_as_hidden_cmd
);
12732 install_element(BGP_NODE
,
12733 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
12734 install_element(BGP_NODE
,
12735 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
12738 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
12739 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
12740 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
12741 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
12742 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12743 install_element(BGP_IPV4_NODE
,
12744 &neighbor_remove_private_as_replace_as_cmd
);
12745 install_element(BGP_IPV4_NODE
,
12746 &no_neighbor_remove_private_as_replace_as_cmd
);
12747 install_element(BGP_IPV4_NODE
,
12748 &neighbor_remove_private_as_all_replace_as_cmd
);
12749 install_element(BGP_IPV4_NODE
,
12750 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12751 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
12752 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
12753 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
12754 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12755 install_element(BGP_IPV4M_NODE
,
12756 &neighbor_remove_private_as_replace_as_cmd
);
12757 install_element(BGP_IPV4M_NODE
,
12758 &no_neighbor_remove_private_as_replace_as_cmd
);
12759 install_element(BGP_IPV4M_NODE
,
12760 &neighbor_remove_private_as_all_replace_as_cmd
);
12761 install_element(BGP_IPV4M_NODE
,
12762 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12763 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
12764 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
12765 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
12766 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12767 install_element(BGP_IPV4L_NODE
,
12768 &neighbor_remove_private_as_replace_as_cmd
);
12769 install_element(BGP_IPV4L_NODE
,
12770 &no_neighbor_remove_private_as_replace_as_cmd
);
12771 install_element(BGP_IPV4L_NODE
,
12772 &neighbor_remove_private_as_all_replace_as_cmd
);
12773 install_element(BGP_IPV4L_NODE
,
12774 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12775 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
12776 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
12777 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
12778 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12779 install_element(BGP_IPV6_NODE
,
12780 &neighbor_remove_private_as_replace_as_cmd
);
12781 install_element(BGP_IPV6_NODE
,
12782 &no_neighbor_remove_private_as_replace_as_cmd
);
12783 install_element(BGP_IPV6_NODE
,
12784 &neighbor_remove_private_as_all_replace_as_cmd
);
12785 install_element(BGP_IPV6_NODE
,
12786 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12787 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
12788 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
12789 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
12790 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12791 install_element(BGP_IPV6M_NODE
,
12792 &neighbor_remove_private_as_replace_as_cmd
);
12793 install_element(BGP_IPV6M_NODE
,
12794 &no_neighbor_remove_private_as_replace_as_cmd
);
12795 install_element(BGP_IPV6M_NODE
,
12796 &neighbor_remove_private_as_all_replace_as_cmd
);
12797 install_element(BGP_IPV6M_NODE
,
12798 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12799 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
12800 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
12801 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
12802 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12803 install_element(BGP_IPV6L_NODE
,
12804 &neighbor_remove_private_as_replace_as_cmd
);
12805 install_element(BGP_IPV6L_NODE
,
12806 &no_neighbor_remove_private_as_replace_as_cmd
);
12807 install_element(BGP_IPV6L_NODE
,
12808 &neighbor_remove_private_as_all_replace_as_cmd
);
12809 install_element(BGP_IPV6L_NODE
,
12810 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12811 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
12812 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
12813 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
12814 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12815 install_element(BGP_VPNV4_NODE
,
12816 &neighbor_remove_private_as_replace_as_cmd
);
12817 install_element(BGP_VPNV4_NODE
,
12818 &no_neighbor_remove_private_as_replace_as_cmd
);
12819 install_element(BGP_VPNV4_NODE
,
12820 &neighbor_remove_private_as_all_replace_as_cmd
);
12821 install_element(BGP_VPNV4_NODE
,
12822 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12823 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
12824 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
12825 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
12826 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12827 install_element(BGP_VPNV6_NODE
,
12828 &neighbor_remove_private_as_replace_as_cmd
);
12829 install_element(BGP_VPNV6_NODE
,
12830 &no_neighbor_remove_private_as_replace_as_cmd
);
12831 install_element(BGP_VPNV6_NODE
,
12832 &neighbor_remove_private_as_all_replace_as_cmd
);
12833 install_element(BGP_VPNV6_NODE
,
12834 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12836 /* "neighbor send-community" commands.*/
12837 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
12838 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
12839 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
12840 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
12841 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
12842 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
12843 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
12844 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
12845 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
12846 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
12847 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
12848 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
12849 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
12850 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
12851 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
12852 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
12853 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
12854 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
12855 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
12856 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
12857 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
12858 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
12859 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
12860 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
12861 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
12862 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
12863 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
12864 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
12865 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
12866 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
12867 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
12868 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
12869 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
12870 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
12871 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
12872 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
12874 /* "neighbor route-reflector" commands.*/
12875 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
12876 install_element(BGP_NODE
,
12877 &no_neighbor_route_reflector_client_hidden_cmd
);
12878 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
12879 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
12880 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
12881 install_element(BGP_IPV4M_NODE
,
12882 &no_neighbor_route_reflector_client_cmd
);
12883 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
12884 install_element(BGP_IPV4L_NODE
,
12885 &no_neighbor_route_reflector_client_cmd
);
12886 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
12887 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
12888 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
12889 install_element(BGP_IPV6M_NODE
,
12890 &no_neighbor_route_reflector_client_cmd
);
12891 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
12892 install_element(BGP_IPV6L_NODE
,
12893 &no_neighbor_route_reflector_client_cmd
);
12894 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
12895 install_element(BGP_VPNV4_NODE
,
12896 &no_neighbor_route_reflector_client_cmd
);
12897 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
12898 install_element(BGP_VPNV6_NODE
,
12899 &no_neighbor_route_reflector_client_cmd
);
12900 install_element(BGP_FLOWSPECV4_NODE
,
12901 &neighbor_route_reflector_client_cmd
);
12902 install_element(BGP_FLOWSPECV4_NODE
,
12903 &no_neighbor_route_reflector_client_cmd
);
12904 install_element(BGP_FLOWSPECV6_NODE
,
12905 &neighbor_route_reflector_client_cmd
);
12906 install_element(BGP_FLOWSPECV6_NODE
,
12907 &no_neighbor_route_reflector_client_cmd
);
12908 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
12909 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
12911 /* "neighbor route-server" commands.*/
12912 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
12913 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
12914 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
12915 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
12916 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
12917 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
12918 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
12919 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
12920 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
12921 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
12922 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
12923 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
12924 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
12925 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
12926 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
12927 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
12928 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
12929 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
12930 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
12931 install_element(BGP_FLOWSPECV4_NODE
,
12932 &no_neighbor_route_server_client_cmd
);
12933 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
12934 install_element(BGP_FLOWSPECV6_NODE
,
12935 &no_neighbor_route_server_client_cmd
);
12937 /* "neighbor addpath-tx-all-paths" commands.*/
12938 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
12939 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
12940 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12941 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12942 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12943 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12944 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12945 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12946 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12947 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12948 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12949 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12950 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12951 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12952 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12953 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12954 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12955 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12957 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
12958 install_element(BGP_NODE
,
12959 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
12960 install_element(BGP_NODE
,
12961 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
12962 install_element(BGP_IPV4_NODE
,
12963 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12964 install_element(BGP_IPV4_NODE
,
12965 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12966 install_element(BGP_IPV4M_NODE
,
12967 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12968 install_element(BGP_IPV4M_NODE
,
12969 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12970 install_element(BGP_IPV4L_NODE
,
12971 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12972 install_element(BGP_IPV4L_NODE
,
12973 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12974 install_element(BGP_IPV6_NODE
,
12975 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12976 install_element(BGP_IPV6_NODE
,
12977 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12978 install_element(BGP_IPV6M_NODE
,
12979 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12980 install_element(BGP_IPV6M_NODE
,
12981 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12982 install_element(BGP_IPV6L_NODE
,
12983 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12984 install_element(BGP_IPV6L_NODE
,
12985 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12986 install_element(BGP_VPNV4_NODE
,
12987 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12988 install_element(BGP_VPNV4_NODE
,
12989 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12990 install_element(BGP_VPNV6_NODE
,
12991 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12992 install_element(BGP_VPNV6_NODE
,
12993 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12995 /* "neighbor passive" commands. */
12996 install_element(BGP_NODE
, &neighbor_passive_cmd
);
12997 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13000 /* "neighbor shutdown" commands. */
13001 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13002 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13003 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13004 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13006 /* "neighbor capability extended-nexthop" commands.*/
13007 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13008 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13010 /* "neighbor capability orf prefix-list" commands.*/
13011 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13012 install_element(BGP_NODE
,
13013 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13014 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13015 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13016 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13017 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13018 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13019 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13020 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13021 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13022 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13023 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13024 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13025 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13027 /* "neighbor capability dynamic" commands.*/
13028 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13029 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13031 /* "neighbor dont-capability-negotiate" commands. */
13032 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13033 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13035 /* "neighbor ebgp-multihop" commands. */
13036 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13037 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13038 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13040 /* "neighbor disable-connected-check" commands. */
13041 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13042 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13044 /* "neighbor enforce-first-as" commands. */
13045 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13046 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13048 /* "neighbor description" commands. */
13049 install_element(BGP_NODE
, &neighbor_description_cmd
);
13050 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13051 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13053 /* "neighbor update-source" commands. "*/
13054 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13055 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13057 /* "neighbor default-originate" commands. */
13058 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13059 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13060 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13061 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13062 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13063 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13064 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13065 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13066 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13067 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13068 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13069 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13070 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13071 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13072 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13073 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13074 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13075 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13076 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13077 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13078 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13080 /* "neighbor port" commands. */
13081 install_element(BGP_NODE
, &neighbor_port_cmd
);
13082 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13084 /* "neighbor weight" commands. */
13085 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13086 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13088 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13089 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13090 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13091 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13092 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13093 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13094 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13095 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13096 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13097 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13098 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13099 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13100 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13101 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13102 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13103 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13105 /* "neighbor override-capability" commands. */
13106 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13107 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13109 /* "neighbor strict-capability-match" commands. */
13110 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13111 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13113 /* "neighbor timers" commands. */
13114 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13115 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13117 /* "neighbor timers connect" commands. */
13118 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13119 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13121 /* "neighbor advertisement-interval" commands. */
13122 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13123 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13125 /* "neighbor interface" commands. */
13126 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13127 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13129 /* "neighbor distribute" commands. */
13130 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13131 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13132 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13133 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13134 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13135 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13136 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13137 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13138 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13139 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13140 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13141 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13142 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13143 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13144 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13145 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13146 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13147 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13149 /* "neighbor prefix-list" commands. */
13150 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13151 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13152 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13153 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13154 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13155 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13156 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13157 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13158 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13159 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13160 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13161 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13162 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13163 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13164 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13165 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13166 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13167 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13168 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13169 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13170 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13171 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13173 /* "neighbor filter-list" commands. */
13174 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13175 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13176 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13177 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13178 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13179 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13180 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13181 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13182 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13183 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13184 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13185 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13186 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13187 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13188 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13189 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13190 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13191 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13192 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13193 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13194 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13195 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13197 /* "neighbor route-map" commands. */
13198 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13199 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13200 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13201 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13202 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13203 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13204 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13205 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13206 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13207 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13208 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13209 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13210 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13211 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13212 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13213 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13214 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13215 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13216 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13217 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13218 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13219 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13220 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13221 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13223 /* "neighbor unsuppress-map" commands. */
13224 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13225 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13226 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13227 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13228 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13229 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13230 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13231 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13232 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13233 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13234 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13235 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13236 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13237 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13238 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13239 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13240 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13241 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13243 /* "neighbor maximum-prefix" commands. */
13244 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13245 install_element(BGP_NODE
,
13246 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13247 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13248 install_element(BGP_NODE
,
13249 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13250 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13251 install_element(BGP_NODE
,
13252 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13253 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13254 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13255 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13256 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13257 install_element(BGP_IPV4_NODE
,
13258 &neighbor_maximum_prefix_threshold_warning_cmd
);
13259 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13260 install_element(BGP_IPV4_NODE
,
13261 &neighbor_maximum_prefix_threshold_restart_cmd
);
13262 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13263 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13264 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13265 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13266 install_element(BGP_IPV4M_NODE
,
13267 &neighbor_maximum_prefix_threshold_warning_cmd
);
13268 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13269 install_element(BGP_IPV4M_NODE
,
13270 &neighbor_maximum_prefix_threshold_restart_cmd
);
13271 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13272 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13273 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13274 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13275 install_element(BGP_IPV4L_NODE
,
13276 &neighbor_maximum_prefix_threshold_warning_cmd
);
13277 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13278 install_element(BGP_IPV4L_NODE
,
13279 &neighbor_maximum_prefix_threshold_restart_cmd
);
13280 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13281 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13282 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13283 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13284 install_element(BGP_IPV6_NODE
,
13285 &neighbor_maximum_prefix_threshold_warning_cmd
);
13286 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13287 install_element(BGP_IPV6_NODE
,
13288 &neighbor_maximum_prefix_threshold_restart_cmd
);
13289 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13290 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13291 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13292 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13293 install_element(BGP_IPV6M_NODE
,
13294 &neighbor_maximum_prefix_threshold_warning_cmd
);
13295 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13296 install_element(BGP_IPV6M_NODE
,
13297 &neighbor_maximum_prefix_threshold_restart_cmd
);
13298 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13299 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13300 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13301 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13302 install_element(BGP_IPV6L_NODE
,
13303 &neighbor_maximum_prefix_threshold_warning_cmd
);
13304 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13305 install_element(BGP_IPV6L_NODE
,
13306 &neighbor_maximum_prefix_threshold_restart_cmd
);
13307 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13308 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13309 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13310 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13311 install_element(BGP_VPNV4_NODE
,
13312 &neighbor_maximum_prefix_threshold_warning_cmd
);
13313 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13314 install_element(BGP_VPNV4_NODE
,
13315 &neighbor_maximum_prefix_threshold_restart_cmd
);
13316 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13317 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13318 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13319 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13320 install_element(BGP_VPNV6_NODE
,
13321 &neighbor_maximum_prefix_threshold_warning_cmd
);
13322 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13323 install_element(BGP_VPNV6_NODE
,
13324 &neighbor_maximum_prefix_threshold_restart_cmd
);
13325 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13327 /* "neighbor allowas-in" */
13328 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13329 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13330 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13331 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13332 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13333 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13334 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13335 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13336 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13337 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13338 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13339 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13340 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13341 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13342 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13343 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13344 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13345 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13346 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13347 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13349 /* address-family commands. */
13350 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13351 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13352 #ifdef KEEP_OLD_VPN_COMMANDS
13353 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13354 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13355 #endif /* KEEP_OLD_VPN_COMMANDS */
13357 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13359 /* "exit-address-family" command. */
13360 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13361 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13362 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13363 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13364 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13365 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13366 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13367 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13368 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13369 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13370 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13372 /* "clear ip bgp commands" */
13373 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13375 /* clear ip bgp prefix */
13376 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13377 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13378 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13380 /* "show [ip] bgp summary" commands. */
13381 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13382 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13383 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13384 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13385 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13386 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
13388 /* "show [ip] bgp neighbors" commands. */
13389 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
13391 /* "show [ip] bgp peer-group" commands. */
13392 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
13394 /* "show [ip] bgp paths" commands. */
13395 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
13397 /* "show [ip] bgp community" commands. */
13398 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
13400 /* "show ip bgp large-community" commands. */
13401 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
13402 /* "show [ip] bgp attribute-info" commands. */
13403 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
13404 /* "show [ip] bgp route-leak" command */
13405 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
13407 /* "redistribute" commands. */
13408 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
13409 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
13410 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
13411 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
13412 install_element(BGP_NODE
,
13413 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
13414 install_element(BGP_NODE
,
13415 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
13416 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
13417 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
13418 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
13419 install_element(BGP_NODE
,
13420 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
13421 install_element(BGP_NODE
,
13422 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
13423 install_element(BGP_NODE
,
13424 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
13425 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
13426 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
13427 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
13428 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
13429 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
13430 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
13431 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
13432 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
13433 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
13434 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
13435 install_element(BGP_IPV4_NODE
,
13436 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
13437 install_element(BGP_IPV4_NODE
,
13438 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
13439 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
13440 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
13441 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
13442 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
13443 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
13444 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
13446 /* import|export vpn [route-map WORD] */
13447 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
13448 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
13450 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
13451 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
13453 /* ttl_security commands */
13454 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
13455 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
13457 /* "show [ip] bgp memory" commands. */
13458 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
13460 /* "show bgp martian next-hop" */
13461 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
13463 /* "show [ip] bgp views" commands. */
13464 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
13466 /* "show [ip] bgp vrfs" commands. */
13467 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
13469 /* Community-list. */
13470 community_list_vty();
13472 /* vpn-policy commands */
13473 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
13474 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
13475 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
13476 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
13477 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
13478 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
13479 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
13480 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
13481 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
13482 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
13483 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
13484 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
13486 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
13487 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
13489 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
13490 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
13491 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
13492 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
13493 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
13494 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
13495 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
13496 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
13497 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13498 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13499 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
13500 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
13503 #include "memory.h"
13504 #include "bgp_regex.h"
13505 #include "bgp_clist.h"
13506 #include "bgp_ecommunity.h"
13508 /* VTY functions. */
13510 /* Direction value to string conversion. */
13511 static const char *community_direct_str(int direct
)
13514 case COMMUNITY_DENY
:
13516 case COMMUNITY_PERMIT
:
13523 /* Display error string. */
13524 static void community_list_perror(struct vty
*vty
, int ret
)
13527 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
13528 vty_out(vty
, "%% Can't find community-list\n");
13530 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
13531 vty_out(vty
, "%% Malformed community-list value\n");
13533 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
13535 "%% Community name conflict, previously defined as standard community\n");
13537 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
13539 "%% Community name conflict, previously defined as expanded community\n");
13544 /* "community-list" keyword help string. */
13545 #define COMMUNITY_LIST_STR "Add a community list entry\n"
13547 /* ip community-list standard */
13548 DEFUN (ip_community_list_standard
,
13549 ip_community_list_standard_cmd
,
13550 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13553 "Community list number (standard)\n"
13554 "Add an standard community-list entry\n"
13555 "Community list name\n"
13556 "Specify community to reject\n"
13557 "Specify community to accept\n"
13560 char *cl_name_or_number
= NULL
;
13562 int style
= COMMUNITY_LIST_STANDARD
;
13565 argv_find(argv
, argc
, "(1-99)", &idx
);
13566 argv_find(argv
, argc
, "WORD", &idx
);
13567 cl_name_or_number
= argv
[idx
]->arg
;
13568 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13570 argv_find(argv
, argc
, "AA:NN", &idx
);
13571 char *str
= argv_concat(argv
, argc
, idx
);
13573 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
13576 XFREE(MTYPE_TMP
, str
);
13579 /* Display error string. */
13580 community_list_perror(vty
, ret
);
13581 return CMD_WARNING_CONFIG_FAILED
;
13584 return CMD_SUCCESS
;
13587 DEFUN (no_ip_community_list_standard_all
,
13588 no_ip_community_list_standard_all_cmd
,
13589 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13593 "Community list number (standard)\n"
13594 "Add an standard community-list entry\n"
13595 "Community list name\n"
13596 "Specify community to reject\n"
13597 "Specify community to accept\n"
13600 char *cl_name_or_number
= NULL
;
13602 int style
= COMMUNITY_LIST_STANDARD
;
13605 argv_find(argv
, argc
, "(1-99)", &idx
);
13606 argv_find(argv
, argc
, "WORD", &idx
);
13607 cl_name_or_number
= argv
[idx
]->arg
;
13608 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13610 argv_find(argv
, argc
, "AA:NN", &idx
);
13611 char *str
= argv_concat(argv
, argc
, idx
);
13613 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
13616 XFREE(MTYPE_TMP
, str
);
13619 community_list_perror(vty
, ret
);
13620 return CMD_WARNING_CONFIG_FAILED
;
13623 return CMD_SUCCESS
;
13626 /* ip community-list expanded */
13627 DEFUN (ip_community_list_expanded_all
,
13628 ip_community_list_expanded_all_cmd
,
13629 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13632 "Community list number (expanded)\n"
13633 "Add an expanded community-list entry\n"
13634 "Community list name\n"
13635 "Specify community to reject\n"
13636 "Specify community to accept\n"
13639 char *cl_name_or_number
= NULL
;
13641 int style
= COMMUNITY_LIST_EXPANDED
;
13644 argv_find(argv
, argc
, "(100-500)", &idx
);
13645 argv_find(argv
, argc
, "WORD", &idx
);
13646 cl_name_or_number
= argv
[idx
]->arg
;
13647 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13649 argv_find(argv
, argc
, "AA:NN", &idx
);
13650 char *str
= argv_concat(argv
, argc
, idx
);
13652 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
13655 XFREE(MTYPE_TMP
, str
);
13658 /* Display error string. */
13659 community_list_perror(vty
, ret
);
13660 return CMD_WARNING_CONFIG_FAILED
;
13663 return CMD_SUCCESS
;
13666 DEFUN (no_ip_community_list_expanded_all
,
13667 no_ip_community_list_expanded_all_cmd
,
13668 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13672 "Community list number (expanded)\n"
13673 "Add an expanded community-list entry\n"
13674 "Community list name\n"
13675 "Specify community to reject\n"
13676 "Specify community to accept\n"
13679 char *cl_name_or_number
= NULL
;
13681 int style
= COMMUNITY_LIST_EXPANDED
;
13684 argv_find(argv
, argc
, "(100-500)", &idx
);
13685 argv_find(argv
, argc
, "WORD", &idx
);
13686 cl_name_or_number
= argv
[idx
]->arg
;
13687 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13689 argv_find(argv
, argc
, "AA:NN", &idx
);
13690 char *str
= argv_concat(argv
, argc
, idx
);
13692 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
13695 XFREE(MTYPE_TMP
, str
);
13698 community_list_perror(vty
, ret
);
13699 return CMD_WARNING_CONFIG_FAILED
;
13702 return CMD_SUCCESS
;
13705 /* Return configuration string of community-list entry. */
13706 static const char *community_list_config_str(struct community_entry
*entry
)
13713 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
13714 str
= community_str(entry
->u
.com
, false);
13715 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
13716 str
= lcommunity_str(entry
->u
.lcom
, false);
13718 str
= entry
->config
;
13723 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
13725 struct community_entry
*entry
;
13727 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13728 if (entry
== list
->head
) {
13729 if (all_digit(list
->name
))
13730 vty_out(vty
, "Community %s list %s\n",
13731 entry
->style
== COMMUNITY_LIST_STANDARD
13733 : "(expanded) access",
13736 vty_out(vty
, "Named Community %s list %s\n",
13737 entry
->style
== COMMUNITY_LIST_STANDARD
13743 vty_out(vty
, " %s\n",
13744 community_direct_str(entry
->direct
));
13746 vty_out(vty
, " %s %s\n",
13747 community_direct_str(entry
->direct
),
13748 community_list_config_str(entry
));
13752 DEFUN (show_ip_community_list
,
13753 show_ip_community_list_cmd
,
13754 "show ip community-list",
13757 "List community-list\n")
13759 struct community_list
*list
;
13760 struct community_list_master
*cm
;
13762 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
13764 return CMD_SUCCESS
;
13766 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13767 community_list_show(vty
, list
);
13769 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13770 community_list_show(vty
, list
);
13772 return CMD_SUCCESS
;
13775 DEFUN (show_ip_community_list_arg
,
13776 show_ip_community_list_arg_cmd
,
13777 "show ip community-list <(1-500)|WORD>",
13780 "List community-list\n"
13781 "Community-list number\n"
13782 "Community-list name\n")
13784 int idx_comm_list
= 3;
13785 struct community_list
*list
;
13787 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
13788 COMMUNITY_LIST_MASTER
);
13790 vty_out(vty
, "%% Can't find community-list\n");
13791 return CMD_WARNING
;
13794 community_list_show(vty
, list
);
13796 return CMD_SUCCESS
;
13800 * Large Community code.
13802 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
13803 struct cmd_token
**argv
, int style
,
13804 int reject_all_digit_name
)
13812 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13815 /* All digit name check. */
13817 argv_find(argv
, argc
, "WORD", &idx
);
13818 argv_find(argv
, argc
, "(1-99)", &idx
);
13819 argv_find(argv
, argc
, "(100-500)", &idx
);
13820 cl_name
= argv
[idx
]->arg
;
13821 if (reject_all_digit_name
&& all_digit(cl_name
)) {
13822 vty_out(vty
, "%% Community name cannot have all digits\n");
13823 return CMD_WARNING_CONFIG_FAILED
;
13827 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
13828 argv_find(argv
, argc
, "LINE", &idx
);
13829 /* Concat community string argument. */
13831 str
= argv_concat(argv
, argc
, idx
);
13835 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
13837 /* Free temporary community list string allocated by
13840 XFREE(MTYPE_TMP
, str
);
13843 community_list_perror(vty
, ret
);
13844 return CMD_WARNING_CONFIG_FAILED
;
13846 return CMD_SUCCESS
;
13849 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
13850 struct cmd_token
**argv
, int style
)
13857 argv_find(argv
, argc
, "permit", &idx
);
13858 argv_find(argv
, argc
, "deny", &idx
);
13861 /* Check the list direct. */
13862 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
13863 direct
= COMMUNITY_PERMIT
;
13865 direct
= COMMUNITY_DENY
;
13868 argv_find(argv
, argc
, "LINE", &idx
);
13869 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
13870 /* Concat community string argument. */
13871 str
= argv_concat(argv
, argc
, idx
);
13875 argv_find(argv
, argc
, "(1-99)", &idx
);
13876 argv_find(argv
, argc
, "(100-500)", &idx
);
13877 argv_find(argv
, argc
, "WORD", &idx
);
13879 /* Unset community list. */
13880 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
13883 /* Free temporary community list string allocated by
13886 XFREE(MTYPE_TMP
, str
);
13889 community_list_perror(vty
, ret
);
13890 return CMD_WARNING_CONFIG_FAILED
;
13893 return CMD_SUCCESS
;
13896 /* "large-community-list" keyword help string. */
13897 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
13898 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
13900 DEFUN (ip_lcommunity_list_standard
,
13901 ip_lcommunity_list_standard_cmd
,
13902 "ip large-community-list (1-99) <deny|permit>",
13904 LCOMMUNITY_LIST_STR
13905 "Large Community list number (standard)\n"
13906 "Specify large community to reject\n"
13907 "Specify large community to accept\n")
13909 return lcommunity_list_set_vty(vty
, argc
, argv
,
13910 LARGE_COMMUNITY_LIST_STANDARD
, 0);
13913 DEFUN (ip_lcommunity_list_standard1
,
13914 ip_lcommunity_list_standard1_cmd
,
13915 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
13917 LCOMMUNITY_LIST_STR
13918 "Large Community list number (standard)\n"
13919 "Specify large community to reject\n"
13920 "Specify large community to accept\n"
13921 LCOMMUNITY_VAL_STR
)
13923 return lcommunity_list_set_vty(vty
, argc
, argv
,
13924 LARGE_COMMUNITY_LIST_STANDARD
, 0);
13927 DEFUN (ip_lcommunity_list_expanded
,
13928 ip_lcommunity_list_expanded_cmd
,
13929 "ip large-community-list (100-500) <deny|permit> LINE...",
13931 LCOMMUNITY_LIST_STR
13932 "Large Community list number (expanded)\n"
13933 "Specify large community to reject\n"
13934 "Specify large community to accept\n"
13935 "An ordered list as a regular-expression\n")
13937 return lcommunity_list_set_vty(vty
, argc
, argv
,
13938 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
13941 DEFUN (ip_lcommunity_list_name_standard
,
13942 ip_lcommunity_list_name_standard_cmd
,
13943 "ip large-community-list standard WORD <deny|permit>",
13945 LCOMMUNITY_LIST_STR
13946 "Specify standard large-community-list\n"
13947 "Large Community list name\n"
13948 "Specify large community to reject\n"
13949 "Specify large community to accept\n")
13951 return lcommunity_list_set_vty(vty
, argc
, argv
,
13952 LARGE_COMMUNITY_LIST_STANDARD
, 1);
13955 DEFUN (ip_lcommunity_list_name_standard1
,
13956 ip_lcommunity_list_name_standard1_cmd
,
13957 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
13959 LCOMMUNITY_LIST_STR
13960 "Specify standard large-community-list\n"
13961 "Large Community list name\n"
13962 "Specify large community to reject\n"
13963 "Specify large community to accept\n"
13964 LCOMMUNITY_VAL_STR
)
13966 return lcommunity_list_set_vty(vty
, argc
, argv
,
13967 LARGE_COMMUNITY_LIST_STANDARD
, 1);
13970 DEFUN (ip_lcommunity_list_name_expanded
,
13971 ip_lcommunity_list_name_expanded_cmd
,
13972 "ip large-community-list expanded WORD <deny|permit> LINE...",
13974 LCOMMUNITY_LIST_STR
13975 "Specify expanded large-community-list\n"
13976 "Large Community list name\n"
13977 "Specify large community to reject\n"
13978 "Specify large community to accept\n"
13979 "An ordered list as a regular-expression\n")
13981 return lcommunity_list_set_vty(vty
, argc
, argv
,
13982 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
13985 DEFUN (no_ip_lcommunity_list_standard_all
,
13986 no_ip_lcommunity_list_standard_all_cmd
,
13987 "no ip large-community-list <(1-99)|(100-500)|WORD>",
13990 LCOMMUNITY_LIST_STR
13991 "Large Community list number (standard)\n"
13992 "Large Community list number (expanded)\n"
13993 "Large Community list name\n")
13995 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13996 LARGE_COMMUNITY_LIST_STANDARD
);
13999 DEFUN (no_ip_lcommunity_list_name_expanded_all
,
14000 no_ip_lcommunity_list_name_expanded_all_cmd
,
14001 "no ip large-community-list expanded WORD",
14004 LCOMMUNITY_LIST_STR
14005 "Specify expanded large-community-list\n"
14006 "Large Community list name\n")
14008 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14009 LARGE_COMMUNITY_LIST_EXPANDED
);
14012 DEFUN (no_ip_lcommunity_list_standard
,
14013 no_ip_lcommunity_list_standard_cmd
,
14014 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
14017 LCOMMUNITY_LIST_STR
14018 "Large Community list number (standard)\n"
14019 "Specify large community to reject\n"
14020 "Specify large community to accept\n"
14021 LCOMMUNITY_VAL_STR
)
14023 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14024 LARGE_COMMUNITY_LIST_STANDARD
);
14027 DEFUN (no_ip_lcommunity_list_expanded
,
14028 no_ip_lcommunity_list_expanded_cmd
,
14029 "no ip large-community-list (100-500) <deny|permit> LINE...",
14032 LCOMMUNITY_LIST_STR
14033 "Large Community list number (expanded)\n"
14034 "Specify large community to reject\n"
14035 "Specify large community to accept\n"
14036 "An ordered list as a regular-expression\n")
14038 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14039 LARGE_COMMUNITY_LIST_EXPANDED
);
14042 DEFUN (no_ip_lcommunity_list_name_standard
,
14043 no_ip_lcommunity_list_name_standard_cmd
,
14044 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
14047 LCOMMUNITY_LIST_STR
14048 "Specify standard large-community-list\n"
14049 "Large Community list name\n"
14050 "Specify large community to reject\n"
14051 "Specify large community to accept\n"
14052 LCOMMUNITY_VAL_STR
)
14054 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14055 LARGE_COMMUNITY_LIST_STANDARD
);
14058 DEFUN (no_ip_lcommunity_list_name_expanded
,
14059 no_ip_lcommunity_list_name_expanded_cmd
,
14060 "no ip large-community-list expanded WORD <deny|permit> LINE...",
14063 LCOMMUNITY_LIST_STR
14064 "Specify expanded large-community-list\n"
14065 "Large community list name\n"
14066 "Specify large community to reject\n"
14067 "Specify large community to accept\n"
14068 "An ordered list as a regular-expression\n")
14070 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14071 LARGE_COMMUNITY_LIST_EXPANDED
);
14074 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14076 struct community_entry
*entry
;
14078 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14079 if (entry
== list
->head
) {
14080 if (all_digit(list
->name
))
14081 vty_out(vty
, "Large community %s list %s\n",
14082 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14084 : "(expanded) access",
14088 "Named large community %s list %s\n",
14089 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14095 vty_out(vty
, " %s\n",
14096 community_direct_str(entry
->direct
));
14098 vty_out(vty
, " %s %s\n",
14099 community_direct_str(entry
->direct
),
14100 community_list_config_str(entry
));
14104 DEFUN (show_ip_lcommunity_list
,
14105 show_ip_lcommunity_list_cmd
,
14106 "show ip large-community-list",
14109 "List large-community list\n")
14111 struct community_list
*list
;
14112 struct community_list_master
*cm
;
14114 cm
= community_list_master_lookup(bgp_clist
,
14115 LARGE_COMMUNITY_LIST_MASTER
);
14117 return CMD_SUCCESS
;
14119 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14120 lcommunity_list_show(vty
, list
);
14122 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14123 lcommunity_list_show(vty
, list
);
14125 return CMD_SUCCESS
;
14128 DEFUN (show_ip_lcommunity_list_arg
,
14129 show_ip_lcommunity_list_arg_cmd
,
14130 "show ip large-community-list <(1-500)|WORD>",
14133 "List large-community list\n"
14134 "large-community-list number\n"
14135 "large-community-list name\n")
14137 struct community_list
*list
;
14139 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
,
14140 LARGE_COMMUNITY_LIST_MASTER
);
14142 vty_out(vty
, "%% Can't find extcommunity-list\n");
14143 return CMD_WARNING
;
14146 lcommunity_list_show(vty
, list
);
14148 return CMD_SUCCESS
;
14151 /* "extcommunity-list" keyword help string. */
14152 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
14153 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
14155 DEFUN (ip_extcommunity_list_standard
,
14156 ip_extcommunity_list_standard_cmd
,
14157 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14159 EXTCOMMUNITY_LIST_STR
14160 "Extended Community list number (standard)\n"
14161 "Specify standard extcommunity-list\n"
14162 "Community list name\n"
14163 "Specify community to reject\n"
14164 "Specify community to accept\n"
14165 EXTCOMMUNITY_VAL_STR
)
14167 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14169 char *cl_number_or_name
= NULL
;
14172 argv_find(argv
, argc
, "(1-99)", &idx
);
14173 argv_find(argv
, argc
, "WORD", &idx
);
14174 cl_number_or_name
= argv
[idx
]->arg
;
14175 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14177 argv_find(argv
, argc
, "AA:NN", &idx
);
14178 char *str
= argv_concat(argv
, argc
, idx
);
14180 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14183 XFREE(MTYPE_TMP
, str
);
14186 community_list_perror(vty
, ret
);
14187 return CMD_WARNING_CONFIG_FAILED
;
14190 return CMD_SUCCESS
;
14193 DEFUN (ip_extcommunity_list_name_expanded
,
14194 ip_extcommunity_list_name_expanded_cmd
,
14195 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14197 EXTCOMMUNITY_LIST_STR
14198 "Extended Community list number (expanded)\n"
14199 "Specify expanded extcommunity-list\n"
14200 "Extended Community list name\n"
14201 "Specify community to reject\n"
14202 "Specify community to accept\n"
14203 "An ordered list as a regular-expression\n")
14205 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
14207 char *cl_number_or_name
= NULL
;
14210 argv_find(argv
, argc
, "(100-500)", &idx
);
14211 argv_find(argv
, argc
, "WORD", &idx
);
14212 cl_number_or_name
= argv
[idx
]->arg
;
14213 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14215 argv_find(argv
, argc
, "LINE", &idx
);
14216 char *str
= argv_concat(argv
, argc
, idx
);
14218 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14221 XFREE(MTYPE_TMP
, str
);
14224 community_list_perror(vty
, ret
);
14225 return CMD_WARNING_CONFIG_FAILED
;
14228 return CMD_SUCCESS
;
14231 DEFUN (no_ip_extcommunity_list_standard_all
,
14232 no_ip_extcommunity_list_standard_all_cmd
,
14233 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14236 EXTCOMMUNITY_LIST_STR
14237 "Extended Community list number (standard)\n"
14238 "Specify standard extcommunity-list\n"
14239 "Community list name\n"
14240 "Specify community to reject\n"
14241 "Specify community to accept\n"
14242 EXTCOMMUNITY_VAL_STR
)
14244 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14246 char *cl_number_or_name
= NULL
;
14249 argv_find(argv
, argc
, "(1-99)", &idx
);
14250 argv_find(argv
, argc
, "WORD", &idx
);
14251 cl_number_or_name
= argv
[idx
]->arg
;
14252 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14254 argv_find(argv
, argc
, "AA:NN", &idx
);
14255 char *str
= argv_concat(argv
, argc
, idx
);
14257 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
14260 XFREE(MTYPE_TMP
, str
);
14263 community_list_perror(vty
, ret
);
14264 return CMD_WARNING_CONFIG_FAILED
;
14267 return CMD_SUCCESS
;
14270 DEFUN (no_ip_extcommunity_list_expanded_all
,
14271 no_ip_extcommunity_list_expanded_all_cmd
,
14272 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14275 EXTCOMMUNITY_LIST_STR
14276 "Extended Community list number (expanded)\n"
14277 "Specify expanded extcommunity-list\n"
14278 "Extended Community list name\n"
14279 "Specify community to reject\n"
14280 "Specify community to accept\n"
14281 "An ordered list as a regular-expression\n")
14283 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
14285 char *cl_number_or_name
= NULL
;
14288 argv_find(argv
, argc
, "(100-500)", &idx
);
14289 argv_find(argv
, argc
, "WORD", &idx
);
14290 cl_number_or_name
= argv
[idx
]->arg
;
14291 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14293 argv_find(argv
, argc
, "LINE", &idx
);
14294 char *str
= argv_concat(argv
, argc
, idx
);
14296 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
14299 XFREE(MTYPE_TMP
, str
);
14302 community_list_perror(vty
, ret
);
14303 return CMD_WARNING_CONFIG_FAILED
;
14306 return CMD_SUCCESS
;
14309 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14311 struct community_entry
*entry
;
14313 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14314 if (entry
== list
->head
) {
14315 if (all_digit(list
->name
))
14316 vty_out(vty
, "Extended community %s list %s\n",
14317 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14319 : "(expanded) access",
14323 "Named extended community %s list %s\n",
14324 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14330 vty_out(vty
, " %s\n",
14331 community_direct_str(entry
->direct
));
14333 vty_out(vty
, " %s %s\n",
14334 community_direct_str(entry
->direct
),
14335 community_list_config_str(entry
));
14339 DEFUN (show_ip_extcommunity_list
,
14340 show_ip_extcommunity_list_cmd
,
14341 "show ip extcommunity-list",
14344 "List extended-community list\n")
14346 struct community_list
*list
;
14347 struct community_list_master
*cm
;
14349 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
14351 return CMD_SUCCESS
;
14353 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14354 extcommunity_list_show(vty
, list
);
14356 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14357 extcommunity_list_show(vty
, list
);
14359 return CMD_SUCCESS
;
14362 DEFUN (show_ip_extcommunity_list_arg
,
14363 show_ip_extcommunity_list_arg_cmd
,
14364 "show ip extcommunity-list <(1-500)|WORD>",
14367 "List extended-community list\n"
14368 "Extcommunity-list number\n"
14369 "Extcommunity-list name\n")
14371 int idx_comm_list
= 3;
14372 struct community_list
*list
;
14374 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
14375 EXTCOMMUNITY_LIST_MASTER
);
14377 vty_out(vty
, "%% Can't find extcommunity-list\n");
14378 return CMD_WARNING
;
14381 extcommunity_list_show(vty
, list
);
14383 return CMD_SUCCESS
;
14386 /* Display community-list and extcommunity-list configuration. */
14387 static int community_list_config_write(struct vty
*vty
)
14389 struct community_list
*list
;
14390 struct community_entry
*entry
;
14391 struct community_list_master
*cm
;
14394 /* Community-list. */
14395 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14397 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14398 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14399 vty_out(vty
, "ip community-list %s %s %s\n", list
->name
,
14400 community_direct_str(entry
->direct
),
14401 community_list_config_str(entry
));
14404 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14405 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14406 vty_out(vty
, "ip community-list %s %s %s %s\n",
14407 entry
->style
== COMMUNITY_LIST_STANDARD
14410 list
->name
, community_direct_str(entry
->direct
),
14411 community_list_config_str(entry
));
14415 /* Extcommunity-list. */
14416 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
14418 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14419 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14420 vty_out(vty
, "ip extcommunity-list %s %s %s\n",
14421 list
->name
, community_direct_str(entry
->direct
),
14422 community_list_config_str(entry
));
14425 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14426 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14427 vty_out(vty
, "ip extcommunity-list %s %s %s %s\n",
14428 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14431 list
->name
, community_direct_str(entry
->direct
),
14432 community_list_config_str(entry
));
14437 /* lcommunity-list. */
14438 cm
= community_list_master_lookup(bgp_clist
,
14439 LARGE_COMMUNITY_LIST_MASTER
);
14441 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14442 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14443 vty_out(vty
, "ip large-community-list %s %s %s\n",
14444 list
->name
, community_direct_str(entry
->direct
),
14445 community_list_config_str(entry
));
14448 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14449 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14450 vty_out(vty
, "ip large-community-list %s %s %s %s\n",
14451 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
14454 list
->name
, community_direct_str(entry
->direct
),
14455 community_list_config_str(entry
));
14462 static struct cmd_node community_list_node
= {
14463 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
14466 static void community_list_vty(void)
14468 install_node(&community_list_node
, community_list_config_write
);
14470 /* Community-list. */
14471 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
14472 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
14473 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
14474 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
14475 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
14476 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
14478 /* Extcommunity-list. */
14479 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
14480 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
14481 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
14482 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
14483 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
14484 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
14486 /* Large Community List */
14487 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
14488 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
14489 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
14490 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
14491 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
14492 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
14493 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
14494 install_element(CONFIG_NODE
,
14495 &no_ip_lcommunity_list_name_expanded_all_cmd
);
14496 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
14497 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
14498 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
14499 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
14500 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
14501 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);