2 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "lib_errors.h"
26 #include "lib/zclient.h"
41 #include "bgpd/bgpd.h"
42 #include "bgpd/bgp_attr_evpn.h"
43 #include "bgpd/bgp_advertise.h"
44 #include "bgpd/bgp_attr.h"
45 #include "bgpd/bgp_aspath.h"
46 #include "bgpd/bgp_community.h"
47 #include "bgpd/bgp_ecommunity.h"
48 #include "bgpd/bgp_lcommunity.h"
49 #include "bgpd/bgp_damp.h"
50 #include "bgpd/bgp_debug.h"
51 #include "bgpd/bgp_errors.h"
52 #include "bgpd/bgp_fsm.h"
53 #include "bgpd/bgp_nexthop.h"
54 #include "bgpd/bgp_open.h"
55 #include "bgpd/bgp_regex.h"
56 #include "bgpd/bgp_route.h"
57 #include "bgpd/bgp_mplsvpn.h"
58 #include "bgpd/bgp_zebra.h"
59 #include "bgpd/bgp_table.h"
60 #include "bgpd/bgp_vty.h"
61 #include "bgpd/bgp_mpath.h"
62 #include "bgpd/bgp_packet.h"
63 #include "bgpd/bgp_updgrp.h"
64 #include "bgpd/bgp_bfd.h"
65 #include "bgpd/bgp_io.h"
66 #include "bgpd/bgp_evpn.h"
67 #include "bgpd/bgp_evpn_vty.h"
68 #include "bgpd/bgp_addpath.h"
69 #include "bgpd/bgp_mac.h"
70 #include "bgpd/bgp_flowspec.h"
72 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
75 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
76 { .val_long
= true, .match_profile
= "datacenter", },
77 { .val_long
= false },
79 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
80 { .val_long
= true, .match_profile
= "datacenter", },
81 { .val_long
= false },
83 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
84 { .val_long
= true, .match_profile
= "datacenter", },
85 { .val_long
= false },
87 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
88 { .val_long
= true, .match_profile
= "datacenter", },
89 { .val_long
= false },
91 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
92 { .val_ulong
= 10, .match_profile
= "datacenter", },
95 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
96 { .val_ulong
= 9, .match_profile
= "datacenter", },
99 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
100 { .val_ulong
= 3, .match_profile
= "datacenter", },
104 DEFINE_HOOK(bgp_inst_config_write
,
105 (struct bgp
*bgp
, struct vty
*vty
),
108 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
109 struct prefix
*range
, int exact
);
111 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
117 return BGP_IPV4_NODE
;
120 return BGP_IPV4M_NODE
;
122 case SAFI_LABELED_UNICAST
:
123 return BGP_IPV4L_NODE
;
126 return BGP_VPNV4_NODE
;
129 return BGP_FLOWSPECV4_NODE
;
132 return BGP_IPV4_NODE
;
139 return BGP_IPV6_NODE
;
142 return BGP_IPV6M_NODE
;
144 case SAFI_LABELED_UNICAST
:
145 return BGP_IPV6L_NODE
;
148 return BGP_VPNV6_NODE
;
151 return BGP_FLOWSPECV6_NODE
;
154 return BGP_IPV4_NODE
;
159 return BGP_EVPN_NODE
;
163 // We should never be here but to clarify the switch statement..
164 return BGP_IPV4_NODE
;
168 // Impossible to happen
169 return BGP_IPV4_NODE
;
172 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
174 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
175 return "IPv4 Unicast";
176 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
177 return "IPv4 Multicast";
178 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
179 return "IPv4 Labeled Unicast";
180 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
182 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
184 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
185 return "IPv4 Flowspec";
186 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
187 return "IPv6 Unicast";
188 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
189 return "IPv6 Multicast";
190 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
191 return "IPv6 Labeled Unicast";
192 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
194 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
196 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
197 return "IPv6 Flowspec";
198 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
205 * Please note that we have intentionally camelCased
206 * the return strings here. So if you want
207 * to use this function, please ensure you
208 * are doing this within json output
210 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
212 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
213 return "ipv4Unicast";
214 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
215 return "ipv4Multicast";
216 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
217 return "ipv4LabeledUnicast";
218 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
220 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
222 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
223 return "ipv4Flowspec";
224 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
225 return "ipv6Unicast";
226 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
227 return "ipv6Multicast";
228 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
229 return "ipv6LabeledUnicast";
230 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
232 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
234 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
235 return "ipv6Flowspec";
236 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
242 /* Utility function to get address family from current node. */
243 afi_t
bgp_node_afi(struct vty
*vty
)
251 case BGP_FLOWSPECV6_NODE
:
264 /* Utility function to get subsequent address family from current
266 safi_t
bgp_node_safi(struct vty
*vty
)
272 safi
= SAFI_MPLS_VPN
;
276 safi
= SAFI_MULTICAST
;
283 safi
= SAFI_LABELED_UNICAST
;
285 case BGP_FLOWSPECV4_NODE
:
286 case BGP_FLOWSPECV6_NODE
:
287 safi
= SAFI_FLOWSPEC
;
297 * Converts an AFI in string form to afi_t
299 * @param afi string, one of
303 * @return the corresponding afi_t
305 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
307 afi_t afi
= AFI_MAX
; /* unknown */
308 if (strmatch(afi_str
, "ipv4"))
310 else if (strmatch(afi_str
, "ipv6"))
312 else if (strmatch(afi_str
, "l2vpn"))
317 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
321 if (argv_find(argv
, argc
, "ipv4", index
)) {
325 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
329 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
337 /* supports <unicast|multicast|vpn|labeled-unicast> */
338 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
340 safi_t safi
= SAFI_MAX
; /* unknown */
341 if (strmatch(safi_str
, "multicast"))
342 safi
= SAFI_MULTICAST
;
343 else if (strmatch(safi_str
, "unicast"))
345 else if (strmatch(safi_str
, "vpn"))
346 safi
= SAFI_MPLS_VPN
;
347 else if (strmatch(safi_str
, "evpn"))
349 else if (strmatch(safi_str
, "labeled-unicast"))
350 safi
= SAFI_LABELED_UNICAST
;
351 else if (strmatch(safi_str
, "flowspec"))
352 safi
= SAFI_FLOWSPEC
;
356 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
360 if (argv_find(argv
, argc
, "unicast", index
)) {
363 *safi
= SAFI_UNICAST
;
364 } else if (argv_find(argv
, argc
, "multicast", index
)) {
367 *safi
= SAFI_MULTICAST
;
368 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
371 *safi
= SAFI_LABELED_UNICAST
;
372 } else if (argv_find(argv
, argc
, "vpn", index
)) {
375 *safi
= SAFI_MPLS_VPN
;
376 } else if (argv_find(argv
, argc
, "evpn", index
)) {
380 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
383 *safi
= SAFI_FLOWSPEC
;
388 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
389 enum bgp_instance_type inst_type
)
391 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
393 if (ret
== BGP_CREATED
) {
394 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
395 DFLT_BGP_CONNECT_RETRY
);
397 if (DFLT_BGP_IMPORT_CHECK
)
398 bgp_flag_set(*bgp
, BGP_FLAG_IMPORT_CHECK
);
399 if (DFLT_BGP_SHOW_HOSTNAME
)
400 bgp_flag_set(*bgp
, BGP_FLAG_SHOW_HOSTNAME
);
401 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
402 bgp_flag_set(*bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
403 if (DFLT_BGP_DETERMINISTIC_MED
)
404 bgp_flag_set(*bgp
, BGP_FLAG_DETERMINISTIC_MED
);
412 * bgp_vty_find_and_parse_afi_safi_bgp
414 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
415 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
416 * to appropriate values for the calling function. This is to allow the
417 * calling function to make decisions appropriate for the show command
418 * that is being parsed.
420 * The show commands are generally of the form:
421 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
422 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
424 * Since we use argv_find if the show command in particular doesn't have:
426 * [<view|vrf> VIEWVRFNAME]
427 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
428 * The command parsing should still be ok.
430 * vty -> The vty for the command so we can output some useful data in
431 * the event of a parse error in the vrf.
432 * argv -> The command tokens
433 * argc -> How many command tokens we have
434 * idx -> The current place in the command, generally should be 0 for this
436 * afi -> The parsed afi if it was included in the show command, returned here
437 * safi -> The parsed safi if it was included in the show command, returned here
438 * bgp -> Pointer to the bgp data structure we need to fill in.
439 * use_json -> json is configured or not
441 * The function returns the correct location in the parse tree for the
444 * Returns 0 for failure to parse correctly, else the idx position of where
445 * it found the last token.
447 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
448 struct cmd_token
**argv
, int argc
,
449 int *idx
, afi_t
*afi
, safi_t
*safi
,
450 struct bgp
**bgp
, bool use_json
)
452 char *vrf_name
= NULL
;
458 if (argv_find(argv
, argc
, "ip", idx
))
461 if (argv_find(argv
, argc
, "view", idx
))
462 vrf_name
= argv
[*idx
+ 1]->arg
;
463 else if (argv_find(argv
, argc
, "vrf", idx
)) {
464 vrf_name
= argv
[*idx
+ 1]->arg
;
465 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
469 if (strmatch(vrf_name
, "all"))
472 *bgp
= bgp_lookup_by_name(vrf_name
);
475 json_object
*json
= NULL
;
476 json
= json_object_new_object();
477 json_object_string_add(
479 "View/Vrf is unknown");
481 json_object_to_json_string_ext(json
,
482 JSON_C_TO_STRING_PRETTY
));
483 json_object_free(json
);
486 vty_out(vty
, "View/Vrf %s is unknown\n",
493 *bgp
= bgp_get_default();
496 json_object
*json
= NULL
;
497 json
= json_object_new_object();
498 json_object_string_add(
500 "Default BGP instance not found");
502 json_object_to_json_string_ext(json
,
503 JSON_C_TO_STRING_PRETTY
));
504 json_object_free(json
);
508 "Default BGP instance not found\n");
514 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
515 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
521 static int peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
523 struct interface
*ifp
= NULL
;
525 if (su
->sa
.sa_family
== AF_INET
)
526 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
527 else if (su
->sa
.sa_family
== AF_INET6
)
528 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
529 su
->sin6
.sin6_scope_id
,
538 /* Utility function for looking up peer from VTY. */
539 /* This is used only for configuration, so disallow if attempted on
540 * a dynamic neighbor.
542 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
544 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
553 ret
= str2sockunion(ip_str
, &su
);
555 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
557 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
560 "%% Malformed address or name: %s\n",
566 peer
= peer_lookup(bgp
, &su
);
569 "%% Specify remote-as or peer-group commands first\n");
572 if (peer_dynamic_neighbor(peer
)) {
574 "%% Operation not allowed on a dynamic neighbor\n");
581 /* Utility function for looking up peer or peer group. */
582 /* This is used only for configuration, so disallow if attempted on
583 * a dynamic neighbor.
585 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
587 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
590 struct peer
*peer
= NULL
;
591 struct peer_group
*group
= NULL
;
597 ret
= str2sockunion(peer_str
, &su
);
599 /* IP address, locate peer. */
600 peer
= peer_lookup(bgp
, &su
);
602 /* Not IP, could match either peer configured on interface or a
604 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
606 group
= peer_group_lookup(bgp
, peer_str
);
610 if (peer_dynamic_neighbor(peer
)) {
612 "%% Operation not allowed on a dynamic neighbor\n");
622 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
627 int bgp_vty_return(struct vty
*vty
, int ret
)
629 const char *str
= NULL
;
632 case BGP_ERR_INVALID_VALUE
:
633 str
= "Invalid value";
635 case BGP_ERR_INVALID_FLAG
:
636 str
= "Invalid flag";
638 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
639 str
= "Peer-group has been shutdown. Activate the peer-group first";
641 case BGP_ERR_PEER_FLAG_CONFLICT
:
642 str
= "Can't set override-capability and strict-capability-match at the same time";
644 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
645 str
= "Specify remote-as or peer-group remote AS first";
647 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
648 str
= "Cannot change the peer-group. Deconfigure first";
650 case BGP_ERR_PEER_GROUP_MISMATCH
:
651 str
= "Peer is not a member of this peer-group";
653 case BGP_ERR_PEER_FILTER_CONFLICT
:
654 str
= "Prefix/distribute list can not co-exist";
656 case BGP_ERR_NOT_INTERNAL_PEER
:
657 str
= "Invalid command. Not an internal neighbor";
659 case BGP_ERR_REMOVE_PRIVATE_AS
:
660 str
= "remove-private-AS cannot be configured for IBGP peers";
662 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
663 str
= "Local-AS allowed only for EBGP peers";
665 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
666 str
= "Cannot have local-as same as BGP AS number";
668 case BGP_ERR_TCPSIG_FAILED
:
669 str
= "Error while applying TCP-Sig to session(s)";
671 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
672 str
= "ebgp-multihop and ttl-security cannot be configured together";
674 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
675 str
= "ttl-security only allowed for EBGP peers";
677 case BGP_ERR_AS_OVERRIDE
:
678 str
= "as-override cannot be configured for IBGP peers";
680 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
681 str
= "Invalid limit for number of dynamic neighbors";
683 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
684 str
= "Dynamic neighbor listen range already exists";
686 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
687 str
= "Operation not allowed on a dynamic neighbor";
689 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
690 str
= "Operation not allowed on a directly connected neighbor";
692 case BGP_ERR_PEER_SAFI_CONFLICT
:
693 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
697 vty_out(vty
, "%% %s\n", str
);
698 return CMD_WARNING_CONFIG_FAILED
;
703 /* BGP clear sort. */
712 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
713 safi_t safi
, int error
)
716 case BGP_ERR_AF_UNCONFIGURED
:
718 "%%BGP: Enable %s address family for the neighbor %s\n",
719 get_afi_safi_str(afi
, safi
, false), peer
->host
);
721 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
723 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
731 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
732 struct listnode
*nnode
, enum bgp_clear_type stype
)
736 /* if afi/.safi not specified, spin thru all of them */
737 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
741 FOREACH_AFI_SAFI (tmp_afi
, tmp_safi
) {
742 if (!peer
->afc
[tmp_afi
][tmp_safi
])
745 if (stype
== BGP_CLEAR_SOFT_NONE
)
746 ret
= peer_clear(peer
, &nnode
);
748 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
751 /* if afi specified and safi not, spin thru safis on this afi */
752 } else if (safi
== SAFI_UNSPEC
) {
755 for (tmp_safi
= SAFI_UNICAST
;
756 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
757 if (!peer
->afc
[afi
][tmp_safi
])
760 if (stype
== BGP_CLEAR_SOFT_NONE
)
761 ret
= peer_clear(peer
, &nnode
);
763 ret
= peer_clear_soft(peer
, afi
,
766 /* both afi/safi specified, let the caller know if not defined */
768 if (!peer
->afc
[afi
][safi
])
771 if (stype
== BGP_CLEAR_SOFT_NONE
)
772 ret
= peer_clear(peer
, &nnode
);
774 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
780 /* `clear ip bgp' functions. */
781 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
782 enum clear_sort sort
, enum bgp_clear_type stype
,
788 struct listnode
*node
, *nnode
;
790 /* Clear all neighbors. */
792 * Pass along pointer to next node to peer_clear() when walking all
793 * nodes on the BGP instance as that may get freed if it is a
796 if (sort
== clear_all
) {
797 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
798 ret
= bgp_peer_clear(peer
, afi
, safi
, nnode
,
802 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
805 /* This is to apply read-only mode on this clear. */
806 if (stype
== BGP_CLEAR_SOFT_NONE
)
807 bgp
->update_delay_over
= 0;
812 /* Clear specified neighbor. */
813 if (sort
== clear_peer
) {
816 /* Make sockunion for lookup. */
817 ret
= str2sockunion(arg
, &su
);
819 peer
= peer_lookup_by_conf_if(bgp
, arg
);
821 peer
= peer_lookup_by_hostname(bgp
, arg
);
824 "Malformed address or name: %s\n",
830 peer
= peer_lookup(bgp
, &su
);
833 "%%BGP: Unknown neighbor - \"%s\"\n",
839 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
841 /* if afi/safi not defined for this peer, let caller know */
843 ret
= BGP_ERR_AF_UNCONFIGURED
;
846 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
851 /* Clear all neighbors belonging to a specific peer-group. */
852 if (sort
== clear_group
) {
853 struct peer_group
*group
;
855 group
= peer_group_lookup(bgp
, arg
);
857 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
861 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
862 ret
= bgp_peer_clear(peer
, afi
, safi
, nnode
, stype
);
865 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
872 "%%BGP: No %s peer belonging to peer-group %s is configured\n",
873 get_afi_safi_str(afi
, safi
, false), arg
);
878 /* Clear all external (eBGP) neighbors. */
879 if (sort
== clear_external
) {
880 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
881 if (peer
->sort
== BGP_PEER_IBGP
)
884 ret
= bgp_peer_clear(peer
, afi
, safi
, nnode
, stype
);
887 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
894 "%%BGP: No external %s peer is configured\n",
895 get_afi_safi_str(afi
, safi
, false));
900 /* Clear all neighbors belonging to a specific AS. */
901 if (sort
== clear_as
) {
902 as_t as
= strtoul(arg
, NULL
, 10);
904 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
908 ret
= bgp_peer_clear(peer
, afi
, safi
, nnode
, stype
);
911 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
918 "%%BGP: No %s peer is configured with AS %s\n",
919 get_afi_safi_str(afi
, safi
, false), arg
);
927 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
928 safi_t safi
, enum clear_sort sort
,
929 enum bgp_clear_type stype
, const char *arg
)
933 /* BGP structure lookup. */
935 bgp
= bgp_lookup_by_name(name
);
937 vty_out(vty
, "Can't find BGP instance %s\n", name
);
941 bgp
= bgp_get_default();
943 vty_out(vty
, "No BGP process is configured\n");
948 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
951 /* clear soft inbound */
952 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
957 FOREACH_AFI_SAFI (afi
, safi
)
958 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
959 BGP_CLEAR_SOFT_IN
, NULL
);
962 /* clear soft outbound */
963 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
968 FOREACH_AFI_SAFI (afi
, safi
)
969 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
970 BGP_CLEAR_SOFT_OUT
, NULL
);
974 #ifndef VTYSH_EXTRACT_PL
975 #include "bgpd/bgp_vty_clippy.c"
978 DEFUN_HIDDEN (bgp_local_mac
,
980 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
983 "VxLAN Network Identifier\n"
987 "mac-mobility sequence\n"
997 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
998 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
999 vty_out(vty
, "%% Malformed MAC address\n");
1002 memset(&ip
, 0, sizeof(ip
));
1003 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1005 bgp
= bgp_get_default();
1007 vty_out(vty
, "Default BGP instance is not there\n");
1011 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
);
1013 vty_out(vty
, "Internal error\n");
1020 DEFUN_HIDDEN (no_bgp_local_mac
,
1021 no_bgp_local_mac_cmd
,
1022 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1025 "Local MAC config\n"
1026 "VxLAN Network Identifier\n"
1037 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1038 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1039 vty_out(vty
, "%% Malformed MAC address\n");
1042 memset(&ip
, 0, sizeof(ip
));
1044 bgp
= bgp_get_default();
1046 vty_out(vty
, "Default BGP instance is not there\n");
1050 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1052 vty_out(vty
, "Internal error\n");
1059 DEFUN (no_synchronization
,
1060 no_synchronization_cmd
,
1061 "no synchronization",
1063 "Perform IGP synchronization\n")
1068 DEFUN (no_auto_summary
,
1069 no_auto_summary_cmd
,
1072 "Enable automatic network number summarization\n")
1077 /* "router bgp" commands. */
1078 DEFUN_NOSH (router_bgp
,
1080 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1084 BGP_INSTANCE_HELP_STR
)
1087 int idx_view_vrf
= 3;
1093 const char *name
= NULL
;
1094 enum bgp_instance_type inst_type
;
1096 // "router bgp" without an ASN
1098 // Pending: Make VRF option available for ASN less config
1099 bgp
= bgp_get_default();
1102 vty_out(vty
, "%% No BGP process is configured\n");
1103 return CMD_WARNING_CONFIG_FAILED
;
1106 if (listcount(bm
->bgp
) > 1) {
1107 vty_out(vty
, "%% Please specify ASN and VRF\n");
1108 return CMD_WARNING_CONFIG_FAILED
;
1114 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1116 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1118 name
= argv
[idx_vrf
]->arg
;
1120 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1121 if (strmatch(name
, VRF_DEFAULT_NAME
))
1124 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1125 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1126 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1129 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1130 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1132 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1134 case BGP_ERR_AS_MISMATCH
:
1135 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1136 return CMD_WARNING_CONFIG_FAILED
;
1137 case BGP_ERR_INSTANCE_MISMATCH
:
1139 "BGP instance name and AS number mismatch\n");
1141 "BGP instance is already running; AS is %u\n",
1143 return CMD_WARNING_CONFIG_FAILED
;
1147 * If we just instantiated the default instance, complete
1148 * any pending VRF-VPN leaking that was configured via
1149 * earlier "router bgp X vrf FOO" blocks.
1151 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1152 vpn_leak_postchange_all();
1154 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1155 bgp_vpn_leak_export(bgp
);
1156 /* Pending: handle when user tries to change a view to vrf n vv.
1160 /* unset the auto created flag as the user config is now present */
1161 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1162 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1167 /* "no router bgp" commands. */
1168 DEFUN (no_router_bgp
,
1170 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1175 BGP_INSTANCE_HELP_STR
)
1181 const char *name
= NULL
;
1183 // "no router bgp" without an ASN
1185 // Pending: Make VRF option available for ASN less config
1186 bgp
= bgp_get_default();
1189 vty_out(vty
, "%% No BGP process is configured\n");
1190 return CMD_WARNING_CONFIG_FAILED
;
1193 if (listcount(bm
->bgp
) > 1) {
1194 vty_out(vty
, "%% Please specify ASN and VRF\n");
1195 return CMD_WARNING_CONFIG_FAILED
;
1199 vty_out(vty
, "%% Please unconfigure l3vni %u",
1201 return CMD_WARNING_CONFIG_FAILED
;
1204 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1207 name
= argv
[idx_vrf
]->arg
;
1209 /* Lookup bgp structure. */
1210 bgp
= bgp_lookup(as
, name
);
1212 vty_out(vty
, "%% Can't find BGP instance\n");
1213 return CMD_WARNING_CONFIG_FAILED
;
1217 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1219 return CMD_WARNING_CONFIG_FAILED
;
1222 /* Cannot delete default instance if vrf instances exist */
1223 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1224 struct listnode
*node
;
1225 struct bgp
*tmp_bgp
;
1227 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1228 if (tmp_bgp
->inst_type
1229 == BGP_INSTANCE_TYPE_VRF
) {
1231 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1232 return CMD_WARNING_CONFIG_FAILED
;
1238 if (bgp_vpn_leak_unimport(bgp
, vty
))
1239 return CMD_WARNING_CONFIG_FAILED
;
1247 /* BGP router-id. */
1249 DEFPY (bgp_router_id
,
1251 "bgp router-id A.B.C.D",
1253 "Override configured router identifier\n"
1254 "Manually configured router identifier\n")
1256 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1257 bgp_router_id_static_set(bgp
, router_id
);
1261 DEFPY (no_bgp_router_id
,
1262 no_bgp_router_id_cmd
,
1263 "no bgp router-id [A.B.C.D]",
1266 "Override configured router identifier\n"
1267 "Manually configured router identifier\n")
1269 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1271 if (router_id_str
) {
1272 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1273 vty_out(vty
, "%% BGP router-id doesn't match\n");
1274 return CMD_WARNING_CONFIG_FAILED
;
1278 router_id
.s_addr
= 0;
1279 bgp_router_id_static_set(bgp
, router_id
);
1285 /* BGP Cluster ID. */
1286 DEFUN (bgp_cluster_id
,
1288 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1290 "Configure Route-Reflector Cluster-id\n"
1291 "Route-Reflector Cluster-id in IP address format\n"
1292 "Route-Reflector Cluster-id as 32 bit quantity\n")
1294 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1297 struct in_addr cluster
;
1299 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1301 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1302 return CMD_WARNING_CONFIG_FAILED
;
1305 bgp_cluster_id_set(bgp
, &cluster
);
1306 bgp_clear_star_soft_out(vty
, bgp
->name
);
1311 DEFUN (no_bgp_cluster_id
,
1312 no_bgp_cluster_id_cmd
,
1313 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1316 "Configure Route-Reflector Cluster-id\n"
1317 "Route-Reflector Cluster-id in IP address format\n"
1318 "Route-Reflector Cluster-id as 32 bit quantity\n")
1320 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1321 bgp_cluster_id_unset(bgp
);
1322 bgp_clear_star_soft_out(vty
, bgp
->name
);
1327 DEFUN (bgp_confederation_identifier
,
1328 bgp_confederation_identifier_cmd
,
1329 "bgp confederation identifier (1-4294967295)",
1330 "BGP specific commands\n"
1331 "AS confederation parameters\n"
1333 "Set routing domain confederation AS\n")
1335 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1339 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1341 bgp_confederation_id_set(bgp
, as
);
1346 DEFUN (no_bgp_confederation_identifier
,
1347 no_bgp_confederation_identifier_cmd
,
1348 "no bgp confederation identifier [(1-4294967295)]",
1350 "BGP specific commands\n"
1351 "AS confederation parameters\n"
1353 "Set routing domain confederation AS\n")
1355 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1356 bgp_confederation_id_unset(bgp
);
1361 DEFUN (bgp_confederation_peers
,
1362 bgp_confederation_peers_cmd
,
1363 "bgp confederation peers (1-4294967295)...",
1364 "BGP specific commands\n"
1365 "AS confederation parameters\n"
1366 "Peer ASs in BGP confederation\n"
1369 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1374 for (i
= idx_asn
; i
< argc
; i
++) {
1375 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1377 if (bgp
->as
== as
) {
1379 "%% Local member-AS not allowed in confed peer list\n");
1383 bgp_confederation_peers_add(bgp
, as
);
1388 DEFUN (no_bgp_confederation_peers
,
1389 no_bgp_confederation_peers_cmd
,
1390 "no bgp confederation peers (1-4294967295)...",
1392 "BGP specific commands\n"
1393 "AS confederation parameters\n"
1394 "Peer ASs in BGP confederation\n"
1397 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1402 for (i
= idx_asn
; i
< argc
; i
++) {
1403 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1405 bgp_confederation_peers_remove(bgp
, as
);
1411 * Central routine for maximum-paths configuration.
1412 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1413 * @set: 1 for setting values, 0 for removing the max-paths config.
1415 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1416 const char *mpaths
, uint16_t options
,
1419 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1420 uint16_t maxpaths
= 0;
1425 afi
= bgp_node_afi(vty
);
1426 safi
= bgp_node_safi(vty
);
1429 maxpaths
= strtol(mpaths
, NULL
, 10);
1430 if (maxpaths
> multipath_num
) {
1432 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1433 maxpaths
, multipath_num
);
1434 return CMD_WARNING_CONFIG_FAILED
;
1436 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1439 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1443 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1444 (set
== 1) ? "" : "un",
1445 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1446 maxpaths
, afi
, safi
);
1447 return CMD_WARNING_CONFIG_FAILED
;
1450 bgp_recalculate_all_bestpaths(bgp
);
1455 DEFUN (bgp_maxmed_admin
,
1456 bgp_maxmed_admin_cmd
,
1457 "bgp max-med administrative ",
1459 "Advertise routes with max-med\n"
1460 "Administratively applied, for an indefinite period\n")
1462 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1464 bgp
->v_maxmed_admin
= 1;
1465 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1467 bgp_maxmed_update(bgp
);
1472 DEFUN (bgp_maxmed_admin_medv
,
1473 bgp_maxmed_admin_medv_cmd
,
1474 "bgp max-med administrative (0-4294967295)",
1476 "Advertise routes with max-med\n"
1477 "Administratively applied, for an indefinite period\n"
1478 "Max MED value to be used\n")
1480 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1483 bgp
->v_maxmed_admin
= 1;
1484 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1486 bgp_maxmed_update(bgp
);
1491 DEFUN (no_bgp_maxmed_admin
,
1492 no_bgp_maxmed_admin_cmd
,
1493 "no bgp max-med administrative [(0-4294967295)]",
1496 "Advertise routes with max-med\n"
1497 "Administratively applied, for an indefinite period\n"
1498 "Max MED value to be used\n")
1500 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1501 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1502 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1503 bgp_maxmed_update(bgp
);
1508 DEFUN (bgp_maxmed_onstartup
,
1509 bgp_maxmed_onstartup_cmd
,
1510 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1512 "Advertise routes with max-med\n"
1513 "Effective on a startup\n"
1514 "Time (seconds) period for max-med\n"
1515 "Max MED value to be used\n")
1517 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1520 argv_find(argv
, argc
, "(5-86400)", &idx
);
1521 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1522 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1523 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1525 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1527 bgp_maxmed_update(bgp
);
1532 DEFUN (no_bgp_maxmed_onstartup
,
1533 no_bgp_maxmed_onstartup_cmd
,
1534 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1537 "Advertise routes with max-med\n"
1538 "Effective on a startup\n"
1539 "Time (seconds) period for max-med\n"
1540 "Max MED value to be used\n")
1542 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1544 /* Cancel max-med onstartup if its on */
1545 if (bgp
->t_maxmed_onstartup
) {
1546 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1547 bgp
->maxmed_onstartup_over
= 1;
1550 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1551 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1553 bgp_maxmed_update(bgp
);
1558 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1561 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1562 uint16_t update_delay
;
1563 uint16_t establish_wait
;
1565 update_delay
= strtoul(delay
, NULL
, 10);
1567 if (!wait
) /* update-delay <delay> */
1569 bgp
->v_update_delay
= update_delay
;
1570 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1574 /* update-delay <delay> <establish-wait> */
1575 establish_wait
= atoi(wait
);
1576 if (update_delay
< establish_wait
) {
1578 "%%Failed: update-delay less than the establish-wait!\n");
1579 return CMD_WARNING_CONFIG_FAILED
;
1582 bgp
->v_update_delay
= update_delay
;
1583 bgp
->v_establish_wait
= establish_wait
;
1588 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1590 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1592 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1593 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1598 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1600 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1601 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1602 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1603 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1609 /* Update-delay configuration */
1610 DEFUN (bgp_update_delay
,
1611 bgp_update_delay_cmd
,
1612 "update-delay (0-3600)",
1613 "Force initial delay for best-path and updates\n"
1617 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1620 DEFUN (bgp_update_delay_establish_wait
,
1621 bgp_update_delay_establish_wait_cmd
,
1622 "update-delay (0-3600) (1-3600)",
1623 "Force initial delay for best-path and updates\n"
1628 int idx_number_2
= 2;
1629 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1630 argv
[idx_number_2
]->arg
);
1633 /* Update-delay deconfiguration */
1634 DEFUN (no_bgp_update_delay
,
1635 no_bgp_update_delay_cmd
,
1636 "no update-delay [(0-3600) [(1-3600)]]",
1638 "Force initial delay for best-path and updates\n"
1642 return bgp_update_delay_deconfig_vty(vty
);
1646 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
1649 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1651 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
1652 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
1657 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
1660 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1662 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
1663 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
1668 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1671 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1672 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1673 vty_out(vty
, " write-quanta %d\n", quanta
);
1676 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1679 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1680 if (quanta
!= BGP_READ_PACKET_MAX
)
1681 vty_out(vty
, " read-quanta %d\n", quanta
);
1684 /* Packet quanta configuration
1686 * XXX: The value set here controls the size of a stack buffer in the IO
1687 * thread. When changing these limits be careful to prevent stack overflow.
1689 * Furthermore, the maximums used here should correspond to
1690 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
1692 DEFPY (bgp_wpkt_quanta
,
1693 bgp_wpkt_quanta_cmd
,
1694 "[no] write-quanta (1-64)$quanta",
1696 "How many packets to write to peer socket per run\n"
1697 "Number of packets\n")
1699 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
1702 DEFPY (bgp_rpkt_quanta
,
1703 bgp_rpkt_quanta_cmd
,
1704 "[no] read-quanta (1-10)$quanta",
1706 "How many packets to read from peer socket per I/O cycle\n"
1707 "Number of packets\n")
1709 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
1712 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1714 if (!bgp
->heuristic_coalesce
)
1715 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1719 DEFUN (bgp_coalesce_time
,
1720 bgp_coalesce_time_cmd
,
1721 "coalesce-time (0-4294967295)",
1722 "Subgroup coalesce timer\n"
1723 "Subgroup coalesce timer value (in ms)\n")
1725 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1728 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1729 bgp
->heuristic_coalesce
= false;
1730 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1734 DEFUN (no_bgp_coalesce_time
,
1735 no_bgp_coalesce_time_cmd
,
1736 "no coalesce-time (0-4294967295)",
1738 "Subgroup coalesce timer\n"
1739 "Subgroup coalesce timer value (in ms)\n")
1741 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1743 bgp
->heuristic_coalesce
= true;
1744 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1748 /* Maximum-paths configuration */
1749 DEFUN (bgp_maxpaths
,
1751 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1752 "Forward packets over multiple paths\n"
1753 "Number of paths\n")
1756 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1757 argv
[idx_number
]->arg
, 0, 1);
1760 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1761 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1762 "Forward packets over multiple paths\n"
1763 "Number of paths\n")
1765 DEFUN (bgp_maxpaths_ibgp
,
1766 bgp_maxpaths_ibgp_cmd
,
1767 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1768 "Forward packets over multiple paths\n"
1770 "Number of paths\n")
1773 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1774 argv
[idx_number
]->arg
, 0, 1);
1777 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1778 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1779 "Forward packets over multiple paths\n"
1781 "Number of paths\n")
1783 DEFUN (bgp_maxpaths_ibgp_cluster
,
1784 bgp_maxpaths_ibgp_cluster_cmd
,
1785 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1786 "Forward packets over multiple paths\n"
1789 "Match the cluster length\n")
1792 return bgp_maxpaths_config_vty(
1793 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1794 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1797 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1798 "maximum-paths ibgp " CMD_RANGE_STR(
1799 1, MULTIPATH_NUM
) " equal-cluster-length",
1800 "Forward packets over multiple paths\n"
1803 "Match the cluster length\n")
1805 DEFUN (no_bgp_maxpaths
,
1806 no_bgp_maxpaths_cmd
,
1807 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1809 "Forward packets over multiple paths\n"
1810 "Number of paths\n")
1812 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1815 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1816 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1817 "Forward packets over multiple paths\n"
1818 "Number of paths\n")
1820 DEFUN (no_bgp_maxpaths_ibgp
,
1821 no_bgp_maxpaths_ibgp_cmd
,
1822 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1824 "Forward packets over multiple paths\n"
1827 "Match the cluster length\n")
1829 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1832 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1833 "no maximum-paths ibgp [" CMD_RANGE_STR(
1834 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1836 "Forward packets over multiple paths\n"
1839 "Match the cluster length\n")
1841 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
1842 afi_t afi
, safi_t safi
)
1844 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1845 vty_out(vty
, " maximum-paths %d\n",
1846 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1849 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1850 vty_out(vty
, " maximum-paths ibgp %d",
1851 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1852 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1853 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1854 vty_out(vty
, " equal-cluster-length");
1863 "timers bgp (0-65535) (0-65535)",
1864 "Adjust routing timers\n"
1866 "Keepalive interval\n"
1869 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1871 int idx_number_2
= 3;
1872 unsigned long keepalive
= 0;
1873 unsigned long holdtime
= 0;
1875 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1876 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1878 /* Holdtime value check. */
1879 if (holdtime
< 3 && holdtime
!= 0) {
1881 "%% hold time value must be either 0 or greater than 3\n");
1882 return CMD_WARNING_CONFIG_FAILED
;
1885 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
);
1890 DEFUN (no_bgp_timers
,
1892 "no timers bgp [(0-65535) (0-65535)]",
1894 "Adjust routing timers\n"
1896 "Keepalive interval\n"
1899 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1900 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
1901 DFLT_BGP_CONNECT_RETRY
);
1907 DEFUN (bgp_client_to_client_reflection
,
1908 bgp_client_to_client_reflection_cmd
,
1909 "bgp client-to-client reflection",
1910 "BGP specific commands\n"
1911 "Configure client to client route reflection\n"
1912 "reflection of routes allowed\n")
1914 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1915 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1916 bgp_clear_star_soft_out(vty
, bgp
->name
);
1921 DEFUN (no_bgp_client_to_client_reflection
,
1922 no_bgp_client_to_client_reflection_cmd
,
1923 "no bgp client-to-client reflection",
1925 "BGP specific commands\n"
1926 "Configure client to client route reflection\n"
1927 "reflection of routes allowed\n")
1929 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1930 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1931 bgp_clear_star_soft_out(vty
, bgp
->name
);
1936 /* "bgp always-compare-med" configuration. */
1937 DEFUN (bgp_always_compare_med
,
1938 bgp_always_compare_med_cmd
,
1939 "bgp always-compare-med",
1940 "BGP specific commands\n"
1941 "Allow comparing MED from different neighbors\n")
1943 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1944 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1945 bgp_recalculate_all_bestpaths(bgp
);
1950 DEFUN (no_bgp_always_compare_med
,
1951 no_bgp_always_compare_med_cmd
,
1952 "no bgp always-compare-med",
1954 "BGP specific commands\n"
1955 "Allow comparing MED from different neighbors\n")
1957 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1958 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1959 bgp_recalculate_all_bestpaths(bgp
);
1965 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
1966 "bgp ebgp-requires-policy",
1967 "BGP specific commands\n"
1968 "Require in and out policy for eBGP peers (RFC8212)\n")
1970 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1971 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_ENABLED
;
1975 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
1976 "no bgp ebgp-requires-policy",
1978 "BGP specific commands\n"
1979 "Require in and out policy for eBGP peers (RFC8212)\n")
1981 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1982 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_DISABLED
;
1986 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
1987 "bgp reject-as-sets",
1988 "BGP specific commands\n"
1989 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
1991 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1992 struct listnode
*node
, *nnode
;
1995 bgp
->reject_as_sets
= BGP_REJECT_AS_SETS_ENABLED
;
1997 /* Reset existing BGP sessions to reject routes
1998 * with aspath containing AS_SET or AS_CONFED_SET.
2000 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2001 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2002 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2003 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2004 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2011 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2012 "no bgp reject-as-sets",
2014 "BGP specific commands\n"
2015 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2017 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2018 struct listnode
*node
, *nnode
;
2021 bgp
->reject_as_sets
= BGP_REJECT_AS_SETS_DISABLED
;
2023 /* Reset existing BGP sessions to reject routes
2024 * with aspath containing AS_SET or AS_CONFED_SET.
2026 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2027 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2028 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2029 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2030 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2037 /* "bgp deterministic-med" configuration. */
2038 DEFUN (bgp_deterministic_med
,
2039 bgp_deterministic_med_cmd
,
2040 "bgp deterministic-med",
2041 "BGP specific commands\n"
2042 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2044 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2046 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
2047 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
2048 bgp_recalculate_all_bestpaths(bgp
);
2054 DEFUN (no_bgp_deterministic_med
,
2055 no_bgp_deterministic_med_cmd
,
2056 "no bgp deterministic-med",
2058 "BGP specific commands\n"
2059 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2061 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2062 int bestpath_per_as_used
;
2066 struct listnode
*node
, *nnode
;
2068 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
2069 bestpath_per_as_used
= 0;
2071 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2072 FOREACH_AFI_SAFI (afi
, safi
)
2073 if (bgp_addpath_dmed_required(
2074 peer
->addpath_type
[afi
][safi
])) {
2075 bestpath_per_as_used
= 1;
2079 if (bestpath_per_as_used
)
2083 if (bestpath_per_as_used
) {
2085 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2086 return CMD_WARNING_CONFIG_FAILED
;
2088 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
2089 bgp_recalculate_all_bestpaths(bgp
);
2096 /* "bgp graceful-restart" configuration. */
2097 DEFUN (bgp_graceful_restart
,
2098 bgp_graceful_restart_cmd
,
2099 "bgp graceful-restart",
2100 "BGP specific commands\n"
2101 "Graceful restart capability parameters\n")
2103 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2104 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
2108 DEFUN (no_bgp_graceful_restart
,
2109 no_bgp_graceful_restart_cmd
,
2110 "no bgp graceful-restart",
2112 "BGP specific commands\n"
2113 "Graceful restart capability parameters\n")
2115 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2116 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
2120 DEFUN (bgp_graceful_restart_stalepath_time
,
2121 bgp_graceful_restart_stalepath_time_cmd
,
2122 "bgp graceful-restart stalepath-time (1-4095)",
2123 "BGP specific commands\n"
2124 "Graceful restart capability parameters\n"
2125 "Set the max time to hold onto restarting peer's stale paths\n"
2126 "Delay value (seconds)\n")
2128 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2132 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2133 bgp
->stalepath_time
= stalepath
;
2137 DEFUN (bgp_graceful_restart_restart_time
,
2138 bgp_graceful_restart_restart_time_cmd
,
2139 "bgp graceful-restart restart-time (1-4095)",
2140 "BGP specific commands\n"
2141 "Graceful restart capability parameters\n"
2142 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2143 "Delay value (seconds)\n")
2145 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2149 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2150 bgp
->restart_time
= restart
;
2154 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2155 no_bgp_graceful_restart_stalepath_time_cmd
,
2156 "no bgp graceful-restart stalepath-time [(1-4095)]",
2158 "BGP specific commands\n"
2159 "Graceful restart capability parameters\n"
2160 "Set the max time to hold onto restarting peer's stale paths\n"
2161 "Delay value (seconds)\n")
2163 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2165 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2169 DEFUN (no_bgp_graceful_restart_restart_time
,
2170 no_bgp_graceful_restart_restart_time_cmd
,
2171 "no bgp graceful-restart restart-time [(1-4095)]",
2173 "BGP specific commands\n"
2174 "Graceful restart capability parameters\n"
2175 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2176 "Delay value (seconds)\n")
2178 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2180 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2184 DEFUN (bgp_graceful_restart_preserve_fw
,
2185 bgp_graceful_restart_preserve_fw_cmd
,
2186 "bgp graceful-restart preserve-fw-state",
2187 "BGP specific commands\n"
2188 "Graceful restart capability parameters\n"
2189 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2191 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2192 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2196 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2197 no_bgp_graceful_restart_preserve_fw_cmd
,
2198 "no bgp graceful-restart preserve-fw-state",
2200 "BGP specific commands\n"
2201 "Graceful restart capability parameters\n"
2202 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2204 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2205 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2209 /* "bgp graceful-shutdown" configuration */
2210 DEFUN (bgp_graceful_shutdown
,
2211 bgp_graceful_shutdown_cmd
,
2212 "bgp graceful-shutdown",
2214 "Graceful shutdown parameters\n")
2216 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2218 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2219 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2220 bgp_static_redo_import_check(bgp
);
2221 bgp_redistribute_redo(bgp
);
2222 bgp_clear_star_soft_out(vty
, bgp
->name
);
2223 bgp_clear_star_soft_in(vty
, bgp
->name
);
2229 DEFUN (no_bgp_graceful_shutdown
,
2230 no_bgp_graceful_shutdown_cmd
,
2231 "no bgp graceful-shutdown",
2234 "Graceful shutdown parameters\n")
2236 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2238 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2239 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2240 bgp_static_redo_import_check(bgp
);
2241 bgp_redistribute_redo(bgp
);
2242 bgp_clear_star_soft_out(vty
, bgp
->name
);
2243 bgp_clear_star_soft_in(vty
, bgp
->name
);
2249 /* "bgp fast-external-failover" configuration. */
2250 DEFUN (bgp_fast_external_failover
,
2251 bgp_fast_external_failover_cmd
,
2252 "bgp fast-external-failover",
2254 "Immediately reset session if a link to a directly connected external peer goes down\n")
2256 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2257 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2261 DEFUN (no_bgp_fast_external_failover
,
2262 no_bgp_fast_external_failover_cmd
,
2263 "no bgp fast-external-failover",
2266 "Immediately reset session if a link to a directly connected external peer goes down\n")
2268 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2269 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2273 /* "bgp bestpath compare-routerid" configuration. */
2274 DEFUN (bgp_bestpath_compare_router_id
,
2275 bgp_bestpath_compare_router_id_cmd
,
2276 "bgp bestpath compare-routerid",
2277 "BGP specific commands\n"
2278 "Change the default bestpath selection\n"
2279 "Compare router-id for identical EBGP paths\n")
2281 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2282 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2283 bgp_recalculate_all_bestpaths(bgp
);
2288 DEFUN (no_bgp_bestpath_compare_router_id
,
2289 no_bgp_bestpath_compare_router_id_cmd
,
2290 "no bgp bestpath compare-routerid",
2292 "BGP specific commands\n"
2293 "Change the default bestpath selection\n"
2294 "Compare router-id for identical EBGP paths\n")
2296 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2297 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2298 bgp_recalculate_all_bestpaths(bgp
);
2303 /* "bgp bestpath as-path ignore" configuration. */
2304 DEFUN (bgp_bestpath_aspath_ignore
,
2305 bgp_bestpath_aspath_ignore_cmd
,
2306 "bgp bestpath as-path ignore",
2307 "BGP specific commands\n"
2308 "Change the default bestpath selection\n"
2309 "AS-path attribute\n"
2310 "Ignore as-path length in selecting a route\n")
2312 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2313 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2314 bgp_recalculate_all_bestpaths(bgp
);
2319 DEFUN (no_bgp_bestpath_aspath_ignore
,
2320 no_bgp_bestpath_aspath_ignore_cmd
,
2321 "no bgp bestpath as-path ignore",
2323 "BGP specific commands\n"
2324 "Change the default bestpath selection\n"
2325 "AS-path attribute\n"
2326 "Ignore as-path length in selecting a route\n")
2328 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2329 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2330 bgp_recalculate_all_bestpaths(bgp
);
2335 /* "bgp bestpath as-path confed" configuration. */
2336 DEFUN (bgp_bestpath_aspath_confed
,
2337 bgp_bestpath_aspath_confed_cmd
,
2338 "bgp bestpath as-path confed",
2339 "BGP specific commands\n"
2340 "Change the default bestpath selection\n"
2341 "AS-path attribute\n"
2342 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2344 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2345 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2346 bgp_recalculate_all_bestpaths(bgp
);
2351 DEFUN (no_bgp_bestpath_aspath_confed
,
2352 no_bgp_bestpath_aspath_confed_cmd
,
2353 "no bgp bestpath as-path confed",
2355 "BGP specific commands\n"
2356 "Change the default bestpath selection\n"
2357 "AS-path attribute\n"
2358 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2360 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2361 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2362 bgp_recalculate_all_bestpaths(bgp
);
2367 /* "bgp bestpath as-path multipath-relax" configuration. */
2368 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2369 bgp_bestpath_aspath_multipath_relax_cmd
,
2370 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2371 "BGP specific commands\n"
2372 "Change the default bestpath selection\n"
2373 "AS-path attribute\n"
2374 "Allow load sharing across routes that have different AS paths (but same length)\n"
2375 "Generate an AS_SET\n"
2376 "Do not generate an AS_SET\n")
2378 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2380 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2382 /* no-as-set is now the default behavior so we can silently
2384 if (argv_find(argv
, argc
, "as-set", &idx
))
2385 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2387 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2389 bgp_recalculate_all_bestpaths(bgp
);
2394 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2395 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2396 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2398 "BGP specific commands\n"
2399 "Change the default bestpath selection\n"
2400 "AS-path attribute\n"
2401 "Allow load sharing across routes that have different AS paths (but same length)\n"
2402 "Generate an AS_SET\n"
2403 "Do not generate an AS_SET\n")
2405 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2406 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2407 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2408 bgp_recalculate_all_bestpaths(bgp
);
2413 /* "bgp log-neighbor-changes" configuration. */
2414 DEFUN (bgp_log_neighbor_changes
,
2415 bgp_log_neighbor_changes_cmd
,
2416 "bgp log-neighbor-changes",
2417 "BGP specific commands\n"
2418 "Log neighbor up/down and reset reason\n")
2420 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2421 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2425 DEFUN (no_bgp_log_neighbor_changes
,
2426 no_bgp_log_neighbor_changes_cmd
,
2427 "no bgp log-neighbor-changes",
2429 "BGP specific commands\n"
2430 "Log neighbor up/down and reset reason\n")
2432 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2433 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2437 /* "bgp bestpath med" configuration. */
2438 DEFUN (bgp_bestpath_med
,
2439 bgp_bestpath_med_cmd
,
2440 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2441 "BGP specific commands\n"
2442 "Change the default bestpath selection\n"
2444 "Compare MED among confederation paths\n"
2445 "Treat missing MED as the least preferred one\n"
2446 "Treat missing MED as the least preferred one\n"
2447 "Compare MED among confederation paths\n")
2449 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2452 if (argv_find(argv
, argc
, "confed", &idx
))
2453 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2455 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2456 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2458 bgp_recalculate_all_bestpaths(bgp
);
2463 DEFUN (no_bgp_bestpath_med
,
2464 no_bgp_bestpath_med_cmd
,
2465 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2467 "BGP specific commands\n"
2468 "Change the default bestpath selection\n"
2470 "Compare MED among confederation paths\n"
2471 "Treat missing MED as the least preferred one\n"
2472 "Treat missing MED as the least preferred one\n"
2473 "Compare MED among confederation paths\n")
2475 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2478 if (argv_find(argv
, argc
, "confed", &idx
))
2479 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2481 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2482 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2484 bgp_recalculate_all_bestpaths(bgp
);
2489 /* "no bgp default ipv4-unicast". */
2490 DEFUN (no_bgp_default_ipv4_unicast
,
2491 no_bgp_default_ipv4_unicast_cmd
,
2492 "no bgp default ipv4-unicast",
2494 "BGP specific commands\n"
2495 "Configure BGP defaults\n"
2496 "Activate ipv4-unicast for a peer by default\n")
2498 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2499 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2503 DEFUN (bgp_default_ipv4_unicast
,
2504 bgp_default_ipv4_unicast_cmd
,
2505 "bgp default ipv4-unicast",
2506 "BGP specific commands\n"
2507 "Configure BGP defaults\n"
2508 "Activate ipv4-unicast for a peer by default\n")
2510 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2511 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2515 /* Display hostname in certain command outputs */
2516 DEFUN (bgp_default_show_hostname
,
2517 bgp_default_show_hostname_cmd
,
2518 "bgp default show-hostname",
2519 "BGP specific commands\n"
2520 "Configure BGP defaults\n"
2521 "Show hostname in certain command outputs\n")
2523 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2524 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2528 DEFUN (no_bgp_default_show_hostname
,
2529 no_bgp_default_show_hostname_cmd
,
2530 "no bgp default show-hostname",
2532 "BGP specific commands\n"
2533 "Configure BGP defaults\n"
2534 "Show hostname in certain command outputs\n")
2536 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2537 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2541 /* "bgp network import-check" configuration. */
2542 DEFUN (bgp_network_import_check
,
2543 bgp_network_import_check_cmd
,
2544 "bgp network import-check",
2545 "BGP specific commands\n"
2546 "BGP network command\n"
2547 "Check BGP network route exists in IGP\n")
2549 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2550 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2551 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2552 bgp_static_redo_import_check(bgp
);
2558 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2559 "bgp network import-check exact",
2560 "BGP specific commands\n"
2561 "BGP network command\n"
2562 "Check BGP network route exists in IGP\n"
2563 "Match route precisely\n")
2565 DEFUN (no_bgp_network_import_check
,
2566 no_bgp_network_import_check_cmd
,
2567 "no bgp network import-check",
2569 "BGP specific commands\n"
2570 "BGP network command\n"
2571 "Check BGP network route exists in IGP\n")
2573 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2574 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2575 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2576 bgp_static_redo_import_check(bgp
);
2582 DEFUN (bgp_default_local_preference
,
2583 bgp_default_local_preference_cmd
,
2584 "bgp default local-preference (0-4294967295)",
2585 "BGP specific commands\n"
2586 "Configure BGP defaults\n"
2587 "local preference (higher=more preferred)\n"
2588 "Configure default local preference value\n")
2590 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2592 uint32_t local_pref
;
2594 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2596 bgp_default_local_preference_set(bgp
, local_pref
);
2597 bgp_clear_star_soft_in(vty
, bgp
->name
);
2602 DEFUN (no_bgp_default_local_preference
,
2603 no_bgp_default_local_preference_cmd
,
2604 "no bgp default local-preference [(0-4294967295)]",
2606 "BGP specific commands\n"
2607 "Configure BGP defaults\n"
2608 "local preference (higher=more preferred)\n"
2609 "Configure default local preference value\n")
2611 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2612 bgp_default_local_preference_unset(bgp
);
2613 bgp_clear_star_soft_in(vty
, bgp
->name
);
2619 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2620 bgp_default_subgroup_pkt_queue_max_cmd
,
2621 "bgp default subgroup-pkt-queue-max (20-100)",
2622 "BGP specific commands\n"
2623 "Configure BGP defaults\n"
2624 "subgroup-pkt-queue-max\n"
2625 "Configure subgroup packet queue max\n")
2627 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2631 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2633 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2638 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2639 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2640 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2642 "BGP specific commands\n"
2643 "Configure BGP defaults\n"
2644 "subgroup-pkt-queue-max\n"
2645 "Configure subgroup packet queue max\n")
2647 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2648 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2653 DEFUN (bgp_rr_allow_outbound_policy
,
2654 bgp_rr_allow_outbound_policy_cmd
,
2655 "bgp route-reflector allow-outbound-policy",
2656 "BGP specific commands\n"
2657 "Allow modifications made by out route-map\n"
2658 "on ibgp neighbors\n")
2660 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2662 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2663 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2664 update_group_announce_rrclients(bgp
);
2665 bgp_clear_star_soft_out(vty
, bgp
->name
);
2671 DEFUN (no_bgp_rr_allow_outbound_policy
,
2672 no_bgp_rr_allow_outbound_policy_cmd
,
2673 "no bgp route-reflector allow-outbound-policy",
2675 "BGP specific commands\n"
2676 "Allow modifications made by out route-map\n"
2677 "on ibgp neighbors\n")
2679 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2681 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2682 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2683 update_group_announce_rrclients(bgp
);
2684 bgp_clear_star_soft_out(vty
, bgp
->name
);
2690 DEFUN (bgp_listen_limit
,
2691 bgp_listen_limit_cmd
,
2692 "bgp listen limit (1-5000)",
2693 "BGP specific commands\n"
2694 "Configure BGP defaults\n"
2695 "maximum number of BGP Dynamic Neighbors that can be created\n"
2696 "Configure Dynamic Neighbors listen limit value\n")
2698 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2702 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2704 bgp_listen_limit_set(bgp
, listen_limit
);
2709 DEFUN (no_bgp_listen_limit
,
2710 no_bgp_listen_limit_cmd
,
2711 "no bgp listen limit [(1-5000)]",
2712 "BGP specific commands\n"
2713 "Configure BGP defaults\n"
2714 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2715 "Configure Dynamic Neighbors listen limit value to default\n"
2716 "Configure Dynamic Neighbors listen limit value\n")
2718 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2719 bgp_listen_limit_unset(bgp
);
2725 * Check if this listen range is already configured. Check for exact
2726 * match or overlap based on input.
2728 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2729 struct prefix
*range
, int exact
)
2731 struct listnode
*node
, *nnode
;
2732 struct listnode
*node1
, *nnode1
;
2733 struct peer_group
*group
;
2738 afi
= family2afi(range
->family
);
2739 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2740 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2743 match
= prefix_same(range
, lr
);
2745 match
= (prefix_match(range
, lr
)
2746 || prefix_match(lr
, range
));
2755 DEFUN (bgp_listen_range
,
2756 bgp_listen_range_cmd
,
2757 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
2758 "BGP specific commands\n"
2759 "Configure BGP dynamic neighbors listen range\n"
2760 "Configure BGP dynamic neighbors listen range\n"
2762 "Member of the peer-group\n"
2763 "Peer-group name\n")
2765 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2766 struct prefix range
;
2767 struct peer_group
*group
, *existing_group
;
2772 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2773 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2774 char *prefix
= argv
[idx
]->arg
;
2775 argv_find(argv
, argc
, "PGNAME", &idx
);
2776 char *peergroup
= argv
[idx
]->arg
;
2778 /* Convert IP prefix string to struct prefix. */
2779 ret
= str2prefix(prefix
, &range
);
2781 vty_out(vty
, "%% Malformed listen range\n");
2782 return CMD_WARNING_CONFIG_FAILED
;
2785 afi
= family2afi(range
.family
);
2787 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2789 "%% Malformed listen range (link-local address)\n");
2790 return CMD_WARNING_CONFIG_FAILED
;
2795 /* Check if same listen range is already configured. */
2796 existing_group
= listen_range_exists(bgp
, &range
, 1);
2797 if (existing_group
) {
2798 if (strcmp(existing_group
->name
, peergroup
) == 0)
2802 "%% Same listen range is attached to peer-group %s\n",
2803 existing_group
->name
);
2804 return CMD_WARNING_CONFIG_FAILED
;
2808 /* Check if an overlapping listen range exists. */
2809 if (listen_range_exists(bgp
, &range
, 0)) {
2811 "%% Listen range overlaps with existing listen range\n");
2812 return CMD_WARNING_CONFIG_FAILED
;
2815 group
= peer_group_lookup(bgp
, peergroup
);
2817 vty_out(vty
, "%% Configure the peer-group first\n");
2818 return CMD_WARNING_CONFIG_FAILED
;
2821 ret
= peer_group_listen_range_add(group
, &range
);
2822 return bgp_vty_return(vty
, ret
);
2825 DEFUN (no_bgp_listen_range
,
2826 no_bgp_listen_range_cmd
,
2827 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
2829 "BGP specific commands\n"
2830 "Unconfigure BGP dynamic neighbors listen range\n"
2831 "Unconfigure BGP dynamic neighbors listen range\n"
2833 "Member of the peer-group\n"
2834 "Peer-group name\n")
2836 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2837 struct prefix range
;
2838 struct peer_group
*group
;
2843 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2844 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2845 char *prefix
= argv
[idx
]->arg
;
2846 argv_find(argv
, argc
, "WORD", &idx
);
2847 char *peergroup
= argv
[idx
]->arg
;
2849 /* Convert IP prefix string to struct prefix. */
2850 ret
= str2prefix(prefix
, &range
);
2852 vty_out(vty
, "%% Malformed listen range\n");
2853 return CMD_WARNING_CONFIG_FAILED
;
2856 afi
= family2afi(range
.family
);
2858 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2860 "%% Malformed listen range (link-local address)\n");
2861 return CMD_WARNING_CONFIG_FAILED
;
2866 group
= peer_group_lookup(bgp
, peergroup
);
2868 vty_out(vty
, "%% Peer-group does not exist\n");
2869 return CMD_WARNING_CONFIG_FAILED
;
2872 ret
= peer_group_listen_range_del(group
, &range
);
2873 return bgp_vty_return(vty
, ret
);
2876 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2878 struct peer_group
*group
;
2879 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2880 struct prefix
*range
;
2882 char buf
[PREFIX2STR_BUFFER
];
2884 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2885 vty_out(vty
, " bgp listen limit %d\n",
2886 bgp
->dynamic_neighbors_limit
);
2888 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2889 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2890 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2892 prefix2str(range
, buf
, sizeof(buf
));
2894 " bgp listen range %s peer-group %s\n",
2902 DEFUN (bgp_disable_connected_route_check
,
2903 bgp_disable_connected_route_check_cmd
,
2904 "bgp disable-ebgp-connected-route-check",
2905 "BGP specific commands\n"
2906 "Disable checking if nexthop is connected on ebgp sessions\n")
2908 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2909 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2910 bgp_clear_star_soft_in(vty
, bgp
->name
);
2915 DEFUN (no_bgp_disable_connected_route_check
,
2916 no_bgp_disable_connected_route_check_cmd
,
2917 "no bgp disable-ebgp-connected-route-check",
2919 "BGP specific commands\n"
2920 "Disable checking if nexthop is connected on ebgp sessions\n")
2922 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2923 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2924 bgp_clear_star_soft_in(vty
, bgp
->name
);
2930 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2931 const char *as_str
, afi_t afi
, safi_t safi
)
2933 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2936 int as_type
= AS_SPECIFIED
;
2939 if (as_str
[0] == 'i') {
2941 as_type
= AS_INTERNAL
;
2942 } else if (as_str
[0] == 'e') {
2944 as_type
= AS_EXTERNAL
;
2946 /* Get AS number. */
2947 as
= strtoul(as_str
, NULL
, 10);
2950 /* If peer is peer group or interface peer, call proper function. */
2951 ret
= str2sockunion(peer_str
, &su
);
2955 /* Check if existing interface peer */
2956 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
2958 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2961 /* if not interface peer, check peer-group settings */
2962 if (ret
< 0 && !peer
) {
2963 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2966 "%% Create the peer-group or interface first\n");
2967 return CMD_WARNING_CONFIG_FAILED
;
2972 if (peer_address_self_check(bgp
, &su
)) {
2974 "%% Can not configure the local system as neighbor\n");
2975 return CMD_WARNING_CONFIG_FAILED
;
2977 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2980 /* This peer belongs to peer group. */
2982 case BGP_ERR_PEER_GROUP_MEMBER
:
2984 "%% Peer-group member cannot override remote-as of peer-group\n");
2985 return CMD_WARNING_CONFIG_FAILED
;
2986 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2988 "%% Peer-group members must be all internal or all external\n");
2989 return CMD_WARNING_CONFIG_FAILED
;
2991 return bgp_vty_return(vty
, ret
);
2994 DEFUN (bgp_default_shutdown
,
2995 bgp_default_shutdown_cmd
,
2996 "[no] bgp default shutdown",
2999 "Configure BGP defaults\n"
3000 "Apply administrative shutdown to newly configured peers\n")
3002 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3003 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
3007 DEFUN (neighbor_remote_as
,
3008 neighbor_remote_as_cmd
,
3009 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
3012 "Specify a BGP neighbor\n"
3014 "Internal BGP peer\n"
3015 "External BGP peer\n")
3018 int idx_remote_as
= 3;
3019 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
3020 argv
[idx_remote_as
]->arg
, AFI_IP
,
3024 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
3025 afi_t afi
, safi_t safi
, int v6only
,
3026 const char *peer_group_name
,
3029 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3031 int as_type
= AS_UNSPECIFIED
;
3033 struct peer_group
*group
;
3037 group
= peer_group_lookup(bgp
, conf_if
);
3040 vty_out(vty
, "%% Name conflict with peer-group \n");
3041 return CMD_WARNING_CONFIG_FAILED
;
3045 if (as_str
[0] == 'i') {
3046 as_type
= AS_INTERNAL
;
3047 } else if (as_str
[0] == 'e') {
3048 as_type
= AS_EXTERNAL
;
3050 /* Get AS number. */
3051 as
= strtoul(as_str
, NULL
, 10);
3052 as_type
= AS_SPECIFIED
;
3056 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
3059 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
3062 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
3063 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
3064 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
3065 as_type
, 0, 0, NULL
);
3067 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
3068 as_type
, afi
, safi
, NULL
);
3071 vty_out(vty
, "%% BGP failed to create peer\n");
3072 return CMD_WARNING_CONFIG_FAILED
;
3076 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
3078 /* Request zebra to initiate IPv6 RAs on this interface. We do
3080 * any unnumbered peer in order to not worry about run-time
3082 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
3084 * gets deleted later etc.)
3087 bgp_zebra_initiate_radv(bgp
, peer
);
3090 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
3091 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
3093 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
3095 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
3097 /* v6only flag changed. Reset bgp seesion */
3098 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
3099 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
3100 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
3101 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
3103 bgp_session_reset(peer
);
3106 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
3107 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
3108 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
3109 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
3112 if (peer_group_name
) {
3113 group
= peer_group_lookup(bgp
, peer_group_name
);
3115 vty_out(vty
, "%% Configure the peer-group first\n");
3116 return CMD_WARNING_CONFIG_FAILED
;
3119 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3122 return bgp_vty_return(vty
, ret
);
3125 DEFUN (neighbor_interface_config
,
3126 neighbor_interface_config_cmd
,
3127 "neighbor WORD interface [peer-group PGNAME]",
3129 "Interface name or neighbor tag\n"
3130 "Enable BGP on interface\n"
3131 "Member of the peer-group\n"
3132 "Peer-group name\n")
3135 int idx_peer_group_word
= 4;
3137 if (argc
> idx_peer_group_word
)
3138 return peer_conf_interface_get(
3139 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
3140 argv
[idx_peer_group_word
]->arg
, NULL
);
3142 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3143 SAFI_UNICAST
, 0, NULL
, NULL
);
3146 DEFUN (neighbor_interface_config_v6only
,
3147 neighbor_interface_config_v6only_cmd
,
3148 "neighbor WORD interface v6only [peer-group PGNAME]",
3150 "Interface name or neighbor tag\n"
3151 "Enable BGP on interface\n"
3152 "Enable BGP with v6 link-local only\n"
3153 "Member of the peer-group\n"
3154 "Peer-group name\n")
3157 int idx_peer_group_word
= 5;
3159 if (argc
> idx_peer_group_word
)
3160 return peer_conf_interface_get(
3161 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
3162 argv
[idx_peer_group_word
]->arg
, NULL
);
3164 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3165 SAFI_UNICAST
, 1, NULL
, NULL
);
3169 DEFUN (neighbor_interface_config_remote_as
,
3170 neighbor_interface_config_remote_as_cmd
,
3171 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
3173 "Interface name or neighbor tag\n"
3174 "Enable BGP on interface\n"
3175 "Specify a BGP neighbor\n"
3177 "Internal BGP peer\n"
3178 "External BGP peer\n")
3181 int idx_remote_as
= 4;
3182 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3183 SAFI_UNICAST
, 0, NULL
,
3184 argv
[idx_remote_as
]->arg
);
3187 DEFUN (neighbor_interface_v6only_config_remote_as
,
3188 neighbor_interface_v6only_config_remote_as_cmd
,
3189 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
3191 "Interface name or neighbor tag\n"
3192 "Enable BGP with v6 link-local only\n"
3193 "Enable BGP on interface\n"
3194 "Specify a BGP neighbor\n"
3196 "Internal BGP peer\n"
3197 "External BGP peer\n")
3200 int idx_remote_as
= 5;
3201 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3202 SAFI_UNICAST
, 1, NULL
,
3203 argv
[idx_remote_as
]->arg
);
3206 DEFUN (neighbor_peer_group
,
3207 neighbor_peer_group_cmd
,
3208 "neighbor WORD peer-group",
3210 "Interface name or neighbor tag\n"
3211 "Configure peer-group\n")
3213 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3216 struct peer_group
*group
;
3218 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3220 vty_out(vty
, "%% Name conflict with interface: \n");
3221 return CMD_WARNING_CONFIG_FAILED
;
3224 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
3226 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
3227 return CMD_WARNING_CONFIG_FAILED
;
3235 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3239 "Specify a BGP neighbor\n"
3241 "Internal BGP peer\n"
3242 "External BGP peer\n")
3244 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3248 struct peer_group
*group
;
3252 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3254 /* look up for neighbor by interface name config. */
3255 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3257 /* Request zebra to terminate IPv6 RAs on this
3260 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3261 peer_notify_unconfig(peer
);
3266 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3268 peer_group_notify_unconfig(group
);
3269 peer_group_delete(group
);
3271 vty_out(vty
, "%% Create the peer-group first\n");
3272 return CMD_WARNING_CONFIG_FAILED
;
3275 peer
= peer_lookup(bgp
, &su
);
3277 if (peer_dynamic_neighbor(peer
)) {
3279 "%% Operation not allowed on a dynamic neighbor\n");
3280 return CMD_WARNING_CONFIG_FAILED
;
3283 other
= peer
->doppelganger
;
3284 peer_notify_unconfig(peer
);
3286 if (other
&& other
->status
!= Deleted
) {
3287 peer_notify_unconfig(other
);
3296 DEFUN (no_neighbor_interface_config
,
3297 no_neighbor_interface_config_cmd
,
3298 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
3302 "Configure BGP on interface\n"
3303 "Enable BGP with v6 link-local only\n"
3304 "Member of the peer-group\n"
3306 "Specify a BGP neighbor\n"
3308 "Internal BGP peer\n"
3309 "External BGP peer\n")
3311 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3315 /* look up for neighbor by interface name config. */
3316 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3318 /* Request zebra to terminate IPv6 RAs on this interface. */
3320 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3321 peer_notify_unconfig(peer
);
3324 vty_out(vty
, "%% Create the bgp interface first\n");
3325 return CMD_WARNING_CONFIG_FAILED
;
3330 DEFUN (no_neighbor_peer_group
,
3331 no_neighbor_peer_group_cmd
,
3332 "no neighbor WORD peer-group",
3336 "Configure peer-group\n")
3338 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3340 struct peer_group
*group
;
3342 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3344 peer_group_notify_unconfig(group
);
3345 peer_group_delete(group
);
3347 vty_out(vty
, "%% Create the peer-group first\n");
3348 return CMD_WARNING_CONFIG_FAILED
;
3353 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3354 no_neighbor_interface_peer_group_remote_as_cmd
,
3355 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3358 "Interface name or neighbor tag\n"
3359 "Specify a BGP neighbor\n"
3361 "Internal BGP peer\n"
3362 "External BGP peer\n")
3364 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3366 struct peer_group
*group
;
3369 /* look up for neighbor by interface name config. */
3370 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3372 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
3376 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3378 peer_group_remote_as_delete(group
);
3380 vty_out(vty
, "%% Create the peer-group or interface first\n");
3381 return CMD_WARNING_CONFIG_FAILED
;
3386 DEFUN (neighbor_local_as
,
3387 neighbor_local_as_cmd
,
3388 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3391 "Specify a local-as number\n"
3392 "AS number used as local AS\n")
3400 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3402 return CMD_WARNING_CONFIG_FAILED
;
3404 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3405 ret
= peer_local_as_set(peer
, as
, 0, 0);
3406 return bgp_vty_return(vty
, ret
);
3409 DEFUN (neighbor_local_as_no_prepend
,
3410 neighbor_local_as_no_prepend_cmd
,
3411 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3414 "Specify a local-as number\n"
3415 "AS number used as local AS\n"
3416 "Do not prepend local-as to updates from ebgp peers\n")
3424 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3426 return CMD_WARNING_CONFIG_FAILED
;
3428 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3429 ret
= peer_local_as_set(peer
, as
, 1, 0);
3430 return bgp_vty_return(vty
, ret
);
3433 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3434 neighbor_local_as_no_prepend_replace_as_cmd
,
3435 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3438 "Specify a local-as number\n"
3439 "AS number used as local AS\n"
3440 "Do not prepend local-as to updates from ebgp peers\n"
3441 "Do not prepend local-as to updates from ibgp peers\n")
3449 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3451 return CMD_WARNING_CONFIG_FAILED
;
3453 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3454 ret
= peer_local_as_set(peer
, as
, 1, 1);
3455 return bgp_vty_return(vty
, ret
);
3458 DEFUN (no_neighbor_local_as
,
3459 no_neighbor_local_as_cmd
,
3460 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3464 "Specify a local-as number\n"
3465 "AS number used as local AS\n"
3466 "Do not prepend local-as to updates from ebgp peers\n"
3467 "Do not prepend local-as to updates from ibgp peers\n")
3473 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3475 return CMD_WARNING_CONFIG_FAILED
;
3477 ret
= peer_local_as_unset(peer
);
3478 return bgp_vty_return(vty
, ret
);
3482 DEFUN (neighbor_solo
,
3484 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3487 "Solo peer - part of its own update group\n")
3493 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3495 return CMD_WARNING_CONFIG_FAILED
;
3497 ret
= update_group_adjust_soloness(peer
, 1);
3498 return bgp_vty_return(vty
, ret
);
3501 DEFUN (no_neighbor_solo
,
3502 no_neighbor_solo_cmd
,
3503 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3507 "Solo peer - part of its own update group\n")
3513 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3515 return CMD_WARNING_CONFIG_FAILED
;
3517 ret
= update_group_adjust_soloness(peer
, 0);
3518 return bgp_vty_return(vty
, ret
);
3521 DEFUN (neighbor_password
,
3522 neighbor_password_cmd
,
3523 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3534 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3536 return CMD_WARNING_CONFIG_FAILED
;
3538 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3539 return bgp_vty_return(vty
, ret
);
3542 DEFUN (no_neighbor_password
,
3543 no_neighbor_password_cmd
,
3544 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3555 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3557 return CMD_WARNING_CONFIG_FAILED
;
3559 ret
= peer_password_unset(peer
);
3560 return bgp_vty_return(vty
, ret
);
3563 DEFUN (neighbor_activate
,
3564 neighbor_activate_cmd
,
3565 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3568 "Enable the Address Family for this Neighbor\n")
3574 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3576 return CMD_WARNING_CONFIG_FAILED
;
3578 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3579 return bgp_vty_return(vty
, ret
);
3582 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3583 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3584 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3585 "Enable the Address Family for this Neighbor\n")
3587 DEFUN (no_neighbor_activate
,
3588 no_neighbor_activate_cmd
,
3589 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3593 "Enable the Address Family for this Neighbor\n")
3600 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3602 return CMD_WARNING_CONFIG_FAILED
;
3604 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3605 return bgp_vty_return(vty
, ret
);
3608 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3609 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3610 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3611 "Enable the Address Family for this Neighbor\n")
3613 DEFUN (neighbor_set_peer_group
,
3614 neighbor_set_peer_group_cmd
,
3615 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3618 "Member of the peer-group\n"
3619 "Peer-group name\n")
3621 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3628 struct peer_group
*group
;
3630 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3632 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3634 vty_out(vty
, "%% Malformed address or name: %s\n",
3635 argv
[idx_peer
]->arg
);
3636 return CMD_WARNING_CONFIG_FAILED
;
3639 if (peer_address_self_check(bgp
, &su
)) {
3641 "%% Can not configure the local system as neighbor\n");
3642 return CMD_WARNING_CONFIG_FAILED
;
3645 /* Disallow for dynamic neighbor. */
3646 peer
= peer_lookup(bgp
, &su
);
3647 if (peer
&& peer_dynamic_neighbor(peer
)) {
3649 "%% Operation not allowed on a dynamic neighbor\n");
3650 return CMD_WARNING_CONFIG_FAILED
;
3654 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3656 vty_out(vty
, "%% Configure the peer-group first\n");
3657 return CMD_WARNING_CONFIG_FAILED
;
3660 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3662 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3664 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3666 return CMD_WARNING_CONFIG_FAILED
;
3669 return bgp_vty_return(vty
, ret
);
3672 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3673 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3674 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3675 "Member of the peer-group\n"
3676 "Peer-group name\n")
3678 DEFUN (no_neighbor_set_peer_group
,
3679 no_neighbor_set_peer_group_cmd
,
3680 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3684 "Member of the peer-group\n"
3685 "Peer-group name\n")
3687 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3692 struct peer_group
*group
;
3694 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3696 return CMD_WARNING_CONFIG_FAILED
;
3698 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3700 vty_out(vty
, "%% Configure the peer-group first\n");
3701 return CMD_WARNING_CONFIG_FAILED
;
3704 peer_notify_unconfig(peer
);
3705 ret
= peer_delete(peer
);
3707 return bgp_vty_return(vty
, ret
);
3710 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3711 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3712 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3713 "Member of the peer-group\n"
3714 "Peer-group name\n")
3716 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3717 uint32_t flag
, int set
)
3722 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3724 return CMD_WARNING_CONFIG_FAILED
;
3727 * If 'neighbor <interface>', then this is for directly connected peers,
3728 * we should not accept disable-connected-check.
3730 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3732 "%s is directly connected peer, cannot accept disable-"
3733 "connected-check\n",
3735 return CMD_WARNING_CONFIG_FAILED
;
3738 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3739 peer_tx_shutdown_message_unset(peer
);
3742 ret
= peer_flag_set(peer
, flag
);
3744 ret
= peer_flag_unset(peer
, flag
);
3746 return bgp_vty_return(vty
, ret
);
3749 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3751 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3754 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3757 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3760 /* neighbor passive. */
3761 DEFUN (neighbor_passive
,
3762 neighbor_passive_cmd
,
3763 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3766 "Don't send open messages to this neighbor\n")
3769 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3772 DEFUN (no_neighbor_passive
,
3773 no_neighbor_passive_cmd
,
3774 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3778 "Don't send open messages to this neighbor\n")
3781 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3784 /* neighbor shutdown. */
3785 DEFUN (neighbor_shutdown_msg
,
3786 neighbor_shutdown_msg_cmd
,
3787 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3790 "Administratively shut down this neighbor\n"
3791 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3792 "Shutdown message\n")
3798 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3802 return CMD_WARNING_CONFIG_FAILED
;
3803 message
= argv_concat(argv
, argc
, 4);
3804 peer_tx_shutdown_message_set(peer
, message
);
3805 XFREE(MTYPE_TMP
, message
);
3808 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3811 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3812 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3813 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3814 "Administratively shut down this neighbor\n")
3816 DEFUN (no_neighbor_shutdown_msg
,
3817 no_neighbor_shutdown_msg_cmd
,
3818 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3822 "Administratively shut down this neighbor\n"
3823 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3824 "Shutdown message\n")
3828 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3829 PEER_FLAG_SHUTDOWN
);
3832 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3833 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3834 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3835 "Administratively shut down this neighbor\n")
3837 /* neighbor capability dynamic. */
3838 DEFUN (neighbor_capability_dynamic
,
3839 neighbor_capability_dynamic_cmd
,
3840 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3843 "Advertise capability to the peer\n"
3844 "Advertise dynamic capability to this neighbor\n")
3847 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3848 PEER_FLAG_DYNAMIC_CAPABILITY
);
3851 DEFUN (no_neighbor_capability_dynamic
,
3852 no_neighbor_capability_dynamic_cmd
,
3853 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3857 "Advertise capability to the peer\n"
3858 "Advertise dynamic capability to this neighbor\n")
3861 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3862 PEER_FLAG_DYNAMIC_CAPABILITY
);
3865 /* neighbor dont-capability-negotiate */
3866 DEFUN (neighbor_dont_capability_negotiate
,
3867 neighbor_dont_capability_negotiate_cmd
,
3868 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3871 "Do not perform capability negotiation\n")
3874 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3875 PEER_FLAG_DONT_CAPABILITY
);
3878 DEFUN (no_neighbor_dont_capability_negotiate
,
3879 no_neighbor_dont_capability_negotiate_cmd
,
3880 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3884 "Do not perform capability negotiation\n")
3887 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3888 PEER_FLAG_DONT_CAPABILITY
);
3891 /* neighbor capability extended next hop encoding */
3892 DEFUN (neighbor_capability_enhe
,
3893 neighbor_capability_enhe_cmd
,
3894 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3897 "Advertise capability to the peer\n"
3898 "Advertise extended next-hop capability to the peer\n")
3901 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3902 PEER_FLAG_CAPABILITY_ENHE
);
3905 DEFUN (no_neighbor_capability_enhe
,
3906 no_neighbor_capability_enhe_cmd
,
3907 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3911 "Advertise capability to the peer\n"
3912 "Advertise extended next-hop capability to the peer\n")
3915 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3916 PEER_FLAG_CAPABILITY_ENHE
);
3919 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3920 afi_t afi
, safi_t safi
, uint32_t flag
,
3926 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3928 return CMD_WARNING_CONFIG_FAILED
;
3931 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3933 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3935 return bgp_vty_return(vty
, ret
);
3938 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3939 afi_t afi
, safi_t safi
, uint32_t flag
)
3941 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3944 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3945 afi_t afi
, safi_t safi
, uint32_t flag
)
3947 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3950 /* neighbor capability orf prefix-list. */
3951 DEFUN (neighbor_capability_orf_prefix
,
3952 neighbor_capability_orf_prefix_cmd
,
3953 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3956 "Advertise capability to the peer\n"
3957 "Advertise ORF capability to the peer\n"
3958 "Advertise prefixlist ORF capability to this neighbor\n"
3959 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3960 "Capability to RECEIVE the ORF from this neighbor\n"
3961 "Capability to SEND the ORF to this neighbor\n")
3964 int idx_send_recv
= 5;
3967 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3968 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3969 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3970 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3971 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3972 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3974 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3975 return CMD_WARNING_CONFIG_FAILED
;
3978 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3979 bgp_node_safi(vty
), flag
);
3983 neighbor_capability_orf_prefix
,
3984 neighbor_capability_orf_prefix_hidden_cmd
,
3985 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3986 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3987 "Advertise capability to the peer\n"
3988 "Advertise ORF capability to the peer\n"
3989 "Advertise prefixlist ORF capability to this neighbor\n"
3990 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3991 "Capability to RECEIVE the ORF from this neighbor\n"
3992 "Capability to SEND the ORF to this neighbor\n")
3994 DEFUN (no_neighbor_capability_orf_prefix
,
3995 no_neighbor_capability_orf_prefix_cmd
,
3996 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
4000 "Advertise capability to the peer\n"
4001 "Advertise ORF capability to the peer\n"
4002 "Advertise prefixlist ORF capability to this neighbor\n"
4003 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
4004 "Capability to RECEIVE the ORF from this neighbor\n"
4005 "Capability to SEND the ORF to this neighbor\n")
4008 int idx_send_recv
= 6;
4011 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
4012 flag
= PEER_FLAG_ORF_PREFIX_SM
;
4013 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
4014 flag
= PEER_FLAG_ORF_PREFIX_RM
;
4015 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
4016 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
4018 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
4019 return CMD_WARNING_CONFIG_FAILED
;
4022 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4023 bgp_node_afi(vty
), bgp_node_safi(vty
),
4028 no_neighbor_capability_orf_prefix
,
4029 no_neighbor_capability_orf_prefix_hidden_cmd
,
4030 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
4031 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4032 "Advertise capability to the peer\n"
4033 "Advertise ORF capability to the peer\n"
4034 "Advertise prefixlist ORF capability to this neighbor\n"
4035 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
4036 "Capability to RECEIVE the ORF from this neighbor\n"
4037 "Capability to SEND the ORF to this neighbor\n")
4039 /* neighbor next-hop-self. */
4040 DEFUN (neighbor_nexthop_self
,
4041 neighbor_nexthop_self_cmd
,
4042 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4045 "Disable the next hop calculation for this neighbor\n")
4048 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4049 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
4052 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
4053 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4054 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4055 "Disable the next hop calculation for this neighbor\n")
4057 /* neighbor next-hop-self. */
4058 DEFUN (neighbor_nexthop_self_force
,
4059 neighbor_nexthop_self_force_cmd
,
4060 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4063 "Disable the next hop calculation for this neighbor\n"
4064 "Set the next hop to self for reflected routes\n")
4067 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4069 PEER_FLAG_FORCE_NEXTHOP_SELF
);
4072 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
4073 neighbor_nexthop_self_force_hidden_cmd
,
4074 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4075 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4076 "Disable the next hop calculation for this neighbor\n"
4077 "Set the next hop to self for reflected routes\n")
4079 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
4080 neighbor_nexthop_self_all_hidden_cmd
,
4081 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
4082 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4083 "Disable the next hop calculation for this neighbor\n"
4084 "Set the next hop to self for reflected routes\n")
4086 DEFUN (no_neighbor_nexthop_self
,
4087 no_neighbor_nexthop_self_cmd
,
4088 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4092 "Disable the next hop calculation for this neighbor\n")
4095 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4096 bgp_node_afi(vty
), bgp_node_safi(vty
),
4097 PEER_FLAG_NEXTHOP_SELF
);
4100 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
4101 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4102 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4103 "Disable the next hop calculation for this neighbor\n")
4105 DEFUN (no_neighbor_nexthop_self_force
,
4106 no_neighbor_nexthop_self_force_cmd
,
4107 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4111 "Disable the next hop calculation for this neighbor\n"
4112 "Set the next hop to self for reflected routes\n")
4115 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4116 bgp_node_afi(vty
), bgp_node_safi(vty
),
4117 PEER_FLAG_FORCE_NEXTHOP_SELF
);
4120 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4121 no_neighbor_nexthop_self_force_hidden_cmd
,
4122 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4123 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4124 "Disable the next hop calculation for this neighbor\n"
4125 "Set the next hop to self for reflected routes\n")
4127 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4128 no_neighbor_nexthop_self_all_hidden_cmd
,
4129 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
4130 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4131 "Disable the next hop calculation for this neighbor\n"
4132 "Set the next hop to self for reflected routes\n")
4134 /* neighbor as-override */
4135 DEFUN (neighbor_as_override
,
4136 neighbor_as_override_cmd
,
4137 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4140 "Override ASNs in outbound updates if aspath equals remote-as\n")
4143 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4144 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
4147 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
4148 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4149 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4150 "Override ASNs in outbound updates if aspath equals remote-as\n")
4152 DEFUN (no_neighbor_as_override
,
4153 no_neighbor_as_override_cmd
,
4154 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4158 "Override ASNs in outbound updates if aspath equals remote-as\n")
4161 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4162 bgp_node_afi(vty
), bgp_node_safi(vty
),
4163 PEER_FLAG_AS_OVERRIDE
);
4166 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
4167 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4168 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4169 "Override ASNs in outbound updates if aspath equals remote-as\n")
4171 /* neighbor remove-private-AS. */
4172 DEFUN (neighbor_remove_private_as
,
4173 neighbor_remove_private_as_cmd
,
4174 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4177 "Remove private ASNs in outbound updates\n")
4180 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4182 PEER_FLAG_REMOVE_PRIVATE_AS
);
4185 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
4186 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4187 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4188 "Remove private ASNs in outbound updates\n")
4190 DEFUN (neighbor_remove_private_as_all
,
4191 neighbor_remove_private_as_all_cmd
,
4192 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4195 "Remove private ASNs in outbound updates\n"
4196 "Apply to all AS numbers\n")
4199 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4201 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4204 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
4205 neighbor_remove_private_as_all_hidden_cmd
,
4206 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4207 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4208 "Remove private ASNs in outbound updates\n"
4209 "Apply to all AS numbers")
4211 DEFUN (neighbor_remove_private_as_replace_as
,
4212 neighbor_remove_private_as_replace_as_cmd
,
4213 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4216 "Remove private ASNs in outbound updates\n"
4217 "Replace private ASNs with our ASN in outbound updates\n")
4220 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4222 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4225 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
4226 neighbor_remove_private_as_replace_as_hidden_cmd
,
4227 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4228 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4229 "Remove private ASNs in outbound updates\n"
4230 "Replace private ASNs with our ASN in outbound updates\n")
4232 DEFUN (neighbor_remove_private_as_all_replace_as
,
4233 neighbor_remove_private_as_all_replace_as_cmd
,
4234 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4237 "Remove private ASNs in outbound updates\n"
4238 "Apply to all AS numbers\n"
4239 "Replace private ASNs with our ASN in outbound updates\n")
4242 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4244 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4248 neighbor_remove_private_as_all_replace_as
,
4249 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4250 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4251 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4252 "Remove private ASNs in outbound updates\n"
4253 "Apply to all AS numbers\n"
4254 "Replace private ASNs with our ASN in outbound updates\n")
4256 DEFUN (no_neighbor_remove_private_as
,
4257 no_neighbor_remove_private_as_cmd
,
4258 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4262 "Remove private ASNs in outbound updates\n")
4265 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4266 bgp_node_afi(vty
), bgp_node_safi(vty
),
4267 PEER_FLAG_REMOVE_PRIVATE_AS
);
4270 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4271 no_neighbor_remove_private_as_hidden_cmd
,
4272 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4273 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4274 "Remove private ASNs in outbound updates\n")
4276 DEFUN (no_neighbor_remove_private_as_all
,
4277 no_neighbor_remove_private_as_all_cmd
,
4278 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4282 "Remove private ASNs in outbound updates\n"
4283 "Apply to all AS numbers\n")
4286 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4287 bgp_node_afi(vty
), bgp_node_safi(vty
),
4288 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4291 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4292 no_neighbor_remove_private_as_all_hidden_cmd
,
4293 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4294 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4295 "Remove private ASNs in outbound updates\n"
4296 "Apply to all AS numbers\n")
4298 DEFUN (no_neighbor_remove_private_as_replace_as
,
4299 no_neighbor_remove_private_as_replace_as_cmd
,
4300 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4304 "Remove private ASNs in outbound updates\n"
4305 "Replace private ASNs with our ASN in outbound updates\n")
4308 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4309 bgp_node_afi(vty
), bgp_node_safi(vty
),
4310 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4313 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4314 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4315 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4316 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4317 "Remove private ASNs in outbound updates\n"
4318 "Replace private ASNs with our ASN in outbound updates\n")
4320 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4321 no_neighbor_remove_private_as_all_replace_as_cmd
,
4322 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4326 "Remove private ASNs in outbound updates\n"
4327 "Apply to all AS numbers\n"
4328 "Replace private ASNs with our ASN in outbound updates\n")
4331 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4332 bgp_node_afi(vty
), bgp_node_safi(vty
),
4333 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4337 no_neighbor_remove_private_as_all_replace_as
,
4338 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4339 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4340 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4341 "Remove private ASNs in outbound updates\n"
4342 "Apply to all AS numbers\n"
4343 "Replace private ASNs with our ASN in outbound updates\n")
4346 /* neighbor send-community. */
4347 DEFUN (neighbor_send_community
,
4348 neighbor_send_community_cmd
,
4349 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4352 "Send Community attribute to this neighbor\n")
4356 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4358 PEER_FLAG_SEND_COMMUNITY
);
4361 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4362 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4363 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4364 "Send Community attribute to this neighbor\n")
4366 DEFUN (no_neighbor_send_community
,
4367 no_neighbor_send_community_cmd
,
4368 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4372 "Send Community attribute to this neighbor\n")
4376 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4377 bgp_node_afi(vty
), bgp_node_safi(vty
),
4378 PEER_FLAG_SEND_COMMUNITY
);
4381 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4382 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4383 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4384 "Send Community attribute to this neighbor\n")
4386 /* neighbor send-community extended. */
4387 DEFUN (neighbor_send_community_type
,
4388 neighbor_send_community_type_cmd
,
4389 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4392 "Send Community attribute to this neighbor\n"
4393 "Send Standard and Extended Community attributes\n"
4394 "Send Standard, Large and Extended Community attributes\n"
4395 "Send Extended Community attributes\n"
4396 "Send Standard Community attributes\n"
4397 "Send Large Community attributes\n")
4401 const char *type
= argv
[argc
- 1]->text
;
4403 if (strmatch(type
, "standard")) {
4404 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4405 } else if (strmatch(type
, "extended")) {
4406 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4407 } else if (strmatch(type
, "large")) {
4408 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4409 } else if (strmatch(type
, "both")) {
4410 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4411 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4412 } else { /* if (strmatch(type, "all")) */
4413 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4414 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4415 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4418 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4419 bgp_node_safi(vty
), flag
);
4423 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4424 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4425 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4426 "Send Community attribute to this neighbor\n"
4427 "Send Standard and Extended Community attributes\n"
4428 "Send Standard, Large and Extended Community attributes\n"
4429 "Send Extended Community attributes\n"
4430 "Send Standard Community attributes\n"
4431 "Send Large Community attributes\n")
4433 DEFUN (no_neighbor_send_community_type
,
4434 no_neighbor_send_community_type_cmd
,
4435 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4439 "Send Community attribute to this neighbor\n"
4440 "Send Standard and Extended Community attributes\n"
4441 "Send Standard, Large and Extended Community attributes\n"
4442 "Send Extended Community attributes\n"
4443 "Send Standard Community attributes\n"
4444 "Send Large Community attributes\n")
4448 const char *type
= argv
[argc
- 1]->text
;
4450 if (strmatch(type
, "standard")) {
4451 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4452 } else if (strmatch(type
, "extended")) {
4453 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4454 } else if (strmatch(type
, "large")) {
4455 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4456 } else if (strmatch(type
, "both")) {
4457 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4458 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4459 } else { /* if (strmatch(type, "all")) */
4460 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4461 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4462 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4465 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4466 bgp_node_afi(vty
), bgp_node_safi(vty
),
4471 no_neighbor_send_community_type
,
4472 no_neighbor_send_community_type_hidden_cmd
,
4473 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4474 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4475 "Send Community attribute to this neighbor\n"
4476 "Send Standard and Extended Community attributes\n"
4477 "Send Standard, Large and Extended Community attributes\n"
4478 "Send Extended Community attributes\n"
4479 "Send Standard Community attributes\n"
4480 "Send Large Community attributes\n")
4482 /* neighbor soft-reconfig. */
4483 DEFUN (neighbor_soft_reconfiguration
,
4484 neighbor_soft_reconfiguration_cmd
,
4485 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4488 "Per neighbor soft reconfiguration\n"
4489 "Allow inbound soft reconfiguration for this neighbor\n")
4492 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4494 PEER_FLAG_SOFT_RECONFIG
);
4497 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4498 neighbor_soft_reconfiguration_hidden_cmd
,
4499 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4500 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4501 "Per neighbor soft reconfiguration\n"
4502 "Allow inbound soft reconfiguration for this neighbor\n")
4504 DEFUN (no_neighbor_soft_reconfiguration
,
4505 no_neighbor_soft_reconfiguration_cmd
,
4506 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4510 "Per neighbor soft reconfiguration\n"
4511 "Allow inbound soft reconfiguration for this neighbor\n")
4514 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4515 bgp_node_afi(vty
), bgp_node_safi(vty
),
4516 PEER_FLAG_SOFT_RECONFIG
);
4519 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4520 no_neighbor_soft_reconfiguration_hidden_cmd
,
4521 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4522 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4523 "Per neighbor soft reconfiguration\n"
4524 "Allow inbound soft reconfiguration for this neighbor\n")
4526 DEFUN (neighbor_route_reflector_client
,
4527 neighbor_route_reflector_client_cmd
,
4528 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4531 "Configure a neighbor as Route Reflector client\n")
4537 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4539 return CMD_WARNING_CONFIG_FAILED
;
4541 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4543 PEER_FLAG_REFLECTOR_CLIENT
);
4546 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4547 neighbor_route_reflector_client_hidden_cmd
,
4548 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4549 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4550 "Configure a neighbor as Route Reflector client\n")
4552 DEFUN (no_neighbor_route_reflector_client
,
4553 no_neighbor_route_reflector_client_cmd
,
4554 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4558 "Configure a neighbor as Route Reflector client\n")
4561 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4562 bgp_node_afi(vty
), bgp_node_safi(vty
),
4563 PEER_FLAG_REFLECTOR_CLIENT
);
4566 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4567 no_neighbor_route_reflector_client_hidden_cmd
,
4568 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4569 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4570 "Configure a neighbor as Route Reflector client\n")
4572 /* neighbor route-server-client. */
4573 DEFUN (neighbor_route_server_client
,
4574 neighbor_route_server_client_cmd
,
4575 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4578 "Configure a neighbor as Route Server client\n")
4583 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4585 return CMD_WARNING_CONFIG_FAILED
;
4586 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4588 PEER_FLAG_RSERVER_CLIENT
);
4591 ALIAS_HIDDEN(neighbor_route_server_client
,
4592 neighbor_route_server_client_hidden_cmd
,
4593 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4594 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4595 "Configure a neighbor as Route Server client\n")
4597 DEFUN (no_neighbor_route_server_client
,
4598 no_neighbor_route_server_client_cmd
,
4599 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4603 "Configure a neighbor as Route Server client\n")
4606 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4607 bgp_node_afi(vty
), bgp_node_safi(vty
),
4608 PEER_FLAG_RSERVER_CLIENT
);
4611 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4612 no_neighbor_route_server_client_hidden_cmd
,
4613 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4614 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4615 "Configure a neighbor as Route Server client\n")
4617 DEFUN (neighbor_nexthop_local_unchanged
,
4618 neighbor_nexthop_local_unchanged_cmd
,
4619 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4622 "Configure treatment of outgoing link-local nexthop attribute\n"
4623 "Leave link-local nexthop unchanged for this peer\n")
4626 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4628 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4631 DEFUN (no_neighbor_nexthop_local_unchanged
,
4632 no_neighbor_nexthop_local_unchanged_cmd
,
4633 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4637 "Configure treatment of outgoing link-local-nexthop attribute\n"
4638 "Leave link-local nexthop unchanged for this peer\n")
4641 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4642 bgp_node_afi(vty
), bgp_node_safi(vty
),
4643 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4646 DEFUN (neighbor_attr_unchanged
,
4647 neighbor_attr_unchanged_cmd
,
4648 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4651 "BGP attribute is propagated unchanged to this neighbor\n"
4652 "As-path attribute\n"
4653 "Nexthop attribute\n"
4657 char *peer_str
= argv
[1]->arg
;
4660 afi_t afi
= bgp_node_afi(vty
);
4661 safi_t safi
= bgp_node_safi(vty
);
4663 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4665 return CMD_WARNING_CONFIG_FAILED
;
4667 if (argv_find(argv
, argc
, "as-path", &idx
))
4668 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4670 if (argv_find(argv
, argc
, "next-hop", &idx
))
4671 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4673 if (argv_find(argv
, argc
, "med", &idx
))
4674 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4676 /* no flags means all of them! */
4678 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4679 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4680 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4682 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4683 && peer_af_flag_check(peer
, afi
, safi
,
4684 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4685 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4686 PEER_FLAG_AS_PATH_UNCHANGED
);
4689 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4690 && peer_af_flag_check(peer
, afi
, safi
,
4691 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4692 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4693 PEER_FLAG_NEXTHOP_UNCHANGED
);
4696 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4697 && peer_af_flag_check(peer
, afi
, safi
,
4698 PEER_FLAG_MED_UNCHANGED
)) {
4699 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4700 PEER_FLAG_MED_UNCHANGED
);
4704 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4708 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4709 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4710 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4711 "BGP attribute is propagated unchanged to this neighbor\n"
4712 "As-path attribute\n"
4713 "Nexthop attribute\n"
4716 DEFUN (no_neighbor_attr_unchanged
,
4717 no_neighbor_attr_unchanged_cmd
,
4718 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4722 "BGP attribute is propagated unchanged to this neighbor\n"
4723 "As-path attribute\n"
4724 "Nexthop attribute\n"
4728 char *peer
= argv
[2]->arg
;
4731 if (argv_find(argv
, argc
, "as-path", &idx
))
4732 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4734 if (argv_find(argv
, argc
, "next-hop", &idx
))
4735 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4737 if (argv_find(argv
, argc
, "med", &idx
))
4738 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4740 if (!flags
) // no flags means all of them!
4742 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4743 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4744 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4747 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4748 bgp_node_safi(vty
), flags
);
4752 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4753 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4754 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4755 "BGP attribute is propagated unchanged to this neighbor\n"
4756 "As-path attribute\n"
4757 "Nexthop attribute\n"
4760 /* EBGP multihop configuration. */
4761 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4762 const char *ttl_str
)
4767 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4769 return CMD_WARNING_CONFIG_FAILED
;
4772 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4777 ttl
= strtoul(ttl_str
, NULL
, 10);
4779 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4782 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4786 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4788 return CMD_WARNING_CONFIG_FAILED
;
4790 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4793 /* neighbor ebgp-multihop. */
4794 DEFUN (neighbor_ebgp_multihop
,
4795 neighbor_ebgp_multihop_cmd
,
4796 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4799 "Allow EBGP neighbors not on directly connected networks\n")
4802 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4805 DEFUN (neighbor_ebgp_multihop_ttl
,
4806 neighbor_ebgp_multihop_ttl_cmd
,
4807 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4810 "Allow EBGP neighbors not on directly connected networks\n"
4811 "maximum hop count\n")
4815 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4816 argv
[idx_number
]->arg
);
4819 DEFUN (no_neighbor_ebgp_multihop
,
4820 no_neighbor_ebgp_multihop_cmd
,
4821 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4825 "Allow EBGP neighbors not on directly connected networks\n"
4826 "maximum hop count\n")
4829 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4833 /* disable-connected-check */
4834 DEFUN (neighbor_disable_connected_check
,
4835 neighbor_disable_connected_check_cmd
,
4836 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4839 "one-hop away EBGP peer using loopback address\n"
4840 "Enforce EBGP neighbors perform multihop\n")
4843 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4844 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4847 DEFUN (no_neighbor_disable_connected_check
,
4848 no_neighbor_disable_connected_check_cmd
,
4849 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4853 "one-hop away EBGP peer using loopback address\n"
4854 "Enforce EBGP neighbors perform multihop\n")
4857 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4858 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4862 /* enforce-first-as */
4863 DEFUN (neighbor_enforce_first_as
,
4864 neighbor_enforce_first_as_cmd
,
4865 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4868 "Enforce the first AS for EBGP routes\n")
4872 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4873 PEER_FLAG_ENFORCE_FIRST_AS
);
4876 DEFUN (no_neighbor_enforce_first_as
,
4877 no_neighbor_enforce_first_as_cmd
,
4878 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4882 "Enforce the first AS for EBGP routes\n")
4886 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4887 PEER_FLAG_ENFORCE_FIRST_AS
);
4891 DEFUN (neighbor_description
,
4892 neighbor_description_cmd
,
4893 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4896 "Neighbor specific description\n"
4897 "Up to 80 characters describing this neighbor\n")
4904 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4906 return CMD_WARNING_CONFIG_FAILED
;
4908 str
= argv_concat(argv
, argc
, idx_line
);
4910 peer_description_set(peer
, str
);
4912 XFREE(MTYPE_TMP
, str
);
4917 DEFUN (no_neighbor_description
,
4918 no_neighbor_description_cmd
,
4919 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4923 "Neighbor specific description\n")
4928 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4930 return CMD_WARNING_CONFIG_FAILED
;
4932 peer_description_unset(peer
);
4937 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4938 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4939 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4940 "Neighbor specific description\n"
4941 "Up to 80 characters describing this neighbor\n")
4943 /* Neighbor update-source. */
4944 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4945 const char *source_str
)
4951 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4953 return CMD_WARNING_CONFIG_FAILED
;
4959 if (str2sockunion(source_str
, &su
) == 0)
4960 peer_update_source_addr_set(peer
, &su
);
4962 if (str2prefix(source_str
, &p
)) {
4964 "%% Invalid update-source, remove prefix length \n");
4965 return CMD_WARNING_CONFIG_FAILED
;
4967 peer_update_source_if_set(peer
, source_str
);
4970 peer_update_source_unset(peer
);
4975 #define BGP_UPDATE_SOURCE_HELP_STR \
4978 "Interface name (requires zebra to be running)\n"
4980 DEFUN (neighbor_update_source
,
4981 neighbor_update_source_cmd
,
4982 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4985 "Source of routing updates\n"
4986 BGP_UPDATE_SOURCE_HELP_STR
)
4990 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4991 argv
[idx_peer_2
]->arg
);
4994 DEFUN (no_neighbor_update_source
,
4995 no_neighbor_update_source_cmd
,
4996 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
5000 "Source of routing updates\n"
5001 BGP_UPDATE_SOURCE_HELP_STR
)
5004 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5007 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
5008 afi_t afi
, safi_t safi
,
5009 const char *rmap
, int set
)
5013 struct route_map
*route_map
= NULL
;
5015 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5017 return CMD_WARNING_CONFIG_FAILED
;
5021 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
5022 ret
= peer_default_originate_set(peer
, afi
, safi
,
5025 ret
= peer_default_originate_unset(peer
, afi
, safi
);
5027 return bgp_vty_return(vty
, ret
);
5030 /* neighbor default-originate. */
5031 DEFUN (neighbor_default_originate
,
5032 neighbor_default_originate_cmd
,
5033 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
5036 "Originate default route to this neighbor\n")
5039 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
5041 bgp_node_safi(vty
), NULL
, 1);
5044 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
5045 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
5046 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5047 "Originate default route to this neighbor\n")
5049 DEFUN (neighbor_default_originate_rmap
,
5050 neighbor_default_originate_rmap_cmd
,
5051 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
5054 "Originate default route to this neighbor\n"
5055 "Route-map to specify criteria to originate default\n"
5060 return peer_default_originate_set_vty(
5061 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5062 argv
[idx_word
]->arg
, 1);
5066 neighbor_default_originate_rmap
,
5067 neighbor_default_originate_rmap_hidden_cmd
,
5068 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
5069 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5070 "Originate default route to this neighbor\n"
5071 "Route-map to specify criteria to originate default\n"
5074 DEFUN (no_neighbor_default_originate
,
5075 no_neighbor_default_originate_cmd
,
5076 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
5080 "Originate default route to this neighbor\n"
5081 "Route-map to specify criteria to originate default\n"
5085 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
5087 bgp_node_safi(vty
), NULL
, 0);
5091 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
5092 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
5093 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5094 "Originate default route to this neighbor\n"
5095 "Route-map to specify criteria to originate default\n"
5099 /* Set neighbor's BGP port. */
5100 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
5101 const char *port_str
)
5107 peer
= peer_lookup_vty(vty
, ip_str
);
5109 return CMD_WARNING_CONFIG_FAILED
;
5112 sp
= getservbyname("bgp", "tcp");
5113 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
5115 port
= strtoul(port_str
, NULL
, 10);
5118 peer_port_set(peer
, port
);
5123 /* Set specified peer's BGP port. */
5124 DEFUN (neighbor_port
,
5126 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
5129 "Neighbor's BGP port\n"
5130 "TCP port number\n")
5134 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
5135 argv
[idx_number
]->arg
);
5138 DEFUN (no_neighbor_port
,
5139 no_neighbor_port_cmd
,
5140 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
5144 "Neighbor's BGP port\n"
5145 "TCP port number\n")
5148 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
5152 /* neighbor weight. */
5153 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5154 safi_t safi
, const char *weight_str
)
5158 unsigned long weight
;
5160 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5162 return CMD_WARNING_CONFIG_FAILED
;
5164 weight
= strtoul(weight_str
, NULL
, 10);
5166 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
5167 return bgp_vty_return(vty
, ret
);
5170 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5176 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5178 return CMD_WARNING_CONFIG_FAILED
;
5180 ret
= peer_weight_unset(peer
, afi
, safi
);
5181 return bgp_vty_return(vty
, ret
);
5184 DEFUN (neighbor_weight
,
5185 neighbor_weight_cmd
,
5186 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5189 "Set default weight for routes from this neighbor\n"
5194 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5195 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
5198 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
5199 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5200 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5201 "Set default weight for routes from this neighbor\n"
5204 DEFUN (no_neighbor_weight
,
5205 no_neighbor_weight_cmd
,
5206 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5210 "Set default weight for routes from this neighbor\n"
5214 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
5215 bgp_node_afi(vty
), bgp_node_safi(vty
));
5218 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
5219 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5220 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5221 "Set default weight for routes from this neighbor\n"
5225 /* Override capability negotiation. */
5226 DEFUN (neighbor_override_capability
,
5227 neighbor_override_capability_cmd
,
5228 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5231 "Override capability negotiation result\n")
5234 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5235 PEER_FLAG_OVERRIDE_CAPABILITY
);
5238 DEFUN (no_neighbor_override_capability
,
5239 no_neighbor_override_capability_cmd
,
5240 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5244 "Override capability negotiation result\n")
5247 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5248 PEER_FLAG_OVERRIDE_CAPABILITY
);
5251 DEFUN (neighbor_strict_capability
,
5252 neighbor_strict_capability_cmd
,
5253 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5256 "Strict capability negotiation match\n")
5260 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5261 PEER_FLAG_STRICT_CAP_MATCH
);
5264 DEFUN (no_neighbor_strict_capability
,
5265 no_neighbor_strict_capability_cmd
,
5266 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5270 "Strict capability negotiation match\n")
5274 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5275 PEER_FLAG_STRICT_CAP_MATCH
);
5278 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5279 const char *keep_str
, const char *hold_str
)
5286 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5288 return CMD_WARNING_CONFIG_FAILED
;
5290 keepalive
= strtoul(keep_str
, NULL
, 10);
5291 holdtime
= strtoul(hold_str
, NULL
, 10);
5293 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5295 return bgp_vty_return(vty
, ret
);
5298 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5303 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5305 return CMD_WARNING_CONFIG_FAILED
;
5307 ret
= peer_timers_unset(peer
);
5309 return bgp_vty_return(vty
, ret
);
5312 DEFUN (neighbor_timers
,
5313 neighbor_timers_cmd
,
5314 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5317 "BGP per neighbor timers\n"
5318 "Keepalive interval\n"
5323 int idx_number_2
= 4;
5324 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5325 argv
[idx_number
]->arg
,
5326 argv
[idx_number_2
]->arg
);
5329 DEFUN (no_neighbor_timers
,
5330 no_neighbor_timers_cmd
,
5331 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5335 "BGP per neighbor timers\n"
5336 "Keepalive interval\n"
5340 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5344 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5345 const char *time_str
)
5351 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5353 return CMD_WARNING_CONFIG_FAILED
;
5355 connect
= strtoul(time_str
, NULL
, 10);
5357 ret
= peer_timers_connect_set(peer
, connect
);
5359 return bgp_vty_return(vty
, ret
);
5362 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5367 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5369 return CMD_WARNING_CONFIG_FAILED
;
5371 ret
= peer_timers_connect_unset(peer
);
5373 return bgp_vty_return(vty
, ret
);
5376 DEFUN (neighbor_timers_connect
,
5377 neighbor_timers_connect_cmd
,
5378 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5381 "BGP per neighbor timers\n"
5382 "BGP connect timer\n"
5387 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5388 argv
[idx_number
]->arg
);
5391 DEFUN (no_neighbor_timers_connect
,
5392 no_neighbor_timers_connect_cmd
,
5393 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5397 "BGP per neighbor timers\n"
5398 "BGP connect timer\n"
5402 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5406 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5407 const char *time_str
, int set
)
5411 uint32_t routeadv
= 0;
5413 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5415 return CMD_WARNING_CONFIG_FAILED
;
5418 routeadv
= strtoul(time_str
, NULL
, 10);
5421 ret
= peer_advertise_interval_set(peer
, routeadv
);
5423 ret
= peer_advertise_interval_unset(peer
);
5425 return bgp_vty_return(vty
, ret
);
5428 DEFUN (neighbor_advertise_interval
,
5429 neighbor_advertise_interval_cmd
,
5430 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5433 "Minimum interval between sending BGP routing updates\n"
5434 "time in seconds\n")
5438 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5439 argv
[idx_number
]->arg
, 1);
5442 DEFUN (no_neighbor_advertise_interval
,
5443 no_neighbor_advertise_interval_cmd
,
5444 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5448 "Minimum interval between sending BGP routing updates\n"
5449 "time in seconds\n")
5452 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5456 /* Time to wait before processing route-map updates */
5457 DEFUN (bgp_set_route_map_delay_timer
,
5458 bgp_set_route_map_delay_timer_cmd
,
5459 "bgp route-map delay-timer (0-600)",
5461 "BGP route-map delay timer\n"
5462 "Time in secs to wait before processing route-map changes\n"
5463 "0 disables the timer, no route updates happen when route-maps change\n")
5466 uint32_t rmap_delay_timer
;
5468 if (argv
[idx_number
]->arg
) {
5469 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5470 bm
->rmap_update_timer
= rmap_delay_timer
;
5472 /* if the dynamic update handling is being disabled, and a timer
5474 * running, stop the timer and act as if the timer has already
5477 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5478 BGP_TIMER_OFF(bm
->t_rmap_update
);
5479 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5484 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5485 return CMD_WARNING_CONFIG_FAILED
;
5489 DEFUN (no_bgp_set_route_map_delay_timer
,
5490 no_bgp_set_route_map_delay_timer_cmd
,
5491 "no bgp route-map delay-timer [(0-600)]",
5494 "Default BGP route-map delay timer\n"
5495 "Reset to default time to wait for processing route-map changes\n"
5496 "0 disables the timer, no route updates happen when route-maps change\n")
5499 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5505 /* neighbor interface */
5506 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5511 peer
= peer_lookup_vty(vty
, ip_str
);
5512 if (!peer
|| peer
->conf_if
) {
5513 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5514 return CMD_WARNING_CONFIG_FAILED
;
5518 peer_interface_set(peer
, str
);
5520 peer_interface_unset(peer
);
5525 DEFUN (neighbor_interface
,
5526 neighbor_interface_cmd
,
5527 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5535 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5538 DEFUN (no_neighbor_interface
,
5539 no_neighbor_interface_cmd
,
5540 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5548 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5551 DEFUN (neighbor_distribute_list
,
5552 neighbor_distribute_list_cmd
,
5553 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5556 "Filter updates to/from this neighbor\n"
5557 "IP access-list number\n"
5558 "IP access-list number (expanded range)\n"
5559 "IP Access-list name\n"
5560 "Filter incoming updates\n"
5561 "Filter outgoing updates\n")
5568 const char *pstr
= argv
[idx_peer
]->arg
;
5569 const char *acl
= argv
[idx_acl
]->arg
;
5570 const char *inout
= argv
[argc
- 1]->text
;
5572 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5574 return CMD_WARNING_CONFIG_FAILED
;
5576 /* Check filter direction. */
5577 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5578 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5581 return bgp_vty_return(vty
, ret
);
5585 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5586 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5587 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5588 "Filter updates to/from this neighbor\n"
5589 "IP access-list number\n"
5590 "IP access-list number (expanded range)\n"
5591 "IP Access-list name\n"
5592 "Filter incoming updates\n"
5593 "Filter outgoing updates\n")
5595 DEFUN (no_neighbor_distribute_list
,
5596 no_neighbor_distribute_list_cmd
,
5597 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5601 "Filter updates to/from this neighbor\n"
5602 "IP access-list number\n"
5603 "IP access-list number (expanded range)\n"
5604 "IP Access-list name\n"
5605 "Filter incoming updates\n"
5606 "Filter outgoing updates\n")
5612 const char *pstr
= argv
[idx_peer
]->arg
;
5613 const char *inout
= argv
[argc
- 1]->text
;
5615 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5617 return CMD_WARNING_CONFIG_FAILED
;
5619 /* Check filter direction. */
5620 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5621 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5624 return bgp_vty_return(vty
, ret
);
5628 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5629 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5630 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5631 "Filter updates to/from this neighbor\n"
5632 "IP access-list number\n"
5633 "IP access-list number (expanded range)\n"
5634 "IP Access-list name\n"
5635 "Filter incoming updates\n"
5636 "Filter outgoing updates\n")
5638 /* Set prefix list to the peer. */
5639 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5640 afi_t afi
, safi_t safi
,
5641 const char *name_str
,
5642 const char *direct_str
)
5645 int direct
= FILTER_IN
;
5648 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5650 return CMD_WARNING_CONFIG_FAILED
;
5652 /* Check filter direction. */
5653 if (strncmp(direct_str
, "i", 1) == 0)
5655 else if (strncmp(direct_str
, "o", 1) == 0)
5656 direct
= FILTER_OUT
;
5658 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5660 return bgp_vty_return(vty
, ret
);
5663 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5664 afi_t afi
, safi_t safi
,
5665 const char *direct_str
)
5669 int direct
= FILTER_IN
;
5671 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5673 return CMD_WARNING_CONFIG_FAILED
;
5675 /* Check filter direction. */
5676 if (strncmp(direct_str
, "i", 1) == 0)
5678 else if (strncmp(direct_str
, "o", 1) == 0)
5679 direct
= FILTER_OUT
;
5681 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5683 return bgp_vty_return(vty
, ret
);
5686 DEFUN (neighbor_prefix_list
,
5687 neighbor_prefix_list_cmd
,
5688 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5691 "Filter updates to/from this neighbor\n"
5692 "Name of a prefix list\n"
5693 "Filter incoming updates\n"
5694 "Filter outgoing updates\n")
5699 return peer_prefix_list_set_vty(
5700 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5701 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5704 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5705 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5706 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5707 "Filter updates to/from this neighbor\n"
5708 "Name of a prefix list\n"
5709 "Filter incoming updates\n"
5710 "Filter outgoing updates\n")
5712 DEFUN (no_neighbor_prefix_list
,
5713 no_neighbor_prefix_list_cmd
,
5714 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5718 "Filter updates to/from this neighbor\n"
5719 "Name of a prefix list\n"
5720 "Filter incoming updates\n"
5721 "Filter outgoing updates\n")
5725 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5726 bgp_node_afi(vty
), bgp_node_safi(vty
),
5727 argv
[idx_in_out
]->arg
);
5730 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5731 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5732 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5733 "Filter updates to/from this neighbor\n"
5734 "Name of a prefix list\n"
5735 "Filter incoming updates\n"
5736 "Filter outgoing updates\n")
5738 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5739 safi_t safi
, const char *name_str
,
5740 const char *direct_str
)
5744 int direct
= FILTER_IN
;
5746 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5748 return CMD_WARNING_CONFIG_FAILED
;
5750 /* Check filter direction. */
5751 if (strncmp(direct_str
, "i", 1) == 0)
5753 else if (strncmp(direct_str
, "o", 1) == 0)
5754 direct
= FILTER_OUT
;
5756 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5758 return bgp_vty_return(vty
, ret
);
5761 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5762 safi_t safi
, const char *direct_str
)
5766 int direct
= FILTER_IN
;
5768 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5770 return CMD_WARNING_CONFIG_FAILED
;
5772 /* Check filter direction. */
5773 if (strncmp(direct_str
, "i", 1) == 0)
5775 else if (strncmp(direct_str
, "o", 1) == 0)
5776 direct
= FILTER_OUT
;
5778 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5780 return bgp_vty_return(vty
, ret
);
5783 DEFUN (neighbor_filter_list
,
5784 neighbor_filter_list_cmd
,
5785 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5788 "Establish BGP filters\n"
5789 "AS path access-list name\n"
5790 "Filter incoming routes\n"
5791 "Filter outgoing routes\n")
5796 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5797 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5798 argv
[idx_in_out
]->arg
);
5801 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5802 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5803 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5804 "Establish BGP filters\n"
5805 "AS path access-list name\n"
5806 "Filter incoming routes\n"
5807 "Filter outgoing routes\n")
5809 DEFUN (no_neighbor_filter_list
,
5810 no_neighbor_filter_list_cmd
,
5811 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5815 "Establish BGP filters\n"
5816 "AS path access-list name\n"
5817 "Filter incoming routes\n"
5818 "Filter outgoing routes\n")
5822 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5823 bgp_node_afi(vty
), bgp_node_safi(vty
),
5824 argv
[idx_in_out
]->arg
);
5827 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5828 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5829 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5830 "Establish BGP filters\n"
5831 "AS path access-list name\n"
5832 "Filter incoming routes\n"
5833 "Filter outgoing routes\n")
5835 /* Set route-map to the peer. */
5836 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5837 afi_t afi
, safi_t safi
, const char *name_str
,
5838 const char *direct_str
)
5842 int direct
= RMAP_IN
;
5843 struct route_map
*route_map
;
5845 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5847 return CMD_WARNING_CONFIG_FAILED
;
5849 /* Check filter direction. */
5850 if (strncmp(direct_str
, "in", 2) == 0)
5852 else if (strncmp(direct_str
, "o", 1) == 0)
5855 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5856 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
5858 return bgp_vty_return(vty
, ret
);
5861 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5862 afi_t afi
, safi_t safi
,
5863 const char *direct_str
)
5867 int direct
= RMAP_IN
;
5869 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5871 return CMD_WARNING_CONFIG_FAILED
;
5873 /* Check filter direction. */
5874 if (strncmp(direct_str
, "in", 2) == 0)
5876 else if (strncmp(direct_str
, "o", 1) == 0)
5879 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5881 return bgp_vty_return(vty
, ret
);
5884 DEFUN (neighbor_route_map
,
5885 neighbor_route_map_cmd
,
5886 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5889 "Apply route map to neighbor\n"
5890 "Name of route map\n"
5891 "Apply map to incoming routes\n"
5892 "Apply map to outbound routes\n")
5897 return peer_route_map_set_vty(
5898 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5899 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5902 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5903 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5904 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5905 "Apply route map to neighbor\n"
5906 "Name of route map\n"
5907 "Apply map to incoming routes\n"
5908 "Apply map to outbound routes\n")
5910 DEFUN (no_neighbor_route_map
,
5911 no_neighbor_route_map_cmd
,
5912 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5916 "Apply route map to neighbor\n"
5917 "Name of route map\n"
5918 "Apply map to incoming routes\n"
5919 "Apply map to outbound routes\n")
5923 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5924 bgp_node_afi(vty
), bgp_node_safi(vty
),
5925 argv
[idx_in_out
]->arg
);
5928 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5929 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5930 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5931 "Apply route map to neighbor\n"
5932 "Name of route map\n"
5933 "Apply map to incoming routes\n"
5934 "Apply map to outbound routes\n")
5936 /* Set unsuppress-map to the peer. */
5937 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5938 afi_t afi
, safi_t safi
,
5939 const char *name_str
)
5943 struct route_map
*route_map
;
5945 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5947 return CMD_WARNING_CONFIG_FAILED
;
5949 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5950 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
5952 return bgp_vty_return(vty
, ret
);
5955 /* Unset route-map from the peer. */
5956 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5957 afi_t afi
, safi_t safi
)
5962 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5964 return CMD_WARNING_CONFIG_FAILED
;
5966 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5968 return bgp_vty_return(vty
, ret
);
5971 DEFUN (neighbor_unsuppress_map
,
5972 neighbor_unsuppress_map_cmd
,
5973 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5976 "Route-map to selectively unsuppress suppressed routes\n"
5977 "Name of route map\n")
5981 return peer_unsuppress_map_set_vty(
5982 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5983 argv
[idx_word
]->arg
);
5986 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5987 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5988 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5989 "Route-map to selectively unsuppress suppressed routes\n"
5990 "Name of route map\n")
5992 DEFUN (no_neighbor_unsuppress_map
,
5993 no_neighbor_unsuppress_map_cmd
,
5994 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5998 "Route-map to selectively unsuppress suppressed routes\n"
5999 "Name of route map\n")
6002 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
6004 bgp_node_safi(vty
));
6007 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
6008 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
6009 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6010 "Route-map to selectively unsuppress suppressed routes\n"
6011 "Name of route map\n")
6013 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
6014 afi_t afi
, safi_t safi
,
6015 const char *num_str
,
6016 const char *threshold_str
, int warning
,
6017 const char *restart_str
)
6025 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6027 return CMD_WARNING_CONFIG_FAILED
;
6029 max
= strtoul(num_str
, NULL
, 10);
6031 threshold
= atoi(threshold_str
);
6033 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
6036 restart
= atoi(restart_str
);
6040 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
6043 return bgp_vty_return(vty
, ret
);
6046 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
6047 afi_t afi
, safi_t safi
)
6052 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6054 return CMD_WARNING_CONFIG_FAILED
;
6056 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
6058 return bgp_vty_return(vty
, ret
);
6061 /* Maximum number of prefix configuration. prefix count is different
6062 for each peer configuration. So this configuration can be set for
6063 each peer configuration. */
6064 DEFUN (neighbor_maximum_prefix
,
6065 neighbor_maximum_prefix_cmd
,
6066 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
6069 "Maximum number of prefix accept from this peer\n"
6070 "maximum no. of prefix limit\n")
6074 return peer_maximum_prefix_set_vty(
6075 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6076 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
6079 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
6080 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
6081 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6082 "Maximum number of prefix accept from this peer\n"
6083 "maximum no. of prefix limit\n")
6085 DEFUN (neighbor_maximum_prefix_threshold
,
6086 neighbor_maximum_prefix_threshold_cmd
,
6087 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
6090 "Maximum number of prefix accept from this peer\n"
6091 "maximum no. of prefix limit\n"
6092 "Threshold value (%) at which to generate a warning msg\n")
6096 int idx_number_2
= 4;
6097 return peer_maximum_prefix_set_vty(
6098 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6099 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
6103 neighbor_maximum_prefix_threshold
,
6104 neighbor_maximum_prefix_threshold_hidden_cmd
,
6105 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
6106 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6107 "Maximum number of prefix accept from this peer\n"
6108 "maximum no. of prefix limit\n"
6109 "Threshold value (%) at which to generate a warning msg\n")
6111 DEFUN (neighbor_maximum_prefix_warning
,
6112 neighbor_maximum_prefix_warning_cmd
,
6113 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6116 "Maximum number of prefix accept from this peer\n"
6117 "maximum no. of prefix limit\n"
6118 "Only give warning message when limit is exceeded\n")
6122 return peer_maximum_prefix_set_vty(
6123 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6124 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
6128 neighbor_maximum_prefix_warning
,
6129 neighbor_maximum_prefix_warning_hidden_cmd
,
6130 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6131 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6132 "Maximum number of prefix accept from this peer\n"
6133 "maximum no. of prefix limit\n"
6134 "Only give warning message when limit is exceeded\n")
6136 DEFUN (neighbor_maximum_prefix_threshold_warning
,
6137 neighbor_maximum_prefix_threshold_warning_cmd
,
6138 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6141 "Maximum number of prefix accept from this peer\n"
6142 "maximum no. of prefix limit\n"
6143 "Threshold value (%) at which to generate a warning msg\n"
6144 "Only give warning message when limit is exceeded\n")
6148 int idx_number_2
= 4;
6149 return peer_maximum_prefix_set_vty(
6150 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6151 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
6155 neighbor_maximum_prefix_threshold_warning
,
6156 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
6157 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6158 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6159 "Maximum number of prefix accept from this peer\n"
6160 "maximum no. of prefix limit\n"
6161 "Threshold value (%) at which to generate a warning msg\n"
6162 "Only give warning message when limit is exceeded\n")
6164 DEFUN (neighbor_maximum_prefix_restart
,
6165 neighbor_maximum_prefix_restart_cmd
,
6166 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6169 "Maximum number of prefix accept from this peer\n"
6170 "maximum no. of prefix limit\n"
6171 "Restart bgp connection after limit is exceeded\n"
6172 "Restart interval in minutes\n")
6176 int idx_number_2
= 5;
6177 return peer_maximum_prefix_set_vty(
6178 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6179 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
6183 neighbor_maximum_prefix_restart
,
6184 neighbor_maximum_prefix_restart_hidden_cmd
,
6185 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6186 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6187 "Maximum number of prefix accept from this peer\n"
6188 "maximum no. of prefix limit\n"
6189 "Restart bgp connection after limit is exceeded\n"
6190 "Restart interval in minutes\n")
6192 DEFUN (neighbor_maximum_prefix_threshold_restart
,
6193 neighbor_maximum_prefix_threshold_restart_cmd
,
6194 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6197 "Maximum number of prefixes to accept from this peer\n"
6198 "maximum no. of prefix limit\n"
6199 "Threshold value (%) at which to generate a warning msg\n"
6200 "Restart bgp connection after limit is exceeded\n"
6201 "Restart interval in minutes\n")
6205 int idx_number_2
= 4;
6206 int idx_number_3
= 6;
6207 return peer_maximum_prefix_set_vty(
6208 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6209 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
6210 argv
[idx_number_3
]->arg
);
6214 neighbor_maximum_prefix_threshold_restart
,
6215 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
6216 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6217 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6218 "Maximum number of prefixes to accept from this peer\n"
6219 "maximum no. of prefix limit\n"
6220 "Threshold value (%) at which to generate a warning msg\n"
6221 "Restart bgp connection after limit is exceeded\n"
6222 "Restart interval in minutes\n")
6224 DEFUN (no_neighbor_maximum_prefix
,
6225 no_neighbor_maximum_prefix_cmd
,
6226 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6230 "Maximum number of prefixes to accept from this peer\n"
6231 "maximum no. of prefix limit\n"
6232 "Threshold value (%) at which to generate a warning msg\n"
6233 "Restart bgp connection after limit is exceeded\n"
6234 "Restart interval in minutes\n"
6235 "Only give warning message when limit is exceeded\n")
6238 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
6240 bgp_node_safi(vty
));
6244 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
6245 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6246 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6247 "Maximum number of prefixes to accept from this peer\n"
6248 "maximum no. of prefix limit\n"
6249 "Threshold value (%) at which to generate a warning msg\n"
6250 "Restart bgp connection after limit is exceeded\n"
6251 "Restart interval in minutes\n"
6252 "Only give warning message when limit is exceeded\n")
6255 /* "neighbor allowas-in" */
6256 DEFUN (neighbor_allowas_in
,
6257 neighbor_allowas_in_cmd
,
6258 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6261 "Accept as-path with my AS present in it\n"
6262 "Number of occurrences of AS number\n"
6263 "Only accept my AS in the as-path if the route was originated in my AS\n")
6266 int idx_number_origin
= 3;
6272 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6274 return CMD_WARNING_CONFIG_FAILED
;
6276 if (argc
<= idx_number_origin
)
6279 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6282 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6285 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6288 return bgp_vty_return(vty
, ret
);
6292 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6293 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6294 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6295 "Accept as-path with my AS present in it\n"
6296 "Number of occurrences of AS number\n"
6297 "Only accept my AS in the as-path if the route was originated in my AS\n")
6299 DEFUN (no_neighbor_allowas_in
,
6300 no_neighbor_allowas_in_cmd
,
6301 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6305 "allow local ASN appears in aspath attribute\n"
6306 "Number of occurrences of AS number\n"
6307 "Only accept my AS in the as-path if the route was originated in my AS\n")
6313 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6315 return CMD_WARNING_CONFIG_FAILED
;
6317 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6318 bgp_node_safi(vty
));
6320 return bgp_vty_return(vty
, ret
);
6324 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6325 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6326 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6327 "allow local ASN appears in aspath attribute\n"
6328 "Number of occurrences of AS number\n"
6329 "Only accept my AS in the as-path if the route was originated in my AS\n")
6331 DEFUN (neighbor_ttl_security
,
6332 neighbor_ttl_security_cmd
,
6333 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6336 "BGP ttl-security parameters\n"
6337 "Specify the maximum number of hops to the BGP peer\n"
6338 "Number of hops to BGP peer\n")
6345 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6347 return CMD_WARNING_CONFIG_FAILED
;
6349 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6352 * If 'neighbor swpX', then this is for directly connected peers,
6353 * we should not accept a ttl-security hops value greater than 1.
6355 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6357 "%s is directly connected peer, hops cannot exceed 1\n",
6358 argv
[idx_peer
]->arg
);
6359 return CMD_WARNING_CONFIG_FAILED
;
6362 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6365 DEFUN (no_neighbor_ttl_security
,
6366 no_neighbor_ttl_security_cmd
,
6367 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6371 "BGP ttl-security parameters\n"
6372 "Specify the maximum number of hops to the BGP peer\n"
6373 "Number of hops to BGP peer\n")
6378 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6380 return CMD_WARNING_CONFIG_FAILED
;
6382 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6385 DEFUN (neighbor_addpath_tx_all_paths
,
6386 neighbor_addpath_tx_all_paths_cmd
,
6387 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6390 "Use addpath to advertise all paths to a neighbor\n")
6395 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6397 return CMD_WARNING_CONFIG_FAILED
;
6399 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6404 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6405 neighbor_addpath_tx_all_paths_hidden_cmd
,
6406 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6407 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6408 "Use addpath to advertise all paths to a neighbor\n")
6410 DEFUN (no_neighbor_addpath_tx_all_paths
,
6411 no_neighbor_addpath_tx_all_paths_cmd
,
6412 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6416 "Use addpath to advertise all paths to a neighbor\n")
6421 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6423 return CMD_WARNING_CONFIG_FAILED
;
6425 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6426 != BGP_ADDPATH_ALL
) {
6428 "%% Peer not currently configured to transmit all paths.");
6429 return CMD_WARNING_CONFIG_FAILED
;
6432 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6438 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6439 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6440 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6441 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6442 "Use addpath to advertise all paths to a neighbor\n")
6444 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6445 neighbor_addpath_tx_bestpath_per_as_cmd
,
6446 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6449 "Use addpath to advertise the bestpath per each neighboring AS\n")
6454 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6456 return CMD_WARNING_CONFIG_FAILED
;
6458 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6459 BGP_ADDPATH_BEST_PER_AS
);
6464 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6465 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6466 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6467 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6468 "Use addpath to advertise the bestpath per each neighboring AS\n")
6470 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6471 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6472 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6476 "Use addpath to advertise the bestpath per each neighboring AS\n")
6481 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6483 return CMD_WARNING_CONFIG_FAILED
;
6485 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6486 != BGP_ADDPATH_BEST_PER_AS
) {
6488 "%% Peer not currently configured to transmit all best path per as.");
6489 return CMD_WARNING_CONFIG_FAILED
;
6492 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6498 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6499 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6500 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6501 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6502 "Use addpath to advertise the bestpath per each neighboring AS\n")
6505 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
6506 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
6509 "Detect AS loops before sending to neighbor\n")
6513 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
6515 return CMD_WARNING_CONFIG_FAILED
;
6517 peer
->as_path_loop_detection
= true;
6523 no_neighbor_aspath_loop_detection
,
6524 no_neighbor_aspath_loop_detection_cmd
,
6525 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
6529 "Detect AS loops before sending to neighbor\n")
6533 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
6535 return CMD_WARNING_CONFIG_FAILED
;
6537 peer
->as_path_loop_detection
= false;
6542 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6543 struct ecommunity
**list
)
6545 struct ecommunity
*ecom
= NULL
;
6546 struct ecommunity
*ecomadd
;
6548 for (; argc
; --argc
, ++argv
) {
6550 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6551 ECOMMUNITY_ROUTE_TARGET
, 0);
6553 vty_out(vty
, "Malformed community-list value\n");
6555 ecommunity_free(&ecom
);
6556 return CMD_WARNING_CONFIG_FAILED
;
6560 ecommunity_merge(ecom
, ecomadd
);
6561 ecommunity_free(&ecomadd
);
6568 ecommunity_free(&*list
);
6576 * v2vimport is true if we are handling a `import vrf ...` command
6578 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6582 switch (vty
->node
) {
6591 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6596 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6597 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6598 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6599 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6601 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6605 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6606 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6607 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6608 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6610 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6617 DEFPY (af_rd_vpn_export
,
6618 af_rd_vpn_export_cmd
,
6619 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6621 "Specify route distinguisher\n"
6622 "Between current address-family and vpn\n"
6623 "For routes leaked from current address-family to vpn\n"
6624 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6626 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6627 struct prefix_rd prd
;
6633 if (argv_find(argv
, argc
, "no", &idx
))
6637 ret
= str2prefix_rd(rd_str
, &prd
);
6639 vty_out(vty
, "%% Malformed rd\n");
6640 return CMD_WARNING_CONFIG_FAILED
;
6644 afi
= vpn_policy_getafi(vty
, bgp
, false);
6646 return CMD_WARNING_CONFIG_FAILED
;
6649 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6651 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6652 bgp_get_default(), bgp
);
6655 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6656 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6657 BGP_VPN_POLICY_TOVPN_RD_SET
);
6659 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6660 BGP_VPN_POLICY_TOVPN_RD_SET
);
6663 /* post-change: re-export vpn routes */
6664 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6665 bgp_get_default(), bgp
);
6670 ALIAS (af_rd_vpn_export
,
6671 af_no_rd_vpn_export_cmd
,
6674 "Specify route distinguisher\n"
6675 "Between current address-family and vpn\n"
6676 "For routes leaked from current address-family to vpn\n")
6678 DEFPY (af_label_vpn_export
,
6679 af_label_vpn_export_cmd
,
6680 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6682 "label value for VRF\n"
6683 "Between current address-family and vpn\n"
6684 "For routes leaked from current address-family to vpn\n"
6685 "Label Value <0-1048575>\n"
6686 "Automatically assign a label\n")
6688 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6689 mpls_label_t label
= MPLS_LABEL_NONE
;
6694 if (argv_find(argv
, argc
, "no", &idx
))
6697 /* If "no ...", squash trailing parameter */
6703 label
= label_val
; /* parser should force unsigned */
6706 afi
= vpn_policy_getafi(vty
, bgp
, false);
6708 return CMD_WARNING_CONFIG_FAILED
;
6711 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6712 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6717 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6719 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6720 bgp_get_default(), bgp
);
6722 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6723 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6725 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6728 * label has previously been automatically
6729 * assigned by labelpool: release it
6731 * NB if tovpn_label == MPLS_LABEL_NONE it
6732 * means the automatic assignment is in flight
6733 * and therefore the labelpool callback must
6734 * detect that the auto label is not needed.
6737 bgp_lp_release(LP_TYPE_VRF
,
6738 &bgp
->vpn_policy
[afi
],
6739 bgp
->vpn_policy
[afi
].tovpn_label
);
6741 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6742 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6745 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6747 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6748 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6749 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6750 vpn_leak_label_callback
);
6753 /* post-change: re-export vpn routes */
6754 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6755 bgp_get_default(), bgp
);
6760 ALIAS (af_label_vpn_export
,
6761 af_no_label_vpn_export_cmd
,
6762 "no label vpn export",
6764 "label value for VRF\n"
6765 "Between current address-family and vpn\n"
6766 "For routes leaked from current address-family to vpn\n")
6768 DEFPY (af_nexthop_vpn_export
,
6769 af_nexthop_vpn_export_cmd
,
6770 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6772 "Specify next hop to use for VRF advertised prefixes\n"
6773 "Between current address-family and vpn\n"
6774 "For routes leaked from current address-family to vpn\n"
6778 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6784 if (argv_find(argv
, argc
, "no", &idx
))
6788 if (!sockunion2hostprefix(nexthop_str
, &p
))
6789 return CMD_WARNING_CONFIG_FAILED
;
6792 afi
= vpn_policy_getafi(vty
, bgp
, false);
6794 return CMD_WARNING_CONFIG_FAILED
;
6797 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6799 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6800 bgp_get_default(), bgp
);
6803 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6804 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6805 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6807 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6808 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6811 /* post-change: re-export vpn routes */
6812 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6813 bgp_get_default(), bgp
);
6818 ALIAS (af_nexthop_vpn_export
,
6819 af_no_nexthop_vpn_export_cmd
,
6820 "no nexthop vpn export",
6822 "Specify next hop to use for VRF advertised prefixes\n"
6823 "Between current address-family and vpn\n"
6824 "For routes leaked from current address-family to vpn\n")
6826 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6828 if (!strcmp(dstr
, "import")) {
6829 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6830 } else if (!strcmp(dstr
, "export")) {
6831 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6832 } else if (!strcmp(dstr
, "both")) {
6833 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6834 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6836 vty_out(vty
, "%% direction parse error\n");
6837 return CMD_WARNING_CONFIG_FAILED
;
6842 DEFPY (af_rt_vpn_imexport
,
6843 af_rt_vpn_imexport_cmd
,
6844 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6846 "Specify route target list\n"
6847 "Specify route target list\n"
6848 "Between current address-family and vpn\n"
6849 "For routes leaked from vpn to current address-family: match any\n"
6850 "For routes leaked from current address-family to vpn: set\n"
6851 "both import: match any and export: set\n"
6852 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6854 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6856 struct ecommunity
*ecom
= NULL
;
6857 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6858 vpn_policy_direction_t dir
;
6863 if (argv_find(argv
, argc
, "no", &idx
))
6866 afi
= vpn_policy_getafi(vty
, bgp
, false);
6868 return CMD_WARNING_CONFIG_FAILED
;
6870 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6871 if (ret
!= CMD_SUCCESS
)
6875 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6876 vty_out(vty
, "%% Missing RTLIST\n");
6877 return CMD_WARNING_CONFIG_FAILED
;
6879 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6880 if (ret
!= CMD_SUCCESS
) {
6885 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6889 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6892 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6894 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6895 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6896 ecommunity_dup(ecom
);
6898 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6900 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6901 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6904 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6908 ecommunity_free(&ecom
);
6913 ALIAS (af_rt_vpn_imexport
,
6914 af_no_rt_vpn_imexport_cmd
,
6915 "no <rt|route-target> vpn <import|export|both>$direction_str",
6917 "Specify route target list\n"
6918 "Specify route target list\n"
6919 "Between current address-family and vpn\n"
6920 "For routes leaked from vpn to current address-family\n"
6921 "For routes leaked from current address-family to vpn\n"
6922 "both import and export\n")
6924 DEFPY (af_route_map_vpn_imexport
,
6925 af_route_map_vpn_imexport_cmd
,
6926 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6927 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6929 "Specify route map\n"
6930 "Between current address-family and vpn\n"
6931 "For routes leaked from vpn to current address-family\n"
6932 "For routes leaked from current address-family to vpn\n"
6933 "name of route-map\n")
6935 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6937 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6938 vpn_policy_direction_t dir
;
6943 if (argv_find(argv
, argc
, "no", &idx
))
6946 afi
= vpn_policy_getafi(vty
, bgp
, false);
6948 return CMD_WARNING_CONFIG_FAILED
;
6950 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6951 if (ret
!= CMD_SUCCESS
)
6954 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6958 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6961 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6962 XFREE(MTYPE_ROUTE_MAP_NAME
,
6963 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6964 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6965 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6966 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6967 route_map_lookup_warn_noexist(vty
, rmap_str
);
6968 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6971 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6972 XFREE(MTYPE_ROUTE_MAP_NAME
,
6973 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6974 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6975 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6978 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6984 ALIAS (af_route_map_vpn_imexport
,
6985 af_no_route_map_vpn_imexport_cmd
,
6986 "no route-map vpn <import|export>$direction_str",
6988 "Specify route map\n"
6989 "Between current address-family and vpn\n"
6990 "For routes leaked from vpn to current address-family\n"
6991 "For routes leaked from current address-family to vpn\n")
6993 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6994 "[no] import vrf route-map RMAP$rmap_str",
6996 "Import routes from another VRF\n"
6997 "Vrf routes being filtered\n"
6998 "Specify route map\n"
6999 "name of route-map\n")
7001 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7002 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
7006 struct bgp
*bgp_default
;
7008 if (argv_find(argv
, argc
, "no", &idx
))
7011 afi
= vpn_policy_getafi(vty
, bgp
, true);
7013 return CMD_WARNING_CONFIG_FAILED
;
7015 bgp_default
= bgp_get_default();
7020 /* Auto-create assuming the same AS */
7021 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
7022 BGP_INSTANCE_TYPE_DEFAULT
);
7026 "VRF default is not configured as a bgp instance\n");
7031 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7034 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
7035 XFREE(MTYPE_ROUTE_MAP_NAME
,
7036 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
7037 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
7038 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
7039 bgp
->vpn_policy
[afi
].rmap
[dir
] =
7040 route_map_lookup_warn_noexist(vty
, rmap_str
);
7041 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
7044 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
7045 XFREE(MTYPE_ROUTE_MAP_NAME
,
7046 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
7047 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
7048 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
7051 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7056 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
7057 "no import vrf route-map",
7059 "Import routes from another VRF\n"
7060 "Vrf routes being filtered\n"
7061 "Specify route map\n")
7063 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
7064 "[no] import vrf VIEWVRFNAME$import_name",
7066 "Import routes from another VRF\n"
7067 "VRF to import from\n"
7068 "The name of the VRF\n")
7070 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7071 struct listnode
*node
;
7072 struct bgp
*vrf_bgp
, *bgp_default
;
7075 bool remove
= false;
7078 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
7082 if (import_name
== NULL
) {
7083 vty_out(vty
, "%% Missing import name\n");
7087 if (argv_find(argv
, argc
, "no", &idx
))
7090 afi
= vpn_policy_getafi(vty
, bgp
, true);
7092 return CMD_WARNING_CONFIG_FAILED
;
7094 safi
= bgp_node_safi(vty
);
7096 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
7097 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
7098 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
7099 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
7100 remove
? "unimport" : "import", import_name
);
7104 bgp_default
= bgp_get_default();
7106 /* Auto-create assuming the same AS */
7107 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
7108 BGP_INSTANCE_TYPE_DEFAULT
);
7112 "VRF default is not configured as a bgp instance\n");
7117 vrf_bgp
= bgp_lookup_by_name(import_name
);
7119 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
7120 vrf_bgp
= bgp_default
;
7122 /* Auto-create assuming the same AS */
7123 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
7127 "VRF %s is not configured as a bgp instance\n",
7134 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
7136 /* Already importing from "import_vrf"? */
7137 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
7139 if (strcmp(vname
, import_name
) == 0)
7143 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
7149 /* This command is valid only in a bgp vrf instance or the default instance */
7150 DEFPY (bgp_imexport_vpn
,
7151 bgp_imexport_vpn_cmd
,
7152 "[no] <import|export>$direction_str vpn",
7154 "Import routes to this address-family\n"
7155 "Export routes from this address-family\n"
7156 "to/from default instance VPN RIB\n")
7158 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7165 vpn_policy_direction_t dir
;
7167 if (argv_find(argv
, argc
, "no", &idx
))
7170 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
7171 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
7173 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
7174 return CMD_WARNING_CONFIG_FAILED
;
7177 afi
= bgp_node_afi(vty
);
7178 safi
= bgp_node_safi(vty
);
7179 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
7180 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
7181 return CMD_WARNING_CONFIG_FAILED
;
7184 if (!strcmp(direction_str
, "import")) {
7185 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
7186 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
7187 } else if (!strcmp(direction_str
, "export")) {
7188 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
7189 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
7191 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
7192 return CMD_WARNING_CONFIG_FAILED
;
7195 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7198 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7199 if (!previous_state
) {
7200 /* trigger export current vrf */
7201 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7204 if (previous_state
) {
7205 /* trigger un-export current vrf */
7206 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7208 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7214 DEFPY (af_routetarget_import
,
7215 af_routetarget_import_cmd
,
7216 "[no] <rt|route-target> redirect import RTLIST...",
7218 "Specify route target list\n"
7219 "Specify route target list\n"
7220 "Flow-spec redirect type route target\n"
7221 "Import routes to this address-family\n"
7222 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
7224 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7226 struct ecommunity
*ecom
= NULL
;
7231 if (argv_find(argv
, argc
, "no", &idx
))
7234 afi
= vpn_policy_getafi(vty
, bgp
, false);
7236 return CMD_WARNING_CONFIG_FAILED
;
7239 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7240 vty_out(vty
, "%% Missing RTLIST\n");
7241 return CMD_WARNING_CONFIG_FAILED
;
7243 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7244 if (ret
!= CMD_SUCCESS
)
7249 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7250 ecommunity_free(&bgp
->vpn_policy
[afi
]
7251 .import_redirect_rtlist
);
7252 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
7253 ecommunity_dup(ecom
);
7255 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7256 ecommunity_free(&bgp
->vpn_policy
[afi
]
7257 .import_redirect_rtlist
);
7258 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
7262 ecommunity_free(&ecom
);
7267 DEFUN_NOSH (address_family_ipv4_safi
,
7268 address_family_ipv4_safi_cmd
,
7269 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7270 "Enter Address Family command mode\n"
7272 BGP_SAFI_WITH_LABEL_HELP_STR
)
7276 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7277 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7278 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7279 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7280 && safi
!= SAFI_EVPN
) {
7282 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7283 return CMD_WARNING_CONFIG_FAILED
;
7285 vty
->node
= bgp_node_type(AFI_IP
, safi
);
7287 vty
->node
= BGP_IPV4_NODE
;
7292 DEFUN_NOSH (address_family_ipv6_safi
,
7293 address_family_ipv6_safi_cmd
,
7294 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7295 "Enter Address Family command mode\n"
7297 BGP_SAFI_WITH_LABEL_HELP_STR
)
7300 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7301 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7302 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7303 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7304 && safi
!= SAFI_EVPN
) {
7306 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7307 return CMD_WARNING_CONFIG_FAILED
;
7309 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
7311 vty
->node
= BGP_IPV6_NODE
;
7316 #ifdef KEEP_OLD_VPN_COMMANDS
7317 DEFUN_NOSH (address_family_vpnv4
,
7318 address_family_vpnv4_cmd
,
7319 "address-family vpnv4 [unicast]",
7320 "Enter Address Family command mode\n"
7322 "Address Family modifier\n")
7324 vty
->node
= BGP_VPNV4_NODE
;
7328 DEFUN_NOSH (address_family_vpnv6
,
7329 address_family_vpnv6_cmd
,
7330 "address-family vpnv6 [unicast]",
7331 "Enter Address Family command mode\n"
7333 "Address Family modifier\n")
7335 vty
->node
= BGP_VPNV6_NODE
;
7338 #endif /* KEEP_OLD_VPN_COMMANDS */
7340 DEFUN_NOSH (address_family_evpn
,
7341 address_family_evpn_cmd
,
7342 "address-family l2vpn evpn",
7343 "Enter Address Family command mode\n"
7345 "Address Family modifier\n")
7347 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7348 vty
->node
= BGP_EVPN_NODE
;
7352 DEFUN_NOSH (exit_address_family
,
7353 exit_address_family_cmd
,
7354 "exit-address-family",
7355 "Exit from Address Family configuration mode\n")
7357 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7358 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7359 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7360 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7361 || vty
->node
== BGP_EVPN_NODE
7362 || vty
->node
== BGP_FLOWSPECV4_NODE
7363 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7364 vty
->node
= BGP_NODE
;
7368 /* Recalculate bestpath and re-advertise a prefix */
7369 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7370 const char *ip_str
, afi_t afi
, safi_t safi
,
7371 struct prefix_rd
*prd
)
7374 struct prefix match
;
7375 struct bgp_node
*rn
;
7376 struct bgp_node
*rm
;
7378 struct bgp_table
*table
;
7379 struct bgp_table
*rib
;
7381 /* BGP structure lookup. */
7383 bgp
= bgp_lookup_by_name(view_name
);
7385 vty_out(vty
, "%% Can't find BGP instance %s\n",
7390 bgp
= bgp_get_default();
7392 vty_out(vty
, "%% No BGP process is configured\n");
7397 /* Check IP address argument. */
7398 ret
= str2prefix(ip_str
, &match
);
7400 vty_out(vty
, "%% address is malformed\n");
7404 match
.family
= afi2family(afi
);
7405 rib
= bgp
->rib
[afi
][safi
];
7407 if (safi
== SAFI_MPLS_VPN
) {
7408 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7409 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7412 table
= bgp_node_get_bgp_table_info(rn
);
7413 if (table
!= NULL
) {
7415 if ((rm
= bgp_node_match(table
, &match
))
7418 == match
.prefixlen
) {
7420 BGP_NODE_USER_CLEAR
);
7421 bgp_process(bgp
, rm
, afi
, safi
);
7423 bgp_unlock_node(rm
);
7428 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7429 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7430 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7431 bgp_process(bgp
, rn
, afi
, safi
);
7433 bgp_unlock_node(rn
);
7440 /* one clear bgp command to rule them all */
7441 DEFUN (clear_ip_bgp_all
,
7442 clear_ip_bgp_all_cmd
,
7443 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D$neighbor|X:X::X:X$neighbor|WORD$neighbor|(1-4294967295)|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out>]",
7447 BGP_INSTANCE_HELP_STR
7450 BGP_SAFI_WITH_LABEL_HELP_STR
7451 "Address Family modifier\n"
7453 "BGP IPv4 neighbor to clear\n"
7454 "BGP IPv6 neighbor to clear\n"
7455 "BGP neighbor on interface to clear\n"
7456 "Clear peers with the AS number\n"
7457 "Clear all external peers\n"
7458 "Clear all members of peer-group\n"
7459 "BGP peer-group name\n"
7464 "Push out prefix-list ORF and do inbound soft reconfig\n"
7469 afi_t afi
= AFI_UNSPEC
;
7470 safi_t safi
= SAFI_UNSPEC
;
7471 enum clear_sort clr_sort
= clear_peer
;
7472 enum bgp_clear_type clr_type
;
7473 char *clr_arg
= NULL
;
7477 /* clear [ip] bgp */
7478 if (argv_find(argv
, argc
, "ip", &idx
))
7481 /* [<vrf> VIEWVRFNAME] */
7482 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7483 vrf
= argv
[idx
+ 1]->arg
;
7485 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7487 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7488 /* [<view> VIEWVRFNAME] */
7489 vrf
= argv
[idx
+ 1]->arg
;
7492 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7493 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7494 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7496 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
7497 if (argv_find(argv
, argc
, "*", &idx
)) {
7498 clr_sort
= clear_all
;
7499 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7500 clr_sort
= clear_peer
;
7501 clr_arg
= argv
[idx
]->arg
;
7502 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7503 clr_sort
= clear_peer
;
7504 clr_arg
= argv
[idx
]->arg
;
7505 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7506 clr_sort
= clear_group
;
7508 clr_arg
= argv
[idx
]->arg
;
7509 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
7510 clr_sort
= clear_peer
;
7511 clr_arg
= argv
[idx
]->arg
;
7512 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7513 clr_sort
= clear_peer
;
7514 clr_arg
= argv
[idx
]->arg
;
7515 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7516 clr_sort
= clear_as
;
7517 clr_arg
= argv
[idx
]->arg
;
7518 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7519 clr_sort
= clear_external
;
7522 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7523 if (argv_find(argv
, argc
, "soft", &idx
)) {
7524 if (argv_find(argv
, argc
, "in", &idx
)
7525 || argv_find(argv
, argc
, "out", &idx
))
7526 clr_type
= strmatch(argv
[idx
]->text
, "in")
7528 : BGP_CLEAR_SOFT_OUT
;
7530 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7531 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7532 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7533 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7534 : BGP_CLEAR_SOFT_IN
;
7535 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7536 clr_type
= BGP_CLEAR_SOFT_OUT
;
7538 clr_type
= BGP_CLEAR_SOFT_NONE
;
7540 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7543 DEFUN (clear_ip_bgp_prefix
,
7544 clear_ip_bgp_prefix_cmd
,
7545 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7549 BGP_INSTANCE_HELP_STR
7550 "Clear bestpath and re-advertise\n"
7554 char *prefix
= NULL
;
7558 /* [<view|vrf> VIEWVRFNAME] */
7559 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7560 vrf
= argv
[idx
+ 1]->arg
;
7562 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7564 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7565 /* [<view> VIEWVRFNAME] */
7566 vrf
= argv
[idx
+ 1]->arg
;
7570 prefix
= argv
[argc
- 1]->arg
;
7572 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7575 DEFUN (clear_bgp_ipv6_safi_prefix
,
7576 clear_bgp_ipv6_safi_prefix_cmd
,
7577 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7583 "Clear bestpath and re-advertise\n"
7587 int idx_ipv6_prefix
= 0;
7588 safi_t safi
= SAFI_UNICAST
;
7589 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7590 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7592 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7593 return bgp_clear_prefix(
7594 vty
, NULL
, prefix
, AFI_IP6
,
7598 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7599 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7600 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7604 BGP_INSTANCE_HELP_STR
7607 "Clear bestpath and re-advertise\n"
7611 int idx_vrfview
= 0;
7612 int idx_ipv6_prefix
= 0;
7613 safi_t safi
= SAFI_UNICAST
;
7614 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7615 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7616 char *vrfview
= NULL
;
7618 /* [<view|vrf> VIEWVRFNAME] */
7619 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
7620 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7621 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
7623 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
7624 /* [<view> VIEWVRFNAME] */
7625 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7627 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7629 return bgp_clear_prefix(
7630 vty
, vrfview
, prefix
,
7631 AFI_IP6
, safi
, NULL
);
7634 DEFUN (show_bgp_views
,
7636 "show [ip] bgp views",
7640 "Show the defined BGP views\n")
7642 struct list
*inst
= bm
->bgp
;
7643 struct listnode
*node
;
7646 vty_out(vty
, "Defined BGP views:\n");
7647 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7649 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7651 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7658 DEFUN (show_bgp_vrfs
,
7660 "show [ip] bgp vrfs [json]",
7667 char buf
[ETHER_ADDR_STRLEN
];
7668 struct list
*inst
= bm
->bgp
;
7669 struct listnode
*node
;
7671 bool uj
= use_json(argc
, argv
);
7672 json_object
*json
= NULL
;
7673 json_object
*json_vrfs
= NULL
;
7677 json
= json_object_new_object();
7678 json_vrfs
= json_object_new_object();
7681 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7682 const char *name
, *type
;
7684 struct listnode
*node2
, *nnode2
;
7685 int peers_cfg
, peers_estb
;
7686 json_object
*json_vrf
= NULL
;
7689 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7693 if (!uj
&& count
== 1) {
7695 "%4s %-5s %-16s %9s %10s %-37s\n",
7696 "Type", "Id", "routerId", "#PeersVfg",
7697 "#PeersEstb", "Name");
7698 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
7699 "L3-VNI", "RouterMAC", "Interface");
7702 peers_cfg
= peers_estb
= 0;
7704 json_vrf
= json_object_new_object();
7707 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
7708 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7711 if (peer
->status
== Established
)
7715 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7716 name
= VRF_DEFAULT_NAME
;
7725 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7727 : (int64_t)bgp
->vrf_id
;
7728 json_object_string_add(json_vrf
, "type", type
);
7729 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7730 json_object_string_add(json_vrf
, "routerId",
7731 inet_ntoa(bgp
->router_id
));
7732 json_object_int_add(json_vrf
, "numConfiguredPeers",
7734 json_object_int_add(json_vrf
, "numEstablishedPeers",
7737 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7738 json_object_string_add(
7740 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7741 json_object_string_add(json_vrf
, "interface",
7742 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
7744 json_object_object_add(json_vrfs
, name
, json_vrf
);
7747 "%4s %-5d %-16s %-9u %-10u %-37s\n",
7749 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7751 inet_ntoa(bgp
->router_id
), peers_cfg
,
7753 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
7755 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
7756 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
7762 json_object_object_add(json
, "vrfs", json_vrfs
);
7764 json_object_int_add(json
, "totalVrfs", count
);
7766 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7767 json
, JSON_C_TO_STRING_PRETTY
));
7768 json_object_free(json
);
7772 "\nTotal number of VRFs (including default): %d\n",
7779 DEFUN (show_bgp_mac_hash
,
7780 show_bgp_mac_hash_cmd
,
7781 "show bgp mac hash",
7785 "Mac Address database\n")
7787 bgp_mac_dump_table(vty
);
7792 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
7794 struct vty
*vty
= (struct vty
*)args
;
7795 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
7797 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7801 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7803 vty_out(vty
, "self nexthop database:\n");
7804 bgp_nexthop_show_address_hash(vty
, bgp
);
7806 vty_out(vty
, "Tunnel-ip database:\n");
7807 hash_iterate(bgp
->tip_hash
,
7808 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
7812 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7813 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7814 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7815 "martian next-hops\n"
7816 "martian next-hop database\n")
7818 struct bgp
*bgp
= NULL
;
7822 /* [<vrf> VIEWVRFNAME] */
7823 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7824 name
= argv
[idx
+ 1]->arg
;
7825 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7827 } else if (argv_find(argv
, argc
, "view", &idx
))
7828 /* [<view> VIEWVRFNAME] */
7829 name
= argv
[idx
+ 1]->arg
;
7831 bgp
= bgp_lookup_by_name(name
);
7833 bgp
= bgp_get_default();
7836 vty_out(vty
, "%% No BGP process is configured\n");
7839 bgp_show_martian_nexthops(vty
, bgp
);
7844 DEFUN (show_bgp_memory
,
7845 show_bgp_memory_cmd
,
7846 "show [ip] bgp memory",
7850 "Global BGP memory statistics\n")
7852 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7853 unsigned long count
;
7855 /* RIB related usage stats */
7856 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7857 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7858 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7859 count
* sizeof(struct bgp_node
)));
7861 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7862 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7863 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7864 count
* sizeof(struct bgp_path_info
)));
7865 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7866 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7869 memstrbuf
, sizeof(memstrbuf
),
7870 count
* sizeof(struct bgp_path_info_extra
)));
7872 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7873 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7874 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7875 count
* sizeof(struct bgp_static
)));
7877 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7878 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7879 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7880 count
* sizeof(struct bpacket
)));
7883 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7884 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7885 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7886 count
* sizeof(struct bgp_adj_in
)));
7887 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7888 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7889 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7890 count
* sizeof(struct bgp_adj_out
)));
7892 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7893 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7895 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7896 count
* sizeof(struct bgp_nexthop_cache
)));
7898 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7899 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7901 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7902 count
* sizeof(struct bgp_damp_info
)));
7905 count
= attr_count();
7906 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7907 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7908 count
* sizeof(struct attr
)));
7910 if ((count
= attr_unknown_count()))
7911 vty_out(vty
, "%ld unknown attributes\n", count
);
7913 /* AS_PATH attributes */
7914 count
= aspath_count();
7915 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7916 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7917 count
* sizeof(struct aspath
)));
7919 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7920 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7921 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7922 count
* sizeof(struct assegment
)));
7924 /* Other attributes */
7925 if ((count
= community_count()))
7926 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7927 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7928 count
* sizeof(struct community
)));
7929 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7930 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7931 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7932 count
* sizeof(struct ecommunity
)));
7933 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7935 "%ld BGP large-community entries, using %s of memory\n",
7936 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7937 count
* sizeof(struct lcommunity
)));
7939 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7940 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7941 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7942 count
* sizeof(struct cluster_list
)));
7944 /* Peer related usage */
7945 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7946 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7947 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7948 count
* sizeof(struct peer
)));
7950 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7951 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7952 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7953 count
* sizeof(struct peer_group
)));
7956 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7957 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7958 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7959 count
* sizeof(regex_t
)));
7963 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7965 json_object
*bestpath
= json_object_new_object();
7967 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7968 json_object_string_add(bestpath
, "asPath", "ignore");
7970 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7971 json_object_string_add(bestpath
, "asPath", "confed");
7973 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7974 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7975 json_object_string_add(bestpath
, "multiPathRelax",
7978 json_object_string_add(bestpath
, "multiPathRelax",
7981 json_object_string_add(bestpath
, "multiPathRelax", "false");
7983 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7984 json_object_string_add(bestpath
, "compareRouterId", "true");
7985 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7986 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7987 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7988 json_object_string_add(bestpath
, "med", "confed");
7989 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7990 json_object_string_add(bestpath
, "med",
7991 "missing-as-worst");
7993 json_object_string_add(bestpath
, "med", "true");
7996 json_object_object_add(json
, "bestPath", bestpath
);
7999 /* Print the error code/subcode for why the peer is down */
8000 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
8001 json_object
*json_peer
, bool use_json
)
8003 const char *code_str
;
8004 const char *subcode_str
;
8007 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
8008 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
8009 char errorcodesubcode_hexstr
[5];
8010 char errorcodesubcode_str
[256];
8012 code_str
= bgp_notify_code_str(peer
->notify
.code
);
8013 subcode_str
= bgp_notify_subcode_str(
8015 peer
->notify
.subcode
);
8017 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
8018 peer
->notify
.code
, peer
->notify
.subcode
);
8019 json_object_string_add(json_peer
,
8020 "lastErrorCodeSubcode",
8021 errorcodesubcode_hexstr
);
8022 snprintf(errorcodesubcode_str
, 255, "%s%s",
8023 code_str
, subcode_str
);
8024 json_object_string_add(json_peer
,
8025 "lastNotificationReason",
8026 errorcodesubcode_str
);
8027 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
8028 && peer
->notify
.code
== BGP_NOTIFY_CEASE
8029 && (peer
->notify
.subcode
8030 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
8031 || peer
->notify
.subcode
8032 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
8033 && peer
->notify
.length
) {
8035 const char *msg_str
;
8037 msg_str
= bgp_notify_admin_message(
8038 msgbuf
, sizeof(msgbuf
),
8039 (uint8_t *)peer
->notify
.data
,
8040 peer
->notify
.length
);
8042 json_object_string_add(
8044 "lastShutdownDescription",
8049 json_object_string_add(json_peer
, "lastResetDueTo",
8050 peer_down_str
[(int)peer
->last_reset
]);
8051 json_object_int_add(json_peer
, "lastResetCode",
8054 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
8055 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
8056 code_str
= bgp_notify_code_str(peer
->notify
.code
);
8058 bgp_notify_subcode_str(peer
->notify
.code
,
8059 peer
->notify
.subcode
);
8060 vty_out(vty
, " Notification %s (%s%s)\n",
8061 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
8064 code_str
, subcode_str
);
8066 vty_out(vty
, " %s\n",
8067 peer_down_str
[(int)peer
->last_reset
]);
8072 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
8075 return ((peer
->status
!= Established
) ||
8076 !peer
->afc_recv
[afi
][safi
]);
8079 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
8080 struct peer
*peer
, json_object
*json_peer
,
8081 int max_neighbor_width
, bool use_json
)
8083 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
8087 if (peer_dynamic_neighbor(peer
))
8088 json_object_boolean_true_add(json_peer
,
8091 json_object_string_add(json_peer
, "hostname",
8094 if (peer
->domainname
)
8095 json_object_string_add(json_peer
, "domainname",
8097 json_object_int_add(json_peer
, "connectionsEstablished",
8099 json_object_int_add(json_peer
, "connectionsDropped",
8101 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8102 use_json
, json_peer
);
8103 if (peer
->status
== Established
)
8104 json_object_string_add(json_peer
, "lastResetDueTo",
8105 "AFI/SAFI Not Negotiated");
8107 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
8110 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
8112 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8113 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8114 peer
->hostname
, peer
->host
);
8116 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8118 /* pad the neighbor column with spaces */
8119 if (len
< max_neighbor_width
)
8120 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8122 vty_out(vty
, "%7d %7d %8s", peer
->established
,
8124 peer_uptime(peer
->uptime
, timebuf
,
8125 BGP_UPTIME_LEN
, 0, NULL
));
8126 if (peer
->status
== Established
)
8127 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
8129 bgp_show_peer_reset(vty
, peer
, NULL
,
8135 /* Show BGP peer's summary information. */
8136 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
8137 bool show_failed
, bool use_json
)
8140 struct listnode
*node
, *nnode
;
8141 unsigned int count
= 0, dn_count
= 0;
8142 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
8143 char neighbor_buf
[VTY_BUFSIZ
];
8144 int neighbor_col_default_width
= 16;
8145 int len
, failed_count
= 0;
8146 int max_neighbor_width
= 0;
8148 json_object
*json
= NULL
;
8149 json_object
*json_peer
= NULL
;
8150 json_object
*json_peers
= NULL
;
8151 struct peer_af
*paf
;
8153 /* labeled-unicast routes are installed in the unicast table so in order
8155 * display the correct PfxRcd value we must look at SAFI_UNICAST
8158 if (safi
== SAFI_LABELED_UNICAST
)
8159 pfx_rcd_safi
= SAFI_UNICAST
;
8161 pfx_rcd_safi
= safi
;
8164 json
= json_object_new_object();
8165 json_peers
= json_object_new_object();
8166 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8167 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8170 if (peer
->afc
[afi
][safi
]) {
8171 /* See if we have at least a single failed peer */
8172 if (bgp_has_peer_failed(peer
, afi
, safi
))
8176 if (peer_dynamic_neighbor(peer
))
8181 /* Loop over all neighbors that will be displayed to determine
8183 * characters are needed for the Neighbor column
8185 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8186 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8189 if (peer
->afc
[afi
][safi
]) {
8190 memset(dn_flag
, '\0', sizeof(dn_flag
));
8191 if (peer_dynamic_neighbor(peer
))
8195 && bgp_flag_check(bgp
,
8196 BGP_FLAG_SHOW_HOSTNAME
))
8197 sprintf(neighbor_buf
, "%s%s(%s) ",
8198 dn_flag
, peer
->hostname
,
8201 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
8204 len
= strlen(neighbor_buf
);
8206 if (len
> max_neighbor_width
)
8207 max_neighbor_width
= len
;
8209 /* See if we have at least a single failed peer */
8210 if (bgp_has_peer_failed(peer
, afi
, safi
))
8216 /* Originally we displayed the Neighbor column as 16
8217 * characters wide so make that the default
8219 if (max_neighbor_width
< neighbor_col_default_width
)
8220 max_neighbor_width
= neighbor_col_default_width
;
8223 if (show_failed
&& !failed_count
) {
8225 json_object_int_add(json
, "failedPeersCount", 0);
8226 json_object_int_add(json
, "dynamicPeers", dn_count
);
8227 json_object_int_add(json
, "totalPeers", count
);
8229 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8230 json
, JSON_C_TO_STRING_PRETTY
));
8231 json_object_free(json
);
8233 vty_out(vty
, "%% No failed BGP neighbors found\n");
8234 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8239 count
= 0; /* Reset the value as its used again */
8240 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8241 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8244 if (!peer
->afc
[afi
][safi
])
8249 char memstrbuf
[MTYPE_MEMSTR_LEN
];
8252 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
8254 : (int64_t)bgp
->vrf_id
;
8256 /* Usage summary and header */
8258 json_object_string_add(
8260 inet_ntoa(bgp
->router_id
));
8261 json_object_int_add(json
, "as", bgp
->as
);
8262 json_object_int_add(json
, "vrfId", vrf_id_ui
);
8263 json_object_string_add(
8266 == BGP_INSTANCE_TYPE_DEFAULT
)
8271 "BGP router identifier %s, local AS number %u vrf-id %d",
8272 inet_ntoa(bgp
->router_id
), bgp
->as
,
8273 bgp
->vrf_id
== VRF_UNKNOWN
8275 : (int)bgp
->vrf_id
);
8279 if (bgp_update_delay_configured(bgp
)) {
8281 json_object_int_add(
8282 json
, "updateDelayLimit",
8283 bgp
->v_update_delay
);
8285 if (bgp
->v_update_delay
8286 != bgp
->v_establish_wait
)
8287 json_object_int_add(
8289 "updateDelayEstablishWait",
8290 bgp
->v_establish_wait
);
8292 if (bgp_update_delay_active(bgp
)) {
8293 json_object_string_add(
8295 "updateDelayFirstNeighbor",
8296 bgp
->update_delay_begin_time
);
8297 json_object_boolean_true_add(
8299 "updateDelayInProgress");
8301 if (bgp
->update_delay_over
) {
8302 json_object_string_add(
8304 "updateDelayFirstNeighbor",
8305 bgp
->update_delay_begin_time
);
8306 json_object_string_add(
8308 "updateDelayBestpathResumed",
8309 bgp
->update_delay_end_time
);
8310 json_object_string_add(
8312 "updateDelayZebraUpdateResume",
8313 bgp
->update_delay_zebra_resume_time
);
8314 json_object_string_add(
8316 "updateDelayPeerUpdateResume",
8317 bgp
->update_delay_peers_resume_time
);
8322 "Read-only mode update-delay limit: %d seconds\n",
8323 bgp
->v_update_delay
);
8324 if (bgp
->v_update_delay
8325 != bgp
->v_establish_wait
)
8327 " Establish wait: %d seconds\n",
8328 bgp
->v_establish_wait
);
8330 if (bgp_update_delay_active(bgp
)) {
8332 " First neighbor established: %s\n",
8333 bgp
->update_delay_begin_time
);
8335 " Delay in progress\n");
8337 if (bgp
->update_delay_over
) {
8339 " First neighbor established: %s\n",
8340 bgp
->update_delay_begin_time
);
8342 " Best-paths resumed: %s\n",
8343 bgp
->update_delay_end_time
);
8345 " zebra update resumed: %s\n",
8346 bgp
->update_delay_zebra_resume_time
);
8348 " peers update resumed: %s\n",
8349 bgp
->update_delay_peers_resume_time
);
8356 if (bgp_maxmed_onstartup_configured(bgp
)
8357 && bgp
->maxmed_active
)
8358 json_object_boolean_true_add(
8359 json
, "maxMedOnStartup");
8360 if (bgp
->v_maxmed_admin
)
8361 json_object_boolean_true_add(
8362 json
, "maxMedAdministrative");
8364 json_object_int_add(
8365 json
, "tableVersion",
8366 bgp_table_version(bgp
->rib
[afi
][safi
]));
8368 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8369 json_object_int_add(json
, "ribCount", ents
);
8370 json_object_int_add(
8372 ents
* sizeof(struct bgp_node
));
8374 ents
= bgp
->af_peer_count
[afi
][safi
];
8375 json_object_int_add(json
, "peerCount", ents
);
8376 json_object_int_add(json
, "peerMemory",
8377 ents
* sizeof(struct peer
));
8379 if ((ents
= listcount(bgp
->group
))) {
8380 json_object_int_add(
8381 json
, "peerGroupCount", ents
);
8382 json_object_int_add(
8383 json
, "peerGroupMemory",
8384 ents
* sizeof(struct
8388 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8389 BGP_CONFIG_DAMPENING
))
8390 json_object_boolean_true_add(
8391 json
, "dampeningEnabled");
8393 if (bgp_maxmed_onstartup_configured(bgp
)
8394 && bgp
->maxmed_active
)
8396 "Max-med on-startup active\n");
8397 if (bgp
->v_maxmed_admin
)
8399 "Max-med administrative active\n");
8401 vty_out(vty
, "BGP table version %" PRIu64
"\n",
8402 bgp_table_version(bgp
->rib
[afi
][safi
]));
8404 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8406 "RIB entries %ld, using %s of memory\n",
8408 mtype_memstr(memstrbuf
,
8410 ents
* sizeof(struct
8413 /* Peer related usage */
8414 ents
= bgp
->af_peer_count
[afi
][safi
];
8415 vty_out(vty
, "Peers %ld, using %s of memory\n",
8418 memstrbuf
, sizeof(memstrbuf
),
8419 ents
* sizeof(struct peer
)));
8421 if ((ents
= listcount(bgp
->group
)))
8423 "Peer groups %ld, using %s of memory\n",
8428 ents
* sizeof(struct
8431 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8432 BGP_CONFIG_DAMPENING
))
8433 vty_out(vty
, "Dampening enabled.\n");
8436 /* Subtract 8 here because 'Neighbor' is
8438 vty_out(vty
, "Neighbor");
8439 vty_out(vty
, "%*s", max_neighbor_width
- 8,
8442 vty_out(vty
, "EstdCnt DropCnt ResetTime Reason\n");
8445 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
8450 /* Works for both failed & successful cases */
8451 if (peer_dynamic_neighbor(peer
))
8458 bgp_has_peer_failed(peer
, afi
, safi
)) {
8459 json_peer
= json_object_new_object();
8460 bgp_show_failed_summary(vty
, bgp
, peer
,
8461 json_peer
, 0, use_json
);
8462 } else if (!show_failed
) {
8463 json_peer
= json_object_new_object();
8464 if (peer_dynamic_neighbor(peer
)) {
8465 json_object_boolean_true_add(json_peer
,
8470 json_object_string_add(json_peer
, "hostname",
8473 if (peer
->domainname
)
8474 json_object_string_add(json_peer
, "domainname",
8477 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
8478 json_object_int_add(json_peer
, "version", 4);
8479 json_object_int_add(json_peer
, "msgRcvd",
8480 PEER_TOTAL_RX(peer
));
8481 json_object_int_add(json_peer
, "msgSent",
8482 PEER_TOTAL_TX(peer
));
8484 json_object_int_add(json_peer
, "tableVersion",
8485 peer
->version
[afi
][safi
]);
8486 json_object_int_add(json_peer
, "outq",
8488 json_object_int_add(json_peer
, "inq", 0);
8489 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8490 use_json
, json_peer
);
8493 * Adding "pfxRcd" field to match with the corresponding
8494 * CLI. "prefixReceivedCount" will be deprecated in
8497 json_object_int_add(json_peer
, "prefixReceivedCount",
8498 peer
->pcount
[afi
][pfx_rcd_safi
]);
8499 json_object_int_add(json_peer
, "pfxRcd",
8500 peer
->pcount
[afi
][pfx_rcd_safi
]);
8502 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
8503 if (paf
&& PAF_SUBGRP(paf
))
8504 json_object_int_add(json_peer
,
8506 (PAF_SUBGRP(paf
))->scount
);
8507 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8508 json_object_string_add(json_peer
, "state",
8510 else if (peer
->afc_recv
[afi
][safi
])
8511 json_object_string_add(
8513 lookup_msg(bgp_status_msg
, peer
->status
,
8515 else if (CHECK_FLAG(peer
->sflags
,
8516 PEER_STATUS_PREFIX_OVERFLOW
))
8517 json_object_string_add(json_peer
, "state",
8520 json_object_string_add(
8522 lookup_msg(bgp_status_msg
, peer
->status
,
8524 json_object_int_add(json_peer
, "connectionsEstablished",
8526 json_object_int_add(json_peer
, "connectionsDropped",
8529 /* Avoid creating empty peer dicts in JSON */
8530 if (json_peer
== NULL
)
8534 json_object_string_add(json_peer
, "idType",
8536 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8537 json_object_string_add(json_peer
, "idType",
8539 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8540 json_object_string_add(json_peer
, "idType",
8542 json_object_object_add(json_peers
, peer
->host
,
8546 bgp_has_peer_failed(peer
, afi
, safi
)) {
8547 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
8550 } else if (!show_failed
) {
8551 memset(dn_flag
, '\0', sizeof(dn_flag
));
8552 if (peer_dynamic_neighbor(peer
)) {
8557 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8558 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8559 peer
->hostname
, peer
->host
);
8561 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8563 /* pad the neighbor column with spaces */
8564 if (len
< max_neighbor_width
)
8565 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8568 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8569 peer
->as
, PEER_TOTAL_RX(peer
),
8570 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8571 0, peer
->obuf
->count
,
8572 peer_uptime(peer
->uptime
, timebuf
,
8573 BGP_UPTIME_LEN
, 0, NULL
));
8575 if (peer
->status
== Established
)
8576 if (peer
->afc_recv
[afi
][safi
])
8577 vty_out(vty
, " %12" PRIu32
,
8582 vty_out(vty
, " NoNeg");
8584 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8585 vty_out(vty
, " Idle (Admin)");
8586 else if (CHECK_FLAG(
8588 PEER_STATUS_PREFIX_OVERFLOW
))
8589 vty_out(vty
, " Idle (PfxCt)");
8591 vty_out(vty
, " %12s",
8592 lookup_msg(bgp_status_msg
,
8593 peer
->status
, NULL
));
8602 json_object_object_add(json
, "peers", json_peers
);
8603 json_object_int_add(json
, "failedPeers", failed_count
);
8604 json_object_int_add(json
, "totalPeers", count
);
8605 json_object_int_add(json
, "dynamicPeers", dn_count
);
8608 bgp_show_bestpath_json(bgp
, json
);
8610 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8611 json
, JSON_C_TO_STRING_PRETTY
));
8612 json_object_free(json
);
8615 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8617 vty_out(vty
, "No %s neighbor is configured\n",
8618 get_afi_safi_str(afi
, safi
, false));
8622 vty_out(vty
, "* - dynamic neighbor\n");
8623 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8624 dn_count
, bgp
->dynamic_neighbors_limit
);
8631 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8632 int safi
, bool show_failed
, bool use_json
)
8635 int afi_wildcard
= (afi
== AFI_MAX
);
8636 int safi_wildcard
= (safi
== SAFI_MAX
);
8637 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8638 bool nbr_output
= false;
8640 if (use_json
&& is_wildcard
)
8641 vty_out(vty
, "{\n");
8643 afi
= 1; /* AFI_IP */
8644 while (afi
< AFI_MAX
) {
8646 safi
= 1; /* SAFI_UNICAST */
8647 while (safi
< SAFI_MAX
) {
8648 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8653 * So limit output to those afi/safi
8655 * actualy have something interesting in
8660 vty_out(vty
, ",\n");
8664 vty_out(vty
, "\"%s\":",
8665 get_afi_safi_str(afi
,
8669 vty_out(vty
, "\n%s Summary:\n",
8670 get_afi_safi_str(afi
,
8675 bgp_show_summary(vty
, bgp
, afi
, safi
, show_failed
,
8687 if (use_json
&& is_wildcard
)
8688 vty_out(vty
, "}\n");
8689 else if (!nbr_output
) {
8691 vty_out(vty
, "{}\n");
8693 vty_out(vty
, "%% No BGP neighbors found\n");
8697 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8698 safi_t safi
, bool show_failed
,
8701 struct listnode
*node
, *nnode
;
8704 bool nbr_output
= false;
8707 vty_out(vty
, "{\n");
8709 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8713 vty_out(vty
, ",\n");
8717 vty_out(vty
, "\"%s\":",
8718 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8722 vty_out(vty
, "\nInstance %s:\n",
8723 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8727 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
8732 vty_out(vty
, "}\n");
8733 else if (!nbr_output
)
8734 vty_out(vty
, "%% BGP instance not found\n");
8737 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8738 safi_t safi
, bool show_failed
, bool use_json
)
8743 if (strmatch(name
, "all")) {
8744 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8749 bgp
= bgp_lookup_by_name(name
);
8753 vty_out(vty
, "{}\n");
8756 "%% BGP instance not found\n");
8760 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
,
8761 show_failed
, use_json
);
8766 bgp
= bgp_get_default();
8769 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
8773 vty_out(vty
, "{}\n");
8775 vty_out(vty
, "%% BGP instance not found\n");
8782 /* `show [ip] bgp summary' commands. */
8783 DEFUN (show_ip_bgp_summary
,
8784 show_ip_bgp_summary_cmd
,
8785 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [failed] [json]",
8789 BGP_INSTANCE_HELP_STR
8791 BGP_SAFI_WITH_LABEL_HELP_STR
8792 "Summary of BGP neighbor status\n"
8793 "Show only sessions not in Established state\n"
8797 afi_t afi
= AFI_MAX
;
8798 safi_t safi
= SAFI_MAX
;
8799 bool show_failed
= false;
8804 if (argv_find(argv
, argc
, "ip", &idx
))
8806 /* [<vrf> VIEWVRFNAME] */
8807 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8808 vrf
= argv
[idx
+ 1]->arg
;
8809 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8811 } else if (argv_find(argv
, argc
, "view", &idx
))
8812 /* [<view> VIEWVRFNAME] */
8813 vrf
= argv
[idx
+ 1]->arg
;
8814 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8815 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8816 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8819 if (argv_find(argv
, argc
, "failed", &idx
))
8822 bool uj
= use_json(argc
, argv
);
8824 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, show_failed
, uj
);
8827 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
8830 return get_afi_safi_json_str(afi
, safi
);
8832 return get_afi_safi_vty_str(afi
, safi
);
8835 /* Show BGP peer's information. */
8836 enum show_type
{ show_all
, show_peer
, show_ipv4_all
, show_ipv6_all
, show_ipv4_peer
, show_ipv6_peer
};
8838 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8839 afi_t afi
, safi_t safi
,
8840 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8841 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8842 bool use_json
, json_object
*json_pref
)
8845 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8846 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8848 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8849 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8850 json_object_string_add(json_pref
, "sendMode",
8851 "advertisedAndReceived");
8852 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8853 json_object_string_add(json_pref
, "sendMode",
8855 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8856 json_object_string_add(json_pref
, "sendMode",
8859 vty_out(vty
, " Send-mode: ");
8860 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8861 vty_out(vty
, "advertised");
8862 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8863 vty_out(vty
, "%sreceived",
8864 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8873 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8874 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8876 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8877 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8878 json_object_string_add(json_pref
, "recvMode",
8879 "advertisedAndReceived");
8880 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8881 json_object_string_add(json_pref
, "recvMode",
8883 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8884 json_object_string_add(json_pref
, "recvMode",
8887 vty_out(vty
, " Receive-mode: ");
8888 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8889 vty_out(vty
, "advertised");
8890 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8891 vty_out(vty
, "%sreceived",
8892 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8901 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8902 safi_t safi
, bool use_json
,
8903 json_object
*json_neigh
)
8905 struct bgp_filter
*filter
;
8906 struct peer_af
*paf
;
8907 char orf_pfx_name
[BUFSIZ
];
8909 json_object
*json_af
= NULL
;
8910 json_object
*json_prefA
= NULL
;
8911 json_object
*json_prefB
= NULL
;
8912 json_object
*json_addr
= NULL
;
8915 json_addr
= json_object_new_object();
8916 json_af
= json_object_new_object();
8917 filter
= &p
->filter
[afi
][safi
];
8919 if (peer_group_active(p
))
8920 json_object_string_add(json_addr
, "peerGroupMember",
8923 paf
= peer_af_find(p
, afi
, safi
);
8924 if (paf
&& PAF_SUBGRP(paf
)) {
8925 json_object_int_add(json_addr
, "updateGroupId",
8926 PAF_UPDGRP(paf
)->id
);
8927 json_object_int_add(json_addr
, "subGroupId",
8928 PAF_SUBGRP(paf
)->id
);
8929 json_object_int_add(json_addr
, "packetQueueLength",
8930 bpacket_queue_virtual_length(paf
));
8933 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8934 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8935 PEER_CAP_ORF_PREFIX_SM_RCV
)
8936 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8937 PEER_CAP_ORF_PREFIX_RM_ADV
)
8938 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8939 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8940 json_object_int_add(json_af
, "orfType",
8942 json_prefA
= json_object_new_object();
8943 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8944 PEER_CAP_ORF_PREFIX_SM_ADV
,
8945 PEER_CAP_ORF_PREFIX_RM_ADV
,
8946 PEER_CAP_ORF_PREFIX_SM_RCV
,
8947 PEER_CAP_ORF_PREFIX_RM_RCV
,
8948 use_json
, json_prefA
);
8949 json_object_object_add(json_af
, "orfPrefixList",
8953 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8954 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8955 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8956 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8957 PEER_CAP_ORF_PREFIX_RM_ADV
)
8958 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8959 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8960 json_object_int_add(json_af
, "orfOldType",
8961 ORF_TYPE_PREFIX_OLD
);
8962 json_prefB
= json_object_new_object();
8963 bgp_show_peer_afi_orf_cap(
8964 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8965 PEER_CAP_ORF_PREFIX_RM_ADV
,
8966 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8967 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8969 json_object_object_add(json_af
, "orfOldPrefixList",
8973 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8974 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8975 PEER_CAP_ORF_PREFIX_SM_RCV
)
8976 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8977 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8978 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8979 PEER_CAP_ORF_PREFIX_RM_ADV
)
8980 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8981 PEER_CAP_ORF_PREFIX_RM_RCV
)
8982 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8983 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8984 json_object_object_add(json_addr
, "afDependentCap",
8987 json_object_free(json_af
);
8989 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8990 orf_pfx_count
= prefix_bgp_show_prefix_list(
8991 NULL
, afi
, orf_pfx_name
, use_json
);
8993 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8994 PEER_STATUS_ORF_PREFIX_SEND
)
8996 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8997 PEER_STATUS_ORF_PREFIX_SEND
))
8998 json_object_boolean_true_add(json_neigh
,
9001 json_object_int_add(json_addr
, "orfRecvCounter",
9004 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9005 PEER_STATUS_ORF_WAIT_REFRESH
))
9006 json_object_string_add(
9007 json_addr
, "orfFirstUpdate",
9008 "deferredUntilORFOrRouteRefreshRecvd");
9010 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9011 PEER_FLAG_REFLECTOR_CLIENT
))
9012 json_object_boolean_true_add(json_addr
,
9013 "routeReflectorClient");
9014 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9015 PEER_FLAG_RSERVER_CLIENT
))
9016 json_object_boolean_true_add(json_addr
,
9017 "routeServerClient");
9018 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9019 json_object_boolean_true_add(json_addr
,
9020 "inboundSoftConfigPermit");
9022 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9023 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
9024 json_object_boolean_true_add(
9026 "privateAsNumsAllReplacedInUpdatesToNbr");
9027 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9028 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
9029 json_object_boolean_true_add(
9031 "privateAsNumsReplacedInUpdatesToNbr");
9032 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9033 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
9034 json_object_boolean_true_add(
9036 "privateAsNumsAllRemovedInUpdatesToNbr");
9037 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9038 PEER_FLAG_REMOVE_PRIVATE_AS
))
9039 json_object_boolean_true_add(
9041 "privateAsNumsRemovedInUpdatesToNbr");
9043 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
9044 json_object_boolean_true_add(
9046 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
9049 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
9050 json_object_string_add(json_addr
,
9051 "overrideASNsInOutboundUpdates",
9052 "ifAspathEqualRemoteAs");
9054 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
9055 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9056 PEER_FLAG_FORCE_NEXTHOP_SELF
))
9057 json_object_boolean_true_add(json_addr
,
9058 "routerAlwaysNextHop");
9059 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9060 PEER_FLAG_AS_PATH_UNCHANGED
))
9061 json_object_boolean_true_add(
9062 json_addr
, "unchangedAsPathPropogatedToNbr");
9063 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9064 PEER_FLAG_NEXTHOP_UNCHANGED
))
9065 json_object_boolean_true_add(
9066 json_addr
, "unchangedNextHopPropogatedToNbr");
9067 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
9068 json_object_boolean_true_add(
9069 json_addr
, "unchangedMedPropogatedToNbr");
9070 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
9071 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9072 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
9073 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9074 PEER_FLAG_SEND_COMMUNITY
)
9075 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9076 PEER_FLAG_SEND_EXT_COMMUNITY
))
9077 json_object_string_add(json_addr
,
9078 "commAttriSentToNbr",
9079 "extendedAndStandard");
9080 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9081 PEER_FLAG_SEND_EXT_COMMUNITY
))
9082 json_object_string_add(json_addr
,
9083 "commAttriSentToNbr",
9086 json_object_string_add(json_addr
,
9087 "commAttriSentToNbr",
9090 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9091 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9092 if (p
->default_rmap
[afi
][safi
].name
)
9093 json_object_string_add(
9094 json_addr
, "defaultRouteMap",
9095 p
->default_rmap
[afi
][safi
].name
);
9097 if (paf
&& PAF_SUBGRP(paf
)
9098 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9099 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9100 json_object_boolean_true_add(json_addr
,
9103 json_object_boolean_true_add(json_addr
,
9107 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9108 if (is_evpn_enabled())
9109 json_object_boolean_true_add(
9110 json_addr
, "advertiseAllVnis");
9113 if (filter
->plist
[FILTER_IN
].name
9114 || filter
->dlist
[FILTER_IN
].name
9115 || filter
->aslist
[FILTER_IN
].name
9116 || filter
->map
[RMAP_IN
].name
)
9117 json_object_boolean_true_add(json_addr
,
9118 "inboundPathPolicyConfig");
9119 if (filter
->plist
[FILTER_OUT
].name
9120 || filter
->dlist
[FILTER_OUT
].name
9121 || filter
->aslist
[FILTER_OUT
].name
9122 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9123 json_object_boolean_true_add(
9124 json_addr
, "outboundPathPolicyConfig");
9127 if (filter
->plist
[FILTER_IN
].name
)
9128 json_object_string_add(json_addr
,
9129 "incomingUpdatePrefixFilterList",
9130 filter
->plist
[FILTER_IN
].name
);
9131 if (filter
->plist
[FILTER_OUT
].name
)
9132 json_object_string_add(json_addr
,
9133 "outgoingUpdatePrefixFilterList",
9134 filter
->plist
[FILTER_OUT
].name
);
9136 /* distribute-list */
9137 if (filter
->dlist
[FILTER_IN
].name
)
9138 json_object_string_add(
9139 json_addr
, "incomingUpdateNetworkFilterList",
9140 filter
->dlist
[FILTER_IN
].name
);
9141 if (filter
->dlist
[FILTER_OUT
].name
)
9142 json_object_string_add(
9143 json_addr
, "outgoingUpdateNetworkFilterList",
9144 filter
->dlist
[FILTER_OUT
].name
);
9147 if (filter
->aslist
[FILTER_IN
].name
)
9148 json_object_string_add(json_addr
,
9149 "incomingUpdateAsPathFilterList",
9150 filter
->aslist
[FILTER_IN
].name
);
9151 if (filter
->aslist
[FILTER_OUT
].name
)
9152 json_object_string_add(json_addr
,
9153 "outgoingUpdateAsPathFilterList",
9154 filter
->aslist
[FILTER_OUT
].name
);
9157 if (filter
->map
[RMAP_IN
].name
)
9158 json_object_string_add(
9159 json_addr
, "routeMapForIncomingAdvertisements",
9160 filter
->map
[RMAP_IN
].name
);
9161 if (filter
->map
[RMAP_OUT
].name
)
9162 json_object_string_add(
9163 json_addr
, "routeMapForOutgoingAdvertisements",
9164 filter
->map
[RMAP_OUT
].name
);
9166 /* ebgp-requires-policy (inbound) */
9167 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9168 && !bgp_inbound_policy_exists(p
, filter
))
9169 json_object_string_add(
9170 json_addr
, "inboundEbgpRequiresPolicy",
9171 "Inbound updates discarded due to missing policy");
9173 /* ebgp-requires-policy (outbound) */
9174 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9175 && (!bgp_outbound_policy_exists(p
, filter
)))
9176 json_object_string_add(
9177 json_addr
, "outboundEbgpRequiresPolicy",
9178 "Outbound updates discarded due to missing policy");
9180 /* unsuppress-map */
9181 if (filter
->usmap
.name
)
9182 json_object_string_add(json_addr
,
9183 "selectiveUnsuppressRouteMap",
9184 filter
->usmap
.name
);
9186 /* Receive prefix count */
9187 json_object_int_add(json_addr
, "acceptedPrefixCounter",
9188 p
->pcount
[afi
][safi
]);
9189 if (paf
&& PAF_SUBGRP(paf
))
9190 json_object_int_add(json_addr
, "sentPrefixCounter",
9191 (PAF_SUBGRP(paf
))->scount
);
9193 /* Maximum prefix */
9194 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9195 json_object_int_add(json_addr
, "prefixAllowedMax",
9196 p
->pmax
[afi
][safi
]);
9197 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9198 PEER_FLAG_MAX_PREFIX_WARNING
))
9199 json_object_boolean_true_add(
9200 json_addr
, "prefixAllowedMaxWarning");
9201 json_object_int_add(json_addr
,
9202 "prefixAllowedWarningThresh",
9203 p
->pmax_threshold
[afi
][safi
]);
9204 if (p
->pmax_restart
[afi
][safi
])
9205 json_object_int_add(
9207 "prefixAllowedRestartIntervalMsecs",
9208 p
->pmax_restart
[afi
][safi
] * 60000);
9210 json_object_object_add(json_neigh
, get_afi_safi_str(afi
, safi
, true),
9214 filter
= &p
->filter
[afi
][safi
];
9216 vty_out(vty
, " For address family: %s\n",
9217 get_afi_safi_str(afi
, safi
, false));
9219 if (peer_group_active(p
))
9220 vty_out(vty
, " %s peer-group member\n",
9223 paf
= peer_af_find(p
, afi
, safi
);
9224 if (paf
&& PAF_SUBGRP(paf
)) {
9225 vty_out(vty
, " Update group %" PRIu64
9226 ", subgroup %" PRIu64
"\n",
9227 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
9228 vty_out(vty
, " Packet Queue length %d\n",
9229 bpacket_queue_virtual_length(paf
));
9231 vty_out(vty
, " Not part of any update group\n");
9233 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9234 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9235 PEER_CAP_ORF_PREFIX_SM_RCV
)
9236 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9237 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
9238 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9239 PEER_CAP_ORF_PREFIX_RM_ADV
)
9240 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9241 PEER_CAP_ORF_PREFIX_RM_RCV
)
9242 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9243 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
9244 vty_out(vty
, " AF-dependant capabilities:\n");
9246 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9247 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9248 PEER_CAP_ORF_PREFIX_SM_RCV
)
9249 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9250 PEER_CAP_ORF_PREFIX_RM_ADV
)
9251 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9252 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
9254 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
9256 bgp_show_peer_afi_orf_cap(
9257 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
9258 PEER_CAP_ORF_PREFIX_RM_ADV
,
9259 PEER_CAP_ORF_PREFIX_SM_RCV
,
9260 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
9262 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9263 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9264 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
9265 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9266 PEER_CAP_ORF_PREFIX_RM_ADV
)
9267 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9268 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
9270 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
9271 ORF_TYPE_PREFIX_OLD
);
9272 bgp_show_peer_afi_orf_cap(
9273 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
9274 PEER_CAP_ORF_PREFIX_RM_ADV
,
9275 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
9276 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
9279 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
9280 orf_pfx_count
= prefix_bgp_show_prefix_list(
9281 NULL
, afi
, orf_pfx_name
, use_json
);
9283 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9284 PEER_STATUS_ORF_PREFIX_SEND
)
9286 vty_out(vty
, " Outbound Route Filter (ORF):");
9287 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9288 PEER_STATUS_ORF_PREFIX_SEND
))
9289 vty_out(vty
, " sent;");
9291 vty_out(vty
, " received (%d entries)",
9295 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9296 PEER_STATUS_ORF_WAIT_REFRESH
))
9298 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
9300 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9301 PEER_FLAG_REFLECTOR_CLIENT
))
9302 vty_out(vty
, " Route-Reflector Client\n");
9303 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9304 PEER_FLAG_RSERVER_CLIENT
))
9305 vty_out(vty
, " Route-Server Client\n");
9306 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9308 " Inbound soft reconfiguration allowed\n");
9310 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9311 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
9313 " Private AS numbers (all) replaced in updates to this neighbor\n");
9314 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9315 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
9317 " Private AS numbers replaced in updates to this neighbor\n");
9318 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9319 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
9321 " Private AS numbers (all) removed in updates to this neighbor\n");
9322 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9323 PEER_FLAG_REMOVE_PRIVATE_AS
))
9325 " Private AS numbers removed in updates to this neighbor\n");
9327 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
9328 vty_out(vty
, " %s\n",
9329 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
9330 ->human_description
);
9332 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
9334 " Override ASNs in outbound updates if aspath equals remote-as\n");
9336 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
9337 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9338 PEER_FLAG_FORCE_NEXTHOP_SELF
))
9339 vty_out(vty
, " NEXT_HOP is always this router\n");
9340 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9341 PEER_FLAG_AS_PATH_UNCHANGED
))
9343 " AS_PATH is propagated unchanged to this neighbor\n");
9344 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9345 PEER_FLAG_NEXTHOP_UNCHANGED
))
9347 " NEXT_HOP is propagated unchanged to this neighbor\n");
9348 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
9350 " MED is propagated unchanged to this neighbor\n");
9351 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
9352 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9353 PEER_FLAG_SEND_EXT_COMMUNITY
)
9354 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9355 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
9357 " Community attribute sent to this neighbor");
9358 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9359 PEER_FLAG_SEND_COMMUNITY
)
9360 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9361 PEER_FLAG_SEND_EXT_COMMUNITY
)
9362 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9363 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9364 vty_out(vty
, "(all)\n");
9365 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9366 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9367 vty_out(vty
, "(large)\n");
9368 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9369 PEER_FLAG_SEND_EXT_COMMUNITY
))
9370 vty_out(vty
, "(extended)\n");
9372 vty_out(vty
, "(standard)\n");
9374 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9375 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9376 vty_out(vty
, " Default information originate,");
9378 if (p
->default_rmap
[afi
][safi
].name
)
9379 vty_out(vty
, " default route-map %s%s,",
9380 p
->default_rmap
[afi
][safi
].map
? "*"
9382 p
->default_rmap
[afi
][safi
].name
);
9383 if (paf
&& PAF_SUBGRP(paf
)
9384 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9385 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9386 vty_out(vty
, " default sent\n");
9388 vty_out(vty
, " default not sent\n");
9391 /* advertise-vni-all */
9392 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9393 if (is_evpn_enabled())
9394 vty_out(vty
, " advertise-all-vni\n");
9397 if (filter
->plist
[FILTER_IN
].name
9398 || filter
->dlist
[FILTER_IN
].name
9399 || filter
->aslist
[FILTER_IN
].name
9400 || filter
->map
[RMAP_IN
].name
)
9401 vty_out(vty
, " Inbound path policy configured\n");
9402 if (filter
->plist
[FILTER_OUT
].name
9403 || filter
->dlist
[FILTER_OUT
].name
9404 || filter
->aslist
[FILTER_OUT
].name
9405 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9406 vty_out(vty
, " Outbound path policy configured\n");
9409 if (filter
->plist
[FILTER_IN
].name
)
9411 " Incoming update prefix filter list is %s%s\n",
9412 filter
->plist
[FILTER_IN
].plist
? "*" : "",
9413 filter
->plist
[FILTER_IN
].name
);
9414 if (filter
->plist
[FILTER_OUT
].name
)
9416 " Outgoing update prefix filter list is %s%s\n",
9417 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
9418 filter
->plist
[FILTER_OUT
].name
);
9420 /* distribute-list */
9421 if (filter
->dlist
[FILTER_IN
].name
)
9423 " Incoming update network filter list is %s%s\n",
9424 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
9425 filter
->dlist
[FILTER_IN
].name
);
9426 if (filter
->dlist
[FILTER_OUT
].name
)
9428 " Outgoing update network filter list is %s%s\n",
9429 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
9430 filter
->dlist
[FILTER_OUT
].name
);
9433 if (filter
->aslist
[FILTER_IN
].name
)
9435 " Incoming update AS path filter list is %s%s\n",
9436 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
9437 filter
->aslist
[FILTER_IN
].name
);
9438 if (filter
->aslist
[FILTER_OUT
].name
)
9440 " Outgoing update AS path filter list is %s%s\n",
9441 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
9442 filter
->aslist
[FILTER_OUT
].name
);
9445 if (filter
->map
[RMAP_IN
].name
)
9447 " Route map for incoming advertisements is %s%s\n",
9448 filter
->map
[RMAP_IN
].map
? "*" : "",
9449 filter
->map
[RMAP_IN
].name
);
9450 if (filter
->map
[RMAP_OUT
].name
)
9452 " Route map for outgoing advertisements is %s%s\n",
9453 filter
->map
[RMAP_OUT
].map
? "*" : "",
9454 filter
->map
[RMAP_OUT
].name
);
9456 /* ebgp-requires-policy (inbound) */
9457 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9458 && !bgp_inbound_policy_exists(p
, filter
))
9460 " Inbound updates discarded due to missing policy\n");
9462 /* ebgp-requires-policy (outbound) */
9463 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9464 && !bgp_outbound_policy_exists(p
, filter
))
9466 " Outbound updates discarded due to missing policy\n");
9468 /* unsuppress-map */
9469 if (filter
->usmap
.name
)
9471 " Route map for selective unsuppress is %s%s\n",
9472 filter
->usmap
.map
? "*" : "",
9473 filter
->usmap
.name
);
9475 /* Receive prefix count */
9476 vty_out(vty
, " %" PRIu32
" accepted prefixes\n",
9477 p
->pcount
[afi
][safi
]);
9479 /* Maximum prefix */
9480 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9482 " Maximum prefixes allowed %" PRIu32
"%s\n",
9484 CHECK_FLAG(p
->af_flags
[afi
][safi
],
9485 PEER_FLAG_MAX_PREFIX_WARNING
)
9488 vty_out(vty
, " Threshold for warning message %d%%",
9489 p
->pmax_threshold
[afi
][safi
]);
9490 if (p
->pmax_restart
[afi
][safi
])
9491 vty_out(vty
, ", restart interval %d min",
9492 p
->pmax_restart
[afi
][safi
]);
9500 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
9504 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
9505 char timebuf
[BGP_UPTIME_LEN
];
9511 json_object
*json_neigh
= NULL
;
9517 json_neigh
= json_object_new_object();
9519 memset(dn_flag
, '\0', sizeof(dn_flag
));
9520 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9524 if (p
->conf_if
) /* Configured interface name. */
9525 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9526 BGP_PEER_SU_UNSPEC(p
)
9528 : sockunion2str(&p
->su
, buf
,
9530 else /* Configured IP address. */
9531 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9536 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9537 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9539 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9540 json_object_string_add(
9541 json_neigh
, "bgpNeighborAddr",
9542 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9544 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9546 if (p
->change_local_as
)
9547 json_object_int_add(json_neigh
, "localAs",
9548 p
->change_local_as
);
9550 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9552 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9553 json_object_boolean_true_add(json_neigh
,
9554 "localAsNoPrepend");
9556 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9557 json_object_boolean_true_add(json_neigh
,
9558 "localAsReplaceAs");
9560 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9561 || (p
->as_type
== AS_INTERNAL
))
9562 vty_out(vty
, "remote AS %u, ", p
->as
);
9564 vty_out(vty
, "remote AS Unspecified, ");
9565 vty_out(vty
, "local AS %u%s%s, ",
9566 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9567 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9570 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9574 /* peer type internal or confed-internal */
9575 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
9577 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9578 json_object_boolean_true_add(
9579 json_neigh
, "nbrConfedInternalLink");
9581 json_object_boolean_true_add(json_neigh
,
9584 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9585 vty_out(vty
, "confed-internal link\n");
9587 vty_out(vty
, "internal link\n");
9589 /* peer type external or confed-external */
9590 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
9592 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9593 json_object_boolean_true_add(
9594 json_neigh
, "nbrConfedExternalLink");
9596 json_object_boolean_true_add(json_neigh
,
9599 if (bgp_confederation_peers_check(bgp
, p
->as
))
9600 vty_out(vty
, "confed-external link\n");
9602 vty_out(vty
, "external link\n");
9606 json_object_boolean_true_add(json_neigh
,
9607 "nbrUnspecifiedLink");
9609 vty_out(vty
, "unspecified link\n");
9615 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9617 vty_out(vty
, " Description: %s\n", p
->desc
);
9623 json_object_string_add(json_neigh
, "hostname",
9627 json_object_string_add(json_neigh
, "domainname",
9630 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9631 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9634 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9641 json_object_string_add(json_neigh
, "peerGroup",
9645 struct prefix prefix
, *range
= NULL
;
9647 sockunion2hostprefix(&(p
->su
), &prefix
);
9648 range
= peer_group_lookup_dynamic_neighbor_range(
9652 prefix2str(range
, buf1
, sizeof(buf1
));
9653 json_object_string_add(
9655 "peerSubnetRangeGroup", buf1
);
9660 " Member of peer-group %s for session parameters\n",
9664 struct prefix prefix
, *range
= NULL
;
9666 sockunion2hostprefix(&(p
->su
), &prefix
);
9667 range
= peer_group_lookup_dynamic_neighbor_range(
9671 prefix2str(range
, buf1
, sizeof(buf1
));
9673 " Belongs to the subnet range group: %s\n",
9681 /* Administrative shutdown. */
9682 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9683 json_object_boolean_true_add(json_neigh
,
9687 json_object_int_add(json_neigh
, "bgpVersion", 4);
9688 json_object_string_add(
9689 json_neigh
, "remoteRouterId",
9690 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9691 json_object_string_add(
9692 json_neigh
, "localRouterId",
9693 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9697 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9698 && bgp_confederation_peers_check(bgp
, p
->as
))
9699 json_object_boolean_true_add(json_neigh
,
9703 json_object_string_add(
9704 json_neigh
, "bgpState",
9705 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9707 if (p
->status
== Established
) {
9710 uptime
= bgp_clock();
9711 uptime
-= p
->uptime
;
9712 epoch_tbuf
= time(NULL
) - uptime
;
9714 #if CONFDATE > 20200101
9716 "bgpTimerUp should be deprecated and can be removed now");
9719 * bgpTimerUp was miliseconds that was accurate
9720 * up to 1 day, then the value returned
9721 * became garbage. So in order to provide
9722 * some level of backwards compatability,
9723 * we still provde the data, but now
9724 * we are returning the correct value
9725 * and also adding a new bgpTimerUpMsec
9726 * which will allow us to deprecate
9729 json_object_int_add(json_neigh
, "bgpTimerUp",
9731 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9733 json_object_string_add(json_neigh
, "bgpTimerUpString",
9734 peer_uptime(p
->uptime
, timebuf
,
9737 json_object_int_add(json_neigh
,
9738 "bgpTimerUpEstablishedEpoch",
9742 else if (p
->status
== Active
) {
9743 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9744 json_object_string_add(json_neigh
, "bgpStateIs",
9746 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9747 json_object_string_add(json_neigh
, "bgpStateIs",
9755 uptime
= bgp_clock();
9756 uptime
-= p
->readtime
;
9757 tm
= gmtime(&uptime
);
9758 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9759 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9760 + (tm
->tm_hour
* 3600000));
9762 uptime
= bgp_clock();
9763 uptime
-= p
->last_write
;
9764 tm
= gmtime(&uptime
);
9765 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9766 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9767 + (tm
->tm_hour
* 3600000));
9769 uptime
= bgp_clock();
9770 uptime
-= p
->update_time
;
9771 tm
= gmtime(&uptime
);
9772 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9773 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9774 + (tm
->tm_hour
* 3600000));
9776 /* Configured timer values. */
9777 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9778 p
->v_holdtime
* 1000);
9779 json_object_int_add(json_neigh
,
9780 "bgpTimerKeepAliveIntervalMsecs",
9781 p
->v_keepalive
* 1000);
9782 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9783 json_object_int_add(json_neigh
,
9784 "bgpTimerConfiguredHoldTimeMsecs",
9785 p
->holdtime
* 1000);
9786 json_object_int_add(
9788 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9789 p
->keepalive
* 1000);
9790 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
9791 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
9792 json_object_int_add(json_neigh
,
9793 "bgpTimerConfiguredHoldTimeMsecs",
9794 bgp
->default_holdtime
);
9795 json_object_int_add(
9797 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9798 bgp
->default_keepalive
);
9801 /* Administrative shutdown. */
9802 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9803 vty_out(vty
, " Administratively shut down\n");
9806 vty_out(vty
, " BGP version 4");
9807 vty_out(vty
, ", remote router ID %s",
9808 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9809 vty_out(vty
, ", local router ID %s\n",
9810 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9814 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9815 && bgp_confederation_peers_check(bgp
, p
->as
))
9817 " Neighbor under common administration\n");
9820 vty_out(vty
, " BGP state = %s",
9821 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9823 if (p
->status
== Established
)
9824 vty_out(vty
, ", up for %8s",
9825 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9828 else if (p
->status
== Active
) {
9829 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9830 vty_out(vty
, " (passive)");
9831 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9832 vty_out(vty
, " (NSF passive)");
9837 vty_out(vty
, " Last read %s",
9838 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9840 vty_out(vty
, ", Last write %s\n",
9841 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9844 /* Configured timer values. */
9846 " Hold time is %d, keepalive interval is %d seconds\n",
9847 p
->v_holdtime
, p
->v_keepalive
);
9848 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9849 vty_out(vty
, " Configured hold time is %d",
9851 vty_out(vty
, ", keepalive interval is %d seconds\n",
9853 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
9854 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
9855 vty_out(vty
, " Configured hold time is %d",
9856 bgp
->default_holdtime
);
9857 vty_out(vty
, ", keepalive interval is %d seconds\n",
9858 bgp
->default_keepalive
);
9862 if (p
->status
== Established
) {
9863 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9864 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9865 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9866 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9867 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9868 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9869 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9870 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9871 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9872 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9873 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9874 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9875 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9876 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9877 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9878 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9879 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9880 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9881 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9882 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9884 json_object
*json_cap
= NULL
;
9886 json_cap
= json_object_new_object();
9889 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9890 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9891 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9892 && CHECK_FLAG(p
->cap
,
9894 json_object_string_add(
9895 json_cap
, "4byteAs",
9896 "advertisedAndReceived");
9897 else if (CHECK_FLAG(p
->cap
,
9899 json_object_string_add(
9900 json_cap
, "4byteAs",
9902 else if (CHECK_FLAG(p
->cap
,
9904 json_object_string_add(
9905 json_cap
, "4byteAs",
9910 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9911 || CHECK_FLAG(p
->cap
,
9912 PEER_CAP_ADDPATH_ADV
)) {
9913 json_object
*json_add
= NULL
;
9914 const char *print_store
;
9916 json_add
= json_object_new_object();
9918 FOREACH_AFI_SAFI (afi
, safi
) {
9919 json_object
*json_sub
= NULL
;
9921 json_object_new_object();
9922 print_store
= get_afi_safi_str(
9928 PEER_CAP_ADDPATH_AF_TX_ADV
)
9932 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9937 PEER_CAP_ADDPATH_AF_TX_ADV
)
9942 PEER_CAP_ADDPATH_AF_TX_RCV
))
9943 json_object_boolean_true_add(
9945 "txAdvertisedAndReceived");
9951 PEER_CAP_ADDPATH_AF_TX_ADV
))
9952 json_object_boolean_true_add(
9960 PEER_CAP_ADDPATH_AF_TX_RCV
))
9961 json_object_boolean_true_add(
9969 PEER_CAP_ADDPATH_AF_RX_ADV
)
9973 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9978 PEER_CAP_ADDPATH_AF_RX_ADV
)
9983 PEER_CAP_ADDPATH_AF_RX_RCV
))
9984 json_object_boolean_true_add(
9986 "rxAdvertisedAndReceived");
9992 PEER_CAP_ADDPATH_AF_RX_ADV
))
9993 json_object_boolean_true_add(
10001 PEER_CAP_ADDPATH_AF_RX_RCV
))
10002 json_object_boolean_true_add(
10010 PEER_CAP_ADDPATH_AF_TX_ADV
)
10014 PEER_CAP_ADDPATH_AF_TX_RCV
)
10018 PEER_CAP_ADDPATH_AF_RX_ADV
)
10022 PEER_CAP_ADDPATH_AF_RX_RCV
))
10023 json_object_object_add(
10032 json_object_object_add(
10033 json_cap
, "addPath", json_add
);
10037 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10038 || CHECK_FLAG(p
->cap
,
10039 PEER_CAP_DYNAMIC_ADV
)) {
10040 if (CHECK_FLAG(p
->cap
,
10041 PEER_CAP_DYNAMIC_ADV
)
10042 && CHECK_FLAG(p
->cap
,
10043 PEER_CAP_DYNAMIC_RCV
))
10044 json_object_string_add(
10045 json_cap
, "dynamic",
10046 "advertisedAndReceived");
10047 else if (CHECK_FLAG(
10049 PEER_CAP_DYNAMIC_ADV
))
10050 json_object_string_add(
10051 json_cap
, "dynamic",
10053 else if (CHECK_FLAG(
10055 PEER_CAP_DYNAMIC_RCV
))
10056 json_object_string_add(
10057 json_cap
, "dynamic",
10061 /* Extended nexthop */
10062 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10063 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10064 json_object
*json_nxt
= NULL
;
10065 const char *print_store
;
10068 if (CHECK_FLAG(p
->cap
,
10070 && CHECK_FLAG(p
->cap
,
10071 PEER_CAP_ENHE_RCV
))
10072 json_object_string_add(
10075 "advertisedAndReceived");
10076 else if (CHECK_FLAG(p
->cap
,
10077 PEER_CAP_ENHE_ADV
))
10078 json_object_string_add(
10082 else if (CHECK_FLAG(p
->cap
,
10083 PEER_CAP_ENHE_RCV
))
10084 json_object_string_add(
10089 if (CHECK_FLAG(p
->cap
,
10090 PEER_CAP_ENHE_RCV
)) {
10092 json_object_new_object();
10094 for (safi
= SAFI_UNICAST
;
10095 safi
< SAFI_MAX
; safi
++) {
10100 PEER_CAP_ENHE_AF_RCV
)) {
10101 print_store
= get_afi_safi_str(
10104 json_object_string_add(
10107 "recieved"); /* misspelled for compatibility */
10110 json_object_object_add(
10112 "extendedNexthopFamililesByPeer",
10117 /* Route Refresh */
10118 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10119 || CHECK_FLAG(p
->cap
,
10120 PEER_CAP_REFRESH_NEW_RCV
)
10121 || CHECK_FLAG(p
->cap
,
10122 PEER_CAP_REFRESH_OLD_RCV
)) {
10123 if (CHECK_FLAG(p
->cap
,
10124 PEER_CAP_REFRESH_ADV
)
10127 PEER_CAP_REFRESH_NEW_RCV
)
10130 PEER_CAP_REFRESH_OLD_RCV
))) {
10133 PEER_CAP_REFRESH_OLD_RCV
)
10136 PEER_CAP_REFRESH_NEW_RCV
))
10137 json_object_string_add(
10140 "advertisedAndReceivedOldNew");
10144 PEER_CAP_REFRESH_OLD_RCV
))
10145 json_object_string_add(
10148 "advertisedAndReceivedOld");
10150 json_object_string_add(
10153 "advertisedAndReceivedNew");
10158 PEER_CAP_REFRESH_ADV
))
10159 json_object_string_add(
10166 PEER_CAP_REFRESH_NEW_RCV
)
10169 PEER_CAP_REFRESH_OLD_RCV
))
10170 json_object_string_add(
10176 /* Multiprotocol Extensions */
10177 json_object
*json_multi
= NULL
;
10178 json_multi
= json_object_new_object();
10180 FOREACH_AFI_SAFI (afi
, safi
) {
10181 if (p
->afc_adv
[afi
][safi
]
10182 || p
->afc_recv
[afi
][safi
]) {
10183 json_object
*json_exten
= NULL
;
10185 json_object_new_object();
10187 if (p
->afc_adv
[afi
][safi
]
10188 && p
->afc_recv
[afi
][safi
])
10189 json_object_boolean_true_add(
10191 "advertisedAndReceived");
10192 else if (p
->afc_adv
[afi
][safi
])
10193 json_object_boolean_true_add(
10196 else if (p
->afc_recv
[afi
][safi
])
10197 json_object_boolean_true_add(
10201 json_object_object_add(
10203 get_afi_safi_str(afi
,
10209 json_object_object_add(
10210 json_cap
, "multiprotocolExtensions",
10213 /* Hostname capabilities */
10214 json_object
*json_hname
= NULL
;
10216 json_hname
= json_object_new_object();
10218 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10219 json_object_string_add(
10220 json_hname
, "advHostName",
10221 bgp
->peer_self
->hostname
10225 json_object_string_add(
10226 json_hname
, "advDomainName",
10227 bgp
->peer_self
->domainname
10234 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10235 json_object_string_add(
10236 json_hname
, "rcvHostName",
10237 p
->hostname
? p
->hostname
10239 json_object_string_add(
10240 json_hname
, "rcvDomainName",
10241 p
->domainname
? p
->domainname
10245 json_object_object_add(json_cap
, "hostName",
10248 /* Gracefull Restart */
10249 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10250 || CHECK_FLAG(p
->cap
,
10251 PEER_CAP_RESTART_ADV
)) {
10252 if (CHECK_FLAG(p
->cap
,
10253 PEER_CAP_RESTART_ADV
)
10254 && CHECK_FLAG(p
->cap
,
10255 PEER_CAP_RESTART_RCV
))
10256 json_object_string_add(
10259 "advertisedAndReceived");
10260 else if (CHECK_FLAG(
10262 PEER_CAP_RESTART_ADV
))
10263 json_object_string_add(
10265 "gracefulRestartCapability",
10267 else if (CHECK_FLAG(
10269 PEER_CAP_RESTART_RCV
))
10270 json_object_string_add(
10272 "gracefulRestartCapability",
10275 if (CHECK_FLAG(p
->cap
,
10276 PEER_CAP_RESTART_RCV
)) {
10277 int restart_af_count
= 0;
10278 json_object
*json_restart
=
10281 json_object_new_object();
10283 json_object_int_add(
10285 "gracefulRestartRemoteTimerMsecs",
10286 p
->v_gr_restart
* 1000);
10288 FOREACH_AFI_SAFI (afi
, safi
) {
10293 PEER_CAP_RESTART_AF_RCV
)) {
10298 json_object_new_object();
10304 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
10305 json_object_boolean_true_add(
10308 restart_af_count
++;
10309 json_object_object_add(
10318 if (!restart_af_count
) {
10319 json_object_string_add(
10321 "addressFamiliesByPeer",
10326 json_object_object_add(
10328 "addressFamiliesByPeer",
10332 json_object_object_add(json_neigh
,
10333 "neighborCapabilities",
10336 vty_out(vty
, " Neighbor capabilities:\n");
10339 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
10340 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
10341 vty_out(vty
, " 4 Byte AS:");
10342 if (CHECK_FLAG(p
->cap
,
10344 vty_out(vty
, " advertised");
10345 if (CHECK_FLAG(p
->cap
,
10347 vty_out(vty
, " %sreceived",
10353 vty_out(vty
, "\n");
10357 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
10358 || CHECK_FLAG(p
->cap
,
10359 PEER_CAP_ADDPATH_ADV
)) {
10360 vty_out(vty
, " AddPath:\n");
10362 FOREACH_AFI_SAFI (afi
, safi
) {
10366 PEER_CAP_ADDPATH_AF_TX_ADV
)
10370 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
10382 PEER_CAP_ADDPATH_AF_TX_ADV
))
10394 PEER_CAP_ADDPATH_AF_TX_RCV
))
10401 PEER_CAP_ADDPATH_AF_TX_ADV
)
10405 vty_out(vty
, "\n");
10411 PEER_CAP_ADDPATH_AF_RX_ADV
)
10415 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
10427 PEER_CAP_ADDPATH_AF_RX_ADV
))
10439 PEER_CAP_ADDPATH_AF_RX_RCV
))
10446 PEER_CAP_ADDPATH_AF_RX_ADV
)
10450 vty_out(vty
, "\n");
10456 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10457 || CHECK_FLAG(p
->cap
,
10458 PEER_CAP_DYNAMIC_ADV
)) {
10459 vty_out(vty
, " Dynamic:");
10460 if (CHECK_FLAG(p
->cap
,
10461 PEER_CAP_DYNAMIC_ADV
))
10462 vty_out(vty
, " advertised");
10463 if (CHECK_FLAG(p
->cap
,
10464 PEER_CAP_DYNAMIC_RCV
))
10465 vty_out(vty
, " %sreceived",
10468 PEER_CAP_DYNAMIC_ADV
)
10471 vty_out(vty
, "\n");
10474 /* Extended nexthop */
10475 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10476 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10477 vty_out(vty
, " Extended nexthop:");
10478 if (CHECK_FLAG(p
->cap
,
10479 PEER_CAP_ENHE_ADV
))
10480 vty_out(vty
, " advertised");
10481 if (CHECK_FLAG(p
->cap
,
10482 PEER_CAP_ENHE_RCV
))
10483 vty_out(vty
, " %sreceived",
10489 vty_out(vty
, "\n");
10491 if (CHECK_FLAG(p
->cap
,
10492 PEER_CAP_ENHE_RCV
)) {
10494 " Address families by peer:\n ");
10495 for (safi
= SAFI_UNICAST
;
10496 safi
< SAFI_MAX
; safi
++)
10501 PEER_CAP_ENHE_AF_RCV
))
10511 /* Route Refresh */
10512 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10513 || CHECK_FLAG(p
->cap
,
10514 PEER_CAP_REFRESH_NEW_RCV
)
10515 || CHECK_FLAG(p
->cap
,
10516 PEER_CAP_REFRESH_OLD_RCV
)) {
10517 vty_out(vty
, " Route refresh:");
10518 if (CHECK_FLAG(p
->cap
,
10519 PEER_CAP_REFRESH_ADV
))
10520 vty_out(vty
, " advertised");
10521 if (CHECK_FLAG(p
->cap
,
10522 PEER_CAP_REFRESH_NEW_RCV
)
10525 PEER_CAP_REFRESH_OLD_RCV
))
10526 vty_out(vty
, " %sreceived(%s)",
10529 PEER_CAP_REFRESH_ADV
)
10534 PEER_CAP_REFRESH_OLD_RCV
)
10537 PEER_CAP_REFRESH_NEW_RCV
))
10541 PEER_CAP_REFRESH_OLD_RCV
)
10545 vty_out(vty
, "\n");
10548 /* Multiprotocol Extensions */
10549 FOREACH_AFI_SAFI (afi
, safi
)
10550 if (p
->afc_adv
[afi
][safi
]
10551 || p
->afc_recv
[afi
][safi
]) {
10553 " Address Family %s:",
10558 if (p
->afc_adv
[afi
][safi
])
10561 if (p
->afc_recv
[afi
][safi
])
10568 vty_out(vty
, "\n");
10571 /* Hostname capability */
10572 vty_out(vty
, " Hostname Capability:");
10574 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10576 " advertised (name: %s,domain name: %s)",
10577 bgp
->peer_self
->hostname
10581 bgp
->peer_self
->domainname
10586 vty_out(vty
, " not advertised");
10589 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10591 " received (name: %s,domain name: %s)",
10592 p
->hostname
? p
->hostname
10594 p
->domainname
? p
->domainname
10597 vty_out(vty
, " not received");
10600 vty_out(vty
, "\n");
10602 /* Gracefull Restart */
10603 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10604 || CHECK_FLAG(p
->cap
,
10605 PEER_CAP_RESTART_ADV
)) {
10607 " Graceful Restart Capabilty:");
10608 if (CHECK_FLAG(p
->cap
,
10609 PEER_CAP_RESTART_ADV
))
10610 vty_out(vty
, " advertised");
10611 if (CHECK_FLAG(p
->cap
,
10612 PEER_CAP_RESTART_RCV
))
10613 vty_out(vty
, " %sreceived",
10616 PEER_CAP_RESTART_ADV
)
10619 vty_out(vty
, "\n");
10621 if (CHECK_FLAG(p
->cap
,
10622 PEER_CAP_RESTART_RCV
)) {
10623 int restart_af_count
= 0;
10626 " Remote Restart timer is %d seconds\n",
10629 " Address families by peer:\n ");
10631 FOREACH_AFI_SAFI (afi
, safi
)
10636 PEER_CAP_RESTART_AF_RCV
)) {
10650 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10652 : "not preserved");
10653 restart_af_count
++;
10655 if (!restart_af_count
)
10656 vty_out(vty
, "none");
10657 vty_out(vty
, "\n");
10664 /* graceful restart information */
10665 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10666 || p
->t_gr_stale
) {
10667 json_object
*json_grace
= NULL
;
10668 json_object
*json_grace_send
= NULL
;
10669 json_object
*json_grace_recv
= NULL
;
10670 int eor_send_af_count
= 0;
10671 int eor_receive_af_count
= 0;
10674 json_grace
= json_object_new_object();
10675 json_grace_send
= json_object_new_object();
10676 json_grace_recv
= json_object_new_object();
10678 if (p
->status
== Established
) {
10679 FOREACH_AFI_SAFI (afi
, safi
) {
10680 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10681 PEER_STATUS_EOR_SEND
)) {
10682 json_object_boolean_true_add(
10684 get_afi_safi_str(afi
,
10687 eor_send_af_count
++;
10690 FOREACH_AFI_SAFI (afi
, safi
) {
10692 p
->af_sflags
[afi
][safi
],
10693 PEER_STATUS_EOR_RECEIVED
)) {
10694 json_object_boolean_true_add(
10696 get_afi_safi_str(afi
,
10699 eor_receive_af_count
++;
10704 json_object_object_add(json_grace
, "endOfRibSend",
10706 json_object_object_add(json_grace
, "endOfRibRecv",
10709 if (p
->t_gr_restart
)
10710 json_object_int_add(json_grace
,
10711 "gracefulRestartTimerMsecs",
10712 thread_timer_remain_second(
10717 json_object_int_add(
10719 "gracefulStalepathTimerMsecs",
10720 thread_timer_remain_second(
10724 json_object_object_add(
10725 json_neigh
, "gracefulRestartInfo", json_grace
);
10727 vty_out(vty
, " Graceful restart information:\n");
10728 if (p
->status
== Established
) {
10729 vty_out(vty
, " End-of-RIB send: ");
10730 FOREACH_AFI_SAFI (afi
, safi
) {
10731 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10732 PEER_STATUS_EOR_SEND
)) {
10733 vty_out(vty
, "%s%s",
10734 eor_send_af_count
? ", "
10736 get_afi_safi_str(afi
,
10739 eor_send_af_count
++;
10742 vty_out(vty
, "\n");
10743 vty_out(vty
, " End-of-RIB received: ");
10744 FOREACH_AFI_SAFI (afi
, safi
) {
10746 p
->af_sflags
[afi
][safi
],
10747 PEER_STATUS_EOR_RECEIVED
)) {
10748 vty_out(vty
, "%s%s",
10749 eor_receive_af_count
10752 get_afi_safi_str(afi
,
10755 eor_receive_af_count
++;
10758 vty_out(vty
, "\n");
10761 if (p
->t_gr_restart
)
10763 " The remaining time of restart timer is %ld\n",
10764 thread_timer_remain_second(
10769 " The remaining time of stalepath timer is %ld\n",
10770 thread_timer_remain_second(
10775 json_object
*json_stat
= NULL
;
10776 json_stat
= json_object_new_object();
10777 /* Packet counts. */
10778 json_object_int_add(json_stat
, "depthInq", 0);
10779 json_object_int_add(json_stat
, "depthOutq",
10780 (unsigned long)p
->obuf
->count
);
10781 json_object_int_add(json_stat
, "opensSent",
10782 atomic_load_explicit(&p
->open_out
,
10783 memory_order_relaxed
));
10784 json_object_int_add(json_stat
, "opensRecv",
10785 atomic_load_explicit(&p
->open_in
,
10786 memory_order_relaxed
));
10787 json_object_int_add(json_stat
, "notificationsSent",
10788 atomic_load_explicit(&p
->notify_out
,
10789 memory_order_relaxed
));
10790 json_object_int_add(json_stat
, "notificationsRecv",
10791 atomic_load_explicit(&p
->notify_in
,
10792 memory_order_relaxed
));
10793 json_object_int_add(json_stat
, "updatesSent",
10794 atomic_load_explicit(&p
->update_out
,
10795 memory_order_relaxed
));
10796 json_object_int_add(json_stat
, "updatesRecv",
10797 atomic_load_explicit(&p
->update_in
,
10798 memory_order_relaxed
));
10799 json_object_int_add(json_stat
, "keepalivesSent",
10800 atomic_load_explicit(&p
->keepalive_out
,
10801 memory_order_relaxed
));
10802 json_object_int_add(json_stat
, "keepalivesRecv",
10803 atomic_load_explicit(&p
->keepalive_in
,
10804 memory_order_relaxed
));
10805 json_object_int_add(json_stat
, "routeRefreshSent",
10806 atomic_load_explicit(&p
->refresh_out
,
10807 memory_order_relaxed
));
10808 json_object_int_add(json_stat
, "routeRefreshRecv",
10809 atomic_load_explicit(&p
->refresh_in
,
10810 memory_order_relaxed
));
10811 json_object_int_add(json_stat
, "capabilitySent",
10812 atomic_load_explicit(&p
->dynamic_cap_out
,
10813 memory_order_relaxed
));
10814 json_object_int_add(json_stat
, "capabilityRecv",
10815 atomic_load_explicit(&p
->dynamic_cap_in
,
10816 memory_order_relaxed
));
10817 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10818 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10819 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10821 /* Packet counts. */
10822 vty_out(vty
, " Message statistics:\n");
10823 vty_out(vty
, " Inq depth is 0\n");
10824 vty_out(vty
, " Outq depth is %lu\n",
10825 (unsigned long)p
->obuf
->count
);
10826 vty_out(vty
, " Sent Rcvd\n");
10827 vty_out(vty
, " Opens: %10d %10d\n",
10828 atomic_load_explicit(&p
->open_out
,
10829 memory_order_relaxed
),
10830 atomic_load_explicit(&p
->open_in
,
10831 memory_order_relaxed
));
10832 vty_out(vty
, " Notifications: %10d %10d\n",
10833 atomic_load_explicit(&p
->notify_out
,
10834 memory_order_relaxed
),
10835 atomic_load_explicit(&p
->notify_in
,
10836 memory_order_relaxed
));
10837 vty_out(vty
, " Updates: %10d %10d\n",
10838 atomic_load_explicit(&p
->update_out
,
10839 memory_order_relaxed
),
10840 atomic_load_explicit(&p
->update_in
,
10841 memory_order_relaxed
));
10842 vty_out(vty
, " Keepalives: %10d %10d\n",
10843 atomic_load_explicit(&p
->keepalive_out
,
10844 memory_order_relaxed
),
10845 atomic_load_explicit(&p
->keepalive_in
,
10846 memory_order_relaxed
));
10847 vty_out(vty
, " Route Refresh: %10d %10d\n",
10848 atomic_load_explicit(&p
->refresh_out
,
10849 memory_order_relaxed
),
10850 atomic_load_explicit(&p
->refresh_in
,
10851 memory_order_relaxed
));
10852 vty_out(vty
, " Capability: %10d %10d\n",
10853 atomic_load_explicit(&p
->dynamic_cap_out
,
10854 memory_order_relaxed
),
10855 atomic_load_explicit(&p
->dynamic_cap_in
,
10856 memory_order_relaxed
));
10857 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10862 /* advertisement-interval */
10863 json_object_int_add(json_neigh
,
10864 "minBtwnAdvertisementRunsTimerMsecs",
10865 p
->v_routeadv
* 1000);
10867 /* Update-source. */
10868 if (p
->update_if
|| p
->update_source
) {
10870 json_object_string_add(json_neigh
,
10873 else if (p
->update_source
)
10874 json_object_string_add(
10875 json_neigh
, "updateSource",
10876 sockunion2str(p
->update_source
, buf1
,
10880 /* advertisement-interval */
10882 " Minimum time between advertisement runs is %d seconds\n",
10885 /* Update-source. */
10886 if (p
->update_if
|| p
->update_source
) {
10887 vty_out(vty
, " Update source is ");
10889 vty_out(vty
, "%s", p
->update_if
);
10890 else if (p
->update_source
)
10892 sockunion2str(p
->update_source
, buf1
,
10894 vty_out(vty
, "\n");
10897 vty_out(vty
, "\n");
10900 /* Address Family Information */
10901 json_object
*json_hold
= NULL
;
10904 json_hold
= json_object_new_object();
10906 FOREACH_AFI_SAFI (afi
, safi
)
10907 if (p
->afc
[afi
][safi
])
10908 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10912 json_object_object_add(json_neigh
, "addressFamilyInfo",
10914 json_object_int_add(json_neigh
, "connectionsEstablished",
10916 json_object_int_add(json_neigh
, "connectionsDropped",
10919 vty_out(vty
, " Connections established %d; dropped %d\n",
10920 p
->established
, p
->dropped
);
10922 if (!p
->last_reset
) {
10924 json_object_string_add(json_neigh
, "lastReset",
10927 vty_out(vty
, " Last reset never\n");
10933 uptime
= bgp_clock();
10934 uptime
-= p
->resettime
;
10935 tm
= gmtime(&uptime
);
10936 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10937 (tm
->tm_sec
* 1000)
10938 + (tm
->tm_min
* 60000)
10939 + (tm
->tm_hour
* 3600000));
10940 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
10942 vty_out(vty
, " Last reset %s, ",
10943 peer_uptime(p
->resettime
, timebuf
,
10944 BGP_UPTIME_LEN
, 0, NULL
));
10946 bgp_show_peer_reset(vty
, p
, NULL
, false);
10947 if (p
->last_reset_cause_size
) {
10948 msg
= p
->last_reset_cause
;
10950 " Message received that caused BGP to send a NOTIFICATION:\n ");
10951 for (i
= 1; i
<= p
->last_reset_cause_size
;
10953 vty_out(vty
, "%02X", *msg
++);
10955 if (i
!= p
->last_reset_cause_size
) {
10957 vty_out(vty
, "\n ");
10958 } else if (i
% 4 == 0) {
10963 vty_out(vty
, "\n");
10968 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10970 json_object_boolean_true_add(json_neigh
,
10971 "prefixesConfigExceedMax");
10974 " Peer had exceeded the max. no. of prefixes configured.\n");
10976 if (p
->t_pmax_restart
) {
10978 json_object_boolean_true_add(
10979 json_neigh
, "reducePrefixNumFrom");
10980 json_object_int_add(json_neigh
,
10981 "restartInTimerMsec",
10982 thread_timer_remain_second(
10987 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10988 p
->host
, thread_timer_remain_second(
10989 p
->t_pmax_restart
));
10992 json_object_boolean_true_add(
10994 "reducePrefixNumAndClearIpBgp");
10997 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
11002 /* EBGP Multihop and GTSM */
11003 if (p
->sort
!= BGP_PEER_IBGP
) {
11005 if (p
->gtsm_hops
> 0)
11006 json_object_int_add(json_neigh
,
11007 "externalBgpNbrMaxHopsAway",
11009 else if (p
->ttl
> BGP_DEFAULT_TTL
)
11010 json_object_int_add(json_neigh
,
11011 "externalBgpNbrMaxHopsAway",
11014 if (p
->gtsm_hops
> 0)
11016 " External BGP neighbor may be up to %d hops away.\n",
11018 else if (p
->ttl
> BGP_DEFAULT_TTL
)
11020 " External BGP neighbor may be up to %d hops away.\n",
11024 if (p
->gtsm_hops
> 0) {
11026 json_object_int_add(json_neigh
,
11027 "internalBgpNbrMaxHopsAway",
11031 " Internal BGP neighbor may be up to %d hops away.\n",
11036 /* Local address. */
11039 json_object_string_add(json_neigh
, "hostLocal",
11040 sockunion2str(p
->su_local
, buf1
,
11042 json_object_int_add(json_neigh
, "portLocal",
11043 ntohs(p
->su_local
->sin
.sin_port
));
11045 vty_out(vty
, "Local host: %s, Local port: %d\n",
11046 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
11047 ntohs(p
->su_local
->sin
.sin_port
));
11050 /* Remote address. */
11051 if (p
->su_remote
) {
11053 json_object_string_add(json_neigh
, "hostForeign",
11054 sockunion2str(p
->su_remote
, buf1
,
11056 json_object_int_add(json_neigh
, "portForeign",
11057 ntohs(p
->su_remote
->sin
.sin_port
));
11059 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
11060 sockunion2str(p
->su_remote
, buf1
,
11062 ntohs(p
->su_remote
->sin
.sin_port
));
11065 /* Nexthop display. */
11068 json_object_string_add(json_neigh
, "nexthop",
11070 &p
->nexthop
.v4
, buf1
,
11072 json_object_string_add(json_neigh
, "nexthopGlobal",
11073 inet_ntop(AF_INET6
,
11074 &p
->nexthop
.v6_global
,
11075 buf1
, sizeof(buf1
)));
11076 json_object_string_add(json_neigh
, "nexthopLocal",
11077 inet_ntop(AF_INET6
,
11078 &p
->nexthop
.v6_local
,
11079 buf1
, sizeof(buf1
)));
11080 if (p
->shared_network
)
11081 json_object_string_add(json_neigh
,
11085 json_object_string_add(json_neigh
,
11087 "nonSharedNetwork");
11089 vty_out(vty
, "Nexthop: %s\n",
11090 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
11092 vty_out(vty
, "Nexthop global: %s\n",
11093 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
11095 vty_out(vty
, "Nexthop local: %s\n",
11096 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
11098 vty_out(vty
, "BGP connection: %s\n",
11099 p
->shared_network
? "shared network"
11100 : "non shared network");
11104 /* Timer information. */
11106 json_object_int_add(json_neigh
, "connectRetryTimer",
11108 if (p
->status
== Established
&& p
->rtt
)
11109 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
11112 json_object_int_add(
11113 json_neigh
, "nextStartTimerDueInMsecs",
11114 thread_timer_remain_second(p
->t_start
) * 1000);
11116 json_object_int_add(
11117 json_neigh
, "nextConnectTimerDueInMsecs",
11118 thread_timer_remain_second(p
->t_connect
)
11120 if (p
->t_routeadv
) {
11121 json_object_int_add(json_neigh
, "mraiInterval",
11123 json_object_int_add(
11124 json_neigh
, "mraiTimerExpireInMsecs",
11125 thread_timer_remain_second(p
->t_routeadv
)
11129 json_object_int_add(json_neigh
, "authenticationEnabled",
11133 json_object_string_add(json_neigh
, "readThread", "on");
11135 json_object_string_add(json_neigh
, "readThread", "off");
11137 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
11138 json_object_string_add(json_neigh
, "writeThread", "on");
11140 json_object_string_add(json_neigh
, "writeThread",
11143 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
11145 if (p
->status
== Established
&& p
->rtt
)
11146 vty_out(vty
, "Estimated round trip time: %d ms\n",
11149 vty_out(vty
, "Next start timer due in %ld seconds\n",
11150 thread_timer_remain_second(p
->t_start
));
11152 vty_out(vty
, "Next connect timer due in %ld seconds\n",
11153 thread_timer_remain_second(p
->t_connect
));
11156 "MRAI (interval %u) timer expires in %ld seconds\n",
11158 thread_timer_remain_second(p
->t_routeadv
));
11160 vty_out(vty
, "Peer Authentication Enabled\n");
11162 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
11163 p
->t_read
? "on" : "off",
11164 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
11169 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
11170 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
11171 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
11174 vty_out(vty
, "\n");
11176 /* BFD information. */
11177 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
11180 if (p
->conf_if
) /* Configured interface name. */
11181 json_object_object_add(json
, p
->conf_if
, json_neigh
);
11182 else /* Configured IP address. */
11183 json_object_object_add(json
, p
->host
, json_neigh
);
11187 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
11188 enum show_type type
, union sockunion
*su
,
11189 const char *conf_if
, bool use_json
,
11192 struct listnode
*node
, *nnode
;
11195 bool nbr_output
= false;
11196 afi_t afi
= AFI_MAX
;
11197 safi_t safi
= SAFI_MAX
;
11199 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
11201 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
11205 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11206 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11211 bgp_show_peer(vty
, peer
, use_json
, json
);
11217 && !strcmp(peer
->conf_if
, conf_if
))
11219 && !strcmp(peer
->hostname
, conf_if
))) {
11221 bgp_show_peer(vty
, peer
, use_json
,
11225 if (sockunion_same(&peer
->su
, su
)) {
11227 bgp_show_peer(vty
, peer
, use_json
,
11232 case show_ipv4_peer
:
11233 case show_ipv6_peer
:
11234 FOREACH_SAFI (safi
) {
11235 if (peer
->afc
[afi
][safi
]) {
11238 && !strcmp(peer
->conf_if
, conf_if
))
11240 && !strcmp(peer
->hostname
, conf_if
))) {
11242 bgp_show_peer(vty
, peer
, use_json
,
11247 if (sockunion_same(&peer
->su
, su
)) {
11249 bgp_show_peer(vty
, peer
, use_json
,
11257 case show_ipv4_all
:
11258 case show_ipv6_all
:
11259 FOREACH_SAFI (safi
) {
11260 if (peer
->afc
[afi
][safi
]) {
11261 bgp_show_peer(vty
, peer
, use_json
, json
);
11270 if ((type
== show_peer
|| type
== show_ipv4_peer
||
11271 type
== show_ipv6_peer
) && !find
) {
11273 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
11275 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
11278 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
11279 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
11280 vty_out(vty
, "%% No BGP neighbors found\n");
11283 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11284 json
, JSON_C_TO_STRING_PRETTY
));
11286 vty_out(vty
, "\n");
11289 return CMD_SUCCESS
;
11292 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
11293 enum show_type type
,
11294 const char *ip_str
,
11297 struct listnode
*node
, *nnode
;
11299 union sockunion su
;
11300 json_object
*json
= NULL
;
11301 int ret
, is_first
= 1;
11302 bool nbr_output
= false;
11305 vty_out(vty
, "{\n");
11307 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11310 if (!(json
= json_object_new_object())) {
11312 EC_BGP_JSON_MEM_ERROR
,
11313 "Unable to allocate memory for JSON object");
11315 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
11319 json_object_int_add(json
, "vrfId",
11320 (bgp
->vrf_id
== VRF_UNKNOWN
)
11322 : (int64_t)bgp
->vrf_id
);
11323 json_object_string_add(
11325 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11330 vty_out(vty
, ",\n");
11334 vty_out(vty
, "\"%s\":",
11335 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11339 vty_out(vty
, "\nInstance %s:\n",
11340 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11345 if (type
== show_peer
|| type
== show_ipv4_peer
||
11346 type
== show_ipv6_peer
) {
11347 ret
= str2sockunion(ip_str
, &su
);
11349 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11352 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11355 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
11358 json_object_free(json
);
11362 vty_out(vty
, "}\n");
11363 json_object_free(json
);
11365 else if (!nbr_output
)
11366 vty_out(vty
, "%% BGP instance not found\n");
11369 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
11370 enum show_type type
, const char *ip_str
,
11375 union sockunion su
;
11376 json_object
*json
= NULL
;
11379 if (strmatch(name
, "all")) {
11380 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
11382 return CMD_SUCCESS
;
11384 bgp
= bgp_lookup_by_name(name
);
11387 json
= json_object_new_object();
11388 vty_out(vty
, "%s\n",
11389 json_object_to_json_string_ext(
11391 JSON_C_TO_STRING_PRETTY
));
11392 json_object_free(json
);
11395 "%% BGP instance not found\n");
11397 return CMD_WARNING
;
11401 bgp
= bgp_get_default();
11405 json
= json_object_new_object();
11407 ret
= str2sockunion(ip_str
, &su
);
11409 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11412 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11415 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
11418 json_object_free(json
);
11421 vty_out(vty
, "{}\n");
11423 vty_out(vty
, "%% BGP instance not found\n");
11426 return CMD_SUCCESS
;
11429 /* "show [ip] bgp neighbors" commands. */
11430 DEFUN (show_ip_bgp_neighbors
,
11431 show_ip_bgp_neighbors_cmd
,
11432 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
11436 BGP_INSTANCE_HELP_STR
11439 "Detailed information on TCP and BGP neighbor connections\n"
11440 "Neighbor to display information about\n"
11441 "Neighbor to display information about\n"
11442 "Neighbor on BGP configured interface\n"
11446 char *sh_arg
= NULL
;
11447 enum show_type sh_type
;
11448 afi_t afi
= AFI_MAX
;
11450 bool uj
= use_json(argc
, argv
);
11454 /* [<vrf> VIEWVRFNAME] */
11455 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11456 vrf
= argv
[idx
+ 1]->arg
;
11457 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11459 } else if (argv_find(argv
, argc
, "view", &idx
))
11460 /* [<view> VIEWVRFNAME] */
11461 vrf
= argv
[idx
+ 1]->arg
;
11465 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
11466 sh_type
= show_ipv4_all
;
11468 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
11469 sh_type
= show_ipv6_all
;
11472 sh_type
= show_all
;
11475 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
11476 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
11477 || argv_find(argv
, argc
, "WORD", &idx
)) {
11478 sh_type
= show_peer
;
11479 sh_arg
= argv
[idx
]->arg
;
11482 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
11483 sh_type
= show_ipv4_peer
;
11484 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
11485 sh_type
= show_ipv6_peer
;
11488 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
11491 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
11492 paths' and `show ip mbgp paths'. Those functions results are the
11494 DEFUN (show_ip_bgp_paths
,
11495 show_ip_bgp_paths_cmd
,
11496 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
11501 "Path information\n")
11503 vty_out(vty
, "Address Refcnt Path\n");
11504 aspath_print_all_vty(vty
);
11505 return CMD_SUCCESS
;
11510 static void community_show_all_iterator(struct hash_bucket
*bucket
,
11513 struct community
*com
;
11515 com
= (struct community
*)bucket
->data
;
11516 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
11517 community_str(com
, false));
11520 /* Show BGP's community internal data. */
11521 DEFUN (show_ip_bgp_community_info
,
11522 show_ip_bgp_community_info_cmd
,
11523 "show [ip] bgp community-info",
11527 "List all bgp community information\n")
11529 vty_out(vty
, "Address Refcnt Community\n");
11531 hash_iterate(community_hash(),
11532 (void (*)(struct hash_bucket
*,
11533 void *))community_show_all_iterator
,
11536 return CMD_SUCCESS
;
11539 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
11542 struct lcommunity
*lcom
;
11544 lcom
= (struct lcommunity
*)bucket
->data
;
11545 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11546 lcommunity_str(lcom
, false));
11549 /* Show BGP's community internal data. */
11550 DEFUN (show_ip_bgp_lcommunity_info
,
11551 show_ip_bgp_lcommunity_info_cmd
,
11552 "show ip bgp large-community-info",
11556 "List all bgp large-community information\n")
11558 vty_out(vty
, "Address Refcnt Large-community\n");
11560 hash_iterate(lcommunity_hash(),
11561 (void (*)(struct hash_bucket
*,
11562 void *))lcommunity_show_all_iterator
,
11565 return CMD_SUCCESS
;
11569 DEFUN (show_ip_bgp_attr_info
,
11570 show_ip_bgp_attr_info_cmd
,
11571 "show [ip] bgp attribute-info",
11575 "List all bgp attribute information\n")
11577 attr_show_all(vty
);
11578 return CMD_SUCCESS
;
11581 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
11582 afi_t afi
, safi_t safi
,
11583 bool use_json
, json_object
*json
)
11586 struct listnode
*node
;
11588 char buf1
[INET6_ADDRSTRLEN
];
11590 vpn_policy_direction_t dir
;
11593 json_object
*json_import_vrfs
= NULL
;
11594 json_object
*json_export_vrfs
= NULL
;
11596 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11599 vty_out(vty
, "%s\n",
11600 json_object_to_json_string_ext(
11602 JSON_C_TO_STRING_PRETTY
));
11603 json_object_free(json
);
11605 return CMD_WARNING
;
11608 /* Provide context for the block */
11609 json_object_string_add(json
, "vrf", name
? name
: "default");
11610 json_object_string_add(json
, "afiSafi",
11611 get_afi_safi_str(afi
, safi
, true));
11613 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11614 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11615 json_object_string_add(json
, "importFromVrfs", "none");
11616 json_object_string_add(json
, "importRts", "none");
11618 json_import_vrfs
= json_object_new_array();
11620 for (ALL_LIST_ELEMENTS_RO(
11621 bgp
->vpn_policy
[afi
].import_vrf
,
11623 json_object_array_add(json_import_vrfs
,
11624 json_object_new_string(vname
));
11626 json_object_object_add(json
, "importFromVrfs",
11628 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11629 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11630 ecom_str
= ecommunity_ecom2str(
11631 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11632 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11633 json_object_string_add(json
, "importRts",
11635 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11637 json_object_string_add(json
, "importRts",
11641 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11642 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11643 json_object_string_add(json
, "exportToVrfs", "none");
11644 json_object_string_add(json
, "routeDistinguisher",
11646 json_object_string_add(json
, "exportRts", "none");
11648 json_export_vrfs
= json_object_new_array();
11650 for (ALL_LIST_ELEMENTS_RO(
11651 bgp
->vpn_policy
[afi
].export_vrf
,
11653 json_object_array_add(json_export_vrfs
,
11654 json_object_new_string(vname
));
11655 json_object_object_add(json
, "exportToVrfs",
11657 json_object_string_add(json
, "routeDistinguisher",
11658 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11659 buf1
, RD_ADDRSTRLEN
));
11661 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11662 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11663 ecom_str
= ecommunity_ecom2str(
11664 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11665 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11666 json_object_string_add(json
, "exportRts",
11668 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11670 json_object_string_add(json
, "exportRts",
11675 vty_out(vty
, "%s\n",
11676 json_object_to_json_string_ext(json
,
11677 JSON_C_TO_STRING_PRETTY
));
11678 json_object_free(json
);
11681 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11684 vty_out(vty
, "%% No such BGP instance exist\n");
11685 return CMD_WARNING
;
11688 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11689 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11691 "This VRF is not importing %s routes from any other VRF\n",
11692 get_afi_safi_str(afi
, safi
, false));
11695 "This VRF is importing %s routes from the following VRFs:\n",
11696 get_afi_safi_str(afi
, safi
, false));
11698 for (ALL_LIST_ELEMENTS_RO(
11699 bgp
->vpn_policy
[afi
].import_vrf
,
11701 vty_out(vty
, " %s\n", vname
);
11703 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11705 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11706 ecom_str
= ecommunity_ecom2str(
11707 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11708 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11709 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11711 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11713 vty_out(vty
, "Import RT(s):\n");
11716 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11717 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11719 "This VRF is not exporting %s routes to any other VRF\n",
11720 get_afi_safi_str(afi
, safi
, false));
11723 "This VRF is exporting %s routes to the following VRFs:\n",
11724 get_afi_safi_str(afi
, safi
, false));
11726 for (ALL_LIST_ELEMENTS_RO(
11727 bgp
->vpn_policy
[afi
].export_vrf
,
11729 vty_out(vty
, " %s\n", vname
);
11731 vty_out(vty
, "RD: %s\n",
11732 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11733 buf1
, RD_ADDRSTRLEN
));
11735 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11736 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11737 ecom_str
= ecommunity_ecom2str(
11738 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11739 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11740 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11741 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11743 vty_out(vty
, "Import RT(s):\n");
11747 return CMD_SUCCESS
;
11750 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
11751 safi_t safi
, bool use_json
)
11753 struct listnode
*node
, *nnode
;
11755 char *vrf_name
= NULL
;
11756 json_object
*json
= NULL
;
11757 json_object
*json_vrf
= NULL
;
11758 json_object
*json_vrfs
= NULL
;
11761 json
= json_object_new_object();
11762 json_vrfs
= json_object_new_object();
11765 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11767 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
11768 vrf_name
= bgp
->name
;
11771 json_vrf
= json_object_new_object();
11773 vty_out(vty
, "\nInstance %s:\n",
11774 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11775 ? VRF_DEFAULT_NAME
: bgp
->name
);
11777 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
11779 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11780 json_object_object_add(json_vrfs
,
11781 VRF_DEFAULT_NAME
, json_vrf
);
11783 json_object_object_add(json_vrfs
, vrf_name
,
11789 json_object_object_add(json
, "vrfs", json_vrfs
);
11790 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
11791 JSON_C_TO_STRING_PRETTY
));
11792 json_object_free(json
);
11795 return CMD_SUCCESS
;
11798 /* "show [ip] bgp route-leak" command. */
11799 DEFUN (show_ip_bgp_route_leak
,
11800 show_ip_bgp_route_leak_cmd
,
11801 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11805 BGP_INSTANCE_HELP_STR
11808 "Route leaking information\n"
11812 afi_t afi
= AFI_MAX
;
11813 safi_t safi
= SAFI_MAX
;
11815 bool uj
= use_json(argc
, argv
);
11817 json_object
*json
= NULL
;
11819 /* show [ip] bgp */
11820 if (argv_find(argv
, argc
, "ip", &idx
)) {
11822 safi
= SAFI_UNICAST
;
11824 /* [vrf VIEWVRFNAME] */
11825 if (argv_find(argv
, argc
, "view", &idx
)) {
11827 "%% This command is not applicable to BGP views\n");
11828 return CMD_WARNING
;
11831 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11832 vrf
= argv
[idx
+ 1]->arg
;
11833 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11836 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11837 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11838 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11841 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11843 "%% This command is applicable only for unicast ipv4|ipv6\n");
11844 return CMD_WARNING
;
11847 if (vrf
&& strmatch(vrf
, "all"))
11848 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
11851 json
= json_object_new_object();
11853 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
11856 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11859 struct listnode
*node
, *nnode
;
11862 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11863 vty_out(vty
, "\nInstance %s:\n",
11864 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11867 update_group_show(bgp
, afi
, safi
, vty
, 0);
11871 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11872 int safi
, uint64_t subgrp_id
)
11877 if (strmatch(name
, "all")) {
11878 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11879 return CMD_SUCCESS
;
11881 bgp
= bgp_lookup_by_name(name
);
11884 bgp
= bgp_get_default();
11888 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11889 return CMD_SUCCESS
;
11892 DEFUN (show_ip_bgp_updgrps
,
11893 show_ip_bgp_updgrps_cmd
,
11894 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11898 BGP_INSTANCE_HELP_STR
11900 BGP_SAFI_WITH_LABEL_HELP_STR
11901 "Detailed info about dynamic update groups\n"
11902 "Specific subgroup to display detailed info for\n")
11905 afi_t afi
= AFI_IP6
;
11906 safi_t safi
= SAFI_UNICAST
;
11907 uint64_t subgrp_id
= 0;
11911 /* show [ip] bgp */
11912 if (argv_find(argv
, argc
, "ip", &idx
))
11914 /* [<vrf> VIEWVRFNAME] */
11915 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11916 vrf
= argv
[idx
+ 1]->arg
;
11917 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11919 } else if (argv_find(argv
, argc
, "view", &idx
))
11920 /* [<view> VIEWVRFNAME] */
11921 vrf
= argv
[idx
+ 1]->arg
;
11922 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11923 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11924 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11927 /* get subgroup id, if provided */
11929 if (argv
[idx
]->type
== VARIABLE_TKN
)
11930 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11932 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11935 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11936 show_bgp_instance_all_ipv6_updgrps_cmd
,
11937 "show [ip] bgp <view|vrf> all update-groups",
11941 BGP_INSTANCE_ALL_HELP_STR
11942 "Detailed info about dynamic update groups\n")
11944 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11945 return CMD_SUCCESS
;
11948 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
11949 show_bgp_l2vpn_evpn_updgrps_cmd
,
11950 "show [ip] bgp l2vpn evpn update-groups",
11954 "l2vpn address family\n"
11955 "evpn sub-address family\n"
11956 "Detailed info about dynamic update groups\n")
11959 uint64_t subgrp_id
= 0;
11961 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
11962 return CMD_SUCCESS
;
11965 DEFUN (show_bgp_updgrps_stats
,
11966 show_bgp_updgrps_stats_cmd
,
11967 "show [ip] bgp update-groups statistics",
11971 "Detailed info about dynamic update groups\n"
11976 bgp
= bgp_get_default();
11978 update_group_show_stats(bgp
, vty
);
11980 return CMD_SUCCESS
;
11983 DEFUN (show_bgp_instance_updgrps_stats
,
11984 show_bgp_instance_updgrps_stats_cmd
,
11985 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11989 BGP_INSTANCE_HELP_STR
11990 "Detailed info about dynamic update groups\n"
11996 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11998 update_group_show_stats(bgp
, vty
);
12000 return CMD_SUCCESS
;
12003 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
12004 afi_t afi
, safi_t safi
,
12005 const char *what
, uint64_t subgrp_id
)
12010 bgp
= bgp_lookup_by_name(name
);
12012 bgp
= bgp_get_default();
12015 if (!strcmp(what
, "advertise-queue"))
12016 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
12018 else if (!strcmp(what
, "advertised-routes"))
12019 update_group_show_advertised(bgp
, afi
, safi
, vty
,
12021 else if (!strcmp(what
, "packet-queue"))
12022 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
12027 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
12028 show_ip_bgp_instance_updgrps_adj_s_cmd
,
12029 "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",
12030 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
12032 "Detailed info about dynamic update groups\n"
12033 "Specific subgroup to display info for\n"
12034 "Advertisement queue\n"
12035 "Announced routes\n"
12038 uint64_t subgrp_id
= 0;
12042 subgrp_id
= strtoull(sgid
, NULL
, 10);
12047 afiz
= bgp_vty_afi_from_str(afi
);
12051 afiz
= bgp_vty_afi_from_str(afi
);
12052 if (afiz
!= AFI_IP
)
12054 "%% Cannot specify both 'ip' and 'ipv6'\n");
12055 return CMD_WARNING
;
12058 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
12060 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
12061 return CMD_SUCCESS
;
12064 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
12066 struct listnode
*node
, *nnode
;
12067 struct prefix
*range
;
12070 char buf
[PREFIX2STR_BUFFER
];
12073 const char *peer_status
;
12074 const char *af_str
;
12079 conf
= group
->conf
;
12081 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
12082 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
12083 group
->name
, conf
->as
);
12084 } else if (conf
->as_type
== AS_INTERNAL
) {
12085 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
12086 group
->name
, group
->bgp
->as
);
12088 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
12091 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
12092 vty_out(vty
, " Peer-group type is internal\n");
12094 vty_out(vty
, " Peer-group type is external\n");
12096 /* Display AFs configured. */
12097 vty_out(vty
, " Configured address-families:");
12098 FOREACH_AFI_SAFI (afi
, safi
) {
12099 if (conf
->afc
[afi
][safi
]) {
12101 vty_out(vty
, " %s;", get_afi_safi_str(afi
, safi
, false));
12105 vty_out(vty
, " none\n");
12107 vty_out(vty
, "\n");
12109 /* Display listen ranges (for dynamic neighbors), if any */
12110 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
12113 else if (afi
== AFI_IP6
)
12117 lr_count
= listcount(group
->listen_range
[afi
]);
12119 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
12123 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
12125 prefix2str(range
, buf
, sizeof(buf
));
12126 vty_out(vty
, " %s\n", buf
);
12131 /* Display group members and their status */
12132 if (listcount(group
->peer
)) {
12133 vty_out(vty
, " Peer-group members:\n");
12134 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
12135 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
12136 peer_status
= "Idle (Admin)";
12137 else if (CHECK_FLAG(peer
->sflags
,
12138 PEER_STATUS_PREFIX_OVERFLOW
))
12139 peer_status
= "Idle (PfxCt)";
12141 peer_status
= lookup_msg(bgp_status_msg
,
12142 peer
->status
, NULL
);
12144 dynamic
= peer_dynamic_neighbor(peer
);
12145 vty_out(vty
, " %s %s %s \n", peer
->host
,
12146 dynamic
? "(dynamic)" : "", peer_status
);
12150 return CMD_SUCCESS
;
12153 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
12154 const char *group_name
)
12157 struct listnode
*node
, *nnode
;
12158 struct peer_group
*group
;
12159 bool found
= false;
12161 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
12164 vty_out(vty
, "%% BGP instance not found\n");
12165 return CMD_WARNING
;
12168 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
12170 if (strmatch(group
->name
, group_name
)) {
12171 bgp_show_one_peer_group(vty
, group
);
12176 bgp_show_one_peer_group(vty
, group
);
12180 if (group_name
&& !found
)
12181 vty_out(vty
, "%% No such peer-group\n");
12183 return CMD_SUCCESS
;
12186 DEFUN (show_ip_bgp_peer_groups
,
12187 show_ip_bgp_peer_groups_cmd
,
12188 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
12192 BGP_INSTANCE_HELP_STR
12193 "Detailed information on BGP peer groups\n"
12194 "Peer group name\n")
12199 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
12201 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
12203 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
12207 /* Redistribute VTY commands. */
12209 DEFUN (bgp_redistribute_ipv4
,
12210 bgp_redistribute_ipv4_cmd
,
12211 "redistribute " FRR_IP_REDIST_STR_BGPD
,
12212 "Redistribute information from another routing protocol\n"
12213 FRR_IP_REDIST_HELP_STR_BGPD
)
12215 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12216 int idx_protocol
= 1;
12219 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12221 vty_out(vty
, "%% Invalid route type\n");
12222 return CMD_WARNING_CONFIG_FAILED
;
12225 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12226 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
12230 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
12231 "redistribute " FRR_IP_REDIST_STR_BGPD
,
12232 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
12234 DEFUN (bgp_redistribute_ipv4_rmap
,
12235 bgp_redistribute_ipv4_rmap_cmd
,
12236 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
12237 "Redistribute information from another routing protocol\n"
12238 FRR_IP_REDIST_HELP_STR_BGPD
12239 "Route map reference\n"
12240 "Pointer to route-map entries\n")
12242 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12243 int idx_protocol
= 1;
12246 struct bgp_redist
*red
;
12248 struct route_map
*route_map
= route_map_lookup_warn_noexist(
12249 vty
, argv
[idx_word
]->arg
);
12251 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12253 vty_out(vty
, "%% Invalid route type\n");
12254 return CMD_WARNING_CONFIG_FAILED
;
12257 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12259 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12260 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12264 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
12265 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
12266 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12267 "Route map reference\n"
12268 "Pointer to route-map entries\n")
12270 DEFUN (bgp_redistribute_ipv4_metric
,
12271 bgp_redistribute_ipv4_metric_cmd
,
12272 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12273 "Redistribute information from another routing protocol\n"
12274 FRR_IP_REDIST_HELP_STR_BGPD
12275 "Metric for redistributed routes\n"
12276 "Default metric\n")
12278 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12279 int idx_protocol
= 1;
12280 int idx_number
= 3;
12283 struct bgp_redist
*red
;
12286 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12288 vty_out(vty
, "%% Invalid route type\n");
12289 return CMD_WARNING_CONFIG_FAILED
;
12291 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12293 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12294 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12295 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12299 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
12300 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12301 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12302 "Metric for redistributed routes\n"
12303 "Default metric\n")
12305 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
12306 bgp_redistribute_ipv4_rmap_metric_cmd
,
12307 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12308 "Redistribute information from another routing protocol\n"
12309 FRR_IP_REDIST_HELP_STR_BGPD
12310 "Route map reference\n"
12311 "Pointer to route-map entries\n"
12312 "Metric for redistributed routes\n"
12313 "Default metric\n")
12315 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12316 int idx_protocol
= 1;
12318 int idx_number
= 5;
12321 struct bgp_redist
*red
;
12323 struct route_map
*route_map
=
12324 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12326 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12328 vty_out(vty
, "%% Invalid route type\n");
12329 return CMD_WARNING_CONFIG_FAILED
;
12331 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12333 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12335 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12336 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12337 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12341 bgp_redistribute_ipv4_rmap_metric
,
12342 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
12343 "redistribute " FRR_IP_REDIST_STR_BGPD
12344 " route-map WORD metric (0-4294967295)",
12345 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12346 "Route map reference\n"
12347 "Pointer to route-map entries\n"
12348 "Metric for redistributed routes\n"
12349 "Default metric\n")
12351 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
12352 bgp_redistribute_ipv4_metric_rmap_cmd
,
12353 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12354 "Redistribute information from another routing protocol\n"
12355 FRR_IP_REDIST_HELP_STR_BGPD
12356 "Metric for redistributed routes\n"
12358 "Route map reference\n"
12359 "Pointer to route-map entries\n")
12361 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12362 int idx_protocol
= 1;
12363 int idx_number
= 3;
12367 struct bgp_redist
*red
;
12369 struct route_map
*route_map
=
12370 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12372 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12374 vty_out(vty
, "%% Invalid route type\n");
12375 return CMD_WARNING_CONFIG_FAILED
;
12377 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12379 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12380 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12382 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12383 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12387 bgp_redistribute_ipv4_metric_rmap
,
12388 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
12389 "redistribute " FRR_IP_REDIST_STR_BGPD
12390 " metric (0-4294967295) route-map WORD",
12391 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12392 "Metric for redistributed routes\n"
12394 "Route map reference\n"
12395 "Pointer to route-map entries\n")
12397 DEFUN (bgp_redistribute_ipv4_ospf
,
12398 bgp_redistribute_ipv4_ospf_cmd
,
12399 "redistribute <ospf|table> (1-65535)",
12400 "Redistribute information from another routing protocol\n"
12401 "Open Shortest Path First (OSPFv2)\n"
12402 "Non-main Kernel Routing Table\n"
12403 "Instance ID/Table ID\n")
12405 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12406 int idx_ospf_table
= 1;
12407 int idx_number
= 2;
12408 unsigned short instance
;
12409 unsigned short protocol
;
12411 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12413 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12414 protocol
= ZEBRA_ROUTE_OSPF
;
12416 protocol
= ZEBRA_ROUTE_TABLE
;
12418 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12419 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
12422 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
12423 "redistribute <ospf|table> (1-65535)",
12424 "Redistribute information from another routing protocol\n"
12425 "Open Shortest Path First (OSPFv2)\n"
12426 "Non-main Kernel Routing Table\n"
12427 "Instance ID/Table ID\n")
12429 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
12430 bgp_redistribute_ipv4_ospf_rmap_cmd
,
12431 "redistribute <ospf|table> (1-65535) route-map WORD",
12432 "Redistribute information from another routing protocol\n"
12433 "Open Shortest Path First (OSPFv2)\n"
12434 "Non-main Kernel Routing Table\n"
12435 "Instance ID/Table ID\n"
12436 "Route map reference\n"
12437 "Pointer to route-map entries\n")
12439 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12440 int idx_ospf_table
= 1;
12441 int idx_number
= 2;
12443 struct bgp_redist
*red
;
12444 unsigned short instance
;
12447 struct route_map
*route_map
=
12448 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12450 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12451 protocol
= ZEBRA_ROUTE_OSPF
;
12453 protocol
= ZEBRA_ROUTE_TABLE
;
12455 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12456 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12458 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12459 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12462 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
12463 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
12464 "redistribute <ospf|table> (1-65535) route-map WORD",
12465 "Redistribute information from another routing protocol\n"
12466 "Open Shortest Path First (OSPFv2)\n"
12467 "Non-main Kernel Routing Table\n"
12468 "Instance ID/Table ID\n"
12469 "Route map reference\n"
12470 "Pointer to route-map entries\n")
12472 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
12473 bgp_redistribute_ipv4_ospf_metric_cmd
,
12474 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12475 "Redistribute information from another routing protocol\n"
12476 "Open Shortest Path First (OSPFv2)\n"
12477 "Non-main Kernel Routing Table\n"
12478 "Instance ID/Table ID\n"
12479 "Metric for redistributed routes\n"
12480 "Default metric\n")
12482 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12483 int idx_ospf_table
= 1;
12484 int idx_number
= 2;
12485 int idx_number_2
= 4;
12487 struct bgp_redist
*red
;
12488 unsigned short instance
;
12492 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12493 protocol
= ZEBRA_ROUTE_OSPF
;
12495 protocol
= ZEBRA_ROUTE_TABLE
;
12497 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12498 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12500 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12501 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12503 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12506 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
12507 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
12508 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12509 "Redistribute information from another routing protocol\n"
12510 "Open Shortest Path First (OSPFv2)\n"
12511 "Non-main Kernel Routing Table\n"
12512 "Instance ID/Table ID\n"
12513 "Metric for redistributed routes\n"
12514 "Default metric\n")
12516 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
12517 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
12518 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12519 "Redistribute information from another routing protocol\n"
12520 "Open Shortest Path First (OSPFv2)\n"
12521 "Non-main Kernel Routing Table\n"
12522 "Instance ID/Table ID\n"
12523 "Route map reference\n"
12524 "Pointer to route-map entries\n"
12525 "Metric for redistributed routes\n"
12526 "Default metric\n")
12528 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12529 int idx_ospf_table
= 1;
12530 int idx_number
= 2;
12532 int idx_number_2
= 6;
12534 struct bgp_redist
*red
;
12535 unsigned short instance
;
12538 struct route_map
*route_map
=
12539 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12541 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12542 protocol
= ZEBRA_ROUTE_OSPF
;
12544 protocol
= ZEBRA_ROUTE_TABLE
;
12546 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12547 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12549 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12551 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12552 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12554 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12558 bgp_redistribute_ipv4_ospf_rmap_metric
,
12559 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
12560 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12561 "Redistribute information from another routing protocol\n"
12562 "Open Shortest Path First (OSPFv2)\n"
12563 "Non-main Kernel Routing Table\n"
12564 "Instance ID/Table ID\n"
12565 "Route map reference\n"
12566 "Pointer to route-map entries\n"
12567 "Metric for redistributed routes\n"
12568 "Default metric\n")
12570 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
12571 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
12572 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12573 "Redistribute information from another routing protocol\n"
12574 "Open Shortest Path First (OSPFv2)\n"
12575 "Non-main Kernel Routing Table\n"
12576 "Instance ID/Table ID\n"
12577 "Metric for redistributed routes\n"
12579 "Route map reference\n"
12580 "Pointer to route-map entries\n")
12582 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12583 int idx_ospf_table
= 1;
12584 int idx_number
= 2;
12585 int idx_number_2
= 4;
12588 struct bgp_redist
*red
;
12589 unsigned short instance
;
12592 struct route_map
*route_map
=
12593 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12595 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12596 protocol
= ZEBRA_ROUTE_OSPF
;
12598 protocol
= ZEBRA_ROUTE_TABLE
;
12600 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12601 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12603 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12604 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12607 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12608 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12612 bgp_redistribute_ipv4_ospf_metric_rmap
,
12613 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
12614 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12615 "Redistribute information from another routing protocol\n"
12616 "Open Shortest Path First (OSPFv2)\n"
12617 "Non-main Kernel Routing Table\n"
12618 "Instance ID/Table ID\n"
12619 "Metric for redistributed routes\n"
12621 "Route map reference\n"
12622 "Pointer to route-map entries\n")
12624 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12625 no_bgp_redistribute_ipv4_ospf_cmd
,
12626 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
12628 "Redistribute information from another routing protocol\n"
12629 "Open Shortest Path First (OSPFv2)\n"
12630 "Non-main Kernel Routing Table\n"
12631 "Instance ID/Table ID\n"
12632 "Metric for redistributed routes\n"
12634 "Route map reference\n"
12635 "Pointer to route-map entries\n")
12637 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12638 int idx_ospf_table
= 2;
12639 int idx_number
= 3;
12640 unsigned short instance
;
12643 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12644 protocol
= ZEBRA_ROUTE_OSPF
;
12646 protocol
= ZEBRA_ROUTE_TABLE
;
12648 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12649 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12653 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12654 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
12656 "Redistribute information from another routing protocol\n"
12657 "Open Shortest Path First (OSPFv2)\n"
12658 "Non-main Kernel Routing Table\n"
12659 "Instance ID/Table ID\n"
12660 "Metric for redistributed routes\n"
12662 "Route map reference\n"
12663 "Pointer to route-map entries\n")
12665 DEFUN (no_bgp_redistribute_ipv4
,
12666 no_bgp_redistribute_ipv4_cmd
,
12667 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
12669 "Redistribute information from another routing protocol\n"
12670 FRR_IP_REDIST_HELP_STR_BGPD
12671 "Metric for redistributed routes\n"
12673 "Route map reference\n"
12674 "Pointer to route-map entries\n")
12676 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12677 int idx_protocol
= 2;
12680 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12682 vty_out(vty
, "%% Invalid route type\n");
12683 return CMD_WARNING_CONFIG_FAILED
;
12685 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12689 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12690 "no redistribute " FRR_IP_REDIST_STR_BGPD
12691 " [{metric (0-4294967295)|route-map WORD}]",
12693 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12694 "Metric for redistributed routes\n"
12696 "Route map reference\n"
12697 "Pointer to route-map entries\n")
12699 DEFUN (bgp_redistribute_ipv6
,
12700 bgp_redistribute_ipv6_cmd
,
12701 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12702 "Redistribute information from another routing protocol\n"
12703 FRR_IP6_REDIST_HELP_STR_BGPD
)
12705 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12706 int idx_protocol
= 1;
12709 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12711 vty_out(vty
, "%% Invalid route type\n");
12712 return CMD_WARNING_CONFIG_FAILED
;
12715 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12716 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12719 DEFUN (bgp_redistribute_ipv6_rmap
,
12720 bgp_redistribute_ipv6_rmap_cmd
,
12721 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12722 "Redistribute information from another routing protocol\n"
12723 FRR_IP6_REDIST_HELP_STR_BGPD
12724 "Route map reference\n"
12725 "Pointer to route-map entries\n")
12727 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12728 int idx_protocol
= 1;
12731 struct bgp_redist
*red
;
12733 struct route_map
*route_map
=
12734 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12736 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12738 vty_out(vty
, "%% Invalid route type\n");
12739 return CMD_WARNING_CONFIG_FAILED
;
12742 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12744 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12745 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12748 DEFUN (bgp_redistribute_ipv6_metric
,
12749 bgp_redistribute_ipv6_metric_cmd
,
12750 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12751 "Redistribute information from another routing protocol\n"
12752 FRR_IP6_REDIST_HELP_STR_BGPD
12753 "Metric for redistributed routes\n"
12754 "Default metric\n")
12756 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12757 int idx_protocol
= 1;
12758 int idx_number
= 3;
12761 struct bgp_redist
*red
;
12764 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12766 vty_out(vty
, "%% Invalid route type\n");
12767 return CMD_WARNING_CONFIG_FAILED
;
12769 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12771 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12772 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12773 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12776 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12777 bgp_redistribute_ipv6_rmap_metric_cmd
,
12778 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12779 "Redistribute information from another routing protocol\n"
12780 FRR_IP6_REDIST_HELP_STR_BGPD
12781 "Route map reference\n"
12782 "Pointer to route-map entries\n"
12783 "Metric for redistributed routes\n"
12784 "Default metric\n")
12786 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12787 int idx_protocol
= 1;
12789 int idx_number
= 5;
12792 struct bgp_redist
*red
;
12794 struct route_map
*route_map
=
12795 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12797 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12799 vty_out(vty
, "%% Invalid route type\n");
12800 return CMD_WARNING_CONFIG_FAILED
;
12802 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12804 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12806 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12807 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12809 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12812 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12813 bgp_redistribute_ipv6_metric_rmap_cmd
,
12814 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12815 "Redistribute information from another routing protocol\n"
12816 FRR_IP6_REDIST_HELP_STR_BGPD
12817 "Metric for redistributed routes\n"
12819 "Route map reference\n"
12820 "Pointer to route-map entries\n")
12822 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12823 int idx_protocol
= 1;
12824 int idx_number
= 3;
12828 struct bgp_redist
*red
;
12830 struct route_map
*route_map
=
12831 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12833 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12835 vty_out(vty
, "%% Invalid route type\n");
12836 return CMD_WARNING_CONFIG_FAILED
;
12838 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12840 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12841 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12844 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12845 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12848 DEFUN (no_bgp_redistribute_ipv6
,
12849 no_bgp_redistribute_ipv6_cmd
,
12850 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
12852 "Redistribute information from another routing protocol\n"
12853 FRR_IP6_REDIST_HELP_STR_BGPD
12854 "Metric for redistributed routes\n"
12856 "Route map reference\n"
12857 "Pointer to route-map entries\n")
12859 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12860 int idx_protocol
= 2;
12863 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12865 vty_out(vty
, "%% Invalid route type\n");
12866 return CMD_WARNING_CONFIG_FAILED
;
12869 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12872 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
12873 afi_t afi
, safi_t safi
)
12877 /* Unicast redistribution only. */
12878 if (safi
!= SAFI_UNICAST
)
12881 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12882 /* Redistribute BGP does not make sense. */
12883 if (i
!= ZEBRA_ROUTE_BGP
) {
12884 struct list
*red_list
;
12885 struct listnode
*node
;
12886 struct bgp_redist
*red
;
12888 red_list
= bgp
->redist
[afi
][i
];
12892 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12893 /* "redistribute" configuration. */
12894 vty_out(vty
, " redistribute %s",
12895 zebra_route_string(i
));
12897 vty_out(vty
, " %d", red
->instance
);
12898 if (red
->redist_metric_flag
)
12899 vty_out(vty
, " metric %u",
12900 red
->redist_metric
);
12901 if (red
->rmap
.name
)
12902 vty_out(vty
, " route-map %s",
12904 vty_out(vty
, "\n");
12910 /* peer-group helpers for config-write */
12912 static bool peergroup_flag_check(struct peer
*peer
, uint32_t flag
)
12914 if (!peer_group_active(peer
)) {
12915 if (CHECK_FLAG(peer
->flags_invert
, flag
))
12916 return !CHECK_FLAG(peer
->flags
, flag
);
12918 return !!CHECK_FLAG(peer
->flags
, flag
);
12921 return !!CHECK_FLAG(peer
->flags_override
, flag
);
12924 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
12927 if (!peer_group_active(peer
)) {
12928 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
12929 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
12931 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
12934 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
12937 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
12938 uint8_t type
, int direct
)
12940 struct bgp_filter
*filter
;
12942 if (peer_group_active(peer
))
12943 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
12946 filter
= &peer
->filter
[afi
][safi
];
12948 case PEER_FT_DISTRIBUTE_LIST
:
12949 return !!(filter
->dlist
[direct
].name
);
12950 case PEER_FT_FILTER_LIST
:
12951 return !!(filter
->aslist
[direct
].name
);
12952 case PEER_FT_PREFIX_LIST
:
12953 return !!(filter
->plist
[direct
].name
);
12954 case PEER_FT_ROUTE_MAP
:
12955 return !!(filter
->map
[direct
].name
);
12956 case PEER_FT_UNSUPPRESS_MAP
:
12957 return !!(filter
->usmap
.name
);
12963 /* Return true if the addpath type is set for peer and different from
12966 static int peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
, safi_t safi
)
12968 enum bgp_addpath_strat type
, g_type
;
12970 type
= peer
->addpath_type
[afi
][safi
];
12972 if (type
!= BGP_ADDPATH_NONE
) {
12973 if (peer_group_active(peer
)) {
12974 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
12976 if (type
!= g_type
)
12988 /* This is part of the address-family block (unicast only) */
12989 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12994 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12995 if (listcount(bgp
->vpn_policy
[afi
].import_vrf
))
12996 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12997 bgp
->vpn_policy
[afi
]
12998 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
13000 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
13001 bgp
->vpn_policy
[afi
]
13002 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
13004 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
13005 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
13006 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
13007 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
13010 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
13011 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
13013 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
13016 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
13017 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
13018 bgp
->vpn_policy
[afi
].tovpn_label
);
13021 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
13022 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
13023 char buf
[RD_ADDRSTRLEN
];
13024 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
13025 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
13028 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
13029 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
13031 char buf
[PREFIX_STRLEN
];
13032 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
13033 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
13036 vty_out(vty
, "%*snexthop vpn export %s\n",
13040 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
13041 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
13043 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
13044 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
13046 char *b
= ecommunity_ecom2str(
13047 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
13048 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
13049 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
13050 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
13052 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
13053 char *b
= ecommunity_ecom2str(
13054 bgp
->vpn_policy
[afi
]
13055 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
13056 ECOMMUNITY_FORMAT_ROUTE_MAP
,
13057 ECOMMUNITY_ROUTE_TARGET
);
13058 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
13059 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
13061 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
13062 char *b
= ecommunity_ecom2str(
13063 bgp
->vpn_policy
[afi
]
13064 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
13065 ECOMMUNITY_FORMAT_ROUTE_MAP
,
13066 ECOMMUNITY_ROUTE_TARGET
);
13067 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
13068 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
13072 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
13073 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
13074 bgp
->vpn_policy
[afi
]
13075 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
13077 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
13078 char *b
= ecommunity_ecom2str(
13079 bgp
->vpn_policy
[afi
]
13080 .import_redirect_rtlist
,
13081 ECOMMUNITY_FORMAT_ROUTE_MAP
,
13082 ECOMMUNITY_ROUTE_TARGET
);
13084 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
13085 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
13089 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
13090 afi_t afi
, safi_t safi
)
13092 struct bgp_filter
*filter
;
13096 filter
= &peer
->filter
[afi
][safi
];
13098 /* distribute-list. */
13099 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
13101 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
13102 filter
->dlist
[FILTER_IN
].name
);
13104 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
13106 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
13107 filter
->dlist
[FILTER_OUT
].name
);
13110 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
13112 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
13113 filter
->plist
[FILTER_IN
].name
);
13115 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
13117 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
13118 filter
->plist
[FILTER_OUT
].name
);
13121 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
13122 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
13123 filter
->map
[RMAP_IN
].name
);
13125 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
13127 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
13128 filter
->map
[RMAP_OUT
].name
);
13130 /* unsuppress-map */
13131 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
13132 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
13133 filter
->usmap
.name
);
13136 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
13138 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
13139 filter
->aslist
[FILTER_IN
].name
);
13141 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
13143 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
13144 filter
->aslist
[FILTER_OUT
].name
);
13147 /* BGP peer configuration display function. */
13148 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
13151 struct peer
*g_peer
= NULL
;
13152 char buf
[SU_ADDRSTRLEN
];
13154 int if_pg_printed
= false;
13155 int if_ras_printed
= false;
13157 /* Skip dynamic neighbors. */
13158 if (peer_dynamic_neighbor(peer
))
13162 addr
= peer
->conf_if
;
13166 /************************************
13167 ****** Global to the neighbor ******
13168 ************************************/
13169 if (peer
->conf_if
) {
13170 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
13171 vty_out(vty
, " neighbor %s interface v6only", addr
);
13173 vty_out(vty
, " neighbor %s interface", addr
);
13175 if (peer_group_active(peer
)) {
13176 vty_out(vty
, " peer-group %s", peer
->group
->name
);
13177 if_pg_printed
= true;
13178 } else if (peer
->as_type
== AS_SPECIFIED
) {
13179 vty_out(vty
, " remote-as %u", peer
->as
);
13180 if_ras_printed
= true;
13181 } else if (peer
->as_type
== AS_INTERNAL
) {
13182 vty_out(vty
, " remote-as internal");
13183 if_ras_printed
= true;
13184 } else if (peer
->as_type
== AS_EXTERNAL
) {
13185 vty_out(vty
, " remote-as external");
13186 if_ras_printed
= true;
13189 vty_out(vty
, "\n");
13192 /* remote-as and peer-group */
13193 /* peer is a member of a peer-group */
13194 if (peer_group_active(peer
)) {
13195 g_peer
= peer
->group
->conf
;
13197 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
13198 if (peer
->as_type
== AS_SPECIFIED
) {
13199 vty_out(vty
, " neighbor %s remote-as %u\n",
13201 } else if (peer
->as_type
== AS_INTERNAL
) {
13203 " neighbor %s remote-as internal\n",
13205 } else if (peer
->as_type
== AS_EXTERNAL
) {
13207 " neighbor %s remote-as external\n",
13212 /* For swpX peers we displayed the peer-group
13213 * via 'neighbor swpX interface peer-group PGNAME' */
13214 if (!if_pg_printed
)
13215 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
13216 peer
->group
->name
);
13219 /* peer is NOT a member of a peer-group */
13221 /* peer is a peer-group, declare the peer-group */
13222 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
13223 vty_out(vty
, " neighbor %s peer-group\n", addr
);
13226 if (!if_ras_printed
) {
13227 if (peer
->as_type
== AS_SPECIFIED
) {
13228 vty_out(vty
, " neighbor %s remote-as %u\n",
13230 } else if (peer
->as_type
== AS_INTERNAL
) {
13232 " neighbor %s remote-as internal\n",
13234 } else if (peer
->as_type
== AS_EXTERNAL
) {
13236 " neighbor %s remote-as external\n",
13243 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
13244 vty_out(vty
, " neighbor %s local-as %u", addr
,
13245 peer
->change_local_as
);
13246 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
13247 vty_out(vty
, " no-prepend");
13248 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
13249 vty_out(vty
, " replace-as");
13250 vty_out(vty
, "\n");
13255 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
13259 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
13260 if (peer
->tx_shutdown_message
)
13261 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
13262 peer
->tx_shutdown_message
);
13264 vty_out(vty
, " neighbor %s shutdown\n", addr
);
13268 if (peer
->bfd_info
) {
13269 if (!peer_group_active(peer
) || !g_peer
->bfd_info
) {
13270 bgp_bfd_peer_config_write(vty
, peer
, addr
);
13275 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
13276 vty_out(vty
, " neighbor %s password %s\n", addr
,
13279 /* neighbor solo */
13280 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
13281 if (!peer_group_active(peer
)) {
13282 vty_out(vty
, " neighbor %s solo\n", addr
);
13287 if (peer
->port
!= BGP_PORT_DEFAULT
) {
13288 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
13291 /* Local interface name */
13292 if (peer
->ifname
) {
13293 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
13297 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
13298 vty_out(vty
, " neighbor %s passive\n", addr
);
13300 /* ebgp-multihop */
13301 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
13302 && !(peer
->gtsm_hops
!= 0 && peer
->ttl
== MAXTTL
)) {
13303 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
13304 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
13309 /* ttl-security hops */
13310 if (peer
->gtsm_hops
!= 0) {
13311 if (!peer_group_active(peer
)
13312 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
13313 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
13314 addr
, peer
->gtsm_hops
);
13318 /* disable-connected-check */
13319 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
13320 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
13322 /* enforce-first-as */
13323 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
13324 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
13326 /* update-source */
13327 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
13328 if (peer
->update_source
)
13329 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
13330 sockunion2str(peer
->update_source
, buf
,
13332 else if (peer
->update_if
)
13333 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
13337 /* advertisement-interval */
13338 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
13339 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
13343 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
13344 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
13345 peer
->keepalive
, peer
->holdtime
);
13347 /* timers connect */
13348 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
13349 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
13351 /* need special-case handling for changed default values due to
13352 * config profile / version (because there is no "timers bgp connect"
13353 * command, we need to save this per-peer :/)
13355 else if (!peer_group_active(peer
) && !peer
->connect
&&
13356 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
13357 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
13358 peer
->bgp
->default_connect_retry
);
13360 /* capability dynamic */
13361 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
13362 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
13364 /* capability extended-nexthop */
13365 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
13366 if (!peer
->conf_if
) {
13367 if (CHECK_FLAG(peer
->flags_invert
,
13368 PEER_FLAG_CAPABILITY_ENHE
))
13370 " no neighbor %s capability extended-nexthop\n",
13374 " neighbor %s capability extended-nexthop\n",
13379 /* dont-capability-negotiation */
13380 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
13381 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
13383 /* override-capability */
13384 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
13385 vty_out(vty
, " neighbor %s override-capability\n", addr
);
13387 /* strict-capability-match */
13388 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
13389 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
13391 /* Sender side AS path loop detection. */
13392 if (peer
->as_path_loop_detection
)
13393 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
13397 /* BGP peer configuration display function. */
13398 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
13399 struct peer
*peer
, afi_t afi
, safi_t safi
)
13401 struct peer
*g_peer
= NULL
;
13403 bool flag_scomm
, flag_secomm
, flag_slcomm
;
13405 /* Skip dynamic neighbors. */
13406 if (peer_dynamic_neighbor(peer
))
13410 addr
= peer
->conf_if
;
13414 /************************************
13415 ****** Per AF to the neighbor ******
13416 ************************************/
13417 if (peer_group_active(peer
)) {
13418 g_peer
= peer
->group
->conf
;
13420 /* If the peer-group is active but peer is not, print a 'no
13422 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
13423 vty_out(vty
, " no neighbor %s activate\n", addr
);
13426 /* If the peer-group is not active but peer is, print an
13428 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
13429 vty_out(vty
, " neighbor %s activate\n", addr
);
13432 if (peer
->afc
[afi
][safi
]) {
13433 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
13434 if (bgp_flag_check(bgp
,
13435 BGP_FLAG_NO_DEFAULT_IPV4
)) {
13436 vty_out(vty
, " neighbor %s activate\n",
13440 vty_out(vty
, " neighbor %s activate\n", addr
);
13442 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
13443 if (!bgp_flag_check(bgp
,
13444 BGP_FLAG_NO_DEFAULT_IPV4
)) {
13446 " no neighbor %s activate\n",
13453 /* addpath TX knobs */
13454 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
13455 switch (peer
->addpath_type
[afi
][safi
]) {
13456 case BGP_ADDPATH_ALL
:
13457 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
13460 case BGP_ADDPATH_BEST_PER_AS
:
13462 " neighbor %s addpath-tx-bestpath-per-AS\n",
13465 case BGP_ADDPATH_MAX
:
13466 case BGP_ADDPATH_NONE
:
13471 /* ORF capability. */
13472 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
13473 || peergroup_af_flag_check(peer
, afi
, safi
,
13474 PEER_FLAG_ORF_PREFIX_RM
)) {
13475 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
13477 if (peergroup_af_flag_check(peer
, afi
, safi
,
13478 PEER_FLAG_ORF_PREFIX_SM
)
13479 && peergroup_af_flag_check(peer
, afi
, safi
,
13480 PEER_FLAG_ORF_PREFIX_RM
))
13481 vty_out(vty
, " both");
13482 else if (peergroup_af_flag_check(peer
, afi
, safi
,
13483 PEER_FLAG_ORF_PREFIX_SM
))
13484 vty_out(vty
, " send");
13486 vty_out(vty
, " receive");
13487 vty_out(vty
, "\n");
13490 /* BGP flag dampening. */
13491 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
13492 BGP_CONFIG_DAMPENING
))
13493 bgp_config_write_damp(vty
, afi
, safi
);
13495 /* Route reflector client. */
13496 if (peergroup_af_flag_check(peer
, afi
, safi
,
13497 PEER_FLAG_REFLECTOR_CLIENT
)) {
13498 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
13501 /* next-hop-self force */
13502 if (peergroup_af_flag_check(peer
, afi
, safi
,
13503 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
13504 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
13507 /* next-hop-self */
13508 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
13509 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
13512 /* remove-private-AS */
13513 if (peergroup_af_flag_check(peer
, afi
, safi
,
13514 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
13515 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
13519 else if (peergroup_af_flag_check(peer
, afi
, safi
,
13520 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
13521 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
13525 else if (peergroup_af_flag_check(peer
, afi
, safi
,
13526 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
13527 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
13530 else if (peergroup_af_flag_check(peer
, afi
, safi
,
13531 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
13532 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
13536 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
13537 vty_out(vty
, " neighbor %s as-override\n", addr
);
13540 /* send-community print. */
13541 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
13542 PEER_FLAG_SEND_COMMUNITY
);
13543 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
13544 PEER_FLAG_SEND_EXT_COMMUNITY
);
13545 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
13546 PEER_FLAG_SEND_LARGE_COMMUNITY
);
13548 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
13549 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
13552 vty_out(vty
, " no neighbor %s send-community\n", addr
);
13555 " no neighbor %s send-community extended\n",
13559 vty_out(vty
, " no neighbor %s send-community large\n",
13563 /* Default information */
13564 if (peergroup_af_flag_check(peer
, afi
, safi
,
13565 PEER_FLAG_DEFAULT_ORIGINATE
)) {
13566 vty_out(vty
, " neighbor %s default-originate", addr
);
13568 if (peer
->default_rmap
[afi
][safi
].name
)
13569 vty_out(vty
, " route-map %s",
13570 peer
->default_rmap
[afi
][safi
].name
);
13572 vty_out(vty
, "\n");
13575 /* Soft reconfiguration inbound. */
13576 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
13577 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
13581 /* maximum-prefix. */
13582 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
13583 vty_out(vty
, " neighbor %s maximum-prefix %" PRIu32
, addr
,
13584 peer
->pmax
[afi
][safi
]);
13586 if (peer
->pmax_threshold
[afi
][safi
]
13587 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
13588 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
13589 if (peer_af_flag_check(peer
, afi
, safi
,
13590 PEER_FLAG_MAX_PREFIX_WARNING
))
13591 vty_out(vty
, " warning-only");
13592 if (peer
->pmax_restart
[afi
][safi
])
13593 vty_out(vty
, " restart %u",
13594 peer
->pmax_restart
[afi
][safi
]);
13596 vty_out(vty
, "\n");
13599 /* Route server client. */
13600 if (peergroup_af_flag_check(peer
, afi
, safi
,
13601 PEER_FLAG_RSERVER_CLIENT
)) {
13602 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
13605 /* Nexthop-local unchanged. */
13606 if (peergroup_af_flag_check(peer
, afi
, safi
,
13607 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
13608 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
13611 /* allowas-in <1-10> */
13612 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
13613 if (peer_af_flag_check(peer
, afi
, safi
,
13614 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
13615 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
13616 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
13617 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
13619 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
13620 peer
->allowas_in
[afi
][safi
]);
13625 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
13626 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
13627 peer
->weight
[afi
][safi
]);
13630 bgp_config_write_filter(vty
, peer
, afi
, safi
);
13632 /* atribute-unchanged. */
13633 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
13634 || (safi
!= SAFI_EVPN
13635 && peer_af_flag_check(peer
, afi
, safi
,
13636 PEER_FLAG_NEXTHOP_UNCHANGED
))
13637 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
13639 if (!peer_group_active(peer
)
13640 || peergroup_af_flag_check(peer
, afi
, safi
,
13641 PEER_FLAG_AS_PATH_UNCHANGED
)
13642 || peergroup_af_flag_check(peer
, afi
, safi
,
13643 PEER_FLAG_NEXTHOP_UNCHANGED
)
13644 || peergroup_af_flag_check(peer
, afi
, safi
,
13645 PEER_FLAG_MED_UNCHANGED
)) {
13648 " neighbor %s attribute-unchanged%s%s%s\n",
13650 peer_af_flag_check(peer
, afi
, safi
,
13651 PEER_FLAG_AS_PATH_UNCHANGED
)
13654 peer_af_flag_check(peer
, afi
, safi
,
13655 PEER_FLAG_NEXTHOP_UNCHANGED
)
13658 peer_af_flag_check(peer
, afi
, safi
,
13659 PEER_FLAG_MED_UNCHANGED
)
13666 /* Address family based peer configuration display. */
13667 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
13671 struct peer_group
*group
;
13672 struct listnode
*node
, *nnode
;
13675 vty_frame(vty
, " !\n address-family ");
13676 if (afi
== AFI_IP
) {
13677 if (safi
== SAFI_UNICAST
)
13678 vty_frame(vty
, "ipv4 unicast");
13679 else if (safi
== SAFI_LABELED_UNICAST
)
13680 vty_frame(vty
, "ipv4 labeled-unicast");
13681 else if (safi
== SAFI_MULTICAST
)
13682 vty_frame(vty
, "ipv4 multicast");
13683 else if (safi
== SAFI_MPLS_VPN
)
13684 vty_frame(vty
, "ipv4 vpn");
13685 else if (safi
== SAFI_ENCAP
)
13686 vty_frame(vty
, "ipv4 encap");
13687 else if (safi
== SAFI_FLOWSPEC
)
13688 vty_frame(vty
, "ipv4 flowspec");
13689 } else if (afi
== AFI_IP6
) {
13690 if (safi
== SAFI_UNICAST
)
13691 vty_frame(vty
, "ipv6 unicast");
13692 else if (safi
== SAFI_LABELED_UNICAST
)
13693 vty_frame(vty
, "ipv6 labeled-unicast");
13694 else if (safi
== SAFI_MULTICAST
)
13695 vty_frame(vty
, "ipv6 multicast");
13696 else if (safi
== SAFI_MPLS_VPN
)
13697 vty_frame(vty
, "ipv6 vpn");
13698 else if (safi
== SAFI_ENCAP
)
13699 vty_frame(vty
, "ipv6 encap");
13700 else if (safi
== SAFI_FLOWSPEC
)
13701 vty_frame(vty
, "ipv6 flowspec");
13702 } else if (afi
== AFI_L2VPN
) {
13703 if (safi
== SAFI_EVPN
)
13704 vty_frame(vty
, "l2vpn evpn");
13706 vty_frame(vty
, "\n");
13708 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
13710 bgp_config_write_network(vty
, bgp
, afi
, safi
);
13712 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
13714 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
13715 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
13717 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
13718 /* Skip dynamic neighbors. */
13719 if (peer_dynamic_neighbor(peer
))
13722 /* Do not display doppelganger peers */
13723 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
13724 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
13727 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
13728 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
13730 if (safi
== SAFI_EVPN
)
13731 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
13733 if (safi
== SAFI_FLOWSPEC
)
13734 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
13736 if (safi
== SAFI_UNICAST
) {
13737 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
13738 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
13739 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
13741 vty_out(vty
, " export vpn\n");
13743 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
13744 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
13746 vty_out(vty
, " import vpn\n");
13748 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
13749 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
13752 for (ALL_LIST_ELEMENTS_RO(
13753 bgp
->vpn_policy
[afi
].import_vrf
, node
,
13755 vty_out(vty
, " import vrf %s\n", name
);
13759 vty_endframe(vty
, " exit-address-family\n");
13762 int bgp_config_write(struct vty
*vty
)
13765 struct peer_group
*group
;
13767 struct listnode
*node
, *nnode
;
13768 struct listnode
*mnode
, *mnnode
;
13770 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
13771 vty_out(vty
, "bgp route-map delay-timer %u\n",
13772 bm
->rmap_update_timer
);
13774 /* BGP configuration. */
13775 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
13777 /* skip all auto created vrf as they dont have user config */
13778 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
13781 /* Router bgp ASN */
13782 vty_out(vty
, "router bgp %u", bgp
->as
);
13785 vty_out(vty
, " %s %s",
13786 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
13787 ? "view" : "vrf", bgp
->name
);
13788 vty_out(vty
, "\n");
13790 /* BGP fast-external-failover. */
13791 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
13792 vty_out(vty
, " no bgp fast-external-failover\n");
13794 /* BGP router ID. */
13795 if (bgp
->router_id_static
.s_addr
!= 0)
13796 vty_out(vty
, " bgp router-id %s\n",
13797 inet_ntoa(bgp
->router_id_static
));
13799 /* BGP log-neighbor-changes. */
13800 if (!!bgp_flag_check(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
13801 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
13802 vty_out(vty
, " %sbgp log-neighbor-changes\n",
13803 bgp_flag_check(bgp
,
13804 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
13808 /* BGP configuration. */
13809 if (bgp_flag_check(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
))
13810 vty_out(vty
, " bgp always-compare-med\n");
13812 /* RFC8212 default eBGP policy. */
13813 if (bgp
->ebgp_requires_policy
13814 == DEFAULT_EBGP_POLICY_ENABLED
)
13815 vty_out(vty
, " bgp ebgp-requires-policy\n");
13817 /* draft-ietf-idr-deprecate-as-set-confed-set */
13818 if (bgp
->reject_as_sets
== BGP_REJECT_AS_SETS_ENABLED
)
13819 vty_out(vty
, " bgp reject-as-sets\n");
13821 /* BGP default ipv4-unicast. */
13822 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
))
13823 vty_out(vty
, " no bgp default ipv4-unicast\n");
13825 /* BGP default local-preference. */
13826 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
13827 vty_out(vty
, " bgp default local-preference %u\n",
13828 bgp
->default_local_pref
);
13830 /* BGP default show-hostname */
13831 if (!!bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
)
13832 != SAVE_BGP_SHOW_HOSTNAME
)
13833 vty_out(vty
, " %sbgp default show-hostname\n",
13834 bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
)
13838 /* BGP default subgroup-pkt-queue-max. */
13839 if (bgp
->default_subgroup_pkt_queue_max
13840 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
13841 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
13842 bgp
->default_subgroup_pkt_queue_max
);
13844 /* BGP client-to-client reflection. */
13845 if (bgp_flag_check(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
13846 vty_out(vty
, " no bgp client-to-client reflection\n");
13848 /* BGP cluster ID. */
13849 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
13850 vty_out(vty
, " bgp cluster-id %s\n",
13851 inet_ntoa(bgp
->cluster_id
));
13853 /* Disable ebgp connected nexthop check */
13854 if (bgp_flag_check(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
13856 " bgp disable-ebgp-connected-route-check\n");
13858 /* Confederation identifier*/
13859 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13860 vty_out(vty
, " bgp confederation identifier %u\n",
13863 /* Confederation peer */
13864 if (bgp
->confed_peers_cnt
> 0) {
13867 vty_out(vty
, " bgp confederation peers");
13869 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
13870 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
13872 vty_out(vty
, "\n");
13875 /* BGP deterministic-med. */
13876 if (!!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)
13877 != SAVE_BGP_DETERMINISTIC_MED
)
13878 vty_out(vty
, " %sbgp deterministic-med\n",
13879 bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)
13883 /* BGP update-delay. */
13884 bgp_config_write_update_delay(vty
, bgp
);
13886 if (bgp
->v_maxmed_onstartup
13887 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
13888 vty_out(vty
, " bgp max-med on-startup %u",
13889 bgp
->v_maxmed_onstartup
);
13890 if (bgp
->maxmed_onstartup_value
13891 != BGP_MAXMED_VALUE_DEFAULT
)
13892 vty_out(vty
, " %u",
13893 bgp
->maxmed_onstartup_value
);
13894 vty_out(vty
, "\n");
13896 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
13897 vty_out(vty
, " bgp max-med administrative");
13898 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
13899 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
13900 vty_out(vty
, "\n");
13904 bgp_config_write_wpkt_quanta(vty
, bgp
);
13906 bgp_config_write_rpkt_quanta(vty
, bgp
);
13908 /* coalesce time */
13909 bgp_config_write_coalesce_time(vty
, bgp
);
13911 /* BGP graceful-restart. */
13912 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
13914 " bgp graceful-restart stalepath-time %u\n",
13915 bgp
->stalepath_time
);
13916 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
13917 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
13918 bgp
->restart_time
);
13919 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_RESTART
))
13920 vty_out(vty
, " bgp graceful-restart\n");
13922 /* BGP graceful-shutdown */
13923 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
13924 vty_out(vty
, " bgp graceful-shutdown\n");
13926 /* BGP graceful-restart Preserve State F bit. */
13927 if (bgp_flag_check(bgp
, BGP_FLAG_GR_PRESERVE_FWD
))
13929 " bgp graceful-restart preserve-fw-state\n");
13931 /* BGP bestpath method. */
13932 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
13933 vty_out(vty
, " bgp bestpath as-path ignore\n");
13934 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
13935 vty_out(vty
, " bgp bestpath as-path confed\n");
13937 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
13938 if (bgp_flag_check(bgp
,
13939 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
13941 " bgp bestpath as-path multipath-relax as-set\n");
13944 " bgp bestpath as-path multipath-relax\n");
13948 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
13950 " bgp route-reflector allow-outbound-policy\n");
13952 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
13953 vty_out(vty
, " bgp bestpath compare-routerid\n");
13954 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
13955 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
13956 vty_out(vty
, " bgp bestpath med");
13957 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
13958 vty_out(vty
, " confed");
13959 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
13960 vty_out(vty
, " missing-as-worst");
13961 vty_out(vty
, "\n");
13964 /* BGP network import check. */
13965 if (!!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)
13966 != SAVE_BGP_IMPORT_CHECK
)
13967 vty_out(vty
, " %sbgp network import-check\n",
13968 bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)
13972 /* BGP timers configuration. */
13973 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
13974 && bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
13975 vty_out(vty
, " timers bgp %u %u\n",
13976 bgp
->default_keepalive
, bgp
->default_holdtime
);
13979 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
13980 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
13983 /* Normal neighbor configuration. */
13984 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
13985 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
13986 bgp_config_write_peer_global(vty
, bgp
, peer
);
13989 /* listen range and limit for dynamic BGP neighbors */
13990 bgp_config_write_listen(vty
, bgp
);
13993 * BGP default autoshutdown neighbors
13995 * This must be placed after any peer and peer-group
13996 * configuration, to avoid setting all peers to shutdown after
13997 * a daemon restart, which is undesired behavior. (see #2286)
13999 if (bgp
->autoshutdown
)
14000 vty_out(vty
, " bgp default shutdown\n");
14002 /* IPv4 unicast configuration. */
14003 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
14005 /* IPv4 multicast configuration. */
14006 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
14008 /* IPv4 labeled-unicast configuration. */
14009 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
14011 /* IPv4 VPN configuration. */
14012 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
14014 /* ENCAPv4 configuration. */
14015 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
14017 /* FLOWSPEC v4 configuration. */
14018 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
14020 /* IPv6 unicast configuration. */
14021 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
14023 /* IPv6 multicast configuration. */
14024 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
14026 /* IPv6 labeled-unicast configuration. */
14027 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
14028 SAFI_LABELED_UNICAST
);
14030 /* IPv6 VPN configuration. */
14031 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
14033 /* ENCAPv6 configuration. */
14034 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
14036 /* FLOWSPEC v6 configuration. */
14037 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
14039 /* EVPN configuration. */
14040 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
14042 hook_call(bgp_inst_config_write
, bgp
, vty
);
14045 bgp_rfapi_cfg_write(vty
, bgp
);
14048 vty_out(vty
, "!\n");
14054 /* BGP node structure. */
14055 static struct cmd_node bgp_node
= {
14056 BGP_NODE
, "%s(config-router)# ", 1,
14059 static struct cmd_node bgp_ipv4_unicast_node
= {
14060 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
14063 static struct cmd_node bgp_ipv4_multicast_node
= {
14064 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
14067 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
14068 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
14071 static struct cmd_node bgp_ipv6_unicast_node
= {
14072 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
14075 static struct cmd_node bgp_ipv6_multicast_node
= {
14076 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
14079 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
14080 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
14083 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
14084 "%s(config-router-af)# ", 1};
14086 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
14087 "%s(config-router-af-vpnv6)# ", 1};
14089 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
14090 "%s(config-router-evpn)# ", 1};
14092 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
14093 "%s(config-router-af-vni)# ", 1};
14095 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
14096 "%s(config-router-af)# ", 1};
14098 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
14099 "%s(config-router-af-vpnv6)# ", 1};
14101 static void community_list_vty(void);
14103 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
14107 struct listnode
*lnbgp
, *lnpeer
;
14109 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
14110 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
14111 /* only provide suggestions on the appropriate input
14113 * they'll otherwise show up multiple times */
14114 enum cmd_token_type match_type
;
14115 char *name
= peer
->host
;
14117 if (peer
->conf_if
) {
14118 match_type
= VARIABLE_TKN
;
14119 name
= peer
->conf_if
;
14120 } else if (strchr(peer
->host
, ':'))
14121 match_type
= IPV6_TKN
;
14123 match_type
= IPV4_TKN
;
14125 if (token
->type
!= match_type
)
14128 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
14133 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
14134 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
14135 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
14136 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
14137 {.completions
= NULL
}};
14139 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
14142 struct peer_group
*group
;
14143 struct listnode
*lnbgp
, *lnpeer
;
14145 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
14146 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
14147 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
14152 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
14153 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
14154 {.completions
= NULL
} };
14156 void bgp_vty_init(void)
14158 cmd_variable_handler_register(bgp_var_neighbor
);
14159 cmd_variable_handler_register(bgp_var_peergroup
);
14161 /* Install bgp top node. */
14162 install_node(&bgp_node
, bgp_config_write
);
14163 install_node(&bgp_ipv4_unicast_node
, NULL
);
14164 install_node(&bgp_ipv4_multicast_node
, NULL
);
14165 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
14166 install_node(&bgp_ipv6_unicast_node
, NULL
);
14167 install_node(&bgp_ipv6_multicast_node
, NULL
);
14168 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
14169 install_node(&bgp_vpnv4_node
, NULL
);
14170 install_node(&bgp_vpnv6_node
, NULL
);
14171 install_node(&bgp_evpn_node
, NULL
);
14172 install_node(&bgp_evpn_vni_node
, NULL
);
14173 install_node(&bgp_flowspecv4_node
, NULL
);
14174 install_node(&bgp_flowspecv6_node
, NULL
);
14176 /* Install default VTY commands to new nodes. */
14177 install_default(BGP_NODE
);
14178 install_default(BGP_IPV4_NODE
);
14179 install_default(BGP_IPV4M_NODE
);
14180 install_default(BGP_IPV4L_NODE
);
14181 install_default(BGP_IPV6_NODE
);
14182 install_default(BGP_IPV6M_NODE
);
14183 install_default(BGP_IPV6L_NODE
);
14184 install_default(BGP_VPNV4_NODE
);
14185 install_default(BGP_VPNV6_NODE
);
14186 install_default(BGP_FLOWSPECV4_NODE
);
14187 install_default(BGP_FLOWSPECV6_NODE
);
14188 install_default(BGP_EVPN_NODE
);
14189 install_default(BGP_EVPN_VNI_NODE
);
14191 /* "bgp local-mac" hidden commands. */
14192 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
14193 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
14195 /* bgp route-map delay-timer commands. */
14196 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
14197 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
14199 /* Dummy commands (Currently not supported) */
14200 install_element(BGP_NODE
, &no_synchronization_cmd
);
14201 install_element(BGP_NODE
, &no_auto_summary_cmd
);
14203 /* "router bgp" commands. */
14204 install_element(CONFIG_NODE
, &router_bgp_cmd
);
14206 /* "no router bgp" commands. */
14207 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
14209 /* "bgp router-id" commands. */
14210 install_element(BGP_NODE
, &bgp_router_id_cmd
);
14211 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
14213 /* "bgp cluster-id" commands. */
14214 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
14215 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
14217 /* "bgp confederation" commands. */
14218 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
14219 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
14221 /* "bgp confederation peers" commands. */
14222 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
14223 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
14225 /* bgp max-med command */
14226 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
14227 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
14228 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
14229 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
14230 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
14232 /* bgp disable-ebgp-connected-nh-check */
14233 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
14234 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
14236 /* bgp update-delay command */
14237 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
14238 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
14239 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
14241 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
14242 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
14244 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
14245 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
14247 /* "maximum-paths" commands. */
14248 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
14249 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
14250 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
14251 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
14252 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
14253 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
14254 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
14255 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
14256 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
14257 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
14258 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
14259 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
14260 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
14261 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
14262 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
14264 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
14265 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
14266 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
14267 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
14268 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
14270 /* "timers bgp" commands. */
14271 install_element(BGP_NODE
, &bgp_timers_cmd
);
14272 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
14274 /* route-map delay-timer commands - per instance for backwards compat.
14276 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
14277 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
14279 /* "bgp client-to-client reflection" commands */
14280 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
14281 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
14283 /* "bgp always-compare-med" commands */
14284 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
14285 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
14287 /* bgp ebgp-requires-policy */
14288 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
14289 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
14291 /* bgp reject-as-sets */
14292 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
14293 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
14295 /* "bgp deterministic-med" commands */
14296 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
14297 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
14299 /* "bgp graceful-restart" commands */
14300 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
14301 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
14302 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
14303 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
14304 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
14305 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
14307 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
14308 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
14310 /* "bgp graceful-shutdown" commands */
14311 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
14312 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
14314 /* "bgp fast-external-failover" commands */
14315 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
14316 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
14318 /* "bgp bestpath compare-routerid" commands */
14319 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
14320 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
14322 /* "bgp bestpath as-path ignore" commands */
14323 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
14324 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
14326 /* "bgp bestpath as-path confed" commands */
14327 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
14328 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
14330 /* "bgp bestpath as-path multipath-relax" commands */
14331 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
14332 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
14334 /* "bgp log-neighbor-changes" commands */
14335 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
14336 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
14338 /* "bgp bestpath med" commands */
14339 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
14340 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
14342 /* "no bgp default ipv4-unicast" commands. */
14343 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
14344 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
14346 /* "bgp network import-check" commands. */
14347 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
14348 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
14349 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
14351 /* "bgp default local-preference" commands. */
14352 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
14353 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
14355 /* bgp default show-hostname */
14356 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
14357 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
14359 /* "bgp default subgroup-pkt-queue-max" commands. */
14360 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
14361 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
14363 /* bgp ibgp-allow-policy-mods command */
14364 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
14365 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
14367 /* "bgp listen limit" commands. */
14368 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
14369 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
14371 /* "bgp listen range" commands. */
14372 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
14373 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
14375 /* "bgp default shutdown" command */
14376 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
14378 /* "neighbor remote-as" commands. */
14379 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
14380 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
14381 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
14382 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
14383 install_element(BGP_NODE
,
14384 &neighbor_interface_v6only_config_remote_as_cmd
);
14385 install_element(BGP_NODE
, &no_neighbor_cmd
);
14386 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
14388 /* "neighbor peer-group" commands. */
14389 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
14390 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
14391 install_element(BGP_NODE
,
14392 &no_neighbor_interface_peer_group_remote_as_cmd
);
14394 /* "neighbor local-as" commands. */
14395 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
14396 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
14397 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
14398 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
14400 /* "neighbor solo" commands. */
14401 install_element(BGP_NODE
, &neighbor_solo_cmd
);
14402 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
14404 /* "neighbor password" commands. */
14405 install_element(BGP_NODE
, &neighbor_password_cmd
);
14406 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
14408 /* "neighbor activate" commands. */
14409 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
14410 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
14411 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
14412 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
14413 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
14414 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
14415 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
14416 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
14417 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
14418 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
14419 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
14420 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
14422 /* "no neighbor activate" commands. */
14423 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
14424 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
14425 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
14426 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
14427 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
14428 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
14429 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
14430 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
14431 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
14432 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
14433 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
14434 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
14436 /* "neighbor peer-group" set commands. */
14437 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
14438 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
14439 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
14440 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
14441 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
14442 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
14443 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
14444 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
14445 install_element(BGP_FLOWSPECV4_NODE
,
14446 &neighbor_set_peer_group_hidden_cmd
);
14447 install_element(BGP_FLOWSPECV6_NODE
,
14448 &neighbor_set_peer_group_hidden_cmd
);
14450 /* "no neighbor peer-group unset" commands. */
14451 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
14452 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
14453 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
14454 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
14455 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
14456 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
14457 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
14458 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
14459 install_element(BGP_FLOWSPECV4_NODE
,
14460 &no_neighbor_set_peer_group_hidden_cmd
);
14461 install_element(BGP_FLOWSPECV6_NODE
,
14462 &no_neighbor_set_peer_group_hidden_cmd
);
14464 /* "neighbor softreconfiguration inbound" commands.*/
14465 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
14466 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
14467 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
14468 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
14469 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
14470 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
14471 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
14472 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
14473 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
14474 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
14475 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
14476 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
14477 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
14478 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
14479 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
14480 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
14481 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
14482 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
14483 install_element(BGP_FLOWSPECV4_NODE
,
14484 &neighbor_soft_reconfiguration_cmd
);
14485 install_element(BGP_FLOWSPECV4_NODE
,
14486 &no_neighbor_soft_reconfiguration_cmd
);
14487 install_element(BGP_FLOWSPECV6_NODE
,
14488 &neighbor_soft_reconfiguration_cmd
);
14489 install_element(BGP_FLOWSPECV6_NODE
,
14490 &no_neighbor_soft_reconfiguration_cmd
);
14491 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
14492 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
14494 /* "neighbor attribute-unchanged" commands. */
14495 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
14496 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
14497 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
14498 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
14499 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
14500 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
14501 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
14502 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
14503 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
14504 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
14505 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
14506 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
14507 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
14508 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
14509 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
14510 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
14511 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
14512 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
14514 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
14515 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
14517 /* "nexthop-local unchanged" commands */
14518 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
14519 install_element(BGP_IPV6_NODE
,
14520 &no_neighbor_nexthop_local_unchanged_cmd
);
14522 /* "neighbor next-hop-self" commands. */
14523 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
14524 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
14525 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
14526 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
14527 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
14528 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
14529 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
14530 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
14531 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
14532 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
14533 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
14534 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
14535 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
14536 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
14537 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
14538 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
14539 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
14540 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
14541 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
14542 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
14544 /* "neighbor next-hop-self force" commands. */
14545 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
14546 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
14547 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
14548 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
14549 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
14550 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
14551 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
14552 install_element(BGP_IPV4_NODE
,
14553 &no_neighbor_nexthop_self_all_hidden_cmd
);
14554 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
14555 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
14556 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
14557 install_element(BGP_IPV4M_NODE
,
14558 &no_neighbor_nexthop_self_all_hidden_cmd
);
14559 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
14560 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
14561 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
14562 install_element(BGP_IPV4L_NODE
,
14563 &no_neighbor_nexthop_self_all_hidden_cmd
);
14564 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
14565 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
14566 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
14567 install_element(BGP_IPV6_NODE
,
14568 &no_neighbor_nexthop_self_all_hidden_cmd
);
14569 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
14570 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
14571 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
14572 install_element(BGP_IPV6M_NODE
,
14573 &no_neighbor_nexthop_self_all_hidden_cmd
);
14574 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
14575 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
14576 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
14577 install_element(BGP_IPV6L_NODE
,
14578 &no_neighbor_nexthop_self_all_hidden_cmd
);
14579 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
14580 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
14581 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
14582 install_element(BGP_VPNV4_NODE
,
14583 &no_neighbor_nexthop_self_all_hidden_cmd
);
14584 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
14585 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
14586 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
14587 install_element(BGP_VPNV6_NODE
,
14588 &no_neighbor_nexthop_self_all_hidden_cmd
);
14590 /* "neighbor as-override" commands. */
14591 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
14592 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
14593 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
14594 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
14595 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
14596 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
14597 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
14598 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
14599 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
14600 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
14601 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
14602 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
14603 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
14604 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
14605 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
14606 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
14607 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
14608 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
14610 /* "neighbor remove-private-AS" commands. */
14611 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
14612 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
14613 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
14614 install_element(BGP_NODE
,
14615 &no_neighbor_remove_private_as_all_hidden_cmd
);
14616 install_element(BGP_NODE
,
14617 &neighbor_remove_private_as_replace_as_hidden_cmd
);
14618 install_element(BGP_NODE
,
14619 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
14620 install_element(BGP_NODE
,
14621 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
14624 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
14625 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
14626 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
14627 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
14628 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
14629 install_element(BGP_IPV4_NODE
,
14630 &neighbor_remove_private_as_replace_as_cmd
);
14631 install_element(BGP_IPV4_NODE
,
14632 &no_neighbor_remove_private_as_replace_as_cmd
);
14633 install_element(BGP_IPV4_NODE
,
14634 &neighbor_remove_private_as_all_replace_as_cmd
);
14635 install_element(BGP_IPV4_NODE
,
14636 &no_neighbor_remove_private_as_all_replace_as_cmd
);
14637 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
14638 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
14639 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
14640 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
14641 install_element(BGP_IPV4M_NODE
,
14642 &neighbor_remove_private_as_replace_as_cmd
);
14643 install_element(BGP_IPV4M_NODE
,
14644 &no_neighbor_remove_private_as_replace_as_cmd
);
14645 install_element(BGP_IPV4M_NODE
,
14646 &neighbor_remove_private_as_all_replace_as_cmd
);
14647 install_element(BGP_IPV4M_NODE
,
14648 &no_neighbor_remove_private_as_all_replace_as_cmd
);
14649 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
14650 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
14651 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
14652 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
14653 install_element(BGP_IPV4L_NODE
,
14654 &neighbor_remove_private_as_replace_as_cmd
);
14655 install_element(BGP_IPV4L_NODE
,
14656 &no_neighbor_remove_private_as_replace_as_cmd
);
14657 install_element(BGP_IPV4L_NODE
,
14658 &neighbor_remove_private_as_all_replace_as_cmd
);
14659 install_element(BGP_IPV4L_NODE
,
14660 &no_neighbor_remove_private_as_all_replace_as_cmd
);
14661 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
14662 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
14663 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
14664 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
14665 install_element(BGP_IPV6_NODE
,
14666 &neighbor_remove_private_as_replace_as_cmd
);
14667 install_element(BGP_IPV6_NODE
,
14668 &no_neighbor_remove_private_as_replace_as_cmd
);
14669 install_element(BGP_IPV6_NODE
,
14670 &neighbor_remove_private_as_all_replace_as_cmd
);
14671 install_element(BGP_IPV6_NODE
,
14672 &no_neighbor_remove_private_as_all_replace_as_cmd
);
14673 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
14674 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
14675 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
14676 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
14677 install_element(BGP_IPV6M_NODE
,
14678 &neighbor_remove_private_as_replace_as_cmd
);
14679 install_element(BGP_IPV6M_NODE
,
14680 &no_neighbor_remove_private_as_replace_as_cmd
);
14681 install_element(BGP_IPV6M_NODE
,
14682 &neighbor_remove_private_as_all_replace_as_cmd
);
14683 install_element(BGP_IPV6M_NODE
,
14684 &no_neighbor_remove_private_as_all_replace_as_cmd
);
14685 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
14686 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
14687 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
14688 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
14689 install_element(BGP_IPV6L_NODE
,
14690 &neighbor_remove_private_as_replace_as_cmd
);
14691 install_element(BGP_IPV6L_NODE
,
14692 &no_neighbor_remove_private_as_replace_as_cmd
);
14693 install_element(BGP_IPV6L_NODE
,
14694 &neighbor_remove_private_as_all_replace_as_cmd
);
14695 install_element(BGP_IPV6L_NODE
,
14696 &no_neighbor_remove_private_as_all_replace_as_cmd
);
14697 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
14698 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
14699 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
14700 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
14701 install_element(BGP_VPNV4_NODE
,
14702 &neighbor_remove_private_as_replace_as_cmd
);
14703 install_element(BGP_VPNV4_NODE
,
14704 &no_neighbor_remove_private_as_replace_as_cmd
);
14705 install_element(BGP_VPNV4_NODE
,
14706 &neighbor_remove_private_as_all_replace_as_cmd
);
14707 install_element(BGP_VPNV4_NODE
,
14708 &no_neighbor_remove_private_as_all_replace_as_cmd
);
14709 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
14710 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
14711 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
14712 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
14713 install_element(BGP_VPNV6_NODE
,
14714 &neighbor_remove_private_as_replace_as_cmd
);
14715 install_element(BGP_VPNV6_NODE
,
14716 &no_neighbor_remove_private_as_replace_as_cmd
);
14717 install_element(BGP_VPNV6_NODE
,
14718 &neighbor_remove_private_as_all_replace_as_cmd
);
14719 install_element(BGP_VPNV6_NODE
,
14720 &no_neighbor_remove_private_as_all_replace_as_cmd
);
14722 /* "neighbor send-community" commands.*/
14723 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
14724 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
14725 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
14726 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
14727 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
14728 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
14729 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
14730 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
14731 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
14732 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
14733 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
14734 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
14735 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
14736 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
14737 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
14738 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
14739 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
14740 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
14741 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
14742 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
14743 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
14744 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
14745 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
14746 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
14747 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
14748 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
14749 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
14750 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
14751 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
14752 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
14753 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
14754 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
14755 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
14756 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
14757 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
14758 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
14760 /* "neighbor route-reflector" commands.*/
14761 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
14762 install_element(BGP_NODE
,
14763 &no_neighbor_route_reflector_client_hidden_cmd
);
14764 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
14765 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
14766 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
14767 install_element(BGP_IPV4M_NODE
,
14768 &no_neighbor_route_reflector_client_cmd
);
14769 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
14770 install_element(BGP_IPV4L_NODE
,
14771 &no_neighbor_route_reflector_client_cmd
);
14772 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
14773 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
14774 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
14775 install_element(BGP_IPV6M_NODE
,
14776 &no_neighbor_route_reflector_client_cmd
);
14777 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
14778 install_element(BGP_IPV6L_NODE
,
14779 &no_neighbor_route_reflector_client_cmd
);
14780 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
14781 install_element(BGP_VPNV4_NODE
,
14782 &no_neighbor_route_reflector_client_cmd
);
14783 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
14784 install_element(BGP_VPNV6_NODE
,
14785 &no_neighbor_route_reflector_client_cmd
);
14786 install_element(BGP_FLOWSPECV4_NODE
,
14787 &neighbor_route_reflector_client_cmd
);
14788 install_element(BGP_FLOWSPECV4_NODE
,
14789 &no_neighbor_route_reflector_client_cmd
);
14790 install_element(BGP_FLOWSPECV6_NODE
,
14791 &neighbor_route_reflector_client_cmd
);
14792 install_element(BGP_FLOWSPECV6_NODE
,
14793 &no_neighbor_route_reflector_client_cmd
);
14794 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
14795 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
14797 /* "neighbor route-server" commands.*/
14798 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
14799 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
14800 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
14801 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
14802 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
14803 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
14804 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
14805 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
14806 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
14807 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
14808 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
14809 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
14810 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
14811 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
14812 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
14813 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
14814 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
14815 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
14816 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
14817 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
14818 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
14819 install_element(BGP_FLOWSPECV4_NODE
,
14820 &no_neighbor_route_server_client_cmd
);
14821 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
14822 install_element(BGP_FLOWSPECV6_NODE
,
14823 &no_neighbor_route_server_client_cmd
);
14825 /* "neighbor addpath-tx-all-paths" commands.*/
14826 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
14827 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
14828 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
14829 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
14830 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
14831 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
14832 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
14833 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
14834 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
14835 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
14836 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
14837 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
14838 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
14839 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
14840 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
14841 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
14842 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
14843 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
14845 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
14846 install_element(BGP_NODE
,
14847 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
14848 install_element(BGP_NODE
,
14849 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
14850 install_element(BGP_IPV4_NODE
,
14851 &neighbor_addpath_tx_bestpath_per_as_cmd
);
14852 install_element(BGP_IPV4_NODE
,
14853 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
14854 install_element(BGP_IPV4M_NODE
,
14855 &neighbor_addpath_tx_bestpath_per_as_cmd
);
14856 install_element(BGP_IPV4M_NODE
,
14857 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
14858 install_element(BGP_IPV4L_NODE
,
14859 &neighbor_addpath_tx_bestpath_per_as_cmd
);
14860 install_element(BGP_IPV4L_NODE
,
14861 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
14862 install_element(BGP_IPV6_NODE
,
14863 &neighbor_addpath_tx_bestpath_per_as_cmd
);
14864 install_element(BGP_IPV6_NODE
,
14865 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
14866 install_element(BGP_IPV6M_NODE
,
14867 &neighbor_addpath_tx_bestpath_per_as_cmd
);
14868 install_element(BGP_IPV6M_NODE
,
14869 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
14870 install_element(BGP_IPV6L_NODE
,
14871 &neighbor_addpath_tx_bestpath_per_as_cmd
);
14872 install_element(BGP_IPV6L_NODE
,
14873 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
14874 install_element(BGP_VPNV4_NODE
,
14875 &neighbor_addpath_tx_bestpath_per_as_cmd
);
14876 install_element(BGP_VPNV4_NODE
,
14877 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
14878 install_element(BGP_VPNV6_NODE
,
14879 &neighbor_addpath_tx_bestpath_per_as_cmd
);
14880 install_element(BGP_VPNV6_NODE
,
14881 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
14883 /* "neighbor sender-as-path-loop-detection" commands. */
14884 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
14885 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
14887 /* "neighbor passive" commands. */
14888 install_element(BGP_NODE
, &neighbor_passive_cmd
);
14889 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
14892 /* "neighbor shutdown" commands. */
14893 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
14894 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
14895 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
14896 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
14898 /* "neighbor capability extended-nexthop" commands.*/
14899 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
14900 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
14902 /* "neighbor capability orf prefix-list" commands.*/
14903 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
14904 install_element(BGP_NODE
,
14905 &no_neighbor_capability_orf_prefix_hidden_cmd
);
14906 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
14907 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
14908 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
14909 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
14910 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
14911 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
14912 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
14913 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
14914 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
14915 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
14916 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
14917 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
14919 /* "neighbor capability dynamic" commands.*/
14920 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
14921 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
14923 /* "neighbor dont-capability-negotiate" commands. */
14924 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
14925 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
14927 /* "neighbor ebgp-multihop" commands. */
14928 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
14929 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
14930 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
14932 /* "neighbor disable-connected-check" commands. */
14933 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
14934 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
14936 /* "neighbor enforce-first-as" commands. */
14937 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
14938 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
14940 /* "neighbor description" commands. */
14941 install_element(BGP_NODE
, &neighbor_description_cmd
);
14942 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
14943 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
14945 /* "neighbor update-source" commands. "*/
14946 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
14947 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
14949 /* "neighbor default-originate" commands. */
14950 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
14951 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
14952 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
14953 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
14954 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
14955 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
14956 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
14957 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
14958 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
14959 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
14960 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
14961 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
14962 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
14963 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
14964 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
14965 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
14966 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
14967 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
14968 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
14969 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
14970 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
14972 /* "neighbor port" commands. */
14973 install_element(BGP_NODE
, &neighbor_port_cmd
);
14974 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
14976 /* "neighbor weight" commands. */
14977 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
14978 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
14980 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
14981 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
14982 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
14983 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
14984 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
14985 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
14986 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
14987 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
14988 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
14989 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
14990 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
14991 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
14992 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
14993 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
14994 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
14995 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
14997 /* "neighbor override-capability" commands. */
14998 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
14999 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
15001 /* "neighbor strict-capability-match" commands. */
15002 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
15003 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
15005 /* "neighbor timers" commands. */
15006 install_element(BGP_NODE
, &neighbor_timers_cmd
);
15007 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
15009 /* "neighbor timers connect" commands. */
15010 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
15011 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
15013 /* "neighbor advertisement-interval" commands. */
15014 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
15015 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
15017 /* "neighbor interface" commands. */
15018 install_element(BGP_NODE
, &neighbor_interface_cmd
);
15019 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
15021 /* "neighbor distribute" commands. */
15022 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
15023 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
15024 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
15025 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
15026 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
15027 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
15028 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
15029 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
15030 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
15031 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
15032 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
15033 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
15034 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
15035 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
15036 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
15037 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
15038 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
15039 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
15041 /* "neighbor prefix-list" commands. */
15042 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
15043 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
15044 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
15045 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
15046 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
15047 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
15048 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
15049 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
15050 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
15051 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
15052 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
15053 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
15054 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
15055 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
15056 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
15057 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
15058 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
15059 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
15060 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
15061 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
15062 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
15063 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
15065 /* "neighbor filter-list" commands. */
15066 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
15067 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
15068 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
15069 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
15070 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
15071 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
15072 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
15073 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
15074 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
15075 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
15076 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
15077 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
15078 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
15079 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
15080 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
15081 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
15082 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
15083 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
15084 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
15085 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
15086 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
15087 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
15089 /* "neighbor route-map" commands. */
15090 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
15091 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
15092 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
15093 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
15094 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
15095 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
15096 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
15097 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
15098 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
15099 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
15100 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
15101 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
15102 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
15103 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
15104 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
15105 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
15106 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
15107 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
15108 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
15109 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
15110 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
15111 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
15112 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
15113 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
15115 /* "neighbor unsuppress-map" commands. */
15116 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
15117 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
15118 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
15119 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
15120 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
15121 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
15122 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
15123 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
15124 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
15125 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
15126 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
15127 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
15128 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
15129 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
15130 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
15131 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
15132 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
15133 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
15135 /* "neighbor maximum-prefix" commands. */
15136 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
15137 install_element(BGP_NODE
,
15138 &neighbor_maximum_prefix_threshold_hidden_cmd
);
15139 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
15140 install_element(BGP_NODE
,
15141 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
15142 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
15143 install_element(BGP_NODE
,
15144 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
15145 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
15146 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
15147 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
15148 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
15149 install_element(BGP_IPV4_NODE
,
15150 &neighbor_maximum_prefix_threshold_warning_cmd
);
15151 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
15152 install_element(BGP_IPV4_NODE
,
15153 &neighbor_maximum_prefix_threshold_restart_cmd
);
15154 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
15155 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
15156 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
15157 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
15158 install_element(BGP_IPV4M_NODE
,
15159 &neighbor_maximum_prefix_threshold_warning_cmd
);
15160 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
15161 install_element(BGP_IPV4M_NODE
,
15162 &neighbor_maximum_prefix_threshold_restart_cmd
);
15163 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
15164 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
15165 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
15166 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
15167 install_element(BGP_IPV4L_NODE
,
15168 &neighbor_maximum_prefix_threshold_warning_cmd
);
15169 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
15170 install_element(BGP_IPV4L_NODE
,
15171 &neighbor_maximum_prefix_threshold_restart_cmd
);
15172 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
15173 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
15174 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
15175 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
15176 install_element(BGP_IPV6_NODE
,
15177 &neighbor_maximum_prefix_threshold_warning_cmd
);
15178 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
15179 install_element(BGP_IPV6_NODE
,
15180 &neighbor_maximum_prefix_threshold_restart_cmd
);
15181 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
15182 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
15183 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
15184 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
15185 install_element(BGP_IPV6M_NODE
,
15186 &neighbor_maximum_prefix_threshold_warning_cmd
);
15187 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
15188 install_element(BGP_IPV6M_NODE
,
15189 &neighbor_maximum_prefix_threshold_restart_cmd
);
15190 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
15191 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
15192 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
15193 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
15194 install_element(BGP_IPV6L_NODE
,
15195 &neighbor_maximum_prefix_threshold_warning_cmd
);
15196 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
15197 install_element(BGP_IPV6L_NODE
,
15198 &neighbor_maximum_prefix_threshold_restart_cmd
);
15199 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
15200 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
15201 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
15202 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
15203 install_element(BGP_VPNV4_NODE
,
15204 &neighbor_maximum_prefix_threshold_warning_cmd
);
15205 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
15206 install_element(BGP_VPNV4_NODE
,
15207 &neighbor_maximum_prefix_threshold_restart_cmd
);
15208 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
15209 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
15210 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
15211 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
15212 install_element(BGP_VPNV6_NODE
,
15213 &neighbor_maximum_prefix_threshold_warning_cmd
);
15214 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
15215 install_element(BGP_VPNV6_NODE
,
15216 &neighbor_maximum_prefix_threshold_restart_cmd
);
15217 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
15219 /* "neighbor allowas-in" */
15220 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
15221 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
15222 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
15223 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
15224 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
15225 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
15226 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
15227 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
15228 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
15229 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
15230 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
15231 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
15232 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
15233 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
15234 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
15235 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
15236 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
15237 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
15238 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
15239 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
15241 /* address-family commands. */
15242 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
15243 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
15244 #ifdef KEEP_OLD_VPN_COMMANDS
15245 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
15246 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
15247 #endif /* KEEP_OLD_VPN_COMMANDS */
15249 install_element(BGP_NODE
, &address_family_evpn_cmd
);
15251 /* "exit-address-family" command. */
15252 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
15253 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
15254 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
15255 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
15256 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
15257 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
15258 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
15259 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
15260 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
15261 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
15262 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
15264 /* "clear ip bgp commands" */
15265 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
15267 /* clear ip bgp prefix */
15268 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
15269 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
15270 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
15272 /* "show [ip] bgp summary" commands. */
15273 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
15274 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
15275 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
15276 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
15277 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
15278 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
15279 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
15281 /* "show [ip] bgp neighbors" commands. */
15282 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
15284 /* "show [ip] bgp peer-group" commands. */
15285 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
15287 /* "show [ip] bgp paths" commands. */
15288 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
15290 /* "show [ip] bgp community" commands. */
15291 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
15293 /* "show ip bgp large-community" commands. */
15294 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
15295 /* "show [ip] bgp attribute-info" commands. */
15296 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
15297 /* "show [ip] bgp route-leak" command */
15298 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
15300 /* "redistribute" commands. */
15301 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
15302 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
15303 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
15304 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
15305 install_element(BGP_NODE
,
15306 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
15307 install_element(BGP_NODE
,
15308 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
15309 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
15310 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
15311 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
15312 install_element(BGP_NODE
,
15313 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
15314 install_element(BGP_NODE
,
15315 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
15316 install_element(BGP_NODE
,
15317 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
15318 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
15319 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
15320 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
15321 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
15322 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
15323 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
15324 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
15325 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
15326 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
15327 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
15328 install_element(BGP_IPV4_NODE
,
15329 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
15330 install_element(BGP_IPV4_NODE
,
15331 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
15332 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
15333 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
15334 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
15335 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
15336 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
15337 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
15339 /* import|export vpn [route-map WORD] */
15340 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
15341 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
15343 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
15344 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
15346 /* ttl_security commands */
15347 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
15348 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
15350 /* "show [ip] bgp memory" commands. */
15351 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
15353 /* "show bgp martian next-hop" */
15354 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
15356 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
15358 /* "show [ip] bgp views" commands. */
15359 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
15361 /* "show [ip] bgp vrfs" commands. */
15362 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
15364 /* Community-list. */
15365 community_list_vty();
15367 /* vpn-policy commands */
15368 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
15369 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
15370 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
15371 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
15372 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
15373 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
15374 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
15375 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
15376 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
15377 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
15378 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
15379 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
15381 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
15382 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
15384 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
15385 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
15386 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
15387 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
15388 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
15389 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
15390 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
15391 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
15392 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
15393 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
15394 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
15395 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
15398 #include "memory.h"
15399 #include "bgp_regex.h"
15400 #include "bgp_clist.h"
15401 #include "bgp_ecommunity.h"
15403 /* VTY functions. */
15405 /* Direction value to string conversion. */
15406 static const char *community_direct_str(int direct
)
15409 case COMMUNITY_DENY
:
15411 case COMMUNITY_PERMIT
:
15418 /* Display error string. */
15419 static void community_list_perror(struct vty
*vty
, int ret
)
15422 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
15423 vty_out(vty
, "%% Can't find community-list\n");
15425 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
15426 vty_out(vty
, "%% Malformed community-list value\n");
15428 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
15430 "%% Community name conflict, previously defined as standard community\n");
15432 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
15434 "%% Community name conflict, previously defined as expanded community\n");
15439 /* "community-list" keyword help string. */
15440 #define COMMUNITY_LIST_STR "Add a community list entry\n"
15442 /*community-list standard */
15443 DEFUN (community_list_standard
,
15444 bgp_community_list_standard_cmd
,
15445 "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15448 "Community list number (standard)\n"
15449 "Add an standard community-list entry\n"
15450 "Community list name\n"
15451 "Specify community to reject\n"
15452 "Specify community to accept\n"
15455 char *cl_name_or_number
= NULL
;
15457 int style
= COMMUNITY_LIST_STANDARD
;
15460 argv_find(argv
, argc
, "(1-99)", &idx
);
15461 argv_find(argv
, argc
, "WORD", &idx
);
15462 cl_name_or_number
= argv
[idx
]->arg
;
15463 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15465 argv_find(argv
, argc
, "AA:NN", &idx
);
15466 char *str
= argv_concat(argv
, argc
, idx
);
15468 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
15471 XFREE(MTYPE_TMP
, str
);
15474 /* Display error string. */
15475 community_list_perror(vty
, ret
);
15476 return CMD_WARNING_CONFIG_FAILED
;
15479 return CMD_SUCCESS
;
15482 DEFUN (no_community_list_standard_all
,
15483 no_bgp_community_list_standard_all_cmd
,
15484 "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15488 "Community list number (standard)\n"
15489 "Add an standard community-list entry\n"
15490 "Community list name\n"
15491 "Specify community to reject\n"
15492 "Specify community to accept\n"
15495 char *cl_name_or_number
= NULL
;
15498 int style
= COMMUNITY_LIST_STANDARD
;
15502 argv_find(argv
, argc
, "permit", &idx
);
15503 argv_find(argv
, argc
, "deny", &idx
);
15506 direct
= argv_find(argv
, argc
, "permit", &idx
)
15511 argv_find(argv
, argc
, "AA:NN", &idx
);
15512 str
= argv_concat(argv
, argc
, idx
);
15516 argv_find(argv
, argc
, "(1-99)", &idx
);
15517 argv_find(argv
, argc
, "WORD", &idx
);
15518 cl_name_or_number
= argv
[idx
]->arg
;
15520 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
15523 XFREE(MTYPE_TMP
, str
);
15526 community_list_perror(vty
, ret
);
15527 return CMD_WARNING_CONFIG_FAILED
;
15530 return CMD_SUCCESS
;
15533 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
15534 "no bgp community-list <(1-99)|standard WORD>",
15535 NO_STR BGP_STR COMMUNITY_LIST_STR
15536 "Community list number (standard)\n"
15537 "Add an standard community-list entry\n"
15538 "Community list name\n")
15540 /*community-list expanded */
15541 DEFUN (community_list_expanded_all
,
15542 bgp_community_list_expanded_all_cmd
,
15543 "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
15546 "Community list number (expanded)\n"
15547 "Add an expanded community-list entry\n"
15548 "Community list name\n"
15549 "Specify community to reject\n"
15550 "Specify community to accept\n"
15553 char *cl_name_or_number
= NULL
;
15555 int style
= COMMUNITY_LIST_EXPANDED
;
15559 argv_find(argv
, argc
, "(100-500)", &idx
);
15560 argv_find(argv
, argc
, "WORD", &idx
);
15561 cl_name_or_number
= argv
[idx
]->arg
;
15562 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15564 argv_find(argv
, argc
, "AA:NN", &idx
);
15565 char *str
= argv_concat(argv
, argc
, idx
);
15567 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
15570 XFREE(MTYPE_TMP
, str
);
15573 /* Display error string. */
15574 community_list_perror(vty
, ret
);
15575 return CMD_WARNING_CONFIG_FAILED
;
15578 return CMD_SUCCESS
;
15581 DEFUN (no_community_list_expanded_all
,
15582 no_bgp_community_list_expanded_all_cmd
,
15583 "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
15587 "Community list number (expanded)\n"
15588 "Add an expanded community-list entry\n"
15589 "Community list name\n"
15590 "Specify community to reject\n"
15591 "Specify community to accept\n"
15594 char *cl_name_or_number
= NULL
;
15597 int style
= COMMUNITY_LIST_EXPANDED
;
15601 argv_find(argv
, argc
, "permit", &idx
);
15602 argv_find(argv
, argc
, "deny", &idx
);
15605 direct
= argv_find(argv
, argc
, "permit", &idx
)
15610 argv_find(argv
, argc
, "AA:NN", &idx
);
15611 str
= argv_concat(argv
, argc
, idx
);
15615 argv_find(argv
, argc
, "(100-500)", &idx
);
15616 argv_find(argv
, argc
, "WORD", &idx
);
15617 cl_name_or_number
= argv
[idx
]->arg
;
15619 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
15622 XFREE(MTYPE_TMP
, str
);
15625 community_list_perror(vty
, ret
);
15626 return CMD_WARNING_CONFIG_FAILED
;
15629 return CMD_SUCCESS
;
15632 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
15633 "no bgp community-list <(100-500)|expanded WORD>",
15634 NO_STR IP_STR COMMUNITY_LIST_STR
15635 "Community list number (expanded)\n"
15636 "Add an expanded community-list entry\n"
15637 "Community list name\n")
15639 /* Return configuration string of community-list entry. */
15640 static const char *community_list_config_str(struct community_entry
*entry
)
15647 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
15648 str
= community_str(entry
->u
.com
, false);
15649 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
15650 str
= lcommunity_str(entry
->u
.lcom
, false);
15652 str
= entry
->config
;
15657 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
15659 struct community_entry
*entry
;
15661 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15662 if (entry
== list
->head
) {
15663 if (all_digit(list
->name
))
15664 vty_out(vty
, "Community %s list %s\n",
15665 entry
->style
== COMMUNITY_LIST_STANDARD
15667 : "(expanded) access",
15670 vty_out(vty
, "Named Community %s list %s\n",
15671 entry
->style
== COMMUNITY_LIST_STANDARD
15677 vty_out(vty
, " %s\n",
15678 community_direct_str(entry
->direct
));
15680 vty_out(vty
, " %s %s\n",
15681 community_direct_str(entry
->direct
),
15682 community_list_config_str(entry
));
15686 DEFUN (show_community_list
,
15687 show_bgp_community_list_cmd
,
15688 "show bgp community-list",
15691 "List community-list\n")
15693 struct community_list
*list
;
15694 struct community_list_master
*cm
;
15696 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
15698 return CMD_SUCCESS
;
15700 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15701 community_list_show(vty
, list
);
15703 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15704 community_list_show(vty
, list
);
15706 return CMD_SUCCESS
;
15709 DEFUN (show_community_list_arg
,
15710 show_bgp_community_list_arg_cmd
,
15711 "show bgp community-list <(1-500)|WORD> detail",
15714 "List community-list\n"
15715 "Community-list number\n"
15716 "Community-list name\n"
15717 "Detailed information on community-list\n")
15719 int idx_comm_list
= 3;
15720 struct community_list
*list
;
15722 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
15723 COMMUNITY_LIST_MASTER
);
15725 vty_out(vty
, "%% Can't find community-list\n");
15726 return CMD_WARNING
;
15729 community_list_show(vty
, list
);
15731 return CMD_SUCCESS
;
15735 * Large Community code.
15737 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
15738 struct cmd_token
**argv
, int style
,
15739 int reject_all_digit_name
)
15747 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15750 /* All digit name check. */
15752 argv_find(argv
, argc
, "WORD", &idx
);
15753 argv_find(argv
, argc
, "(1-99)", &idx
);
15754 argv_find(argv
, argc
, "(100-500)", &idx
);
15755 cl_name
= argv
[idx
]->arg
;
15756 if (reject_all_digit_name
&& all_digit(cl_name
)) {
15757 vty_out(vty
, "%% Community name cannot have all digits\n");
15758 return CMD_WARNING_CONFIG_FAILED
;
15762 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
15763 argv_find(argv
, argc
, "LINE", &idx
);
15764 /* Concat community string argument. */
15766 str
= argv_concat(argv
, argc
, idx
);
15770 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
15772 /* Free temporary community list string allocated by
15774 XFREE(MTYPE_TMP
, str
);
15777 community_list_perror(vty
, ret
);
15778 return CMD_WARNING_CONFIG_FAILED
;
15780 return CMD_SUCCESS
;
15783 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
15784 struct cmd_token
**argv
, int style
)
15791 argv_find(argv
, argc
, "permit", &idx
);
15792 argv_find(argv
, argc
, "deny", &idx
);
15795 /* Check the list direct. */
15796 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
15797 direct
= COMMUNITY_PERMIT
;
15799 direct
= COMMUNITY_DENY
;
15802 argv_find(argv
, argc
, "LINE", &idx
);
15803 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
15804 /* Concat community string argument. */
15805 str
= argv_concat(argv
, argc
, idx
);
15809 argv_find(argv
, argc
, "(1-99)", &idx
);
15810 argv_find(argv
, argc
, "(100-500)", &idx
);
15811 argv_find(argv
, argc
, "WORD", &idx
);
15813 /* Unset community list. */
15814 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
15817 /* Free temporary community list string allocated by
15819 XFREE(MTYPE_TMP
, str
);
15822 community_list_perror(vty
, ret
);
15823 return CMD_WARNING_CONFIG_FAILED
;
15826 return CMD_SUCCESS
;
15829 /* "large-community-list" keyword help string. */
15830 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
15831 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
15833 DEFUN (lcommunity_list_standard
,
15834 bgp_lcommunity_list_standard_cmd
,
15835 "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...",
15837 LCOMMUNITY_LIST_STR
15838 "Large Community list number (standard)\n"
15839 "Specify large community to reject\n"
15840 "Specify large community to accept\n"
15841 LCOMMUNITY_VAL_STR
)
15843 return lcommunity_list_set_vty(vty
, argc
, argv
,
15844 LARGE_COMMUNITY_LIST_STANDARD
, 0);
15847 DEFUN (lcommunity_list_expanded
,
15848 bgp_lcommunity_list_expanded_cmd
,
15849 "bgp large-community-list (100-500) <deny|permit> LINE...",
15851 LCOMMUNITY_LIST_STR
15852 "Large Community list number (expanded)\n"
15853 "Specify large community to reject\n"
15854 "Specify large community to accept\n"
15855 "An ordered list as a regular-expression\n")
15857 return lcommunity_list_set_vty(vty
, argc
, argv
,
15858 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
15861 DEFUN (lcommunity_list_name_standard
,
15862 bgp_lcommunity_list_name_standard_cmd
,
15863 "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
15865 LCOMMUNITY_LIST_STR
15866 "Specify standard large-community-list\n"
15867 "Large Community list name\n"
15868 "Specify large community to reject\n"
15869 "Specify large community to accept\n"
15870 LCOMMUNITY_VAL_STR
)
15872 return lcommunity_list_set_vty(vty
, argc
, argv
,
15873 LARGE_COMMUNITY_LIST_STANDARD
, 1);
15876 DEFUN (lcommunity_list_name_expanded
,
15877 bgp_lcommunity_list_name_expanded_cmd
,
15878 "bgp large-community-list expanded WORD <deny|permit> LINE...",
15880 LCOMMUNITY_LIST_STR
15881 "Specify expanded large-community-list\n"
15882 "Large Community list name\n"
15883 "Specify large community to reject\n"
15884 "Specify large community to accept\n"
15885 "An ordered list as a regular-expression\n")
15887 return lcommunity_list_set_vty(vty
, argc
, argv
,
15888 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
15891 DEFUN (no_lcommunity_list_standard_all
,
15892 no_bgp_lcommunity_list_standard_all_cmd
,
15893 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
15896 LCOMMUNITY_LIST_STR
15897 "Large Community list number (standard)\n"
15898 "Large Community list number (expanded)\n"
15899 "Large Community list name\n")
15901 return lcommunity_list_unset_vty(vty
, argc
, argv
,
15902 LARGE_COMMUNITY_LIST_STANDARD
);
15905 DEFUN (no_lcommunity_list_name_expanded_all
,
15906 no_bgp_lcommunity_list_name_expanded_all_cmd
,
15907 "no bgp large-community-list expanded WORD",
15910 LCOMMUNITY_LIST_STR
15911 "Specify expanded large-community-list\n"
15912 "Large Community list name\n")
15914 return lcommunity_list_unset_vty(vty
, argc
, argv
,
15915 LARGE_COMMUNITY_LIST_EXPANDED
);
15918 DEFUN (no_lcommunity_list_standard
,
15919 no_bgp_lcommunity_list_standard_cmd
,
15920 "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
15923 LCOMMUNITY_LIST_STR
15924 "Large Community list number (standard)\n"
15925 "Specify large community to reject\n"
15926 "Specify large community to accept\n"
15927 LCOMMUNITY_VAL_STR
)
15929 return lcommunity_list_unset_vty(vty
, argc
, argv
,
15930 LARGE_COMMUNITY_LIST_STANDARD
);
15933 DEFUN (no_lcommunity_list_expanded
,
15934 no_bgp_lcommunity_list_expanded_cmd
,
15935 "no bgp large-community-list (100-500) <deny|permit> LINE...",
15938 LCOMMUNITY_LIST_STR
15939 "Large Community list number (expanded)\n"
15940 "Specify large community to reject\n"
15941 "Specify large community to accept\n"
15942 "An ordered list as a regular-expression\n")
15944 return lcommunity_list_unset_vty(vty
, argc
, argv
,
15945 LARGE_COMMUNITY_LIST_EXPANDED
);
15948 DEFUN (no_lcommunity_list_name_standard
,
15949 no_bgp_lcommunity_list_name_standard_cmd
,
15950 "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
15953 LCOMMUNITY_LIST_STR
15954 "Specify standard large-community-list\n"
15955 "Large Community list name\n"
15956 "Specify large community to reject\n"
15957 "Specify large community to accept\n"
15958 LCOMMUNITY_VAL_STR
)
15960 return lcommunity_list_unset_vty(vty
, argc
, argv
,
15961 LARGE_COMMUNITY_LIST_STANDARD
);
15964 DEFUN (no_lcommunity_list_name_expanded
,
15965 no_bgp_lcommunity_list_name_expanded_cmd
,
15966 "no bgp large-community-list expanded WORD <deny|permit> LINE...",
15969 LCOMMUNITY_LIST_STR
15970 "Specify expanded large-community-list\n"
15971 "Large community list name\n"
15972 "Specify large community to reject\n"
15973 "Specify large community to accept\n"
15974 "An ordered list as a regular-expression\n")
15976 return lcommunity_list_unset_vty(vty
, argc
, argv
,
15977 LARGE_COMMUNITY_LIST_EXPANDED
);
15980 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
15982 struct community_entry
*entry
;
15984 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15985 if (entry
== list
->head
) {
15986 if (all_digit(list
->name
))
15987 vty_out(vty
, "Large community %s list %s\n",
15989 LARGE_COMMUNITY_LIST_STANDARD
15991 : "(expanded) access",
15995 "Named large community %s list %s\n",
15997 LARGE_COMMUNITY_LIST_STANDARD
16003 vty_out(vty
, " %s\n",
16004 community_direct_str(entry
->direct
));
16006 vty_out(vty
, " %s %s\n",
16007 community_direct_str(entry
->direct
),
16008 community_list_config_str(entry
));
16012 DEFUN (show_lcommunity_list
,
16013 show_bgp_lcommunity_list_cmd
,
16014 "show bgp large-community-list",
16017 "List large-community list\n")
16019 struct community_list
*list
;
16020 struct community_list_master
*cm
;
16022 cm
= community_list_master_lookup(bgp_clist
,
16023 LARGE_COMMUNITY_LIST_MASTER
);
16025 return CMD_SUCCESS
;
16027 for (list
= cm
->num
.head
; list
; list
= list
->next
)
16028 lcommunity_list_show(vty
, list
);
16030 for (list
= cm
->str
.head
; list
; list
= list
->next
)
16031 lcommunity_list_show(vty
, list
);
16033 return CMD_SUCCESS
;
16036 DEFUN (show_lcommunity_list_arg
,
16037 show_bgp_lcommunity_list_arg_cmd
,
16038 "show bgp large-community-list <(1-500)|WORD> detail",
16041 "List large-community list\n"
16042 "Large-community-list number\n"
16043 "Large-community-list name\n"
16044 "Detailed information on large-community-list\n")
16046 struct community_list
*list
;
16048 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
16049 LARGE_COMMUNITY_LIST_MASTER
);
16051 vty_out(vty
, "%% Can't find large-community-list\n");
16052 return CMD_WARNING
;
16055 lcommunity_list_show(vty
, list
);
16057 return CMD_SUCCESS
;
16060 /* "extcommunity-list" keyword help string. */
16061 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
16062 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
16064 DEFUN (extcommunity_list_standard
,
16065 bgp_extcommunity_list_standard_cmd
,
16066 "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
16068 EXTCOMMUNITY_LIST_STR
16069 "Extended Community list number (standard)\n"
16070 "Specify standard extcommunity-list\n"
16071 "Community list name\n"
16072 "Specify community to reject\n"
16073 "Specify community to accept\n"
16074 EXTCOMMUNITY_VAL_STR
)
16076 int style
= EXTCOMMUNITY_LIST_STANDARD
;
16078 char *cl_number_or_name
= NULL
;
16082 argv_find(argv
, argc
, "(1-99)", &idx
);
16083 argv_find(argv
, argc
, "WORD", &idx
);
16084 cl_number_or_name
= argv
[idx
]->arg
;
16085 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
16087 argv_find(argv
, argc
, "AA:NN", &idx
);
16088 char *str
= argv_concat(argv
, argc
, idx
);
16090 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
16093 XFREE(MTYPE_TMP
, str
);
16096 community_list_perror(vty
, ret
);
16097 return CMD_WARNING_CONFIG_FAILED
;
16100 return CMD_SUCCESS
;
16103 DEFUN (extcommunity_list_name_expanded
,
16104 bgp_extcommunity_list_name_expanded_cmd
,
16105 "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
16107 EXTCOMMUNITY_LIST_STR
16108 "Extended Community list number (expanded)\n"
16109 "Specify expanded extcommunity-list\n"
16110 "Extended Community list name\n"
16111 "Specify community to reject\n"
16112 "Specify community to accept\n"
16113 "An ordered list as a regular-expression\n")
16115 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
16117 char *cl_number_or_name
= NULL
;
16120 argv_find(argv
, argc
, "(100-500)", &idx
);
16121 argv_find(argv
, argc
, "WORD", &idx
);
16122 cl_number_or_name
= argv
[idx
]->arg
;
16123 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
16125 argv_find(argv
, argc
, "LINE", &idx
);
16126 char *str
= argv_concat(argv
, argc
, idx
);
16128 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
16131 XFREE(MTYPE_TMP
, str
);
16134 community_list_perror(vty
, ret
);
16135 return CMD_WARNING_CONFIG_FAILED
;
16138 return CMD_SUCCESS
;
16141 DEFUN (no_extcommunity_list_standard_all
,
16142 no_bgp_extcommunity_list_standard_all_cmd
,
16143 "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
16146 EXTCOMMUNITY_LIST_STR
16147 "Extended Community list number (standard)\n"
16148 "Specify standard extcommunity-list\n"
16149 "Community list name\n"
16150 "Specify community to reject\n"
16151 "Specify community to accept\n"
16152 EXTCOMMUNITY_VAL_STR
)
16154 int style
= EXTCOMMUNITY_LIST_STANDARD
;
16156 char *cl_number_or_name
= NULL
;
16160 argv_find(argv
, argc
, "permit", &idx
);
16161 argv_find(argv
, argc
, "deny", &idx
);
16164 direct
= argv_find(argv
, argc
, "permit", &idx
)
16169 argv_find(argv
, argc
, "AA:NN", &idx
);
16170 str
= argv_concat(argv
, argc
, idx
);
16174 argv_find(argv
, argc
, "(1-99)", &idx
);
16175 argv_find(argv
, argc
, "WORD", &idx
);
16176 cl_number_or_name
= argv
[idx
]->arg
;
16178 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
16181 XFREE(MTYPE_TMP
, str
);
16184 community_list_perror(vty
, ret
);
16185 return CMD_WARNING_CONFIG_FAILED
;
16188 return CMD_SUCCESS
;
16191 ALIAS(no_extcommunity_list_standard_all
,
16192 no_bgp_extcommunity_list_standard_all_list_cmd
,
16193 "no bgp extcommunity-list <(1-99)|standard WORD>",
16194 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
16195 "Extended Community list number (standard)\n"
16196 "Specify standard extcommunity-list\n"
16197 "Community list name\n")
16199 DEFUN (no_extcommunity_list_expanded_all
,
16200 no_bgp_extcommunity_list_expanded_all_cmd
,
16201 "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
16204 EXTCOMMUNITY_LIST_STR
16205 "Extended Community list number (expanded)\n"
16206 "Specify expanded extcommunity-list\n"
16207 "Extended Community list name\n"
16208 "Specify community to reject\n"
16209 "Specify community to accept\n"
16210 "An ordered list as a regular-expression\n")
16212 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
16214 char *cl_number_or_name
= NULL
;
16218 argv_find(argv
, argc
, "permit", &idx
);
16219 argv_find(argv
, argc
, "deny", &idx
);
16222 direct
= argv_find(argv
, argc
, "permit", &idx
)
16227 argv_find(argv
, argc
, "LINE", &idx
);
16228 str
= argv_concat(argv
, argc
, idx
);
16232 argv_find(argv
, argc
, "(100-500)", &idx
);
16233 argv_find(argv
, argc
, "WORD", &idx
);
16234 cl_number_or_name
= argv
[idx
]->arg
;
16236 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
16239 XFREE(MTYPE_TMP
, str
);
16242 community_list_perror(vty
, ret
);
16243 return CMD_WARNING_CONFIG_FAILED
;
16246 return CMD_SUCCESS
;
16249 ALIAS(no_extcommunity_list_expanded_all
,
16250 no_bgp_extcommunity_list_expanded_all_list_cmd
,
16251 "no bgp extcommunity-list <(100-500)|expanded WORD>",
16252 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
16253 "Extended Community list number (expanded)\n"
16254 "Specify expanded extcommunity-list\n"
16255 "Extended Community list name\n")
16257 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
16259 struct community_entry
*entry
;
16261 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
16262 if (entry
== list
->head
) {
16263 if (all_digit(list
->name
))
16264 vty_out(vty
, "Extended community %s list %s\n",
16265 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
16267 : "(expanded) access",
16271 "Named extended community %s list %s\n",
16272 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
16278 vty_out(vty
, " %s\n",
16279 community_direct_str(entry
->direct
));
16281 vty_out(vty
, " %s %s\n",
16282 community_direct_str(entry
->direct
),
16283 community_list_config_str(entry
));
16287 DEFUN (show_extcommunity_list
,
16288 show_bgp_extcommunity_list_cmd
,
16289 "show bgp extcommunity-list",
16292 "List extended-community list\n")
16294 struct community_list
*list
;
16295 struct community_list_master
*cm
;
16297 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
16299 return CMD_SUCCESS
;
16301 for (list
= cm
->num
.head
; list
; list
= list
->next
)
16302 extcommunity_list_show(vty
, list
);
16304 for (list
= cm
->str
.head
; list
; list
= list
->next
)
16305 extcommunity_list_show(vty
, list
);
16307 return CMD_SUCCESS
;
16310 DEFUN (show_extcommunity_list_arg
,
16311 show_bgp_extcommunity_list_arg_cmd
,
16312 "show bgp extcommunity-list <(1-500)|WORD> detail",
16315 "List extended-community list\n"
16316 "Extcommunity-list number\n"
16317 "Extcommunity-list name\n"
16318 "Detailed information on extcommunity-list\n")
16320 int idx_comm_list
= 3;
16321 struct community_list
*list
;
16323 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
16324 EXTCOMMUNITY_LIST_MASTER
);
16326 vty_out(vty
, "%% Can't find extcommunity-list\n");
16327 return CMD_WARNING
;
16330 extcommunity_list_show(vty
, list
);
16332 return CMD_SUCCESS
;
16335 /* Display community-list and extcommunity-list configuration. */
16336 static int community_list_config_write(struct vty
*vty
)
16338 struct community_list
*list
;
16339 struct community_entry
*entry
;
16340 struct community_list_master
*cm
;
16343 /* Community-list. */
16344 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
16346 for (list
= cm
->num
.head
; list
; list
= list
->next
)
16347 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
16348 vty_out(vty
, "bgp community-list %s %s %s\n", list
->name
,
16349 community_direct_str(entry
->direct
),
16350 community_list_config_str(entry
));
16353 for (list
= cm
->str
.head
; list
; list
= list
->next
)
16354 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
16355 vty_out(vty
, "bgp community-list %s %s %s %s\n",
16356 entry
->style
== COMMUNITY_LIST_STANDARD
16359 list
->name
, community_direct_str(entry
->direct
),
16360 community_list_config_str(entry
));
16364 /* Extcommunity-list. */
16365 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
16367 for (list
= cm
->num
.head
; list
; list
= list
->next
)
16368 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
16369 vty_out(vty
, "bgp extcommunity-list %s %s %s\n",
16370 list
->name
, community_direct_str(entry
->direct
),
16371 community_list_config_str(entry
));
16374 for (list
= cm
->str
.head
; list
; list
= list
->next
)
16375 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
16376 vty_out(vty
, "bgp extcommunity-list %s %s %s %s\n",
16377 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
16380 list
->name
, community_direct_str(entry
->direct
),
16381 community_list_config_str(entry
));
16386 /* lcommunity-list. */
16387 cm
= community_list_master_lookup(bgp_clist
,
16388 LARGE_COMMUNITY_LIST_MASTER
);
16390 for (list
= cm
->num
.head
; list
; list
= list
->next
)
16391 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
16392 vty_out(vty
, "bgp large-community-list %s %s %s\n",
16393 list
->name
, community_direct_str(entry
->direct
),
16394 community_list_config_str(entry
));
16397 for (list
= cm
->str
.head
; list
; list
= list
->next
)
16398 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
16399 vty_out(vty
, "bgp large-community-list %s %s %s %s\n",
16400 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
16403 list
->name
, community_direct_str(entry
->direct
),
16404 community_list_config_str(entry
));
16411 static struct cmd_node community_list_node
= {
16412 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
16415 static void community_list_vty(void)
16417 install_node(&community_list_node
, community_list_config_write
);
16419 /* Community-list. */
16420 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
16421 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
16422 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
16423 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
16424 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
16425 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
16426 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
16427 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
16429 /* Extcommunity-list. */
16430 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
16431 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
16432 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
16433 install_element(CONFIG_NODE
,
16434 &no_bgp_extcommunity_list_standard_all_list_cmd
);
16435 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
16436 install_element(CONFIG_NODE
,
16437 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
16438 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
16439 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
16441 /* Large Community List */
16442 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
16443 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
16444 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
16445 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
16446 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_all_cmd
);
16447 install_element(CONFIG_NODE
,
16448 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
16449 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
16450 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
16451 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
16452 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
16453 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
16454 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);