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 DEFINE_HOOK(bgp_inst_config_write
,
76 (struct bgp
*bgp
, struct vty
*vty
),
79 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
80 struct prefix
*range
, int exact
);
82 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
91 return BGP_IPV4M_NODE
;
93 case SAFI_LABELED_UNICAST
:
94 return BGP_IPV4L_NODE
;
97 return BGP_VPNV4_NODE
;
100 return BGP_FLOWSPECV4_NODE
;
103 return BGP_IPV4_NODE
;
110 return BGP_IPV6_NODE
;
113 return BGP_IPV6M_NODE
;
115 case SAFI_LABELED_UNICAST
:
116 return BGP_IPV6L_NODE
;
119 return BGP_VPNV6_NODE
;
122 return BGP_FLOWSPECV6_NODE
;
125 return BGP_IPV4_NODE
;
130 return BGP_EVPN_NODE
;
134 // We should never be here but to clarify the switch statement..
135 return BGP_IPV4_NODE
;
139 // Impossible to happen
140 return BGP_IPV4_NODE
;
143 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
145 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
146 return "IPv4 Unicast";
147 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
148 return "IPv4 Multicast";
149 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
150 return "IPv4 Labeled Unicast";
151 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
153 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
155 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
156 return "IPv4 Flowspec";
157 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
158 return "IPv6 Unicast";
159 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
160 return "IPv6 Multicast";
161 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
162 return "IPv6 Labeled Unicast";
163 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
165 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
167 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
168 return "IPv6 Flowspec";
169 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
176 * Please note that we have intentionally camelCased
177 * the return strings here. So if you want
178 * to use this function, please ensure you
179 * are doing this within json output
181 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
183 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
184 return "ipv4Unicast";
185 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
186 return "ipv4Multicast";
187 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
188 return "ipv4LabeledUnicast";
189 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
191 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
193 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
194 return "ipv4Flowspec";
195 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
196 return "ipv6Unicast";
197 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
198 return "ipv6Multicast";
199 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
200 return "ipv6LabeledUnicast";
201 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
203 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
205 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
206 return "ipv6Flowspec";
207 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
213 /* Utility function to get address family from current node. */
214 afi_t
bgp_node_afi(struct vty
*vty
)
222 case BGP_FLOWSPECV6_NODE
:
235 /* Utility function to get subsequent address family from current
237 safi_t
bgp_node_safi(struct vty
*vty
)
243 safi
= SAFI_MPLS_VPN
;
247 safi
= SAFI_MULTICAST
;
254 safi
= SAFI_LABELED_UNICAST
;
256 case BGP_FLOWSPECV4_NODE
:
257 case BGP_FLOWSPECV6_NODE
:
258 safi
= SAFI_FLOWSPEC
;
268 * Converts an AFI in string form to afi_t
270 * @param afi string, one of
274 * @return the corresponding afi_t
276 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
278 afi_t afi
= AFI_MAX
; /* unknown */
279 if (strmatch(afi_str
, "ipv4"))
281 else if (strmatch(afi_str
, "ipv6"))
283 else if (strmatch(afi_str
, "l2vpn"))
288 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
292 if (argv_find(argv
, argc
, "ipv4", index
)) {
296 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
300 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
308 /* supports <unicast|multicast|vpn|labeled-unicast> */
309 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
311 safi_t safi
= SAFI_MAX
; /* unknown */
312 if (strmatch(safi_str
, "multicast"))
313 safi
= SAFI_MULTICAST
;
314 else if (strmatch(safi_str
, "unicast"))
316 else if (strmatch(safi_str
, "vpn"))
317 safi
= SAFI_MPLS_VPN
;
318 else if (strmatch(safi_str
, "evpn"))
320 else if (strmatch(safi_str
, "labeled-unicast"))
321 safi
= SAFI_LABELED_UNICAST
;
322 else if (strmatch(safi_str
, "flowspec"))
323 safi
= SAFI_FLOWSPEC
;
327 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
331 if (argv_find(argv
, argc
, "unicast", index
)) {
334 *safi
= SAFI_UNICAST
;
335 } else if (argv_find(argv
, argc
, "multicast", index
)) {
338 *safi
= SAFI_MULTICAST
;
339 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
342 *safi
= SAFI_LABELED_UNICAST
;
343 } else if (argv_find(argv
, argc
, "vpn", index
)) {
346 *safi
= SAFI_MPLS_VPN
;
347 } else if (argv_find(argv
, argc
, "evpn", index
)) {
351 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
354 *safi
= SAFI_FLOWSPEC
;
360 * bgp_vty_find_and_parse_afi_safi_bgp
362 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
363 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
364 * to appropriate values for the calling function. This is to allow the
365 * calling function to make decisions appropriate for the show command
366 * that is being parsed.
368 * The show commands are generally of the form:
369 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
370 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
372 * Since we use argv_find if the show command in particular doesn't have:
374 * [<view|vrf> VIEWVRFNAME]
375 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
376 * The command parsing should still be ok.
378 * vty -> The vty for the command so we can output some useful data in
379 * the event of a parse error in the vrf.
380 * argv -> The command tokens
381 * argc -> How many command tokens we have
382 * idx -> The current place in the command, generally should be 0 for this
384 * afi -> The parsed afi if it was included in the show command, returned here
385 * safi -> The parsed safi if it was included in the show command, returned here
386 * bgp -> Pointer to the bgp data structure we need to fill in.
387 * use_json -> json is configured or not
389 * The function returns the correct location in the parse tree for the
392 * Returns 0 for failure to parse correctly, else the idx position of where
393 * it found the last token.
395 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
396 struct cmd_token
**argv
, int argc
,
397 int *idx
, afi_t
*afi
, safi_t
*safi
,
398 struct bgp
**bgp
, bool use_json
)
400 char *vrf_name
= NULL
;
406 if (argv_find(argv
, argc
, "ip", idx
))
409 if (argv_find(argv
, argc
, "view", idx
))
410 vrf_name
= argv
[*idx
+ 1]->arg
;
411 else if (argv_find(argv
, argc
, "vrf", idx
)) {
412 vrf_name
= argv
[*idx
+ 1]->arg
;
413 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
417 if (strmatch(vrf_name
, "all"))
420 *bgp
= bgp_lookup_by_name(vrf_name
);
423 json_object
*json
= NULL
;
424 json
= json_object_new_object();
425 json_object_string_add(
427 "View/Vrf is unknown");
429 json_object_to_json_string_ext(json
,
430 JSON_C_TO_STRING_PRETTY
));
431 json_object_free(json
);
434 vty_out(vty
, "View/Vrf %s is unknown\n",
441 *bgp
= bgp_get_default();
444 json_object
*json
= NULL
;
445 json
= json_object_new_object();
446 json_object_string_add(
448 "Default BGP instance not found");
450 json_object_to_json_string_ext(json
,
451 JSON_C_TO_STRING_PRETTY
));
452 json_object_free(json
);
456 "Default BGP instance not found\n");
462 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
463 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
469 static int peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
471 struct interface
*ifp
= NULL
;
473 if (su
->sa
.sa_family
== AF_INET
)
474 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
475 else if (su
->sa
.sa_family
== AF_INET6
)
476 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
477 su
->sin6
.sin6_scope_id
,
486 /* Utility function for looking up peer from VTY. */
487 /* This is used only for configuration, so disallow if attempted on
488 * a dynamic neighbor.
490 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
492 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
501 ret
= str2sockunion(ip_str
, &su
);
503 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
505 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
508 "%% Malformed address or name: %s\n",
514 peer
= peer_lookup(bgp
, &su
);
517 "%% Specify remote-as or peer-group commands first\n");
520 if (peer_dynamic_neighbor(peer
)) {
522 "%% Operation not allowed on a dynamic neighbor\n");
529 /* Utility function for looking up peer or peer group. */
530 /* This is used only for configuration, so disallow if attempted on
531 * a dynamic neighbor.
533 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
535 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
538 struct peer
*peer
= NULL
;
539 struct peer_group
*group
= NULL
;
545 ret
= str2sockunion(peer_str
, &su
);
547 /* IP address, locate peer. */
548 peer
= peer_lookup(bgp
, &su
);
550 /* Not IP, could match either peer configured on interface or a
552 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
554 group
= peer_group_lookup(bgp
, peer_str
);
558 if (peer_dynamic_neighbor(peer
)) {
560 "%% Operation not allowed on a dynamic neighbor\n");
570 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
575 int bgp_vty_return(struct vty
*vty
, int ret
)
577 const char *str
= NULL
;
580 case BGP_ERR_INVALID_VALUE
:
581 str
= "Invalid value";
583 case BGP_ERR_INVALID_FLAG
:
584 str
= "Invalid flag";
586 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
587 str
= "Peer-group has been shutdown. Activate the peer-group first";
589 case BGP_ERR_PEER_FLAG_CONFLICT
:
590 str
= "Can't set override-capability and strict-capability-match at the same time";
592 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
593 str
= "Specify remote-as or peer-group remote AS first";
595 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
596 str
= "Cannot change the peer-group. Deconfigure first";
598 case BGP_ERR_PEER_GROUP_MISMATCH
:
599 str
= "Peer is not a member of this peer-group";
601 case BGP_ERR_PEER_FILTER_CONFLICT
:
602 str
= "Prefix/distribute list can not co-exist";
604 case BGP_ERR_NOT_INTERNAL_PEER
:
605 str
= "Invalid command. Not an internal neighbor";
607 case BGP_ERR_REMOVE_PRIVATE_AS
:
608 str
= "remove-private-AS cannot be configured for IBGP peers";
610 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
611 str
= "Local-AS allowed only for EBGP peers";
613 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
614 str
= "Cannot have local-as same as BGP AS number";
616 case BGP_ERR_TCPSIG_FAILED
:
617 str
= "Error while applying TCP-Sig to session(s)";
619 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
620 str
= "ebgp-multihop and ttl-security cannot be configured together";
622 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
623 str
= "ttl-security only allowed for EBGP peers";
625 case BGP_ERR_AS_OVERRIDE
:
626 str
= "as-override cannot be configured for IBGP peers";
628 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
629 str
= "Invalid limit for number of dynamic neighbors";
631 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
632 str
= "Dynamic neighbor listen range already exists";
634 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
635 str
= "Operation not allowed on a dynamic neighbor";
637 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
638 str
= "Operation not allowed on a directly connected neighbor";
640 case BGP_ERR_PEER_SAFI_CONFLICT
:
641 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
645 vty_out(vty
, "%% %s\n", str
);
646 return CMD_WARNING_CONFIG_FAILED
;
651 /* BGP clear sort. */
660 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
661 safi_t safi
, int error
)
664 case BGP_ERR_AF_UNCONFIGURED
:
666 "%%BGP: Enable %s address family for the neighbor %s\n",
667 get_afi_safi_str(afi
, safi
, false), peer
->host
);
669 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
671 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
679 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
680 struct listnode
*nnode
, enum bgp_clear_type stype
)
684 /* if afi/.safi not specified, spin thru all of them */
685 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
689 FOREACH_AFI_SAFI (tmp_afi
, tmp_safi
) {
690 if (!peer
->afc
[tmp_afi
][tmp_safi
])
693 if (stype
== BGP_CLEAR_SOFT_NONE
)
694 ret
= peer_clear(peer
, &nnode
);
696 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
699 /* if afi specified and safi not, spin thru safis on this afi */
700 } else if (safi
== SAFI_UNSPEC
) {
703 for (tmp_safi
= SAFI_UNICAST
;
704 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
705 if (!peer
->afc
[afi
][tmp_safi
])
708 if (stype
== BGP_CLEAR_SOFT_NONE
)
709 ret
= peer_clear(peer
, &nnode
);
711 ret
= peer_clear_soft(peer
, afi
,
714 /* both afi/safi specified, let the caller know if not defined */
716 if (!peer
->afc
[afi
][safi
])
719 if (stype
== BGP_CLEAR_SOFT_NONE
)
720 ret
= peer_clear(peer
, &nnode
);
722 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
728 /* `clear ip bgp' functions. */
729 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
730 enum clear_sort sort
, enum bgp_clear_type stype
,
736 struct listnode
*node
, *nnode
;
738 /* Clear all neighbors. */
740 * Pass along pointer to next node to peer_clear() when walking all
741 * nodes on the BGP instance as that may get freed if it is a
744 if (sort
== clear_all
) {
745 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
746 ret
= bgp_peer_clear(peer
, afi
, safi
, nnode
,
750 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
753 /* This is to apply read-only mode on this clear. */
754 if (stype
== BGP_CLEAR_SOFT_NONE
)
755 bgp
->update_delay_over
= 0;
760 /* Clear specified neighbor. */
761 if (sort
== clear_peer
) {
764 /* Make sockunion for lookup. */
765 ret
= str2sockunion(arg
, &su
);
767 peer
= peer_lookup_by_conf_if(bgp
, arg
);
769 peer
= peer_lookup_by_hostname(bgp
, arg
);
772 "Malformed address or name: %s\n",
778 peer
= peer_lookup(bgp
, &su
);
781 "%%BGP: Unknown neighbor - \"%s\"\n",
787 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
789 /* if afi/safi not defined for this peer, let caller know */
791 ret
= BGP_ERR_AF_UNCONFIGURED
;
794 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
799 /* Clear all neighbors belonging to a specific peer-group. */
800 if (sort
== clear_group
) {
801 struct peer_group
*group
;
803 group
= peer_group_lookup(bgp
, arg
);
805 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
809 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
810 ret
= bgp_peer_clear(peer
, afi
, safi
, nnode
, stype
);
813 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
820 "%%BGP: No %s peer belonging to peer-group %s is configured\n",
821 get_afi_safi_str(afi
, safi
, false), arg
);
826 /* Clear all external (eBGP) neighbors. */
827 if (sort
== clear_external
) {
828 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
829 if (peer
->sort
== BGP_PEER_IBGP
)
832 ret
= bgp_peer_clear(peer
, afi
, safi
, nnode
, stype
);
835 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
842 "%%BGP: No external %s peer is configured\n",
843 get_afi_safi_str(afi
, safi
, false));
848 /* Clear all neighbors belonging to a specific AS. */
849 if (sort
== clear_as
) {
850 as_t as
= strtoul(arg
, NULL
, 10);
852 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
856 ret
= bgp_peer_clear(peer
, afi
, safi
, nnode
, stype
);
859 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
866 "%%BGP: No %s peer is configured with AS %s\n",
867 get_afi_safi_str(afi
, safi
, false), arg
);
875 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
876 safi_t safi
, enum clear_sort sort
,
877 enum bgp_clear_type stype
, const char *arg
)
881 /* BGP structure lookup. */
883 bgp
= bgp_lookup_by_name(name
);
885 vty_out(vty
, "Can't find BGP instance %s\n", name
);
889 bgp
= bgp_get_default();
891 vty_out(vty
, "No BGP process is configured\n");
896 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
899 /* clear soft inbound */
900 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
905 FOREACH_AFI_SAFI (afi
, safi
)
906 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
907 BGP_CLEAR_SOFT_IN
, NULL
);
910 /* clear soft outbound */
911 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
916 FOREACH_AFI_SAFI (afi
, safi
)
917 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
918 BGP_CLEAR_SOFT_OUT
, NULL
);
922 #ifndef VTYSH_EXTRACT_PL
923 #include "bgpd/bgp_vty_clippy.c"
926 DEFUN_HIDDEN (bgp_local_mac
,
928 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
931 "VxLAN Network Identifier\n"
935 "mac-mobility sequence\n"
945 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
946 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
947 vty_out(vty
, "%% Malformed MAC address\n");
950 memset(&ip
, 0, sizeof(ip
));
951 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
953 bgp
= bgp_get_default();
955 vty_out(vty
, "Default BGP instance is not there\n");
959 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
);
961 vty_out(vty
, "Internal error\n");
968 DEFUN_HIDDEN (no_bgp_local_mac
,
969 no_bgp_local_mac_cmd
,
970 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
974 "VxLAN Network Identifier\n"
985 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
986 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
987 vty_out(vty
, "%% Malformed MAC address\n");
990 memset(&ip
, 0, sizeof(ip
));
992 bgp
= bgp_get_default();
994 vty_out(vty
, "Default BGP instance is not there\n");
998 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1000 vty_out(vty
, "Internal error\n");
1007 DEFUN (no_synchronization
,
1008 no_synchronization_cmd
,
1009 "no synchronization",
1011 "Perform IGP synchronization\n")
1016 DEFUN (no_auto_summary
,
1017 no_auto_summary_cmd
,
1020 "Enable automatic network number summarization\n")
1025 /* "router bgp" commands. */
1026 DEFUN_NOSH (router_bgp
,
1028 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1032 BGP_INSTANCE_HELP_STR
)
1035 int idx_view_vrf
= 3;
1041 const char *name
= NULL
;
1042 enum bgp_instance_type inst_type
;
1044 // "router bgp" without an ASN
1046 // Pending: Make VRF option available for ASN less config
1047 bgp
= bgp_get_default();
1050 vty_out(vty
, "%% No BGP process is configured\n");
1051 return CMD_WARNING_CONFIG_FAILED
;
1054 if (listcount(bm
->bgp
) > 1) {
1055 vty_out(vty
, "%% Please specify ASN and VRF\n");
1056 return CMD_WARNING_CONFIG_FAILED
;
1062 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1064 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1066 name
= argv
[idx_vrf
]->arg
;
1068 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1069 if (strmatch(name
, VRF_DEFAULT_NAME
))
1072 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1073 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1074 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1077 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1078 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1080 ret
= bgp_get(&bgp
, &as
, name
, inst_type
);
1082 case BGP_ERR_AS_MISMATCH
:
1083 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1084 return CMD_WARNING_CONFIG_FAILED
;
1085 case BGP_ERR_INSTANCE_MISMATCH
:
1087 "BGP instance name and AS number mismatch\n");
1089 "BGP instance is already running; AS is %u\n",
1091 return CMD_WARNING_CONFIG_FAILED
;
1095 * If we just instantiated the default instance, complete
1096 * any pending VRF-VPN leaking that was configured via
1097 * earlier "router bgp X vrf FOO" blocks.
1099 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1100 vpn_leak_postchange_all();
1102 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1103 bgp_vpn_leak_export(bgp
);
1104 /* Pending: handle when user tries to change a view to vrf n vv.
1108 /* unset the auto created flag as the user config is now present */
1109 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1110 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1115 /* "no router bgp" commands. */
1116 DEFUN (no_router_bgp
,
1118 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1123 BGP_INSTANCE_HELP_STR
)
1129 const char *name
= NULL
;
1131 // "no router bgp" without an ASN
1133 // Pending: Make VRF option available for ASN less config
1134 bgp
= bgp_get_default();
1137 vty_out(vty
, "%% No BGP process is configured\n");
1138 return CMD_WARNING_CONFIG_FAILED
;
1141 if (listcount(bm
->bgp
) > 1) {
1142 vty_out(vty
, "%% Please specify ASN and VRF\n");
1143 return CMD_WARNING_CONFIG_FAILED
;
1147 vty_out(vty
, "%% Please unconfigure l3vni %u",
1149 return CMD_WARNING_CONFIG_FAILED
;
1152 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1155 name
= argv
[idx_vrf
]->arg
;
1157 /* Lookup bgp structure. */
1158 bgp
= bgp_lookup(as
, name
);
1160 vty_out(vty
, "%% Can't find BGP instance\n");
1161 return CMD_WARNING_CONFIG_FAILED
;
1165 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1167 return CMD_WARNING_CONFIG_FAILED
;
1170 /* Cannot delete default instance if vrf instances exist */
1171 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1172 struct listnode
*node
;
1173 struct bgp
*tmp_bgp
;
1175 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1176 if (tmp_bgp
->inst_type
1177 == BGP_INSTANCE_TYPE_VRF
) {
1179 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1180 return CMD_WARNING_CONFIG_FAILED
;
1186 if (bgp_vpn_leak_unimport(bgp
, vty
))
1187 return CMD_WARNING_CONFIG_FAILED
;
1195 /* BGP router-id. */
1197 DEFPY (bgp_router_id
,
1199 "bgp router-id A.B.C.D",
1201 "Override configured router identifier\n"
1202 "Manually configured router identifier\n")
1204 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1205 bgp_router_id_static_set(bgp
, router_id
);
1209 DEFPY (no_bgp_router_id
,
1210 no_bgp_router_id_cmd
,
1211 "no bgp router-id [A.B.C.D]",
1214 "Override configured router identifier\n"
1215 "Manually configured router identifier\n")
1217 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1219 if (router_id_str
) {
1220 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1221 vty_out(vty
, "%% BGP router-id doesn't match\n");
1222 return CMD_WARNING_CONFIG_FAILED
;
1226 router_id
.s_addr
= 0;
1227 bgp_router_id_static_set(bgp
, router_id
);
1233 /* BGP Cluster ID. */
1234 DEFUN (bgp_cluster_id
,
1236 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1238 "Configure Route-Reflector Cluster-id\n"
1239 "Route-Reflector Cluster-id in IP address format\n"
1240 "Route-Reflector Cluster-id as 32 bit quantity\n")
1242 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1245 struct in_addr cluster
;
1247 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1249 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1250 return CMD_WARNING_CONFIG_FAILED
;
1253 bgp_cluster_id_set(bgp
, &cluster
);
1254 bgp_clear_star_soft_out(vty
, bgp
->name
);
1259 DEFUN (no_bgp_cluster_id
,
1260 no_bgp_cluster_id_cmd
,
1261 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1264 "Configure Route-Reflector Cluster-id\n"
1265 "Route-Reflector Cluster-id in IP address format\n"
1266 "Route-Reflector Cluster-id as 32 bit quantity\n")
1268 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1269 bgp_cluster_id_unset(bgp
);
1270 bgp_clear_star_soft_out(vty
, bgp
->name
);
1275 DEFUN (bgp_confederation_identifier
,
1276 bgp_confederation_identifier_cmd
,
1277 "bgp confederation identifier (1-4294967295)",
1278 "BGP specific commands\n"
1279 "AS confederation parameters\n"
1281 "Set routing domain confederation AS\n")
1283 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1287 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1289 bgp_confederation_id_set(bgp
, as
);
1294 DEFUN (no_bgp_confederation_identifier
,
1295 no_bgp_confederation_identifier_cmd
,
1296 "no bgp confederation identifier [(1-4294967295)]",
1298 "BGP specific commands\n"
1299 "AS confederation parameters\n"
1301 "Set routing domain confederation AS\n")
1303 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1304 bgp_confederation_id_unset(bgp
);
1309 DEFUN (bgp_confederation_peers
,
1310 bgp_confederation_peers_cmd
,
1311 "bgp confederation peers (1-4294967295)...",
1312 "BGP specific commands\n"
1313 "AS confederation parameters\n"
1314 "Peer ASs in BGP confederation\n"
1317 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1322 for (i
= idx_asn
; i
< argc
; i
++) {
1323 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1325 if (bgp
->as
== as
) {
1327 "%% Local member-AS not allowed in confed peer list\n");
1331 bgp_confederation_peers_add(bgp
, as
);
1336 DEFUN (no_bgp_confederation_peers
,
1337 no_bgp_confederation_peers_cmd
,
1338 "no bgp confederation peers (1-4294967295)...",
1340 "BGP specific commands\n"
1341 "AS confederation parameters\n"
1342 "Peer ASs in BGP confederation\n"
1345 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1350 for (i
= idx_asn
; i
< argc
; i
++) {
1351 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1353 bgp_confederation_peers_remove(bgp
, as
);
1359 * Central routine for maximum-paths configuration.
1360 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1361 * @set: 1 for setting values, 0 for removing the max-paths config.
1363 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1364 const char *mpaths
, uint16_t options
,
1367 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1368 uint16_t maxpaths
= 0;
1373 afi
= bgp_node_afi(vty
);
1374 safi
= bgp_node_safi(vty
);
1377 maxpaths
= strtol(mpaths
, NULL
, 10);
1378 if (maxpaths
> multipath_num
) {
1380 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1381 maxpaths
, multipath_num
);
1382 return CMD_WARNING_CONFIG_FAILED
;
1384 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1387 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1391 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1392 (set
== 1) ? "" : "un",
1393 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1394 maxpaths
, afi
, safi
);
1395 return CMD_WARNING_CONFIG_FAILED
;
1398 bgp_recalculate_all_bestpaths(bgp
);
1403 DEFUN (bgp_maxmed_admin
,
1404 bgp_maxmed_admin_cmd
,
1405 "bgp max-med administrative ",
1407 "Advertise routes with max-med\n"
1408 "Administratively applied, for an indefinite period\n")
1410 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1412 bgp
->v_maxmed_admin
= 1;
1413 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1415 bgp_maxmed_update(bgp
);
1420 DEFUN (bgp_maxmed_admin_medv
,
1421 bgp_maxmed_admin_medv_cmd
,
1422 "bgp max-med administrative (0-4294967295)",
1424 "Advertise routes with max-med\n"
1425 "Administratively applied, for an indefinite period\n"
1426 "Max MED value to be used\n")
1428 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1431 bgp
->v_maxmed_admin
= 1;
1432 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1434 bgp_maxmed_update(bgp
);
1439 DEFUN (no_bgp_maxmed_admin
,
1440 no_bgp_maxmed_admin_cmd
,
1441 "no bgp max-med administrative [(0-4294967295)]",
1444 "Advertise routes with max-med\n"
1445 "Administratively applied, for an indefinite period\n"
1446 "Max MED value to be used\n")
1448 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1449 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1450 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1451 bgp_maxmed_update(bgp
);
1456 DEFUN (bgp_maxmed_onstartup
,
1457 bgp_maxmed_onstartup_cmd
,
1458 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1460 "Advertise routes with max-med\n"
1461 "Effective on a startup\n"
1462 "Time (seconds) period for max-med\n"
1463 "Max MED value to be used\n")
1465 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1468 argv_find(argv
, argc
, "(5-86400)", &idx
);
1469 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1470 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1471 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1473 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1475 bgp_maxmed_update(bgp
);
1480 DEFUN (no_bgp_maxmed_onstartup
,
1481 no_bgp_maxmed_onstartup_cmd
,
1482 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1485 "Advertise routes with max-med\n"
1486 "Effective on a startup\n"
1487 "Time (seconds) period for max-med\n"
1488 "Max MED value to be used\n")
1490 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1492 /* Cancel max-med onstartup if its on */
1493 if (bgp
->t_maxmed_onstartup
) {
1494 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1495 bgp
->maxmed_onstartup_over
= 1;
1498 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1499 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1501 bgp_maxmed_update(bgp
);
1506 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1509 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1510 uint16_t update_delay
;
1511 uint16_t establish_wait
;
1513 update_delay
= strtoul(delay
, NULL
, 10);
1515 if (!wait
) /* update-delay <delay> */
1517 bgp
->v_update_delay
= update_delay
;
1518 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1522 /* update-delay <delay> <establish-wait> */
1523 establish_wait
= atoi(wait
);
1524 if (update_delay
< establish_wait
) {
1526 "%%Failed: update-delay less than the establish-wait!\n");
1527 return CMD_WARNING_CONFIG_FAILED
;
1530 bgp
->v_update_delay
= update_delay
;
1531 bgp
->v_establish_wait
= establish_wait
;
1536 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1538 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1540 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1541 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1546 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1548 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1549 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1550 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1551 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1557 /* Update-delay configuration */
1558 DEFUN (bgp_update_delay
,
1559 bgp_update_delay_cmd
,
1560 "update-delay (0-3600)",
1561 "Force initial delay for best-path and updates\n"
1565 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1568 DEFUN (bgp_update_delay_establish_wait
,
1569 bgp_update_delay_establish_wait_cmd
,
1570 "update-delay (0-3600) (1-3600)",
1571 "Force initial delay for best-path and updates\n"
1576 int idx_number_2
= 2;
1577 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1578 argv
[idx_number_2
]->arg
);
1581 /* Update-delay deconfiguration */
1582 DEFUN (no_bgp_update_delay
,
1583 no_bgp_update_delay_cmd
,
1584 "no update-delay [(0-3600) [(1-3600)]]",
1586 "Force initial delay for best-path and updates\n"
1590 return bgp_update_delay_deconfig_vty(vty
);
1594 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
1597 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1599 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
1600 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
1605 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
1608 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1610 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
1611 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
1616 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1619 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1620 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1621 vty_out(vty
, " write-quanta %d\n", quanta
);
1624 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1627 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1628 if (quanta
!= BGP_READ_PACKET_MAX
)
1629 vty_out(vty
, " read-quanta %d\n", quanta
);
1632 /* Packet quanta configuration
1634 * XXX: The value set here controls the size of a stack buffer in the IO
1635 * thread. When changing these limits be careful to prevent stack overflow.
1637 * Furthermore, the maximums used here should correspond to
1638 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
1640 DEFPY (bgp_wpkt_quanta
,
1641 bgp_wpkt_quanta_cmd
,
1642 "[no] write-quanta (1-64)$quanta",
1644 "How many packets to write to peer socket per run\n"
1645 "Number of packets\n")
1647 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
1650 DEFPY (bgp_rpkt_quanta
,
1651 bgp_rpkt_quanta_cmd
,
1652 "[no] read-quanta (1-10)$quanta",
1654 "How many packets to read from peer socket per I/O cycle\n"
1655 "Number of packets\n")
1657 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
1660 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1662 if (!bgp
->heuristic_coalesce
)
1663 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1667 DEFUN (bgp_coalesce_time
,
1668 bgp_coalesce_time_cmd
,
1669 "coalesce-time (0-4294967295)",
1670 "Subgroup coalesce timer\n"
1671 "Subgroup coalesce timer value (in ms)\n")
1673 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1676 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1677 bgp
->heuristic_coalesce
= false;
1678 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1682 DEFUN (no_bgp_coalesce_time
,
1683 no_bgp_coalesce_time_cmd
,
1684 "no coalesce-time (0-4294967295)",
1686 "Subgroup coalesce timer\n"
1687 "Subgroup coalesce timer value (in ms)\n")
1689 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1691 bgp
->heuristic_coalesce
= true;
1692 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1696 /* Maximum-paths configuration */
1697 DEFUN (bgp_maxpaths
,
1699 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1700 "Forward packets over multiple paths\n"
1701 "Number of paths\n")
1704 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1705 argv
[idx_number
]->arg
, 0, 1);
1708 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1709 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1710 "Forward packets over multiple paths\n"
1711 "Number of paths\n")
1713 DEFUN (bgp_maxpaths_ibgp
,
1714 bgp_maxpaths_ibgp_cmd
,
1715 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1716 "Forward packets over multiple paths\n"
1718 "Number of paths\n")
1721 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1722 argv
[idx_number
]->arg
, 0, 1);
1725 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1726 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1727 "Forward packets over multiple paths\n"
1729 "Number of paths\n")
1731 DEFUN (bgp_maxpaths_ibgp_cluster
,
1732 bgp_maxpaths_ibgp_cluster_cmd
,
1733 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1734 "Forward packets over multiple paths\n"
1737 "Match the cluster length\n")
1740 return bgp_maxpaths_config_vty(
1741 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1742 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1745 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1746 "maximum-paths ibgp " CMD_RANGE_STR(
1747 1, MULTIPATH_NUM
) " equal-cluster-length",
1748 "Forward packets over multiple paths\n"
1751 "Match the cluster length\n")
1753 DEFUN (no_bgp_maxpaths
,
1754 no_bgp_maxpaths_cmd
,
1755 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1757 "Forward packets over multiple paths\n"
1758 "Number of paths\n")
1760 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1763 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1764 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1765 "Forward packets over multiple paths\n"
1766 "Number of paths\n")
1768 DEFUN (no_bgp_maxpaths_ibgp
,
1769 no_bgp_maxpaths_ibgp_cmd
,
1770 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1772 "Forward packets over multiple paths\n"
1775 "Match the cluster length\n")
1777 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1780 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1781 "no maximum-paths ibgp [" CMD_RANGE_STR(
1782 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1784 "Forward packets over multiple paths\n"
1787 "Match the cluster length\n")
1789 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
1790 afi_t afi
, safi_t safi
)
1792 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1793 vty_out(vty
, " maximum-paths %d\n",
1794 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1797 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1798 vty_out(vty
, " maximum-paths ibgp %d",
1799 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1800 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1801 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1802 vty_out(vty
, " equal-cluster-length");
1811 "timers bgp (0-65535) (0-65535)",
1812 "Adjust routing timers\n"
1814 "Keepalive interval\n"
1817 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1819 int idx_number_2
= 3;
1820 unsigned long keepalive
= 0;
1821 unsigned long holdtime
= 0;
1823 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1824 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1826 /* Holdtime value check. */
1827 if (holdtime
< 3 && holdtime
!= 0) {
1829 "%% hold time value must be either 0 or greater than 3\n");
1830 return CMD_WARNING_CONFIG_FAILED
;
1833 bgp_timers_set(bgp
, keepalive
, holdtime
);
1838 DEFUN (no_bgp_timers
,
1840 "no timers bgp [(0-65535) (0-65535)]",
1842 "Adjust routing timers\n"
1844 "Keepalive interval\n"
1847 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1848 bgp_timers_unset(bgp
);
1854 DEFUN (bgp_client_to_client_reflection
,
1855 bgp_client_to_client_reflection_cmd
,
1856 "bgp client-to-client reflection",
1857 "BGP specific commands\n"
1858 "Configure client to client route reflection\n"
1859 "reflection of routes allowed\n")
1861 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1862 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1863 bgp_clear_star_soft_out(vty
, bgp
->name
);
1868 DEFUN (no_bgp_client_to_client_reflection
,
1869 no_bgp_client_to_client_reflection_cmd
,
1870 "no bgp client-to-client reflection",
1872 "BGP specific commands\n"
1873 "Configure client to client route reflection\n"
1874 "reflection of routes allowed\n")
1876 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1877 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1878 bgp_clear_star_soft_out(vty
, bgp
->name
);
1883 /* "bgp always-compare-med" configuration. */
1884 DEFUN (bgp_always_compare_med
,
1885 bgp_always_compare_med_cmd
,
1886 "bgp always-compare-med",
1887 "BGP specific commands\n"
1888 "Allow comparing MED from different neighbors\n")
1890 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1891 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1892 bgp_recalculate_all_bestpaths(bgp
);
1897 DEFUN (no_bgp_always_compare_med
,
1898 no_bgp_always_compare_med_cmd
,
1899 "no bgp always-compare-med",
1901 "BGP specific commands\n"
1902 "Allow comparing MED from different neighbors\n")
1904 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1905 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1906 bgp_recalculate_all_bestpaths(bgp
);
1912 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
1913 "bgp ebgp-requires-policy",
1914 "BGP specific commands\n"
1915 "Require in and out policy for eBGP peers (RFC8212)\n")
1917 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1918 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_ENABLED
;
1922 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
1923 "no bgp ebgp-requires-policy",
1925 "BGP specific commands\n"
1926 "Require in and out policy for eBGP peers (RFC8212)\n")
1928 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1929 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_DISABLED
;
1933 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
1934 "bgp reject-as-sets",
1935 "BGP specific commands\n"
1936 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
1938 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1939 struct listnode
*node
, *nnode
;
1942 bgp
->reject_as_sets
= BGP_REJECT_AS_SETS_ENABLED
;
1944 /* Reset existing BGP sessions to reject routes
1945 * with aspath containing AS_SET or AS_CONFED_SET.
1947 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1948 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
1949 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
1950 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
1951 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
1958 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
1959 "no bgp reject-as-sets",
1961 "BGP specific commands\n"
1962 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
1964 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1965 struct listnode
*node
, *nnode
;
1968 bgp
->reject_as_sets
= BGP_REJECT_AS_SETS_DISABLED
;
1970 /* Reset existing BGP sessions to reject routes
1971 * with aspath containing AS_SET or AS_CONFED_SET.
1973 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1974 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
1975 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
1976 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
1977 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
1984 /* "bgp deterministic-med" configuration. */
1985 DEFUN (bgp_deterministic_med
,
1986 bgp_deterministic_med_cmd
,
1987 "bgp deterministic-med",
1988 "BGP specific commands\n"
1989 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1991 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1993 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1994 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1995 bgp_recalculate_all_bestpaths(bgp
);
2001 DEFUN (no_bgp_deterministic_med
,
2002 no_bgp_deterministic_med_cmd
,
2003 "no bgp deterministic-med",
2005 "BGP specific commands\n"
2006 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2008 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2009 int bestpath_per_as_used
;
2013 struct listnode
*node
, *nnode
;
2015 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
2016 bestpath_per_as_used
= 0;
2018 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2019 FOREACH_AFI_SAFI (afi
, safi
)
2020 if (bgp_addpath_dmed_required(
2021 peer
->addpath_type
[afi
][safi
])) {
2022 bestpath_per_as_used
= 1;
2026 if (bestpath_per_as_used
)
2030 if (bestpath_per_as_used
) {
2032 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2033 return CMD_WARNING_CONFIG_FAILED
;
2035 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
2036 bgp_recalculate_all_bestpaths(bgp
);
2043 /* "bgp graceful-restart" configuration. */
2044 DEFUN (bgp_graceful_restart
,
2045 bgp_graceful_restart_cmd
,
2046 "bgp graceful-restart",
2047 "BGP specific commands\n"
2048 "Graceful restart capability parameters\n")
2050 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2051 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
2055 DEFUN (no_bgp_graceful_restart
,
2056 no_bgp_graceful_restart_cmd
,
2057 "no bgp graceful-restart",
2059 "BGP specific commands\n"
2060 "Graceful restart capability parameters\n")
2062 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2063 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
2067 DEFUN (bgp_graceful_restart_stalepath_time
,
2068 bgp_graceful_restart_stalepath_time_cmd
,
2069 "bgp graceful-restart stalepath-time (1-4095)",
2070 "BGP specific commands\n"
2071 "Graceful restart capability parameters\n"
2072 "Set the max time to hold onto restarting peer's stale paths\n"
2073 "Delay value (seconds)\n")
2075 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2079 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2080 bgp
->stalepath_time
= stalepath
;
2084 DEFUN (bgp_graceful_restart_restart_time
,
2085 bgp_graceful_restart_restart_time_cmd
,
2086 "bgp graceful-restart restart-time (1-4095)",
2087 "BGP specific commands\n"
2088 "Graceful restart capability parameters\n"
2089 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2090 "Delay value (seconds)\n")
2092 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2096 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2097 bgp
->restart_time
= restart
;
2101 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2102 no_bgp_graceful_restart_stalepath_time_cmd
,
2103 "no bgp graceful-restart stalepath-time [(1-4095)]",
2105 "BGP specific commands\n"
2106 "Graceful restart capability parameters\n"
2107 "Set the max time to hold onto restarting peer's stale paths\n"
2108 "Delay value (seconds)\n")
2110 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2112 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2116 DEFUN (no_bgp_graceful_restart_restart_time
,
2117 no_bgp_graceful_restart_restart_time_cmd
,
2118 "no bgp graceful-restart restart-time [(1-4095)]",
2120 "BGP specific commands\n"
2121 "Graceful restart capability parameters\n"
2122 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2123 "Delay value (seconds)\n")
2125 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2127 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2131 DEFUN (bgp_graceful_restart_preserve_fw
,
2132 bgp_graceful_restart_preserve_fw_cmd
,
2133 "bgp graceful-restart preserve-fw-state",
2134 "BGP specific commands\n"
2135 "Graceful restart capability parameters\n"
2136 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2138 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2139 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2143 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2144 no_bgp_graceful_restart_preserve_fw_cmd
,
2145 "no bgp graceful-restart preserve-fw-state",
2147 "BGP specific commands\n"
2148 "Graceful restart capability parameters\n"
2149 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2151 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2152 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2156 /* "bgp graceful-shutdown" configuration */
2157 DEFUN (bgp_graceful_shutdown
,
2158 bgp_graceful_shutdown_cmd
,
2159 "bgp graceful-shutdown",
2161 "Graceful shutdown parameters\n")
2163 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2165 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2166 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2167 bgp_static_redo_import_check(bgp
);
2168 bgp_redistribute_redo(bgp
);
2169 bgp_clear_star_soft_out(vty
, bgp
->name
);
2170 bgp_clear_star_soft_in(vty
, bgp
->name
);
2176 DEFUN (no_bgp_graceful_shutdown
,
2177 no_bgp_graceful_shutdown_cmd
,
2178 "no bgp graceful-shutdown",
2181 "Graceful shutdown parameters\n")
2183 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2185 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2186 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2187 bgp_static_redo_import_check(bgp
);
2188 bgp_redistribute_redo(bgp
);
2189 bgp_clear_star_soft_out(vty
, bgp
->name
);
2190 bgp_clear_star_soft_in(vty
, bgp
->name
);
2196 /* "bgp fast-external-failover" configuration. */
2197 DEFUN (bgp_fast_external_failover
,
2198 bgp_fast_external_failover_cmd
,
2199 "bgp fast-external-failover",
2201 "Immediately reset session if a link to a directly connected external peer goes down\n")
2203 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2204 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2208 DEFUN (no_bgp_fast_external_failover
,
2209 no_bgp_fast_external_failover_cmd
,
2210 "no bgp fast-external-failover",
2213 "Immediately reset session if a link to a directly connected external peer goes down\n")
2215 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2216 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2220 /* "bgp bestpath compare-routerid" configuration. */
2221 DEFUN (bgp_bestpath_compare_router_id
,
2222 bgp_bestpath_compare_router_id_cmd
,
2223 "bgp bestpath compare-routerid",
2224 "BGP specific commands\n"
2225 "Change the default bestpath selection\n"
2226 "Compare router-id for identical EBGP paths\n")
2228 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2229 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2230 bgp_recalculate_all_bestpaths(bgp
);
2235 DEFUN (no_bgp_bestpath_compare_router_id
,
2236 no_bgp_bestpath_compare_router_id_cmd
,
2237 "no bgp bestpath compare-routerid",
2239 "BGP specific commands\n"
2240 "Change the default bestpath selection\n"
2241 "Compare router-id for identical EBGP paths\n")
2243 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2244 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2245 bgp_recalculate_all_bestpaths(bgp
);
2250 /* "bgp bestpath as-path ignore" configuration. */
2251 DEFUN (bgp_bestpath_aspath_ignore
,
2252 bgp_bestpath_aspath_ignore_cmd
,
2253 "bgp bestpath as-path ignore",
2254 "BGP specific commands\n"
2255 "Change the default bestpath selection\n"
2256 "AS-path attribute\n"
2257 "Ignore as-path length in selecting a route\n")
2259 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2260 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2261 bgp_recalculate_all_bestpaths(bgp
);
2266 DEFUN (no_bgp_bestpath_aspath_ignore
,
2267 no_bgp_bestpath_aspath_ignore_cmd
,
2268 "no bgp bestpath as-path ignore",
2270 "BGP specific commands\n"
2271 "Change the default bestpath selection\n"
2272 "AS-path attribute\n"
2273 "Ignore as-path length in selecting a route\n")
2275 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2276 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2277 bgp_recalculate_all_bestpaths(bgp
);
2282 /* "bgp bestpath as-path confed" configuration. */
2283 DEFUN (bgp_bestpath_aspath_confed
,
2284 bgp_bestpath_aspath_confed_cmd
,
2285 "bgp bestpath as-path confed",
2286 "BGP specific commands\n"
2287 "Change the default bestpath selection\n"
2288 "AS-path attribute\n"
2289 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2291 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2292 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2293 bgp_recalculate_all_bestpaths(bgp
);
2298 DEFUN (no_bgp_bestpath_aspath_confed
,
2299 no_bgp_bestpath_aspath_confed_cmd
,
2300 "no bgp bestpath as-path confed",
2302 "BGP specific commands\n"
2303 "Change the default bestpath selection\n"
2304 "AS-path attribute\n"
2305 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2307 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2308 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2309 bgp_recalculate_all_bestpaths(bgp
);
2314 /* "bgp bestpath as-path multipath-relax" configuration. */
2315 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2316 bgp_bestpath_aspath_multipath_relax_cmd
,
2317 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2318 "BGP specific commands\n"
2319 "Change the default bestpath selection\n"
2320 "AS-path attribute\n"
2321 "Allow load sharing across routes that have different AS paths (but same length)\n"
2322 "Generate an AS_SET\n"
2323 "Do not generate an AS_SET\n")
2325 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2327 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2329 /* no-as-set is now the default behavior so we can silently
2331 if (argv_find(argv
, argc
, "as-set", &idx
))
2332 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2334 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2336 bgp_recalculate_all_bestpaths(bgp
);
2341 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2342 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2343 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2345 "BGP specific commands\n"
2346 "Change the default bestpath selection\n"
2347 "AS-path attribute\n"
2348 "Allow load sharing across routes that have different AS paths (but same length)\n"
2349 "Generate an AS_SET\n"
2350 "Do not generate an AS_SET\n")
2352 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2353 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2354 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2355 bgp_recalculate_all_bestpaths(bgp
);
2360 /* "bgp log-neighbor-changes" configuration. */
2361 DEFUN (bgp_log_neighbor_changes
,
2362 bgp_log_neighbor_changes_cmd
,
2363 "bgp log-neighbor-changes",
2364 "BGP specific commands\n"
2365 "Log neighbor up/down and reset reason\n")
2367 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2368 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2372 DEFUN (no_bgp_log_neighbor_changes
,
2373 no_bgp_log_neighbor_changes_cmd
,
2374 "no bgp log-neighbor-changes",
2376 "BGP specific commands\n"
2377 "Log neighbor up/down and reset reason\n")
2379 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2380 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2384 /* "bgp bestpath med" configuration. */
2385 DEFUN (bgp_bestpath_med
,
2386 bgp_bestpath_med_cmd
,
2387 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2388 "BGP specific commands\n"
2389 "Change the default bestpath selection\n"
2391 "Compare MED among confederation paths\n"
2392 "Treat missing MED as the least preferred one\n"
2393 "Treat missing MED as the least preferred one\n"
2394 "Compare MED among confederation paths\n")
2396 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2399 if (argv_find(argv
, argc
, "confed", &idx
))
2400 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2402 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2403 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2405 bgp_recalculate_all_bestpaths(bgp
);
2410 DEFUN (no_bgp_bestpath_med
,
2411 no_bgp_bestpath_med_cmd
,
2412 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2414 "BGP specific commands\n"
2415 "Change the default bestpath selection\n"
2417 "Compare MED among confederation paths\n"
2418 "Treat missing MED as the least preferred one\n"
2419 "Treat missing MED as the least preferred one\n"
2420 "Compare MED among confederation paths\n")
2422 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2425 if (argv_find(argv
, argc
, "confed", &idx
))
2426 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2428 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2429 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2431 bgp_recalculate_all_bestpaths(bgp
);
2436 /* "no bgp default ipv4-unicast". */
2437 DEFUN (no_bgp_default_ipv4_unicast
,
2438 no_bgp_default_ipv4_unicast_cmd
,
2439 "no bgp default ipv4-unicast",
2441 "BGP specific commands\n"
2442 "Configure BGP defaults\n"
2443 "Activate ipv4-unicast for a peer by default\n")
2445 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2446 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2450 DEFUN (bgp_default_ipv4_unicast
,
2451 bgp_default_ipv4_unicast_cmd
,
2452 "bgp default ipv4-unicast",
2453 "BGP specific commands\n"
2454 "Configure BGP defaults\n"
2455 "Activate ipv4-unicast for a peer by default\n")
2457 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2458 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2462 /* Display hostname in certain command outputs */
2463 DEFUN (bgp_default_show_hostname
,
2464 bgp_default_show_hostname_cmd
,
2465 "bgp default show-hostname",
2466 "BGP specific commands\n"
2467 "Configure BGP defaults\n"
2468 "Show hostname in certain command outputs\n")
2470 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2471 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2475 DEFUN (no_bgp_default_show_hostname
,
2476 no_bgp_default_show_hostname_cmd
,
2477 "no bgp default show-hostname",
2479 "BGP specific commands\n"
2480 "Configure BGP defaults\n"
2481 "Show hostname in certain command outputs\n")
2483 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2484 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2488 /* "bgp network import-check" configuration. */
2489 DEFUN (bgp_network_import_check
,
2490 bgp_network_import_check_cmd
,
2491 "bgp network import-check",
2492 "BGP specific commands\n"
2493 "BGP network command\n"
2494 "Check BGP network route exists in IGP\n")
2496 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2497 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2498 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2499 bgp_static_redo_import_check(bgp
);
2505 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2506 "bgp network import-check exact",
2507 "BGP specific commands\n"
2508 "BGP network command\n"
2509 "Check BGP network route exists in IGP\n"
2510 "Match route precisely\n")
2512 DEFUN (no_bgp_network_import_check
,
2513 no_bgp_network_import_check_cmd
,
2514 "no bgp network import-check",
2516 "BGP specific commands\n"
2517 "BGP network command\n"
2518 "Check BGP network route exists in IGP\n")
2520 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2521 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2522 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2523 bgp_static_redo_import_check(bgp
);
2529 DEFUN (bgp_default_local_preference
,
2530 bgp_default_local_preference_cmd
,
2531 "bgp default local-preference (0-4294967295)",
2532 "BGP specific commands\n"
2533 "Configure BGP defaults\n"
2534 "local preference (higher=more preferred)\n"
2535 "Configure default local preference value\n")
2537 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2539 uint32_t local_pref
;
2541 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2543 bgp_default_local_preference_set(bgp
, local_pref
);
2544 bgp_clear_star_soft_in(vty
, bgp
->name
);
2549 DEFUN (no_bgp_default_local_preference
,
2550 no_bgp_default_local_preference_cmd
,
2551 "no bgp default local-preference [(0-4294967295)]",
2553 "BGP specific commands\n"
2554 "Configure BGP defaults\n"
2555 "local preference (higher=more preferred)\n"
2556 "Configure default local preference value\n")
2558 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2559 bgp_default_local_preference_unset(bgp
);
2560 bgp_clear_star_soft_in(vty
, bgp
->name
);
2566 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2567 bgp_default_subgroup_pkt_queue_max_cmd
,
2568 "bgp default subgroup-pkt-queue-max (20-100)",
2569 "BGP specific commands\n"
2570 "Configure BGP defaults\n"
2571 "subgroup-pkt-queue-max\n"
2572 "Configure subgroup packet queue max\n")
2574 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2578 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2580 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2585 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2586 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2587 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2589 "BGP specific commands\n"
2590 "Configure BGP defaults\n"
2591 "subgroup-pkt-queue-max\n"
2592 "Configure subgroup packet queue max\n")
2594 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2595 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2600 DEFUN (bgp_rr_allow_outbound_policy
,
2601 bgp_rr_allow_outbound_policy_cmd
,
2602 "bgp route-reflector allow-outbound-policy",
2603 "BGP specific commands\n"
2604 "Allow modifications made by out route-map\n"
2605 "on ibgp neighbors\n")
2607 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2609 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2610 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2611 update_group_announce_rrclients(bgp
);
2612 bgp_clear_star_soft_out(vty
, bgp
->name
);
2618 DEFUN (no_bgp_rr_allow_outbound_policy
,
2619 no_bgp_rr_allow_outbound_policy_cmd
,
2620 "no bgp route-reflector allow-outbound-policy",
2622 "BGP specific commands\n"
2623 "Allow modifications made by out route-map\n"
2624 "on ibgp neighbors\n")
2626 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2628 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2629 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2630 update_group_announce_rrclients(bgp
);
2631 bgp_clear_star_soft_out(vty
, bgp
->name
);
2637 DEFUN (bgp_listen_limit
,
2638 bgp_listen_limit_cmd
,
2639 "bgp listen limit (1-5000)",
2640 "BGP specific commands\n"
2641 "Configure BGP defaults\n"
2642 "maximum number of BGP Dynamic Neighbors that can be created\n"
2643 "Configure Dynamic Neighbors listen limit value\n")
2645 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2649 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2651 bgp_listen_limit_set(bgp
, listen_limit
);
2656 DEFUN (no_bgp_listen_limit
,
2657 no_bgp_listen_limit_cmd
,
2658 "no bgp listen limit [(1-5000)]",
2659 "BGP specific commands\n"
2660 "Configure BGP defaults\n"
2661 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2662 "Configure Dynamic Neighbors listen limit value to default\n"
2663 "Configure Dynamic Neighbors listen limit value\n")
2665 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2666 bgp_listen_limit_unset(bgp
);
2672 * Check if this listen range is already configured. Check for exact
2673 * match or overlap based on input.
2675 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2676 struct prefix
*range
, int exact
)
2678 struct listnode
*node
, *nnode
;
2679 struct listnode
*node1
, *nnode1
;
2680 struct peer_group
*group
;
2685 afi
= family2afi(range
->family
);
2686 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2687 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2690 match
= prefix_same(range
, lr
);
2692 match
= (prefix_match(range
, lr
)
2693 || prefix_match(lr
, range
));
2702 DEFUN (bgp_listen_range
,
2703 bgp_listen_range_cmd
,
2704 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
2705 "BGP specific commands\n"
2706 "Configure BGP dynamic neighbors listen range\n"
2707 "Configure BGP dynamic neighbors listen range\n"
2709 "Member of the peer-group\n"
2710 "Peer-group name\n")
2712 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2713 struct prefix range
;
2714 struct peer_group
*group
, *existing_group
;
2719 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2720 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2721 char *prefix
= argv
[idx
]->arg
;
2722 argv_find(argv
, argc
, "PGNAME", &idx
);
2723 char *peergroup
= argv
[idx
]->arg
;
2725 /* Convert IP prefix string to struct prefix. */
2726 ret
= str2prefix(prefix
, &range
);
2728 vty_out(vty
, "%% Malformed listen range\n");
2729 return CMD_WARNING_CONFIG_FAILED
;
2732 afi
= family2afi(range
.family
);
2734 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2736 "%% Malformed listen range (link-local address)\n");
2737 return CMD_WARNING_CONFIG_FAILED
;
2742 /* Check if same listen range is already configured. */
2743 existing_group
= listen_range_exists(bgp
, &range
, 1);
2744 if (existing_group
) {
2745 if (strcmp(existing_group
->name
, peergroup
) == 0)
2749 "%% Same listen range is attached to peer-group %s\n",
2750 existing_group
->name
);
2751 return CMD_WARNING_CONFIG_FAILED
;
2755 /* Check if an overlapping listen range exists. */
2756 if (listen_range_exists(bgp
, &range
, 0)) {
2758 "%% Listen range overlaps with existing listen range\n");
2759 return CMD_WARNING_CONFIG_FAILED
;
2762 group
= peer_group_lookup(bgp
, peergroup
);
2764 vty_out(vty
, "%% Configure the peer-group first\n");
2765 return CMD_WARNING_CONFIG_FAILED
;
2768 ret
= peer_group_listen_range_add(group
, &range
);
2769 return bgp_vty_return(vty
, ret
);
2772 DEFUN (no_bgp_listen_range
,
2773 no_bgp_listen_range_cmd
,
2774 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
2776 "BGP specific commands\n"
2777 "Unconfigure BGP dynamic neighbors listen range\n"
2778 "Unconfigure BGP dynamic neighbors listen range\n"
2780 "Member of the peer-group\n"
2781 "Peer-group name\n")
2783 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2784 struct prefix range
;
2785 struct peer_group
*group
;
2790 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2791 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2792 char *prefix
= argv
[idx
]->arg
;
2793 argv_find(argv
, argc
, "WORD", &idx
);
2794 char *peergroup
= argv
[idx
]->arg
;
2796 /* Convert IP prefix string to struct prefix. */
2797 ret
= str2prefix(prefix
, &range
);
2799 vty_out(vty
, "%% Malformed listen range\n");
2800 return CMD_WARNING_CONFIG_FAILED
;
2803 afi
= family2afi(range
.family
);
2805 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2807 "%% Malformed listen range (link-local address)\n");
2808 return CMD_WARNING_CONFIG_FAILED
;
2813 group
= peer_group_lookup(bgp
, peergroup
);
2815 vty_out(vty
, "%% Peer-group does not exist\n");
2816 return CMD_WARNING_CONFIG_FAILED
;
2819 ret
= peer_group_listen_range_del(group
, &range
);
2820 return bgp_vty_return(vty
, ret
);
2823 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2825 struct peer_group
*group
;
2826 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2827 struct prefix
*range
;
2829 char buf
[PREFIX2STR_BUFFER
];
2831 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2832 vty_out(vty
, " bgp listen limit %d\n",
2833 bgp
->dynamic_neighbors_limit
);
2835 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2836 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2837 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2839 prefix2str(range
, buf
, sizeof(buf
));
2841 " bgp listen range %s peer-group %s\n",
2849 DEFUN (bgp_disable_connected_route_check
,
2850 bgp_disable_connected_route_check_cmd
,
2851 "bgp disable-ebgp-connected-route-check",
2852 "BGP specific commands\n"
2853 "Disable checking if nexthop is connected on ebgp sessions\n")
2855 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2856 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2857 bgp_clear_star_soft_in(vty
, bgp
->name
);
2862 DEFUN (no_bgp_disable_connected_route_check
,
2863 no_bgp_disable_connected_route_check_cmd
,
2864 "no bgp disable-ebgp-connected-route-check",
2866 "BGP specific commands\n"
2867 "Disable checking if nexthop is connected on ebgp sessions\n")
2869 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2870 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2871 bgp_clear_star_soft_in(vty
, bgp
->name
);
2877 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2878 const char *as_str
, afi_t afi
, safi_t safi
)
2880 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2883 int as_type
= AS_SPECIFIED
;
2886 if (as_str
[0] == 'i') {
2888 as_type
= AS_INTERNAL
;
2889 } else if (as_str
[0] == 'e') {
2891 as_type
= AS_EXTERNAL
;
2893 /* Get AS number. */
2894 as
= strtoul(as_str
, NULL
, 10);
2897 /* If peer is peer group or interface peer, call proper function. */
2898 ret
= str2sockunion(peer_str
, &su
);
2902 /* Check if existing interface peer */
2903 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
2905 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2908 /* if not interface peer, check peer-group settings */
2909 if (ret
< 0 && !peer
) {
2910 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2913 "%% Create the peer-group or interface first\n");
2914 return CMD_WARNING_CONFIG_FAILED
;
2919 if (peer_address_self_check(bgp
, &su
)) {
2921 "%% Can not configure the local system as neighbor\n");
2922 return CMD_WARNING_CONFIG_FAILED
;
2924 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2927 /* This peer belongs to peer group. */
2929 case BGP_ERR_PEER_GROUP_MEMBER
:
2931 "%% Peer-group member cannot override remote-as of peer-group\n");
2932 return CMD_WARNING_CONFIG_FAILED
;
2933 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2935 "%% Peer-group members must be all internal or all external\n");
2936 return CMD_WARNING_CONFIG_FAILED
;
2938 return bgp_vty_return(vty
, ret
);
2941 DEFUN (bgp_default_shutdown
,
2942 bgp_default_shutdown_cmd
,
2943 "[no] bgp default shutdown",
2946 "Configure BGP defaults\n"
2947 "Apply administrative shutdown to newly configured peers\n")
2949 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2950 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2954 DEFUN (neighbor_remote_as
,
2955 neighbor_remote_as_cmd
,
2956 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2959 "Specify a BGP neighbor\n"
2961 "Internal BGP peer\n"
2962 "External BGP peer\n")
2965 int idx_remote_as
= 3;
2966 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2967 argv
[idx_remote_as
]->arg
, AFI_IP
,
2971 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2972 afi_t afi
, safi_t safi
, int v6only
,
2973 const char *peer_group_name
,
2976 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2978 int as_type
= AS_UNSPECIFIED
;
2980 struct peer_group
*group
;
2984 group
= peer_group_lookup(bgp
, conf_if
);
2987 vty_out(vty
, "%% Name conflict with peer-group \n");
2988 return CMD_WARNING_CONFIG_FAILED
;
2992 if (as_str
[0] == 'i') {
2993 as_type
= AS_INTERNAL
;
2994 } else if (as_str
[0] == 'e') {
2995 as_type
= AS_EXTERNAL
;
2997 /* Get AS number. */
2998 as
= strtoul(as_str
, NULL
, 10);
2999 as_type
= AS_SPECIFIED
;
3003 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
3006 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
3009 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
3010 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
3011 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
3012 as_type
, 0, 0, NULL
);
3014 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
3015 as_type
, afi
, safi
, NULL
);
3018 vty_out(vty
, "%% BGP failed to create peer\n");
3019 return CMD_WARNING_CONFIG_FAILED
;
3023 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
3025 /* Request zebra to initiate IPv6 RAs on this interface. We do
3027 * any unnumbered peer in order to not worry about run-time
3029 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
3031 * gets deleted later etc.)
3034 bgp_zebra_initiate_radv(bgp
, peer
);
3037 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
3038 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
3040 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
3042 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
3044 /* v6only flag changed. Reset bgp seesion */
3045 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
3046 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
3047 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
3048 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
3050 bgp_session_reset(peer
);
3053 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
3054 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
3055 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
3056 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
3059 if (peer_group_name
) {
3060 group
= peer_group_lookup(bgp
, peer_group_name
);
3062 vty_out(vty
, "%% Configure the peer-group first\n");
3063 return CMD_WARNING_CONFIG_FAILED
;
3066 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3069 return bgp_vty_return(vty
, ret
);
3072 DEFUN (neighbor_interface_config
,
3073 neighbor_interface_config_cmd
,
3074 "neighbor WORD interface [peer-group PGNAME]",
3076 "Interface name or neighbor tag\n"
3077 "Enable BGP on interface\n"
3078 "Member of the peer-group\n"
3079 "Peer-group name\n")
3082 int idx_peer_group_word
= 4;
3084 if (argc
> idx_peer_group_word
)
3085 return peer_conf_interface_get(
3086 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
3087 argv
[idx_peer_group_word
]->arg
, NULL
);
3089 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3090 SAFI_UNICAST
, 0, NULL
, NULL
);
3093 DEFUN (neighbor_interface_config_v6only
,
3094 neighbor_interface_config_v6only_cmd
,
3095 "neighbor WORD interface v6only [peer-group PGNAME]",
3097 "Interface name or neighbor tag\n"
3098 "Enable BGP on interface\n"
3099 "Enable BGP with v6 link-local only\n"
3100 "Member of the peer-group\n"
3101 "Peer-group name\n")
3104 int idx_peer_group_word
= 5;
3106 if (argc
> idx_peer_group_word
)
3107 return peer_conf_interface_get(
3108 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
3109 argv
[idx_peer_group_word
]->arg
, NULL
);
3111 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3112 SAFI_UNICAST
, 1, NULL
, NULL
);
3116 DEFUN (neighbor_interface_config_remote_as
,
3117 neighbor_interface_config_remote_as_cmd
,
3118 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
3120 "Interface name or neighbor tag\n"
3121 "Enable BGP on interface\n"
3122 "Specify a BGP neighbor\n"
3124 "Internal BGP peer\n"
3125 "External BGP peer\n")
3128 int idx_remote_as
= 4;
3129 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3130 SAFI_UNICAST
, 0, NULL
,
3131 argv
[idx_remote_as
]->arg
);
3134 DEFUN (neighbor_interface_v6only_config_remote_as
,
3135 neighbor_interface_v6only_config_remote_as_cmd
,
3136 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
3138 "Interface name or neighbor tag\n"
3139 "Enable BGP with v6 link-local only\n"
3140 "Enable BGP on interface\n"
3141 "Specify a BGP neighbor\n"
3143 "Internal BGP peer\n"
3144 "External BGP peer\n")
3147 int idx_remote_as
= 5;
3148 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3149 SAFI_UNICAST
, 1, NULL
,
3150 argv
[idx_remote_as
]->arg
);
3153 DEFUN (neighbor_peer_group
,
3154 neighbor_peer_group_cmd
,
3155 "neighbor WORD peer-group",
3157 "Interface name or neighbor tag\n"
3158 "Configure peer-group\n")
3160 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3163 struct peer_group
*group
;
3165 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3167 vty_out(vty
, "%% Name conflict with interface: \n");
3168 return CMD_WARNING_CONFIG_FAILED
;
3171 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
3173 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
3174 return CMD_WARNING_CONFIG_FAILED
;
3182 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3186 "Specify a BGP neighbor\n"
3188 "Internal BGP peer\n"
3189 "External BGP peer\n")
3191 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3195 struct peer_group
*group
;
3199 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3201 /* look up for neighbor by interface name config. */
3202 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3204 /* Request zebra to terminate IPv6 RAs on this
3207 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3208 peer_notify_unconfig(peer
);
3213 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3215 peer_group_notify_unconfig(group
);
3216 peer_group_delete(group
);
3218 vty_out(vty
, "%% Create the peer-group first\n");
3219 return CMD_WARNING_CONFIG_FAILED
;
3222 peer
= peer_lookup(bgp
, &su
);
3224 if (peer_dynamic_neighbor(peer
)) {
3226 "%% Operation not allowed on a dynamic neighbor\n");
3227 return CMD_WARNING_CONFIG_FAILED
;
3230 other
= peer
->doppelganger
;
3231 peer_notify_unconfig(peer
);
3233 if (other
&& other
->status
!= Deleted
) {
3234 peer_notify_unconfig(other
);
3243 DEFUN (no_neighbor_interface_config
,
3244 no_neighbor_interface_config_cmd
,
3245 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
3249 "Configure BGP on interface\n"
3250 "Enable BGP with v6 link-local only\n"
3251 "Member of the peer-group\n"
3253 "Specify a BGP neighbor\n"
3255 "Internal BGP peer\n"
3256 "External BGP peer\n")
3258 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3262 /* look up for neighbor by interface name config. */
3263 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3265 /* Request zebra to terminate IPv6 RAs on this interface. */
3267 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3268 peer_notify_unconfig(peer
);
3271 vty_out(vty
, "%% Create the bgp interface first\n");
3272 return CMD_WARNING_CONFIG_FAILED
;
3277 DEFUN (no_neighbor_peer_group
,
3278 no_neighbor_peer_group_cmd
,
3279 "no neighbor WORD peer-group",
3283 "Configure peer-group\n")
3285 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3287 struct peer_group
*group
;
3289 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3291 peer_group_notify_unconfig(group
);
3292 peer_group_delete(group
);
3294 vty_out(vty
, "%% Create the peer-group first\n");
3295 return CMD_WARNING_CONFIG_FAILED
;
3300 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3301 no_neighbor_interface_peer_group_remote_as_cmd
,
3302 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3305 "Interface name or neighbor tag\n"
3306 "Specify a BGP neighbor\n"
3308 "Internal BGP peer\n"
3309 "External BGP peer\n")
3311 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3313 struct peer_group
*group
;
3316 /* look up for neighbor by interface name config. */
3317 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3319 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
3323 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3325 peer_group_remote_as_delete(group
);
3327 vty_out(vty
, "%% Create the peer-group or interface first\n");
3328 return CMD_WARNING_CONFIG_FAILED
;
3333 DEFUN (neighbor_local_as
,
3334 neighbor_local_as_cmd
,
3335 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3338 "Specify a local-as number\n"
3339 "AS number used as local AS\n")
3347 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3349 return CMD_WARNING_CONFIG_FAILED
;
3351 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3352 ret
= peer_local_as_set(peer
, as
, 0, 0);
3353 return bgp_vty_return(vty
, ret
);
3356 DEFUN (neighbor_local_as_no_prepend
,
3357 neighbor_local_as_no_prepend_cmd
,
3358 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3361 "Specify a local-as number\n"
3362 "AS number used as local AS\n"
3363 "Do not prepend local-as to updates from ebgp peers\n")
3371 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3373 return CMD_WARNING_CONFIG_FAILED
;
3375 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3376 ret
= peer_local_as_set(peer
, as
, 1, 0);
3377 return bgp_vty_return(vty
, ret
);
3380 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3381 neighbor_local_as_no_prepend_replace_as_cmd
,
3382 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3385 "Specify a local-as number\n"
3386 "AS number used as local AS\n"
3387 "Do not prepend local-as to updates from ebgp peers\n"
3388 "Do not prepend local-as to updates from ibgp peers\n")
3396 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3398 return CMD_WARNING_CONFIG_FAILED
;
3400 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3401 ret
= peer_local_as_set(peer
, as
, 1, 1);
3402 return bgp_vty_return(vty
, ret
);
3405 DEFUN (no_neighbor_local_as
,
3406 no_neighbor_local_as_cmd
,
3407 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3411 "Specify a local-as number\n"
3412 "AS number used as local AS\n"
3413 "Do not prepend local-as to updates from ebgp peers\n"
3414 "Do not prepend local-as to updates from ibgp peers\n")
3420 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3422 return CMD_WARNING_CONFIG_FAILED
;
3424 ret
= peer_local_as_unset(peer
);
3425 return bgp_vty_return(vty
, ret
);
3429 DEFUN (neighbor_solo
,
3431 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3434 "Solo peer - part of its own update group\n")
3440 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3442 return CMD_WARNING_CONFIG_FAILED
;
3444 ret
= update_group_adjust_soloness(peer
, 1);
3445 return bgp_vty_return(vty
, ret
);
3448 DEFUN (no_neighbor_solo
,
3449 no_neighbor_solo_cmd
,
3450 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3454 "Solo peer - part of its own update group\n")
3460 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3462 return CMD_WARNING_CONFIG_FAILED
;
3464 ret
= update_group_adjust_soloness(peer
, 0);
3465 return bgp_vty_return(vty
, ret
);
3468 DEFUN (neighbor_password
,
3469 neighbor_password_cmd
,
3470 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3481 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3483 return CMD_WARNING_CONFIG_FAILED
;
3485 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3486 return bgp_vty_return(vty
, ret
);
3489 DEFUN (no_neighbor_password
,
3490 no_neighbor_password_cmd
,
3491 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3502 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3504 return CMD_WARNING_CONFIG_FAILED
;
3506 ret
= peer_password_unset(peer
);
3507 return bgp_vty_return(vty
, ret
);
3510 DEFUN (neighbor_activate
,
3511 neighbor_activate_cmd
,
3512 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3515 "Enable the Address Family for this Neighbor\n")
3521 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3523 return CMD_WARNING_CONFIG_FAILED
;
3525 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3526 return bgp_vty_return(vty
, ret
);
3529 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3530 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3531 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3532 "Enable the Address Family for this Neighbor\n")
3534 DEFUN (no_neighbor_activate
,
3535 no_neighbor_activate_cmd
,
3536 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3540 "Enable the Address Family for this Neighbor\n")
3547 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3549 return CMD_WARNING_CONFIG_FAILED
;
3551 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3552 return bgp_vty_return(vty
, ret
);
3555 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3556 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3557 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3558 "Enable the Address Family for this Neighbor\n")
3560 DEFUN (neighbor_set_peer_group
,
3561 neighbor_set_peer_group_cmd
,
3562 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3565 "Member of the peer-group\n"
3566 "Peer-group name\n")
3568 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3575 struct peer_group
*group
;
3577 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3579 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3581 vty_out(vty
, "%% Malformed address or name: %s\n",
3582 argv
[idx_peer
]->arg
);
3583 return CMD_WARNING_CONFIG_FAILED
;
3586 if (peer_address_self_check(bgp
, &su
)) {
3588 "%% Can not configure the local system as neighbor\n");
3589 return CMD_WARNING_CONFIG_FAILED
;
3592 /* Disallow for dynamic neighbor. */
3593 peer
= peer_lookup(bgp
, &su
);
3594 if (peer
&& peer_dynamic_neighbor(peer
)) {
3596 "%% Operation not allowed on a dynamic neighbor\n");
3597 return CMD_WARNING_CONFIG_FAILED
;
3601 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3603 vty_out(vty
, "%% Configure the peer-group first\n");
3604 return CMD_WARNING_CONFIG_FAILED
;
3607 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3609 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3611 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3613 return CMD_WARNING_CONFIG_FAILED
;
3616 return bgp_vty_return(vty
, ret
);
3619 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3620 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3621 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3622 "Member of the peer-group\n"
3623 "Peer-group name\n")
3625 DEFUN (no_neighbor_set_peer_group
,
3626 no_neighbor_set_peer_group_cmd
,
3627 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3631 "Member of the peer-group\n"
3632 "Peer-group name\n")
3634 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3639 struct peer_group
*group
;
3641 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3643 return CMD_WARNING_CONFIG_FAILED
;
3645 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3647 vty_out(vty
, "%% Configure the peer-group first\n");
3648 return CMD_WARNING_CONFIG_FAILED
;
3651 peer_notify_unconfig(peer
);
3652 ret
= peer_delete(peer
);
3654 return bgp_vty_return(vty
, ret
);
3657 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3658 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3659 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3660 "Member of the peer-group\n"
3661 "Peer-group name\n")
3663 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3664 uint32_t flag
, int set
)
3669 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3671 return CMD_WARNING_CONFIG_FAILED
;
3674 * If 'neighbor <interface>', then this is for directly connected peers,
3675 * we should not accept disable-connected-check.
3677 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3679 "%s is directly connected peer, cannot accept disable-"
3680 "connected-check\n",
3682 return CMD_WARNING_CONFIG_FAILED
;
3685 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3686 peer_tx_shutdown_message_unset(peer
);
3689 ret
= peer_flag_set(peer
, flag
);
3691 ret
= peer_flag_unset(peer
, flag
);
3693 return bgp_vty_return(vty
, ret
);
3696 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3698 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3701 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3704 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3707 /* neighbor passive. */
3708 DEFUN (neighbor_passive
,
3709 neighbor_passive_cmd
,
3710 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3713 "Don't send open messages to this neighbor\n")
3716 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3719 DEFUN (no_neighbor_passive
,
3720 no_neighbor_passive_cmd
,
3721 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3725 "Don't send open messages to this neighbor\n")
3728 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3731 /* neighbor shutdown. */
3732 DEFUN (neighbor_shutdown_msg
,
3733 neighbor_shutdown_msg_cmd
,
3734 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3737 "Administratively shut down this neighbor\n"
3738 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3739 "Shutdown message\n")
3745 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3749 return CMD_WARNING_CONFIG_FAILED
;
3750 message
= argv_concat(argv
, argc
, 4);
3751 peer_tx_shutdown_message_set(peer
, message
);
3752 XFREE(MTYPE_TMP
, message
);
3755 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3758 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3759 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3760 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3761 "Administratively shut down this neighbor\n")
3763 DEFUN (no_neighbor_shutdown_msg
,
3764 no_neighbor_shutdown_msg_cmd
,
3765 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3769 "Administratively shut down this neighbor\n"
3770 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3771 "Shutdown message\n")
3775 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3776 PEER_FLAG_SHUTDOWN
);
3779 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3780 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3781 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3782 "Administratively shut down this neighbor\n")
3784 /* neighbor capability dynamic. */
3785 DEFUN (neighbor_capability_dynamic
,
3786 neighbor_capability_dynamic_cmd
,
3787 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3790 "Advertise capability to the peer\n"
3791 "Advertise dynamic capability to this neighbor\n")
3794 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3795 PEER_FLAG_DYNAMIC_CAPABILITY
);
3798 DEFUN (no_neighbor_capability_dynamic
,
3799 no_neighbor_capability_dynamic_cmd
,
3800 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3804 "Advertise capability to the peer\n"
3805 "Advertise dynamic capability to this neighbor\n")
3808 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3809 PEER_FLAG_DYNAMIC_CAPABILITY
);
3812 /* neighbor dont-capability-negotiate */
3813 DEFUN (neighbor_dont_capability_negotiate
,
3814 neighbor_dont_capability_negotiate_cmd
,
3815 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3818 "Do not perform capability negotiation\n")
3821 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3822 PEER_FLAG_DONT_CAPABILITY
);
3825 DEFUN (no_neighbor_dont_capability_negotiate
,
3826 no_neighbor_dont_capability_negotiate_cmd
,
3827 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3831 "Do not perform capability negotiation\n")
3834 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3835 PEER_FLAG_DONT_CAPABILITY
);
3838 /* neighbor capability extended next hop encoding */
3839 DEFUN (neighbor_capability_enhe
,
3840 neighbor_capability_enhe_cmd
,
3841 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3844 "Advertise capability to the peer\n"
3845 "Advertise extended next-hop capability to the peer\n")
3848 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3849 PEER_FLAG_CAPABILITY_ENHE
);
3852 DEFUN (no_neighbor_capability_enhe
,
3853 no_neighbor_capability_enhe_cmd
,
3854 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3858 "Advertise capability to the peer\n"
3859 "Advertise extended next-hop capability to the peer\n")
3862 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3863 PEER_FLAG_CAPABILITY_ENHE
);
3866 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3867 afi_t afi
, safi_t safi
, uint32_t flag
,
3873 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3875 return CMD_WARNING_CONFIG_FAILED
;
3878 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3880 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3882 return bgp_vty_return(vty
, ret
);
3885 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3886 afi_t afi
, safi_t safi
, uint32_t flag
)
3888 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3891 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3892 afi_t afi
, safi_t safi
, uint32_t flag
)
3894 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3897 /* neighbor capability orf prefix-list. */
3898 DEFUN (neighbor_capability_orf_prefix
,
3899 neighbor_capability_orf_prefix_cmd
,
3900 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3903 "Advertise capability to the peer\n"
3904 "Advertise ORF capability to the peer\n"
3905 "Advertise prefixlist ORF capability to this neighbor\n"
3906 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3907 "Capability to RECEIVE the ORF from this neighbor\n"
3908 "Capability to SEND the ORF to this neighbor\n")
3911 int idx_send_recv
= 5;
3914 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3915 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3916 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3917 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3918 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3919 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3921 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3922 return CMD_WARNING_CONFIG_FAILED
;
3925 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3926 bgp_node_safi(vty
), flag
);
3930 neighbor_capability_orf_prefix
,
3931 neighbor_capability_orf_prefix_hidden_cmd
,
3932 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3933 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3934 "Advertise capability to the peer\n"
3935 "Advertise ORF capability to the peer\n"
3936 "Advertise prefixlist ORF capability to this neighbor\n"
3937 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3938 "Capability to RECEIVE the ORF from this neighbor\n"
3939 "Capability to SEND the ORF to this neighbor\n")
3941 DEFUN (no_neighbor_capability_orf_prefix
,
3942 no_neighbor_capability_orf_prefix_cmd
,
3943 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3947 "Advertise capability to the peer\n"
3948 "Advertise ORF capability to the peer\n"
3949 "Advertise prefixlist ORF capability to this neighbor\n"
3950 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3951 "Capability to RECEIVE the ORF from this neighbor\n"
3952 "Capability to SEND the ORF to this neighbor\n")
3955 int idx_send_recv
= 6;
3958 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3959 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3960 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3961 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3962 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3963 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3965 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3966 return CMD_WARNING_CONFIG_FAILED
;
3969 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3970 bgp_node_afi(vty
), bgp_node_safi(vty
),
3975 no_neighbor_capability_orf_prefix
,
3976 no_neighbor_capability_orf_prefix_hidden_cmd
,
3977 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3978 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3979 "Advertise capability to the peer\n"
3980 "Advertise ORF capability to the peer\n"
3981 "Advertise prefixlist ORF capability to this neighbor\n"
3982 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3983 "Capability to RECEIVE the ORF from this neighbor\n"
3984 "Capability to SEND the ORF to this neighbor\n")
3986 /* neighbor next-hop-self. */
3987 DEFUN (neighbor_nexthop_self
,
3988 neighbor_nexthop_self_cmd
,
3989 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3992 "Disable the next hop calculation for this neighbor\n")
3995 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3996 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3999 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
4000 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4001 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4002 "Disable the next hop calculation for this neighbor\n")
4004 /* neighbor next-hop-self. */
4005 DEFUN (neighbor_nexthop_self_force
,
4006 neighbor_nexthop_self_force_cmd
,
4007 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4010 "Disable the next hop calculation for this neighbor\n"
4011 "Set the next hop to self for reflected routes\n")
4014 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4016 PEER_FLAG_FORCE_NEXTHOP_SELF
);
4019 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
4020 neighbor_nexthop_self_force_hidden_cmd
,
4021 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4022 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4023 "Disable the next hop calculation for this neighbor\n"
4024 "Set the next hop to self for reflected routes\n")
4026 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
4027 neighbor_nexthop_self_all_hidden_cmd
,
4028 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
4029 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4030 "Disable the next hop calculation for this neighbor\n"
4031 "Set the next hop to self for reflected routes\n")
4033 DEFUN (no_neighbor_nexthop_self
,
4034 no_neighbor_nexthop_self_cmd
,
4035 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4039 "Disable the next hop calculation for this neighbor\n")
4042 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4043 bgp_node_afi(vty
), bgp_node_safi(vty
),
4044 PEER_FLAG_NEXTHOP_SELF
);
4047 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
4048 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4049 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4050 "Disable the next hop calculation for this neighbor\n")
4052 DEFUN (no_neighbor_nexthop_self_force
,
4053 no_neighbor_nexthop_self_force_cmd
,
4054 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4058 "Disable the next hop calculation for this neighbor\n"
4059 "Set the next hop to self for reflected routes\n")
4062 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4063 bgp_node_afi(vty
), bgp_node_safi(vty
),
4064 PEER_FLAG_FORCE_NEXTHOP_SELF
);
4067 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4068 no_neighbor_nexthop_self_force_hidden_cmd
,
4069 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4070 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4071 "Disable the next hop calculation for this neighbor\n"
4072 "Set the next hop to self for reflected routes\n")
4074 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4075 no_neighbor_nexthop_self_all_hidden_cmd
,
4076 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
4077 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4078 "Disable the next hop calculation for this neighbor\n"
4079 "Set the next hop to self for reflected routes\n")
4081 /* neighbor as-override */
4082 DEFUN (neighbor_as_override
,
4083 neighbor_as_override_cmd
,
4084 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4087 "Override ASNs in outbound updates if aspath equals remote-as\n")
4090 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4091 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
4094 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
4095 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4096 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4097 "Override ASNs in outbound updates if aspath equals remote-as\n")
4099 DEFUN (no_neighbor_as_override
,
4100 no_neighbor_as_override_cmd
,
4101 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4105 "Override ASNs in outbound updates if aspath equals remote-as\n")
4108 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4109 bgp_node_afi(vty
), bgp_node_safi(vty
),
4110 PEER_FLAG_AS_OVERRIDE
);
4113 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
4114 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4115 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4116 "Override ASNs in outbound updates if aspath equals remote-as\n")
4118 /* neighbor remove-private-AS. */
4119 DEFUN (neighbor_remove_private_as
,
4120 neighbor_remove_private_as_cmd
,
4121 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4124 "Remove private ASNs in outbound updates\n")
4127 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4129 PEER_FLAG_REMOVE_PRIVATE_AS
);
4132 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
4133 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4134 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4135 "Remove private ASNs in outbound updates\n")
4137 DEFUN (neighbor_remove_private_as_all
,
4138 neighbor_remove_private_as_all_cmd
,
4139 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4142 "Remove private ASNs in outbound updates\n"
4143 "Apply to all AS numbers\n")
4146 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4148 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4151 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
4152 neighbor_remove_private_as_all_hidden_cmd
,
4153 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4154 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4155 "Remove private ASNs in outbound updates\n"
4156 "Apply to all AS numbers")
4158 DEFUN (neighbor_remove_private_as_replace_as
,
4159 neighbor_remove_private_as_replace_as_cmd
,
4160 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4163 "Remove private ASNs in outbound updates\n"
4164 "Replace private ASNs with our ASN in outbound updates\n")
4167 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4169 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4172 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
4173 neighbor_remove_private_as_replace_as_hidden_cmd
,
4174 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4175 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4176 "Remove private ASNs in outbound updates\n"
4177 "Replace private ASNs with our ASN in outbound updates\n")
4179 DEFUN (neighbor_remove_private_as_all_replace_as
,
4180 neighbor_remove_private_as_all_replace_as_cmd
,
4181 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4184 "Remove private ASNs in outbound updates\n"
4185 "Apply to all AS numbers\n"
4186 "Replace private ASNs with our ASN in outbound updates\n")
4189 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4191 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4195 neighbor_remove_private_as_all_replace_as
,
4196 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4197 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4198 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4199 "Remove private ASNs in outbound updates\n"
4200 "Apply to all AS numbers\n"
4201 "Replace private ASNs with our ASN in outbound updates\n")
4203 DEFUN (no_neighbor_remove_private_as
,
4204 no_neighbor_remove_private_as_cmd
,
4205 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4209 "Remove private ASNs in outbound updates\n")
4212 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4213 bgp_node_afi(vty
), bgp_node_safi(vty
),
4214 PEER_FLAG_REMOVE_PRIVATE_AS
);
4217 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4218 no_neighbor_remove_private_as_hidden_cmd
,
4219 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4220 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4221 "Remove private ASNs in outbound updates\n")
4223 DEFUN (no_neighbor_remove_private_as_all
,
4224 no_neighbor_remove_private_as_all_cmd
,
4225 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4229 "Remove private ASNs in outbound updates\n"
4230 "Apply to all AS numbers\n")
4233 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4234 bgp_node_afi(vty
), bgp_node_safi(vty
),
4235 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4238 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4239 no_neighbor_remove_private_as_all_hidden_cmd
,
4240 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4241 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4242 "Remove private ASNs in outbound updates\n"
4243 "Apply to all AS numbers\n")
4245 DEFUN (no_neighbor_remove_private_as_replace_as
,
4246 no_neighbor_remove_private_as_replace_as_cmd
,
4247 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4251 "Remove private ASNs in outbound updates\n"
4252 "Replace private ASNs with our ASN in outbound updates\n")
4255 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4256 bgp_node_afi(vty
), bgp_node_safi(vty
),
4257 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4260 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4261 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4262 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4263 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4264 "Remove private ASNs in outbound updates\n"
4265 "Replace private ASNs with our ASN in outbound updates\n")
4267 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4268 no_neighbor_remove_private_as_all_replace_as_cmd
,
4269 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4273 "Remove private ASNs in outbound updates\n"
4274 "Apply to all AS numbers\n"
4275 "Replace private ASNs with our ASN in outbound updates\n")
4278 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4279 bgp_node_afi(vty
), bgp_node_safi(vty
),
4280 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4284 no_neighbor_remove_private_as_all_replace_as
,
4285 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4286 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4287 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4288 "Remove private ASNs in outbound updates\n"
4289 "Apply to all AS numbers\n"
4290 "Replace private ASNs with our ASN in outbound updates\n")
4293 /* neighbor send-community. */
4294 DEFUN (neighbor_send_community
,
4295 neighbor_send_community_cmd
,
4296 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4299 "Send Community attribute to this neighbor\n")
4303 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4305 PEER_FLAG_SEND_COMMUNITY
);
4308 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4309 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4310 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4311 "Send Community attribute to this neighbor\n")
4313 DEFUN (no_neighbor_send_community
,
4314 no_neighbor_send_community_cmd
,
4315 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4319 "Send Community attribute to this neighbor\n")
4323 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4324 bgp_node_afi(vty
), bgp_node_safi(vty
),
4325 PEER_FLAG_SEND_COMMUNITY
);
4328 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4329 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4330 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4331 "Send Community attribute to this neighbor\n")
4333 /* neighbor send-community extended. */
4334 DEFUN (neighbor_send_community_type
,
4335 neighbor_send_community_type_cmd
,
4336 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4339 "Send Community attribute to this neighbor\n"
4340 "Send Standard and Extended Community attributes\n"
4341 "Send Standard, Large and Extended Community attributes\n"
4342 "Send Extended Community attributes\n"
4343 "Send Standard Community attributes\n"
4344 "Send Large Community attributes\n")
4348 const char *type
= argv
[argc
- 1]->text
;
4350 if (strmatch(type
, "standard")) {
4351 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4352 } else if (strmatch(type
, "extended")) {
4353 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4354 } else if (strmatch(type
, "large")) {
4355 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4356 } else if (strmatch(type
, "both")) {
4357 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4358 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4359 } else { /* if (strmatch(type, "all")) */
4360 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4361 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4362 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4365 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4366 bgp_node_safi(vty
), flag
);
4370 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4371 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4372 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4373 "Send Community attribute to this neighbor\n"
4374 "Send Standard and Extended Community attributes\n"
4375 "Send Standard, Large and Extended Community attributes\n"
4376 "Send Extended Community attributes\n"
4377 "Send Standard Community attributes\n"
4378 "Send Large Community attributes\n")
4380 DEFUN (no_neighbor_send_community_type
,
4381 no_neighbor_send_community_type_cmd
,
4382 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4386 "Send Community attribute to this neighbor\n"
4387 "Send Standard and Extended Community attributes\n"
4388 "Send Standard, Large and Extended Community attributes\n"
4389 "Send Extended Community attributes\n"
4390 "Send Standard Community attributes\n"
4391 "Send Large Community attributes\n")
4395 const char *type
= argv
[argc
- 1]->text
;
4397 if (strmatch(type
, "standard")) {
4398 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4399 } else if (strmatch(type
, "extended")) {
4400 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4401 } else if (strmatch(type
, "large")) {
4402 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4403 } else if (strmatch(type
, "both")) {
4404 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4405 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4406 } else { /* if (strmatch(type, "all")) */
4407 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4408 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4409 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4412 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4413 bgp_node_afi(vty
), bgp_node_safi(vty
),
4418 no_neighbor_send_community_type
,
4419 no_neighbor_send_community_type_hidden_cmd
,
4420 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4421 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4422 "Send Community attribute to this neighbor\n"
4423 "Send Standard and Extended Community attributes\n"
4424 "Send Standard, Large and Extended Community attributes\n"
4425 "Send Extended Community attributes\n"
4426 "Send Standard Community attributes\n"
4427 "Send Large Community attributes\n")
4429 /* neighbor soft-reconfig. */
4430 DEFUN (neighbor_soft_reconfiguration
,
4431 neighbor_soft_reconfiguration_cmd
,
4432 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4435 "Per neighbor soft reconfiguration\n"
4436 "Allow inbound soft reconfiguration for this neighbor\n")
4439 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4441 PEER_FLAG_SOFT_RECONFIG
);
4444 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4445 neighbor_soft_reconfiguration_hidden_cmd
,
4446 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4447 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4448 "Per neighbor soft reconfiguration\n"
4449 "Allow inbound soft reconfiguration for this neighbor\n")
4451 DEFUN (no_neighbor_soft_reconfiguration
,
4452 no_neighbor_soft_reconfiguration_cmd
,
4453 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4457 "Per neighbor soft reconfiguration\n"
4458 "Allow inbound soft reconfiguration for this neighbor\n")
4461 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4462 bgp_node_afi(vty
), bgp_node_safi(vty
),
4463 PEER_FLAG_SOFT_RECONFIG
);
4466 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4467 no_neighbor_soft_reconfiguration_hidden_cmd
,
4468 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4469 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4470 "Per neighbor soft reconfiguration\n"
4471 "Allow inbound soft reconfiguration for this neighbor\n")
4473 DEFUN (neighbor_route_reflector_client
,
4474 neighbor_route_reflector_client_cmd
,
4475 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4478 "Configure a neighbor as Route Reflector client\n")
4484 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4486 return CMD_WARNING_CONFIG_FAILED
;
4488 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4490 PEER_FLAG_REFLECTOR_CLIENT
);
4493 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4494 neighbor_route_reflector_client_hidden_cmd
,
4495 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4496 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4497 "Configure a neighbor as Route Reflector client\n")
4499 DEFUN (no_neighbor_route_reflector_client
,
4500 no_neighbor_route_reflector_client_cmd
,
4501 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4505 "Configure a neighbor as Route Reflector client\n")
4508 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4509 bgp_node_afi(vty
), bgp_node_safi(vty
),
4510 PEER_FLAG_REFLECTOR_CLIENT
);
4513 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4514 no_neighbor_route_reflector_client_hidden_cmd
,
4515 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4516 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4517 "Configure a neighbor as Route Reflector client\n")
4519 /* neighbor route-server-client. */
4520 DEFUN (neighbor_route_server_client
,
4521 neighbor_route_server_client_cmd
,
4522 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4525 "Configure a neighbor as Route Server client\n")
4530 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4532 return CMD_WARNING_CONFIG_FAILED
;
4533 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4535 PEER_FLAG_RSERVER_CLIENT
);
4538 ALIAS_HIDDEN(neighbor_route_server_client
,
4539 neighbor_route_server_client_hidden_cmd
,
4540 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4541 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4542 "Configure a neighbor as Route Server client\n")
4544 DEFUN (no_neighbor_route_server_client
,
4545 no_neighbor_route_server_client_cmd
,
4546 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4550 "Configure a neighbor as Route Server client\n")
4553 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4554 bgp_node_afi(vty
), bgp_node_safi(vty
),
4555 PEER_FLAG_RSERVER_CLIENT
);
4558 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4559 no_neighbor_route_server_client_hidden_cmd
,
4560 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4561 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4562 "Configure a neighbor as Route Server client\n")
4564 DEFUN (neighbor_nexthop_local_unchanged
,
4565 neighbor_nexthop_local_unchanged_cmd
,
4566 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4569 "Configure treatment of outgoing link-local nexthop attribute\n"
4570 "Leave link-local nexthop unchanged for this peer\n")
4573 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4575 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4578 DEFUN (no_neighbor_nexthop_local_unchanged
,
4579 no_neighbor_nexthop_local_unchanged_cmd
,
4580 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4584 "Configure treatment of outgoing link-local-nexthop attribute\n"
4585 "Leave link-local nexthop unchanged for this peer\n")
4588 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4589 bgp_node_afi(vty
), bgp_node_safi(vty
),
4590 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4593 DEFUN (neighbor_attr_unchanged
,
4594 neighbor_attr_unchanged_cmd
,
4595 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4598 "BGP attribute is propagated unchanged to this neighbor\n"
4599 "As-path attribute\n"
4600 "Nexthop attribute\n"
4604 char *peer_str
= argv
[1]->arg
;
4607 afi_t afi
= bgp_node_afi(vty
);
4608 safi_t safi
= bgp_node_safi(vty
);
4610 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4612 return CMD_WARNING_CONFIG_FAILED
;
4614 if (argv_find(argv
, argc
, "as-path", &idx
))
4615 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4617 if (argv_find(argv
, argc
, "next-hop", &idx
))
4618 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4620 if (argv_find(argv
, argc
, "med", &idx
))
4621 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4623 /* no flags means all of them! */
4625 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4626 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4627 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4629 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4630 && peer_af_flag_check(peer
, afi
, safi
,
4631 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4632 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4633 PEER_FLAG_AS_PATH_UNCHANGED
);
4636 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4637 && peer_af_flag_check(peer
, afi
, safi
,
4638 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4639 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4640 PEER_FLAG_NEXTHOP_UNCHANGED
);
4643 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4644 && peer_af_flag_check(peer
, afi
, safi
,
4645 PEER_FLAG_MED_UNCHANGED
)) {
4646 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4647 PEER_FLAG_MED_UNCHANGED
);
4651 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4655 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4656 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4657 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4658 "BGP attribute is propagated unchanged to this neighbor\n"
4659 "As-path attribute\n"
4660 "Nexthop attribute\n"
4663 DEFUN (no_neighbor_attr_unchanged
,
4664 no_neighbor_attr_unchanged_cmd
,
4665 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4669 "BGP attribute is propagated unchanged to this neighbor\n"
4670 "As-path attribute\n"
4671 "Nexthop attribute\n"
4675 char *peer
= argv
[2]->arg
;
4678 if (argv_find(argv
, argc
, "as-path", &idx
))
4679 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4681 if (argv_find(argv
, argc
, "next-hop", &idx
))
4682 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4684 if (argv_find(argv
, argc
, "med", &idx
))
4685 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4687 if (!flags
) // no flags means all of them!
4689 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4690 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4691 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4694 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4695 bgp_node_safi(vty
), flags
);
4699 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4700 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4701 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4702 "BGP attribute is propagated unchanged to this neighbor\n"
4703 "As-path attribute\n"
4704 "Nexthop attribute\n"
4707 /* EBGP multihop configuration. */
4708 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4709 const char *ttl_str
)
4714 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4716 return CMD_WARNING_CONFIG_FAILED
;
4719 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4724 ttl
= strtoul(ttl_str
, NULL
, 10);
4726 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4729 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4733 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4735 return CMD_WARNING_CONFIG_FAILED
;
4737 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4740 /* neighbor ebgp-multihop. */
4741 DEFUN (neighbor_ebgp_multihop
,
4742 neighbor_ebgp_multihop_cmd
,
4743 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4746 "Allow EBGP neighbors not on directly connected networks\n")
4749 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4752 DEFUN (neighbor_ebgp_multihop_ttl
,
4753 neighbor_ebgp_multihop_ttl_cmd
,
4754 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4757 "Allow EBGP neighbors not on directly connected networks\n"
4758 "maximum hop count\n")
4762 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4763 argv
[idx_number
]->arg
);
4766 DEFUN (no_neighbor_ebgp_multihop
,
4767 no_neighbor_ebgp_multihop_cmd
,
4768 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4772 "Allow EBGP neighbors not on directly connected networks\n"
4773 "maximum hop count\n")
4776 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4780 /* disable-connected-check */
4781 DEFUN (neighbor_disable_connected_check
,
4782 neighbor_disable_connected_check_cmd
,
4783 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4786 "one-hop away EBGP peer using loopback address\n"
4787 "Enforce EBGP neighbors perform multihop\n")
4790 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4791 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4794 DEFUN (no_neighbor_disable_connected_check
,
4795 no_neighbor_disable_connected_check_cmd
,
4796 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4800 "one-hop away EBGP peer using loopback address\n"
4801 "Enforce EBGP neighbors perform multihop\n")
4804 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4805 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4809 /* enforce-first-as */
4810 DEFUN (neighbor_enforce_first_as
,
4811 neighbor_enforce_first_as_cmd
,
4812 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4815 "Enforce the first AS for EBGP routes\n")
4819 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4820 PEER_FLAG_ENFORCE_FIRST_AS
);
4823 DEFUN (no_neighbor_enforce_first_as
,
4824 no_neighbor_enforce_first_as_cmd
,
4825 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4829 "Enforce the first AS for EBGP routes\n")
4833 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4834 PEER_FLAG_ENFORCE_FIRST_AS
);
4838 DEFUN (neighbor_description
,
4839 neighbor_description_cmd
,
4840 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4843 "Neighbor specific description\n"
4844 "Up to 80 characters describing this neighbor\n")
4851 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4853 return CMD_WARNING_CONFIG_FAILED
;
4855 str
= argv_concat(argv
, argc
, idx_line
);
4857 peer_description_set(peer
, str
);
4859 XFREE(MTYPE_TMP
, str
);
4864 DEFUN (no_neighbor_description
,
4865 no_neighbor_description_cmd
,
4866 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4870 "Neighbor specific description\n")
4875 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4877 return CMD_WARNING_CONFIG_FAILED
;
4879 peer_description_unset(peer
);
4884 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4885 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4886 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4887 "Neighbor specific description\n"
4888 "Up to 80 characters describing this neighbor\n")
4890 /* Neighbor update-source. */
4891 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4892 const char *source_str
)
4898 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4900 return CMD_WARNING_CONFIG_FAILED
;
4906 if (str2sockunion(source_str
, &su
) == 0)
4907 peer_update_source_addr_set(peer
, &su
);
4909 if (str2prefix(source_str
, &p
)) {
4911 "%% Invalid update-source, remove prefix length \n");
4912 return CMD_WARNING_CONFIG_FAILED
;
4914 peer_update_source_if_set(peer
, source_str
);
4917 peer_update_source_unset(peer
);
4922 #define BGP_UPDATE_SOURCE_HELP_STR \
4925 "Interface name (requires zebra to be running)\n"
4927 DEFUN (neighbor_update_source
,
4928 neighbor_update_source_cmd
,
4929 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4932 "Source of routing updates\n"
4933 BGP_UPDATE_SOURCE_HELP_STR
)
4937 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4938 argv
[idx_peer_2
]->arg
);
4941 DEFUN (no_neighbor_update_source
,
4942 no_neighbor_update_source_cmd
,
4943 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4947 "Source of routing updates\n"
4948 BGP_UPDATE_SOURCE_HELP_STR
)
4951 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4954 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4955 afi_t afi
, safi_t safi
,
4956 const char *rmap
, int set
)
4960 struct route_map
*route_map
= NULL
;
4962 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4964 return CMD_WARNING_CONFIG_FAILED
;
4968 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
4969 ret
= peer_default_originate_set(peer
, afi
, safi
,
4972 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4974 return bgp_vty_return(vty
, ret
);
4977 /* neighbor default-originate. */
4978 DEFUN (neighbor_default_originate
,
4979 neighbor_default_originate_cmd
,
4980 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4983 "Originate default route to this neighbor\n")
4986 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4988 bgp_node_safi(vty
), NULL
, 1);
4991 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4992 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4993 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4994 "Originate default route to this neighbor\n")
4996 DEFUN (neighbor_default_originate_rmap
,
4997 neighbor_default_originate_rmap_cmd
,
4998 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
5001 "Originate default route to this neighbor\n"
5002 "Route-map to specify criteria to originate default\n"
5007 return peer_default_originate_set_vty(
5008 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5009 argv
[idx_word
]->arg
, 1);
5013 neighbor_default_originate_rmap
,
5014 neighbor_default_originate_rmap_hidden_cmd
,
5015 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
5016 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5017 "Originate default route to this neighbor\n"
5018 "Route-map to specify criteria to originate default\n"
5021 DEFUN (no_neighbor_default_originate
,
5022 no_neighbor_default_originate_cmd
,
5023 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
5027 "Originate default route to this neighbor\n"
5028 "Route-map to specify criteria to originate default\n"
5032 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
5034 bgp_node_safi(vty
), NULL
, 0);
5038 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
5039 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
5040 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5041 "Originate default route to this neighbor\n"
5042 "Route-map to specify criteria to originate default\n"
5046 /* Set neighbor's BGP port. */
5047 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
5048 const char *port_str
)
5054 peer
= peer_lookup_vty(vty
, ip_str
);
5056 return CMD_WARNING_CONFIG_FAILED
;
5059 sp
= getservbyname("bgp", "tcp");
5060 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
5062 port
= strtoul(port_str
, NULL
, 10);
5065 peer_port_set(peer
, port
);
5070 /* Set specified peer's BGP port. */
5071 DEFUN (neighbor_port
,
5073 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
5076 "Neighbor's BGP port\n"
5077 "TCP port number\n")
5081 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
5082 argv
[idx_number
]->arg
);
5085 DEFUN (no_neighbor_port
,
5086 no_neighbor_port_cmd
,
5087 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
5091 "Neighbor's BGP port\n"
5092 "TCP port number\n")
5095 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
5099 /* neighbor weight. */
5100 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5101 safi_t safi
, const char *weight_str
)
5105 unsigned long weight
;
5107 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5109 return CMD_WARNING_CONFIG_FAILED
;
5111 weight
= strtoul(weight_str
, NULL
, 10);
5113 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
5114 return bgp_vty_return(vty
, ret
);
5117 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5123 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5125 return CMD_WARNING_CONFIG_FAILED
;
5127 ret
= peer_weight_unset(peer
, afi
, safi
);
5128 return bgp_vty_return(vty
, ret
);
5131 DEFUN (neighbor_weight
,
5132 neighbor_weight_cmd
,
5133 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5136 "Set default weight for routes from this neighbor\n"
5141 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5142 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
5145 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
5146 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5147 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5148 "Set default weight for routes from this neighbor\n"
5151 DEFUN (no_neighbor_weight
,
5152 no_neighbor_weight_cmd
,
5153 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5157 "Set default weight for routes from this neighbor\n"
5161 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
5162 bgp_node_afi(vty
), bgp_node_safi(vty
));
5165 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
5166 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5167 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5168 "Set default weight for routes from this neighbor\n"
5172 /* Override capability negotiation. */
5173 DEFUN (neighbor_override_capability
,
5174 neighbor_override_capability_cmd
,
5175 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5178 "Override capability negotiation result\n")
5181 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5182 PEER_FLAG_OVERRIDE_CAPABILITY
);
5185 DEFUN (no_neighbor_override_capability
,
5186 no_neighbor_override_capability_cmd
,
5187 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5191 "Override capability negotiation result\n")
5194 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5195 PEER_FLAG_OVERRIDE_CAPABILITY
);
5198 DEFUN (neighbor_strict_capability
,
5199 neighbor_strict_capability_cmd
,
5200 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5203 "Strict capability negotiation match\n")
5207 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5208 PEER_FLAG_STRICT_CAP_MATCH
);
5211 DEFUN (no_neighbor_strict_capability
,
5212 no_neighbor_strict_capability_cmd
,
5213 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5217 "Strict capability negotiation match\n")
5221 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5222 PEER_FLAG_STRICT_CAP_MATCH
);
5225 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5226 const char *keep_str
, const char *hold_str
)
5233 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5235 return CMD_WARNING_CONFIG_FAILED
;
5237 keepalive
= strtoul(keep_str
, NULL
, 10);
5238 holdtime
= strtoul(hold_str
, NULL
, 10);
5240 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5242 return bgp_vty_return(vty
, ret
);
5245 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5250 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5252 return CMD_WARNING_CONFIG_FAILED
;
5254 ret
= peer_timers_unset(peer
);
5256 return bgp_vty_return(vty
, ret
);
5259 DEFUN (neighbor_timers
,
5260 neighbor_timers_cmd
,
5261 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5264 "BGP per neighbor timers\n"
5265 "Keepalive interval\n"
5270 int idx_number_2
= 4;
5271 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5272 argv
[idx_number
]->arg
,
5273 argv
[idx_number_2
]->arg
);
5276 DEFUN (no_neighbor_timers
,
5277 no_neighbor_timers_cmd
,
5278 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5282 "BGP per neighbor timers\n"
5283 "Keepalive interval\n"
5287 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5291 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5292 const char *time_str
)
5298 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5300 return CMD_WARNING_CONFIG_FAILED
;
5302 connect
= strtoul(time_str
, NULL
, 10);
5304 ret
= peer_timers_connect_set(peer
, connect
);
5306 return bgp_vty_return(vty
, ret
);
5309 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5314 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5316 return CMD_WARNING_CONFIG_FAILED
;
5318 ret
= peer_timers_connect_unset(peer
);
5320 return bgp_vty_return(vty
, ret
);
5323 DEFUN (neighbor_timers_connect
,
5324 neighbor_timers_connect_cmd
,
5325 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5328 "BGP per neighbor timers\n"
5329 "BGP connect timer\n"
5334 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5335 argv
[idx_number
]->arg
);
5338 DEFUN (no_neighbor_timers_connect
,
5339 no_neighbor_timers_connect_cmd
,
5340 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5344 "BGP per neighbor timers\n"
5345 "BGP connect timer\n"
5349 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5353 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5354 const char *time_str
, int set
)
5358 uint32_t routeadv
= 0;
5360 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5362 return CMD_WARNING_CONFIG_FAILED
;
5365 routeadv
= strtoul(time_str
, NULL
, 10);
5368 ret
= peer_advertise_interval_set(peer
, routeadv
);
5370 ret
= peer_advertise_interval_unset(peer
);
5372 return bgp_vty_return(vty
, ret
);
5375 DEFUN (neighbor_advertise_interval
,
5376 neighbor_advertise_interval_cmd
,
5377 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5380 "Minimum interval between sending BGP routing updates\n"
5381 "time in seconds\n")
5385 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5386 argv
[idx_number
]->arg
, 1);
5389 DEFUN (no_neighbor_advertise_interval
,
5390 no_neighbor_advertise_interval_cmd
,
5391 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5395 "Minimum interval between sending BGP routing updates\n"
5396 "time in seconds\n")
5399 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5403 /* Time to wait before processing route-map updates */
5404 DEFUN (bgp_set_route_map_delay_timer
,
5405 bgp_set_route_map_delay_timer_cmd
,
5406 "bgp route-map delay-timer (0-600)",
5408 "BGP route-map delay timer\n"
5409 "Time in secs to wait before processing route-map changes\n"
5410 "0 disables the timer, no route updates happen when route-maps change\n")
5413 uint32_t rmap_delay_timer
;
5415 if (argv
[idx_number
]->arg
) {
5416 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5417 bm
->rmap_update_timer
= rmap_delay_timer
;
5419 /* if the dynamic update handling is being disabled, and a timer
5421 * running, stop the timer and act as if the timer has already
5424 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5425 BGP_TIMER_OFF(bm
->t_rmap_update
);
5426 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5431 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5432 return CMD_WARNING_CONFIG_FAILED
;
5436 DEFUN (no_bgp_set_route_map_delay_timer
,
5437 no_bgp_set_route_map_delay_timer_cmd
,
5438 "no bgp route-map delay-timer [(0-600)]",
5441 "Default BGP route-map delay timer\n"
5442 "Reset to default time to wait for processing route-map changes\n"
5443 "0 disables the timer, no route updates happen when route-maps change\n")
5446 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5452 /* neighbor interface */
5453 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5458 peer
= peer_lookup_vty(vty
, ip_str
);
5459 if (!peer
|| peer
->conf_if
) {
5460 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5461 return CMD_WARNING_CONFIG_FAILED
;
5465 peer_interface_set(peer
, str
);
5467 peer_interface_unset(peer
);
5472 DEFUN (neighbor_interface
,
5473 neighbor_interface_cmd
,
5474 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5482 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5485 DEFUN (no_neighbor_interface
,
5486 no_neighbor_interface_cmd
,
5487 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5495 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5498 DEFUN (neighbor_distribute_list
,
5499 neighbor_distribute_list_cmd
,
5500 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5503 "Filter updates to/from this neighbor\n"
5504 "IP access-list number\n"
5505 "IP access-list number (expanded range)\n"
5506 "IP Access-list name\n"
5507 "Filter incoming updates\n"
5508 "Filter outgoing updates\n")
5515 const char *pstr
= argv
[idx_peer
]->arg
;
5516 const char *acl
= argv
[idx_acl
]->arg
;
5517 const char *inout
= argv
[argc
- 1]->text
;
5519 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5521 return CMD_WARNING_CONFIG_FAILED
;
5523 /* Check filter direction. */
5524 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5525 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5528 return bgp_vty_return(vty
, ret
);
5532 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5533 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5534 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5535 "Filter updates to/from this neighbor\n"
5536 "IP access-list number\n"
5537 "IP access-list number (expanded range)\n"
5538 "IP Access-list name\n"
5539 "Filter incoming updates\n"
5540 "Filter outgoing updates\n")
5542 DEFUN (no_neighbor_distribute_list
,
5543 no_neighbor_distribute_list_cmd
,
5544 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5548 "Filter updates to/from this neighbor\n"
5549 "IP access-list number\n"
5550 "IP access-list number (expanded range)\n"
5551 "IP Access-list name\n"
5552 "Filter incoming updates\n"
5553 "Filter outgoing updates\n")
5559 const char *pstr
= argv
[idx_peer
]->arg
;
5560 const char *inout
= argv
[argc
- 1]->text
;
5562 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5564 return CMD_WARNING_CONFIG_FAILED
;
5566 /* Check filter direction. */
5567 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5568 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5571 return bgp_vty_return(vty
, ret
);
5575 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5576 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5577 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5578 "Filter updates to/from this neighbor\n"
5579 "IP access-list number\n"
5580 "IP access-list number (expanded range)\n"
5581 "IP Access-list name\n"
5582 "Filter incoming updates\n"
5583 "Filter outgoing updates\n")
5585 /* Set prefix list to the peer. */
5586 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5587 afi_t afi
, safi_t safi
,
5588 const char *name_str
,
5589 const char *direct_str
)
5592 int direct
= FILTER_IN
;
5595 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5597 return CMD_WARNING_CONFIG_FAILED
;
5599 /* Check filter direction. */
5600 if (strncmp(direct_str
, "i", 1) == 0)
5602 else if (strncmp(direct_str
, "o", 1) == 0)
5603 direct
= FILTER_OUT
;
5605 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5607 return bgp_vty_return(vty
, ret
);
5610 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5611 afi_t afi
, safi_t safi
,
5612 const char *direct_str
)
5616 int direct
= FILTER_IN
;
5618 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5620 return CMD_WARNING_CONFIG_FAILED
;
5622 /* Check filter direction. */
5623 if (strncmp(direct_str
, "i", 1) == 0)
5625 else if (strncmp(direct_str
, "o", 1) == 0)
5626 direct
= FILTER_OUT
;
5628 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5630 return bgp_vty_return(vty
, ret
);
5633 DEFUN (neighbor_prefix_list
,
5634 neighbor_prefix_list_cmd
,
5635 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5638 "Filter updates to/from this neighbor\n"
5639 "Name of a prefix list\n"
5640 "Filter incoming updates\n"
5641 "Filter outgoing updates\n")
5646 return peer_prefix_list_set_vty(
5647 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5648 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5651 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5652 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5653 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5654 "Filter updates to/from this neighbor\n"
5655 "Name of a prefix list\n"
5656 "Filter incoming updates\n"
5657 "Filter outgoing updates\n")
5659 DEFUN (no_neighbor_prefix_list
,
5660 no_neighbor_prefix_list_cmd
,
5661 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5665 "Filter updates to/from this neighbor\n"
5666 "Name of a prefix list\n"
5667 "Filter incoming updates\n"
5668 "Filter outgoing updates\n")
5672 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5673 bgp_node_afi(vty
), bgp_node_safi(vty
),
5674 argv
[idx_in_out
]->arg
);
5677 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5678 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5679 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5680 "Filter updates to/from this neighbor\n"
5681 "Name of a prefix list\n"
5682 "Filter incoming updates\n"
5683 "Filter outgoing updates\n")
5685 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5686 safi_t safi
, const char *name_str
,
5687 const char *direct_str
)
5691 int direct
= FILTER_IN
;
5693 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5695 return CMD_WARNING_CONFIG_FAILED
;
5697 /* Check filter direction. */
5698 if (strncmp(direct_str
, "i", 1) == 0)
5700 else if (strncmp(direct_str
, "o", 1) == 0)
5701 direct
= FILTER_OUT
;
5703 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5705 return bgp_vty_return(vty
, ret
);
5708 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5709 safi_t safi
, const char *direct_str
)
5713 int direct
= FILTER_IN
;
5715 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5717 return CMD_WARNING_CONFIG_FAILED
;
5719 /* Check filter direction. */
5720 if (strncmp(direct_str
, "i", 1) == 0)
5722 else if (strncmp(direct_str
, "o", 1) == 0)
5723 direct
= FILTER_OUT
;
5725 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5727 return bgp_vty_return(vty
, ret
);
5730 DEFUN (neighbor_filter_list
,
5731 neighbor_filter_list_cmd
,
5732 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5735 "Establish BGP filters\n"
5736 "AS path access-list name\n"
5737 "Filter incoming routes\n"
5738 "Filter outgoing routes\n")
5743 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5744 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5745 argv
[idx_in_out
]->arg
);
5748 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5749 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5750 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5751 "Establish BGP filters\n"
5752 "AS path access-list name\n"
5753 "Filter incoming routes\n"
5754 "Filter outgoing routes\n")
5756 DEFUN (no_neighbor_filter_list
,
5757 no_neighbor_filter_list_cmd
,
5758 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5762 "Establish BGP filters\n"
5763 "AS path access-list name\n"
5764 "Filter incoming routes\n"
5765 "Filter outgoing routes\n")
5769 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5770 bgp_node_afi(vty
), bgp_node_safi(vty
),
5771 argv
[idx_in_out
]->arg
);
5774 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5775 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5776 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5777 "Establish BGP filters\n"
5778 "AS path access-list name\n"
5779 "Filter incoming routes\n"
5780 "Filter outgoing routes\n")
5782 /* Set route-map to the peer. */
5783 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5784 afi_t afi
, safi_t safi
, const char *name_str
,
5785 const char *direct_str
)
5789 int direct
= RMAP_IN
;
5790 struct route_map
*route_map
;
5792 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5794 return CMD_WARNING_CONFIG_FAILED
;
5796 /* Check filter direction. */
5797 if (strncmp(direct_str
, "in", 2) == 0)
5799 else if (strncmp(direct_str
, "o", 1) == 0)
5802 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5803 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
5805 return bgp_vty_return(vty
, ret
);
5808 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5809 afi_t afi
, safi_t safi
,
5810 const char *direct_str
)
5814 int direct
= RMAP_IN
;
5816 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5818 return CMD_WARNING_CONFIG_FAILED
;
5820 /* Check filter direction. */
5821 if (strncmp(direct_str
, "in", 2) == 0)
5823 else if (strncmp(direct_str
, "o", 1) == 0)
5826 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5828 return bgp_vty_return(vty
, ret
);
5831 DEFUN (neighbor_route_map
,
5832 neighbor_route_map_cmd
,
5833 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5836 "Apply route map to neighbor\n"
5837 "Name of route map\n"
5838 "Apply map to incoming routes\n"
5839 "Apply map to outbound routes\n")
5844 return peer_route_map_set_vty(
5845 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5846 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5849 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5850 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5851 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5852 "Apply route map to neighbor\n"
5853 "Name of route map\n"
5854 "Apply map to incoming routes\n"
5855 "Apply map to outbound routes\n")
5857 DEFUN (no_neighbor_route_map
,
5858 no_neighbor_route_map_cmd
,
5859 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5863 "Apply route map to neighbor\n"
5864 "Name of route map\n"
5865 "Apply map to incoming routes\n"
5866 "Apply map to outbound routes\n")
5870 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5871 bgp_node_afi(vty
), bgp_node_safi(vty
),
5872 argv
[idx_in_out
]->arg
);
5875 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5876 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5877 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5878 "Apply route map to neighbor\n"
5879 "Name of route map\n"
5880 "Apply map to incoming routes\n"
5881 "Apply map to outbound routes\n")
5883 /* Set unsuppress-map to the peer. */
5884 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5885 afi_t afi
, safi_t safi
,
5886 const char *name_str
)
5890 struct route_map
*route_map
;
5892 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5894 return CMD_WARNING_CONFIG_FAILED
;
5896 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5897 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
5899 return bgp_vty_return(vty
, ret
);
5902 /* Unset route-map from the peer. */
5903 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5904 afi_t afi
, safi_t safi
)
5909 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5911 return CMD_WARNING_CONFIG_FAILED
;
5913 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5915 return bgp_vty_return(vty
, ret
);
5918 DEFUN (neighbor_unsuppress_map
,
5919 neighbor_unsuppress_map_cmd
,
5920 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5923 "Route-map to selectively unsuppress suppressed routes\n"
5924 "Name of route map\n")
5928 return peer_unsuppress_map_set_vty(
5929 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5930 argv
[idx_word
]->arg
);
5933 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5934 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5935 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5936 "Route-map to selectively unsuppress suppressed routes\n"
5937 "Name of route map\n")
5939 DEFUN (no_neighbor_unsuppress_map
,
5940 no_neighbor_unsuppress_map_cmd
,
5941 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5945 "Route-map to selectively unsuppress suppressed routes\n"
5946 "Name of route map\n")
5949 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5951 bgp_node_safi(vty
));
5954 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5955 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5956 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5957 "Route-map to selectively unsuppress suppressed routes\n"
5958 "Name of route map\n")
5960 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5961 afi_t afi
, safi_t safi
,
5962 const char *num_str
,
5963 const char *threshold_str
, int warning
,
5964 const char *restart_str
)
5972 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5974 return CMD_WARNING_CONFIG_FAILED
;
5976 max
= strtoul(num_str
, NULL
, 10);
5978 threshold
= atoi(threshold_str
);
5980 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5983 restart
= atoi(restart_str
);
5987 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5990 return bgp_vty_return(vty
, ret
);
5993 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5994 afi_t afi
, safi_t safi
)
5999 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6001 return CMD_WARNING_CONFIG_FAILED
;
6003 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
6005 return bgp_vty_return(vty
, ret
);
6008 /* Maximum number of prefix configuration. prefix count is different
6009 for each peer configuration. So this configuration can be set for
6010 each peer configuration. */
6011 DEFUN (neighbor_maximum_prefix
,
6012 neighbor_maximum_prefix_cmd
,
6013 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
6016 "Maximum number of prefix accept from this peer\n"
6017 "maximum no. of prefix limit\n")
6021 return peer_maximum_prefix_set_vty(
6022 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6023 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
6026 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
6027 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
6028 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6029 "Maximum number of prefix accept from this peer\n"
6030 "maximum no. of prefix limit\n")
6032 DEFUN (neighbor_maximum_prefix_threshold
,
6033 neighbor_maximum_prefix_threshold_cmd
,
6034 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
6037 "Maximum number of prefix accept from this peer\n"
6038 "maximum no. of prefix limit\n"
6039 "Threshold value (%) at which to generate a warning msg\n")
6043 int idx_number_2
= 4;
6044 return peer_maximum_prefix_set_vty(
6045 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6046 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
6050 neighbor_maximum_prefix_threshold
,
6051 neighbor_maximum_prefix_threshold_hidden_cmd
,
6052 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
6053 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6054 "Maximum number of prefix accept from this peer\n"
6055 "maximum no. of prefix limit\n"
6056 "Threshold value (%) at which to generate a warning msg\n")
6058 DEFUN (neighbor_maximum_prefix_warning
,
6059 neighbor_maximum_prefix_warning_cmd
,
6060 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6063 "Maximum number of prefix accept from this peer\n"
6064 "maximum no. of prefix limit\n"
6065 "Only give warning message when limit is exceeded\n")
6069 return peer_maximum_prefix_set_vty(
6070 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6071 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
6075 neighbor_maximum_prefix_warning
,
6076 neighbor_maximum_prefix_warning_hidden_cmd
,
6077 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6078 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6079 "Maximum number of prefix accept from this peer\n"
6080 "maximum no. of prefix limit\n"
6081 "Only give warning message when limit is exceeded\n")
6083 DEFUN (neighbor_maximum_prefix_threshold_warning
,
6084 neighbor_maximum_prefix_threshold_warning_cmd
,
6085 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6088 "Maximum number of prefix accept from this peer\n"
6089 "maximum no. of prefix limit\n"
6090 "Threshold value (%) at which to generate a warning msg\n"
6091 "Only give warning message when limit is exceeded\n")
6095 int idx_number_2
= 4;
6096 return peer_maximum_prefix_set_vty(
6097 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6098 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
6102 neighbor_maximum_prefix_threshold_warning
,
6103 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
6104 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6105 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6106 "Maximum number of prefix accept from this peer\n"
6107 "maximum no. of prefix limit\n"
6108 "Threshold value (%) at which to generate a warning msg\n"
6109 "Only give warning message when limit is exceeded\n")
6111 DEFUN (neighbor_maximum_prefix_restart
,
6112 neighbor_maximum_prefix_restart_cmd
,
6113 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6116 "Maximum number of prefix accept from this peer\n"
6117 "maximum no. of prefix limit\n"
6118 "Restart bgp connection after limit is exceeded\n"
6119 "Restart interval in minutes\n")
6123 int idx_number_2
= 5;
6124 return peer_maximum_prefix_set_vty(
6125 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6126 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
6130 neighbor_maximum_prefix_restart
,
6131 neighbor_maximum_prefix_restart_hidden_cmd
,
6132 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6133 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6134 "Maximum number of prefix accept from this peer\n"
6135 "maximum no. of prefix limit\n"
6136 "Restart bgp connection after limit is exceeded\n"
6137 "Restart interval in minutes\n")
6139 DEFUN (neighbor_maximum_prefix_threshold_restart
,
6140 neighbor_maximum_prefix_threshold_restart_cmd
,
6141 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6144 "Maximum number of prefixes to accept from this peer\n"
6145 "maximum no. of prefix limit\n"
6146 "Threshold value (%) at which to generate a warning msg\n"
6147 "Restart bgp connection after limit is exceeded\n"
6148 "Restart interval in minutes\n")
6152 int idx_number_2
= 4;
6153 int idx_number_3
= 6;
6154 return peer_maximum_prefix_set_vty(
6155 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6156 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
6157 argv
[idx_number_3
]->arg
);
6161 neighbor_maximum_prefix_threshold_restart
,
6162 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
6163 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6164 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6165 "Maximum number of prefixes to accept from this peer\n"
6166 "maximum no. of prefix limit\n"
6167 "Threshold value (%) at which to generate a warning msg\n"
6168 "Restart bgp connection after limit is exceeded\n"
6169 "Restart interval in minutes\n")
6171 DEFUN (no_neighbor_maximum_prefix
,
6172 no_neighbor_maximum_prefix_cmd
,
6173 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6177 "Maximum number of prefixes to accept from this peer\n"
6178 "maximum no. of prefix limit\n"
6179 "Threshold value (%) at which to generate a warning msg\n"
6180 "Restart bgp connection after limit is exceeded\n"
6181 "Restart interval in minutes\n"
6182 "Only give warning message when limit is exceeded\n")
6185 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
6187 bgp_node_safi(vty
));
6191 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
6192 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6193 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6194 "Maximum number of prefixes to accept from this peer\n"
6195 "maximum no. of prefix limit\n"
6196 "Threshold value (%) at which to generate a warning msg\n"
6197 "Restart bgp connection after limit is exceeded\n"
6198 "Restart interval in minutes\n"
6199 "Only give warning message when limit is exceeded\n")
6202 /* "neighbor allowas-in" */
6203 DEFUN (neighbor_allowas_in
,
6204 neighbor_allowas_in_cmd
,
6205 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6208 "Accept as-path with my AS present in it\n"
6209 "Number of occurrences of AS number\n"
6210 "Only accept my AS in the as-path if the route was originated in my AS\n")
6213 int idx_number_origin
= 3;
6219 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6221 return CMD_WARNING_CONFIG_FAILED
;
6223 if (argc
<= idx_number_origin
)
6226 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6229 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6232 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6235 return bgp_vty_return(vty
, ret
);
6239 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6240 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6241 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6242 "Accept as-path with my AS present in it\n"
6243 "Number of occurrences of AS number\n"
6244 "Only accept my AS in the as-path if the route was originated in my AS\n")
6246 DEFUN (no_neighbor_allowas_in
,
6247 no_neighbor_allowas_in_cmd
,
6248 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6252 "allow local ASN appears in aspath attribute\n"
6253 "Number of occurrences of AS number\n"
6254 "Only accept my AS in the as-path if the route was originated in my AS\n")
6260 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6262 return CMD_WARNING_CONFIG_FAILED
;
6264 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6265 bgp_node_safi(vty
));
6267 return bgp_vty_return(vty
, ret
);
6271 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6272 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6273 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6274 "allow local ASN appears in aspath attribute\n"
6275 "Number of occurrences of AS number\n"
6276 "Only accept my AS in the as-path if the route was originated in my AS\n")
6278 DEFUN (neighbor_ttl_security
,
6279 neighbor_ttl_security_cmd
,
6280 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6283 "BGP ttl-security parameters\n"
6284 "Specify the maximum number of hops to the BGP peer\n"
6285 "Number of hops to BGP peer\n")
6292 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6294 return CMD_WARNING_CONFIG_FAILED
;
6296 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6299 * If 'neighbor swpX', then this is for directly connected peers,
6300 * we should not accept a ttl-security hops value greater than 1.
6302 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6304 "%s is directly connected peer, hops cannot exceed 1\n",
6305 argv
[idx_peer
]->arg
);
6306 return CMD_WARNING_CONFIG_FAILED
;
6309 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6312 DEFUN (no_neighbor_ttl_security
,
6313 no_neighbor_ttl_security_cmd
,
6314 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6318 "BGP ttl-security parameters\n"
6319 "Specify the maximum number of hops to the BGP peer\n"
6320 "Number of hops to BGP peer\n")
6325 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6327 return CMD_WARNING_CONFIG_FAILED
;
6329 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6332 DEFUN (neighbor_addpath_tx_all_paths
,
6333 neighbor_addpath_tx_all_paths_cmd
,
6334 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6337 "Use addpath to advertise all paths to a neighbor\n")
6342 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6344 return CMD_WARNING_CONFIG_FAILED
;
6346 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6351 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6352 neighbor_addpath_tx_all_paths_hidden_cmd
,
6353 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6354 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6355 "Use addpath to advertise all paths to a neighbor\n")
6357 DEFUN (no_neighbor_addpath_tx_all_paths
,
6358 no_neighbor_addpath_tx_all_paths_cmd
,
6359 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6363 "Use addpath to advertise all paths to a neighbor\n")
6368 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6370 return CMD_WARNING_CONFIG_FAILED
;
6372 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6373 != BGP_ADDPATH_ALL
) {
6375 "%% Peer not currently configured to transmit all paths.");
6376 return CMD_WARNING_CONFIG_FAILED
;
6379 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6385 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6386 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6387 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6388 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6389 "Use addpath to advertise all paths to a neighbor\n")
6391 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6392 neighbor_addpath_tx_bestpath_per_as_cmd
,
6393 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6396 "Use addpath to advertise the bestpath per each neighboring AS\n")
6401 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6403 return CMD_WARNING_CONFIG_FAILED
;
6405 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6406 BGP_ADDPATH_BEST_PER_AS
);
6411 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6412 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6413 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6414 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6415 "Use addpath to advertise the bestpath per each neighboring AS\n")
6417 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6418 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6419 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6423 "Use addpath to advertise the bestpath per each neighboring AS\n")
6428 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6430 return CMD_WARNING_CONFIG_FAILED
;
6432 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6433 != BGP_ADDPATH_BEST_PER_AS
) {
6435 "%% Peer not currently configured to transmit all best path per as.");
6436 return CMD_WARNING_CONFIG_FAILED
;
6439 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6445 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6446 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6447 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6448 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6449 "Use addpath to advertise the bestpath per each neighboring AS\n")
6452 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
6453 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
6456 "Detect AS loops before sending to neighbor\n")
6460 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
6462 return CMD_WARNING_CONFIG_FAILED
;
6464 peer
->as_path_loop_detection
= true;
6470 no_neighbor_aspath_loop_detection
,
6471 no_neighbor_aspath_loop_detection_cmd
,
6472 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
6476 "Detect AS loops before sending to neighbor\n")
6480 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
6482 return CMD_WARNING_CONFIG_FAILED
;
6484 peer
->as_path_loop_detection
= false;
6489 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6490 struct ecommunity
**list
)
6492 struct ecommunity
*ecom
= NULL
;
6493 struct ecommunity
*ecomadd
;
6495 for (; argc
; --argc
, ++argv
) {
6497 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6498 ECOMMUNITY_ROUTE_TARGET
, 0);
6500 vty_out(vty
, "Malformed community-list value\n");
6502 ecommunity_free(&ecom
);
6503 return CMD_WARNING_CONFIG_FAILED
;
6507 ecommunity_merge(ecom
, ecomadd
);
6508 ecommunity_free(&ecomadd
);
6515 ecommunity_free(&*list
);
6523 * v2vimport is true if we are handling a `import vrf ...` command
6525 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6529 switch (vty
->node
) {
6538 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6543 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6544 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6545 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6546 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6548 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6552 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6553 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6554 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6555 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6557 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6564 DEFPY (af_rd_vpn_export
,
6565 af_rd_vpn_export_cmd
,
6566 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6568 "Specify route distinguisher\n"
6569 "Between current address-family and vpn\n"
6570 "For routes leaked from current address-family to vpn\n"
6571 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6573 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6574 struct prefix_rd prd
;
6580 if (argv_find(argv
, argc
, "no", &idx
))
6584 ret
= str2prefix_rd(rd_str
, &prd
);
6586 vty_out(vty
, "%% Malformed rd\n");
6587 return CMD_WARNING_CONFIG_FAILED
;
6591 afi
= vpn_policy_getafi(vty
, bgp
, false);
6593 return CMD_WARNING_CONFIG_FAILED
;
6596 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6598 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6599 bgp_get_default(), bgp
);
6602 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6603 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6604 BGP_VPN_POLICY_TOVPN_RD_SET
);
6606 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6607 BGP_VPN_POLICY_TOVPN_RD_SET
);
6610 /* post-change: re-export vpn routes */
6611 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6612 bgp_get_default(), bgp
);
6617 ALIAS (af_rd_vpn_export
,
6618 af_no_rd_vpn_export_cmd
,
6621 "Specify route distinguisher\n"
6622 "Between current address-family and vpn\n"
6623 "For routes leaked from current address-family to vpn\n")
6625 DEFPY (af_label_vpn_export
,
6626 af_label_vpn_export_cmd
,
6627 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6629 "label value for VRF\n"
6630 "Between current address-family and vpn\n"
6631 "For routes leaked from current address-family to vpn\n"
6632 "Label Value <0-1048575>\n"
6633 "Automatically assign a label\n")
6635 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6636 mpls_label_t label
= MPLS_LABEL_NONE
;
6641 if (argv_find(argv
, argc
, "no", &idx
))
6644 /* If "no ...", squash trailing parameter */
6650 label
= label_val
; /* parser should force unsigned */
6653 afi
= vpn_policy_getafi(vty
, bgp
, false);
6655 return CMD_WARNING_CONFIG_FAILED
;
6658 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6659 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6664 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6666 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6667 bgp_get_default(), bgp
);
6669 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6670 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6672 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6675 * label has previously been automatically
6676 * assigned by labelpool: release it
6678 * NB if tovpn_label == MPLS_LABEL_NONE it
6679 * means the automatic assignment is in flight
6680 * and therefore the labelpool callback must
6681 * detect that the auto label is not needed.
6684 bgp_lp_release(LP_TYPE_VRF
,
6685 &bgp
->vpn_policy
[afi
],
6686 bgp
->vpn_policy
[afi
].tovpn_label
);
6688 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6689 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6692 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6694 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6695 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6696 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6697 vpn_leak_label_callback
);
6700 /* post-change: re-export vpn routes */
6701 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6702 bgp_get_default(), bgp
);
6707 ALIAS (af_label_vpn_export
,
6708 af_no_label_vpn_export_cmd
,
6709 "no label vpn export",
6711 "label value for VRF\n"
6712 "Between current address-family and vpn\n"
6713 "For routes leaked from current address-family to vpn\n")
6715 DEFPY (af_nexthop_vpn_export
,
6716 af_nexthop_vpn_export_cmd
,
6717 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6719 "Specify next hop to use for VRF advertised prefixes\n"
6720 "Between current address-family and vpn\n"
6721 "For routes leaked from current address-family to vpn\n"
6725 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6731 if (argv_find(argv
, argc
, "no", &idx
))
6735 if (!sockunion2hostprefix(nexthop_str
, &p
))
6736 return CMD_WARNING_CONFIG_FAILED
;
6739 afi
= vpn_policy_getafi(vty
, bgp
, false);
6741 return CMD_WARNING_CONFIG_FAILED
;
6744 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6746 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6747 bgp_get_default(), bgp
);
6750 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6751 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6752 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6754 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6755 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6758 /* post-change: re-export vpn routes */
6759 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6760 bgp_get_default(), bgp
);
6765 ALIAS (af_nexthop_vpn_export
,
6766 af_no_nexthop_vpn_export_cmd
,
6767 "no nexthop vpn export",
6769 "Specify next hop to use for VRF advertised prefixes\n"
6770 "Between current address-family and vpn\n"
6771 "For routes leaked from current address-family to vpn\n")
6773 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6775 if (!strcmp(dstr
, "import")) {
6776 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6777 } else if (!strcmp(dstr
, "export")) {
6778 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6779 } else if (!strcmp(dstr
, "both")) {
6780 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6781 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6783 vty_out(vty
, "%% direction parse error\n");
6784 return CMD_WARNING_CONFIG_FAILED
;
6789 DEFPY (af_rt_vpn_imexport
,
6790 af_rt_vpn_imexport_cmd
,
6791 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6793 "Specify route target list\n"
6794 "Specify route target list\n"
6795 "Between current address-family and vpn\n"
6796 "For routes leaked from vpn to current address-family: match any\n"
6797 "For routes leaked from current address-family to vpn: set\n"
6798 "both import: match any and export: set\n"
6799 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6801 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6803 struct ecommunity
*ecom
= NULL
;
6804 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6805 vpn_policy_direction_t dir
;
6810 if (argv_find(argv
, argc
, "no", &idx
))
6813 afi
= vpn_policy_getafi(vty
, bgp
, false);
6815 return CMD_WARNING_CONFIG_FAILED
;
6817 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6818 if (ret
!= CMD_SUCCESS
)
6822 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6823 vty_out(vty
, "%% Missing RTLIST\n");
6824 return CMD_WARNING_CONFIG_FAILED
;
6826 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6827 if (ret
!= CMD_SUCCESS
) {
6832 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6836 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6839 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6841 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6842 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6843 ecommunity_dup(ecom
);
6845 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6847 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6848 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6851 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6855 ecommunity_free(&ecom
);
6860 ALIAS (af_rt_vpn_imexport
,
6861 af_no_rt_vpn_imexport_cmd
,
6862 "no <rt|route-target> vpn <import|export|both>$direction_str",
6864 "Specify route target list\n"
6865 "Specify route target list\n"
6866 "Between current address-family and vpn\n"
6867 "For routes leaked from vpn to current address-family\n"
6868 "For routes leaked from current address-family to vpn\n"
6869 "both import and export\n")
6871 DEFPY (af_route_map_vpn_imexport
,
6872 af_route_map_vpn_imexport_cmd
,
6873 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6874 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6876 "Specify route map\n"
6877 "Between current address-family and vpn\n"
6878 "For routes leaked from vpn to current address-family\n"
6879 "For routes leaked from current address-family to vpn\n"
6880 "name of route-map\n")
6882 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6884 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6885 vpn_policy_direction_t dir
;
6890 if (argv_find(argv
, argc
, "no", &idx
))
6893 afi
= vpn_policy_getafi(vty
, bgp
, false);
6895 return CMD_WARNING_CONFIG_FAILED
;
6897 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6898 if (ret
!= CMD_SUCCESS
)
6901 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6905 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6908 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6909 XFREE(MTYPE_ROUTE_MAP_NAME
,
6910 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6911 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6912 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6913 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6914 route_map_lookup_warn_noexist(vty
, rmap_str
);
6915 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6918 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6919 XFREE(MTYPE_ROUTE_MAP_NAME
,
6920 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6921 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6922 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6925 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6931 ALIAS (af_route_map_vpn_imexport
,
6932 af_no_route_map_vpn_imexport_cmd
,
6933 "no route-map vpn <import|export>$direction_str",
6935 "Specify route map\n"
6936 "Between current address-family and vpn\n"
6937 "For routes leaked from vpn to current address-family\n"
6938 "For routes leaked from current address-family to vpn\n")
6940 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6941 "[no] import vrf route-map RMAP$rmap_str",
6943 "Import routes from another VRF\n"
6944 "Vrf routes being filtered\n"
6945 "Specify route map\n"
6946 "name of route-map\n")
6948 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6949 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6953 struct bgp
*bgp_default
;
6955 if (argv_find(argv
, argc
, "no", &idx
))
6958 afi
= vpn_policy_getafi(vty
, bgp
, true);
6960 return CMD_WARNING_CONFIG_FAILED
;
6962 bgp_default
= bgp_get_default();
6967 /* Auto-create assuming the same AS */
6968 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6969 BGP_INSTANCE_TYPE_DEFAULT
);
6973 "VRF default is not configured as a bgp instance\n");
6978 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6981 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6982 XFREE(MTYPE_ROUTE_MAP_NAME
,
6983 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6984 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6985 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6986 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6987 route_map_lookup_warn_noexist(vty
, rmap_str
);
6988 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6991 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6992 XFREE(MTYPE_ROUTE_MAP_NAME
,
6993 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6994 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6995 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6998 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7003 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
7004 "no import vrf route-map",
7006 "Import routes from another VRF\n"
7007 "Vrf routes being filtered\n"
7008 "Specify route map\n")
7010 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
7011 "[no] import vrf VIEWVRFNAME$import_name",
7013 "Import routes from another VRF\n"
7014 "VRF to import from\n"
7015 "The name of the VRF\n")
7017 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7018 struct listnode
*node
;
7019 struct bgp
*vrf_bgp
, *bgp_default
;
7022 bool remove
= false;
7025 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
7029 if (import_name
== NULL
) {
7030 vty_out(vty
, "%% Missing import name\n");
7034 if (argv_find(argv
, argc
, "no", &idx
))
7037 afi
= vpn_policy_getafi(vty
, bgp
, true);
7039 return CMD_WARNING_CONFIG_FAILED
;
7041 safi
= bgp_node_safi(vty
);
7043 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
7044 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
7045 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
7046 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
7047 remove
? "unimport" : "import", import_name
);
7051 bgp_default
= bgp_get_default();
7053 /* Auto-create assuming the same AS */
7054 ret
= bgp_get(&bgp_default
, &as
, NULL
,
7055 BGP_INSTANCE_TYPE_DEFAULT
);
7059 "VRF default is not configured as a bgp instance\n");
7064 vrf_bgp
= bgp_lookup_by_name(import_name
);
7066 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
7067 vrf_bgp
= bgp_default
;
7069 /* Auto-create assuming the same AS */
7070 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
7074 "VRF %s is not configured as a bgp instance\n",
7081 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
7083 /* Already importing from "import_vrf"? */
7084 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
7086 if (strcmp(vname
, import_name
) == 0)
7090 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
7096 /* This command is valid only in a bgp vrf instance or the default instance */
7097 DEFPY (bgp_imexport_vpn
,
7098 bgp_imexport_vpn_cmd
,
7099 "[no] <import|export>$direction_str vpn",
7101 "Import routes to this address-family\n"
7102 "Export routes from this address-family\n"
7103 "to/from default instance VPN RIB\n")
7105 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7112 vpn_policy_direction_t dir
;
7114 if (argv_find(argv
, argc
, "no", &idx
))
7117 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
7118 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
7120 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
7121 return CMD_WARNING_CONFIG_FAILED
;
7124 afi
= bgp_node_afi(vty
);
7125 safi
= bgp_node_safi(vty
);
7126 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
7127 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
7128 return CMD_WARNING_CONFIG_FAILED
;
7131 if (!strcmp(direction_str
, "import")) {
7132 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
7133 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
7134 } else if (!strcmp(direction_str
, "export")) {
7135 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
7136 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
7138 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
7139 return CMD_WARNING_CONFIG_FAILED
;
7142 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7145 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7146 if (!previous_state
) {
7147 /* trigger export current vrf */
7148 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7151 if (previous_state
) {
7152 /* trigger un-export current vrf */
7153 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7155 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7161 DEFPY (af_routetarget_import
,
7162 af_routetarget_import_cmd
,
7163 "[no] <rt|route-target> redirect import RTLIST...",
7165 "Specify route target list\n"
7166 "Specify route target list\n"
7167 "Flow-spec redirect type route target\n"
7168 "Import routes to this address-family\n"
7169 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
7171 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7173 struct ecommunity
*ecom
= NULL
;
7178 if (argv_find(argv
, argc
, "no", &idx
))
7181 afi
= vpn_policy_getafi(vty
, bgp
, false);
7183 return CMD_WARNING_CONFIG_FAILED
;
7186 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7187 vty_out(vty
, "%% Missing RTLIST\n");
7188 return CMD_WARNING_CONFIG_FAILED
;
7190 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7191 if (ret
!= CMD_SUCCESS
)
7196 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7197 ecommunity_free(&bgp
->vpn_policy
[afi
]
7198 .import_redirect_rtlist
);
7199 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
7200 ecommunity_dup(ecom
);
7202 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7203 ecommunity_free(&bgp
->vpn_policy
[afi
]
7204 .import_redirect_rtlist
);
7205 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
7209 ecommunity_free(&ecom
);
7214 DEFUN_NOSH (address_family_ipv4_safi
,
7215 address_family_ipv4_safi_cmd
,
7216 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7217 "Enter Address Family command mode\n"
7219 BGP_SAFI_WITH_LABEL_HELP_STR
)
7223 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7224 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7225 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7226 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7227 && safi
!= SAFI_EVPN
) {
7229 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7230 return CMD_WARNING_CONFIG_FAILED
;
7232 vty
->node
= bgp_node_type(AFI_IP
, safi
);
7234 vty
->node
= BGP_IPV4_NODE
;
7239 DEFUN_NOSH (address_family_ipv6_safi
,
7240 address_family_ipv6_safi_cmd
,
7241 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7242 "Enter Address Family command mode\n"
7244 BGP_SAFI_WITH_LABEL_HELP_STR
)
7247 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7248 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7249 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7250 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7251 && safi
!= SAFI_EVPN
) {
7253 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7254 return CMD_WARNING_CONFIG_FAILED
;
7256 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
7258 vty
->node
= BGP_IPV6_NODE
;
7263 #ifdef KEEP_OLD_VPN_COMMANDS
7264 DEFUN_NOSH (address_family_vpnv4
,
7265 address_family_vpnv4_cmd
,
7266 "address-family vpnv4 [unicast]",
7267 "Enter Address Family command mode\n"
7269 "Address Family modifier\n")
7271 vty
->node
= BGP_VPNV4_NODE
;
7275 DEFUN_NOSH (address_family_vpnv6
,
7276 address_family_vpnv6_cmd
,
7277 "address-family vpnv6 [unicast]",
7278 "Enter Address Family command mode\n"
7280 "Address Family modifier\n")
7282 vty
->node
= BGP_VPNV6_NODE
;
7285 #endif /* KEEP_OLD_VPN_COMMANDS */
7287 DEFUN_NOSH (address_family_evpn
,
7288 address_family_evpn_cmd
,
7289 "address-family l2vpn evpn",
7290 "Enter Address Family command mode\n"
7292 "Address Family modifier\n")
7294 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7295 vty
->node
= BGP_EVPN_NODE
;
7299 DEFUN_NOSH (exit_address_family
,
7300 exit_address_family_cmd
,
7301 "exit-address-family",
7302 "Exit from Address Family configuration mode\n")
7304 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7305 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7306 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7307 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7308 || vty
->node
== BGP_EVPN_NODE
7309 || vty
->node
== BGP_FLOWSPECV4_NODE
7310 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7311 vty
->node
= BGP_NODE
;
7315 /* Recalculate bestpath and re-advertise a prefix */
7316 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7317 const char *ip_str
, afi_t afi
, safi_t safi
,
7318 struct prefix_rd
*prd
)
7321 struct prefix match
;
7322 struct bgp_node
*rn
;
7323 struct bgp_node
*rm
;
7325 struct bgp_table
*table
;
7326 struct bgp_table
*rib
;
7328 /* BGP structure lookup. */
7330 bgp
= bgp_lookup_by_name(view_name
);
7332 vty_out(vty
, "%% Can't find BGP instance %s\n",
7337 bgp
= bgp_get_default();
7339 vty_out(vty
, "%% No BGP process is configured\n");
7344 /* Check IP address argument. */
7345 ret
= str2prefix(ip_str
, &match
);
7347 vty_out(vty
, "%% address is malformed\n");
7351 match
.family
= afi2family(afi
);
7352 rib
= bgp
->rib
[afi
][safi
];
7354 if (safi
== SAFI_MPLS_VPN
) {
7355 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7356 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7359 table
= bgp_node_get_bgp_table_info(rn
);
7360 if (table
!= NULL
) {
7362 if ((rm
= bgp_node_match(table
, &match
))
7365 == match
.prefixlen
) {
7367 BGP_NODE_USER_CLEAR
);
7368 bgp_process(bgp
, rm
, afi
, safi
);
7370 bgp_unlock_node(rm
);
7375 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7376 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7377 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7378 bgp_process(bgp
, rn
, afi
, safi
);
7380 bgp_unlock_node(rn
);
7387 /* one clear bgp command to rule them all */
7388 DEFUN (clear_ip_bgp_all
,
7389 clear_ip_bgp_all_cmd
,
7390 "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>]",
7394 BGP_INSTANCE_HELP_STR
7397 BGP_SAFI_WITH_LABEL_HELP_STR
7398 "Address Family modifier\n"
7400 "BGP IPv4 neighbor to clear\n"
7401 "BGP IPv6 neighbor to clear\n"
7402 "BGP neighbor on interface to clear\n"
7403 "Clear peers with the AS number\n"
7404 "Clear all external peers\n"
7405 "Clear all members of peer-group\n"
7406 "BGP peer-group name\n"
7411 "Push out prefix-list ORF and do inbound soft reconfig\n"
7416 afi_t afi
= AFI_UNSPEC
;
7417 safi_t safi
= SAFI_UNSPEC
;
7418 enum clear_sort clr_sort
= clear_peer
;
7419 enum bgp_clear_type clr_type
;
7420 char *clr_arg
= NULL
;
7424 /* clear [ip] bgp */
7425 if (argv_find(argv
, argc
, "ip", &idx
))
7428 /* [<vrf> VIEWVRFNAME] */
7429 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7430 vrf
= argv
[idx
+ 1]->arg
;
7432 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7434 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7435 /* [<view> VIEWVRFNAME] */
7436 vrf
= argv
[idx
+ 1]->arg
;
7439 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7440 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7441 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7443 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
7444 if (argv_find(argv
, argc
, "*", &idx
)) {
7445 clr_sort
= clear_all
;
7446 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7447 clr_sort
= clear_peer
;
7448 clr_arg
= argv
[idx
]->arg
;
7449 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7450 clr_sort
= clear_peer
;
7451 clr_arg
= argv
[idx
]->arg
;
7452 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7453 clr_sort
= clear_group
;
7455 clr_arg
= argv
[idx
]->arg
;
7456 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
7457 clr_sort
= clear_peer
;
7458 clr_arg
= argv
[idx
]->arg
;
7459 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7460 clr_sort
= clear_peer
;
7461 clr_arg
= argv
[idx
]->arg
;
7462 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7463 clr_sort
= clear_as
;
7464 clr_arg
= argv
[idx
]->arg
;
7465 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7466 clr_sort
= clear_external
;
7469 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7470 if (argv_find(argv
, argc
, "soft", &idx
)) {
7471 if (argv_find(argv
, argc
, "in", &idx
)
7472 || argv_find(argv
, argc
, "out", &idx
))
7473 clr_type
= strmatch(argv
[idx
]->text
, "in")
7475 : BGP_CLEAR_SOFT_OUT
;
7477 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7478 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7479 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7480 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7481 : BGP_CLEAR_SOFT_IN
;
7482 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7483 clr_type
= BGP_CLEAR_SOFT_OUT
;
7485 clr_type
= BGP_CLEAR_SOFT_NONE
;
7487 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7490 DEFUN (clear_ip_bgp_prefix
,
7491 clear_ip_bgp_prefix_cmd
,
7492 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7496 BGP_INSTANCE_HELP_STR
7497 "Clear bestpath and re-advertise\n"
7501 char *prefix
= NULL
;
7505 /* [<view|vrf> VIEWVRFNAME] */
7506 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7507 vrf
= argv
[idx
+ 1]->arg
;
7509 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7511 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7512 /* [<view> VIEWVRFNAME] */
7513 vrf
= argv
[idx
+ 1]->arg
;
7517 prefix
= argv
[argc
- 1]->arg
;
7519 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7522 DEFUN (clear_bgp_ipv6_safi_prefix
,
7523 clear_bgp_ipv6_safi_prefix_cmd
,
7524 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7530 "Clear bestpath and re-advertise\n"
7534 int idx_ipv6_prefix
= 0;
7535 safi_t safi
= SAFI_UNICAST
;
7536 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7537 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7539 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7540 return bgp_clear_prefix(
7541 vty
, NULL
, prefix
, AFI_IP6
,
7545 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7546 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7547 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7551 BGP_INSTANCE_HELP_STR
7554 "Clear bestpath and re-advertise\n"
7558 int idx_vrfview
= 0;
7559 int idx_ipv6_prefix
= 0;
7560 safi_t safi
= SAFI_UNICAST
;
7561 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7562 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7563 char *vrfview
= NULL
;
7565 /* [<view|vrf> VIEWVRFNAME] */
7566 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
7567 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7568 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
7570 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
7571 /* [<view> VIEWVRFNAME] */
7572 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7574 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7576 return bgp_clear_prefix(
7577 vty
, vrfview
, prefix
,
7578 AFI_IP6
, safi
, NULL
);
7581 DEFUN (show_bgp_views
,
7583 "show [ip] bgp views",
7587 "Show the defined BGP views\n")
7589 struct list
*inst
= bm
->bgp
;
7590 struct listnode
*node
;
7593 vty_out(vty
, "Defined BGP views:\n");
7594 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7596 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7598 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7605 DEFUN (show_bgp_vrfs
,
7607 "show [ip] bgp vrfs [json]",
7614 char buf
[ETHER_ADDR_STRLEN
];
7615 struct list
*inst
= bm
->bgp
;
7616 struct listnode
*node
;
7618 bool uj
= use_json(argc
, argv
);
7619 json_object
*json
= NULL
;
7620 json_object
*json_vrfs
= NULL
;
7624 json
= json_object_new_object();
7625 json_vrfs
= json_object_new_object();
7628 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7629 const char *name
, *type
;
7631 struct listnode
*node2
, *nnode2
;
7632 int peers_cfg
, peers_estb
;
7633 json_object
*json_vrf
= NULL
;
7636 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7640 if (!uj
&& count
== 1) {
7642 "%4s %-5s %-16s %9s %10s %-37s\n",
7643 "Type", "Id", "routerId", "#PeersVfg",
7644 "#PeersEstb", "Name");
7645 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
7646 "L3-VNI", "RouterMAC", "Interface");
7649 peers_cfg
= peers_estb
= 0;
7651 json_vrf
= json_object_new_object();
7654 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
7655 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7658 if (peer
->status
== Established
)
7662 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7663 name
= VRF_DEFAULT_NAME
;
7672 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7674 : (int64_t)bgp
->vrf_id
;
7675 json_object_string_add(json_vrf
, "type", type
);
7676 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7677 json_object_string_add(json_vrf
, "routerId",
7678 inet_ntoa(bgp
->router_id
));
7679 json_object_int_add(json_vrf
, "numConfiguredPeers",
7681 json_object_int_add(json_vrf
, "numEstablishedPeers",
7684 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7685 json_object_string_add(
7687 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7688 json_object_string_add(json_vrf
, "interface",
7689 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
7691 json_object_object_add(json_vrfs
, name
, json_vrf
);
7694 "%4s %-5d %-16s %-9u %-10u %-37s\n",
7696 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7698 inet_ntoa(bgp
->router_id
), peers_cfg
,
7700 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
7702 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
7703 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
7709 json_object_object_add(json
, "vrfs", json_vrfs
);
7711 json_object_int_add(json
, "totalVrfs", count
);
7713 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7714 json
, JSON_C_TO_STRING_PRETTY
));
7715 json_object_free(json
);
7719 "\nTotal number of VRFs (including default): %d\n",
7726 DEFUN (show_bgp_mac_hash
,
7727 show_bgp_mac_hash_cmd
,
7728 "show bgp mac hash",
7732 "Mac Address database\n")
7734 bgp_mac_dump_table(vty
);
7739 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
7741 struct vty
*vty
= (struct vty
*)args
;
7742 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
7744 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7748 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7750 vty_out(vty
, "self nexthop database:\n");
7751 bgp_nexthop_show_address_hash(vty
, bgp
);
7753 vty_out(vty
, "Tunnel-ip database:\n");
7754 hash_iterate(bgp
->tip_hash
,
7755 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
7759 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7760 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7761 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7762 "martian next-hops\n"
7763 "martian next-hop database\n")
7765 struct bgp
*bgp
= NULL
;
7769 /* [<vrf> VIEWVRFNAME] */
7770 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7771 name
= argv
[idx
+ 1]->arg
;
7772 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7774 } else if (argv_find(argv
, argc
, "view", &idx
))
7775 /* [<view> VIEWVRFNAME] */
7776 name
= argv
[idx
+ 1]->arg
;
7778 bgp
= bgp_lookup_by_name(name
);
7780 bgp
= bgp_get_default();
7783 vty_out(vty
, "%% No BGP process is configured\n");
7786 bgp_show_martian_nexthops(vty
, bgp
);
7791 DEFUN (show_bgp_memory
,
7792 show_bgp_memory_cmd
,
7793 "show [ip] bgp memory",
7797 "Global BGP memory statistics\n")
7799 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7800 unsigned long count
;
7802 /* RIB related usage stats */
7803 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7804 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7805 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7806 count
* sizeof(struct bgp_node
)));
7808 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7809 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7810 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7811 count
* sizeof(struct bgp_path_info
)));
7812 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7813 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7816 memstrbuf
, sizeof(memstrbuf
),
7817 count
* sizeof(struct bgp_path_info_extra
)));
7819 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7820 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7821 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7822 count
* sizeof(struct bgp_static
)));
7824 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7825 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7826 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7827 count
* sizeof(struct bpacket
)));
7830 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7831 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7832 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7833 count
* sizeof(struct bgp_adj_in
)));
7834 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7835 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7836 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7837 count
* sizeof(struct bgp_adj_out
)));
7839 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7840 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7842 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7843 count
* sizeof(struct bgp_nexthop_cache
)));
7845 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7846 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7848 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7849 count
* sizeof(struct bgp_damp_info
)));
7852 count
= attr_count();
7853 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7854 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7855 count
* sizeof(struct attr
)));
7857 if ((count
= attr_unknown_count()))
7858 vty_out(vty
, "%ld unknown attributes\n", count
);
7860 /* AS_PATH attributes */
7861 count
= aspath_count();
7862 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7863 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7864 count
* sizeof(struct aspath
)));
7866 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7867 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7868 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7869 count
* sizeof(struct assegment
)));
7871 /* Other attributes */
7872 if ((count
= community_count()))
7873 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7874 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7875 count
* sizeof(struct community
)));
7876 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7877 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7878 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7879 count
* sizeof(struct ecommunity
)));
7880 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7882 "%ld BGP large-community entries, using %s of memory\n",
7883 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7884 count
* sizeof(struct lcommunity
)));
7886 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7887 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7888 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7889 count
* sizeof(struct cluster_list
)));
7891 /* Peer related usage */
7892 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7893 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7894 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7895 count
* sizeof(struct peer
)));
7897 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7898 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7899 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7900 count
* sizeof(struct peer_group
)));
7903 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7904 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7905 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7906 count
* sizeof(regex_t
)));
7910 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7912 json_object
*bestpath
= json_object_new_object();
7914 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7915 json_object_string_add(bestpath
, "asPath", "ignore");
7917 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7918 json_object_string_add(bestpath
, "asPath", "confed");
7920 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7921 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7922 json_object_string_add(bestpath
, "multiPathRelax",
7925 json_object_string_add(bestpath
, "multiPathRelax",
7928 json_object_string_add(bestpath
, "multiPathRelax", "false");
7930 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7931 json_object_string_add(bestpath
, "compareRouterId", "true");
7932 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7933 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7934 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7935 json_object_string_add(bestpath
, "med", "confed");
7936 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7937 json_object_string_add(bestpath
, "med",
7938 "missing-as-worst");
7940 json_object_string_add(bestpath
, "med", "true");
7943 json_object_object_add(json
, "bestPath", bestpath
);
7946 /* Print the error code/subcode for why the peer is down */
7947 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
7948 json_object
*json_peer
, bool use_json
)
7950 const char *code_str
;
7951 const char *subcode_str
;
7954 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
7955 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
7956 char errorcodesubcode_hexstr
[5];
7957 char errorcodesubcode_str
[256];
7959 code_str
= bgp_notify_code_str(peer
->notify
.code
);
7960 subcode_str
= bgp_notify_subcode_str(
7962 peer
->notify
.subcode
);
7964 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
7965 peer
->notify
.code
, peer
->notify
.subcode
);
7966 json_object_string_add(json_peer
,
7967 "lastErrorCodeSubcode",
7968 errorcodesubcode_hexstr
);
7969 snprintf(errorcodesubcode_str
, 255, "%s%s",
7970 code_str
, subcode_str
);
7971 json_object_string_add(json_peer
,
7972 "lastNotificationReason",
7973 errorcodesubcode_str
);
7974 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
7975 && peer
->notify
.code
== BGP_NOTIFY_CEASE
7976 && (peer
->notify
.subcode
7977 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
7978 || peer
->notify
.subcode
7979 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
7980 && peer
->notify
.length
) {
7982 const char *msg_str
;
7984 msg_str
= bgp_notify_admin_message(
7985 msgbuf
, sizeof(msgbuf
),
7986 (uint8_t *)peer
->notify
.data
,
7987 peer
->notify
.length
);
7989 json_object_string_add(
7991 "lastShutdownDescription",
7996 json_object_string_add(json_peer
, "lastResetDueTo",
7997 peer_down_str
[(int)peer
->last_reset
]);
7998 json_object_int_add(json_peer
, "lastResetCode",
8001 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
8002 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
8003 code_str
= bgp_notify_code_str(peer
->notify
.code
);
8005 bgp_notify_subcode_str(peer
->notify
.code
,
8006 peer
->notify
.subcode
);
8007 vty_out(vty
, " Notification %s (%s%s)\n",
8008 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
8011 code_str
, subcode_str
);
8013 vty_out(vty
, " %s\n",
8014 peer_down_str
[(int)peer
->last_reset
]);
8019 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
8022 return ((peer
->status
!= Established
) ||
8023 !peer
->afc_recv
[afi
][safi
]);
8026 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
8027 struct peer
*peer
, json_object
*json_peer
,
8028 int max_neighbor_width
, bool use_json
)
8030 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
8034 if (peer_dynamic_neighbor(peer
))
8035 json_object_boolean_true_add(json_peer
,
8038 json_object_string_add(json_peer
, "hostname",
8041 if (peer
->domainname
)
8042 json_object_string_add(json_peer
, "domainname",
8044 json_object_int_add(json_peer
, "connectionsEstablished",
8046 json_object_int_add(json_peer
, "connectionsDropped",
8048 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8049 use_json
, json_peer
);
8050 if (peer
->status
== Established
)
8051 json_object_string_add(json_peer
, "lastResetDueTo",
8052 "AFI/SAFI Not Negotiated");
8054 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
8057 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
8059 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8060 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8061 peer
->hostname
, peer
->host
);
8063 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8065 /* pad the neighbor column with spaces */
8066 if (len
< max_neighbor_width
)
8067 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8069 vty_out(vty
, "%7d %7d %8s", peer
->established
,
8071 peer_uptime(peer
->uptime
, timebuf
,
8072 BGP_UPTIME_LEN
, 0, NULL
));
8073 if (peer
->status
== Established
)
8074 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
8076 bgp_show_peer_reset(vty
, peer
, NULL
,
8082 /* Show BGP peer's summary information. */
8083 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
8084 bool show_failed
, bool use_json
)
8087 struct listnode
*node
, *nnode
;
8088 unsigned int count
= 0, dn_count
= 0;
8089 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
8090 char neighbor_buf
[VTY_BUFSIZ
];
8091 int neighbor_col_default_width
= 16;
8092 int len
, failed_count
= 0;
8093 int max_neighbor_width
= 0;
8095 json_object
*json
= NULL
;
8096 json_object
*json_peer
= NULL
;
8097 json_object
*json_peers
= NULL
;
8098 struct peer_af
*paf
;
8100 /* labeled-unicast routes are installed in the unicast table so in order
8102 * display the correct PfxRcd value we must look at SAFI_UNICAST
8105 if (safi
== SAFI_LABELED_UNICAST
)
8106 pfx_rcd_safi
= SAFI_UNICAST
;
8108 pfx_rcd_safi
= safi
;
8111 json
= json_object_new_object();
8112 json_peers
= json_object_new_object();
8113 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8114 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8117 if (peer
->afc
[afi
][safi
]) {
8118 /* See if we have at least a single failed peer */
8119 if (bgp_has_peer_failed(peer
, afi
, safi
))
8123 if (peer_dynamic_neighbor(peer
))
8128 /* Loop over all neighbors that will be displayed to determine
8130 * characters are needed for the Neighbor column
8132 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8133 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8136 if (peer
->afc
[afi
][safi
]) {
8137 memset(dn_flag
, '\0', sizeof(dn_flag
));
8138 if (peer_dynamic_neighbor(peer
))
8142 && bgp_flag_check(bgp
,
8143 BGP_FLAG_SHOW_HOSTNAME
))
8144 sprintf(neighbor_buf
, "%s%s(%s) ",
8145 dn_flag
, peer
->hostname
,
8148 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
8151 len
= strlen(neighbor_buf
);
8153 if (len
> max_neighbor_width
)
8154 max_neighbor_width
= len
;
8156 /* See if we have at least a single failed peer */
8157 if (bgp_has_peer_failed(peer
, afi
, safi
))
8163 /* Originally we displayed the Neighbor column as 16
8164 * characters wide so make that the default
8166 if (max_neighbor_width
< neighbor_col_default_width
)
8167 max_neighbor_width
= neighbor_col_default_width
;
8170 if (show_failed
&& !failed_count
) {
8172 json_object_int_add(json
, "failedPeersCount", 0);
8173 json_object_int_add(json
, "dynamicPeers", dn_count
);
8174 json_object_int_add(json
, "totalPeers", count
);
8176 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8177 json
, JSON_C_TO_STRING_PRETTY
));
8178 json_object_free(json
);
8180 vty_out(vty
, "%% No failed BGP neighbors found\n");
8181 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8186 count
= 0; /* Reset the value as its used again */
8187 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8188 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8191 if (!peer
->afc
[afi
][safi
])
8196 char memstrbuf
[MTYPE_MEMSTR_LEN
];
8199 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
8201 : (int64_t)bgp
->vrf_id
;
8203 /* Usage summary and header */
8205 json_object_string_add(
8207 inet_ntoa(bgp
->router_id
));
8208 json_object_int_add(json
, "as", bgp
->as
);
8209 json_object_int_add(json
, "vrfId", vrf_id_ui
);
8210 json_object_string_add(
8213 == BGP_INSTANCE_TYPE_DEFAULT
)
8218 "BGP router identifier %s, local AS number %u vrf-id %d",
8219 inet_ntoa(bgp
->router_id
), bgp
->as
,
8220 bgp
->vrf_id
== VRF_UNKNOWN
8222 : (int)bgp
->vrf_id
);
8226 if (bgp_update_delay_configured(bgp
)) {
8228 json_object_int_add(
8229 json
, "updateDelayLimit",
8230 bgp
->v_update_delay
);
8232 if (bgp
->v_update_delay
8233 != bgp
->v_establish_wait
)
8234 json_object_int_add(
8236 "updateDelayEstablishWait",
8237 bgp
->v_establish_wait
);
8239 if (bgp_update_delay_active(bgp
)) {
8240 json_object_string_add(
8242 "updateDelayFirstNeighbor",
8243 bgp
->update_delay_begin_time
);
8244 json_object_boolean_true_add(
8246 "updateDelayInProgress");
8248 if (bgp
->update_delay_over
) {
8249 json_object_string_add(
8251 "updateDelayFirstNeighbor",
8252 bgp
->update_delay_begin_time
);
8253 json_object_string_add(
8255 "updateDelayBestpathResumed",
8256 bgp
->update_delay_end_time
);
8257 json_object_string_add(
8259 "updateDelayZebraUpdateResume",
8260 bgp
->update_delay_zebra_resume_time
);
8261 json_object_string_add(
8263 "updateDelayPeerUpdateResume",
8264 bgp
->update_delay_peers_resume_time
);
8269 "Read-only mode update-delay limit: %d seconds\n",
8270 bgp
->v_update_delay
);
8271 if (bgp
->v_update_delay
8272 != bgp
->v_establish_wait
)
8274 " Establish wait: %d seconds\n",
8275 bgp
->v_establish_wait
);
8277 if (bgp_update_delay_active(bgp
)) {
8279 " First neighbor established: %s\n",
8280 bgp
->update_delay_begin_time
);
8282 " Delay in progress\n");
8284 if (bgp
->update_delay_over
) {
8286 " First neighbor established: %s\n",
8287 bgp
->update_delay_begin_time
);
8289 " Best-paths resumed: %s\n",
8290 bgp
->update_delay_end_time
);
8292 " zebra update resumed: %s\n",
8293 bgp
->update_delay_zebra_resume_time
);
8295 " peers update resumed: %s\n",
8296 bgp
->update_delay_peers_resume_time
);
8303 if (bgp_maxmed_onstartup_configured(bgp
)
8304 && bgp
->maxmed_active
)
8305 json_object_boolean_true_add(
8306 json
, "maxMedOnStartup");
8307 if (bgp
->v_maxmed_admin
)
8308 json_object_boolean_true_add(
8309 json
, "maxMedAdministrative");
8311 json_object_int_add(
8312 json
, "tableVersion",
8313 bgp_table_version(bgp
->rib
[afi
][safi
]));
8315 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8316 json_object_int_add(json
, "ribCount", ents
);
8317 json_object_int_add(
8319 ents
* sizeof(struct bgp_node
));
8321 ents
= bgp
->af_peer_count
[afi
][safi
];
8322 json_object_int_add(json
, "peerCount", ents
);
8323 json_object_int_add(json
, "peerMemory",
8324 ents
* sizeof(struct peer
));
8326 if ((ents
= listcount(bgp
->group
))) {
8327 json_object_int_add(
8328 json
, "peerGroupCount", ents
);
8329 json_object_int_add(
8330 json
, "peerGroupMemory",
8331 ents
* sizeof(struct
8335 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8336 BGP_CONFIG_DAMPENING
))
8337 json_object_boolean_true_add(
8338 json
, "dampeningEnabled");
8340 if (bgp_maxmed_onstartup_configured(bgp
)
8341 && bgp
->maxmed_active
)
8343 "Max-med on-startup active\n");
8344 if (bgp
->v_maxmed_admin
)
8346 "Max-med administrative active\n");
8348 vty_out(vty
, "BGP table version %" PRIu64
"\n",
8349 bgp_table_version(bgp
->rib
[afi
][safi
]));
8351 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8353 "RIB entries %ld, using %s of memory\n",
8355 mtype_memstr(memstrbuf
,
8357 ents
* sizeof(struct
8360 /* Peer related usage */
8361 ents
= bgp
->af_peer_count
[afi
][safi
];
8362 vty_out(vty
, "Peers %ld, using %s of memory\n",
8365 memstrbuf
, sizeof(memstrbuf
),
8366 ents
* sizeof(struct peer
)));
8368 if ((ents
= listcount(bgp
->group
)))
8370 "Peer groups %ld, using %s of memory\n",
8375 ents
* sizeof(struct
8378 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8379 BGP_CONFIG_DAMPENING
))
8380 vty_out(vty
, "Dampening enabled.\n");
8383 /* Subtract 8 here because 'Neighbor' is
8385 vty_out(vty
, "Neighbor");
8386 vty_out(vty
, "%*s", max_neighbor_width
- 8,
8389 vty_out(vty
, "EstdCnt DropCnt ResetTime Reason\n");
8392 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
8397 /* Works for both failed & successful cases */
8398 if (peer_dynamic_neighbor(peer
))
8405 bgp_has_peer_failed(peer
, afi
, safi
)) {
8406 json_peer
= json_object_new_object();
8407 bgp_show_failed_summary(vty
, bgp
, peer
,
8408 json_peer
, 0, use_json
);
8409 } else if (!show_failed
) {
8410 json_peer
= json_object_new_object();
8411 if (peer_dynamic_neighbor(peer
)) {
8412 json_object_boolean_true_add(json_peer
,
8417 json_object_string_add(json_peer
, "hostname",
8420 if (peer
->domainname
)
8421 json_object_string_add(json_peer
, "domainname",
8424 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
8425 json_object_int_add(json_peer
, "version", 4);
8426 json_object_int_add(json_peer
, "msgRcvd",
8427 PEER_TOTAL_RX(peer
));
8428 json_object_int_add(json_peer
, "msgSent",
8429 PEER_TOTAL_TX(peer
));
8431 json_object_int_add(json_peer
, "tableVersion",
8432 peer
->version
[afi
][safi
]);
8433 json_object_int_add(json_peer
, "outq",
8435 json_object_int_add(json_peer
, "inq", 0);
8436 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8437 use_json
, json_peer
);
8440 * Adding "pfxRcd" field to match with the corresponding
8441 * CLI. "prefixReceivedCount" will be deprecated in
8444 json_object_int_add(json_peer
, "prefixReceivedCount",
8445 peer
->pcount
[afi
][pfx_rcd_safi
]);
8446 json_object_int_add(json_peer
, "pfxRcd",
8447 peer
->pcount
[afi
][pfx_rcd_safi
]);
8449 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
8450 if (paf
&& PAF_SUBGRP(paf
))
8451 json_object_int_add(json_peer
,
8453 (PAF_SUBGRP(paf
))->scount
);
8454 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8455 json_object_string_add(json_peer
, "state",
8457 else if (peer
->afc_recv
[afi
][safi
])
8458 json_object_string_add(
8460 lookup_msg(bgp_status_msg
, peer
->status
,
8462 else if (CHECK_FLAG(peer
->sflags
,
8463 PEER_STATUS_PREFIX_OVERFLOW
))
8464 json_object_string_add(json_peer
, "state",
8467 json_object_string_add(
8469 lookup_msg(bgp_status_msg
, peer
->status
,
8471 json_object_int_add(json_peer
, "connectionsEstablished",
8473 json_object_int_add(json_peer
, "connectionsDropped",
8476 /* Avoid creating empty peer dicts in JSON */
8477 if (json_peer
== NULL
)
8481 json_object_string_add(json_peer
, "idType",
8483 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8484 json_object_string_add(json_peer
, "idType",
8486 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8487 json_object_string_add(json_peer
, "idType",
8489 json_object_object_add(json_peers
, peer
->host
,
8493 bgp_has_peer_failed(peer
, afi
, safi
)) {
8494 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
8497 } else if (!show_failed
) {
8498 memset(dn_flag
, '\0', sizeof(dn_flag
));
8499 if (peer_dynamic_neighbor(peer
)) {
8504 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8505 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8506 peer
->hostname
, peer
->host
);
8508 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8510 /* pad the neighbor column with spaces */
8511 if (len
< max_neighbor_width
)
8512 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8515 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8516 peer
->as
, PEER_TOTAL_RX(peer
),
8517 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8518 0, peer
->obuf
->count
,
8519 peer_uptime(peer
->uptime
, timebuf
,
8520 BGP_UPTIME_LEN
, 0, NULL
));
8522 if (peer
->status
== Established
)
8523 if (peer
->afc_recv
[afi
][safi
])
8524 vty_out(vty
, " %12" PRIu32
,
8529 vty_out(vty
, " NoNeg");
8531 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8532 vty_out(vty
, " Idle (Admin)");
8533 else if (CHECK_FLAG(
8535 PEER_STATUS_PREFIX_OVERFLOW
))
8536 vty_out(vty
, " Idle (PfxCt)");
8538 vty_out(vty
, " %12s",
8539 lookup_msg(bgp_status_msg
,
8540 peer
->status
, NULL
));
8549 json_object_object_add(json
, "peers", json_peers
);
8550 json_object_int_add(json
, "failedPeers", failed_count
);
8551 json_object_int_add(json
, "totalPeers", count
);
8552 json_object_int_add(json
, "dynamicPeers", dn_count
);
8555 bgp_show_bestpath_json(bgp
, json
);
8557 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8558 json
, JSON_C_TO_STRING_PRETTY
));
8559 json_object_free(json
);
8562 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8564 vty_out(vty
, "No %s neighbor is configured\n",
8565 get_afi_safi_str(afi
, safi
, false));
8569 vty_out(vty
, "* - dynamic neighbor\n");
8570 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8571 dn_count
, bgp
->dynamic_neighbors_limit
);
8578 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8579 int safi
, bool show_failed
, bool use_json
)
8582 int afi_wildcard
= (afi
== AFI_MAX
);
8583 int safi_wildcard
= (safi
== SAFI_MAX
);
8584 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8585 bool nbr_output
= false;
8587 if (use_json
&& is_wildcard
)
8588 vty_out(vty
, "{\n");
8590 afi
= 1; /* AFI_IP */
8591 while (afi
< AFI_MAX
) {
8593 safi
= 1; /* SAFI_UNICAST */
8594 while (safi
< SAFI_MAX
) {
8595 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8600 * So limit output to those afi/safi
8602 * actualy have something interesting in
8607 vty_out(vty
, ",\n");
8611 vty_out(vty
, "\"%s\":",
8612 get_afi_safi_str(afi
,
8616 vty_out(vty
, "\n%s Summary:\n",
8617 get_afi_safi_str(afi
,
8622 bgp_show_summary(vty
, bgp
, afi
, safi
, show_failed
,
8634 if (use_json
&& is_wildcard
)
8635 vty_out(vty
, "}\n");
8636 else if (!nbr_output
) {
8638 vty_out(vty
, "{}\n");
8640 vty_out(vty
, "%% No BGP neighbors found\n");
8644 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8645 safi_t safi
, bool show_failed
,
8648 struct listnode
*node
, *nnode
;
8651 bool nbr_output
= false;
8654 vty_out(vty
, "{\n");
8656 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8660 vty_out(vty
, ",\n");
8664 vty_out(vty
, "\"%s\":",
8665 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8669 vty_out(vty
, "\nInstance %s:\n",
8670 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8674 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
8679 vty_out(vty
, "}\n");
8680 else if (!nbr_output
)
8681 vty_out(vty
, "%% BGP instance not found\n");
8684 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8685 safi_t safi
, bool show_failed
, bool use_json
)
8690 if (strmatch(name
, "all")) {
8691 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8696 bgp
= bgp_lookup_by_name(name
);
8700 vty_out(vty
, "{}\n");
8703 "%% BGP instance not found\n");
8707 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
,
8708 show_failed
, use_json
);
8713 bgp
= bgp_get_default();
8716 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
8720 vty_out(vty
, "{}\n");
8722 vty_out(vty
, "%% BGP instance not found\n");
8729 /* `show [ip] bgp summary' commands. */
8730 DEFUN (show_ip_bgp_summary
,
8731 show_ip_bgp_summary_cmd
,
8732 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [failed] [json]",
8736 BGP_INSTANCE_HELP_STR
8738 BGP_SAFI_WITH_LABEL_HELP_STR
8739 "Summary of BGP neighbor status\n"
8740 "Show only sessions not in Established state\n"
8744 afi_t afi
= AFI_MAX
;
8745 safi_t safi
= SAFI_MAX
;
8746 bool show_failed
= false;
8751 if (argv_find(argv
, argc
, "ip", &idx
))
8753 /* [<vrf> VIEWVRFNAME] */
8754 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8755 vrf
= argv
[idx
+ 1]->arg
;
8756 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8758 } else if (argv_find(argv
, argc
, "view", &idx
))
8759 /* [<view> VIEWVRFNAME] */
8760 vrf
= argv
[idx
+ 1]->arg
;
8761 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8762 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8763 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8766 if (argv_find(argv
, argc
, "failed", &idx
))
8769 bool uj
= use_json(argc
, argv
);
8771 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, show_failed
, uj
);
8774 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
8777 return get_afi_safi_json_str(afi
, safi
);
8779 return get_afi_safi_vty_str(afi
, safi
);
8782 /* Show BGP peer's information. */
8783 enum show_type
{ show_all
, show_peer
, show_ipv4_all
, show_ipv6_all
, show_ipv4_peer
, show_ipv6_peer
};
8785 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8786 afi_t afi
, safi_t safi
,
8787 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8788 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8789 bool use_json
, json_object
*json_pref
)
8792 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8793 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8795 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8796 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8797 json_object_string_add(json_pref
, "sendMode",
8798 "advertisedAndReceived");
8799 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8800 json_object_string_add(json_pref
, "sendMode",
8802 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8803 json_object_string_add(json_pref
, "sendMode",
8806 vty_out(vty
, " Send-mode: ");
8807 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8808 vty_out(vty
, "advertised");
8809 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8810 vty_out(vty
, "%sreceived",
8811 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8820 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8821 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8823 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8824 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8825 json_object_string_add(json_pref
, "recvMode",
8826 "advertisedAndReceived");
8827 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8828 json_object_string_add(json_pref
, "recvMode",
8830 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8831 json_object_string_add(json_pref
, "recvMode",
8834 vty_out(vty
, " Receive-mode: ");
8835 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8836 vty_out(vty
, "advertised");
8837 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8838 vty_out(vty
, "%sreceived",
8839 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8848 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8849 safi_t safi
, bool use_json
,
8850 json_object
*json_neigh
)
8852 struct bgp_filter
*filter
;
8853 struct peer_af
*paf
;
8854 char orf_pfx_name
[BUFSIZ
];
8856 json_object
*json_af
= NULL
;
8857 json_object
*json_prefA
= NULL
;
8858 json_object
*json_prefB
= NULL
;
8859 json_object
*json_addr
= NULL
;
8862 json_addr
= json_object_new_object();
8863 json_af
= json_object_new_object();
8864 filter
= &p
->filter
[afi
][safi
];
8866 if (peer_group_active(p
))
8867 json_object_string_add(json_addr
, "peerGroupMember",
8870 paf
= peer_af_find(p
, afi
, safi
);
8871 if (paf
&& PAF_SUBGRP(paf
)) {
8872 json_object_int_add(json_addr
, "updateGroupId",
8873 PAF_UPDGRP(paf
)->id
);
8874 json_object_int_add(json_addr
, "subGroupId",
8875 PAF_SUBGRP(paf
)->id
);
8876 json_object_int_add(json_addr
, "packetQueueLength",
8877 bpacket_queue_virtual_length(paf
));
8880 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8881 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8882 PEER_CAP_ORF_PREFIX_SM_RCV
)
8883 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8884 PEER_CAP_ORF_PREFIX_RM_ADV
)
8885 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8886 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8887 json_object_int_add(json_af
, "orfType",
8889 json_prefA
= json_object_new_object();
8890 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8891 PEER_CAP_ORF_PREFIX_SM_ADV
,
8892 PEER_CAP_ORF_PREFIX_RM_ADV
,
8893 PEER_CAP_ORF_PREFIX_SM_RCV
,
8894 PEER_CAP_ORF_PREFIX_RM_RCV
,
8895 use_json
, json_prefA
);
8896 json_object_object_add(json_af
, "orfPrefixList",
8900 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8901 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8902 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8903 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8904 PEER_CAP_ORF_PREFIX_RM_ADV
)
8905 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8906 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8907 json_object_int_add(json_af
, "orfOldType",
8908 ORF_TYPE_PREFIX_OLD
);
8909 json_prefB
= json_object_new_object();
8910 bgp_show_peer_afi_orf_cap(
8911 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8912 PEER_CAP_ORF_PREFIX_RM_ADV
,
8913 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8914 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8916 json_object_object_add(json_af
, "orfOldPrefixList",
8920 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8921 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8922 PEER_CAP_ORF_PREFIX_SM_RCV
)
8923 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8924 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8925 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8926 PEER_CAP_ORF_PREFIX_RM_ADV
)
8927 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8928 PEER_CAP_ORF_PREFIX_RM_RCV
)
8929 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8930 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8931 json_object_object_add(json_addr
, "afDependentCap",
8934 json_object_free(json_af
);
8936 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8937 orf_pfx_count
= prefix_bgp_show_prefix_list(
8938 NULL
, afi
, orf_pfx_name
, use_json
);
8940 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8941 PEER_STATUS_ORF_PREFIX_SEND
)
8943 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8944 PEER_STATUS_ORF_PREFIX_SEND
))
8945 json_object_boolean_true_add(json_neigh
,
8948 json_object_int_add(json_addr
, "orfRecvCounter",
8951 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8952 PEER_STATUS_ORF_WAIT_REFRESH
))
8953 json_object_string_add(
8954 json_addr
, "orfFirstUpdate",
8955 "deferredUntilORFOrRouteRefreshRecvd");
8957 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8958 PEER_FLAG_REFLECTOR_CLIENT
))
8959 json_object_boolean_true_add(json_addr
,
8960 "routeReflectorClient");
8961 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8962 PEER_FLAG_RSERVER_CLIENT
))
8963 json_object_boolean_true_add(json_addr
,
8964 "routeServerClient");
8965 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8966 json_object_boolean_true_add(json_addr
,
8967 "inboundSoftConfigPermit");
8969 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8970 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8971 json_object_boolean_true_add(
8973 "privateAsNumsAllReplacedInUpdatesToNbr");
8974 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8975 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8976 json_object_boolean_true_add(
8978 "privateAsNumsReplacedInUpdatesToNbr");
8979 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8980 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8981 json_object_boolean_true_add(
8983 "privateAsNumsAllRemovedInUpdatesToNbr");
8984 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8985 PEER_FLAG_REMOVE_PRIVATE_AS
))
8986 json_object_boolean_true_add(
8988 "privateAsNumsRemovedInUpdatesToNbr");
8990 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8991 json_object_boolean_true_add(
8993 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8996 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8997 json_object_string_add(json_addr
,
8998 "overrideASNsInOutboundUpdates",
8999 "ifAspathEqualRemoteAs");
9001 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
9002 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9003 PEER_FLAG_FORCE_NEXTHOP_SELF
))
9004 json_object_boolean_true_add(json_addr
,
9005 "routerAlwaysNextHop");
9006 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9007 PEER_FLAG_AS_PATH_UNCHANGED
))
9008 json_object_boolean_true_add(
9009 json_addr
, "unchangedAsPathPropogatedToNbr");
9010 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9011 PEER_FLAG_NEXTHOP_UNCHANGED
))
9012 json_object_boolean_true_add(
9013 json_addr
, "unchangedNextHopPropogatedToNbr");
9014 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
9015 json_object_boolean_true_add(
9016 json_addr
, "unchangedMedPropogatedToNbr");
9017 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
9018 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9019 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
9020 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9021 PEER_FLAG_SEND_COMMUNITY
)
9022 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9023 PEER_FLAG_SEND_EXT_COMMUNITY
))
9024 json_object_string_add(json_addr
,
9025 "commAttriSentToNbr",
9026 "extendedAndStandard");
9027 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9028 PEER_FLAG_SEND_EXT_COMMUNITY
))
9029 json_object_string_add(json_addr
,
9030 "commAttriSentToNbr",
9033 json_object_string_add(json_addr
,
9034 "commAttriSentToNbr",
9037 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9038 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9039 if (p
->default_rmap
[afi
][safi
].name
)
9040 json_object_string_add(
9041 json_addr
, "defaultRouteMap",
9042 p
->default_rmap
[afi
][safi
].name
);
9044 if (paf
&& PAF_SUBGRP(paf
)
9045 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9046 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9047 json_object_boolean_true_add(json_addr
,
9050 json_object_boolean_true_add(json_addr
,
9054 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9055 if (is_evpn_enabled())
9056 json_object_boolean_true_add(
9057 json_addr
, "advertiseAllVnis");
9060 if (filter
->plist
[FILTER_IN
].name
9061 || filter
->dlist
[FILTER_IN
].name
9062 || filter
->aslist
[FILTER_IN
].name
9063 || filter
->map
[RMAP_IN
].name
)
9064 json_object_boolean_true_add(json_addr
,
9065 "inboundPathPolicyConfig");
9066 if (filter
->plist
[FILTER_OUT
].name
9067 || filter
->dlist
[FILTER_OUT
].name
9068 || filter
->aslist
[FILTER_OUT
].name
9069 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9070 json_object_boolean_true_add(
9071 json_addr
, "outboundPathPolicyConfig");
9074 if (filter
->plist
[FILTER_IN
].name
)
9075 json_object_string_add(json_addr
,
9076 "incomingUpdatePrefixFilterList",
9077 filter
->plist
[FILTER_IN
].name
);
9078 if (filter
->plist
[FILTER_OUT
].name
)
9079 json_object_string_add(json_addr
,
9080 "outgoingUpdatePrefixFilterList",
9081 filter
->plist
[FILTER_OUT
].name
);
9083 /* distribute-list */
9084 if (filter
->dlist
[FILTER_IN
].name
)
9085 json_object_string_add(
9086 json_addr
, "incomingUpdateNetworkFilterList",
9087 filter
->dlist
[FILTER_IN
].name
);
9088 if (filter
->dlist
[FILTER_OUT
].name
)
9089 json_object_string_add(
9090 json_addr
, "outgoingUpdateNetworkFilterList",
9091 filter
->dlist
[FILTER_OUT
].name
);
9094 if (filter
->aslist
[FILTER_IN
].name
)
9095 json_object_string_add(json_addr
,
9096 "incomingUpdateAsPathFilterList",
9097 filter
->aslist
[FILTER_IN
].name
);
9098 if (filter
->aslist
[FILTER_OUT
].name
)
9099 json_object_string_add(json_addr
,
9100 "outgoingUpdateAsPathFilterList",
9101 filter
->aslist
[FILTER_OUT
].name
);
9104 if (filter
->map
[RMAP_IN
].name
)
9105 json_object_string_add(
9106 json_addr
, "routeMapForIncomingAdvertisements",
9107 filter
->map
[RMAP_IN
].name
);
9108 if (filter
->map
[RMAP_OUT
].name
)
9109 json_object_string_add(
9110 json_addr
, "routeMapForOutgoingAdvertisements",
9111 filter
->map
[RMAP_OUT
].name
);
9113 /* ebgp-requires-policy (inbound) */
9114 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9115 && !bgp_inbound_policy_exists(p
, filter
))
9116 json_object_string_add(
9117 json_addr
, "inboundEbgpRequiresPolicy",
9118 "Inbound updates discarded due to missing policy");
9120 /* ebgp-requires-policy (outbound) */
9121 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9122 && (!bgp_outbound_policy_exists(p
, filter
)))
9123 json_object_string_add(
9124 json_addr
, "outboundEbgpRequiresPolicy",
9125 "Outbound updates discarded due to missing policy");
9127 /* unsuppress-map */
9128 if (filter
->usmap
.name
)
9129 json_object_string_add(json_addr
,
9130 "selectiveUnsuppressRouteMap",
9131 filter
->usmap
.name
);
9133 /* Receive prefix count */
9134 json_object_int_add(json_addr
, "acceptedPrefixCounter",
9135 p
->pcount
[afi
][safi
]);
9136 if (paf
&& PAF_SUBGRP(paf
))
9137 json_object_int_add(json_addr
, "sentPrefixCounter",
9138 (PAF_SUBGRP(paf
))->scount
);
9140 /* Maximum prefix */
9141 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9142 json_object_int_add(json_addr
, "prefixAllowedMax",
9143 p
->pmax
[afi
][safi
]);
9144 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9145 PEER_FLAG_MAX_PREFIX_WARNING
))
9146 json_object_boolean_true_add(
9147 json_addr
, "prefixAllowedMaxWarning");
9148 json_object_int_add(json_addr
,
9149 "prefixAllowedWarningThresh",
9150 p
->pmax_threshold
[afi
][safi
]);
9151 if (p
->pmax_restart
[afi
][safi
])
9152 json_object_int_add(
9154 "prefixAllowedRestartIntervalMsecs",
9155 p
->pmax_restart
[afi
][safi
] * 60000);
9157 json_object_object_add(json_neigh
, get_afi_safi_str(afi
, safi
, true),
9161 filter
= &p
->filter
[afi
][safi
];
9163 vty_out(vty
, " For address family: %s\n",
9164 get_afi_safi_str(afi
, safi
, false));
9166 if (peer_group_active(p
))
9167 vty_out(vty
, " %s peer-group member\n",
9170 paf
= peer_af_find(p
, afi
, safi
);
9171 if (paf
&& PAF_SUBGRP(paf
)) {
9172 vty_out(vty
, " Update group %" PRIu64
9173 ", subgroup %" PRIu64
"\n",
9174 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
9175 vty_out(vty
, " Packet Queue length %d\n",
9176 bpacket_queue_virtual_length(paf
));
9178 vty_out(vty
, " Not part of any update group\n");
9180 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9181 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9182 PEER_CAP_ORF_PREFIX_SM_RCV
)
9183 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9184 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
9185 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9186 PEER_CAP_ORF_PREFIX_RM_ADV
)
9187 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9188 PEER_CAP_ORF_PREFIX_RM_RCV
)
9189 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9190 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
9191 vty_out(vty
, " AF-dependant capabilities:\n");
9193 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9194 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9195 PEER_CAP_ORF_PREFIX_SM_RCV
)
9196 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9197 PEER_CAP_ORF_PREFIX_RM_ADV
)
9198 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9199 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
9201 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
9203 bgp_show_peer_afi_orf_cap(
9204 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
9205 PEER_CAP_ORF_PREFIX_RM_ADV
,
9206 PEER_CAP_ORF_PREFIX_SM_RCV
,
9207 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
9209 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9210 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9211 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
9212 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9213 PEER_CAP_ORF_PREFIX_RM_ADV
)
9214 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9215 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
9217 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
9218 ORF_TYPE_PREFIX_OLD
);
9219 bgp_show_peer_afi_orf_cap(
9220 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
9221 PEER_CAP_ORF_PREFIX_RM_ADV
,
9222 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
9223 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
9226 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
9227 orf_pfx_count
= prefix_bgp_show_prefix_list(
9228 NULL
, afi
, orf_pfx_name
, use_json
);
9230 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9231 PEER_STATUS_ORF_PREFIX_SEND
)
9233 vty_out(vty
, " Outbound Route Filter (ORF):");
9234 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9235 PEER_STATUS_ORF_PREFIX_SEND
))
9236 vty_out(vty
, " sent;");
9238 vty_out(vty
, " received (%d entries)",
9242 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9243 PEER_STATUS_ORF_WAIT_REFRESH
))
9245 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
9247 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9248 PEER_FLAG_REFLECTOR_CLIENT
))
9249 vty_out(vty
, " Route-Reflector Client\n");
9250 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9251 PEER_FLAG_RSERVER_CLIENT
))
9252 vty_out(vty
, " Route-Server Client\n");
9253 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9255 " Inbound soft reconfiguration allowed\n");
9257 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9258 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
9260 " Private AS numbers (all) replaced in updates to this neighbor\n");
9261 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9262 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
9264 " Private AS numbers replaced in updates to this neighbor\n");
9265 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9266 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
9268 " Private AS numbers (all) removed in updates to this neighbor\n");
9269 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9270 PEER_FLAG_REMOVE_PRIVATE_AS
))
9272 " Private AS numbers removed in updates to this neighbor\n");
9274 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
9275 vty_out(vty
, " %s\n",
9276 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
9277 ->human_description
);
9279 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
9281 " Override ASNs in outbound updates if aspath equals remote-as\n");
9283 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
9284 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9285 PEER_FLAG_FORCE_NEXTHOP_SELF
))
9286 vty_out(vty
, " NEXT_HOP is always this router\n");
9287 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9288 PEER_FLAG_AS_PATH_UNCHANGED
))
9290 " AS_PATH is propagated unchanged to this neighbor\n");
9291 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9292 PEER_FLAG_NEXTHOP_UNCHANGED
))
9294 " NEXT_HOP is propagated unchanged to this neighbor\n");
9295 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
9297 " MED is propagated unchanged to this neighbor\n");
9298 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
9299 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9300 PEER_FLAG_SEND_EXT_COMMUNITY
)
9301 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9302 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
9304 " Community attribute sent to this neighbor");
9305 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9306 PEER_FLAG_SEND_COMMUNITY
)
9307 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9308 PEER_FLAG_SEND_EXT_COMMUNITY
)
9309 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9310 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9311 vty_out(vty
, "(all)\n");
9312 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9313 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9314 vty_out(vty
, "(large)\n");
9315 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9316 PEER_FLAG_SEND_EXT_COMMUNITY
))
9317 vty_out(vty
, "(extended)\n");
9319 vty_out(vty
, "(standard)\n");
9321 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9322 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9323 vty_out(vty
, " Default information originate,");
9325 if (p
->default_rmap
[afi
][safi
].name
)
9326 vty_out(vty
, " default route-map %s%s,",
9327 p
->default_rmap
[afi
][safi
].map
? "*"
9329 p
->default_rmap
[afi
][safi
].name
);
9330 if (paf
&& PAF_SUBGRP(paf
)
9331 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9332 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9333 vty_out(vty
, " default sent\n");
9335 vty_out(vty
, " default not sent\n");
9338 /* advertise-vni-all */
9339 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9340 if (is_evpn_enabled())
9341 vty_out(vty
, " advertise-all-vni\n");
9344 if (filter
->plist
[FILTER_IN
].name
9345 || filter
->dlist
[FILTER_IN
].name
9346 || filter
->aslist
[FILTER_IN
].name
9347 || filter
->map
[RMAP_IN
].name
)
9348 vty_out(vty
, " Inbound path policy configured\n");
9349 if (filter
->plist
[FILTER_OUT
].name
9350 || filter
->dlist
[FILTER_OUT
].name
9351 || filter
->aslist
[FILTER_OUT
].name
9352 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9353 vty_out(vty
, " Outbound path policy configured\n");
9356 if (filter
->plist
[FILTER_IN
].name
)
9358 " Incoming update prefix filter list is %s%s\n",
9359 filter
->plist
[FILTER_IN
].plist
? "*" : "",
9360 filter
->plist
[FILTER_IN
].name
);
9361 if (filter
->plist
[FILTER_OUT
].name
)
9363 " Outgoing update prefix filter list is %s%s\n",
9364 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
9365 filter
->plist
[FILTER_OUT
].name
);
9367 /* distribute-list */
9368 if (filter
->dlist
[FILTER_IN
].name
)
9370 " Incoming update network filter list is %s%s\n",
9371 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
9372 filter
->dlist
[FILTER_IN
].name
);
9373 if (filter
->dlist
[FILTER_OUT
].name
)
9375 " Outgoing update network filter list is %s%s\n",
9376 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
9377 filter
->dlist
[FILTER_OUT
].name
);
9380 if (filter
->aslist
[FILTER_IN
].name
)
9382 " Incoming update AS path filter list is %s%s\n",
9383 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
9384 filter
->aslist
[FILTER_IN
].name
);
9385 if (filter
->aslist
[FILTER_OUT
].name
)
9387 " Outgoing update AS path filter list is %s%s\n",
9388 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
9389 filter
->aslist
[FILTER_OUT
].name
);
9392 if (filter
->map
[RMAP_IN
].name
)
9394 " Route map for incoming advertisements is %s%s\n",
9395 filter
->map
[RMAP_IN
].map
? "*" : "",
9396 filter
->map
[RMAP_IN
].name
);
9397 if (filter
->map
[RMAP_OUT
].name
)
9399 " Route map for outgoing advertisements is %s%s\n",
9400 filter
->map
[RMAP_OUT
].map
? "*" : "",
9401 filter
->map
[RMAP_OUT
].name
);
9403 /* ebgp-requires-policy (inbound) */
9404 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9405 && !bgp_inbound_policy_exists(p
, filter
))
9407 " Inbound updates discarded due to missing policy\n");
9409 /* ebgp-requires-policy (outbound) */
9410 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9411 && !bgp_outbound_policy_exists(p
, filter
))
9413 " Outbound updates discarded due to missing policy\n");
9415 /* unsuppress-map */
9416 if (filter
->usmap
.name
)
9418 " Route map for selective unsuppress is %s%s\n",
9419 filter
->usmap
.map
? "*" : "",
9420 filter
->usmap
.name
);
9422 /* Receive prefix count */
9423 vty_out(vty
, " %" PRIu32
" accepted prefixes\n",
9424 p
->pcount
[afi
][safi
]);
9426 /* Maximum prefix */
9427 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9429 " Maximum prefixes allowed %" PRIu32
"%s\n",
9431 CHECK_FLAG(p
->af_flags
[afi
][safi
],
9432 PEER_FLAG_MAX_PREFIX_WARNING
)
9435 vty_out(vty
, " Threshold for warning message %d%%",
9436 p
->pmax_threshold
[afi
][safi
]);
9437 if (p
->pmax_restart
[afi
][safi
])
9438 vty_out(vty
, ", restart interval %d min",
9439 p
->pmax_restart
[afi
][safi
]);
9447 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
9451 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
9452 char timebuf
[BGP_UPTIME_LEN
];
9458 json_object
*json_neigh
= NULL
;
9464 json_neigh
= json_object_new_object();
9466 memset(dn_flag
, '\0', sizeof(dn_flag
));
9467 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9471 if (p
->conf_if
) /* Configured interface name. */
9472 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9473 BGP_PEER_SU_UNSPEC(p
)
9475 : sockunion2str(&p
->su
, buf
,
9477 else /* Configured IP address. */
9478 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9483 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9484 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9486 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9487 json_object_string_add(
9488 json_neigh
, "bgpNeighborAddr",
9489 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9491 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9493 if (p
->change_local_as
)
9494 json_object_int_add(json_neigh
, "localAs",
9495 p
->change_local_as
);
9497 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9499 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9500 json_object_boolean_true_add(json_neigh
,
9501 "localAsNoPrepend");
9503 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9504 json_object_boolean_true_add(json_neigh
,
9505 "localAsReplaceAs");
9507 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9508 || (p
->as_type
== AS_INTERNAL
))
9509 vty_out(vty
, "remote AS %u, ", p
->as
);
9511 vty_out(vty
, "remote AS Unspecified, ");
9512 vty_out(vty
, "local AS %u%s%s, ",
9513 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9514 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9517 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9521 /* peer type internal or confed-internal */
9522 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
9524 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9525 json_object_boolean_true_add(
9526 json_neigh
, "nbrConfedInternalLink");
9528 json_object_boolean_true_add(json_neigh
,
9531 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9532 vty_out(vty
, "confed-internal link\n");
9534 vty_out(vty
, "internal link\n");
9536 /* peer type external or confed-external */
9537 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
9539 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9540 json_object_boolean_true_add(
9541 json_neigh
, "nbrConfedExternalLink");
9543 json_object_boolean_true_add(json_neigh
,
9546 if (bgp_confederation_peers_check(bgp
, p
->as
))
9547 vty_out(vty
, "confed-external link\n");
9549 vty_out(vty
, "external link\n");
9553 json_object_boolean_true_add(json_neigh
,
9554 "nbrUnspecifiedLink");
9556 vty_out(vty
, "unspecified link\n");
9562 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9564 vty_out(vty
, " Description: %s\n", p
->desc
);
9570 json_object_string_add(json_neigh
, "hostname",
9574 json_object_string_add(json_neigh
, "domainname",
9577 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9578 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9581 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9588 json_object_string_add(json_neigh
, "peerGroup",
9592 struct prefix prefix
, *range
= NULL
;
9594 sockunion2hostprefix(&(p
->su
), &prefix
);
9595 range
= peer_group_lookup_dynamic_neighbor_range(
9599 prefix2str(range
, buf1
, sizeof(buf1
));
9600 json_object_string_add(
9602 "peerSubnetRangeGroup", buf1
);
9607 " Member of peer-group %s for session parameters\n",
9611 struct prefix prefix
, *range
= NULL
;
9613 sockunion2hostprefix(&(p
->su
), &prefix
);
9614 range
= peer_group_lookup_dynamic_neighbor_range(
9618 prefix2str(range
, buf1
, sizeof(buf1
));
9620 " Belongs to the subnet range group: %s\n",
9628 /* Administrative shutdown. */
9629 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9630 json_object_boolean_true_add(json_neigh
,
9634 json_object_int_add(json_neigh
, "bgpVersion", 4);
9635 json_object_string_add(
9636 json_neigh
, "remoteRouterId",
9637 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9638 json_object_string_add(
9639 json_neigh
, "localRouterId",
9640 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9644 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9645 && bgp_confederation_peers_check(bgp
, p
->as
))
9646 json_object_boolean_true_add(json_neigh
,
9650 json_object_string_add(
9651 json_neigh
, "bgpState",
9652 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9654 if (p
->status
== Established
) {
9657 uptime
= bgp_clock();
9658 uptime
-= p
->uptime
;
9659 epoch_tbuf
= time(NULL
) - uptime
;
9661 #if CONFDATE > 20200101
9663 "bgpTimerUp should be deprecated and can be removed now");
9666 * bgpTimerUp was miliseconds that was accurate
9667 * up to 1 day, then the value returned
9668 * became garbage. So in order to provide
9669 * some level of backwards compatability,
9670 * we still provde the data, but now
9671 * we are returning the correct value
9672 * and also adding a new bgpTimerUpMsec
9673 * which will allow us to deprecate
9676 json_object_int_add(json_neigh
, "bgpTimerUp",
9678 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9680 json_object_string_add(json_neigh
, "bgpTimerUpString",
9681 peer_uptime(p
->uptime
, timebuf
,
9684 json_object_int_add(json_neigh
,
9685 "bgpTimerUpEstablishedEpoch",
9689 else if (p
->status
== Active
) {
9690 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9691 json_object_string_add(json_neigh
, "bgpStateIs",
9693 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9694 json_object_string_add(json_neigh
, "bgpStateIs",
9702 uptime
= bgp_clock();
9703 uptime
-= p
->readtime
;
9704 tm
= gmtime(&uptime
);
9705 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9706 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9707 + (tm
->tm_hour
* 3600000));
9709 uptime
= bgp_clock();
9710 uptime
-= p
->last_write
;
9711 tm
= gmtime(&uptime
);
9712 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9713 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9714 + (tm
->tm_hour
* 3600000));
9716 uptime
= bgp_clock();
9717 uptime
-= p
->update_time
;
9718 tm
= gmtime(&uptime
);
9719 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9720 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9721 + (tm
->tm_hour
* 3600000));
9723 /* Configured timer values. */
9724 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9725 p
->v_holdtime
* 1000);
9726 json_object_int_add(json_neigh
,
9727 "bgpTimerKeepAliveIntervalMsecs",
9728 p
->v_keepalive
* 1000);
9729 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9730 json_object_int_add(json_neigh
,
9731 "bgpTimerConfiguredHoldTimeMsecs",
9732 p
->holdtime
* 1000);
9733 json_object_int_add(
9735 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9736 p
->keepalive
* 1000);
9737 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9738 || (bgp
->default_keepalive
9739 != BGP_DEFAULT_KEEPALIVE
)) {
9740 json_object_int_add(json_neigh
,
9741 "bgpTimerConfiguredHoldTimeMsecs",
9742 bgp
->default_holdtime
);
9743 json_object_int_add(
9745 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9746 bgp
->default_keepalive
);
9749 /* Administrative shutdown. */
9750 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9751 vty_out(vty
, " Administratively shut down\n");
9754 vty_out(vty
, " BGP version 4");
9755 vty_out(vty
, ", remote router ID %s",
9756 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9757 vty_out(vty
, ", local router ID %s\n",
9758 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9762 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9763 && bgp_confederation_peers_check(bgp
, p
->as
))
9765 " Neighbor under common administration\n");
9768 vty_out(vty
, " BGP state = %s",
9769 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9771 if (p
->status
== Established
)
9772 vty_out(vty
, ", up for %8s",
9773 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9776 else if (p
->status
== Active
) {
9777 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9778 vty_out(vty
, " (passive)");
9779 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9780 vty_out(vty
, " (NSF passive)");
9785 vty_out(vty
, " Last read %s",
9786 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9788 vty_out(vty
, ", Last write %s\n",
9789 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9792 /* Configured timer values. */
9794 " Hold time is %d, keepalive interval is %d seconds\n",
9795 p
->v_holdtime
, p
->v_keepalive
);
9796 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9797 vty_out(vty
, " Configured hold time is %d",
9799 vty_out(vty
, ", keepalive interval is %d seconds\n",
9801 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9802 || (bgp
->default_keepalive
9803 != BGP_DEFAULT_KEEPALIVE
)) {
9804 vty_out(vty
, " Configured hold time is %d",
9805 bgp
->default_holdtime
);
9806 vty_out(vty
, ", keepalive interval is %d seconds\n",
9807 bgp
->default_keepalive
);
9811 if (p
->status
== Established
) {
9812 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9813 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9814 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9815 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9816 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9817 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9818 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9819 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9820 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9821 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9822 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9823 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9824 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9825 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9826 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9827 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9828 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9829 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9830 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9831 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9833 json_object
*json_cap
= NULL
;
9835 json_cap
= json_object_new_object();
9838 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9839 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9840 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9841 && CHECK_FLAG(p
->cap
,
9843 json_object_string_add(
9844 json_cap
, "4byteAs",
9845 "advertisedAndReceived");
9846 else if (CHECK_FLAG(p
->cap
,
9848 json_object_string_add(
9849 json_cap
, "4byteAs",
9851 else if (CHECK_FLAG(p
->cap
,
9853 json_object_string_add(
9854 json_cap
, "4byteAs",
9859 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9860 || CHECK_FLAG(p
->cap
,
9861 PEER_CAP_ADDPATH_ADV
)) {
9862 json_object
*json_add
= NULL
;
9863 const char *print_store
;
9865 json_add
= json_object_new_object();
9867 FOREACH_AFI_SAFI (afi
, safi
) {
9868 json_object
*json_sub
= NULL
;
9870 json_object_new_object();
9871 print_store
= get_afi_safi_str(
9877 PEER_CAP_ADDPATH_AF_TX_ADV
)
9881 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9886 PEER_CAP_ADDPATH_AF_TX_ADV
)
9891 PEER_CAP_ADDPATH_AF_TX_RCV
))
9892 json_object_boolean_true_add(
9894 "txAdvertisedAndReceived");
9900 PEER_CAP_ADDPATH_AF_TX_ADV
))
9901 json_object_boolean_true_add(
9909 PEER_CAP_ADDPATH_AF_TX_RCV
))
9910 json_object_boolean_true_add(
9918 PEER_CAP_ADDPATH_AF_RX_ADV
)
9922 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9927 PEER_CAP_ADDPATH_AF_RX_ADV
)
9932 PEER_CAP_ADDPATH_AF_RX_RCV
))
9933 json_object_boolean_true_add(
9935 "rxAdvertisedAndReceived");
9941 PEER_CAP_ADDPATH_AF_RX_ADV
))
9942 json_object_boolean_true_add(
9950 PEER_CAP_ADDPATH_AF_RX_RCV
))
9951 json_object_boolean_true_add(
9959 PEER_CAP_ADDPATH_AF_TX_ADV
)
9963 PEER_CAP_ADDPATH_AF_TX_RCV
)
9967 PEER_CAP_ADDPATH_AF_RX_ADV
)
9971 PEER_CAP_ADDPATH_AF_RX_RCV
))
9972 json_object_object_add(
9981 json_object_object_add(
9982 json_cap
, "addPath", json_add
);
9986 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9987 || CHECK_FLAG(p
->cap
,
9988 PEER_CAP_DYNAMIC_ADV
)) {
9989 if (CHECK_FLAG(p
->cap
,
9990 PEER_CAP_DYNAMIC_ADV
)
9991 && CHECK_FLAG(p
->cap
,
9992 PEER_CAP_DYNAMIC_RCV
))
9993 json_object_string_add(
9994 json_cap
, "dynamic",
9995 "advertisedAndReceived");
9996 else if (CHECK_FLAG(
9998 PEER_CAP_DYNAMIC_ADV
))
9999 json_object_string_add(
10000 json_cap
, "dynamic",
10002 else if (CHECK_FLAG(
10004 PEER_CAP_DYNAMIC_RCV
))
10005 json_object_string_add(
10006 json_cap
, "dynamic",
10010 /* Extended nexthop */
10011 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10012 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10013 json_object
*json_nxt
= NULL
;
10014 const char *print_store
;
10017 if (CHECK_FLAG(p
->cap
,
10019 && CHECK_FLAG(p
->cap
,
10020 PEER_CAP_ENHE_RCV
))
10021 json_object_string_add(
10024 "advertisedAndReceived");
10025 else if (CHECK_FLAG(p
->cap
,
10026 PEER_CAP_ENHE_ADV
))
10027 json_object_string_add(
10031 else if (CHECK_FLAG(p
->cap
,
10032 PEER_CAP_ENHE_RCV
))
10033 json_object_string_add(
10038 if (CHECK_FLAG(p
->cap
,
10039 PEER_CAP_ENHE_RCV
)) {
10041 json_object_new_object();
10043 for (safi
= SAFI_UNICAST
;
10044 safi
< SAFI_MAX
; safi
++) {
10049 PEER_CAP_ENHE_AF_RCV
)) {
10050 print_store
= get_afi_safi_str(
10053 json_object_string_add(
10056 "recieved"); /* misspelled for compatibility */
10059 json_object_object_add(
10061 "extendedNexthopFamililesByPeer",
10066 /* Route Refresh */
10067 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10068 || CHECK_FLAG(p
->cap
,
10069 PEER_CAP_REFRESH_NEW_RCV
)
10070 || CHECK_FLAG(p
->cap
,
10071 PEER_CAP_REFRESH_OLD_RCV
)) {
10072 if (CHECK_FLAG(p
->cap
,
10073 PEER_CAP_REFRESH_ADV
)
10076 PEER_CAP_REFRESH_NEW_RCV
)
10079 PEER_CAP_REFRESH_OLD_RCV
))) {
10082 PEER_CAP_REFRESH_OLD_RCV
)
10085 PEER_CAP_REFRESH_NEW_RCV
))
10086 json_object_string_add(
10089 "advertisedAndReceivedOldNew");
10093 PEER_CAP_REFRESH_OLD_RCV
))
10094 json_object_string_add(
10097 "advertisedAndReceivedOld");
10099 json_object_string_add(
10102 "advertisedAndReceivedNew");
10107 PEER_CAP_REFRESH_ADV
))
10108 json_object_string_add(
10115 PEER_CAP_REFRESH_NEW_RCV
)
10118 PEER_CAP_REFRESH_OLD_RCV
))
10119 json_object_string_add(
10125 /* Multiprotocol Extensions */
10126 json_object
*json_multi
= NULL
;
10127 json_multi
= json_object_new_object();
10129 FOREACH_AFI_SAFI (afi
, safi
) {
10130 if (p
->afc_adv
[afi
][safi
]
10131 || p
->afc_recv
[afi
][safi
]) {
10132 json_object
*json_exten
= NULL
;
10134 json_object_new_object();
10136 if (p
->afc_adv
[afi
][safi
]
10137 && p
->afc_recv
[afi
][safi
])
10138 json_object_boolean_true_add(
10140 "advertisedAndReceived");
10141 else if (p
->afc_adv
[afi
][safi
])
10142 json_object_boolean_true_add(
10145 else if (p
->afc_recv
[afi
][safi
])
10146 json_object_boolean_true_add(
10150 json_object_object_add(
10152 get_afi_safi_str(afi
,
10158 json_object_object_add(
10159 json_cap
, "multiprotocolExtensions",
10162 /* Hostname capabilities */
10163 json_object
*json_hname
= NULL
;
10165 json_hname
= json_object_new_object();
10167 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10168 json_object_string_add(
10169 json_hname
, "advHostName",
10170 bgp
->peer_self
->hostname
10174 json_object_string_add(
10175 json_hname
, "advDomainName",
10176 bgp
->peer_self
->domainname
10183 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10184 json_object_string_add(
10185 json_hname
, "rcvHostName",
10186 p
->hostname
? p
->hostname
10188 json_object_string_add(
10189 json_hname
, "rcvDomainName",
10190 p
->domainname
? p
->domainname
10194 json_object_object_add(json_cap
, "hostName",
10197 /* Gracefull Restart */
10198 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10199 || CHECK_FLAG(p
->cap
,
10200 PEER_CAP_RESTART_ADV
)) {
10201 if (CHECK_FLAG(p
->cap
,
10202 PEER_CAP_RESTART_ADV
)
10203 && CHECK_FLAG(p
->cap
,
10204 PEER_CAP_RESTART_RCV
))
10205 json_object_string_add(
10208 "advertisedAndReceived");
10209 else if (CHECK_FLAG(
10211 PEER_CAP_RESTART_ADV
))
10212 json_object_string_add(
10214 "gracefulRestartCapability",
10216 else if (CHECK_FLAG(
10218 PEER_CAP_RESTART_RCV
))
10219 json_object_string_add(
10221 "gracefulRestartCapability",
10224 if (CHECK_FLAG(p
->cap
,
10225 PEER_CAP_RESTART_RCV
)) {
10226 int restart_af_count
= 0;
10227 json_object
*json_restart
=
10230 json_object_new_object();
10232 json_object_int_add(
10234 "gracefulRestartRemoteTimerMsecs",
10235 p
->v_gr_restart
* 1000);
10237 FOREACH_AFI_SAFI (afi
, safi
) {
10242 PEER_CAP_RESTART_AF_RCV
)) {
10247 json_object_new_object();
10253 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
10254 json_object_boolean_true_add(
10257 restart_af_count
++;
10258 json_object_object_add(
10267 if (!restart_af_count
) {
10268 json_object_string_add(
10270 "addressFamiliesByPeer",
10275 json_object_object_add(
10277 "addressFamiliesByPeer",
10281 json_object_object_add(json_neigh
,
10282 "neighborCapabilities",
10285 vty_out(vty
, " Neighbor capabilities:\n");
10288 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
10289 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
10290 vty_out(vty
, " 4 Byte AS:");
10291 if (CHECK_FLAG(p
->cap
,
10293 vty_out(vty
, " advertised");
10294 if (CHECK_FLAG(p
->cap
,
10296 vty_out(vty
, " %sreceived",
10302 vty_out(vty
, "\n");
10306 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
10307 || CHECK_FLAG(p
->cap
,
10308 PEER_CAP_ADDPATH_ADV
)) {
10309 vty_out(vty
, " AddPath:\n");
10311 FOREACH_AFI_SAFI (afi
, safi
) {
10315 PEER_CAP_ADDPATH_AF_TX_ADV
)
10319 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
10331 PEER_CAP_ADDPATH_AF_TX_ADV
))
10343 PEER_CAP_ADDPATH_AF_TX_RCV
))
10350 PEER_CAP_ADDPATH_AF_TX_ADV
)
10354 vty_out(vty
, "\n");
10360 PEER_CAP_ADDPATH_AF_RX_ADV
)
10364 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
10376 PEER_CAP_ADDPATH_AF_RX_ADV
))
10388 PEER_CAP_ADDPATH_AF_RX_RCV
))
10395 PEER_CAP_ADDPATH_AF_RX_ADV
)
10399 vty_out(vty
, "\n");
10405 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10406 || CHECK_FLAG(p
->cap
,
10407 PEER_CAP_DYNAMIC_ADV
)) {
10408 vty_out(vty
, " Dynamic:");
10409 if (CHECK_FLAG(p
->cap
,
10410 PEER_CAP_DYNAMIC_ADV
))
10411 vty_out(vty
, " advertised");
10412 if (CHECK_FLAG(p
->cap
,
10413 PEER_CAP_DYNAMIC_RCV
))
10414 vty_out(vty
, " %sreceived",
10417 PEER_CAP_DYNAMIC_ADV
)
10420 vty_out(vty
, "\n");
10423 /* Extended nexthop */
10424 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10425 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10426 vty_out(vty
, " Extended nexthop:");
10427 if (CHECK_FLAG(p
->cap
,
10428 PEER_CAP_ENHE_ADV
))
10429 vty_out(vty
, " advertised");
10430 if (CHECK_FLAG(p
->cap
,
10431 PEER_CAP_ENHE_RCV
))
10432 vty_out(vty
, " %sreceived",
10438 vty_out(vty
, "\n");
10440 if (CHECK_FLAG(p
->cap
,
10441 PEER_CAP_ENHE_RCV
)) {
10443 " Address families by peer:\n ");
10444 for (safi
= SAFI_UNICAST
;
10445 safi
< SAFI_MAX
; safi
++)
10450 PEER_CAP_ENHE_AF_RCV
))
10460 /* Route Refresh */
10461 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10462 || CHECK_FLAG(p
->cap
,
10463 PEER_CAP_REFRESH_NEW_RCV
)
10464 || CHECK_FLAG(p
->cap
,
10465 PEER_CAP_REFRESH_OLD_RCV
)) {
10466 vty_out(vty
, " Route refresh:");
10467 if (CHECK_FLAG(p
->cap
,
10468 PEER_CAP_REFRESH_ADV
))
10469 vty_out(vty
, " advertised");
10470 if (CHECK_FLAG(p
->cap
,
10471 PEER_CAP_REFRESH_NEW_RCV
)
10474 PEER_CAP_REFRESH_OLD_RCV
))
10475 vty_out(vty
, " %sreceived(%s)",
10478 PEER_CAP_REFRESH_ADV
)
10483 PEER_CAP_REFRESH_OLD_RCV
)
10486 PEER_CAP_REFRESH_NEW_RCV
))
10490 PEER_CAP_REFRESH_OLD_RCV
)
10494 vty_out(vty
, "\n");
10497 /* Multiprotocol Extensions */
10498 FOREACH_AFI_SAFI (afi
, safi
)
10499 if (p
->afc_adv
[afi
][safi
]
10500 || p
->afc_recv
[afi
][safi
]) {
10502 " Address Family %s:",
10507 if (p
->afc_adv
[afi
][safi
])
10510 if (p
->afc_recv
[afi
][safi
])
10517 vty_out(vty
, "\n");
10520 /* Hostname capability */
10521 vty_out(vty
, " Hostname Capability:");
10523 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10525 " advertised (name: %s,domain name: %s)",
10526 bgp
->peer_self
->hostname
10530 bgp
->peer_self
->domainname
10535 vty_out(vty
, " not advertised");
10538 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10540 " received (name: %s,domain name: %s)",
10541 p
->hostname
? p
->hostname
10543 p
->domainname
? p
->domainname
10546 vty_out(vty
, " not received");
10549 vty_out(vty
, "\n");
10551 /* Gracefull Restart */
10552 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10553 || CHECK_FLAG(p
->cap
,
10554 PEER_CAP_RESTART_ADV
)) {
10556 " Graceful Restart Capabilty:");
10557 if (CHECK_FLAG(p
->cap
,
10558 PEER_CAP_RESTART_ADV
))
10559 vty_out(vty
, " advertised");
10560 if (CHECK_FLAG(p
->cap
,
10561 PEER_CAP_RESTART_RCV
))
10562 vty_out(vty
, " %sreceived",
10565 PEER_CAP_RESTART_ADV
)
10568 vty_out(vty
, "\n");
10570 if (CHECK_FLAG(p
->cap
,
10571 PEER_CAP_RESTART_RCV
)) {
10572 int restart_af_count
= 0;
10575 " Remote Restart timer is %d seconds\n",
10578 " Address families by peer:\n ");
10580 FOREACH_AFI_SAFI (afi
, safi
)
10585 PEER_CAP_RESTART_AF_RCV
)) {
10599 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10601 : "not preserved");
10602 restart_af_count
++;
10604 if (!restart_af_count
)
10605 vty_out(vty
, "none");
10606 vty_out(vty
, "\n");
10613 /* graceful restart information */
10614 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10615 || p
->t_gr_stale
) {
10616 json_object
*json_grace
= NULL
;
10617 json_object
*json_grace_send
= NULL
;
10618 json_object
*json_grace_recv
= NULL
;
10619 int eor_send_af_count
= 0;
10620 int eor_receive_af_count
= 0;
10623 json_grace
= json_object_new_object();
10624 json_grace_send
= json_object_new_object();
10625 json_grace_recv
= json_object_new_object();
10627 if (p
->status
== Established
) {
10628 FOREACH_AFI_SAFI (afi
, safi
) {
10629 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10630 PEER_STATUS_EOR_SEND
)) {
10631 json_object_boolean_true_add(
10633 get_afi_safi_str(afi
,
10636 eor_send_af_count
++;
10639 FOREACH_AFI_SAFI (afi
, safi
) {
10641 p
->af_sflags
[afi
][safi
],
10642 PEER_STATUS_EOR_RECEIVED
)) {
10643 json_object_boolean_true_add(
10645 get_afi_safi_str(afi
,
10648 eor_receive_af_count
++;
10653 json_object_object_add(json_grace
, "endOfRibSend",
10655 json_object_object_add(json_grace
, "endOfRibRecv",
10658 if (p
->t_gr_restart
)
10659 json_object_int_add(json_grace
,
10660 "gracefulRestartTimerMsecs",
10661 thread_timer_remain_second(
10666 json_object_int_add(
10668 "gracefulStalepathTimerMsecs",
10669 thread_timer_remain_second(
10673 json_object_object_add(
10674 json_neigh
, "gracefulRestartInfo", json_grace
);
10676 vty_out(vty
, " Graceful restart information:\n");
10677 if (p
->status
== Established
) {
10678 vty_out(vty
, " End-of-RIB send: ");
10679 FOREACH_AFI_SAFI (afi
, safi
) {
10680 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10681 PEER_STATUS_EOR_SEND
)) {
10682 vty_out(vty
, "%s%s",
10683 eor_send_af_count
? ", "
10685 get_afi_safi_str(afi
,
10688 eor_send_af_count
++;
10691 vty_out(vty
, "\n");
10692 vty_out(vty
, " End-of-RIB received: ");
10693 FOREACH_AFI_SAFI (afi
, safi
) {
10695 p
->af_sflags
[afi
][safi
],
10696 PEER_STATUS_EOR_RECEIVED
)) {
10697 vty_out(vty
, "%s%s",
10698 eor_receive_af_count
10701 get_afi_safi_str(afi
,
10704 eor_receive_af_count
++;
10707 vty_out(vty
, "\n");
10710 if (p
->t_gr_restart
)
10712 " The remaining time of restart timer is %ld\n",
10713 thread_timer_remain_second(
10718 " The remaining time of stalepath timer is %ld\n",
10719 thread_timer_remain_second(
10724 json_object
*json_stat
= NULL
;
10725 json_stat
= json_object_new_object();
10726 /* Packet counts. */
10727 json_object_int_add(json_stat
, "depthInq", 0);
10728 json_object_int_add(json_stat
, "depthOutq",
10729 (unsigned long)p
->obuf
->count
);
10730 json_object_int_add(json_stat
, "opensSent",
10731 atomic_load_explicit(&p
->open_out
,
10732 memory_order_relaxed
));
10733 json_object_int_add(json_stat
, "opensRecv",
10734 atomic_load_explicit(&p
->open_in
,
10735 memory_order_relaxed
));
10736 json_object_int_add(json_stat
, "notificationsSent",
10737 atomic_load_explicit(&p
->notify_out
,
10738 memory_order_relaxed
));
10739 json_object_int_add(json_stat
, "notificationsRecv",
10740 atomic_load_explicit(&p
->notify_in
,
10741 memory_order_relaxed
));
10742 json_object_int_add(json_stat
, "updatesSent",
10743 atomic_load_explicit(&p
->update_out
,
10744 memory_order_relaxed
));
10745 json_object_int_add(json_stat
, "updatesRecv",
10746 atomic_load_explicit(&p
->update_in
,
10747 memory_order_relaxed
));
10748 json_object_int_add(json_stat
, "keepalivesSent",
10749 atomic_load_explicit(&p
->keepalive_out
,
10750 memory_order_relaxed
));
10751 json_object_int_add(json_stat
, "keepalivesRecv",
10752 atomic_load_explicit(&p
->keepalive_in
,
10753 memory_order_relaxed
));
10754 json_object_int_add(json_stat
, "routeRefreshSent",
10755 atomic_load_explicit(&p
->refresh_out
,
10756 memory_order_relaxed
));
10757 json_object_int_add(json_stat
, "routeRefreshRecv",
10758 atomic_load_explicit(&p
->refresh_in
,
10759 memory_order_relaxed
));
10760 json_object_int_add(json_stat
, "capabilitySent",
10761 atomic_load_explicit(&p
->dynamic_cap_out
,
10762 memory_order_relaxed
));
10763 json_object_int_add(json_stat
, "capabilityRecv",
10764 atomic_load_explicit(&p
->dynamic_cap_in
,
10765 memory_order_relaxed
));
10766 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10767 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10768 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10770 /* Packet counts. */
10771 vty_out(vty
, " Message statistics:\n");
10772 vty_out(vty
, " Inq depth is 0\n");
10773 vty_out(vty
, " Outq depth is %lu\n",
10774 (unsigned long)p
->obuf
->count
);
10775 vty_out(vty
, " Sent Rcvd\n");
10776 vty_out(vty
, " Opens: %10d %10d\n",
10777 atomic_load_explicit(&p
->open_out
,
10778 memory_order_relaxed
),
10779 atomic_load_explicit(&p
->open_in
,
10780 memory_order_relaxed
));
10781 vty_out(vty
, " Notifications: %10d %10d\n",
10782 atomic_load_explicit(&p
->notify_out
,
10783 memory_order_relaxed
),
10784 atomic_load_explicit(&p
->notify_in
,
10785 memory_order_relaxed
));
10786 vty_out(vty
, " Updates: %10d %10d\n",
10787 atomic_load_explicit(&p
->update_out
,
10788 memory_order_relaxed
),
10789 atomic_load_explicit(&p
->update_in
,
10790 memory_order_relaxed
));
10791 vty_out(vty
, " Keepalives: %10d %10d\n",
10792 atomic_load_explicit(&p
->keepalive_out
,
10793 memory_order_relaxed
),
10794 atomic_load_explicit(&p
->keepalive_in
,
10795 memory_order_relaxed
));
10796 vty_out(vty
, " Route Refresh: %10d %10d\n",
10797 atomic_load_explicit(&p
->refresh_out
,
10798 memory_order_relaxed
),
10799 atomic_load_explicit(&p
->refresh_in
,
10800 memory_order_relaxed
));
10801 vty_out(vty
, " Capability: %10d %10d\n",
10802 atomic_load_explicit(&p
->dynamic_cap_out
,
10803 memory_order_relaxed
),
10804 atomic_load_explicit(&p
->dynamic_cap_in
,
10805 memory_order_relaxed
));
10806 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10811 /* advertisement-interval */
10812 json_object_int_add(json_neigh
,
10813 "minBtwnAdvertisementRunsTimerMsecs",
10814 p
->v_routeadv
* 1000);
10816 /* Update-source. */
10817 if (p
->update_if
|| p
->update_source
) {
10819 json_object_string_add(json_neigh
,
10822 else if (p
->update_source
)
10823 json_object_string_add(
10824 json_neigh
, "updateSource",
10825 sockunion2str(p
->update_source
, buf1
,
10829 /* advertisement-interval */
10831 " Minimum time between advertisement runs is %d seconds\n",
10834 /* Update-source. */
10835 if (p
->update_if
|| p
->update_source
) {
10836 vty_out(vty
, " Update source is ");
10838 vty_out(vty
, "%s", p
->update_if
);
10839 else if (p
->update_source
)
10841 sockunion2str(p
->update_source
, buf1
,
10843 vty_out(vty
, "\n");
10846 vty_out(vty
, "\n");
10849 /* Address Family Information */
10850 json_object
*json_hold
= NULL
;
10853 json_hold
= json_object_new_object();
10855 FOREACH_AFI_SAFI (afi
, safi
)
10856 if (p
->afc
[afi
][safi
])
10857 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10861 json_object_object_add(json_neigh
, "addressFamilyInfo",
10863 json_object_int_add(json_neigh
, "connectionsEstablished",
10865 json_object_int_add(json_neigh
, "connectionsDropped",
10868 vty_out(vty
, " Connections established %d; dropped %d\n",
10869 p
->established
, p
->dropped
);
10871 if (!p
->last_reset
) {
10873 json_object_string_add(json_neigh
, "lastReset",
10876 vty_out(vty
, " Last reset never\n");
10882 uptime
= bgp_clock();
10883 uptime
-= p
->resettime
;
10884 tm
= gmtime(&uptime
);
10885 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10886 (tm
->tm_sec
* 1000)
10887 + (tm
->tm_min
* 60000)
10888 + (tm
->tm_hour
* 3600000));
10889 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
10891 vty_out(vty
, " Last reset %s, ",
10892 peer_uptime(p
->resettime
, timebuf
,
10893 BGP_UPTIME_LEN
, 0, NULL
));
10895 bgp_show_peer_reset(vty
, p
, NULL
, false);
10896 if (p
->last_reset_cause_size
) {
10897 msg
= p
->last_reset_cause
;
10899 " Message received that caused BGP to send a NOTIFICATION:\n ");
10900 for (i
= 1; i
<= p
->last_reset_cause_size
;
10902 vty_out(vty
, "%02X", *msg
++);
10904 if (i
!= p
->last_reset_cause_size
) {
10906 vty_out(vty
, "\n ");
10907 } else if (i
% 4 == 0) {
10912 vty_out(vty
, "\n");
10917 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10919 json_object_boolean_true_add(json_neigh
,
10920 "prefixesConfigExceedMax");
10923 " Peer had exceeded the max. no. of prefixes configured.\n");
10925 if (p
->t_pmax_restart
) {
10927 json_object_boolean_true_add(
10928 json_neigh
, "reducePrefixNumFrom");
10929 json_object_int_add(json_neigh
,
10930 "restartInTimerMsec",
10931 thread_timer_remain_second(
10936 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10937 p
->host
, thread_timer_remain_second(
10938 p
->t_pmax_restart
));
10941 json_object_boolean_true_add(
10943 "reducePrefixNumAndClearIpBgp");
10946 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10951 /* EBGP Multihop and GTSM */
10952 if (p
->sort
!= BGP_PEER_IBGP
) {
10954 if (p
->gtsm_hops
> 0)
10955 json_object_int_add(json_neigh
,
10956 "externalBgpNbrMaxHopsAway",
10958 else if (p
->ttl
> BGP_DEFAULT_TTL
)
10959 json_object_int_add(json_neigh
,
10960 "externalBgpNbrMaxHopsAway",
10963 if (p
->gtsm_hops
> 0)
10965 " External BGP neighbor may be up to %d hops away.\n",
10967 else if (p
->ttl
> BGP_DEFAULT_TTL
)
10969 " External BGP neighbor may be up to %d hops away.\n",
10973 if (p
->gtsm_hops
> 0) {
10975 json_object_int_add(json_neigh
,
10976 "internalBgpNbrMaxHopsAway",
10980 " Internal BGP neighbor may be up to %d hops away.\n",
10985 /* Local address. */
10988 json_object_string_add(json_neigh
, "hostLocal",
10989 sockunion2str(p
->su_local
, buf1
,
10991 json_object_int_add(json_neigh
, "portLocal",
10992 ntohs(p
->su_local
->sin
.sin_port
));
10994 vty_out(vty
, "Local host: %s, Local port: %d\n",
10995 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10996 ntohs(p
->su_local
->sin
.sin_port
));
10999 /* Remote address. */
11000 if (p
->su_remote
) {
11002 json_object_string_add(json_neigh
, "hostForeign",
11003 sockunion2str(p
->su_remote
, buf1
,
11005 json_object_int_add(json_neigh
, "portForeign",
11006 ntohs(p
->su_remote
->sin
.sin_port
));
11008 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
11009 sockunion2str(p
->su_remote
, buf1
,
11011 ntohs(p
->su_remote
->sin
.sin_port
));
11014 /* Nexthop display. */
11017 json_object_string_add(json_neigh
, "nexthop",
11019 &p
->nexthop
.v4
, buf1
,
11021 json_object_string_add(json_neigh
, "nexthopGlobal",
11022 inet_ntop(AF_INET6
,
11023 &p
->nexthop
.v6_global
,
11024 buf1
, sizeof(buf1
)));
11025 json_object_string_add(json_neigh
, "nexthopLocal",
11026 inet_ntop(AF_INET6
,
11027 &p
->nexthop
.v6_local
,
11028 buf1
, sizeof(buf1
)));
11029 if (p
->shared_network
)
11030 json_object_string_add(json_neigh
,
11034 json_object_string_add(json_neigh
,
11036 "nonSharedNetwork");
11038 vty_out(vty
, "Nexthop: %s\n",
11039 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
11041 vty_out(vty
, "Nexthop global: %s\n",
11042 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
11044 vty_out(vty
, "Nexthop local: %s\n",
11045 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
11047 vty_out(vty
, "BGP connection: %s\n",
11048 p
->shared_network
? "shared network"
11049 : "non shared network");
11053 /* Timer information. */
11055 json_object_int_add(json_neigh
, "connectRetryTimer",
11057 if (p
->status
== Established
&& p
->rtt
)
11058 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
11061 json_object_int_add(
11062 json_neigh
, "nextStartTimerDueInMsecs",
11063 thread_timer_remain_second(p
->t_start
) * 1000);
11065 json_object_int_add(
11066 json_neigh
, "nextConnectTimerDueInMsecs",
11067 thread_timer_remain_second(p
->t_connect
)
11069 if (p
->t_routeadv
) {
11070 json_object_int_add(json_neigh
, "mraiInterval",
11072 json_object_int_add(
11073 json_neigh
, "mraiTimerExpireInMsecs",
11074 thread_timer_remain_second(p
->t_routeadv
)
11078 json_object_int_add(json_neigh
, "authenticationEnabled",
11082 json_object_string_add(json_neigh
, "readThread", "on");
11084 json_object_string_add(json_neigh
, "readThread", "off");
11086 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
11087 json_object_string_add(json_neigh
, "writeThread", "on");
11089 json_object_string_add(json_neigh
, "writeThread",
11092 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
11094 if (p
->status
== Established
&& p
->rtt
)
11095 vty_out(vty
, "Estimated round trip time: %d ms\n",
11098 vty_out(vty
, "Next start timer due in %ld seconds\n",
11099 thread_timer_remain_second(p
->t_start
));
11101 vty_out(vty
, "Next connect timer due in %ld seconds\n",
11102 thread_timer_remain_second(p
->t_connect
));
11105 "MRAI (interval %u) timer expires in %ld seconds\n",
11107 thread_timer_remain_second(p
->t_routeadv
));
11109 vty_out(vty
, "Peer Authentication Enabled\n");
11111 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
11112 p
->t_read
? "on" : "off",
11113 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
11118 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
11119 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
11120 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
11123 vty_out(vty
, "\n");
11125 /* BFD information. */
11126 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
11129 if (p
->conf_if
) /* Configured interface name. */
11130 json_object_object_add(json
, p
->conf_if
, json_neigh
);
11131 else /* Configured IP address. */
11132 json_object_object_add(json
, p
->host
, json_neigh
);
11136 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
11137 enum show_type type
, union sockunion
*su
,
11138 const char *conf_if
, bool use_json
,
11141 struct listnode
*node
, *nnode
;
11144 bool nbr_output
= false;
11145 afi_t afi
= AFI_MAX
;
11146 safi_t safi
= SAFI_MAX
;
11148 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
11150 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
11154 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11155 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11160 bgp_show_peer(vty
, peer
, use_json
, json
);
11166 && !strcmp(peer
->conf_if
, conf_if
))
11168 && !strcmp(peer
->hostname
, conf_if
))) {
11170 bgp_show_peer(vty
, peer
, use_json
,
11174 if (sockunion_same(&peer
->su
, su
)) {
11176 bgp_show_peer(vty
, peer
, use_json
,
11181 case show_ipv4_peer
:
11182 case show_ipv6_peer
:
11183 FOREACH_SAFI (safi
) {
11184 if (peer
->afc
[afi
][safi
]) {
11187 && !strcmp(peer
->conf_if
, conf_if
))
11189 && !strcmp(peer
->hostname
, conf_if
))) {
11191 bgp_show_peer(vty
, peer
, use_json
,
11196 if (sockunion_same(&peer
->su
, su
)) {
11198 bgp_show_peer(vty
, peer
, use_json
,
11206 case show_ipv4_all
:
11207 case show_ipv6_all
:
11208 FOREACH_SAFI (safi
) {
11209 if (peer
->afc
[afi
][safi
]) {
11210 bgp_show_peer(vty
, peer
, use_json
, json
);
11219 if ((type
== show_peer
|| type
== show_ipv4_peer
||
11220 type
== show_ipv6_peer
) && !find
) {
11222 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
11224 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
11227 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
11228 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
11229 vty_out(vty
, "%% No BGP neighbors found\n");
11232 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11233 json
, JSON_C_TO_STRING_PRETTY
));
11235 vty_out(vty
, "\n");
11238 return CMD_SUCCESS
;
11241 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
11242 enum show_type type
,
11243 const char *ip_str
,
11246 struct listnode
*node
, *nnode
;
11248 union sockunion su
;
11249 json_object
*json
= NULL
;
11250 int ret
, is_first
= 1;
11251 bool nbr_output
= false;
11254 vty_out(vty
, "{\n");
11256 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11259 if (!(json
= json_object_new_object())) {
11261 EC_BGP_JSON_MEM_ERROR
,
11262 "Unable to allocate memory for JSON object");
11264 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
11268 json_object_int_add(json
, "vrfId",
11269 (bgp
->vrf_id
== VRF_UNKNOWN
)
11271 : (int64_t)bgp
->vrf_id
);
11272 json_object_string_add(
11274 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11279 vty_out(vty
, ",\n");
11283 vty_out(vty
, "\"%s\":",
11284 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11288 vty_out(vty
, "\nInstance %s:\n",
11289 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11294 if (type
== show_peer
|| type
== show_ipv4_peer
||
11295 type
== show_ipv6_peer
) {
11296 ret
= str2sockunion(ip_str
, &su
);
11298 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11301 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11304 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
11307 json_object_free(json
);
11311 vty_out(vty
, "}\n");
11312 json_object_free(json
);
11314 else if (!nbr_output
)
11315 vty_out(vty
, "%% BGP instance not found\n");
11318 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
11319 enum show_type type
, const char *ip_str
,
11324 union sockunion su
;
11325 json_object
*json
= NULL
;
11328 if (strmatch(name
, "all")) {
11329 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
11331 return CMD_SUCCESS
;
11333 bgp
= bgp_lookup_by_name(name
);
11336 json
= json_object_new_object();
11337 vty_out(vty
, "%s\n",
11338 json_object_to_json_string_ext(
11340 JSON_C_TO_STRING_PRETTY
));
11341 json_object_free(json
);
11344 "%% BGP instance not found\n");
11346 return CMD_WARNING
;
11350 bgp
= bgp_get_default();
11354 json
= json_object_new_object();
11356 ret
= str2sockunion(ip_str
, &su
);
11358 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11361 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11364 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
11367 json_object_free(json
);
11370 vty_out(vty
, "{}\n");
11372 vty_out(vty
, "%% BGP instance not found\n");
11375 return CMD_SUCCESS
;
11378 /* "show [ip] bgp neighbors" commands. */
11379 DEFUN (show_ip_bgp_neighbors
,
11380 show_ip_bgp_neighbors_cmd
,
11381 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
11385 BGP_INSTANCE_HELP_STR
11388 "Detailed information on TCP and BGP neighbor connections\n"
11389 "Neighbor to display information about\n"
11390 "Neighbor to display information about\n"
11391 "Neighbor on BGP configured interface\n"
11395 char *sh_arg
= NULL
;
11396 enum show_type sh_type
;
11397 afi_t afi
= AFI_MAX
;
11399 bool uj
= use_json(argc
, argv
);
11403 /* [<vrf> VIEWVRFNAME] */
11404 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11405 vrf
= argv
[idx
+ 1]->arg
;
11406 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11408 } else if (argv_find(argv
, argc
, "view", &idx
))
11409 /* [<view> VIEWVRFNAME] */
11410 vrf
= argv
[idx
+ 1]->arg
;
11414 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
11415 sh_type
= show_ipv4_all
;
11417 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
11418 sh_type
= show_ipv6_all
;
11421 sh_type
= show_all
;
11424 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
11425 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
11426 || argv_find(argv
, argc
, "WORD", &idx
)) {
11427 sh_type
= show_peer
;
11428 sh_arg
= argv
[idx
]->arg
;
11431 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
11432 sh_type
= show_ipv4_peer
;
11433 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
11434 sh_type
= show_ipv6_peer
;
11437 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
11440 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
11441 paths' and `show ip mbgp paths'. Those functions results are the
11443 DEFUN (show_ip_bgp_paths
,
11444 show_ip_bgp_paths_cmd
,
11445 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
11450 "Path information\n")
11452 vty_out(vty
, "Address Refcnt Path\n");
11453 aspath_print_all_vty(vty
);
11454 return CMD_SUCCESS
;
11459 static void community_show_all_iterator(struct hash_bucket
*bucket
,
11462 struct community
*com
;
11464 com
= (struct community
*)bucket
->data
;
11465 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
11466 community_str(com
, false));
11469 /* Show BGP's community internal data. */
11470 DEFUN (show_ip_bgp_community_info
,
11471 show_ip_bgp_community_info_cmd
,
11472 "show [ip] bgp community-info",
11476 "List all bgp community information\n")
11478 vty_out(vty
, "Address Refcnt Community\n");
11480 hash_iterate(community_hash(),
11481 (void (*)(struct hash_bucket
*,
11482 void *))community_show_all_iterator
,
11485 return CMD_SUCCESS
;
11488 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
11491 struct lcommunity
*lcom
;
11493 lcom
= (struct lcommunity
*)bucket
->data
;
11494 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11495 lcommunity_str(lcom
, false));
11498 /* Show BGP's community internal data. */
11499 DEFUN (show_ip_bgp_lcommunity_info
,
11500 show_ip_bgp_lcommunity_info_cmd
,
11501 "show ip bgp large-community-info",
11505 "List all bgp large-community information\n")
11507 vty_out(vty
, "Address Refcnt Large-community\n");
11509 hash_iterate(lcommunity_hash(),
11510 (void (*)(struct hash_bucket
*,
11511 void *))lcommunity_show_all_iterator
,
11514 return CMD_SUCCESS
;
11518 DEFUN (show_ip_bgp_attr_info
,
11519 show_ip_bgp_attr_info_cmd
,
11520 "show [ip] bgp attribute-info",
11524 "List all bgp attribute information\n")
11526 attr_show_all(vty
);
11527 return CMD_SUCCESS
;
11530 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
11531 afi_t afi
, safi_t safi
,
11532 bool use_json
, json_object
*json
)
11535 struct listnode
*node
;
11537 char buf1
[INET6_ADDRSTRLEN
];
11539 vpn_policy_direction_t dir
;
11542 json_object
*json_import_vrfs
= NULL
;
11543 json_object
*json_export_vrfs
= NULL
;
11545 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11548 vty_out(vty
, "%s\n",
11549 json_object_to_json_string_ext(
11551 JSON_C_TO_STRING_PRETTY
));
11552 json_object_free(json
);
11554 return CMD_WARNING
;
11557 /* Provide context for the block */
11558 json_object_string_add(json
, "vrf", name
? name
: "default");
11559 json_object_string_add(json
, "afiSafi",
11560 get_afi_safi_str(afi
, safi
, true));
11562 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11563 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11564 json_object_string_add(json
, "importFromVrfs", "none");
11565 json_object_string_add(json
, "importRts", "none");
11567 json_import_vrfs
= json_object_new_array();
11569 for (ALL_LIST_ELEMENTS_RO(
11570 bgp
->vpn_policy
[afi
].import_vrf
,
11572 json_object_array_add(json_import_vrfs
,
11573 json_object_new_string(vname
));
11575 json_object_object_add(json
, "importFromVrfs",
11577 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11578 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11579 ecom_str
= ecommunity_ecom2str(
11580 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11581 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11582 json_object_string_add(json
, "importRts",
11584 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11586 json_object_string_add(json
, "importRts",
11590 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11591 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11592 json_object_string_add(json
, "exportToVrfs", "none");
11593 json_object_string_add(json
, "routeDistinguisher",
11595 json_object_string_add(json
, "exportRts", "none");
11597 json_export_vrfs
= json_object_new_array();
11599 for (ALL_LIST_ELEMENTS_RO(
11600 bgp
->vpn_policy
[afi
].export_vrf
,
11602 json_object_array_add(json_export_vrfs
,
11603 json_object_new_string(vname
));
11604 json_object_object_add(json
, "exportToVrfs",
11606 json_object_string_add(json
, "routeDistinguisher",
11607 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11608 buf1
, RD_ADDRSTRLEN
));
11610 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11611 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11612 ecom_str
= ecommunity_ecom2str(
11613 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11614 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11615 json_object_string_add(json
, "exportRts",
11617 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11619 json_object_string_add(json
, "exportRts",
11624 vty_out(vty
, "%s\n",
11625 json_object_to_json_string_ext(json
,
11626 JSON_C_TO_STRING_PRETTY
));
11627 json_object_free(json
);
11630 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11633 vty_out(vty
, "%% No such BGP instance exist\n");
11634 return CMD_WARNING
;
11637 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11638 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11640 "This VRF is not importing %s routes from any other VRF\n",
11641 get_afi_safi_str(afi
, safi
, false));
11644 "This VRF is importing %s routes from the following VRFs:\n",
11645 get_afi_safi_str(afi
, safi
, false));
11647 for (ALL_LIST_ELEMENTS_RO(
11648 bgp
->vpn_policy
[afi
].import_vrf
,
11650 vty_out(vty
, " %s\n", vname
);
11652 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11654 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11655 ecom_str
= ecommunity_ecom2str(
11656 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11657 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11658 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11660 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11662 vty_out(vty
, "Import RT(s):\n");
11665 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11666 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11668 "This VRF is not exporting %s routes to any other VRF\n",
11669 get_afi_safi_str(afi
, safi
, false));
11672 "This VRF is exporting %s routes to the following VRFs:\n",
11673 get_afi_safi_str(afi
, safi
, false));
11675 for (ALL_LIST_ELEMENTS_RO(
11676 bgp
->vpn_policy
[afi
].export_vrf
,
11678 vty_out(vty
, " %s\n", vname
);
11680 vty_out(vty
, "RD: %s\n",
11681 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11682 buf1
, RD_ADDRSTRLEN
));
11684 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11685 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11686 ecom_str
= ecommunity_ecom2str(
11687 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11688 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11689 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11690 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11692 vty_out(vty
, "Import RT(s):\n");
11696 return CMD_SUCCESS
;
11699 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
11700 safi_t safi
, bool use_json
)
11702 struct listnode
*node
, *nnode
;
11704 char *vrf_name
= NULL
;
11705 json_object
*json
= NULL
;
11706 json_object
*json_vrf
= NULL
;
11707 json_object
*json_vrfs
= NULL
;
11710 json
= json_object_new_object();
11711 json_vrfs
= json_object_new_object();
11714 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11716 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
11717 vrf_name
= bgp
->name
;
11720 json_vrf
= json_object_new_object();
11722 vty_out(vty
, "\nInstance %s:\n",
11723 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11724 ? VRF_DEFAULT_NAME
: bgp
->name
);
11726 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
11728 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11729 json_object_object_add(json_vrfs
,
11730 VRF_DEFAULT_NAME
, json_vrf
);
11732 json_object_object_add(json_vrfs
, vrf_name
,
11738 json_object_object_add(json
, "vrfs", json_vrfs
);
11739 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
11740 JSON_C_TO_STRING_PRETTY
));
11741 json_object_free(json
);
11744 return CMD_SUCCESS
;
11747 /* "show [ip] bgp route-leak" command. */
11748 DEFUN (show_ip_bgp_route_leak
,
11749 show_ip_bgp_route_leak_cmd
,
11750 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11754 BGP_INSTANCE_HELP_STR
11757 "Route leaking information\n"
11761 afi_t afi
= AFI_MAX
;
11762 safi_t safi
= SAFI_MAX
;
11764 bool uj
= use_json(argc
, argv
);
11766 json_object
*json
= NULL
;
11768 /* show [ip] bgp */
11769 if (argv_find(argv
, argc
, "ip", &idx
)) {
11771 safi
= SAFI_UNICAST
;
11773 /* [vrf VIEWVRFNAME] */
11774 if (argv_find(argv
, argc
, "view", &idx
)) {
11776 "%% This command is not applicable to BGP views\n");
11777 return CMD_WARNING
;
11780 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11781 vrf
= argv
[idx
+ 1]->arg
;
11782 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11785 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11786 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11787 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11790 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11792 "%% This command is applicable only for unicast ipv4|ipv6\n");
11793 return CMD_WARNING
;
11796 if (vrf
&& strmatch(vrf
, "all"))
11797 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
11800 json
= json_object_new_object();
11802 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
11805 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11808 struct listnode
*node
, *nnode
;
11811 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11812 vty_out(vty
, "\nInstance %s:\n",
11813 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11816 update_group_show(bgp
, afi
, safi
, vty
, 0);
11820 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11821 int safi
, uint64_t subgrp_id
)
11826 if (strmatch(name
, "all")) {
11827 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11828 return CMD_SUCCESS
;
11830 bgp
= bgp_lookup_by_name(name
);
11833 bgp
= bgp_get_default();
11837 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11838 return CMD_SUCCESS
;
11841 DEFUN (show_ip_bgp_updgrps
,
11842 show_ip_bgp_updgrps_cmd
,
11843 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11847 BGP_INSTANCE_HELP_STR
11849 BGP_SAFI_WITH_LABEL_HELP_STR
11850 "Detailed info about dynamic update groups\n"
11851 "Specific subgroup to display detailed info for\n")
11854 afi_t afi
= AFI_IP6
;
11855 safi_t safi
= SAFI_UNICAST
;
11856 uint64_t subgrp_id
= 0;
11860 /* show [ip] bgp */
11861 if (argv_find(argv
, argc
, "ip", &idx
))
11863 /* [<vrf> VIEWVRFNAME] */
11864 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11865 vrf
= argv
[idx
+ 1]->arg
;
11866 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11868 } else if (argv_find(argv
, argc
, "view", &idx
))
11869 /* [<view> VIEWVRFNAME] */
11870 vrf
= argv
[idx
+ 1]->arg
;
11871 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11872 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11873 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11876 /* get subgroup id, if provided */
11878 if (argv
[idx
]->type
== VARIABLE_TKN
)
11879 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11881 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11884 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11885 show_bgp_instance_all_ipv6_updgrps_cmd
,
11886 "show [ip] bgp <view|vrf> all update-groups",
11890 BGP_INSTANCE_ALL_HELP_STR
11891 "Detailed info about dynamic update groups\n")
11893 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11894 return CMD_SUCCESS
;
11897 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
11898 show_bgp_l2vpn_evpn_updgrps_cmd
,
11899 "show [ip] bgp l2vpn evpn update-groups",
11903 "l2vpn address family\n"
11904 "evpn sub-address family\n"
11905 "Detailed info about dynamic update groups\n")
11908 uint64_t subgrp_id
= 0;
11910 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
11911 return CMD_SUCCESS
;
11914 DEFUN (show_bgp_updgrps_stats
,
11915 show_bgp_updgrps_stats_cmd
,
11916 "show [ip] bgp update-groups statistics",
11920 "Detailed info about dynamic update groups\n"
11925 bgp
= bgp_get_default();
11927 update_group_show_stats(bgp
, vty
);
11929 return CMD_SUCCESS
;
11932 DEFUN (show_bgp_instance_updgrps_stats
,
11933 show_bgp_instance_updgrps_stats_cmd
,
11934 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11938 BGP_INSTANCE_HELP_STR
11939 "Detailed info about dynamic update groups\n"
11945 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11947 update_group_show_stats(bgp
, vty
);
11949 return CMD_SUCCESS
;
11952 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11953 afi_t afi
, safi_t safi
,
11954 const char *what
, uint64_t subgrp_id
)
11959 bgp
= bgp_lookup_by_name(name
);
11961 bgp
= bgp_get_default();
11964 if (!strcmp(what
, "advertise-queue"))
11965 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11967 else if (!strcmp(what
, "advertised-routes"))
11968 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11970 else if (!strcmp(what
, "packet-queue"))
11971 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11976 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11977 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11978 "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",
11979 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11981 "Detailed info about dynamic update groups\n"
11982 "Specific subgroup to display info for\n"
11983 "Advertisement queue\n"
11984 "Announced routes\n"
11987 uint64_t subgrp_id
= 0;
11991 subgrp_id
= strtoull(sgid
, NULL
, 10);
11996 afiz
= bgp_vty_afi_from_str(afi
);
12000 afiz
= bgp_vty_afi_from_str(afi
);
12001 if (afiz
!= AFI_IP
)
12003 "%% Cannot specify both 'ip' and 'ipv6'\n");
12004 return CMD_WARNING
;
12007 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
12009 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
12010 return CMD_SUCCESS
;
12013 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
12015 struct listnode
*node
, *nnode
;
12016 struct prefix
*range
;
12019 char buf
[PREFIX2STR_BUFFER
];
12022 const char *peer_status
;
12023 const char *af_str
;
12028 conf
= group
->conf
;
12030 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
12031 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
12032 group
->name
, conf
->as
);
12033 } else if (conf
->as_type
== AS_INTERNAL
) {
12034 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
12035 group
->name
, group
->bgp
->as
);
12037 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
12040 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
12041 vty_out(vty
, " Peer-group type is internal\n");
12043 vty_out(vty
, " Peer-group type is external\n");
12045 /* Display AFs configured. */
12046 vty_out(vty
, " Configured address-families:");
12047 FOREACH_AFI_SAFI (afi
, safi
) {
12048 if (conf
->afc
[afi
][safi
]) {
12050 vty_out(vty
, " %s;", get_afi_safi_str(afi
, safi
, false));
12054 vty_out(vty
, " none\n");
12056 vty_out(vty
, "\n");
12058 /* Display listen ranges (for dynamic neighbors), if any */
12059 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
12062 else if (afi
== AFI_IP6
)
12066 lr_count
= listcount(group
->listen_range
[afi
]);
12068 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
12072 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
12074 prefix2str(range
, buf
, sizeof(buf
));
12075 vty_out(vty
, " %s\n", buf
);
12080 /* Display group members and their status */
12081 if (listcount(group
->peer
)) {
12082 vty_out(vty
, " Peer-group members:\n");
12083 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
12084 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
12085 peer_status
= "Idle (Admin)";
12086 else if (CHECK_FLAG(peer
->sflags
,
12087 PEER_STATUS_PREFIX_OVERFLOW
))
12088 peer_status
= "Idle (PfxCt)";
12090 peer_status
= lookup_msg(bgp_status_msg
,
12091 peer
->status
, NULL
);
12093 dynamic
= peer_dynamic_neighbor(peer
);
12094 vty_out(vty
, " %s %s %s \n", peer
->host
,
12095 dynamic
? "(dynamic)" : "", peer_status
);
12099 return CMD_SUCCESS
;
12102 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
12103 const char *group_name
)
12106 struct listnode
*node
, *nnode
;
12107 struct peer_group
*group
;
12108 bool found
= false;
12110 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
12113 vty_out(vty
, "%% BGP instance not found\n");
12114 return CMD_WARNING
;
12117 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
12119 if (strmatch(group
->name
, group_name
)) {
12120 bgp_show_one_peer_group(vty
, group
);
12125 bgp_show_one_peer_group(vty
, group
);
12129 if (group_name
&& !found
)
12130 vty_out(vty
, "%% No such peer-group\n");
12132 return CMD_SUCCESS
;
12135 DEFUN (show_ip_bgp_peer_groups
,
12136 show_ip_bgp_peer_groups_cmd
,
12137 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
12141 BGP_INSTANCE_HELP_STR
12142 "Detailed information on BGP peer groups\n"
12143 "Peer group name\n")
12148 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
12150 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
12152 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
12156 /* Redistribute VTY commands. */
12158 DEFUN (bgp_redistribute_ipv4
,
12159 bgp_redistribute_ipv4_cmd
,
12160 "redistribute " FRR_IP_REDIST_STR_BGPD
,
12161 "Redistribute information from another routing protocol\n"
12162 FRR_IP_REDIST_HELP_STR_BGPD
)
12164 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12165 int idx_protocol
= 1;
12168 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12170 vty_out(vty
, "%% Invalid route type\n");
12171 return CMD_WARNING_CONFIG_FAILED
;
12174 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12175 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
12179 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
12180 "redistribute " FRR_IP_REDIST_STR_BGPD
,
12181 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
12183 DEFUN (bgp_redistribute_ipv4_rmap
,
12184 bgp_redistribute_ipv4_rmap_cmd
,
12185 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
12186 "Redistribute information from another routing protocol\n"
12187 FRR_IP_REDIST_HELP_STR_BGPD
12188 "Route map reference\n"
12189 "Pointer to route-map entries\n")
12191 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12192 int idx_protocol
= 1;
12195 struct bgp_redist
*red
;
12197 struct route_map
*route_map
= route_map_lookup_warn_noexist(
12198 vty
, argv
[idx_word
]->arg
);
12200 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12202 vty_out(vty
, "%% Invalid route type\n");
12203 return CMD_WARNING_CONFIG_FAILED
;
12206 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12208 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12209 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12213 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
12214 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
12215 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12216 "Route map reference\n"
12217 "Pointer to route-map entries\n")
12219 DEFUN (bgp_redistribute_ipv4_metric
,
12220 bgp_redistribute_ipv4_metric_cmd
,
12221 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12222 "Redistribute information from another routing protocol\n"
12223 FRR_IP_REDIST_HELP_STR_BGPD
12224 "Metric for redistributed routes\n"
12225 "Default metric\n")
12227 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12228 int idx_protocol
= 1;
12229 int idx_number
= 3;
12232 struct bgp_redist
*red
;
12235 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12237 vty_out(vty
, "%% Invalid route type\n");
12238 return CMD_WARNING_CONFIG_FAILED
;
12240 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12242 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12243 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12244 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12248 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
12249 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12250 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12251 "Metric for redistributed routes\n"
12252 "Default metric\n")
12254 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
12255 bgp_redistribute_ipv4_rmap_metric_cmd
,
12256 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12257 "Redistribute information from another routing protocol\n"
12258 FRR_IP_REDIST_HELP_STR_BGPD
12259 "Route map reference\n"
12260 "Pointer to route-map entries\n"
12261 "Metric for redistributed routes\n"
12262 "Default metric\n")
12264 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12265 int idx_protocol
= 1;
12267 int idx_number
= 5;
12270 struct bgp_redist
*red
;
12272 struct route_map
*route_map
=
12273 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12275 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12277 vty_out(vty
, "%% Invalid route type\n");
12278 return CMD_WARNING_CONFIG_FAILED
;
12280 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12282 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12284 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12285 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12286 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12290 bgp_redistribute_ipv4_rmap_metric
,
12291 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
12292 "redistribute " FRR_IP_REDIST_STR_BGPD
12293 " route-map WORD metric (0-4294967295)",
12294 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12295 "Route map reference\n"
12296 "Pointer to route-map entries\n"
12297 "Metric for redistributed routes\n"
12298 "Default metric\n")
12300 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
12301 bgp_redistribute_ipv4_metric_rmap_cmd
,
12302 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12303 "Redistribute information from another routing protocol\n"
12304 FRR_IP_REDIST_HELP_STR_BGPD
12305 "Metric for redistributed routes\n"
12307 "Route map reference\n"
12308 "Pointer to route-map entries\n")
12310 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12311 int idx_protocol
= 1;
12312 int idx_number
= 3;
12316 struct bgp_redist
*red
;
12318 struct route_map
*route_map
=
12319 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12321 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12323 vty_out(vty
, "%% Invalid route type\n");
12324 return CMD_WARNING_CONFIG_FAILED
;
12326 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12328 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12329 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12331 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12332 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12336 bgp_redistribute_ipv4_metric_rmap
,
12337 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
12338 "redistribute " FRR_IP_REDIST_STR_BGPD
12339 " metric (0-4294967295) route-map WORD",
12340 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12341 "Metric for redistributed routes\n"
12343 "Route map reference\n"
12344 "Pointer to route-map entries\n")
12346 DEFUN (bgp_redistribute_ipv4_ospf
,
12347 bgp_redistribute_ipv4_ospf_cmd
,
12348 "redistribute <ospf|table> (1-65535)",
12349 "Redistribute information from another routing protocol\n"
12350 "Open Shortest Path First (OSPFv2)\n"
12351 "Non-main Kernel Routing Table\n"
12352 "Instance ID/Table ID\n")
12354 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12355 int idx_ospf_table
= 1;
12356 int idx_number
= 2;
12357 unsigned short instance
;
12358 unsigned short protocol
;
12360 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12362 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12363 protocol
= ZEBRA_ROUTE_OSPF
;
12365 protocol
= ZEBRA_ROUTE_TABLE
;
12367 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12368 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
12371 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
12372 "redistribute <ospf|table> (1-65535)",
12373 "Redistribute information from another routing protocol\n"
12374 "Open Shortest Path First (OSPFv2)\n"
12375 "Non-main Kernel Routing Table\n"
12376 "Instance ID/Table ID\n")
12378 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
12379 bgp_redistribute_ipv4_ospf_rmap_cmd
,
12380 "redistribute <ospf|table> (1-65535) route-map WORD",
12381 "Redistribute information from another routing protocol\n"
12382 "Open Shortest Path First (OSPFv2)\n"
12383 "Non-main Kernel Routing Table\n"
12384 "Instance ID/Table ID\n"
12385 "Route map reference\n"
12386 "Pointer to route-map entries\n")
12388 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12389 int idx_ospf_table
= 1;
12390 int idx_number
= 2;
12392 struct bgp_redist
*red
;
12393 unsigned short instance
;
12396 struct route_map
*route_map
=
12397 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12399 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12400 protocol
= ZEBRA_ROUTE_OSPF
;
12402 protocol
= ZEBRA_ROUTE_TABLE
;
12404 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12405 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12407 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12408 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12411 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
12412 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
12413 "redistribute <ospf|table> (1-65535) route-map WORD",
12414 "Redistribute information from another routing protocol\n"
12415 "Open Shortest Path First (OSPFv2)\n"
12416 "Non-main Kernel Routing Table\n"
12417 "Instance ID/Table ID\n"
12418 "Route map reference\n"
12419 "Pointer to route-map entries\n")
12421 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
12422 bgp_redistribute_ipv4_ospf_metric_cmd
,
12423 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
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"
12428 "Metric for redistributed routes\n"
12429 "Default metric\n")
12431 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12432 int idx_ospf_table
= 1;
12433 int idx_number
= 2;
12434 int idx_number_2
= 4;
12436 struct bgp_redist
*red
;
12437 unsigned short instance
;
12441 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12442 protocol
= ZEBRA_ROUTE_OSPF
;
12444 protocol
= ZEBRA_ROUTE_TABLE
;
12446 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12447 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12449 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12450 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12452 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12455 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
12456 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
12457 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12458 "Redistribute information from another routing protocol\n"
12459 "Open Shortest Path First (OSPFv2)\n"
12460 "Non-main Kernel Routing Table\n"
12461 "Instance ID/Table ID\n"
12462 "Metric for redistributed routes\n"
12463 "Default metric\n")
12465 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
12466 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
12467 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12468 "Redistribute information from another routing protocol\n"
12469 "Open Shortest Path First (OSPFv2)\n"
12470 "Non-main Kernel Routing Table\n"
12471 "Instance ID/Table ID\n"
12472 "Route map reference\n"
12473 "Pointer to route-map entries\n"
12474 "Metric for redistributed routes\n"
12475 "Default metric\n")
12477 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12478 int idx_ospf_table
= 1;
12479 int idx_number
= 2;
12481 int idx_number_2
= 6;
12483 struct bgp_redist
*red
;
12484 unsigned short instance
;
12487 struct route_map
*route_map
=
12488 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12490 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12491 protocol
= ZEBRA_ROUTE_OSPF
;
12493 protocol
= ZEBRA_ROUTE_TABLE
;
12495 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12496 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12498 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12500 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12501 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12503 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12507 bgp_redistribute_ipv4_ospf_rmap_metric
,
12508 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
12509 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12510 "Redistribute information from another routing protocol\n"
12511 "Open Shortest Path First (OSPFv2)\n"
12512 "Non-main Kernel Routing Table\n"
12513 "Instance ID/Table ID\n"
12514 "Route map reference\n"
12515 "Pointer to route-map entries\n"
12516 "Metric for redistributed routes\n"
12517 "Default metric\n")
12519 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
12520 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
12521 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12522 "Redistribute information from another routing protocol\n"
12523 "Open Shortest Path First (OSPFv2)\n"
12524 "Non-main Kernel Routing Table\n"
12525 "Instance ID/Table ID\n"
12526 "Metric for redistributed routes\n"
12528 "Route map reference\n"
12529 "Pointer to route-map entries\n")
12531 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12532 int idx_ospf_table
= 1;
12533 int idx_number
= 2;
12534 int idx_number_2
= 4;
12537 struct bgp_redist
*red
;
12538 unsigned short instance
;
12541 struct route_map
*route_map
=
12542 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12544 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12545 protocol
= ZEBRA_ROUTE_OSPF
;
12547 protocol
= ZEBRA_ROUTE_TABLE
;
12549 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12550 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12552 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12553 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12556 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12557 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12561 bgp_redistribute_ipv4_ospf_metric_rmap
,
12562 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
12563 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12564 "Redistribute information from another routing protocol\n"
12565 "Open Shortest Path First (OSPFv2)\n"
12566 "Non-main Kernel Routing Table\n"
12567 "Instance ID/Table ID\n"
12568 "Metric for redistributed routes\n"
12570 "Route map reference\n"
12571 "Pointer to route-map entries\n")
12573 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12574 no_bgp_redistribute_ipv4_ospf_cmd
,
12575 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
12577 "Redistribute information from another routing protocol\n"
12578 "Open Shortest Path First (OSPFv2)\n"
12579 "Non-main Kernel Routing Table\n"
12580 "Instance ID/Table ID\n"
12581 "Metric for redistributed routes\n"
12583 "Route map reference\n"
12584 "Pointer to route-map entries\n")
12586 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12587 int idx_ospf_table
= 2;
12588 int idx_number
= 3;
12589 unsigned short instance
;
12592 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12593 protocol
= ZEBRA_ROUTE_OSPF
;
12595 protocol
= ZEBRA_ROUTE_TABLE
;
12597 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12598 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12602 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12603 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
12605 "Redistribute information from another routing protocol\n"
12606 "Open Shortest Path First (OSPFv2)\n"
12607 "Non-main Kernel Routing Table\n"
12608 "Instance ID/Table ID\n"
12609 "Metric for redistributed routes\n"
12611 "Route map reference\n"
12612 "Pointer to route-map entries\n")
12614 DEFUN (no_bgp_redistribute_ipv4
,
12615 no_bgp_redistribute_ipv4_cmd
,
12616 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
12618 "Redistribute information from another routing protocol\n"
12619 FRR_IP_REDIST_HELP_STR_BGPD
12620 "Metric for redistributed routes\n"
12622 "Route map reference\n"
12623 "Pointer to route-map entries\n")
12625 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12626 int idx_protocol
= 2;
12629 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12631 vty_out(vty
, "%% Invalid route type\n");
12632 return CMD_WARNING_CONFIG_FAILED
;
12634 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12638 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12639 "no redistribute " FRR_IP_REDIST_STR_BGPD
12640 " [{metric (0-4294967295)|route-map WORD}]",
12642 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12643 "Metric for redistributed routes\n"
12645 "Route map reference\n"
12646 "Pointer to route-map entries\n")
12648 DEFUN (bgp_redistribute_ipv6
,
12649 bgp_redistribute_ipv6_cmd
,
12650 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12651 "Redistribute information from another routing protocol\n"
12652 FRR_IP6_REDIST_HELP_STR_BGPD
)
12654 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12655 int idx_protocol
= 1;
12658 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12660 vty_out(vty
, "%% Invalid route type\n");
12661 return CMD_WARNING_CONFIG_FAILED
;
12664 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12665 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12668 DEFUN (bgp_redistribute_ipv6_rmap
,
12669 bgp_redistribute_ipv6_rmap_cmd
,
12670 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12671 "Redistribute information from another routing protocol\n"
12672 FRR_IP6_REDIST_HELP_STR_BGPD
12673 "Route map reference\n"
12674 "Pointer to route-map entries\n")
12676 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12677 int idx_protocol
= 1;
12680 struct bgp_redist
*red
;
12682 struct route_map
*route_map
=
12683 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12685 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12687 vty_out(vty
, "%% Invalid route type\n");
12688 return CMD_WARNING_CONFIG_FAILED
;
12691 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12693 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12694 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12697 DEFUN (bgp_redistribute_ipv6_metric
,
12698 bgp_redistribute_ipv6_metric_cmd
,
12699 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12700 "Redistribute information from another routing protocol\n"
12701 FRR_IP6_REDIST_HELP_STR_BGPD
12702 "Metric for redistributed routes\n"
12703 "Default metric\n")
12705 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12706 int idx_protocol
= 1;
12707 int idx_number
= 3;
12710 struct bgp_redist
*red
;
12713 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12715 vty_out(vty
, "%% Invalid route type\n");
12716 return CMD_WARNING_CONFIG_FAILED
;
12718 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12720 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12721 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12722 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12725 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12726 bgp_redistribute_ipv6_rmap_metric_cmd
,
12727 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12728 "Redistribute information from another routing protocol\n"
12729 FRR_IP6_REDIST_HELP_STR_BGPD
12730 "Route map reference\n"
12731 "Pointer to route-map entries\n"
12732 "Metric for redistributed routes\n"
12733 "Default metric\n")
12735 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12736 int idx_protocol
= 1;
12738 int idx_number
= 5;
12741 struct bgp_redist
*red
;
12743 struct route_map
*route_map
=
12744 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12746 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12748 vty_out(vty
, "%% Invalid route type\n");
12749 return CMD_WARNING_CONFIG_FAILED
;
12751 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12753 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12755 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12756 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12758 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12761 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12762 bgp_redistribute_ipv6_metric_rmap_cmd
,
12763 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12764 "Redistribute information from another routing protocol\n"
12765 FRR_IP6_REDIST_HELP_STR_BGPD
12766 "Metric for redistributed routes\n"
12768 "Route map reference\n"
12769 "Pointer to route-map entries\n")
12771 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12772 int idx_protocol
= 1;
12773 int idx_number
= 3;
12777 struct bgp_redist
*red
;
12779 struct route_map
*route_map
=
12780 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12782 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12784 vty_out(vty
, "%% Invalid route type\n");
12785 return CMD_WARNING_CONFIG_FAILED
;
12787 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12789 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12790 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12793 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12794 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12797 DEFUN (no_bgp_redistribute_ipv6
,
12798 no_bgp_redistribute_ipv6_cmd
,
12799 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
12801 "Redistribute information from another routing protocol\n"
12802 FRR_IP6_REDIST_HELP_STR_BGPD
12803 "Metric for redistributed routes\n"
12805 "Route map reference\n"
12806 "Pointer to route-map entries\n")
12808 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12809 int idx_protocol
= 2;
12812 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12814 vty_out(vty
, "%% Invalid route type\n");
12815 return CMD_WARNING_CONFIG_FAILED
;
12818 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12821 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
12822 afi_t afi
, safi_t safi
)
12826 /* Unicast redistribution only. */
12827 if (safi
!= SAFI_UNICAST
)
12830 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12831 /* Redistribute BGP does not make sense. */
12832 if (i
!= ZEBRA_ROUTE_BGP
) {
12833 struct list
*red_list
;
12834 struct listnode
*node
;
12835 struct bgp_redist
*red
;
12837 red_list
= bgp
->redist
[afi
][i
];
12841 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12842 /* "redistribute" configuration. */
12843 vty_out(vty
, " redistribute %s",
12844 zebra_route_string(i
));
12846 vty_out(vty
, " %d", red
->instance
);
12847 if (red
->redist_metric_flag
)
12848 vty_out(vty
, " metric %u",
12849 red
->redist_metric
);
12850 if (red
->rmap
.name
)
12851 vty_out(vty
, " route-map %s",
12853 vty_out(vty
, "\n");
12859 /* peer-group helpers for config-write */
12861 static bool peergroup_flag_check(struct peer
*peer
, uint32_t flag
)
12863 if (!peer_group_active(peer
)) {
12864 if (CHECK_FLAG(peer
->flags_invert
, flag
))
12865 return !CHECK_FLAG(peer
->flags
, flag
);
12867 return !!CHECK_FLAG(peer
->flags
, flag
);
12870 return !!CHECK_FLAG(peer
->flags_override
, flag
);
12873 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
12876 if (!peer_group_active(peer
)) {
12877 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
12878 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
12880 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
12883 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
12886 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
12887 uint8_t type
, int direct
)
12889 struct bgp_filter
*filter
;
12891 if (peer_group_active(peer
))
12892 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
12895 filter
= &peer
->filter
[afi
][safi
];
12897 case PEER_FT_DISTRIBUTE_LIST
:
12898 return !!(filter
->dlist
[direct
].name
);
12899 case PEER_FT_FILTER_LIST
:
12900 return !!(filter
->aslist
[direct
].name
);
12901 case PEER_FT_PREFIX_LIST
:
12902 return !!(filter
->plist
[direct
].name
);
12903 case PEER_FT_ROUTE_MAP
:
12904 return !!(filter
->map
[direct
].name
);
12905 case PEER_FT_UNSUPPRESS_MAP
:
12906 return !!(filter
->usmap
.name
);
12912 /* Return true if the addpath type is set for peer and different from
12915 static int peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
, safi_t safi
)
12917 enum bgp_addpath_strat type
, g_type
;
12919 type
= peer
->addpath_type
[afi
][safi
];
12921 if (type
!= BGP_ADDPATH_NONE
) {
12922 if (peer_group_active(peer
)) {
12923 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
12925 if (type
!= g_type
)
12937 /* This is part of the address-family block (unicast only) */
12938 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12943 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12944 if (listcount(bgp
->vpn_policy
[afi
].import_vrf
))
12945 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12946 bgp
->vpn_policy
[afi
]
12947 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12949 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
12950 bgp
->vpn_policy
[afi
]
12951 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12953 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12954 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12955 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12956 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12959 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12960 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12962 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12965 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12966 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12967 bgp
->vpn_policy
[afi
].tovpn_label
);
12970 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12971 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12972 char buf
[RD_ADDRSTRLEN
];
12973 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12974 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12977 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12978 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12980 char buf
[PREFIX_STRLEN
];
12981 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12982 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12985 vty_out(vty
, "%*snexthop vpn export %s\n",
12989 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12990 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12992 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12993 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12995 char *b
= ecommunity_ecom2str(
12996 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12997 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12998 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12999 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
13001 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
13002 char *b
= ecommunity_ecom2str(
13003 bgp
->vpn_policy
[afi
]
13004 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
13005 ECOMMUNITY_FORMAT_ROUTE_MAP
,
13006 ECOMMUNITY_ROUTE_TARGET
);
13007 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
13008 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
13010 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
13011 char *b
= ecommunity_ecom2str(
13012 bgp
->vpn_policy
[afi
]
13013 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
13014 ECOMMUNITY_FORMAT_ROUTE_MAP
,
13015 ECOMMUNITY_ROUTE_TARGET
);
13016 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
13017 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
13021 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
13022 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
13023 bgp
->vpn_policy
[afi
]
13024 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
13026 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
13027 char *b
= ecommunity_ecom2str(
13028 bgp
->vpn_policy
[afi
]
13029 .import_redirect_rtlist
,
13030 ECOMMUNITY_FORMAT_ROUTE_MAP
,
13031 ECOMMUNITY_ROUTE_TARGET
);
13033 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
13034 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
13038 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
13039 afi_t afi
, safi_t safi
)
13041 struct bgp_filter
*filter
;
13045 filter
= &peer
->filter
[afi
][safi
];
13047 /* distribute-list. */
13048 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
13050 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
13051 filter
->dlist
[FILTER_IN
].name
);
13053 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
13055 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
13056 filter
->dlist
[FILTER_OUT
].name
);
13059 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
13061 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
13062 filter
->plist
[FILTER_IN
].name
);
13064 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
13066 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
13067 filter
->plist
[FILTER_OUT
].name
);
13070 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
13071 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
13072 filter
->map
[RMAP_IN
].name
);
13074 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
13076 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
13077 filter
->map
[RMAP_OUT
].name
);
13079 /* unsuppress-map */
13080 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
13081 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
13082 filter
->usmap
.name
);
13085 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
13087 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
13088 filter
->aslist
[FILTER_IN
].name
);
13090 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
13092 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
13093 filter
->aslist
[FILTER_OUT
].name
);
13096 /* BGP peer configuration display function. */
13097 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
13100 struct peer
*g_peer
= NULL
;
13101 char buf
[SU_ADDRSTRLEN
];
13103 int if_pg_printed
= false;
13104 int if_ras_printed
= false;
13106 /* Skip dynamic neighbors. */
13107 if (peer_dynamic_neighbor(peer
))
13111 addr
= peer
->conf_if
;
13115 /************************************
13116 ****** Global to the neighbor ******
13117 ************************************/
13118 if (peer
->conf_if
) {
13119 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
13120 vty_out(vty
, " neighbor %s interface v6only", addr
);
13122 vty_out(vty
, " neighbor %s interface", addr
);
13124 if (peer_group_active(peer
)) {
13125 vty_out(vty
, " peer-group %s", peer
->group
->name
);
13126 if_pg_printed
= true;
13127 } else if (peer
->as_type
== AS_SPECIFIED
) {
13128 vty_out(vty
, " remote-as %u", peer
->as
);
13129 if_ras_printed
= true;
13130 } else if (peer
->as_type
== AS_INTERNAL
) {
13131 vty_out(vty
, " remote-as internal");
13132 if_ras_printed
= true;
13133 } else if (peer
->as_type
== AS_EXTERNAL
) {
13134 vty_out(vty
, " remote-as external");
13135 if_ras_printed
= true;
13138 vty_out(vty
, "\n");
13141 /* remote-as and peer-group */
13142 /* peer is a member of a peer-group */
13143 if (peer_group_active(peer
)) {
13144 g_peer
= peer
->group
->conf
;
13146 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
13147 if (peer
->as_type
== AS_SPECIFIED
) {
13148 vty_out(vty
, " neighbor %s remote-as %u\n",
13150 } else if (peer
->as_type
== AS_INTERNAL
) {
13152 " neighbor %s remote-as internal\n",
13154 } else if (peer
->as_type
== AS_EXTERNAL
) {
13156 " neighbor %s remote-as external\n",
13161 /* For swpX peers we displayed the peer-group
13162 * via 'neighbor swpX interface peer-group PGNAME' */
13163 if (!if_pg_printed
)
13164 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
13165 peer
->group
->name
);
13168 /* peer is NOT a member of a peer-group */
13170 /* peer is a peer-group, declare the peer-group */
13171 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
13172 vty_out(vty
, " neighbor %s peer-group\n", addr
);
13175 if (!if_ras_printed
) {
13176 if (peer
->as_type
== AS_SPECIFIED
) {
13177 vty_out(vty
, " neighbor %s remote-as %u\n",
13179 } else if (peer
->as_type
== AS_INTERNAL
) {
13181 " neighbor %s remote-as internal\n",
13183 } else if (peer
->as_type
== AS_EXTERNAL
) {
13185 " neighbor %s remote-as external\n",
13192 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
13193 vty_out(vty
, " neighbor %s local-as %u", addr
,
13194 peer
->change_local_as
);
13195 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
13196 vty_out(vty
, " no-prepend");
13197 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
13198 vty_out(vty
, " replace-as");
13199 vty_out(vty
, "\n");
13204 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
13208 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
13209 if (peer
->tx_shutdown_message
)
13210 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
13211 peer
->tx_shutdown_message
);
13213 vty_out(vty
, " neighbor %s shutdown\n", addr
);
13217 if (peer
->bfd_info
) {
13218 if (!peer_group_active(peer
) || !g_peer
->bfd_info
) {
13219 bgp_bfd_peer_config_write(vty
, peer
, addr
);
13224 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
13225 vty_out(vty
, " neighbor %s password %s\n", addr
,
13228 /* neighbor solo */
13229 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
13230 if (!peer_group_active(peer
)) {
13231 vty_out(vty
, " neighbor %s solo\n", addr
);
13236 if (peer
->port
!= BGP_PORT_DEFAULT
) {
13237 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
13240 /* Local interface name */
13241 if (peer
->ifname
) {
13242 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
13246 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
13247 vty_out(vty
, " neighbor %s passive\n", addr
);
13249 /* ebgp-multihop */
13250 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
13251 && !(peer
->gtsm_hops
!= 0 && peer
->ttl
== MAXTTL
)) {
13252 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
13253 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
13258 /* ttl-security hops */
13259 if (peer
->gtsm_hops
!= 0) {
13260 if (!peer_group_active(peer
)
13261 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
13262 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
13263 addr
, peer
->gtsm_hops
);
13267 /* disable-connected-check */
13268 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
13269 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
13271 /* enforce-first-as */
13272 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
13273 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
13275 /* update-source */
13276 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
13277 if (peer
->update_source
)
13278 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
13279 sockunion2str(peer
->update_source
, buf
,
13281 else if (peer
->update_if
)
13282 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
13286 /* advertisement-interval */
13287 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
13288 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
13292 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
13293 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
13294 peer
->keepalive
, peer
->holdtime
);
13296 /* timers connect */
13297 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
13298 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
13301 /* capability dynamic */
13302 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
13303 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
13305 /* capability extended-nexthop */
13306 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
13307 if (!peer
->conf_if
) {
13308 if (CHECK_FLAG(peer
->flags_invert
,
13309 PEER_FLAG_CAPABILITY_ENHE
))
13311 " no neighbor %s capability extended-nexthop\n",
13315 " neighbor %s capability extended-nexthop\n",
13320 /* dont-capability-negotiation */
13321 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
13322 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
13324 /* override-capability */
13325 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
13326 vty_out(vty
, " neighbor %s override-capability\n", addr
);
13328 /* strict-capability-match */
13329 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
13330 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
13332 /* Sender side AS path loop detection. */
13333 if (peer
->as_path_loop_detection
)
13334 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
13338 /* BGP peer configuration display function. */
13339 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
13340 struct peer
*peer
, afi_t afi
, safi_t safi
)
13342 struct peer
*g_peer
= NULL
;
13344 bool flag_scomm
, flag_secomm
, flag_slcomm
;
13346 /* Skip dynamic neighbors. */
13347 if (peer_dynamic_neighbor(peer
))
13351 addr
= peer
->conf_if
;
13355 /************************************
13356 ****** Per AF to the neighbor ******
13357 ************************************/
13358 if (peer_group_active(peer
)) {
13359 g_peer
= peer
->group
->conf
;
13361 /* If the peer-group is active but peer is not, print a 'no
13363 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
13364 vty_out(vty
, " no neighbor %s activate\n", addr
);
13367 /* If the peer-group is not active but peer is, print an
13369 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
13370 vty_out(vty
, " neighbor %s activate\n", addr
);
13373 if (peer
->afc
[afi
][safi
]) {
13374 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
13375 if (bgp_flag_check(bgp
,
13376 BGP_FLAG_NO_DEFAULT_IPV4
)) {
13377 vty_out(vty
, " neighbor %s activate\n",
13381 vty_out(vty
, " neighbor %s activate\n", addr
);
13383 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
13384 if (!bgp_flag_check(bgp
,
13385 BGP_FLAG_NO_DEFAULT_IPV4
)) {
13387 " no neighbor %s activate\n",
13394 /* addpath TX knobs */
13395 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
13396 switch (peer
->addpath_type
[afi
][safi
]) {
13397 case BGP_ADDPATH_ALL
:
13398 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
13401 case BGP_ADDPATH_BEST_PER_AS
:
13403 " neighbor %s addpath-tx-bestpath-per-AS\n",
13406 case BGP_ADDPATH_MAX
:
13407 case BGP_ADDPATH_NONE
:
13412 /* ORF capability. */
13413 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
13414 || peergroup_af_flag_check(peer
, afi
, safi
,
13415 PEER_FLAG_ORF_PREFIX_RM
)) {
13416 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
13418 if (peergroup_af_flag_check(peer
, afi
, safi
,
13419 PEER_FLAG_ORF_PREFIX_SM
)
13420 && peergroup_af_flag_check(peer
, afi
, safi
,
13421 PEER_FLAG_ORF_PREFIX_RM
))
13422 vty_out(vty
, " both");
13423 else if (peergroup_af_flag_check(peer
, afi
, safi
,
13424 PEER_FLAG_ORF_PREFIX_SM
))
13425 vty_out(vty
, " send");
13427 vty_out(vty
, " receive");
13428 vty_out(vty
, "\n");
13431 /* BGP flag dampening. */
13432 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
13433 BGP_CONFIG_DAMPENING
))
13434 bgp_config_write_damp(vty
, afi
, safi
);
13436 /* Route reflector client. */
13437 if (peergroup_af_flag_check(peer
, afi
, safi
,
13438 PEER_FLAG_REFLECTOR_CLIENT
)) {
13439 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
13442 /* next-hop-self force */
13443 if (peergroup_af_flag_check(peer
, afi
, safi
,
13444 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
13445 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
13448 /* next-hop-self */
13449 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
13450 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
13453 /* remove-private-AS */
13454 if (peergroup_af_flag_check(peer
, afi
, safi
,
13455 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
13456 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
13460 else if (peergroup_af_flag_check(peer
, afi
, safi
,
13461 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
13462 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
13466 else if (peergroup_af_flag_check(peer
, afi
, safi
,
13467 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
13468 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
13471 else if (peergroup_af_flag_check(peer
, afi
, safi
,
13472 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
13473 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
13477 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
13478 vty_out(vty
, " neighbor %s as-override\n", addr
);
13481 /* send-community print. */
13482 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
13483 PEER_FLAG_SEND_COMMUNITY
);
13484 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
13485 PEER_FLAG_SEND_EXT_COMMUNITY
);
13486 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
13487 PEER_FLAG_SEND_LARGE_COMMUNITY
);
13489 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
13490 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
13493 vty_out(vty
, " no neighbor %s send-community\n", addr
);
13496 " no neighbor %s send-community extended\n",
13500 vty_out(vty
, " no neighbor %s send-community large\n",
13504 /* Default information */
13505 if (peergroup_af_flag_check(peer
, afi
, safi
,
13506 PEER_FLAG_DEFAULT_ORIGINATE
)) {
13507 vty_out(vty
, " neighbor %s default-originate", addr
);
13509 if (peer
->default_rmap
[afi
][safi
].name
)
13510 vty_out(vty
, " route-map %s",
13511 peer
->default_rmap
[afi
][safi
].name
);
13513 vty_out(vty
, "\n");
13516 /* Soft reconfiguration inbound. */
13517 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
13518 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
13522 /* maximum-prefix. */
13523 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
13524 vty_out(vty
, " neighbor %s maximum-prefix %" PRIu32
, addr
,
13525 peer
->pmax
[afi
][safi
]);
13527 if (peer
->pmax_threshold
[afi
][safi
]
13528 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
13529 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
13530 if (peer_af_flag_check(peer
, afi
, safi
,
13531 PEER_FLAG_MAX_PREFIX_WARNING
))
13532 vty_out(vty
, " warning-only");
13533 if (peer
->pmax_restart
[afi
][safi
])
13534 vty_out(vty
, " restart %u",
13535 peer
->pmax_restart
[afi
][safi
]);
13537 vty_out(vty
, "\n");
13540 /* Route server client. */
13541 if (peergroup_af_flag_check(peer
, afi
, safi
,
13542 PEER_FLAG_RSERVER_CLIENT
)) {
13543 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
13546 /* Nexthop-local unchanged. */
13547 if (peergroup_af_flag_check(peer
, afi
, safi
,
13548 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
13549 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
13552 /* allowas-in <1-10> */
13553 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
13554 if (peer_af_flag_check(peer
, afi
, safi
,
13555 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
13556 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
13557 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
13558 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
13560 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
13561 peer
->allowas_in
[afi
][safi
]);
13566 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
13567 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
13568 peer
->weight
[afi
][safi
]);
13571 bgp_config_write_filter(vty
, peer
, afi
, safi
);
13573 /* atribute-unchanged. */
13574 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
13575 || (safi
!= SAFI_EVPN
13576 && peer_af_flag_check(peer
, afi
, safi
,
13577 PEER_FLAG_NEXTHOP_UNCHANGED
))
13578 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
13580 if (!peer_group_active(peer
)
13581 || peergroup_af_flag_check(peer
, afi
, safi
,
13582 PEER_FLAG_AS_PATH_UNCHANGED
)
13583 || peergroup_af_flag_check(peer
, afi
, safi
,
13584 PEER_FLAG_NEXTHOP_UNCHANGED
)
13585 || peergroup_af_flag_check(peer
, afi
, safi
,
13586 PEER_FLAG_MED_UNCHANGED
)) {
13589 " neighbor %s attribute-unchanged%s%s%s\n",
13591 peer_af_flag_check(peer
, afi
, safi
,
13592 PEER_FLAG_AS_PATH_UNCHANGED
)
13595 peer_af_flag_check(peer
, afi
, safi
,
13596 PEER_FLAG_NEXTHOP_UNCHANGED
)
13599 peer_af_flag_check(peer
, afi
, safi
,
13600 PEER_FLAG_MED_UNCHANGED
)
13607 /* Address family based peer configuration display. */
13608 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
13612 struct peer_group
*group
;
13613 struct listnode
*node
, *nnode
;
13616 vty_frame(vty
, " !\n address-family ");
13617 if (afi
== AFI_IP
) {
13618 if (safi
== SAFI_UNICAST
)
13619 vty_frame(vty
, "ipv4 unicast");
13620 else if (safi
== SAFI_LABELED_UNICAST
)
13621 vty_frame(vty
, "ipv4 labeled-unicast");
13622 else if (safi
== SAFI_MULTICAST
)
13623 vty_frame(vty
, "ipv4 multicast");
13624 else if (safi
== SAFI_MPLS_VPN
)
13625 vty_frame(vty
, "ipv4 vpn");
13626 else if (safi
== SAFI_ENCAP
)
13627 vty_frame(vty
, "ipv4 encap");
13628 else if (safi
== SAFI_FLOWSPEC
)
13629 vty_frame(vty
, "ipv4 flowspec");
13630 } else if (afi
== AFI_IP6
) {
13631 if (safi
== SAFI_UNICAST
)
13632 vty_frame(vty
, "ipv6 unicast");
13633 else if (safi
== SAFI_LABELED_UNICAST
)
13634 vty_frame(vty
, "ipv6 labeled-unicast");
13635 else if (safi
== SAFI_MULTICAST
)
13636 vty_frame(vty
, "ipv6 multicast");
13637 else if (safi
== SAFI_MPLS_VPN
)
13638 vty_frame(vty
, "ipv6 vpn");
13639 else if (safi
== SAFI_ENCAP
)
13640 vty_frame(vty
, "ipv6 encap");
13641 else if (safi
== SAFI_FLOWSPEC
)
13642 vty_frame(vty
, "ipv6 flowspec");
13643 } else if (afi
== AFI_L2VPN
) {
13644 if (safi
== SAFI_EVPN
)
13645 vty_frame(vty
, "l2vpn evpn");
13647 vty_frame(vty
, "\n");
13649 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
13651 bgp_config_write_network(vty
, bgp
, afi
, safi
);
13653 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
13655 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
13656 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
13658 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
13659 /* Skip dynamic neighbors. */
13660 if (peer_dynamic_neighbor(peer
))
13663 /* Do not display doppelganger peers */
13664 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
13665 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
13668 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
13669 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
13671 if (safi
== SAFI_EVPN
)
13672 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
13674 if (safi
== SAFI_FLOWSPEC
)
13675 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
13677 if (safi
== SAFI_UNICAST
) {
13678 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
13679 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
13680 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
13682 vty_out(vty
, " export vpn\n");
13684 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
13685 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
13687 vty_out(vty
, " import vpn\n");
13689 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
13690 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
13693 for (ALL_LIST_ELEMENTS_RO(
13694 bgp
->vpn_policy
[afi
].import_vrf
, node
,
13696 vty_out(vty
, " import vrf %s\n", name
);
13700 vty_endframe(vty
, " exit-address-family\n");
13703 int bgp_config_write(struct vty
*vty
)
13706 struct peer_group
*group
;
13708 struct listnode
*node
, *nnode
;
13709 struct listnode
*mnode
, *mnnode
;
13711 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
13712 vty_out(vty
, "bgp route-map delay-timer %u\n",
13713 bm
->rmap_update_timer
);
13715 /* BGP configuration. */
13716 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
13718 /* skip all auto created vrf as they dont have user config */
13719 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
13722 /* Router bgp ASN */
13723 vty_out(vty
, "router bgp %u", bgp
->as
);
13726 vty_out(vty
, " %s %s",
13727 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
13728 ? "view" : "vrf", bgp
->name
);
13729 vty_out(vty
, "\n");
13731 /* BGP fast-external-failover. */
13732 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
13733 vty_out(vty
, " no bgp fast-external-failover\n");
13735 /* BGP router ID. */
13736 if (bgp
->router_id_static
.s_addr
!= 0)
13737 vty_out(vty
, " bgp router-id %s\n",
13738 inet_ntoa(bgp
->router_id_static
));
13740 /* BGP log-neighbor-changes. */
13741 if (!!bgp_flag_check(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
13742 != DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
13743 vty_out(vty
, " %sbgp log-neighbor-changes\n",
13744 bgp_flag_check(bgp
,
13745 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
13749 /* BGP configuration. */
13750 if (bgp_flag_check(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
))
13751 vty_out(vty
, " bgp always-compare-med\n");
13753 /* RFC8212 default eBGP policy. */
13754 if (bgp
->ebgp_requires_policy
13755 == DEFAULT_EBGP_POLICY_ENABLED
)
13756 vty_out(vty
, " bgp ebgp-requires-policy\n");
13758 /* draft-ietf-idr-deprecate-as-set-confed-set */
13759 if (bgp
->reject_as_sets
== BGP_REJECT_AS_SETS_ENABLED
)
13760 vty_out(vty
, " bgp reject-as-sets\n");
13762 /* BGP default ipv4-unicast. */
13763 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
))
13764 vty_out(vty
, " no bgp default ipv4-unicast\n");
13766 /* BGP default local-preference. */
13767 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
13768 vty_out(vty
, " bgp default local-preference %u\n",
13769 bgp
->default_local_pref
);
13771 /* BGP default show-hostname */
13772 if (!!bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
)
13773 != DFLT_BGP_SHOW_HOSTNAME
)
13774 vty_out(vty
, " %sbgp default show-hostname\n",
13775 bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
)
13779 /* BGP default subgroup-pkt-queue-max. */
13780 if (bgp
->default_subgroup_pkt_queue_max
13781 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
13782 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
13783 bgp
->default_subgroup_pkt_queue_max
);
13785 /* BGP client-to-client reflection. */
13786 if (bgp_flag_check(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
13787 vty_out(vty
, " no bgp client-to-client reflection\n");
13789 /* BGP cluster ID. */
13790 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
13791 vty_out(vty
, " bgp cluster-id %s\n",
13792 inet_ntoa(bgp
->cluster_id
));
13794 /* Disable ebgp connected nexthop check */
13795 if (bgp_flag_check(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
13797 " bgp disable-ebgp-connected-route-check\n");
13799 /* Confederation identifier*/
13800 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13801 vty_out(vty
, " bgp confederation identifier %u\n",
13804 /* Confederation peer */
13805 if (bgp
->confed_peers_cnt
> 0) {
13808 vty_out(vty
, " bgp confederation peers");
13810 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
13811 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
13813 vty_out(vty
, "\n");
13816 /* BGP deterministic-med. */
13817 if (!!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)
13818 != DFLT_BGP_DETERMINISTIC_MED
)
13819 vty_out(vty
, " %sbgp deterministic-med\n",
13820 bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)
13824 /* BGP update-delay. */
13825 bgp_config_write_update_delay(vty
, bgp
);
13827 if (bgp
->v_maxmed_onstartup
13828 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
13829 vty_out(vty
, " bgp max-med on-startup %u",
13830 bgp
->v_maxmed_onstartup
);
13831 if (bgp
->maxmed_onstartup_value
13832 != BGP_MAXMED_VALUE_DEFAULT
)
13833 vty_out(vty
, " %u",
13834 bgp
->maxmed_onstartup_value
);
13835 vty_out(vty
, "\n");
13837 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
13838 vty_out(vty
, " bgp max-med administrative");
13839 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
13840 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
13841 vty_out(vty
, "\n");
13845 bgp_config_write_wpkt_quanta(vty
, bgp
);
13847 bgp_config_write_rpkt_quanta(vty
, bgp
);
13849 /* coalesce time */
13850 bgp_config_write_coalesce_time(vty
, bgp
);
13852 /* BGP graceful-restart. */
13853 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
13855 " bgp graceful-restart stalepath-time %u\n",
13856 bgp
->stalepath_time
);
13857 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
13858 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
13859 bgp
->restart_time
);
13860 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_RESTART
))
13861 vty_out(vty
, " bgp graceful-restart\n");
13863 /* BGP graceful-shutdown */
13864 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
13865 vty_out(vty
, " bgp graceful-shutdown\n");
13867 /* BGP graceful-restart Preserve State F bit. */
13868 if (bgp_flag_check(bgp
, BGP_FLAG_GR_PRESERVE_FWD
))
13870 " bgp graceful-restart preserve-fw-state\n");
13872 /* BGP bestpath method. */
13873 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
13874 vty_out(vty
, " bgp bestpath as-path ignore\n");
13875 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
13876 vty_out(vty
, " bgp bestpath as-path confed\n");
13878 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
13879 if (bgp_flag_check(bgp
,
13880 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
13882 " bgp bestpath as-path multipath-relax as-set\n");
13885 " bgp bestpath as-path multipath-relax\n");
13889 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
13891 " bgp route-reflector allow-outbound-policy\n");
13893 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
13894 vty_out(vty
, " bgp bestpath compare-routerid\n");
13895 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
13896 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
13897 vty_out(vty
, " bgp bestpath med");
13898 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
13899 vty_out(vty
, " confed");
13900 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
13901 vty_out(vty
, " missing-as-worst");
13902 vty_out(vty
, "\n");
13905 /* BGP network import check. */
13906 if (!!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)
13907 != DFLT_BGP_IMPORT_CHECK
)
13908 vty_out(vty
, " %sbgp network import-check\n",
13909 bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)
13913 /* BGP timers configuration. */
13914 if (bgp
->default_keepalive
!= BGP_DEFAULT_KEEPALIVE
13915 && bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
13916 vty_out(vty
, " timers bgp %u %u\n",
13917 bgp
->default_keepalive
, bgp
->default_holdtime
);
13920 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
13921 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
13924 /* Normal neighbor configuration. */
13925 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
13926 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
13927 bgp_config_write_peer_global(vty
, bgp
, peer
);
13930 /* listen range and limit for dynamic BGP neighbors */
13931 bgp_config_write_listen(vty
, bgp
);
13934 * BGP default autoshutdown neighbors
13936 * This must be placed after any peer and peer-group
13937 * configuration, to avoid setting all peers to shutdown after
13938 * a daemon restart, which is undesired behavior. (see #2286)
13940 if (bgp
->autoshutdown
)
13941 vty_out(vty
, " bgp default shutdown\n");
13943 /* IPv4 unicast configuration. */
13944 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
13946 /* IPv4 multicast configuration. */
13947 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
13949 /* IPv4 labeled-unicast configuration. */
13950 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
13952 /* IPv4 VPN configuration. */
13953 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
13955 /* ENCAPv4 configuration. */
13956 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
13958 /* FLOWSPEC v4 configuration. */
13959 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
13961 /* IPv6 unicast configuration. */
13962 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
13964 /* IPv6 multicast configuration. */
13965 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
13967 /* IPv6 labeled-unicast configuration. */
13968 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
13969 SAFI_LABELED_UNICAST
);
13971 /* IPv6 VPN configuration. */
13972 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
13974 /* ENCAPv6 configuration. */
13975 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
13977 /* FLOWSPEC v6 configuration. */
13978 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
13980 /* EVPN configuration. */
13981 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
13983 hook_call(bgp_inst_config_write
, bgp
, vty
);
13986 bgp_rfapi_cfg_write(vty
, bgp
);
13989 vty_out(vty
, "!\n");
13995 /* BGP node structure. */
13996 static struct cmd_node bgp_node
= {
13997 BGP_NODE
, "%s(config-router)# ", 1,
14000 static struct cmd_node bgp_ipv4_unicast_node
= {
14001 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
14004 static struct cmd_node bgp_ipv4_multicast_node
= {
14005 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
14008 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
14009 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
14012 static struct cmd_node bgp_ipv6_unicast_node
= {
14013 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
14016 static struct cmd_node bgp_ipv6_multicast_node
= {
14017 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
14020 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
14021 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
14024 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
14025 "%s(config-router-af)# ", 1};
14027 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
14028 "%s(config-router-af-vpnv6)# ", 1};
14030 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
14031 "%s(config-router-evpn)# ", 1};
14033 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
14034 "%s(config-router-af-vni)# ", 1};
14036 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
14037 "%s(config-router-af)# ", 1};
14039 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
14040 "%s(config-router-af-vpnv6)# ", 1};
14042 static void community_list_vty(void);
14044 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
14048 struct listnode
*lnbgp
, *lnpeer
;
14050 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
14051 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
14052 /* only provide suggestions on the appropriate input
14054 * they'll otherwise show up multiple times */
14055 enum cmd_token_type match_type
;
14056 char *name
= peer
->host
;
14058 if (peer
->conf_if
) {
14059 match_type
= VARIABLE_TKN
;
14060 name
= peer
->conf_if
;
14061 } else if (strchr(peer
->host
, ':'))
14062 match_type
= IPV6_TKN
;
14064 match_type
= IPV4_TKN
;
14066 if (token
->type
!= match_type
)
14069 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
14074 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
14075 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
14076 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
14077 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
14078 {.completions
= NULL
}};
14080 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
14083 struct peer_group
*group
;
14084 struct listnode
*lnbgp
, *lnpeer
;
14086 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
14087 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
14088 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
14093 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
14094 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
14095 {.completions
= NULL
} };
14097 void bgp_vty_init(void)
14099 cmd_variable_handler_register(bgp_var_neighbor
);
14100 cmd_variable_handler_register(bgp_var_peergroup
);
14102 /* Install bgp top node. */
14103 install_node(&bgp_node
, bgp_config_write
);
14104 install_node(&bgp_ipv4_unicast_node
, NULL
);
14105 install_node(&bgp_ipv4_multicast_node
, NULL
);
14106 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
14107 install_node(&bgp_ipv6_unicast_node
, NULL
);
14108 install_node(&bgp_ipv6_multicast_node
, NULL
);
14109 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
14110 install_node(&bgp_vpnv4_node
, NULL
);
14111 install_node(&bgp_vpnv6_node
, NULL
);
14112 install_node(&bgp_evpn_node
, NULL
);
14113 install_node(&bgp_evpn_vni_node
, NULL
);
14114 install_node(&bgp_flowspecv4_node
, NULL
);
14115 install_node(&bgp_flowspecv6_node
, NULL
);
14117 /* Install default VTY commands to new nodes. */
14118 install_default(BGP_NODE
);
14119 install_default(BGP_IPV4_NODE
);
14120 install_default(BGP_IPV4M_NODE
);
14121 install_default(BGP_IPV4L_NODE
);
14122 install_default(BGP_IPV6_NODE
);
14123 install_default(BGP_IPV6M_NODE
);
14124 install_default(BGP_IPV6L_NODE
);
14125 install_default(BGP_VPNV4_NODE
);
14126 install_default(BGP_VPNV6_NODE
);
14127 install_default(BGP_FLOWSPECV4_NODE
);
14128 install_default(BGP_FLOWSPECV6_NODE
);
14129 install_default(BGP_EVPN_NODE
);
14130 install_default(BGP_EVPN_VNI_NODE
);
14132 /* "bgp local-mac" hidden commands. */
14133 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
14134 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
14136 /* bgp route-map delay-timer commands. */
14137 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
14138 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
14140 /* Dummy commands (Currently not supported) */
14141 install_element(BGP_NODE
, &no_synchronization_cmd
);
14142 install_element(BGP_NODE
, &no_auto_summary_cmd
);
14144 /* "router bgp" commands. */
14145 install_element(CONFIG_NODE
, &router_bgp_cmd
);
14147 /* "no router bgp" commands. */
14148 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
14150 /* "bgp router-id" commands. */
14151 install_element(BGP_NODE
, &bgp_router_id_cmd
);
14152 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
14154 /* "bgp cluster-id" commands. */
14155 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
14156 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
14158 /* "bgp confederation" commands. */
14159 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
14160 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
14162 /* "bgp confederation peers" commands. */
14163 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
14164 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
14166 /* bgp max-med command */
14167 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
14168 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
14169 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
14170 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
14171 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
14173 /* bgp disable-ebgp-connected-nh-check */
14174 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
14175 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
14177 /* bgp update-delay command */
14178 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
14179 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
14180 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
14182 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
14183 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
14185 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
14186 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
14188 /* "maximum-paths" commands. */
14189 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
14190 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
14191 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
14192 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
14193 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
14194 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
14195 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
14196 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
14197 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
14198 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
14199 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
14200 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
14201 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
14202 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
14203 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
14205 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
14206 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
14207 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
14208 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
14209 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
14211 /* "timers bgp" commands. */
14212 install_element(BGP_NODE
, &bgp_timers_cmd
);
14213 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
14215 /* route-map delay-timer commands - per instance for backwards compat.
14217 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
14218 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
14220 /* "bgp client-to-client reflection" commands */
14221 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
14222 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
14224 /* "bgp always-compare-med" commands */
14225 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
14226 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
14228 /* bgp ebgp-requires-policy */
14229 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
14230 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
14232 /* bgp reject-as-sets */
14233 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
14234 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
14236 /* "bgp deterministic-med" commands */
14237 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
14238 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
14240 /* "bgp graceful-restart" commands */
14241 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
14242 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
14243 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
14244 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
14245 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
14246 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
14248 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
14249 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
14251 /* "bgp graceful-shutdown" commands */
14252 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
14253 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
14255 /* "bgp fast-external-failover" commands */
14256 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
14257 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
14259 /* "bgp bestpath compare-routerid" commands */
14260 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
14261 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
14263 /* "bgp bestpath as-path ignore" commands */
14264 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
14265 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
14267 /* "bgp bestpath as-path confed" commands */
14268 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
14269 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
14271 /* "bgp bestpath as-path multipath-relax" commands */
14272 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
14273 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
14275 /* "bgp log-neighbor-changes" commands */
14276 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
14277 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
14279 /* "bgp bestpath med" commands */
14280 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
14281 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
14283 /* "no bgp default ipv4-unicast" commands. */
14284 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
14285 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
14287 /* "bgp network import-check" commands. */
14288 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
14289 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
14290 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
14292 /* "bgp default local-preference" commands. */
14293 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
14294 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
14296 /* bgp default show-hostname */
14297 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
14298 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
14300 /* "bgp default subgroup-pkt-queue-max" commands. */
14301 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
14302 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
14304 /* bgp ibgp-allow-policy-mods command */
14305 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
14306 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
14308 /* "bgp listen limit" commands. */
14309 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
14310 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
14312 /* "bgp listen range" commands. */
14313 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
14314 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
14316 /* "bgp default shutdown" command */
14317 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
14319 /* "neighbor remote-as" commands. */
14320 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
14321 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
14322 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
14323 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
14324 install_element(BGP_NODE
,
14325 &neighbor_interface_v6only_config_remote_as_cmd
);
14326 install_element(BGP_NODE
, &no_neighbor_cmd
);
14327 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
14329 /* "neighbor peer-group" commands. */
14330 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
14331 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
14332 install_element(BGP_NODE
,
14333 &no_neighbor_interface_peer_group_remote_as_cmd
);
14335 /* "neighbor local-as" commands. */
14336 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
14337 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
14338 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
14339 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
14341 /* "neighbor solo" commands. */
14342 install_element(BGP_NODE
, &neighbor_solo_cmd
);
14343 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
14345 /* "neighbor password" commands. */
14346 install_element(BGP_NODE
, &neighbor_password_cmd
);
14347 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
14349 /* "neighbor activate" commands. */
14350 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
14351 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
14352 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
14353 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
14354 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
14355 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
14356 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
14357 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
14358 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
14359 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
14360 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
14361 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
14363 /* "no neighbor activate" commands. */
14364 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
14365 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
14366 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
14367 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
14368 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
14369 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
14370 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
14371 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
14372 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
14373 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
14374 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
14375 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
14377 /* "neighbor peer-group" set commands. */
14378 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
14379 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
14380 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
14381 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
14382 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
14383 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
14384 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
14385 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
14386 install_element(BGP_FLOWSPECV4_NODE
,
14387 &neighbor_set_peer_group_hidden_cmd
);
14388 install_element(BGP_FLOWSPECV6_NODE
,
14389 &neighbor_set_peer_group_hidden_cmd
);
14391 /* "no neighbor peer-group unset" commands. */
14392 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
14393 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
14394 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
14395 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
14396 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
14397 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
14398 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
14399 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
14400 install_element(BGP_FLOWSPECV4_NODE
,
14401 &no_neighbor_set_peer_group_hidden_cmd
);
14402 install_element(BGP_FLOWSPECV6_NODE
,
14403 &no_neighbor_set_peer_group_hidden_cmd
);
14405 /* "neighbor softreconfiguration inbound" commands.*/
14406 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
14407 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
14408 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
14409 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
14410 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
14411 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
14412 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
14413 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
14414 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
14415 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
14416 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
14417 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
14418 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
14419 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
14420 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
14421 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
14422 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
14423 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
14424 install_element(BGP_FLOWSPECV4_NODE
,
14425 &neighbor_soft_reconfiguration_cmd
);
14426 install_element(BGP_FLOWSPECV4_NODE
,
14427 &no_neighbor_soft_reconfiguration_cmd
);
14428 install_element(BGP_FLOWSPECV6_NODE
,
14429 &neighbor_soft_reconfiguration_cmd
);
14430 install_element(BGP_FLOWSPECV6_NODE
,
14431 &no_neighbor_soft_reconfiguration_cmd
);
14432 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
14433 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
14435 /* "neighbor attribute-unchanged" commands. */
14436 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
14437 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
14438 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
14439 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
14440 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
14441 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
14442 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
14443 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
14444 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
14445 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
14446 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
14447 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
14448 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
14449 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
14450 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
14451 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
14452 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
14453 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
14455 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
14456 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
14458 /* "nexthop-local unchanged" commands */
14459 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
14460 install_element(BGP_IPV6_NODE
,
14461 &no_neighbor_nexthop_local_unchanged_cmd
);
14463 /* "neighbor next-hop-self" commands. */
14464 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
14465 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
14466 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
14467 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
14468 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
14469 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
14470 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
14471 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
14472 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
14473 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
14474 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
14475 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
14476 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
14477 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
14478 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
14479 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
14480 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
14481 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
14482 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
14483 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
14485 /* "neighbor next-hop-self force" commands. */
14486 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
14487 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
14488 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
14489 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
14490 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
14491 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
14492 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
14493 install_element(BGP_IPV4_NODE
,
14494 &no_neighbor_nexthop_self_all_hidden_cmd
);
14495 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
14496 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
14497 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
14498 install_element(BGP_IPV4M_NODE
,
14499 &no_neighbor_nexthop_self_all_hidden_cmd
);
14500 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
14501 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
14502 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
14503 install_element(BGP_IPV4L_NODE
,
14504 &no_neighbor_nexthop_self_all_hidden_cmd
);
14505 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
14506 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
14507 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
14508 install_element(BGP_IPV6_NODE
,
14509 &no_neighbor_nexthop_self_all_hidden_cmd
);
14510 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
14511 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
14512 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
14513 install_element(BGP_IPV6M_NODE
,
14514 &no_neighbor_nexthop_self_all_hidden_cmd
);
14515 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
14516 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
14517 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
14518 install_element(BGP_IPV6L_NODE
,
14519 &no_neighbor_nexthop_self_all_hidden_cmd
);
14520 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
14521 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
14522 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
14523 install_element(BGP_VPNV4_NODE
,
14524 &no_neighbor_nexthop_self_all_hidden_cmd
);
14525 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
14526 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
14527 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
14528 install_element(BGP_VPNV6_NODE
,
14529 &no_neighbor_nexthop_self_all_hidden_cmd
);
14531 /* "neighbor as-override" commands. */
14532 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
14533 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
14534 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
14535 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
14536 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
14537 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
14538 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
14539 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
14540 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
14541 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
14542 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
14543 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
14544 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
14545 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
14546 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
14547 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
14548 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
14549 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
14551 /* "neighbor remove-private-AS" commands. */
14552 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
14553 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
14554 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
14555 install_element(BGP_NODE
,
14556 &no_neighbor_remove_private_as_all_hidden_cmd
);
14557 install_element(BGP_NODE
,
14558 &neighbor_remove_private_as_replace_as_hidden_cmd
);
14559 install_element(BGP_NODE
,
14560 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
14561 install_element(BGP_NODE
,
14562 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
14565 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
14566 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
14567 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
14568 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
14569 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
14570 install_element(BGP_IPV4_NODE
,
14571 &neighbor_remove_private_as_replace_as_cmd
);
14572 install_element(BGP_IPV4_NODE
,
14573 &no_neighbor_remove_private_as_replace_as_cmd
);
14574 install_element(BGP_IPV4_NODE
,
14575 &neighbor_remove_private_as_all_replace_as_cmd
);
14576 install_element(BGP_IPV4_NODE
,
14577 &no_neighbor_remove_private_as_all_replace_as_cmd
);
14578 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
14579 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
14580 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
14581 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
14582 install_element(BGP_IPV4M_NODE
,
14583 &neighbor_remove_private_as_replace_as_cmd
);
14584 install_element(BGP_IPV4M_NODE
,
14585 &no_neighbor_remove_private_as_replace_as_cmd
);
14586 install_element(BGP_IPV4M_NODE
,
14587 &neighbor_remove_private_as_all_replace_as_cmd
);
14588 install_element(BGP_IPV4M_NODE
,
14589 &no_neighbor_remove_private_as_all_replace_as_cmd
);
14590 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
14591 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
14592 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
14593 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
14594 install_element(BGP_IPV4L_NODE
,
14595 &neighbor_remove_private_as_replace_as_cmd
);
14596 install_element(BGP_IPV4L_NODE
,
14597 &no_neighbor_remove_private_as_replace_as_cmd
);
14598 install_element(BGP_IPV4L_NODE
,
14599 &neighbor_remove_private_as_all_replace_as_cmd
);
14600 install_element(BGP_IPV4L_NODE
,
14601 &no_neighbor_remove_private_as_all_replace_as_cmd
);
14602 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
14603 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
14604 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
14605 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
14606 install_element(BGP_IPV6_NODE
,
14607 &neighbor_remove_private_as_replace_as_cmd
);
14608 install_element(BGP_IPV6_NODE
,
14609 &no_neighbor_remove_private_as_replace_as_cmd
);
14610 install_element(BGP_IPV6_NODE
,
14611 &neighbor_remove_private_as_all_replace_as_cmd
);
14612 install_element(BGP_IPV6_NODE
,
14613 &no_neighbor_remove_private_as_all_replace_as_cmd
);
14614 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
14615 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
14616 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
14617 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
14618 install_element(BGP_IPV6M_NODE
,
14619 &neighbor_remove_private_as_replace_as_cmd
);
14620 install_element(BGP_IPV6M_NODE
,
14621 &no_neighbor_remove_private_as_replace_as_cmd
);
14622 install_element(BGP_IPV6M_NODE
,
14623 &neighbor_remove_private_as_all_replace_as_cmd
);
14624 install_element(BGP_IPV6M_NODE
,
14625 &no_neighbor_remove_private_as_all_replace_as_cmd
);
14626 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
14627 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
14628 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
14629 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
14630 install_element(BGP_IPV6L_NODE
,
14631 &neighbor_remove_private_as_replace_as_cmd
);
14632 install_element(BGP_IPV6L_NODE
,
14633 &no_neighbor_remove_private_as_replace_as_cmd
);
14634 install_element(BGP_IPV6L_NODE
,
14635 &neighbor_remove_private_as_all_replace_as_cmd
);
14636 install_element(BGP_IPV6L_NODE
,
14637 &no_neighbor_remove_private_as_all_replace_as_cmd
);
14638 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
14639 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
14640 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
14641 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
14642 install_element(BGP_VPNV4_NODE
,
14643 &neighbor_remove_private_as_replace_as_cmd
);
14644 install_element(BGP_VPNV4_NODE
,
14645 &no_neighbor_remove_private_as_replace_as_cmd
);
14646 install_element(BGP_VPNV4_NODE
,
14647 &neighbor_remove_private_as_all_replace_as_cmd
);
14648 install_element(BGP_VPNV4_NODE
,
14649 &no_neighbor_remove_private_as_all_replace_as_cmd
);
14650 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
14651 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
14652 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
14653 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
14654 install_element(BGP_VPNV6_NODE
,
14655 &neighbor_remove_private_as_replace_as_cmd
);
14656 install_element(BGP_VPNV6_NODE
,
14657 &no_neighbor_remove_private_as_replace_as_cmd
);
14658 install_element(BGP_VPNV6_NODE
,
14659 &neighbor_remove_private_as_all_replace_as_cmd
);
14660 install_element(BGP_VPNV6_NODE
,
14661 &no_neighbor_remove_private_as_all_replace_as_cmd
);
14663 /* "neighbor send-community" commands.*/
14664 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
14665 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
14666 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
14667 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
14668 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
14669 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
14670 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
14671 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
14672 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
14673 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
14674 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
14675 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
14676 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
14677 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
14678 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
14679 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
14680 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
14681 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
14682 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
14683 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
14684 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
14685 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
14686 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
14687 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
14688 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
14689 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
14690 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
14691 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
14692 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
14693 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
14694 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
14695 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
14696 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
14697 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
14698 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
14699 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
14701 /* "neighbor route-reflector" commands.*/
14702 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
14703 install_element(BGP_NODE
,
14704 &no_neighbor_route_reflector_client_hidden_cmd
);
14705 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
14706 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
14707 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
14708 install_element(BGP_IPV4M_NODE
,
14709 &no_neighbor_route_reflector_client_cmd
);
14710 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
14711 install_element(BGP_IPV4L_NODE
,
14712 &no_neighbor_route_reflector_client_cmd
);
14713 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
14714 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
14715 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
14716 install_element(BGP_IPV6M_NODE
,
14717 &no_neighbor_route_reflector_client_cmd
);
14718 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
14719 install_element(BGP_IPV6L_NODE
,
14720 &no_neighbor_route_reflector_client_cmd
);
14721 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
14722 install_element(BGP_VPNV4_NODE
,
14723 &no_neighbor_route_reflector_client_cmd
);
14724 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
14725 install_element(BGP_VPNV6_NODE
,
14726 &no_neighbor_route_reflector_client_cmd
);
14727 install_element(BGP_FLOWSPECV4_NODE
,
14728 &neighbor_route_reflector_client_cmd
);
14729 install_element(BGP_FLOWSPECV4_NODE
,
14730 &no_neighbor_route_reflector_client_cmd
);
14731 install_element(BGP_FLOWSPECV6_NODE
,
14732 &neighbor_route_reflector_client_cmd
);
14733 install_element(BGP_FLOWSPECV6_NODE
,
14734 &no_neighbor_route_reflector_client_cmd
);
14735 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
14736 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
14738 /* "neighbor route-server" commands.*/
14739 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
14740 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
14741 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
14742 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
14743 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
14744 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
14745 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
14746 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
14747 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
14748 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
14749 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
14750 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
14751 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
14752 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
14753 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
14754 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
14755 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
14756 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
14757 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
14758 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
14759 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
14760 install_element(BGP_FLOWSPECV4_NODE
,
14761 &no_neighbor_route_server_client_cmd
);
14762 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
14763 install_element(BGP_FLOWSPECV6_NODE
,
14764 &no_neighbor_route_server_client_cmd
);
14766 /* "neighbor addpath-tx-all-paths" commands.*/
14767 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
14768 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
14769 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
14770 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
14771 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
14772 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
14773 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
14774 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
14775 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
14776 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
14777 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
14778 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
14779 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
14780 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
14781 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
14782 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
14783 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
14784 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
14786 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
14787 install_element(BGP_NODE
,
14788 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
14789 install_element(BGP_NODE
,
14790 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
14791 install_element(BGP_IPV4_NODE
,
14792 &neighbor_addpath_tx_bestpath_per_as_cmd
);
14793 install_element(BGP_IPV4_NODE
,
14794 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
14795 install_element(BGP_IPV4M_NODE
,
14796 &neighbor_addpath_tx_bestpath_per_as_cmd
);
14797 install_element(BGP_IPV4M_NODE
,
14798 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
14799 install_element(BGP_IPV4L_NODE
,
14800 &neighbor_addpath_tx_bestpath_per_as_cmd
);
14801 install_element(BGP_IPV4L_NODE
,
14802 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
14803 install_element(BGP_IPV6_NODE
,
14804 &neighbor_addpath_tx_bestpath_per_as_cmd
);
14805 install_element(BGP_IPV6_NODE
,
14806 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
14807 install_element(BGP_IPV6M_NODE
,
14808 &neighbor_addpath_tx_bestpath_per_as_cmd
);
14809 install_element(BGP_IPV6M_NODE
,
14810 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
14811 install_element(BGP_IPV6L_NODE
,
14812 &neighbor_addpath_tx_bestpath_per_as_cmd
);
14813 install_element(BGP_IPV6L_NODE
,
14814 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
14815 install_element(BGP_VPNV4_NODE
,
14816 &neighbor_addpath_tx_bestpath_per_as_cmd
);
14817 install_element(BGP_VPNV4_NODE
,
14818 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
14819 install_element(BGP_VPNV6_NODE
,
14820 &neighbor_addpath_tx_bestpath_per_as_cmd
);
14821 install_element(BGP_VPNV6_NODE
,
14822 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
14824 /* "neighbor sender-as-path-loop-detection" commands. */
14825 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
14826 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
14828 /* "neighbor passive" commands. */
14829 install_element(BGP_NODE
, &neighbor_passive_cmd
);
14830 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
14833 /* "neighbor shutdown" commands. */
14834 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
14835 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
14836 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
14837 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
14839 /* "neighbor capability extended-nexthop" commands.*/
14840 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
14841 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
14843 /* "neighbor capability orf prefix-list" commands.*/
14844 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
14845 install_element(BGP_NODE
,
14846 &no_neighbor_capability_orf_prefix_hidden_cmd
);
14847 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
14848 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
14849 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
14850 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
14851 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
14852 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
14853 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
14854 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
14855 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
14856 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
14857 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
14858 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
14860 /* "neighbor capability dynamic" commands.*/
14861 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
14862 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
14864 /* "neighbor dont-capability-negotiate" commands. */
14865 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
14866 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
14868 /* "neighbor ebgp-multihop" commands. */
14869 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
14870 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
14871 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
14873 /* "neighbor disable-connected-check" commands. */
14874 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
14875 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
14877 /* "neighbor enforce-first-as" commands. */
14878 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
14879 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
14881 /* "neighbor description" commands. */
14882 install_element(BGP_NODE
, &neighbor_description_cmd
);
14883 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
14884 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
14886 /* "neighbor update-source" commands. "*/
14887 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
14888 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
14890 /* "neighbor default-originate" commands. */
14891 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
14892 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
14893 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
14894 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
14895 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
14896 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
14897 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
14898 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
14899 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
14900 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
14901 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
14902 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
14903 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
14904 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
14905 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
14906 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
14907 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
14908 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
14909 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
14910 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
14911 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
14913 /* "neighbor port" commands. */
14914 install_element(BGP_NODE
, &neighbor_port_cmd
);
14915 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
14917 /* "neighbor weight" commands. */
14918 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
14919 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
14921 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
14922 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
14923 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
14924 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
14925 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
14926 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
14927 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
14928 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
14929 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
14930 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
14931 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
14932 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
14933 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
14934 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
14935 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
14936 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
14938 /* "neighbor override-capability" commands. */
14939 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
14940 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
14942 /* "neighbor strict-capability-match" commands. */
14943 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
14944 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
14946 /* "neighbor timers" commands. */
14947 install_element(BGP_NODE
, &neighbor_timers_cmd
);
14948 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
14950 /* "neighbor timers connect" commands. */
14951 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
14952 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
14954 /* "neighbor advertisement-interval" commands. */
14955 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
14956 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
14958 /* "neighbor interface" commands. */
14959 install_element(BGP_NODE
, &neighbor_interface_cmd
);
14960 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
14962 /* "neighbor distribute" commands. */
14963 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
14964 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
14965 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
14966 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
14967 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
14968 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
14969 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
14970 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
14971 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
14972 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
14973 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
14974 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
14975 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
14976 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
14977 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
14978 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
14979 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
14980 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
14982 /* "neighbor prefix-list" commands. */
14983 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
14984 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
14985 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
14986 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
14987 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
14988 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
14989 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
14990 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
14991 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
14992 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
14993 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
14994 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
14995 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
14996 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
14997 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
14998 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
14999 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
15000 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
15001 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
15002 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
15003 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
15004 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
15006 /* "neighbor filter-list" commands. */
15007 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
15008 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
15009 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
15010 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
15011 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
15012 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
15013 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
15014 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
15015 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
15016 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
15017 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
15018 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
15019 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
15020 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
15021 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
15022 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
15023 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
15024 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
15025 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
15026 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
15027 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
15028 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
15030 /* "neighbor route-map" commands. */
15031 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
15032 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
15033 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
15034 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
15035 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
15036 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
15037 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
15038 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
15039 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
15040 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
15041 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
15042 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
15043 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
15044 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
15045 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
15046 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
15047 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
15048 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
15049 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
15050 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
15051 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
15052 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
15053 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
15054 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
15056 /* "neighbor unsuppress-map" commands. */
15057 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
15058 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
15059 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
15060 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
15061 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
15062 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
15063 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
15064 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
15065 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
15066 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
15067 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
15068 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
15069 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
15070 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
15071 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
15072 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
15073 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
15074 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
15076 /* "neighbor maximum-prefix" commands. */
15077 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
15078 install_element(BGP_NODE
,
15079 &neighbor_maximum_prefix_threshold_hidden_cmd
);
15080 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
15081 install_element(BGP_NODE
,
15082 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
15083 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
15084 install_element(BGP_NODE
,
15085 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
15086 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
15087 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
15088 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
15089 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
15090 install_element(BGP_IPV4_NODE
,
15091 &neighbor_maximum_prefix_threshold_warning_cmd
);
15092 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
15093 install_element(BGP_IPV4_NODE
,
15094 &neighbor_maximum_prefix_threshold_restart_cmd
);
15095 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
15096 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
15097 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
15098 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
15099 install_element(BGP_IPV4M_NODE
,
15100 &neighbor_maximum_prefix_threshold_warning_cmd
);
15101 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
15102 install_element(BGP_IPV4M_NODE
,
15103 &neighbor_maximum_prefix_threshold_restart_cmd
);
15104 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
15105 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
15106 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
15107 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
15108 install_element(BGP_IPV4L_NODE
,
15109 &neighbor_maximum_prefix_threshold_warning_cmd
);
15110 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
15111 install_element(BGP_IPV4L_NODE
,
15112 &neighbor_maximum_prefix_threshold_restart_cmd
);
15113 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
15114 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
15115 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
15116 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
15117 install_element(BGP_IPV6_NODE
,
15118 &neighbor_maximum_prefix_threshold_warning_cmd
);
15119 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
15120 install_element(BGP_IPV6_NODE
,
15121 &neighbor_maximum_prefix_threshold_restart_cmd
);
15122 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
15123 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
15124 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
15125 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
15126 install_element(BGP_IPV6M_NODE
,
15127 &neighbor_maximum_prefix_threshold_warning_cmd
);
15128 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
15129 install_element(BGP_IPV6M_NODE
,
15130 &neighbor_maximum_prefix_threshold_restart_cmd
);
15131 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
15132 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
15133 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
15134 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
15135 install_element(BGP_IPV6L_NODE
,
15136 &neighbor_maximum_prefix_threshold_warning_cmd
);
15137 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
15138 install_element(BGP_IPV6L_NODE
,
15139 &neighbor_maximum_prefix_threshold_restart_cmd
);
15140 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
15141 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
15142 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
15143 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
15144 install_element(BGP_VPNV4_NODE
,
15145 &neighbor_maximum_prefix_threshold_warning_cmd
);
15146 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
15147 install_element(BGP_VPNV4_NODE
,
15148 &neighbor_maximum_prefix_threshold_restart_cmd
);
15149 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
15150 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
15151 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
15152 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
15153 install_element(BGP_VPNV6_NODE
,
15154 &neighbor_maximum_prefix_threshold_warning_cmd
);
15155 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
15156 install_element(BGP_VPNV6_NODE
,
15157 &neighbor_maximum_prefix_threshold_restart_cmd
);
15158 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
15160 /* "neighbor allowas-in" */
15161 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
15162 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
15163 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
15164 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
15165 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
15166 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
15167 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
15168 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
15169 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
15170 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
15171 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
15172 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
15173 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
15174 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
15175 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
15176 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
15177 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
15178 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
15179 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
15180 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
15182 /* address-family commands. */
15183 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
15184 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
15185 #ifdef KEEP_OLD_VPN_COMMANDS
15186 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
15187 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
15188 #endif /* KEEP_OLD_VPN_COMMANDS */
15190 install_element(BGP_NODE
, &address_family_evpn_cmd
);
15192 /* "exit-address-family" command. */
15193 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
15194 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
15195 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
15196 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
15197 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
15198 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
15199 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
15200 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
15201 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
15202 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
15203 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
15205 /* "clear ip bgp commands" */
15206 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
15208 /* clear ip bgp prefix */
15209 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
15210 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
15211 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
15213 /* "show [ip] bgp summary" commands. */
15214 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
15215 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
15216 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
15217 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
15218 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
15219 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
15220 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
15222 /* "show [ip] bgp neighbors" commands. */
15223 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
15225 /* "show [ip] bgp peer-group" commands. */
15226 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
15228 /* "show [ip] bgp paths" commands. */
15229 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
15231 /* "show [ip] bgp community" commands. */
15232 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
15234 /* "show ip bgp large-community" commands. */
15235 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
15236 /* "show [ip] bgp attribute-info" commands. */
15237 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
15238 /* "show [ip] bgp route-leak" command */
15239 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
15241 /* "redistribute" commands. */
15242 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
15243 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
15244 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
15245 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
15246 install_element(BGP_NODE
,
15247 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
15248 install_element(BGP_NODE
,
15249 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
15250 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
15251 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
15252 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
15253 install_element(BGP_NODE
,
15254 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
15255 install_element(BGP_NODE
,
15256 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
15257 install_element(BGP_NODE
,
15258 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
15259 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
15260 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
15261 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
15262 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
15263 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
15264 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
15265 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
15266 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
15267 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
15268 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
15269 install_element(BGP_IPV4_NODE
,
15270 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
15271 install_element(BGP_IPV4_NODE
,
15272 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
15273 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
15274 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
15275 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
15276 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
15277 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
15278 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
15280 /* import|export vpn [route-map WORD] */
15281 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
15282 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
15284 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
15285 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
15287 /* ttl_security commands */
15288 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
15289 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
15291 /* "show [ip] bgp memory" commands. */
15292 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
15294 /* "show bgp martian next-hop" */
15295 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
15297 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
15299 /* "show [ip] bgp views" commands. */
15300 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
15302 /* "show [ip] bgp vrfs" commands. */
15303 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
15305 /* Community-list. */
15306 community_list_vty();
15308 /* vpn-policy commands */
15309 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
15310 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
15311 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
15312 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
15313 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
15314 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
15315 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
15316 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
15317 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
15318 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
15319 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
15320 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
15322 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
15323 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
15325 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
15326 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
15327 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
15328 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
15329 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
15330 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
15331 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
15332 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
15333 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
15334 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
15335 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
15336 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
15339 #include "memory.h"
15340 #include "bgp_regex.h"
15341 #include "bgp_clist.h"
15342 #include "bgp_ecommunity.h"
15344 /* VTY functions. */
15346 /* Direction value to string conversion. */
15347 static const char *community_direct_str(int direct
)
15350 case COMMUNITY_DENY
:
15352 case COMMUNITY_PERMIT
:
15359 /* Display error string. */
15360 static void community_list_perror(struct vty
*vty
, int ret
)
15363 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
15364 vty_out(vty
, "%% Can't find community-list\n");
15366 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
15367 vty_out(vty
, "%% Malformed community-list value\n");
15369 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
15371 "%% Community name conflict, previously defined as standard community\n");
15373 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
15375 "%% Community name conflict, previously defined as expanded community\n");
15380 /* "community-list" keyword help string. */
15381 #define COMMUNITY_LIST_STR "Add a community list entry\n"
15383 /*community-list standard */
15384 DEFUN (community_list_standard
,
15385 bgp_community_list_standard_cmd
,
15386 "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15389 "Community list number (standard)\n"
15390 "Add an standard community-list entry\n"
15391 "Community list name\n"
15392 "Specify community to reject\n"
15393 "Specify community to accept\n"
15396 char *cl_name_or_number
= NULL
;
15398 int style
= COMMUNITY_LIST_STANDARD
;
15401 argv_find(argv
, argc
, "(1-99)", &idx
);
15402 argv_find(argv
, argc
, "WORD", &idx
);
15403 cl_name_or_number
= argv
[idx
]->arg
;
15404 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15406 argv_find(argv
, argc
, "AA:NN", &idx
);
15407 char *str
= argv_concat(argv
, argc
, idx
);
15409 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
15412 XFREE(MTYPE_TMP
, str
);
15415 /* Display error string. */
15416 community_list_perror(vty
, ret
);
15417 return CMD_WARNING_CONFIG_FAILED
;
15420 return CMD_SUCCESS
;
15423 DEFUN (no_community_list_standard_all
,
15424 no_bgp_community_list_standard_all_cmd
,
15425 "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15429 "Community list number (standard)\n"
15430 "Add an standard community-list entry\n"
15431 "Community list name\n"
15432 "Specify community to reject\n"
15433 "Specify community to accept\n"
15436 char *cl_name_or_number
= NULL
;
15439 int style
= COMMUNITY_LIST_STANDARD
;
15443 argv_find(argv
, argc
, "permit", &idx
);
15444 argv_find(argv
, argc
, "deny", &idx
);
15447 direct
= argv_find(argv
, argc
, "permit", &idx
)
15452 argv_find(argv
, argc
, "AA:NN", &idx
);
15453 str
= argv_concat(argv
, argc
, idx
);
15457 argv_find(argv
, argc
, "(1-99)", &idx
);
15458 argv_find(argv
, argc
, "WORD", &idx
);
15459 cl_name_or_number
= argv
[idx
]->arg
;
15461 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
15464 XFREE(MTYPE_TMP
, str
);
15467 community_list_perror(vty
, ret
);
15468 return CMD_WARNING_CONFIG_FAILED
;
15471 return CMD_SUCCESS
;
15474 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
15475 "no bgp community-list <(1-99)|standard WORD>",
15476 NO_STR BGP_STR COMMUNITY_LIST_STR
15477 "Community list number (standard)\n"
15478 "Add an standard community-list entry\n"
15479 "Community list name\n")
15481 /*community-list expanded */
15482 DEFUN (community_list_expanded_all
,
15483 bgp_community_list_expanded_all_cmd
,
15484 "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
15487 "Community list number (expanded)\n"
15488 "Add an expanded community-list entry\n"
15489 "Community list name\n"
15490 "Specify community to reject\n"
15491 "Specify community to accept\n"
15494 char *cl_name_or_number
= NULL
;
15496 int style
= COMMUNITY_LIST_EXPANDED
;
15500 argv_find(argv
, argc
, "(100-500)", &idx
);
15501 argv_find(argv
, argc
, "WORD", &idx
);
15502 cl_name_or_number
= argv
[idx
]->arg
;
15503 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15505 argv_find(argv
, argc
, "AA:NN", &idx
);
15506 char *str
= argv_concat(argv
, argc
, idx
);
15508 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
15511 XFREE(MTYPE_TMP
, str
);
15514 /* Display error string. */
15515 community_list_perror(vty
, ret
);
15516 return CMD_WARNING_CONFIG_FAILED
;
15519 return CMD_SUCCESS
;
15522 DEFUN (no_community_list_expanded_all
,
15523 no_bgp_community_list_expanded_all_cmd
,
15524 "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
15528 "Community list number (expanded)\n"
15529 "Add an expanded community-list entry\n"
15530 "Community list name\n"
15531 "Specify community to reject\n"
15532 "Specify community to accept\n"
15535 char *cl_name_or_number
= NULL
;
15538 int style
= COMMUNITY_LIST_EXPANDED
;
15542 argv_find(argv
, argc
, "permit", &idx
);
15543 argv_find(argv
, argc
, "deny", &idx
);
15546 direct
= argv_find(argv
, argc
, "permit", &idx
)
15551 argv_find(argv
, argc
, "AA:NN", &idx
);
15552 str
= argv_concat(argv
, argc
, idx
);
15556 argv_find(argv
, argc
, "(100-500)", &idx
);
15557 argv_find(argv
, argc
, "WORD", &idx
);
15558 cl_name_or_number
= argv
[idx
]->arg
;
15560 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
15563 XFREE(MTYPE_TMP
, str
);
15566 community_list_perror(vty
, ret
);
15567 return CMD_WARNING_CONFIG_FAILED
;
15570 return CMD_SUCCESS
;
15573 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
15574 "no bgp community-list <(100-500)|expanded WORD>",
15575 NO_STR IP_STR COMMUNITY_LIST_STR
15576 "Community list number (expanded)\n"
15577 "Add an expanded community-list entry\n"
15578 "Community list name\n")
15580 /* Return configuration string of community-list entry. */
15581 static const char *community_list_config_str(struct community_entry
*entry
)
15588 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
15589 str
= community_str(entry
->u
.com
, false);
15590 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
15591 str
= lcommunity_str(entry
->u
.lcom
, false);
15593 str
= entry
->config
;
15598 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
15600 struct community_entry
*entry
;
15602 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15603 if (entry
== list
->head
) {
15604 if (all_digit(list
->name
))
15605 vty_out(vty
, "Community %s list %s\n",
15606 entry
->style
== COMMUNITY_LIST_STANDARD
15608 : "(expanded) access",
15611 vty_out(vty
, "Named Community %s list %s\n",
15612 entry
->style
== COMMUNITY_LIST_STANDARD
15618 vty_out(vty
, " %s\n",
15619 community_direct_str(entry
->direct
));
15621 vty_out(vty
, " %s %s\n",
15622 community_direct_str(entry
->direct
),
15623 community_list_config_str(entry
));
15627 DEFUN (show_community_list
,
15628 show_bgp_community_list_cmd
,
15629 "show bgp community-list",
15632 "List community-list\n")
15634 struct community_list
*list
;
15635 struct community_list_master
*cm
;
15637 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
15639 return CMD_SUCCESS
;
15641 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15642 community_list_show(vty
, list
);
15644 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15645 community_list_show(vty
, list
);
15647 return CMD_SUCCESS
;
15650 DEFUN (show_community_list_arg
,
15651 show_bgp_community_list_arg_cmd
,
15652 "show bgp community-list <(1-500)|WORD> detail",
15655 "List community-list\n"
15656 "Community-list number\n"
15657 "Community-list name\n"
15658 "Detailed information on community-list\n")
15660 int idx_comm_list
= 3;
15661 struct community_list
*list
;
15663 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
15664 COMMUNITY_LIST_MASTER
);
15666 vty_out(vty
, "%% Can't find community-list\n");
15667 return CMD_WARNING
;
15670 community_list_show(vty
, list
);
15672 return CMD_SUCCESS
;
15676 * Large Community code.
15678 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
15679 struct cmd_token
**argv
, int style
,
15680 int reject_all_digit_name
)
15688 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15691 /* All digit name check. */
15693 argv_find(argv
, argc
, "WORD", &idx
);
15694 argv_find(argv
, argc
, "(1-99)", &idx
);
15695 argv_find(argv
, argc
, "(100-500)", &idx
);
15696 cl_name
= argv
[idx
]->arg
;
15697 if (reject_all_digit_name
&& all_digit(cl_name
)) {
15698 vty_out(vty
, "%% Community name cannot have all digits\n");
15699 return CMD_WARNING_CONFIG_FAILED
;
15703 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
15704 argv_find(argv
, argc
, "LINE", &idx
);
15705 /* Concat community string argument. */
15707 str
= argv_concat(argv
, argc
, idx
);
15711 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
15713 /* Free temporary community list string allocated by
15715 XFREE(MTYPE_TMP
, str
);
15718 community_list_perror(vty
, ret
);
15719 return CMD_WARNING_CONFIG_FAILED
;
15721 return CMD_SUCCESS
;
15724 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
15725 struct cmd_token
**argv
, int style
)
15732 argv_find(argv
, argc
, "permit", &idx
);
15733 argv_find(argv
, argc
, "deny", &idx
);
15736 /* Check the list direct. */
15737 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
15738 direct
= COMMUNITY_PERMIT
;
15740 direct
= COMMUNITY_DENY
;
15743 argv_find(argv
, argc
, "LINE", &idx
);
15744 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
15745 /* Concat community string argument. */
15746 str
= argv_concat(argv
, argc
, idx
);
15750 argv_find(argv
, argc
, "(1-99)", &idx
);
15751 argv_find(argv
, argc
, "(100-500)", &idx
);
15752 argv_find(argv
, argc
, "WORD", &idx
);
15754 /* Unset community list. */
15755 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
15758 /* Free temporary community list string allocated by
15760 XFREE(MTYPE_TMP
, str
);
15763 community_list_perror(vty
, ret
);
15764 return CMD_WARNING_CONFIG_FAILED
;
15767 return CMD_SUCCESS
;
15770 /* "large-community-list" keyword help string. */
15771 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
15772 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
15774 DEFUN (lcommunity_list_standard
,
15775 bgp_lcommunity_list_standard_cmd
,
15776 "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...",
15778 LCOMMUNITY_LIST_STR
15779 "Large Community list number (standard)\n"
15780 "Specify large community to reject\n"
15781 "Specify large community to accept\n"
15782 LCOMMUNITY_VAL_STR
)
15784 return lcommunity_list_set_vty(vty
, argc
, argv
,
15785 LARGE_COMMUNITY_LIST_STANDARD
, 0);
15788 DEFUN (lcommunity_list_expanded
,
15789 bgp_lcommunity_list_expanded_cmd
,
15790 "bgp large-community-list (100-500) <deny|permit> LINE...",
15792 LCOMMUNITY_LIST_STR
15793 "Large Community list number (expanded)\n"
15794 "Specify large community to reject\n"
15795 "Specify large community to accept\n"
15796 "An ordered list as a regular-expression\n")
15798 return lcommunity_list_set_vty(vty
, argc
, argv
,
15799 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
15802 DEFUN (lcommunity_list_name_standard
,
15803 bgp_lcommunity_list_name_standard_cmd
,
15804 "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
15806 LCOMMUNITY_LIST_STR
15807 "Specify standard large-community-list\n"
15808 "Large Community list name\n"
15809 "Specify large community to reject\n"
15810 "Specify large community to accept\n"
15811 LCOMMUNITY_VAL_STR
)
15813 return lcommunity_list_set_vty(vty
, argc
, argv
,
15814 LARGE_COMMUNITY_LIST_STANDARD
, 1);
15817 DEFUN (lcommunity_list_name_expanded
,
15818 bgp_lcommunity_list_name_expanded_cmd
,
15819 "bgp large-community-list expanded WORD <deny|permit> LINE...",
15821 LCOMMUNITY_LIST_STR
15822 "Specify expanded large-community-list\n"
15823 "Large Community list name\n"
15824 "Specify large community to reject\n"
15825 "Specify large community to accept\n"
15826 "An ordered list as a regular-expression\n")
15828 return lcommunity_list_set_vty(vty
, argc
, argv
,
15829 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
15832 DEFUN (no_lcommunity_list_standard_all
,
15833 no_bgp_lcommunity_list_standard_all_cmd
,
15834 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
15837 LCOMMUNITY_LIST_STR
15838 "Large Community list number (standard)\n"
15839 "Large Community list number (expanded)\n"
15840 "Large Community list name\n")
15842 return lcommunity_list_unset_vty(vty
, argc
, argv
,
15843 LARGE_COMMUNITY_LIST_STANDARD
);
15846 DEFUN (no_lcommunity_list_name_expanded_all
,
15847 no_bgp_lcommunity_list_name_expanded_all_cmd
,
15848 "no bgp large-community-list expanded WORD",
15851 LCOMMUNITY_LIST_STR
15852 "Specify expanded large-community-list\n"
15853 "Large Community list name\n")
15855 return lcommunity_list_unset_vty(vty
, argc
, argv
,
15856 LARGE_COMMUNITY_LIST_EXPANDED
);
15859 DEFUN (no_lcommunity_list_standard
,
15860 no_bgp_lcommunity_list_standard_cmd
,
15861 "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
15864 LCOMMUNITY_LIST_STR
15865 "Large Community list number (standard)\n"
15866 "Specify large community to reject\n"
15867 "Specify large community to accept\n"
15868 LCOMMUNITY_VAL_STR
)
15870 return lcommunity_list_unset_vty(vty
, argc
, argv
,
15871 LARGE_COMMUNITY_LIST_STANDARD
);
15874 DEFUN (no_lcommunity_list_expanded
,
15875 no_bgp_lcommunity_list_expanded_cmd
,
15876 "no bgp large-community-list (100-500) <deny|permit> LINE...",
15879 LCOMMUNITY_LIST_STR
15880 "Large Community list number (expanded)\n"
15881 "Specify large community to reject\n"
15882 "Specify large community to accept\n"
15883 "An ordered list as a regular-expression\n")
15885 return lcommunity_list_unset_vty(vty
, argc
, argv
,
15886 LARGE_COMMUNITY_LIST_EXPANDED
);
15889 DEFUN (no_lcommunity_list_name_standard
,
15890 no_bgp_lcommunity_list_name_standard_cmd
,
15891 "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
15894 LCOMMUNITY_LIST_STR
15895 "Specify standard large-community-list\n"
15896 "Large Community list name\n"
15897 "Specify large community to reject\n"
15898 "Specify large community to accept\n"
15899 LCOMMUNITY_VAL_STR
)
15901 return lcommunity_list_unset_vty(vty
, argc
, argv
,
15902 LARGE_COMMUNITY_LIST_STANDARD
);
15905 DEFUN (no_lcommunity_list_name_expanded
,
15906 no_bgp_lcommunity_list_name_expanded_cmd
,
15907 "no bgp large-community-list expanded WORD <deny|permit> LINE...",
15910 LCOMMUNITY_LIST_STR
15911 "Specify expanded large-community-list\n"
15912 "Large community list name\n"
15913 "Specify large community to reject\n"
15914 "Specify large community to accept\n"
15915 "An ordered list as a regular-expression\n")
15917 return lcommunity_list_unset_vty(vty
, argc
, argv
,
15918 LARGE_COMMUNITY_LIST_EXPANDED
);
15921 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
15923 struct community_entry
*entry
;
15925 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15926 if (entry
== list
->head
) {
15927 if (all_digit(list
->name
))
15928 vty_out(vty
, "Large community %s list %s\n",
15930 LARGE_COMMUNITY_LIST_STANDARD
15932 : "(expanded) access",
15936 "Named large community %s list %s\n",
15938 LARGE_COMMUNITY_LIST_STANDARD
15944 vty_out(vty
, " %s\n",
15945 community_direct_str(entry
->direct
));
15947 vty_out(vty
, " %s %s\n",
15948 community_direct_str(entry
->direct
),
15949 community_list_config_str(entry
));
15953 DEFUN (show_lcommunity_list
,
15954 show_bgp_lcommunity_list_cmd
,
15955 "show bgp large-community-list",
15958 "List large-community list\n")
15960 struct community_list
*list
;
15961 struct community_list_master
*cm
;
15963 cm
= community_list_master_lookup(bgp_clist
,
15964 LARGE_COMMUNITY_LIST_MASTER
);
15966 return CMD_SUCCESS
;
15968 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15969 lcommunity_list_show(vty
, list
);
15971 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15972 lcommunity_list_show(vty
, list
);
15974 return CMD_SUCCESS
;
15977 DEFUN (show_lcommunity_list_arg
,
15978 show_bgp_lcommunity_list_arg_cmd
,
15979 "show bgp large-community-list <(1-500)|WORD> detail",
15982 "List large-community list\n"
15983 "Large-community-list number\n"
15984 "Large-community-list name\n"
15985 "Detailed information on large-community-list\n")
15987 struct community_list
*list
;
15989 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
15990 LARGE_COMMUNITY_LIST_MASTER
);
15992 vty_out(vty
, "%% Can't find large-community-list\n");
15993 return CMD_WARNING
;
15996 lcommunity_list_show(vty
, list
);
15998 return CMD_SUCCESS
;
16001 /* "extcommunity-list" keyword help string. */
16002 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
16003 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
16005 DEFUN (extcommunity_list_standard
,
16006 bgp_extcommunity_list_standard_cmd
,
16007 "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
16009 EXTCOMMUNITY_LIST_STR
16010 "Extended Community list number (standard)\n"
16011 "Specify standard extcommunity-list\n"
16012 "Community list name\n"
16013 "Specify community to reject\n"
16014 "Specify community to accept\n"
16015 EXTCOMMUNITY_VAL_STR
)
16017 int style
= EXTCOMMUNITY_LIST_STANDARD
;
16019 char *cl_number_or_name
= NULL
;
16023 argv_find(argv
, argc
, "(1-99)", &idx
);
16024 argv_find(argv
, argc
, "WORD", &idx
);
16025 cl_number_or_name
= argv
[idx
]->arg
;
16026 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
16028 argv_find(argv
, argc
, "AA:NN", &idx
);
16029 char *str
= argv_concat(argv
, argc
, idx
);
16031 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
16034 XFREE(MTYPE_TMP
, str
);
16037 community_list_perror(vty
, ret
);
16038 return CMD_WARNING_CONFIG_FAILED
;
16041 return CMD_SUCCESS
;
16044 DEFUN (extcommunity_list_name_expanded
,
16045 bgp_extcommunity_list_name_expanded_cmd
,
16046 "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
16048 EXTCOMMUNITY_LIST_STR
16049 "Extended Community list number (expanded)\n"
16050 "Specify expanded extcommunity-list\n"
16051 "Extended Community list name\n"
16052 "Specify community to reject\n"
16053 "Specify community to accept\n"
16054 "An ordered list as a regular-expression\n")
16056 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
16058 char *cl_number_or_name
= NULL
;
16061 argv_find(argv
, argc
, "(100-500)", &idx
);
16062 argv_find(argv
, argc
, "WORD", &idx
);
16063 cl_number_or_name
= argv
[idx
]->arg
;
16064 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
16066 argv_find(argv
, argc
, "LINE", &idx
);
16067 char *str
= argv_concat(argv
, argc
, idx
);
16069 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
16072 XFREE(MTYPE_TMP
, str
);
16075 community_list_perror(vty
, ret
);
16076 return CMD_WARNING_CONFIG_FAILED
;
16079 return CMD_SUCCESS
;
16082 DEFUN (no_extcommunity_list_standard_all
,
16083 no_bgp_extcommunity_list_standard_all_cmd
,
16084 "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
16087 EXTCOMMUNITY_LIST_STR
16088 "Extended Community list number (standard)\n"
16089 "Specify standard extcommunity-list\n"
16090 "Community list name\n"
16091 "Specify community to reject\n"
16092 "Specify community to accept\n"
16093 EXTCOMMUNITY_VAL_STR
)
16095 int style
= EXTCOMMUNITY_LIST_STANDARD
;
16097 char *cl_number_or_name
= NULL
;
16101 argv_find(argv
, argc
, "permit", &idx
);
16102 argv_find(argv
, argc
, "deny", &idx
);
16105 direct
= argv_find(argv
, argc
, "permit", &idx
)
16110 argv_find(argv
, argc
, "AA:NN", &idx
);
16111 str
= argv_concat(argv
, argc
, idx
);
16115 argv_find(argv
, argc
, "(1-99)", &idx
);
16116 argv_find(argv
, argc
, "WORD", &idx
);
16117 cl_number_or_name
= argv
[idx
]->arg
;
16119 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
16122 XFREE(MTYPE_TMP
, str
);
16125 community_list_perror(vty
, ret
);
16126 return CMD_WARNING_CONFIG_FAILED
;
16129 return CMD_SUCCESS
;
16132 ALIAS(no_extcommunity_list_standard_all
,
16133 no_bgp_extcommunity_list_standard_all_list_cmd
,
16134 "no bgp extcommunity-list <(1-99)|standard WORD>",
16135 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
16136 "Extended Community list number (standard)\n"
16137 "Specify standard extcommunity-list\n"
16138 "Community list name\n")
16140 DEFUN (no_extcommunity_list_expanded_all
,
16141 no_bgp_extcommunity_list_expanded_all_cmd
,
16142 "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
16145 EXTCOMMUNITY_LIST_STR
16146 "Extended Community list number (expanded)\n"
16147 "Specify expanded extcommunity-list\n"
16148 "Extended Community list name\n"
16149 "Specify community to reject\n"
16150 "Specify community to accept\n"
16151 "An ordered list as a regular-expression\n")
16153 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
16155 char *cl_number_or_name
= NULL
;
16159 argv_find(argv
, argc
, "permit", &idx
);
16160 argv_find(argv
, argc
, "deny", &idx
);
16163 direct
= argv_find(argv
, argc
, "permit", &idx
)
16168 argv_find(argv
, argc
, "LINE", &idx
);
16169 str
= argv_concat(argv
, argc
, idx
);
16173 argv_find(argv
, argc
, "(100-500)", &idx
);
16174 argv_find(argv
, argc
, "WORD", &idx
);
16175 cl_number_or_name
= argv
[idx
]->arg
;
16177 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
16180 XFREE(MTYPE_TMP
, str
);
16183 community_list_perror(vty
, ret
);
16184 return CMD_WARNING_CONFIG_FAILED
;
16187 return CMD_SUCCESS
;
16190 ALIAS(no_extcommunity_list_expanded_all
,
16191 no_bgp_extcommunity_list_expanded_all_list_cmd
,
16192 "no bgp extcommunity-list <(100-500)|expanded WORD>",
16193 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
16194 "Extended Community list number (expanded)\n"
16195 "Specify expanded extcommunity-list\n"
16196 "Extended Community list name\n")
16198 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
16200 struct community_entry
*entry
;
16202 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
16203 if (entry
== list
->head
) {
16204 if (all_digit(list
->name
))
16205 vty_out(vty
, "Extended community %s list %s\n",
16206 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
16208 : "(expanded) access",
16212 "Named extended community %s list %s\n",
16213 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
16219 vty_out(vty
, " %s\n",
16220 community_direct_str(entry
->direct
));
16222 vty_out(vty
, " %s %s\n",
16223 community_direct_str(entry
->direct
),
16224 community_list_config_str(entry
));
16228 DEFUN (show_extcommunity_list
,
16229 show_bgp_extcommunity_list_cmd
,
16230 "show bgp extcommunity-list",
16233 "List extended-community list\n")
16235 struct community_list
*list
;
16236 struct community_list_master
*cm
;
16238 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
16240 return CMD_SUCCESS
;
16242 for (list
= cm
->num
.head
; list
; list
= list
->next
)
16243 extcommunity_list_show(vty
, list
);
16245 for (list
= cm
->str
.head
; list
; list
= list
->next
)
16246 extcommunity_list_show(vty
, list
);
16248 return CMD_SUCCESS
;
16251 DEFUN (show_extcommunity_list_arg
,
16252 show_bgp_extcommunity_list_arg_cmd
,
16253 "show bgp extcommunity-list <(1-500)|WORD> detail",
16256 "List extended-community list\n"
16257 "Extcommunity-list number\n"
16258 "Extcommunity-list name\n"
16259 "Detailed information on extcommunity-list\n")
16261 int idx_comm_list
= 3;
16262 struct community_list
*list
;
16264 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
16265 EXTCOMMUNITY_LIST_MASTER
);
16267 vty_out(vty
, "%% Can't find extcommunity-list\n");
16268 return CMD_WARNING
;
16271 extcommunity_list_show(vty
, list
);
16273 return CMD_SUCCESS
;
16276 /* Display community-list and extcommunity-list configuration. */
16277 static int community_list_config_write(struct vty
*vty
)
16279 struct community_list
*list
;
16280 struct community_entry
*entry
;
16281 struct community_list_master
*cm
;
16284 /* Community-list. */
16285 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
16287 for (list
= cm
->num
.head
; list
; list
= list
->next
)
16288 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
16289 vty_out(vty
, "bgp community-list %s %s %s\n", list
->name
,
16290 community_direct_str(entry
->direct
),
16291 community_list_config_str(entry
));
16294 for (list
= cm
->str
.head
; list
; list
= list
->next
)
16295 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
16296 vty_out(vty
, "bgp community-list %s %s %s %s\n",
16297 entry
->style
== COMMUNITY_LIST_STANDARD
16300 list
->name
, community_direct_str(entry
->direct
),
16301 community_list_config_str(entry
));
16305 /* Extcommunity-list. */
16306 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
16308 for (list
= cm
->num
.head
; list
; list
= list
->next
)
16309 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
16310 vty_out(vty
, "bgp extcommunity-list %s %s %s\n",
16311 list
->name
, community_direct_str(entry
->direct
),
16312 community_list_config_str(entry
));
16315 for (list
= cm
->str
.head
; list
; list
= list
->next
)
16316 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
16317 vty_out(vty
, "bgp extcommunity-list %s %s %s %s\n",
16318 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
16321 list
->name
, community_direct_str(entry
->direct
),
16322 community_list_config_str(entry
));
16327 /* lcommunity-list. */
16328 cm
= community_list_master_lookup(bgp_clist
,
16329 LARGE_COMMUNITY_LIST_MASTER
);
16331 for (list
= cm
->num
.head
; list
; list
= list
->next
)
16332 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
16333 vty_out(vty
, "bgp large-community-list %s %s %s\n",
16334 list
->name
, community_direct_str(entry
->direct
),
16335 community_list_config_str(entry
));
16338 for (list
= cm
->str
.head
; list
; list
= list
->next
)
16339 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
16340 vty_out(vty
, "bgp large-community-list %s %s %s %s\n",
16341 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
16344 list
->name
, community_direct_str(entry
->direct
),
16345 community_list_config_str(entry
));
16352 static struct cmd_node community_list_node
= {
16353 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
16356 static void community_list_vty(void)
16358 install_node(&community_list_node
, community_list_config_write
);
16360 /* Community-list. */
16361 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
16362 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
16363 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
16364 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
16365 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
16366 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
16367 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
16368 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
16370 /* Extcommunity-list. */
16371 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
16372 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
16373 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
16374 install_element(CONFIG_NODE
,
16375 &no_bgp_extcommunity_list_standard_all_list_cmd
);
16376 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
16377 install_element(CONFIG_NODE
,
16378 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
16379 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
16380 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
16382 /* Large Community List */
16383 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
16384 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
16385 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
16386 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
16387 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_all_cmd
);
16388 install_element(CONFIG_NODE
,
16389 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
16390 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
16391 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
16392 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
16393 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
16394 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
16395 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);