2 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "lib_errors.h"
26 #include "lib/zclient.h"
41 #include "bgpd/bgpd.h"
42 #include "bgpd/bgp_attr_evpn.h"
43 #include "bgpd/bgp_advertise.h"
44 #include "bgpd/bgp_attr.h"
45 #include "bgpd/bgp_aspath.h"
46 #include "bgpd/bgp_community.h"
47 #include "bgpd/bgp_ecommunity.h"
48 #include "bgpd/bgp_lcommunity.h"
49 #include "bgpd/bgp_damp.h"
50 #include "bgpd/bgp_debug.h"
51 #include "bgpd/bgp_errors.h"
52 #include "bgpd/bgp_fsm.h"
53 #include "bgpd/bgp_nexthop.h"
54 #include "bgpd/bgp_open.h"
55 #include "bgpd/bgp_regex.h"
56 #include "bgpd/bgp_route.h"
57 #include "bgpd/bgp_mplsvpn.h"
58 #include "bgpd/bgp_zebra.h"
59 #include "bgpd/bgp_table.h"
60 #include "bgpd/bgp_vty.h"
61 #include "bgpd/bgp_mpath.h"
62 #include "bgpd/bgp_packet.h"
63 #include "bgpd/bgp_updgrp.h"
64 #include "bgpd/bgp_bfd.h"
65 #include "bgpd/bgp_io.h"
66 #include "bgpd/bgp_evpn.h"
67 #include "bgpd/bgp_evpn_vty.h"
68 #include "bgpd/bgp_addpath.h"
69 #include "bgpd/bgp_mac.h"
70 #include "bgpd/bgp_flowspec.h"
72 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
75 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
76 { .val_long
= true, .match_profile
= "datacenter", },
77 { .val_long
= false },
79 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
80 { .val_long
= true, .match_profile
= "datacenter", },
81 { .val_long
= false },
83 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
84 { .val_long
= true, .match_profile
= "datacenter", },
85 { .val_long
= false },
87 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
88 { .val_long
= true, .match_profile
= "datacenter", },
89 { .val_long
= false },
91 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
92 { .val_ulong
= 10, .match_profile
= "datacenter", },
95 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
96 { .val_ulong
= 9, .match_profile
= "datacenter", },
99 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
100 { .val_ulong
= 3, .match_profile
= "datacenter", },
104 DEFINE_HOOK(bgp_inst_config_write
,
105 (struct bgp
*bgp
, struct vty
*vty
),
109 "The Graceful Restart No Operation was executed as cmd same as previous one."
111 "The Graceful Restart command used is not valid at this moment."
112 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
113 struct prefix
*range
, int exact
);
115 /* Show BGP peer's information. */
125 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
126 struct prefix
*range
, int exact
);
128 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
133 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
136 afi_t afi
, bool use_json
);
138 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
144 return BGP_IPV4_NODE
;
147 return BGP_IPV4M_NODE
;
149 case SAFI_LABELED_UNICAST
:
150 return BGP_IPV4L_NODE
;
153 return BGP_VPNV4_NODE
;
156 return BGP_FLOWSPECV4_NODE
;
159 return BGP_IPV4_NODE
;
166 return BGP_IPV6_NODE
;
169 return BGP_IPV6M_NODE
;
171 case SAFI_LABELED_UNICAST
:
172 return BGP_IPV6L_NODE
;
175 return BGP_VPNV6_NODE
;
178 return BGP_FLOWSPECV6_NODE
;
181 return BGP_IPV4_NODE
;
186 return BGP_EVPN_NODE
;
190 // We should never be here but to clarify the switch statement..
191 return BGP_IPV4_NODE
;
195 // Impossible to happen
196 return BGP_IPV4_NODE
;
199 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
201 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
202 return "IPv4 Unicast";
203 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
204 return "IPv4 Multicast";
205 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
206 return "IPv4 Labeled Unicast";
207 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
209 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
211 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
212 return "IPv4 Flowspec";
213 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
214 return "IPv6 Unicast";
215 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
216 return "IPv6 Multicast";
217 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
218 return "IPv6 Labeled Unicast";
219 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
221 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
223 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
224 return "IPv6 Flowspec";
225 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
232 * Please note that we have intentionally camelCased
233 * the return strings here. So if you want
234 * to use this function, please ensure you
235 * are doing this within json output
237 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
239 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
240 return "ipv4Unicast";
241 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
242 return "ipv4Multicast";
243 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
244 return "ipv4LabeledUnicast";
245 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
247 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
249 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
250 return "ipv4Flowspec";
251 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
252 return "ipv6Unicast";
253 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
254 return "ipv6Multicast";
255 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
256 return "ipv6LabeledUnicast";
257 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
259 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
261 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
262 return "ipv6Flowspec";
263 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
269 /* Utility function to get address family from current node. */
270 afi_t
bgp_node_afi(struct vty
*vty
)
278 case BGP_FLOWSPECV6_NODE
:
291 /* Utility function to get subsequent address family from current
293 safi_t
bgp_node_safi(struct vty
*vty
)
299 safi
= SAFI_MPLS_VPN
;
303 safi
= SAFI_MULTICAST
;
310 safi
= SAFI_LABELED_UNICAST
;
312 case BGP_FLOWSPECV4_NODE
:
313 case BGP_FLOWSPECV6_NODE
:
314 safi
= SAFI_FLOWSPEC
;
324 * Converts an AFI in string form to afi_t
326 * @param afi string, one of
330 * @return the corresponding afi_t
332 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
334 afi_t afi
= AFI_MAX
; /* unknown */
335 if (strmatch(afi_str
, "ipv4"))
337 else if (strmatch(afi_str
, "ipv6"))
339 else if (strmatch(afi_str
, "l2vpn"))
344 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
348 if (argv_find(argv
, argc
, "ipv4", index
)) {
352 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
356 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
364 /* supports <unicast|multicast|vpn|labeled-unicast> */
365 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
367 safi_t safi
= SAFI_MAX
; /* unknown */
368 if (strmatch(safi_str
, "multicast"))
369 safi
= SAFI_MULTICAST
;
370 else if (strmatch(safi_str
, "unicast"))
372 else if (strmatch(safi_str
, "vpn"))
373 safi
= SAFI_MPLS_VPN
;
374 else if (strmatch(safi_str
, "evpn"))
376 else if (strmatch(safi_str
, "labeled-unicast"))
377 safi
= SAFI_LABELED_UNICAST
;
378 else if (strmatch(safi_str
, "flowspec"))
379 safi
= SAFI_FLOWSPEC
;
383 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
387 if (argv_find(argv
, argc
, "unicast", index
)) {
390 *safi
= SAFI_UNICAST
;
391 } else if (argv_find(argv
, argc
, "multicast", index
)) {
394 *safi
= SAFI_MULTICAST
;
395 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
398 *safi
= SAFI_LABELED_UNICAST
;
399 } else if (argv_find(argv
, argc
, "vpn", index
)) {
402 *safi
= SAFI_MPLS_VPN
;
403 } else if (argv_find(argv
, argc
, "evpn", index
)) {
407 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
410 *safi
= SAFI_FLOWSPEC
;
415 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
416 enum bgp_instance_type inst_type
)
418 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
420 if (ret
== BGP_CREATED
) {
421 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
422 DFLT_BGP_CONNECT_RETRY
);
424 if (DFLT_BGP_IMPORT_CHECK
)
425 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
426 if (DFLT_BGP_SHOW_HOSTNAME
)
427 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
428 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
429 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
430 if (DFLT_BGP_DETERMINISTIC_MED
)
431 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
439 * bgp_vty_find_and_parse_afi_safi_bgp
441 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
442 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
443 * to appropriate values for the calling function. This is to allow the
444 * calling function to make decisions appropriate for the show command
445 * that is being parsed.
447 * The show commands are generally of the form:
448 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
449 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
451 * Since we use argv_find if the show command in particular doesn't have:
453 * [<view|vrf> VIEWVRFNAME]
454 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
455 * The command parsing should still be ok.
457 * vty -> The vty for the command so we can output some useful data in
458 * the event of a parse error in the vrf.
459 * argv -> The command tokens
460 * argc -> How many command tokens we have
461 * idx -> The current place in the command, generally should be 0 for this
463 * afi -> The parsed afi if it was included in the show command, returned here
464 * safi -> The parsed safi if it was included in the show command, returned here
465 * bgp -> Pointer to the bgp data structure we need to fill in.
466 * use_json -> json is configured or not
468 * The function returns the correct location in the parse tree for the
471 * Returns 0 for failure to parse correctly, else the idx position of where
472 * it found the last token.
474 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
475 struct cmd_token
**argv
, int argc
,
476 int *idx
, afi_t
*afi
, safi_t
*safi
,
477 struct bgp
**bgp
, bool use_json
)
479 char *vrf_name
= NULL
;
485 if (argv_find(argv
, argc
, "ip", idx
))
488 if (argv_find(argv
, argc
, "view", idx
))
489 vrf_name
= argv
[*idx
+ 1]->arg
;
490 else if (argv_find(argv
, argc
, "vrf", idx
)) {
491 vrf_name
= argv
[*idx
+ 1]->arg
;
492 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
496 if (strmatch(vrf_name
, "all"))
499 *bgp
= bgp_lookup_by_name(vrf_name
);
502 json_object
*json
= NULL
;
503 json
= json_object_new_object();
504 json_object_string_add(
506 "View/Vrf is unknown");
508 json_object_to_json_string_ext(json
,
509 JSON_C_TO_STRING_PRETTY
));
510 json_object_free(json
);
513 vty_out(vty
, "View/Vrf %s is unknown\n",
520 *bgp
= bgp_get_default();
523 json_object
*json
= NULL
;
524 json
= json_object_new_object();
525 json_object_string_add(
527 "Default BGP instance not found");
529 json_object_to_json_string_ext(json
,
530 JSON_C_TO_STRING_PRETTY
));
531 json_object_free(json
);
535 "Default BGP instance not found\n");
541 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
542 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
548 static int peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
550 struct interface
*ifp
= NULL
;
552 if (su
->sa
.sa_family
== AF_INET
)
553 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
554 else if (su
->sa
.sa_family
== AF_INET6
)
555 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
556 su
->sin6
.sin6_scope_id
,
565 /* Utility function for looking up peer from VTY. */
566 /* This is used only for configuration, so disallow if attempted on
567 * a dynamic neighbor.
569 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
571 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
580 ret
= str2sockunion(ip_str
, &su
);
582 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
584 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
587 "%% Malformed address or name: %s\n",
593 peer
= peer_lookup(bgp
, &su
);
596 "%% Specify remote-as or peer-group commands first\n");
599 if (peer_dynamic_neighbor(peer
)) {
601 "%% Operation not allowed on a dynamic neighbor\n");
608 /* Utility function for looking up peer or peer group. */
609 /* This is used only for configuration, so disallow if attempted on
610 * a dynamic neighbor.
612 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
614 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
617 struct peer
*peer
= NULL
;
618 struct peer_group
*group
= NULL
;
624 ret
= str2sockunion(peer_str
, &su
);
626 /* IP address, locate peer. */
627 peer
= peer_lookup(bgp
, &su
);
629 /* Not IP, could match either peer configured on interface or a
631 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
633 group
= peer_group_lookup(bgp
, peer_str
);
637 if (peer_dynamic_neighbor(peer
)) {
639 "%% Operation not allowed on a dynamic neighbor\n");
649 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
654 int bgp_vty_return(struct vty
*vty
, int ret
)
656 const char *str
= NULL
;
659 case BGP_ERR_INVALID_VALUE
:
660 str
= "Invalid value";
662 case BGP_ERR_INVALID_FLAG
:
663 str
= "Invalid flag";
665 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
666 str
= "Peer-group has been shutdown. Activate the peer-group first";
668 case BGP_ERR_PEER_FLAG_CONFLICT
:
669 str
= "Can't set override-capability and strict-capability-match at the same time";
671 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
672 str
= "Specify remote-as or peer-group remote AS first";
674 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
675 str
= "Cannot change the peer-group. Deconfigure first";
677 case BGP_ERR_PEER_GROUP_MISMATCH
:
678 str
= "Peer is not a member of this peer-group";
680 case BGP_ERR_PEER_FILTER_CONFLICT
:
681 str
= "Prefix/distribute list can not co-exist";
683 case BGP_ERR_NOT_INTERNAL_PEER
:
684 str
= "Invalid command. Not an internal neighbor";
686 case BGP_ERR_REMOVE_PRIVATE_AS
:
687 str
= "remove-private-AS cannot be configured for IBGP peers";
689 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
690 str
= "Local-AS allowed only for EBGP peers";
692 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
693 str
= "Cannot have local-as same as BGP AS number";
695 case BGP_ERR_TCPSIG_FAILED
:
696 str
= "Error while applying TCP-Sig to session(s)";
698 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
699 str
= "ebgp-multihop and ttl-security cannot be configured together";
701 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
702 str
= "ttl-security only allowed for EBGP peers";
704 case BGP_ERR_AS_OVERRIDE
:
705 str
= "as-override cannot be configured for IBGP peers";
707 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
708 str
= "Invalid limit for number of dynamic neighbors";
710 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
711 str
= "Dynamic neighbor listen range already exists";
713 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
714 str
= "Operation not allowed on a dynamic neighbor";
716 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
717 str
= "Operation not allowed on a directly connected neighbor";
719 case BGP_ERR_PEER_SAFI_CONFLICT
:
722 case BGP_ERR_GR_INVALID_CMD
:
723 str
= "The Graceful Restart command used is not valid at this moment.";
725 case BGP_ERR_GR_OPERATION_FAILED
:
726 str
= "The Graceful Restart Operation failed due to an err.";
728 case BGP_GR_NO_OPERATION
:
733 vty_out(vty
, "%% %s\n", str
);
734 return CMD_WARNING_CONFIG_FAILED
;
739 /* BGP clear sort. */
748 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
749 safi_t safi
, int error
)
752 case BGP_ERR_AF_UNCONFIGURED
:
754 "%%BGP: Enable %s address family for the neighbor %s\n",
755 get_afi_safi_str(afi
, safi
, false), peer
->host
);
757 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
759 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
767 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
768 struct listnode
*nnode
, enum bgp_clear_type stype
)
772 /* if afi/.safi not specified, spin thru all of them */
773 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
777 FOREACH_AFI_SAFI (tmp_afi
, tmp_safi
) {
778 if (!peer
->afc
[tmp_afi
][tmp_safi
])
781 if (stype
== BGP_CLEAR_SOFT_NONE
)
782 ret
= peer_clear(peer
, &nnode
);
784 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
787 /* if afi specified and safi not, spin thru safis on this afi */
788 } else if (safi
== SAFI_UNSPEC
) {
791 for (tmp_safi
= SAFI_UNICAST
;
792 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
793 if (!peer
->afc
[afi
][tmp_safi
])
796 if (stype
== BGP_CLEAR_SOFT_NONE
)
797 ret
= peer_clear(peer
, &nnode
);
799 ret
= peer_clear_soft(peer
, afi
,
802 /* both afi/safi specified, let the caller know if not defined */
804 if (!peer
->afc
[afi
][safi
])
807 if (stype
== BGP_CLEAR_SOFT_NONE
)
808 ret
= peer_clear(peer
, &nnode
);
810 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
816 /* `clear ip bgp' functions. */
817 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
818 enum clear_sort sort
, enum bgp_clear_type stype
,
825 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
827 /* Clear all neighbors. */
829 * Pass along pointer to next node to peer_clear() when walking all
830 * nodes on the BGP instance as that may get freed if it is a
833 if (sort
== clear_all
) {
834 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
836 bgp_peer_gr_flags_update(peer
);
838 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
839 gr_router_detected
= true;
841 ret
= bgp_peer_clear(peer
, afi
, safi
, nnode
,
845 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
848 if (gr_router_detected
849 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
850 bgp_zebra_send_capabilities(bgp
, false);
851 } else if (!gr_router_detected
852 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
853 bgp_zebra_send_capabilities(bgp
, true);
856 /* This is to apply read-only mode on this clear. */
857 if (stype
== BGP_CLEAR_SOFT_NONE
)
858 bgp
->update_delay_over
= 0;
863 /* Clear specified neighbor. */
864 if (sort
== clear_peer
) {
867 /* Make sockunion for lookup. */
868 ret
= str2sockunion(arg
, &su
);
870 peer
= peer_lookup_by_conf_if(bgp
, arg
);
872 peer
= peer_lookup_by_hostname(bgp
, arg
);
875 "Malformed address or name: %s\n",
881 peer
= peer_lookup(bgp
, &su
);
884 "%%BGP: Unknown neighbor - \"%s\"\n",
890 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
891 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
893 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
895 /* if afi/safi not defined for this peer, let caller know */
897 ret
= BGP_ERR_AF_UNCONFIGURED
;
900 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
905 /* Clear all neighbors belonging to a specific peer-group. */
906 if (sort
== clear_group
) {
907 struct peer_group
*group
;
909 group
= peer_group_lookup(bgp
, arg
);
911 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
915 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
916 ret
= bgp_peer_clear(peer
, afi
, safi
, nnode
, stype
);
919 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
926 "%%BGP: No %s peer belonging to peer-group %s is configured\n",
927 get_afi_safi_str(afi
, safi
, false), arg
);
932 /* Clear all external (eBGP) neighbors. */
933 if (sort
== clear_external
) {
934 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
935 if (peer
->sort
== BGP_PEER_IBGP
)
938 bgp_peer_gr_flags_update(peer
);
940 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
941 gr_router_detected
= true;
943 ret
= bgp_peer_clear(peer
, afi
, safi
, nnode
, stype
);
946 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
951 if (gr_router_detected
952 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
953 bgp_zebra_send_capabilities(bgp
, false);
954 } else if (!gr_router_detected
955 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
956 bgp_zebra_send_capabilities(bgp
, true);
961 "%%BGP: No external %s peer is configured\n",
962 get_afi_safi_str(afi
, safi
, false));
967 /* Clear all neighbors belonging to a specific AS. */
968 if (sort
== clear_as
) {
969 as_t as
= strtoul(arg
, NULL
, 10);
971 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
975 bgp_peer_gr_flags_update(peer
);
977 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
978 gr_router_detected
= true;
980 ret
= bgp_peer_clear(peer
, afi
, safi
, nnode
, stype
);
983 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
988 if (gr_router_detected
989 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
990 bgp_zebra_send_capabilities(bgp
, false);
991 } else if (!gr_router_detected
992 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
993 bgp_zebra_send_capabilities(bgp
, true);
998 "%%BGP: No %s peer is configured with AS %s\n",
999 get_afi_safi_str(afi
, safi
, false), arg
);
1007 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1008 safi_t safi
, enum clear_sort sort
,
1009 enum bgp_clear_type stype
, const char *arg
)
1013 /* BGP structure lookup. */
1015 bgp
= bgp_lookup_by_name(name
);
1017 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1021 bgp
= bgp_get_default();
1023 vty_out(vty
, "No BGP process is configured\n");
1028 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1031 /* clear soft inbound */
1032 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1037 FOREACH_AFI_SAFI (afi
, safi
)
1038 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1039 BGP_CLEAR_SOFT_IN
, NULL
);
1042 /* clear soft outbound */
1043 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1048 FOREACH_AFI_SAFI (afi
, safi
)
1049 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1050 BGP_CLEAR_SOFT_OUT
, NULL
);
1054 #ifndef VTYSH_EXTRACT_PL
1055 #include "bgpd/bgp_vty_clippy.c"
1058 DEFUN_HIDDEN (bgp_local_mac
,
1060 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1062 "Local MAC config\n"
1063 "VxLAN Network Identifier\n"
1067 "mac-mobility sequence\n"
1077 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1078 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1079 vty_out(vty
, "%% Malformed MAC address\n");
1082 memset(&ip
, 0, sizeof(ip
));
1083 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1085 bgp
= bgp_get_default();
1087 vty_out(vty
, "Default BGP instance is not there\n");
1091 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
);
1093 vty_out(vty
, "Internal error\n");
1100 DEFUN_HIDDEN (no_bgp_local_mac
,
1101 no_bgp_local_mac_cmd
,
1102 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1105 "Local MAC config\n"
1106 "VxLAN Network Identifier\n"
1117 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1118 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1119 vty_out(vty
, "%% Malformed MAC address\n");
1122 memset(&ip
, 0, sizeof(ip
));
1124 bgp
= bgp_get_default();
1126 vty_out(vty
, "Default BGP instance is not there\n");
1130 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1132 vty_out(vty
, "Internal error\n");
1139 DEFUN (no_synchronization
,
1140 no_synchronization_cmd
,
1141 "no synchronization",
1143 "Perform IGP synchronization\n")
1148 DEFUN (no_auto_summary
,
1149 no_auto_summary_cmd
,
1152 "Enable automatic network number summarization\n")
1157 /* "router bgp" commands. */
1158 DEFUN_NOSH (router_bgp
,
1160 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1164 BGP_INSTANCE_HELP_STR
)
1167 int idx_view_vrf
= 3;
1173 const char *name
= NULL
;
1174 enum bgp_instance_type inst_type
;
1176 // "router bgp" without an ASN
1178 // Pending: Make VRF option available for ASN less config
1179 bgp
= bgp_get_default();
1182 vty_out(vty
, "%% No BGP process is configured\n");
1183 return CMD_WARNING_CONFIG_FAILED
;
1186 if (listcount(bm
->bgp
) > 1) {
1187 vty_out(vty
, "%% Please specify ASN and VRF\n");
1188 return CMD_WARNING_CONFIG_FAILED
;
1194 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1196 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1198 name
= argv
[idx_vrf
]->arg
;
1200 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1201 if (strmatch(name
, VRF_DEFAULT_NAME
))
1204 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1205 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1206 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1209 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1210 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1212 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1214 case BGP_ERR_AS_MISMATCH
:
1215 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1216 return CMD_WARNING_CONFIG_FAILED
;
1217 case BGP_ERR_INSTANCE_MISMATCH
:
1219 "BGP instance name and AS number mismatch\n");
1221 "BGP instance is already running; AS is %u\n",
1223 return CMD_WARNING_CONFIG_FAILED
;
1227 * If we just instantiated the default instance, complete
1228 * any pending VRF-VPN leaking that was configured via
1229 * earlier "router bgp X vrf FOO" blocks.
1231 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1232 vpn_leak_postchange_all();
1234 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1235 bgp_vpn_leak_export(bgp
);
1236 /* Pending: handle when user tries to change a view to vrf n vv.
1240 /* unset the auto created flag as the user config is now present */
1241 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1242 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1247 /* "no router bgp" commands. */
1248 DEFUN (no_router_bgp
,
1250 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1255 BGP_INSTANCE_HELP_STR
)
1261 const char *name
= NULL
;
1263 // "no router bgp" without an ASN
1265 // Pending: Make VRF option available for ASN less config
1266 bgp
= bgp_get_default();
1269 vty_out(vty
, "%% No BGP process is configured\n");
1270 return CMD_WARNING_CONFIG_FAILED
;
1273 if (listcount(bm
->bgp
) > 1) {
1274 vty_out(vty
, "%% Please specify ASN and VRF\n");
1275 return CMD_WARNING_CONFIG_FAILED
;
1279 vty_out(vty
, "%% Please unconfigure l3vni %u",
1281 return CMD_WARNING_CONFIG_FAILED
;
1284 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1287 name
= argv
[idx_vrf
]->arg
;
1289 /* Lookup bgp structure. */
1290 bgp
= bgp_lookup(as
, name
);
1292 vty_out(vty
, "%% Can't find BGP instance\n");
1293 return CMD_WARNING_CONFIG_FAILED
;
1297 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1299 return CMD_WARNING_CONFIG_FAILED
;
1302 /* Cannot delete default instance if vrf instances exist */
1303 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1304 struct listnode
*node
;
1305 struct bgp
*tmp_bgp
;
1307 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1308 if (tmp_bgp
->inst_type
1309 == BGP_INSTANCE_TYPE_VRF
) {
1311 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1312 return CMD_WARNING_CONFIG_FAILED
;
1318 if (bgp_vpn_leak_unimport(bgp
, vty
))
1319 return CMD_WARNING_CONFIG_FAILED
;
1327 /* BGP router-id. */
1329 DEFPY (bgp_router_id
,
1331 "bgp router-id A.B.C.D",
1333 "Override configured router identifier\n"
1334 "Manually configured router identifier\n")
1336 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1337 bgp_router_id_static_set(bgp
, router_id
);
1341 DEFPY (no_bgp_router_id
,
1342 no_bgp_router_id_cmd
,
1343 "no bgp router-id [A.B.C.D]",
1346 "Override configured router identifier\n"
1347 "Manually configured router identifier\n")
1349 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1351 if (router_id_str
) {
1352 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1353 vty_out(vty
, "%% BGP router-id doesn't match\n");
1354 return CMD_WARNING_CONFIG_FAILED
;
1358 router_id
.s_addr
= 0;
1359 bgp_router_id_static_set(bgp
, router_id
);
1365 /* BGP Cluster ID. */
1366 DEFUN (bgp_cluster_id
,
1368 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1370 "Configure Route-Reflector Cluster-id\n"
1371 "Route-Reflector Cluster-id in IP address format\n"
1372 "Route-Reflector Cluster-id as 32 bit quantity\n")
1374 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1377 struct in_addr cluster
;
1379 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1381 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1382 return CMD_WARNING_CONFIG_FAILED
;
1385 bgp_cluster_id_set(bgp
, &cluster
);
1386 bgp_clear_star_soft_out(vty
, bgp
->name
);
1391 DEFUN (no_bgp_cluster_id
,
1392 no_bgp_cluster_id_cmd
,
1393 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1396 "Configure Route-Reflector Cluster-id\n"
1397 "Route-Reflector Cluster-id in IP address format\n"
1398 "Route-Reflector Cluster-id as 32 bit quantity\n")
1400 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1401 bgp_cluster_id_unset(bgp
);
1402 bgp_clear_star_soft_out(vty
, bgp
->name
);
1407 DEFUN (bgp_confederation_identifier
,
1408 bgp_confederation_identifier_cmd
,
1409 "bgp confederation identifier (1-4294967295)",
1410 "BGP specific commands\n"
1411 "AS confederation parameters\n"
1413 "Set routing domain confederation AS\n")
1415 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1419 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1421 bgp_confederation_id_set(bgp
, as
);
1426 DEFUN (no_bgp_confederation_identifier
,
1427 no_bgp_confederation_identifier_cmd
,
1428 "no bgp confederation identifier [(1-4294967295)]",
1430 "BGP specific commands\n"
1431 "AS confederation parameters\n"
1433 "Set routing domain confederation AS\n")
1435 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1436 bgp_confederation_id_unset(bgp
);
1441 DEFUN (bgp_confederation_peers
,
1442 bgp_confederation_peers_cmd
,
1443 "bgp confederation peers (1-4294967295)...",
1444 "BGP specific commands\n"
1445 "AS confederation parameters\n"
1446 "Peer ASs in BGP confederation\n"
1449 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1454 for (i
= idx_asn
; i
< argc
; i
++) {
1455 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1457 if (bgp
->as
== as
) {
1459 "%% Local member-AS not allowed in confed peer list\n");
1463 bgp_confederation_peers_add(bgp
, as
);
1468 DEFUN (no_bgp_confederation_peers
,
1469 no_bgp_confederation_peers_cmd
,
1470 "no bgp confederation peers (1-4294967295)...",
1472 "BGP specific commands\n"
1473 "AS confederation parameters\n"
1474 "Peer ASs in BGP confederation\n"
1477 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1482 for (i
= idx_asn
; i
< argc
; i
++) {
1483 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1485 bgp_confederation_peers_remove(bgp
, as
);
1491 * Central routine for maximum-paths configuration.
1492 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1493 * @set: 1 for setting values, 0 for removing the max-paths config.
1495 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1496 const char *mpaths
, uint16_t options
,
1499 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1500 uint16_t maxpaths
= 0;
1505 afi
= bgp_node_afi(vty
);
1506 safi
= bgp_node_safi(vty
);
1509 maxpaths
= strtol(mpaths
, NULL
, 10);
1510 if (maxpaths
> multipath_num
) {
1512 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1513 maxpaths
, multipath_num
);
1514 return CMD_WARNING_CONFIG_FAILED
;
1516 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1519 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1523 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1524 (set
== 1) ? "" : "un",
1525 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1526 maxpaths
, afi
, safi
);
1527 return CMD_WARNING_CONFIG_FAILED
;
1530 bgp_recalculate_all_bestpaths(bgp
);
1535 DEFUN (bgp_maxmed_admin
,
1536 bgp_maxmed_admin_cmd
,
1537 "bgp max-med administrative ",
1539 "Advertise routes with max-med\n"
1540 "Administratively applied, for an indefinite period\n")
1542 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1544 bgp
->v_maxmed_admin
= 1;
1545 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1547 bgp_maxmed_update(bgp
);
1552 DEFUN (bgp_maxmed_admin_medv
,
1553 bgp_maxmed_admin_medv_cmd
,
1554 "bgp max-med administrative (0-4294967295)",
1556 "Advertise routes with max-med\n"
1557 "Administratively applied, for an indefinite period\n"
1558 "Max MED value to be used\n")
1560 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1563 bgp
->v_maxmed_admin
= 1;
1564 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1566 bgp_maxmed_update(bgp
);
1571 DEFUN (no_bgp_maxmed_admin
,
1572 no_bgp_maxmed_admin_cmd
,
1573 "no bgp max-med administrative [(0-4294967295)]",
1576 "Advertise routes with max-med\n"
1577 "Administratively applied, for an indefinite period\n"
1578 "Max MED value to be used\n")
1580 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1581 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1582 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1583 bgp_maxmed_update(bgp
);
1588 DEFUN (bgp_maxmed_onstartup
,
1589 bgp_maxmed_onstartup_cmd
,
1590 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1592 "Advertise routes with max-med\n"
1593 "Effective on a startup\n"
1594 "Time (seconds) period for max-med\n"
1595 "Max MED value to be used\n")
1597 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1600 argv_find(argv
, argc
, "(5-86400)", &idx
);
1601 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1602 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1603 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1605 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1607 bgp_maxmed_update(bgp
);
1612 DEFUN (no_bgp_maxmed_onstartup
,
1613 no_bgp_maxmed_onstartup_cmd
,
1614 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1617 "Advertise routes with max-med\n"
1618 "Effective on a startup\n"
1619 "Time (seconds) period for max-med\n"
1620 "Max MED value to be used\n")
1622 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1624 /* Cancel max-med onstartup if its on */
1625 if (bgp
->t_maxmed_onstartup
) {
1626 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1627 bgp
->maxmed_onstartup_over
= 1;
1630 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1631 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1633 bgp_maxmed_update(bgp
);
1638 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1641 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1642 uint16_t update_delay
;
1643 uint16_t establish_wait
;
1645 update_delay
= strtoul(delay
, NULL
, 10);
1647 if (!wait
) /* update-delay <delay> */
1649 bgp
->v_update_delay
= update_delay
;
1650 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1654 /* update-delay <delay> <establish-wait> */
1655 establish_wait
= atoi(wait
);
1656 if (update_delay
< establish_wait
) {
1658 "%%Failed: update-delay less than the establish-wait!\n");
1659 return CMD_WARNING_CONFIG_FAILED
;
1662 bgp
->v_update_delay
= update_delay
;
1663 bgp
->v_establish_wait
= establish_wait
;
1668 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1670 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1672 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1673 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1678 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1680 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1681 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1682 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1683 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1689 /* Update-delay configuration */
1690 DEFUN (bgp_update_delay
,
1691 bgp_update_delay_cmd
,
1692 "update-delay (0-3600)",
1693 "Force initial delay for best-path and updates\n"
1697 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1700 DEFUN (bgp_update_delay_establish_wait
,
1701 bgp_update_delay_establish_wait_cmd
,
1702 "update-delay (0-3600) (1-3600)",
1703 "Force initial delay for best-path and updates\n"
1708 int idx_number_2
= 2;
1709 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1710 argv
[idx_number_2
]->arg
);
1713 /* Update-delay deconfiguration */
1714 DEFUN (no_bgp_update_delay
,
1715 no_bgp_update_delay_cmd
,
1716 "no update-delay [(0-3600) [(1-3600)]]",
1718 "Force initial delay for best-path and updates\n"
1722 return bgp_update_delay_deconfig_vty(vty
);
1726 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
1729 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1731 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
1732 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
1737 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
1740 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1742 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
1743 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
1748 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1751 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1752 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1753 vty_out(vty
, " write-quanta %d\n", quanta
);
1756 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1759 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1760 if (quanta
!= BGP_READ_PACKET_MAX
)
1761 vty_out(vty
, " read-quanta %d\n", quanta
);
1764 /* Packet quanta configuration
1766 * XXX: The value set here controls the size of a stack buffer in the IO
1767 * thread. When changing these limits be careful to prevent stack overflow.
1769 * Furthermore, the maximums used here should correspond to
1770 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
1772 DEFPY (bgp_wpkt_quanta
,
1773 bgp_wpkt_quanta_cmd
,
1774 "[no] write-quanta (1-64)$quanta",
1776 "How many packets to write to peer socket per run\n"
1777 "Number of packets\n")
1779 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
1782 DEFPY (bgp_rpkt_quanta
,
1783 bgp_rpkt_quanta_cmd
,
1784 "[no] read-quanta (1-10)$quanta",
1786 "How many packets to read from peer socket per I/O cycle\n"
1787 "Number of packets\n")
1789 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
1792 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1794 if (!bgp
->heuristic_coalesce
)
1795 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1799 DEFUN (bgp_coalesce_time
,
1800 bgp_coalesce_time_cmd
,
1801 "coalesce-time (0-4294967295)",
1802 "Subgroup coalesce timer\n"
1803 "Subgroup coalesce timer value (in ms)\n")
1805 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1808 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1809 bgp
->heuristic_coalesce
= false;
1810 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1814 DEFUN (no_bgp_coalesce_time
,
1815 no_bgp_coalesce_time_cmd
,
1816 "no coalesce-time (0-4294967295)",
1818 "Subgroup coalesce timer\n"
1819 "Subgroup coalesce timer value (in ms)\n")
1821 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1823 bgp
->heuristic_coalesce
= true;
1824 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1828 /* Maximum-paths configuration */
1829 DEFUN (bgp_maxpaths
,
1831 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1832 "Forward packets over multiple paths\n"
1833 "Number of paths\n")
1836 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1837 argv
[idx_number
]->arg
, 0, 1);
1840 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1841 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1842 "Forward packets over multiple paths\n"
1843 "Number of paths\n")
1845 DEFUN (bgp_maxpaths_ibgp
,
1846 bgp_maxpaths_ibgp_cmd
,
1847 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1848 "Forward packets over multiple paths\n"
1850 "Number of paths\n")
1853 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1854 argv
[idx_number
]->arg
, 0, 1);
1857 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1858 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1859 "Forward packets over multiple paths\n"
1861 "Number of paths\n")
1863 DEFUN (bgp_maxpaths_ibgp_cluster
,
1864 bgp_maxpaths_ibgp_cluster_cmd
,
1865 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1866 "Forward packets over multiple paths\n"
1869 "Match the cluster length\n")
1872 return bgp_maxpaths_config_vty(
1873 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1874 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1877 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1878 "maximum-paths ibgp " CMD_RANGE_STR(
1879 1, MULTIPATH_NUM
) " equal-cluster-length",
1880 "Forward packets over multiple paths\n"
1883 "Match the cluster length\n")
1885 DEFUN (no_bgp_maxpaths
,
1886 no_bgp_maxpaths_cmd
,
1887 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1889 "Forward packets over multiple paths\n"
1890 "Number of paths\n")
1892 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1895 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1896 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1897 "Forward packets over multiple paths\n"
1898 "Number of paths\n")
1900 DEFUN (no_bgp_maxpaths_ibgp
,
1901 no_bgp_maxpaths_ibgp_cmd
,
1902 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1904 "Forward packets over multiple paths\n"
1907 "Match the cluster length\n")
1909 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1912 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1913 "no maximum-paths ibgp [" CMD_RANGE_STR(
1914 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1916 "Forward packets over multiple paths\n"
1919 "Match the cluster length\n")
1921 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
1922 afi_t afi
, safi_t safi
)
1924 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1925 vty_out(vty
, " maximum-paths %d\n",
1926 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1929 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1930 vty_out(vty
, " maximum-paths ibgp %d",
1931 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1932 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1933 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1934 vty_out(vty
, " equal-cluster-length");
1943 "timers bgp (0-65535) (0-65535)",
1944 "Adjust routing timers\n"
1946 "Keepalive interval\n"
1949 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1951 int idx_number_2
= 3;
1952 unsigned long keepalive
= 0;
1953 unsigned long holdtime
= 0;
1955 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1956 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1958 /* Holdtime value check. */
1959 if (holdtime
< 3 && holdtime
!= 0) {
1961 "%% hold time value must be either 0 or greater than 3\n");
1962 return CMD_WARNING_CONFIG_FAILED
;
1965 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
);
1970 DEFUN (no_bgp_timers
,
1972 "no timers bgp [(0-65535) (0-65535)]",
1974 "Adjust routing timers\n"
1976 "Keepalive interval\n"
1979 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1980 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
1981 DFLT_BGP_CONNECT_RETRY
);
1987 DEFUN (bgp_client_to_client_reflection
,
1988 bgp_client_to_client_reflection_cmd
,
1989 "bgp client-to-client reflection",
1990 "BGP specific commands\n"
1991 "Configure client to client route reflection\n"
1992 "reflection of routes allowed\n")
1994 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1995 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1996 bgp_clear_star_soft_out(vty
, bgp
->name
);
2001 DEFUN (no_bgp_client_to_client_reflection
,
2002 no_bgp_client_to_client_reflection_cmd
,
2003 "no bgp client-to-client reflection",
2005 "BGP specific commands\n"
2006 "Configure client to client route reflection\n"
2007 "reflection of routes allowed\n")
2009 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2010 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2011 bgp_clear_star_soft_out(vty
, bgp
->name
);
2016 /* "bgp always-compare-med" configuration. */
2017 DEFUN (bgp_always_compare_med
,
2018 bgp_always_compare_med_cmd
,
2019 "bgp always-compare-med",
2020 "BGP specific commands\n"
2021 "Allow comparing MED from different neighbors\n")
2023 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2024 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2025 bgp_recalculate_all_bestpaths(bgp
);
2030 DEFUN (no_bgp_always_compare_med
,
2031 no_bgp_always_compare_med_cmd
,
2032 "no bgp always-compare-med",
2034 "BGP specific commands\n"
2035 "Allow comparing MED from different neighbors\n")
2037 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2038 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2039 bgp_recalculate_all_bestpaths(bgp
);
2045 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2046 "bgp ebgp-requires-policy",
2047 "BGP specific commands\n"
2048 "Require in and out policy for eBGP peers (RFC8212)\n")
2050 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2051 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_ENABLED
;
2055 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2056 "no bgp ebgp-requires-policy",
2058 "BGP specific commands\n"
2059 "Require in and out policy for eBGP peers (RFC8212)\n")
2061 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2062 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_DISABLED
;
2066 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2067 "bgp reject-as-sets",
2068 "BGP specific commands\n"
2069 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2071 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2072 struct listnode
*node
, *nnode
;
2075 bgp
->reject_as_sets
= BGP_REJECT_AS_SETS_ENABLED
;
2077 /* Reset existing BGP sessions to reject routes
2078 * with aspath containing AS_SET or AS_CONFED_SET.
2080 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2081 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2082 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2083 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2084 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2091 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2092 "no bgp reject-as-sets",
2094 "BGP specific commands\n"
2095 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2097 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2098 struct listnode
*node
, *nnode
;
2101 bgp
->reject_as_sets
= BGP_REJECT_AS_SETS_DISABLED
;
2103 /* Reset existing BGP sessions to reject routes
2104 * with aspath containing AS_SET or AS_CONFED_SET.
2106 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2107 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2108 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2109 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2110 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2117 /* "bgp deterministic-med" configuration. */
2118 DEFUN (bgp_deterministic_med
,
2119 bgp_deterministic_med_cmd
,
2120 "bgp deterministic-med",
2121 "BGP specific commands\n"
2122 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2124 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2126 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2127 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2128 bgp_recalculate_all_bestpaths(bgp
);
2134 DEFUN (no_bgp_deterministic_med
,
2135 no_bgp_deterministic_med_cmd
,
2136 "no bgp deterministic-med",
2138 "BGP specific commands\n"
2139 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2141 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2142 int bestpath_per_as_used
;
2146 struct listnode
*node
, *nnode
;
2148 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2149 bestpath_per_as_used
= 0;
2151 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2152 FOREACH_AFI_SAFI (afi
, safi
)
2153 if (bgp_addpath_dmed_required(
2154 peer
->addpath_type
[afi
][safi
])) {
2155 bestpath_per_as_used
= 1;
2159 if (bestpath_per_as_used
)
2163 if (bestpath_per_as_used
) {
2165 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2166 return CMD_WARNING_CONFIG_FAILED
;
2168 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2169 bgp_recalculate_all_bestpaths(bgp
);
2176 /* "bgp graceful-restart mode" configuration. */
2177 DEFUN (bgp_graceful_restart
,
2178 bgp_graceful_restart_cmd
,
2179 "bgp graceful-restart",
2180 "BGP specific commands\n"
2184 int ret
= BGP_GR_FAILURE
;
2186 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2187 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2189 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2191 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2193 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2196 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2197 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2199 "Graceful restart configuration changed, reset all peers to take effect\n");
2200 return bgp_vty_return(vty
, ret
);
2203 DEFUN (no_bgp_graceful_restart
,
2204 no_bgp_graceful_restart_cmd
,
2205 "no bgp graceful-restart",
2207 "BGP specific commands\n"
2211 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2213 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2214 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2216 int ret
= BGP_GR_FAILURE
;
2218 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2220 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2223 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2224 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2226 "Graceful restart configuration changed, reset all peers to take effect\n");
2228 return bgp_vty_return(vty
, ret
);
2231 DEFUN (bgp_graceful_restart_stalepath_time
,
2232 bgp_graceful_restart_stalepath_time_cmd
,
2233 "bgp graceful-restart stalepath-time (1-4095)",
2234 "BGP specific commands\n"
2235 "Graceful restart capability parameters\n"
2236 "Set the max time to hold onto restarting peer's stale paths\n"
2237 "Delay value (seconds)\n")
2239 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2243 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2244 bgp
->stalepath_time
= stalepath
;
2248 DEFUN (bgp_graceful_restart_restart_time
,
2249 bgp_graceful_restart_restart_time_cmd
,
2250 "bgp graceful-restart restart-time (1-4095)",
2251 "BGP specific commands\n"
2252 "Graceful restart capability parameters\n"
2253 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2254 "Delay value (seconds)\n")
2256 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2260 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2261 bgp
->restart_time
= restart
;
2265 DEFUN (bgp_graceful_restart_select_defer_time
,
2266 bgp_graceful_restart_select_defer_time_cmd
,
2267 "bgp graceful-restart select-defer-time (0-3600)",
2268 "BGP specific commands\n"
2269 "Graceful restart capability parameters\n"
2270 "Set the time to defer the BGP route selection after restart\n"
2271 "Delay value (seconds, 0 - disable)\n")
2273 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2275 uint32_t defer_time
;
2277 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2278 bgp
->select_defer_time
= defer_time
;
2279 if (defer_time
== 0)
2280 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2282 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2287 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2288 no_bgp_graceful_restart_stalepath_time_cmd
,
2289 "no bgp graceful-restart stalepath-time [(1-4095)]",
2291 "BGP specific commands\n"
2292 "Graceful restart capability parameters\n"
2293 "Set the max time to hold onto restarting peer's stale paths\n"
2294 "Delay value (seconds)\n")
2296 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2298 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2302 DEFUN (no_bgp_graceful_restart_restart_time
,
2303 no_bgp_graceful_restart_restart_time_cmd
,
2304 "no bgp graceful-restart restart-time [(1-4095)]",
2306 "BGP specific commands\n"
2307 "Graceful restart capability parameters\n"
2308 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2309 "Delay value (seconds)\n")
2311 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2313 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2317 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2318 no_bgp_graceful_restart_select_defer_time_cmd
,
2319 "no bgp graceful-restart select-defer-time [(0-3600)]",
2321 "BGP specific commands\n"
2322 "Graceful restart capability parameters\n"
2323 "Set the time to defer the BGP route selection after restart\n"
2324 "Delay value (seconds)\n")
2326 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2328 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2329 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2334 DEFUN (bgp_graceful_restart_preserve_fw
,
2335 bgp_graceful_restart_preserve_fw_cmd
,
2336 "bgp graceful-restart preserve-fw-state",
2337 "BGP specific commands\n"
2338 "Graceful restart capability parameters\n"
2339 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2341 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2342 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2346 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2347 no_bgp_graceful_restart_preserve_fw_cmd
,
2348 "no bgp graceful-restart preserve-fw-state",
2350 "BGP specific commands\n"
2351 "Graceful restart capability parameters\n"
2352 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2354 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2355 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2359 DEFUN (bgp_graceful_restart_disable
,
2360 bgp_graceful_restart_disable_cmd
,
2361 "bgp graceful-restart-disable",
2362 "BGP specific commands\n"
2365 int ret
= BGP_GR_FAILURE
;
2367 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2369 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
2371 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2373 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
2375 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
2378 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2380 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
2382 "Graceful restart configuration changed, reset all peers to take effect\n");
2384 return bgp_vty_return(vty
, ret
);
2387 DEFUN (no_bgp_graceful_restart_disable
,
2388 no_bgp_graceful_restart_disable_cmd
,
2389 "no bgp graceful-restart-disable",
2391 "BGP specific commands\n"
2395 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2397 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2399 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
2401 int ret
= BGP_GR_FAILURE
;
2403 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
2405 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2408 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2410 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
2412 "Graceful restart configuration changed, reset all peers to take effect\n");
2414 return bgp_vty_return(vty
, ret
);
2417 DEFUN (bgp_neighbor_graceful_restart_set
,
2418 bgp_neighbor_graceful_restart_set_cmd
,
2419 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
2427 int ret
= BGP_GR_FAILURE
;
2429 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2431 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2433 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
2435 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2437 return CMD_WARNING_CONFIG_FAILED
;
2439 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
2441 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2442 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2444 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2446 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
2448 "Graceful restart configuration changed, reset this peer to take effect\n");
2450 return bgp_vty_return(vty
, ret
);
2453 DEFUN (no_bgp_neighbor_graceful_restart
,
2454 no_bgp_neighbor_graceful_restart_set_cmd
,
2455 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
2463 int ret
= BGP_GR_FAILURE
;
2466 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2468 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2470 return CMD_WARNING_CONFIG_FAILED
;
2472 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2474 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
2476 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
2478 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2479 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2481 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2483 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
2485 "Graceful restart configuration changed, reset this peer to take effect\n");
2487 return bgp_vty_return(vty
, ret
);
2490 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
2491 bgp_neighbor_graceful_restart_helper_set_cmd
,
2492 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
2495 GR_NEIGHBOR_HELPER_CMD
2500 int ret
= BGP_GR_FAILURE
;
2502 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2504 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2506 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
2508 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2511 return CMD_WARNING_CONFIG_FAILED
;
2514 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
2516 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2517 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2519 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2521 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
2523 "Graceful restart configuration changed, reset this peer to take effect\n");
2525 return bgp_vty_return(vty
, ret
);
2528 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
2529 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
2530 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
2534 NO_GR_NEIGHBOR_HELPER_CMD
2538 int ret
= BGP_GR_FAILURE
;
2541 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2543 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2545 return CMD_WARNING_CONFIG_FAILED
;
2547 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2549 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
2551 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
2553 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2554 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2556 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2558 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
2560 "Graceful restart configuration changed, reset this peer to take effect\n");
2562 return bgp_vty_return(vty
, ret
);
2565 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
2566 bgp_neighbor_graceful_restart_disable_set_cmd
,
2567 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
2570 GR_NEIGHBOR_DISABLE_CMD
2575 int ret
= BGP_GR_FAILURE
;
2577 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2579 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2581 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
2583 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2585 return CMD_WARNING_CONFIG_FAILED
;
2587 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
2589 if (peer
->bgp
->t_startup
)
2590 bgp_peer_gr_flags_update(peer
);
2592 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2593 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2595 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2597 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
2599 "Graceful restart configuration changed, reset this peer to take effect\n");
2601 return bgp_vty_return(vty
, ret
);
2604 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
2605 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
2606 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
2610 NO_GR_NEIGHBOR_DISABLE_CMD
2614 int ret
= BGP_GR_FAILURE
;
2617 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2619 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2621 return CMD_WARNING_CONFIG_FAILED
;
2623 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2625 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
2627 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
2629 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2630 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2632 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2634 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
2636 "Graceful restart configuration changed, reset this peer to take effect\n");
2638 return bgp_vty_return(vty
, ret
);
2641 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
2642 bgp_graceful_restart_disable_eor_cmd
,
2643 "bgp graceful-restart disable-eor",
2644 "BGP specific commands\n"
2645 "Graceful restart configuration parameters\n"
2646 "Disable EOR Check\n")
2648 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2649 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
2654 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
2655 no_bgp_graceful_restart_disable_eor_cmd
,
2656 "no bgp graceful-restart disable-eor",
2658 "BGP specific commands\n"
2659 "Graceful restart configuration parameters\n"
2660 "Disable EOR Check\n")
2662 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2663 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
2668 DEFUN (bgp_graceful_restart_rib_stale_time
,
2669 bgp_graceful_restart_rib_stale_time_cmd
,
2670 "bgp graceful-restart rib-stale-time (1-3600)",
2671 "BGP specific commands\n"
2672 "Graceful restart configuration parameters\n"
2673 "Specify the stale route removal timer in rib\n"
2674 "Delay value (seconds)\n")
2676 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2678 uint32_t stale_time
;
2680 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2681 bgp
->rib_stale_time
= stale_time
;
2682 /* Send the stale timer update message to RIB */
2683 if (bgp_zebra_stale_timer_update(bgp
))
2689 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
2690 no_bgp_graceful_restart_rib_stale_time_cmd
,
2691 "no bgp graceful-restart rib-stale-time [(1-3600)]",
2693 "BGP specific commands\n"
2694 "Graceful restart configuration parameters\n"
2695 "Specify the stale route removal timer in rib\n"
2696 "Delay value (seconds)\n")
2698 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2700 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
2701 /* Send the stale timer update message to RIB */
2702 if (bgp_zebra_stale_timer_update(bgp
))
2708 /* "bgp graceful-shutdown" configuration */
2709 DEFUN (bgp_graceful_shutdown
,
2710 bgp_graceful_shutdown_cmd
,
2711 "bgp graceful-shutdown",
2713 "Graceful shutdown parameters\n")
2715 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2717 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2718 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2719 bgp_static_redo_import_check(bgp
);
2720 bgp_redistribute_redo(bgp
);
2721 bgp_clear_star_soft_out(vty
, bgp
->name
);
2722 bgp_clear_star_soft_in(vty
, bgp
->name
);
2728 DEFUN (no_bgp_graceful_shutdown
,
2729 no_bgp_graceful_shutdown_cmd
,
2730 "no bgp graceful-shutdown",
2733 "Graceful shutdown parameters\n")
2735 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2737 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2738 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2739 bgp_static_redo_import_check(bgp
);
2740 bgp_redistribute_redo(bgp
);
2741 bgp_clear_star_soft_out(vty
, bgp
->name
);
2742 bgp_clear_star_soft_in(vty
, bgp
->name
);
2748 /* "bgp fast-external-failover" configuration. */
2749 DEFUN (bgp_fast_external_failover
,
2750 bgp_fast_external_failover_cmd
,
2751 "bgp fast-external-failover",
2753 "Immediately reset session if a link to a directly connected external peer goes down\n")
2755 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2756 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2760 DEFUN (no_bgp_fast_external_failover
,
2761 no_bgp_fast_external_failover_cmd
,
2762 "no bgp fast-external-failover",
2765 "Immediately reset session if a link to a directly connected external peer goes down\n")
2767 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2768 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2772 /* "bgp bestpath compare-routerid" configuration. */
2773 DEFUN (bgp_bestpath_compare_router_id
,
2774 bgp_bestpath_compare_router_id_cmd
,
2775 "bgp bestpath compare-routerid",
2776 "BGP specific commands\n"
2777 "Change the default bestpath selection\n"
2778 "Compare router-id for identical EBGP paths\n")
2780 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2781 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
2782 bgp_recalculate_all_bestpaths(bgp
);
2787 DEFUN (no_bgp_bestpath_compare_router_id
,
2788 no_bgp_bestpath_compare_router_id_cmd
,
2789 "no bgp bestpath compare-routerid",
2791 "BGP specific commands\n"
2792 "Change the default bestpath selection\n"
2793 "Compare router-id for identical EBGP paths\n")
2795 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2796 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
2797 bgp_recalculate_all_bestpaths(bgp
);
2802 /* "bgp bestpath as-path ignore" configuration. */
2803 DEFUN (bgp_bestpath_aspath_ignore
,
2804 bgp_bestpath_aspath_ignore_cmd
,
2805 "bgp bestpath as-path ignore",
2806 "BGP specific commands\n"
2807 "Change the default bestpath selection\n"
2808 "AS-path attribute\n"
2809 "Ignore as-path length in selecting a route\n")
2811 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2812 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
2813 bgp_recalculate_all_bestpaths(bgp
);
2818 DEFUN (no_bgp_bestpath_aspath_ignore
,
2819 no_bgp_bestpath_aspath_ignore_cmd
,
2820 "no bgp bestpath as-path ignore",
2822 "BGP specific commands\n"
2823 "Change the default bestpath selection\n"
2824 "AS-path attribute\n"
2825 "Ignore as-path length in selecting a route\n")
2827 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2828 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
2829 bgp_recalculate_all_bestpaths(bgp
);
2834 /* "bgp bestpath as-path confed" configuration. */
2835 DEFUN (bgp_bestpath_aspath_confed
,
2836 bgp_bestpath_aspath_confed_cmd
,
2837 "bgp bestpath as-path confed",
2838 "BGP specific commands\n"
2839 "Change the default bestpath selection\n"
2840 "AS-path attribute\n"
2841 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2843 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2844 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
2845 bgp_recalculate_all_bestpaths(bgp
);
2850 DEFUN (no_bgp_bestpath_aspath_confed
,
2851 no_bgp_bestpath_aspath_confed_cmd
,
2852 "no bgp bestpath as-path confed",
2854 "BGP specific commands\n"
2855 "Change the default bestpath selection\n"
2856 "AS-path attribute\n"
2857 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2859 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2860 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
2861 bgp_recalculate_all_bestpaths(bgp
);
2866 /* "bgp bestpath as-path multipath-relax" configuration. */
2867 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2868 bgp_bestpath_aspath_multipath_relax_cmd
,
2869 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2870 "BGP specific commands\n"
2871 "Change the default bestpath selection\n"
2872 "AS-path attribute\n"
2873 "Allow load sharing across routes that have different AS paths (but same length)\n"
2874 "Generate an AS_SET\n"
2875 "Do not generate an AS_SET\n")
2877 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2879 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2881 /* no-as-set is now the default behavior so we can silently
2883 if (argv_find(argv
, argc
, "as-set", &idx
))
2884 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2886 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2888 bgp_recalculate_all_bestpaths(bgp
);
2893 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2894 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2895 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2897 "BGP specific commands\n"
2898 "Change the default bestpath selection\n"
2899 "AS-path attribute\n"
2900 "Allow load sharing across routes that have different AS paths (but same length)\n"
2901 "Generate an AS_SET\n"
2902 "Do not generate an AS_SET\n")
2904 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2905 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2906 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2907 bgp_recalculate_all_bestpaths(bgp
);
2912 /* "bgp log-neighbor-changes" configuration. */
2913 DEFUN (bgp_log_neighbor_changes
,
2914 bgp_log_neighbor_changes_cmd
,
2915 "bgp log-neighbor-changes",
2916 "BGP specific commands\n"
2917 "Log neighbor up/down and reset reason\n")
2919 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2920 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2924 DEFUN (no_bgp_log_neighbor_changes
,
2925 no_bgp_log_neighbor_changes_cmd
,
2926 "no bgp log-neighbor-changes",
2928 "BGP specific commands\n"
2929 "Log neighbor up/down and reset reason\n")
2931 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2932 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2936 /* "bgp bestpath med" configuration. */
2937 DEFUN (bgp_bestpath_med
,
2938 bgp_bestpath_med_cmd
,
2939 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2940 "BGP specific commands\n"
2941 "Change the default bestpath selection\n"
2943 "Compare MED among confederation paths\n"
2944 "Treat missing MED as the least preferred one\n"
2945 "Treat missing MED as the least preferred one\n"
2946 "Compare MED among confederation paths\n")
2948 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2951 if (argv_find(argv
, argc
, "confed", &idx
))
2952 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
2954 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2955 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
2957 bgp_recalculate_all_bestpaths(bgp
);
2962 DEFUN (no_bgp_bestpath_med
,
2963 no_bgp_bestpath_med_cmd
,
2964 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2966 "BGP specific commands\n"
2967 "Change the default bestpath selection\n"
2969 "Compare MED among confederation paths\n"
2970 "Treat missing MED as the least preferred one\n"
2971 "Treat missing MED as the least preferred one\n"
2972 "Compare MED among confederation paths\n")
2974 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2977 if (argv_find(argv
, argc
, "confed", &idx
))
2978 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
2980 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2981 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
2983 bgp_recalculate_all_bestpaths(bgp
);
2988 /* "no bgp default ipv4-unicast". */
2989 DEFUN (no_bgp_default_ipv4_unicast
,
2990 no_bgp_default_ipv4_unicast_cmd
,
2991 "no bgp default ipv4-unicast",
2993 "BGP specific commands\n"
2994 "Configure BGP defaults\n"
2995 "Activate ipv4-unicast for a peer by default\n")
2997 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2998 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
);
3002 DEFUN (bgp_default_ipv4_unicast
,
3003 bgp_default_ipv4_unicast_cmd
,
3004 "bgp default ipv4-unicast",
3005 "BGP specific commands\n"
3006 "Configure BGP defaults\n"
3007 "Activate ipv4-unicast for a peer by default\n")
3009 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3010 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
);
3014 /* Display hostname in certain command outputs */
3015 DEFUN (bgp_default_show_hostname
,
3016 bgp_default_show_hostname_cmd
,
3017 "bgp default show-hostname",
3018 "BGP specific commands\n"
3019 "Configure BGP defaults\n"
3020 "Show hostname in certain command outputs\n")
3022 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3023 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3027 DEFUN (no_bgp_default_show_hostname
,
3028 no_bgp_default_show_hostname_cmd
,
3029 "no bgp default show-hostname",
3031 "BGP specific commands\n"
3032 "Configure BGP defaults\n"
3033 "Show hostname in certain command outputs\n")
3035 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3036 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3040 /* "bgp network import-check" configuration. */
3041 DEFUN (bgp_network_import_check
,
3042 bgp_network_import_check_cmd
,
3043 "bgp network import-check",
3044 "BGP specific commands\n"
3045 "BGP network command\n"
3046 "Check BGP network route exists in IGP\n")
3048 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3049 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3050 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3051 bgp_static_redo_import_check(bgp
);
3057 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
3058 "bgp network import-check exact",
3059 "BGP specific commands\n"
3060 "BGP network command\n"
3061 "Check BGP network route exists in IGP\n"
3062 "Match route precisely\n")
3064 DEFUN (no_bgp_network_import_check
,
3065 no_bgp_network_import_check_cmd
,
3066 "no bgp network import-check",
3068 "BGP specific commands\n"
3069 "BGP network command\n"
3070 "Check BGP network route exists in IGP\n")
3072 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3073 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3074 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3075 bgp_static_redo_import_check(bgp
);
3081 DEFUN (bgp_default_local_preference
,
3082 bgp_default_local_preference_cmd
,
3083 "bgp default local-preference (0-4294967295)",
3084 "BGP specific commands\n"
3085 "Configure BGP defaults\n"
3086 "local preference (higher=more preferred)\n"
3087 "Configure default local preference value\n")
3089 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3091 uint32_t local_pref
;
3093 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3095 bgp_default_local_preference_set(bgp
, local_pref
);
3096 bgp_clear_star_soft_in(vty
, bgp
->name
);
3101 DEFUN (no_bgp_default_local_preference
,
3102 no_bgp_default_local_preference_cmd
,
3103 "no bgp default local-preference [(0-4294967295)]",
3105 "BGP specific commands\n"
3106 "Configure BGP defaults\n"
3107 "local preference (higher=more preferred)\n"
3108 "Configure default local preference value\n")
3110 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3111 bgp_default_local_preference_unset(bgp
);
3112 bgp_clear_star_soft_in(vty
, bgp
->name
);
3118 DEFUN (bgp_default_subgroup_pkt_queue_max
,
3119 bgp_default_subgroup_pkt_queue_max_cmd
,
3120 "bgp default subgroup-pkt-queue-max (20-100)",
3121 "BGP specific commands\n"
3122 "Configure BGP defaults\n"
3123 "subgroup-pkt-queue-max\n"
3124 "Configure subgroup packet queue max\n")
3126 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3130 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3132 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
3137 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
3138 no_bgp_default_subgroup_pkt_queue_max_cmd
,
3139 "no bgp default subgroup-pkt-queue-max [(20-100)]",
3141 "BGP specific commands\n"
3142 "Configure BGP defaults\n"
3143 "subgroup-pkt-queue-max\n"
3144 "Configure subgroup packet queue max\n")
3146 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3147 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
3152 DEFUN (bgp_rr_allow_outbound_policy
,
3153 bgp_rr_allow_outbound_policy_cmd
,
3154 "bgp route-reflector allow-outbound-policy",
3155 "BGP specific commands\n"
3156 "Allow modifications made by out route-map\n"
3157 "on ibgp neighbors\n")
3159 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3161 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
3162 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
3163 update_group_announce_rrclients(bgp
);
3164 bgp_clear_star_soft_out(vty
, bgp
->name
);
3170 DEFUN (no_bgp_rr_allow_outbound_policy
,
3171 no_bgp_rr_allow_outbound_policy_cmd
,
3172 "no bgp route-reflector allow-outbound-policy",
3174 "BGP specific commands\n"
3175 "Allow modifications made by out route-map\n"
3176 "on ibgp neighbors\n")
3178 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3180 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
3181 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
3182 update_group_announce_rrclients(bgp
);
3183 bgp_clear_star_soft_out(vty
, bgp
->name
);
3189 DEFUN (bgp_listen_limit
,
3190 bgp_listen_limit_cmd
,
3191 "bgp listen limit (1-5000)",
3192 "BGP specific commands\n"
3193 "BGP Dynamic Neighbors listen commands\n"
3194 "Maximum number of BGP Dynamic Neighbors that can be created\n"
3195 "Configure Dynamic Neighbors listen limit value\n")
3197 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3201 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3203 bgp_listen_limit_set(bgp
, listen_limit
);
3208 DEFUN (no_bgp_listen_limit
,
3209 no_bgp_listen_limit_cmd
,
3210 "no bgp listen limit [(1-5000)]",
3212 "BGP specific commands\n"
3213 "BGP Dynamic Neighbors listen commands\n"
3214 "Maximum number of BGP Dynamic Neighbors that can be created\n"
3215 "Configure Dynamic Neighbors listen limit value\n")
3217 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3218 bgp_listen_limit_unset(bgp
);
3224 * Check if this listen range is already configured. Check for exact
3225 * match or overlap based on input.
3227 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
3228 struct prefix
*range
, int exact
)
3230 struct listnode
*node
, *nnode
;
3231 struct listnode
*node1
, *nnode1
;
3232 struct peer_group
*group
;
3237 afi
= family2afi(range
->family
);
3238 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
3239 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
3242 match
= prefix_same(range
, lr
);
3244 match
= (prefix_match(range
, lr
)
3245 || prefix_match(lr
, range
));
3254 DEFUN (bgp_listen_range
,
3255 bgp_listen_range_cmd
,
3256 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
3257 "BGP specific commands\n"
3258 "Configure BGP dynamic neighbors listen range\n"
3259 "Configure BGP dynamic neighbors listen range\n"
3261 "Member of the peer-group\n"
3262 "Peer-group name\n")
3264 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3265 struct prefix range
;
3266 struct peer_group
*group
, *existing_group
;
3271 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
3272 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
3273 char *prefix
= argv
[idx
]->arg
;
3274 argv_find(argv
, argc
, "PGNAME", &idx
);
3275 char *peergroup
= argv
[idx
]->arg
;
3277 /* Convert IP prefix string to struct prefix. */
3278 ret
= str2prefix(prefix
, &range
);
3280 vty_out(vty
, "%% Malformed listen range\n");
3281 return CMD_WARNING_CONFIG_FAILED
;
3284 afi
= family2afi(range
.family
);
3286 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
3288 "%% Malformed listen range (link-local address)\n");
3289 return CMD_WARNING_CONFIG_FAILED
;
3294 /* Check if same listen range is already configured. */
3295 existing_group
= listen_range_exists(bgp
, &range
, 1);
3296 if (existing_group
) {
3297 if (strcmp(existing_group
->name
, peergroup
) == 0)
3301 "%% Same listen range is attached to peer-group %s\n",
3302 existing_group
->name
);
3303 return CMD_WARNING_CONFIG_FAILED
;
3307 /* Check if an overlapping listen range exists. */
3308 if (listen_range_exists(bgp
, &range
, 0)) {
3310 "%% Listen range overlaps with existing listen range\n");
3311 return CMD_WARNING_CONFIG_FAILED
;
3314 group
= peer_group_lookup(bgp
, peergroup
);
3316 vty_out(vty
, "%% Configure the peer-group first\n");
3317 return CMD_WARNING_CONFIG_FAILED
;
3320 ret
= peer_group_listen_range_add(group
, &range
);
3321 return bgp_vty_return(vty
, ret
);
3324 DEFUN (no_bgp_listen_range
,
3325 no_bgp_listen_range_cmd
,
3326 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
3328 "BGP specific commands\n"
3329 "Unconfigure BGP dynamic neighbors listen range\n"
3330 "Unconfigure BGP dynamic neighbors listen range\n"
3332 "Member of the peer-group\n"
3333 "Peer-group name\n")
3335 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3336 struct prefix range
;
3337 struct peer_group
*group
;
3342 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
3343 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
3344 char *prefix
= argv
[idx
]->arg
;
3345 argv_find(argv
, argc
, "PGNAME", &idx
);
3346 char *peergroup
= argv
[idx
]->arg
;
3348 /* Convert IP prefix string to struct prefix. */
3349 ret
= str2prefix(prefix
, &range
);
3351 vty_out(vty
, "%% Malformed listen range\n");
3352 return CMD_WARNING_CONFIG_FAILED
;
3355 afi
= family2afi(range
.family
);
3357 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
3359 "%% Malformed listen range (link-local address)\n");
3360 return CMD_WARNING_CONFIG_FAILED
;
3365 group
= peer_group_lookup(bgp
, peergroup
);
3367 vty_out(vty
, "%% Peer-group does not exist\n");
3368 return CMD_WARNING_CONFIG_FAILED
;
3371 ret
= peer_group_listen_range_del(group
, &range
);
3372 return bgp_vty_return(vty
, ret
);
3375 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
3377 struct peer_group
*group
;
3378 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
3379 struct prefix
*range
;
3381 char buf
[PREFIX2STR_BUFFER
];
3383 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
3384 vty_out(vty
, " bgp listen limit %d\n",
3385 bgp
->dynamic_neighbors_limit
);
3387 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
3388 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
3389 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
3391 prefix2str(range
, buf
, sizeof(buf
));
3393 " bgp listen range %s peer-group %s\n",
3401 DEFUN (bgp_disable_connected_route_check
,
3402 bgp_disable_connected_route_check_cmd
,
3403 "bgp disable-ebgp-connected-route-check",
3404 "BGP specific commands\n"
3405 "Disable checking if nexthop is connected on ebgp sessions\n")
3407 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3408 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
3409 bgp_clear_star_soft_in(vty
, bgp
->name
);
3414 DEFUN (no_bgp_disable_connected_route_check
,
3415 no_bgp_disable_connected_route_check_cmd
,
3416 "no bgp disable-ebgp-connected-route-check",
3418 "BGP specific commands\n"
3419 "Disable checking if nexthop is connected on ebgp sessions\n")
3421 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3422 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
3423 bgp_clear_star_soft_in(vty
, bgp
->name
);
3429 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
3430 const char *as_str
, afi_t afi
, safi_t safi
)
3432 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3435 int as_type
= AS_SPECIFIED
;
3438 if (as_str
[0] == 'i') {
3440 as_type
= AS_INTERNAL
;
3441 } else if (as_str
[0] == 'e') {
3443 as_type
= AS_EXTERNAL
;
3445 /* Get AS number. */
3446 as
= strtoul(as_str
, NULL
, 10);
3449 /* If peer is peer group or interface peer, call proper function. */
3450 ret
= str2sockunion(peer_str
, &su
);
3454 /* Check if existing interface peer */
3455 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
3457 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
3460 /* if not interface peer, check peer-group settings */
3461 if (ret
< 0 && !peer
) {
3462 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
3465 "%% Create the peer-group or interface first\n");
3466 return CMD_WARNING_CONFIG_FAILED
;
3471 if (peer_address_self_check(bgp
, &su
)) {
3473 "%% Can not configure the local system as neighbor\n");
3474 return CMD_WARNING_CONFIG_FAILED
;
3476 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
3479 /* This peer belongs to peer group. */
3481 case BGP_ERR_PEER_GROUP_MEMBER
:
3483 "%% Peer-group member cannot override remote-as of peer-group\n");
3484 return CMD_WARNING_CONFIG_FAILED
;
3485 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
3487 "%% Peer-group members must be all internal or all external\n");
3488 return CMD_WARNING_CONFIG_FAILED
;
3490 return bgp_vty_return(vty
, ret
);
3493 DEFUN (bgp_default_shutdown
,
3494 bgp_default_shutdown_cmd
,
3495 "[no] bgp default shutdown",
3498 "Configure BGP defaults\n"
3499 "Apply administrative shutdown to newly configured peers\n")
3501 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3502 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
3506 DEFUN (neighbor_remote_as
,
3507 neighbor_remote_as_cmd
,
3508 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
3511 "Specify a BGP neighbor\n"
3513 "Internal BGP peer\n"
3514 "External BGP peer\n")
3517 int idx_remote_as
= 3;
3518 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
3519 argv
[idx_remote_as
]->arg
, AFI_IP
,
3523 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
3524 afi_t afi
, safi_t safi
, int v6only
,
3525 const char *peer_group_name
,
3528 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3530 int as_type
= AS_UNSPECIFIED
;
3532 struct peer_group
*group
;
3536 group
= peer_group_lookup(bgp
, conf_if
);
3539 vty_out(vty
, "%% Name conflict with peer-group \n");
3540 return CMD_WARNING_CONFIG_FAILED
;
3544 if (as_str
[0] == 'i') {
3545 as_type
= AS_INTERNAL
;
3546 } else if (as_str
[0] == 'e') {
3547 as_type
= AS_EXTERNAL
;
3549 /* Get AS number. */
3550 as
= strtoul(as_str
, NULL
, 10);
3551 as_type
= AS_SPECIFIED
;
3555 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
3558 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
3561 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
)
3562 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
3563 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
3564 as_type
, 0, 0, NULL
);
3566 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
3567 as_type
, afi
, safi
, NULL
);
3570 vty_out(vty
, "%% BGP failed to create peer\n");
3571 return CMD_WARNING_CONFIG_FAILED
;
3575 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
3577 /* Request zebra to initiate IPv6 RAs on this interface. We do
3579 * any unnumbered peer in order to not worry about run-time
3581 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
3583 * gets deleted later etc.)
3586 bgp_zebra_initiate_radv(bgp
, peer
);
3589 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
3590 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
3592 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
3594 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
3596 /* v6only flag changed. Reset bgp seesion */
3597 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
3598 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
3599 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
3600 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
3602 bgp_session_reset(peer
);
3605 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
3606 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
3607 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
3608 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
3611 if (peer_group_name
) {
3612 group
= peer_group_lookup(bgp
, peer_group_name
);
3614 vty_out(vty
, "%% Configure the peer-group first\n");
3615 return CMD_WARNING_CONFIG_FAILED
;
3618 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3621 return bgp_vty_return(vty
, ret
);
3624 DEFUN (neighbor_interface_config
,
3625 neighbor_interface_config_cmd
,
3626 "neighbor WORD interface [peer-group PGNAME]",
3628 "Interface name or neighbor tag\n"
3629 "Enable BGP on interface\n"
3630 "Member of the peer-group\n"
3631 "Peer-group name\n")
3634 int idx_peer_group_word
= 4;
3636 if (argc
> idx_peer_group_word
)
3637 return peer_conf_interface_get(
3638 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
3639 argv
[idx_peer_group_word
]->arg
, NULL
);
3641 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3642 SAFI_UNICAST
, 0, NULL
, NULL
);
3645 DEFUN (neighbor_interface_config_v6only
,
3646 neighbor_interface_config_v6only_cmd
,
3647 "neighbor WORD interface v6only [peer-group PGNAME]",
3649 "Interface name or neighbor tag\n"
3650 "Enable BGP on interface\n"
3651 "Enable BGP with v6 link-local only\n"
3652 "Member of the peer-group\n"
3653 "Peer-group name\n")
3656 int idx_peer_group_word
= 5;
3658 if (argc
> idx_peer_group_word
)
3659 return peer_conf_interface_get(
3660 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
3661 argv
[idx_peer_group_word
]->arg
, NULL
);
3663 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3664 SAFI_UNICAST
, 1, NULL
, NULL
);
3668 DEFUN (neighbor_interface_config_remote_as
,
3669 neighbor_interface_config_remote_as_cmd
,
3670 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
3672 "Interface name or neighbor tag\n"
3673 "Enable BGP on interface\n"
3674 "Specify a BGP neighbor\n"
3676 "Internal BGP peer\n"
3677 "External BGP peer\n")
3680 int idx_remote_as
= 4;
3681 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3682 SAFI_UNICAST
, 0, NULL
,
3683 argv
[idx_remote_as
]->arg
);
3686 DEFUN (neighbor_interface_v6only_config_remote_as
,
3687 neighbor_interface_v6only_config_remote_as_cmd
,
3688 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
3690 "Interface name or neighbor tag\n"
3691 "Enable BGP with v6 link-local only\n"
3692 "Enable BGP on interface\n"
3693 "Specify a BGP neighbor\n"
3695 "Internal BGP peer\n"
3696 "External BGP peer\n")
3699 int idx_remote_as
= 5;
3700 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3701 SAFI_UNICAST
, 1, NULL
,
3702 argv
[idx_remote_as
]->arg
);
3705 DEFUN (neighbor_peer_group
,
3706 neighbor_peer_group_cmd
,
3707 "neighbor WORD peer-group",
3709 "Interface name or neighbor tag\n"
3710 "Configure peer-group\n")
3712 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3715 struct peer_group
*group
;
3717 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3719 vty_out(vty
, "%% Name conflict with interface: \n");
3720 return CMD_WARNING_CONFIG_FAILED
;
3723 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
3725 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
3726 return CMD_WARNING_CONFIG_FAILED
;
3734 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3738 "Specify a BGP neighbor\n"
3740 "Internal BGP peer\n"
3741 "External BGP peer\n")
3743 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3747 struct peer_group
*group
;
3751 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3753 /* look up for neighbor by interface name config. */
3754 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3756 /* Request zebra to terminate IPv6 RAs on this
3759 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3760 peer_notify_unconfig(peer
);
3765 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3767 peer_group_notify_unconfig(group
);
3768 peer_group_delete(group
);
3770 vty_out(vty
, "%% Create the peer-group first\n");
3771 return CMD_WARNING_CONFIG_FAILED
;
3774 peer
= peer_lookup(bgp
, &su
);
3776 if (peer_dynamic_neighbor(peer
)) {
3778 "%% Operation not allowed on a dynamic neighbor\n");
3779 return CMD_WARNING_CONFIG_FAILED
;
3782 other
= peer
->doppelganger
;
3783 peer_notify_unconfig(peer
);
3785 if (other
&& other
->status
!= Deleted
) {
3786 peer_notify_unconfig(other
);
3795 DEFUN (no_neighbor_interface_config
,
3796 no_neighbor_interface_config_cmd
,
3797 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
3801 "Configure BGP on interface\n"
3802 "Enable BGP with v6 link-local only\n"
3803 "Member of the peer-group\n"
3805 "Specify a BGP neighbor\n"
3807 "Internal BGP peer\n"
3808 "External BGP peer\n")
3810 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3814 /* look up for neighbor by interface name config. */
3815 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3817 /* Request zebra to terminate IPv6 RAs on this interface. */
3819 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3820 peer_notify_unconfig(peer
);
3823 vty_out(vty
, "%% Create the bgp interface first\n");
3824 return CMD_WARNING_CONFIG_FAILED
;
3829 DEFUN (no_neighbor_peer_group
,
3830 no_neighbor_peer_group_cmd
,
3831 "no neighbor WORD peer-group",
3835 "Configure peer-group\n")
3837 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3839 struct peer_group
*group
;
3841 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3843 peer_group_notify_unconfig(group
);
3844 peer_group_delete(group
);
3846 vty_out(vty
, "%% Create the peer-group first\n");
3847 return CMD_WARNING_CONFIG_FAILED
;
3852 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3853 no_neighbor_interface_peer_group_remote_as_cmd
,
3854 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3857 "Interface name or neighbor tag\n"
3858 "Specify a BGP neighbor\n"
3860 "Internal BGP peer\n"
3861 "External BGP peer\n")
3863 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3865 struct peer_group
*group
;
3868 /* look up for neighbor by interface name config. */
3869 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3871 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
3875 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3877 peer_group_remote_as_delete(group
);
3879 vty_out(vty
, "%% Create the peer-group or interface first\n");
3880 return CMD_WARNING_CONFIG_FAILED
;
3885 DEFUN (neighbor_local_as
,
3886 neighbor_local_as_cmd
,
3887 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3890 "Specify a local-as number\n"
3891 "AS number used as local AS\n")
3899 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3901 return CMD_WARNING_CONFIG_FAILED
;
3903 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3904 ret
= peer_local_as_set(peer
, as
, 0, 0);
3905 return bgp_vty_return(vty
, ret
);
3908 DEFUN (neighbor_local_as_no_prepend
,
3909 neighbor_local_as_no_prepend_cmd
,
3910 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3913 "Specify a local-as number\n"
3914 "AS number used as local AS\n"
3915 "Do not prepend local-as to updates from ebgp peers\n")
3923 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3925 return CMD_WARNING_CONFIG_FAILED
;
3927 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3928 ret
= peer_local_as_set(peer
, as
, 1, 0);
3929 return bgp_vty_return(vty
, ret
);
3932 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3933 neighbor_local_as_no_prepend_replace_as_cmd
,
3934 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3937 "Specify a local-as number\n"
3938 "AS number used as local AS\n"
3939 "Do not prepend local-as to updates from ebgp peers\n"
3940 "Do not prepend local-as to updates from ibgp peers\n")
3948 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3950 return CMD_WARNING_CONFIG_FAILED
;
3952 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3953 ret
= peer_local_as_set(peer
, as
, 1, 1);
3954 return bgp_vty_return(vty
, ret
);
3957 DEFUN (no_neighbor_local_as
,
3958 no_neighbor_local_as_cmd
,
3959 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3963 "Specify a local-as number\n"
3964 "AS number used as local AS\n"
3965 "Do not prepend local-as to updates from ebgp peers\n"
3966 "Do not prepend local-as to updates from ibgp peers\n")
3972 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3974 return CMD_WARNING_CONFIG_FAILED
;
3976 ret
= peer_local_as_unset(peer
);
3977 return bgp_vty_return(vty
, ret
);
3981 DEFUN (neighbor_solo
,
3983 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3986 "Solo peer - part of its own update group\n")
3992 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3994 return CMD_WARNING_CONFIG_FAILED
;
3996 ret
= update_group_adjust_soloness(peer
, 1);
3997 return bgp_vty_return(vty
, ret
);
4000 DEFUN (no_neighbor_solo
,
4001 no_neighbor_solo_cmd
,
4002 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4006 "Solo peer - part of its own update group\n")
4012 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4014 return CMD_WARNING_CONFIG_FAILED
;
4016 ret
= update_group_adjust_soloness(peer
, 0);
4017 return bgp_vty_return(vty
, ret
);
4020 DEFUN (neighbor_password
,
4021 neighbor_password_cmd
,
4022 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
4033 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4035 return CMD_WARNING_CONFIG_FAILED
;
4037 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
4038 return bgp_vty_return(vty
, ret
);
4041 DEFUN (no_neighbor_password
,
4042 no_neighbor_password_cmd
,
4043 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
4054 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4056 return CMD_WARNING_CONFIG_FAILED
;
4058 ret
= peer_password_unset(peer
);
4059 return bgp_vty_return(vty
, ret
);
4062 DEFUN (neighbor_activate
,
4063 neighbor_activate_cmd
,
4064 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4067 "Enable the Address Family for this Neighbor\n")
4073 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4075 return CMD_WARNING_CONFIG_FAILED
;
4077 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
4078 return bgp_vty_return(vty
, ret
);
4081 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
4082 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4083 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4084 "Enable the Address Family for this Neighbor\n")
4086 DEFUN (no_neighbor_activate
,
4087 no_neighbor_activate_cmd
,
4088 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4092 "Enable the Address Family for this Neighbor\n")
4099 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4101 return CMD_WARNING_CONFIG_FAILED
;
4103 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
4104 return bgp_vty_return(vty
, ret
);
4107 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
4108 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4109 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4110 "Enable the Address Family for this Neighbor\n")
4112 DEFUN (neighbor_set_peer_group
,
4113 neighbor_set_peer_group_cmd
,
4114 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4117 "Member of the peer-group\n"
4118 "Peer-group name\n")
4120 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4127 struct peer_group
*group
;
4129 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4131 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4133 vty_out(vty
, "%% Malformed address or name: %s\n",
4134 argv
[idx_peer
]->arg
);
4135 return CMD_WARNING_CONFIG_FAILED
;
4138 if (peer_address_self_check(bgp
, &su
)) {
4140 "%% Can not configure the local system as neighbor\n");
4141 return CMD_WARNING_CONFIG_FAILED
;
4144 /* Disallow for dynamic neighbor. */
4145 peer
= peer_lookup(bgp
, &su
);
4146 if (peer
&& peer_dynamic_neighbor(peer
)) {
4148 "%% Operation not allowed on a dynamic neighbor\n");
4149 return CMD_WARNING_CONFIG_FAILED
;
4153 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4155 vty_out(vty
, "%% Configure the peer-group first\n");
4156 return CMD_WARNING_CONFIG_FAILED
;
4159 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
4161 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
4163 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
4165 return CMD_WARNING_CONFIG_FAILED
;
4168 return bgp_vty_return(vty
, ret
);
4171 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
4172 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4173 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4174 "Member of the peer-group\n"
4175 "Peer-group name\n")
4177 DEFUN (no_neighbor_set_peer_group
,
4178 no_neighbor_set_peer_group_cmd
,
4179 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4183 "Member of the peer-group\n"
4184 "Peer-group name\n")
4186 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4191 struct peer_group
*group
;
4193 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4195 return CMD_WARNING_CONFIG_FAILED
;
4197 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4199 vty_out(vty
, "%% Configure the peer-group first\n");
4200 return CMD_WARNING_CONFIG_FAILED
;
4203 peer_notify_unconfig(peer
);
4204 ret
= peer_delete(peer
);
4206 return bgp_vty_return(vty
, ret
);
4209 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
4210 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4211 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4212 "Member of the peer-group\n"
4213 "Peer-group name\n")
4215 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
4216 uint32_t flag
, int set
)
4221 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4223 return CMD_WARNING_CONFIG_FAILED
;
4226 * If 'neighbor <interface>', then this is for directly connected peers,
4227 * we should not accept disable-connected-check.
4229 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
4231 "%s is directly connected peer, cannot accept disable-"
4232 "connected-check\n",
4234 return CMD_WARNING_CONFIG_FAILED
;
4237 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
4238 peer_tx_shutdown_message_unset(peer
);
4241 ret
= peer_flag_set(peer
, flag
);
4243 ret
= peer_flag_unset(peer
, flag
);
4245 return bgp_vty_return(vty
, ret
);
4248 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
4250 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
4253 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
4256 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
4259 /* neighbor passive. */
4260 DEFUN (neighbor_passive
,
4261 neighbor_passive_cmd
,
4262 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
4265 "Don't send open messages to this neighbor\n")
4268 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
4271 DEFUN (no_neighbor_passive
,
4272 no_neighbor_passive_cmd
,
4273 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
4277 "Don't send open messages to this neighbor\n")
4280 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
4283 /* neighbor shutdown. */
4284 DEFUN (neighbor_shutdown_msg
,
4285 neighbor_shutdown_msg_cmd
,
4286 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
4289 "Administratively shut down this neighbor\n"
4290 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
4291 "Shutdown message\n")
4297 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4301 return CMD_WARNING_CONFIG_FAILED
;
4302 message
= argv_concat(argv
, argc
, 4);
4303 peer_tx_shutdown_message_set(peer
, message
);
4304 XFREE(MTYPE_TMP
, message
);
4307 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
4310 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
4311 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
4312 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4313 "Administratively shut down this neighbor\n")
4315 DEFUN (no_neighbor_shutdown_msg
,
4316 no_neighbor_shutdown_msg_cmd
,
4317 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
4321 "Administratively shut down this neighbor\n"
4322 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
4323 "Shutdown message\n")
4327 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4328 PEER_FLAG_SHUTDOWN
);
4331 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
4332 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
4333 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4334 "Administratively shut down this neighbor\n")
4336 /* neighbor capability dynamic. */
4337 DEFUN (neighbor_capability_dynamic
,
4338 neighbor_capability_dynamic_cmd
,
4339 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
4342 "Advertise capability to the peer\n"
4343 "Advertise dynamic capability to this neighbor\n")
4346 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4347 PEER_FLAG_DYNAMIC_CAPABILITY
);
4350 DEFUN (no_neighbor_capability_dynamic
,
4351 no_neighbor_capability_dynamic_cmd
,
4352 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
4356 "Advertise capability to the peer\n"
4357 "Advertise dynamic capability to this neighbor\n")
4360 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4361 PEER_FLAG_DYNAMIC_CAPABILITY
);
4364 /* neighbor dont-capability-negotiate */
4365 DEFUN (neighbor_dont_capability_negotiate
,
4366 neighbor_dont_capability_negotiate_cmd
,
4367 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
4370 "Do not perform capability negotiation\n")
4373 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4374 PEER_FLAG_DONT_CAPABILITY
);
4377 DEFUN (no_neighbor_dont_capability_negotiate
,
4378 no_neighbor_dont_capability_negotiate_cmd
,
4379 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
4383 "Do not perform capability negotiation\n")
4386 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4387 PEER_FLAG_DONT_CAPABILITY
);
4390 /* neighbor capability extended next hop encoding */
4391 DEFUN (neighbor_capability_enhe
,
4392 neighbor_capability_enhe_cmd
,
4393 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
4396 "Advertise capability to the peer\n"
4397 "Advertise extended next-hop capability to the peer\n")
4400 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4401 PEER_FLAG_CAPABILITY_ENHE
);
4404 DEFUN (no_neighbor_capability_enhe
,
4405 no_neighbor_capability_enhe_cmd
,
4406 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
4410 "Advertise capability to the peer\n"
4411 "Advertise extended next-hop capability to the peer\n")
4414 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4415 PEER_FLAG_CAPABILITY_ENHE
);
4418 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
4419 afi_t afi
, safi_t safi
, uint32_t flag
,
4425 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4427 return CMD_WARNING_CONFIG_FAILED
;
4430 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
4432 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
4434 return bgp_vty_return(vty
, ret
);
4437 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
4438 afi_t afi
, safi_t safi
, uint32_t flag
)
4440 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
4443 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
4444 afi_t afi
, safi_t safi
, uint32_t flag
)
4446 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
4449 /* neighbor capability orf prefix-list. */
4450 DEFUN (neighbor_capability_orf_prefix
,
4451 neighbor_capability_orf_prefix_cmd
,
4452 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
4455 "Advertise capability to the peer\n"
4456 "Advertise ORF capability to the peer\n"
4457 "Advertise prefixlist ORF capability to this neighbor\n"
4458 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
4459 "Capability to RECEIVE the ORF from this neighbor\n"
4460 "Capability to SEND the ORF to this neighbor\n")
4463 int idx_send_recv
= 5;
4466 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
4467 flag
= PEER_FLAG_ORF_PREFIX_SM
;
4468 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
4469 flag
= PEER_FLAG_ORF_PREFIX_RM
;
4470 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
4471 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
4473 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
4474 return CMD_WARNING_CONFIG_FAILED
;
4477 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4478 bgp_node_safi(vty
), flag
);
4482 neighbor_capability_orf_prefix
,
4483 neighbor_capability_orf_prefix_hidden_cmd
,
4484 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
4485 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4486 "Advertise capability to the peer\n"
4487 "Advertise ORF capability to the peer\n"
4488 "Advertise prefixlist ORF capability to this neighbor\n"
4489 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
4490 "Capability to RECEIVE the ORF from this neighbor\n"
4491 "Capability to SEND the ORF to this neighbor\n")
4493 DEFUN (no_neighbor_capability_orf_prefix
,
4494 no_neighbor_capability_orf_prefix_cmd
,
4495 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
4499 "Advertise capability to the peer\n"
4500 "Advertise ORF capability to the peer\n"
4501 "Advertise prefixlist ORF capability to this neighbor\n"
4502 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
4503 "Capability to RECEIVE the ORF from this neighbor\n"
4504 "Capability to SEND the ORF to this neighbor\n")
4507 int idx_send_recv
= 6;
4510 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
4511 flag
= PEER_FLAG_ORF_PREFIX_SM
;
4512 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
4513 flag
= PEER_FLAG_ORF_PREFIX_RM
;
4514 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
4515 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
4517 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
4518 return CMD_WARNING_CONFIG_FAILED
;
4521 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4522 bgp_node_afi(vty
), bgp_node_safi(vty
),
4527 no_neighbor_capability_orf_prefix
,
4528 no_neighbor_capability_orf_prefix_hidden_cmd
,
4529 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
4530 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4531 "Advertise capability to the peer\n"
4532 "Advertise ORF capability to the peer\n"
4533 "Advertise prefixlist ORF capability to this neighbor\n"
4534 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
4535 "Capability to RECEIVE the ORF from this neighbor\n"
4536 "Capability to SEND the ORF to this neighbor\n")
4538 /* neighbor next-hop-self. */
4539 DEFUN (neighbor_nexthop_self
,
4540 neighbor_nexthop_self_cmd
,
4541 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4544 "Disable the next hop calculation for this neighbor\n")
4547 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4548 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
4551 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
4552 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4553 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4554 "Disable the next hop calculation for this neighbor\n")
4556 /* neighbor next-hop-self. */
4557 DEFUN (neighbor_nexthop_self_force
,
4558 neighbor_nexthop_self_force_cmd
,
4559 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4562 "Disable the next hop calculation for this neighbor\n"
4563 "Set the next hop to self for reflected routes\n")
4566 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4568 PEER_FLAG_FORCE_NEXTHOP_SELF
);
4571 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
4572 neighbor_nexthop_self_force_hidden_cmd
,
4573 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4574 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4575 "Disable the next hop calculation for this neighbor\n"
4576 "Set the next hop to self for reflected routes\n")
4578 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
4579 neighbor_nexthop_self_all_hidden_cmd
,
4580 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
4581 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4582 "Disable the next hop calculation for this neighbor\n"
4583 "Set the next hop to self for reflected routes\n")
4585 DEFUN (no_neighbor_nexthop_self
,
4586 no_neighbor_nexthop_self_cmd
,
4587 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4591 "Disable the next hop calculation for this neighbor\n")
4594 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4595 bgp_node_afi(vty
), bgp_node_safi(vty
),
4596 PEER_FLAG_NEXTHOP_SELF
);
4599 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
4600 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4601 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4602 "Disable the next hop calculation for this neighbor\n")
4604 DEFUN (no_neighbor_nexthop_self_force
,
4605 no_neighbor_nexthop_self_force_cmd
,
4606 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4610 "Disable the next hop calculation for this neighbor\n"
4611 "Set the next hop to self for reflected routes\n")
4614 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4615 bgp_node_afi(vty
), bgp_node_safi(vty
),
4616 PEER_FLAG_FORCE_NEXTHOP_SELF
);
4619 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4620 no_neighbor_nexthop_self_force_hidden_cmd
,
4621 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4622 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4623 "Disable the next hop calculation for this neighbor\n"
4624 "Set the next hop to self for reflected routes\n")
4626 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4627 no_neighbor_nexthop_self_all_hidden_cmd
,
4628 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
4629 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4630 "Disable the next hop calculation for this neighbor\n"
4631 "Set the next hop to self for reflected routes\n")
4633 /* neighbor as-override */
4634 DEFUN (neighbor_as_override
,
4635 neighbor_as_override_cmd
,
4636 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4639 "Override ASNs in outbound updates if aspath equals remote-as\n")
4642 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4643 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
4646 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
4647 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4648 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4649 "Override ASNs in outbound updates if aspath equals remote-as\n")
4651 DEFUN (no_neighbor_as_override
,
4652 no_neighbor_as_override_cmd
,
4653 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4657 "Override ASNs in outbound updates if aspath equals remote-as\n")
4660 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4661 bgp_node_afi(vty
), bgp_node_safi(vty
),
4662 PEER_FLAG_AS_OVERRIDE
);
4665 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
4666 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4667 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4668 "Override ASNs in outbound updates if aspath equals remote-as\n")
4670 /* neighbor remove-private-AS. */
4671 DEFUN (neighbor_remove_private_as
,
4672 neighbor_remove_private_as_cmd
,
4673 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4676 "Remove private ASNs in outbound updates\n")
4679 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4681 PEER_FLAG_REMOVE_PRIVATE_AS
);
4684 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
4685 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4686 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4687 "Remove private ASNs in outbound updates\n")
4689 DEFUN (neighbor_remove_private_as_all
,
4690 neighbor_remove_private_as_all_cmd
,
4691 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4694 "Remove private ASNs in outbound updates\n"
4695 "Apply to all AS numbers\n")
4698 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4700 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4703 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
4704 neighbor_remove_private_as_all_hidden_cmd
,
4705 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4706 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4707 "Remove private ASNs in outbound updates\n"
4708 "Apply to all AS numbers")
4710 DEFUN (neighbor_remove_private_as_replace_as
,
4711 neighbor_remove_private_as_replace_as_cmd
,
4712 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4715 "Remove private ASNs in outbound updates\n"
4716 "Replace private ASNs with our ASN in outbound updates\n")
4719 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4721 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4724 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
4725 neighbor_remove_private_as_replace_as_hidden_cmd
,
4726 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4727 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4728 "Remove private ASNs in outbound updates\n"
4729 "Replace private ASNs with our ASN in outbound updates\n")
4731 DEFUN (neighbor_remove_private_as_all_replace_as
,
4732 neighbor_remove_private_as_all_replace_as_cmd
,
4733 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4736 "Remove private ASNs in outbound updates\n"
4737 "Apply to all AS numbers\n"
4738 "Replace private ASNs with our ASN in outbound updates\n")
4741 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4743 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4747 neighbor_remove_private_as_all_replace_as
,
4748 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4749 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4750 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4751 "Remove private ASNs in outbound updates\n"
4752 "Apply to all AS numbers\n"
4753 "Replace private ASNs with our ASN in outbound updates\n")
4755 DEFUN (no_neighbor_remove_private_as
,
4756 no_neighbor_remove_private_as_cmd
,
4757 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4761 "Remove private ASNs in outbound updates\n")
4764 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4765 bgp_node_afi(vty
), bgp_node_safi(vty
),
4766 PEER_FLAG_REMOVE_PRIVATE_AS
);
4769 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4770 no_neighbor_remove_private_as_hidden_cmd
,
4771 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4772 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4773 "Remove private ASNs in outbound updates\n")
4775 DEFUN (no_neighbor_remove_private_as_all
,
4776 no_neighbor_remove_private_as_all_cmd
,
4777 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4781 "Remove private ASNs in outbound updates\n"
4782 "Apply to all AS numbers\n")
4785 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4786 bgp_node_afi(vty
), bgp_node_safi(vty
),
4787 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4790 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4791 no_neighbor_remove_private_as_all_hidden_cmd
,
4792 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4793 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4794 "Remove private ASNs in outbound updates\n"
4795 "Apply to all AS numbers\n")
4797 DEFUN (no_neighbor_remove_private_as_replace_as
,
4798 no_neighbor_remove_private_as_replace_as_cmd
,
4799 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4803 "Remove private ASNs in outbound updates\n"
4804 "Replace private ASNs with our ASN in outbound updates\n")
4807 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4808 bgp_node_afi(vty
), bgp_node_safi(vty
),
4809 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4812 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4813 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4814 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4815 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4816 "Remove private ASNs in outbound updates\n"
4817 "Replace private ASNs with our ASN in outbound updates\n")
4819 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4820 no_neighbor_remove_private_as_all_replace_as_cmd
,
4821 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4825 "Remove private ASNs in outbound updates\n"
4826 "Apply to all AS numbers\n"
4827 "Replace private ASNs with our ASN in outbound updates\n")
4830 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4831 bgp_node_afi(vty
), bgp_node_safi(vty
),
4832 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4836 no_neighbor_remove_private_as_all_replace_as
,
4837 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4838 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4839 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4840 "Remove private ASNs in outbound updates\n"
4841 "Apply to all AS numbers\n"
4842 "Replace private ASNs with our ASN in outbound updates\n")
4845 /* neighbor send-community. */
4846 DEFUN (neighbor_send_community
,
4847 neighbor_send_community_cmd
,
4848 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4851 "Send Community attribute to this neighbor\n")
4855 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4857 PEER_FLAG_SEND_COMMUNITY
);
4860 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4861 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4862 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4863 "Send Community attribute to this neighbor\n")
4865 DEFUN (no_neighbor_send_community
,
4866 no_neighbor_send_community_cmd
,
4867 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4871 "Send Community attribute to this neighbor\n")
4875 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4876 bgp_node_afi(vty
), bgp_node_safi(vty
),
4877 PEER_FLAG_SEND_COMMUNITY
);
4880 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4881 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4882 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4883 "Send Community attribute to this neighbor\n")
4885 /* neighbor send-community extended. */
4886 DEFUN (neighbor_send_community_type
,
4887 neighbor_send_community_type_cmd
,
4888 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4891 "Send Community attribute to this neighbor\n"
4892 "Send Standard and Extended Community attributes\n"
4893 "Send Standard, Large and Extended Community attributes\n"
4894 "Send Extended Community attributes\n"
4895 "Send Standard Community attributes\n"
4896 "Send Large Community attributes\n")
4900 const char *type
= argv
[argc
- 1]->text
;
4902 if (strmatch(type
, "standard")) {
4903 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4904 } else if (strmatch(type
, "extended")) {
4905 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4906 } else if (strmatch(type
, "large")) {
4907 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4908 } else if (strmatch(type
, "both")) {
4909 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4910 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4911 } else { /* if (strmatch(type, "all")) */
4912 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4913 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4914 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4917 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4918 bgp_node_safi(vty
), flag
);
4922 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4923 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4924 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4925 "Send Community attribute to this neighbor\n"
4926 "Send Standard and Extended Community attributes\n"
4927 "Send Standard, Large and Extended Community attributes\n"
4928 "Send Extended Community attributes\n"
4929 "Send Standard Community attributes\n"
4930 "Send Large Community attributes\n")
4932 DEFUN (no_neighbor_send_community_type
,
4933 no_neighbor_send_community_type_cmd
,
4934 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4938 "Send Community attribute to this neighbor\n"
4939 "Send Standard and Extended Community attributes\n"
4940 "Send Standard, Large and Extended Community attributes\n"
4941 "Send Extended Community attributes\n"
4942 "Send Standard Community attributes\n"
4943 "Send Large Community attributes\n")
4947 const char *type
= argv
[argc
- 1]->text
;
4949 if (strmatch(type
, "standard")) {
4950 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4951 } else if (strmatch(type
, "extended")) {
4952 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4953 } else if (strmatch(type
, "large")) {
4954 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4955 } else if (strmatch(type
, "both")) {
4956 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4957 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4958 } else { /* if (strmatch(type, "all")) */
4959 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4960 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4961 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4964 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4965 bgp_node_afi(vty
), bgp_node_safi(vty
),
4970 no_neighbor_send_community_type
,
4971 no_neighbor_send_community_type_hidden_cmd
,
4972 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4973 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4974 "Send Community attribute to this neighbor\n"
4975 "Send Standard and Extended Community attributes\n"
4976 "Send Standard, Large and Extended Community attributes\n"
4977 "Send Extended Community attributes\n"
4978 "Send Standard Community attributes\n"
4979 "Send Large Community attributes\n")
4981 /* neighbor soft-reconfig. */
4982 DEFUN (neighbor_soft_reconfiguration
,
4983 neighbor_soft_reconfiguration_cmd
,
4984 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4987 "Per neighbor soft reconfiguration\n"
4988 "Allow inbound soft reconfiguration for this neighbor\n")
4991 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4993 PEER_FLAG_SOFT_RECONFIG
);
4996 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4997 neighbor_soft_reconfiguration_hidden_cmd
,
4998 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4999 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5000 "Per neighbor soft reconfiguration\n"
5001 "Allow inbound soft reconfiguration for this neighbor\n")
5003 DEFUN (no_neighbor_soft_reconfiguration
,
5004 no_neighbor_soft_reconfiguration_cmd
,
5005 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5009 "Per neighbor soft reconfiguration\n"
5010 "Allow inbound soft reconfiguration for this neighbor\n")
5013 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5014 bgp_node_afi(vty
), bgp_node_safi(vty
),
5015 PEER_FLAG_SOFT_RECONFIG
);
5018 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
5019 no_neighbor_soft_reconfiguration_hidden_cmd
,
5020 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5021 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5022 "Per neighbor soft reconfiguration\n"
5023 "Allow inbound soft reconfiguration for this neighbor\n")
5025 DEFUN (neighbor_route_reflector_client
,
5026 neighbor_route_reflector_client_cmd
,
5027 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5030 "Configure a neighbor as Route Reflector client\n")
5036 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5038 return CMD_WARNING_CONFIG_FAILED
;
5040 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5042 PEER_FLAG_REFLECTOR_CLIENT
);
5045 ALIAS_HIDDEN(neighbor_route_reflector_client
,
5046 neighbor_route_reflector_client_hidden_cmd
,
5047 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5048 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5049 "Configure a neighbor as Route Reflector client\n")
5051 DEFUN (no_neighbor_route_reflector_client
,
5052 no_neighbor_route_reflector_client_cmd
,
5053 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5057 "Configure a neighbor as Route Reflector client\n")
5060 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5061 bgp_node_afi(vty
), bgp_node_safi(vty
),
5062 PEER_FLAG_REFLECTOR_CLIENT
);
5065 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
5066 no_neighbor_route_reflector_client_hidden_cmd
,
5067 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5068 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5069 "Configure a neighbor as Route Reflector client\n")
5071 /* neighbor route-server-client. */
5072 DEFUN (neighbor_route_server_client
,
5073 neighbor_route_server_client_cmd
,
5074 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5077 "Configure a neighbor as Route Server client\n")
5082 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5084 return CMD_WARNING_CONFIG_FAILED
;
5085 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5087 PEER_FLAG_RSERVER_CLIENT
);
5090 ALIAS_HIDDEN(neighbor_route_server_client
,
5091 neighbor_route_server_client_hidden_cmd
,
5092 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5093 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5094 "Configure a neighbor as Route Server client\n")
5096 DEFUN (no_neighbor_route_server_client
,
5097 no_neighbor_route_server_client_cmd
,
5098 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5102 "Configure a neighbor as Route Server client\n")
5105 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5106 bgp_node_afi(vty
), bgp_node_safi(vty
),
5107 PEER_FLAG_RSERVER_CLIENT
);
5110 ALIAS_HIDDEN(no_neighbor_route_server_client
,
5111 no_neighbor_route_server_client_hidden_cmd
,
5112 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5113 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5114 "Configure a neighbor as Route Server client\n")
5116 DEFUN (neighbor_nexthop_local_unchanged
,
5117 neighbor_nexthop_local_unchanged_cmd
,
5118 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
5121 "Configure treatment of outgoing link-local nexthop attribute\n"
5122 "Leave link-local nexthop unchanged for this peer\n")
5125 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5127 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
5130 DEFUN (no_neighbor_nexthop_local_unchanged
,
5131 no_neighbor_nexthop_local_unchanged_cmd
,
5132 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
5136 "Configure treatment of outgoing link-local-nexthop attribute\n"
5137 "Leave link-local nexthop unchanged for this peer\n")
5140 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5141 bgp_node_afi(vty
), bgp_node_safi(vty
),
5142 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
5145 DEFUN (neighbor_attr_unchanged
,
5146 neighbor_attr_unchanged_cmd
,
5147 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
5150 "BGP attribute is propagated unchanged to this neighbor\n"
5151 "As-path attribute\n"
5152 "Nexthop attribute\n"
5156 char *peer_str
= argv
[1]->arg
;
5159 afi_t afi
= bgp_node_afi(vty
);
5160 safi_t safi
= bgp_node_safi(vty
);
5162 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5164 return CMD_WARNING_CONFIG_FAILED
;
5166 if (argv_find(argv
, argc
, "as-path", &idx
))
5167 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
5169 if (argv_find(argv
, argc
, "next-hop", &idx
))
5170 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
5172 if (argv_find(argv
, argc
, "med", &idx
))
5173 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
5175 /* no flags means all of them! */
5177 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
5178 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
5179 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
5181 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
5182 && peer_af_flag_check(peer
, afi
, safi
,
5183 PEER_FLAG_AS_PATH_UNCHANGED
)) {
5184 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5185 PEER_FLAG_AS_PATH_UNCHANGED
);
5188 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
5189 && peer_af_flag_check(peer
, afi
, safi
,
5190 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
5191 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5192 PEER_FLAG_NEXTHOP_UNCHANGED
);
5195 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
5196 && peer_af_flag_check(peer
, afi
, safi
,
5197 PEER_FLAG_MED_UNCHANGED
)) {
5198 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5199 PEER_FLAG_MED_UNCHANGED
);
5203 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
5207 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
5208 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
5209 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5210 "BGP attribute is propagated unchanged to this neighbor\n"
5211 "As-path attribute\n"
5212 "Nexthop attribute\n"
5215 DEFUN (no_neighbor_attr_unchanged
,
5216 no_neighbor_attr_unchanged_cmd
,
5217 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
5221 "BGP attribute is propagated unchanged to this neighbor\n"
5222 "As-path attribute\n"
5223 "Nexthop attribute\n"
5227 char *peer
= argv
[2]->arg
;
5230 if (argv_find(argv
, argc
, "as-path", &idx
))
5231 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
5233 if (argv_find(argv
, argc
, "next-hop", &idx
))
5234 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
5236 if (argv_find(argv
, argc
, "med", &idx
))
5237 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
5239 if (!flags
) // no flags means all of them!
5241 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
5242 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
5243 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
5246 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
5247 bgp_node_safi(vty
), flags
);
5251 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
5252 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
5253 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5254 "BGP attribute is propagated unchanged to this neighbor\n"
5255 "As-path attribute\n"
5256 "Nexthop attribute\n"
5259 /* EBGP multihop configuration. */
5260 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
5261 const char *ttl_str
)
5266 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5268 return CMD_WARNING_CONFIG_FAILED
;
5271 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
5276 ttl
= strtoul(ttl_str
, NULL
, 10);
5278 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
5281 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
5285 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5287 return CMD_WARNING_CONFIG_FAILED
;
5289 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
5292 /* neighbor ebgp-multihop. */
5293 DEFUN (neighbor_ebgp_multihop
,
5294 neighbor_ebgp_multihop_cmd
,
5295 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
5298 "Allow EBGP neighbors not on directly connected networks\n")
5301 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5304 DEFUN (neighbor_ebgp_multihop_ttl
,
5305 neighbor_ebgp_multihop_ttl_cmd
,
5306 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
5309 "Allow EBGP neighbors not on directly connected networks\n"
5310 "maximum hop count\n")
5314 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
5315 argv
[idx_number
]->arg
);
5318 DEFUN (no_neighbor_ebgp_multihop
,
5319 no_neighbor_ebgp_multihop_cmd
,
5320 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
5324 "Allow EBGP neighbors not on directly connected networks\n"
5325 "maximum hop count\n")
5328 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
5332 /* disable-connected-check */
5333 DEFUN (neighbor_disable_connected_check
,
5334 neighbor_disable_connected_check_cmd
,
5335 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
5338 "one-hop away EBGP peer using loopback address\n"
5339 "Enforce EBGP neighbors perform multihop\n")
5342 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5343 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
5346 DEFUN (no_neighbor_disable_connected_check
,
5347 no_neighbor_disable_connected_check_cmd
,
5348 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
5352 "one-hop away EBGP peer using loopback address\n"
5353 "Enforce EBGP neighbors perform multihop\n")
5356 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5357 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
5361 /* enforce-first-as */
5362 DEFUN (neighbor_enforce_first_as
,
5363 neighbor_enforce_first_as_cmd
,
5364 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
5367 "Enforce the first AS for EBGP routes\n")
5371 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5372 PEER_FLAG_ENFORCE_FIRST_AS
);
5375 DEFUN (no_neighbor_enforce_first_as
,
5376 no_neighbor_enforce_first_as_cmd
,
5377 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
5381 "Enforce the first AS for EBGP routes\n")
5385 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5386 PEER_FLAG_ENFORCE_FIRST_AS
);
5390 DEFUN (neighbor_description
,
5391 neighbor_description_cmd
,
5392 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
5395 "Neighbor specific description\n"
5396 "Up to 80 characters describing this neighbor\n")
5403 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5405 return CMD_WARNING_CONFIG_FAILED
;
5407 str
= argv_concat(argv
, argc
, idx_line
);
5409 peer_description_set(peer
, str
);
5411 XFREE(MTYPE_TMP
, str
);
5416 DEFUN (no_neighbor_description
,
5417 no_neighbor_description_cmd
,
5418 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
5422 "Neighbor specific description\n")
5427 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5429 return CMD_WARNING_CONFIG_FAILED
;
5431 peer_description_unset(peer
);
5436 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
5437 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
5438 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5439 "Neighbor specific description\n"
5440 "Up to 80 characters describing this neighbor\n")
5442 /* Neighbor update-source. */
5443 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
5444 const char *source_str
)
5450 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5452 return CMD_WARNING_CONFIG_FAILED
;
5458 if (str2sockunion(source_str
, &su
) == 0)
5459 peer_update_source_addr_set(peer
, &su
);
5461 if (str2prefix(source_str
, &p
)) {
5463 "%% Invalid update-source, remove prefix length \n");
5464 return CMD_WARNING_CONFIG_FAILED
;
5466 peer_update_source_if_set(peer
, source_str
);
5469 peer_update_source_unset(peer
);
5474 #define BGP_UPDATE_SOURCE_HELP_STR \
5477 "Interface name (requires zebra to be running)\n"
5479 DEFUN (neighbor_update_source
,
5480 neighbor_update_source_cmd
,
5481 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
5484 "Source of routing updates\n"
5485 BGP_UPDATE_SOURCE_HELP_STR
)
5489 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
5490 argv
[idx_peer_2
]->arg
);
5493 DEFUN (no_neighbor_update_source
,
5494 no_neighbor_update_source_cmd
,
5495 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
5499 "Source of routing updates\n"
5500 BGP_UPDATE_SOURCE_HELP_STR
)
5503 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5506 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
5507 afi_t afi
, safi_t safi
,
5508 const char *rmap
, int set
)
5512 struct route_map
*route_map
= NULL
;
5514 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5516 return CMD_WARNING_CONFIG_FAILED
;
5520 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
5521 ret
= peer_default_originate_set(peer
, afi
, safi
,
5524 ret
= peer_default_originate_unset(peer
, afi
, safi
);
5526 return bgp_vty_return(vty
, ret
);
5529 /* neighbor default-originate. */
5530 DEFUN (neighbor_default_originate
,
5531 neighbor_default_originate_cmd
,
5532 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
5535 "Originate default route to this neighbor\n")
5538 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
5540 bgp_node_safi(vty
), NULL
, 1);
5543 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
5544 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
5545 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5546 "Originate default route to this neighbor\n")
5548 DEFUN (neighbor_default_originate_rmap
,
5549 neighbor_default_originate_rmap_cmd
,
5550 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
5553 "Originate default route to this neighbor\n"
5554 "Route-map to specify criteria to originate default\n"
5559 return peer_default_originate_set_vty(
5560 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5561 argv
[idx_word
]->arg
, 1);
5565 neighbor_default_originate_rmap
,
5566 neighbor_default_originate_rmap_hidden_cmd
,
5567 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
5568 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5569 "Originate default route to this neighbor\n"
5570 "Route-map to specify criteria to originate default\n"
5573 DEFUN (no_neighbor_default_originate
,
5574 no_neighbor_default_originate_cmd
,
5575 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
5579 "Originate default route to this neighbor\n"
5580 "Route-map to specify criteria to originate default\n"
5584 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
5586 bgp_node_safi(vty
), NULL
, 0);
5590 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
5591 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
5592 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5593 "Originate default route to this neighbor\n"
5594 "Route-map to specify criteria to originate default\n"
5598 /* Set neighbor's BGP port. */
5599 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
5600 const char *port_str
)
5606 peer
= peer_lookup_vty(vty
, ip_str
);
5608 return CMD_WARNING_CONFIG_FAILED
;
5611 sp
= getservbyname("bgp", "tcp");
5612 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
5614 port
= strtoul(port_str
, NULL
, 10);
5617 peer_port_set(peer
, port
);
5622 /* Set specified peer's BGP port. */
5623 DEFUN (neighbor_port
,
5625 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
5628 "Neighbor's BGP port\n"
5629 "TCP port number\n")
5633 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
5634 argv
[idx_number
]->arg
);
5637 DEFUN (no_neighbor_port
,
5638 no_neighbor_port_cmd
,
5639 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
5643 "Neighbor's BGP port\n"
5644 "TCP port number\n")
5647 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
5651 /* neighbor weight. */
5652 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5653 safi_t safi
, const char *weight_str
)
5657 unsigned long weight
;
5659 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5661 return CMD_WARNING_CONFIG_FAILED
;
5663 weight
= strtoul(weight_str
, NULL
, 10);
5665 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
5666 return bgp_vty_return(vty
, ret
);
5669 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5675 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5677 return CMD_WARNING_CONFIG_FAILED
;
5679 ret
= peer_weight_unset(peer
, afi
, safi
);
5680 return bgp_vty_return(vty
, ret
);
5683 DEFUN (neighbor_weight
,
5684 neighbor_weight_cmd
,
5685 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5688 "Set default weight for routes from this neighbor\n"
5693 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5694 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
5697 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
5698 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5699 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5700 "Set default weight for routes from this neighbor\n"
5703 DEFUN (no_neighbor_weight
,
5704 no_neighbor_weight_cmd
,
5705 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5709 "Set default weight for routes from this neighbor\n"
5713 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
5714 bgp_node_afi(vty
), bgp_node_safi(vty
));
5717 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
5718 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5719 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5720 "Set default weight for routes from this neighbor\n"
5724 /* Override capability negotiation. */
5725 DEFUN (neighbor_override_capability
,
5726 neighbor_override_capability_cmd
,
5727 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5730 "Override capability negotiation result\n")
5733 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5734 PEER_FLAG_OVERRIDE_CAPABILITY
);
5737 DEFUN (no_neighbor_override_capability
,
5738 no_neighbor_override_capability_cmd
,
5739 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5743 "Override capability negotiation result\n")
5746 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5747 PEER_FLAG_OVERRIDE_CAPABILITY
);
5750 DEFUN (neighbor_strict_capability
,
5751 neighbor_strict_capability_cmd
,
5752 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5755 "Strict capability negotiation match\n")
5759 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5760 PEER_FLAG_STRICT_CAP_MATCH
);
5763 DEFUN (no_neighbor_strict_capability
,
5764 no_neighbor_strict_capability_cmd
,
5765 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5769 "Strict capability negotiation match\n")
5773 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5774 PEER_FLAG_STRICT_CAP_MATCH
);
5777 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5778 const char *keep_str
, const char *hold_str
)
5785 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5787 return CMD_WARNING_CONFIG_FAILED
;
5789 keepalive
= strtoul(keep_str
, NULL
, 10);
5790 holdtime
= strtoul(hold_str
, NULL
, 10);
5792 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5794 return bgp_vty_return(vty
, ret
);
5797 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5802 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5804 return CMD_WARNING_CONFIG_FAILED
;
5806 ret
= peer_timers_unset(peer
);
5808 return bgp_vty_return(vty
, ret
);
5811 DEFUN (neighbor_timers
,
5812 neighbor_timers_cmd
,
5813 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5816 "BGP per neighbor timers\n"
5817 "Keepalive interval\n"
5822 int idx_number_2
= 4;
5823 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5824 argv
[idx_number
]->arg
,
5825 argv
[idx_number_2
]->arg
);
5828 DEFUN (no_neighbor_timers
,
5829 no_neighbor_timers_cmd
,
5830 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5834 "BGP per neighbor timers\n"
5835 "Keepalive interval\n"
5839 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5843 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5844 const char *time_str
)
5850 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5852 return CMD_WARNING_CONFIG_FAILED
;
5854 connect
= strtoul(time_str
, NULL
, 10);
5856 ret
= peer_timers_connect_set(peer
, connect
);
5858 return bgp_vty_return(vty
, ret
);
5861 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5866 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5868 return CMD_WARNING_CONFIG_FAILED
;
5870 ret
= peer_timers_connect_unset(peer
);
5872 return bgp_vty_return(vty
, ret
);
5875 DEFUN (neighbor_timers_connect
,
5876 neighbor_timers_connect_cmd
,
5877 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5880 "BGP per neighbor timers\n"
5881 "BGP connect timer\n"
5886 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5887 argv
[idx_number
]->arg
);
5890 DEFUN (no_neighbor_timers_connect
,
5891 no_neighbor_timers_connect_cmd
,
5892 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5896 "BGP per neighbor timers\n"
5897 "BGP connect timer\n"
5901 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5905 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5906 const char *time_str
, int set
)
5910 uint32_t routeadv
= 0;
5912 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5914 return CMD_WARNING_CONFIG_FAILED
;
5917 routeadv
= strtoul(time_str
, NULL
, 10);
5920 ret
= peer_advertise_interval_set(peer
, routeadv
);
5922 ret
= peer_advertise_interval_unset(peer
);
5924 return bgp_vty_return(vty
, ret
);
5927 DEFUN (neighbor_advertise_interval
,
5928 neighbor_advertise_interval_cmd
,
5929 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5932 "Minimum interval between sending BGP routing updates\n"
5933 "time in seconds\n")
5937 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5938 argv
[idx_number
]->arg
, 1);
5941 DEFUN (no_neighbor_advertise_interval
,
5942 no_neighbor_advertise_interval_cmd
,
5943 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5947 "Minimum interval between sending BGP routing updates\n"
5948 "time in seconds\n")
5951 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5955 /* Time to wait before processing route-map updates */
5956 DEFUN (bgp_set_route_map_delay_timer
,
5957 bgp_set_route_map_delay_timer_cmd
,
5958 "bgp route-map delay-timer (0-600)",
5960 "BGP route-map delay timer\n"
5961 "Time in secs to wait before processing route-map changes\n"
5962 "0 disables the timer, no route updates happen when route-maps change\n")
5965 uint32_t rmap_delay_timer
;
5967 if (argv
[idx_number
]->arg
) {
5968 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5969 bm
->rmap_update_timer
= rmap_delay_timer
;
5971 /* if the dynamic update handling is being disabled, and a timer
5973 * running, stop the timer and act as if the timer has already
5976 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5977 BGP_TIMER_OFF(bm
->t_rmap_update
);
5978 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5983 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5984 return CMD_WARNING_CONFIG_FAILED
;
5988 DEFUN (no_bgp_set_route_map_delay_timer
,
5989 no_bgp_set_route_map_delay_timer_cmd
,
5990 "no bgp route-map delay-timer [(0-600)]",
5993 "Default BGP route-map delay timer\n"
5994 "Reset to default time to wait for processing route-map changes\n"
5995 "0 disables the timer, no route updates happen when route-maps change\n")
5998 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
6004 /* neighbor interface */
6005 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
6010 peer
= peer_lookup_vty(vty
, ip_str
);
6011 if (!peer
|| peer
->conf_if
) {
6012 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
6013 return CMD_WARNING_CONFIG_FAILED
;
6017 peer_interface_set(peer
, str
);
6019 peer_interface_unset(peer
);
6024 DEFUN (neighbor_interface
,
6025 neighbor_interface_cmd
,
6026 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
6034 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
6037 DEFUN (no_neighbor_interface
,
6038 no_neighbor_interface_cmd
,
6039 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
6047 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6050 DEFUN (neighbor_distribute_list
,
6051 neighbor_distribute_list_cmd
,
6052 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
6055 "Filter updates to/from this neighbor\n"
6056 "IP access-list number\n"
6057 "IP access-list number (expanded range)\n"
6058 "IP Access-list name\n"
6059 "Filter incoming updates\n"
6060 "Filter outgoing updates\n")
6067 const char *pstr
= argv
[idx_peer
]->arg
;
6068 const char *acl
= argv
[idx_acl
]->arg
;
6069 const char *inout
= argv
[argc
- 1]->text
;
6071 peer
= peer_and_group_lookup_vty(vty
, pstr
);
6073 return CMD_WARNING_CONFIG_FAILED
;
6075 /* Check filter direction. */
6076 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
6077 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6080 return bgp_vty_return(vty
, ret
);
6084 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
6085 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
6086 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6087 "Filter updates to/from this neighbor\n"
6088 "IP access-list number\n"
6089 "IP access-list number (expanded range)\n"
6090 "IP Access-list name\n"
6091 "Filter incoming updates\n"
6092 "Filter outgoing updates\n")
6094 DEFUN (no_neighbor_distribute_list
,
6095 no_neighbor_distribute_list_cmd
,
6096 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
6100 "Filter updates to/from this neighbor\n"
6101 "IP access-list number\n"
6102 "IP access-list number (expanded range)\n"
6103 "IP Access-list name\n"
6104 "Filter incoming updates\n"
6105 "Filter outgoing updates\n")
6111 const char *pstr
= argv
[idx_peer
]->arg
;
6112 const char *inout
= argv
[argc
- 1]->text
;
6114 peer
= peer_and_group_lookup_vty(vty
, pstr
);
6116 return CMD_WARNING_CONFIG_FAILED
;
6118 /* Check filter direction. */
6119 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
6120 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6123 return bgp_vty_return(vty
, ret
);
6127 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
6128 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
6129 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6130 "Filter updates to/from this neighbor\n"
6131 "IP access-list number\n"
6132 "IP access-list number (expanded range)\n"
6133 "IP Access-list name\n"
6134 "Filter incoming updates\n"
6135 "Filter outgoing updates\n")
6137 /* Set prefix list to the peer. */
6138 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
6139 afi_t afi
, safi_t safi
,
6140 const char *name_str
,
6141 const char *direct_str
)
6144 int direct
= FILTER_IN
;
6147 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6149 return CMD_WARNING_CONFIG_FAILED
;
6151 /* Check filter direction. */
6152 if (strncmp(direct_str
, "i", 1) == 0)
6154 else if (strncmp(direct_str
, "o", 1) == 0)
6155 direct
= FILTER_OUT
;
6157 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
6159 return bgp_vty_return(vty
, ret
);
6162 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
6163 afi_t afi
, safi_t safi
,
6164 const char *direct_str
)
6168 int direct
= FILTER_IN
;
6170 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6172 return CMD_WARNING_CONFIG_FAILED
;
6174 /* Check filter direction. */
6175 if (strncmp(direct_str
, "i", 1) == 0)
6177 else if (strncmp(direct_str
, "o", 1) == 0)
6178 direct
= FILTER_OUT
;
6180 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
6182 return bgp_vty_return(vty
, ret
);
6185 DEFUN (neighbor_prefix_list
,
6186 neighbor_prefix_list_cmd
,
6187 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
6190 "Filter updates to/from this neighbor\n"
6191 "Name of a prefix list\n"
6192 "Filter incoming updates\n"
6193 "Filter outgoing updates\n")
6198 return peer_prefix_list_set_vty(
6199 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6200 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
6203 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
6204 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
6205 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6206 "Filter updates to/from this neighbor\n"
6207 "Name of a prefix list\n"
6208 "Filter incoming updates\n"
6209 "Filter outgoing updates\n")
6211 DEFUN (no_neighbor_prefix_list
,
6212 no_neighbor_prefix_list_cmd
,
6213 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
6217 "Filter updates to/from this neighbor\n"
6218 "Name of a prefix list\n"
6219 "Filter incoming updates\n"
6220 "Filter outgoing updates\n")
6224 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
6225 bgp_node_afi(vty
), bgp_node_safi(vty
),
6226 argv
[idx_in_out
]->arg
);
6229 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
6230 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
6231 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6232 "Filter updates to/from this neighbor\n"
6233 "Name of a prefix list\n"
6234 "Filter incoming updates\n"
6235 "Filter outgoing updates\n")
6237 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6238 safi_t safi
, const char *name_str
,
6239 const char *direct_str
)
6243 int direct
= FILTER_IN
;
6245 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6247 return CMD_WARNING_CONFIG_FAILED
;
6249 /* Check filter direction. */
6250 if (strncmp(direct_str
, "i", 1) == 0)
6252 else if (strncmp(direct_str
, "o", 1) == 0)
6253 direct
= FILTER_OUT
;
6255 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
6257 return bgp_vty_return(vty
, ret
);
6260 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6261 safi_t safi
, const char *direct_str
)
6265 int direct
= FILTER_IN
;
6267 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6269 return CMD_WARNING_CONFIG_FAILED
;
6271 /* Check filter direction. */
6272 if (strncmp(direct_str
, "i", 1) == 0)
6274 else if (strncmp(direct_str
, "o", 1) == 0)
6275 direct
= FILTER_OUT
;
6277 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
6279 return bgp_vty_return(vty
, ret
);
6282 DEFUN (neighbor_filter_list
,
6283 neighbor_filter_list_cmd
,
6284 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
6287 "Establish BGP filters\n"
6288 "AS path access-list name\n"
6289 "Filter incoming routes\n"
6290 "Filter outgoing routes\n")
6295 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6296 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
6297 argv
[idx_in_out
]->arg
);
6300 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
6301 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
6302 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6303 "Establish BGP filters\n"
6304 "AS path access-list name\n"
6305 "Filter incoming routes\n"
6306 "Filter outgoing routes\n")
6308 DEFUN (no_neighbor_filter_list
,
6309 no_neighbor_filter_list_cmd
,
6310 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
6314 "Establish BGP filters\n"
6315 "AS path access-list name\n"
6316 "Filter incoming routes\n"
6317 "Filter outgoing routes\n")
6321 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
6322 bgp_node_afi(vty
), bgp_node_safi(vty
),
6323 argv
[idx_in_out
]->arg
);
6326 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
6327 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
6328 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6329 "Establish BGP filters\n"
6330 "AS path access-list name\n"
6331 "Filter incoming routes\n"
6332 "Filter outgoing routes\n")
6334 /* Set route-map to the peer. */
6335 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
6336 afi_t afi
, safi_t safi
, const char *name_str
,
6337 const char *direct_str
)
6341 int direct
= RMAP_IN
;
6342 struct route_map
*route_map
;
6344 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6346 return CMD_WARNING_CONFIG_FAILED
;
6348 /* Check filter direction. */
6349 if (strncmp(direct_str
, "in", 2) == 0)
6351 else if (strncmp(direct_str
, "o", 1) == 0)
6354 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
6355 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
6357 return bgp_vty_return(vty
, ret
);
6360 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
6361 afi_t afi
, safi_t safi
,
6362 const char *direct_str
)
6366 int direct
= RMAP_IN
;
6368 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6370 return CMD_WARNING_CONFIG_FAILED
;
6372 /* Check filter direction. */
6373 if (strncmp(direct_str
, "in", 2) == 0)
6375 else if (strncmp(direct_str
, "o", 1) == 0)
6378 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
6380 return bgp_vty_return(vty
, ret
);
6383 DEFUN (neighbor_route_map
,
6384 neighbor_route_map_cmd
,
6385 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
6388 "Apply route map to neighbor\n"
6389 "Name of route map\n"
6390 "Apply map to incoming routes\n"
6391 "Apply map to outbound routes\n")
6396 return peer_route_map_set_vty(
6397 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6398 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
6401 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
6402 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
6403 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6404 "Apply route map to neighbor\n"
6405 "Name of route map\n"
6406 "Apply map to incoming routes\n"
6407 "Apply map to outbound routes\n")
6409 DEFUN (no_neighbor_route_map
,
6410 no_neighbor_route_map_cmd
,
6411 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
6415 "Apply route map to neighbor\n"
6416 "Name of route map\n"
6417 "Apply map to incoming routes\n"
6418 "Apply map to outbound routes\n")
6422 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
6423 bgp_node_afi(vty
), bgp_node_safi(vty
),
6424 argv
[idx_in_out
]->arg
);
6427 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
6428 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
6429 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6430 "Apply route map to neighbor\n"
6431 "Name of route map\n"
6432 "Apply map to incoming routes\n"
6433 "Apply map to outbound routes\n")
6435 /* Set unsuppress-map to the peer. */
6436 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
6437 afi_t afi
, safi_t safi
,
6438 const char *name_str
)
6442 struct route_map
*route_map
;
6444 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6446 return CMD_WARNING_CONFIG_FAILED
;
6448 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
6449 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
6451 return bgp_vty_return(vty
, ret
);
6454 /* Unset route-map from the peer. */
6455 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
6456 afi_t afi
, safi_t safi
)
6461 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6463 return CMD_WARNING_CONFIG_FAILED
;
6465 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
6467 return bgp_vty_return(vty
, ret
);
6470 DEFUN (neighbor_unsuppress_map
,
6471 neighbor_unsuppress_map_cmd
,
6472 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
6475 "Route-map to selectively unsuppress suppressed routes\n"
6476 "Name of route map\n")
6480 return peer_unsuppress_map_set_vty(
6481 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6482 argv
[idx_word
]->arg
);
6485 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
6486 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
6487 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6488 "Route-map to selectively unsuppress suppressed routes\n"
6489 "Name of route map\n")
6491 DEFUN (no_neighbor_unsuppress_map
,
6492 no_neighbor_unsuppress_map_cmd
,
6493 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
6497 "Route-map to selectively unsuppress suppressed routes\n"
6498 "Name of route map\n")
6501 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
6503 bgp_node_safi(vty
));
6506 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
6507 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
6508 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6509 "Route-map to selectively unsuppress suppressed routes\n"
6510 "Name of route map\n")
6512 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
6513 afi_t afi
, safi_t safi
,
6514 const char *num_str
,
6515 const char *threshold_str
, int warning
,
6516 const char *restart_str
)
6524 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6526 return CMD_WARNING_CONFIG_FAILED
;
6528 max
= strtoul(num_str
, NULL
, 10);
6530 threshold
= atoi(threshold_str
);
6532 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
6535 restart
= atoi(restart_str
);
6539 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
6542 return bgp_vty_return(vty
, ret
);
6545 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
6546 afi_t afi
, safi_t safi
)
6551 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6553 return CMD_WARNING_CONFIG_FAILED
;
6555 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
6557 return bgp_vty_return(vty
, ret
);
6560 /* Maximum number of prefix to be sent to the neighbor. */
6561 DEFUN(neighbor_maximum_prefix_out
,
6562 neighbor_maximum_prefix_out_cmd
,
6563 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
6566 "Maximum number of prefixes to be sent to this peer\n"
6567 "Maximum no. of prefix limit\n")
6573 afi_t afi
= bgp_node_afi(vty
);
6574 safi_t safi
= bgp_node_safi(vty
);
6576 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6578 return CMD_WARNING_CONFIG_FAILED
;
6580 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6582 SET_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
);
6583 peer
->pmax_out
[afi
][safi
] = max
;
6588 DEFUN(no_neighbor_maximum_prefix_out
,
6589 no_neighbor_maximum_prefix_out_cmd
,
6590 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out",
6594 "Maximum number of prefixes to be sent to this peer\n")
6598 afi_t afi
= bgp_node_afi(vty
);
6599 safi_t safi
= bgp_node_safi(vty
);
6601 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6603 return CMD_WARNING_CONFIG_FAILED
;
6605 peer
->pmax_out
[afi
][safi
] = 0;
6610 /* Maximum number of prefix configuration. prefix count is different
6611 for each peer configuration. So this configuration can be set for
6612 each peer configuration. */
6613 DEFUN (neighbor_maximum_prefix
,
6614 neighbor_maximum_prefix_cmd
,
6615 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
6618 "Maximum number of prefix accept from this peer\n"
6619 "maximum no. of prefix limit\n")
6623 return peer_maximum_prefix_set_vty(
6624 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6625 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
6628 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
6629 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
6630 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6631 "Maximum number of prefix accept from this peer\n"
6632 "maximum no. of prefix limit\n")
6634 DEFUN (neighbor_maximum_prefix_threshold
,
6635 neighbor_maximum_prefix_threshold_cmd
,
6636 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
6639 "Maximum number of prefix accept from this peer\n"
6640 "maximum no. of prefix limit\n"
6641 "Threshold value (%) at which to generate a warning msg\n")
6645 int idx_number_2
= 4;
6646 return peer_maximum_prefix_set_vty(
6647 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6648 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
6652 neighbor_maximum_prefix_threshold
,
6653 neighbor_maximum_prefix_threshold_hidden_cmd
,
6654 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
6655 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6656 "Maximum number of prefix accept from this peer\n"
6657 "maximum no. of prefix limit\n"
6658 "Threshold value (%) at which to generate a warning msg\n")
6660 DEFUN (neighbor_maximum_prefix_warning
,
6661 neighbor_maximum_prefix_warning_cmd
,
6662 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6665 "Maximum number of prefix accept from this peer\n"
6666 "maximum no. of prefix limit\n"
6667 "Only give warning message when limit is exceeded\n")
6671 return peer_maximum_prefix_set_vty(
6672 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6673 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
6677 neighbor_maximum_prefix_warning
,
6678 neighbor_maximum_prefix_warning_hidden_cmd
,
6679 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6680 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6681 "Maximum number of prefix accept from this peer\n"
6682 "maximum no. of prefix limit\n"
6683 "Only give warning message when limit is exceeded\n")
6685 DEFUN (neighbor_maximum_prefix_threshold_warning
,
6686 neighbor_maximum_prefix_threshold_warning_cmd
,
6687 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6690 "Maximum number of prefix accept from this peer\n"
6691 "maximum no. of prefix limit\n"
6692 "Threshold value (%) at which to generate a warning msg\n"
6693 "Only give warning message when limit is exceeded\n")
6697 int idx_number_2
= 4;
6698 return peer_maximum_prefix_set_vty(
6699 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6700 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
6704 neighbor_maximum_prefix_threshold_warning
,
6705 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
6706 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6707 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6708 "Maximum number of prefix accept from this peer\n"
6709 "maximum no. of prefix limit\n"
6710 "Threshold value (%) at which to generate a warning msg\n"
6711 "Only give warning message when limit is exceeded\n")
6713 DEFUN (neighbor_maximum_prefix_restart
,
6714 neighbor_maximum_prefix_restart_cmd
,
6715 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6718 "Maximum number of prefix accept from this peer\n"
6719 "maximum no. of prefix limit\n"
6720 "Restart bgp connection after limit is exceeded\n"
6721 "Restart interval in minutes\n")
6725 int idx_number_2
= 5;
6726 return peer_maximum_prefix_set_vty(
6727 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6728 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
6732 neighbor_maximum_prefix_restart
,
6733 neighbor_maximum_prefix_restart_hidden_cmd
,
6734 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6735 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6736 "Maximum number of prefix accept from this peer\n"
6737 "maximum no. of prefix limit\n"
6738 "Restart bgp connection after limit is exceeded\n"
6739 "Restart interval in minutes\n")
6741 DEFUN (neighbor_maximum_prefix_threshold_restart
,
6742 neighbor_maximum_prefix_threshold_restart_cmd
,
6743 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6746 "Maximum number of prefixes to accept from this peer\n"
6747 "maximum no. of prefix limit\n"
6748 "Threshold value (%) at which to generate a warning msg\n"
6749 "Restart bgp connection after limit is exceeded\n"
6750 "Restart interval in minutes\n")
6754 int idx_number_2
= 4;
6755 int idx_number_3
= 6;
6756 return peer_maximum_prefix_set_vty(
6757 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6758 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
6759 argv
[idx_number_3
]->arg
);
6763 neighbor_maximum_prefix_threshold_restart
,
6764 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
6765 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6766 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6767 "Maximum number of prefixes to accept from this peer\n"
6768 "maximum no. of prefix limit\n"
6769 "Threshold value (%) at which to generate a warning msg\n"
6770 "Restart bgp connection after limit is exceeded\n"
6771 "Restart interval in minutes\n")
6773 DEFUN (no_neighbor_maximum_prefix
,
6774 no_neighbor_maximum_prefix_cmd
,
6775 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6779 "Maximum number of prefixes to accept from this peer\n"
6780 "maximum no. of prefix limit\n"
6781 "Threshold value (%) at which to generate a warning msg\n"
6782 "Restart bgp connection after limit is exceeded\n"
6783 "Restart interval in minutes\n"
6784 "Only give warning message when limit is exceeded\n")
6787 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
6789 bgp_node_safi(vty
));
6793 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
6794 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6795 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6796 "Maximum number of prefixes to accept from this peer\n"
6797 "maximum no. of prefix limit\n"
6798 "Threshold value (%) at which to generate a warning msg\n"
6799 "Restart bgp connection after limit is exceeded\n"
6800 "Restart interval in minutes\n"
6801 "Only give warning message when limit is exceeded\n")
6804 /* "neighbor allowas-in" */
6805 DEFUN (neighbor_allowas_in
,
6806 neighbor_allowas_in_cmd
,
6807 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6810 "Accept as-path with my AS present in it\n"
6811 "Number of occurrences of AS number\n"
6812 "Only accept my AS in the as-path if the route was originated in my AS\n")
6815 int idx_number_origin
= 3;
6821 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6823 return CMD_WARNING_CONFIG_FAILED
;
6825 if (argc
<= idx_number_origin
)
6828 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6831 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6834 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6837 return bgp_vty_return(vty
, ret
);
6841 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6842 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6843 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6844 "Accept as-path with my AS present in it\n"
6845 "Number of occurrences of AS number\n"
6846 "Only accept my AS in the as-path if the route was originated in my AS\n")
6848 DEFUN (no_neighbor_allowas_in
,
6849 no_neighbor_allowas_in_cmd
,
6850 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6854 "allow local ASN appears in aspath attribute\n"
6855 "Number of occurrences of AS number\n"
6856 "Only accept my AS in the as-path if the route was originated in my AS\n")
6862 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6864 return CMD_WARNING_CONFIG_FAILED
;
6866 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6867 bgp_node_safi(vty
));
6869 return bgp_vty_return(vty
, ret
);
6873 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6874 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6875 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6876 "allow local ASN appears in aspath attribute\n"
6877 "Number of occurrences of AS number\n"
6878 "Only accept my AS in the as-path if the route was originated in my AS\n")
6880 DEFUN (neighbor_ttl_security
,
6881 neighbor_ttl_security_cmd
,
6882 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6885 "BGP ttl-security parameters\n"
6886 "Specify the maximum number of hops to the BGP peer\n"
6887 "Number of hops to BGP peer\n")
6894 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6896 return CMD_WARNING_CONFIG_FAILED
;
6898 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6901 * If 'neighbor swpX', then this is for directly connected peers,
6902 * we should not accept a ttl-security hops value greater than 1.
6904 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
6906 "%s is directly connected peer, hops cannot exceed 1\n",
6907 argv
[idx_peer
]->arg
);
6908 return CMD_WARNING_CONFIG_FAILED
;
6911 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6914 DEFUN (no_neighbor_ttl_security
,
6915 no_neighbor_ttl_security_cmd
,
6916 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6920 "BGP ttl-security parameters\n"
6921 "Specify the maximum number of hops to the BGP peer\n"
6922 "Number of hops to BGP peer\n")
6927 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6929 return CMD_WARNING_CONFIG_FAILED
;
6931 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6934 DEFUN (neighbor_addpath_tx_all_paths
,
6935 neighbor_addpath_tx_all_paths_cmd
,
6936 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6939 "Use addpath to advertise all paths to a neighbor\n")
6944 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6946 return CMD_WARNING_CONFIG_FAILED
;
6948 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6953 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6954 neighbor_addpath_tx_all_paths_hidden_cmd
,
6955 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6956 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6957 "Use addpath to advertise all paths to a neighbor\n")
6959 DEFUN (no_neighbor_addpath_tx_all_paths
,
6960 no_neighbor_addpath_tx_all_paths_cmd
,
6961 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6965 "Use addpath to advertise all paths to a neighbor\n")
6970 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6972 return CMD_WARNING_CONFIG_FAILED
;
6974 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6975 != BGP_ADDPATH_ALL
) {
6977 "%% Peer not currently configured to transmit all paths.");
6978 return CMD_WARNING_CONFIG_FAILED
;
6981 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6987 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6988 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6989 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6990 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6991 "Use addpath to advertise all paths to a neighbor\n")
6993 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6994 neighbor_addpath_tx_bestpath_per_as_cmd
,
6995 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6998 "Use addpath to advertise the bestpath per each neighboring AS\n")
7003 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7005 return CMD_WARNING_CONFIG_FAILED
;
7007 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7008 BGP_ADDPATH_BEST_PER_AS
);
7013 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
7014 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
7015 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
7016 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7017 "Use addpath to advertise the bestpath per each neighboring AS\n")
7019 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
7020 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
7021 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
7025 "Use addpath to advertise the bestpath per each neighboring AS\n")
7030 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7032 return CMD_WARNING_CONFIG_FAILED
;
7034 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
7035 != BGP_ADDPATH_BEST_PER_AS
) {
7037 "%% Peer not currently configured to transmit all best path per as.");
7038 return CMD_WARNING_CONFIG_FAILED
;
7041 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7047 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
7048 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
7049 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
7050 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7051 "Use addpath to advertise the bestpath per each neighboring AS\n")
7054 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
7055 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
7058 "Detect AS loops before sending to neighbor\n")
7062 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7064 return CMD_WARNING_CONFIG_FAILED
;
7066 peer
->as_path_loop_detection
= true;
7072 no_neighbor_aspath_loop_detection
,
7073 no_neighbor_aspath_loop_detection_cmd
,
7074 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
7078 "Detect AS loops before sending to neighbor\n")
7082 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7084 return CMD_WARNING_CONFIG_FAILED
;
7086 peer
->as_path_loop_detection
= false;
7091 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
7092 struct ecommunity
**list
)
7094 struct ecommunity
*ecom
= NULL
;
7095 struct ecommunity
*ecomadd
;
7097 for (; argc
; --argc
, ++argv
) {
7099 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
7100 ECOMMUNITY_ROUTE_TARGET
, 0);
7102 vty_out(vty
, "Malformed community-list value\n");
7104 ecommunity_free(&ecom
);
7105 return CMD_WARNING_CONFIG_FAILED
;
7109 ecommunity_merge(ecom
, ecomadd
);
7110 ecommunity_free(&ecomadd
);
7117 ecommunity_free(&*list
);
7125 * v2vimport is true if we are handling a `import vrf ...` command
7127 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
7131 switch (vty
->node
) {
7140 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
7145 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
7146 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
7147 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
7148 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
7150 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
7154 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
7155 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
7156 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
7157 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
7159 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
7166 DEFPY (af_rd_vpn_export
,
7167 af_rd_vpn_export_cmd
,
7168 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
7170 "Specify route distinguisher\n"
7171 "Between current address-family and vpn\n"
7172 "For routes leaked from current address-family to vpn\n"
7173 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
7175 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7176 struct prefix_rd prd
;
7182 if (argv_find(argv
, argc
, "no", &idx
))
7186 ret
= str2prefix_rd(rd_str
, &prd
);
7188 vty_out(vty
, "%% Malformed rd\n");
7189 return CMD_WARNING_CONFIG_FAILED
;
7193 afi
= vpn_policy_getafi(vty
, bgp
, false);
7195 return CMD_WARNING_CONFIG_FAILED
;
7198 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
7200 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
7201 bgp_get_default(), bgp
);
7204 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
7205 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
7206 BGP_VPN_POLICY_TOVPN_RD_SET
);
7208 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
7209 BGP_VPN_POLICY_TOVPN_RD_SET
);
7212 /* post-change: re-export vpn routes */
7213 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
7214 bgp_get_default(), bgp
);
7219 ALIAS (af_rd_vpn_export
,
7220 af_no_rd_vpn_export_cmd
,
7223 "Specify route distinguisher\n"
7224 "Between current address-family and vpn\n"
7225 "For routes leaked from current address-family to vpn\n")
7227 DEFPY (af_label_vpn_export
,
7228 af_label_vpn_export_cmd
,
7229 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
7231 "label value for VRF\n"
7232 "Between current address-family and vpn\n"
7233 "For routes leaked from current address-family to vpn\n"
7234 "Label Value <0-1048575>\n"
7235 "Automatically assign a label\n")
7237 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7238 mpls_label_t label
= MPLS_LABEL_NONE
;
7243 if (argv_find(argv
, argc
, "no", &idx
))
7246 /* If "no ...", squash trailing parameter */
7252 label
= label_val
; /* parser should force unsigned */
7255 afi
= vpn_policy_getafi(vty
, bgp
, false);
7257 return CMD_WARNING_CONFIG_FAILED
;
7260 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
7261 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
7266 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
7268 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
7269 bgp_get_default(), bgp
);
7271 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
7272 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
7274 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
7277 * label has previously been automatically
7278 * assigned by labelpool: release it
7280 * NB if tovpn_label == MPLS_LABEL_NONE it
7281 * means the automatic assignment is in flight
7282 * and therefore the labelpool callback must
7283 * detect that the auto label is not needed.
7286 bgp_lp_release(LP_TYPE_VRF
,
7287 &bgp
->vpn_policy
[afi
],
7288 bgp
->vpn_policy
[afi
].tovpn_label
);
7290 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
7291 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
7294 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
7296 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
7297 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
7298 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
7299 vpn_leak_label_callback
);
7302 /* post-change: re-export vpn routes */
7303 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
7304 bgp_get_default(), bgp
);
7309 ALIAS (af_label_vpn_export
,
7310 af_no_label_vpn_export_cmd
,
7311 "no label vpn export",
7313 "label value for VRF\n"
7314 "Between current address-family and vpn\n"
7315 "For routes leaked from current address-family to vpn\n")
7317 DEFPY (af_nexthop_vpn_export
,
7318 af_nexthop_vpn_export_cmd
,
7319 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
7321 "Specify next hop to use for VRF advertised prefixes\n"
7322 "Between current address-family and vpn\n"
7323 "For routes leaked from current address-family to vpn\n"
7327 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7333 if (argv_find(argv
, argc
, "no", &idx
))
7337 if (!sockunion2hostprefix(nexthop_str
, &p
))
7338 return CMD_WARNING_CONFIG_FAILED
;
7341 afi
= vpn_policy_getafi(vty
, bgp
, false);
7343 return CMD_WARNING_CONFIG_FAILED
;
7346 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
7348 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
7349 bgp_get_default(), bgp
);
7352 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
7353 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
7354 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
7356 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
7357 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
7360 /* post-change: re-export vpn routes */
7361 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
7362 bgp_get_default(), bgp
);
7367 ALIAS (af_nexthop_vpn_export
,
7368 af_no_nexthop_vpn_export_cmd
,
7369 "no nexthop vpn export",
7371 "Specify next hop to use for VRF advertised prefixes\n"
7372 "Between current address-family and vpn\n"
7373 "For routes leaked from current address-family to vpn\n")
7375 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
7377 if (!strcmp(dstr
, "import")) {
7378 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
7379 } else if (!strcmp(dstr
, "export")) {
7380 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
7381 } else if (!strcmp(dstr
, "both")) {
7382 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
7383 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
7385 vty_out(vty
, "%% direction parse error\n");
7386 return CMD_WARNING_CONFIG_FAILED
;
7391 DEFPY (af_rt_vpn_imexport
,
7392 af_rt_vpn_imexport_cmd
,
7393 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
7395 "Specify route target list\n"
7396 "Specify route target list\n"
7397 "Between current address-family and vpn\n"
7398 "For routes leaked from vpn to current address-family: match any\n"
7399 "For routes leaked from current address-family to vpn: set\n"
7400 "both import: match any and export: set\n"
7401 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
7403 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7405 struct ecommunity
*ecom
= NULL
;
7406 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
7407 vpn_policy_direction_t dir
;
7412 if (argv_find(argv
, argc
, "no", &idx
))
7415 afi
= vpn_policy_getafi(vty
, bgp
, false);
7417 return CMD_WARNING_CONFIG_FAILED
;
7419 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
7420 if (ret
!= CMD_SUCCESS
)
7424 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7425 vty_out(vty
, "%% Missing RTLIST\n");
7426 return CMD_WARNING_CONFIG_FAILED
;
7428 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7429 if (ret
!= CMD_SUCCESS
) {
7434 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
7438 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7441 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
7443 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
7444 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
7445 ecommunity_dup(ecom
);
7447 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
7449 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
7450 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
7453 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7457 ecommunity_free(&ecom
);
7462 ALIAS (af_rt_vpn_imexport
,
7463 af_no_rt_vpn_imexport_cmd
,
7464 "no <rt|route-target> vpn <import|export|both>$direction_str",
7466 "Specify route target list\n"
7467 "Specify route target list\n"
7468 "Between current address-family and vpn\n"
7469 "For routes leaked from vpn to current address-family\n"
7470 "For routes leaked from current address-family to vpn\n"
7471 "both import and export\n")
7473 DEFPY (af_route_map_vpn_imexport
,
7474 af_route_map_vpn_imexport_cmd
,
7475 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
7476 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
7478 "Specify route map\n"
7479 "Between current address-family and vpn\n"
7480 "For routes leaked from vpn to current address-family\n"
7481 "For routes leaked from current address-family to vpn\n"
7482 "name of route-map\n")
7484 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7486 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
7487 vpn_policy_direction_t dir
;
7492 if (argv_find(argv
, argc
, "no", &idx
))
7495 afi
= vpn_policy_getafi(vty
, bgp
, false);
7497 return CMD_WARNING_CONFIG_FAILED
;
7499 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
7500 if (ret
!= CMD_SUCCESS
)
7503 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
7507 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7510 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
7511 XFREE(MTYPE_ROUTE_MAP_NAME
,
7512 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
7513 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
7514 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
7515 bgp
->vpn_policy
[afi
].rmap
[dir
] =
7516 route_map_lookup_warn_noexist(vty
, rmap_str
);
7517 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
7520 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
7521 XFREE(MTYPE_ROUTE_MAP_NAME
,
7522 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
7523 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
7524 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
7527 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7533 ALIAS (af_route_map_vpn_imexport
,
7534 af_no_route_map_vpn_imexport_cmd
,
7535 "no route-map vpn <import|export>$direction_str",
7537 "Specify route map\n"
7538 "Between current address-family and vpn\n"
7539 "For routes leaked from vpn to current address-family\n"
7540 "For routes leaked from current address-family to vpn\n")
7542 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
7543 "[no] import vrf route-map RMAP$rmap_str",
7545 "Import routes from another VRF\n"
7546 "Vrf routes being filtered\n"
7547 "Specify route map\n"
7548 "name of route-map\n")
7550 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7551 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
7555 struct bgp
*bgp_default
;
7557 if (argv_find(argv
, argc
, "no", &idx
))
7560 afi
= vpn_policy_getafi(vty
, bgp
, true);
7562 return CMD_WARNING_CONFIG_FAILED
;
7564 bgp_default
= bgp_get_default();
7569 /* Auto-create assuming the same AS */
7570 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
7571 BGP_INSTANCE_TYPE_DEFAULT
);
7575 "VRF default is not configured as a bgp instance\n");
7580 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7583 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
7584 XFREE(MTYPE_ROUTE_MAP_NAME
,
7585 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
7586 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
7587 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
7588 bgp
->vpn_policy
[afi
].rmap
[dir
] =
7589 route_map_lookup_warn_noexist(vty
, rmap_str
);
7590 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
7593 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
7594 XFREE(MTYPE_ROUTE_MAP_NAME
,
7595 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
7596 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
7597 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
7600 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7605 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
7606 "no import vrf route-map",
7608 "Import routes from another VRF\n"
7609 "Vrf routes being filtered\n"
7610 "Specify route map\n")
7612 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
7613 "[no] import vrf VIEWVRFNAME$import_name",
7615 "Import routes from another VRF\n"
7616 "VRF to import from\n"
7617 "The name of the VRF\n")
7619 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7620 struct listnode
*node
;
7621 struct bgp
*vrf_bgp
, *bgp_default
;
7624 bool remove
= false;
7627 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
7631 if (import_name
== NULL
) {
7632 vty_out(vty
, "%% Missing import name\n");
7636 if (argv_find(argv
, argc
, "no", &idx
))
7639 afi
= vpn_policy_getafi(vty
, bgp
, true);
7641 return CMD_WARNING_CONFIG_FAILED
;
7643 safi
= bgp_node_safi(vty
);
7645 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
7646 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
7647 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
7648 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
7649 remove
? "unimport" : "import", import_name
);
7653 bgp_default
= bgp_get_default();
7655 /* Auto-create assuming the same AS */
7656 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
7657 BGP_INSTANCE_TYPE_DEFAULT
);
7661 "VRF default is not configured as a bgp instance\n");
7666 vrf_bgp
= bgp_lookup_by_name(import_name
);
7668 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
7669 vrf_bgp
= bgp_default
;
7671 /* Auto-create assuming the same AS */
7672 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
7676 "VRF %s is not configured as a bgp instance\n",
7683 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
7685 /* Already importing from "import_vrf"? */
7686 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
7688 if (strcmp(vname
, import_name
) == 0)
7692 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
7698 /* This command is valid only in a bgp vrf instance or the default instance */
7699 DEFPY (bgp_imexport_vpn
,
7700 bgp_imexport_vpn_cmd
,
7701 "[no] <import|export>$direction_str vpn",
7703 "Import routes to this address-family\n"
7704 "Export routes from this address-family\n"
7705 "to/from default instance VPN RIB\n")
7707 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7714 vpn_policy_direction_t dir
;
7716 if (argv_find(argv
, argc
, "no", &idx
))
7719 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
7720 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
7722 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
7723 return CMD_WARNING_CONFIG_FAILED
;
7726 afi
= bgp_node_afi(vty
);
7727 safi
= bgp_node_safi(vty
);
7728 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
7729 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
7730 return CMD_WARNING_CONFIG_FAILED
;
7733 if (!strcmp(direction_str
, "import")) {
7734 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
7735 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
7736 } else if (!strcmp(direction_str
, "export")) {
7737 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
7738 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
7740 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
7741 return CMD_WARNING_CONFIG_FAILED
;
7744 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7747 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7748 if (!previous_state
) {
7749 /* trigger export current vrf */
7750 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7753 if (previous_state
) {
7754 /* trigger un-export current vrf */
7755 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7757 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7763 DEFPY (af_routetarget_import
,
7764 af_routetarget_import_cmd
,
7765 "[no] <rt|route-target> redirect import RTLIST...",
7767 "Specify route target list\n"
7768 "Specify route target list\n"
7769 "Flow-spec redirect type route target\n"
7770 "Import routes to this address-family\n"
7771 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
7773 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7775 struct ecommunity
*ecom
= NULL
;
7780 if (argv_find(argv
, argc
, "no", &idx
))
7783 afi
= vpn_policy_getafi(vty
, bgp
, false);
7785 return CMD_WARNING_CONFIG_FAILED
;
7788 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7789 vty_out(vty
, "%% Missing RTLIST\n");
7790 return CMD_WARNING_CONFIG_FAILED
;
7792 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7793 if (ret
!= CMD_SUCCESS
)
7798 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7799 ecommunity_free(&bgp
->vpn_policy
[afi
]
7800 .import_redirect_rtlist
);
7801 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
7802 ecommunity_dup(ecom
);
7804 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7805 ecommunity_free(&bgp
->vpn_policy
[afi
]
7806 .import_redirect_rtlist
);
7807 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
7811 ecommunity_free(&ecom
);
7816 DEFUN_NOSH (address_family_ipv4_safi
,
7817 address_family_ipv4_safi_cmd
,
7818 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7819 "Enter Address Family command mode\n"
7821 BGP_SAFI_WITH_LABEL_HELP_STR
)
7825 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7826 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7827 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7828 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7829 && safi
!= SAFI_EVPN
) {
7831 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7832 return CMD_WARNING_CONFIG_FAILED
;
7834 vty
->node
= bgp_node_type(AFI_IP
, safi
);
7836 vty
->node
= BGP_IPV4_NODE
;
7841 DEFUN_NOSH (address_family_ipv6_safi
,
7842 address_family_ipv6_safi_cmd
,
7843 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7844 "Enter Address Family command mode\n"
7846 BGP_SAFI_WITH_LABEL_HELP_STR
)
7849 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7850 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7851 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7852 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7853 && safi
!= SAFI_EVPN
) {
7855 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7856 return CMD_WARNING_CONFIG_FAILED
;
7858 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
7860 vty
->node
= BGP_IPV6_NODE
;
7865 #ifdef KEEP_OLD_VPN_COMMANDS
7866 DEFUN_NOSH (address_family_vpnv4
,
7867 address_family_vpnv4_cmd
,
7868 "address-family vpnv4 [unicast]",
7869 "Enter Address Family command mode\n"
7871 "Address Family modifier\n")
7873 vty
->node
= BGP_VPNV4_NODE
;
7877 DEFUN_NOSH (address_family_vpnv6
,
7878 address_family_vpnv6_cmd
,
7879 "address-family vpnv6 [unicast]",
7880 "Enter Address Family command mode\n"
7882 "Address Family modifier\n")
7884 vty
->node
= BGP_VPNV6_NODE
;
7887 #endif /* KEEP_OLD_VPN_COMMANDS */
7889 DEFUN_NOSH (address_family_evpn
,
7890 address_family_evpn_cmd
,
7891 "address-family l2vpn evpn",
7892 "Enter Address Family command mode\n"
7894 "Address Family modifier\n")
7896 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7897 vty
->node
= BGP_EVPN_NODE
;
7901 DEFUN_NOSH (exit_address_family
,
7902 exit_address_family_cmd
,
7903 "exit-address-family",
7904 "Exit from Address Family configuration mode\n")
7906 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7907 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7908 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7909 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7910 || vty
->node
== BGP_EVPN_NODE
7911 || vty
->node
== BGP_FLOWSPECV4_NODE
7912 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7913 vty
->node
= BGP_NODE
;
7917 /* Recalculate bestpath and re-advertise a prefix */
7918 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7919 const char *ip_str
, afi_t afi
, safi_t safi
,
7920 struct prefix_rd
*prd
)
7923 struct prefix match
;
7924 struct bgp_node
*rn
;
7925 struct bgp_node
*rm
;
7927 struct bgp_table
*table
;
7928 struct bgp_table
*rib
;
7930 /* BGP structure lookup. */
7932 bgp
= bgp_lookup_by_name(view_name
);
7934 vty_out(vty
, "%% Can't find BGP instance %s\n",
7939 bgp
= bgp_get_default();
7941 vty_out(vty
, "%% No BGP process is configured\n");
7946 /* Check IP address argument. */
7947 ret
= str2prefix(ip_str
, &match
);
7949 vty_out(vty
, "%% address is malformed\n");
7953 match
.family
= afi2family(afi
);
7954 rib
= bgp
->rib
[afi
][safi
];
7956 if (safi
== SAFI_MPLS_VPN
) {
7957 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7958 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7961 table
= bgp_node_get_bgp_table_info(rn
);
7962 if (table
!= NULL
) {
7964 if ((rm
= bgp_node_match(table
, &match
))
7967 == match
.prefixlen
) {
7969 BGP_NODE_USER_CLEAR
);
7970 bgp_process(bgp
, rm
, afi
, safi
);
7972 bgp_unlock_node(rm
);
7977 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7978 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7979 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7980 bgp_process(bgp
, rn
, afi
, safi
);
7982 bgp_unlock_node(rn
);
7989 /* one clear bgp command to rule them all */
7990 DEFUN (clear_ip_bgp_all
,
7991 clear_ip_bgp_all_cmd
,
7992 "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>]",
7996 BGP_INSTANCE_HELP_STR
7999 BGP_SAFI_WITH_LABEL_HELP_STR
8000 "Address Family modifier\n"
8002 "BGP IPv4 neighbor to clear\n"
8003 "BGP IPv6 neighbor to clear\n"
8004 "BGP neighbor on interface to clear\n"
8005 "Clear peers with the AS number\n"
8006 "Clear all external peers\n"
8007 "Clear all members of peer-group\n"
8008 "BGP peer-group name\n"
8013 "Push out prefix-list ORF and do inbound soft reconfig\n"
8018 afi_t afi
= AFI_UNSPEC
;
8019 safi_t safi
= SAFI_UNSPEC
;
8020 enum clear_sort clr_sort
= clear_peer
;
8021 enum bgp_clear_type clr_type
;
8022 char *clr_arg
= NULL
;
8026 /* clear [ip] bgp */
8027 if (argv_find(argv
, argc
, "ip", &idx
))
8030 /* [<vrf> VIEWVRFNAME] */
8031 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8032 vrf
= argv
[idx
+ 1]->arg
;
8034 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8036 } else if (argv_find(argv
, argc
, "view", &idx
)) {
8037 /* [<view> VIEWVRFNAME] */
8038 vrf
= argv
[idx
+ 1]->arg
;
8041 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8042 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
8043 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8045 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
8046 if (argv_find(argv
, argc
, "*", &idx
)) {
8047 clr_sort
= clear_all
;
8048 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8049 clr_sort
= clear_peer
;
8050 clr_arg
= argv
[idx
]->arg
;
8051 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
8052 clr_sort
= clear_peer
;
8053 clr_arg
= argv
[idx
]->arg
;
8054 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
8055 clr_sort
= clear_group
;
8057 clr_arg
= argv
[idx
]->arg
;
8058 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
8059 clr_sort
= clear_peer
;
8060 clr_arg
= argv
[idx
]->arg
;
8061 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
8062 clr_sort
= clear_peer
;
8063 clr_arg
= argv
[idx
]->arg
;
8064 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
8065 clr_sort
= clear_as
;
8066 clr_arg
= argv
[idx
]->arg
;
8067 } else if (argv_find(argv
, argc
, "external", &idx
)) {
8068 clr_sort
= clear_external
;
8071 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
8072 if (argv_find(argv
, argc
, "soft", &idx
)) {
8073 if (argv_find(argv
, argc
, "in", &idx
)
8074 || argv_find(argv
, argc
, "out", &idx
))
8075 clr_type
= strmatch(argv
[idx
]->text
, "in")
8077 : BGP_CLEAR_SOFT_OUT
;
8079 clr_type
= BGP_CLEAR_SOFT_BOTH
;
8080 } else if (argv_find(argv
, argc
, "in", &idx
)) {
8081 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
8082 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
8083 : BGP_CLEAR_SOFT_IN
;
8084 } else if (argv_find(argv
, argc
, "out", &idx
)) {
8085 clr_type
= BGP_CLEAR_SOFT_OUT
;
8087 clr_type
= BGP_CLEAR_SOFT_NONE
;
8089 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
8092 DEFUN (clear_ip_bgp_prefix
,
8093 clear_ip_bgp_prefix_cmd
,
8094 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
8098 BGP_INSTANCE_HELP_STR
8099 "Clear bestpath and re-advertise\n"
8103 char *prefix
= NULL
;
8107 /* [<view|vrf> VIEWVRFNAME] */
8108 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8109 vrf
= argv
[idx
+ 1]->arg
;
8111 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8113 } else if (argv_find(argv
, argc
, "view", &idx
)) {
8114 /* [<view> VIEWVRFNAME] */
8115 vrf
= argv
[idx
+ 1]->arg
;
8119 prefix
= argv
[argc
- 1]->arg
;
8121 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
8124 DEFUN (clear_bgp_ipv6_safi_prefix
,
8125 clear_bgp_ipv6_safi_prefix_cmd
,
8126 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
8132 "Clear bestpath and re-advertise\n"
8136 int idx_ipv6_prefix
= 0;
8137 safi_t safi
= SAFI_UNICAST
;
8138 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
8139 argv
[idx_ipv6_prefix
]->arg
: NULL
;
8141 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
8142 return bgp_clear_prefix(
8143 vty
, NULL
, prefix
, AFI_IP6
,
8147 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
8148 clear_bgp_instance_ipv6_safi_prefix_cmd
,
8149 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
8153 BGP_INSTANCE_HELP_STR
8156 "Clear bestpath and re-advertise\n"
8160 int idx_vrfview
= 0;
8161 int idx_ipv6_prefix
= 0;
8162 safi_t safi
= SAFI_UNICAST
;
8163 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
8164 argv
[idx_ipv6_prefix
]->arg
: NULL
;
8165 char *vrfview
= NULL
;
8167 /* [<view|vrf> VIEWVRFNAME] */
8168 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
8169 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
8170 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
8172 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
8173 /* [<view> VIEWVRFNAME] */
8174 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
8176 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
8178 return bgp_clear_prefix(
8179 vty
, vrfview
, prefix
,
8180 AFI_IP6
, safi
, NULL
);
8183 DEFUN (show_bgp_views
,
8185 "show [ip] bgp views",
8189 "Show the defined BGP views\n")
8191 struct list
*inst
= bm
->bgp
;
8192 struct listnode
*node
;
8195 vty_out(vty
, "Defined BGP views:\n");
8196 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
8198 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
8200 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
8207 DEFUN (show_bgp_vrfs
,
8209 "show [ip] bgp vrfs [json]",
8216 char buf
[ETHER_ADDR_STRLEN
];
8217 struct list
*inst
= bm
->bgp
;
8218 struct listnode
*node
;
8220 bool uj
= use_json(argc
, argv
);
8221 json_object
*json
= NULL
;
8222 json_object
*json_vrfs
= NULL
;
8226 json
= json_object_new_object();
8227 json_vrfs
= json_object_new_object();
8230 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
8231 const char *name
, *type
;
8233 struct listnode
*node2
, *nnode2
;
8234 int peers_cfg
, peers_estb
;
8235 json_object
*json_vrf
= NULL
;
8238 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
8242 if (!uj
&& count
== 1) {
8244 "%4s %-5s %-16s %9s %10s %-37s\n",
8245 "Type", "Id", "routerId", "#PeersCfg",
8246 "#PeersEstb", "Name");
8247 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
8248 "L3-VNI", "RouterMAC", "Interface");
8251 peers_cfg
= peers_estb
= 0;
8253 json_vrf
= json_object_new_object();
8256 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
8257 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8260 if (peer
->status
== Established
)
8264 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
8265 name
= VRF_DEFAULT_NAME
;
8274 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
8276 : (int64_t)bgp
->vrf_id
;
8277 json_object_string_add(json_vrf
, "type", type
);
8278 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
8279 json_object_string_add(json_vrf
, "routerId",
8280 inet_ntoa(bgp
->router_id
));
8281 json_object_int_add(json_vrf
, "numConfiguredPeers",
8283 json_object_int_add(json_vrf
, "numEstablishedPeers",
8286 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
8287 json_object_string_add(
8289 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
8290 json_object_string_add(json_vrf
, "interface",
8291 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
8293 json_object_object_add(json_vrfs
, name
, json_vrf
);
8296 "%4s %-5d %-16s %-9u %-10u %-37s\n",
8298 bgp
->vrf_id
== VRF_UNKNOWN
? -1
8300 inet_ntoa(bgp
->router_id
), peers_cfg
,
8302 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
8304 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
8305 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
8311 json_object_object_add(json
, "vrfs", json_vrfs
);
8313 json_object_int_add(json
, "totalVrfs", count
);
8315 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8316 json
, JSON_C_TO_STRING_PRETTY
));
8317 json_object_free(json
);
8321 "\nTotal number of VRFs (including default): %d\n",
8328 DEFUN (show_bgp_mac_hash
,
8329 show_bgp_mac_hash_cmd
,
8330 "show bgp mac hash",
8334 "Mac Address database\n")
8336 bgp_mac_dump_table(vty
);
8341 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
8343 struct vty
*vty
= (struct vty
*)args
;
8344 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
8346 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
8350 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
8352 vty_out(vty
, "self nexthop database:\n");
8353 bgp_nexthop_show_address_hash(vty
, bgp
);
8355 vty_out(vty
, "Tunnel-ip database:\n");
8356 hash_iterate(bgp
->tip_hash
,
8357 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
8361 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
8362 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
8363 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
8364 "martian next-hops\n"
8365 "martian next-hop database\n")
8367 struct bgp
*bgp
= NULL
;
8371 /* [<vrf> VIEWVRFNAME] */
8372 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8373 name
= argv
[idx
+ 1]->arg
;
8374 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
8376 } else if (argv_find(argv
, argc
, "view", &idx
))
8377 /* [<view> VIEWVRFNAME] */
8378 name
= argv
[idx
+ 1]->arg
;
8380 bgp
= bgp_lookup_by_name(name
);
8382 bgp
= bgp_get_default();
8385 vty_out(vty
, "%% No BGP process is configured\n");
8388 bgp_show_martian_nexthops(vty
, bgp
);
8393 DEFUN (show_bgp_memory
,
8394 show_bgp_memory_cmd
,
8395 "show [ip] bgp memory",
8399 "Global BGP memory statistics\n")
8401 char memstrbuf
[MTYPE_MEMSTR_LEN
];
8402 unsigned long count
;
8404 /* RIB related usage stats */
8405 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
8406 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
8407 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8408 count
* sizeof(struct bgp_node
)));
8410 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
8411 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
8412 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8413 count
* sizeof(struct bgp_path_info
)));
8414 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
8415 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
8418 memstrbuf
, sizeof(memstrbuf
),
8419 count
* sizeof(struct bgp_path_info_extra
)));
8421 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
8422 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
8423 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8424 count
* sizeof(struct bgp_static
)));
8426 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
8427 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
8428 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8429 count
* sizeof(struct bpacket
)));
8432 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
8433 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
8434 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8435 count
* sizeof(struct bgp_adj_in
)));
8436 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
8437 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
8438 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8439 count
* sizeof(struct bgp_adj_out
)));
8441 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
8442 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
8444 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8445 count
* sizeof(struct bgp_nexthop_cache
)));
8447 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
8448 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
8450 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8451 count
* sizeof(struct bgp_damp_info
)));
8454 count
= attr_count();
8455 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
8456 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8457 count
* sizeof(struct attr
)));
8459 if ((count
= attr_unknown_count()))
8460 vty_out(vty
, "%ld unknown attributes\n", count
);
8462 /* AS_PATH attributes */
8463 count
= aspath_count();
8464 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
8465 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8466 count
* sizeof(struct aspath
)));
8468 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
8469 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
8470 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8471 count
* sizeof(struct assegment
)));
8473 /* Other attributes */
8474 if ((count
= community_count()))
8475 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
8476 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8477 count
* sizeof(struct community
)));
8478 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
8479 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
8480 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8481 count
* sizeof(struct ecommunity
)));
8482 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
8484 "%ld BGP large-community entries, using %s of memory\n",
8485 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8486 count
* sizeof(struct lcommunity
)));
8488 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
8489 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
8490 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8491 count
* sizeof(struct cluster_list
)));
8493 /* Peer related usage */
8494 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
8495 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
8496 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8497 count
* sizeof(struct peer
)));
8499 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
8500 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
8501 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8502 count
* sizeof(struct peer_group
)));
8505 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
8506 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
8507 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8508 count
* sizeof(regex_t
)));
8512 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
8514 json_object
*bestpath
= json_object_new_object();
8516 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
8517 json_object_string_add(bestpath
, "asPath", "ignore");
8519 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
8520 json_object_string_add(bestpath
, "asPath", "confed");
8522 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
8523 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
8524 json_object_string_add(bestpath
, "multiPathRelax",
8527 json_object_string_add(bestpath
, "multiPathRelax",
8530 json_object_string_add(bestpath
, "multiPathRelax", "false");
8532 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
8533 json_object_string_add(bestpath
, "compareRouterId", "true");
8534 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
8535 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
8536 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
8537 json_object_string_add(bestpath
, "med", "confed");
8538 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
8539 json_object_string_add(bestpath
, "med",
8540 "missing-as-worst");
8542 json_object_string_add(bestpath
, "med", "true");
8545 json_object_object_add(json
, "bestPath", bestpath
);
8548 /* Print the error code/subcode for why the peer is down */
8549 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
8550 json_object
*json_peer
, bool use_json
)
8552 const char *code_str
;
8553 const char *subcode_str
;
8556 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
8557 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
8558 char errorcodesubcode_hexstr
[5];
8559 char errorcodesubcode_str
[256];
8561 code_str
= bgp_notify_code_str(peer
->notify
.code
);
8562 subcode_str
= bgp_notify_subcode_str(
8564 peer
->notify
.subcode
);
8566 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
8567 peer
->notify
.code
, peer
->notify
.subcode
);
8568 json_object_string_add(json_peer
,
8569 "lastErrorCodeSubcode",
8570 errorcodesubcode_hexstr
);
8571 snprintf(errorcodesubcode_str
, 255, "%s%s",
8572 code_str
, subcode_str
);
8573 json_object_string_add(json_peer
,
8574 "lastNotificationReason",
8575 errorcodesubcode_str
);
8576 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
8577 && peer
->notify
.code
== BGP_NOTIFY_CEASE
8578 && (peer
->notify
.subcode
8579 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
8580 || peer
->notify
.subcode
8581 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
8582 && peer
->notify
.length
) {
8584 const char *msg_str
;
8586 msg_str
= bgp_notify_admin_message(
8587 msgbuf
, sizeof(msgbuf
),
8588 (uint8_t *)peer
->notify
.data
,
8589 peer
->notify
.length
);
8591 json_object_string_add(
8593 "lastShutdownDescription",
8598 json_object_string_add(json_peer
, "lastResetDueTo",
8599 peer_down_str
[(int)peer
->last_reset
]);
8600 json_object_int_add(json_peer
, "lastResetCode",
8603 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
8604 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
8605 code_str
= bgp_notify_code_str(peer
->notify
.code
);
8607 bgp_notify_subcode_str(peer
->notify
.code
,
8608 peer
->notify
.subcode
);
8609 vty_out(vty
, " Notification %s (%s%s)\n",
8610 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
8613 code_str
, subcode_str
);
8615 vty_out(vty
, " %s\n",
8616 peer_down_str
[(int)peer
->last_reset
]);
8621 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
8624 return ((peer
->status
!= Established
) ||
8625 !peer
->afc_recv
[afi
][safi
]);
8628 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
8629 struct peer
*peer
, json_object
*json_peer
,
8630 int max_neighbor_width
, bool use_json
)
8632 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
8636 if (peer_dynamic_neighbor(peer
))
8637 json_object_boolean_true_add(json_peer
,
8640 json_object_string_add(json_peer
, "hostname",
8643 if (peer
->domainname
)
8644 json_object_string_add(json_peer
, "domainname",
8646 json_object_int_add(json_peer
, "connectionsEstablished",
8648 json_object_int_add(json_peer
, "connectionsDropped",
8650 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8651 use_json
, json_peer
);
8652 if (peer
->status
== Established
)
8653 json_object_string_add(json_peer
, "lastResetDueTo",
8654 "AFI/SAFI Not Negotiated");
8656 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
8659 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
8661 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
8662 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8663 peer
->hostname
, peer
->host
);
8665 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8667 /* pad the neighbor column with spaces */
8668 if (len
< max_neighbor_width
)
8669 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8671 vty_out(vty
, "%7d %7d %8s", peer
->established
,
8673 peer_uptime(peer
->uptime
, timebuf
,
8674 BGP_UPTIME_LEN
, 0, NULL
));
8675 if (peer
->status
== Established
)
8676 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
8678 bgp_show_peer_reset(vty
, peer
, NULL
,
8684 /* Show BGP peer's summary information. */
8685 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
8686 bool show_failed
, bool use_json
)
8689 struct listnode
*node
, *nnode
;
8690 unsigned int count
= 0, dn_count
= 0;
8691 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
8692 char neighbor_buf
[VTY_BUFSIZ
];
8693 int neighbor_col_default_width
= 16;
8694 int len
, failed_count
= 0;
8695 int max_neighbor_width
= 0;
8697 json_object
*json
= NULL
;
8698 json_object
*json_peer
= NULL
;
8699 json_object
*json_peers
= NULL
;
8700 struct peer_af
*paf
;
8702 /* labeled-unicast routes are installed in the unicast table so in order
8704 * display the correct PfxRcd value we must look at SAFI_UNICAST
8707 if (safi
== SAFI_LABELED_UNICAST
)
8708 pfx_rcd_safi
= SAFI_UNICAST
;
8710 pfx_rcd_safi
= safi
;
8713 json
= json_object_new_object();
8714 json_peers
= json_object_new_object();
8715 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8716 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8719 if (peer
->afc
[afi
][safi
]) {
8720 /* See if we have at least a single failed peer */
8721 if (bgp_has_peer_failed(peer
, afi
, safi
))
8725 if (peer_dynamic_neighbor(peer
))
8730 /* Loop over all neighbors that will be displayed to determine
8732 * characters are needed for the Neighbor column
8734 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8735 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8738 if (peer
->afc
[afi
][safi
]) {
8739 memset(dn_flag
, '\0', sizeof(dn_flag
));
8740 if (peer_dynamic_neighbor(peer
))
8744 && CHECK_FLAG(bgp
->flags
,
8745 BGP_FLAG_SHOW_HOSTNAME
))
8746 sprintf(neighbor_buf
, "%s%s(%s) ",
8747 dn_flag
, peer
->hostname
,
8750 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
8753 len
= strlen(neighbor_buf
);
8755 if (len
> max_neighbor_width
)
8756 max_neighbor_width
= len
;
8758 /* See if we have at least a single failed peer */
8759 if (bgp_has_peer_failed(peer
, afi
, safi
))
8765 /* Originally we displayed the Neighbor column as 16
8766 * characters wide so make that the default
8768 if (max_neighbor_width
< neighbor_col_default_width
)
8769 max_neighbor_width
= neighbor_col_default_width
;
8772 if (show_failed
&& !failed_count
) {
8774 json_object_int_add(json
, "failedPeersCount", 0);
8775 json_object_int_add(json
, "dynamicPeers", dn_count
);
8776 json_object_int_add(json
, "totalPeers", count
);
8778 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8779 json
, JSON_C_TO_STRING_PRETTY
));
8780 json_object_free(json
);
8782 vty_out(vty
, "%% No failed BGP neighbors found\n");
8783 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8788 count
= 0; /* Reset the value as its used again */
8789 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8790 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8793 if (!peer
->afc
[afi
][safi
])
8798 char memstrbuf
[MTYPE_MEMSTR_LEN
];
8801 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
8803 : (int64_t)bgp
->vrf_id
;
8805 /* Usage summary and header */
8807 json_object_string_add(
8809 inet_ntoa(bgp
->router_id
));
8810 json_object_int_add(json
, "as", bgp
->as
);
8811 json_object_int_add(json
, "vrfId", vrf_id_ui
);
8812 json_object_string_add(
8815 == BGP_INSTANCE_TYPE_DEFAULT
)
8820 "BGP router identifier %s, local AS number %u vrf-id %d",
8821 inet_ntoa(bgp
->router_id
), bgp
->as
,
8822 bgp
->vrf_id
== VRF_UNKNOWN
8824 : (int)bgp
->vrf_id
);
8828 if (bgp_update_delay_configured(bgp
)) {
8830 json_object_int_add(
8831 json
, "updateDelayLimit",
8832 bgp
->v_update_delay
);
8834 if (bgp
->v_update_delay
8835 != bgp
->v_establish_wait
)
8836 json_object_int_add(
8838 "updateDelayEstablishWait",
8839 bgp
->v_establish_wait
);
8841 if (bgp_update_delay_active(bgp
)) {
8842 json_object_string_add(
8844 "updateDelayFirstNeighbor",
8845 bgp
->update_delay_begin_time
);
8846 json_object_boolean_true_add(
8848 "updateDelayInProgress");
8850 if (bgp
->update_delay_over
) {
8851 json_object_string_add(
8853 "updateDelayFirstNeighbor",
8854 bgp
->update_delay_begin_time
);
8855 json_object_string_add(
8857 "updateDelayBestpathResumed",
8858 bgp
->update_delay_end_time
);
8859 json_object_string_add(
8861 "updateDelayZebraUpdateResume",
8862 bgp
->update_delay_zebra_resume_time
);
8863 json_object_string_add(
8865 "updateDelayPeerUpdateResume",
8866 bgp
->update_delay_peers_resume_time
);
8871 "Read-only mode update-delay limit: %d seconds\n",
8872 bgp
->v_update_delay
);
8873 if (bgp
->v_update_delay
8874 != bgp
->v_establish_wait
)
8876 " Establish wait: %d seconds\n",
8877 bgp
->v_establish_wait
);
8879 if (bgp_update_delay_active(bgp
)) {
8881 " First neighbor established: %s\n",
8882 bgp
->update_delay_begin_time
);
8884 " Delay in progress\n");
8886 if (bgp
->update_delay_over
) {
8888 " First neighbor established: %s\n",
8889 bgp
->update_delay_begin_time
);
8891 " Best-paths resumed: %s\n",
8892 bgp
->update_delay_end_time
);
8894 " zebra update resumed: %s\n",
8895 bgp
->update_delay_zebra_resume_time
);
8897 " peers update resumed: %s\n",
8898 bgp
->update_delay_peers_resume_time
);
8905 if (bgp_maxmed_onstartup_configured(bgp
)
8906 && bgp
->maxmed_active
)
8907 json_object_boolean_true_add(
8908 json
, "maxMedOnStartup");
8909 if (bgp
->v_maxmed_admin
)
8910 json_object_boolean_true_add(
8911 json
, "maxMedAdministrative");
8913 json_object_int_add(
8914 json
, "tableVersion",
8915 bgp_table_version(bgp
->rib
[afi
][safi
]));
8917 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8918 json_object_int_add(json
, "ribCount", ents
);
8919 json_object_int_add(
8921 ents
* sizeof(struct bgp_node
));
8923 ents
= bgp
->af_peer_count
[afi
][safi
];
8924 json_object_int_add(json
, "peerCount", ents
);
8925 json_object_int_add(json
, "peerMemory",
8926 ents
* sizeof(struct peer
));
8928 if ((ents
= listcount(bgp
->group
))) {
8929 json_object_int_add(
8930 json
, "peerGroupCount", ents
);
8931 json_object_int_add(
8932 json
, "peerGroupMemory",
8933 ents
* sizeof(struct
8937 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8938 BGP_CONFIG_DAMPENING
))
8939 json_object_boolean_true_add(
8940 json
, "dampeningEnabled");
8942 if (bgp_maxmed_onstartup_configured(bgp
)
8943 && bgp
->maxmed_active
)
8945 "Max-med on-startup active\n");
8946 if (bgp
->v_maxmed_admin
)
8948 "Max-med administrative active\n");
8950 vty_out(vty
, "BGP table version %" PRIu64
"\n",
8951 bgp_table_version(bgp
->rib
[afi
][safi
]));
8953 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8955 "RIB entries %ld, using %s of memory\n",
8957 mtype_memstr(memstrbuf
,
8959 ents
* sizeof(struct
8962 /* Peer related usage */
8963 ents
= bgp
->af_peer_count
[afi
][safi
];
8964 vty_out(vty
, "Peers %ld, using %s of memory\n",
8967 memstrbuf
, sizeof(memstrbuf
),
8968 ents
* sizeof(struct peer
)));
8970 if ((ents
= listcount(bgp
->group
)))
8972 "Peer groups %ld, using %s of memory\n",
8977 ents
* sizeof(struct
8980 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8981 BGP_CONFIG_DAMPENING
))
8982 vty_out(vty
, "Dampening enabled.\n");
8985 /* Subtract 8 here because 'Neighbor' is
8987 vty_out(vty
, "Neighbor");
8988 vty_out(vty
, "%*s", max_neighbor_width
- 8,
8991 vty_out(vty
, "EstdCnt DropCnt ResetTime Reason\n");
8994 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
8999 /* Works for both failed & successful cases */
9000 if (peer_dynamic_neighbor(peer
))
9007 bgp_has_peer_failed(peer
, afi
, safi
)) {
9008 json_peer
= json_object_new_object();
9009 bgp_show_failed_summary(vty
, bgp
, peer
,
9010 json_peer
, 0, use_json
);
9011 } else if (!show_failed
) {
9012 json_peer
= json_object_new_object();
9013 if (peer_dynamic_neighbor(peer
)) {
9014 json_object_boolean_true_add(json_peer
,
9019 json_object_string_add(json_peer
, "hostname",
9022 if (peer
->domainname
)
9023 json_object_string_add(json_peer
, "domainname",
9026 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
9027 json_object_int_add(json_peer
, "version", 4);
9028 json_object_int_add(json_peer
, "msgRcvd",
9029 PEER_TOTAL_RX(peer
));
9030 json_object_int_add(json_peer
, "msgSent",
9031 PEER_TOTAL_TX(peer
));
9033 json_object_int_add(json_peer
, "tableVersion",
9034 peer
->version
[afi
][safi
]);
9035 json_object_int_add(json_peer
, "outq",
9037 json_object_int_add(json_peer
, "inq", 0);
9038 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9039 use_json
, json_peer
);
9042 * Adding "pfxRcd" field to match with the corresponding
9043 * CLI. "prefixReceivedCount" will be deprecated in
9046 json_object_int_add(json_peer
, "prefixReceivedCount",
9047 peer
->pcount
[afi
][pfx_rcd_safi
]);
9048 json_object_int_add(json_peer
, "pfxRcd",
9049 peer
->pcount
[afi
][pfx_rcd_safi
]);
9051 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
9052 if (paf
&& PAF_SUBGRP(paf
))
9053 json_object_int_add(json_peer
,
9055 (PAF_SUBGRP(paf
))->scount
);
9056 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
9057 json_object_string_add(json_peer
, "state",
9059 else if (peer
->afc_recv
[afi
][safi
])
9060 json_object_string_add(
9062 lookup_msg(bgp_status_msg
, peer
->status
,
9064 else if (CHECK_FLAG(peer
->sflags
,
9065 PEER_STATUS_PREFIX_OVERFLOW
))
9066 json_object_string_add(json_peer
, "state",
9069 json_object_string_add(
9071 lookup_msg(bgp_status_msg
, peer
->status
,
9073 json_object_int_add(json_peer
, "connectionsEstablished",
9075 json_object_int_add(json_peer
, "connectionsDropped",
9078 /* Avoid creating empty peer dicts in JSON */
9079 if (json_peer
== NULL
)
9083 json_object_string_add(json_peer
, "idType",
9085 else if (peer
->su
.sa
.sa_family
== AF_INET
)
9086 json_object_string_add(json_peer
, "idType",
9088 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
9089 json_object_string_add(json_peer
, "idType",
9091 json_object_object_add(json_peers
, peer
->host
,
9095 bgp_has_peer_failed(peer
, afi
, safi
)) {
9096 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
9099 } else if (!show_failed
) {
9100 memset(dn_flag
, '\0', sizeof(dn_flag
));
9101 if (peer_dynamic_neighbor(peer
)) {
9106 && CHECK_FLAG(bgp
->flags
,
9107 BGP_FLAG_SHOW_HOSTNAME
))
9108 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
9112 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
9114 /* pad the neighbor column with spaces */
9115 if (len
< max_neighbor_width
)
9116 vty_out(vty
, "%*s", max_neighbor_width
- len
,
9119 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
9120 peer
->as
, PEER_TOTAL_RX(peer
),
9121 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
9122 0, peer
->obuf
->count
,
9123 peer_uptime(peer
->uptime
, timebuf
,
9124 BGP_UPTIME_LEN
, 0, NULL
));
9126 if (peer
->status
== Established
)
9127 if (peer
->afc_recv
[afi
][safi
])
9128 vty_out(vty
, " %12" PRIu32
,
9133 vty_out(vty
, " NoNeg");
9135 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
9136 vty_out(vty
, " Idle (Admin)");
9137 else if (CHECK_FLAG(
9139 PEER_STATUS_PREFIX_OVERFLOW
))
9140 vty_out(vty
, " Idle (PfxCt)");
9142 vty_out(vty
, " %12s",
9143 lookup_msg(bgp_status_msg
,
9144 peer
->status
, NULL
));
9153 json_object_object_add(json
, "peers", json_peers
);
9154 json_object_int_add(json
, "failedPeers", failed_count
);
9155 json_object_int_add(json
, "totalPeers", count
);
9156 json_object_int_add(json
, "dynamicPeers", dn_count
);
9159 bgp_show_bestpath_json(bgp
, json
);
9161 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
9162 json
, JSON_C_TO_STRING_PRETTY
));
9163 json_object_free(json
);
9166 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
9168 vty_out(vty
, "No %s neighbor is configured\n",
9169 get_afi_safi_str(afi
, safi
, false));
9173 vty_out(vty
, "* - dynamic neighbor\n");
9174 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
9175 dn_count
, bgp
->dynamic_neighbors_limit
);
9182 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
9183 int safi
, bool show_failed
, bool use_json
)
9186 int afi_wildcard
= (afi
== AFI_MAX
);
9187 int safi_wildcard
= (safi
== SAFI_MAX
);
9188 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
9189 bool nbr_output
= false;
9191 if (use_json
&& is_wildcard
)
9192 vty_out(vty
, "{\n");
9194 afi
= 1; /* AFI_IP */
9195 while (afi
< AFI_MAX
) {
9197 safi
= 1; /* SAFI_UNICAST */
9198 while (safi
< SAFI_MAX
) {
9199 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
9204 * So limit output to those afi/safi
9206 * actualy have something interesting in
9211 vty_out(vty
, ",\n");
9215 vty_out(vty
, "\"%s\":",
9216 get_afi_safi_str(afi
,
9220 vty_out(vty
, "\n%s Summary:\n",
9221 get_afi_safi_str(afi
,
9226 bgp_show_summary(vty
, bgp
, afi
, safi
, show_failed
,
9238 if (use_json
&& is_wildcard
)
9239 vty_out(vty
, "}\n");
9240 else if (!nbr_output
) {
9242 vty_out(vty
, "{}\n");
9244 vty_out(vty
, "%% No BGP neighbors found\n");
9248 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
9249 safi_t safi
, bool show_failed
,
9252 struct listnode
*node
, *nnode
;
9255 bool nbr_output
= false;
9258 vty_out(vty
, "{\n");
9260 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
9264 vty_out(vty
, ",\n");
9268 vty_out(vty
, "\"%s\":",
9269 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
9273 vty_out(vty
, "\nInstance %s:\n",
9274 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
9278 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
9283 vty_out(vty
, "}\n");
9284 else if (!nbr_output
)
9285 vty_out(vty
, "%% BGP instance not found\n");
9288 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
9289 safi_t safi
, bool show_failed
, bool use_json
)
9294 if (strmatch(name
, "all")) {
9295 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
9300 bgp
= bgp_lookup_by_name(name
);
9304 vty_out(vty
, "{}\n");
9307 "%% BGP instance not found\n");
9311 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
,
9312 show_failed
, use_json
);
9317 bgp
= bgp_get_default();
9320 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
9324 vty_out(vty
, "{}\n");
9326 vty_out(vty
, "%% BGP instance not found\n");
9333 /* `show [ip] bgp summary' commands. */
9334 DEFUN (show_ip_bgp_summary
,
9335 show_ip_bgp_summary_cmd
,
9336 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [failed] [json]",
9340 BGP_INSTANCE_HELP_STR
9342 BGP_SAFI_WITH_LABEL_HELP_STR
9343 "Summary of BGP neighbor status\n"
9344 "Show only sessions not in Established state\n"
9348 afi_t afi
= AFI_MAX
;
9349 safi_t safi
= SAFI_MAX
;
9350 bool show_failed
= false;
9355 if (argv_find(argv
, argc
, "ip", &idx
))
9357 /* [<vrf> VIEWVRFNAME] */
9358 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9359 vrf
= argv
[idx
+ 1]->arg
;
9360 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9362 } else if (argv_find(argv
, argc
, "view", &idx
))
9363 /* [<view> VIEWVRFNAME] */
9364 vrf
= argv
[idx
+ 1]->arg
;
9365 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9366 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
9367 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
9370 if (argv_find(argv
, argc
, "failed", &idx
))
9373 bool uj
= use_json(argc
, argv
);
9375 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, show_failed
, uj
);
9378 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
9381 return get_afi_safi_json_str(afi
, safi
);
9383 return get_afi_safi_vty_str(afi
, safi
);
9387 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
9388 afi_t afi
, safi_t safi
,
9389 uint16_t adv_smcap
, uint16_t adv_rmcap
,
9390 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
9391 bool use_json
, json_object
*json_pref
)
9394 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
9395 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
9397 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
9398 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
9399 json_object_string_add(json_pref
, "sendMode",
9400 "advertisedAndReceived");
9401 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
9402 json_object_string_add(json_pref
, "sendMode",
9404 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
9405 json_object_string_add(json_pref
, "sendMode",
9408 vty_out(vty
, " Send-mode: ");
9409 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
9410 vty_out(vty
, "advertised");
9411 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
9412 vty_out(vty
, "%sreceived",
9413 CHECK_FLAG(p
->af_cap
[afi
][safi
],
9422 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
9423 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
9425 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
9426 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
9427 json_object_string_add(json_pref
, "recvMode",
9428 "advertisedAndReceived");
9429 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
9430 json_object_string_add(json_pref
, "recvMode",
9432 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
9433 json_object_string_add(json_pref
, "recvMode",
9436 vty_out(vty
, " Receive-mode: ");
9437 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
9438 vty_out(vty
, "advertised");
9439 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
9440 vty_out(vty
, "%sreceived",
9441 CHECK_FLAG(p
->af_cap
[afi
][safi
],
9450 static void bgp_show_neighnor_graceful_restart_rbit(struct vty
*vty
,
9455 bool rbit_status
= 0;
9458 vty_out(vty
, "\n R bit : ");
9460 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
9461 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
9462 && (p
->status
== Established
)) {
9464 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_BIT_RCV
))
9472 json_object_boolean_true_add(json
, "rBit");
9474 vty_out(vty
, "True\n");
9477 json_object_boolean_false_add(json
, "rBit");
9479 vty_out(vty
, "False\n");
9483 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
9488 const char *mode
= "NotApplicable";
9491 vty_out(vty
, "\n Remote GR Mode : ");
9493 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
9494 && (peer
->status
== Established
)) {
9496 if ((peer
->nsf_af_count
== 0)
9497 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
9501 } else if (peer
->nsf_af_count
== 0
9502 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
9506 } else if (peer
->nsf_af_count
!= 0
9507 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
9514 json_object_string_add(json
, "remoteGrMode", mode
);
9516 vty_out(vty
, mode
, "\n");
9519 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
9524 const char *mode
= "Invalid";
9527 vty_out(vty
, " Local GR Mode : ");
9529 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
9531 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
9533 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
9535 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
9536 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
9538 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
9540 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
9547 json_object_string_add(json
, "localGrMode", mode
);
9549 vty_out(vty
, mode
, "\n");
9553 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
9554 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
9558 json_object
*json_afi_safi
= NULL
;
9559 json_object
*json_timer
= NULL
;
9560 json_object
*json_endofrib_status
= NULL
;
9561 bool eor_flag
= false;
9563 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
9564 for (safi
= SAFI_UNICAST
; safi
<= SAFI_MPLS_VPN
; safi
++) {
9565 if (!peer
->afc
[afi
][safi
])
9568 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
9569 || !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
9573 json_afi_safi
= json_object_new_object();
9574 json_endofrib_status
= json_object_new_object();
9575 json_timer
= json_object_new_object();
9578 if (peer
->eor_stime
[afi
][safi
]
9579 >= peer
->pkt_stime
[afi
][safi
])
9585 vty_out(vty
, " %s :\n",
9586 get_afi_safi_str(afi
, safi
, false));
9588 vty_out(vty
, " F bit : ");
9591 if (peer
->nsf
[afi
][safi
]
9592 && CHECK_FLAG(peer
->af_cap
[afi
][safi
],
9593 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
9596 json_object_boolean_true_add(
9597 json_afi_safi
, "fBit");
9599 vty_out(vty
, "True\n");
9602 json_object_boolean_false_add(
9603 json_afi_safi
, "fBit");
9605 vty_out(vty
, "False\n");
9609 vty_out(vty
, " End-of-RIB Received : ");
9611 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
9612 PEER_STATUS_EOR_RECEIVED
)) {
9614 json_object_boolean_true_add(
9615 json_endofrib_status
,
9618 vty_out(vty
, "Yes\n");
9621 json_object_boolean_false_add(
9622 json_endofrib_status
,
9625 vty_out(vty
, "No\n");
9629 vty_out(vty
, " End-of-RIB Send : ");
9631 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
9632 PEER_STATUS_EOR_SEND
)) {
9634 json_object_boolean_true_add(
9635 json_endofrib_status
,
9638 PRINT_EOR_JSON(eor_flag
);
9640 vty_out(vty
, "Yes\n");
9642 " EoRSentAfterUpdate : ");
9644 PRINT_EOR(eor_flag
);
9648 json_object_boolean_false_add(
9649 json_endofrib_status
,
9651 json_object_boolean_false_add(
9652 json_endofrib_status
,
9653 "endOfRibSentAfterUpdate");
9655 vty_out(vty
, "No\n");
9657 " EoRSentAfterUpdate : ");
9658 vty_out(vty
, "No\n");
9663 json_object_int_add(json_timer
,
9665 peer
->bgp
->stalepath_time
);
9667 if (peer
->t_gr_stale
!= NULL
) {
9668 json_object_int_add(
9670 "stalePathTimerRemaining",
9671 thread_timer_remain_second(
9675 /* Display Configured Selection
9676 * Deferral only when when
9677 * Gr mode is enabled.
9679 if (CHECK_FLAG(peer
->flags
,
9680 PEER_FLAG_GRACEFUL_RESTART
)) {
9681 json_object_int_add(
9683 "selectionDeferralTimer",
9684 peer
->bgp
->stalepath_time
);
9687 if (peer
->bgp
->gr_info
[afi
][safi
]
9691 json_object_int_add(
9693 "selectionDeferralTimerRemaining",
9694 thread_timer_remain_second(
9698 .t_select_deferral
));
9701 vty_out(vty
, " Timers:\n");
9703 vty_out(vty
, "%*s", 6, "");
9705 "Configured Stale Path Time(sec)%*s: %u\n",
9706 8, "", peer
->bgp
->stalepath_time
);
9708 if (peer
->t_gr_stale
!= NULL
) {
9709 vty_out(vty
, "%*s", 6, "");
9711 "Stale Path Remaining(sec)%*s: %ld\n",
9713 thread_timer_remain_second(
9716 /* Display Configured Selection
9717 * Deferral only when when
9718 * Gr mode is enabled.
9720 if (CHECK_FLAG(peer
->flags
,
9721 PEER_FLAG_GRACEFUL_RESTART
)) {
9722 vty_out(vty
, "%*s", 6, "");
9724 "Configured Selection Deferral Time(sec): %u\n",
9725 peer
->bgp
->select_defer_time
);
9728 if (peer
->bgp
->gr_info
[afi
][safi
]
9732 vty_out(vty
, "%*s", 6, "");
9734 "Selection Deferral Time Remaining(sec) : %ld\n",
9735 thread_timer_remain_second(
9739 .t_select_deferral
));
9743 json_object_object_add(json_afi_safi
,
9745 json_endofrib_status
);
9746 json_object_object_add(json_afi_safi
, "timers",
9748 json_object_object_add(
9749 json
, get_afi_safi_str(afi
, safi
, true),
9756 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
9762 json_object
*json_timer
= NULL
;
9764 json_timer
= json_object_new_object();
9766 json_object_int_add(json_timer
, "configuredRestartTimer",
9767 p
->bgp
->restart_time
);
9769 json_object_int_add(json_timer
, "receivedRestartTimer",
9772 if (p
->t_gr_restart
!= NULL
)
9773 json_object_int_add(
9774 json_timer
, "restartTimerRemaining",
9775 thread_timer_remain_second(p
->t_gr_restart
));
9777 json_object_object_add(json
, "timers", json_timer
);
9780 vty_out(vty
, " Timers :\n");
9781 vty_out(vty
, " Configured Restart Time(sec) : %u\n",
9782 p
->bgp
->restart_time
);
9784 vty_out(vty
, " Received Restart Time(sec) : %u\n",
9786 if (p
->t_gr_restart
!= NULL
)
9788 " Restart Time Remaining(sec) : %ld\n",
9789 thread_timer_remain_second(p
->t_gr_restart
));
9790 if (p
->t_gr_restart
!= NULL
) {
9792 " Restart Time Remaining(sec) : %ld\n",
9793 thread_timer_remain_second(p
->t_gr_restart
));
9798 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
9799 bool use_json
, json_object
*json
)
9801 char buf
[SU_ADDRSTRLEN
] = {0};
9802 char dn_flag
[2] = {0};
9803 char neighborAddr
[INET6_ADDRSTRLEN
] = {0};
9805 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9810 json_object_string_add(
9811 json
, "neighborAddr",
9812 BGP_PEER_SU_UNSPEC(p
)
9814 : sockunion2str(&p
->su
, buf
,
9817 vty_out(vty
, "BGP neighbor on %s: %s\n", p
->conf_if
,
9818 BGP_PEER_SU_UNSPEC(p
)
9820 : sockunion2str(&p
->su
, buf
,
9823 sprintf(neighborAddr
, "%s%s", dn_flag
, p
->host
);
9826 json_object_string_add(json
, "neighborAddr",
9829 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
9832 /* more gr info in new format */
9833 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
9836 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
9837 safi_t safi
, bool use_json
,
9838 json_object
*json_neigh
)
9840 struct bgp_filter
*filter
;
9841 struct peer_af
*paf
;
9842 char orf_pfx_name
[BUFSIZ
];
9844 json_object
*json_af
= NULL
;
9845 json_object
*json_prefA
= NULL
;
9846 json_object
*json_prefB
= NULL
;
9847 json_object
*json_addr
= NULL
;
9850 json_addr
= json_object_new_object();
9851 json_af
= json_object_new_object();
9852 filter
= &p
->filter
[afi
][safi
];
9854 if (peer_group_active(p
))
9855 json_object_string_add(json_addr
, "peerGroupMember",
9858 paf
= peer_af_find(p
, afi
, safi
);
9859 if (paf
&& PAF_SUBGRP(paf
)) {
9860 json_object_int_add(json_addr
, "updateGroupId",
9861 PAF_UPDGRP(paf
)->id
);
9862 json_object_int_add(json_addr
, "subGroupId",
9863 PAF_SUBGRP(paf
)->id
);
9864 json_object_int_add(json_addr
, "packetQueueLength",
9865 bpacket_queue_virtual_length(paf
));
9868 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9869 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9870 PEER_CAP_ORF_PREFIX_SM_RCV
)
9871 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9872 PEER_CAP_ORF_PREFIX_RM_ADV
)
9873 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9874 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
9875 json_object_int_add(json_af
, "orfType",
9877 json_prefA
= json_object_new_object();
9878 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
9879 PEER_CAP_ORF_PREFIX_SM_ADV
,
9880 PEER_CAP_ORF_PREFIX_RM_ADV
,
9881 PEER_CAP_ORF_PREFIX_SM_RCV
,
9882 PEER_CAP_ORF_PREFIX_RM_RCV
,
9883 use_json
, json_prefA
);
9884 json_object_object_add(json_af
, "orfPrefixList",
9888 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9889 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9890 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
9891 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9892 PEER_CAP_ORF_PREFIX_RM_ADV
)
9893 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9894 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
9895 json_object_int_add(json_af
, "orfOldType",
9896 ORF_TYPE_PREFIX_OLD
);
9897 json_prefB
= json_object_new_object();
9898 bgp_show_peer_afi_orf_cap(
9899 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
9900 PEER_CAP_ORF_PREFIX_RM_ADV
,
9901 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
9902 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
9904 json_object_object_add(json_af
, "orfOldPrefixList",
9908 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9909 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9910 PEER_CAP_ORF_PREFIX_SM_RCV
)
9911 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9912 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
9913 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9914 PEER_CAP_ORF_PREFIX_RM_ADV
)
9915 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9916 PEER_CAP_ORF_PREFIX_RM_RCV
)
9917 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9918 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
9919 json_object_object_add(json_addr
, "afDependentCap",
9922 json_object_free(json_af
);
9924 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
9925 orf_pfx_count
= prefix_bgp_show_prefix_list(
9926 NULL
, afi
, orf_pfx_name
, use_json
);
9928 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9929 PEER_STATUS_ORF_PREFIX_SEND
)
9931 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9932 PEER_STATUS_ORF_PREFIX_SEND
))
9933 json_object_boolean_true_add(json_neigh
,
9936 json_object_int_add(json_addr
, "orfRecvCounter",
9939 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9940 PEER_STATUS_ORF_WAIT_REFRESH
))
9941 json_object_string_add(
9942 json_addr
, "orfFirstUpdate",
9943 "deferredUntilORFOrRouteRefreshRecvd");
9945 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9946 PEER_FLAG_REFLECTOR_CLIENT
))
9947 json_object_boolean_true_add(json_addr
,
9948 "routeReflectorClient");
9949 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9950 PEER_FLAG_RSERVER_CLIENT
))
9951 json_object_boolean_true_add(json_addr
,
9952 "routeServerClient");
9953 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9954 json_object_boolean_true_add(json_addr
,
9955 "inboundSoftConfigPermit");
9957 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9958 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
9959 json_object_boolean_true_add(
9961 "privateAsNumsAllReplacedInUpdatesToNbr");
9962 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9963 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
9964 json_object_boolean_true_add(
9966 "privateAsNumsReplacedInUpdatesToNbr");
9967 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9968 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
9969 json_object_boolean_true_add(
9971 "privateAsNumsAllRemovedInUpdatesToNbr");
9972 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9973 PEER_FLAG_REMOVE_PRIVATE_AS
))
9974 json_object_boolean_true_add(
9976 "privateAsNumsRemovedInUpdatesToNbr");
9978 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
9979 json_object_boolean_true_add(
9981 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
9984 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
9985 json_object_string_add(json_addr
,
9986 "overrideASNsInOutboundUpdates",
9987 "ifAspathEqualRemoteAs");
9989 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
9990 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9991 PEER_FLAG_FORCE_NEXTHOP_SELF
))
9992 json_object_boolean_true_add(json_addr
,
9993 "routerAlwaysNextHop");
9994 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9995 PEER_FLAG_AS_PATH_UNCHANGED
))
9996 json_object_boolean_true_add(
9997 json_addr
, "unchangedAsPathPropogatedToNbr");
9998 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9999 PEER_FLAG_NEXTHOP_UNCHANGED
))
10000 json_object_boolean_true_add(
10001 json_addr
, "unchangedNextHopPropogatedToNbr");
10002 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
10003 json_object_boolean_true_add(
10004 json_addr
, "unchangedMedPropogatedToNbr");
10005 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
10006 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
10007 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
10008 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10009 PEER_FLAG_SEND_COMMUNITY
)
10010 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
10011 PEER_FLAG_SEND_EXT_COMMUNITY
))
10012 json_object_string_add(json_addr
,
10013 "commAttriSentToNbr",
10014 "extendedAndStandard");
10015 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10016 PEER_FLAG_SEND_EXT_COMMUNITY
))
10017 json_object_string_add(json_addr
,
10018 "commAttriSentToNbr",
10021 json_object_string_add(json_addr
,
10022 "commAttriSentToNbr",
10025 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10026 PEER_FLAG_DEFAULT_ORIGINATE
)) {
10027 if (p
->default_rmap
[afi
][safi
].name
)
10028 json_object_string_add(
10029 json_addr
, "defaultRouteMap",
10030 p
->default_rmap
[afi
][safi
].name
);
10032 if (paf
&& PAF_SUBGRP(paf
)
10033 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
10034 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
10035 json_object_boolean_true_add(json_addr
,
10038 json_object_boolean_true_add(json_addr
,
10042 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
10043 if (is_evpn_enabled())
10044 json_object_boolean_true_add(
10045 json_addr
, "advertiseAllVnis");
10048 if (filter
->plist
[FILTER_IN
].name
10049 || filter
->dlist
[FILTER_IN
].name
10050 || filter
->aslist
[FILTER_IN
].name
10051 || filter
->map
[RMAP_IN
].name
)
10052 json_object_boolean_true_add(json_addr
,
10053 "inboundPathPolicyConfig");
10054 if (filter
->plist
[FILTER_OUT
].name
10055 || filter
->dlist
[FILTER_OUT
].name
10056 || filter
->aslist
[FILTER_OUT
].name
10057 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
10058 json_object_boolean_true_add(
10059 json_addr
, "outboundPathPolicyConfig");
10062 if (filter
->plist
[FILTER_IN
].name
)
10063 json_object_string_add(json_addr
,
10064 "incomingUpdatePrefixFilterList",
10065 filter
->plist
[FILTER_IN
].name
);
10066 if (filter
->plist
[FILTER_OUT
].name
)
10067 json_object_string_add(json_addr
,
10068 "outgoingUpdatePrefixFilterList",
10069 filter
->plist
[FILTER_OUT
].name
);
10071 /* distribute-list */
10072 if (filter
->dlist
[FILTER_IN
].name
)
10073 json_object_string_add(
10074 json_addr
, "incomingUpdateNetworkFilterList",
10075 filter
->dlist
[FILTER_IN
].name
);
10076 if (filter
->dlist
[FILTER_OUT
].name
)
10077 json_object_string_add(
10078 json_addr
, "outgoingUpdateNetworkFilterList",
10079 filter
->dlist
[FILTER_OUT
].name
);
10082 if (filter
->aslist
[FILTER_IN
].name
)
10083 json_object_string_add(json_addr
,
10084 "incomingUpdateAsPathFilterList",
10085 filter
->aslist
[FILTER_IN
].name
);
10086 if (filter
->aslist
[FILTER_OUT
].name
)
10087 json_object_string_add(json_addr
,
10088 "outgoingUpdateAsPathFilterList",
10089 filter
->aslist
[FILTER_OUT
].name
);
10092 if (filter
->map
[RMAP_IN
].name
)
10093 json_object_string_add(
10094 json_addr
, "routeMapForIncomingAdvertisements",
10095 filter
->map
[RMAP_IN
].name
);
10096 if (filter
->map
[RMAP_OUT
].name
)
10097 json_object_string_add(
10098 json_addr
, "routeMapForOutgoingAdvertisements",
10099 filter
->map
[RMAP_OUT
].name
);
10101 /* ebgp-requires-policy (inbound) */
10102 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
10103 && !bgp_inbound_policy_exists(p
, filter
))
10104 json_object_string_add(
10105 json_addr
, "inboundEbgpRequiresPolicy",
10106 "Inbound updates discarded due to missing policy");
10108 /* ebgp-requires-policy (outbound) */
10109 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
10110 && (!bgp_outbound_policy_exists(p
, filter
)))
10111 json_object_string_add(
10112 json_addr
, "outboundEbgpRequiresPolicy",
10113 "Outbound updates discarded due to missing policy");
10115 /* unsuppress-map */
10116 if (filter
->usmap
.name
)
10117 json_object_string_add(json_addr
,
10118 "selectiveUnsuppressRouteMap",
10119 filter
->usmap
.name
);
10121 /* Receive prefix count */
10122 json_object_int_add(json_addr
, "acceptedPrefixCounter",
10123 p
->pcount
[afi
][safi
]);
10124 if (paf
&& PAF_SUBGRP(paf
))
10125 json_object_int_add(json_addr
, "sentPrefixCounter",
10126 (PAF_SUBGRP(paf
))->scount
);
10128 /* Maximum prefix */
10129 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
10130 json_object_int_add(json_addr
, "prefixOutAllowedMax",
10131 p
->pmax_out
[afi
][safi
]);
10133 /* Maximum prefix */
10134 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
10135 json_object_int_add(json_addr
, "prefixAllowedMax",
10136 p
->pmax
[afi
][safi
]);
10137 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10138 PEER_FLAG_MAX_PREFIX_WARNING
))
10139 json_object_boolean_true_add(
10140 json_addr
, "prefixAllowedMaxWarning");
10141 json_object_int_add(json_addr
,
10142 "prefixAllowedWarningThresh",
10143 p
->pmax_threshold
[afi
][safi
]);
10144 if (p
->pmax_restart
[afi
][safi
])
10145 json_object_int_add(
10147 "prefixAllowedRestartIntervalMsecs",
10148 p
->pmax_restart
[afi
][safi
] * 60000);
10150 json_object_object_add(json_neigh
,
10151 get_afi_safi_str(afi
, safi
, true),
10155 filter
= &p
->filter
[afi
][safi
];
10157 vty_out(vty
, " For address family: %s\n",
10158 get_afi_safi_str(afi
, safi
, false));
10160 if (peer_group_active(p
))
10161 vty_out(vty
, " %s peer-group member\n",
10164 paf
= peer_af_find(p
, afi
, safi
);
10165 if (paf
&& PAF_SUBGRP(paf
)) {
10166 vty_out(vty
, " Update group %" PRIu64
10167 ", subgroup %" PRIu64
"\n",
10168 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
10169 vty_out(vty
, " Packet Queue length %d\n",
10170 bpacket_queue_virtual_length(paf
));
10172 vty_out(vty
, " Not part of any update group\n");
10174 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
10175 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10176 PEER_CAP_ORF_PREFIX_SM_RCV
)
10177 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10178 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
10179 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10180 PEER_CAP_ORF_PREFIX_RM_ADV
)
10181 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10182 PEER_CAP_ORF_PREFIX_RM_RCV
)
10183 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10184 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
10185 vty_out(vty
, " AF-dependant capabilities:\n");
10187 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
10188 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10189 PEER_CAP_ORF_PREFIX_SM_RCV
)
10190 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10191 PEER_CAP_ORF_PREFIX_RM_ADV
)
10192 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10193 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
10195 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
10197 bgp_show_peer_afi_orf_cap(
10198 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
10199 PEER_CAP_ORF_PREFIX_RM_ADV
,
10200 PEER_CAP_ORF_PREFIX_SM_RCV
,
10201 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
10203 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
10204 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10205 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
10206 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10207 PEER_CAP_ORF_PREFIX_RM_ADV
)
10208 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10209 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
10211 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
10212 ORF_TYPE_PREFIX_OLD
);
10213 bgp_show_peer_afi_orf_cap(
10214 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
10215 PEER_CAP_ORF_PREFIX_RM_ADV
,
10216 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
10217 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
10220 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
10221 orf_pfx_count
= prefix_bgp_show_prefix_list(
10222 NULL
, afi
, orf_pfx_name
, use_json
);
10224 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10225 PEER_STATUS_ORF_PREFIX_SEND
)
10226 || orf_pfx_count
) {
10227 vty_out(vty
, " Outbound Route Filter (ORF):");
10228 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10229 PEER_STATUS_ORF_PREFIX_SEND
))
10230 vty_out(vty
, " sent;");
10232 vty_out(vty
, " received (%d entries)",
10234 vty_out(vty
, "\n");
10236 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10237 PEER_STATUS_ORF_WAIT_REFRESH
))
10239 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
10241 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10242 PEER_FLAG_REFLECTOR_CLIENT
))
10243 vty_out(vty
, " Route-Reflector Client\n");
10244 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10245 PEER_FLAG_RSERVER_CLIENT
))
10246 vty_out(vty
, " Route-Server Client\n");
10247 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
10249 " Inbound soft reconfiguration allowed\n");
10251 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10252 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
10254 " Private AS numbers (all) replaced in updates to this neighbor\n");
10255 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10256 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
10258 " Private AS numbers replaced in updates to this neighbor\n");
10259 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10260 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
10262 " Private AS numbers (all) removed in updates to this neighbor\n");
10263 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10264 PEER_FLAG_REMOVE_PRIVATE_AS
))
10266 " Private AS numbers removed in updates to this neighbor\n");
10268 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
10269 vty_out(vty
, " %s\n",
10270 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
10271 ->human_description
);
10273 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
10275 " Override ASNs in outbound updates if aspath equals remote-as\n");
10277 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
10278 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
10279 PEER_FLAG_FORCE_NEXTHOP_SELF
))
10280 vty_out(vty
, " NEXT_HOP is always this router\n");
10281 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10282 PEER_FLAG_AS_PATH_UNCHANGED
))
10284 " AS_PATH is propagated unchanged to this neighbor\n");
10285 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10286 PEER_FLAG_NEXTHOP_UNCHANGED
))
10288 " NEXT_HOP is propagated unchanged to this neighbor\n");
10289 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
10291 " MED is propagated unchanged to this neighbor\n");
10292 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
10293 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
10294 PEER_FLAG_SEND_EXT_COMMUNITY
)
10295 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
10296 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
10298 " Community attribute sent to this neighbor");
10299 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10300 PEER_FLAG_SEND_COMMUNITY
)
10301 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
10302 PEER_FLAG_SEND_EXT_COMMUNITY
)
10303 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
10304 PEER_FLAG_SEND_LARGE_COMMUNITY
))
10305 vty_out(vty
, "(all)\n");
10306 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10307 PEER_FLAG_SEND_LARGE_COMMUNITY
))
10308 vty_out(vty
, "(large)\n");
10309 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10310 PEER_FLAG_SEND_EXT_COMMUNITY
))
10311 vty_out(vty
, "(extended)\n");
10313 vty_out(vty
, "(standard)\n");
10315 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10316 PEER_FLAG_DEFAULT_ORIGINATE
)) {
10317 vty_out(vty
, " Default information originate,");
10319 if (p
->default_rmap
[afi
][safi
].name
)
10320 vty_out(vty
, " default route-map %s%s,",
10321 p
->default_rmap
[afi
][safi
].map
? "*"
10323 p
->default_rmap
[afi
][safi
].name
);
10324 if (paf
&& PAF_SUBGRP(paf
)
10325 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
10326 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
10327 vty_out(vty
, " default sent\n");
10329 vty_out(vty
, " default not sent\n");
10332 /* advertise-vni-all */
10333 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
10334 if (is_evpn_enabled())
10335 vty_out(vty
, " advertise-all-vni\n");
10338 if (filter
->plist
[FILTER_IN
].name
10339 || filter
->dlist
[FILTER_IN
].name
10340 || filter
->aslist
[FILTER_IN
].name
10341 || filter
->map
[RMAP_IN
].name
)
10342 vty_out(vty
, " Inbound path policy configured\n");
10343 if (filter
->plist
[FILTER_OUT
].name
10344 || filter
->dlist
[FILTER_OUT
].name
10345 || filter
->aslist
[FILTER_OUT
].name
10346 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
10347 vty_out(vty
, " Outbound path policy configured\n");
10350 if (filter
->plist
[FILTER_IN
].name
)
10352 " Incoming update prefix filter list is %s%s\n",
10353 filter
->plist
[FILTER_IN
].plist
? "*" : "",
10354 filter
->plist
[FILTER_IN
].name
);
10355 if (filter
->plist
[FILTER_OUT
].name
)
10357 " Outgoing update prefix filter list is %s%s\n",
10358 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
10359 filter
->plist
[FILTER_OUT
].name
);
10361 /* distribute-list */
10362 if (filter
->dlist
[FILTER_IN
].name
)
10364 " Incoming update network filter list is %s%s\n",
10365 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
10366 filter
->dlist
[FILTER_IN
].name
);
10367 if (filter
->dlist
[FILTER_OUT
].name
)
10369 " Outgoing update network filter list is %s%s\n",
10370 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
10371 filter
->dlist
[FILTER_OUT
].name
);
10374 if (filter
->aslist
[FILTER_IN
].name
)
10376 " Incoming update AS path filter list is %s%s\n",
10377 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
10378 filter
->aslist
[FILTER_IN
].name
);
10379 if (filter
->aslist
[FILTER_OUT
].name
)
10381 " Outgoing update AS path filter list is %s%s\n",
10382 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
10383 filter
->aslist
[FILTER_OUT
].name
);
10386 if (filter
->map
[RMAP_IN
].name
)
10388 " Route map for incoming advertisements is %s%s\n",
10389 filter
->map
[RMAP_IN
].map
? "*" : "",
10390 filter
->map
[RMAP_IN
].name
);
10391 if (filter
->map
[RMAP_OUT
].name
)
10393 " Route map for outgoing advertisements is %s%s\n",
10394 filter
->map
[RMAP_OUT
].map
? "*" : "",
10395 filter
->map
[RMAP_OUT
].name
);
10397 /* ebgp-requires-policy (inbound) */
10398 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
10399 && !bgp_inbound_policy_exists(p
, filter
))
10401 " Inbound updates discarded due to missing policy\n");
10403 /* ebgp-requires-policy (outbound) */
10404 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
10405 && !bgp_outbound_policy_exists(p
, filter
))
10407 " Outbound updates discarded due to missing policy\n");
10409 /* unsuppress-map */
10410 if (filter
->usmap
.name
)
10412 " Route map for selective unsuppress is %s%s\n",
10413 filter
->usmap
.map
? "*" : "",
10414 filter
->usmap
.name
);
10416 /* Receive prefix count */
10417 vty_out(vty
, " %" PRIu32
" accepted prefixes\n",
10418 p
->pcount
[afi
][safi
]);
10420 /* maximum-prefix-out */
10421 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10422 PEER_FLAG_MAX_PREFIX_OUT
))
10424 " Maximum allowed prefixes sent %" PRIu32
"\n",
10425 p
->pmax_out
[afi
][safi
]);
10427 /* Maximum prefix */
10428 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
10430 " Maximum prefixes allowed %" PRIu32
"%s\n",
10431 p
->pmax
[afi
][safi
],
10432 CHECK_FLAG(p
->af_flags
[afi
][safi
],
10433 PEER_FLAG_MAX_PREFIX_WARNING
)
10434 ? " (warning-only)"
10436 vty_out(vty
, " Threshold for warning message %d%%",
10437 p
->pmax_threshold
[afi
][safi
]);
10438 if (p
->pmax_restart
[afi
][safi
])
10439 vty_out(vty
, ", restart interval %d min",
10440 p
->pmax_restart
[afi
][safi
]);
10441 vty_out(vty
, "\n");
10444 vty_out(vty
, "\n");
10448 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
10452 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
10453 char timebuf
[BGP_UPTIME_LEN
];
10459 json_object
*json_neigh
= NULL
;
10465 json_neigh
= json_object_new_object();
10467 memset(dn_flag
, '\0', sizeof(dn_flag
));
10468 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
10472 if (p
->conf_if
) /* Configured interface name. */
10473 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
10474 BGP_PEER_SU_UNSPEC(p
)
10476 : sockunion2str(&p
->su
, buf
,
10478 else /* Configured IP address. */
10479 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
10484 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
10485 json_object_string_add(json_neigh
, "bgpNeighborAddr",
10487 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
10488 json_object_string_add(
10489 json_neigh
, "bgpNeighborAddr",
10490 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
10492 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
10494 if (p
->change_local_as
)
10495 json_object_int_add(json_neigh
, "localAs",
10496 p
->change_local_as
);
10498 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
10500 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
10501 json_object_boolean_true_add(json_neigh
,
10502 "localAsNoPrepend");
10504 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
10505 json_object_boolean_true_add(json_neigh
,
10506 "localAsReplaceAs");
10508 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
10509 || (p
->as_type
== AS_INTERNAL
))
10510 vty_out(vty
, "remote AS %u, ", p
->as
);
10512 vty_out(vty
, "remote AS Unspecified, ");
10513 vty_out(vty
, "local AS %u%s%s, ",
10514 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
10515 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
10518 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
10522 /* peer type internal or confed-internal */
10523 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
10525 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
10526 json_object_boolean_true_add(
10527 json_neigh
, "nbrConfedInternalLink");
10529 json_object_boolean_true_add(json_neigh
,
10530 "nbrInternalLink");
10532 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
10533 vty_out(vty
, "confed-internal link\n");
10535 vty_out(vty
, "internal link\n");
10537 /* peer type external or confed-external */
10538 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
10540 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
10541 json_object_boolean_true_add(
10542 json_neigh
, "nbrConfedExternalLink");
10544 json_object_boolean_true_add(json_neigh
,
10545 "nbrExternalLink");
10547 if (bgp_confederation_peers_check(bgp
, p
->as
))
10548 vty_out(vty
, "confed-external link\n");
10550 vty_out(vty
, "external link\n");
10554 json_object_boolean_true_add(json_neigh
,
10555 "nbrUnspecifiedLink");
10557 vty_out(vty
, "unspecified link\n");
10563 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
10565 vty_out(vty
, " Description: %s\n", p
->desc
);
10571 json_object_string_add(json_neigh
, "hostname",
10575 json_object_string_add(json_neigh
, "domainname",
10578 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
10579 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
10582 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
10589 json_object_string_add(json_neigh
, "peerGroup",
10593 struct prefix prefix
, *range
= NULL
;
10595 sockunion2hostprefix(&(p
->su
), &prefix
);
10596 range
= peer_group_lookup_dynamic_neighbor_range(
10597 p
->group
, &prefix
);
10600 prefix2str(range
, buf1
, sizeof(buf1
));
10601 json_object_string_add(
10603 "peerSubnetRangeGroup", buf1
);
10608 " Member of peer-group %s for session parameters\n",
10612 struct prefix prefix
, *range
= NULL
;
10614 sockunion2hostprefix(&(p
->su
), &prefix
);
10615 range
= peer_group_lookup_dynamic_neighbor_range(
10616 p
->group
, &prefix
);
10619 prefix2str(range
, buf1
, sizeof(buf1
));
10621 " Belongs to the subnet range group: %s\n",
10629 /* Administrative shutdown. */
10630 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
10631 json_object_boolean_true_add(json_neigh
,
10635 json_object_int_add(json_neigh
, "bgpVersion", 4);
10636 json_object_string_add(
10637 json_neigh
, "remoteRouterId",
10638 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
10639 json_object_string_add(
10640 json_neigh
, "localRouterId",
10641 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
10644 /* Confederation */
10645 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
10646 && bgp_confederation_peers_check(bgp
, p
->as
))
10647 json_object_boolean_true_add(json_neigh
,
10651 json_object_string_add(
10652 json_neigh
, "bgpState",
10653 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
10655 if (p
->status
== Established
) {
10658 uptime
= bgp_clock();
10659 uptime
-= p
->uptime
;
10660 epoch_tbuf
= time(NULL
) - uptime
;
10662 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
10664 json_object_string_add(json_neigh
, "bgpTimerUpString",
10665 peer_uptime(p
->uptime
, timebuf
,
10668 json_object_int_add(json_neigh
,
10669 "bgpTimerUpEstablishedEpoch",
10673 else if (p
->status
== Active
) {
10674 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
10675 json_object_string_add(json_neigh
, "bgpStateIs",
10677 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
10678 json_object_string_add(json_neigh
, "bgpStateIs",
10686 uptime
= bgp_clock();
10687 uptime
-= p
->readtime
;
10688 tm
= gmtime(&uptime
);
10689 json_object_int_add(json_neigh
, "bgpTimerLastRead",
10690 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
10691 + (tm
->tm_hour
* 3600000));
10693 uptime
= bgp_clock();
10694 uptime
-= p
->last_write
;
10695 tm
= gmtime(&uptime
);
10696 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
10697 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
10698 + (tm
->tm_hour
* 3600000));
10700 uptime
= bgp_clock();
10701 uptime
-= p
->update_time
;
10702 tm
= gmtime(&uptime
);
10703 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
10704 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
10705 + (tm
->tm_hour
* 3600000));
10707 /* Configured timer values. */
10708 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
10709 p
->v_holdtime
* 1000);
10710 json_object_int_add(json_neigh
,
10711 "bgpTimerKeepAliveIntervalMsecs",
10712 p
->v_keepalive
* 1000);
10713 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
10714 json_object_int_add(json_neigh
,
10715 "bgpTimerConfiguredHoldTimeMsecs",
10716 p
->holdtime
* 1000);
10717 json_object_int_add(
10719 "bgpTimerConfiguredKeepAliveIntervalMsecs",
10720 p
->keepalive
* 1000);
10721 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
10722 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
10723 json_object_int_add(json_neigh
,
10724 "bgpTimerConfiguredHoldTimeMsecs",
10725 bgp
->default_holdtime
);
10726 json_object_int_add(
10728 "bgpTimerConfiguredKeepAliveIntervalMsecs",
10729 bgp
->default_keepalive
);
10732 /* Administrative shutdown. */
10733 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
10734 vty_out(vty
, " Administratively shut down\n");
10737 vty_out(vty
, " BGP version 4");
10738 vty_out(vty
, ", remote router ID %s",
10739 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
10740 vty_out(vty
, ", local router ID %s\n",
10741 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
10744 /* Confederation */
10745 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
10746 && bgp_confederation_peers_check(bgp
, p
->as
))
10748 " Neighbor under common administration\n");
10751 vty_out(vty
, " BGP state = %s",
10752 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
10754 if (p
->status
== Established
)
10755 vty_out(vty
, ", up for %8s",
10756 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10759 else if (p
->status
== Active
) {
10760 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
10761 vty_out(vty
, " (passive)");
10762 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
10763 vty_out(vty
, " (NSF passive)");
10765 vty_out(vty
, "\n");
10768 vty_out(vty
, " Last read %s",
10769 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
10771 vty_out(vty
, ", Last write %s\n",
10772 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
10775 /* Configured timer values. */
10777 " Hold time is %d, keepalive interval is %d seconds\n",
10778 p
->v_holdtime
, p
->v_keepalive
);
10779 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
10780 vty_out(vty
, " Configured hold time is %d",
10782 vty_out(vty
, ", keepalive interval is %d seconds\n",
10784 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
10785 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
10786 vty_out(vty
, " Configured hold time is %d",
10787 bgp
->default_holdtime
);
10788 vty_out(vty
, ", keepalive interval is %d seconds\n",
10789 bgp
->default_keepalive
);
10793 if (p
->status
== Established
) {
10794 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
10795 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
10796 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
10797 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
10798 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
10799 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
10800 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
10801 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
10802 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
10803 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
10804 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
10805 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
10806 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
10807 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
10808 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
10809 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
10810 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
10811 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
10812 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
10813 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
10815 json_object
*json_cap
= NULL
;
10817 json_cap
= json_object_new_object();
10820 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
10821 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
10822 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
10823 && CHECK_FLAG(p
->cap
,
10825 json_object_string_add(
10826 json_cap
, "4byteAs",
10827 "advertisedAndReceived");
10828 else if (CHECK_FLAG(p
->cap
,
10830 json_object_string_add(
10831 json_cap
, "4byteAs",
10833 else if (CHECK_FLAG(p
->cap
,
10835 json_object_string_add(
10836 json_cap
, "4byteAs",
10841 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
10842 || CHECK_FLAG(p
->cap
,
10843 PEER_CAP_ADDPATH_ADV
)) {
10844 json_object
*json_add
= NULL
;
10845 const char *print_store
;
10847 json_add
= json_object_new_object();
10849 FOREACH_AFI_SAFI (afi
, safi
) {
10850 json_object
*json_sub
= NULL
;
10852 json_object_new_object();
10853 print_store
= get_afi_safi_str(
10859 PEER_CAP_ADDPATH_AF_TX_ADV
)
10863 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
10868 PEER_CAP_ADDPATH_AF_TX_ADV
)
10873 PEER_CAP_ADDPATH_AF_TX_RCV
))
10874 json_object_boolean_true_add(
10876 "txAdvertisedAndReceived");
10882 PEER_CAP_ADDPATH_AF_TX_ADV
))
10883 json_object_boolean_true_add(
10891 PEER_CAP_ADDPATH_AF_TX_RCV
))
10892 json_object_boolean_true_add(
10900 PEER_CAP_ADDPATH_AF_RX_ADV
)
10904 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
10909 PEER_CAP_ADDPATH_AF_RX_ADV
)
10914 PEER_CAP_ADDPATH_AF_RX_RCV
))
10915 json_object_boolean_true_add(
10917 "rxAdvertisedAndReceived");
10923 PEER_CAP_ADDPATH_AF_RX_ADV
))
10924 json_object_boolean_true_add(
10932 PEER_CAP_ADDPATH_AF_RX_RCV
))
10933 json_object_boolean_true_add(
10941 PEER_CAP_ADDPATH_AF_TX_ADV
)
10945 PEER_CAP_ADDPATH_AF_TX_RCV
)
10949 PEER_CAP_ADDPATH_AF_RX_ADV
)
10953 PEER_CAP_ADDPATH_AF_RX_RCV
))
10954 json_object_object_add(
10963 json_object_object_add(
10964 json_cap
, "addPath", json_add
);
10968 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10969 || CHECK_FLAG(p
->cap
,
10970 PEER_CAP_DYNAMIC_ADV
)) {
10971 if (CHECK_FLAG(p
->cap
,
10972 PEER_CAP_DYNAMIC_ADV
)
10973 && CHECK_FLAG(p
->cap
,
10974 PEER_CAP_DYNAMIC_RCV
))
10975 json_object_string_add(
10976 json_cap
, "dynamic",
10977 "advertisedAndReceived");
10978 else if (CHECK_FLAG(
10980 PEER_CAP_DYNAMIC_ADV
))
10981 json_object_string_add(
10982 json_cap
, "dynamic",
10984 else if (CHECK_FLAG(
10986 PEER_CAP_DYNAMIC_RCV
))
10987 json_object_string_add(
10988 json_cap
, "dynamic",
10992 /* Extended nexthop */
10993 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10994 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10995 json_object
*json_nxt
= NULL
;
10996 const char *print_store
;
10999 if (CHECK_FLAG(p
->cap
,
11001 && CHECK_FLAG(p
->cap
,
11002 PEER_CAP_ENHE_RCV
))
11003 json_object_string_add(
11006 "advertisedAndReceived");
11007 else if (CHECK_FLAG(p
->cap
,
11008 PEER_CAP_ENHE_ADV
))
11009 json_object_string_add(
11013 else if (CHECK_FLAG(p
->cap
,
11014 PEER_CAP_ENHE_RCV
))
11015 json_object_string_add(
11020 if (CHECK_FLAG(p
->cap
,
11021 PEER_CAP_ENHE_RCV
)) {
11023 json_object_new_object();
11025 for (safi
= SAFI_UNICAST
;
11026 safi
< SAFI_MAX
; safi
++) {
11031 PEER_CAP_ENHE_AF_RCV
)) {
11032 print_store
= get_afi_safi_str(
11035 json_object_string_add(
11038 "recieved"); /* misspelled for compatibility */
11041 json_object_object_add(
11043 "extendedNexthopFamililesByPeer",
11048 /* Route Refresh */
11049 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
11050 || CHECK_FLAG(p
->cap
,
11051 PEER_CAP_REFRESH_NEW_RCV
)
11052 || CHECK_FLAG(p
->cap
,
11053 PEER_CAP_REFRESH_OLD_RCV
)) {
11054 if (CHECK_FLAG(p
->cap
,
11055 PEER_CAP_REFRESH_ADV
)
11058 PEER_CAP_REFRESH_NEW_RCV
)
11061 PEER_CAP_REFRESH_OLD_RCV
))) {
11064 PEER_CAP_REFRESH_OLD_RCV
)
11067 PEER_CAP_REFRESH_NEW_RCV
))
11068 json_object_string_add(
11071 "advertisedAndReceivedOldNew");
11075 PEER_CAP_REFRESH_OLD_RCV
))
11076 json_object_string_add(
11079 "advertisedAndReceivedOld");
11081 json_object_string_add(
11084 "advertisedAndReceivedNew");
11089 PEER_CAP_REFRESH_ADV
))
11090 json_object_string_add(
11097 PEER_CAP_REFRESH_NEW_RCV
)
11100 PEER_CAP_REFRESH_OLD_RCV
))
11101 json_object_string_add(
11107 /* Multiprotocol Extensions */
11108 json_object
*json_multi
= NULL
;
11109 json_multi
= json_object_new_object();
11111 FOREACH_AFI_SAFI (afi
, safi
) {
11112 if (p
->afc_adv
[afi
][safi
]
11113 || p
->afc_recv
[afi
][safi
]) {
11114 json_object
*json_exten
= NULL
;
11116 json_object_new_object();
11118 if (p
->afc_adv
[afi
][safi
]
11119 && p
->afc_recv
[afi
][safi
])
11120 json_object_boolean_true_add(
11122 "advertisedAndReceived");
11123 else if (p
->afc_adv
[afi
][safi
])
11124 json_object_boolean_true_add(
11127 else if (p
->afc_recv
[afi
][safi
])
11128 json_object_boolean_true_add(
11132 json_object_object_add(
11134 get_afi_safi_str(afi
,
11140 json_object_object_add(
11141 json_cap
, "multiprotocolExtensions",
11144 /* Hostname capabilities */
11145 json_object
*json_hname
= NULL
;
11147 json_hname
= json_object_new_object();
11149 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
11150 json_object_string_add(
11151 json_hname
, "advHostName",
11152 bgp
->peer_self
->hostname
11156 json_object_string_add(
11157 json_hname
, "advDomainName",
11158 bgp
->peer_self
->domainname
11165 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
11166 json_object_string_add(
11167 json_hname
, "rcvHostName",
11168 p
->hostname
? p
->hostname
11170 json_object_string_add(
11171 json_hname
, "rcvDomainName",
11172 p
->domainname
? p
->domainname
11176 json_object_object_add(json_cap
, "hostName",
11179 /* Gracefull Restart */
11180 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
11181 || CHECK_FLAG(p
->cap
,
11182 PEER_CAP_RESTART_ADV
)) {
11183 if (CHECK_FLAG(p
->cap
,
11184 PEER_CAP_RESTART_ADV
)
11185 && CHECK_FLAG(p
->cap
,
11186 PEER_CAP_RESTART_RCV
))
11187 json_object_string_add(
11190 "advertisedAndReceived");
11191 else if (CHECK_FLAG(
11193 PEER_CAP_RESTART_ADV
))
11194 json_object_string_add(
11196 "gracefulRestartCapability",
11198 else if (CHECK_FLAG(
11200 PEER_CAP_RESTART_RCV
))
11201 json_object_string_add(
11203 "gracefulRestartCapability",
11206 if (CHECK_FLAG(p
->cap
,
11207 PEER_CAP_RESTART_RCV
)) {
11208 int restart_af_count
= 0;
11209 json_object
*json_restart
=
11212 json_object_new_object();
11214 json_object_int_add(
11216 "gracefulRestartRemoteTimerMsecs",
11217 p
->v_gr_restart
* 1000);
11219 FOREACH_AFI_SAFI (afi
, safi
) {
11224 PEER_CAP_RESTART_AF_RCV
)) {
11229 json_object_new_object();
11235 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
11236 json_object_boolean_true_add(
11239 restart_af_count
++;
11240 json_object_object_add(
11249 if (!restart_af_count
) {
11250 json_object_string_add(
11252 "addressFamiliesByPeer",
11257 json_object_object_add(
11259 "addressFamiliesByPeer",
11263 json_object_object_add(json_neigh
,
11264 "neighborCapabilities",
11267 vty_out(vty
, " Neighbor capabilities:\n");
11270 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
11271 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
11272 vty_out(vty
, " 4 Byte AS:");
11273 if (CHECK_FLAG(p
->cap
,
11275 vty_out(vty
, " advertised");
11276 if (CHECK_FLAG(p
->cap
,
11278 vty_out(vty
, " %sreceived",
11284 vty_out(vty
, "\n");
11288 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
11289 || CHECK_FLAG(p
->cap
,
11290 PEER_CAP_ADDPATH_ADV
)) {
11291 vty_out(vty
, " AddPath:\n");
11293 FOREACH_AFI_SAFI (afi
, safi
) {
11297 PEER_CAP_ADDPATH_AF_TX_ADV
)
11301 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
11313 PEER_CAP_ADDPATH_AF_TX_ADV
))
11325 PEER_CAP_ADDPATH_AF_TX_RCV
))
11332 PEER_CAP_ADDPATH_AF_TX_ADV
)
11336 vty_out(vty
, "\n");
11342 PEER_CAP_ADDPATH_AF_RX_ADV
)
11346 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
11358 PEER_CAP_ADDPATH_AF_RX_ADV
))
11370 PEER_CAP_ADDPATH_AF_RX_RCV
))
11377 PEER_CAP_ADDPATH_AF_RX_ADV
)
11381 vty_out(vty
, "\n");
11387 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
11388 || CHECK_FLAG(p
->cap
,
11389 PEER_CAP_DYNAMIC_ADV
)) {
11390 vty_out(vty
, " Dynamic:");
11391 if (CHECK_FLAG(p
->cap
,
11392 PEER_CAP_DYNAMIC_ADV
))
11393 vty_out(vty
, " advertised");
11394 if (CHECK_FLAG(p
->cap
,
11395 PEER_CAP_DYNAMIC_RCV
))
11396 vty_out(vty
, " %sreceived",
11399 PEER_CAP_DYNAMIC_ADV
)
11402 vty_out(vty
, "\n");
11405 /* Extended nexthop */
11406 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
11407 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
11408 vty_out(vty
, " Extended nexthop:");
11409 if (CHECK_FLAG(p
->cap
,
11410 PEER_CAP_ENHE_ADV
))
11411 vty_out(vty
, " advertised");
11412 if (CHECK_FLAG(p
->cap
,
11413 PEER_CAP_ENHE_RCV
))
11414 vty_out(vty
, " %sreceived",
11420 vty_out(vty
, "\n");
11422 if (CHECK_FLAG(p
->cap
,
11423 PEER_CAP_ENHE_RCV
)) {
11425 " Address families by peer:\n ");
11426 for (safi
= SAFI_UNICAST
;
11427 safi
< SAFI_MAX
; safi
++)
11432 PEER_CAP_ENHE_AF_RCV
))
11442 /* Route Refresh */
11443 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
11444 || CHECK_FLAG(p
->cap
,
11445 PEER_CAP_REFRESH_NEW_RCV
)
11446 || CHECK_FLAG(p
->cap
,
11447 PEER_CAP_REFRESH_OLD_RCV
)) {
11448 vty_out(vty
, " Route refresh:");
11449 if (CHECK_FLAG(p
->cap
,
11450 PEER_CAP_REFRESH_ADV
))
11451 vty_out(vty
, " advertised");
11452 if (CHECK_FLAG(p
->cap
,
11453 PEER_CAP_REFRESH_NEW_RCV
)
11456 PEER_CAP_REFRESH_OLD_RCV
))
11457 vty_out(vty
, " %sreceived(%s)",
11460 PEER_CAP_REFRESH_ADV
)
11465 PEER_CAP_REFRESH_OLD_RCV
)
11468 PEER_CAP_REFRESH_NEW_RCV
))
11472 PEER_CAP_REFRESH_OLD_RCV
)
11476 vty_out(vty
, "\n");
11479 /* Multiprotocol Extensions */
11480 FOREACH_AFI_SAFI (afi
, safi
)
11481 if (p
->afc_adv
[afi
][safi
]
11482 || p
->afc_recv
[afi
][safi
]) {
11484 " Address Family %s:",
11489 if (p
->afc_adv
[afi
][safi
])
11492 if (p
->afc_recv
[afi
][safi
])
11499 vty_out(vty
, "\n");
11502 /* Hostname capability */
11503 vty_out(vty
, " Hostname Capability:");
11505 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
11507 " advertised (name: %s,domain name: %s)",
11508 bgp
->peer_self
->hostname
11512 bgp
->peer_self
->domainname
11517 vty_out(vty
, " not advertised");
11520 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
11522 " received (name: %s,domain name: %s)",
11523 p
->hostname
? p
->hostname
11525 p
->domainname
? p
->domainname
11528 vty_out(vty
, " not received");
11531 vty_out(vty
, "\n");
11533 /* Gracefull Restart */
11534 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
11535 || CHECK_FLAG(p
->cap
,
11536 PEER_CAP_RESTART_ADV
)) {
11538 " Graceful Restart Capabilty:");
11539 if (CHECK_FLAG(p
->cap
,
11540 PEER_CAP_RESTART_ADV
))
11541 vty_out(vty
, " advertised");
11542 if (CHECK_FLAG(p
->cap
,
11543 PEER_CAP_RESTART_RCV
))
11544 vty_out(vty
, " %sreceived",
11547 PEER_CAP_RESTART_ADV
)
11550 vty_out(vty
, "\n");
11552 if (CHECK_FLAG(p
->cap
,
11553 PEER_CAP_RESTART_RCV
)) {
11554 int restart_af_count
= 0;
11557 " Remote Restart timer is %d seconds\n",
11560 " Address families by peer:\n ");
11562 FOREACH_AFI_SAFI (afi
, safi
)
11567 PEER_CAP_RESTART_AF_RCV
)) {
11581 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
11583 : "not preserved");
11584 restart_af_count
++;
11586 if (!restart_af_count
)
11587 vty_out(vty
, "none");
11588 vty_out(vty
, "\n");
11590 } /* Gracefull Restart */
11595 /* graceful restart information */
11596 json_object
*json_grace
= NULL
;
11597 json_object
*json_grace_send
= NULL
;
11598 json_object
*json_grace_recv
= NULL
;
11599 int eor_send_af_count
= 0;
11600 int eor_receive_af_count
= 0;
11603 json_grace
= json_object_new_object();
11604 json_grace_send
= json_object_new_object();
11605 json_grace_recv
= json_object_new_object();
11607 if ((p
->status
== Established
)
11608 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
11609 FOREACH_AFI_SAFI (afi
, safi
) {
11610 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11611 PEER_STATUS_EOR_SEND
)) {
11612 json_object_boolean_true_add(
11614 get_afi_safi_str(afi
,
11617 eor_send_af_count
++;
11620 FOREACH_AFI_SAFI (afi
, safi
) {
11622 p
->af_sflags
[afi
][safi
],
11623 PEER_STATUS_EOR_RECEIVED
)) {
11624 json_object_boolean_true_add(
11626 get_afi_safi_str(afi
,
11629 eor_receive_af_count
++;
11633 json_object_object_add(json_grace
, "endOfRibSend",
11635 json_object_object_add(json_grace
, "endOfRibRecv",
11639 if (p
->t_gr_restart
)
11640 json_object_int_add(json_grace
,
11641 "gracefulRestartTimerMsecs",
11642 thread_timer_remain_second(
11647 json_object_int_add(
11649 "gracefulStalepathTimerMsecs",
11650 thread_timer_remain_second(
11653 /* more gr info in new format */
11654 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
,
11656 json_object_object_add(
11657 json_neigh
, "gracefulRestartInfo", json_grace
);
11659 vty_out(vty
, " Graceful restart informations:\n");
11660 if ((p
->status
== Established
)
11661 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
11663 vty_out(vty
, " End-of-RIB send: ");
11664 FOREACH_AFI_SAFI (afi
, safi
) {
11665 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11666 PEER_STATUS_EOR_SEND
)) {
11667 vty_out(vty
, "%s%s",
11668 eor_send_af_count
? ", "
11673 eor_send_af_count
++;
11676 vty_out(vty
, "\n");
11677 vty_out(vty
, " End-of-RIB received: ");
11678 FOREACH_AFI_SAFI (afi
, safi
) {
11680 p
->af_sflags
[afi
][safi
],
11681 PEER_STATUS_EOR_RECEIVED
)) {
11682 vty_out(vty
, "%s%s",
11683 eor_receive_af_count
11686 get_afi_safi_str(afi
,
11689 eor_receive_af_count
++;
11692 vty_out(vty
, "\n");
11695 if (p
->t_gr_restart
)
11697 " The remaining time of restart timer is %ld\n",
11698 thread_timer_remain_second(
11703 " The remaining time of stalepath timer is %ld\n",
11704 thread_timer_remain_second(
11707 /* more gr info in new format */
11708 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
11712 json_object
*json_stat
= NULL
;
11713 json_stat
= json_object_new_object();
11714 /* Packet counts. */
11715 json_object_int_add(json_stat
, "depthInq", 0);
11716 json_object_int_add(json_stat
, "depthOutq",
11717 (unsigned long)p
->obuf
->count
);
11718 json_object_int_add(json_stat
, "opensSent",
11719 atomic_load_explicit(&p
->open_out
,
11720 memory_order_relaxed
));
11721 json_object_int_add(json_stat
, "opensRecv",
11722 atomic_load_explicit(&p
->open_in
,
11723 memory_order_relaxed
));
11724 json_object_int_add(json_stat
, "notificationsSent",
11725 atomic_load_explicit(&p
->notify_out
,
11726 memory_order_relaxed
));
11727 json_object_int_add(json_stat
, "notificationsRecv",
11728 atomic_load_explicit(&p
->notify_in
,
11729 memory_order_relaxed
));
11730 json_object_int_add(json_stat
, "updatesSent",
11731 atomic_load_explicit(&p
->update_out
,
11732 memory_order_relaxed
));
11733 json_object_int_add(json_stat
, "updatesRecv",
11734 atomic_load_explicit(&p
->update_in
,
11735 memory_order_relaxed
));
11736 json_object_int_add(json_stat
, "keepalivesSent",
11737 atomic_load_explicit(&p
->keepalive_out
,
11738 memory_order_relaxed
));
11739 json_object_int_add(json_stat
, "keepalivesRecv",
11740 atomic_load_explicit(&p
->keepalive_in
,
11741 memory_order_relaxed
));
11742 json_object_int_add(json_stat
, "routeRefreshSent",
11743 atomic_load_explicit(&p
->refresh_out
,
11744 memory_order_relaxed
));
11745 json_object_int_add(json_stat
, "routeRefreshRecv",
11746 atomic_load_explicit(&p
->refresh_in
,
11747 memory_order_relaxed
));
11748 json_object_int_add(json_stat
, "capabilitySent",
11749 atomic_load_explicit(&p
->dynamic_cap_out
,
11750 memory_order_relaxed
));
11751 json_object_int_add(json_stat
, "capabilityRecv",
11752 atomic_load_explicit(&p
->dynamic_cap_in
,
11753 memory_order_relaxed
));
11754 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
11755 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
11756 json_object_object_add(json_neigh
, "messageStats", json_stat
);
11758 /* Packet counts. */
11759 vty_out(vty
, " Message statistics:\n");
11760 vty_out(vty
, " Inq depth is 0\n");
11761 vty_out(vty
, " Outq depth is %lu\n",
11762 (unsigned long)p
->obuf
->count
);
11763 vty_out(vty
, " Sent Rcvd\n");
11764 vty_out(vty
, " Opens: %10d %10d\n",
11765 atomic_load_explicit(&p
->open_out
,
11766 memory_order_relaxed
),
11767 atomic_load_explicit(&p
->open_in
,
11768 memory_order_relaxed
));
11769 vty_out(vty
, " Notifications: %10d %10d\n",
11770 atomic_load_explicit(&p
->notify_out
,
11771 memory_order_relaxed
),
11772 atomic_load_explicit(&p
->notify_in
,
11773 memory_order_relaxed
));
11774 vty_out(vty
, " Updates: %10d %10d\n",
11775 atomic_load_explicit(&p
->update_out
,
11776 memory_order_relaxed
),
11777 atomic_load_explicit(&p
->update_in
,
11778 memory_order_relaxed
));
11779 vty_out(vty
, " Keepalives: %10d %10d\n",
11780 atomic_load_explicit(&p
->keepalive_out
,
11781 memory_order_relaxed
),
11782 atomic_load_explicit(&p
->keepalive_in
,
11783 memory_order_relaxed
));
11784 vty_out(vty
, " Route Refresh: %10d %10d\n",
11785 atomic_load_explicit(&p
->refresh_out
,
11786 memory_order_relaxed
),
11787 atomic_load_explicit(&p
->refresh_in
,
11788 memory_order_relaxed
));
11789 vty_out(vty
, " Capability: %10d %10d\n",
11790 atomic_load_explicit(&p
->dynamic_cap_out
,
11791 memory_order_relaxed
),
11792 atomic_load_explicit(&p
->dynamic_cap_in
,
11793 memory_order_relaxed
));
11794 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
11799 /* advertisement-interval */
11800 json_object_int_add(json_neigh
,
11801 "minBtwnAdvertisementRunsTimerMsecs",
11802 p
->v_routeadv
* 1000);
11804 /* Update-source. */
11805 if (p
->update_if
|| p
->update_source
) {
11807 json_object_string_add(json_neigh
,
11810 else if (p
->update_source
)
11811 json_object_string_add(
11812 json_neigh
, "updateSource",
11813 sockunion2str(p
->update_source
, buf1
,
11817 /* advertisement-interval */
11819 " Minimum time between advertisement runs is %d seconds\n",
11822 /* Update-source. */
11823 if (p
->update_if
|| p
->update_source
) {
11824 vty_out(vty
, " Update source is ");
11826 vty_out(vty
, "%s", p
->update_if
);
11827 else if (p
->update_source
)
11829 sockunion2str(p
->update_source
, buf1
,
11831 vty_out(vty
, "\n");
11834 vty_out(vty
, "\n");
11837 /* Address Family Information */
11838 json_object
*json_hold
= NULL
;
11841 json_hold
= json_object_new_object();
11843 FOREACH_AFI_SAFI (afi
, safi
)
11844 if (p
->afc
[afi
][safi
])
11845 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
11849 json_object_object_add(json_neigh
, "addressFamilyInfo",
11851 json_object_int_add(json_neigh
, "connectionsEstablished",
11853 json_object_int_add(json_neigh
, "connectionsDropped",
11856 vty_out(vty
, " Connections established %d; dropped %d\n",
11857 p
->established
, p
->dropped
);
11859 if (!p
->last_reset
) {
11861 json_object_string_add(json_neigh
, "lastReset",
11864 vty_out(vty
, " Last reset never\n");
11870 uptime
= bgp_clock();
11871 uptime
-= p
->resettime
;
11872 tm
= gmtime(&uptime
);
11873 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
11874 (tm
->tm_sec
* 1000)
11875 + (tm
->tm_min
* 60000)
11876 + (tm
->tm_hour
* 3600000));
11877 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
11879 vty_out(vty
, " Last reset %s, ",
11880 peer_uptime(p
->resettime
, timebuf
,
11881 BGP_UPTIME_LEN
, 0, NULL
));
11883 bgp_show_peer_reset(vty
, p
, NULL
, false);
11884 if (p
->last_reset_cause_size
) {
11885 msg
= p
->last_reset_cause
;
11887 " Message received that caused BGP to send a NOTIFICATION:\n ");
11888 for (i
= 1; i
<= p
->last_reset_cause_size
;
11890 vty_out(vty
, "%02X", *msg
++);
11892 if (i
!= p
->last_reset_cause_size
) {
11894 vty_out(vty
, "\n ");
11895 } else if (i
% 4 == 0) {
11900 vty_out(vty
, "\n");
11905 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
11907 json_object_boolean_true_add(json_neigh
,
11908 "prefixesConfigExceedMax");
11911 " Peer had exceeded the max. no. of prefixes configured.\n");
11913 if (p
->t_pmax_restart
) {
11915 json_object_boolean_true_add(
11916 json_neigh
, "reducePrefixNumFrom");
11917 json_object_int_add(json_neigh
,
11918 "restartInTimerMsec",
11919 thread_timer_remain_second(
11924 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
11925 p
->host
, thread_timer_remain_second(
11926 p
->t_pmax_restart
));
11929 json_object_boolean_true_add(
11931 "reducePrefixNumAndClearIpBgp");
11934 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
11939 /* EBGP Multihop and GTSM */
11940 if (p
->sort
!= BGP_PEER_IBGP
) {
11942 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
11943 json_object_int_add(json_neigh
,
11944 "externalBgpNbrMaxHopsAway",
11946 else if (p
->ttl
> BGP_DEFAULT_TTL
)
11947 json_object_int_add(json_neigh
,
11948 "externalBgpNbrMaxHopsAway",
11951 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
11953 " External BGP neighbor may be up to %d hops away.\n",
11955 else if (p
->ttl
> BGP_DEFAULT_TTL
)
11957 " External BGP neighbor may be up to %d hops away.\n",
11961 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
) {
11963 json_object_int_add(json_neigh
,
11964 "internalBgpNbrMaxHopsAway",
11968 " Internal BGP neighbor may be up to %d hops away.\n",
11973 /* Local address. */
11976 json_object_string_add(json_neigh
, "hostLocal",
11977 sockunion2str(p
->su_local
, buf1
,
11979 json_object_int_add(json_neigh
, "portLocal",
11980 ntohs(p
->su_local
->sin
.sin_port
));
11982 vty_out(vty
, "Local host: %s, Local port: %d\n",
11983 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
11984 ntohs(p
->su_local
->sin
.sin_port
));
11987 /* Remote address. */
11988 if (p
->su_remote
) {
11990 json_object_string_add(json_neigh
, "hostForeign",
11991 sockunion2str(p
->su_remote
, buf1
,
11993 json_object_int_add(json_neigh
, "portForeign",
11994 ntohs(p
->su_remote
->sin
.sin_port
));
11996 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
11997 sockunion2str(p
->su_remote
, buf1
,
11999 ntohs(p
->su_remote
->sin
.sin_port
));
12002 /* Nexthop display. */
12005 json_object_string_add(json_neigh
, "nexthop",
12007 &p
->nexthop
.v4
, buf1
,
12009 json_object_string_add(json_neigh
, "nexthopGlobal",
12010 inet_ntop(AF_INET6
,
12011 &p
->nexthop
.v6_global
,
12012 buf1
, sizeof(buf1
)));
12013 json_object_string_add(json_neigh
, "nexthopLocal",
12014 inet_ntop(AF_INET6
,
12015 &p
->nexthop
.v6_local
,
12016 buf1
, sizeof(buf1
)));
12017 if (p
->shared_network
)
12018 json_object_string_add(json_neigh
,
12022 json_object_string_add(json_neigh
,
12024 "nonSharedNetwork");
12026 vty_out(vty
, "Nexthop: %s\n",
12027 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
12029 vty_out(vty
, "Nexthop global: %s\n",
12030 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
12032 vty_out(vty
, "Nexthop local: %s\n",
12033 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
12035 vty_out(vty
, "BGP connection: %s\n",
12036 p
->shared_network
? "shared network"
12037 : "non shared network");
12041 /* Timer information. */
12043 json_object_int_add(json_neigh
, "connectRetryTimer",
12045 if (p
->status
== Established
&& p
->rtt
)
12046 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
12049 json_object_int_add(
12050 json_neigh
, "nextStartTimerDueInMsecs",
12051 thread_timer_remain_second(p
->t_start
) * 1000);
12053 json_object_int_add(
12054 json_neigh
, "nextConnectTimerDueInMsecs",
12055 thread_timer_remain_second(p
->t_connect
)
12057 if (p
->t_routeadv
) {
12058 json_object_int_add(json_neigh
, "mraiInterval",
12060 json_object_int_add(
12061 json_neigh
, "mraiTimerExpireInMsecs",
12062 thread_timer_remain_second(p
->t_routeadv
)
12066 json_object_int_add(json_neigh
, "authenticationEnabled",
12070 json_object_string_add(json_neigh
, "readThread", "on");
12072 json_object_string_add(json_neigh
, "readThread", "off");
12074 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
12075 json_object_string_add(json_neigh
, "writeThread", "on");
12077 json_object_string_add(json_neigh
, "writeThread",
12080 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
12082 if (p
->status
== Established
&& p
->rtt
)
12083 vty_out(vty
, "Estimated round trip time: %d ms\n",
12086 vty_out(vty
, "Next start timer due in %ld seconds\n",
12087 thread_timer_remain_second(p
->t_start
));
12089 vty_out(vty
, "Next connect timer due in %ld seconds\n",
12090 thread_timer_remain_second(p
->t_connect
));
12093 "MRAI (interval %u) timer expires in %ld seconds\n",
12095 thread_timer_remain_second(p
->t_routeadv
));
12097 vty_out(vty
, "Peer Authentication Enabled\n");
12099 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
12100 p
->t_read
? "on" : "off",
12101 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
12106 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
12107 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
12108 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
12111 vty_out(vty
, "\n");
12113 /* BFD information. */
12114 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
12117 if (p
->conf_if
) /* Configured interface name. */
12118 json_object_object_add(json
, p
->conf_if
, json_neigh
);
12119 else /* Configured IP address. */
12120 json_object_object_add(json
, p
->host
, json_neigh
);
12124 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
12125 enum show_type type
,
12126 union sockunion
*su
,
12127 const char *conf_if
, afi_t afi
,
12128 bool use_json
, json_object
*json
)
12130 struct listnode
*node
, *nnode
;
12133 safi_t safi
= SAFI_UNICAST
;
12134 json_object
*json_neighbor
= NULL
;
12136 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
12138 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
12141 if ((peer
->afc
[afi
][safi
]) == 0)
12145 json_neighbor
= json_object_new_object();
12147 if (type
== show_all
) {
12148 bgp_show_peer_gr_status(vty
, peer
, use_json
,
12152 json_object_object_add(json
, peer
->host
,
12155 } else if (type
== show_peer
) {
12158 && !strcmp(peer
->conf_if
, conf_if
))
12160 && !strcmp(peer
->hostname
, conf_if
))) {
12162 bgp_show_peer_gr_status(vty
, peer
,
12167 if (sockunion_same(&peer
->su
, su
)) {
12169 bgp_show_peer_gr_status(vty
, peer
,
12174 if (use_json
&& find
)
12175 json_object_object_add(json
, peer
->host
,
12183 if (type
== show_peer
&& !find
) {
12185 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
12187 vty_out(vty
, "%% No such neighbor\n");
12190 vty_out(vty
, "%s\n",
12191 json_object_to_json_string_ext(
12192 json
, JSON_C_TO_STRING_PRETTY
));
12194 vty_out(vty
, "\n");
12197 return CMD_SUCCESS
;
12200 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
12201 enum show_type type
, union sockunion
*su
,
12202 const char *conf_if
, bool use_json
,
12205 struct listnode
*node
, *nnode
;
12208 bool nbr_output
= false;
12209 afi_t afi
= AFI_MAX
;
12210 safi_t safi
= SAFI_MAX
;
12212 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
12214 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
12218 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
12219 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
12224 bgp_show_peer(vty
, peer
, use_json
, json
);
12230 && !strcmp(peer
->conf_if
, conf_if
))
12232 && !strcmp(peer
->hostname
, conf_if
))) {
12234 bgp_show_peer(vty
, peer
, use_json
,
12238 if (sockunion_same(&peer
->su
, su
)) {
12240 bgp_show_peer(vty
, peer
, use_json
,
12245 case show_ipv4_peer
:
12246 case show_ipv6_peer
:
12247 FOREACH_SAFI (safi
) {
12248 if (peer
->afc
[afi
][safi
]) {
12251 && !strcmp(peer
->conf_if
, conf_if
))
12253 && !strcmp(peer
->hostname
, conf_if
))) {
12255 bgp_show_peer(vty
, peer
, use_json
,
12260 if (sockunion_same(&peer
->su
, su
)) {
12262 bgp_show_peer(vty
, peer
, use_json
,
12270 case show_ipv4_all
:
12271 case show_ipv6_all
:
12272 FOREACH_SAFI (safi
) {
12273 if (peer
->afc
[afi
][safi
]) {
12274 bgp_show_peer(vty
, peer
, use_json
, json
);
12283 if ((type
== show_peer
|| type
== show_ipv4_peer
||
12284 type
== show_ipv6_peer
) && !find
) {
12286 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
12288 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
12291 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
12292 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
12293 vty_out(vty
, "%% No BGP neighbors found\n");
12296 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
12297 json
, JSON_C_TO_STRING_PRETTY
));
12299 vty_out(vty
, "\n");
12302 return CMD_SUCCESS
;
12305 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
12306 enum show_type type
,
12307 const char *ip_str
,
12308 afi_t afi
, bool use_json
)
12313 union sockunion su
;
12314 json_object
*json
= NULL
;
12316 bgp
= bgp_get_default();
12322 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
12325 json
= json_object_new_object();
12327 ret
= str2sockunion(ip_str
, &su
);
12329 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
,
12333 bgp_show_neighbor_graceful_restart(
12334 vty
, bgp
, type
, &su
, NULL
, afi
, use_json
, json
);
12336 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
12337 afi
, use_json
, json
);
12338 json_object_free(json
);
12341 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
12342 enum show_type type
,
12343 const char *ip_str
,
12346 struct listnode
*node
, *nnode
;
12348 union sockunion su
;
12349 json_object
*json
= NULL
;
12350 int ret
, is_first
= 1;
12351 bool nbr_output
= false;
12354 vty_out(vty
, "{\n");
12356 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
12359 if (!(json
= json_object_new_object())) {
12361 EC_BGP_JSON_MEM_ERROR
,
12362 "Unable to allocate memory for JSON object");
12364 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
12368 json_object_int_add(json
, "vrfId",
12369 (bgp
->vrf_id
== VRF_UNKNOWN
)
12371 : (int64_t)bgp
->vrf_id
);
12372 json_object_string_add(
12374 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
12379 vty_out(vty
, ",\n");
12383 vty_out(vty
, "\"%s\":",
12384 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
12388 vty_out(vty
, "\nInstance %s:\n",
12389 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
12394 if (type
== show_peer
|| type
== show_ipv4_peer
||
12395 type
== show_ipv6_peer
) {
12396 ret
= str2sockunion(ip_str
, &su
);
12398 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
12401 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
12404 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
12407 json_object_free(json
);
12411 vty_out(vty
, "}\n");
12412 json_object_free(json
);
12414 else if (!nbr_output
)
12415 vty_out(vty
, "%% BGP instance not found\n");
12418 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
12419 enum show_type type
, const char *ip_str
,
12424 union sockunion su
;
12425 json_object
*json
= NULL
;
12428 if (strmatch(name
, "all")) {
12429 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
12431 return CMD_SUCCESS
;
12433 bgp
= bgp_lookup_by_name(name
);
12436 json
= json_object_new_object();
12437 vty_out(vty
, "%s\n",
12438 json_object_to_json_string_ext(
12440 JSON_C_TO_STRING_PRETTY
));
12441 json_object_free(json
);
12444 "%% BGP instance not found\n");
12446 return CMD_WARNING
;
12450 bgp
= bgp_get_default();
12454 json
= json_object_new_object();
12456 ret
= str2sockunion(ip_str
, &su
);
12458 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
12461 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
12464 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
12467 json_object_free(json
);
12470 vty_out(vty
, "{}\n");
12472 vty_out(vty
, "%% BGP instance not found\n");
12475 return CMD_SUCCESS
;
12480 /* "show [ip] bgp neighbors graceful-restart" commands. */
12481 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
12482 show_ip_bgp_neighbors_graceful_restart_cmd
,
12483 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
12489 "Neighbor to display information about\n"
12490 "Neighbor to display information about\n"
12491 "Neighbor on BGP configured interface\n"
12495 char *sh_arg
= NULL
;
12496 enum show_type sh_type
;
12498 afi_t afi
= AFI_MAX
;
12499 bool uj
= use_json(argc
, argv
);
12501 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
12506 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
12507 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
12508 || argv_find(argv
, argc
, "WORD", &idx
)) {
12509 sh_type
= show_peer
;
12510 sh_arg
= argv
[idx
]->arg
;
12512 sh_type
= show_all
;
12514 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
12515 return CMD_SUCCESS
;
12518 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
12522 /* "show [ip] bgp neighbors" commands. */
12523 DEFUN (show_ip_bgp_neighbors
,
12524 show_ip_bgp_neighbors_cmd
,
12525 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
12529 BGP_INSTANCE_HELP_STR
12532 "Detailed information on TCP and BGP neighbor connections\n"
12533 "Neighbor to display information about\n"
12534 "Neighbor to display information about\n"
12535 "Neighbor on BGP configured interface\n"
12539 char *sh_arg
= NULL
;
12540 enum show_type sh_type
;
12541 afi_t afi
= AFI_MAX
;
12543 bool uj
= use_json(argc
, argv
);
12547 /* [<vrf> VIEWVRFNAME] */
12548 if (argv_find(argv
, argc
, "vrf", &idx
)) {
12549 vrf
= argv
[idx
+ 1]->arg
;
12550 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
12552 } else if (argv_find(argv
, argc
, "view", &idx
))
12553 /* [<view> VIEWVRFNAME] */
12554 vrf
= argv
[idx
+ 1]->arg
;
12558 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
12559 sh_type
= show_ipv4_all
;
12561 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
12562 sh_type
= show_ipv6_all
;
12565 sh_type
= show_all
;
12568 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
12569 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
12570 || argv_find(argv
, argc
, "WORD", &idx
)) {
12571 sh_type
= show_peer
;
12572 sh_arg
= argv
[idx
]->arg
;
12575 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
12576 sh_type
= show_ipv4_peer
;
12577 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
12578 sh_type
= show_ipv6_peer
;
12581 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
12584 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
12585 paths' and `show ip mbgp paths'. Those functions results are the
12587 DEFUN (show_ip_bgp_paths
,
12588 show_ip_bgp_paths_cmd
,
12589 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
12594 "Path information\n")
12596 vty_out(vty
, "Address Refcnt Path\n");
12597 aspath_print_all_vty(vty
);
12598 return CMD_SUCCESS
;
12603 static void community_show_all_iterator(struct hash_bucket
*bucket
,
12606 struct community
*com
;
12608 com
= (struct community
*)bucket
->data
;
12609 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
12610 community_str(com
, false));
12613 /* Show BGP's community internal data. */
12614 DEFUN (show_ip_bgp_community_info
,
12615 show_ip_bgp_community_info_cmd
,
12616 "show [ip] bgp community-info",
12620 "List all bgp community information\n")
12622 vty_out(vty
, "Address Refcnt Community\n");
12624 hash_iterate(community_hash(),
12625 (void (*)(struct hash_bucket
*,
12626 void *))community_show_all_iterator
,
12629 return CMD_SUCCESS
;
12632 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
12635 struct lcommunity
*lcom
;
12637 lcom
= (struct lcommunity
*)bucket
->data
;
12638 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
12639 lcommunity_str(lcom
, false));
12642 /* Show BGP's community internal data. */
12643 DEFUN (show_ip_bgp_lcommunity_info
,
12644 show_ip_bgp_lcommunity_info_cmd
,
12645 "show ip bgp large-community-info",
12649 "List all bgp large-community information\n")
12651 vty_out(vty
, "Address Refcnt Large-community\n");
12653 hash_iterate(lcommunity_hash(),
12654 (void (*)(struct hash_bucket
*,
12655 void *))lcommunity_show_all_iterator
,
12658 return CMD_SUCCESS
;
12660 /* Graceful Restart */
12662 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
12669 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
12671 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
12673 switch (bgp_global_gr_mode
) {
12675 case GLOBAL_HELPER
:
12676 vty_out(vty
, "Global BGP GR Mode : Helper\n");
12680 vty_out(vty
, "Global BGP GR Mode : Restart\n");
12683 case GLOBAL_DISABLE
:
12684 vty_out(vty
, "Global BGP GR Mode : Disable\n");
12687 case GLOBAL_INVALID
:
12689 "Global BGP GR Mode Invalid\n");
12692 vty_out(vty
, "\n");
12695 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
12696 enum show_type type
,
12697 const char *ip_str
,
12698 afi_t afi
, bool use_json
)
12700 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
12703 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
12705 bgp_show_neighbor_graceful_restart_vty(
12706 vty
, type
, ip_str
, afi
, use_json
);
12709 } else if (afi
!= AFI_MAX
) {
12710 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
12713 return CMD_ERR_INCOMPLETE
;
12716 return CMD_SUCCESS
;
12718 /* Graceful Restart */
12720 DEFUN (show_ip_bgp_attr_info
,
12721 show_ip_bgp_attr_info_cmd
,
12722 "show [ip] bgp attribute-info",
12726 "List all bgp attribute information\n")
12728 attr_show_all(vty
);
12729 return CMD_SUCCESS
;
12732 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
12733 afi_t afi
, safi_t safi
,
12734 bool use_json
, json_object
*json
)
12737 struct listnode
*node
;
12739 char buf1
[INET6_ADDRSTRLEN
];
12741 vpn_policy_direction_t dir
;
12744 json_object
*json_import_vrfs
= NULL
;
12745 json_object
*json_export_vrfs
= NULL
;
12747 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
12750 vty_out(vty
, "%s\n",
12751 json_object_to_json_string_ext(
12753 JSON_C_TO_STRING_PRETTY
));
12754 json_object_free(json
);
12756 return CMD_WARNING
;
12759 /* Provide context for the block */
12760 json_object_string_add(json
, "vrf", name
? name
: "default");
12761 json_object_string_add(json
, "afiSafi",
12762 get_afi_safi_str(afi
, safi
, true));
12764 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
12765 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
12766 json_object_string_add(json
, "importFromVrfs", "none");
12767 json_object_string_add(json
, "importRts", "none");
12769 json_import_vrfs
= json_object_new_array();
12771 for (ALL_LIST_ELEMENTS_RO(
12772 bgp
->vpn_policy
[afi
].import_vrf
,
12774 json_object_array_add(json_import_vrfs
,
12775 json_object_new_string(vname
));
12777 json_object_object_add(json
, "importFromVrfs",
12779 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
12780 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
12781 ecom_str
= ecommunity_ecom2str(
12782 bgp
->vpn_policy
[afi
].rtlist
[dir
],
12783 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
12784 json_object_string_add(json
, "importRts",
12786 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
12788 json_object_string_add(json
, "importRts",
12792 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
12793 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
12794 json_object_string_add(json
, "exportToVrfs", "none");
12795 json_object_string_add(json
, "routeDistinguisher",
12797 json_object_string_add(json
, "exportRts", "none");
12799 json_export_vrfs
= json_object_new_array();
12801 for (ALL_LIST_ELEMENTS_RO(
12802 bgp
->vpn_policy
[afi
].export_vrf
,
12804 json_object_array_add(json_export_vrfs
,
12805 json_object_new_string(vname
));
12806 json_object_object_add(json
, "exportToVrfs",
12808 json_object_string_add(json
, "routeDistinguisher",
12809 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
12810 buf1
, RD_ADDRSTRLEN
));
12812 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
12813 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
12814 ecom_str
= ecommunity_ecom2str(
12815 bgp
->vpn_policy
[afi
].rtlist
[dir
],
12816 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
12817 json_object_string_add(json
, "exportRts",
12819 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
12821 json_object_string_add(json
, "exportRts",
12826 vty_out(vty
, "%s\n",
12827 json_object_to_json_string_ext(json
,
12828 JSON_C_TO_STRING_PRETTY
));
12829 json_object_free(json
);
12832 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
12835 vty_out(vty
, "%% No such BGP instance exist\n");
12836 return CMD_WARNING
;
12839 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
12840 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
12842 "This VRF is not importing %s routes from any other VRF\n",
12843 get_afi_safi_str(afi
, safi
, false));
12846 "This VRF is importing %s routes from the following VRFs:\n",
12847 get_afi_safi_str(afi
, safi
, false));
12849 for (ALL_LIST_ELEMENTS_RO(
12850 bgp
->vpn_policy
[afi
].import_vrf
,
12852 vty_out(vty
, " %s\n", vname
);
12854 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
12856 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
12857 ecom_str
= ecommunity_ecom2str(
12858 bgp
->vpn_policy
[afi
].rtlist
[dir
],
12859 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
12860 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
12862 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
12864 vty_out(vty
, "Import RT(s):\n");
12867 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
12868 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12870 "This VRF is not exporting %s routes to any other VRF\n",
12871 get_afi_safi_str(afi
, safi
, false));
12874 "This VRF is exporting %s routes to the following VRFs:\n",
12875 get_afi_safi_str(afi
, safi
, false));
12877 for (ALL_LIST_ELEMENTS_RO(
12878 bgp
->vpn_policy
[afi
].export_vrf
,
12880 vty_out(vty
, " %s\n", vname
);
12882 vty_out(vty
, "RD: %s\n",
12883 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
12884 buf1
, RD_ADDRSTRLEN
));
12886 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
12887 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
12888 ecom_str
= ecommunity_ecom2str(
12889 bgp
->vpn_policy
[afi
].rtlist
[dir
],
12890 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
12891 vty_out(vty
, "Export RT: %s\n", ecom_str
);
12892 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
12894 vty_out(vty
, "Import RT(s):\n");
12898 return CMD_SUCCESS
;
12901 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
12902 safi_t safi
, bool use_json
)
12904 struct listnode
*node
, *nnode
;
12906 char *vrf_name
= NULL
;
12907 json_object
*json
= NULL
;
12908 json_object
*json_vrf
= NULL
;
12909 json_object
*json_vrfs
= NULL
;
12912 json
= json_object_new_object();
12913 json_vrfs
= json_object_new_object();
12916 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
12918 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
12919 vrf_name
= bgp
->name
;
12922 json_vrf
= json_object_new_object();
12924 vty_out(vty
, "\nInstance %s:\n",
12925 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
12926 ? VRF_DEFAULT_NAME
: bgp
->name
);
12928 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
12930 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
12931 json_object_object_add(json_vrfs
,
12932 VRF_DEFAULT_NAME
, json_vrf
);
12934 json_object_object_add(json_vrfs
, vrf_name
,
12940 json_object_object_add(json
, "vrfs", json_vrfs
);
12941 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
12942 JSON_C_TO_STRING_PRETTY
));
12943 json_object_free(json
);
12946 return CMD_SUCCESS
;
12949 /* "show [ip] bgp route-leak" command. */
12950 DEFUN (show_ip_bgp_route_leak
,
12951 show_ip_bgp_route_leak_cmd
,
12952 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
12956 BGP_INSTANCE_HELP_STR
12959 "Route leaking information\n"
12963 afi_t afi
= AFI_MAX
;
12964 safi_t safi
= SAFI_MAX
;
12966 bool uj
= use_json(argc
, argv
);
12968 json_object
*json
= NULL
;
12970 /* show [ip] bgp */
12971 if (argv_find(argv
, argc
, "ip", &idx
)) {
12973 safi
= SAFI_UNICAST
;
12975 /* [vrf VIEWVRFNAME] */
12976 if (argv_find(argv
, argc
, "view", &idx
)) {
12978 "%% This command is not applicable to BGP views\n");
12979 return CMD_WARNING
;
12982 if (argv_find(argv
, argc
, "vrf", &idx
)) {
12983 vrf
= argv
[idx
+ 1]->arg
;
12984 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
12987 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
12988 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
12989 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
12992 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
12994 "%% This command is applicable only for unicast ipv4|ipv6\n");
12995 return CMD_WARNING
;
12998 if (vrf
&& strmatch(vrf
, "all"))
12999 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
13002 json
= json_object_new_object();
13004 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
13007 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
13010 struct listnode
*node
, *nnode
;
13013 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
13014 vty_out(vty
, "\nInstance %s:\n",
13015 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
13018 update_group_show(bgp
, afi
, safi
, vty
, 0);
13022 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
13023 int safi
, uint64_t subgrp_id
)
13028 if (strmatch(name
, "all")) {
13029 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
13030 return CMD_SUCCESS
;
13032 bgp
= bgp_lookup_by_name(name
);
13035 bgp
= bgp_get_default();
13039 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
13040 return CMD_SUCCESS
;
13043 DEFUN (show_ip_bgp_updgrps
,
13044 show_ip_bgp_updgrps_cmd
,
13045 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
13049 BGP_INSTANCE_HELP_STR
13051 BGP_SAFI_WITH_LABEL_HELP_STR
13052 "Detailed info about dynamic update groups\n"
13053 "Specific subgroup to display detailed info for\n")
13056 afi_t afi
= AFI_IP6
;
13057 safi_t safi
= SAFI_UNICAST
;
13058 uint64_t subgrp_id
= 0;
13062 /* show [ip] bgp */
13063 if (argv_find(argv
, argc
, "ip", &idx
))
13065 /* [<vrf> VIEWVRFNAME] */
13066 if (argv_find(argv
, argc
, "vrf", &idx
)) {
13067 vrf
= argv
[idx
+ 1]->arg
;
13068 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
13070 } else if (argv_find(argv
, argc
, "view", &idx
))
13071 /* [<view> VIEWVRFNAME] */
13072 vrf
= argv
[idx
+ 1]->arg
;
13073 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
13074 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
13075 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
13078 /* get subgroup id, if provided */
13080 if (argv
[idx
]->type
== VARIABLE_TKN
)
13081 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
13083 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
13086 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
13087 show_bgp_instance_all_ipv6_updgrps_cmd
,
13088 "show [ip] bgp <view|vrf> all update-groups",
13092 BGP_INSTANCE_ALL_HELP_STR
13093 "Detailed info about dynamic update groups\n")
13095 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
13096 return CMD_SUCCESS
;
13099 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
13100 show_bgp_l2vpn_evpn_updgrps_cmd
,
13101 "show [ip] bgp l2vpn evpn update-groups",
13105 "l2vpn address family\n"
13106 "evpn sub-address family\n"
13107 "Detailed info about dynamic update groups\n")
13110 uint64_t subgrp_id
= 0;
13112 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
13113 return CMD_SUCCESS
;
13116 DEFUN (show_bgp_updgrps_stats
,
13117 show_bgp_updgrps_stats_cmd
,
13118 "show [ip] bgp update-groups statistics",
13122 "Detailed info about dynamic update groups\n"
13127 bgp
= bgp_get_default();
13129 update_group_show_stats(bgp
, vty
);
13131 return CMD_SUCCESS
;
13134 DEFUN (show_bgp_instance_updgrps_stats
,
13135 show_bgp_instance_updgrps_stats_cmd
,
13136 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
13140 BGP_INSTANCE_HELP_STR
13141 "Detailed info about dynamic update groups\n"
13147 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
13149 update_group_show_stats(bgp
, vty
);
13151 return CMD_SUCCESS
;
13154 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
13155 afi_t afi
, safi_t safi
,
13156 const char *what
, uint64_t subgrp_id
)
13161 bgp
= bgp_lookup_by_name(name
);
13163 bgp
= bgp_get_default();
13166 if (!strcmp(what
, "advertise-queue"))
13167 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
13169 else if (!strcmp(what
, "advertised-routes"))
13170 update_group_show_advertised(bgp
, afi
, safi
, vty
,
13172 else if (!strcmp(what
, "packet-queue"))
13173 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
13178 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
13179 show_ip_bgp_instance_updgrps_adj_s_cmd
,
13180 "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",
13181 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
13183 "Detailed info about dynamic update groups\n"
13184 "Specific subgroup to display info for\n"
13185 "Advertisement queue\n"
13186 "Announced routes\n"
13189 uint64_t subgrp_id
= 0;
13193 subgrp_id
= strtoull(sgid
, NULL
, 10);
13198 afiz
= bgp_vty_afi_from_str(afi
);
13202 afiz
= bgp_vty_afi_from_str(afi
);
13203 if (afiz
!= AFI_IP
)
13205 "%% Cannot specify both 'ip' and 'ipv6'\n");
13206 return CMD_WARNING
;
13209 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
13211 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
13212 return CMD_SUCCESS
;
13215 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
13217 struct listnode
*node
, *nnode
;
13218 struct prefix
*range
;
13221 char buf
[PREFIX2STR_BUFFER
];
13224 const char *peer_status
;
13225 const char *af_str
;
13230 conf
= group
->conf
;
13232 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
13233 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
13234 group
->name
, conf
->as
);
13235 } else if (conf
->as_type
== AS_INTERNAL
) {
13236 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
13237 group
->name
, group
->bgp
->as
);
13239 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
13242 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
13243 vty_out(vty
, " Peer-group type is internal\n");
13245 vty_out(vty
, " Peer-group type is external\n");
13247 /* Display AFs configured. */
13248 vty_out(vty
, " Configured address-families:");
13249 FOREACH_AFI_SAFI (afi
, safi
) {
13250 if (conf
->afc
[afi
][safi
]) {
13252 vty_out(vty
, " %s;", get_afi_safi_str(afi
, safi
, false));
13256 vty_out(vty
, " none\n");
13258 vty_out(vty
, "\n");
13260 /* Display listen ranges (for dynamic neighbors), if any */
13261 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
13264 else if (afi
== AFI_IP6
)
13268 lr_count
= listcount(group
->listen_range
[afi
]);
13270 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
13274 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
13276 prefix2str(range
, buf
, sizeof(buf
));
13277 vty_out(vty
, " %s\n", buf
);
13282 /* Display group members and their status */
13283 if (listcount(group
->peer
)) {
13284 vty_out(vty
, " Peer-group members:\n");
13285 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
13286 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
13287 peer_status
= "Idle (Admin)";
13288 else if (CHECK_FLAG(peer
->sflags
,
13289 PEER_STATUS_PREFIX_OVERFLOW
))
13290 peer_status
= "Idle (PfxCt)";
13292 peer_status
= lookup_msg(bgp_status_msg
,
13293 peer
->status
, NULL
);
13295 dynamic
= peer_dynamic_neighbor(peer
);
13296 vty_out(vty
, " %s %s %s \n", peer
->host
,
13297 dynamic
? "(dynamic)" : "", peer_status
);
13301 return CMD_SUCCESS
;
13304 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
13305 const char *group_name
)
13308 struct listnode
*node
, *nnode
;
13309 struct peer_group
*group
;
13310 bool found
= false;
13312 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
13315 vty_out(vty
, "%% BGP instance not found\n");
13316 return CMD_WARNING
;
13319 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
13321 if (strmatch(group
->name
, group_name
)) {
13322 bgp_show_one_peer_group(vty
, group
);
13327 bgp_show_one_peer_group(vty
, group
);
13331 if (group_name
&& !found
)
13332 vty_out(vty
, "%% No such peer-group\n");
13334 return CMD_SUCCESS
;
13337 DEFUN (show_ip_bgp_peer_groups
,
13338 show_ip_bgp_peer_groups_cmd
,
13339 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
13343 BGP_INSTANCE_HELP_STR
13344 "Detailed information on BGP peer groups\n"
13345 "Peer group name\n")
13350 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
13352 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
13354 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
13358 /* Redistribute VTY commands. */
13360 DEFUN (bgp_redistribute_ipv4
,
13361 bgp_redistribute_ipv4_cmd
,
13362 "redistribute " FRR_IP_REDIST_STR_BGPD
,
13363 "Redistribute information from another routing protocol\n"
13364 FRR_IP_REDIST_HELP_STR_BGPD
)
13366 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13367 int idx_protocol
= 1;
13370 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
13372 vty_out(vty
, "%% Invalid route type\n");
13373 return CMD_WARNING_CONFIG_FAILED
;
13376 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
13377 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
13381 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
13382 "redistribute " FRR_IP_REDIST_STR_BGPD
,
13383 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
13385 DEFUN (bgp_redistribute_ipv4_rmap
,
13386 bgp_redistribute_ipv4_rmap_cmd
,
13387 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
13388 "Redistribute information from another routing protocol\n"
13389 FRR_IP_REDIST_HELP_STR_BGPD
13390 "Route map reference\n"
13391 "Pointer to route-map entries\n")
13393 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13394 int idx_protocol
= 1;
13397 struct bgp_redist
*red
;
13399 struct route_map
*route_map
= route_map_lookup_warn_noexist(
13400 vty
, argv
[idx_word
]->arg
);
13402 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
13404 vty_out(vty
, "%% Invalid route type\n");
13405 return CMD_WARNING_CONFIG_FAILED
;
13408 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
13410 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
13411 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
13415 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
13416 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
13417 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
13418 "Route map reference\n"
13419 "Pointer to route-map entries\n")
13421 DEFUN (bgp_redistribute_ipv4_metric
,
13422 bgp_redistribute_ipv4_metric_cmd
,
13423 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
13424 "Redistribute information from another routing protocol\n"
13425 FRR_IP_REDIST_HELP_STR_BGPD
13426 "Metric for redistributed routes\n"
13427 "Default metric\n")
13429 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13430 int idx_protocol
= 1;
13431 int idx_number
= 3;
13434 struct bgp_redist
*red
;
13437 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
13439 vty_out(vty
, "%% Invalid route type\n");
13440 return CMD_WARNING_CONFIG_FAILED
;
13442 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13444 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
13445 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
13446 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
13450 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
13451 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
13452 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
13453 "Metric for redistributed routes\n"
13454 "Default metric\n")
13456 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
13457 bgp_redistribute_ipv4_rmap_metric_cmd
,
13458 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
13459 "Redistribute information from another routing protocol\n"
13460 FRR_IP_REDIST_HELP_STR_BGPD
13461 "Route map reference\n"
13462 "Pointer to route-map entries\n"
13463 "Metric for redistributed routes\n"
13464 "Default metric\n")
13466 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13467 int idx_protocol
= 1;
13469 int idx_number
= 5;
13472 struct bgp_redist
*red
;
13474 struct route_map
*route_map
=
13475 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
13477 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
13479 vty_out(vty
, "%% Invalid route type\n");
13480 return CMD_WARNING_CONFIG_FAILED
;
13482 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13484 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
13486 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
13487 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
13488 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
13492 bgp_redistribute_ipv4_rmap_metric
,
13493 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
13494 "redistribute " FRR_IP_REDIST_STR_BGPD
13495 " route-map WORD metric (0-4294967295)",
13496 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
13497 "Route map reference\n"
13498 "Pointer to route-map entries\n"
13499 "Metric for redistributed routes\n"
13500 "Default metric\n")
13502 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
13503 bgp_redistribute_ipv4_metric_rmap_cmd
,
13504 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
13505 "Redistribute information from another routing protocol\n"
13506 FRR_IP_REDIST_HELP_STR_BGPD
13507 "Metric for redistributed routes\n"
13509 "Route map reference\n"
13510 "Pointer to route-map entries\n")
13512 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13513 int idx_protocol
= 1;
13514 int idx_number
= 3;
13518 struct bgp_redist
*red
;
13520 struct route_map
*route_map
=
13521 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
13523 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
13525 vty_out(vty
, "%% Invalid route type\n");
13526 return CMD_WARNING_CONFIG_FAILED
;
13528 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13530 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
13531 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
13533 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
13534 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
13538 bgp_redistribute_ipv4_metric_rmap
,
13539 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
13540 "redistribute " FRR_IP_REDIST_STR_BGPD
13541 " metric (0-4294967295) route-map WORD",
13542 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
13543 "Metric for redistributed routes\n"
13545 "Route map reference\n"
13546 "Pointer to route-map entries\n")
13548 DEFUN (bgp_redistribute_ipv4_ospf
,
13549 bgp_redistribute_ipv4_ospf_cmd
,
13550 "redistribute <ospf|table> (1-65535)",
13551 "Redistribute information from another routing protocol\n"
13552 "Open Shortest Path First (OSPFv2)\n"
13553 "Non-main Kernel Routing Table\n"
13554 "Instance ID/Table ID\n")
13556 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13557 int idx_ospf_table
= 1;
13558 int idx_number
= 2;
13559 unsigned short instance
;
13560 unsigned short protocol
;
13562 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13564 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
13565 protocol
= ZEBRA_ROUTE_OSPF
;
13567 protocol
= ZEBRA_ROUTE_TABLE
;
13569 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
13570 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
13573 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
13574 "redistribute <ospf|table> (1-65535)",
13575 "Redistribute information from another routing protocol\n"
13576 "Open Shortest Path First (OSPFv2)\n"
13577 "Non-main Kernel Routing Table\n"
13578 "Instance ID/Table ID\n")
13580 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
13581 bgp_redistribute_ipv4_ospf_rmap_cmd
,
13582 "redistribute <ospf|table> (1-65535) route-map WORD",
13583 "Redistribute information from another routing protocol\n"
13584 "Open Shortest Path First (OSPFv2)\n"
13585 "Non-main Kernel Routing Table\n"
13586 "Instance ID/Table ID\n"
13587 "Route map reference\n"
13588 "Pointer to route-map entries\n")
13590 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13591 int idx_ospf_table
= 1;
13592 int idx_number
= 2;
13594 struct bgp_redist
*red
;
13595 unsigned short instance
;
13598 struct route_map
*route_map
=
13599 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
13601 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
13602 protocol
= ZEBRA_ROUTE_OSPF
;
13604 protocol
= ZEBRA_ROUTE_TABLE
;
13606 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13607 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
13609 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
13610 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
13613 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
13614 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
13615 "redistribute <ospf|table> (1-65535) route-map WORD",
13616 "Redistribute information from another routing protocol\n"
13617 "Open Shortest Path First (OSPFv2)\n"
13618 "Non-main Kernel Routing Table\n"
13619 "Instance ID/Table ID\n"
13620 "Route map reference\n"
13621 "Pointer to route-map entries\n")
13623 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
13624 bgp_redistribute_ipv4_ospf_metric_cmd
,
13625 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
13626 "Redistribute information from another routing protocol\n"
13627 "Open Shortest Path First (OSPFv2)\n"
13628 "Non-main Kernel Routing Table\n"
13629 "Instance ID/Table ID\n"
13630 "Metric for redistributed routes\n"
13631 "Default metric\n")
13633 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13634 int idx_ospf_table
= 1;
13635 int idx_number
= 2;
13636 int idx_number_2
= 4;
13638 struct bgp_redist
*red
;
13639 unsigned short instance
;
13643 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
13644 protocol
= ZEBRA_ROUTE_OSPF
;
13646 protocol
= ZEBRA_ROUTE_TABLE
;
13648 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13649 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
13651 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
13652 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
13654 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
13657 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
13658 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
13659 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
13660 "Redistribute information from another routing protocol\n"
13661 "Open Shortest Path First (OSPFv2)\n"
13662 "Non-main Kernel Routing Table\n"
13663 "Instance ID/Table ID\n"
13664 "Metric for redistributed routes\n"
13665 "Default metric\n")
13667 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
13668 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
13669 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
13670 "Redistribute information from another routing protocol\n"
13671 "Open Shortest Path First (OSPFv2)\n"
13672 "Non-main Kernel Routing Table\n"
13673 "Instance ID/Table ID\n"
13674 "Route map reference\n"
13675 "Pointer to route-map entries\n"
13676 "Metric for redistributed routes\n"
13677 "Default metric\n")
13679 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13680 int idx_ospf_table
= 1;
13681 int idx_number
= 2;
13683 int idx_number_2
= 6;
13685 struct bgp_redist
*red
;
13686 unsigned short instance
;
13689 struct route_map
*route_map
=
13690 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
13692 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
13693 protocol
= ZEBRA_ROUTE_OSPF
;
13695 protocol
= ZEBRA_ROUTE_TABLE
;
13697 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13698 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
13700 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
13702 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
13703 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
13705 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
13709 bgp_redistribute_ipv4_ospf_rmap_metric
,
13710 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
13711 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
13712 "Redistribute information from another routing protocol\n"
13713 "Open Shortest Path First (OSPFv2)\n"
13714 "Non-main Kernel Routing Table\n"
13715 "Instance ID/Table ID\n"
13716 "Route map reference\n"
13717 "Pointer to route-map entries\n"
13718 "Metric for redistributed routes\n"
13719 "Default metric\n")
13721 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
13722 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
13723 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
13724 "Redistribute information from another routing protocol\n"
13725 "Open Shortest Path First (OSPFv2)\n"
13726 "Non-main Kernel Routing Table\n"
13727 "Instance ID/Table ID\n"
13728 "Metric for redistributed routes\n"
13730 "Route map reference\n"
13731 "Pointer to route-map entries\n")
13733 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13734 int idx_ospf_table
= 1;
13735 int idx_number
= 2;
13736 int idx_number_2
= 4;
13739 struct bgp_redist
*red
;
13740 unsigned short instance
;
13743 struct route_map
*route_map
=
13744 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
13746 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
13747 protocol
= ZEBRA_ROUTE_OSPF
;
13749 protocol
= ZEBRA_ROUTE_TABLE
;
13751 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13752 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
13754 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
13755 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
13758 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
13759 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
13763 bgp_redistribute_ipv4_ospf_metric_rmap
,
13764 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
13765 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
13766 "Redistribute information from another routing protocol\n"
13767 "Open Shortest Path First (OSPFv2)\n"
13768 "Non-main Kernel Routing Table\n"
13769 "Instance ID/Table ID\n"
13770 "Metric for redistributed routes\n"
13772 "Route map reference\n"
13773 "Pointer to route-map entries\n")
13775 DEFUN (no_bgp_redistribute_ipv4_ospf
,
13776 no_bgp_redistribute_ipv4_ospf_cmd
,
13777 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
13779 "Redistribute information from another routing protocol\n"
13780 "Open Shortest Path First (OSPFv2)\n"
13781 "Non-main Kernel Routing Table\n"
13782 "Instance ID/Table ID\n"
13783 "Metric for redistributed routes\n"
13785 "Route map reference\n"
13786 "Pointer to route-map entries\n")
13788 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13789 int idx_ospf_table
= 2;
13790 int idx_number
= 3;
13791 unsigned short instance
;
13794 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
13795 protocol
= ZEBRA_ROUTE_OSPF
;
13797 protocol
= ZEBRA_ROUTE_TABLE
;
13799 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13800 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
13804 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
13805 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
13807 "Redistribute information from another routing protocol\n"
13808 "Open Shortest Path First (OSPFv2)\n"
13809 "Non-main Kernel Routing Table\n"
13810 "Instance ID/Table ID\n"
13811 "Metric for redistributed routes\n"
13813 "Route map reference\n"
13814 "Pointer to route-map entries\n")
13816 DEFUN (no_bgp_redistribute_ipv4
,
13817 no_bgp_redistribute_ipv4_cmd
,
13818 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
13820 "Redistribute information from another routing protocol\n"
13821 FRR_IP_REDIST_HELP_STR_BGPD
13822 "Metric for redistributed routes\n"
13824 "Route map reference\n"
13825 "Pointer to route-map entries\n")
13827 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13828 int idx_protocol
= 2;
13831 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
13833 vty_out(vty
, "%% Invalid route type\n");
13834 return CMD_WARNING_CONFIG_FAILED
;
13836 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
13840 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
13841 "no redistribute " FRR_IP_REDIST_STR_BGPD
13842 " [{metric (0-4294967295)|route-map WORD}]",
13844 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
13845 "Metric for redistributed routes\n"
13847 "Route map reference\n"
13848 "Pointer to route-map entries\n")
13850 DEFUN (bgp_redistribute_ipv6
,
13851 bgp_redistribute_ipv6_cmd
,
13852 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
13853 "Redistribute information from another routing protocol\n"
13854 FRR_IP6_REDIST_HELP_STR_BGPD
)
13856 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13857 int idx_protocol
= 1;
13860 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
13862 vty_out(vty
, "%% Invalid route type\n");
13863 return CMD_WARNING_CONFIG_FAILED
;
13866 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
13867 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
13870 DEFUN (bgp_redistribute_ipv6_rmap
,
13871 bgp_redistribute_ipv6_rmap_cmd
,
13872 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
13873 "Redistribute information from another routing protocol\n"
13874 FRR_IP6_REDIST_HELP_STR_BGPD
13875 "Route map reference\n"
13876 "Pointer to route-map entries\n")
13878 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13879 int idx_protocol
= 1;
13882 struct bgp_redist
*red
;
13884 struct route_map
*route_map
=
13885 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
13887 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
13889 vty_out(vty
, "%% Invalid route type\n");
13890 return CMD_WARNING_CONFIG_FAILED
;
13893 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
13895 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
13896 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
13899 DEFUN (bgp_redistribute_ipv6_metric
,
13900 bgp_redistribute_ipv6_metric_cmd
,
13901 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
13902 "Redistribute information from another routing protocol\n"
13903 FRR_IP6_REDIST_HELP_STR_BGPD
13904 "Metric for redistributed routes\n"
13905 "Default metric\n")
13907 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13908 int idx_protocol
= 1;
13909 int idx_number
= 3;
13912 struct bgp_redist
*red
;
13915 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
13917 vty_out(vty
, "%% Invalid route type\n");
13918 return CMD_WARNING_CONFIG_FAILED
;
13920 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13922 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
13923 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
13924 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
13927 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
13928 bgp_redistribute_ipv6_rmap_metric_cmd
,
13929 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
13930 "Redistribute information from another routing protocol\n"
13931 FRR_IP6_REDIST_HELP_STR_BGPD
13932 "Route map reference\n"
13933 "Pointer to route-map entries\n"
13934 "Metric for redistributed routes\n"
13935 "Default metric\n")
13937 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13938 int idx_protocol
= 1;
13940 int idx_number
= 5;
13943 struct bgp_redist
*red
;
13945 struct route_map
*route_map
=
13946 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
13948 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
13950 vty_out(vty
, "%% Invalid route type\n");
13951 return CMD_WARNING_CONFIG_FAILED
;
13953 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13955 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
13957 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
13958 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
13960 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
13963 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
13964 bgp_redistribute_ipv6_metric_rmap_cmd
,
13965 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
13966 "Redistribute information from another routing protocol\n"
13967 FRR_IP6_REDIST_HELP_STR_BGPD
13968 "Metric for redistributed routes\n"
13970 "Route map reference\n"
13971 "Pointer to route-map entries\n")
13973 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13974 int idx_protocol
= 1;
13975 int idx_number
= 3;
13979 struct bgp_redist
*red
;
13981 struct route_map
*route_map
=
13982 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
13984 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
13986 vty_out(vty
, "%% Invalid route type\n");
13987 return CMD_WARNING_CONFIG_FAILED
;
13989 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13991 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
13992 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
13995 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
13996 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
13999 DEFUN (no_bgp_redistribute_ipv6
,
14000 no_bgp_redistribute_ipv6_cmd
,
14001 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
14003 "Redistribute information from another routing protocol\n"
14004 FRR_IP6_REDIST_HELP_STR_BGPD
14005 "Metric for redistributed routes\n"
14007 "Route map reference\n"
14008 "Pointer to route-map entries\n")
14010 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14011 int idx_protocol
= 2;
14014 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
14016 vty_out(vty
, "%% Invalid route type\n");
14017 return CMD_WARNING_CONFIG_FAILED
;
14020 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
14023 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
14024 afi_t afi
, safi_t safi
)
14028 /* Unicast redistribution only. */
14029 if (safi
!= SAFI_UNICAST
)
14032 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
14033 /* Redistribute BGP does not make sense. */
14034 if (i
!= ZEBRA_ROUTE_BGP
) {
14035 struct list
*red_list
;
14036 struct listnode
*node
;
14037 struct bgp_redist
*red
;
14039 red_list
= bgp
->redist
[afi
][i
];
14043 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
14044 /* "redistribute" configuration. */
14045 vty_out(vty
, " redistribute %s",
14046 zebra_route_string(i
));
14048 vty_out(vty
, " %d", red
->instance
);
14049 if (red
->redist_metric_flag
)
14050 vty_out(vty
, " metric %u",
14051 red
->redist_metric
);
14052 if (red
->rmap
.name
)
14053 vty_out(vty
, " route-map %s",
14055 vty_out(vty
, "\n");
14061 /* peer-group helpers for config-write */
14063 static bool peergroup_flag_check(struct peer
*peer
, uint32_t flag
)
14065 if (!peer_group_active(peer
)) {
14066 if (CHECK_FLAG(peer
->flags_invert
, flag
))
14067 return !CHECK_FLAG(peer
->flags
, flag
);
14069 return !!CHECK_FLAG(peer
->flags
, flag
);
14072 return !!CHECK_FLAG(peer
->flags_override
, flag
);
14075 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
14078 if (!peer_group_active(peer
)) {
14079 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
14080 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
14082 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
14085 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
14088 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
14089 uint8_t type
, int direct
)
14091 struct bgp_filter
*filter
;
14093 if (peer_group_active(peer
))
14094 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
14097 filter
= &peer
->filter
[afi
][safi
];
14099 case PEER_FT_DISTRIBUTE_LIST
:
14100 return !!(filter
->dlist
[direct
].name
);
14101 case PEER_FT_FILTER_LIST
:
14102 return !!(filter
->aslist
[direct
].name
);
14103 case PEER_FT_PREFIX_LIST
:
14104 return !!(filter
->plist
[direct
].name
);
14105 case PEER_FT_ROUTE_MAP
:
14106 return !!(filter
->map
[direct
].name
);
14107 case PEER_FT_UNSUPPRESS_MAP
:
14108 return !!(filter
->usmap
.name
);
14114 /* Return true if the addpath type is set for peer and different from
14117 static int peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
, safi_t safi
)
14119 enum bgp_addpath_strat type
, g_type
;
14121 type
= peer
->addpath_type
[afi
][safi
];
14123 if (type
!= BGP_ADDPATH_NONE
) {
14124 if (peer_group_active(peer
)) {
14125 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
14127 if (type
!= g_type
)
14139 /* This is part of the address-family block (unicast only) */
14140 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
14145 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
14146 if (listcount(bgp
->vpn_policy
[afi
].import_vrf
))
14147 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
14148 bgp
->vpn_policy
[afi
]
14149 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
14151 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
14152 bgp
->vpn_policy
[afi
]
14153 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
14155 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
14156 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
14157 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
14158 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
14161 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
14162 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
14164 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
14167 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
14168 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
14169 bgp
->vpn_policy
[afi
].tovpn_label
);
14172 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
14173 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
14174 char buf
[RD_ADDRSTRLEN
];
14175 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
14176 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
14179 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
14180 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
14182 char buf
[PREFIX_STRLEN
];
14183 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
14184 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
14187 vty_out(vty
, "%*snexthop vpn export %s\n",
14191 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
14192 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
14194 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
14195 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
14197 char *b
= ecommunity_ecom2str(
14198 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
14199 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
14200 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
14201 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
14203 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
14204 char *b
= ecommunity_ecom2str(
14205 bgp
->vpn_policy
[afi
]
14206 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
14207 ECOMMUNITY_FORMAT_ROUTE_MAP
,
14208 ECOMMUNITY_ROUTE_TARGET
);
14209 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
14210 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
14212 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
14213 char *b
= ecommunity_ecom2str(
14214 bgp
->vpn_policy
[afi
]
14215 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
14216 ECOMMUNITY_FORMAT_ROUTE_MAP
,
14217 ECOMMUNITY_ROUTE_TARGET
);
14218 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
14219 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
14223 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
14224 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
14225 bgp
->vpn_policy
[afi
]
14226 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
14228 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
14229 char *b
= ecommunity_ecom2str(
14230 bgp
->vpn_policy
[afi
]
14231 .import_redirect_rtlist
,
14232 ECOMMUNITY_FORMAT_ROUTE_MAP
,
14233 ECOMMUNITY_ROUTE_TARGET
);
14235 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
14236 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
14240 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
14241 afi_t afi
, safi_t safi
)
14243 struct bgp_filter
*filter
;
14247 filter
= &peer
->filter
[afi
][safi
];
14249 /* distribute-list. */
14250 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
14252 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
14253 filter
->dlist
[FILTER_IN
].name
);
14255 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
14257 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
14258 filter
->dlist
[FILTER_OUT
].name
);
14261 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
14263 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
14264 filter
->plist
[FILTER_IN
].name
);
14266 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
14268 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
14269 filter
->plist
[FILTER_OUT
].name
);
14272 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
14273 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
14274 filter
->map
[RMAP_IN
].name
);
14276 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
14278 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
14279 filter
->map
[RMAP_OUT
].name
);
14281 /* unsuppress-map */
14282 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
14283 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
14284 filter
->usmap
.name
);
14287 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
14289 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
14290 filter
->aslist
[FILTER_IN
].name
);
14292 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
14294 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
14295 filter
->aslist
[FILTER_OUT
].name
);
14298 /* BGP peer configuration display function. */
14299 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
14302 struct peer
*g_peer
= NULL
;
14303 char buf
[SU_ADDRSTRLEN
];
14305 int if_pg_printed
= false;
14306 int if_ras_printed
= false;
14308 /* Skip dynamic neighbors. */
14309 if (peer_dynamic_neighbor(peer
))
14313 addr
= peer
->conf_if
;
14317 /************************************
14318 ****** Global to the neighbor ******
14319 ************************************/
14320 if (peer
->conf_if
) {
14321 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
14322 vty_out(vty
, " neighbor %s interface v6only", addr
);
14324 vty_out(vty
, " neighbor %s interface", addr
);
14326 if (peer_group_active(peer
)) {
14327 vty_out(vty
, " peer-group %s", peer
->group
->name
);
14328 if_pg_printed
= true;
14329 } else if (peer
->as_type
== AS_SPECIFIED
) {
14330 vty_out(vty
, " remote-as %u", peer
->as
);
14331 if_ras_printed
= true;
14332 } else if (peer
->as_type
== AS_INTERNAL
) {
14333 vty_out(vty
, " remote-as internal");
14334 if_ras_printed
= true;
14335 } else if (peer
->as_type
== AS_EXTERNAL
) {
14336 vty_out(vty
, " remote-as external");
14337 if_ras_printed
= true;
14340 vty_out(vty
, "\n");
14343 /* remote-as and peer-group */
14344 /* peer is a member of a peer-group */
14345 if (peer_group_active(peer
)) {
14346 g_peer
= peer
->group
->conf
;
14348 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
14349 if (peer
->as_type
== AS_SPECIFIED
) {
14350 vty_out(vty
, " neighbor %s remote-as %u\n",
14352 } else if (peer
->as_type
== AS_INTERNAL
) {
14354 " neighbor %s remote-as internal\n",
14356 } else if (peer
->as_type
== AS_EXTERNAL
) {
14358 " neighbor %s remote-as external\n",
14363 /* For swpX peers we displayed the peer-group
14364 * via 'neighbor swpX interface peer-group PGNAME' */
14365 if (!if_pg_printed
)
14366 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
14367 peer
->group
->name
);
14370 /* peer is NOT a member of a peer-group */
14372 /* peer is a peer-group, declare the peer-group */
14373 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
14374 vty_out(vty
, " neighbor %s peer-group\n", addr
);
14377 if (!if_ras_printed
) {
14378 if (peer
->as_type
== AS_SPECIFIED
) {
14379 vty_out(vty
, " neighbor %s remote-as %u\n",
14381 } else if (peer
->as_type
== AS_INTERNAL
) {
14383 " neighbor %s remote-as internal\n",
14385 } else if (peer
->as_type
== AS_EXTERNAL
) {
14387 " neighbor %s remote-as external\n",
14394 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
14395 vty_out(vty
, " neighbor %s local-as %u", addr
,
14396 peer
->change_local_as
);
14397 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
14398 vty_out(vty
, " no-prepend");
14399 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
14400 vty_out(vty
, " replace-as");
14401 vty_out(vty
, "\n");
14406 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
14410 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
14411 if (peer
->tx_shutdown_message
)
14412 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
14413 peer
->tx_shutdown_message
);
14415 vty_out(vty
, " neighbor %s shutdown\n", addr
);
14419 if (peer
->bfd_info
) {
14420 if (!peer_group_active(peer
) || !g_peer
->bfd_info
) {
14421 bgp_bfd_peer_config_write(vty
, peer
, addr
);
14426 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
14427 vty_out(vty
, " neighbor %s password %s\n", addr
,
14430 /* neighbor solo */
14431 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
14432 if (!peer_group_active(peer
)) {
14433 vty_out(vty
, " neighbor %s solo\n", addr
);
14438 if (peer
->port
!= BGP_PORT_DEFAULT
) {
14439 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
14442 /* Local interface name */
14443 if (peer
->ifname
) {
14444 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
14448 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
14449 vty_out(vty
, " neighbor %s passive\n", addr
);
14451 /* ebgp-multihop */
14452 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
14453 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
14454 && peer
->ttl
== MAXTTL
)) {
14455 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
14456 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
14461 /* ttl-security hops */
14462 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
14463 if (!peer_group_active(peer
)
14464 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
14465 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
14466 addr
, peer
->gtsm_hops
);
14470 /* disable-connected-check */
14471 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
14472 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
14474 /* enforce-first-as */
14475 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
14476 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
14478 /* update-source */
14479 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
14480 if (peer
->update_source
)
14481 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
14482 sockunion2str(peer
->update_source
, buf
,
14484 else if (peer
->update_if
)
14485 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
14489 /* advertisement-interval */
14490 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
14491 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
14495 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
14496 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
14497 peer
->keepalive
, peer
->holdtime
);
14499 /* timers connect */
14500 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
14501 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
14503 /* need special-case handling for changed default values due to
14504 * config profile / version (because there is no "timers bgp connect"
14505 * command, we need to save this per-peer :/)
14507 else if (!peer_group_active(peer
) && !peer
->connect
&&
14508 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
14509 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
14510 peer
->bgp
->default_connect_retry
);
14512 /* capability dynamic */
14513 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
14514 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
14516 /* capability extended-nexthop */
14517 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
14518 if (!peer
->conf_if
) {
14519 if (CHECK_FLAG(peer
->flags_invert
,
14520 PEER_FLAG_CAPABILITY_ENHE
))
14522 " no neighbor %s capability extended-nexthop\n",
14526 " neighbor %s capability extended-nexthop\n",
14531 /* dont-capability-negotiation */
14532 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
14533 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
14535 /* override-capability */
14536 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
14537 vty_out(vty
, " neighbor %s override-capability\n", addr
);
14539 /* strict-capability-match */
14540 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
14541 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
14543 /* Sender side AS path loop detection. */
14544 if (peer
->as_path_loop_detection
)
14545 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
14548 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
14549 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
14551 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
14552 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
14554 " neighbor %s graceful-restart-helper\n", addr
);
14555 } else if (CHECK_FLAG(
14556 peer
->peer_gr_new_status_flag
,
14557 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
14559 " neighbor %s graceful-restart\n", addr
);
14561 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
14562 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
14564 peer
->peer_gr_new_status_flag
,
14565 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
14566 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
14572 /* BGP peer configuration display function. */
14573 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
14574 struct peer
*peer
, afi_t afi
, safi_t safi
)
14576 struct peer
*g_peer
= NULL
;
14578 bool flag_scomm
, flag_secomm
, flag_slcomm
;
14580 /* Skip dynamic neighbors. */
14581 if (peer_dynamic_neighbor(peer
))
14585 addr
= peer
->conf_if
;
14589 /************************************
14590 ****** Per AF to the neighbor ******
14591 ************************************/
14592 if (peer_group_active(peer
)) {
14593 g_peer
= peer
->group
->conf
;
14595 /* If the peer-group is active but peer is not, print a 'no
14597 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
14598 vty_out(vty
, " no neighbor %s activate\n", addr
);
14601 /* If the peer-group is not active but peer is, print an
14603 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
14604 vty_out(vty
, " neighbor %s activate\n", addr
);
14607 if (peer
->afc
[afi
][safi
]) {
14608 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
14609 if (CHECK_FLAG(bgp
->flags
,
14610 BGP_FLAG_NO_DEFAULT_IPV4
)) {
14611 vty_out(vty
, " neighbor %s activate\n",
14615 vty_out(vty
, " neighbor %s activate\n", addr
);
14617 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
14618 if (!CHECK_FLAG(bgp
->flags
,
14619 BGP_FLAG_NO_DEFAULT_IPV4
)) {
14621 " no neighbor %s activate\n",
14628 /* addpath TX knobs */
14629 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
14630 switch (peer
->addpath_type
[afi
][safi
]) {
14631 case BGP_ADDPATH_ALL
:
14632 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
14635 case BGP_ADDPATH_BEST_PER_AS
:
14637 " neighbor %s addpath-tx-bestpath-per-AS\n",
14640 case BGP_ADDPATH_MAX
:
14641 case BGP_ADDPATH_NONE
:
14646 /* ORF capability. */
14647 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
14648 || peergroup_af_flag_check(peer
, afi
, safi
,
14649 PEER_FLAG_ORF_PREFIX_RM
)) {
14650 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
14652 if (peergroup_af_flag_check(peer
, afi
, safi
,
14653 PEER_FLAG_ORF_PREFIX_SM
)
14654 && peergroup_af_flag_check(peer
, afi
, safi
,
14655 PEER_FLAG_ORF_PREFIX_RM
))
14656 vty_out(vty
, " both");
14657 else if (peergroup_af_flag_check(peer
, afi
, safi
,
14658 PEER_FLAG_ORF_PREFIX_SM
))
14659 vty_out(vty
, " send");
14661 vty_out(vty
, " receive");
14662 vty_out(vty
, "\n");
14665 /* BGP flag dampening. */
14666 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14667 BGP_CONFIG_DAMPENING
))
14668 bgp_config_write_damp(vty
, afi
, safi
);
14670 /* Route reflector client. */
14671 if (peergroup_af_flag_check(peer
, afi
, safi
,
14672 PEER_FLAG_REFLECTOR_CLIENT
)) {
14673 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
14676 /* next-hop-self force */
14677 if (peergroup_af_flag_check(peer
, afi
, safi
,
14678 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
14679 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
14682 /* next-hop-self */
14683 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
14684 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
14687 /* remove-private-AS */
14688 if (peergroup_af_flag_check(peer
, afi
, safi
,
14689 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
14690 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
14694 else if (peergroup_af_flag_check(peer
, afi
, safi
,
14695 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
14696 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
14700 else if (peergroup_af_flag_check(peer
, afi
, safi
,
14701 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
14702 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
14705 else if (peergroup_af_flag_check(peer
, afi
, safi
,
14706 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
14707 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
14711 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
14712 vty_out(vty
, " neighbor %s as-override\n", addr
);
14715 /* send-community print. */
14716 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
14717 PEER_FLAG_SEND_COMMUNITY
);
14718 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
14719 PEER_FLAG_SEND_EXT_COMMUNITY
);
14720 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
14721 PEER_FLAG_SEND_LARGE_COMMUNITY
);
14723 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
14724 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
14727 vty_out(vty
, " no neighbor %s send-community\n", addr
);
14730 " no neighbor %s send-community extended\n",
14734 vty_out(vty
, " no neighbor %s send-community large\n",
14738 /* Default information */
14739 if (peergroup_af_flag_check(peer
, afi
, safi
,
14740 PEER_FLAG_DEFAULT_ORIGINATE
)) {
14741 vty_out(vty
, " neighbor %s default-originate", addr
);
14743 if (peer
->default_rmap
[afi
][safi
].name
)
14744 vty_out(vty
, " route-map %s",
14745 peer
->default_rmap
[afi
][safi
].name
);
14747 vty_out(vty
, "\n");
14750 /* Soft reconfiguration inbound. */
14751 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
14752 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
14756 /* maximum-prefix. */
14757 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
14758 vty_out(vty
, " neighbor %s maximum-prefix %" PRIu32
, addr
,
14759 peer
->pmax
[afi
][safi
]);
14761 if (peer
->pmax_threshold
[afi
][safi
]
14762 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
14763 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
14764 if (peer_af_flag_check(peer
, afi
, safi
,
14765 PEER_FLAG_MAX_PREFIX_WARNING
))
14766 vty_out(vty
, " warning-only");
14767 if (peer
->pmax_restart
[afi
][safi
])
14768 vty_out(vty
, " restart %u",
14769 peer
->pmax_restart
[afi
][safi
]);
14771 vty_out(vty
, "\n");
14774 /* maximum-prefix-out */
14775 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
14776 vty_out(vty
, " neighbor %s maximum-prefix-out %" PRIu32
"\n",
14777 addr
, peer
->pmax_out
[afi
][safi
]);
14779 /* Route server client. */
14780 if (peergroup_af_flag_check(peer
, afi
, safi
,
14781 PEER_FLAG_RSERVER_CLIENT
)) {
14782 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
14785 /* Nexthop-local unchanged. */
14786 if (peergroup_af_flag_check(peer
, afi
, safi
,
14787 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
14788 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
14791 /* allowas-in <1-10> */
14792 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
14793 if (peer_af_flag_check(peer
, afi
, safi
,
14794 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
14795 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
14796 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
14797 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
14799 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
14800 peer
->allowas_in
[afi
][safi
]);
14805 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
14806 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
14807 peer
->weight
[afi
][safi
]);
14810 bgp_config_write_filter(vty
, peer
, afi
, safi
);
14812 /* atribute-unchanged. */
14813 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
14814 || (safi
!= SAFI_EVPN
14815 && peer_af_flag_check(peer
, afi
, safi
,
14816 PEER_FLAG_NEXTHOP_UNCHANGED
))
14817 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
14819 if (!peer_group_active(peer
)
14820 || peergroup_af_flag_check(peer
, afi
, safi
,
14821 PEER_FLAG_AS_PATH_UNCHANGED
)
14822 || peergroup_af_flag_check(peer
, afi
, safi
,
14823 PEER_FLAG_NEXTHOP_UNCHANGED
)
14824 || peergroup_af_flag_check(peer
, afi
, safi
,
14825 PEER_FLAG_MED_UNCHANGED
)) {
14828 " neighbor %s attribute-unchanged%s%s%s\n",
14830 peer_af_flag_check(peer
, afi
, safi
,
14831 PEER_FLAG_AS_PATH_UNCHANGED
)
14834 peer_af_flag_check(peer
, afi
, safi
,
14835 PEER_FLAG_NEXTHOP_UNCHANGED
)
14838 peer_af_flag_check(peer
, afi
, safi
,
14839 PEER_FLAG_MED_UNCHANGED
)
14846 /* Address family based peer configuration display. */
14847 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
14851 struct peer_group
*group
;
14852 struct listnode
*node
, *nnode
;
14855 vty_frame(vty
, " !\n address-family ");
14856 if (afi
== AFI_IP
) {
14857 if (safi
== SAFI_UNICAST
)
14858 vty_frame(vty
, "ipv4 unicast");
14859 else if (safi
== SAFI_LABELED_UNICAST
)
14860 vty_frame(vty
, "ipv4 labeled-unicast");
14861 else if (safi
== SAFI_MULTICAST
)
14862 vty_frame(vty
, "ipv4 multicast");
14863 else if (safi
== SAFI_MPLS_VPN
)
14864 vty_frame(vty
, "ipv4 vpn");
14865 else if (safi
== SAFI_ENCAP
)
14866 vty_frame(vty
, "ipv4 encap");
14867 else if (safi
== SAFI_FLOWSPEC
)
14868 vty_frame(vty
, "ipv4 flowspec");
14869 } else if (afi
== AFI_IP6
) {
14870 if (safi
== SAFI_UNICAST
)
14871 vty_frame(vty
, "ipv6 unicast");
14872 else if (safi
== SAFI_LABELED_UNICAST
)
14873 vty_frame(vty
, "ipv6 labeled-unicast");
14874 else if (safi
== SAFI_MULTICAST
)
14875 vty_frame(vty
, "ipv6 multicast");
14876 else if (safi
== SAFI_MPLS_VPN
)
14877 vty_frame(vty
, "ipv6 vpn");
14878 else if (safi
== SAFI_ENCAP
)
14879 vty_frame(vty
, "ipv6 encap");
14880 else if (safi
== SAFI_FLOWSPEC
)
14881 vty_frame(vty
, "ipv6 flowspec");
14882 } else if (afi
== AFI_L2VPN
) {
14883 if (safi
== SAFI_EVPN
)
14884 vty_frame(vty
, "l2vpn evpn");
14886 vty_frame(vty
, "\n");
14888 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
14890 bgp_config_write_network(vty
, bgp
, afi
, safi
);
14892 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
14894 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
14895 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
14897 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14898 /* Skip dynamic neighbors. */
14899 if (peer_dynamic_neighbor(peer
))
14902 /* Do not display doppelganger peers */
14903 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14904 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
14907 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
14908 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
14910 if (safi
== SAFI_EVPN
)
14911 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
14913 if (safi
== SAFI_FLOWSPEC
)
14914 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
14916 if (safi
== SAFI_UNICAST
) {
14917 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
14918 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14919 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
14921 vty_out(vty
, " export vpn\n");
14923 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14924 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
14926 vty_out(vty
, " import vpn\n");
14928 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14929 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
14932 for (ALL_LIST_ELEMENTS_RO(
14933 bgp
->vpn_policy
[afi
].import_vrf
, node
,
14935 vty_out(vty
, " import vrf %s\n", name
);
14939 vty_endframe(vty
, " exit-address-family\n");
14942 int bgp_config_write(struct vty
*vty
)
14945 struct peer_group
*group
;
14947 struct listnode
*node
, *nnode
;
14948 struct listnode
*mnode
, *mnnode
;
14950 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
14951 vty_out(vty
, "bgp route-map delay-timer %u\n",
14952 bm
->rmap_update_timer
);
14954 /* BGP configuration. */
14955 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
14957 /* skip all auto created vrf as they dont have user config */
14958 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
14961 /* Router bgp ASN */
14962 vty_out(vty
, "router bgp %u", bgp
->as
);
14965 vty_out(vty
, " %s %s",
14966 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
14967 ? "view" : "vrf", bgp
->name
);
14968 vty_out(vty
, "\n");
14970 /* BGP fast-external-failover. */
14971 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
14972 vty_out(vty
, " no bgp fast-external-failover\n");
14974 /* BGP router ID. */
14975 if (bgp
->router_id_static
.s_addr
!= 0)
14976 vty_out(vty
, " bgp router-id %s\n",
14977 inet_ntoa(bgp
->router_id_static
));
14979 /* BGP log-neighbor-changes. */
14980 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
14981 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
14982 vty_out(vty
, " %sbgp log-neighbor-changes\n",
14983 CHECK_FLAG(bgp
->flags
,
14984 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
14988 /* BGP configuration. */
14989 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
14990 vty_out(vty
, " bgp always-compare-med\n");
14992 /* RFC8212 default eBGP policy. */
14993 if (bgp
->ebgp_requires_policy
14994 == DEFAULT_EBGP_POLICY_ENABLED
)
14995 vty_out(vty
, " bgp ebgp-requires-policy\n");
14997 /* draft-ietf-idr-deprecate-as-set-confed-set */
14998 if (bgp
->reject_as_sets
== BGP_REJECT_AS_SETS_ENABLED
)
14999 vty_out(vty
, " bgp reject-as-sets\n");
15001 /* BGP default ipv4-unicast. */
15002 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
))
15003 vty_out(vty
, " no bgp default ipv4-unicast\n");
15005 /* BGP default local-preference. */
15006 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
15007 vty_out(vty
, " bgp default local-preference %u\n",
15008 bgp
->default_local_pref
);
15010 /* BGP default show-hostname */
15011 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
15012 != SAVE_BGP_SHOW_HOSTNAME
)
15013 vty_out(vty
, " %sbgp default show-hostname\n",
15014 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
15018 /* BGP default subgroup-pkt-queue-max. */
15019 if (bgp
->default_subgroup_pkt_queue_max
15020 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
15021 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
15022 bgp
->default_subgroup_pkt_queue_max
);
15024 /* BGP client-to-client reflection. */
15025 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
15026 vty_out(vty
, " no bgp client-to-client reflection\n");
15028 /* BGP cluster ID. */
15029 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
15030 vty_out(vty
, " bgp cluster-id %s\n",
15031 inet_ntoa(bgp
->cluster_id
));
15033 /* Disable ebgp connected nexthop check */
15034 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
15036 " bgp disable-ebgp-connected-route-check\n");
15038 /* Confederation identifier*/
15039 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
15040 vty_out(vty
, " bgp confederation identifier %u\n",
15043 /* Confederation peer */
15044 if (bgp
->confed_peers_cnt
> 0) {
15047 vty_out(vty
, " bgp confederation peers");
15049 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
15050 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
15052 vty_out(vty
, "\n");
15055 /* BGP deterministic-med. */
15056 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
15057 != SAVE_BGP_DETERMINISTIC_MED
)
15058 vty_out(vty
, " %sbgp deterministic-med\n",
15059 CHECK_FLAG(bgp
->flags
,
15060 BGP_FLAG_DETERMINISTIC_MED
)
15064 /* BGP update-delay. */
15065 bgp_config_write_update_delay(vty
, bgp
);
15067 if (bgp
->v_maxmed_onstartup
15068 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
15069 vty_out(vty
, " bgp max-med on-startup %u",
15070 bgp
->v_maxmed_onstartup
);
15071 if (bgp
->maxmed_onstartup_value
15072 != BGP_MAXMED_VALUE_DEFAULT
)
15073 vty_out(vty
, " %u",
15074 bgp
->maxmed_onstartup_value
);
15075 vty_out(vty
, "\n");
15077 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
15078 vty_out(vty
, " bgp max-med administrative");
15079 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
15080 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
15081 vty_out(vty
, "\n");
15085 bgp_config_write_wpkt_quanta(vty
, bgp
);
15087 bgp_config_write_rpkt_quanta(vty
, bgp
);
15089 /* coalesce time */
15090 bgp_config_write_coalesce_time(vty
, bgp
);
15092 /* BGP graceful-restart. */
15093 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
15095 " bgp graceful-restart stalepath-time %u\n",
15096 bgp
->stalepath_time
);
15098 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
15099 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
15100 bgp
->restart_time
);
15102 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
15104 " bgp graceful-restart select-defer-time %u\n",
15105 bgp
->select_defer_time
);
15107 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
15108 vty_out(vty
, " bgp graceful-restart\n");
15110 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
15111 vty_out(vty
, " bgp graceful-restart-disable\n");
15113 /* BGP graceful-shutdown */
15114 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
15115 vty_out(vty
, " bgp graceful-shutdown\n");
15117 /* BGP graceful-restart Preserve State F bit. */
15118 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
15120 " bgp graceful-restart preserve-fw-state\n");
15122 /* Stale timer for RIB */
15123 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
15125 " bgp graceful-restart rib-stale-time %u\n",
15126 bgp
->rib_stale_time
);
15128 /* BGP bestpath method. */
15129 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
15130 vty_out(vty
, " bgp bestpath as-path ignore\n");
15131 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
15132 vty_out(vty
, " bgp bestpath as-path confed\n");
15134 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
15135 if (CHECK_FLAG(bgp
->flags
,
15136 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
15138 " bgp bestpath as-path multipath-relax as-set\n");
15141 " bgp bestpath as-path multipath-relax\n");
15145 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
15147 " bgp route-reflector allow-outbound-policy\n");
15149 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
15150 vty_out(vty
, " bgp bestpath compare-routerid\n");
15151 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
15152 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
15153 vty_out(vty
, " bgp bestpath med");
15154 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
15155 vty_out(vty
, " confed");
15156 if (CHECK_FLAG(bgp
->flags
,
15157 BGP_FLAG_MED_MISSING_AS_WORST
))
15158 vty_out(vty
, " missing-as-worst");
15159 vty_out(vty
, "\n");
15162 /* BGP network import check. */
15163 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
15164 != SAVE_BGP_IMPORT_CHECK
)
15165 vty_out(vty
, " %sbgp network import-check\n",
15166 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
15170 /* BGP timers configuration. */
15171 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
15172 && bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
15173 vty_out(vty
, " timers bgp %u %u\n",
15174 bgp
->default_keepalive
, bgp
->default_holdtime
);
15177 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15178 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
15181 /* Normal neighbor configuration. */
15182 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
15183 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
15184 bgp_config_write_peer_global(vty
, bgp
, peer
);
15187 /* listen range and limit for dynamic BGP neighbors */
15188 bgp_config_write_listen(vty
, bgp
);
15191 * BGP default autoshutdown neighbors
15193 * This must be placed after any peer and peer-group
15194 * configuration, to avoid setting all peers to shutdown after
15195 * a daemon restart, which is undesired behavior. (see #2286)
15197 if (bgp
->autoshutdown
)
15198 vty_out(vty
, " bgp default shutdown\n");
15200 /* IPv4 unicast configuration. */
15201 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
15203 /* IPv4 multicast configuration. */
15204 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
15206 /* IPv4 labeled-unicast configuration. */
15207 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
15209 /* IPv4 VPN configuration. */
15210 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
15212 /* ENCAPv4 configuration. */
15213 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
15215 /* FLOWSPEC v4 configuration. */
15216 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
15218 /* IPv6 unicast configuration. */
15219 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
15221 /* IPv6 multicast configuration. */
15222 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
15224 /* IPv6 labeled-unicast configuration. */
15225 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
15226 SAFI_LABELED_UNICAST
);
15228 /* IPv6 VPN configuration. */
15229 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
15231 /* ENCAPv6 configuration. */
15232 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
15234 /* FLOWSPEC v6 configuration. */
15235 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
15237 /* EVPN configuration. */
15238 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
15240 hook_call(bgp_inst_config_write
, bgp
, vty
);
15243 bgp_rfapi_cfg_write(vty
, bgp
);
15246 vty_out(vty
, "!\n");
15252 /* BGP node structure. */
15253 static struct cmd_node bgp_node
= {
15254 BGP_NODE
, "%s(config-router)# ", 1,
15257 static struct cmd_node bgp_ipv4_unicast_node
= {
15258 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
15261 static struct cmd_node bgp_ipv4_multicast_node
= {
15262 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
15265 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
15266 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
15269 static struct cmd_node bgp_ipv6_unicast_node
= {
15270 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
15273 static struct cmd_node bgp_ipv6_multicast_node
= {
15274 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
15277 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
15278 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
15281 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
15282 "%s(config-router-af)# ", 1};
15284 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
15285 "%s(config-router-af-vpnv6)# ", 1};
15287 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
15288 "%s(config-router-evpn)# ", 1};
15290 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
15291 "%s(config-router-af-vni)# ", 1};
15293 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
15294 "%s(config-router-af)# ", 1};
15296 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
15297 "%s(config-router-af-vpnv6)# ", 1};
15299 static void community_list_vty(void);
15301 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
15305 struct listnode
*lnbgp
, *lnpeer
;
15307 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
15308 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
15309 /* only provide suggestions on the appropriate input
15311 * they'll otherwise show up multiple times */
15312 enum cmd_token_type match_type
;
15313 char *name
= peer
->host
;
15315 if (peer
->conf_if
) {
15316 match_type
= VARIABLE_TKN
;
15317 name
= peer
->conf_if
;
15318 } else if (strchr(peer
->host
, ':'))
15319 match_type
= IPV6_TKN
;
15321 match_type
= IPV4_TKN
;
15323 if (token
->type
!= match_type
)
15326 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
15331 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
15332 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
15333 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
15334 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
15335 {.completions
= NULL
}};
15337 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
15340 struct peer_group
*group
;
15341 struct listnode
*lnbgp
, *lnpeer
;
15343 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
15344 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
15345 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
15350 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
15351 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
15352 {.completions
= NULL
} };
15354 void bgp_vty_init(void)
15356 cmd_variable_handler_register(bgp_var_neighbor
);
15357 cmd_variable_handler_register(bgp_var_peergroup
);
15359 /* Install bgp top node. */
15360 install_node(&bgp_node
, bgp_config_write
);
15361 install_node(&bgp_ipv4_unicast_node
, NULL
);
15362 install_node(&bgp_ipv4_multicast_node
, NULL
);
15363 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
15364 install_node(&bgp_ipv6_unicast_node
, NULL
);
15365 install_node(&bgp_ipv6_multicast_node
, NULL
);
15366 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
15367 install_node(&bgp_vpnv4_node
, NULL
);
15368 install_node(&bgp_vpnv6_node
, NULL
);
15369 install_node(&bgp_evpn_node
, NULL
);
15370 install_node(&bgp_evpn_vni_node
, NULL
);
15371 install_node(&bgp_flowspecv4_node
, NULL
);
15372 install_node(&bgp_flowspecv6_node
, NULL
);
15374 /* Install default VTY commands to new nodes. */
15375 install_default(BGP_NODE
);
15376 install_default(BGP_IPV4_NODE
);
15377 install_default(BGP_IPV4M_NODE
);
15378 install_default(BGP_IPV4L_NODE
);
15379 install_default(BGP_IPV6_NODE
);
15380 install_default(BGP_IPV6M_NODE
);
15381 install_default(BGP_IPV6L_NODE
);
15382 install_default(BGP_VPNV4_NODE
);
15383 install_default(BGP_VPNV6_NODE
);
15384 install_default(BGP_FLOWSPECV4_NODE
);
15385 install_default(BGP_FLOWSPECV6_NODE
);
15386 install_default(BGP_EVPN_NODE
);
15387 install_default(BGP_EVPN_VNI_NODE
);
15389 /* "bgp local-mac" hidden commands. */
15390 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
15391 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
15393 /* bgp route-map delay-timer commands. */
15394 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
15395 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
15397 /* Dummy commands (Currently not supported) */
15398 install_element(BGP_NODE
, &no_synchronization_cmd
);
15399 install_element(BGP_NODE
, &no_auto_summary_cmd
);
15401 /* "router bgp" commands. */
15402 install_element(CONFIG_NODE
, &router_bgp_cmd
);
15404 /* "no router bgp" commands. */
15405 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
15407 /* "bgp router-id" commands. */
15408 install_element(BGP_NODE
, &bgp_router_id_cmd
);
15409 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
15411 /* "bgp cluster-id" commands. */
15412 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
15413 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
15415 /* "bgp confederation" commands. */
15416 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
15417 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
15419 /* "bgp confederation peers" commands. */
15420 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
15421 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
15423 /* bgp max-med command */
15424 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
15425 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
15426 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
15427 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
15428 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
15430 /* bgp disable-ebgp-connected-nh-check */
15431 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
15432 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
15434 /* bgp update-delay command */
15435 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
15436 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
15437 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
15439 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
15440 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
15442 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
15443 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
15445 /* "maximum-paths" commands. */
15446 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
15447 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
15448 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
15449 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
15450 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
15451 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
15452 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
15453 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
15454 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
15455 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
15456 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
15457 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
15458 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
15459 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
15460 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
15462 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
15463 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
15464 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
15465 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
15466 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
15468 /* "timers bgp" commands. */
15469 install_element(BGP_NODE
, &bgp_timers_cmd
);
15470 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
15472 /* route-map delay-timer commands - per instance for backwards compat.
15474 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
15475 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
15477 /* "bgp client-to-client reflection" commands */
15478 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
15479 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
15481 /* "bgp always-compare-med" commands */
15482 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
15483 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
15485 /* bgp ebgp-requires-policy */
15486 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
15487 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
15489 /* bgp reject-as-sets */
15490 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
15491 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
15493 /* "bgp deterministic-med" commands */
15494 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
15495 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
15497 /* "bgp graceful-restart" command */
15498 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
15499 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
15501 /* "bgp graceful-restart-disable" command */
15502 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
15503 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
15505 /* "neighbor a:b:c:d graceful-restart" command */
15506 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
15507 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
15509 /* "neighbor a:b:c:d graceful-restart-disable" command */
15510 install_element(BGP_NODE
,
15511 &bgp_neighbor_graceful_restart_disable_set_cmd
);
15512 install_element(BGP_NODE
,
15513 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
15515 /* "neighbor a:b:c:d graceful-restart-helper" command */
15516 install_element(BGP_NODE
,
15517 &bgp_neighbor_graceful_restart_helper_set_cmd
);
15518 install_element(BGP_NODE
,
15519 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
15521 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
15522 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
15523 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
15524 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
15525 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
15526 install_element(BGP_NODE
,
15527 &no_bgp_graceful_restart_select_defer_time_cmd
);
15528 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
15529 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
15531 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
15532 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
15533 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
15534 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
15536 /* "bgp graceful-shutdown" commands */
15537 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
15538 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
15540 /* "bgp fast-external-failover" commands */
15541 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
15542 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
15544 /* "bgp bestpath compare-routerid" commands */
15545 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
15546 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
15548 /* "bgp bestpath as-path ignore" commands */
15549 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
15550 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
15552 /* "bgp bestpath as-path confed" commands */
15553 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
15554 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
15556 /* "bgp bestpath as-path multipath-relax" commands */
15557 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
15558 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
15560 /* "bgp log-neighbor-changes" commands */
15561 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
15562 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
15564 /* "bgp bestpath med" commands */
15565 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
15566 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
15568 /* "no bgp default ipv4-unicast" commands. */
15569 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
15570 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
15572 /* "bgp network import-check" commands. */
15573 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
15574 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
15575 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
15577 /* "bgp default local-preference" commands. */
15578 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
15579 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
15581 /* bgp default show-hostname */
15582 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
15583 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
15585 /* "bgp default subgroup-pkt-queue-max" commands. */
15586 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
15587 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
15589 /* bgp ibgp-allow-policy-mods command */
15590 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
15591 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
15593 /* "bgp listen limit" commands. */
15594 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
15595 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
15597 /* "bgp listen range" commands. */
15598 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
15599 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
15601 /* "bgp default shutdown" command */
15602 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
15604 /* "neighbor remote-as" commands. */
15605 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
15606 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
15607 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
15608 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
15609 install_element(BGP_NODE
,
15610 &neighbor_interface_v6only_config_remote_as_cmd
);
15611 install_element(BGP_NODE
, &no_neighbor_cmd
);
15612 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
15614 /* "neighbor peer-group" commands. */
15615 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
15616 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
15617 install_element(BGP_NODE
,
15618 &no_neighbor_interface_peer_group_remote_as_cmd
);
15620 /* "neighbor local-as" commands. */
15621 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
15622 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
15623 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
15624 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
15626 /* "neighbor solo" commands. */
15627 install_element(BGP_NODE
, &neighbor_solo_cmd
);
15628 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
15630 /* "neighbor password" commands. */
15631 install_element(BGP_NODE
, &neighbor_password_cmd
);
15632 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
15634 /* "neighbor activate" commands. */
15635 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
15636 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
15637 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
15638 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
15639 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
15640 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
15641 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
15642 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
15643 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
15644 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
15645 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
15646 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
15648 /* "no neighbor activate" commands. */
15649 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
15650 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
15651 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
15652 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
15653 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
15654 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
15655 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
15656 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
15657 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
15658 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
15659 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
15660 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
15662 /* "neighbor peer-group" set commands. */
15663 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
15664 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
15665 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
15666 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
15667 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
15668 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
15669 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
15670 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
15671 install_element(BGP_FLOWSPECV4_NODE
,
15672 &neighbor_set_peer_group_hidden_cmd
);
15673 install_element(BGP_FLOWSPECV6_NODE
,
15674 &neighbor_set_peer_group_hidden_cmd
);
15676 /* "no neighbor peer-group unset" commands. */
15677 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
15678 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
15679 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
15680 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
15681 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
15682 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
15683 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
15684 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
15685 install_element(BGP_FLOWSPECV4_NODE
,
15686 &no_neighbor_set_peer_group_hidden_cmd
);
15687 install_element(BGP_FLOWSPECV6_NODE
,
15688 &no_neighbor_set_peer_group_hidden_cmd
);
15690 /* "neighbor softreconfiguration inbound" commands.*/
15691 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
15692 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
15693 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
15694 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
15695 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
15696 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
15697 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
15698 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
15699 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
15700 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
15701 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
15702 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
15703 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
15704 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
15705 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
15706 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
15707 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
15708 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
15709 install_element(BGP_FLOWSPECV4_NODE
,
15710 &neighbor_soft_reconfiguration_cmd
);
15711 install_element(BGP_FLOWSPECV4_NODE
,
15712 &no_neighbor_soft_reconfiguration_cmd
);
15713 install_element(BGP_FLOWSPECV6_NODE
,
15714 &neighbor_soft_reconfiguration_cmd
);
15715 install_element(BGP_FLOWSPECV6_NODE
,
15716 &no_neighbor_soft_reconfiguration_cmd
);
15717 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
15718 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
15720 /* "neighbor attribute-unchanged" commands. */
15721 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
15722 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
15723 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
15724 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
15725 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
15726 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
15727 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
15728 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
15729 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
15730 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
15731 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
15732 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
15733 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
15734 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
15735 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
15736 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
15737 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
15738 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
15740 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
15741 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
15743 /* "nexthop-local unchanged" commands */
15744 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
15745 install_element(BGP_IPV6_NODE
,
15746 &no_neighbor_nexthop_local_unchanged_cmd
);
15748 /* "neighbor next-hop-self" commands. */
15749 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
15750 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
15751 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
15752 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
15753 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
15754 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
15755 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
15756 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
15757 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
15758 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
15759 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
15760 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
15761 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
15762 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
15763 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
15764 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
15765 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
15766 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
15767 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
15768 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
15770 /* "neighbor next-hop-self force" commands. */
15771 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
15772 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
15773 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
15774 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
15775 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
15776 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
15777 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
15778 install_element(BGP_IPV4_NODE
,
15779 &no_neighbor_nexthop_self_all_hidden_cmd
);
15780 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
15781 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
15782 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
15783 install_element(BGP_IPV4M_NODE
,
15784 &no_neighbor_nexthop_self_all_hidden_cmd
);
15785 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
15786 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
15787 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
15788 install_element(BGP_IPV4L_NODE
,
15789 &no_neighbor_nexthop_self_all_hidden_cmd
);
15790 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
15791 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
15792 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
15793 install_element(BGP_IPV6_NODE
,
15794 &no_neighbor_nexthop_self_all_hidden_cmd
);
15795 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
15796 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
15797 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
15798 install_element(BGP_IPV6M_NODE
,
15799 &no_neighbor_nexthop_self_all_hidden_cmd
);
15800 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
15801 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
15802 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
15803 install_element(BGP_IPV6L_NODE
,
15804 &no_neighbor_nexthop_self_all_hidden_cmd
);
15805 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
15806 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
15807 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
15808 install_element(BGP_VPNV4_NODE
,
15809 &no_neighbor_nexthop_self_all_hidden_cmd
);
15810 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
15811 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
15812 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
15813 install_element(BGP_VPNV6_NODE
,
15814 &no_neighbor_nexthop_self_all_hidden_cmd
);
15816 /* "neighbor as-override" commands. */
15817 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
15818 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
15819 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
15820 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
15821 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
15822 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
15823 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
15824 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
15825 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
15826 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
15827 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
15828 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
15829 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
15830 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
15831 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
15832 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
15833 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
15834 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
15836 /* "neighbor remove-private-AS" commands. */
15837 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
15838 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
15839 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
15840 install_element(BGP_NODE
,
15841 &no_neighbor_remove_private_as_all_hidden_cmd
);
15842 install_element(BGP_NODE
,
15843 &neighbor_remove_private_as_replace_as_hidden_cmd
);
15844 install_element(BGP_NODE
,
15845 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
15846 install_element(BGP_NODE
,
15847 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
15850 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
15851 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
15852 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
15853 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
15854 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
15855 install_element(BGP_IPV4_NODE
,
15856 &neighbor_remove_private_as_replace_as_cmd
);
15857 install_element(BGP_IPV4_NODE
,
15858 &no_neighbor_remove_private_as_replace_as_cmd
);
15859 install_element(BGP_IPV4_NODE
,
15860 &neighbor_remove_private_as_all_replace_as_cmd
);
15861 install_element(BGP_IPV4_NODE
,
15862 &no_neighbor_remove_private_as_all_replace_as_cmd
);
15863 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
15864 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
15865 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
15866 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
15867 install_element(BGP_IPV4M_NODE
,
15868 &neighbor_remove_private_as_replace_as_cmd
);
15869 install_element(BGP_IPV4M_NODE
,
15870 &no_neighbor_remove_private_as_replace_as_cmd
);
15871 install_element(BGP_IPV4M_NODE
,
15872 &neighbor_remove_private_as_all_replace_as_cmd
);
15873 install_element(BGP_IPV4M_NODE
,
15874 &no_neighbor_remove_private_as_all_replace_as_cmd
);
15875 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
15876 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
15877 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
15878 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
15879 install_element(BGP_IPV4L_NODE
,
15880 &neighbor_remove_private_as_replace_as_cmd
);
15881 install_element(BGP_IPV4L_NODE
,
15882 &no_neighbor_remove_private_as_replace_as_cmd
);
15883 install_element(BGP_IPV4L_NODE
,
15884 &neighbor_remove_private_as_all_replace_as_cmd
);
15885 install_element(BGP_IPV4L_NODE
,
15886 &no_neighbor_remove_private_as_all_replace_as_cmd
);
15887 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
15888 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
15889 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
15890 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
15891 install_element(BGP_IPV6_NODE
,
15892 &neighbor_remove_private_as_replace_as_cmd
);
15893 install_element(BGP_IPV6_NODE
,
15894 &no_neighbor_remove_private_as_replace_as_cmd
);
15895 install_element(BGP_IPV6_NODE
,
15896 &neighbor_remove_private_as_all_replace_as_cmd
);
15897 install_element(BGP_IPV6_NODE
,
15898 &no_neighbor_remove_private_as_all_replace_as_cmd
);
15899 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
15900 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
15901 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
15902 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
15903 install_element(BGP_IPV6M_NODE
,
15904 &neighbor_remove_private_as_replace_as_cmd
);
15905 install_element(BGP_IPV6M_NODE
,
15906 &no_neighbor_remove_private_as_replace_as_cmd
);
15907 install_element(BGP_IPV6M_NODE
,
15908 &neighbor_remove_private_as_all_replace_as_cmd
);
15909 install_element(BGP_IPV6M_NODE
,
15910 &no_neighbor_remove_private_as_all_replace_as_cmd
);
15911 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
15912 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
15913 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
15914 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
15915 install_element(BGP_IPV6L_NODE
,
15916 &neighbor_remove_private_as_replace_as_cmd
);
15917 install_element(BGP_IPV6L_NODE
,
15918 &no_neighbor_remove_private_as_replace_as_cmd
);
15919 install_element(BGP_IPV6L_NODE
,
15920 &neighbor_remove_private_as_all_replace_as_cmd
);
15921 install_element(BGP_IPV6L_NODE
,
15922 &no_neighbor_remove_private_as_all_replace_as_cmd
);
15923 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
15924 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
15925 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
15926 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
15927 install_element(BGP_VPNV4_NODE
,
15928 &neighbor_remove_private_as_replace_as_cmd
);
15929 install_element(BGP_VPNV4_NODE
,
15930 &no_neighbor_remove_private_as_replace_as_cmd
);
15931 install_element(BGP_VPNV4_NODE
,
15932 &neighbor_remove_private_as_all_replace_as_cmd
);
15933 install_element(BGP_VPNV4_NODE
,
15934 &no_neighbor_remove_private_as_all_replace_as_cmd
);
15935 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
15936 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
15937 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
15938 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
15939 install_element(BGP_VPNV6_NODE
,
15940 &neighbor_remove_private_as_replace_as_cmd
);
15941 install_element(BGP_VPNV6_NODE
,
15942 &no_neighbor_remove_private_as_replace_as_cmd
);
15943 install_element(BGP_VPNV6_NODE
,
15944 &neighbor_remove_private_as_all_replace_as_cmd
);
15945 install_element(BGP_VPNV6_NODE
,
15946 &no_neighbor_remove_private_as_all_replace_as_cmd
);
15948 /* "neighbor send-community" commands.*/
15949 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
15950 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
15951 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
15952 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
15953 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
15954 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
15955 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
15956 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
15957 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
15958 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
15959 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
15960 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
15961 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
15962 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
15963 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
15964 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
15965 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
15966 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
15967 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
15968 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
15969 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
15970 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
15971 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
15972 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
15973 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
15974 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
15975 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
15976 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
15977 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
15978 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
15979 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
15980 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
15981 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
15982 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
15983 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
15984 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
15986 /* "neighbor route-reflector" commands.*/
15987 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
15988 install_element(BGP_NODE
,
15989 &no_neighbor_route_reflector_client_hidden_cmd
);
15990 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
15991 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
15992 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
15993 install_element(BGP_IPV4M_NODE
,
15994 &no_neighbor_route_reflector_client_cmd
);
15995 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
15996 install_element(BGP_IPV4L_NODE
,
15997 &no_neighbor_route_reflector_client_cmd
);
15998 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
15999 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
16000 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
16001 install_element(BGP_IPV6M_NODE
,
16002 &no_neighbor_route_reflector_client_cmd
);
16003 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
16004 install_element(BGP_IPV6L_NODE
,
16005 &no_neighbor_route_reflector_client_cmd
);
16006 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
16007 install_element(BGP_VPNV4_NODE
,
16008 &no_neighbor_route_reflector_client_cmd
);
16009 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
16010 install_element(BGP_VPNV6_NODE
,
16011 &no_neighbor_route_reflector_client_cmd
);
16012 install_element(BGP_FLOWSPECV4_NODE
,
16013 &neighbor_route_reflector_client_cmd
);
16014 install_element(BGP_FLOWSPECV4_NODE
,
16015 &no_neighbor_route_reflector_client_cmd
);
16016 install_element(BGP_FLOWSPECV6_NODE
,
16017 &neighbor_route_reflector_client_cmd
);
16018 install_element(BGP_FLOWSPECV6_NODE
,
16019 &no_neighbor_route_reflector_client_cmd
);
16020 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
16021 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
16023 /* "neighbor route-server" commands.*/
16024 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
16025 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
16026 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
16027 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
16028 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
16029 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
16030 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
16031 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
16032 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
16033 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
16034 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
16035 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
16036 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
16037 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
16038 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
16039 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
16040 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
16041 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
16042 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
16043 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
16044 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
16045 install_element(BGP_FLOWSPECV4_NODE
,
16046 &no_neighbor_route_server_client_cmd
);
16047 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
16048 install_element(BGP_FLOWSPECV6_NODE
,
16049 &no_neighbor_route_server_client_cmd
);
16051 /* "neighbor addpath-tx-all-paths" commands.*/
16052 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
16053 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
16054 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16055 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16056 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16057 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16058 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16059 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16060 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16061 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16062 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16063 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16064 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16065 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16066 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16067 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16068 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16069 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16071 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
16072 install_element(BGP_NODE
,
16073 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
16074 install_element(BGP_NODE
,
16075 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
16076 install_element(BGP_IPV4_NODE
,
16077 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16078 install_element(BGP_IPV4_NODE
,
16079 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16080 install_element(BGP_IPV4M_NODE
,
16081 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16082 install_element(BGP_IPV4M_NODE
,
16083 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16084 install_element(BGP_IPV4L_NODE
,
16085 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16086 install_element(BGP_IPV4L_NODE
,
16087 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16088 install_element(BGP_IPV6_NODE
,
16089 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16090 install_element(BGP_IPV6_NODE
,
16091 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16092 install_element(BGP_IPV6M_NODE
,
16093 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16094 install_element(BGP_IPV6M_NODE
,
16095 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16096 install_element(BGP_IPV6L_NODE
,
16097 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16098 install_element(BGP_IPV6L_NODE
,
16099 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16100 install_element(BGP_VPNV4_NODE
,
16101 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16102 install_element(BGP_VPNV4_NODE
,
16103 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16104 install_element(BGP_VPNV6_NODE
,
16105 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16106 install_element(BGP_VPNV6_NODE
,
16107 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16109 /* "neighbor sender-as-path-loop-detection" commands. */
16110 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
16111 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
16113 /* "neighbor passive" commands. */
16114 install_element(BGP_NODE
, &neighbor_passive_cmd
);
16115 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
16118 /* "neighbor shutdown" commands. */
16119 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
16120 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
16121 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
16122 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
16124 /* "neighbor capability extended-nexthop" commands.*/
16125 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
16126 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
16128 /* "neighbor capability orf prefix-list" commands.*/
16129 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
16130 install_element(BGP_NODE
,
16131 &no_neighbor_capability_orf_prefix_hidden_cmd
);
16132 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
16133 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
16134 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
16135 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
16136 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
16137 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
16138 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
16139 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
16140 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
16141 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
16142 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
16143 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
16145 /* "neighbor capability dynamic" commands.*/
16146 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
16147 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
16149 /* "neighbor dont-capability-negotiate" commands. */
16150 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
16151 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
16153 /* "neighbor ebgp-multihop" commands. */
16154 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
16155 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
16156 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
16158 /* "neighbor disable-connected-check" commands. */
16159 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
16160 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
16162 /* "neighbor enforce-first-as" commands. */
16163 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
16164 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
16166 /* "neighbor description" commands. */
16167 install_element(BGP_NODE
, &neighbor_description_cmd
);
16168 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
16169 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
16171 /* "neighbor update-source" commands. "*/
16172 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
16173 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
16175 /* "neighbor default-originate" commands. */
16176 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
16177 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
16178 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
16179 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
16180 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
16181 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
16182 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
16183 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
16184 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
16185 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
16186 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
16187 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
16188 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
16189 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
16190 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
16191 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
16192 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
16193 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
16194 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
16195 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
16196 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
16198 /* "neighbor port" commands. */
16199 install_element(BGP_NODE
, &neighbor_port_cmd
);
16200 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
16202 /* "neighbor weight" commands. */
16203 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
16204 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
16206 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
16207 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
16208 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
16209 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
16210 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
16211 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
16212 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
16213 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
16214 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
16215 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
16216 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
16217 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
16218 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
16219 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
16220 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
16221 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
16223 /* "neighbor override-capability" commands. */
16224 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
16225 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
16227 /* "neighbor strict-capability-match" commands. */
16228 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
16229 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
16231 /* "neighbor timers" commands. */
16232 install_element(BGP_NODE
, &neighbor_timers_cmd
);
16233 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
16235 /* "neighbor timers connect" commands. */
16236 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
16237 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
16239 /* "neighbor advertisement-interval" commands. */
16240 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
16241 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
16243 /* "neighbor interface" commands. */
16244 install_element(BGP_NODE
, &neighbor_interface_cmd
);
16245 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
16247 /* "neighbor distribute" commands. */
16248 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
16249 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
16250 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
16251 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
16252 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
16253 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
16254 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
16255 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
16256 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
16257 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
16258 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
16259 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
16260 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
16261 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
16262 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
16263 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
16264 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
16265 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
16267 /* "neighbor prefix-list" commands. */
16268 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
16269 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
16270 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
16271 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
16272 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
16273 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
16274 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
16275 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
16276 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
16277 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
16278 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
16279 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
16280 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
16281 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
16282 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
16283 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
16284 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
16285 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
16286 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
16287 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
16288 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
16289 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
16291 /* "neighbor filter-list" commands. */
16292 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
16293 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
16294 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
16295 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
16296 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
16297 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
16298 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
16299 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
16300 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
16301 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
16302 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
16303 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
16304 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
16305 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
16306 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
16307 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
16308 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
16309 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
16310 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
16311 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
16312 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
16313 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
16315 /* "neighbor route-map" commands. */
16316 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
16317 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
16318 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
16319 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
16320 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
16321 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
16322 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
16323 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
16324 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
16325 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
16326 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
16327 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
16328 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
16329 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
16330 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
16331 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
16332 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
16333 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
16334 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
16335 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
16336 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
16337 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
16338 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
16339 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
16341 /* "neighbor unsuppress-map" commands. */
16342 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
16343 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
16344 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
16345 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
16346 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
16347 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
16348 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
16349 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
16350 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
16351 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
16352 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
16353 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
16354 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
16355 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
16356 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
16357 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
16358 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
16359 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
16361 /* neighbor maximum-prefix-out commands. */
16362 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
16363 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16364 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
16365 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16366 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
16367 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16368 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
16369 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16370 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
16371 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16372 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
16373 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16374 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
16375 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16376 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
16377 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16378 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
16379 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16381 /* "neighbor maximum-prefix" commands. */
16382 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
16383 install_element(BGP_NODE
,
16384 &neighbor_maximum_prefix_threshold_hidden_cmd
);
16385 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
16386 install_element(BGP_NODE
,
16387 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
16388 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
16389 install_element(BGP_NODE
,
16390 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
16391 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
16392 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
16393 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16394 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16395 install_element(BGP_IPV4_NODE
,
16396 &neighbor_maximum_prefix_threshold_warning_cmd
);
16397 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16398 install_element(BGP_IPV4_NODE
,
16399 &neighbor_maximum_prefix_threshold_restart_cmd
);
16400 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
16401 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
16402 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16403 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16404 install_element(BGP_IPV4M_NODE
,
16405 &neighbor_maximum_prefix_threshold_warning_cmd
);
16406 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16407 install_element(BGP_IPV4M_NODE
,
16408 &neighbor_maximum_prefix_threshold_restart_cmd
);
16409 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
16410 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
16411 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16412 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16413 install_element(BGP_IPV4L_NODE
,
16414 &neighbor_maximum_prefix_threshold_warning_cmd
);
16415 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16416 install_element(BGP_IPV4L_NODE
,
16417 &neighbor_maximum_prefix_threshold_restart_cmd
);
16418 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
16419 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
16420 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16421 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16422 install_element(BGP_IPV6_NODE
,
16423 &neighbor_maximum_prefix_threshold_warning_cmd
);
16424 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16425 install_element(BGP_IPV6_NODE
,
16426 &neighbor_maximum_prefix_threshold_restart_cmd
);
16427 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
16428 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
16429 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16430 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16431 install_element(BGP_IPV6M_NODE
,
16432 &neighbor_maximum_prefix_threshold_warning_cmd
);
16433 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16434 install_element(BGP_IPV6M_NODE
,
16435 &neighbor_maximum_prefix_threshold_restart_cmd
);
16436 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
16437 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
16438 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16439 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16440 install_element(BGP_IPV6L_NODE
,
16441 &neighbor_maximum_prefix_threshold_warning_cmd
);
16442 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16443 install_element(BGP_IPV6L_NODE
,
16444 &neighbor_maximum_prefix_threshold_restart_cmd
);
16445 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
16446 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
16447 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16448 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16449 install_element(BGP_VPNV4_NODE
,
16450 &neighbor_maximum_prefix_threshold_warning_cmd
);
16451 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16452 install_element(BGP_VPNV4_NODE
,
16453 &neighbor_maximum_prefix_threshold_restart_cmd
);
16454 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
16455 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
16456 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16457 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16458 install_element(BGP_VPNV6_NODE
,
16459 &neighbor_maximum_prefix_threshold_warning_cmd
);
16460 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16461 install_element(BGP_VPNV6_NODE
,
16462 &neighbor_maximum_prefix_threshold_restart_cmd
);
16463 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
16465 /* "neighbor allowas-in" */
16466 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
16467 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
16468 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
16469 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
16470 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
16471 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
16472 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
16473 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
16474 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
16475 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
16476 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
16477 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
16478 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
16479 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
16480 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
16481 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
16482 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
16483 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
16484 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
16485 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
16487 /* address-family commands. */
16488 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
16489 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
16490 #ifdef KEEP_OLD_VPN_COMMANDS
16491 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
16492 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
16493 #endif /* KEEP_OLD_VPN_COMMANDS */
16495 install_element(BGP_NODE
, &address_family_evpn_cmd
);
16497 /* "exit-address-family" command. */
16498 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
16499 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
16500 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
16501 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
16502 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
16503 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
16504 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
16505 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
16506 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
16507 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
16508 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
16510 /* "clear ip bgp commands" */
16511 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
16513 /* clear ip bgp prefix */
16514 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
16515 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
16516 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
16518 /* "show [ip] bgp summary" commands. */
16519 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
16520 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
16521 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
16522 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
16523 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
16524 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
16525 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
16527 /* "show [ip] bgp neighbors" commands. */
16528 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
16530 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
16532 /* "show [ip] bgp peer-group" commands. */
16533 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
16535 /* "show [ip] bgp paths" commands. */
16536 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
16538 /* "show [ip] bgp community" commands. */
16539 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
16541 /* "show ip bgp large-community" commands. */
16542 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
16543 /* "show [ip] bgp attribute-info" commands. */
16544 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
16545 /* "show [ip] bgp route-leak" command */
16546 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
16548 /* "redistribute" commands. */
16549 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
16550 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
16551 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
16552 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
16553 install_element(BGP_NODE
,
16554 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
16555 install_element(BGP_NODE
,
16556 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
16557 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
16558 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
16559 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
16560 install_element(BGP_NODE
,
16561 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
16562 install_element(BGP_NODE
,
16563 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
16564 install_element(BGP_NODE
,
16565 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
16566 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
16567 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
16568 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
16569 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
16570 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
16571 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
16572 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
16573 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
16574 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
16575 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
16576 install_element(BGP_IPV4_NODE
,
16577 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
16578 install_element(BGP_IPV4_NODE
,
16579 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
16580 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
16581 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
16582 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
16583 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
16584 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
16585 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
16587 /* import|export vpn [route-map WORD] */
16588 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
16589 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
16591 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
16592 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
16594 /* ttl_security commands */
16595 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
16596 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
16598 /* "show [ip] bgp memory" commands. */
16599 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
16601 /* "show bgp martian next-hop" */
16602 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
16604 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
16606 /* "show [ip] bgp views" commands. */
16607 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
16609 /* "show [ip] bgp vrfs" commands. */
16610 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
16612 /* Community-list. */
16613 community_list_vty();
16615 /* vpn-policy commands */
16616 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
16617 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
16618 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
16619 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
16620 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
16621 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
16622 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
16623 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
16624 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
16625 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
16626 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
16627 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
16629 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
16630 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
16632 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
16633 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
16634 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
16635 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
16636 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
16637 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
16638 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
16639 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
16640 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
16641 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
16642 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
16643 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
16646 #include "memory.h"
16647 #include "bgp_regex.h"
16648 #include "bgp_clist.h"
16649 #include "bgp_ecommunity.h"
16651 /* VTY functions. */
16653 /* Direction value to string conversion. */
16654 static const char *community_direct_str(int direct
)
16657 case COMMUNITY_DENY
:
16659 case COMMUNITY_PERMIT
:
16666 /* Display error string. */
16667 static void community_list_perror(struct vty
*vty
, int ret
)
16670 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
16671 vty_out(vty
, "%% Can't find community-list\n");
16673 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
16674 vty_out(vty
, "%% Malformed community-list value\n");
16676 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
16678 "%% Community name conflict, previously defined as standard community\n");
16680 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
16682 "%% Community name conflict, previously defined as expanded community\n");
16687 /* "community-list" keyword help string. */
16688 #define COMMUNITY_LIST_STR "Add a community list entry\n"
16690 /*community-list standard */
16691 DEFUN (community_list_standard
,
16692 bgp_community_list_standard_cmd
,
16693 "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
16696 "Community list number (standard)\n"
16697 "Add an standard community-list entry\n"
16698 "Community list name\n"
16699 "Sequence number of an entry\n"
16700 "Sequence number\n"
16701 "Specify community to reject\n"
16702 "Specify community to accept\n"
16705 char *cl_name_or_number
= NULL
;
16708 int style
= COMMUNITY_LIST_STANDARD
;
16711 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
16713 seq
= argv
[idx
]->arg
;
16716 argv_find(argv
, argc
, "(1-99)", &idx
);
16717 argv_find(argv
, argc
, "WORD", &idx
);
16718 cl_name_or_number
= argv
[idx
]->arg
;
16719 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
16721 argv_find(argv
, argc
, "AA:NN", &idx
);
16722 char *str
= argv_concat(argv
, argc
, idx
);
16724 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
16727 XFREE(MTYPE_TMP
, str
);
16730 /* Display error string. */
16731 community_list_perror(vty
, ret
);
16732 return CMD_WARNING_CONFIG_FAILED
;
16735 return CMD_SUCCESS
;
16738 DEFUN (no_community_list_standard_all
,
16739 no_bgp_community_list_standard_all_cmd
,
16740 "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
16744 "Community list number (standard)\n"
16745 "Add an standard community-list entry\n"
16746 "Community list name\n"
16747 "Sequence number of an entry\n"
16748 "Sequence number\n"
16749 "Specify community to reject\n"
16750 "Specify community to accept\n"
16753 char *cl_name_or_number
= NULL
;
16756 int style
= COMMUNITY_LIST_STANDARD
;
16760 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
16762 seq
= argv
[idx
]->arg
;
16765 argv_find(argv
, argc
, "permit", &idx
);
16766 argv_find(argv
, argc
, "deny", &idx
);
16769 direct
= argv_find(argv
, argc
, "permit", &idx
)
16774 argv_find(argv
, argc
, "AA:NN", &idx
);
16775 str
= argv_concat(argv
, argc
, idx
);
16779 argv_find(argv
, argc
, "(1-99)", &idx
);
16780 argv_find(argv
, argc
, "WORD", &idx
);
16781 cl_name_or_number
= argv
[idx
]->arg
;
16783 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
16786 XFREE(MTYPE_TMP
, str
);
16789 community_list_perror(vty
, ret
);
16790 return CMD_WARNING_CONFIG_FAILED
;
16793 return CMD_SUCCESS
;
16796 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
16797 "no bgp community-list <(1-99)|standard WORD>",
16798 NO_STR BGP_STR COMMUNITY_LIST_STR
16799 "Community list number (standard)\n"
16800 "Add an standard community-list entry\n"
16801 "Community list name\n")
16803 /*community-list expanded */
16804 DEFUN (community_list_expanded_all
,
16805 bgp_community_list_expanded_all_cmd
,
16806 "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
16809 "Community list number (expanded)\n"
16810 "Add an expanded community-list entry\n"
16811 "Community list name\n"
16812 "Sequence number of an entry\n"
16813 "Sequence number\n"
16814 "Specify community to reject\n"
16815 "Specify community to accept\n"
16818 char *cl_name_or_number
= NULL
;
16821 int style
= COMMUNITY_LIST_EXPANDED
;
16824 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
16826 seq
= argv
[idx
]->arg
;
16830 argv_find(argv
, argc
, "(100-500)", &idx
);
16831 argv_find(argv
, argc
, "WORD", &idx
);
16832 cl_name_or_number
= argv
[idx
]->arg
;
16833 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
16835 argv_find(argv
, argc
, "AA:NN", &idx
);
16836 char *str
= argv_concat(argv
, argc
, idx
);
16838 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
16841 XFREE(MTYPE_TMP
, str
);
16844 /* Display error string. */
16845 community_list_perror(vty
, ret
);
16846 return CMD_WARNING_CONFIG_FAILED
;
16849 return CMD_SUCCESS
;
16852 DEFUN (no_community_list_expanded_all
,
16853 no_bgp_community_list_expanded_all_cmd
,
16854 "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
16858 "Community list number (expanded)\n"
16859 "Add an expanded community-list entry\n"
16860 "Community list name\n"
16861 "Sequence number of an entry\n"
16862 "Sequence number\n"
16863 "Specify community to reject\n"
16864 "Specify community to accept\n"
16867 char *cl_name_or_number
= NULL
;
16871 int style
= COMMUNITY_LIST_EXPANDED
;
16874 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
16876 seq
= argv
[idx
]->arg
;
16879 argv_find(argv
, argc
, "permit", &idx
);
16880 argv_find(argv
, argc
, "deny", &idx
);
16883 direct
= argv_find(argv
, argc
, "permit", &idx
)
16888 argv_find(argv
, argc
, "AA:NN", &idx
);
16889 str
= argv_concat(argv
, argc
, idx
);
16893 argv_find(argv
, argc
, "(100-500)", &idx
);
16894 argv_find(argv
, argc
, "WORD", &idx
);
16895 cl_name_or_number
= argv
[idx
]->arg
;
16897 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
16900 XFREE(MTYPE_TMP
, str
);
16903 community_list_perror(vty
, ret
);
16904 return CMD_WARNING_CONFIG_FAILED
;
16907 return CMD_SUCCESS
;
16910 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
16911 "no bgp community-list <(100-500)|expanded WORD>",
16912 NO_STR IP_STR COMMUNITY_LIST_STR
16913 "Community list number (expanded)\n"
16914 "Add an expanded community-list entry\n"
16915 "Community list name\n")
16917 /* Return configuration string of community-list entry. */
16918 static const char *community_list_config_str(struct community_entry
*entry
)
16925 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
16926 str
= community_str(entry
->u
.com
, false);
16927 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
16928 str
= lcommunity_str(entry
->u
.lcom
, false);
16930 str
= entry
->config
;
16935 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
16937 struct community_entry
*entry
;
16939 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
16940 if (entry
== list
->head
) {
16941 if (all_digit(list
->name
))
16942 vty_out(vty
, "Community %s list %s\n",
16943 entry
->style
== COMMUNITY_LIST_STANDARD
16945 : "(expanded) access",
16948 vty_out(vty
, "Named Community %s list %s\n",
16949 entry
->style
== COMMUNITY_LIST_STANDARD
16955 vty_out(vty
, " %s\n",
16956 community_direct_str(entry
->direct
));
16958 vty_out(vty
, " %s %s\n",
16959 community_direct_str(entry
->direct
),
16960 community_list_config_str(entry
));
16964 DEFUN (show_community_list
,
16965 show_bgp_community_list_cmd
,
16966 "show bgp community-list",
16969 "List community-list\n")
16971 struct community_list
*list
;
16972 struct community_list_master
*cm
;
16974 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
16976 return CMD_SUCCESS
;
16978 for (list
= cm
->num
.head
; list
; list
= list
->next
)
16979 community_list_show(vty
, list
);
16981 for (list
= cm
->str
.head
; list
; list
= list
->next
)
16982 community_list_show(vty
, list
);
16984 return CMD_SUCCESS
;
16987 DEFUN (show_community_list_arg
,
16988 show_bgp_community_list_arg_cmd
,
16989 "show bgp community-list <(1-500)|WORD> detail",
16992 "List community-list\n"
16993 "Community-list number\n"
16994 "Community-list name\n"
16995 "Detailed information on community-list\n")
16997 int idx_comm_list
= 3;
16998 struct community_list
*list
;
17000 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
17001 COMMUNITY_LIST_MASTER
);
17003 vty_out(vty
, "%% Can't find community-list\n");
17004 return CMD_WARNING
;
17007 community_list_show(vty
, list
);
17009 return CMD_SUCCESS
;
17013 * Large Community code.
17015 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
17016 struct cmd_token
**argv
, int style
,
17017 int reject_all_digit_name
)
17026 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
17028 seq
= argv
[idx
]->arg
;
17031 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
17034 /* All digit name check. */
17036 argv_find(argv
, argc
, "WORD", &idx
);
17037 argv_find(argv
, argc
, "(1-99)", &idx
);
17038 argv_find(argv
, argc
, "(100-500)", &idx
);
17039 cl_name
= argv
[idx
]->arg
;
17040 if (reject_all_digit_name
&& all_digit(cl_name
)) {
17041 vty_out(vty
, "%% Community name cannot have all digits\n");
17042 return CMD_WARNING_CONFIG_FAILED
;
17046 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
17047 argv_find(argv
, argc
, "LINE", &idx
);
17048 /* Concat community string argument. */
17050 str
= argv_concat(argv
, argc
, idx
);
17054 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
17056 /* Free temporary community list string allocated by
17058 XFREE(MTYPE_TMP
, str
);
17061 community_list_perror(vty
, ret
);
17062 return CMD_WARNING_CONFIG_FAILED
;
17064 return CMD_SUCCESS
;
17067 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
17068 struct cmd_token
**argv
, int style
)
17076 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
17078 seq
= argv
[idx
]->arg
;
17081 argv_find(argv
, argc
, "permit", &idx
);
17082 argv_find(argv
, argc
, "deny", &idx
);
17085 /* Check the list direct. */
17086 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
17087 direct
= COMMUNITY_PERMIT
;
17089 direct
= COMMUNITY_DENY
;
17092 argv_find(argv
, argc
, "LINE", &idx
);
17093 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
17094 /* Concat community string argument. */
17095 str
= argv_concat(argv
, argc
, idx
);
17099 argv_find(argv
, argc
, "(1-99)", &idx
);
17100 argv_find(argv
, argc
, "(100-500)", &idx
);
17101 argv_find(argv
, argc
, "WORD", &idx
);
17103 /* Unset community list. */
17104 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
17107 /* Free temporary community list string allocated by
17109 XFREE(MTYPE_TMP
, str
);
17112 community_list_perror(vty
, ret
);
17113 return CMD_WARNING_CONFIG_FAILED
;
17116 return CMD_SUCCESS
;
17119 /* "large-community-list" keyword help string. */
17120 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
17121 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
17123 DEFUN (lcommunity_list_standard
,
17124 bgp_lcommunity_list_standard_cmd
,
17125 "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...",
17127 LCOMMUNITY_LIST_STR
17128 "Large Community list number (standard)\n"
17129 "Sequence number of an entry\n"
17130 "Sequence number\n"
17131 "Specify large community to reject\n"
17132 "Specify large community to accept\n"
17133 LCOMMUNITY_VAL_STR
)
17135 return lcommunity_list_set_vty(vty
, argc
, argv
,
17136 LARGE_COMMUNITY_LIST_STANDARD
, 0);
17139 DEFUN (lcommunity_list_expanded
,
17140 bgp_lcommunity_list_expanded_cmd
,
17141 "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...",
17143 LCOMMUNITY_LIST_STR
17144 "Large Community list number (expanded)\n"
17145 "Sequence number of an entry\n"
17146 "Sequence number\n"
17147 "Specify large community to reject\n"
17148 "Specify large community to accept\n"
17149 "An ordered list as a regular-expression\n")
17151 return lcommunity_list_set_vty(vty
, argc
, argv
,
17152 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
17155 DEFUN (lcommunity_list_name_standard
,
17156 bgp_lcommunity_list_name_standard_cmd
,
17157 "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...",
17159 LCOMMUNITY_LIST_STR
17160 "Specify standard large-community-list\n"
17161 "Large Community list name\n"
17162 "Sequence number of an entry\n"
17163 "Sequence number\n"
17164 "Specify large community to reject\n"
17165 "Specify large community to accept\n"
17166 LCOMMUNITY_VAL_STR
)
17168 return lcommunity_list_set_vty(vty
, argc
, argv
,
17169 LARGE_COMMUNITY_LIST_STANDARD
, 1);
17172 DEFUN (lcommunity_list_name_expanded
,
17173 bgp_lcommunity_list_name_expanded_cmd
,
17174 "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...",
17176 LCOMMUNITY_LIST_STR
17177 "Specify expanded large-community-list\n"
17178 "Large Community list name\n"
17179 "Sequence number of an entry\n"
17180 "Sequence number\n"
17181 "Specify large community to reject\n"
17182 "Specify large community to accept\n"
17183 "An ordered list as a regular-expression\n")
17185 return lcommunity_list_set_vty(vty
, argc
, argv
,
17186 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
17189 DEFUN (no_lcommunity_list_all
,
17190 no_bgp_lcommunity_list_all_cmd
,
17191 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
17194 LCOMMUNITY_LIST_STR
17195 "Large Community list number (standard)\n"
17196 "Large Community list number (expanded)\n"
17197 "Large Community list name\n")
17199 return lcommunity_list_unset_vty(vty
, argc
, argv
,
17200 LARGE_COMMUNITY_LIST_STANDARD
);
17203 DEFUN (no_lcommunity_list_name_standard_all
,
17204 no_bgp_lcommunity_list_name_standard_all_cmd
,
17205 "no bgp large-community-list standard WORD",
17208 LCOMMUNITY_LIST_STR
17209 "Specify standard large-community-list\n"
17210 "Large Community list name\n")
17212 return lcommunity_list_unset_vty(vty
, argc
, argv
,
17213 LARGE_COMMUNITY_LIST_STANDARD
);
17216 DEFUN (no_lcommunity_list_name_expanded_all
,
17217 no_bgp_lcommunity_list_name_expanded_all_cmd
,
17218 "no bgp large-community-list expanded WORD",
17221 LCOMMUNITY_LIST_STR
17222 "Specify expanded large-community-list\n"
17223 "Large Community list name\n")
17225 return lcommunity_list_unset_vty(vty
, argc
, argv
,
17226 LARGE_COMMUNITY_LIST_EXPANDED
);
17229 DEFUN (no_lcommunity_list_standard
,
17230 no_bgp_lcommunity_list_standard_cmd
,
17231 "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...",
17234 LCOMMUNITY_LIST_STR
17235 "Large Community list number (standard)\n"
17236 "Sequence number of an entry\n"
17237 "Sequence number\n"
17238 "Specify large community to reject\n"
17239 "Specify large community to accept\n"
17240 LCOMMUNITY_VAL_STR
)
17242 return lcommunity_list_unset_vty(vty
, argc
, argv
,
17243 LARGE_COMMUNITY_LIST_STANDARD
);
17246 DEFUN (no_lcommunity_list_expanded
,
17247 no_bgp_lcommunity_list_expanded_cmd
,
17248 "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...",
17251 LCOMMUNITY_LIST_STR
17252 "Large Community list number (expanded)\n"
17253 "Sequence number of an entry\n"
17254 "Sequence number\n"
17255 "Specify large community to reject\n"
17256 "Specify large community to accept\n"
17257 "An ordered list as a regular-expression\n")
17259 return lcommunity_list_unset_vty(vty
, argc
, argv
,
17260 LARGE_COMMUNITY_LIST_EXPANDED
);
17263 DEFUN (no_lcommunity_list_name_standard
,
17264 no_bgp_lcommunity_list_name_standard_cmd
,
17265 "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...",
17268 LCOMMUNITY_LIST_STR
17269 "Specify standard large-community-list\n"
17270 "Large Community list name\n"
17271 "Sequence number of an entry\n"
17272 "Sequence number\n"
17273 "Specify large community to reject\n"
17274 "Specify large community to accept\n"
17275 LCOMMUNITY_VAL_STR
)
17277 return lcommunity_list_unset_vty(vty
, argc
, argv
,
17278 LARGE_COMMUNITY_LIST_STANDARD
);
17281 DEFUN (no_lcommunity_list_name_expanded
,
17282 no_bgp_lcommunity_list_name_expanded_cmd
,
17283 "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...",
17286 LCOMMUNITY_LIST_STR
17287 "Specify expanded large-community-list\n"
17288 "Large community list name\n"
17289 "Sequence number of an entry\n"
17290 "Sequence number\n"
17291 "Specify large community to reject\n"
17292 "Specify large community to accept\n"
17293 "An ordered list as a regular-expression\n")
17295 return lcommunity_list_unset_vty(vty
, argc
, argv
,
17296 LARGE_COMMUNITY_LIST_EXPANDED
);
17299 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
17301 struct community_entry
*entry
;
17303 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
17304 if (entry
== list
->head
) {
17305 if (all_digit(list
->name
))
17306 vty_out(vty
, "Large community %s list %s\n",
17308 LARGE_COMMUNITY_LIST_STANDARD
17310 : "(expanded) access",
17314 "Named large community %s list %s\n",
17316 LARGE_COMMUNITY_LIST_STANDARD
17322 vty_out(vty
, " %s\n",
17323 community_direct_str(entry
->direct
));
17325 vty_out(vty
, " %s %s\n",
17326 community_direct_str(entry
->direct
),
17327 community_list_config_str(entry
));
17331 DEFUN (show_lcommunity_list
,
17332 show_bgp_lcommunity_list_cmd
,
17333 "show bgp large-community-list",
17336 "List large-community list\n")
17338 struct community_list
*list
;
17339 struct community_list_master
*cm
;
17341 cm
= community_list_master_lookup(bgp_clist
,
17342 LARGE_COMMUNITY_LIST_MASTER
);
17344 return CMD_SUCCESS
;
17346 for (list
= cm
->num
.head
; list
; list
= list
->next
)
17347 lcommunity_list_show(vty
, list
);
17349 for (list
= cm
->str
.head
; list
; list
= list
->next
)
17350 lcommunity_list_show(vty
, list
);
17352 return CMD_SUCCESS
;
17355 DEFUN (show_lcommunity_list_arg
,
17356 show_bgp_lcommunity_list_arg_cmd
,
17357 "show bgp large-community-list <(1-500)|WORD> detail",
17360 "List large-community list\n"
17361 "Large-community-list number\n"
17362 "Large-community-list name\n"
17363 "Detailed information on large-community-list\n")
17365 struct community_list
*list
;
17367 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
17368 LARGE_COMMUNITY_LIST_MASTER
);
17370 vty_out(vty
, "%% Can't find large-community-list\n");
17371 return CMD_WARNING
;
17374 lcommunity_list_show(vty
, list
);
17376 return CMD_SUCCESS
;
17379 /* "extcommunity-list" keyword help string. */
17380 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
17381 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
17383 DEFUN (extcommunity_list_standard
,
17384 bgp_extcommunity_list_standard_cmd
,
17385 "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
17387 EXTCOMMUNITY_LIST_STR
17388 "Extended Community list number (standard)\n"
17389 "Specify standard extcommunity-list\n"
17390 "Community list name\n"
17391 "Sequence number of an entry\n"
17392 "Sequence number\n"
17393 "Specify community to reject\n"
17394 "Specify community to accept\n"
17395 EXTCOMMUNITY_VAL_STR
)
17397 int style
= EXTCOMMUNITY_LIST_STANDARD
;
17399 char *cl_number_or_name
= NULL
;
17404 argv_find(argv
, argc
, "(1-99)", &idx
);
17405 argv_find(argv
, argc
, "WORD", &idx
);
17406 cl_number_or_name
= argv
[idx
]->arg
;
17408 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
17410 seq
= argv
[idx
]->arg
;
17412 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
17414 argv_find(argv
, argc
, "AA:NN", &idx
);
17415 char *str
= argv_concat(argv
, argc
, idx
);
17417 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
17420 XFREE(MTYPE_TMP
, str
);
17423 community_list_perror(vty
, ret
);
17424 return CMD_WARNING_CONFIG_FAILED
;
17427 return CMD_SUCCESS
;
17430 DEFUN (extcommunity_list_name_expanded
,
17431 bgp_extcommunity_list_name_expanded_cmd
,
17432 "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...",
17434 EXTCOMMUNITY_LIST_STR
17435 "Extended Community list number (expanded)\n"
17436 "Specify expanded extcommunity-list\n"
17437 "Extended Community list name\n"
17438 "Sequence number of an entry\n"
17439 "Sequence number\n"
17440 "Specify community to reject\n"
17441 "Specify community to accept\n"
17442 "An ordered list as a regular-expression\n")
17444 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
17446 char *cl_number_or_name
= NULL
;
17450 argv_find(argv
, argc
, "(100-500)", &idx
);
17451 argv_find(argv
, argc
, "WORD", &idx
);
17452 cl_number_or_name
= argv
[idx
]->arg
;
17454 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
17456 seq
= argv
[idx
]->arg
;
17458 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
17460 argv_find(argv
, argc
, "LINE", &idx
);
17461 char *str
= argv_concat(argv
, argc
, idx
);
17463 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
17466 XFREE(MTYPE_TMP
, str
);
17469 community_list_perror(vty
, ret
);
17470 return CMD_WARNING_CONFIG_FAILED
;
17473 return CMD_SUCCESS
;
17476 DEFUN (no_extcommunity_list_standard_all
,
17477 no_bgp_extcommunity_list_standard_all_cmd
,
17478 "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
17481 EXTCOMMUNITY_LIST_STR
17482 "Extended Community list number (standard)\n"
17483 "Specify standard extcommunity-list\n"
17484 "Community list name\n"
17485 "Sequence number of an entry\n"
17486 "Sequence number\n"
17487 "Specify community to reject\n"
17488 "Specify community to accept\n"
17489 EXTCOMMUNITY_VAL_STR
)
17491 int style
= EXTCOMMUNITY_LIST_STANDARD
;
17493 char *cl_number_or_name
= NULL
;
17498 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
17500 seq
= argv
[idx
]->arg
;
17503 argv_find(argv
, argc
, "permit", &idx
);
17504 argv_find(argv
, argc
, "deny", &idx
);
17506 direct
= argv_find(argv
, argc
, "permit", &idx
)
17511 argv_find(argv
, argc
, "AA:NN", &idx
);
17512 str
= argv_concat(argv
, argc
, idx
);
17516 argv_find(argv
, argc
, "(1-99)", &idx
);
17517 argv_find(argv
, argc
, "WORD", &idx
);
17518 cl_number_or_name
= argv
[idx
]->arg
;
17520 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
17521 seq
, direct
, style
);
17523 XFREE(MTYPE_TMP
, str
);
17526 community_list_perror(vty
, ret
);
17527 return CMD_WARNING_CONFIG_FAILED
;
17530 return CMD_SUCCESS
;
17533 ALIAS(no_extcommunity_list_standard_all
,
17534 no_bgp_extcommunity_list_standard_all_list_cmd
,
17535 "no bgp extcommunity-list <(1-99)|standard WORD>",
17536 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
17537 "Extended Community list number (standard)\n"
17538 "Specify standard extcommunity-list\n"
17539 "Community list name\n")
17541 DEFUN (no_extcommunity_list_expanded_all
,
17542 no_bgp_extcommunity_list_expanded_all_cmd
,
17543 "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...",
17546 EXTCOMMUNITY_LIST_STR
17547 "Extended Community list number (expanded)\n"
17548 "Specify expanded extcommunity-list\n"
17549 "Extended Community list name\n"
17550 "Sequence number of an entry\n"
17551 "Sequence number\n"
17552 "Specify community to reject\n"
17553 "Specify community to accept\n"
17554 "An ordered list as a regular-expression\n")
17556 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
17558 char *cl_number_or_name
= NULL
;
17563 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
17565 seq
= argv
[idx
]->arg
;
17568 argv_find(argv
, argc
, "permit", &idx
);
17569 argv_find(argv
, argc
, "deny", &idx
);
17572 direct
= argv_find(argv
, argc
, "permit", &idx
)
17577 argv_find(argv
, argc
, "LINE", &idx
);
17578 str
= argv_concat(argv
, argc
, idx
);
17582 argv_find(argv
, argc
, "(100-500)", &idx
);
17583 argv_find(argv
, argc
, "WORD", &idx
);
17584 cl_number_or_name
= argv
[idx
]->arg
;
17586 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
17587 seq
, direct
, style
);
17589 XFREE(MTYPE_TMP
, str
);
17592 community_list_perror(vty
, ret
);
17593 return CMD_WARNING_CONFIG_FAILED
;
17596 return CMD_SUCCESS
;
17599 ALIAS(no_extcommunity_list_expanded_all
,
17600 no_bgp_extcommunity_list_expanded_all_list_cmd
,
17601 "no bgp extcommunity-list <(100-500)|expanded WORD>",
17602 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
17603 "Extended Community list number (expanded)\n"
17604 "Specify expanded extcommunity-list\n"
17605 "Extended Community list name\n")
17607 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
17609 struct community_entry
*entry
;
17611 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
17612 if (entry
== list
->head
) {
17613 if (all_digit(list
->name
))
17614 vty_out(vty
, "Extended community %s list %s\n",
17615 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
17617 : "(expanded) access",
17621 "Named extended community %s list %s\n",
17622 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
17628 vty_out(vty
, " %s\n",
17629 community_direct_str(entry
->direct
));
17631 vty_out(vty
, " %s %s\n",
17632 community_direct_str(entry
->direct
),
17633 community_list_config_str(entry
));
17637 DEFUN (show_extcommunity_list
,
17638 show_bgp_extcommunity_list_cmd
,
17639 "show bgp extcommunity-list",
17642 "List extended-community list\n")
17644 struct community_list
*list
;
17645 struct community_list_master
*cm
;
17647 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
17649 return CMD_SUCCESS
;
17651 for (list
= cm
->num
.head
; list
; list
= list
->next
)
17652 extcommunity_list_show(vty
, list
);
17654 for (list
= cm
->str
.head
; list
; list
= list
->next
)
17655 extcommunity_list_show(vty
, list
);
17657 return CMD_SUCCESS
;
17660 DEFUN (show_extcommunity_list_arg
,
17661 show_bgp_extcommunity_list_arg_cmd
,
17662 "show bgp extcommunity-list <(1-500)|WORD> detail",
17665 "List extended-community list\n"
17666 "Extcommunity-list number\n"
17667 "Extcommunity-list name\n"
17668 "Detailed information on extcommunity-list\n")
17670 int idx_comm_list
= 3;
17671 struct community_list
*list
;
17673 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
17674 EXTCOMMUNITY_LIST_MASTER
);
17676 vty_out(vty
, "%% Can't find extcommunity-list\n");
17677 return CMD_WARNING
;
17680 extcommunity_list_show(vty
, list
);
17682 return CMD_SUCCESS
;
17685 /* Display community-list and extcommunity-list configuration. */
17686 static int community_list_config_write(struct vty
*vty
)
17688 struct community_list
*list
;
17689 struct community_entry
*entry
;
17690 struct community_list_master
*cm
;
17693 /* Community-list. */
17694 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
17696 for (list
= cm
->num
.head
; list
; list
= list
->next
)
17697 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
17699 "bgp community-list %s seq %" PRId64
" %s %s\n",
17700 list
->name
, entry
->seq
,
17701 community_direct_str(entry
->direct
),
17702 community_list_config_str(entry
));
17705 for (list
= cm
->str
.head
; list
; list
= list
->next
)
17706 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
17708 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
17709 entry
->style
== COMMUNITY_LIST_STANDARD
17712 list
->name
, entry
->seq
,
17713 community_direct_str(entry
->direct
),
17714 community_list_config_str(entry
));
17718 /* Extcommunity-list. */
17719 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
17721 for (list
= cm
->num
.head
; list
; list
= list
->next
)
17722 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
17724 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
17725 list
->name
, entry
->seq
,
17726 community_direct_str(entry
->direct
),
17727 community_list_config_str(entry
));
17730 for (list
= cm
->str
.head
; list
; list
= list
->next
)
17731 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
17733 "bgp extcommunity-list %s %s seq %" PRId64
17735 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
17738 list
->name
, entry
->seq
,
17739 community_direct_str(entry
->direct
),
17740 community_list_config_str(entry
));
17745 /* lcommunity-list. */
17746 cm
= community_list_master_lookup(bgp_clist
,
17747 LARGE_COMMUNITY_LIST_MASTER
);
17749 for (list
= cm
->num
.head
; list
; list
= list
->next
)
17750 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
17752 "bgp large-community-list %s seq %" PRId64
17754 list
->name
, entry
->seq
,
17755 community_direct_str(entry
->direct
),
17756 community_list_config_str(entry
));
17759 for (list
= cm
->str
.head
; list
; list
= list
->next
)
17760 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
17762 "bgp large-community-list %s %s seq %" PRId64
17765 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
17768 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
17769 community_list_config_str(entry
));
17776 static struct cmd_node community_list_node
= {
17777 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
17780 static void community_list_vty(void)
17782 install_node(&community_list_node
, community_list_config_write
);
17784 /* Community-list. */
17785 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
17786 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
17787 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
17788 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
17789 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
17790 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
17791 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
17792 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
17794 /* Extcommunity-list. */
17795 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
17796 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
17797 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
17798 install_element(CONFIG_NODE
,
17799 &no_bgp_extcommunity_list_standard_all_list_cmd
);
17800 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
17801 install_element(CONFIG_NODE
,
17802 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
17803 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
17804 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
17806 /* Large Community List */
17807 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
17808 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
17809 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
17810 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
17811 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
17812 install_element(CONFIG_NODE
,
17813 &no_bgp_lcommunity_list_name_standard_all_cmd
);
17814 install_element(CONFIG_NODE
,
17815 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
17816 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
17817 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
17818 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
17819 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
17820 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
17821 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);