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/sockopt.h"
26 #include "lib_errors.h"
27 #include "lib/zclient.h"
28 #include "lib/printfrr.h"
43 #include "bgpd/bgpd.h"
44 #include "bgpd/bgp_attr_evpn.h"
45 #include "bgpd/bgp_advertise.h"
46 #include "bgpd/bgp_attr.h"
47 #include "bgpd/bgp_aspath.h"
48 #include "bgpd/bgp_community.h"
49 #include "bgpd/bgp_community_alias.h"
50 #include "bgpd/bgp_ecommunity.h"
51 #include "bgpd/bgp_lcommunity.h"
52 #include "bgpd/bgp_damp.h"
53 #include "bgpd/bgp_debug.h"
54 #include "bgpd/bgp_errors.h"
55 #include "bgpd/bgp_fsm.h"
56 #include "bgpd/bgp_nexthop.h"
57 #include "bgpd/bgp_open.h"
58 #include "bgpd/bgp_regex.h"
59 #include "bgpd/bgp_route.h"
60 #include "bgpd/bgp_mplsvpn.h"
61 #include "bgpd/bgp_zebra.h"
62 #include "bgpd/bgp_table.h"
63 #include "bgpd/bgp_vty.h"
64 #include "bgpd/bgp_mpath.h"
65 #include "bgpd/bgp_packet.h"
66 #include "bgpd/bgp_updgrp.h"
67 #include "bgpd/bgp_bfd.h"
68 #include "bgpd/bgp_io.h"
69 #include "bgpd/bgp_evpn.h"
70 #include "bgpd/bgp_evpn_vty.h"
71 #include "bgpd/bgp_evpn_mh.h"
72 #include "bgpd/bgp_addpath.h"
73 #include "bgpd/bgp_mac.h"
74 #include "bgpd/bgp_flowspec.h"
75 #include "bgpd/bgp_conditional_adv.h"
77 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
80 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
83 .match_profile
= "traditional",
84 .match_version
= "< 7.4",
88 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
89 { .val_bool
= true, .match_profile
= "datacenter", },
90 { .val_bool
= false },
92 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
93 { .val_bool
= true, .match_profile
= "datacenter", },
94 { .val_bool
= false },
96 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
97 { .val_bool
= true, .match_profile
= "datacenter", },
98 { .val_bool
= false },
100 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
101 { .val_bool
= true, .match_profile
= "datacenter", },
102 { .val_bool
= false },
104 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
105 { .val_ulong
= 10, .match_profile
= "datacenter", },
106 { .val_ulong
= 120 },
108 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
109 { .val_ulong
= 9, .match_profile
= "datacenter", },
110 { .val_ulong
= 180 },
112 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
113 { .val_ulong
= 3, .match_profile
= "datacenter", },
116 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
117 { .val_bool
= false, .match_profile
= "datacenter", },
118 { .val_bool
= false, .match_version
= "< 7.4", },
119 { .val_bool
= true },
121 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
122 { .val_bool
= false, .match_version
= "< 7.6", },
123 { .val_bool
= true },
126 DEFINE_HOOK(bgp_inst_config_write
,
127 (struct bgp
*bgp
, struct vty
*vty
),
129 DEFINE_HOOK(bgp_snmp_update_last_changed
, (struct bgp
*bgp
), (bgp
));
130 DEFINE_HOOK(bgp_snmp_init_stats
, (struct bgp
*bgp
), (bgp
));
132 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
133 struct prefix
*range
, int exact
);
135 /* Show BGP peer's information. */
145 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
146 struct prefix
*range
, int exact
);
148 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
153 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
156 afi_t afi
, bool use_json
);
158 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
164 return BGP_IPV4_NODE
;
166 return BGP_IPV4M_NODE
;
167 case SAFI_LABELED_UNICAST
:
168 return BGP_IPV4L_NODE
;
170 return BGP_VPNV4_NODE
;
172 return BGP_FLOWSPECV4_NODE
;
175 return BGP_IPV4_NODE
;
181 return BGP_IPV6_NODE
;
183 return BGP_IPV6M_NODE
;
184 case SAFI_LABELED_UNICAST
:
185 return BGP_IPV6L_NODE
;
187 return BGP_VPNV6_NODE
;
189 return BGP_FLOWSPECV6_NODE
;
192 return BGP_IPV4_NODE
;
196 return BGP_EVPN_NODE
;
199 // We should never be here but to clarify the switch statement..
200 return BGP_IPV4_NODE
;
203 // Impossible to happen
204 return BGP_IPV4_NODE
;
207 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
210 if (safi
== SAFI_UNICAST
)
211 return "IPv4 Unicast";
212 if (safi
== SAFI_MULTICAST
)
213 return "IPv4 Multicast";
214 if (safi
== SAFI_LABELED_UNICAST
)
215 return "IPv4 Labeled Unicast";
216 if (safi
== SAFI_MPLS_VPN
)
218 if (safi
== SAFI_ENCAP
)
220 if (safi
== SAFI_FLOWSPEC
)
221 return "IPv4 Flowspec";
222 } else if (afi
== AFI_IP6
) {
223 if (safi
== SAFI_UNICAST
)
224 return "IPv6 Unicast";
225 if (safi
== SAFI_MULTICAST
)
226 return "IPv6 Multicast";
227 if (safi
== SAFI_LABELED_UNICAST
)
228 return "IPv6 Labeled Unicast";
229 if (safi
== SAFI_MPLS_VPN
)
231 if (safi
== SAFI_ENCAP
)
233 if (safi
== SAFI_FLOWSPEC
)
234 return "IPv6 Flowspec";
235 } else if (afi
== AFI_L2VPN
) {
236 if (safi
== SAFI_EVPN
)
244 * Please note that we have intentionally camelCased
245 * the return strings here. So if you want
246 * to use this function, please ensure you
247 * are doing this within json output
249 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
252 if (safi
== SAFI_UNICAST
)
253 return "ipv4Unicast";
254 if (safi
== SAFI_MULTICAST
)
255 return "ipv4Multicast";
256 if (safi
== SAFI_LABELED_UNICAST
)
257 return "ipv4LabeledUnicast";
258 if (safi
== SAFI_MPLS_VPN
)
260 if (safi
== SAFI_ENCAP
)
262 if (safi
== SAFI_FLOWSPEC
)
263 return "ipv4Flowspec";
264 } else if (afi
== AFI_IP6
) {
265 if (safi
== SAFI_UNICAST
)
266 return "ipv6Unicast";
267 if (safi
== SAFI_MULTICAST
)
268 return "ipv6Multicast";
269 if (safi
== SAFI_LABELED_UNICAST
)
270 return "ipv6LabeledUnicast";
271 if (safi
== SAFI_MPLS_VPN
)
273 if (safi
== SAFI_ENCAP
)
275 if (safi
== SAFI_FLOWSPEC
)
276 return "ipv6Flowspec";
277 } else if (afi
== AFI_L2VPN
) {
278 if (safi
== SAFI_EVPN
)
285 /* Utility function to get address family from current node. */
286 afi_t
bgp_node_afi(struct vty
*vty
)
294 case BGP_FLOWSPECV6_NODE
:
307 /* Utility function to get subsequent address family from current
309 safi_t
bgp_node_safi(struct vty
*vty
)
315 safi
= SAFI_MPLS_VPN
;
319 safi
= SAFI_MULTICAST
;
326 safi
= SAFI_LABELED_UNICAST
;
328 case BGP_FLOWSPECV4_NODE
:
329 case BGP_FLOWSPECV6_NODE
:
330 safi
= SAFI_FLOWSPEC
;
340 * Converts an AFI in string form to afi_t
342 * @param afi string, one of
346 * @return the corresponding afi_t
348 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
350 afi_t afi
= AFI_MAX
; /* unknown */
351 if (strmatch(afi_str
, "ipv4"))
353 else if (strmatch(afi_str
, "ipv6"))
355 else if (strmatch(afi_str
, "l2vpn"))
360 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
364 if (argv_find(argv
, argc
, "ipv4", index
)) {
368 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
372 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
380 /* supports <unicast|multicast|vpn|labeled-unicast> */
381 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
383 safi_t safi
= SAFI_MAX
; /* unknown */
384 if (strmatch(safi_str
, "multicast"))
385 safi
= SAFI_MULTICAST
;
386 else if (strmatch(safi_str
, "unicast"))
388 else if (strmatch(safi_str
, "vpn"))
389 safi
= SAFI_MPLS_VPN
;
390 else if (strmatch(safi_str
, "evpn"))
392 else if (strmatch(safi_str
, "labeled-unicast"))
393 safi
= SAFI_LABELED_UNICAST
;
394 else if (strmatch(safi_str
, "flowspec"))
395 safi
= SAFI_FLOWSPEC
;
399 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
403 if (argv_find(argv
, argc
, "unicast", index
)) {
406 *safi
= SAFI_UNICAST
;
407 } else if (argv_find(argv
, argc
, "multicast", index
)) {
410 *safi
= SAFI_MULTICAST
;
411 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
414 *safi
= SAFI_LABELED_UNICAST
;
415 } else if (argv_find(argv
, argc
, "vpn", index
)) {
418 *safi
= SAFI_MPLS_VPN
;
419 } else if (argv_find(argv
, argc
, "evpn", index
)) {
423 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
426 *safi
= SAFI_FLOWSPEC
;
432 * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag.
435 * address-family identifier
438 * subsequent address-family identifier
441 * default_af string corresponding to the supplied afi/safi pair.
442 * If afi/safi is invalid or if flag for afi/safi doesn't exist,
445 static const char *get_bgp_default_af_flag(afi_t afi
, safi_t safi
)
451 return "ipv4-unicast";
453 return "ipv4-multicast";
458 case SAFI_LABELED_UNICAST
:
459 return "ipv4-labeled-unicast";
461 return "ipv4-flowspec";
463 return "unknown-afi/safi";
469 return "ipv6-unicast";
471 return "ipv6-multicast";
476 case SAFI_LABELED_UNICAST
:
477 return "ipv6-labeled-unicast";
479 return "ipv6-flowspec";
481 return "unknown-afi/safi";
489 return "unknown-afi/safi";
493 return "unknown-afi/safi";
495 /* all AFIs are accounted for above, so this shouldn't happen */
496 return "unknown-afi/safi";
499 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
500 enum bgp_instance_type inst_type
)
502 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
504 if (ret
== BGP_CREATED
) {
505 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
506 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
508 if (DFLT_BGP_IMPORT_CHECK
)
509 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
510 if (DFLT_BGP_SHOW_HOSTNAME
)
511 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
512 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
513 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
514 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
515 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
516 if (DFLT_BGP_DETERMINISTIC_MED
)
517 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
518 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
519 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
520 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
521 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
529 * bgp_vty_find_and_parse_afi_safi_bgp
531 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
532 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
533 * to appropriate values for the calling function. This is to allow the
534 * calling function to make decisions appropriate for the show command
535 * that is being parsed.
537 * The show commands are generally of the form:
538 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
539 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
541 * Since we use argv_find if the show command in particular doesn't have:
543 * [<view|vrf> VIEWVRFNAME]
544 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
545 * The command parsing should still be ok.
547 * vty -> The vty for the command so we can output some useful data in
548 * the event of a parse error in the vrf.
549 * argv -> The command tokens
550 * argc -> How many command tokens we have
551 * idx -> The current place in the command, generally should be 0 for this
553 * afi -> The parsed afi if it was included in the show command, returned here
554 * safi -> The parsed safi if it was included in the show command, returned here
555 * bgp -> Pointer to the bgp data structure we need to fill in.
556 * use_json -> json is configured or not
558 * The function returns the correct location in the parse tree for the
561 * Returns 0 for failure to parse correctly, else the idx position of where
562 * it found the last token.
564 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
565 struct cmd_token
**argv
, int argc
,
566 int *idx
, afi_t
*afi
, safi_t
*safi
,
567 struct bgp
**bgp
, bool use_json
)
569 char *vrf_name
= NULL
;
575 if (argv_find(argv
, argc
, "ip", idx
))
578 if (argv_find(argv
, argc
, "view", idx
))
579 vrf_name
= argv
[*idx
+ 1]->arg
;
580 else if (argv_find(argv
, argc
, "vrf", idx
)) {
581 vrf_name
= argv
[*idx
+ 1]->arg
;
582 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
586 if (strmatch(vrf_name
, "all"))
589 *bgp
= bgp_lookup_by_name(vrf_name
);
592 json_object
*json
= NULL
;
593 json
= json_object_new_object();
594 json_object_string_add(
596 "View/Vrf is unknown");
598 json_object_to_json_string_ext(json
,
599 JSON_C_TO_STRING_PRETTY
));
600 json_object_free(json
);
603 vty_out(vty
, "View/Vrf %s is unknown\n",
610 *bgp
= bgp_get_default();
613 json_object
*json
= NULL
;
614 json
= json_object_new_object();
615 json_object_string_add(
617 "Default BGP instance not found");
619 json_object_to_json_string_ext(json
,
620 JSON_C_TO_STRING_PRETTY
));
621 json_object_free(json
);
625 "Default BGP instance not found\n");
631 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
632 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
638 static bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
640 struct interface
*ifp
= NULL
;
642 if (su
->sa
.sa_family
== AF_INET
)
643 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
644 else if (su
->sa
.sa_family
== AF_INET6
)
645 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
646 su
->sin6
.sin6_scope_id
,
655 /* Utility function for looking up peer from VTY. */
656 /* This is used only for configuration, so disallow if attempted on
657 * a dynamic neighbor.
659 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
661 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
670 ret
= str2sockunion(ip_str
, &su
);
672 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
674 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
677 "%% Malformed address or name: %s\n",
683 peer
= peer_lookup(bgp
, &su
);
686 "%% Specify remote-as or peer-group commands first\n");
689 if (peer_dynamic_neighbor(peer
)) {
691 "%% Operation not allowed on a dynamic neighbor\n");
698 /* Utility function for looking up peer or peer group. */
699 /* This is used only for configuration, so disallow if attempted on
700 * a dynamic neighbor.
702 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
704 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
707 struct peer
*peer
= NULL
;
708 struct peer_group
*group
= NULL
;
714 ret
= str2sockunion(peer_str
, &su
);
716 /* IP address, locate peer. */
717 peer
= peer_lookup(bgp
, &su
);
719 /* Not IP, could match either peer configured on interface or a
721 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
723 group
= peer_group_lookup(bgp
, peer_str
);
727 if (peer_dynamic_neighbor(peer
)) {
729 "%% Operation not allowed on a dynamic neighbor\n");
739 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
744 int bgp_vty_return(struct vty
*vty
, int ret
)
746 const char *str
= NULL
;
749 case BGP_ERR_INVALID_VALUE
:
750 str
= "Invalid value";
752 case BGP_ERR_INVALID_FLAG
:
753 str
= "Invalid flag";
755 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
756 str
= "Peer-group has been shutdown. Activate the peer-group first";
758 case BGP_ERR_PEER_FLAG_CONFLICT
:
759 str
= "Can't set override-capability and strict-capability-match at the same time";
761 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
762 str
= "Specify remote-as or peer-group remote AS first";
764 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
765 str
= "Cannot change the peer-group. Deconfigure first";
767 case BGP_ERR_PEER_GROUP_MISMATCH
:
768 str
= "Peer is not a member of this peer-group";
770 case BGP_ERR_PEER_FILTER_CONFLICT
:
771 str
= "Prefix/distribute list can not co-exist";
773 case BGP_ERR_NOT_INTERNAL_PEER
:
774 str
= "Invalid command. Not an internal neighbor";
776 case BGP_ERR_REMOVE_PRIVATE_AS
:
777 str
= "remove-private-AS cannot be configured for IBGP peers";
779 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
780 str
= "Local-AS allowed only for EBGP peers";
782 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
783 str
= "Cannot have local-as same as BGP AS number";
785 case BGP_ERR_TCPSIG_FAILED
:
786 str
= "Error while applying TCP-Sig to session(s)";
788 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
789 str
= "ebgp-multihop and ttl-security cannot be configured together";
791 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
792 str
= "ttl-security only allowed for EBGP peers";
794 case BGP_ERR_AS_OVERRIDE
:
795 str
= "as-override cannot be configured for IBGP peers";
797 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
798 str
= "Invalid limit for number of dynamic neighbors";
800 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
801 str
= "Dynamic neighbor listen range already exists";
803 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
804 str
= "Operation not allowed on a dynamic neighbor";
806 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
807 str
= "Operation not allowed on a directly connected neighbor";
809 case BGP_ERR_PEER_SAFI_CONFLICT
:
810 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
812 case BGP_ERR_GR_INVALID_CMD
:
813 str
= "The Graceful Restart command used is not valid at this moment.";
815 case BGP_ERR_GR_OPERATION_FAILED
:
816 str
= "The Graceful Restart Operation failed due to an err.";
820 vty_out(vty
, "%% %s\n", str
);
821 return CMD_WARNING_CONFIG_FAILED
;
826 /* BGP clear sort. */
835 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
836 safi_t safi
, int error
)
839 case BGP_ERR_AF_UNCONFIGURED
:
841 "%%BGP: Enable %s address family for the neighbor %s\n",
842 get_afi_safi_str(afi
, safi
, false), peer
->host
);
844 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
846 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
854 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
855 struct listnode
**nnode
, enum bgp_clear_type stype
)
860 /* if afi/.safi not specified, spin thru all of them */
861 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
865 FOREACH_AFI_SAFI (tmp_afi
, tmp_safi
) {
866 paf
= peer_af_find(peer
, tmp_afi
, tmp_safi
);
867 if (paf
&& paf
->subgroup
)
868 SET_FLAG(paf
->subgroup
->sflags
,
869 SUBGRP_STATUS_FORCE_UPDATES
);
871 if (!peer
->afc
[tmp_afi
][tmp_safi
])
874 if (stype
== BGP_CLEAR_SOFT_NONE
)
875 ret
= peer_clear(peer
, nnode
);
877 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
880 /* if afi specified and safi not, spin thru safis on this afi */
881 } else if (safi
== SAFI_UNSPEC
) {
884 for (tmp_safi
= SAFI_UNICAST
;
885 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
886 if (!peer
->afc
[afi
][tmp_safi
])
889 paf
= peer_af_find(peer
, afi
, tmp_safi
);
890 if (paf
&& paf
->subgroup
)
891 SET_FLAG(paf
->subgroup
->sflags
,
892 SUBGRP_STATUS_FORCE_UPDATES
);
894 if (stype
== BGP_CLEAR_SOFT_NONE
)
895 ret
= peer_clear(peer
, nnode
);
897 ret
= peer_clear_soft(peer
, afi
,
900 /* both afi/safi specified, let the caller know if not defined */
902 if (!peer
->afc
[afi
][safi
])
905 paf
= peer_af_find(peer
, afi
, safi
);
906 if (paf
&& paf
->subgroup
)
907 SET_FLAG(paf
->subgroup
->sflags
,
908 SUBGRP_STATUS_FORCE_UPDATES
);
910 if (stype
== BGP_CLEAR_SOFT_NONE
)
911 ret
= peer_clear(peer
, nnode
);
913 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
919 /* `clear ip bgp' functions. */
920 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
921 enum clear_sort sort
, enum bgp_clear_type stype
,
928 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
930 /* Clear all neighbors. */
932 * Pass along pointer to next node to peer_clear() when walking all
933 * nodes on the BGP instance as that may get freed if it is a
936 if (sort
== clear_all
) {
937 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
939 bgp_peer_gr_flags_update(peer
);
941 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
942 gr_router_detected
= true;
944 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
948 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);
959 /* This is to apply read-only mode on this clear. */
960 if (stype
== BGP_CLEAR_SOFT_NONE
)
961 bgp
->update_delay_over
= 0;
966 /* Clear specified neighbor. */
967 if (sort
== clear_peer
) {
970 /* Make sockunion for lookup. */
971 ret
= str2sockunion(arg
, &su
);
973 peer
= peer_lookup_by_conf_if(bgp
, arg
);
975 peer
= peer_lookup_by_hostname(bgp
, arg
);
978 "Malformed address or name: %s\n",
984 peer
= peer_lookup(bgp
, &su
);
987 "%%BGP: Unknown neighbor - \"%s\"\n",
993 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
994 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
996 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
998 /* if afi/safi not defined for this peer, let caller know */
1000 ret
= BGP_ERR_AF_UNCONFIGURED
;
1003 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1008 /* Clear all neighbors belonging to a specific peer-group. */
1009 if (sort
== clear_group
) {
1010 struct peer_group
*group
;
1012 group
= peer_group_lookup(bgp
, arg
);
1014 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
1018 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1019 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1022 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1029 "%%BGP: No %s peer belonging to peer-group %s is configured\n",
1030 get_afi_safi_str(afi
, safi
, false), arg
);
1035 /* Clear all external (eBGP) neighbors. */
1036 if (sort
== clear_external
) {
1037 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1038 if (peer
->sort
== BGP_PEER_IBGP
)
1041 bgp_peer_gr_flags_update(peer
);
1043 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1044 gr_router_detected
= true;
1046 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1049 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1054 if (gr_router_detected
1055 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1056 bgp_zebra_send_capabilities(bgp
, false);
1057 } else if (!gr_router_detected
1058 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1059 bgp_zebra_send_capabilities(bgp
, true);
1064 "%%BGP: No external %s peer is configured\n",
1065 get_afi_safi_str(afi
, safi
, false));
1070 /* Clear all neighbors belonging to a specific AS. */
1071 if (sort
== clear_as
) {
1072 as_t as
= strtoul(arg
, NULL
, 10);
1074 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1078 bgp_peer_gr_flags_update(peer
);
1080 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1081 gr_router_detected
= true;
1083 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1086 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1091 if (gr_router_detected
1092 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1093 bgp_zebra_send_capabilities(bgp
, false);
1094 } else if (!gr_router_detected
1095 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1096 bgp_zebra_send_capabilities(bgp
, true);
1101 "%%BGP: No %s peer is configured with AS %s\n",
1102 get_afi_safi_str(afi
, safi
, false), arg
);
1110 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1111 safi_t safi
, enum clear_sort sort
,
1112 enum bgp_clear_type stype
, const char *arg
)
1116 /* BGP structure lookup. */
1118 bgp
= bgp_lookup_by_name(name
);
1120 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1124 bgp
= bgp_get_default();
1126 vty_out(vty
, "No BGP process is configured\n");
1131 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1134 /* clear soft inbound */
1135 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1140 FOREACH_AFI_SAFI (afi
, safi
)
1141 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1142 BGP_CLEAR_SOFT_IN
, NULL
);
1145 /* clear soft outbound */
1146 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1151 FOREACH_AFI_SAFI (afi
, safi
)
1152 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1153 BGP_CLEAR_SOFT_OUT
, NULL
);
1157 #ifndef VTYSH_EXTRACT_PL
1158 #include "bgpd/bgp_vty_clippy.c"
1161 DEFUN_HIDDEN (bgp_local_mac
,
1163 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1165 "Local MAC config\n"
1166 "VxLAN Network Identifier\n"
1170 "mac-mobility sequence\n"
1180 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1181 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1182 vty_out(vty
, "%% Malformed MAC address\n");
1185 memset(&ip
, 0, sizeof(ip
));
1186 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1188 bgp
= bgp_get_default();
1190 vty_out(vty
, "Default BGP instance is not there\n");
1194 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1197 vty_out(vty
, "Internal error\n");
1204 DEFUN_HIDDEN (no_bgp_local_mac
,
1205 no_bgp_local_mac_cmd
,
1206 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1209 "Local MAC config\n"
1210 "VxLAN Network Identifier\n"
1221 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1222 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1223 vty_out(vty
, "%% Malformed MAC address\n");
1226 memset(&ip
, 0, sizeof(ip
));
1228 bgp
= bgp_get_default();
1230 vty_out(vty
, "Default BGP instance is not there\n");
1234 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1236 vty_out(vty
, "Internal error\n");
1243 DEFUN (no_synchronization
,
1244 no_synchronization_cmd
,
1245 "no synchronization",
1247 "Perform IGP synchronization\n")
1252 DEFUN (no_auto_summary
,
1253 no_auto_summary_cmd
,
1256 "Enable automatic network number summarization\n")
1261 /* "router bgp" commands. */
1262 DEFUN_NOSH (router_bgp
,
1264 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1268 BGP_INSTANCE_HELP_STR
)
1271 int idx_view_vrf
= 3;
1277 const char *name
= NULL
;
1278 enum bgp_instance_type inst_type
;
1280 // "router bgp" without an ASN
1282 // Pending: Make VRF option available for ASN less config
1283 bgp
= bgp_get_default();
1286 vty_out(vty
, "%% No BGP process is configured\n");
1287 return CMD_WARNING_CONFIG_FAILED
;
1290 if (listcount(bm
->bgp
) > 1) {
1291 vty_out(vty
, "%% Please specify ASN and VRF\n");
1292 return CMD_WARNING_CONFIG_FAILED
;
1298 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1300 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1302 name
= argv
[idx_vrf
]->arg
;
1304 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1305 if (strmatch(name
, VRF_DEFAULT_NAME
))
1308 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1309 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1310 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1313 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1314 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1316 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1318 case BGP_ERR_AS_MISMATCH
:
1319 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1320 return CMD_WARNING_CONFIG_FAILED
;
1321 case BGP_ERR_INSTANCE_MISMATCH
:
1323 "BGP instance name and AS number mismatch\n");
1325 "BGP instance is already running; AS is %u\n",
1327 return CMD_WARNING_CONFIG_FAILED
;
1331 * If we just instantiated the default instance, complete
1332 * any pending VRF-VPN leaking that was configured via
1333 * earlier "router bgp X vrf FOO" blocks.
1335 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1336 vpn_leak_postchange_all();
1338 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1339 bgp_vpn_leak_export(bgp
);
1340 /* Pending: handle when user tries to change a view to vrf n vv.
1344 /* unset the auto created flag as the user config is now present */
1345 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1346 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1351 /* "no router bgp" commands. */
1352 DEFUN (no_router_bgp
,
1354 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1359 BGP_INSTANCE_HELP_STR
)
1365 const char *name
= NULL
;
1367 // "no router bgp" without an ASN
1369 // Pending: Make VRF option available for ASN less config
1370 bgp
= bgp_get_default();
1373 vty_out(vty
, "%% No BGP process is configured\n");
1374 return CMD_WARNING_CONFIG_FAILED
;
1377 if (listcount(bm
->bgp
) > 1) {
1378 vty_out(vty
, "%% Please specify ASN and VRF\n");
1379 return CMD_WARNING_CONFIG_FAILED
;
1383 vty_out(vty
, "%% Please unconfigure l3vni %u",
1385 return CMD_WARNING_CONFIG_FAILED
;
1388 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1391 name
= argv
[idx_vrf
]->arg
;
1393 /* Lookup bgp structure. */
1394 bgp
= bgp_lookup(as
, name
);
1396 vty_out(vty
, "%% Can't find BGP instance\n");
1397 return CMD_WARNING_CONFIG_FAILED
;
1401 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1403 return CMD_WARNING_CONFIG_FAILED
;
1406 /* Cannot delete default instance if vrf instances exist */
1407 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1408 struct listnode
*node
;
1409 struct bgp
*tmp_bgp
;
1411 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1412 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1414 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1415 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1416 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1417 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1418 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1419 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1420 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1421 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1422 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1423 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1424 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1425 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1426 (bgp
== bgp_get_evpn() &&
1427 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1428 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST
) ||
1429 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1430 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP
) ||
1431 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1432 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST
) ||
1433 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1434 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP
))) ||
1435 (tmp_bgp
->vnihash
&& hashcount(tmp_bgp
->vnihash
))) {
1437 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1438 return CMD_WARNING_CONFIG_FAILED
;
1450 /* BGP router-id. */
1452 DEFPY (bgp_router_id
,
1454 "bgp router-id A.B.C.D",
1456 "Override configured router identifier\n"
1457 "Manually configured router identifier\n")
1459 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1460 bgp_router_id_static_set(bgp
, router_id
);
1464 DEFPY (no_bgp_router_id
,
1465 no_bgp_router_id_cmd
,
1466 "no bgp router-id [A.B.C.D]",
1469 "Override configured router identifier\n"
1470 "Manually configured router identifier\n")
1472 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1474 if (router_id_str
) {
1475 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1476 vty_out(vty
, "%% BGP router-id doesn't match\n");
1477 return CMD_WARNING_CONFIG_FAILED
;
1481 router_id
.s_addr
= 0;
1482 bgp_router_id_static_set(bgp
, router_id
);
1487 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1488 "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name",
1490 "Add community specific parameters\n"
1491 "Create an alias for a community\n"
1492 "Community (AA:BB or AA:BB:CC)\n"
1495 struct community_alias ca1
;
1496 struct community_alias ca2
;
1497 struct community_alias
*lookup_community
;
1498 struct community_alias
*lookup_alias
;
1500 if (!community_str2com(community
) && !lcommunity_str2com(community
)) {
1501 vty_out(vty
, "Invalid community format\n");
1505 memset(&ca1
, 0, sizeof(ca1
));
1506 memset(&ca2
, 0, sizeof(ca2
));
1507 strlcpy(ca1
.community
, community
, sizeof(ca1
.community
));
1508 strlcpy(ca1
.alias
, alias_name
, sizeof(ca1
.alias
));
1510 lookup_community
= bgp_ca_community_lookup(&ca1
);
1511 lookup_alias
= bgp_ca_alias_lookup(&ca1
);
1514 bgp_ca_alias_delete(&ca1
);
1515 bgp_ca_community_delete(&ca1
);
1518 /* Lookup if community hash table has an item
1519 * with the same alias name.
1521 strlcpy(ca2
.community
, lookup_alias
->community
,
1522 sizeof(ca2
.community
));
1523 if (bgp_ca_community_lookup(&ca2
)) {
1525 "community (%s) already has this alias (%s)\n",
1526 lookup_alias
->community
,
1527 lookup_alias
->alias
);
1530 bgp_ca_alias_delete(&ca1
);
1533 if (lookup_community
)
1534 bgp_ca_community_delete(&ca1
);
1536 bgp_ca_alias_insert(&ca1
);
1537 bgp_ca_community_insert(&ca1
);
1543 DEFPY (bgp_global_suppress_fib_pending
,
1544 bgp_global_suppress_fib_pending_cmd
,
1545 "[no] bgp suppress-fib-pending",
1548 "Advertise only routes that are programmed in kernel to peers globally\n")
1550 bm_wait_for_fib_set(!no
);
1555 DEFPY (bgp_suppress_fib_pending
,
1556 bgp_suppress_fib_pending_cmd
,
1557 "[no] bgp suppress-fib-pending",
1560 "Advertise only routes that are programmed in kernel to peers\n")
1562 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1564 bgp_suppress_fib_pending_set(bgp
, !no
);
1569 /* BGP Cluster ID. */
1570 DEFUN (bgp_cluster_id
,
1572 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1574 "Configure Route-Reflector Cluster-id\n"
1575 "Route-Reflector Cluster-id in IP address format\n"
1576 "Route-Reflector Cluster-id as 32 bit quantity\n")
1578 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1581 struct in_addr cluster
;
1583 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1585 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1586 return CMD_WARNING_CONFIG_FAILED
;
1589 bgp_cluster_id_set(bgp
, &cluster
);
1590 bgp_clear_star_soft_out(vty
, bgp
->name
);
1595 DEFUN (no_bgp_cluster_id
,
1596 no_bgp_cluster_id_cmd
,
1597 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1600 "Configure Route-Reflector Cluster-id\n"
1601 "Route-Reflector Cluster-id in IP address format\n"
1602 "Route-Reflector Cluster-id as 32 bit quantity\n")
1604 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1605 bgp_cluster_id_unset(bgp
);
1606 bgp_clear_star_soft_out(vty
, bgp
->name
);
1615 "Disable BGP route installation to RIB (Zebra)\n")
1617 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1619 "%% No-RIB option is already set, nothing to do here.\n");
1623 bgp_option_norib_set_runtime();
1628 DEFPY (no_bgp_norib
,
1633 "Disable BGP route installation to RIB (Zebra)\n")
1635 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1637 "%% No-RIB option is not set, nothing to do here.\n");
1641 bgp_option_norib_unset_runtime();
1646 DEFPY (no_bgp_send_extra_data
,
1647 no_bgp_send_extra_data_cmd
,
1648 "[no] bgp send-extra-data zebra",
1651 "Extra data to Zebra for display/use\n"
1655 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1657 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1662 DEFUN (bgp_confederation_identifier
,
1663 bgp_confederation_identifier_cmd
,
1664 "bgp confederation identifier (1-4294967295)",
1665 "BGP specific commands\n"
1666 "AS confederation parameters\n"
1668 "Set routing domain confederation AS\n")
1670 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1674 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1676 bgp_confederation_id_set(bgp
, as
);
1681 DEFUN (no_bgp_confederation_identifier
,
1682 no_bgp_confederation_identifier_cmd
,
1683 "no bgp confederation identifier [(1-4294967295)]",
1685 "BGP specific commands\n"
1686 "AS confederation parameters\n"
1688 "Set routing domain confederation AS\n")
1690 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1691 bgp_confederation_id_unset(bgp
);
1696 DEFUN (bgp_confederation_peers
,
1697 bgp_confederation_peers_cmd
,
1698 "bgp confederation peers (1-4294967295)...",
1699 "BGP specific commands\n"
1700 "AS confederation parameters\n"
1701 "Peer ASs in BGP confederation\n"
1704 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1709 for (i
= idx_asn
; i
< argc
; i
++) {
1710 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1712 if (bgp
->as
== as
) {
1714 "%% Local member-AS not allowed in confed peer list\n");
1718 bgp_confederation_peers_add(bgp
, as
);
1723 DEFUN (no_bgp_confederation_peers
,
1724 no_bgp_confederation_peers_cmd
,
1725 "no bgp confederation peers (1-4294967295)...",
1727 "BGP specific commands\n"
1728 "AS confederation parameters\n"
1729 "Peer ASs in BGP confederation\n"
1732 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1737 for (i
= idx_asn
; i
< argc
; i
++) {
1738 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1740 bgp_confederation_peers_remove(bgp
, as
);
1746 * Central routine for maximum-paths configuration.
1747 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1748 * @set: 1 for setting values, 0 for removing the max-paths config.
1750 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1751 const char *mpaths
, uint16_t options
,
1754 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1755 uint16_t maxpaths
= 0;
1760 afi
= bgp_node_afi(vty
);
1761 safi
= bgp_node_safi(vty
);
1764 maxpaths
= strtol(mpaths
, NULL
, 10);
1765 if (maxpaths
> multipath_num
) {
1767 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1768 maxpaths
, multipath_num
);
1769 return CMD_WARNING_CONFIG_FAILED
;
1771 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1774 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1778 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1779 (set
== 1) ? "" : "un",
1780 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1781 maxpaths
, afi
, safi
);
1782 return CMD_WARNING_CONFIG_FAILED
;
1785 bgp_recalculate_all_bestpaths(bgp
);
1790 DEFUN (bgp_maxmed_admin
,
1791 bgp_maxmed_admin_cmd
,
1792 "bgp max-med administrative ",
1794 "Advertise routes with max-med\n"
1795 "Administratively applied, for an indefinite period\n")
1797 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1799 bgp
->v_maxmed_admin
= 1;
1800 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1802 bgp_maxmed_update(bgp
);
1807 DEFUN (bgp_maxmed_admin_medv
,
1808 bgp_maxmed_admin_medv_cmd
,
1809 "bgp max-med administrative (0-4294967295)",
1811 "Advertise routes with max-med\n"
1812 "Administratively applied, for an indefinite period\n"
1813 "Max MED value to be used\n")
1815 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1818 bgp
->v_maxmed_admin
= 1;
1819 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1821 bgp_maxmed_update(bgp
);
1826 DEFUN (no_bgp_maxmed_admin
,
1827 no_bgp_maxmed_admin_cmd
,
1828 "no bgp max-med administrative [(0-4294967295)]",
1831 "Advertise routes with max-med\n"
1832 "Administratively applied, for an indefinite period\n"
1833 "Max MED value to be used\n")
1835 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1836 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1837 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1838 bgp_maxmed_update(bgp
);
1843 DEFUN (bgp_maxmed_onstartup
,
1844 bgp_maxmed_onstartup_cmd
,
1845 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1847 "Advertise routes with max-med\n"
1848 "Effective on a startup\n"
1849 "Time (seconds) period for max-med\n"
1850 "Max MED value to be used\n")
1852 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1855 argv_find(argv
, argc
, "(5-86400)", &idx
);
1856 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1857 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1858 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1860 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1862 bgp_maxmed_update(bgp
);
1867 DEFUN (no_bgp_maxmed_onstartup
,
1868 no_bgp_maxmed_onstartup_cmd
,
1869 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1872 "Advertise routes with max-med\n"
1873 "Effective on a startup\n"
1874 "Time (seconds) period for max-med\n"
1875 "Max MED value to be used\n")
1877 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1879 /* Cancel max-med onstartup if its on */
1880 if (bgp
->t_maxmed_onstartup
) {
1881 thread_cancel(&bgp
->t_maxmed_onstartup
);
1882 bgp
->maxmed_onstartup_over
= 1;
1885 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1886 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1888 bgp_maxmed_update(bgp
);
1893 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
1894 uint16_t update_delay
,
1895 uint16_t establish_wait
)
1897 struct listnode
*node
, *nnode
;
1899 bool vrf_cfg
= false;
1902 * See if update-delay is set per-vrf and warn user to delete it
1903 * Note that we only need to check this if this is the first time
1904 * setting the global config.
1906 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
1907 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1908 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1910 "%% update-delay configuration found in vrf %s\n",
1911 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
1921 "%%Failed: global update-delay config not permitted\n");
1925 if (!establish_wait
) { /* update-delay <delay> */
1926 bm
->v_update_delay
= update_delay
;
1927 bm
->v_establish_wait
= bm
->v_update_delay
;
1929 /* update-delay <delay> <establish-wait> */
1930 if (update_delay
< establish_wait
) {
1932 "%%Failed: update-delay less than the establish-wait!\n");
1933 return CMD_WARNING_CONFIG_FAILED
;
1936 bm
->v_update_delay
= update_delay
;
1937 bm
->v_establish_wait
= establish_wait
;
1940 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1941 bgp
->v_update_delay
= bm
->v_update_delay
;
1942 bgp
->v_establish_wait
= bm
->v_establish_wait
;
1948 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
1950 struct listnode
*node
, *nnode
;
1953 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1954 bm
->v_establish_wait
= bm
->v_update_delay
;
1956 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1957 bgp
->v_update_delay
= bm
->v_update_delay
;
1958 bgp
->v_establish_wait
= bm
->v_establish_wait
;
1964 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
1965 uint16_t establish_wait
)
1967 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1969 /* if configured globally, per-instance config is not allowed */
1970 if (bm
->v_update_delay
) {
1972 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
1973 return CMD_WARNING_CONFIG_FAILED
;
1977 if (!establish_wait
) /* update-delay <delay> */
1979 bgp
->v_update_delay
= update_delay
;
1980 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1984 /* update-delay <delay> <establish-wait> */
1985 if (update_delay
< establish_wait
) {
1987 "%%Failed: update-delay less than the establish-wait!\n");
1988 return CMD_WARNING_CONFIG_FAILED
;
1991 bgp
->v_update_delay
= update_delay
;
1992 bgp
->v_establish_wait
= establish_wait
;
1997 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1999 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2001 /* If configured globally, cannot remove from one bgp instance */
2002 if (bm
->v_update_delay
) {
2004 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2005 return CMD_WARNING_CONFIG_FAILED
;
2007 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2008 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2013 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2015 /* If configured globally, no need to display per-instance value */
2016 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2017 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2018 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2019 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2024 /* Global update-delay configuration */
2025 DEFPY (bgp_global_update_delay
,
2026 bgp_global_update_delay_cmd
,
2027 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2029 "Force initial delay for best-path and updates for all bgp instances\n"
2030 "Max delay in seconds\n"
2031 "Establish wait in seconds\n")
2033 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2036 /* Global update-delay deconfiguration */
2037 DEFPY (no_bgp_global_update_delay
,
2038 no_bgp_global_update_delay_cmd
,
2039 "no bgp update-delay [(0-3600) [(1-3600)]]",
2042 "Force initial delay for best-path and updates\n"
2043 "Max delay in seconds\n"
2044 "Establish wait in seconds\n")
2046 return bgp_global_update_delay_deconfig_vty(vty
);
2049 /* Update-delay configuration */
2051 DEFPY (bgp_update_delay
,
2052 bgp_update_delay_cmd
,
2053 "update-delay (0-3600)$delay [(1-3600)$wait]",
2054 "Force initial delay for best-path and updates\n"
2055 "Max delay in seconds\n"
2056 "Establish wait in seconds\n")
2058 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2061 /* Update-delay deconfiguration */
2062 DEFPY (no_bgp_update_delay
,
2063 no_bgp_update_delay_cmd
,
2064 "no update-delay [(0-3600) [(1-3600)]]",
2066 "Force initial delay for best-path and updates\n"
2067 "Max delay in seconds\n"
2068 "Establish wait in seconds\n")
2070 return bgp_update_delay_deconfig_vty(vty
);
2074 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2077 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2079 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2080 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2085 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2088 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2090 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2091 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2096 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2099 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2100 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2101 vty_out(vty
, " write-quanta %d\n", quanta
);
2104 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2107 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2108 if (quanta
!= BGP_READ_PACKET_MAX
)
2109 vty_out(vty
, " read-quanta %d\n", quanta
);
2112 /* Packet quanta configuration
2114 * XXX: The value set here controls the size of a stack buffer in the IO
2115 * thread. When changing these limits be careful to prevent stack overflow.
2117 * Furthermore, the maximums used here should correspond to
2118 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2120 DEFPY (bgp_wpkt_quanta
,
2121 bgp_wpkt_quanta_cmd
,
2122 "[no] write-quanta (1-64)$quanta",
2124 "How many packets to write to peer socket per run\n"
2125 "Number of packets\n")
2127 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
2130 DEFPY (bgp_rpkt_quanta
,
2131 bgp_rpkt_quanta_cmd
,
2132 "[no] read-quanta (1-10)$quanta",
2134 "How many packets to read from peer socket per I/O cycle\n"
2135 "Number of packets\n")
2137 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
2140 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2142 if (!bgp
->heuristic_coalesce
)
2143 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2147 DEFUN (bgp_coalesce_time
,
2148 bgp_coalesce_time_cmd
,
2149 "coalesce-time (0-4294967295)",
2150 "Subgroup coalesce timer\n"
2151 "Subgroup coalesce timer value (in ms)\n")
2153 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2156 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
2157 bgp
->heuristic_coalesce
= false;
2158 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2162 DEFUN (no_bgp_coalesce_time
,
2163 no_bgp_coalesce_time_cmd
,
2164 "no coalesce-time (0-4294967295)",
2166 "Subgroup coalesce timer\n"
2167 "Subgroup coalesce timer value (in ms)\n")
2169 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2171 bgp
->heuristic_coalesce
= true;
2172 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
2176 /* Maximum-paths configuration */
2177 DEFUN (bgp_maxpaths
,
2179 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2180 "Forward packets over multiple paths\n"
2181 "Number of paths\n")
2184 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
2185 argv
[idx_number
]->arg
, 0, 1);
2188 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2189 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2190 "Forward packets over multiple paths\n"
2191 "Number of paths\n")
2193 DEFUN (bgp_maxpaths_ibgp
,
2194 bgp_maxpaths_ibgp_cmd
,
2195 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2196 "Forward packets over multiple paths\n"
2198 "Number of paths\n")
2201 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2202 argv
[idx_number
]->arg
, 0, 1);
2205 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2206 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2207 "Forward packets over multiple paths\n"
2209 "Number of paths\n")
2211 DEFUN (bgp_maxpaths_ibgp_cluster
,
2212 bgp_maxpaths_ibgp_cluster_cmd
,
2213 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2214 "Forward packets over multiple paths\n"
2217 "Match the cluster length\n")
2220 return bgp_maxpaths_config_vty(
2221 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
2222 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
2225 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2226 "maximum-paths ibgp " CMD_RANGE_STR(
2227 1, MULTIPATH_NUM
) " equal-cluster-length",
2228 "Forward packets over multiple paths\n"
2231 "Match the cluster length\n")
2233 DEFUN (no_bgp_maxpaths
,
2234 no_bgp_maxpaths_cmd
,
2235 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2237 "Forward packets over multiple paths\n"
2238 "Number of paths\n")
2240 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
2243 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2244 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2245 "Forward packets over multiple paths\n"
2246 "Number of paths\n")
2248 DEFUN (no_bgp_maxpaths_ibgp
,
2249 no_bgp_maxpaths_ibgp_cmd
,
2250 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2252 "Forward packets over multiple paths\n"
2255 "Match the cluster length\n")
2257 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
2260 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2261 "no maximum-paths ibgp [" CMD_RANGE_STR(
2262 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2264 "Forward packets over multiple paths\n"
2267 "Match the cluster length\n")
2269 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2270 afi_t afi
, safi_t safi
)
2272 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2273 vty_out(vty
, " maximum-paths %d\n",
2274 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2277 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2278 vty_out(vty
, " maximum-paths ibgp %d",
2279 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2280 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
2281 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
2282 vty_out(vty
, " equal-cluster-length");
2291 "timers bgp (0-65535) (0-65535)",
2292 "Adjust routing timers\n"
2294 "Keepalive interval\n"
2297 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2299 int idx_number_2
= 3;
2300 unsigned long keepalive
= 0;
2301 unsigned long holdtime
= 0;
2303 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2304 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2306 /* Holdtime value check. */
2307 if (holdtime
< 3 && holdtime
!= 0) {
2309 "%% hold time value must be either 0 or greater than 3\n");
2310 return CMD_WARNING_CONFIG_FAILED
;
2313 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
,
2314 BGP_DEFAULT_DELAYOPEN
);
2319 DEFUN (no_bgp_timers
,
2321 "no timers bgp [(0-65535) (0-65535)]",
2323 "Adjust routing timers\n"
2325 "Keepalive interval\n"
2328 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2329 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
2330 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
2336 DEFUN (bgp_client_to_client_reflection
,
2337 bgp_client_to_client_reflection_cmd
,
2338 "bgp client-to-client reflection",
2339 "BGP specific commands\n"
2340 "Configure client to client route reflection\n"
2341 "reflection of routes allowed\n")
2343 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2344 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2345 bgp_clear_star_soft_out(vty
, bgp
->name
);
2350 DEFUN (no_bgp_client_to_client_reflection
,
2351 no_bgp_client_to_client_reflection_cmd
,
2352 "no bgp client-to-client reflection",
2354 "BGP specific commands\n"
2355 "Configure client to client route reflection\n"
2356 "reflection of routes allowed\n")
2358 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2359 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2360 bgp_clear_star_soft_out(vty
, bgp
->name
);
2365 /* "bgp always-compare-med" configuration. */
2366 DEFUN (bgp_always_compare_med
,
2367 bgp_always_compare_med_cmd
,
2368 "bgp always-compare-med",
2369 "BGP specific commands\n"
2370 "Allow comparing MED from different neighbors\n")
2372 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2373 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2374 bgp_recalculate_all_bestpaths(bgp
);
2379 DEFUN (no_bgp_always_compare_med
,
2380 no_bgp_always_compare_med_cmd
,
2381 "no bgp always-compare-med",
2383 "BGP specific commands\n"
2384 "Allow comparing MED from different neighbors\n")
2386 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2387 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2388 bgp_recalculate_all_bestpaths(bgp
);
2394 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2395 "bgp ebgp-requires-policy",
2396 "BGP specific commands\n"
2397 "Require in and out policy for eBGP peers (RFC8212)\n")
2399 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2400 SET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2404 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2405 "no bgp ebgp-requires-policy",
2407 "BGP specific commands\n"
2408 "Require in and out policy for eBGP peers (RFC8212)\n")
2410 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2411 UNSET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2415 DEFUN(bgp_suppress_duplicates
, bgp_suppress_duplicates_cmd
,
2416 "bgp suppress-duplicates",
2417 "BGP specific commands\n"
2418 "Suppress duplicate updates if the route actually not changed\n")
2420 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2421 SET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2425 DEFUN(no_bgp_suppress_duplicates
, no_bgp_suppress_duplicates_cmd
,
2426 "no bgp suppress-duplicates",
2428 "BGP specific commands\n"
2429 "Suppress duplicate updates if the route actually not changed\n")
2431 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2432 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2436 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2437 "bgp reject-as-sets",
2438 "BGP specific commands\n"
2439 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2441 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2442 struct listnode
*node
, *nnode
;
2445 bgp
->reject_as_sets
= true;
2447 /* Reset existing BGP sessions to reject routes
2448 * with aspath containing AS_SET or AS_CONFED_SET.
2450 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2451 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2452 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2453 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2454 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2461 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2462 "no bgp reject-as-sets",
2464 "BGP specific commands\n"
2465 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2467 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2468 struct listnode
*node
, *nnode
;
2471 bgp
->reject_as_sets
= false;
2473 /* Reset existing BGP sessions to reject routes
2474 * with aspath containing AS_SET or AS_CONFED_SET.
2476 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2477 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2478 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2479 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2480 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2487 /* "bgp deterministic-med" configuration. */
2488 DEFUN (bgp_deterministic_med
,
2489 bgp_deterministic_med_cmd
,
2490 "bgp deterministic-med",
2491 "BGP specific commands\n"
2492 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2494 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2496 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2497 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2498 bgp_recalculate_all_bestpaths(bgp
);
2504 DEFUN (no_bgp_deterministic_med
,
2505 no_bgp_deterministic_med_cmd
,
2506 "no bgp deterministic-med",
2508 "BGP specific commands\n"
2509 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2511 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2512 int bestpath_per_as_used
;
2516 struct listnode
*node
, *nnode
;
2518 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2519 bestpath_per_as_used
= 0;
2521 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2522 FOREACH_AFI_SAFI (afi
, safi
)
2523 if (bgp_addpath_dmed_required(
2524 peer
->addpath_type
[afi
][safi
])) {
2525 bestpath_per_as_used
= 1;
2529 if (bestpath_per_as_used
)
2533 if (bestpath_per_as_used
) {
2535 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2536 return CMD_WARNING_CONFIG_FAILED
;
2538 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2539 bgp_recalculate_all_bestpaths(bgp
);
2546 /* "bgp graceful-restart mode" configuration. */
2547 DEFUN (bgp_graceful_restart
,
2548 bgp_graceful_restart_cmd
,
2549 "bgp graceful-restart",
2550 "BGP specific commands\n"
2554 int ret
= BGP_GR_FAILURE
;
2556 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2557 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2559 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2561 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2563 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2566 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2567 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2569 "Graceful restart configuration changed, reset all peers to take effect\n");
2570 return bgp_vty_return(vty
, ret
);
2573 DEFUN (no_bgp_graceful_restart
,
2574 no_bgp_graceful_restart_cmd
,
2575 "no bgp graceful-restart",
2577 "BGP specific commands\n"
2581 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2583 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2584 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2586 int ret
= BGP_GR_FAILURE
;
2588 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2590 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2593 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2594 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2596 "Graceful restart configuration changed, reset all peers to take effect\n");
2598 return bgp_vty_return(vty
, ret
);
2601 DEFUN (bgp_graceful_restart_stalepath_time
,
2602 bgp_graceful_restart_stalepath_time_cmd
,
2603 "bgp graceful-restart stalepath-time (1-4095)",
2604 "BGP specific commands\n"
2605 "Graceful restart capability parameters\n"
2606 "Set the max time to hold onto restarting peer's stale paths\n"
2607 "Delay value (seconds)\n")
2609 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2613 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2614 bgp
->stalepath_time
= stalepath
;
2618 DEFUN (bgp_graceful_restart_restart_time
,
2619 bgp_graceful_restart_restart_time_cmd
,
2620 "bgp graceful-restart restart-time (1-4095)",
2621 "BGP specific commands\n"
2622 "Graceful restart capability parameters\n"
2623 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2624 "Delay value (seconds)\n")
2626 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2630 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2631 bgp
->restart_time
= restart
;
2635 DEFUN (bgp_graceful_restart_select_defer_time
,
2636 bgp_graceful_restart_select_defer_time_cmd
,
2637 "bgp graceful-restart select-defer-time (0-3600)",
2638 "BGP specific commands\n"
2639 "Graceful restart capability parameters\n"
2640 "Set the time to defer the BGP route selection after restart\n"
2641 "Delay value (seconds, 0 - disable)\n")
2643 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2645 uint32_t defer_time
;
2647 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2648 bgp
->select_defer_time
= defer_time
;
2649 if (defer_time
== 0)
2650 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2652 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2657 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2658 no_bgp_graceful_restart_stalepath_time_cmd
,
2659 "no bgp graceful-restart stalepath-time [(1-4095)]",
2661 "BGP specific commands\n"
2662 "Graceful restart capability parameters\n"
2663 "Set the max time to hold onto restarting peer's stale paths\n"
2664 "Delay value (seconds)\n")
2666 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2668 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2672 DEFUN (no_bgp_graceful_restart_restart_time
,
2673 no_bgp_graceful_restart_restart_time_cmd
,
2674 "no bgp graceful-restart restart-time [(1-4095)]",
2676 "BGP specific commands\n"
2677 "Graceful restart capability parameters\n"
2678 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2679 "Delay value (seconds)\n")
2681 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2683 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2687 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2688 no_bgp_graceful_restart_select_defer_time_cmd
,
2689 "no bgp graceful-restart select-defer-time [(0-3600)]",
2691 "BGP specific commands\n"
2692 "Graceful restart capability parameters\n"
2693 "Set the time to defer the BGP route selection after restart\n"
2694 "Delay value (seconds)\n")
2696 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2698 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2699 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2704 DEFUN (bgp_graceful_restart_preserve_fw
,
2705 bgp_graceful_restart_preserve_fw_cmd
,
2706 "bgp graceful-restart preserve-fw-state",
2707 "BGP specific commands\n"
2708 "Graceful restart capability parameters\n"
2709 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2711 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2712 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2716 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2717 no_bgp_graceful_restart_preserve_fw_cmd
,
2718 "no bgp graceful-restart preserve-fw-state",
2720 "BGP specific commands\n"
2721 "Graceful restart capability parameters\n"
2722 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2724 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2725 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2729 DEFUN (bgp_graceful_restart_disable
,
2730 bgp_graceful_restart_disable_cmd
,
2731 "bgp graceful-restart-disable",
2732 "BGP specific commands\n"
2735 int ret
= BGP_GR_FAILURE
;
2737 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2739 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
2741 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2743 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
2745 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
2748 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2750 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
2752 "Graceful restart configuration changed, reset all peers to take effect\n");
2754 return bgp_vty_return(vty
, ret
);
2757 DEFUN (no_bgp_graceful_restart_disable
,
2758 no_bgp_graceful_restart_disable_cmd
,
2759 "no bgp graceful-restart-disable",
2761 "BGP specific commands\n"
2765 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2767 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2769 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
2771 int ret
= BGP_GR_FAILURE
;
2773 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
2775 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2778 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2780 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
2782 "Graceful restart configuration changed, reset all peers to take effect\n");
2784 return bgp_vty_return(vty
, ret
);
2787 DEFUN (bgp_neighbor_graceful_restart_set
,
2788 bgp_neighbor_graceful_restart_set_cmd
,
2789 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
2797 int ret
= BGP_GR_FAILURE
;
2799 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2801 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2803 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
2805 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2807 return CMD_WARNING_CONFIG_FAILED
;
2809 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
2811 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2812 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2814 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2816 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
2818 "Graceful restart configuration changed, reset this peer to take effect\n");
2820 return bgp_vty_return(vty
, ret
);
2823 DEFUN (no_bgp_neighbor_graceful_restart
,
2824 no_bgp_neighbor_graceful_restart_set_cmd
,
2825 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
2833 int ret
= BGP_GR_FAILURE
;
2836 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2838 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2840 return CMD_WARNING_CONFIG_FAILED
;
2842 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2844 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
2846 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
2848 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2849 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2851 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2853 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
2855 "Graceful restart configuration changed, reset this peer to take effect\n");
2857 return bgp_vty_return(vty
, ret
);
2860 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
2861 bgp_neighbor_graceful_restart_helper_set_cmd
,
2862 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
2865 GR_NEIGHBOR_HELPER_CMD
2870 int ret
= BGP_GR_FAILURE
;
2872 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2874 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2876 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
2878 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2881 return CMD_WARNING_CONFIG_FAILED
;
2884 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
2886 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2887 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2889 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2891 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
2893 "Graceful restart configuration changed, reset this peer to take effect\n");
2895 return bgp_vty_return(vty
, ret
);
2898 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
2899 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
2900 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
2904 NO_GR_NEIGHBOR_HELPER_CMD
2908 int ret
= BGP_GR_FAILURE
;
2911 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2913 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2915 return CMD_WARNING_CONFIG_FAILED
;
2917 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2919 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
2921 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
2923 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2924 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2926 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2928 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
2930 "Graceful restart configuration changed, reset this peer to take effect\n");
2932 return bgp_vty_return(vty
, ret
);
2935 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
2936 bgp_neighbor_graceful_restart_disable_set_cmd
,
2937 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
2940 GR_NEIGHBOR_DISABLE_CMD
2945 int ret
= BGP_GR_FAILURE
;
2947 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2949 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2951 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
2953 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2955 return CMD_WARNING_CONFIG_FAILED
;
2957 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
2959 if (peer
->bgp
->t_startup
)
2960 bgp_peer_gr_flags_update(peer
);
2962 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2963 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2965 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2967 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
2969 "Graceful restart configuration changed, reset this peer to take effect\n");
2971 return bgp_vty_return(vty
, ret
);
2974 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
2975 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
2976 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
2980 NO_GR_NEIGHBOR_DISABLE_CMD
2984 int ret
= BGP_GR_FAILURE
;
2987 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2989 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2991 return CMD_WARNING_CONFIG_FAILED
;
2993 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2995 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
2997 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
2999 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3000 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3002 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3004 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3006 "Graceful restart configuration changed, reset this peer to take effect\n");
3008 return bgp_vty_return(vty
, ret
);
3011 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3012 bgp_graceful_restart_disable_eor_cmd
,
3013 "bgp graceful-restart disable-eor",
3014 "BGP specific commands\n"
3015 "Graceful restart configuration parameters\n"
3016 "Disable EOR Check\n")
3018 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3019 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3024 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3025 no_bgp_graceful_restart_disable_eor_cmd
,
3026 "no bgp graceful-restart disable-eor",
3028 "BGP specific commands\n"
3029 "Graceful restart configuration parameters\n"
3030 "Disable EOR Check\n")
3032 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3033 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3038 DEFUN (bgp_graceful_restart_rib_stale_time
,
3039 bgp_graceful_restart_rib_stale_time_cmd
,
3040 "bgp graceful-restart rib-stale-time (1-3600)",
3041 "BGP specific commands\n"
3042 "Graceful restart configuration parameters\n"
3043 "Specify the stale route removal timer in rib\n"
3044 "Delay value (seconds)\n")
3046 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3048 uint32_t stale_time
;
3050 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3051 bgp
->rib_stale_time
= stale_time
;
3052 /* Send the stale timer update message to RIB */
3053 if (bgp_zebra_stale_timer_update(bgp
))
3059 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3060 no_bgp_graceful_restart_rib_stale_time_cmd
,
3061 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3063 "BGP specific commands\n"
3064 "Graceful restart configuration parameters\n"
3065 "Specify the stale route removal timer in rib\n"
3066 "Delay value (seconds)\n")
3068 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3070 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3071 /* Send the stale timer update message to RIB */
3072 if (bgp_zebra_stale_timer_update(bgp
))
3078 static inline void bgp_initiate_graceful_shut_unshut(struct vty
*vty
,
3081 bgp_static_redo_import_check(bgp
);
3082 bgp_redistribute_redo(bgp
);
3083 bgp_clear_star_soft_out(vty
, bgp
->name
);
3084 bgp_clear_star_soft_in(vty
, bgp
->name
);
3087 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3089 struct listnode
*node
, *nnode
;
3091 bool vrf_cfg
= false;
3093 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3096 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3097 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3098 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3100 "%% graceful-shutdown configuration found in vrf %s\n",
3101 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3102 VRF_DEFAULT_NAME
: bgp
->name
);
3109 "%%Failed: global graceful-shutdown not permitted\n");
3113 /* Set flag globally */
3114 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3116 /* Initiate processing for all BGP instances. */
3117 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3118 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3123 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3125 struct listnode
*node
, *nnode
;
3128 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3131 /* Unset flag globally */
3132 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3134 /* Initiate processing for all BGP instances. */
3135 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3136 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3141 /* "bgp graceful-shutdown" configuration */
3142 DEFUN (bgp_graceful_shutdown
,
3143 bgp_graceful_shutdown_cmd
,
3144 "bgp graceful-shutdown",
3146 "Graceful shutdown parameters\n")
3148 if (vty
->node
== CONFIG_NODE
)
3149 return bgp_global_graceful_shutdown_config_vty(vty
);
3151 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3153 /* if configured globally, per-instance config is not allowed */
3154 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3156 "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n");
3157 return CMD_WARNING_CONFIG_FAILED
;
3160 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3161 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3162 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3168 DEFUN (no_bgp_graceful_shutdown
,
3169 no_bgp_graceful_shutdown_cmd
,
3170 "no bgp graceful-shutdown",
3173 "Graceful shutdown parameters\n")
3175 if (vty
->node
== CONFIG_NODE
)
3176 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3178 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3180 /* If configured globally, cannot remove from one bgp instance */
3181 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3183 "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n");
3184 return CMD_WARNING_CONFIG_FAILED
;
3187 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3188 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3189 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3195 /* "bgp fast-external-failover" configuration. */
3196 DEFUN (bgp_fast_external_failover
,
3197 bgp_fast_external_failover_cmd
,
3198 "bgp fast-external-failover",
3200 "Immediately reset session if a link to a directly connected external peer goes down\n")
3202 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3203 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3207 DEFUN (no_bgp_fast_external_failover
,
3208 no_bgp_fast_external_failover_cmd
,
3209 "no bgp fast-external-failover",
3212 "Immediately reset session if a link to a directly connected external peer goes down\n")
3214 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3215 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3219 /* "bgp bestpath compare-routerid" configuration. */
3220 DEFUN (bgp_bestpath_compare_router_id
,
3221 bgp_bestpath_compare_router_id_cmd
,
3222 "bgp bestpath compare-routerid",
3223 "BGP specific commands\n"
3224 "Change the default bestpath selection\n"
3225 "Compare router-id for identical EBGP paths\n")
3227 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3228 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3229 bgp_recalculate_all_bestpaths(bgp
);
3234 DEFUN (no_bgp_bestpath_compare_router_id
,
3235 no_bgp_bestpath_compare_router_id_cmd
,
3236 "no bgp bestpath compare-routerid",
3238 "BGP specific commands\n"
3239 "Change the default bestpath selection\n"
3240 "Compare router-id for identical EBGP paths\n")
3242 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3243 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3244 bgp_recalculate_all_bestpaths(bgp
);
3249 /* "bgp bestpath as-path ignore" configuration. */
3250 DEFUN (bgp_bestpath_aspath_ignore
,
3251 bgp_bestpath_aspath_ignore_cmd
,
3252 "bgp bestpath as-path ignore",
3253 "BGP specific commands\n"
3254 "Change the default bestpath selection\n"
3255 "AS-path attribute\n"
3256 "Ignore as-path length in selecting a route\n")
3258 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3259 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3260 bgp_recalculate_all_bestpaths(bgp
);
3265 DEFUN (no_bgp_bestpath_aspath_ignore
,
3266 no_bgp_bestpath_aspath_ignore_cmd
,
3267 "no bgp bestpath as-path ignore",
3269 "BGP specific commands\n"
3270 "Change the default bestpath selection\n"
3271 "AS-path attribute\n"
3272 "Ignore as-path length in selecting a route\n")
3274 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3275 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3276 bgp_recalculate_all_bestpaths(bgp
);
3281 /* "bgp bestpath as-path confed" configuration. */
3282 DEFUN (bgp_bestpath_aspath_confed
,
3283 bgp_bestpath_aspath_confed_cmd
,
3284 "bgp bestpath as-path confed",
3285 "BGP specific commands\n"
3286 "Change the default bestpath selection\n"
3287 "AS-path attribute\n"
3288 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3290 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3291 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3292 bgp_recalculate_all_bestpaths(bgp
);
3297 DEFUN (no_bgp_bestpath_aspath_confed
,
3298 no_bgp_bestpath_aspath_confed_cmd
,
3299 "no bgp bestpath as-path confed",
3301 "BGP specific commands\n"
3302 "Change the default bestpath selection\n"
3303 "AS-path attribute\n"
3304 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3306 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3307 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3308 bgp_recalculate_all_bestpaths(bgp
);
3313 /* "bgp bestpath as-path multipath-relax" configuration. */
3314 DEFUN (bgp_bestpath_aspath_multipath_relax
,
3315 bgp_bestpath_aspath_multipath_relax_cmd
,
3316 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3317 "BGP specific commands\n"
3318 "Change the default bestpath selection\n"
3319 "AS-path attribute\n"
3320 "Allow load sharing across routes that have different AS paths (but same length)\n"
3321 "Generate an AS_SET\n"
3322 "Do not generate an AS_SET\n")
3324 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3326 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3328 /* no-as-set is now the default behavior so we can silently
3330 if (argv_find(argv
, argc
, "as-set", &idx
))
3331 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3333 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3335 bgp_recalculate_all_bestpaths(bgp
);
3340 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
3341 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3342 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3344 "BGP specific commands\n"
3345 "Change the default bestpath selection\n"
3346 "AS-path attribute\n"
3347 "Allow load sharing across routes that have different AS paths (but same length)\n"
3348 "Generate an AS_SET\n"
3349 "Do not generate an AS_SET\n")
3351 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3352 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3353 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3354 bgp_recalculate_all_bestpaths(bgp
);
3359 /* "bgp bestpath peer-type multipath-relax" configuration. */
3360 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3361 bgp_bestpath_peer_type_multipath_relax_cmd
,
3362 "bgp bestpath peer-type multipath-relax",
3364 "Change the default bestpath selection\n"
3366 "Allow load sharing across routes learned from different peer types\n")
3368 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3369 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3370 bgp_recalculate_all_bestpaths(bgp
);
3375 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3376 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3377 "no bgp bestpath peer-type multipath-relax",
3379 "Change the default bestpath selection\n"
3381 "Allow load sharing across routes learned from different peer types\n")
3383 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3384 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3385 bgp_recalculate_all_bestpaths(bgp
);
3390 /* "bgp log-neighbor-changes" configuration. */
3391 DEFUN (bgp_log_neighbor_changes
,
3392 bgp_log_neighbor_changes_cmd
,
3393 "bgp log-neighbor-changes",
3394 "BGP specific commands\n"
3395 "Log neighbor up/down and reset reason\n")
3397 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3398 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3402 DEFUN (no_bgp_log_neighbor_changes
,
3403 no_bgp_log_neighbor_changes_cmd
,
3404 "no bgp log-neighbor-changes",
3406 "BGP specific commands\n"
3407 "Log neighbor up/down and reset reason\n")
3409 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3410 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3414 /* "bgp bestpath med" configuration. */
3415 DEFUN (bgp_bestpath_med
,
3416 bgp_bestpath_med_cmd
,
3417 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3418 "BGP specific commands\n"
3419 "Change the default bestpath selection\n"
3421 "Compare MED among confederation paths\n"
3422 "Treat missing MED as the least preferred one\n"
3423 "Treat missing MED as the least preferred one\n"
3424 "Compare MED among confederation paths\n")
3426 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3429 if (argv_find(argv
, argc
, "confed", &idx
))
3430 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3432 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3433 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3435 bgp_recalculate_all_bestpaths(bgp
);
3440 DEFUN (no_bgp_bestpath_med
,
3441 no_bgp_bestpath_med_cmd
,
3442 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3444 "BGP specific commands\n"
3445 "Change the default bestpath selection\n"
3447 "Compare MED among confederation paths\n"
3448 "Treat missing MED as the least preferred one\n"
3449 "Treat missing MED as the least preferred one\n"
3450 "Compare MED among confederation paths\n")
3452 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3455 if (argv_find(argv
, argc
, "confed", &idx
))
3456 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3458 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3459 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3461 bgp_recalculate_all_bestpaths(bgp
);
3466 /* "bgp bestpath bandwidth" configuration. */
3467 DEFPY (bgp_bestpath_bw
,
3468 bgp_bestpath_bw_cmd
,
3469 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3470 "BGP specific commands\n"
3471 "Change the default bestpath selection\n"
3472 "Link Bandwidth attribute\n"
3473 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3474 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3475 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3477 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3482 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3483 return CMD_ERR_INCOMPLETE
;
3485 if (!strcmp(bw_cfg
, "ignore"))
3486 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3487 else if (!strcmp(bw_cfg
, "skip-missing"))
3488 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3489 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3490 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3492 return CMD_ERR_NO_MATCH
;
3494 /* This config is used in route install, so redo that. */
3495 FOREACH_AFI_SAFI (afi
, safi
) {
3496 if (!bgp_fibupd_safi(safi
))
3498 bgp_zebra_announce_table(bgp
, afi
, safi
);
3504 DEFPY (no_bgp_bestpath_bw
,
3505 no_bgp_bestpath_bw_cmd
,
3506 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3508 "BGP specific commands\n"
3509 "Change the default bestpath selection\n"
3510 "Link Bandwidth attribute\n"
3511 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3512 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3513 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3515 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3519 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3521 /* This config is used in route install, so redo that. */
3522 FOREACH_AFI_SAFI (afi
, safi
) {
3523 if (!bgp_fibupd_safi(safi
))
3525 bgp_zebra_announce_table(bgp
, afi
, safi
);
3530 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
3531 "[no] bgp default <ipv4-unicast|"
3534 "ipv4-labeled-unicast|"
3539 "ipv6-labeled-unicast|"
3541 "l2vpn-evpn>$afi_safi",
3543 "BGP specific commands\n"
3544 "Configure BGP defaults\n"
3545 "Activate ipv4-unicast for a peer by default\n"
3546 "Activate ipv4-multicast for a peer by default\n"
3547 "Activate ipv4-vpn for a peer by default\n"
3548 "Activate ipv4-labeled-unicast for a peer by default\n"
3549 "Activate ipv4-flowspec for a peer by default\n"
3550 "Activate ipv6-unicast for a peer by default\n"
3551 "Activate ipv6-multicast for a peer by default\n"
3552 "Activate ipv6-vpn for a peer by default\n"
3553 "Activate ipv6-labeled-unicast for a peer by default\n"
3554 "Activate ipv6-flowspec for a peer by default\n"
3555 "Activate l2vpn-evpn for a peer by default\n")
3557 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3558 char afi_safi_str
[strlen(afi_safi
) + 1];
3559 char *afi_safi_str_tok
;
3561 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
3562 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
3563 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
3564 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
3567 if (strmatch(safi_str
, "labeled"))
3568 safi
= bgp_vty_safi_from_str("labeled-unicast");
3570 safi
= bgp_vty_safi_from_str(safi_str
);
3573 bgp
->default_af
[afi
][safi
] = false;
3575 if ((safi
== SAFI_LABELED_UNICAST
3576 && bgp
->default_af
[afi
][SAFI_UNICAST
])
3577 || (safi
== SAFI_UNICAST
3578 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
3579 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
3581 bgp
->default_af
[afi
][safi
] = true;
3587 /* Display hostname in certain command outputs */
3588 DEFUN (bgp_default_show_hostname
,
3589 bgp_default_show_hostname_cmd
,
3590 "bgp default show-hostname",
3591 "BGP specific commands\n"
3592 "Configure BGP defaults\n"
3593 "Show hostname in certain command outputs\n")
3595 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3596 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3600 DEFUN (no_bgp_default_show_hostname
,
3601 no_bgp_default_show_hostname_cmd
,
3602 "no bgp default show-hostname",
3604 "BGP specific commands\n"
3605 "Configure BGP defaults\n"
3606 "Show hostname in certain command outputs\n")
3608 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3609 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3613 /* Display hostname in certain command outputs */
3614 DEFUN (bgp_default_show_nexthop_hostname
,
3615 bgp_default_show_nexthop_hostname_cmd
,
3616 "bgp default show-nexthop-hostname",
3617 "BGP specific commands\n"
3618 "Configure BGP defaults\n"
3619 "Show hostname for nexthop in certain command outputs\n")
3621 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3622 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3626 DEFUN (no_bgp_default_show_nexthop_hostname
,
3627 no_bgp_default_show_nexthop_hostname_cmd
,
3628 "no bgp default show-nexthop-hostname",
3630 "BGP specific commands\n"
3631 "Configure BGP defaults\n"
3632 "Show hostname for nexthop in certain command outputs\n")
3634 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3635 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3639 /* "bgp network import-check" configuration. */
3640 DEFUN (bgp_network_import_check
,
3641 bgp_network_import_check_cmd
,
3642 "bgp network import-check",
3643 "BGP specific commands\n"
3644 "BGP network command\n"
3645 "Check BGP network route exists in IGP\n")
3647 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3648 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3649 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3650 bgp_static_redo_import_check(bgp
);
3656 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
3657 "bgp network import-check exact",
3658 "BGP specific commands\n"
3659 "BGP network command\n"
3660 "Check BGP network route exists in IGP\n"
3661 "Match route precisely\n")
3663 DEFUN (no_bgp_network_import_check
,
3664 no_bgp_network_import_check_cmd
,
3665 "no bgp network import-check",
3667 "BGP specific commands\n"
3668 "BGP network command\n"
3669 "Check BGP network route exists in IGP\n")
3671 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3672 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3673 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3674 bgp_static_redo_import_check(bgp
);
3680 DEFUN (bgp_default_local_preference
,
3681 bgp_default_local_preference_cmd
,
3682 "bgp default local-preference (0-4294967295)",
3683 "BGP specific commands\n"
3684 "Configure BGP defaults\n"
3685 "local preference (higher=more preferred)\n"
3686 "Configure default local preference value\n")
3688 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3690 uint32_t local_pref
;
3692 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3694 bgp_default_local_preference_set(bgp
, local_pref
);
3695 bgp_clear_star_soft_in(vty
, bgp
->name
);
3700 DEFUN (no_bgp_default_local_preference
,
3701 no_bgp_default_local_preference_cmd
,
3702 "no bgp default local-preference [(0-4294967295)]",
3704 "BGP specific commands\n"
3705 "Configure BGP defaults\n"
3706 "local preference (higher=more preferred)\n"
3707 "Configure default local preference value\n")
3709 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3710 bgp_default_local_preference_unset(bgp
);
3711 bgp_clear_star_soft_in(vty
, bgp
->name
);
3717 DEFUN (bgp_default_subgroup_pkt_queue_max
,
3718 bgp_default_subgroup_pkt_queue_max_cmd
,
3719 "bgp default subgroup-pkt-queue-max (20-100)",
3720 "BGP specific commands\n"
3721 "Configure BGP defaults\n"
3722 "subgroup-pkt-queue-max\n"
3723 "Configure subgroup packet queue max\n")
3725 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3729 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3731 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
3736 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
3737 no_bgp_default_subgroup_pkt_queue_max_cmd
,
3738 "no bgp default subgroup-pkt-queue-max [(20-100)]",
3740 "BGP specific commands\n"
3741 "Configure BGP defaults\n"
3742 "subgroup-pkt-queue-max\n"
3743 "Configure subgroup packet queue max\n")
3745 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3746 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
3751 DEFUN (bgp_rr_allow_outbound_policy
,
3752 bgp_rr_allow_outbound_policy_cmd
,
3753 "bgp route-reflector allow-outbound-policy",
3754 "BGP specific commands\n"
3755 "Allow modifications made by out route-map\n"
3756 "on ibgp neighbors\n")
3758 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3760 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
3761 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
3762 update_group_announce_rrclients(bgp
);
3763 bgp_clear_star_soft_out(vty
, bgp
->name
);
3769 DEFUN (no_bgp_rr_allow_outbound_policy
,
3770 no_bgp_rr_allow_outbound_policy_cmd
,
3771 "no bgp route-reflector allow-outbound-policy",
3773 "BGP specific commands\n"
3774 "Allow modifications made by out route-map\n"
3775 "on ibgp neighbors\n")
3777 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3779 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
3780 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
3781 update_group_announce_rrclients(bgp
);
3782 bgp_clear_star_soft_out(vty
, bgp
->name
);
3788 DEFUN (bgp_listen_limit
,
3789 bgp_listen_limit_cmd
,
3790 "bgp listen limit (1-65535)",
3791 "BGP specific commands\n"
3792 "BGP Dynamic Neighbors listen commands\n"
3793 "Maximum number of BGP Dynamic Neighbors that can be created\n"
3794 "Configure Dynamic Neighbors listen limit value\n")
3796 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3800 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3802 bgp_listen_limit_set(bgp
, listen_limit
);
3807 DEFUN (no_bgp_listen_limit
,
3808 no_bgp_listen_limit_cmd
,
3809 "no bgp listen limit [(1-65535)]",
3811 "BGP specific commands\n"
3812 "BGP Dynamic Neighbors listen commands\n"
3813 "Maximum number of BGP Dynamic Neighbors that can be created\n"
3814 "Configure Dynamic Neighbors listen limit value\n")
3816 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3817 bgp_listen_limit_unset(bgp
);
3823 * Check if this listen range is already configured. Check for exact
3824 * match or overlap based on input.
3826 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
3827 struct prefix
*range
, int exact
)
3829 struct listnode
*node
, *nnode
;
3830 struct listnode
*node1
, *nnode1
;
3831 struct peer_group
*group
;
3836 afi
= family2afi(range
->family
);
3837 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
3838 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
3841 match
= prefix_same(range
, lr
);
3843 match
= (prefix_match(range
, lr
)
3844 || prefix_match(lr
, range
));
3853 DEFUN (bgp_listen_range
,
3854 bgp_listen_range_cmd
,
3855 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
3856 "BGP specific commands\n"
3857 "Configure BGP dynamic neighbors listen range\n"
3858 "Configure BGP dynamic neighbors listen range\n"
3860 "Member of the peer-group\n"
3861 "Peer-group name\n")
3863 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3864 struct prefix range
;
3865 struct peer_group
*group
, *existing_group
;
3870 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
3871 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
3872 char *prefix
= argv
[idx
]->arg
;
3873 argv_find(argv
, argc
, "PGNAME", &idx
);
3874 char *peergroup
= argv
[idx
]->arg
;
3876 /* Convert IP prefix string to struct prefix. */
3877 ret
= str2prefix(prefix
, &range
);
3879 vty_out(vty
, "%% Malformed listen range\n");
3880 return CMD_WARNING_CONFIG_FAILED
;
3883 afi
= family2afi(range
.family
);
3885 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
3887 "%% Malformed listen range (link-local address)\n");
3888 return CMD_WARNING_CONFIG_FAILED
;
3893 /* Check if same listen range is already configured. */
3894 existing_group
= listen_range_exists(bgp
, &range
, 1);
3895 if (existing_group
) {
3896 if (strcmp(existing_group
->name
, peergroup
) == 0)
3900 "%% Same listen range is attached to peer-group %s\n",
3901 existing_group
->name
);
3902 return CMD_WARNING_CONFIG_FAILED
;
3906 /* Check if an overlapping listen range exists. */
3907 if (listen_range_exists(bgp
, &range
, 0)) {
3909 "%% Listen range overlaps with existing listen range\n");
3910 return CMD_WARNING_CONFIG_FAILED
;
3913 group
= peer_group_lookup(bgp
, peergroup
);
3915 vty_out(vty
, "%% Configure the peer-group first\n");
3916 return CMD_WARNING_CONFIG_FAILED
;
3919 ret
= peer_group_listen_range_add(group
, &range
);
3920 return bgp_vty_return(vty
, ret
);
3923 DEFUN (no_bgp_listen_range
,
3924 no_bgp_listen_range_cmd
,
3925 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
3927 "BGP specific commands\n"
3928 "Unconfigure BGP dynamic neighbors listen range\n"
3929 "Unconfigure BGP dynamic neighbors listen range\n"
3931 "Member of the peer-group\n"
3932 "Peer-group name\n")
3934 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3935 struct prefix range
;
3936 struct peer_group
*group
;
3941 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
3942 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
3943 char *prefix
= argv
[idx
]->arg
;
3944 argv_find(argv
, argc
, "PGNAME", &idx
);
3945 char *peergroup
= argv
[idx
]->arg
;
3947 /* Convert IP prefix string to struct prefix. */
3948 ret
= str2prefix(prefix
, &range
);
3950 vty_out(vty
, "%% Malformed listen range\n");
3951 return CMD_WARNING_CONFIG_FAILED
;
3954 afi
= family2afi(range
.family
);
3956 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
3958 "%% Malformed listen range (link-local address)\n");
3959 return CMD_WARNING_CONFIG_FAILED
;
3964 group
= peer_group_lookup(bgp
, peergroup
);
3966 vty_out(vty
, "%% Peer-group does not exist\n");
3967 return CMD_WARNING_CONFIG_FAILED
;
3970 ret
= peer_group_listen_range_del(group
, &range
);
3971 return bgp_vty_return(vty
, ret
);
3974 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
3976 struct peer_group
*group
;
3977 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
3978 struct prefix
*range
;
3981 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
3982 vty_out(vty
, " bgp listen limit %d\n",
3983 bgp
->dynamic_neighbors_limit
);
3985 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
3986 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
3987 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
3990 " bgp listen range %pFX peer-group %s\n",
3991 range
, group
->name
);
3998 DEFUN (bgp_disable_connected_route_check
,
3999 bgp_disable_connected_route_check_cmd
,
4000 "bgp disable-ebgp-connected-route-check",
4001 "BGP specific commands\n"
4002 "Disable checking if nexthop is connected on ebgp sessions\n")
4004 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4005 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4006 bgp_clear_star_soft_in(vty
, bgp
->name
);
4011 DEFUN (no_bgp_disable_connected_route_check
,
4012 no_bgp_disable_connected_route_check_cmd
,
4013 "no bgp disable-ebgp-connected-route-check",
4015 "BGP specific commands\n"
4016 "Disable checking if nexthop is connected on ebgp sessions\n")
4018 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4019 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4020 bgp_clear_star_soft_in(vty
, bgp
->name
);
4026 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
4029 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4032 int as_type
= AS_SPECIFIED
;
4035 if (as_str
[0] == 'i') {
4037 as_type
= AS_INTERNAL
;
4038 } else if (as_str
[0] == 'e') {
4040 as_type
= AS_EXTERNAL
;
4042 /* Get AS number. */
4043 as
= strtoul(as_str
, NULL
, 10);
4046 /* If peer is peer group or interface peer, call proper function. */
4047 ret
= str2sockunion(peer_str
, &su
);
4051 /* Check if existing interface peer */
4052 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
4054 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
);
4056 /* if not interface peer, check peer-group settings */
4057 if (ret
< 0 && !peer
) {
4058 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
4061 "%% Create the peer-group or interface first\n");
4062 return CMD_WARNING_CONFIG_FAILED
;
4067 if (peer_address_self_check(bgp
, &su
)) {
4069 "%% Can not configure the local system as neighbor\n");
4070 return CMD_WARNING_CONFIG_FAILED
;
4072 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
);
4075 /* This peer belongs to peer group. */
4077 case BGP_ERR_PEER_GROUP_MEMBER
:
4079 "%% Peer-group member cannot override remote-as of peer-group\n");
4080 return CMD_WARNING_CONFIG_FAILED
;
4081 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
4083 "%% Peer-group members must be all internal or all external\n");
4084 return CMD_WARNING_CONFIG_FAILED
;
4086 return bgp_vty_return(vty
, ret
);
4089 DEFUN (bgp_default_shutdown
,
4090 bgp_default_shutdown_cmd
,
4091 "[no] bgp default shutdown",
4094 "Configure BGP defaults\n"
4095 "Apply administrative shutdown to newly configured peers\n")
4097 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4098 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
4102 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4104 "Administrative shutdown of the BGP instance\n"
4105 "Add a shutdown message (RFC 8203)\n"
4106 "Shutdown message\n")
4108 char *msgstr
= NULL
;
4110 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4113 msgstr
= argv_concat(argv
, argc
, 3);
4115 bgp_shutdown_enable(bgp
, msgstr
);
4116 XFREE(MTYPE_TMP
, msgstr
);
4121 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4122 BGP_STR
"Administrative shutdown of the BGP instance\n")
4124 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4126 bgp_shutdown_enable(bgp
, NULL
);
4131 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4132 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4134 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4136 bgp_shutdown_disable(bgp
);
4141 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4142 "no bgp shutdown message MSG...", NO_STR BGP_STR
4143 "Administrative shutdown of the BGP instance\n"
4144 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4146 DEFUN (neighbor_remote_as
,
4147 neighbor_remote_as_cmd
,
4148 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4151 "Specify a BGP neighbor\n"
4153 "Internal BGP peer\n"
4154 "External BGP peer\n")
4157 int idx_remote_as
= 3;
4158 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
4159 argv
[idx_remote_as
]->arg
);
4162 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
4164 const char *peer_group_name
,
4167 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4169 int as_type
= AS_UNSPECIFIED
;
4171 struct peer_group
*group
;
4174 group
= peer_group_lookup(bgp
, conf_if
);
4177 vty_out(vty
, "%% Name conflict with peer-group \n");
4178 return CMD_WARNING_CONFIG_FAILED
;
4182 if (as_str
[0] == 'i') {
4183 as_type
= AS_INTERNAL
;
4184 } else if (as_str
[0] == 'e') {
4185 as_type
= AS_EXTERNAL
;
4187 /* Get AS number. */
4188 as
= strtoul(as_str
, NULL
, 10);
4189 as_type
= AS_SPECIFIED
;
4193 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4196 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4198 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4202 vty_out(vty
, "%% BGP failed to create peer\n");
4203 return CMD_WARNING_CONFIG_FAILED
;
4207 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4209 /* Request zebra to initiate IPv6 RAs on this interface. We do
4211 * any unnumbered peer in order to not worry about run-time
4213 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4215 * gets deleted later etc.)
4218 bgp_zebra_initiate_radv(bgp
, peer
);
4221 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4222 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4224 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4226 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4228 /* v6only flag changed. Reset bgp seesion */
4229 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4230 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4231 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4232 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4234 bgp_session_reset(peer
);
4237 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4238 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4239 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4240 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4243 if (peer_group_name
) {
4244 group
= peer_group_lookup(bgp
, peer_group_name
);
4246 vty_out(vty
, "%% Configure the peer-group first\n");
4247 return CMD_WARNING_CONFIG_FAILED
;
4250 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4253 return bgp_vty_return(vty
, ret
);
4256 DEFUN (neighbor_interface_config
,
4257 neighbor_interface_config_cmd
,
4258 "neighbor WORD interface [peer-group PGNAME]",
4260 "Interface name or neighbor tag\n"
4261 "Enable BGP on interface\n"
4262 "Member of the peer-group\n"
4263 "Peer-group name\n")
4266 int idx_peer_group_word
= 4;
4268 if (argc
> idx_peer_group_word
)
4269 return peer_conf_interface_get(
4270 vty
, argv
[idx_word
]->arg
, 0,
4271 argv
[idx_peer_group_word
]->arg
, NULL
);
4273 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0,
4277 DEFUN (neighbor_interface_config_v6only
,
4278 neighbor_interface_config_v6only_cmd
,
4279 "neighbor WORD interface v6only [peer-group PGNAME]",
4281 "Interface name or neighbor tag\n"
4282 "Enable BGP on interface\n"
4283 "Enable BGP with v6 link-local only\n"
4284 "Member of the peer-group\n"
4285 "Peer-group name\n")
4288 int idx_peer_group_word
= 5;
4290 if (argc
> idx_peer_group_word
)
4291 return peer_conf_interface_get(
4292 vty
, argv
[idx_word
]->arg
, 1,
4293 argv
[idx_peer_group_word
]->arg
, NULL
);
4295 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
, NULL
);
4299 DEFUN (neighbor_interface_config_remote_as
,
4300 neighbor_interface_config_remote_as_cmd
,
4301 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4303 "Interface name or neighbor tag\n"
4304 "Enable BGP on interface\n"
4305 "Specify a BGP neighbor\n"
4307 "Internal BGP peer\n"
4308 "External BGP peer\n")
4311 int idx_remote_as
= 4;
4312 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0, NULL
,
4313 argv
[idx_remote_as
]->arg
);
4316 DEFUN (neighbor_interface_v6only_config_remote_as
,
4317 neighbor_interface_v6only_config_remote_as_cmd
,
4318 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4320 "Interface name or neighbor tag\n"
4321 "Enable BGP with v6 link-local only\n"
4322 "Enable BGP on interface\n"
4323 "Specify a BGP neighbor\n"
4325 "Internal BGP peer\n"
4326 "External BGP peer\n")
4329 int idx_remote_as
= 5;
4330 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
,
4331 argv
[idx_remote_as
]->arg
);
4334 DEFUN (neighbor_peer_group
,
4335 neighbor_peer_group_cmd
,
4336 "neighbor WORD peer-group",
4338 "Interface name or neighbor tag\n"
4339 "Configure peer-group\n")
4341 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4344 struct peer_group
*group
;
4346 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4348 vty_out(vty
, "%% Name conflict with interface: \n");
4349 return CMD_WARNING_CONFIG_FAILED
;
4352 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
4354 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
4355 return CMD_WARNING_CONFIG_FAILED
;
4363 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4367 "Specify a BGP neighbor\n"
4369 "Internal BGP peer\n"
4370 "External BGP peer\n")
4372 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4376 struct peer_group
*group
;
4380 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4382 /* look up for neighbor by interface name config. */
4383 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4385 /* Request zebra to terminate IPv6 RAs on this
4388 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4389 peer_notify_unconfig(peer
);
4394 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
4396 peer_group_notify_unconfig(group
);
4397 peer_group_delete(group
);
4399 vty_out(vty
, "%% Create the peer-group first\n");
4400 return CMD_WARNING_CONFIG_FAILED
;
4403 peer
= peer_lookup(bgp
, &su
);
4405 if (peer_dynamic_neighbor(peer
)) {
4407 "%% Operation not allowed on a dynamic neighbor\n");
4408 return CMD_WARNING_CONFIG_FAILED
;
4411 other
= peer
->doppelganger
;
4413 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4414 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4416 peer_notify_unconfig(peer
);
4418 if (other
&& other
->status
!= Deleted
) {
4419 peer_notify_unconfig(other
);
4428 DEFUN (no_neighbor_interface_config
,
4429 no_neighbor_interface_config_cmd
,
4430 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4434 "Configure BGP on interface\n"
4435 "Enable BGP with v6 link-local only\n"
4436 "Member of the peer-group\n"
4438 "Specify a BGP neighbor\n"
4440 "Internal BGP peer\n"
4441 "External BGP peer\n")
4443 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4447 /* look up for neighbor by interface name config. */
4448 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4450 /* Request zebra to terminate IPv6 RAs on this interface. */
4452 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4453 peer_notify_unconfig(peer
);
4456 vty_out(vty
, "%% Create the bgp interface first\n");
4457 return CMD_WARNING_CONFIG_FAILED
;
4462 DEFUN (no_neighbor_peer_group
,
4463 no_neighbor_peer_group_cmd
,
4464 "no neighbor WORD peer-group",
4468 "Configure peer-group\n")
4470 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4472 struct peer_group
*group
;
4474 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4476 peer_group_notify_unconfig(group
);
4477 peer_group_delete(group
);
4479 vty_out(vty
, "%% Create the peer-group first\n");
4480 return CMD_WARNING_CONFIG_FAILED
;
4485 DEFUN (no_neighbor_interface_peer_group_remote_as
,
4486 no_neighbor_interface_peer_group_remote_as_cmd
,
4487 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4490 "Interface name or neighbor tag\n"
4491 "Specify a BGP neighbor\n"
4493 "Internal BGP peer\n"
4494 "External BGP peer\n")
4496 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4498 struct peer_group
*group
;
4501 /* look up for neighbor by interface name config. */
4502 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4504 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
4508 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4510 peer_group_remote_as_delete(group
);
4512 vty_out(vty
, "%% Create the peer-group or interface first\n");
4513 return CMD_WARNING_CONFIG_FAILED
;
4518 DEFUN (neighbor_local_as
,
4519 neighbor_local_as_cmd
,
4520 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4523 "Specify a local-as number\n"
4524 "AS number used as local AS\n")
4532 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4534 return CMD_WARNING_CONFIG_FAILED
;
4536 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4537 ret
= peer_local_as_set(peer
, as
, 0, 0);
4538 return bgp_vty_return(vty
, ret
);
4541 DEFUN (neighbor_local_as_no_prepend
,
4542 neighbor_local_as_no_prepend_cmd
,
4543 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4546 "Specify a local-as number\n"
4547 "AS number used as local AS\n"
4548 "Do not prepend local-as to updates from ebgp peers\n")
4556 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4558 return CMD_WARNING_CONFIG_FAILED
;
4560 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4561 ret
= peer_local_as_set(peer
, as
, 1, 0);
4562 return bgp_vty_return(vty
, ret
);
4565 DEFUN (neighbor_local_as_no_prepend_replace_as
,
4566 neighbor_local_as_no_prepend_replace_as_cmd
,
4567 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4570 "Specify a local-as number\n"
4571 "AS number used as local AS\n"
4572 "Do not prepend local-as to updates from ebgp peers\n"
4573 "Do not prepend local-as to updates from ibgp peers\n")
4581 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4583 return CMD_WARNING_CONFIG_FAILED
;
4585 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4586 ret
= peer_local_as_set(peer
, as
, 1, 1);
4587 return bgp_vty_return(vty
, ret
);
4590 DEFUN (no_neighbor_local_as
,
4591 no_neighbor_local_as_cmd
,
4592 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4596 "Specify a local-as number\n"
4597 "AS number used as local AS\n"
4598 "Do not prepend local-as to updates from ebgp peers\n"
4599 "Do not prepend local-as to updates from ibgp peers\n")
4605 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4607 return CMD_WARNING_CONFIG_FAILED
;
4609 ret
= peer_local_as_unset(peer
);
4610 return bgp_vty_return(vty
, ret
);
4614 DEFUN (neighbor_solo
,
4616 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4619 "Solo peer - part of its own update group\n")
4625 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4627 return CMD_WARNING_CONFIG_FAILED
;
4629 ret
= update_group_adjust_soloness(peer
, 1);
4630 return bgp_vty_return(vty
, ret
);
4633 DEFUN (no_neighbor_solo
,
4634 no_neighbor_solo_cmd
,
4635 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4639 "Solo peer - part of its own update group\n")
4645 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4647 return CMD_WARNING_CONFIG_FAILED
;
4649 ret
= update_group_adjust_soloness(peer
, 0);
4650 return bgp_vty_return(vty
, ret
);
4653 DEFUN (neighbor_password
,
4654 neighbor_password_cmd
,
4655 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
4666 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4668 return CMD_WARNING_CONFIG_FAILED
;
4670 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
4671 return bgp_vty_return(vty
, ret
);
4674 DEFUN (no_neighbor_password
,
4675 no_neighbor_password_cmd
,
4676 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
4687 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4689 return CMD_WARNING_CONFIG_FAILED
;
4691 ret
= peer_password_unset(peer
);
4692 return bgp_vty_return(vty
, ret
);
4695 DEFUN (neighbor_activate
,
4696 neighbor_activate_cmd
,
4697 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4700 "Enable the Address Family for this Neighbor\n")
4706 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4708 return CMD_WARNING_CONFIG_FAILED
;
4710 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
4711 return bgp_vty_return(vty
, ret
);
4714 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
4715 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4716 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4717 "Enable the Address Family for this Neighbor\n")
4719 DEFUN (no_neighbor_activate
,
4720 no_neighbor_activate_cmd
,
4721 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4725 "Enable the Address Family for this Neighbor\n")
4732 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4734 return CMD_WARNING_CONFIG_FAILED
;
4736 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
4737 return bgp_vty_return(vty
, ret
);
4740 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
4741 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4742 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4743 "Enable the Address Family for this Neighbor\n")
4745 DEFUN (neighbor_set_peer_group
,
4746 neighbor_set_peer_group_cmd
,
4747 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4750 "Member of the peer-group\n"
4751 "Peer-group name\n")
4753 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4760 struct peer_group
*group
;
4762 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4764 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4766 vty_out(vty
, "%% Malformed address or name: %s\n",
4767 argv
[idx_peer
]->arg
);
4768 return CMD_WARNING_CONFIG_FAILED
;
4771 if (peer_address_self_check(bgp
, &su
)) {
4773 "%% Can not configure the local system as neighbor\n");
4774 return CMD_WARNING_CONFIG_FAILED
;
4777 /* Disallow for dynamic neighbor. */
4778 peer
= peer_lookup(bgp
, &su
);
4779 if (peer
&& peer_dynamic_neighbor(peer
)) {
4781 "%% Operation not allowed on a dynamic neighbor\n");
4782 return CMD_WARNING_CONFIG_FAILED
;
4786 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4788 vty_out(vty
, "%% Configure the peer-group first\n");
4789 return CMD_WARNING_CONFIG_FAILED
;
4792 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
4794 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
4796 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
4798 return CMD_WARNING_CONFIG_FAILED
;
4801 return bgp_vty_return(vty
, ret
);
4804 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
4805 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4806 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4807 "Member of the peer-group\n"
4808 "Peer-group name\n")
4810 DEFUN (no_neighbor_set_peer_group
,
4811 no_neighbor_set_peer_group_cmd
,
4812 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4816 "Member of the peer-group\n"
4817 "Peer-group name\n")
4819 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4824 struct peer_group
*group
;
4826 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4828 return CMD_WARNING_CONFIG_FAILED
;
4830 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4832 vty_out(vty
, "%% Configure the peer-group first\n");
4833 return CMD_WARNING_CONFIG_FAILED
;
4836 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4837 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4839 peer_notify_unconfig(peer
);
4840 ret
= peer_delete(peer
);
4842 return bgp_vty_return(vty
, ret
);
4845 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
4846 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4847 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4848 "Member of the peer-group\n"
4849 "Peer-group name\n")
4851 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
4852 uint32_t flag
, int set
)
4857 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4859 return CMD_WARNING_CONFIG_FAILED
;
4862 * If 'neighbor <interface>', then this is for directly connected peers,
4863 * we should not accept disable-connected-check.
4865 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
4867 "%s is directly connected peer, cannot accept disable-connected-check\n",
4869 return CMD_WARNING_CONFIG_FAILED
;
4872 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
4873 peer_tx_shutdown_message_unset(peer
);
4876 ret
= peer_flag_set(peer
, flag
);
4878 ret
= peer_flag_unset(peer
, flag
);
4880 return bgp_vty_return(vty
, ret
);
4883 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
4885 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
4888 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
4891 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
4894 /* neighbor passive. */
4895 DEFUN (neighbor_passive
,
4896 neighbor_passive_cmd
,
4897 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
4900 "Don't send open messages to this neighbor\n")
4903 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
4906 DEFUN (no_neighbor_passive
,
4907 no_neighbor_passive_cmd
,
4908 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
4912 "Don't send open messages to this neighbor\n")
4915 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
4918 /* neighbor shutdown. */
4919 DEFUN (neighbor_shutdown_msg
,
4920 neighbor_shutdown_msg_cmd
,
4921 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
4924 "Administratively shut down this neighbor\n"
4925 "Add a shutdown message (RFC 8203)\n"
4926 "Shutdown message\n")
4932 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4936 return CMD_WARNING_CONFIG_FAILED
;
4937 message
= argv_concat(argv
, argc
, 4);
4938 peer_tx_shutdown_message_set(peer
, message
);
4939 XFREE(MTYPE_TMP
, message
);
4942 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
4945 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
4946 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
4947 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4948 "Administratively shut down this neighbor\n")
4950 DEFUN (no_neighbor_shutdown_msg
,
4951 no_neighbor_shutdown_msg_cmd
,
4952 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
4956 "Administratively shut down this neighbor\n"
4957 "Remove a shutdown message (RFC 8203)\n"
4958 "Shutdown message\n")
4962 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4963 PEER_FLAG_SHUTDOWN
);
4966 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
4967 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
4968 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4969 "Administratively shut down this neighbor\n")
4971 DEFUN(neighbor_shutdown_rtt
,
4972 neighbor_shutdown_rtt_cmd
,
4973 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
4976 "Administratively shut down this neighbor\n"
4977 "Shutdown if round-trip-time is higher than expected\n"
4978 "Round-trip-time in milliseconds\n"
4979 "Specify the number of keepalives before shutdown\n"
4980 "The number of keepalives with higher RTT to shutdown\n")
4987 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4990 return CMD_WARNING_CONFIG_FAILED
;
4992 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
4994 if (argv_find(argv
, argc
, "count", &idx_count
))
4995 peer
->rtt_keepalive_conf
=
4996 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
4998 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4999 PEER_FLAG_RTT_SHUTDOWN
);
5002 DEFUN(no_neighbor_shutdown_rtt
,
5003 no_neighbor_shutdown_rtt_cmd
,
5004 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5008 "Administratively shut down this neighbor\n"
5009 "Shutdown if round-trip-time is higher than expected\n"
5010 "Round-trip-time in milliseconds\n"
5011 "Specify the number of keepalives before shutdown\n"
5012 "The number of keepalives with higher RTT to shutdown\n")
5017 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5020 return CMD_WARNING_CONFIG_FAILED
;
5022 peer
->rtt_expected
= 0;
5023 peer
->rtt_keepalive_conf
= 1;
5025 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5026 PEER_FLAG_RTT_SHUTDOWN
);
5029 /* neighbor capability dynamic. */
5030 DEFUN (neighbor_capability_dynamic
,
5031 neighbor_capability_dynamic_cmd
,
5032 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5035 "Advertise capability to the peer\n"
5036 "Advertise dynamic capability to this neighbor\n")
5039 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5040 PEER_FLAG_DYNAMIC_CAPABILITY
);
5043 DEFUN (no_neighbor_capability_dynamic
,
5044 no_neighbor_capability_dynamic_cmd
,
5045 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5049 "Advertise capability to the peer\n"
5050 "Advertise dynamic capability to this neighbor\n")
5053 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5054 PEER_FLAG_DYNAMIC_CAPABILITY
);
5057 /* neighbor dont-capability-negotiate */
5058 DEFUN (neighbor_dont_capability_negotiate
,
5059 neighbor_dont_capability_negotiate_cmd
,
5060 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5063 "Do not perform capability negotiation\n")
5066 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5067 PEER_FLAG_DONT_CAPABILITY
);
5070 DEFUN (no_neighbor_dont_capability_negotiate
,
5071 no_neighbor_dont_capability_negotiate_cmd
,
5072 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5076 "Do not perform capability negotiation\n")
5079 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5080 PEER_FLAG_DONT_CAPABILITY
);
5083 /* neighbor capability extended next hop encoding */
5084 DEFUN (neighbor_capability_enhe
,
5085 neighbor_capability_enhe_cmd
,
5086 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5089 "Advertise capability to the peer\n"
5090 "Advertise extended next-hop capability to the peer\n")
5093 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5094 PEER_FLAG_CAPABILITY_ENHE
);
5097 DEFUN (no_neighbor_capability_enhe
,
5098 no_neighbor_capability_enhe_cmd
,
5099 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5103 "Advertise capability to the peer\n"
5104 "Advertise extended next-hop capability to the peer\n")
5107 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5108 PEER_FLAG_CAPABILITY_ENHE
);
5111 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5112 afi_t afi
, safi_t safi
, uint32_t flag
,
5118 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5120 return CMD_WARNING_CONFIG_FAILED
;
5123 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5125 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5127 return bgp_vty_return(vty
, ret
);
5130 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5131 afi_t afi
, safi_t safi
, uint32_t flag
)
5133 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5136 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5137 afi_t afi
, safi_t safi
, uint32_t flag
)
5139 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5142 /* neighbor capability orf prefix-list. */
5143 DEFUN (neighbor_capability_orf_prefix
,
5144 neighbor_capability_orf_prefix_cmd
,
5145 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5148 "Advertise capability to the peer\n"
5149 "Advertise ORF capability to the peer\n"
5150 "Advertise prefixlist ORF capability to this neighbor\n"
5151 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5152 "Capability to RECEIVE the ORF from this neighbor\n"
5153 "Capability to SEND the ORF to this neighbor\n")
5155 int idx_send_recv
= 5;
5156 char *peer_str
= argv
[1]->arg
;
5158 afi_t afi
= bgp_node_afi(vty
);
5159 safi_t safi
= bgp_node_safi(vty
);
5161 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5163 return CMD_WARNING_CONFIG_FAILED
;
5165 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5166 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5167 PEER_FLAG_ORF_PREFIX_SM
);
5169 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5170 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5171 PEER_FLAG_ORF_PREFIX_RM
);
5173 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5174 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5175 PEER_FLAG_ORF_PREFIX_SM
)
5176 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5177 PEER_FLAG_ORF_PREFIX_RM
);
5179 return CMD_WARNING_CONFIG_FAILED
;
5183 neighbor_capability_orf_prefix
,
5184 neighbor_capability_orf_prefix_hidden_cmd
,
5185 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5186 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5187 "Advertise capability to the peer\n"
5188 "Advertise ORF capability to the peer\n"
5189 "Advertise prefixlist ORF capability to this neighbor\n"
5190 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5191 "Capability to RECEIVE the ORF from this neighbor\n"
5192 "Capability to SEND the ORF to this neighbor\n")
5194 DEFUN (no_neighbor_capability_orf_prefix
,
5195 no_neighbor_capability_orf_prefix_cmd
,
5196 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5200 "Advertise capability to the peer\n"
5201 "Advertise ORF capability to the peer\n"
5202 "Advertise prefixlist ORF capability to this neighbor\n"
5203 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5204 "Capability to RECEIVE the ORF from this neighbor\n"
5205 "Capability to SEND the ORF to this neighbor\n")
5207 int idx_send_recv
= 6;
5208 char *peer_str
= argv
[2]->arg
;
5210 afi_t afi
= bgp_node_afi(vty
);
5211 safi_t safi
= bgp_node_safi(vty
);
5213 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5215 return CMD_WARNING_CONFIG_FAILED
;
5217 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5218 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5219 PEER_FLAG_ORF_PREFIX_SM
);
5221 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5222 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5223 PEER_FLAG_ORF_PREFIX_RM
);
5225 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5226 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5227 PEER_FLAG_ORF_PREFIX_SM
)
5228 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5229 PEER_FLAG_ORF_PREFIX_RM
);
5231 return CMD_WARNING_CONFIG_FAILED
;
5235 no_neighbor_capability_orf_prefix
,
5236 no_neighbor_capability_orf_prefix_hidden_cmd
,
5237 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5238 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5239 "Advertise capability to the peer\n"
5240 "Advertise ORF capability to the peer\n"
5241 "Advertise prefixlist ORF capability to this neighbor\n"
5242 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5243 "Capability to RECEIVE the ORF from this neighbor\n"
5244 "Capability to SEND the ORF to this neighbor\n")
5246 /* neighbor next-hop-self. */
5247 DEFUN (neighbor_nexthop_self
,
5248 neighbor_nexthop_self_cmd
,
5249 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5252 "Disable the next hop calculation for this neighbor\n")
5255 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5256 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
5259 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5260 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5261 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5262 "Disable the next hop calculation for this neighbor\n")
5264 /* neighbor next-hop-self. */
5265 DEFUN (neighbor_nexthop_self_force
,
5266 neighbor_nexthop_self_force_cmd
,
5267 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5270 "Disable the next hop calculation for this neighbor\n"
5271 "Set the next hop to self for reflected routes\n")
5274 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5276 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5279 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5280 neighbor_nexthop_self_force_hidden_cmd
,
5281 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5282 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5283 "Disable the next hop calculation for this neighbor\n"
5284 "Set the next hop to self for reflected routes\n")
5286 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5287 neighbor_nexthop_self_all_hidden_cmd
,
5288 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5289 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5290 "Disable the next hop calculation for this neighbor\n"
5291 "Set the next hop to self for reflected routes\n")
5293 DEFUN (no_neighbor_nexthop_self
,
5294 no_neighbor_nexthop_self_cmd
,
5295 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5299 "Disable the next hop calculation for this neighbor\n")
5302 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5303 bgp_node_afi(vty
), bgp_node_safi(vty
),
5304 PEER_FLAG_NEXTHOP_SELF
);
5307 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5308 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5309 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5310 "Disable the next hop calculation for this neighbor\n")
5312 DEFUN (no_neighbor_nexthop_self_force
,
5313 no_neighbor_nexthop_self_force_cmd
,
5314 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5318 "Disable the next hop calculation for this neighbor\n"
5319 "Set the next hop to self for reflected routes\n")
5322 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5323 bgp_node_afi(vty
), bgp_node_safi(vty
),
5324 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5327 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5328 no_neighbor_nexthop_self_force_hidden_cmd
,
5329 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5330 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5331 "Disable the next hop calculation for this neighbor\n"
5332 "Set the next hop to self for reflected routes\n")
5334 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5335 no_neighbor_nexthop_self_all_hidden_cmd
,
5336 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5337 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5338 "Disable the next hop calculation for this neighbor\n"
5339 "Set the next hop to self for reflected routes\n")
5341 /* neighbor as-override */
5342 DEFUN (neighbor_as_override
,
5343 neighbor_as_override_cmd
,
5344 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5347 "Override ASNs in outbound updates if aspath equals remote-as\n")
5350 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5351 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
5354 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5355 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5356 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5357 "Override ASNs in outbound updates if aspath equals remote-as\n")
5359 DEFUN (no_neighbor_as_override
,
5360 no_neighbor_as_override_cmd
,
5361 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5365 "Override ASNs in outbound updates if aspath equals remote-as\n")
5368 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5369 bgp_node_afi(vty
), bgp_node_safi(vty
),
5370 PEER_FLAG_AS_OVERRIDE
);
5373 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5374 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5375 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5376 "Override ASNs in outbound updates if aspath equals remote-as\n")
5378 /* neighbor remove-private-AS. */
5379 DEFUN (neighbor_remove_private_as
,
5380 neighbor_remove_private_as_cmd
,
5381 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5384 "Remove private ASNs in outbound updates\n")
5387 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5389 PEER_FLAG_REMOVE_PRIVATE_AS
);
5392 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5393 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5394 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5395 "Remove private ASNs in outbound updates\n")
5397 DEFUN (neighbor_remove_private_as_all
,
5398 neighbor_remove_private_as_all_cmd
,
5399 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5402 "Remove private ASNs in outbound updates\n"
5403 "Apply to all AS numbers\n")
5406 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5408 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5411 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5412 neighbor_remove_private_as_all_hidden_cmd
,
5413 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5414 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5415 "Remove private ASNs in outbound updates\n"
5416 "Apply to all AS numbers")
5418 DEFUN (neighbor_remove_private_as_replace_as
,
5419 neighbor_remove_private_as_replace_as_cmd
,
5420 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5423 "Remove private ASNs in outbound updates\n"
5424 "Replace private ASNs with our ASN in outbound updates\n")
5427 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5429 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5432 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5433 neighbor_remove_private_as_replace_as_hidden_cmd
,
5434 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5435 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5436 "Remove private ASNs in outbound updates\n"
5437 "Replace private ASNs with our ASN in outbound updates\n")
5439 DEFUN (neighbor_remove_private_as_all_replace_as
,
5440 neighbor_remove_private_as_all_replace_as_cmd
,
5441 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5444 "Remove private ASNs in outbound updates\n"
5445 "Apply to all AS numbers\n"
5446 "Replace private ASNs with our ASN in outbound updates\n")
5449 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5451 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5455 neighbor_remove_private_as_all_replace_as
,
5456 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5457 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5458 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5459 "Remove private ASNs in outbound updates\n"
5460 "Apply to all AS numbers\n"
5461 "Replace private ASNs with our ASN in outbound updates\n")
5463 DEFUN (no_neighbor_remove_private_as
,
5464 no_neighbor_remove_private_as_cmd
,
5465 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5469 "Remove private ASNs in outbound updates\n")
5472 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5473 bgp_node_afi(vty
), bgp_node_safi(vty
),
5474 PEER_FLAG_REMOVE_PRIVATE_AS
);
5477 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5478 no_neighbor_remove_private_as_hidden_cmd
,
5479 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5480 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5481 "Remove private ASNs in outbound updates\n")
5483 DEFUN (no_neighbor_remove_private_as_all
,
5484 no_neighbor_remove_private_as_all_cmd
,
5485 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5489 "Remove private ASNs in outbound updates\n"
5490 "Apply to all AS numbers\n")
5493 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5494 bgp_node_afi(vty
), bgp_node_safi(vty
),
5495 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5498 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5499 no_neighbor_remove_private_as_all_hidden_cmd
,
5500 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5501 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5502 "Remove private ASNs in outbound updates\n"
5503 "Apply to all AS numbers\n")
5505 DEFUN (no_neighbor_remove_private_as_replace_as
,
5506 no_neighbor_remove_private_as_replace_as_cmd
,
5507 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5511 "Remove private ASNs in outbound updates\n"
5512 "Replace private ASNs with our ASN in outbound updates\n")
5515 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5516 bgp_node_afi(vty
), bgp_node_safi(vty
),
5517 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5520 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
5521 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
5522 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5523 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5524 "Remove private ASNs in outbound updates\n"
5525 "Replace private ASNs with our ASN in outbound updates\n")
5527 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
5528 no_neighbor_remove_private_as_all_replace_as_cmd
,
5529 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5533 "Remove private ASNs in outbound updates\n"
5534 "Apply to all AS numbers\n"
5535 "Replace private ASNs with our ASN in outbound updates\n")
5538 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5539 bgp_node_afi(vty
), bgp_node_safi(vty
),
5540 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5544 no_neighbor_remove_private_as_all_replace_as
,
5545 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5546 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5547 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5548 "Remove private ASNs in outbound updates\n"
5549 "Apply to all AS numbers\n"
5550 "Replace private ASNs with our ASN in outbound updates\n")
5553 /* neighbor send-community. */
5554 DEFUN (neighbor_send_community
,
5555 neighbor_send_community_cmd
,
5556 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5559 "Send Community attribute to this neighbor\n")
5563 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5565 PEER_FLAG_SEND_COMMUNITY
);
5568 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
5569 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5570 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5571 "Send Community attribute to this neighbor\n")
5573 DEFUN (no_neighbor_send_community
,
5574 no_neighbor_send_community_cmd
,
5575 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5579 "Send Community attribute to this neighbor\n")
5583 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5584 bgp_node_afi(vty
), bgp_node_safi(vty
),
5585 PEER_FLAG_SEND_COMMUNITY
);
5588 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
5589 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5590 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5591 "Send Community attribute to this neighbor\n")
5593 /* neighbor send-community extended. */
5594 DEFUN (neighbor_send_community_type
,
5595 neighbor_send_community_type_cmd
,
5596 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5599 "Send Community attribute to this neighbor\n"
5600 "Send Standard and Extended Community attributes\n"
5601 "Send Standard, Large and Extended Community attributes\n"
5602 "Send Extended Community attributes\n"
5603 "Send Standard Community attributes\n"
5604 "Send Large Community attributes\n")
5606 const char *type
= argv
[argc
- 1]->text
;
5607 char *peer_str
= argv
[1]->arg
;
5609 afi_t afi
= bgp_node_afi(vty
);
5610 safi_t safi
= bgp_node_safi(vty
);
5612 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5614 return CMD_WARNING_CONFIG_FAILED
;
5616 if (strmatch(type
, "standard"))
5617 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5618 PEER_FLAG_SEND_COMMUNITY
);
5620 if (strmatch(type
, "extended"))
5621 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5622 PEER_FLAG_SEND_EXT_COMMUNITY
);
5624 if (strmatch(type
, "large"))
5625 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5626 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5628 if (strmatch(type
, "both")) {
5629 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5630 PEER_FLAG_SEND_COMMUNITY
)
5631 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5632 PEER_FLAG_SEND_EXT_COMMUNITY
);
5634 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5635 PEER_FLAG_SEND_COMMUNITY
)
5636 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5637 PEER_FLAG_SEND_EXT_COMMUNITY
)
5638 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5639 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5643 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
5644 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5645 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5646 "Send Community attribute to this neighbor\n"
5647 "Send Standard and Extended Community attributes\n"
5648 "Send Standard, Large and Extended Community attributes\n"
5649 "Send Extended Community attributes\n"
5650 "Send Standard Community attributes\n"
5651 "Send Large Community attributes\n")
5653 DEFUN (no_neighbor_send_community_type
,
5654 no_neighbor_send_community_type_cmd
,
5655 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5659 "Send Community attribute to this neighbor\n"
5660 "Send Standard and Extended Community attributes\n"
5661 "Send Standard, Large and Extended Community attributes\n"
5662 "Send Extended Community attributes\n"
5663 "Send Standard Community attributes\n"
5664 "Send Large Community attributes\n")
5666 const char *type
= argv
[argc
- 1]->text
;
5667 char *peer_str
= argv
[2]->arg
;
5669 afi_t afi
= bgp_node_afi(vty
);
5670 safi_t safi
= bgp_node_safi(vty
);
5672 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5674 return CMD_WARNING_CONFIG_FAILED
;
5676 if (strmatch(type
, "standard"))
5677 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5678 PEER_FLAG_SEND_COMMUNITY
);
5680 if (strmatch(type
, "extended"))
5681 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5682 PEER_FLAG_SEND_EXT_COMMUNITY
);
5684 if (strmatch(type
, "large"))
5685 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5686 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5688 if (strmatch(type
, "both")) {
5690 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5691 PEER_FLAG_SEND_COMMUNITY
)
5692 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5693 PEER_FLAG_SEND_EXT_COMMUNITY
);
5696 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5697 PEER_FLAG_SEND_COMMUNITY
)
5698 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5699 PEER_FLAG_SEND_EXT_COMMUNITY
)
5700 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5701 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5705 no_neighbor_send_community_type
,
5706 no_neighbor_send_community_type_hidden_cmd
,
5707 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5708 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5709 "Send Community attribute to this neighbor\n"
5710 "Send Standard and Extended Community attributes\n"
5711 "Send Standard, Large and Extended Community attributes\n"
5712 "Send Extended Community attributes\n"
5713 "Send Standard Community attributes\n"
5714 "Send Large Community attributes\n")
5716 /* neighbor soft-reconfig. */
5717 DEFUN (neighbor_soft_reconfiguration
,
5718 neighbor_soft_reconfiguration_cmd
,
5719 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5722 "Per neighbor soft reconfiguration\n"
5723 "Allow inbound soft reconfiguration for this neighbor\n")
5726 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5728 PEER_FLAG_SOFT_RECONFIG
);
5731 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
5732 neighbor_soft_reconfiguration_hidden_cmd
,
5733 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5734 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5735 "Per neighbor soft reconfiguration\n"
5736 "Allow inbound soft reconfiguration for this neighbor\n")
5738 DEFUN (no_neighbor_soft_reconfiguration
,
5739 no_neighbor_soft_reconfiguration_cmd
,
5740 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5744 "Per neighbor soft reconfiguration\n"
5745 "Allow inbound soft reconfiguration for this neighbor\n")
5748 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5749 bgp_node_afi(vty
), bgp_node_safi(vty
),
5750 PEER_FLAG_SOFT_RECONFIG
);
5753 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
5754 no_neighbor_soft_reconfiguration_hidden_cmd
,
5755 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5756 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5757 "Per neighbor soft reconfiguration\n"
5758 "Allow inbound soft reconfiguration for this neighbor\n")
5760 DEFUN (neighbor_route_reflector_client
,
5761 neighbor_route_reflector_client_cmd
,
5762 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5765 "Configure a neighbor as Route Reflector client\n")
5771 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5773 return CMD_WARNING_CONFIG_FAILED
;
5775 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5777 PEER_FLAG_REFLECTOR_CLIENT
);
5780 ALIAS_HIDDEN(neighbor_route_reflector_client
,
5781 neighbor_route_reflector_client_hidden_cmd
,
5782 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5783 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5784 "Configure a neighbor as Route Reflector client\n")
5786 DEFUN (no_neighbor_route_reflector_client
,
5787 no_neighbor_route_reflector_client_cmd
,
5788 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5792 "Configure a neighbor as Route Reflector client\n")
5795 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5796 bgp_node_afi(vty
), bgp_node_safi(vty
),
5797 PEER_FLAG_REFLECTOR_CLIENT
);
5800 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
5801 no_neighbor_route_reflector_client_hidden_cmd
,
5802 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5803 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5804 "Configure a neighbor as Route Reflector client\n")
5806 /* neighbor route-server-client. */
5807 DEFUN (neighbor_route_server_client
,
5808 neighbor_route_server_client_cmd
,
5809 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5812 "Configure a neighbor as Route Server client\n")
5817 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5819 return CMD_WARNING_CONFIG_FAILED
;
5820 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5822 PEER_FLAG_RSERVER_CLIENT
);
5825 ALIAS_HIDDEN(neighbor_route_server_client
,
5826 neighbor_route_server_client_hidden_cmd
,
5827 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5828 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5829 "Configure a neighbor as Route Server client\n")
5831 DEFUN (no_neighbor_route_server_client
,
5832 no_neighbor_route_server_client_cmd
,
5833 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5837 "Configure a neighbor as Route Server client\n")
5840 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5841 bgp_node_afi(vty
), bgp_node_safi(vty
),
5842 PEER_FLAG_RSERVER_CLIENT
);
5845 ALIAS_HIDDEN(no_neighbor_route_server_client
,
5846 no_neighbor_route_server_client_hidden_cmd
,
5847 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5848 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5849 "Configure a neighbor as Route Server client\n")
5851 DEFUN (neighbor_nexthop_local_unchanged
,
5852 neighbor_nexthop_local_unchanged_cmd
,
5853 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
5856 "Configure treatment of outgoing link-local nexthop attribute\n"
5857 "Leave link-local nexthop unchanged for this peer\n")
5860 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5862 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
5865 DEFUN (no_neighbor_nexthop_local_unchanged
,
5866 no_neighbor_nexthop_local_unchanged_cmd
,
5867 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
5871 "Configure treatment of outgoing link-local-nexthop attribute\n"
5872 "Leave link-local nexthop unchanged for this peer\n")
5875 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5876 bgp_node_afi(vty
), bgp_node_safi(vty
),
5877 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
5880 DEFUN (neighbor_attr_unchanged
,
5881 neighbor_attr_unchanged_cmd
,
5882 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
5885 "BGP attribute is propagated unchanged to this neighbor\n"
5886 "As-path attribute\n"
5887 "Nexthop attribute\n"
5891 char *peer_str
= argv
[1]->arg
;
5893 bool aspath
= false;
5894 bool nexthop
= false;
5896 afi_t afi
= bgp_node_afi(vty
);
5897 safi_t safi
= bgp_node_safi(vty
);
5900 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5902 return CMD_WARNING_CONFIG_FAILED
;
5904 if (argv_find(argv
, argc
, "as-path", &idx
))
5908 if (argv_find(argv
, argc
, "next-hop", &idx
))
5912 if (argv_find(argv
, argc
, "med", &idx
))
5915 /* no flags means all of them! */
5916 if (!aspath
&& !nexthop
&& !med
) {
5917 ret
= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5918 PEER_FLAG_AS_PATH_UNCHANGED
);
5919 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5920 PEER_FLAG_NEXTHOP_UNCHANGED
);
5921 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5922 PEER_FLAG_MED_UNCHANGED
);
5925 if (peer_af_flag_check(peer
, afi
, safi
,
5926 PEER_FLAG_AS_PATH_UNCHANGED
)) {
5927 ret
|= peer_af_flag_unset_vty(
5928 vty
, peer_str
, afi
, safi
,
5929 PEER_FLAG_AS_PATH_UNCHANGED
);
5932 ret
|= peer_af_flag_set_vty(
5933 vty
, peer_str
, afi
, safi
,
5934 PEER_FLAG_AS_PATH_UNCHANGED
);
5937 if (peer_af_flag_check(peer
, afi
, safi
,
5938 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
5939 ret
|= peer_af_flag_unset_vty(
5940 vty
, peer_str
, afi
, safi
,
5941 PEER_FLAG_NEXTHOP_UNCHANGED
);
5944 ret
|= peer_af_flag_set_vty(
5945 vty
, peer_str
, afi
, safi
,
5946 PEER_FLAG_NEXTHOP_UNCHANGED
);
5949 if (peer_af_flag_check(peer
, afi
, safi
,
5950 PEER_FLAG_MED_UNCHANGED
)) {
5951 ret
|= peer_af_flag_unset_vty(
5952 vty
, peer_str
, afi
, safi
,
5953 PEER_FLAG_MED_UNCHANGED
);
5956 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5957 PEER_FLAG_MED_UNCHANGED
);
5964 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
5965 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
5966 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5967 "BGP attribute is propagated unchanged to this neighbor\n"
5968 "As-path attribute\n"
5969 "Nexthop attribute\n"
5972 DEFUN (no_neighbor_attr_unchanged
,
5973 no_neighbor_attr_unchanged_cmd
,
5974 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
5978 "BGP attribute is propagated unchanged to this neighbor\n"
5979 "As-path attribute\n"
5980 "Nexthop attribute\n"
5984 char *peer_str
= argv
[2]->arg
;
5986 bool aspath
= false;
5987 bool nexthop
= false;
5989 afi_t afi
= bgp_node_afi(vty
);
5990 safi_t safi
= bgp_node_safi(vty
);
5993 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5995 return CMD_WARNING_CONFIG_FAILED
;
5997 if (argv_find(argv
, argc
, "as-path", &idx
))
6001 if (argv_find(argv
, argc
, "next-hop", &idx
))
6005 if (argv_find(argv
, argc
, "med", &idx
))
6008 if (!aspath
&& !nexthop
&& !med
) // no flags means all of them!
6009 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6010 PEER_FLAG_AS_PATH_UNCHANGED
)
6011 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6012 PEER_FLAG_NEXTHOP_UNCHANGED
)
6013 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6014 PEER_FLAG_MED_UNCHANGED
);
6017 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6018 PEER_FLAG_AS_PATH_UNCHANGED
);
6021 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6022 PEER_FLAG_NEXTHOP_UNCHANGED
);
6025 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6026 PEER_FLAG_MED_UNCHANGED
);
6032 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6033 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6034 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6035 "BGP attribute is propagated unchanged to this neighbor\n"
6036 "As-path attribute\n"
6037 "Nexthop attribute\n"
6040 /* EBGP multihop configuration. */
6041 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
6042 const char *ttl_str
)
6047 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6049 return CMD_WARNING_CONFIG_FAILED
;
6052 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
6057 ttl
= strtoul(ttl_str
, NULL
, 10);
6059 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
6062 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
6066 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6068 return CMD_WARNING_CONFIG_FAILED
;
6070 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
6073 /* neighbor ebgp-multihop. */
6074 DEFUN (neighbor_ebgp_multihop
,
6075 neighbor_ebgp_multihop_cmd
,
6076 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6079 "Allow EBGP neighbors not on directly connected networks\n")
6082 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6085 DEFUN (neighbor_ebgp_multihop_ttl
,
6086 neighbor_ebgp_multihop_ttl_cmd
,
6087 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6090 "Allow EBGP neighbors not on directly connected networks\n"
6091 "maximum hop count\n")
6095 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
6096 argv
[idx_number
]->arg
);
6099 DEFUN (no_neighbor_ebgp_multihop
,
6100 no_neighbor_ebgp_multihop_cmd
,
6101 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6105 "Allow EBGP neighbors not on directly connected networks\n"
6106 "maximum hop count\n")
6109 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
6113 /* disable-connected-check */
6114 DEFUN (neighbor_disable_connected_check
,
6115 neighbor_disable_connected_check_cmd
,
6116 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6119 "one-hop away EBGP peer using loopback address\n"
6120 "Enforce EBGP neighbors perform multihop\n")
6123 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6124 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6127 DEFUN (no_neighbor_disable_connected_check
,
6128 no_neighbor_disable_connected_check_cmd
,
6129 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6133 "one-hop away EBGP peer using loopback address\n"
6134 "Enforce EBGP neighbors perform multihop\n")
6137 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6138 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6142 /* enforce-first-as */
6143 DEFUN (neighbor_enforce_first_as
,
6144 neighbor_enforce_first_as_cmd
,
6145 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6148 "Enforce the first AS for EBGP routes\n")
6152 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6153 PEER_FLAG_ENFORCE_FIRST_AS
);
6156 DEFUN (no_neighbor_enforce_first_as
,
6157 no_neighbor_enforce_first_as_cmd
,
6158 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6162 "Enforce the first AS for EBGP routes\n")
6166 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6167 PEER_FLAG_ENFORCE_FIRST_AS
);
6171 DEFUN (neighbor_description
,
6172 neighbor_description_cmd
,
6173 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6176 "Neighbor specific description\n"
6177 "Up to 80 characters describing this neighbor\n")
6184 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6186 return CMD_WARNING_CONFIG_FAILED
;
6188 str
= argv_concat(argv
, argc
, idx_line
);
6190 peer_description_set(peer
, str
);
6192 XFREE(MTYPE_TMP
, str
);
6197 DEFUN (no_neighbor_description
,
6198 no_neighbor_description_cmd
,
6199 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6203 "Neighbor specific description\n")
6208 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6210 return CMD_WARNING_CONFIG_FAILED
;
6212 peer_description_unset(peer
);
6217 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6218 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6219 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6220 "Neighbor specific description\n"
6221 "Up to 80 characters describing this neighbor\n")
6223 /* Neighbor update-source. */
6224 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
6225 const char *source_str
)
6231 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6233 return CMD_WARNING_CONFIG_FAILED
;
6239 if (str2sockunion(source_str
, &su
) == 0)
6240 peer_update_source_addr_set(peer
, &su
);
6242 if (str2prefix(source_str
, &p
)) {
6244 "%% Invalid update-source, remove prefix length \n");
6245 return CMD_WARNING_CONFIG_FAILED
;
6247 peer_update_source_if_set(peer
, source_str
);
6250 peer_update_source_unset(peer
);
6255 #define BGP_UPDATE_SOURCE_HELP_STR \
6258 "Interface name (requires zebra to be running)\n"
6260 DEFUN (neighbor_update_source
,
6261 neighbor_update_source_cmd
,
6262 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6265 "Source of routing updates\n"
6266 BGP_UPDATE_SOURCE_HELP_STR
)
6270 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
6271 argv
[idx_peer_2
]->arg
);
6274 DEFUN (no_neighbor_update_source
,
6275 no_neighbor_update_source_cmd
,
6276 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6280 "Source of routing updates\n"
6281 BGP_UPDATE_SOURCE_HELP_STR
)
6284 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6287 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
6288 afi_t afi
, safi_t safi
,
6289 const char *rmap
, int set
)
6293 struct route_map
*route_map
= NULL
;
6295 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6297 return CMD_WARNING_CONFIG_FAILED
;
6301 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
6302 ret
= peer_default_originate_set(peer
, afi
, safi
,
6305 ret
= peer_default_originate_unset(peer
, afi
, safi
);
6307 return bgp_vty_return(vty
, ret
);
6310 /* neighbor default-originate. */
6311 DEFUN (neighbor_default_originate
,
6312 neighbor_default_originate_cmd
,
6313 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6316 "Originate default route to this neighbor\n")
6319 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6321 bgp_node_safi(vty
), NULL
, 1);
6324 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
6325 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6326 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6327 "Originate default route to this neighbor\n")
6329 DEFUN (neighbor_default_originate_rmap
,
6330 neighbor_default_originate_rmap_cmd
,
6331 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
6334 "Originate default route to this neighbor\n"
6335 "Route-map to specify criteria to originate default\n"
6340 return peer_default_originate_set_vty(
6341 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6342 argv
[idx_word
]->arg
, 1);
6346 neighbor_default_originate_rmap
,
6347 neighbor_default_originate_rmap_hidden_cmd
,
6348 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
6349 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6350 "Originate default route to this neighbor\n"
6351 "Route-map to specify criteria to originate default\n"
6354 DEFUN (no_neighbor_default_originate
,
6355 no_neighbor_default_originate_cmd
,
6356 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
6360 "Originate default route to this neighbor\n"
6361 "Route-map to specify criteria to originate default\n"
6365 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6367 bgp_node_safi(vty
), NULL
, 0);
6371 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
6372 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
6373 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6374 "Originate default route to this neighbor\n"
6375 "Route-map to specify criteria to originate default\n"
6379 /* Set neighbor's BGP port. */
6380 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
6381 const char *port_str
)
6387 peer
= peer_lookup_vty(vty
, ip_str
);
6389 return CMD_WARNING_CONFIG_FAILED
;
6392 sp
= getservbyname("bgp", "tcp");
6393 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
6395 port
= strtoul(port_str
, NULL
, 10);
6398 peer_port_set(peer
, port
);
6403 /* Set specified peer's BGP port. */
6404 DEFUN (neighbor_port
,
6406 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
6409 "Neighbor's BGP port\n"
6410 "TCP port number\n")
6414 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
6415 argv
[idx_number
]->arg
);
6418 DEFUN (no_neighbor_port
,
6419 no_neighbor_port_cmd
,
6420 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
6424 "Neighbor's BGP port\n"
6425 "TCP port number\n")
6428 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
6432 /* neighbor weight. */
6433 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6434 safi_t safi
, const char *weight_str
)
6438 unsigned long weight
;
6440 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6442 return CMD_WARNING_CONFIG_FAILED
;
6444 weight
= strtoul(weight_str
, NULL
, 10);
6446 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
6447 return bgp_vty_return(vty
, ret
);
6450 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6456 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6458 return CMD_WARNING_CONFIG_FAILED
;
6460 ret
= peer_weight_unset(peer
, afi
, safi
);
6461 return bgp_vty_return(vty
, ret
);
6464 DEFUN (neighbor_weight
,
6465 neighbor_weight_cmd
,
6466 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
6469 "Set default weight for routes from this neighbor\n"
6474 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6475 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
6478 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
6479 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
6480 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6481 "Set default weight for routes from this neighbor\n"
6484 DEFUN (no_neighbor_weight
,
6485 no_neighbor_weight_cmd
,
6486 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
6490 "Set default weight for routes from this neighbor\n"
6494 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
6495 bgp_node_afi(vty
), bgp_node_safi(vty
));
6498 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
6499 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
6500 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6501 "Set default weight for routes from this neighbor\n"
6505 /* Override capability negotiation. */
6506 DEFUN (neighbor_override_capability
,
6507 neighbor_override_capability_cmd
,
6508 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
6511 "Override capability negotiation result\n")
6514 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6515 PEER_FLAG_OVERRIDE_CAPABILITY
);
6518 DEFUN (no_neighbor_override_capability
,
6519 no_neighbor_override_capability_cmd
,
6520 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
6524 "Override capability negotiation result\n")
6527 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6528 PEER_FLAG_OVERRIDE_CAPABILITY
);
6531 DEFUN (neighbor_strict_capability
,
6532 neighbor_strict_capability_cmd
,
6533 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
6536 "Strict capability negotiation match\n")
6540 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6541 PEER_FLAG_STRICT_CAP_MATCH
);
6544 DEFUN (no_neighbor_strict_capability
,
6545 no_neighbor_strict_capability_cmd
,
6546 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
6550 "Strict capability negotiation match\n")
6554 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6555 PEER_FLAG_STRICT_CAP_MATCH
);
6558 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
6559 const char *keep_str
, const char *hold_str
)
6566 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6568 return CMD_WARNING_CONFIG_FAILED
;
6570 keepalive
= strtoul(keep_str
, NULL
, 10);
6571 holdtime
= strtoul(hold_str
, NULL
, 10);
6573 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
6575 return bgp_vty_return(vty
, ret
);
6578 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
6583 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6585 return CMD_WARNING_CONFIG_FAILED
;
6587 ret
= peer_timers_unset(peer
);
6589 return bgp_vty_return(vty
, ret
);
6592 DEFUN (neighbor_timers
,
6593 neighbor_timers_cmd
,
6594 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
6597 "BGP per neighbor timers\n"
6598 "Keepalive interval\n"
6603 int idx_number_2
= 4;
6604 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
6605 argv
[idx_number
]->arg
,
6606 argv
[idx_number_2
]->arg
);
6609 DEFUN (no_neighbor_timers
,
6610 no_neighbor_timers_cmd
,
6611 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
6615 "BGP per neighbor timers\n"
6616 "Keepalive interval\n"
6620 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
6624 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
6625 const char *time_str
)
6631 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6633 return CMD_WARNING_CONFIG_FAILED
;
6635 connect
= strtoul(time_str
, NULL
, 10);
6637 ret
= peer_timers_connect_set(peer
, connect
);
6639 return bgp_vty_return(vty
, ret
);
6642 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
6647 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6649 return CMD_WARNING_CONFIG_FAILED
;
6651 ret
= peer_timers_connect_unset(peer
);
6653 return bgp_vty_return(vty
, ret
);
6656 DEFUN (neighbor_timers_connect
,
6657 neighbor_timers_connect_cmd
,
6658 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
6661 "BGP per neighbor timers\n"
6662 "BGP connect timer\n"
6667 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
6668 argv
[idx_number
]->arg
);
6671 DEFUN (no_neighbor_timers_connect
,
6672 no_neighbor_timers_connect_cmd
,
6673 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
6677 "BGP per neighbor timers\n"
6678 "BGP connect timer\n"
6682 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
6685 DEFPY (neighbor_timers_delayopen
,
6686 neighbor_timers_delayopen_cmd
,
6687 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
6690 "BGP per neighbor timers\n"
6691 "RFC 4271 DelayOpenTimer\n"
6692 "DelayOpenTime timer interval\n")
6696 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
6698 return CMD_WARNING_CONFIG_FAILED
;
6701 if (peer_timers_delayopen_unset(peer
))
6702 return CMD_WARNING_CONFIG_FAILED
;
6704 if (peer_timers_delayopen_set(peer
, interval
))
6705 return CMD_WARNING_CONFIG_FAILED
;
6711 DEFPY (no_neighbor_timers_delayopen
,
6712 no_neighbor_timers_delayopen_cmd
,
6713 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
6717 "BGP per neighbor timers\n"
6718 "RFC 4271 DelayOpenTimer\n"
6719 "DelayOpenTime timer interval\n")
6723 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
6725 return CMD_WARNING_CONFIG_FAILED
;
6727 if (peer_timers_delayopen_unset(peer
))
6728 return CMD_WARNING_CONFIG_FAILED
;
6733 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
6734 const char *time_str
, int set
)
6738 uint32_t routeadv
= 0;
6740 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6742 return CMD_WARNING_CONFIG_FAILED
;
6745 routeadv
= strtoul(time_str
, NULL
, 10);
6748 ret
= peer_advertise_interval_set(peer
, routeadv
);
6750 ret
= peer_advertise_interval_unset(peer
);
6752 return bgp_vty_return(vty
, ret
);
6755 DEFUN (neighbor_advertise_interval
,
6756 neighbor_advertise_interval_cmd
,
6757 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
6760 "Minimum interval between sending BGP routing updates\n"
6761 "time in seconds\n")
6765 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
6766 argv
[idx_number
]->arg
, 1);
6769 DEFUN (no_neighbor_advertise_interval
,
6770 no_neighbor_advertise_interval_cmd
,
6771 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
6775 "Minimum interval between sending BGP routing updates\n"
6776 "time in seconds\n")
6779 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
6783 /* Time to wait before processing route-map updates */
6784 DEFUN (bgp_set_route_map_delay_timer
,
6785 bgp_set_route_map_delay_timer_cmd
,
6786 "bgp route-map delay-timer (0-600)",
6788 "BGP route-map delay timer\n"
6789 "Time in secs to wait before processing route-map changes\n"
6790 "0 disables the timer, no route updates happen when route-maps change\n")
6793 uint32_t rmap_delay_timer
;
6795 if (argv
[idx_number
]->arg
) {
6796 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6797 bm
->rmap_update_timer
= rmap_delay_timer
;
6799 /* if the dynamic update handling is being disabled, and a timer
6801 * running, stop the timer and act as if the timer has already
6804 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
6805 BGP_TIMER_OFF(bm
->t_rmap_update
);
6806 thread_execute(bm
->master
, bgp_route_map_update_timer
,
6811 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
6812 return CMD_WARNING_CONFIG_FAILED
;
6816 DEFUN (no_bgp_set_route_map_delay_timer
,
6817 no_bgp_set_route_map_delay_timer_cmd
,
6818 "no bgp route-map delay-timer [(0-600)]",
6821 "Default BGP route-map delay timer\n"
6822 "Reset to default time to wait for processing route-map changes\n"
6823 "0 disables the timer, no route updates happen when route-maps change\n")
6826 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
6831 /* neighbor interface */
6832 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
6837 peer
= peer_lookup_vty(vty
, ip_str
);
6838 if (!peer
|| peer
->conf_if
) {
6839 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
6840 return CMD_WARNING_CONFIG_FAILED
;
6844 peer_interface_set(peer
, str
);
6846 peer_interface_unset(peer
);
6851 DEFUN (neighbor_interface
,
6852 neighbor_interface_cmd
,
6853 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
6861 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
6864 DEFUN (no_neighbor_interface
,
6865 no_neighbor_interface_cmd
,
6866 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
6874 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6877 DEFUN (neighbor_distribute_list
,
6878 neighbor_distribute_list_cmd
,
6879 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
6882 "Filter updates to/from this neighbor\n"
6883 "IP access-list number\n"
6884 "IP access-list number (expanded range)\n"
6885 "IP Access-list name\n"
6886 "Filter incoming updates\n"
6887 "Filter outgoing updates\n")
6894 const char *pstr
= argv
[idx_peer
]->arg
;
6895 const char *acl
= argv
[idx_acl
]->arg
;
6896 const char *inout
= argv
[argc
- 1]->text
;
6898 peer
= peer_and_group_lookup_vty(vty
, pstr
);
6900 return CMD_WARNING_CONFIG_FAILED
;
6902 /* Check filter direction. */
6903 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
6904 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6907 return bgp_vty_return(vty
, ret
);
6911 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
6912 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
6913 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6914 "Filter updates to/from this neighbor\n"
6915 "IP access-list number\n"
6916 "IP access-list number (expanded range)\n"
6917 "IP Access-list name\n"
6918 "Filter incoming updates\n"
6919 "Filter outgoing updates\n")
6921 DEFUN (no_neighbor_distribute_list
,
6922 no_neighbor_distribute_list_cmd
,
6923 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
6927 "Filter updates to/from this neighbor\n"
6928 "IP access-list number\n"
6929 "IP access-list number (expanded range)\n"
6930 "IP Access-list name\n"
6931 "Filter incoming updates\n"
6932 "Filter outgoing updates\n")
6938 const char *pstr
= argv
[idx_peer
]->arg
;
6939 const char *inout
= argv
[argc
- 1]->text
;
6941 peer
= peer_and_group_lookup_vty(vty
, pstr
);
6943 return CMD_WARNING_CONFIG_FAILED
;
6945 /* Check filter direction. */
6946 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
6947 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6950 return bgp_vty_return(vty
, ret
);
6954 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
6955 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
6956 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6957 "Filter updates to/from this neighbor\n"
6958 "IP access-list number\n"
6959 "IP access-list number (expanded range)\n"
6960 "IP Access-list name\n"
6961 "Filter incoming updates\n"
6962 "Filter outgoing updates\n")
6964 /* Set prefix list to the peer. */
6965 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
6966 afi_t afi
, safi_t safi
,
6967 const char *name_str
,
6968 const char *direct_str
)
6971 int direct
= FILTER_IN
;
6974 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6976 return CMD_WARNING_CONFIG_FAILED
;
6978 /* Check filter direction. */
6979 if (strncmp(direct_str
, "i", 1) == 0)
6981 else if (strncmp(direct_str
, "o", 1) == 0)
6982 direct
= FILTER_OUT
;
6984 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
6986 return bgp_vty_return(vty
, ret
);
6989 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
6990 afi_t afi
, safi_t safi
,
6991 const char *direct_str
)
6995 int direct
= FILTER_IN
;
6997 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6999 return CMD_WARNING_CONFIG_FAILED
;
7001 /* Check filter direction. */
7002 if (strncmp(direct_str
, "i", 1) == 0)
7004 else if (strncmp(direct_str
, "o", 1) == 0)
7005 direct
= FILTER_OUT
;
7007 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7009 return bgp_vty_return(vty
, ret
);
7012 DEFUN (neighbor_prefix_list
,
7013 neighbor_prefix_list_cmd
,
7014 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7017 "Filter updates to/from this neighbor\n"
7018 "Name of a prefix list\n"
7019 "Filter incoming updates\n"
7020 "Filter outgoing updates\n")
7025 return peer_prefix_list_set_vty(
7026 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7027 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7030 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7031 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7032 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7033 "Filter updates to/from this neighbor\n"
7034 "Name of a prefix list\n"
7035 "Filter incoming updates\n"
7036 "Filter outgoing updates\n")
7038 DEFUN (no_neighbor_prefix_list
,
7039 no_neighbor_prefix_list_cmd
,
7040 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7044 "Filter updates to/from this neighbor\n"
7045 "Name of a prefix list\n"
7046 "Filter incoming updates\n"
7047 "Filter outgoing updates\n")
7051 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7052 bgp_node_afi(vty
), bgp_node_safi(vty
),
7053 argv
[idx_in_out
]->arg
);
7056 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7057 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7058 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7059 "Filter updates to/from this neighbor\n"
7060 "Name of a prefix list\n"
7061 "Filter incoming updates\n"
7062 "Filter outgoing updates\n")
7064 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7065 safi_t safi
, const char *name_str
,
7066 const char *direct_str
)
7070 int direct
= FILTER_IN
;
7072 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7074 return CMD_WARNING_CONFIG_FAILED
;
7076 /* Check filter direction. */
7077 if (strncmp(direct_str
, "i", 1) == 0)
7079 else if (strncmp(direct_str
, "o", 1) == 0)
7080 direct
= FILTER_OUT
;
7082 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7084 return bgp_vty_return(vty
, ret
);
7087 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7088 safi_t safi
, const char *direct_str
)
7092 int direct
= FILTER_IN
;
7094 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7096 return CMD_WARNING_CONFIG_FAILED
;
7098 /* Check filter direction. */
7099 if (strncmp(direct_str
, "i", 1) == 0)
7101 else if (strncmp(direct_str
, "o", 1) == 0)
7102 direct
= FILTER_OUT
;
7104 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7106 return bgp_vty_return(vty
, ret
);
7109 DEFUN (neighbor_filter_list
,
7110 neighbor_filter_list_cmd
,
7111 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7114 "Establish BGP filters\n"
7115 "AS path access-list name\n"
7116 "Filter incoming routes\n"
7117 "Filter outgoing routes\n")
7122 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7123 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7124 argv
[idx_in_out
]->arg
);
7127 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7128 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7129 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7130 "Establish BGP filters\n"
7131 "AS path access-list name\n"
7132 "Filter incoming routes\n"
7133 "Filter outgoing routes\n")
7135 DEFUN (no_neighbor_filter_list
,
7136 no_neighbor_filter_list_cmd
,
7137 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7141 "Establish BGP filters\n"
7142 "AS path access-list name\n"
7143 "Filter incoming routes\n"
7144 "Filter outgoing routes\n")
7148 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7149 bgp_node_afi(vty
), bgp_node_safi(vty
),
7150 argv
[idx_in_out
]->arg
);
7153 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7154 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7155 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7156 "Establish BGP filters\n"
7157 "AS path access-list name\n"
7158 "Filter incoming routes\n"
7159 "Filter outgoing routes\n")
7161 /* Set advertise-map to the peer. */
7162 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7163 afi_t afi
, safi_t safi
,
7164 const char *advertise_str
,
7165 const char *condition_str
, bool condition
,
7168 int ret
= CMD_WARNING_CONFIG_FAILED
;
7170 struct route_map
*advertise_map
;
7171 struct route_map
*condition_map
;
7173 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7177 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7178 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7181 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7182 advertise_map
, condition_str
,
7183 condition_map
, condition
);
7185 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7186 advertise_map
, condition_str
,
7187 condition_map
, condition
);
7189 return bgp_vty_return(vty
, ret
);
7192 DEFPY (bgp_condadv_period
,
7193 bgp_condadv_period_cmd
,
7194 "[no$no] bgp conditional-advertisement timer (5-240)$period",
7197 "Conditional advertisement settings\n"
7198 "Set period to rescan BGP table to check if condition is met\n"
7199 "Period between BGP table scans, in seconds; default 60\n")
7201 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7203 bgp
->condition_check_period
=
7204 no
? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
: period
;
7209 DEFPY (neighbor_advertise_map
,
7210 neighbor_advertise_map_cmd
,
7211 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor advertise-map WORD$advertise_str <exist-map|non-exist-map>$exist WORD$condition_str",
7215 "Route-map to conditionally advertise routes\n"
7216 "Name of advertise map\n"
7217 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7218 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7219 "Name of the exist or non exist map\n")
7221 bool condition
= CONDITION_EXIST
;
7223 if (!strcmp(exist
, "non-exist-map"))
7224 condition
= CONDITION_NON_EXIST
;
7226 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7227 bgp_node_safi(vty
), advertise_str
,
7228 condition_str
, condition
, !no
);
7231 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7232 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor advertise-map WORD$advertise_str <exist-map|non-exist-map>$exist WORD$condition_str",
7233 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7234 "Route-map to conditionally advertise routes\n"
7235 "Name of advertise map\n"
7236 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7237 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7238 "Name of the exist or non exist map\n")
7240 /* Set route-map to the peer. */
7241 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7242 afi_t afi
, safi_t safi
, const char *name_str
,
7243 const char *direct_str
)
7247 int direct
= RMAP_IN
;
7248 struct route_map
*route_map
;
7250 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7252 return CMD_WARNING_CONFIG_FAILED
;
7254 /* Check filter direction. */
7255 if (strncmp(direct_str
, "in", 2) == 0)
7257 else if (strncmp(direct_str
, "o", 1) == 0)
7260 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7261 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7263 return bgp_vty_return(vty
, ret
);
7266 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7267 afi_t afi
, safi_t safi
,
7268 const char *direct_str
)
7272 int direct
= RMAP_IN
;
7274 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7276 return CMD_WARNING_CONFIG_FAILED
;
7278 /* Check filter direction. */
7279 if (strncmp(direct_str
, "in", 2) == 0)
7281 else if (strncmp(direct_str
, "o", 1) == 0)
7284 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7286 return bgp_vty_return(vty
, ret
);
7289 DEFUN (neighbor_route_map
,
7290 neighbor_route_map_cmd
,
7291 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7294 "Apply route map to neighbor\n"
7295 "Name of route map\n"
7296 "Apply map to incoming routes\n"
7297 "Apply map to outbound routes\n")
7302 return peer_route_map_set_vty(
7303 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7304 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7307 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7308 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7309 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7310 "Apply route map to neighbor\n"
7311 "Name of route map\n"
7312 "Apply map to incoming routes\n"
7313 "Apply map to outbound routes\n")
7315 DEFUN (no_neighbor_route_map
,
7316 no_neighbor_route_map_cmd
,
7317 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7321 "Apply route map to neighbor\n"
7322 "Name of route map\n"
7323 "Apply map to incoming routes\n"
7324 "Apply map to outbound routes\n")
7328 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7329 bgp_node_afi(vty
), bgp_node_safi(vty
),
7330 argv
[idx_in_out
]->arg
);
7333 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7334 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7335 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7336 "Apply route map to neighbor\n"
7337 "Name of route map\n"
7338 "Apply map to incoming routes\n"
7339 "Apply map to outbound routes\n")
7341 /* Set unsuppress-map to the peer. */
7342 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
7343 afi_t afi
, safi_t safi
,
7344 const char *name_str
)
7348 struct route_map
*route_map
;
7350 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7352 return CMD_WARNING_CONFIG_FAILED
;
7354 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7355 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
7357 return bgp_vty_return(vty
, ret
);
7360 /* Unset route-map from the peer. */
7361 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7362 afi_t afi
, safi_t safi
)
7367 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7369 return CMD_WARNING_CONFIG_FAILED
;
7371 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
7373 return bgp_vty_return(vty
, ret
);
7376 DEFUN (neighbor_unsuppress_map
,
7377 neighbor_unsuppress_map_cmd
,
7378 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7381 "Route-map to selectively unsuppress suppressed routes\n"
7382 "Name of route map\n")
7386 return peer_unsuppress_map_set_vty(
7387 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7388 argv
[idx_word
]->arg
);
7391 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
7392 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7393 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7394 "Route-map to selectively unsuppress suppressed routes\n"
7395 "Name of route map\n")
7397 DEFUN (no_neighbor_unsuppress_map
,
7398 no_neighbor_unsuppress_map_cmd
,
7399 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7403 "Route-map to selectively unsuppress suppressed routes\n"
7404 "Name of route map\n")
7407 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7409 bgp_node_safi(vty
));
7412 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
7413 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7414 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7415 "Route-map to selectively unsuppress suppressed routes\n"
7416 "Name of route map\n")
7418 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
7419 afi_t afi
, safi_t safi
,
7420 const char *num_str
,
7421 const char *threshold_str
, int warning
,
7422 const char *restart_str
,
7423 const char *force_str
)
7431 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7433 return CMD_WARNING_CONFIG_FAILED
;
7435 max
= strtoul(num_str
, NULL
, 10);
7437 threshold
= atoi(threshold_str
);
7439 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
7442 restart
= atoi(restart_str
);
7446 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
7447 restart
, force_str
? true : false);
7449 return bgp_vty_return(vty
, ret
);
7452 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
7453 afi_t afi
, safi_t safi
)
7458 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7460 return CMD_WARNING_CONFIG_FAILED
;
7462 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
7464 return bgp_vty_return(vty
, ret
);
7467 /* Maximum number of prefix to be sent to the neighbor. */
7468 DEFUN(neighbor_maximum_prefix_out
,
7469 neighbor_maximum_prefix_out_cmd
,
7470 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
7473 "Maximum number of prefixes to be sent to this peer\n"
7474 "Maximum no. of prefix limit\n")
7480 afi_t afi
= bgp_node_afi(vty
);
7481 safi_t safi
= bgp_node_safi(vty
);
7483 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7485 return CMD_WARNING_CONFIG_FAILED
;
7487 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7489 SET_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
);
7490 peer
->pmax_out
[afi
][safi
] = max
;
7495 DEFUN(no_neighbor_maximum_prefix_out
,
7496 no_neighbor_maximum_prefix_out_cmd
,
7497 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out",
7501 "Maximum number of prefixes to be sent to this peer\n")
7505 afi_t afi
= bgp_node_afi(vty
);
7506 safi_t safi
= bgp_node_safi(vty
);
7508 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7510 return CMD_WARNING_CONFIG_FAILED
;
7512 UNSET_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
);
7513 peer
->pmax_out
[afi
][safi
] = 0;
7518 /* Maximum number of prefix configuration. Prefix count is different
7519 for each peer configuration. So this configuration can be set for
7520 each peer configuration. */
7521 DEFUN (neighbor_maximum_prefix
,
7522 neighbor_maximum_prefix_cmd
,
7523 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
7526 "Maximum number of prefix accept from this peer\n"
7527 "maximum no. of prefix limit\n"
7528 "Force checking all received routes not only accepted\n")
7535 if (argv_find(argv
, argc
, "force", &idx_force
))
7536 force
= argv
[idx_force
]->arg
;
7538 return peer_maximum_prefix_set_vty(
7539 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7540 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
7543 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
7544 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
7545 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7546 "Maximum number of prefix accept from this peer\n"
7547 "maximum no. of prefix limit\n"
7548 "Force checking all received routes not only accepted\n")
7550 DEFUN (neighbor_maximum_prefix_threshold
,
7551 neighbor_maximum_prefix_threshold_cmd
,
7552 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
7555 "Maximum number of prefix accept from this peer\n"
7556 "maximum no. of prefix limit\n"
7557 "Threshold value (%) at which to generate a warning msg\n"
7558 "Force checking all received routes not only accepted\n")
7562 int idx_number_2
= 4;
7566 if (argv_find(argv
, argc
, "force", &idx_force
))
7567 force
= argv
[idx_force
]->arg
;
7569 return peer_maximum_prefix_set_vty(
7570 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7571 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
7575 neighbor_maximum_prefix_threshold
,
7576 neighbor_maximum_prefix_threshold_hidden_cmd
,
7577 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
7578 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7579 "Maximum number of prefix accept from this peer\n"
7580 "maximum no. of prefix limit\n"
7581 "Threshold value (%) at which to generate a warning msg\n"
7582 "Force checking all received routes not only accepted\n")
7584 DEFUN (neighbor_maximum_prefix_warning
,
7585 neighbor_maximum_prefix_warning_cmd
,
7586 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
7589 "Maximum number of prefix accept from this peer\n"
7590 "maximum no. of prefix limit\n"
7591 "Only give warning message when limit is exceeded\n"
7592 "Force checking all received routes not only accepted\n")
7599 if (argv_find(argv
, argc
, "force", &idx_force
))
7600 force
= argv
[idx_force
]->arg
;
7602 return peer_maximum_prefix_set_vty(
7603 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7604 argv
[idx_number
]->arg
, NULL
, 1, NULL
, force
);
7608 neighbor_maximum_prefix_warning
,
7609 neighbor_maximum_prefix_warning_hidden_cmd
,
7610 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
7611 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7612 "Maximum number of prefix accept from this peer\n"
7613 "maximum no. of prefix limit\n"
7614 "Only give warning message when limit is exceeded\n"
7615 "Force checking all received routes not only accepted\n")
7617 DEFUN (neighbor_maximum_prefix_threshold_warning
,
7618 neighbor_maximum_prefix_threshold_warning_cmd
,
7619 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
7622 "Maximum number of prefix accept from this peer\n"
7623 "maximum no. of prefix limit\n"
7624 "Threshold value (%) at which to generate a warning msg\n"
7625 "Only give warning message when limit is exceeded\n"
7626 "Force checking all received routes not only accepted\n")
7630 int idx_number_2
= 4;
7634 if (argv_find(argv
, argc
, "force", &idx_force
))
7635 force
= argv
[idx_force
]->arg
;
7637 return peer_maximum_prefix_set_vty(
7638 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7639 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
7643 neighbor_maximum_prefix_threshold_warning
,
7644 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
7645 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
7646 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7647 "Maximum number of prefix accept from this peer\n"
7648 "maximum no. of prefix limit\n"
7649 "Threshold value (%) at which to generate a warning msg\n"
7650 "Only give warning message when limit is exceeded\n"
7651 "Force checking all received routes not only accepted\n")
7653 DEFUN (neighbor_maximum_prefix_restart
,
7654 neighbor_maximum_prefix_restart_cmd
,
7655 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
7658 "Maximum number of prefix accept from this peer\n"
7659 "maximum no. of prefix limit\n"
7660 "Restart bgp connection after limit is exceeded\n"
7661 "Restart interval in minutes\n"
7662 "Force checking all received routes not only accepted\n")
7666 int idx_number_2
= 5;
7670 if (argv_find(argv
, argc
, "force", &idx_force
))
7671 force
= argv
[idx_force
]->arg
;
7673 return peer_maximum_prefix_set_vty(
7674 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7675 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
7679 neighbor_maximum_prefix_restart
,
7680 neighbor_maximum_prefix_restart_hidden_cmd
,
7681 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
7682 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7683 "Maximum number of prefix accept from this peer\n"
7684 "maximum no. of prefix limit\n"
7685 "Restart bgp connection after limit is exceeded\n"
7686 "Restart interval in minutes\n"
7687 "Force checking all received routes not only accepted\n")
7689 DEFUN (neighbor_maximum_prefix_threshold_restart
,
7690 neighbor_maximum_prefix_threshold_restart_cmd
,
7691 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
7694 "Maximum number of prefixes to accept from this peer\n"
7695 "maximum no. of prefix limit\n"
7696 "Threshold value (%) at which to generate a warning msg\n"
7697 "Restart bgp connection after limit is exceeded\n"
7698 "Restart interval in minutes\n"
7699 "Force checking all received routes not only accepted\n")
7703 int idx_number_2
= 4;
7704 int idx_number_3
= 6;
7708 if (argv_find(argv
, argc
, "force", &idx_force
))
7709 force
= argv
[idx_force
]->arg
;
7711 return peer_maximum_prefix_set_vty(
7712 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7713 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
7714 argv
[idx_number_3
]->arg
, force
);
7718 neighbor_maximum_prefix_threshold_restart
,
7719 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
7720 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
7721 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7722 "Maximum number of prefixes to accept from this peer\n"
7723 "maximum no. of prefix limit\n"
7724 "Threshold value (%) at which to generate a warning msg\n"
7725 "Restart bgp connection after limit is exceeded\n"
7726 "Restart interval in minutes\n"
7727 "Force checking all received routes not only accepted\n")
7729 DEFUN (no_neighbor_maximum_prefix
,
7730 no_neighbor_maximum_prefix_cmd
,
7731 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
7735 "Maximum number of prefixes to accept from this peer\n"
7736 "maximum no. of prefix limit\n"
7737 "Threshold value (%) at which to generate a warning msg\n"
7738 "Restart bgp connection after limit is exceeded\n"
7739 "Restart interval in minutes\n"
7740 "Only give warning message when limit is exceeded\n"
7741 "Force checking all received routes not only accepted\n")
7744 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
7746 bgp_node_safi(vty
));
7750 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
7751 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
7752 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7753 "Maximum number of prefixes to accept from this peer\n"
7754 "maximum no. of prefix limit\n"
7755 "Threshold value (%) at which to generate a warning msg\n"
7756 "Restart bgp connection after limit is exceeded\n"
7757 "Restart interval in minutes\n"
7758 "Only give warning message when limit is exceeded\n"
7759 "Force checking all received routes not only accepted\n")
7762 /* "neighbor allowas-in" */
7763 DEFUN (neighbor_allowas_in
,
7764 neighbor_allowas_in_cmd
,
7765 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
7768 "Accept as-path with my AS present in it\n"
7769 "Number of occurrences of AS number\n"
7770 "Only accept my AS in the as-path if the route was originated in my AS\n")
7773 int idx_number_origin
= 3;
7779 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7781 return CMD_WARNING_CONFIG_FAILED
;
7783 if (argc
<= idx_number_origin
)
7786 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
7789 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
7792 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7795 return bgp_vty_return(vty
, ret
);
7799 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
7800 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
7801 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7802 "Accept as-path with my AS present in it\n"
7803 "Number of occurrences of AS number\n"
7804 "Only accept my AS in the as-path if the route was originated in my AS\n")
7806 DEFUN (no_neighbor_allowas_in
,
7807 no_neighbor_allowas_in_cmd
,
7808 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
7812 "allow local ASN appears in aspath attribute\n"
7813 "Number of occurrences of AS number\n"
7814 "Only accept my AS in the as-path if the route was originated in my AS\n")
7820 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7822 return CMD_WARNING_CONFIG_FAILED
;
7824 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
7825 bgp_node_safi(vty
));
7827 return bgp_vty_return(vty
, ret
);
7831 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
7832 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
7833 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7834 "allow local ASN appears in aspath attribute\n"
7835 "Number of occurrences of AS number\n"
7836 "Only accept my AS in the as-path if the route was originated in my AS\n")
7838 DEFUN (neighbor_ttl_security
,
7839 neighbor_ttl_security_cmd
,
7840 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
7843 "BGP ttl-security parameters\n"
7844 "Specify the maximum number of hops to the BGP peer\n"
7845 "Number of hops to BGP peer\n")
7852 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7854 return CMD_WARNING_CONFIG_FAILED
;
7856 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7859 * If 'neighbor swpX', then this is for directly connected peers,
7860 * we should not accept a ttl-security hops value greater than 1.
7862 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
7864 "%s is directly connected peer, hops cannot exceed 1\n",
7865 argv
[idx_peer
]->arg
);
7866 return CMD_WARNING_CONFIG_FAILED
;
7869 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
7872 DEFUN (no_neighbor_ttl_security
,
7873 no_neighbor_ttl_security_cmd
,
7874 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
7878 "BGP ttl-security parameters\n"
7879 "Specify the maximum number of hops to the BGP peer\n"
7880 "Number of hops to BGP peer\n")
7885 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7887 return CMD_WARNING_CONFIG_FAILED
;
7889 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
7892 DEFUN (neighbor_addpath_tx_all_paths
,
7893 neighbor_addpath_tx_all_paths_cmd
,
7894 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
7897 "Use addpath to advertise all paths to a neighbor\n")
7902 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7904 return CMD_WARNING_CONFIG_FAILED
;
7906 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7911 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
7912 neighbor_addpath_tx_all_paths_hidden_cmd
,
7913 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
7914 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7915 "Use addpath to advertise all paths to a neighbor\n")
7917 DEFUN (no_neighbor_addpath_tx_all_paths
,
7918 no_neighbor_addpath_tx_all_paths_cmd
,
7919 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
7923 "Use addpath to advertise all paths to a neighbor\n")
7928 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7930 return CMD_WARNING_CONFIG_FAILED
;
7932 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
7933 != BGP_ADDPATH_ALL
) {
7935 "%% Peer not currently configured to transmit all paths.");
7936 return CMD_WARNING_CONFIG_FAILED
;
7939 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7945 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
7946 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
7947 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
7948 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7949 "Use addpath to advertise all paths to a neighbor\n")
7951 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
7952 neighbor_addpath_tx_bestpath_per_as_cmd
,
7953 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
7956 "Use addpath to advertise the bestpath per each neighboring AS\n")
7961 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7963 return CMD_WARNING_CONFIG_FAILED
;
7965 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7966 BGP_ADDPATH_BEST_PER_AS
);
7971 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
7972 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
7973 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
7974 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7975 "Use addpath to advertise the bestpath per each neighboring AS\n")
7977 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
7978 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
7979 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
7983 "Use addpath to advertise the bestpath per each neighboring AS\n")
7988 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7990 return CMD_WARNING_CONFIG_FAILED
;
7992 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
7993 != BGP_ADDPATH_BEST_PER_AS
) {
7995 "%% Peer not currently configured to transmit all best path per as.");
7996 return CMD_WARNING_CONFIG_FAILED
;
7999 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8005 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8006 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8007 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8008 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8009 "Use addpath to advertise the bestpath per each neighboring AS\n")
8012 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8013 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8016 "Detect AS loops before sending to neighbor\n")
8020 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8022 return CMD_WARNING_CONFIG_FAILED
;
8024 peer
->as_path_loop_detection
= true;
8030 no_neighbor_aspath_loop_detection
,
8031 no_neighbor_aspath_loop_detection_cmd
,
8032 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8036 "Detect AS loops before sending to neighbor\n")
8040 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8042 return CMD_WARNING_CONFIG_FAILED
;
8044 peer
->as_path_loop_detection
= false;
8049 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8050 struct ecommunity
**list
, bool is_rt6
)
8052 struct ecommunity
*ecom
= NULL
;
8053 struct ecommunity
*ecomadd
;
8055 for (; argc
; --argc
, ++argv
) {
8057 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8058 ECOMMUNITY_ROUTE_TARGET
,
8061 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8062 ECOMMUNITY_ROUTE_TARGET
,
8065 vty_out(vty
, "Malformed community-list value\n");
8067 ecommunity_free(&ecom
);
8068 return CMD_WARNING_CONFIG_FAILED
;
8072 ecommunity_merge(ecom
, ecomadd
);
8073 ecommunity_free(&ecomadd
);
8080 ecommunity_free(&*list
);
8088 * v2vimport is true if we are handling a `import vrf ...` command
8090 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8094 switch (vty
->node
) {
8103 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8108 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8109 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8110 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8111 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8113 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8117 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8118 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8119 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8120 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8122 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8129 DEFPY (af_rd_vpn_export
,
8130 af_rd_vpn_export_cmd
,
8131 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8133 "Specify route distinguisher\n"
8134 "Between current address-family and vpn\n"
8135 "For routes leaked from current address-family to vpn\n"
8136 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8138 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8139 struct prefix_rd prd
;
8145 if (argv_find(argv
, argc
, "no", &idx
))
8149 ret
= str2prefix_rd(rd_str
, &prd
);
8151 vty_out(vty
, "%% Malformed rd\n");
8152 return CMD_WARNING_CONFIG_FAILED
;
8156 afi
= vpn_policy_getafi(vty
, bgp
, false);
8158 return CMD_WARNING_CONFIG_FAILED
;
8161 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8163 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8164 bgp_get_default(), bgp
);
8167 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
8168 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8169 BGP_VPN_POLICY_TOVPN_RD_SET
);
8171 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8172 BGP_VPN_POLICY_TOVPN_RD_SET
);
8175 /* post-change: re-export vpn routes */
8176 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8177 bgp_get_default(), bgp
);
8182 ALIAS (af_rd_vpn_export
,
8183 af_no_rd_vpn_export_cmd
,
8186 "Specify route distinguisher\n"
8187 "Between current address-family and vpn\n"
8188 "For routes leaked from current address-family to vpn\n")
8190 DEFPY (af_label_vpn_export
,
8191 af_label_vpn_export_cmd
,
8192 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
8194 "label value for VRF\n"
8195 "Between current address-family and vpn\n"
8196 "For routes leaked from current address-family to vpn\n"
8197 "Label Value <0-1048575>\n"
8198 "Automatically assign a label\n")
8200 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8201 mpls_label_t label
= MPLS_LABEL_NONE
;
8206 if (argv_find(argv
, argc
, "no", &idx
))
8209 /* If "no ...", squash trailing parameter */
8215 label
= label_val
; /* parser should force unsigned */
8218 afi
= vpn_policy_getafi(vty
, bgp
, false);
8220 return CMD_WARNING_CONFIG_FAILED
;
8223 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8224 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
8229 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8231 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8232 bgp_get_default(), bgp
);
8234 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8235 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
8237 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
8240 * label has previously been automatically
8241 * assigned by labelpool: release it
8243 * NB if tovpn_label == MPLS_LABEL_NONE it
8244 * means the automatic assignment is in flight
8245 * and therefore the labelpool callback must
8246 * detect that the auto label is not needed.
8249 bgp_lp_release(LP_TYPE_VRF
,
8250 &bgp
->vpn_policy
[afi
],
8251 bgp
->vpn_policy
[afi
].tovpn_label
);
8253 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8254 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8257 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
8259 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8260 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8261 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
8262 vpn_leak_label_callback
);
8265 /* post-change: re-export vpn routes */
8266 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8267 bgp_get_default(), bgp
);
8269 hook_call(bgp_snmp_update_last_changed
, bgp
);
8273 DEFPY (af_sid_vpn_export
,
8274 af_sid_vpn_export_cmd
,
8275 "[no] sid vpn export <(1-255)$sid_idx|auto$sid_auto>",
8277 "sid value for VRF\n"
8278 "Between current address-family and vpn\n"
8279 "For routes leaked from current address-family to vpn\n"
8280 "Sid allocation index\n"
8281 "Automatically assign a label\n")
8283 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8289 if (argv_find(argv
, argc
, "no", &idx
))
8291 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
8292 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
8294 afi
= vpn_policy_getafi(vty
, bgp
, false);
8296 return CMD_WARNING_CONFIG_FAILED
;
8300 vty_out(vty
, "It's not implemented");
8301 return CMD_WARNING_CONFIG_FAILED
;
8304 /* skip when it's already configured */
8305 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8306 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8307 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
8311 * mode change between sid_idx and sid_auto isn't supported.
8312 * user must negate sid vpn export when they want to change the mode
8314 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
8315 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8316 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
8317 vty_out(vty
, "it's already configured as %s.\n",
8318 sid_auto
? "auto-mode" : "idx-mode");
8319 return CMD_WARNING_CONFIG_FAILED
;
8323 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8324 bgp_get_default(), bgp
);
8327 /* SID allocation auto-mode */
8329 zlog_debug("%s: auto sid alloc.", __func__
);
8330 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8331 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
8333 /* SID allocation index-mode */
8335 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
8336 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
8340 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8341 bgp_get_default(), bgp
);
8345 ALIAS (af_label_vpn_export
,
8346 af_no_label_vpn_export_cmd
,
8347 "no label vpn export",
8349 "label value for VRF\n"
8350 "Between current address-family and vpn\n"
8351 "For routes leaked from current address-family to vpn\n")
8353 DEFPY (af_nexthop_vpn_export
,
8354 af_nexthop_vpn_export_cmd
,
8355 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
8357 "Specify next hop to use for VRF advertised prefixes\n"
8358 "Between current address-family and vpn\n"
8359 "For routes leaked from current address-family to vpn\n"
8363 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8369 vty_out(vty
, "%% Nexthop required\n");
8370 return CMD_WARNING_CONFIG_FAILED
;
8372 if (!sockunion2hostprefix(nexthop_su
, &p
))
8373 return CMD_WARNING_CONFIG_FAILED
;
8376 afi
= vpn_policy_getafi(vty
, bgp
, false);
8378 return CMD_WARNING_CONFIG_FAILED
;
8381 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8383 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8384 bgp_get_default(), bgp
);
8387 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
8388 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8389 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
8391 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8392 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
8395 /* post-change: re-export vpn routes */
8396 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8397 bgp_get_default(), bgp
);
8402 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
8404 if (!strcmp(dstr
, "import")) {
8405 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
8406 } else if (!strcmp(dstr
, "export")) {
8407 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
8408 } else if (!strcmp(dstr
, "both")) {
8409 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
8410 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
8412 vty_out(vty
, "%% direction parse error\n");
8413 return CMD_WARNING_CONFIG_FAILED
;
8418 DEFPY (af_rt_vpn_imexport
,
8419 af_rt_vpn_imexport_cmd
,
8420 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
8422 "Specify route target list\n"
8423 "Specify route target list\n"
8424 "Between current address-family and vpn\n"
8425 "For routes leaked from vpn to current address-family: match any\n"
8426 "For routes leaked from current address-family to vpn: set\n"
8427 "both import: match any and export: set\n"
8428 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
8430 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8432 struct ecommunity
*ecom
= NULL
;
8433 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
8434 vpn_policy_direction_t dir
;
8439 if (argv_find(argv
, argc
, "no", &idx
))
8442 afi
= vpn_policy_getafi(vty
, bgp
, false);
8444 return CMD_WARNING_CONFIG_FAILED
;
8446 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
8447 if (ret
!= CMD_SUCCESS
)
8451 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
8452 vty_out(vty
, "%% Missing RTLIST\n");
8453 return CMD_WARNING_CONFIG_FAILED
;
8455 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
8456 if (ret
!= CMD_SUCCESS
) {
8461 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
8465 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8468 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
8470 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
8471 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
8472 ecommunity_dup(ecom
);
8474 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
8476 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
8477 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
8480 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8484 ecommunity_free(&ecom
);
8489 ALIAS (af_rt_vpn_imexport
,
8490 af_no_rt_vpn_imexport_cmd
,
8491 "no <rt|route-target> vpn <import|export|both>$direction_str",
8493 "Specify route target list\n"
8494 "Specify route target list\n"
8495 "Between current address-family and vpn\n"
8496 "For routes leaked from vpn to current address-family\n"
8497 "For routes leaked from current address-family to vpn\n"
8498 "both import and export\n")
8500 DEFPY (af_route_map_vpn_imexport
,
8501 af_route_map_vpn_imexport_cmd
,
8502 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
8503 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
8505 "Specify route map\n"
8506 "Between current address-family and vpn\n"
8507 "For routes leaked from vpn to current address-family\n"
8508 "For routes leaked from current address-family to vpn\n"
8509 "name of route-map\n")
8511 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8513 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
8514 vpn_policy_direction_t dir
;
8519 if (argv_find(argv
, argc
, "no", &idx
))
8522 afi
= vpn_policy_getafi(vty
, bgp
, false);
8524 return CMD_WARNING_CONFIG_FAILED
;
8526 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
8527 if (ret
!= CMD_SUCCESS
)
8530 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
8534 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8537 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
8538 XFREE(MTYPE_ROUTE_MAP_NAME
,
8539 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
8540 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
8541 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
8542 bgp
->vpn_policy
[afi
].rmap
[dir
] =
8543 route_map_lookup_warn_noexist(vty
, rmap_str
);
8544 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
8547 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
8548 XFREE(MTYPE_ROUTE_MAP_NAME
,
8549 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
8550 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
8551 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
8554 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8560 ALIAS (af_route_map_vpn_imexport
,
8561 af_no_route_map_vpn_imexport_cmd
,
8562 "no route-map vpn <import|export>$direction_str",
8564 "Specify route map\n"
8565 "Between current address-family and vpn\n"
8566 "For routes leaked from vpn to current address-family\n"
8567 "For routes leaked from current address-family to vpn\n")
8569 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
8570 "import vrf route-map RMAP$rmap_str",
8571 "Import routes from another VRF\n"
8572 "Vrf routes being filtered\n"
8573 "Specify route map\n"
8574 "name of route-map\n")
8576 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8577 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
8579 struct bgp
*bgp_default
;
8581 afi
= vpn_policy_getafi(vty
, bgp
, true);
8583 return CMD_WARNING_CONFIG_FAILED
;
8585 bgp_default
= bgp_get_default();
8590 /* Auto-create assuming the same AS */
8591 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
8592 BGP_INSTANCE_TYPE_DEFAULT
);
8596 "VRF default is not configured as a bgp instance\n");
8601 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8603 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
8604 XFREE(MTYPE_ROUTE_MAP_NAME
,
8605 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
8606 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
8607 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
8608 bgp
->vpn_policy
[afi
].rmap
[dir
] =
8609 route_map_lookup_warn_noexist(vty
, rmap_str
);
8610 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
8613 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8614 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
8616 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8621 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
8622 "no import vrf route-map [RMAP$rmap_str]",
8624 "Import routes from another VRF\n"
8625 "Vrf routes being filtered\n"
8626 "Specify route map\n"
8627 "name of route-map\n")
8629 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8630 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
8633 afi
= vpn_policy_getafi(vty
, bgp
, true);
8635 return CMD_WARNING_CONFIG_FAILED
;
8637 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8639 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
8640 XFREE(MTYPE_ROUTE_MAP_NAME
,
8641 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
8642 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
8643 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
8645 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
8646 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8647 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
8649 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8654 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
8655 "[no] import vrf VIEWVRFNAME$import_name",
8657 "Import routes from another VRF\n"
8658 "VRF to import from\n"
8659 "The name of the VRF\n")
8661 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8662 struct listnode
*node
;
8663 struct bgp
*vrf_bgp
, *bgp_default
;
8666 bool remove
= false;
8669 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
8673 if (import_name
== NULL
) {
8674 vty_out(vty
, "%% Missing import name\n");
8678 if (strcmp(import_name
, "route-map") == 0) {
8679 vty_out(vty
, "%% Must include route-map name\n");
8683 if (argv_find(argv
, argc
, "no", &idx
))
8686 afi
= vpn_policy_getafi(vty
, bgp
, true);
8688 return CMD_WARNING_CONFIG_FAILED
;
8690 safi
= bgp_node_safi(vty
);
8692 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
8693 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
8694 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
8695 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
8696 remove
? "unimport" : "import", import_name
);
8700 bgp_default
= bgp_get_default();
8702 /* Auto-create assuming the same AS */
8703 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
8704 BGP_INSTANCE_TYPE_DEFAULT
);
8708 "VRF default is not configured as a bgp instance\n");
8713 vrf_bgp
= bgp_lookup_by_name(import_name
);
8715 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
8716 vrf_bgp
= bgp_default
;
8718 /* Auto-create assuming the same AS */
8719 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
8723 "VRF %s is not configured as a bgp instance\n",
8730 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
8732 /* Already importing from "import_vrf"? */
8733 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
8735 if (strcmp(vname
, import_name
) == 0)
8739 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
8745 /* This command is valid only in a bgp vrf instance or the default instance */
8746 DEFPY (bgp_imexport_vpn
,
8747 bgp_imexport_vpn_cmd
,
8748 "[no] <import|export>$direction_str vpn",
8750 "Import routes to this address-family\n"
8751 "Export routes from this address-family\n"
8752 "to/from default instance VPN RIB\n")
8754 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8761 vpn_policy_direction_t dir
;
8763 if (argv_find(argv
, argc
, "no", &idx
))
8766 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
8767 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
8769 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
8770 return CMD_WARNING_CONFIG_FAILED
;
8773 afi
= bgp_node_afi(vty
);
8774 safi
= bgp_node_safi(vty
);
8775 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
8776 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
8777 return CMD_WARNING_CONFIG_FAILED
;
8780 if (!strcmp(direction_str
, "import")) {
8781 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
8782 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
8783 } else if (!strcmp(direction_str
, "export")) {
8784 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
8785 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
8787 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
8788 return CMD_WARNING_CONFIG_FAILED
;
8791 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
8794 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
8795 if (!previous_state
) {
8796 /* trigger export current vrf */
8797 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8800 if (previous_state
) {
8801 /* trigger un-export current vrf */
8802 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8804 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
8807 hook_call(bgp_snmp_init_stats
, bgp
);
8812 DEFPY (af_routetarget_import
,
8813 af_routetarget_import_cmd
,
8814 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
8816 "Specify route target list\n"
8817 "Specify route target list\n"
8818 "Specify route target list\n"
8819 "Specify route target list\n"
8820 "Flow-spec redirect type route target\n"
8821 "Import routes to this address-family\n"
8822 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
8824 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8826 struct ecommunity
*ecom
= NULL
;
8828 int idx
= 0, idx_unused
= 0;
8832 if (argv_find(argv
, argc
, "no", &idx
))
8835 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
8836 argv_find(argv
, argc
, "route-target6", &idx_unused
))
8839 afi
= vpn_policy_getafi(vty
, bgp
, false);
8841 return CMD_WARNING_CONFIG_FAILED
;
8843 if (rt6
&& afi
!= AFI_IP6
)
8844 return CMD_WARNING_CONFIG_FAILED
;
8847 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
8848 vty_out(vty
, "%% Missing RTLIST\n");
8849 return CMD_WARNING_CONFIG_FAILED
;
8851 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
8852 if (ret
!= CMD_SUCCESS
)
8857 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
8858 ecommunity_free(&bgp
->vpn_policy
[afi
]
8859 .import_redirect_rtlist
);
8860 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
8861 ecommunity_dup(ecom
);
8863 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
8864 ecommunity_free(&bgp
->vpn_policy
[afi
]
8865 .import_redirect_rtlist
);
8866 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
8870 ecommunity_free(&ecom
);
8875 DEFUN_NOSH (address_family_ipv4_safi
,
8876 address_family_ipv4_safi_cmd
,
8877 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
8878 "Enter Address Family command mode\n"
8880 BGP_SAFI_WITH_LABEL_HELP_STR
)
8884 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8885 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
8886 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
8887 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
8888 && safi
!= SAFI_EVPN
) {
8890 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
8891 return CMD_WARNING_CONFIG_FAILED
;
8893 vty
->node
= bgp_node_type(AFI_IP
, safi
);
8895 vty
->node
= BGP_IPV4_NODE
;
8900 DEFUN_NOSH (address_family_ipv6_safi
,
8901 address_family_ipv6_safi_cmd
,
8902 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
8903 "Enter Address Family command mode\n"
8905 BGP_SAFI_WITH_LABEL_HELP_STR
)
8908 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8909 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
8910 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
8911 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
8912 && safi
!= SAFI_EVPN
) {
8914 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
8915 return CMD_WARNING_CONFIG_FAILED
;
8917 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
8919 vty
->node
= BGP_IPV6_NODE
;
8924 #ifdef KEEP_OLD_VPN_COMMANDS
8925 DEFUN_NOSH (address_family_vpnv4
,
8926 address_family_vpnv4_cmd
,
8927 "address-family vpnv4 [unicast]",
8928 "Enter Address Family command mode\n"
8930 "Address Family modifier\n")
8932 vty
->node
= BGP_VPNV4_NODE
;
8936 DEFUN_NOSH (address_family_vpnv6
,
8937 address_family_vpnv6_cmd
,
8938 "address-family vpnv6 [unicast]",
8939 "Enter Address Family command mode\n"
8941 "Address Family modifier\n")
8943 vty
->node
= BGP_VPNV6_NODE
;
8946 #endif /* KEEP_OLD_VPN_COMMANDS */
8948 DEFUN_NOSH (address_family_evpn
,
8949 address_family_evpn_cmd
,
8950 "address-family l2vpn evpn",
8951 "Enter Address Family command mode\n"
8953 "Address Family modifier\n")
8955 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8956 vty
->node
= BGP_EVPN_NODE
;
8960 DEFUN_NOSH (bgp_segment_routing_srv6
,
8961 bgp_segment_routing_srv6_cmd
,
8962 "segment-routing srv6",
8963 "Segment-Routing configuration\n"
8964 "Segment-Routing SRv6 configuration\n")
8966 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8967 bgp
->srv6_enabled
= true;
8968 vty
->node
= BGP_SRV6_NODE
;
8972 DEFPY (bgp_srv6_locator
,
8973 bgp_srv6_locator_cmd
,
8974 "locator NAME$name",
8975 "Specify SRv6 locator\n"
8976 "Specify SRv6 locator\n")
8978 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8981 if (strlen(bgp
->srv6_locator_name
) > 0
8982 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
8983 vty_out(vty
, "srv6 locator is already configured\n");
8984 return CMD_WARNING_CONFIG_FAILED
;
8987 snprintf(bgp
->srv6_locator_name
,
8988 sizeof(bgp
->srv6_locator_name
), "%s", name
);
8990 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
8992 return CMD_WARNING_CONFIG_FAILED
;
8997 DEFPY (show_bgp_srv6
,
8999 "show bgp segment-routing srv6",
9002 "BGP Segment Routing\n"
9003 "BGP Segment Routing SRv6\n")
9006 struct listnode
*node
;
9007 struct prefix_ipv6
*chunk
;
9008 struct bgp_srv6_function
*func
;
9009 struct in6_addr
*tovpn4_sid
;
9010 struct in6_addr
*tovpn6_sid
;
9012 char buf_tovpn4_sid
[256];
9013 char buf_tovpn6_sid
[256];
9015 bgp
= bgp_get_default();
9019 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
9020 vty_out(vty
, "locator_chunks:\n");
9021 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
)) {
9022 prefix2str(chunk
, buf
, sizeof(buf
));
9023 vty_out(vty
, "- %s\n", buf
);
9026 vty_out(vty
, "functions:\n");
9027 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
9028 inet_ntop(AF_INET6
, &func
->sid
, buf
, sizeof(buf
));
9029 vty_out(vty
, "- sid: %s\n", buf
);
9030 vty_out(vty
, " locator: %s\n", func
->locator_name
);
9033 vty_out(vty
, "bgps:\n");
9034 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
9035 vty_out(vty
, "- name: %s\n",
9036 bgp
->name
? bgp
->name
: "default");
9038 tovpn4_sid
= bgp
->vpn_policy
[AFI_IP
].tovpn_sid
;
9039 tovpn6_sid
= bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
;
9041 inet_ntop(AF_INET6
, tovpn4_sid
, buf_tovpn4_sid
,
9042 sizeof(buf_tovpn4_sid
));
9044 inet_ntop(AF_INET6
, tovpn6_sid
, buf_tovpn6_sid
,
9045 sizeof(buf_tovpn6_sid
));
9047 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %s\n",
9048 tovpn4_sid
? buf_tovpn4_sid
: "none");
9049 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %s\n",
9050 tovpn6_sid
? buf_tovpn6_sid
: "none");
9056 DEFUN_NOSH (exit_address_family
,
9057 exit_address_family_cmd
,
9058 "exit-address-family",
9059 "Exit from Address Family configuration mode\n")
9061 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9062 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9063 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9064 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9065 || vty
->node
== BGP_EVPN_NODE
9066 || vty
->node
== BGP_FLOWSPECV4_NODE
9067 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9068 vty
->node
= BGP_NODE
;
9072 /* Recalculate bestpath and re-advertise a prefix */
9073 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9074 const char *ip_str
, afi_t afi
, safi_t safi
,
9075 struct prefix_rd
*prd
)
9078 struct prefix match
;
9079 struct bgp_dest
*dest
;
9080 struct bgp_dest
*rm
;
9082 struct bgp_table
*table
;
9083 struct bgp_table
*rib
;
9085 /* BGP structure lookup. */
9087 bgp
= bgp_lookup_by_name(view_name
);
9089 vty_out(vty
, "%% Can't find BGP instance %s\n",
9094 bgp
= bgp_get_default();
9096 vty_out(vty
, "%% No BGP process is configured\n");
9101 /* Check IP address argument. */
9102 ret
= str2prefix(ip_str
, &match
);
9104 vty_out(vty
, "%% address is malformed\n");
9108 match
.family
= afi2family(afi
);
9109 rib
= bgp
->rib
[afi
][safi
];
9111 if (safi
== SAFI_MPLS_VPN
) {
9112 for (dest
= bgp_table_top(rib
); dest
;
9113 dest
= bgp_route_next(dest
)) {
9114 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9116 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9119 table
= bgp_dest_get_bgp_table_info(dest
);
9123 rm
= bgp_node_match(table
, &match
);
9125 const struct prefix
*rm_p
=
9126 bgp_dest_get_prefix(rm
);
9128 if (rm_p
->prefixlen
== match
.prefixlen
) {
9130 BGP_NODE_USER_CLEAR
);
9131 bgp_process(bgp
, rm
, afi
, safi
);
9133 bgp_dest_unlock_node(rm
);
9137 dest
= bgp_node_match(rib
, &match
);
9139 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9141 if (dest_p
->prefixlen
== match
.prefixlen
) {
9142 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9143 bgp_process(bgp
, dest
, afi
, safi
);
9145 bgp_dest_unlock_node(dest
);
9152 /* one clear bgp command to rule them all */
9153 DEFUN (clear_ip_bgp_all
,
9154 clear_ip_bgp_all_cmd
,
9155 "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>]",
9159 BGP_INSTANCE_HELP_STR
9162 BGP_SAFI_WITH_LABEL_HELP_STR
9163 "Address Family modifier\n"
9165 "BGP IPv4 neighbor to clear\n"
9166 "BGP IPv6 neighbor to clear\n"
9167 "BGP neighbor on interface to clear\n"
9168 "Clear peers with the AS number\n"
9169 "Clear all external peers\n"
9170 "Clear all members of peer-group\n"
9171 "BGP peer-group name\n"
9176 "Push out prefix-list ORF and do inbound soft reconfig\n"
9181 afi_t afi
= AFI_UNSPEC
;
9182 safi_t safi
= SAFI_UNSPEC
;
9183 enum clear_sort clr_sort
= clear_peer
;
9184 enum bgp_clear_type clr_type
;
9185 char *clr_arg
= NULL
;
9189 /* clear [ip] bgp */
9190 if (argv_find(argv
, argc
, "ip", &idx
))
9193 /* [<vrf> VIEWVRFNAME] */
9194 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9195 vrf
= argv
[idx
+ 1]->arg
;
9197 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9199 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9200 /* [<view> VIEWVRFNAME] */
9201 vrf
= argv
[idx
+ 1]->arg
;
9204 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9205 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
9206 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
9208 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
9209 if (argv_find(argv
, argc
, "*", &idx
)) {
9210 clr_sort
= clear_all
;
9211 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
9212 clr_sort
= clear_peer
;
9213 clr_arg
= argv
[idx
]->arg
;
9214 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
9215 clr_sort
= clear_peer
;
9216 clr_arg
= argv
[idx
]->arg
;
9217 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
9218 clr_sort
= clear_group
;
9220 clr_arg
= argv
[idx
]->arg
;
9221 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
9222 clr_sort
= clear_peer
;
9223 clr_arg
= argv
[idx
]->arg
;
9224 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
9225 clr_sort
= clear_peer
;
9226 clr_arg
= argv
[idx
]->arg
;
9227 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
9228 clr_sort
= clear_as
;
9229 clr_arg
= argv
[idx
]->arg
;
9230 } else if (argv_find(argv
, argc
, "external", &idx
)) {
9231 clr_sort
= clear_external
;
9234 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
9235 if (argv_find(argv
, argc
, "soft", &idx
)) {
9236 if (argv_find(argv
, argc
, "in", &idx
)
9237 || argv_find(argv
, argc
, "out", &idx
))
9238 clr_type
= strmatch(argv
[idx
]->text
, "in")
9240 : BGP_CLEAR_SOFT_OUT
;
9242 clr_type
= BGP_CLEAR_SOFT_BOTH
;
9243 } else if (argv_find(argv
, argc
, "in", &idx
)) {
9244 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
9245 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
9246 : BGP_CLEAR_SOFT_IN
;
9247 } else if (argv_find(argv
, argc
, "out", &idx
)) {
9248 clr_type
= BGP_CLEAR_SOFT_OUT
;
9250 clr_type
= BGP_CLEAR_SOFT_NONE
;
9252 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
9255 DEFUN (clear_ip_bgp_prefix
,
9256 clear_ip_bgp_prefix_cmd
,
9257 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
9261 BGP_INSTANCE_HELP_STR
9262 "Clear bestpath and re-advertise\n"
9266 char *prefix
= NULL
;
9270 /* [<view|vrf> VIEWVRFNAME] */
9271 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9272 vrf
= argv
[idx
+ 1]->arg
;
9274 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9276 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9277 /* [<view> VIEWVRFNAME] */
9278 vrf
= argv
[idx
+ 1]->arg
;
9282 prefix
= argv
[argc
- 1]->arg
;
9284 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
9287 DEFUN (clear_bgp_ipv6_safi_prefix
,
9288 clear_bgp_ipv6_safi_prefix_cmd
,
9289 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9295 "Clear bestpath and re-advertise\n"
9299 int idx_ipv6_prefix
= 0;
9300 safi_t safi
= SAFI_UNICAST
;
9301 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9302 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9304 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9305 return bgp_clear_prefix(
9306 vty
, NULL
, prefix
, AFI_IP6
,
9310 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
9311 clear_bgp_instance_ipv6_safi_prefix_cmd
,
9312 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9316 BGP_INSTANCE_HELP_STR
9319 "Clear bestpath and re-advertise\n"
9323 int idx_vrfview
= 0;
9324 int idx_ipv6_prefix
= 0;
9325 safi_t safi
= SAFI_UNICAST
;
9326 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9327 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9328 char *vrfview
= NULL
;
9330 /* [<view|vrf> VIEWVRFNAME] */
9331 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
9332 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9333 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
9335 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
9336 /* [<view> VIEWVRFNAME] */
9337 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9339 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9341 return bgp_clear_prefix(
9342 vty
, vrfview
, prefix
,
9343 AFI_IP6
, safi
, NULL
);
9346 DEFUN (show_bgp_views
,
9348 "show [ip] bgp views",
9352 "Show the defined BGP views\n")
9354 struct list
*inst
= bm
->bgp
;
9355 struct listnode
*node
;
9358 vty_out(vty
, "Defined BGP views:\n");
9359 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
9361 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
9363 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
9370 DEFUN (show_bgp_vrfs
,
9372 "show [ip] bgp vrfs [json]",
9379 char buf
[ETHER_ADDR_STRLEN
];
9380 struct list
*inst
= bm
->bgp
;
9381 struct listnode
*node
;
9383 bool uj
= use_json(argc
, argv
);
9384 json_object
*json
= NULL
;
9385 json_object
*json_vrfs
= NULL
;
9389 json
= json_object_new_object();
9390 json_vrfs
= json_object_new_object();
9393 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
9394 const char *name
, *type
;
9396 struct listnode
*node2
, *nnode2
;
9397 int peers_cfg
, peers_estb
;
9398 json_object
*json_vrf
= NULL
;
9401 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
9405 if (!uj
&& count
== 1) {
9407 "%4s %-5s %-16s %9s %10s %-37s\n",
9408 "Type", "Id", "routerId", "#PeersCfg",
9409 "#PeersEstb", "Name");
9410 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
9411 "L3-VNI", "RouterMAC", "Interface");
9414 peers_cfg
= peers_estb
= 0;
9416 json_vrf
= json_object_new_object();
9419 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
9420 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
9423 if (peer_established(peer
))
9427 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
9428 name
= VRF_DEFAULT_NAME
;
9437 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
9439 : (int64_t)bgp
->vrf_id
;
9440 char buf
[BUFSIZ
] = {0};
9442 json_object_string_add(json_vrf
, "type", type
);
9443 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
9444 json_object_string_add(json_vrf
, "routerId",
9446 &bgp
->router_id
, buf
,
9448 json_object_int_add(json_vrf
, "numConfiguredPeers",
9450 json_object_int_add(json_vrf
, "numEstablishedPeers",
9453 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
9454 json_object_string_add(
9456 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
9457 json_object_string_add(json_vrf
, "interface",
9458 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
9460 json_object_object_add(json_vrfs
, name
, json_vrf
);
9462 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
9464 bgp
->vrf_id
== VRF_UNKNOWN
? -1
9466 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
9467 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
9469 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
9470 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
9476 json_object_object_add(json
, "vrfs", json_vrfs
);
9478 json_object_int_add(json
, "totalVrfs", count
);
9480 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
9481 json
, JSON_C_TO_STRING_PRETTY
));
9482 json_object_free(json
);
9486 "\nTotal number of VRFs (including default): %d\n",
9493 DEFUN (show_bgp_mac_hash
,
9494 show_bgp_mac_hash_cmd
,
9495 "show bgp mac hash",
9499 "Mac Address database\n")
9501 bgp_mac_dump_table(vty
);
9506 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
9508 struct vty
*vty
= (struct vty
*)args
;
9509 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
9511 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
9514 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
9516 vty_out(vty
, "self nexthop database:\n");
9517 bgp_nexthop_show_address_hash(vty
, bgp
);
9519 vty_out(vty
, "Tunnel-ip database:\n");
9520 hash_iterate(bgp
->tip_hash
,
9521 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
9525 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
9526 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
9527 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
9528 "martian next-hops\n"
9529 "martian next-hop database\n")
9531 struct bgp
*bgp
= NULL
;
9535 /* [<vrf> VIEWVRFNAME] */
9536 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9537 name
= argv
[idx
+ 1]->arg
;
9538 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
9540 } else if (argv_find(argv
, argc
, "view", &idx
))
9541 /* [<view> VIEWVRFNAME] */
9542 name
= argv
[idx
+ 1]->arg
;
9544 bgp
= bgp_lookup_by_name(name
);
9546 bgp
= bgp_get_default();
9549 vty_out(vty
, "%% No BGP process is configured\n");
9552 bgp_show_martian_nexthops(vty
, bgp
);
9557 DEFUN (show_bgp_memory
,
9558 show_bgp_memory_cmd
,
9559 "show [ip] bgp memory",
9563 "Global BGP memory statistics\n")
9565 char memstrbuf
[MTYPE_MEMSTR_LEN
];
9566 unsigned long count
;
9568 /* RIB related usage stats */
9569 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
9570 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
9571 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9572 count
* sizeof(struct bgp_dest
)));
9574 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
9575 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
9576 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9577 count
* sizeof(struct bgp_path_info
)));
9578 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
9579 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
9582 memstrbuf
, sizeof(memstrbuf
),
9583 count
* sizeof(struct bgp_path_info_extra
)));
9585 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
9586 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
9587 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9588 count
* sizeof(struct bgp_static
)));
9590 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
9591 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
9592 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9593 count
* sizeof(struct bpacket
)));
9596 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
9597 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
9598 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9599 count
* sizeof(struct bgp_adj_in
)));
9600 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
9601 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
9602 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9603 count
* sizeof(struct bgp_adj_out
)));
9605 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
9606 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
9608 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9609 count
* sizeof(struct bgp_nexthop_cache
)));
9611 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
9612 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
9614 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9615 count
* sizeof(struct bgp_damp_info
)));
9618 count
= attr_count();
9619 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
9620 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9621 count
* sizeof(struct attr
)));
9623 if ((count
= attr_unknown_count()))
9624 vty_out(vty
, "%ld unknown attributes\n", count
);
9626 /* AS_PATH attributes */
9627 count
= aspath_count();
9628 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
9629 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9630 count
* sizeof(struct aspath
)));
9632 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
9633 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
9634 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9635 count
* sizeof(struct assegment
)));
9637 /* Other attributes */
9638 if ((count
= community_count()))
9639 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
9640 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9641 count
* sizeof(struct community
)));
9642 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
9643 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
9644 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9645 count
* sizeof(struct ecommunity
)));
9646 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
9648 "%ld BGP large-community entries, using %s of memory\n",
9649 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9650 count
* sizeof(struct lcommunity
)));
9652 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
9653 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
9654 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9655 count
* sizeof(struct cluster_list
)));
9657 /* Peer related usage */
9658 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
9659 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
9660 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9661 count
* sizeof(struct peer
)));
9663 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
9664 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
9665 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9666 count
* sizeof(struct peer_group
)));
9669 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
9670 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
9671 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9672 count
* sizeof(regex_t
)));
9676 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
9678 json_object
*bestpath
= json_object_new_object();
9680 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
9681 json_object_string_add(bestpath
, "asPath", "ignore");
9683 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
9684 json_object_string_add(bestpath
, "asPath", "confed");
9686 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
9687 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
9688 json_object_string_add(bestpath
, "multiPathRelax",
9691 json_object_string_add(bestpath
, "multiPathRelax",
9694 json_object_string_add(bestpath
, "multiPathRelax", "false");
9696 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
9697 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
9699 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
9700 json_object_string_add(bestpath
, "compareRouterId", "true");
9701 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
9702 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
9703 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
9704 json_object_string_add(bestpath
, "med", "confed");
9705 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
9706 json_object_string_add(bestpath
, "med",
9707 "missing-as-worst");
9709 json_object_string_add(bestpath
, "med", "true");
9712 json_object_object_add(json
, "bestPath", bestpath
);
9715 /* Print the error code/subcode for why the peer is down */
9716 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
9717 json_object
*json_peer
, bool use_json
)
9719 const char *code_str
;
9720 const char *subcode_str
;
9723 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
9724 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
9725 char errorcodesubcode_hexstr
[5];
9726 char errorcodesubcode_str
[256];
9728 code_str
= bgp_notify_code_str(peer
->notify
.code
);
9729 subcode_str
= bgp_notify_subcode_str(
9731 peer
->notify
.subcode
);
9733 snprintf(errorcodesubcode_hexstr
,
9734 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
9735 peer
->notify
.code
, peer
->notify
.subcode
);
9736 json_object_string_add(json_peer
,
9737 "lastErrorCodeSubcode",
9738 errorcodesubcode_hexstr
);
9739 snprintf(errorcodesubcode_str
, 255, "%s%s",
9740 code_str
, subcode_str
);
9741 json_object_string_add(json_peer
,
9742 "lastNotificationReason",
9743 errorcodesubcode_str
);
9744 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
9745 && peer
->notify
.code
== BGP_NOTIFY_CEASE
9746 && (peer
->notify
.subcode
9747 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
9748 || peer
->notify
.subcode
9749 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
9750 && peer
->notify
.length
) {
9752 const char *msg_str
;
9754 msg_str
= bgp_notify_admin_message(
9755 msgbuf
, sizeof(msgbuf
),
9756 (uint8_t *)peer
->notify
.data
,
9757 peer
->notify
.length
);
9759 json_object_string_add(
9761 "lastShutdownDescription",
9766 json_object_string_add(json_peer
, "lastResetDueTo",
9767 peer_down_str
[(int)peer
->last_reset
]);
9768 json_object_int_add(json_peer
, "lastResetCode",
9771 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
9772 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
9773 code_str
= bgp_notify_code_str(peer
->notify
.code
);
9775 bgp_notify_subcode_str(peer
->notify
.code
,
9776 peer
->notify
.subcode
);
9777 vty_out(vty
, " Notification %s (%s%s)\n",
9778 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
9781 code_str
, subcode_str
);
9783 vty_out(vty
, " %s\n",
9784 peer_down_str
[(int)peer
->last_reset
]);
9789 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
9792 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
9795 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
9796 struct peer
*peer
, json_object
*json_peer
,
9797 int max_neighbor_width
, bool use_json
)
9799 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
9803 if (peer_dynamic_neighbor(peer
))
9804 json_object_boolean_true_add(json_peer
,
9807 json_object_string_add(json_peer
, "hostname",
9810 if (peer
->domainname
)
9811 json_object_string_add(json_peer
, "domainname",
9813 json_object_int_add(json_peer
, "connectionsEstablished",
9815 json_object_int_add(json_peer
, "connectionsDropped",
9817 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9818 use_json
, json_peer
);
9819 if (peer_established(peer
))
9820 json_object_string_add(json_peer
, "lastResetDueTo",
9821 "AFI/SAFI Not Negotiated");
9823 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
9826 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
9828 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
9829 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
9830 peer
->hostname
, peer
->host
);
9832 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
9834 /* pad the neighbor column with spaces */
9835 if (len
< max_neighbor_width
)
9836 vty_out(vty
, "%*s", max_neighbor_width
- len
,
9838 vty_out(vty
, "%7d %7d %9s", peer
->established
,
9840 peer_uptime(peer
->uptime
, timebuf
,
9841 BGP_UPTIME_LEN
, 0, NULL
));
9842 if (peer_established(peer
))
9843 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
9845 bgp_show_peer_reset(vty
, peer
, NULL
,
9850 /* If the peer's description includes whitespaces
9851 * then return the first occurrence. Also strip description
9852 * to the given size if needed.
9854 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
9856 static char stripped
[BUFSIZ
];
9858 uint32_t len
= size
> strlen(desc
) ? strlen(desc
) : size
;
9860 pnt
= strchr(desc
, ' ');
9862 len
= size
> (uint32_t)(pnt
- desc
) ? (uint32_t)(pnt
- desc
)
9865 strlcpy(stripped
, desc
, len
+ 1);
9870 /* Determine whether var peer should be filtered out of the summary. */
9871 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
9872 struct peer
*fpeer
, int as_type
,
9876 /* filter neighbor XXXX */
9877 if (fpeer
&& fpeer
!= peer
)
9880 /* filter remote-as (internal|external) */
9881 if (as_type
!= AS_UNSPECIFIED
) {
9882 if (peer
->as_type
== AS_SPECIFIED
) {
9883 if (as_type
== AS_INTERNAL
) {
9884 if (peer
->as
!= peer
->local_as
)
9886 } else if (peer
->as
== peer
->local_as
)
9888 } else if (as_type
!= peer
->as_type
)
9890 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
9896 /* Show BGP peer's summary information. */
9897 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
9898 struct peer
*fpeer
, int as_type
, as_t as
,
9899 uint16_t show_flags
)
9902 struct listnode
*node
, *nnode
;
9903 unsigned int count
= 0, dn_count
= 0;
9904 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
9905 char neighbor_buf
[VTY_BUFSIZ
];
9906 int neighbor_col_default_width
= 16;
9907 int len
, failed_count
= 0;
9908 unsigned int filtered_count
= 0;
9909 int max_neighbor_width
= 0;
9911 json_object
*json
= NULL
;
9912 json_object
*json_peer
= NULL
;
9913 json_object
*json_peers
= NULL
;
9914 struct peer_af
*paf
;
9915 struct bgp_filter
*filter
;
9916 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
9917 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
9918 bool show_established
=
9919 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
9920 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
9921 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
9923 /* labeled-unicast routes are installed in the unicast table so in order
9925 * display the correct PfxRcd value we must look at SAFI_UNICAST
9928 if (safi
== SAFI_LABELED_UNICAST
)
9929 pfx_rcd_safi
= SAFI_UNICAST
;
9931 pfx_rcd_safi
= safi
;
9934 json
= json_object_new_object();
9935 json_peers
= json_object_new_object();
9936 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
9937 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
9944 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
9947 if (peer
->afc
[afi
][safi
]) {
9948 /* See if we have at least a single failed peer */
9949 if (bgp_has_peer_failed(peer
, afi
, safi
))
9953 if (peer_dynamic_neighbor(peer
))
9958 /* Loop over all neighbors that will be displayed to determine
9960 * characters are needed for the Neighbor column
9962 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
9963 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
9970 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
9973 if (peer
->afc
[afi
][safi
]) {
9974 memset(dn_flag
, '\0', sizeof(dn_flag
));
9975 if (peer_dynamic_neighbor(peer
))
9979 && CHECK_FLAG(bgp
->flags
,
9980 BGP_FLAG_SHOW_HOSTNAME
))
9981 snprintf(neighbor_buf
,
9982 sizeof(neighbor_buf
),
9983 "%s%s(%s) ", dn_flag
,
9984 peer
->hostname
, peer
->host
);
9986 snprintf(neighbor_buf
,
9987 sizeof(neighbor_buf
), "%s%s ",
9988 dn_flag
, peer
->host
);
9990 len
= strlen(neighbor_buf
);
9992 if (len
> max_neighbor_width
)
9993 max_neighbor_width
= len
;
9995 /* See if we have at least a single failed peer */
9996 if (bgp_has_peer_failed(peer
, afi
, safi
))
10002 /* Originally we displayed the Neighbor column as 16
10003 * characters wide so make that the default
10005 if (max_neighbor_width
< neighbor_col_default_width
)
10006 max_neighbor_width
= neighbor_col_default_width
;
10009 if (show_failed
&& !failed_count
) {
10011 json_object_int_add(json
, "failedPeersCount", 0);
10012 json_object_int_add(json
, "dynamicPeers", dn_count
);
10013 json_object_int_add(json
, "totalPeers", count
);
10015 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10016 json
, JSON_C_TO_STRING_PRETTY
));
10017 json_object_free(json
);
10019 vty_out(vty
, "%% No failed BGP neighbors found\n");
10021 return CMD_SUCCESS
;
10024 count
= 0; /* Reset the value as its used again */
10025 filtered_count
= 0;
10026 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10027 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10030 if (!peer
->afc
[afi
][safi
])
10034 unsigned long ents
;
10035 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10038 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10040 : (int64_t)bgp
->vrf_id
;
10042 /* Usage summary and header */
10044 char buf
[BUFSIZ
] = {0};
10046 json_object_string_add(
10048 inet_ntop(AF_INET
, &bgp
->router_id
, buf
,
10050 json_object_int_add(json
, "as", bgp
->as
);
10051 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10052 json_object_string_add(
10055 == BGP_INSTANCE_TYPE_DEFAULT
)
10060 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10061 &bgp
->router_id
, bgp
->as
,
10062 bgp
->vrf_id
== VRF_UNKNOWN
10064 : (int)bgp
->vrf_id
);
10065 vty_out(vty
, "\n");
10068 if (bgp_update_delay_configured(bgp
)) {
10070 json_object_int_add(
10071 json
, "updateDelayLimit",
10072 bgp
->v_update_delay
);
10074 if (bgp
->v_update_delay
10075 != bgp
->v_establish_wait
)
10076 json_object_int_add(
10078 "updateDelayEstablishWait",
10079 bgp
->v_establish_wait
);
10081 if (bgp_update_delay_active(bgp
)) {
10082 json_object_string_add(
10084 "updateDelayFirstNeighbor",
10085 bgp
->update_delay_begin_time
);
10086 json_object_boolean_true_add(
10088 "updateDelayInProgress");
10090 if (bgp
->update_delay_over
) {
10091 json_object_string_add(
10093 "updateDelayFirstNeighbor",
10094 bgp
->update_delay_begin_time
);
10095 json_object_string_add(
10097 "updateDelayBestpathResumed",
10098 bgp
->update_delay_end_time
);
10099 json_object_string_add(
10101 "updateDelayZebraUpdateResume",
10102 bgp
->update_delay_zebra_resume_time
);
10103 json_object_string_add(
10105 "updateDelayPeerUpdateResume",
10106 bgp
->update_delay_peers_resume_time
);
10111 "Read-only mode update-delay limit: %d seconds\n",
10112 bgp
->v_update_delay
);
10113 if (bgp
->v_update_delay
10114 != bgp
->v_establish_wait
)
10116 " Establish wait: %d seconds\n",
10117 bgp
->v_establish_wait
);
10119 if (bgp_update_delay_active(bgp
)) {
10121 " First neighbor established: %s\n",
10122 bgp
->update_delay_begin_time
);
10124 " Delay in progress\n");
10126 if (bgp
->update_delay_over
) {
10128 " First neighbor established: %s\n",
10129 bgp
->update_delay_begin_time
);
10131 " Best-paths resumed: %s\n",
10132 bgp
->update_delay_end_time
);
10134 " zebra update resumed: %s\n",
10135 bgp
->update_delay_zebra_resume_time
);
10137 " peers update resumed: %s\n",
10138 bgp
->update_delay_peers_resume_time
);
10145 if (bgp_maxmed_onstartup_configured(bgp
)
10146 && bgp
->maxmed_active
)
10147 json_object_boolean_true_add(
10148 json
, "maxMedOnStartup");
10149 if (bgp
->v_maxmed_admin
)
10150 json_object_boolean_true_add(
10151 json
, "maxMedAdministrative");
10153 json_object_int_add(
10154 json
, "tableVersion",
10155 bgp_table_version(bgp
->rib
[afi
][safi
]));
10157 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10158 json_object_int_add(json
, "ribCount", ents
);
10159 json_object_int_add(
10161 ents
* sizeof(struct bgp_dest
));
10163 ents
= bgp
->af_peer_count
[afi
][safi
];
10164 json_object_int_add(json
, "peerCount", ents
);
10165 json_object_int_add(json
, "peerMemory",
10166 ents
* sizeof(struct peer
));
10168 if ((ents
= listcount(bgp
->group
))) {
10169 json_object_int_add(
10170 json
, "peerGroupCount", ents
);
10171 json_object_int_add(
10172 json
, "peerGroupMemory",
10173 ents
* sizeof(struct
10177 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10178 BGP_CONFIG_DAMPENING
))
10179 json_object_boolean_true_add(
10180 json
, "dampeningEnabled");
10183 if (bgp_maxmed_onstartup_configured(bgp
)
10184 && bgp
->maxmed_active
)
10186 "Max-med on-startup active\n");
10187 if (bgp
->v_maxmed_admin
)
10189 "Max-med administrative active\n");
10192 "BGP table version %" PRIu64
10195 bgp
->rib
[afi
][safi
]));
10197 ents
= bgp_table_count(
10198 bgp
->rib
[afi
][safi
]);
10200 "RIB entries %ld, using %s of memory\n",
10210 /* Peer related usage */
10211 ents
= bgp
->af_peer_count
[afi
][safi
];
10213 "Peers %ld, using %s of memory\n",
10223 if ((ents
= listcount(bgp
->group
)))
10225 "Peer groups %ld, using %s of memory\n",
10235 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10236 BGP_CONFIG_DAMPENING
))
10238 "Dampening enabled.\n");
10241 vty_out(vty
, "\n");
10243 /* Subtract 8 here because 'Neighbor' is
10245 vty_out(vty
, "Neighbor");
10246 vty_out(vty
, "%*s",
10247 max_neighbor_width
- 8, " ");
10249 BGP_SHOW_SUMMARY_HEADER_FAILED
);
10254 paf
= peer_af_find(peer
, afi
, safi
);
10255 filter
= &peer
->filter
[afi
][safi
];
10258 /* Works for both failed & successful cases */
10259 if (peer_dynamic_neighbor(peer
))
10264 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10270 bgp_has_peer_failed(peer
, afi
, safi
)) {
10271 json_peer
= json_object_new_object();
10272 bgp_show_failed_summary(vty
, bgp
, peer
,
10273 json_peer
, 0, use_json
);
10274 } else if (!show_failed
) {
10275 if (show_established
10276 && bgp_has_peer_failed(peer
, afi
, safi
)) {
10281 json_peer
= json_object_new_object();
10282 if (peer_dynamic_neighbor(peer
)) {
10283 json_object_boolean_true_add(json_peer
,
10287 if (peer
->hostname
)
10288 json_object_string_add(json_peer
, "hostname",
10291 if (peer
->domainname
)
10292 json_object_string_add(json_peer
, "domainname",
10295 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
10296 json_object_int_add(
10297 json_peer
, "localAs",
10298 peer
->change_local_as
10299 ? peer
->change_local_as
10301 json_object_int_add(json_peer
, "version", 4);
10302 json_object_int_add(json_peer
, "msgRcvd",
10303 PEER_TOTAL_RX(peer
));
10304 json_object_int_add(json_peer
, "msgSent",
10305 PEER_TOTAL_TX(peer
));
10307 atomic_size_t outq_count
, inq_count
;
10308 outq_count
= atomic_load_explicit(
10309 &peer
->obuf
->count
,
10310 memory_order_relaxed
);
10311 inq_count
= atomic_load_explicit(
10312 &peer
->ibuf
->count
,
10313 memory_order_relaxed
);
10315 json_object_int_add(json_peer
, "tableVersion",
10316 peer
->version
[afi
][safi
]);
10317 json_object_int_add(json_peer
, "outq",
10319 json_object_int_add(json_peer
, "inq",
10321 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10322 use_json
, json_peer
);
10324 json_object_int_add(json_peer
, "pfxRcd",
10325 peer
->pcount
[afi
][pfx_rcd_safi
]);
10327 if (paf
&& PAF_SUBGRP(paf
))
10328 json_object_int_add(
10329 json_peer
, "pfxSnt",
10330 (PAF_SUBGRP(paf
))->scount
);
10332 json_object_int_add(json_peer
, "pfxSnt",
10335 /* BGP FSM state */
10336 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10337 || CHECK_FLAG(peer
->bgp
->flags
,
10338 BGP_FLAG_SHUTDOWN
))
10339 json_object_string_add(json_peer
,
10342 else if (peer
->afc_recv
[afi
][safi
])
10343 json_object_string_add(
10344 json_peer
, "state",
10345 lookup_msg(bgp_status_msg
,
10346 peer
->status
, NULL
));
10347 else if (CHECK_FLAG(
10349 PEER_STATUS_PREFIX_OVERFLOW
))
10350 json_object_string_add(json_peer
,
10354 json_object_string_add(
10355 json_peer
, "state",
10356 lookup_msg(bgp_status_msg
,
10357 peer
->status
, NULL
));
10359 /* BGP peer state */
10360 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10361 || CHECK_FLAG(peer
->bgp
->flags
,
10362 BGP_FLAG_SHUTDOWN
))
10363 json_object_string_add(json_peer
,
10366 else if (CHECK_FLAG(
10368 PEER_STATUS_PREFIX_OVERFLOW
))
10369 json_object_string_add(json_peer
,
10372 else if (CHECK_FLAG(peer
->flags
,
10373 PEER_FLAG_PASSIVE
))
10374 json_object_string_add(json_peer
,
10377 else if (CHECK_FLAG(peer
->sflags
,
10378 PEER_STATUS_NSF_WAIT
))
10379 json_object_string_add(json_peer
,
10382 else if (CHECK_FLAG(
10384 BGP_FLAG_EBGP_REQUIRES_POLICY
)
10385 && (!bgp_inbound_policy_exists(peer
,
10387 || !bgp_outbound_policy_exists(
10389 json_object_string_add(json_peer
,
10393 json_object_string_add(
10394 json_peer
, "peerState", "OK");
10396 json_object_int_add(json_peer
, "connectionsEstablished",
10397 peer
->established
);
10398 json_object_int_add(json_peer
, "connectionsDropped",
10401 json_object_string_add(
10402 json_peer
, "desc", peer
->desc
);
10404 /* Avoid creating empty peer dicts in JSON */
10405 if (json_peer
== NULL
)
10409 json_object_string_add(json_peer
, "idType",
10411 else if (peer
->su
.sa
.sa_family
== AF_INET
)
10412 json_object_string_add(json_peer
, "idType",
10414 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
10415 json_object_string_add(json_peer
, "idType",
10417 json_object_object_add(json_peers
, peer
->host
,
10420 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10426 bgp_has_peer_failed(peer
, afi
, safi
)) {
10427 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
10428 max_neighbor_width
,
10430 } else if (!show_failed
) {
10431 if (show_established
10432 && bgp_has_peer_failed(peer
, afi
, safi
)) {
10437 if ((count
- filtered_count
) == 1) {
10438 /* display headline before the first
10440 vty_out(vty
, "\n");
10442 /* Subtract 8 here because 'Neighbor' is
10444 vty_out(vty
, "Neighbor");
10445 vty_out(vty
, "%*s",
10446 max_neighbor_width
- 8, " ");
10449 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
10450 : BGP_SHOW_SUMMARY_HEADER_ALL
);
10453 memset(dn_flag
, '\0', sizeof(dn_flag
));
10454 if (peer_dynamic_neighbor(peer
)) {
10459 && CHECK_FLAG(bgp
->flags
,
10460 BGP_FLAG_SHOW_HOSTNAME
))
10461 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10465 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10467 /* pad the neighbor column with spaces */
10468 if (len
< max_neighbor_width
)
10469 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10472 atomic_size_t outq_count
, inq_count
;
10473 outq_count
= atomic_load_explicit(
10474 &peer
->obuf
->count
,
10475 memory_order_relaxed
);
10476 inq_count
= atomic_load_explicit(
10477 &peer
->ibuf
->count
,
10478 memory_order_relaxed
);
10482 "4 %10u %10u %9u %9u %8" PRIu64
10485 peer
->change_local_as
10486 ? peer
->change_local_as
10488 PEER_TOTAL_RX(peer
),
10489 PEER_TOTAL_TX(peer
),
10490 peer
->version
[afi
][safi
],
10491 inq_count
, outq_count
,
10492 peer_uptime(peer
->uptime
,
10497 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
10499 peer
->as
, PEER_TOTAL_RX(peer
),
10500 PEER_TOTAL_TX(peer
),
10501 peer
->version
[afi
][safi
],
10502 inq_count
, outq_count
,
10503 peer_uptime(peer
->uptime
,
10508 if (peer_established(peer
)) {
10509 if (peer
->afc_recv
[afi
][safi
]) {
10512 BGP_FLAG_EBGP_REQUIRES_POLICY
)
10513 && !bgp_inbound_policy_exists(
10515 vty_out(vty
, " %12s",
10524 vty_out(vty
, " NoNeg");
10527 if (paf
&& PAF_SUBGRP(paf
)) {
10530 BGP_FLAG_EBGP_REQUIRES_POLICY
)
10531 && !bgp_outbound_policy_exists(
10533 vty_out(vty
, " %8s",
10542 vty_out(vty
, " NoNeg");
10545 if (CHECK_FLAG(peer
->flags
,
10546 PEER_FLAG_SHUTDOWN
)
10547 || CHECK_FLAG(peer
->bgp
->flags
,
10548 BGP_FLAG_SHUTDOWN
))
10549 vty_out(vty
, " Idle (Admin)");
10550 else if (CHECK_FLAG(
10552 PEER_STATUS_PREFIX_OVERFLOW
))
10553 vty_out(vty
, " Idle (PfxCt)");
10555 vty_out(vty
, " %12s",
10556 lookup_msg(bgp_status_msg
,
10557 peer
->status
, NULL
));
10559 vty_out(vty
, " %8u", 0);
10562 vty_out(vty
, " %s",
10563 bgp_peer_description_stripped(
10565 show_wide
? 64 : 20));
10567 vty_out(vty
, " N/A");
10568 vty_out(vty
, "\n");
10575 json_object_object_add(json
, "peers", json_peers
);
10576 json_object_int_add(json
, "failedPeers", failed_count
);
10577 json_object_int_add(json
, "displayedPeers",
10578 count
- filtered_count
);
10579 json_object_int_add(json
, "totalPeers", count
);
10580 json_object_int_add(json
, "dynamicPeers", dn_count
);
10583 bgp_show_bestpath_json(bgp
, json
);
10585 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10586 json
, JSON_C_TO_STRING_PRETTY
));
10587 json_object_free(json
);
10590 if (filtered_count
== count
)
10591 vty_out(vty
, "\n%% No matching neighbor\n");
10594 vty_out(vty
, "\nDisplayed neighbors %d",
10596 else if (as_type
!= AS_UNSPECIFIED
|| as
10597 || fpeer
|| show_established
)
10598 vty_out(vty
, "\nDisplayed neighbors %d",
10599 count
- filtered_count
);
10601 vty_out(vty
, "\nTotal number of neighbors %d\n",
10605 vty_out(vty
, "No %s neighbor is configured\n",
10606 get_afi_safi_str(afi
, safi
, false));
10610 vty_out(vty
, "* - dynamic neighbor\n");
10611 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
10612 dn_count
, bgp
->dynamic_neighbors_limit
);
10616 return CMD_SUCCESS
;
10619 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
10620 int safi
, struct peer
*fpeer
, int as_type
,
10621 as_t as
, uint16_t show_flags
)
10624 int afi_wildcard
= (afi
== AFI_MAX
);
10625 int safi_wildcard
= (safi
== SAFI_MAX
);
10626 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
10627 bool nbr_output
= false;
10628 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10630 if (use_json
&& is_wildcard
)
10631 vty_out(vty
, "{\n");
10633 afi
= 1; /* AFI_IP */
10634 while (afi
< AFI_MAX
) {
10636 safi
= 1; /* SAFI_UNICAST */
10637 while (safi
< SAFI_MAX
) {
10638 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
10643 * So limit output to those afi/safi
10645 * actualy have something interesting in
10650 vty_out(vty
, ",\n");
10654 vty_out(vty
, "\"%s\":",
10655 get_afi_safi_str(afi
,
10660 "\n%s Summary (%s):\n",
10661 get_afi_safi_str(afi
,
10667 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
10668 as_type
, as
, show_flags
);
10671 if (!safi_wildcard
)
10679 if (use_json
&& is_wildcard
)
10680 vty_out(vty
, "}\n");
10681 else if (!nbr_output
) {
10683 vty_out(vty
, "{}\n");
10685 vty_out(vty
, "%% No BGP neighbors found in %s\n",
10690 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
10692 const char *neighbor
,
10693 int as_type
, as_t as
,
10694 uint16_t show_flags
)
10696 struct listnode
*node
, *nnode
;
10698 struct peer
*fpeer
= NULL
;
10700 bool nbr_output
= false;
10701 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10704 vty_out(vty
, "{\n");
10706 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
10710 vty_out(vty
, ",\n");
10714 vty_out(vty
, "\"%s\":",
10715 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10720 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
10725 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
10730 vty_out(vty
, "}\n");
10731 else if (!nbr_output
)
10732 vty_out(vty
, "%% BGP instance not found\n");
10735 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
10736 safi_t safi
, const char *neighbor
, int as_type
,
10737 as_t as
, uint16_t show_flags
)
10740 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10741 struct peer
*fpeer
= NULL
;
10744 if (strmatch(name
, "all")) {
10745 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
10748 return CMD_SUCCESS
;
10750 bgp
= bgp_lookup_by_name(name
);
10754 vty_out(vty
, "{}\n");
10757 "%% BGP instance not found\n");
10758 return CMD_WARNING
;
10762 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
10765 return CMD_WARNING
;
10767 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
10768 as_type
, as
, show_flags
);
10769 return CMD_SUCCESS
;
10773 bgp
= bgp_get_default();
10777 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
10780 return CMD_WARNING
;
10782 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
10786 vty_out(vty
, "{}\n");
10788 vty_out(vty
, "%% BGP instance not found\n");
10789 return CMD_WARNING
;
10792 return CMD_SUCCESS
;
10795 /* `show [ip] bgp summary' commands. */
10796 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
10797 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
10798 " [" BGP_SAFI_WITH_LABEL_CMD_STR
10799 "]] [all$all] summary [established|failed] [<neighbor <A.B.C.D|X:X::X:X|WORD>|remote-as <(1-4294967295)|internal|external>>] [terse] [wide] [json$uj]",
10800 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
10801 BGP_SAFI_WITH_LABEL_HELP_STR
10802 "Display the entries for all address families\n"
10803 "Summary of BGP neighbor status\n"
10804 "Show only sessions in Established state\n"
10805 "Show only sessions not in Established state\n"
10806 "Show only the specified neighbor session\n"
10807 "Neighbor to display information about\n"
10808 "Neighbor to display information about\n"
10809 "Neighbor on BGP configured interface\n"
10810 "Show only the specified remote AS sessions\n"
10812 "Internal (iBGP) AS sessions\n"
10813 "External (eBGP) AS sessions\n"
10814 "Shorten the information on BGP instances\n"
10815 "Increase table width for longer output\n" JSON_STR
)
10818 afi_t afi
= AFI_MAX
;
10819 safi_t safi
= SAFI_MAX
;
10820 as_t as
= 0; /* 0 means AS filter not set */
10821 int as_type
= AS_UNSPECIFIED
;
10822 uint16_t show_flags
= 0;
10826 /* show [ip] bgp */
10827 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
10829 /* [<vrf> VIEWVRFNAME] */
10830 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10831 vrf
= argv
[idx
+ 1]->arg
;
10832 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10834 } else if (argv_find(argv
, argc
, "view", &idx
))
10835 /* [<view> VIEWVRFNAME] */
10836 vrf
= argv
[idx
+ 1]->arg
;
10837 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
10838 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
10839 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
10842 if (argv_find(argv
, argc
, "failed", &idx
))
10843 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10845 if (argv_find(argv
, argc
, "established", &idx
))
10846 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10848 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
10849 if (argv
[idx
+ 1]->arg
[0] == 'i')
10850 as_type
= AS_INTERNAL
;
10851 else if (argv
[idx
+ 1]->arg
[0] == 'e')
10852 as_type
= AS_EXTERNAL
;
10854 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
10857 if (argv_find(argv
, argc
, "terse", &idx
))
10858 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
10860 if (argv_find(argv
, argc
, "wide", &idx
))
10861 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10863 if (argv_find(argv
, argc
, "json", &idx
))
10864 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10866 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
10870 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
10873 return get_afi_safi_json_str(afi
, safi
);
10875 return get_afi_safi_vty_str(afi
, safi
);
10879 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
10880 afi_t afi
, safi_t safi
,
10881 uint16_t adv_smcap
, uint16_t adv_rmcap
,
10882 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
10883 bool use_json
, json_object
*json_pref
)
10886 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
10887 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
10889 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
10890 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
10891 json_object_string_add(json_pref
, "sendMode",
10892 "advertisedAndReceived");
10893 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
10894 json_object_string_add(json_pref
, "sendMode",
10896 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
10897 json_object_string_add(json_pref
, "sendMode",
10900 vty_out(vty
, " Send-mode: ");
10901 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
10902 vty_out(vty
, "advertised");
10903 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
10904 vty_out(vty
, "%sreceived",
10905 CHECK_FLAG(p
->af_cap
[afi
][safi
],
10909 vty_out(vty
, "\n");
10914 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
10915 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
10917 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
10918 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
10919 json_object_string_add(json_pref
, "recvMode",
10920 "advertisedAndReceived");
10921 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
10922 json_object_string_add(json_pref
, "recvMode",
10924 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
10925 json_object_string_add(json_pref
, "recvMode",
10928 vty_out(vty
, " Receive-mode: ");
10929 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
10930 vty_out(vty
, "advertised");
10931 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
10932 vty_out(vty
, "%sreceived",
10933 CHECK_FLAG(p
->af_cap
[afi
][safi
],
10937 vty_out(vty
, "\n");
10942 static void bgp_show_neighnor_graceful_restart_rbit(struct vty
*vty
,
10947 bool rbit_status
= false;
10950 vty_out(vty
, "\n R bit: ");
10952 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
10953 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
10954 && (peer_established(p
))) {
10956 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_BIT_RCV
))
10957 rbit_status
= true;
10959 rbit_status
= false;
10964 json_object_boolean_true_add(json
, "rBit");
10966 vty_out(vty
, "True\n");
10969 json_object_boolean_false_add(json
, "rBit");
10971 vty_out(vty
, "False\n");
10975 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
10980 const char *mode
= "NotApplicable";
10983 vty_out(vty
, "\n Remote GR Mode: ");
10985 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
10986 && (peer_established(peer
))) {
10988 if ((peer
->nsf_af_count
== 0)
10989 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
10993 } else if (peer
->nsf_af_count
== 0
10994 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
10998 } else if (peer
->nsf_af_count
!= 0
10999 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11006 json_object_string_add(json
, "remoteGrMode", mode
);
11008 vty_out(vty
, mode
, "\n");
11011 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11016 const char *mode
= "Invalid";
11019 vty_out(vty
, " Local GR Mode: ");
11021 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11023 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11025 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11027 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11028 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11030 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11032 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11039 json_object_string_add(json
, "localGrMode", mode
);
11041 vty_out(vty
, mode
, "\n");
11045 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11046 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11050 json_object
*json_afi_safi
= NULL
;
11051 json_object
*json_timer
= NULL
;
11052 json_object
*json_endofrib_status
= NULL
;
11053 bool eor_flag
= false;
11055 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11056 for (safi
= SAFI_UNICAST
; safi
<= SAFI_MPLS_VPN
; safi
++) {
11057 if (!peer
->afc
[afi
][safi
])
11060 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11061 || !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11065 json_afi_safi
= json_object_new_object();
11066 json_endofrib_status
= json_object_new_object();
11067 json_timer
= json_object_new_object();
11070 if (peer
->eor_stime
[afi
][safi
]
11071 >= peer
->pkt_stime
[afi
][safi
])
11077 vty_out(vty
, " %s:\n",
11078 get_afi_safi_str(afi
, safi
, false));
11080 vty_out(vty
, " F bit: ");
11083 if (peer
->nsf
[afi
][safi
]
11084 && CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11085 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11088 json_object_boolean_true_add(
11089 json_afi_safi
, "fBit");
11091 vty_out(vty
, "True\n");
11094 json_object_boolean_false_add(
11095 json_afi_safi
, "fBit");
11097 vty_out(vty
, "False\n");
11101 vty_out(vty
, " End-of-RIB sent: ");
11103 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11104 PEER_STATUS_EOR_SEND
)) {
11106 json_object_boolean_true_add(
11107 json_endofrib_status
,
11110 PRINT_EOR_JSON(eor_flag
);
11112 vty_out(vty
, "Yes\n");
11114 " End-of-RIB sent after update: ");
11116 PRINT_EOR(eor_flag
);
11120 json_object_boolean_false_add(
11121 json_endofrib_status
,
11123 json_object_boolean_false_add(
11124 json_endofrib_status
,
11125 "endOfRibSentAfterUpdate");
11127 vty_out(vty
, "No\n");
11129 " End-of-RIB sent after update: ");
11130 vty_out(vty
, "No\n");
11135 vty_out(vty
, " End-of-RIB received: ");
11137 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11138 PEER_STATUS_EOR_RECEIVED
)) {
11140 json_object_boolean_true_add(
11141 json_endofrib_status
,
11144 vty_out(vty
, "Yes\n");
11147 json_object_boolean_false_add(
11148 json_endofrib_status
,
11151 vty_out(vty
, "No\n");
11155 json_object_int_add(json_timer
,
11157 peer
->bgp
->stalepath_time
);
11159 if (peer
->t_gr_stale
!= NULL
) {
11160 json_object_int_add(
11162 "stalePathTimerRemaining",
11163 thread_timer_remain_second(
11164 peer
->t_gr_stale
));
11167 /* Display Configured Selection
11168 * Deferral only when when
11169 * Gr mode is enabled.
11171 if (CHECK_FLAG(peer
->flags
,
11172 PEER_FLAG_GRACEFUL_RESTART
)) {
11173 json_object_int_add(
11175 "selectionDeferralTimer",
11176 peer
->bgp
->stalepath_time
);
11179 if (peer
->bgp
->gr_info
[afi
][safi
]
11183 json_object_int_add(
11185 "selectionDeferralTimerRemaining",
11186 thread_timer_remain_second(
11190 .t_select_deferral
));
11193 vty_out(vty
, " Timers:\n");
11195 " Configured Stale Path Time(sec): %u\n",
11196 peer
->bgp
->stalepath_time
);
11198 if (peer
->t_gr_stale
!= NULL
)
11200 " Stale Path Remaining(sec): %ld\n",
11201 thread_timer_remain_second(
11202 peer
->t_gr_stale
));
11203 /* Display Configured Selection
11204 * Deferral only when when
11205 * Gr mode is enabled.
11207 if (CHECK_FLAG(peer
->flags
,
11208 PEER_FLAG_GRACEFUL_RESTART
))
11210 " Configured Selection Deferral Time(sec): %u\n",
11211 peer
->bgp
->select_defer_time
);
11213 if (peer
->bgp
->gr_info
[afi
][safi
]
11217 " Selection Deferral Time Remaining(sec): %ld\n",
11218 thread_timer_remain_second(
11222 .t_select_deferral
));
11225 json_object_object_add(json_afi_safi
,
11227 json_endofrib_status
);
11228 json_object_object_add(json_afi_safi
, "timers",
11230 json_object_object_add(
11231 json
, get_afi_safi_str(afi
, safi
, true),
11238 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
11244 json_object
*json_timer
= NULL
;
11246 json_timer
= json_object_new_object();
11248 json_object_int_add(json_timer
, "configuredRestartTimer",
11249 p
->bgp
->restart_time
);
11251 json_object_int_add(json_timer
, "receivedRestartTimer",
11254 if (p
->t_gr_restart
!= NULL
)
11255 json_object_int_add(
11256 json_timer
, "restartTimerRemaining",
11257 thread_timer_remain_second(p
->t_gr_restart
));
11259 json_object_object_add(json
, "timers", json_timer
);
11262 vty_out(vty
, " Timers:\n");
11263 vty_out(vty
, " Configured Restart Time(sec): %u\n",
11264 p
->bgp
->restart_time
);
11266 vty_out(vty
, " Received Restart Time(sec): %u\n",
11268 if (p
->t_gr_restart
!= NULL
)
11269 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11270 thread_timer_remain_second(p
->t_gr_restart
));
11271 if (p
->t_gr_restart
!= NULL
) {
11272 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11273 thread_timer_remain_second(p
->t_gr_restart
));
11278 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
11279 bool use_json
, json_object
*json
)
11281 char buf
[SU_ADDRSTRLEN
] = {0};
11282 char dn_flag
[2] = {0};
11283 /* '*' + v6 address of neighbor */
11284 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
11286 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11291 json_object_string_add(
11292 json
, "neighborAddr",
11293 BGP_PEER_SU_UNSPEC(p
)
11295 : sockunion2str(&p
->su
, buf
,
11298 vty_out(vty
, "BGP neighbor on %s: %s\n", p
->conf_if
,
11299 BGP_PEER_SU_UNSPEC(p
)
11301 : sockunion2str(&p
->su
, buf
,
11304 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
11308 json_object_string_add(json
, "neighborAddr",
11311 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
11314 /* more gr info in new format */
11315 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
11318 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
11319 safi_t safi
, bool use_json
,
11320 json_object
*json_neigh
)
11322 struct bgp_filter
*filter
;
11323 struct peer_af
*paf
;
11324 char orf_pfx_name
[BUFSIZ
];
11326 json_object
*json_af
= NULL
;
11327 json_object
*json_prefA
= NULL
;
11328 json_object
*json_prefB
= NULL
;
11329 json_object
*json_addr
= NULL
;
11330 json_object
*json_advmap
= NULL
;
11333 json_addr
= json_object_new_object();
11334 json_af
= json_object_new_object();
11335 filter
= &p
->filter
[afi
][safi
];
11337 if (peer_group_active(p
))
11338 json_object_string_add(json_addr
, "peerGroupMember",
11341 paf
= peer_af_find(p
, afi
, safi
);
11342 if (paf
&& PAF_SUBGRP(paf
)) {
11343 json_object_int_add(json_addr
, "updateGroupId",
11344 PAF_UPDGRP(paf
)->id
);
11345 json_object_int_add(json_addr
, "subGroupId",
11346 PAF_SUBGRP(paf
)->id
);
11347 json_object_int_add(json_addr
, "packetQueueLength",
11348 bpacket_queue_virtual_length(paf
));
11351 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11352 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11353 PEER_CAP_ORF_PREFIX_SM_RCV
)
11354 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11355 PEER_CAP_ORF_PREFIX_RM_ADV
)
11356 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11357 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11358 json_object_int_add(json_af
, "orfType",
11360 json_prefA
= json_object_new_object();
11361 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
11362 PEER_CAP_ORF_PREFIX_SM_ADV
,
11363 PEER_CAP_ORF_PREFIX_RM_ADV
,
11364 PEER_CAP_ORF_PREFIX_SM_RCV
,
11365 PEER_CAP_ORF_PREFIX_RM_RCV
,
11366 use_json
, json_prefA
);
11367 json_object_object_add(json_af
, "orfPrefixList",
11371 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11372 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11373 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11374 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11375 PEER_CAP_ORF_PREFIX_RM_ADV
)
11376 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11377 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
11378 json_object_int_add(json_af
, "orfOldType",
11379 ORF_TYPE_PREFIX_OLD
);
11380 json_prefB
= json_object_new_object();
11381 bgp_show_peer_afi_orf_cap(
11382 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
11383 PEER_CAP_ORF_PREFIX_RM_ADV
,
11384 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
11385 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
11387 json_object_object_add(json_af
, "orfOldPrefixList",
11391 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11392 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11393 PEER_CAP_ORF_PREFIX_SM_RCV
)
11394 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11395 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11396 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11397 PEER_CAP_ORF_PREFIX_RM_ADV
)
11398 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11399 PEER_CAP_ORF_PREFIX_RM_RCV
)
11400 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11401 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
11402 json_object_object_add(json_addr
, "afDependentCap",
11405 json_object_free(json_af
);
11407 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
11408 p
->host
, afi
, safi
);
11409 orf_pfx_count
= prefix_bgp_show_prefix_list(
11410 NULL
, afi
, orf_pfx_name
, use_json
);
11412 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11413 PEER_STATUS_ORF_PREFIX_SEND
)
11414 || orf_pfx_count
) {
11415 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11416 PEER_STATUS_ORF_PREFIX_SEND
))
11417 json_object_boolean_true_add(json_neigh
,
11420 json_object_int_add(json_addr
, "orfRecvCounter",
11423 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11424 PEER_STATUS_ORF_WAIT_REFRESH
))
11425 json_object_string_add(
11426 json_addr
, "orfFirstUpdate",
11427 "deferredUntilORFOrRouteRefreshRecvd");
11429 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11430 PEER_FLAG_REFLECTOR_CLIENT
))
11431 json_object_boolean_true_add(json_addr
,
11432 "routeReflectorClient");
11433 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11434 PEER_FLAG_RSERVER_CLIENT
))
11435 json_object_boolean_true_add(json_addr
,
11436 "routeServerClient");
11437 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
11438 json_object_boolean_true_add(json_addr
,
11439 "inboundSoftConfigPermit");
11441 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11442 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
11443 json_object_boolean_true_add(
11445 "privateAsNumsAllReplacedInUpdatesToNbr");
11446 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11447 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
11448 json_object_boolean_true_add(
11450 "privateAsNumsReplacedInUpdatesToNbr");
11451 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11452 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
11453 json_object_boolean_true_add(
11455 "privateAsNumsAllRemovedInUpdatesToNbr");
11456 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11457 PEER_FLAG_REMOVE_PRIVATE_AS
))
11458 json_object_boolean_true_add(
11460 "privateAsNumsRemovedInUpdatesToNbr");
11462 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
11463 json_object_boolean_true_add(
11465 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
11468 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
11469 json_object_string_add(json_addr
,
11470 "overrideASNsInOutboundUpdates",
11471 "ifAspathEqualRemoteAs");
11473 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
11474 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11475 PEER_FLAG_FORCE_NEXTHOP_SELF
))
11476 json_object_boolean_true_add(json_addr
,
11477 "routerAlwaysNextHop");
11478 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11479 PEER_FLAG_AS_PATH_UNCHANGED
))
11480 json_object_boolean_true_add(
11481 json_addr
, "unchangedAsPathPropogatedToNbr");
11482 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11483 PEER_FLAG_NEXTHOP_UNCHANGED
))
11484 json_object_boolean_true_add(
11485 json_addr
, "unchangedNextHopPropogatedToNbr");
11486 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
11487 json_object_boolean_true_add(
11488 json_addr
, "unchangedMedPropogatedToNbr");
11489 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
11490 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11491 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
11492 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11493 PEER_FLAG_SEND_COMMUNITY
)
11494 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
11495 PEER_FLAG_SEND_EXT_COMMUNITY
))
11496 json_object_string_add(json_addr
,
11497 "commAttriSentToNbr",
11498 "extendedAndStandard");
11499 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11500 PEER_FLAG_SEND_EXT_COMMUNITY
))
11501 json_object_string_add(json_addr
,
11502 "commAttriSentToNbr",
11505 json_object_string_add(json_addr
,
11506 "commAttriSentToNbr",
11509 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11510 PEER_FLAG_DEFAULT_ORIGINATE
)) {
11511 if (p
->default_rmap
[afi
][safi
].name
)
11512 json_object_string_add(
11513 json_addr
, "defaultRouteMap",
11514 p
->default_rmap
[afi
][safi
].name
);
11516 if (paf
&& PAF_SUBGRP(paf
)
11517 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
11518 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
11519 json_object_boolean_true_add(json_addr
,
11522 json_object_boolean_true_add(json_addr
,
11526 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
11527 if (is_evpn_enabled())
11528 json_object_boolean_true_add(
11529 json_addr
, "advertiseAllVnis");
11532 if (filter
->plist
[FILTER_IN
].name
11533 || filter
->dlist
[FILTER_IN
].name
11534 || filter
->aslist
[FILTER_IN
].name
11535 || filter
->map
[RMAP_IN
].name
)
11536 json_object_boolean_true_add(json_addr
,
11537 "inboundPathPolicyConfig");
11538 if (filter
->plist
[FILTER_OUT
].name
11539 || filter
->dlist
[FILTER_OUT
].name
11540 || filter
->aslist
[FILTER_OUT
].name
11541 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
11542 json_object_boolean_true_add(
11543 json_addr
, "outboundPathPolicyConfig");
11546 if (filter
->plist
[FILTER_IN
].name
)
11547 json_object_string_add(json_addr
,
11548 "incomingUpdatePrefixFilterList",
11549 filter
->plist
[FILTER_IN
].name
);
11550 if (filter
->plist
[FILTER_OUT
].name
)
11551 json_object_string_add(json_addr
,
11552 "outgoingUpdatePrefixFilterList",
11553 filter
->plist
[FILTER_OUT
].name
);
11555 /* distribute-list */
11556 if (filter
->dlist
[FILTER_IN
].name
)
11557 json_object_string_add(
11558 json_addr
, "incomingUpdateNetworkFilterList",
11559 filter
->dlist
[FILTER_IN
].name
);
11560 if (filter
->dlist
[FILTER_OUT
].name
)
11561 json_object_string_add(
11562 json_addr
, "outgoingUpdateNetworkFilterList",
11563 filter
->dlist
[FILTER_OUT
].name
);
11566 if (filter
->aslist
[FILTER_IN
].name
)
11567 json_object_string_add(json_addr
,
11568 "incomingUpdateAsPathFilterList",
11569 filter
->aslist
[FILTER_IN
].name
);
11570 if (filter
->aslist
[FILTER_OUT
].name
)
11571 json_object_string_add(json_addr
,
11572 "outgoingUpdateAsPathFilterList",
11573 filter
->aslist
[FILTER_OUT
].name
);
11576 if (filter
->map
[RMAP_IN
].name
)
11577 json_object_string_add(
11578 json_addr
, "routeMapForIncomingAdvertisements",
11579 filter
->map
[RMAP_IN
].name
);
11580 if (filter
->map
[RMAP_OUT
].name
)
11581 json_object_string_add(
11582 json_addr
, "routeMapForOutgoingAdvertisements",
11583 filter
->map
[RMAP_OUT
].name
);
11585 /* ebgp-requires-policy (inbound) */
11586 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
11587 && !bgp_inbound_policy_exists(p
, filter
))
11588 json_object_string_add(
11589 json_addr
, "inboundEbgpRequiresPolicy",
11590 "Inbound updates discarded due to missing policy");
11592 /* ebgp-requires-policy (outbound) */
11593 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
11594 && (!bgp_outbound_policy_exists(p
, filter
)))
11595 json_object_string_add(
11596 json_addr
, "outboundEbgpRequiresPolicy",
11597 "Outbound updates discarded due to missing policy");
11599 /* unsuppress-map */
11600 if (filter
->usmap
.name
)
11601 json_object_string_add(json_addr
,
11602 "selectiveUnsuppressRouteMap",
11603 filter
->usmap
.name
);
11605 /* advertise-map */
11606 if (filter
->advmap
.aname
) {
11607 json_advmap
= json_object_new_object();
11608 json_object_string_add(json_advmap
, "condition",
11609 filter
->advmap
.condition
11612 json_object_string_add(json_advmap
, "conditionMap",
11613 filter
->advmap
.cname
);
11614 json_object_string_add(json_advmap
, "advertiseMap",
11615 filter
->advmap
.aname
);
11616 json_object_string_add(json_advmap
, "advertiseStatus",
11617 filter
->advmap
.update_type
11621 json_object_object_add(json_addr
, "advertiseMap",
11625 /* Receive prefix count */
11626 json_object_int_add(json_addr
, "acceptedPrefixCounter",
11627 p
->pcount
[afi
][safi
]);
11628 if (paf
&& PAF_SUBGRP(paf
))
11629 json_object_int_add(json_addr
, "sentPrefixCounter",
11630 (PAF_SUBGRP(paf
))->scount
);
11632 /* Maximum prefix */
11633 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
11634 json_object_int_add(json_addr
, "prefixOutAllowedMax",
11635 p
->pmax_out
[afi
][safi
]);
11637 /* Maximum prefix */
11638 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
11639 json_object_int_add(json_addr
, "prefixAllowedMax",
11640 p
->pmax
[afi
][safi
]);
11641 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11642 PEER_FLAG_MAX_PREFIX_WARNING
))
11643 json_object_boolean_true_add(
11644 json_addr
, "prefixAllowedMaxWarning");
11645 json_object_int_add(json_addr
,
11646 "prefixAllowedWarningThresh",
11647 p
->pmax_threshold
[afi
][safi
]);
11648 if (p
->pmax_restart
[afi
][safi
])
11649 json_object_int_add(
11651 "prefixAllowedRestartIntervalMsecs",
11652 p
->pmax_restart
[afi
][safi
] * 60000);
11654 json_object_object_add(json_neigh
,
11655 get_afi_safi_str(afi
, safi
, true),
11659 filter
= &p
->filter
[afi
][safi
];
11661 vty_out(vty
, " For address family: %s\n",
11662 get_afi_safi_str(afi
, safi
, false));
11664 if (peer_group_active(p
))
11665 vty_out(vty
, " %s peer-group member\n",
11668 paf
= peer_af_find(p
, afi
, safi
);
11669 if (paf
&& PAF_SUBGRP(paf
)) {
11670 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
11671 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
11672 vty_out(vty
, " Packet Queue length %d\n",
11673 bpacket_queue_virtual_length(paf
));
11675 vty_out(vty
, " Not part of any update group\n");
11677 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11678 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11679 PEER_CAP_ORF_PREFIX_SM_RCV
)
11680 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11681 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11682 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11683 PEER_CAP_ORF_PREFIX_RM_ADV
)
11684 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11685 PEER_CAP_ORF_PREFIX_RM_RCV
)
11686 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11687 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
11688 vty_out(vty
, " AF-dependant capabilities:\n");
11690 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11691 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11692 PEER_CAP_ORF_PREFIX_SM_RCV
)
11693 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11694 PEER_CAP_ORF_PREFIX_RM_ADV
)
11695 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11696 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11698 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
11700 bgp_show_peer_afi_orf_cap(
11701 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
11702 PEER_CAP_ORF_PREFIX_RM_ADV
,
11703 PEER_CAP_ORF_PREFIX_SM_RCV
,
11704 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
11706 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11707 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11708 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11709 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11710 PEER_CAP_ORF_PREFIX_RM_ADV
)
11711 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11712 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
11714 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
11715 ORF_TYPE_PREFIX_OLD
);
11716 bgp_show_peer_afi_orf_cap(
11717 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
11718 PEER_CAP_ORF_PREFIX_RM_ADV
,
11719 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
11720 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
11723 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
11724 p
->host
, afi
, safi
);
11725 orf_pfx_count
= prefix_bgp_show_prefix_list(
11726 NULL
, afi
, orf_pfx_name
, use_json
);
11728 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11729 PEER_STATUS_ORF_PREFIX_SEND
)
11730 || orf_pfx_count
) {
11731 vty_out(vty
, " Outbound Route Filter (ORF):");
11732 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11733 PEER_STATUS_ORF_PREFIX_SEND
))
11734 vty_out(vty
, " sent;");
11736 vty_out(vty
, " received (%d entries)",
11738 vty_out(vty
, "\n");
11740 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11741 PEER_STATUS_ORF_WAIT_REFRESH
))
11743 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
11745 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11746 PEER_FLAG_REFLECTOR_CLIENT
))
11747 vty_out(vty
, " Route-Reflector Client\n");
11748 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11749 PEER_FLAG_RSERVER_CLIENT
))
11750 vty_out(vty
, " Route-Server Client\n");
11751 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
11753 " Inbound soft reconfiguration allowed\n");
11755 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11756 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
11758 " Private AS numbers (all) replaced in updates to this neighbor\n");
11759 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11760 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
11762 " Private AS numbers replaced in updates to this neighbor\n");
11763 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11764 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
11766 " Private AS numbers (all) removed in updates to this neighbor\n");
11767 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11768 PEER_FLAG_REMOVE_PRIVATE_AS
))
11770 " Private AS numbers removed in updates to this neighbor\n");
11772 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
11773 vty_out(vty
, " %s\n",
11774 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
11775 ->human_description
);
11777 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
11779 " Override ASNs in outbound updates if aspath equals remote-as\n");
11781 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
11782 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11783 PEER_FLAG_FORCE_NEXTHOP_SELF
))
11784 vty_out(vty
, " NEXT_HOP is always this router\n");
11785 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11786 PEER_FLAG_AS_PATH_UNCHANGED
))
11788 " AS_PATH is propagated unchanged to this neighbor\n");
11789 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11790 PEER_FLAG_NEXTHOP_UNCHANGED
))
11792 " NEXT_HOP is propagated unchanged to this neighbor\n");
11793 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
11795 " MED is propagated unchanged to this neighbor\n");
11796 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
11797 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11798 PEER_FLAG_SEND_EXT_COMMUNITY
)
11799 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11800 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
11802 " Community attribute sent to this neighbor");
11803 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11804 PEER_FLAG_SEND_COMMUNITY
)
11805 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
11806 PEER_FLAG_SEND_EXT_COMMUNITY
)
11807 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
11808 PEER_FLAG_SEND_LARGE_COMMUNITY
))
11809 vty_out(vty
, "(all)\n");
11810 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11811 PEER_FLAG_SEND_LARGE_COMMUNITY
))
11812 vty_out(vty
, "(large)\n");
11813 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11814 PEER_FLAG_SEND_EXT_COMMUNITY
))
11815 vty_out(vty
, "(extended)\n");
11817 vty_out(vty
, "(standard)\n");
11819 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11820 PEER_FLAG_DEFAULT_ORIGINATE
)) {
11821 vty_out(vty
, " Default information originate,");
11823 if (p
->default_rmap
[afi
][safi
].name
)
11824 vty_out(vty
, " default route-map %s%s,",
11825 p
->default_rmap
[afi
][safi
].map
? "*"
11827 p
->default_rmap
[afi
][safi
].name
);
11828 if (paf
&& PAF_SUBGRP(paf
)
11829 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
11830 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
11831 vty_out(vty
, " default sent\n");
11833 vty_out(vty
, " default not sent\n");
11836 /* advertise-vni-all */
11837 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
11838 if (is_evpn_enabled())
11839 vty_out(vty
, " advertise-all-vni\n");
11842 if (filter
->plist
[FILTER_IN
].name
11843 || filter
->dlist
[FILTER_IN
].name
11844 || filter
->aslist
[FILTER_IN
].name
11845 || filter
->map
[RMAP_IN
].name
)
11846 vty_out(vty
, " Inbound path policy configured\n");
11847 if (filter
->plist
[FILTER_OUT
].name
11848 || filter
->dlist
[FILTER_OUT
].name
11849 || filter
->aslist
[FILTER_OUT
].name
11850 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
11851 vty_out(vty
, " Outbound path policy configured\n");
11854 if (filter
->plist
[FILTER_IN
].name
)
11856 " Incoming update prefix filter list is %s%s\n",
11857 filter
->plist
[FILTER_IN
].plist
? "*" : "",
11858 filter
->plist
[FILTER_IN
].name
);
11859 if (filter
->plist
[FILTER_OUT
].name
)
11861 " Outgoing update prefix filter list is %s%s\n",
11862 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
11863 filter
->plist
[FILTER_OUT
].name
);
11865 /* distribute-list */
11866 if (filter
->dlist
[FILTER_IN
].name
)
11868 " Incoming update network filter list is %s%s\n",
11869 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
11870 filter
->dlist
[FILTER_IN
].name
);
11871 if (filter
->dlist
[FILTER_OUT
].name
)
11873 " Outgoing update network filter list is %s%s\n",
11874 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
11875 filter
->dlist
[FILTER_OUT
].name
);
11878 if (filter
->aslist
[FILTER_IN
].name
)
11880 " Incoming update AS path filter list is %s%s\n",
11881 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
11882 filter
->aslist
[FILTER_IN
].name
);
11883 if (filter
->aslist
[FILTER_OUT
].name
)
11885 " Outgoing update AS path filter list is %s%s\n",
11886 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
11887 filter
->aslist
[FILTER_OUT
].name
);
11890 if (filter
->map
[RMAP_IN
].name
)
11892 " Route map for incoming advertisements is %s%s\n",
11893 filter
->map
[RMAP_IN
].map
? "*" : "",
11894 filter
->map
[RMAP_IN
].name
);
11895 if (filter
->map
[RMAP_OUT
].name
)
11897 " Route map for outgoing advertisements is %s%s\n",
11898 filter
->map
[RMAP_OUT
].map
? "*" : "",
11899 filter
->map
[RMAP_OUT
].name
);
11901 /* ebgp-requires-policy (inbound) */
11902 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
11903 && !bgp_inbound_policy_exists(p
, filter
))
11905 " Inbound updates discarded due to missing policy\n");
11907 /* ebgp-requires-policy (outbound) */
11908 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
11909 && !bgp_outbound_policy_exists(p
, filter
))
11911 " Outbound updates discarded due to missing policy\n");
11913 /* unsuppress-map */
11914 if (filter
->usmap
.name
)
11916 " Route map for selective unsuppress is %s%s\n",
11917 filter
->usmap
.map
? "*" : "",
11918 filter
->usmap
.name
);
11920 /* advertise-map */
11921 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
11923 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
11924 filter
->advmap
.condition
? "EXIST"
11926 filter
->advmap
.cmap
? "*" : "",
11927 filter
->advmap
.cname
,
11928 filter
->advmap
.amap
? "*" : "",
11929 filter
->advmap
.aname
,
11930 filter
->advmap
.update_type
== ADVERTISE
11934 /* Receive prefix count */
11935 vty_out(vty
, " %u accepted prefixes\n",
11936 p
->pcount
[afi
][safi
]);
11938 /* maximum-prefix-out */
11939 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11940 PEER_FLAG_MAX_PREFIX_OUT
))
11942 " Maximum allowed prefixes sent %u\n",
11943 p
->pmax_out
[afi
][safi
]);
11945 /* Maximum prefix */
11946 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
11948 " Maximum prefixes allowed %u%s\n",
11949 p
->pmax
[afi
][safi
],
11950 CHECK_FLAG(p
->af_flags
[afi
][safi
],
11951 PEER_FLAG_MAX_PREFIX_WARNING
)
11952 ? " (warning-only)"
11954 vty_out(vty
, " Threshold for warning message %d%%",
11955 p
->pmax_threshold
[afi
][safi
]);
11956 if (p
->pmax_restart
[afi
][safi
])
11957 vty_out(vty
, ", restart interval %d min",
11958 p
->pmax_restart
[afi
][safi
]);
11959 vty_out(vty
, "\n");
11962 vty_out(vty
, "\n");
11966 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
11970 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
11971 char timebuf
[BGP_UPTIME_LEN
];
11977 json_object
*json_neigh
= NULL
;
11979 uint32_t sync_tcp_mss
;
11984 json_neigh
= json_object_new_object();
11986 memset(dn_flag
, '\0', sizeof(dn_flag
));
11987 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11991 if (p
->conf_if
) /* Configured interface name. */
11992 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
11993 BGP_PEER_SU_UNSPEC(p
)
11995 : sockunion2str(&p
->su
, buf
,
11997 else /* Configured IP address. */
11998 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12003 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12004 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12006 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12007 json_object_string_add(
12008 json_neigh
, "bgpNeighborAddr",
12009 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
12011 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12013 if (p
->change_local_as
)
12014 json_object_int_add(json_neigh
, "localAs",
12015 p
->change_local_as
);
12017 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12019 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12020 json_object_boolean_true_add(json_neigh
,
12021 "localAsNoPrepend");
12023 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12024 json_object_boolean_true_add(json_neigh
,
12025 "localAsReplaceAs");
12027 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12028 || (p
->as_type
== AS_INTERNAL
))
12029 vty_out(vty
, "remote AS %u, ", p
->as
);
12031 vty_out(vty
, "remote AS Unspecified, ");
12032 vty_out(vty
, "local AS %u%s%s, ",
12033 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12034 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12037 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12041 /* peer type internal or confed-internal */
12042 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12044 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12045 json_object_boolean_true_add(
12046 json_neigh
, "nbrConfedInternalLink");
12048 json_object_boolean_true_add(json_neigh
,
12049 "nbrInternalLink");
12051 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12052 vty_out(vty
, "confed-internal link\n");
12054 vty_out(vty
, "internal link\n");
12056 /* peer type external or confed-external */
12057 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12059 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12060 json_object_boolean_true_add(
12061 json_neigh
, "nbrConfedExternalLink");
12063 json_object_boolean_true_add(json_neigh
,
12064 "nbrExternalLink");
12066 if (bgp_confederation_peers_check(bgp
, p
->as
))
12067 vty_out(vty
, "confed-external link\n");
12069 vty_out(vty
, "external link\n");
12073 json_object_boolean_true_add(json_neigh
,
12074 "nbrUnspecifiedLink");
12076 vty_out(vty
, "unspecified link\n");
12082 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12084 vty_out(vty
, " Description: %s\n", p
->desc
);
12090 json_object_string_add(json_neigh
, "hostname",
12094 json_object_string_add(json_neigh
, "domainname",
12097 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12098 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12101 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12108 json_object_string_add(json_neigh
, "peerGroup",
12112 struct prefix prefix
, *range
= NULL
;
12114 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12115 range
= peer_group_lookup_dynamic_neighbor_range(
12116 p
->group
, &prefix
);
12119 prefix2str(range
, buf1
, sizeof(buf1
));
12120 json_object_string_add(
12122 "peerSubnetRangeGroup", buf1
);
12127 " Member of peer-group %s for session parameters\n",
12131 struct prefix prefix
, *range
= NULL
;
12133 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12134 range
= peer_group_lookup_dynamic_neighbor_range(
12135 p
->group
, &prefix
);
12139 " Belongs to the subnet range group: %pFX\n",
12147 /* Administrative shutdown. */
12148 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12149 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12150 json_object_boolean_true_add(json_neigh
,
12154 json_object_int_add(json_neigh
, "bgpVersion", 4);
12155 json_object_string_add(
12156 json_neigh
, "remoteRouterId",
12157 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12158 json_object_string_add(
12159 json_neigh
, "localRouterId",
12160 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12163 /* Confederation */
12164 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12165 && bgp_confederation_peers_check(bgp
, p
->as
))
12166 json_object_boolean_true_add(json_neigh
,
12170 json_object_string_add(
12171 json_neigh
, "bgpState",
12172 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12174 if (peer_established(p
)) {
12177 uptime
= bgp_clock();
12178 uptime
-= p
->uptime
;
12179 epoch_tbuf
= time(NULL
) - uptime
;
12181 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
12183 json_object_string_add(json_neigh
, "bgpTimerUpString",
12184 peer_uptime(p
->uptime
, timebuf
,
12187 json_object_int_add(json_neigh
,
12188 "bgpTimerUpEstablishedEpoch",
12192 else if (p
->status
== Active
) {
12193 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12194 json_object_string_add(json_neigh
, "bgpStateIs",
12196 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12197 json_object_string_add(json_neigh
, "bgpStateIs",
12205 uptime
= bgp_clock();
12206 uptime
-= p
->readtime
;
12207 gmtime_r(&uptime
, &tm
);
12209 json_object_int_add(json_neigh
, "bgpTimerLastRead",
12210 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12211 + (tm
.tm_hour
* 3600000));
12213 uptime
= bgp_clock();
12214 uptime
-= p
->last_write
;
12215 gmtime_r(&uptime
, &tm
);
12217 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
12218 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12219 + (tm
.tm_hour
* 3600000));
12221 uptime
= bgp_clock();
12222 uptime
-= p
->update_time
;
12223 gmtime_r(&uptime
, &tm
);
12225 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
12226 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12227 + (tm
.tm_hour
* 3600000));
12229 /* Configured timer values. */
12230 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
12231 p
->v_holdtime
* 1000);
12232 json_object_int_add(json_neigh
,
12233 "bgpTimerKeepAliveIntervalMsecs",
12234 p
->v_keepalive
* 1000);
12235 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
12236 json_object_int_add(json_neigh
,
12237 "bgpTimerDelayOpenTimeMsecs",
12238 p
->v_delayopen
* 1000);
12241 /* Configured and Synced tcp-mss value for peer */
12242 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12243 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12244 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
12246 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
12250 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12251 json_object_int_add(json_neigh
,
12252 "bgpTimerConfiguredHoldTimeMsecs",
12253 p
->holdtime
* 1000);
12254 json_object_int_add(
12256 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12257 p
->keepalive
* 1000);
12258 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12259 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12260 json_object_int_add(json_neigh
,
12261 "bgpTimerConfiguredHoldTimeMsecs",
12262 bgp
->default_holdtime
);
12263 json_object_int_add(
12265 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12266 bgp
->default_keepalive
);
12269 /* Administrative shutdown. */
12270 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12271 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12272 vty_out(vty
, " Administratively shut down\n");
12275 vty_out(vty
, " BGP version 4");
12276 vty_out(vty
, ", remote router ID %s",
12277 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12278 vty_out(vty
, ", local router ID %s\n",
12279 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12282 /* Confederation */
12283 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12284 && bgp_confederation_peers_check(bgp
, p
->as
))
12286 " Neighbor under common administration\n");
12289 vty_out(vty
, " BGP state = %s",
12290 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12292 if (peer_established(p
))
12293 vty_out(vty
, ", up for %8s",
12294 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
12297 else if (p
->status
== Active
) {
12298 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12299 vty_out(vty
, " (passive)");
12300 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12301 vty_out(vty
, " (NSF passive)");
12303 vty_out(vty
, "\n");
12306 vty_out(vty
, " Last read %s",
12307 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
12309 vty_out(vty
, ", Last write %s\n",
12310 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
12313 /* Configured timer values. */
12315 " Hold time is %d, keepalive interval is %d seconds\n",
12316 p
->v_holdtime
, p
->v_keepalive
);
12317 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12318 vty_out(vty
, " Configured hold time is %d",
12320 vty_out(vty
, ", keepalive interval is %d seconds\n",
12322 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12323 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12324 vty_out(vty
, " Configured hold time is %d",
12325 bgp
->default_holdtime
);
12326 vty_out(vty
, ", keepalive interval is %d seconds\n",
12327 bgp
->default_keepalive
);
12329 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
12331 " Configured DelayOpenTime is %d seconds\n",
12334 /* Configured and synced tcp-mss value for peer */
12335 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12336 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12337 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
12338 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
12342 if (peer_established(p
)) {
12343 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
12344 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
12345 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
12346 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
12347 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
12348 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
12349 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
12350 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
12351 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
12352 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
12353 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
12354 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
12355 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
12356 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
12357 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
12358 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
12359 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
12360 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
12361 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
12362 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
12364 json_object
*json_cap
= NULL
;
12366 json_cap
= json_object_new_object();
12369 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
12370 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
12371 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
12372 && CHECK_FLAG(p
->cap
,
12374 json_object_string_add(
12375 json_cap
, "4byteAs",
12376 "advertisedAndReceived");
12377 else if (CHECK_FLAG(p
->cap
,
12379 json_object_string_add(
12380 json_cap
, "4byteAs",
12382 else if (CHECK_FLAG(p
->cap
,
12384 json_object_string_add(
12385 json_cap
, "4byteAs",
12389 /* Extended Message Support */
12390 if (CHECK_FLAG(p
->cap
,
12391 PEER_CAP_EXTENDED_MESSAGE_ADV
)
12394 PEER_CAP_EXTENDED_MESSAGE_RCV
))
12395 json_object_string_add(
12396 json_cap
, "extendedMessage",
12397 "advertisedAndReceived");
12398 else if (CHECK_FLAG(
12400 PEER_CAP_EXTENDED_MESSAGE_ADV
))
12401 json_object_string_add(
12402 json_cap
, "extendedMessage",
12404 else if (CHECK_FLAG(
12406 PEER_CAP_EXTENDED_MESSAGE_RCV
))
12407 json_object_string_add(
12408 json_cap
, "extendedMessage",
12412 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
12413 || CHECK_FLAG(p
->cap
,
12414 PEER_CAP_ADDPATH_ADV
)) {
12415 json_object
*json_add
= NULL
;
12416 const char *print_store
;
12418 json_add
= json_object_new_object();
12420 FOREACH_AFI_SAFI (afi
, safi
) {
12421 json_object
*json_sub
= NULL
;
12423 json_object_new_object();
12424 print_store
= get_afi_safi_str(
12430 PEER_CAP_ADDPATH_AF_TX_ADV
)
12434 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
12439 PEER_CAP_ADDPATH_AF_TX_ADV
)
12444 PEER_CAP_ADDPATH_AF_TX_RCV
))
12445 json_object_boolean_true_add(
12447 "txAdvertisedAndReceived");
12453 PEER_CAP_ADDPATH_AF_TX_ADV
))
12454 json_object_boolean_true_add(
12462 PEER_CAP_ADDPATH_AF_TX_RCV
))
12463 json_object_boolean_true_add(
12471 PEER_CAP_ADDPATH_AF_RX_ADV
)
12475 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
12480 PEER_CAP_ADDPATH_AF_RX_ADV
)
12485 PEER_CAP_ADDPATH_AF_RX_RCV
))
12486 json_object_boolean_true_add(
12488 "rxAdvertisedAndReceived");
12494 PEER_CAP_ADDPATH_AF_RX_ADV
))
12495 json_object_boolean_true_add(
12503 PEER_CAP_ADDPATH_AF_RX_RCV
))
12504 json_object_boolean_true_add(
12512 PEER_CAP_ADDPATH_AF_TX_ADV
)
12516 PEER_CAP_ADDPATH_AF_TX_RCV
)
12520 PEER_CAP_ADDPATH_AF_RX_ADV
)
12524 PEER_CAP_ADDPATH_AF_RX_RCV
))
12525 json_object_object_add(
12534 json_object_object_add(
12535 json_cap
, "addPath", json_add
);
12539 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
12540 || CHECK_FLAG(p
->cap
,
12541 PEER_CAP_DYNAMIC_ADV
)) {
12542 if (CHECK_FLAG(p
->cap
,
12543 PEER_CAP_DYNAMIC_ADV
)
12544 && CHECK_FLAG(p
->cap
,
12545 PEER_CAP_DYNAMIC_RCV
))
12546 json_object_string_add(
12547 json_cap
, "dynamic",
12548 "advertisedAndReceived");
12549 else if (CHECK_FLAG(
12551 PEER_CAP_DYNAMIC_ADV
))
12552 json_object_string_add(
12553 json_cap
, "dynamic",
12555 else if (CHECK_FLAG(
12557 PEER_CAP_DYNAMIC_RCV
))
12558 json_object_string_add(
12559 json_cap
, "dynamic",
12563 /* Extended nexthop */
12564 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
12565 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
12566 json_object
*json_nxt
= NULL
;
12567 const char *print_store
;
12570 if (CHECK_FLAG(p
->cap
,
12572 && CHECK_FLAG(p
->cap
,
12573 PEER_CAP_ENHE_RCV
))
12574 json_object_string_add(
12577 "advertisedAndReceived");
12578 else if (CHECK_FLAG(p
->cap
,
12579 PEER_CAP_ENHE_ADV
))
12580 json_object_string_add(
12584 else if (CHECK_FLAG(p
->cap
,
12585 PEER_CAP_ENHE_RCV
))
12586 json_object_string_add(
12591 if (CHECK_FLAG(p
->cap
,
12592 PEER_CAP_ENHE_RCV
)) {
12594 json_object_new_object();
12596 for (safi
= SAFI_UNICAST
;
12597 safi
< SAFI_MAX
; safi
++) {
12602 PEER_CAP_ENHE_AF_RCV
)) {
12603 print_store
= get_afi_safi_str(
12606 json_object_string_add(
12609 "recieved"); /* misspelled for compatibility */
12612 json_object_object_add(
12614 "extendedNexthopFamililesByPeer",
12619 /* Route Refresh */
12620 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
12621 || CHECK_FLAG(p
->cap
,
12622 PEER_CAP_REFRESH_NEW_RCV
)
12623 || CHECK_FLAG(p
->cap
,
12624 PEER_CAP_REFRESH_OLD_RCV
)) {
12625 if (CHECK_FLAG(p
->cap
,
12626 PEER_CAP_REFRESH_ADV
)
12629 PEER_CAP_REFRESH_NEW_RCV
)
12632 PEER_CAP_REFRESH_OLD_RCV
))) {
12635 PEER_CAP_REFRESH_OLD_RCV
)
12638 PEER_CAP_REFRESH_NEW_RCV
))
12639 json_object_string_add(
12642 "advertisedAndReceivedOldNew");
12646 PEER_CAP_REFRESH_OLD_RCV
))
12647 json_object_string_add(
12650 "advertisedAndReceivedOld");
12652 json_object_string_add(
12655 "advertisedAndReceivedNew");
12660 PEER_CAP_REFRESH_ADV
))
12661 json_object_string_add(
12668 PEER_CAP_REFRESH_NEW_RCV
)
12671 PEER_CAP_REFRESH_OLD_RCV
))
12672 json_object_string_add(
12678 /* Enhanced Route Refresh */
12679 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
)
12680 || CHECK_FLAG(p
->cap
,
12681 PEER_CAP_ENHANCED_RR_RCV
)) {
12682 if (CHECK_FLAG(p
->cap
,
12683 PEER_CAP_ENHANCED_RR_ADV
)
12686 PEER_CAP_ENHANCED_RR_RCV
))
12687 json_object_string_add(
12689 "enhancedRouteRefresh",
12690 "advertisedAndReceived");
12694 PEER_CAP_ENHANCED_RR_ADV
))
12695 json_object_string_add(
12697 "enhancedRouteRefresh",
12702 PEER_CAP_ENHANCED_RR_RCV
))
12703 json_object_string_add(
12705 "enhancedRouteRefresh",
12709 /* Multiprotocol Extensions */
12710 json_object
*json_multi
= NULL
;
12711 json_multi
= json_object_new_object();
12713 FOREACH_AFI_SAFI (afi
, safi
) {
12714 if (p
->afc_adv
[afi
][safi
]
12715 || p
->afc_recv
[afi
][safi
]) {
12716 json_object
*json_exten
= NULL
;
12718 json_object_new_object();
12720 if (p
->afc_adv
[afi
][safi
]
12721 && p
->afc_recv
[afi
][safi
])
12722 json_object_boolean_true_add(
12724 "advertisedAndReceived");
12725 else if (p
->afc_adv
[afi
][safi
])
12726 json_object_boolean_true_add(
12729 else if (p
->afc_recv
[afi
][safi
])
12730 json_object_boolean_true_add(
12734 json_object_object_add(
12736 get_afi_safi_str(afi
,
12742 json_object_object_add(
12743 json_cap
, "multiprotocolExtensions",
12746 /* Hostname capabilities */
12747 json_object
*json_hname
= NULL
;
12749 json_hname
= json_object_new_object();
12751 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
12752 json_object_string_add(
12753 json_hname
, "advHostName",
12754 bgp
->peer_self
->hostname
12758 json_object_string_add(
12759 json_hname
, "advDomainName",
12760 bgp
->peer_self
->domainname
12767 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
12768 json_object_string_add(
12769 json_hname
, "rcvHostName",
12770 p
->hostname
? p
->hostname
12772 json_object_string_add(
12773 json_hname
, "rcvDomainName",
12774 p
->domainname
? p
->domainname
12778 json_object_object_add(json_cap
, "hostName",
12781 /* Gracefull Restart */
12782 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
12783 || CHECK_FLAG(p
->cap
,
12784 PEER_CAP_RESTART_ADV
)) {
12785 if (CHECK_FLAG(p
->cap
,
12786 PEER_CAP_RESTART_ADV
)
12787 && CHECK_FLAG(p
->cap
,
12788 PEER_CAP_RESTART_RCV
))
12789 json_object_string_add(
12792 "advertisedAndReceived");
12793 else if (CHECK_FLAG(
12795 PEER_CAP_RESTART_ADV
))
12796 json_object_string_add(
12798 "gracefulRestartCapability",
12800 else if (CHECK_FLAG(
12802 PEER_CAP_RESTART_RCV
))
12803 json_object_string_add(
12805 "gracefulRestartCapability",
12808 if (CHECK_FLAG(p
->cap
,
12809 PEER_CAP_RESTART_RCV
)) {
12810 int restart_af_count
= 0;
12811 json_object
*json_restart
=
12814 json_object_new_object();
12816 json_object_int_add(
12818 "gracefulRestartRemoteTimerMsecs",
12819 p
->v_gr_restart
* 1000);
12821 FOREACH_AFI_SAFI (afi
, safi
) {
12826 PEER_CAP_RESTART_AF_RCV
)) {
12831 json_object_new_object();
12837 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
12838 json_object_boolean_true_add(
12841 restart_af_count
++;
12842 json_object_object_add(
12851 if (!restart_af_count
) {
12852 json_object_string_add(
12854 "addressFamiliesByPeer",
12859 json_object_object_add(
12861 "addressFamiliesByPeer",
12865 json_object_object_add(json_neigh
,
12866 "neighborCapabilities",
12869 vty_out(vty
, " Neighbor capabilities:\n");
12872 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
12873 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
12874 vty_out(vty
, " 4 Byte AS:");
12875 if (CHECK_FLAG(p
->cap
,
12877 vty_out(vty
, " advertised");
12878 if (CHECK_FLAG(p
->cap
,
12880 vty_out(vty
, " %sreceived",
12886 vty_out(vty
, "\n");
12889 /* Extended Message Support */
12890 if (CHECK_FLAG(p
->cap
,
12891 PEER_CAP_EXTENDED_MESSAGE_RCV
)
12894 PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
12895 vty_out(vty
, " Extended Message:");
12898 PEER_CAP_EXTENDED_MESSAGE_ADV
))
12899 vty_out(vty
, " advertised");
12902 PEER_CAP_EXTENDED_MESSAGE_RCV
))
12903 vty_out(vty
, " %sreceived",
12906 PEER_CAP_EXTENDED_MESSAGE_ADV
)
12909 vty_out(vty
, "\n");
12913 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
12914 || CHECK_FLAG(p
->cap
,
12915 PEER_CAP_ADDPATH_ADV
)) {
12916 vty_out(vty
, " AddPath:\n");
12918 FOREACH_AFI_SAFI (afi
, safi
) {
12922 PEER_CAP_ADDPATH_AF_TX_ADV
)
12926 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
12938 PEER_CAP_ADDPATH_AF_TX_ADV
))
12950 PEER_CAP_ADDPATH_AF_TX_RCV
))
12957 PEER_CAP_ADDPATH_AF_TX_ADV
)
12961 vty_out(vty
, "\n");
12967 PEER_CAP_ADDPATH_AF_RX_ADV
)
12971 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
12983 PEER_CAP_ADDPATH_AF_RX_ADV
))
12995 PEER_CAP_ADDPATH_AF_RX_RCV
))
13002 PEER_CAP_ADDPATH_AF_RX_ADV
)
13006 vty_out(vty
, "\n");
13012 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
13013 || CHECK_FLAG(p
->cap
,
13014 PEER_CAP_DYNAMIC_ADV
)) {
13015 vty_out(vty
, " Dynamic:");
13016 if (CHECK_FLAG(p
->cap
,
13017 PEER_CAP_DYNAMIC_ADV
))
13018 vty_out(vty
, " advertised");
13019 if (CHECK_FLAG(p
->cap
,
13020 PEER_CAP_DYNAMIC_RCV
))
13021 vty_out(vty
, " %sreceived",
13024 PEER_CAP_DYNAMIC_ADV
)
13027 vty_out(vty
, "\n");
13030 /* Extended nexthop */
13031 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
13032 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13033 vty_out(vty
, " Extended nexthop:");
13034 if (CHECK_FLAG(p
->cap
,
13035 PEER_CAP_ENHE_ADV
))
13036 vty_out(vty
, " advertised");
13037 if (CHECK_FLAG(p
->cap
,
13038 PEER_CAP_ENHE_RCV
))
13039 vty_out(vty
, " %sreceived",
13045 vty_out(vty
, "\n");
13047 if (CHECK_FLAG(p
->cap
,
13048 PEER_CAP_ENHE_RCV
)) {
13050 " Address families by peer:\n ");
13051 for (safi
= SAFI_UNICAST
;
13052 safi
< SAFI_MAX
; safi
++)
13057 PEER_CAP_ENHE_AF_RCV
))
13067 /* Route Refresh */
13068 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
13069 || CHECK_FLAG(p
->cap
,
13070 PEER_CAP_REFRESH_NEW_RCV
)
13071 || CHECK_FLAG(p
->cap
,
13072 PEER_CAP_REFRESH_OLD_RCV
)) {
13073 vty_out(vty
, " Route refresh:");
13074 if (CHECK_FLAG(p
->cap
,
13075 PEER_CAP_REFRESH_ADV
))
13076 vty_out(vty
, " advertised");
13077 if (CHECK_FLAG(p
->cap
,
13078 PEER_CAP_REFRESH_NEW_RCV
)
13081 PEER_CAP_REFRESH_OLD_RCV
))
13082 vty_out(vty
, " %sreceived(%s)",
13085 PEER_CAP_REFRESH_ADV
)
13090 PEER_CAP_REFRESH_OLD_RCV
)
13093 PEER_CAP_REFRESH_NEW_RCV
))
13097 PEER_CAP_REFRESH_OLD_RCV
)
13101 vty_out(vty
, "\n");
13104 /* Enhanced Route Refresh */
13105 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
)
13106 || CHECK_FLAG(p
->cap
,
13107 PEER_CAP_ENHANCED_RR_RCV
)) {
13109 " Enhanced Route Refresh:");
13112 PEER_CAP_ENHANCED_RR_ADV
))
13113 vty_out(vty
, " advertised");
13116 PEER_CAP_ENHANCED_RR_RCV
))
13117 vty_out(vty
, " %sreceived",
13120 PEER_CAP_REFRESH_ADV
)
13123 vty_out(vty
, "\n");
13126 /* Multiprotocol Extensions */
13127 FOREACH_AFI_SAFI (afi
, safi
)
13128 if (p
->afc_adv
[afi
][safi
]
13129 || p
->afc_recv
[afi
][safi
]) {
13131 " Address Family %s:",
13136 if (p
->afc_adv
[afi
][safi
])
13139 if (p
->afc_recv
[afi
][safi
])
13146 vty_out(vty
, "\n");
13149 /* Hostname capability */
13150 vty_out(vty
, " Hostname Capability:");
13152 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13154 " advertised (name: %s,domain name: %s)",
13155 bgp
->peer_self
->hostname
13159 bgp
->peer_self
->domainname
13164 vty_out(vty
, " not advertised");
13167 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13169 " received (name: %s,domain name: %s)",
13170 p
->hostname
? p
->hostname
13172 p
->domainname
? p
->domainname
13175 vty_out(vty
, " not received");
13178 vty_out(vty
, "\n");
13180 /* Graceful Restart */
13181 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
13182 || CHECK_FLAG(p
->cap
,
13183 PEER_CAP_RESTART_ADV
)) {
13185 " Graceful Restart Capability:");
13186 if (CHECK_FLAG(p
->cap
,
13187 PEER_CAP_RESTART_ADV
))
13188 vty_out(vty
, " advertised");
13189 if (CHECK_FLAG(p
->cap
,
13190 PEER_CAP_RESTART_RCV
))
13191 vty_out(vty
, " %sreceived",
13194 PEER_CAP_RESTART_ADV
)
13197 vty_out(vty
, "\n");
13199 if (CHECK_FLAG(p
->cap
,
13200 PEER_CAP_RESTART_RCV
)) {
13201 int restart_af_count
= 0;
13204 " Remote Restart timer is %d seconds\n",
13207 " Address families by peer:\n ");
13209 FOREACH_AFI_SAFI (afi
, safi
)
13214 PEER_CAP_RESTART_AF_RCV
)) {
13228 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13230 : "not preserved");
13231 restart_af_count
++;
13233 if (!restart_af_count
)
13234 vty_out(vty
, "none");
13235 vty_out(vty
, "\n");
13237 } /* Gracefull Restart */
13242 /* graceful restart information */
13243 json_object
*json_grace
= NULL
;
13244 json_object
*json_grace_send
= NULL
;
13245 json_object
*json_grace_recv
= NULL
;
13246 int eor_send_af_count
= 0;
13247 int eor_receive_af_count
= 0;
13250 json_grace
= json_object_new_object();
13251 json_grace_send
= json_object_new_object();
13252 json_grace_recv
= json_object_new_object();
13254 if ((peer_established(p
))
13255 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13256 FOREACH_AFI_SAFI (afi
, safi
) {
13257 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13258 PEER_STATUS_EOR_SEND
)) {
13259 json_object_boolean_true_add(
13261 get_afi_safi_str(afi
,
13264 eor_send_af_count
++;
13267 FOREACH_AFI_SAFI (afi
, safi
) {
13269 p
->af_sflags
[afi
][safi
],
13270 PEER_STATUS_EOR_RECEIVED
)) {
13271 json_object_boolean_true_add(
13273 get_afi_safi_str(afi
,
13276 eor_receive_af_count
++;
13280 json_object_object_add(json_grace
, "endOfRibSend",
13282 json_object_object_add(json_grace
, "endOfRibRecv",
13286 if (p
->t_gr_restart
)
13287 json_object_int_add(json_grace
,
13288 "gracefulRestartTimerMsecs",
13289 thread_timer_remain_second(
13294 json_object_int_add(
13296 "gracefulStalepathTimerMsecs",
13297 thread_timer_remain_second(
13300 /* more gr info in new format */
13301 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
,
13303 json_object_object_add(
13304 json_neigh
, "gracefulRestartInfo", json_grace
);
13306 vty_out(vty
, " Graceful restart information:\n");
13307 if ((peer_established(p
))
13308 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13310 vty_out(vty
, " End-of-RIB send: ");
13311 FOREACH_AFI_SAFI (afi
, safi
) {
13312 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13313 PEER_STATUS_EOR_SEND
)) {
13314 vty_out(vty
, "%s%s",
13315 eor_send_af_count
? ", "
13320 eor_send_af_count
++;
13323 vty_out(vty
, "\n");
13324 vty_out(vty
, " End-of-RIB received: ");
13325 FOREACH_AFI_SAFI (afi
, safi
) {
13327 p
->af_sflags
[afi
][safi
],
13328 PEER_STATUS_EOR_RECEIVED
)) {
13329 vty_out(vty
, "%s%s",
13330 eor_receive_af_count
13333 get_afi_safi_str(afi
,
13336 eor_receive_af_count
++;
13339 vty_out(vty
, "\n");
13342 if (p
->t_gr_restart
)
13344 " The remaining time of restart timer is %ld\n",
13345 thread_timer_remain_second(
13350 " The remaining time of stalepath timer is %ld\n",
13351 thread_timer_remain_second(
13354 /* more gr info in new format */
13355 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
13359 json_object
*json_stat
= NULL
;
13360 json_stat
= json_object_new_object();
13361 /* Packet counts. */
13363 atomic_size_t outq_count
, inq_count
;
13364 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13365 memory_order_relaxed
);
13366 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13367 memory_order_relaxed
);
13369 json_object_int_add(json_stat
, "depthInq",
13370 (unsigned long)inq_count
);
13371 json_object_int_add(json_stat
, "depthOutq",
13372 (unsigned long)outq_count
);
13373 json_object_int_add(json_stat
, "opensSent",
13374 atomic_load_explicit(&p
->open_out
,
13375 memory_order_relaxed
));
13376 json_object_int_add(json_stat
, "opensRecv",
13377 atomic_load_explicit(&p
->open_in
,
13378 memory_order_relaxed
));
13379 json_object_int_add(json_stat
, "notificationsSent",
13380 atomic_load_explicit(&p
->notify_out
,
13381 memory_order_relaxed
));
13382 json_object_int_add(json_stat
, "notificationsRecv",
13383 atomic_load_explicit(&p
->notify_in
,
13384 memory_order_relaxed
));
13385 json_object_int_add(json_stat
, "updatesSent",
13386 atomic_load_explicit(&p
->update_out
,
13387 memory_order_relaxed
));
13388 json_object_int_add(json_stat
, "updatesRecv",
13389 atomic_load_explicit(&p
->update_in
,
13390 memory_order_relaxed
));
13391 json_object_int_add(json_stat
, "keepalivesSent",
13392 atomic_load_explicit(&p
->keepalive_out
,
13393 memory_order_relaxed
));
13394 json_object_int_add(json_stat
, "keepalivesRecv",
13395 atomic_load_explicit(&p
->keepalive_in
,
13396 memory_order_relaxed
));
13397 json_object_int_add(json_stat
, "routeRefreshSent",
13398 atomic_load_explicit(&p
->refresh_out
,
13399 memory_order_relaxed
));
13400 json_object_int_add(json_stat
, "routeRefreshRecv",
13401 atomic_load_explicit(&p
->refresh_in
,
13402 memory_order_relaxed
));
13403 json_object_int_add(json_stat
, "capabilitySent",
13404 atomic_load_explicit(&p
->dynamic_cap_out
,
13405 memory_order_relaxed
));
13406 json_object_int_add(json_stat
, "capabilityRecv",
13407 atomic_load_explicit(&p
->dynamic_cap_in
,
13408 memory_order_relaxed
));
13409 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
13410 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
13411 json_object_object_add(json_neigh
, "messageStats", json_stat
);
13413 atomic_size_t outq_count
, inq_count
;
13414 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13415 memory_order_relaxed
);
13416 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13417 memory_order_relaxed
);
13419 /* Packet counts. */
13420 vty_out(vty
, " Message statistics:\n");
13421 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
13422 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
13423 vty_out(vty
, " Sent Rcvd\n");
13424 vty_out(vty
, " Opens: %10d %10d\n",
13425 atomic_load_explicit(&p
->open_out
,
13426 memory_order_relaxed
),
13427 atomic_load_explicit(&p
->open_in
,
13428 memory_order_relaxed
));
13429 vty_out(vty
, " Notifications: %10d %10d\n",
13430 atomic_load_explicit(&p
->notify_out
,
13431 memory_order_relaxed
),
13432 atomic_load_explicit(&p
->notify_in
,
13433 memory_order_relaxed
));
13434 vty_out(vty
, " Updates: %10d %10d\n",
13435 atomic_load_explicit(&p
->update_out
,
13436 memory_order_relaxed
),
13437 atomic_load_explicit(&p
->update_in
,
13438 memory_order_relaxed
));
13439 vty_out(vty
, " Keepalives: %10d %10d\n",
13440 atomic_load_explicit(&p
->keepalive_out
,
13441 memory_order_relaxed
),
13442 atomic_load_explicit(&p
->keepalive_in
,
13443 memory_order_relaxed
));
13444 vty_out(vty
, " Route Refresh: %10d %10d\n",
13445 atomic_load_explicit(&p
->refresh_out
,
13446 memory_order_relaxed
),
13447 atomic_load_explicit(&p
->refresh_in
,
13448 memory_order_relaxed
));
13449 vty_out(vty
, " Capability: %10d %10d\n",
13450 atomic_load_explicit(&p
->dynamic_cap_out
,
13451 memory_order_relaxed
),
13452 atomic_load_explicit(&p
->dynamic_cap_in
,
13453 memory_order_relaxed
));
13454 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
13459 /* advertisement-interval */
13460 json_object_int_add(json_neigh
,
13461 "minBtwnAdvertisementRunsTimerMsecs",
13462 p
->v_routeadv
* 1000);
13464 /* Update-source. */
13465 if (p
->update_if
|| p
->update_source
) {
13467 json_object_string_add(json_neigh
,
13470 else if (p
->update_source
)
13471 json_object_string_add(
13472 json_neigh
, "updateSource",
13473 sockunion2str(p
->update_source
, buf1
,
13477 /* advertisement-interval */
13479 " Minimum time between advertisement runs is %d seconds\n",
13482 /* Update-source. */
13483 if (p
->update_if
|| p
->update_source
) {
13484 vty_out(vty
, " Update source is ");
13486 vty_out(vty
, "%s", p
->update_if
);
13487 else if (p
->update_source
)
13489 sockunion2str(p
->update_source
, buf1
,
13491 vty_out(vty
, "\n");
13494 vty_out(vty
, "\n");
13497 /* Address Family Information */
13498 json_object
*json_hold
= NULL
;
13501 json_hold
= json_object_new_object();
13503 FOREACH_AFI_SAFI (afi
, safi
)
13504 if (p
->afc
[afi
][safi
])
13505 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
13509 json_object_object_add(json_neigh
, "addressFamilyInfo",
13511 json_object_int_add(json_neigh
, "connectionsEstablished",
13513 json_object_int_add(json_neigh
, "connectionsDropped",
13516 vty_out(vty
, " Connections established %d; dropped %d\n",
13517 p
->established
, p
->dropped
);
13519 if (!p
->last_reset
) {
13521 json_object_string_add(json_neigh
, "lastReset",
13524 vty_out(vty
, " Last reset never\n");
13530 uptime
= bgp_clock();
13531 uptime
-= p
->resettime
;
13532 gmtime_r(&uptime
, &tm
);
13534 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
13536 + (tm
.tm_min
* 60000)
13537 + (tm
.tm_hour
* 3600000));
13538 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
13540 vty_out(vty
, " Last reset %s, ",
13541 peer_uptime(p
->resettime
, timebuf
,
13542 BGP_UPTIME_LEN
, 0, NULL
));
13544 bgp_show_peer_reset(vty
, p
, NULL
, false);
13545 if (p
->last_reset_cause_size
) {
13546 msg
= p
->last_reset_cause
;
13548 " Message received that caused BGP to send a NOTIFICATION:\n ");
13549 for (i
= 1; i
<= p
->last_reset_cause_size
;
13551 vty_out(vty
, "%02X", *msg
++);
13553 if (i
!= p
->last_reset_cause_size
) {
13555 vty_out(vty
, "\n ");
13556 } else if (i
% 4 == 0) {
13561 vty_out(vty
, "\n");
13566 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
13568 json_object_boolean_true_add(json_neigh
,
13569 "prefixesConfigExceedMax");
13572 " Peer had exceeded the max. no. of prefixes configured.\n");
13574 if (p
->t_pmax_restart
) {
13576 json_object_boolean_true_add(
13577 json_neigh
, "reducePrefixNumFrom");
13578 json_object_int_add(json_neigh
,
13579 "restartInTimerMsec",
13580 thread_timer_remain_second(
13585 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
13586 p
->host
, thread_timer_remain_second(
13587 p
->t_pmax_restart
));
13590 json_object_boolean_true_add(
13592 "reducePrefixNumAndClearIpBgp");
13595 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
13600 /* EBGP Multihop and GTSM */
13601 if (p
->sort
!= BGP_PEER_IBGP
) {
13603 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
13604 json_object_int_add(json_neigh
,
13605 "externalBgpNbrMaxHopsAway",
13607 else if (p
->ttl
> BGP_DEFAULT_TTL
)
13608 json_object_int_add(json_neigh
,
13609 "externalBgpNbrMaxHopsAway",
13612 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
13614 " External BGP neighbor may be up to %d hops away.\n",
13616 else if (p
->ttl
> BGP_DEFAULT_TTL
)
13618 " External BGP neighbor may be up to %d hops away.\n",
13622 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
) {
13624 json_object_int_add(json_neigh
,
13625 "internalBgpNbrMaxHopsAway",
13629 " Internal BGP neighbor may be up to %d hops away.\n",
13634 /* Local address. */
13637 json_object_string_add(json_neigh
, "hostLocal",
13638 sockunion2str(p
->su_local
, buf1
,
13640 json_object_int_add(json_neigh
, "portLocal",
13641 ntohs(p
->su_local
->sin
.sin_port
));
13643 vty_out(vty
, "Local host: %s, Local port: %d\n",
13644 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
13645 ntohs(p
->su_local
->sin
.sin_port
));
13648 /* Remote address. */
13649 if (p
->su_remote
) {
13651 json_object_string_add(json_neigh
, "hostForeign",
13652 sockunion2str(p
->su_remote
, buf1
,
13654 json_object_int_add(json_neigh
, "portForeign",
13655 ntohs(p
->su_remote
->sin
.sin_port
));
13657 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
13658 sockunion2str(p
->su_remote
, buf1
,
13660 ntohs(p
->su_remote
->sin
.sin_port
));
13663 /* Nexthop display. */
13666 json_object_string_add(json_neigh
, "nexthop",
13668 &p
->nexthop
.v4
, buf1
,
13670 json_object_string_add(json_neigh
, "nexthopGlobal",
13671 inet_ntop(AF_INET6
,
13672 &p
->nexthop
.v6_global
,
13673 buf1
, sizeof(buf1
)));
13674 json_object_string_add(json_neigh
, "nexthopLocal",
13675 inet_ntop(AF_INET6
,
13676 &p
->nexthop
.v6_local
,
13677 buf1
, sizeof(buf1
)));
13678 if (p
->shared_network
)
13679 json_object_string_add(json_neigh
,
13683 json_object_string_add(json_neigh
,
13685 "nonSharedNetwork");
13687 vty_out(vty
, "Nexthop: %s\n",
13688 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
13690 vty_out(vty
, "Nexthop global: %s\n",
13691 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
13693 vty_out(vty
, "Nexthop local: %s\n",
13694 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
13696 vty_out(vty
, "BGP connection: %s\n",
13697 p
->shared_network
? "shared network"
13698 : "non shared network");
13702 /* Timer information. */
13704 json_object_int_add(json_neigh
, "connectRetryTimer",
13706 if (peer_established(p
) && p
->rtt
)
13707 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
13710 json_object_int_add(
13711 json_neigh
, "nextStartTimerDueInMsecs",
13712 thread_timer_remain_second(p
->t_start
) * 1000);
13714 json_object_int_add(
13715 json_neigh
, "nextConnectTimerDueInMsecs",
13716 thread_timer_remain_second(p
->t_connect
)
13718 if (p
->t_routeadv
) {
13719 json_object_int_add(json_neigh
, "mraiInterval",
13721 json_object_int_add(
13722 json_neigh
, "mraiTimerExpireInMsecs",
13723 thread_timer_remain_second(p
->t_routeadv
)
13727 json_object_int_add(json_neigh
, "authenticationEnabled",
13731 json_object_string_add(json_neigh
, "readThread", "on");
13733 json_object_string_add(json_neigh
, "readThread", "off");
13735 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
13736 json_object_string_add(json_neigh
, "writeThread", "on");
13738 json_object_string_add(json_neigh
, "writeThread",
13741 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
13743 if (peer_established(p
) && p
->rtt
)
13744 vty_out(vty
, "Estimated round trip time: %d ms\n",
13747 vty_out(vty
, "Next start timer due in %ld seconds\n",
13748 thread_timer_remain_second(p
->t_start
));
13750 vty_out(vty
, "Next connect timer due in %ld seconds\n",
13751 thread_timer_remain_second(p
->t_connect
));
13754 "MRAI (interval %u) timer expires in %ld seconds\n",
13756 thread_timer_remain_second(p
->t_routeadv
));
13758 vty_out(vty
, "Peer Authentication Enabled\n");
13760 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
13761 p
->t_read
? "on" : "off",
13762 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
13767 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
13768 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
13769 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
13772 vty_out(vty
, "\n");
13774 /* BFD information. */
13776 bgp_bfd_show_info(vty
, p
, json_neigh
);
13779 if (p
->conf_if
) /* Configured interface name. */
13780 json_object_object_add(json
, p
->conf_if
, json_neigh
);
13781 else /* Configured IP address. */
13782 json_object_object_add(json
, p
->host
, json_neigh
);
13786 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
13787 enum show_type type
,
13788 union sockunion
*su
,
13789 const char *conf_if
, afi_t afi
,
13792 struct listnode
*node
, *nnode
;
13795 safi_t safi
= SAFI_UNICAST
;
13796 json_object
*json
= NULL
;
13797 json_object
*json_neighbor
= NULL
;
13800 json
= json_object_new_object();
13801 json_neighbor
= json_object_new_object();
13804 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
13806 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
13809 if ((peer
->afc
[afi
][safi
]) == 0)
13812 if (type
== show_all
) {
13813 bgp_show_peer_gr_status(vty
, peer
, use_json
,
13817 json_object_object_add(json
, peer
->host
,
13819 json_neighbor
= NULL
;
13822 } else if (type
== show_peer
) {
13825 && !strcmp(peer
->conf_if
, conf_if
))
13827 && !strcmp(peer
->hostname
, conf_if
))) {
13829 bgp_show_peer_gr_status(vty
, peer
,
13834 if (sockunion_same(&peer
->su
, su
)) {
13836 bgp_show_peer_gr_status(vty
, peer
,
13841 if (use_json
&& find
)
13842 json_object_object_add(json
, peer
->host
,
13847 json_neighbor
= NULL
;
13852 if (type
== show_peer
&& !find
) {
13854 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
13856 vty_out(vty
, "%% No such neighbor\n");
13859 vty_out(vty
, "%s\n",
13860 json_object_to_json_string_ext(
13861 json
, JSON_C_TO_STRING_PRETTY
));
13864 json_object_free(json_neighbor
);
13865 json_object_free(json
);
13867 vty_out(vty
, "\n");
13870 return CMD_SUCCESS
;
13873 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
13874 enum show_type type
, union sockunion
*su
,
13875 const char *conf_if
, bool use_json
,
13878 struct listnode
*node
, *nnode
;
13881 bool nbr_output
= false;
13882 afi_t afi
= AFI_MAX
;
13883 safi_t safi
= SAFI_MAX
;
13885 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
13887 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
13891 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
13892 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
13897 bgp_show_peer(vty
, peer
, use_json
, json
);
13903 && !strcmp(peer
->conf_if
, conf_if
))
13905 && !strcmp(peer
->hostname
, conf_if
))) {
13907 bgp_show_peer(vty
, peer
, use_json
,
13911 if (sockunion_same(&peer
->su
, su
)) {
13913 bgp_show_peer(vty
, peer
, use_json
,
13918 case show_ipv4_peer
:
13919 case show_ipv6_peer
:
13920 FOREACH_SAFI (safi
) {
13921 if (peer
->afc
[afi
][safi
]) {
13924 && !strcmp(peer
->conf_if
, conf_if
))
13926 && !strcmp(peer
->hostname
, conf_if
))) {
13928 bgp_show_peer(vty
, peer
, use_json
,
13933 if (sockunion_same(&peer
->su
, su
)) {
13935 bgp_show_peer(vty
, peer
, use_json
,
13943 case show_ipv4_all
:
13944 case show_ipv6_all
:
13945 FOREACH_SAFI (safi
) {
13946 if (peer
->afc
[afi
][safi
]) {
13947 bgp_show_peer(vty
, peer
, use_json
, json
);
13956 if ((type
== show_peer
|| type
== show_ipv4_peer
||
13957 type
== show_ipv6_peer
) && !find
) {
13959 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
13961 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
13964 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
13965 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
13966 vty_out(vty
, "%% No BGP neighbors found\n");
13969 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
13970 json
, JSON_C_TO_STRING_PRETTY
));
13972 vty_out(vty
, "\n");
13975 return CMD_SUCCESS
;
13978 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
13979 enum show_type type
,
13980 const char *ip_str
,
13981 afi_t afi
, bool use_json
)
13986 union sockunion su
;
13988 bgp
= bgp_get_default();
13994 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
13998 ret
= str2sockunion(ip_str
, &su
);
14000 bgp_show_neighbor_graceful_restart(
14001 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14003 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14004 NULL
, afi
, use_json
);
14006 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14010 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14011 enum show_type type
,
14012 const char *ip_str
,
14015 struct listnode
*node
, *nnode
;
14017 union sockunion su
;
14018 json_object
*json
= NULL
;
14019 int ret
, is_first
= 1;
14020 bool nbr_output
= false;
14023 vty_out(vty
, "{\n");
14025 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14028 if (!(json
= json_object_new_object())) {
14030 EC_BGP_JSON_MEM_ERROR
,
14031 "Unable to allocate memory for JSON object");
14033 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14037 json_object_int_add(json
, "vrfId",
14038 (bgp
->vrf_id
== VRF_UNKNOWN
)
14040 : (int64_t)bgp
->vrf_id
);
14041 json_object_string_add(
14043 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14048 vty_out(vty
, ",\n");
14052 vty_out(vty
, "\"%s\":",
14053 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14057 vty_out(vty
, "\nInstance %s:\n",
14058 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14063 if (type
== show_peer
|| type
== show_ipv4_peer
||
14064 type
== show_ipv6_peer
) {
14065 ret
= str2sockunion(ip_str
, &su
);
14067 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14070 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14073 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14076 json_object_free(json
);
14081 vty_out(vty
, "}\n");
14082 else if (!nbr_output
)
14083 vty_out(vty
, "%% BGP instance not found\n");
14086 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14087 enum show_type type
, const char *ip_str
,
14092 union sockunion su
;
14093 json_object
*json
= NULL
;
14096 if (strmatch(name
, "all")) {
14097 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14099 return CMD_SUCCESS
;
14101 bgp
= bgp_lookup_by_name(name
);
14104 json
= json_object_new_object();
14105 vty_out(vty
, "%s\n",
14106 json_object_to_json_string_ext(
14108 JSON_C_TO_STRING_PRETTY
));
14109 json_object_free(json
);
14112 "%% BGP instance not found\n");
14114 return CMD_WARNING
;
14118 bgp
= bgp_get_default();
14122 json
= json_object_new_object();
14124 ret
= str2sockunion(ip_str
, &su
);
14126 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14129 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14132 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14135 json_object_free(json
);
14138 vty_out(vty
, "{}\n");
14140 vty_out(vty
, "%% BGP instance not found\n");
14143 return CMD_SUCCESS
;
14148 /* "show [ip] bgp neighbors graceful-restart" commands. */
14149 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
14150 show_ip_bgp_neighbors_graceful_restart_cmd
,
14151 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14157 "Neighbor to display information about\n"
14158 "Neighbor to display information about\n"
14159 "Neighbor on BGP configured interface\n"
14163 char *sh_arg
= NULL
;
14164 enum show_type sh_type
;
14166 afi_t afi
= AFI_MAX
;
14167 bool uj
= use_json(argc
, argv
);
14169 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14174 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14175 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14176 || argv_find(argv
, argc
, "WORD", &idx
)) {
14177 sh_type
= show_peer
;
14178 sh_arg
= argv
[idx
]->arg
;
14180 sh_type
= show_all
;
14182 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14183 return CMD_SUCCESS
;
14186 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14190 /* "show [ip] bgp neighbors" commands. */
14191 DEFUN (show_ip_bgp_neighbors
,
14192 show_ip_bgp_neighbors_cmd
,
14193 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14197 BGP_INSTANCE_HELP_STR
14200 "Detailed information on TCP and BGP neighbor connections\n"
14201 "Neighbor to display information about\n"
14202 "Neighbor to display information about\n"
14203 "Neighbor on BGP configured interface\n"
14207 char *sh_arg
= NULL
;
14208 enum show_type sh_type
;
14209 afi_t afi
= AFI_MAX
;
14211 bool uj
= use_json(argc
, argv
);
14215 /* [<vrf> VIEWVRFNAME] */
14216 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14217 vrf
= argv
[idx
+ 1]->arg
;
14218 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14220 } else if (argv_find(argv
, argc
, "view", &idx
))
14221 /* [<view> VIEWVRFNAME] */
14222 vrf
= argv
[idx
+ 1]->arg
;
14226 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14227 sh_type
= show_ipv4_all
;
14229 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14230 sh_type
= show_ipv6_all
;
14233 sh_type
= show_all
;
14236 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14237 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14238 || argv_find(argv
, argc
, "WORD", &idx
)) {
14239 sh_type
= show_peer
;
14240 sh_arg
= argv
[idx
]->arg
;
14243 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14244 sh_type
= show_ipv4_peer
;
14245 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14246 sh_type
= show_ipv6_peer
;
14249 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14252 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14253 paths' and `show ip mbgp paths'. Those functions results are the
14255 DEFUN (show_ip_bgp_paths
,
14256 show_ip_bgp_paths_cmd
,
14257 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14262 "Path information\n")
14264 vty_out(vty
, "Address Refcnt Path\n");
14265 aspath_print_all_vty(vty
);
14266 return CMD_SUCCESS
;
14271 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14274 struct community
*com
;
14276 com
= (struct community
*)bucket
->data
;
14277 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14278 community_str(com
, false));
14281 /* Show BGP's community internal data. */
14282 DEFUN (show_ip_bgp_community_info
,
14283 show_ip_bgp_community_info_cmd
,
14284 "show [ip] bgp community-info",
14288 "List all bgp community information\n")
14290 vty_out(vty
, "Address Refcnt Community\n");
14292 hash_iterate(community_hash(),
14293 (void (*)(struct hash_bucket
*,
14294 void *))community_show_all_iterator
,
14297 return CMD_SUCCESS
;
14300 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14303 struct lcommunity
*lcom
;
14305 lcom
= (struct lcommunity
*)bucket
->data
;
14306 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14307 lcommunity_str(lcom
, false));
14310 /* Show BGP's community internal data. */
14311 DEFUN (show_ip_bgp_lcommunity_info
,
14312 show_ip_bgp_lcommunity_info_cmd
,
14313 "show ip bgp large-community-info",
14317 "List all bgp large-community information\n")
14319 vty_out(vty
, "Address Refcnt Large-community\n");
14321 hash_iterate(lcommunity_hash(),
14322 (void (*)(struct hash_bucket
*,
14323 void *))lcommunity_show_all_iterator
,
14326 return CMD_SUCCESS
;
14328 /* Graceful Restart */
14330 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
14337 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
14339 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
14341 switch (bgp_global_gr_mode
) {
14343 case GLOBAL_HELPER
:
14344 vty_out(vty
, "Global BGP GR Mode : Helper\n");
14348 vty_out(vty
, "Global BGP GR Mode : Restart\n");
14351 case GLOBAL_DISABLE
:
14352 vty_out(vty
, "Global BGP GR Mode : Disable\n");
14355 case GLOBAL_INVALID
:
14357 "Global BGP GR Mode Invalid\n");
14360 vty_out(vty
, "\n");
14363 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
14364 enum show_type type
,
14365 const char *ip_str
,
14366 afi_t afi
, bool use_json
)
14368 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
14371 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
14373 bgp_show_neighbor_graceful_restart_vty(
14374 vty
, type
, ip_str
, afi
, use_json
);
14377 } else if (afi
!= AFI_MAX
) {
14378 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
14381 return CMD_ERR_INCOMPLETE
;
14384 return CMD_SUCCESS
;
14386 /* Graceful Restart */
14388 DEFUN (show_ip_bgp_attr_info
,
14389 show_ip_bgp_attr_info_cmd
,
14390 "show [ip] bgp attribute-info",
14394 "List all bgp attribute information\n")
14396 attr_show_all(vty
);
14397 return CMD_SUCCESS
;
14400 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
14401 afi_t afi
, safi_t safi
,
14402 bool use_json
, json_object
*json
)
14405 struct listnode
*node
;
14407 char buf1
[INET6_ADDRSTRLEN
];
14409 vpn_policy_direction_t dir
;
14412 json_object
*json_import_vrfs
= NULL
;
14413 json_object
*json_export_vrfs
= NULL
;
14415 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14418 vty_out(vty
, "%s\n",
14419 json_object_to_json_string_ext(
14421 JSON_C_TO_STRING_PRETTY
));
14422 json_object_free(json
);
14424 return CMD_WARNING
;
14427 /* Provide context for the block */
14428 json_object_string_add(json
, "vrf", name
? name
: "default");
14429 json_object_string_add(json
, "afiSafi",
14430 get_afi_safi_str(afi
, safi
, true));
14432 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14433 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
14434 json_object_string_add(json
, "importFromVrfs", "none");
14435 json_object_string_add(json
, "importRts", "none");
14437 json_import_vrfs
= json_object_new_array();
14439 for (ALL_LIST_ELEMENTS_RO(
14440 bgp
->vpn_policy
[afi
].import_vrf
,
14442 json_object_array_add(json_import_vrfs
,
14443 json_object_new_string(vname
));
14445 json_object_object_add(json
, "importFromVrfs",
14447 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14448 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14449 ecom_str
= ecommunity_ecom2str(
14450 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14451 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14452 json_object_string_add(json
, "importRts",
14454 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14456 json_object_string_add(json
, "importRts",
14460 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14461 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
14462 json_object_string_add(json
, "exportToVrfs", "none");
14463 json_object_string_add(json
, "routeDistinguisher",
14465 json_object_string_add(json
, "exportRts", "none");
14467 json_export_vrfs
= json_object_new_array();
14469 for (ALL_LIST_ELEMENTS_RO(
14470 bgp
->vpn_policy
[afi
].export_vrf
,
14472 json_object_array_add(json_export_vrfs
,
14473 json_object_new_string(vname
));
14474 json_object_object_add(json
, "exportToVrfs",
14476 json_object_string_add(json
, "routeDistinguisher",
14477 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
14478 buf1
, RD_ADDRSTRLEN
));
14480 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
14481 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14482 ecom_str
= ecommunity_ecom2str(
14483 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14484 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14485 json_object_string_add(json
, "exportRts",
14487 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14489 json_object_string_add(json
, "exportRts",
14494 vty_out(vty
, "%s\n",
14495 json_object_to_json_string_ext(json
,
14496 JSON_C_TO_STRING_PRETTY
));
14497 json_object_free(json
);
14500 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14503 vty_out(vty
, "%% No such BGP instance exist\n");
14504 return CMD_WARNING
;
14507 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14508 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
14510 "This VRF is not importing %s routes from any other VRF\n",
14511 get_afi_safi_str(afi
, safi
, false));
14514 "This VRF is importing %s routes from the following VRFs:\n",
14515 get_afi_safi_str(afi
, safi
, false));
14517 for (ALL_LIST_ELEMENTS_RO(
14518 bgp
->vpn_policy
[afi
].import_vrf
,
14520 vty_out(vty
, " %s\n", vname
);
14522 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14524 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14525 ecom_str
= ecommunity_ecom2str(
14526 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14527 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14528 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
14530 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14532 vty_out(vty
, "Import RT(s):\n");
14535 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14536 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
14538 "This VRF is not exporting %s routes to any other VRF\n",
14539 get_afi_safi_str(afi
, safi
, false));
14542 "This VRF is exporting %s routes to the following VRFs:\n",
14543 get_afi_safi_str(afi
, safi
, false));
14545 for (ALL_LIST_ELEMENTS_RO(
14546 bgp
->vpn_policy
[afi
].export_vrf
,
14548 vty_out(vty
, " %s\n", vname
);
14550 vty_out(vty
, "RD: %s\n",
14551 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
14552 buf1
, RD_ADDRSTRLEN
));
14554 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
14555 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14556 ecom_str
= ecommunity_ecom2str(
14557 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14558 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14559 vty_out(vty
, "Export RT: %s\n", ecom_str
);
14560 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14562 vty_out(vty
, "Import RT(s):\n");
14566 return CMD_SUCCESS
;
14569 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
14570 safi_t safi
, bool use_json
)
14572 struct listnode
*node
, *nnode
;
14574 char *vrf_name
= NULL
;
14575 json_object
*json
= NULL
;
14576 json_object
*json_vrf
= NULL
;
14577 json_object
*json_vrfs
= NULL
;
14580 json
= json_object_new_object();
14581 json_vrfs
= json_object_new_object();
14584 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14586 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
14587 vrf_name
= bgp
->name
;
14590 json_vrf
= json_object_new_object();
14592 vty_out(vty
, "\nInstance %s:\n",
14593 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14594 ? VRF_DEFAULT_NAME
: bgp
->name
);
14596 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
14598 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14599 json_object_object_add(json_vrfs
,
14600 VRF_DEFAULT_NAME
, json_vrf
);
14602 json_object_object_add(json_vrfs
, vrf_name
,
14608 json_object_object_add(json
, "vrfs", json_vrfs
);
14609 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
14610 JSON_C_TO_STRING_PRETTY
));
14611 json_object_free(json
);
14614 return CMD_SUCCESS
;
14617 /* "show [ip] bgp route-leak" command. */
14618 DEFUN (show_ip_bgp_route_leak
,
14619 show_ip_bgp_route_leak_cmd
,
14620 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
14624 BGP_INSTANCE_HELP_STR
14627 "Route leaking information\n"
14631 afi_t afi
= AFI_MAX
;
14632 safi_t safi
= SAFI_MAX
;
14634 bool uj
= use_json(argc
, argv
);
14636 json_object
*json
= NULL
;
14638 /* show [ip] bgp */
14639 if (argv_find(argv
, argc
, "ip", &idx
)) {
14641 safi
= SAFI_UNICAST
;
14643 /* [vrf VIEWVRFNAME] */
14644 if (argv_find(argv
, argc
, "view", &idx
)) {
14646 "%% This command is not applicable to BGP views\n");
14647 return CMD_WARNING
;
14650 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14651 vrf
= argv
[idx
+ 1]->arg
;
14652 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14655 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
14656 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
14657 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
14660 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
14662 "%% This command is applicable only for unicast ipv4|ipv6\n");
14663 return CMD_WARNING
;
14666 if (vrf
&& strmatch(vrf
, "all"))
14667 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
14670 json
= json_object_new_object();
14672 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
14675 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
14678 struct listnode
*node
, *nnode
;
14681 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14682 vty_out(vty
, "\nInstance %s:\n",
14683 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14686 update_group_show(bgp
, afi
, safi
, vty
, 0);
14690 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
14691 int safi
, uint64_t subgrp_id
)
14696 if (strmatch(name
, "all")) {
14697 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
14698 return CMD_SUCCESS
;
14700 bgp
= bgp_lookup_by_name(name
);
14703 bgp
= bgp_get_default();
14707 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
14708 return CMD_SUCCESS
;
14711 DEFUN (show_ip_bgp_updgrps
,
14712 show_ip_bgp_updgrps_cmd
,
14713 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
14717 BGP_INSTANCE_HELP_STR
14719 BGP_SAFI_WITH_LABEL_HELP_STR
14720 "Detailed info about dynamic update groups\n"
14721 "Specific subgroup to display detailed info for\n")
14724 afi_t afi
= AFI_IP6
;
14725 safi_t safi
= SAFI_UNICAST
;
14726 uint64_t subgrp_id
= 0;
14730 /* show [ip] bgp */
14731 if (argv_find(argv
, argc
, "ip", &idx
))
14733 /* [<vrf> VIEWVRFNAME] */
14734 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14735 vrf
= argv
[idx
+ 1]->arg
;
14736 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14738 } else if (argv_find(argv
, argc
, "view", &idx
))
14739 /* [<view> VIEWVRFNAME] */
14740 vrf
= argv
[idx
+ 1]->arg
;
14741 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
14742 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
14743 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
14746 /* get subgroup id, if provided */
14748 if (argv
[idx
]->type
== VARIABLE_TKN
)
14749 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
14751 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
14754 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
14755 show_bgp_instance_all_ipv6_updgrps_cmd
,
14756 "show [ip] bgp <view|vrf> all update-groups",
14760 BGP_INSTANCE_ALL_HELP_STR
14761 "Detailed info about dynamic update groups\n")
14763 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
14764 return CMD_SUCCESS
;
14767 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
14768 show_bgp_l2vpn_evpn_updgrps_cmd
,
14769 "show [ip] bgp l2vpn evpn update-groups",
14773 "l2vpn address family\n"
14774 "evpn sub-address family\n"
14775 "Detailed info about dynamic update groups\n")
14778 uint64_t subgrp_id
= 0;
14780 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
14781 return CMD_SUCCESS
;
14784 DEFUN (show_bgp_updgrps_stats
,
14785 show_bgp_updgrps_stats_cmd
,
14786 "show [ip] bgp update-groups statistics",
14790 "Detailed info about dynamic update groups\n"
14795 bgp
= bgp_get_default();
14797 update_group_show_stats(bgp
, vty
);
14799 return CMD_SUCCESS
;
14802 DEFUN (show_bgp_instance_updgrps_stats
,
14803 show_bgp_instance_updgrps_stats_cmd
,
14804 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
14808 BGP_INSTANCE_HELP_STR
14809 "Detailed info about dynamic update groups\n"
14815 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
14817 update_group_show_stats(bgp
, vty
);
14819 return CMD_SUCCESS
;
14822 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
14823 afi_t afi
, safi_t safi
,
14824 const char *what
, uint64_t subgrp_id
)
14829 bgp
= bgp_lookup_by_name(name
);
14831 bgp
= bgp_get_default();
14834 if (!strcmp(what
, "advertise-queue"))
14835 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
14837 else if (!strcmp(what
, "advertised-routes"))
14838 update_group_show_advertised(bgp
, afi
, safi
, vty
,
14840 else if (!strcmp(what
, "packet-queue"))
14841 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
14846 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
14847 show_ip_bgp_instance_updgrps_adj_s_cmd
,
14848 "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",
14849 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
14851 "Detailed info about dynamic update groups\n"
14852 "Specific subgroup to display info for\n"
14853 "Advertisement queue\n"
14854 "Announced routes\n"
14857 uint64_t subgrp_id
= 0;
14861 subgrp_id
= strtoull(sgid
, NULL
, 10);
14866 afiz
= bgp_vty_afi_from_str(afi
);
14870 afiz
= bgp_vty_afi_from_str(afi
);
14871 if (afiz
!= AFI_IP
)
14873 "%% Cannot specify both 'ip' and 'ipv6'\n");
14874 return CMD_WARNING
;
14877 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
14879 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
14880 return CMD_SUCCESS
;
14883 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
14886 struct listnode
*node
, *nnode
;
14887 struct prefix
*range
;
14892 const char *peer_status
;
14896 json_object
*json_peer_group
= NULL
;
14897 json_object
*json_peer_group_afc
= NULL
;
14898 json_object
*json_peer_group_members
= NULL
;
14899 json_object
*json_peer_group_dynamic
= NULL
;
14900 json_object
*json_peer_group_dynamic_af
= NULL
;
14901 json_object
*json_peer_group_ranges
= NULL
;
14903 conf
= group
->conf
;
14906 json_peer_group
= json_object_new_object();
14907 json_peer_group_afc
= json_object_new_array();
14910 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
14912 json_object_int_add(json_peer_group
, "remoteAs",
14915 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
14916 group
->name
, conf
->as
);
14917 } else if (conf
->as_type
== AS_INTERNAL
) {
14919 json_object_int_add(json_peer_group
, "remoteAs",
14922 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
14923 group
->name
, group
->bgp
->as
);
14926 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
14929 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
14931 json_object_string_add(json_peer_group
, "type",
14934 vty_out(vty
, " Peer-group type is internal\n");
14937 json_object_string_add(json_peer_group
, "type",
14940 vty_out(vty
, " Peer-group type is external\n");
14943 /* Display AFs configured. */
14945 vty_out(vty
, " Configured address-families:");
14947 FOREACH_AFI_SAFI (afi
, safi
) {
14948 if (conf
->afc
[afi
][safi
]) {
14951 json_object_array_add(
14952 json_peer_group_afc
,
14953 json_object_new_string(get_afi_safi_str(
14954 afi
, safi
, false)));
14956 vty_out(vty
, " %s;",
14957 get_afi_safi_str(afi
, safi
, false));
14962 json_object_object_add(json_peer_group
,
14963 "addressFamiliesConfigured",
14964 json_peer_group_afc
);
14967 vty_out(vty
, " none\n");
14969 vty_out(vty
, "\n");
14972 /* Display listen ranges (for dynamic neighbors), if any */
14973 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
14974 lr_count
= listcount(group
->listen_range
[afi
]);
14977 if (!json_peer_group_dynamic
)
14978 json_peer_group_dynamic
=
14979 json_object_new_object();
14981 json_peer_group_dynamic_af
=
14982 json_object_new_object();
14983 json_peer_group_ranges
=
14984 json_object_new_array();
14985 json_object_int_add(json_peer_group_dynamic_af
,
14986 "count", lr_count
);
14988 vty_out(vty
, " %d %s listen range(s)\n",
14989 lr_count
, afi2str(afi
));
14992 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
14997 snprintfrr(buf
, sizeof(buf
), "%pFX",
15000 json_object_array_add(
15001 json_peer_group_ranges
,
15002 json_object_new_string(buf
));
15004 vty_out(vty
, " %pFX\n", range
);
15009 json_object_object_add(
15010 json_peer_group_dynamic_af
, "ranges",
15011 json_peer_group_ranges
);
15013 json_object_object_add(
15014 json_peer_group_dynamic
, afi2str(afi
),
15015 json_peer_group_dynamic_af
);
15020 if (json_peer_group_dynamic
)
15021 json_object_object_add(json_peer_group
, "dynamicRanges",
15022 json_peer_group_dynamic
);
15024 /* Display group members and their status */
15025 if (listcount(group
->peer
)) {
15027 json_peer_group_members
= json_object_new_object();
15029 vty_out(vty
, " Peer-group members:\n");
15030 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15031 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15032 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15033 peer_status
= "Idle (Admin)";
15034 else if (CHECK_FLAG(peer
->sflags
,
15035 PEER_STATUS_PREFIX_OVERFLOW
))
15036 peer_status
= "Idle (PfxCt)";
15038 peer_status
= lookup_msg(bgp_status_msg
,
15039 peer
->status
, NULL
);
15041 dynamic
= peer_dynamic_neighbor(peer
);
15044 json_object
*json_peer_group_member
=
15045 json_object_new_object();
15047 json_object_string_add(json_peer_group_member
,
15048 "status", peer_status
);
15051 json_object_boolean_true_add(
15052 json_peer_group_member
,
15055 json_object_object_add(json_peer_group_members
,
15057 json_peer_group_member
);
15059 vty_out(vty
, " %s %s %s \n", peer
->host
,
15060 dynamic
? "(dynamic)" : "",
15065 json_object_object_add(json_peer_group
, "members",
15066 json_peer_group_members
);
15070 json_object_object_add(json
, group
->name
, json_peer_group
);
15072 return CMD_SUCCESS
;
15075 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15076 const char *group_name
, bool uj
)
15079 struct listnode
*node
, *nnode
;
15080 struct peer_group
*group
;
15081 bool found
= false;
15082 json_object
*json
= NULL
;
15085 json
= json_object_new_object();
15087 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15091 vty_out(vty
, "%s\n",
15092 json_object_to_json_string_ext(
15093 json
, JSON_C_TO_STRING_PRETTY
));
15094 json_object_free(json
);
15096 vty_out(vty
, "%% BGP instance not found\n");
15099 return CMD_WARNING
;
15102 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15104 if (strmatch(group
->name
, group_name
)) {
15105 bgp_show_one_peer_group(vty
, group
, json
);
15110 bgp_show_one_peer_group(vty
, group
, json
);
15114 if (group_name
&& !found
&& !uj
)
15115 vty_out(vty
, "%% No such peer-group\n");
15118 vty_out(vty
, "%s\n",
15119 json_object_to_json_string_ext(
15120 json
, JSON_C_TO_STRING_PRETTY
));
15121 json_object_free(json
);
15124 return CMD_SUCCESS
;
15127 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
15128 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
15129 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
15130 "Detailed information on BGP peer groups\n"
15131 "Peer group name\n" JSON_STR
)
15135 bool uj
= use_json(argc
, argv
);
15137 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15139 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15141 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
15145 /* Redistribute VTY commands. */
15147 DEFUN (bgp_redistribute_ipv4
,
15148 bgp_redistribute_ipv4_cmd
,
15149 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15150 "Redistribute information from another routing protocol\n"
15151 FRR_IP_REDIST_HELP_STR_BGPD
)
15153 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15154 int idx_protocol
= 1;
15157 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15159 vty_out(vty
, "%% Invalid route type\n");
15160 return CMD_WARNING_CONFIG_FAILED
;
15163 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15164 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
15168 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15169 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15170 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15172 DEFUN (bgp_redistribute_ipv4_rmap
,
15173 bgp_redistribute_ipv4_rmap_cmd
,
15174 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15175 "Redistribute information from another routing protocol\n"
15176 FRR_IP_REDIST_HELP_STR_BGPD
15177 "Route map reference\n"
15178 "Pointer to route-map entries\n")
15180 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15181 int idx_protocol
= 1;
15184 struct bgp_redist
*red
;
15186 struct route_map
*route_map
= route_map_lookup_warn_noexist(
15187 vty
, argv
[idx_word
]->arg
);
15189 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15191 vty_out(vty
, "%% Invalid route type\n");
15192 return CMD_WARNING_CONFIG_FAILED
;
15195 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15197 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15198 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15202 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15203 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15204 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15205 "Route map reference\n"
15206 "Pointer to route-map entries\n")
15208 DEFUN (bgp_redistribute_ipv4_metric
,
15209 bgp_redistribute_ipv4_metric_cmd
,
15210 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15211 "Redistribute information from another routing protocol\n"
15212 FRR_IP_REDIST_HELP_STR_BGPD
15213 "Metric for redistributed routes\n"
15214 "Default metric\n")
15216 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15217 int idx_protocol
= 1;
15218 int idx_number
= 3;
15221 struct bgp_redist
*red
;
15224 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15226 vty_out(vty
, "%% Invalid route type\n");
15227 return CMD_WARNING_CONFIG_FAILED
;
15229 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15231 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15232 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15233 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15237 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15238 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15239 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15240 "Metric for redistributed routes\n"
15241 "Default metric\n")
15243 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
15244 bgp_redistribute_ipv4_rmap_metric_cmd
,
15245 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
15246 "Redistribute information from another routing protocol\n"
15247 FRR_IP_REDIST_HELP_STR_BGPD
15248 "Route map reference\n"
15249 "Pointer to route-map entries\n"
15250 "Metric for redistributed routes\n"
15251 "Default metric\n")
15253 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15254 int idx_protocol
= 1;
15256 int idx_number
= 5;
15259 struct bgp_redist
*red
;
15261 struct route_map
*route_map
=
15262 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15264 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15266 vty_out(vty
, "%% Invalid route type\n");
15267 return CMD_WARNING_CONFIG_FAILED
;
15269 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15271 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15273 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15274 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15275 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15279 bgp_redistribute_ipv4_rmap_metric
,
15280 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15281 "redistribute " FRR_IP_REDIST_STR_BGPD
15282 " route-map WORD metric (0-4294967295)",
15283 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15284 "Route map reference\n"
15285 "Pointer to route-map entries\n"
15286 "Metric for redistributed routes\n"
15287 "Default metric\n")
15289 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
15290 bgp_redistribute_ipv4_metric_rmap_cmd
,
15291 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
15292 "Redistribute information from another routing protocol\n"
15293 FRR_IP_REDIST_HELP_STR_BGPD
15294 "Metric for redistributed routes\n"
15296 "Route map reference\n"
15297 "Pointer to route-map entries\n")
15299 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15300 int idx_protocol
= 1;
15301 int idx_number
= 3;
15305 struct bgp_redist
*red
;
15307 struct route_map
*route_map
=
15308 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15310 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15312 vty_out(vty
, "%% Invalid route type\n");
15313 return CMD_WARNING_CONFIG_FAILED
;
15315 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15317 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15318 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15320 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15321 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15325 bgp_redistribute_ipv4_metric_rmap
,
15326 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15327 "redistribute " FRR_IP_REDIST_STR_BGPD
15328 " metric (0-4294967295) route-map WORD",
15329 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15330 "Metric for redistributed routes\n"
15332 "Route map reference\n"
15333 "Pointer to route-map entries\n")
15335 DEFUN (bgp_redistribute_ipv4_ospf
,
15336 bgp_redistribute_ipv4_ospf_cmd
,
15337 "redistribute <ospf|table> (1-65535)",
15338 "Redistribute information from another routing protocol\n"
15339 "Open Shortest Path First (OSPFv2)\n"
15340 "Non-main Kernel Routing Table\n"
15341 "Instance ID/Table ID\n")
15343 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15344 int idx_ospf_table
= 1;
15345 int idx_number
= 2;
15346 unsigned short instance
;
15347 unsigned short protocol
;
15349 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15351 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15352 protocol
= ZEBRA_ROUTE_OSPF
;
15354 protocol
= ZEBRA_ROUTE_TABLE
;
15356 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15357 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
15360 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
15361 "redistribute <ospf|table> (1-65535)",
15362 "Redistribute information from another routing protocol\n"
15363 "Open Shortest Path First (OSPFv2)\n"
15364 "Non-main Kernel Routing Table\n"
15365 "Instance ID/Table ID\n")
15367 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
15368 bgp_redistribute_ipv4_ospf_rmap_cmd
,
15369 "redistribute <ospf|table> (1-65535) route-map WORD",
15370 "Redistribute information from another routing protocol\n"
15371 "Open Shortest Path First (OSPFv2)\n"
15372 "Non-main Kernel Routing Table\n"
15373 "Instance ID/Table ID\n"
15374 "Route map reference\n"
15375 "Pointer to route-map entries\n")
15377 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15378 int idx_ospf_table
= 1;
15379 int idx_number
= 2;
15381 struct bgp_redist
*red
;
15382 unsigned short instance
;
15385 struct route_map
*route_map
=
15386 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15388 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15389 protocol
= ZEBRA_ROUTE_OSPF
;
15391 protocol
= ZEBRA_ROUTE_TABLE
;
15393 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15394 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15396 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15397 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15400 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
15401 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
15402 "redistribute <ospf|table> (1-65535) route-map WORD",
15403 "Redistribute information from another routing protocol\n"
15404 "Open Shortest Path First (OSPFv2)\n"
15405 "Non-main Kernel Routing Table\n"
15406 "Instance ID/Table ID\n"
15407 "Route map reference\n"
15408 "Pointer to route-map entries\n")
15410 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
15411 bgp_redistribute_ipv4_ospf_metric_cmd
,
15412 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15413 "Redistribute information from another routing protocol\n"
15414 "Open Shortest Path First (OSPFv2)\n"
15415 "Non-main Kernel Routing Table\n"
15416 "Instance ID/Table ID\n"
15417 "Metric for redistributed routes\n"
15418 "Default metric\n")
15420 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15421 int idx_ospf_table
= 1;
15422 int idx_number
= 2;
15423 int idx_number_2
= 4;
15425 struct bgp_redist
*red
;
15426 unsigned short instance
;
15430 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15431 protocol
= ZEBRA_ROUTE_OSPF
;
15433 protocol
= ZEBRA_ROUTE_TABLE
;
15435 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15436 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
15438 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15439 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
15441 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15444 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
15445 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
15446 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15447 "Redistribute information from another routing protocol\n"
15448 "Open Shortest Path First (OSPFv2)\n"
15449 "Non-main Kernel Routing Table\n"
15450 "Instance ID/Table ID\n"
15451 "Metric for redistributed routes\n"
15452 "Default metric\n")
15454 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
15455 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
15456 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15457 "Redistribute information from another routing protocol\n"
15458 "Open Shortest Path First (OSPFv2)\n"
15459 "Non-main Kernel Routing Table\n"
15460 "Instance ID/Table ID\n"
15461 "Route map reference\n"
15462 "Pointer to route-map entries\n"
15463 "Metric for redistributed routes\n"
15464 "Default metric\n")
15466 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15467 int idx_ospf_table
= 1;
15468 int idx_number
= 2;
15470 int idx_number_2
= 6;
15472 struct bgp_redist
*red
;
15473 unsigned short instance
;
15476 struct route_map
*route_map
=
15477 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15479 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15480 protocol
= ZEBRA_ROUTE_OSPF
;
15482 protocol
= ZEBRA_ROUTE_TABLE
;
15484 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15485 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
15487 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15489 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15490 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
15492 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15496 bgp_redistribute_ipv4_ospf_rmap_metric
,
15497 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
15498 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15499 "Redistribute information from another routing protocol\n"
15500 "Open Shortest Path First (OSPFv2)\n"
15501 "Non-main Kernel Routing Table\n"
15502 "Instance ID/Table ID\n"
15503 "Route map reference\n"
15504 "Pointer to route-map entries\n"
15505 "Metric for redistributed routes\n"
15506 "Default metric\n")
15508 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
15509 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
15510 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15511 "Redistribute information from another routing protocol\n"
15512 "Open Shortest Path First (OSPFv2)\n"
15513 "Non-main Kernel Routing Table\n"
15514 "Instance ID/Table ID\n"
15515 "Metric for redistributed routes\n"
15517 "Route map reference\n"
15518 "Pointer to route-map entries\n")
15520 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15521 int idx_ospf_table
= 1;
15522 int idx_number
= 2;
15523 int idx_number_2
= 4;
15526 struct bgp_redist
*red
;
15527 unsigned short instance
;
15530 struct route_map
*route_map
=
15531 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15533 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15534 protocol
= ZEBRA_ROUTE_OSPF
;
15536 protocol
= ZEBRA_ROUTE_TABLE
;
15538 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15539 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
15541 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
15542 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
15545 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15546 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
15550 bgp_redistribute_ipv4_ospf_metric_rmap
,
15551 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
15552 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15553 "Redistribute information from another routing protocol\n"
15554 "Open Shortest Path First (OSPFv2)\n"
15555 "Non-main Kernel Routing Table\n"
15556 "Instance ID/Table ID\n"
15557 "Metric for redistributed routes\n"
15559 "Route map reference\n"
15560 "Pointer to route-map entries\n")
15562 DEFUN (no_bgp_redistribute_ipv4_ospf
,
15563 no_bgp_redistribute_ipv4_ospf_cmd
,
15564 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
15566 "Redistribute information from another routing protocol\n"
15567 "Open Shortest Path First (OSPFv2)\n"
15568 "Non-main Kernel Routing Table\n"
15569 "Instance ID/Table ID\n"
15570 "Metric for redistributed routes\n"
15572 "Route map reference\n"
15573 "Pointer to route-map entries\n")
15575 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15576 int idx_ospf_table
= 2;
15577 int idx_number
= 3;
15578 unsigned short instance
;
15581 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
15582 protocol
= ZEBRA_ROUTE_OSPF
;
15584 protocol
= ZEBRA_ROUTE_TABLE
;
15586 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15587 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
15591 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
15592 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
15594 "Redistribute information from another routing protocol\n"
15595 "Open Shortest Path First (OSPFv2)\n"
15596 "Non-main Kernel Routing Table\n"
15597 "Instance ID/Table ID\n"
15598 "Metric for redistributed routes\n"
15600 "Route map reference\n"
15601 "Pointer to route-map entries\n")
15603 DEFUN (no_bgp_redistribute_ipv4
,
15604 no_bgp_redistribute_ipv4_cmd
,
15605 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
15607 "Redistribute information from another routing protocol\n"
15608 FRR_IP_REDIST_HELP_STR_BGPD
15609 "Metric for redistributed routes\n"
15611 "Route map reference\n"
15612 "Pointer to route-map entries\n")
15614 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15615 int idx_protocol
= 2;
15618 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15620 vty_out(vty
, "%% Invalid route type\n");
15621 return CMD_WARNING_CONFIG_FAILED
;
15623 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
15627 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
15628 "no redistribute " FRR_IP_REDIST_STR_BGPD
15629 " [{metric (0-4294967295)|route-map WORD}]",
15631 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15632 "Metric for redistributed routes\n"
15634 "Route map reference\n"
15635 "Pointer to route-map entries\n")
15637 DEFUN (bgp_redistribute_ipv6
,
15638 bgp_redistribute_ipv6_cmd
,
15639 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
15640 "Redistribute information from another routing protocol\n"
15641 FRR_IP6_REDIST_HELP_STR_BGPD
)
15643 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15644 int idx_protocol
= 1;
15647 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15649 vty_out(vty
, "%% Invalid route type\n");
15650 return CMD_WARNING_CONFIG_FAILED
;
15653 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
15654 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
15657 DEFUN (bgp_redistribute_ipv6_rmap
,
15658 bgp_redistribute_ipv6_rmap_cmd
,
15659 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
15660 "Redistribute information from another routing protocol\n"
15661 FRR_IP6_REDIST_HELP_STR_BGPD
15662 "Route map reference\n"
15663 "Pointer to route-map entries\n")
15665 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15666 int idx_protocol
= 1;
15669 struct bgp_redist
*red
;
15671 struct route_map
*route_map
=
15672 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15674 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15676 vty_out(vty
, "%% Invalid route type\n");
15677 return CMD_WARNING_CONFIG_FAILED
;
15680 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
15682 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15683 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
15686 DEFUN (bgp_redistribute_ipv6_metric
,
15687 bgp_redistribute_ipv6_metric_cmd
,
15688 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
15689 "Redistribute information from another routing protocol\n"
15690 FRR_IP6_REDIST_HELP_STR_BGPD
15691 "Metric for redistributed routes\n"
15692 "Default metric\n")
15694 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15695 int idx_protocol
= 1;
15696 int idx_number
= 3;
15699 struct bgp_redist
*red
;
15702 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15704 vty_out(vty
, "%% Invalid route type\n");
15705 return CMD_WARNING_CONFIG_FAILED
;
15707 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15709 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
15710 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
15711 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
15714 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
15715 bgp_redistribute_ipv6_rmap_metric_cmd
,
15716 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
15717 "Redistribute information from another routing protocol\n"
15718 FRR_IP6_REDIST_HELP_STR_BGPD
15719 "Route map reference\n"
15720 "Pointer to route-map entries\n"
15721 "Metric for redistributed routes\n"
15722 "Default metric\n")
15724 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15725 int idx_protocol
= 1;
15727 int idx_number
= 5;
15730 struct bgp_redist
*red
;
15732 struct route_map
*route_map
=
15733 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15735 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15737 vty_out(vty
, "%% Invalid route type\n");
15738 return CMD_WARNING_CONFIG_FAILED
;
15740 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15742 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
15744 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15745 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
15747 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
15750 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
15751 bgp_redistribute_ipv6_metric_rmap_cmd
,
15752 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
15753 "Redistribute information from another routing protocol\n"
15754 FRR_IP6_REDIST_HELP_STR_BGPD
15755 "Metric for redistributed routes\n"
15757 "Route map reference\n"
15758 "Pointer to route-map entries\n")
15760 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15761 int idx_protocol
= 1;
15762 int idx_number
= 3;
15766 struct bgp_redist
*red
;
15768 struct route_map
*route_map
=
15769 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15771 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15773 vty_out(vty
, "%% Invalid route type\n");
15774 return CMD_WARNING_CONFIG_FAILED
;
15776 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15778 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
15779 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
15782 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15783 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
15786 DEFUN (no_bgp_redistribute_ipv6
,
15787 no_bgp_redistribute_ipv6_cmd
,
15788 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
15790 "Redistribute information from another routing protocol\n"
15791 FRR_IP6_REDIST_HELP_STR_BGPD
15792 "Metric for redistributed routes\n"
15794 "Route map reference\n"
15795 "Pointer to route-map entries\n")
15797 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15798 int idx_protocol
= 2;
15801 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
15803 vty_out(vty
, "%% Invalid route type\n");
15804 return CMD_WARNING_CONFIG_FAILED
;
15807 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
15810 /* Neighbor update tcp-mss. */
15811 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
15812 const char *tcp_mss_str
)
15815 uint32_t tcp_mss_val
= 0;
15817 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
15819 return CMD_WARNING_CONFIG_FAILED
;
15822 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
15823 peer_tcp_mss_set(peer
, tcp_mss_val
);
15825 peer_tcp_mss_unset(peer
);
15828 return CMD_SUCCESS
;
15831 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
15832 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
15833 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
15834 "TCP max segment size\n"
15837 int peer_index
= 1;
15841 " Warning: Reset BGP session for tcp-mss value to take effect\n");
15842 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
15843 argv
[mss_index
]->arg
);
15846 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
15847 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
15848 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
15849 "TCP max segment size\n"
15852 int peer_index
= 2;
15855 " Warning: Reset BGP session for tcp-mss value to take effect\n");
15856 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
15859 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
15860 afi_t afi
, safi_t safi
)
15864 /* Unicast redistribution only. */
15865 if (safi
!= SAFI_UNICAST
)
15868 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
15869 /* Redistribute BGP does not make sense. */
15870 if (i
!= ZEBRA_ROUTE_BGP
) {
15871 struct list
*red_list
;
15872 struct listnode
*node
;
15873 struct bgp_redist
*red
;
15875 red_list
= bgp
->redist
[afi
][i
];
15879 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
15880 /* "redistribute" configuration. */
15881 vty_out(vty
, " redistribute %s",
15882 zebra_route_string(i
));
15884 vty_out(vty
, " %d", red
->instance
);
15885 if (red
->redist_metric_flag
)
15886 vty_out(vty
, " metric %u",
15887 red
->redist_metric
);
15888 if (red
->rmap
.name
)
15889 vty_out(vty
, " route-map %s",
15891 vty_out(vty
, "\n");
15897 /* peer-group helpers for config-write */
15899 static bool peergroup_flag_check(struct peer
*peer
, uint32_t flag
)
15901 if (!peer_group_active(peer
)) {
15902 if (CHECK_FLAG(peer
->flags_invert
, flag
))
15903 return !CHECK_FLAG(peer
->flags
, flag
);
15905 return !!CHECK_FLAG(peer
->flags
, flag
);
15908 return !!CHECK_FLAG(peer
->flags_override
, flag
);
15911 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
15914 if (!peer_group_active(peer
)) {
15915 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
15916 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
15918 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
15921 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
15924 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
15925 uint8_t type
, int direct
)
15927 struct bgp_filter
*filter
;
15929 if (peer_group_active(peer
))
15930 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
15933 filter
= &peer
->filter
[afi
][safi
];
15935 case PEER_FT_DISTRIBUTE_LIST
:
15936 return !!(filter
->dlist
[direct
].name
);
15937 case PEER_FT_FILTER_LIST
:
15938 return !!(filter
->aslist
[direct
].name
);
15939 case PEER_FT_PREFIX_LIST
:
15940 return !!(filter
->plist
[direct
].name
);
15941 case PEER_FT_ROUTE_MAP
:
15942 return !!(filter
->map
[direct
].name
);
15943 case PEER_FT_UNSUPPRESS_MAP
:
15944 return !!(filter
->usmap
.name
);
15945 case PEER_FT_ADVERTISE_MAP
:
15946 return !!(filter
->advmap
.aname
15947 && ((filter
->advmap
.condition
== direct
)
15948 && filter
->advmap
.cname
));
15954 /* Return true if the addpath type is set for peer and different from
15957 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
15960 enum bgp_addpath_strat type
, g_type
;
15962 type
= peer
->addpath_type
[afi
][safi
];
15964 if (type
!= BGP_ADDPATH_NONE
) {
15965 if (peer_group_active(peer
)) {
15966 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
15968 if (type
!= g_type
)
15980 /* This is part of the address-family block (unicast only) */
15981 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
15986 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
15987 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
15988 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15989 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
15990 bgp
->vpn_policy
[afi
]
15991 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
15993 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
15994 bgp
->vpn_policy
[afi
]
15995 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
15997 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
15998 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
15999 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16000 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16003 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16004 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16006 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16009 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16010 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16011 bgp
->vpn_policy
[afi
].tovpn_label
);
16014 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16015 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
16016 char buf
[RD_ADDRSTRLEN
];
16017 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
16018 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
16021 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16022 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16024 char buf
[PREFIX_STRLEN
];
16025 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16026 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16029 vty_out(vty
, "%*snexthop vpn export %s\n",
16033 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16034 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16036 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16037 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16039 char *b
= ecommunity_ecom2str(
16040 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16041 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16042 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16043 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16045 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16046 char *b
= ecommunity_ecom2str(
16047 bgp
->vpn_policy
[afi
]
16048 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16049 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16050 ECOMMUNITY_ROUTE_TARGET
);
16051 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16052 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16054 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16055 char *b
= ecommunity_ecom2str(
16056 bgp
->vpn_policy
[afi
]
16057 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16058 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16059 ECOMMUNITY_ROUTE_TARGET
);
16060 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16061 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16065 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16066 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16067 bgp
->vpn_policy
[afi
]
16068 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16070 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16071 char *b
= ecommunity_ecom2str(
16072 bgp
->vpn_policy
[afi
]
16073 .import_redirect_rtlist
,
16074 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16075 ECOMMUNITY_ROUTE_TARGET
);
16077 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16078 != ECOMMUNITY_SIZE
)
16079 vty_out(vty
, "%*srt6 redirect import %s\n",
16082 vty_out(vty
, "%*srt redirect import %s\n",
16084 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16088 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16089 afi_t afi
, safi_t safi
)
16091 struct bgp_filter
*filter
;
16095 filter
= &peer
->filter
[afi
][safi
];
16097 /* distribute-list. */
16098 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16100 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16101 filter
->dlist
[FILTER_IN
].name
);
16103 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16105 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16106 filter
->dlist
[FILTER_OUT
].name
);
16109 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16111 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16112 filter
->plist
[FILTER_IN
].name
);
16114 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16116 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16117 filter
->plist
[FILTER_OUT
].name
);
16120 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16121 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16122 filter
->map
[RMAP_IN
].name
);
16124 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16126 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16127 filter
->map
[RMAP_OUT
].name
);
16129 /* unsuppress-map */
16130 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16131 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16132 filter
->usmap
.name
);
16134 /* advertise-map : always applied in OUT direction*/
16135 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16136 CONDITION_NON_EXIST
))
16138 " neighbor %s advertise-map %s non-exist-map %s\n",
16139 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16141 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16143 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16144 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16147 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16149 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16150 filter
->aslist
[FILTER_IN
].name
);
16152 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16154 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16155 filter
->aslist
[FILTER_OUT
].name
);
16158 /* BGP peer configuration display function. */
16159 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16162 struct peer
*g_peer
= NULL
;
16163 char buf
[SU_ADDRSTRLEN
];
16165 int if_pg_printed
= false;
16166 int if_ras_printed
= false;
16168 /* Skip dynamic neighbors. */
16169 if (peer_dynamic_neighbor(peer
))
16173 addr
= peer
->conf_if
;
16177 /************************************
16178 ****** Global to the neighbor ******
16179 ************************************/
16180 if (peer
->conf_if
) {
16181 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16182 vty_out(vty
, " neighbor %s interface v6only", addr
);
16184 vty_out(vty
, " neighbor %s interface", addr
);
16186 if (peer_group_active(peer
)) {
16187 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16188 if_pg_printed
= true;
16189 } else if (peer
->as_type
== AS_SPECIFIED
) {
16190 vty_out(vty
, " remote-as %u", peer
->as
);
16191 if_ras_printed
= true;
16192 } else if (peer
->as_type
== AS_INTERNAL
) {
16193 vty_out(vty
, " remote-as internal");
16194 if_ras_printed
= true;
16195 } else if (peer
->as_type
== AS_EXTERNAL
) {
16196 vty_out(vty
, " remote-as external");
16197 if_ras_printed
= true;
16200 vty_out(vty
, "\n");
16203 /* remote-as and peer-group */
16204 /* peer is a member of a peer-group */
16205 if (peer_group_active(peer
)) {
16206 g_peer
= peer
->group
->conf
;
16208 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16209 if (peer
->as_type
== AS_SPECIFIED
) {
16210 vty_out(vty
, " neighbor %s remote-as %u\n",
16212 } else if (peer
->as_type
== AS_INTERNAL
) {
16214 " neighbor %s remote-as internal\n",
16216 } else if (peer
->as_type
== AS_EXTERNAL
) {
16218 " neighbor %s remote-as external\n",
16223 /* For swpX peers we displayed the peer-group
16224 * via 'neighbor swpX interface peer-group PGNAME' */
16225 if (!if_pg_printed
)
16226 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16227 peer
->group
->name
);
16230 /* peer is NOT a member of a peer-group */
16232 /* peer is a peer-group, declare the peer-group */
16233 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16234 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16237 if (!if_ras_printed
) {
16238 if (peer
->as_type
== AS_SPECIFIED
) {
16239 vty_out(vty
, " neighbor %s remote-as %u\n",
16241 } else if (peer
->as_type
== AS_INTERNAL
) {
16243 " neighbor %s remote-as internal\n",
16245 } else if (peer
->as_type
== AS_EXTERNAL
) {
16247 " neighbor %s remote-as external\n",
16254 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16255 vty_out(vty
, " neighbor %s local-as %u", addr
,
16256 peer
->change_local_as
);
16257 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16258 vty_out(vty
, " no-prepend");
16259 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16260 vty_out(vty
, " replace-as");
16261 vty_out(vty
, "\n");
16266 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16270 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16271 if (peer
->tx_shutdown_message
)
16272 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16273 peer
->tx_shutdown_message
);
16275 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16278 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16279 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16280 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16283 if (peer
->bfd_config
)
16284 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16287 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16288 vty_out(vty
, " neighbor %s password %s\n", addr
,
16291 /* neighbor solo */
16292 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16293 if (!peer_group_active(peer
)) {
16294 vty_out(vty
, " neighbor %s solo\n", addr
);
16299 if (peer
->port
!= BGP_PORT_DEFAULT
) {
16300 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
16303 /* Local interface name */
16304 if (peer
->ifname
) {
16305 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
16308 /* TCP max segment size */
16309 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
16310 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
16313 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
16314 vty_out(vty
, " neighbor %s passive\n", addr
);
16316 /* ebgp-multihop */
16317 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
16318 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
16319 && peer
->ttl
== MAXTTL
)) {
16320 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
16321 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
16326 /* ttl-security hops */
16327 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
16328 if (!peer_group_active(peer
)
16329 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
16330 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
16331 addr
, peer
->gtsm_hops
);
16335 /* disable-connected-check */
16336 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
16337 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
16339 /* enforce-first-as */
16340 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
16341 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
16343 /* update-source */
16344 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
16345 if (peer
->update_source
)
16346 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16347 sockunion2str(peer
->update_source
, buf
,
16349 else if (peer
->update_if
)
16350 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16354 /* advertisement-interval */
16355 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
16356 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
16360 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
16361 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
16362 peer
->keepalive
, peer
->holdtime
);
16364 /* timers connect */
16365 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
16366 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16368 /* need special-case handling for changed default values due to
16369 * config profile / version (because there is no "timers bgp connect"
16370 * command, we need to save this per-peer :/)
16372 else if (!peer_group_active(peer
) && !peer
->connect
&&
16373 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
16374 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16375 peer
->bgp
->default_connect_retry
);
16377 /* timers delayopen */
16378 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
16379 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16381 /* Save config even though flag is not set if default values have been
16384 else if (!peer_group_active(peer
) && !peer
->delayopen
16385 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
16386 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16387 peer
->bgp
->default_delayopen
);
16389 /* capability dynamic */
16390 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
16391 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
16393 /* capability extended-nexthop */
16394 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
16395 if (!peer
->conf_if
) {
16396 if (CHECK_FLAG(peer
->flags_invert
,
16397 PEER_FLAG_CAPABILITY_ENHE
))
16399 " no neighbor %s capability extended-nexthop\n",
16403 " neighbor %s capability extended-nexthop\n",
16408 /* dont-capability-negotiation */
16409 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
16410 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
16412 /* override-capability */
16413 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
16414 vty_out(vty
, " neighbor %s override-capability\n", addr
);
16416 /* strict-capability-match */
16417 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
16418 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
16420 /* Sender side AS path loop detection. */
16421 if (peer
->as_path_loop_detection
)
16422 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
16425 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16426 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
16428 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16429 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
16431 " neighbor %s graceful-restart-helper\n", addr
);
16432 } else if (CHECK_FLAG(
16433 peer
->peer_gr_new_status_flag
,
16434 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
16436 " neighbor %s graceful-restart\n", addr
);
16438 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16439 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
16441 peer
->peer_gr_new_status_flag
,
16442 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
16443 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
16449 /* BGP peer configuration display function. */
16450 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
16451 struct peer
*peer
, afi_t afi
, safi_t safi
)
16453 struct peer
*g_peer
= NULL
;
16455 bool flag_scomm
, flag_secomm
, flag_slcomm
;
16457 /* Skip dynamic neighbors. */
16458 if (peer_dynamic_neighbor(peer
))
16462 addr
= peer
->conf_if
;
16466 /************************************
16467 ****** Per AF to the neighbor ******
16468 ************************************/
16469 if (peer_group_active(peer
)) {
16470 g_peer
= peer
->group
->conf
;
16472 /* If the peer-group is active but peer is not, print a 'no
16474 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
16475 vty_out(vty
, " no neighbor %s activate\n", addr
);
16478 /* If the peer-group is not active but peer is, print an
16480 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
16481 vty_out(vty
, " neighbor %s activate\n", addr
);
16484 if (peer
->afc
[afi
][safi
]) {
16485 if (safi
== SAFI_ENCAP
)
16486 vty_out(vty
, " neighbor %s activate\n", addr
);
16487 else if (!bgp
->default_af
[afi
][safi
])
16488 vty_out(vty
, " neighbor %s activate\n", addr
);
16490 if (bgp
->default_af
[afi
][safi
])
16491 vty_out(vty
, " no neighbor %s activate\n",
16496 /* addpath TX knobs */
16497 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
16498 switch (peer
->addpath_type
[afi
][safi
]) {
16499 case BGP_ADDPATH_ALL
:
16500 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
16503 case BGP_ADDPATH_BEST_PER_AS
:
16505 " neighbor %s addpath-tx-bestpath-per-AS\n",
16508 case BGP_ADDPATH_MAX
:
16509 case BGP_ADDPATH_NONE
:
16514 /* ORF capability. */
16515 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
16516 || peergroup_af_flag_check(peer
, afi
, safi
,
16517 PEER_FLAG_ORF_PREFIX_RM
)) {
16518 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
16520 if (peergroup_af_flag_check(peer
, afi
, safi
,
16521 PEER_FLAG_ORF_PREFIX_SM
)
16522 && peergroup_af_flag_check(peer
, afi
, safi
,
16523 PEER_FLAG_ORF_PREFIX_RM
))
16524 vty_out(vty
, " both");
16525 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16526 PEER_FLAG_ORF_PREFIX_SM
))
16527 vty_out(vty
, " send");
16529 vty_out(vty
, " receive");
16530 vty_out(vty
, "\n");
16533 /* Route reflector client. */
16534 if (peergroup_af_flag_check(peer
, afi
, safi
,
16535 PEER_FLAG_REFLECTOR_CLIENT
)) {
16536 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
16539 /* next-hop-self force */
16540 if (peergroup_af_flag_check(peer
, afi
, safi
,
16541 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
16542 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
16545 /* next-hop-self */
16546 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
16547 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
16550 /* remove-private-AS */
16551 if (peergroup_af_flag_check(peer
, afi
, safi
,
16552 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
16553 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
16557 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16558 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
16559 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
16563 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16564 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
16565 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
16568 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16569 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
16570 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
16574 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
16575 vty_out(vty
, " neighbor %s as-override\n", addr
);
16578 /* send-community print. */
16579 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16580 PEER_FLAG_SEND_COMMUNITY
);
16581 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16582 PEER_FLAG_SEND_EXT_COMMUNITY
);
16583 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16584 PEER_FLAG_SEND_LARGE_COMMUNITY
);
16586 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
16587 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
16590 vty_out(vty
, " no neighbor %s send-community\n", addr
);
16593 " no neighbor %s send-community extended\n",
16597 vty_out(vty
, " no neighbor %s send-community large\n",
16601 /* Default information */
16602 if (peergroup_af_flag_check(peer
, afi
, safi
,
16603 PEER_FLAG_DEFAULT_ORIGINATE
)) {
16604 vty_out(vty
, " neighbor %s default-originate", addr
);
16606 if (peer
->default_rmap
[afi
][safi
].name
)
16607 vty_out(vty
, " route-map %s",
16608 peer
->default_rmap
[afi
][safi
].name
);
16610 vty_out(vty
, "\n");
16613 /* Soft reconfiguration inbound. */
16614 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
16615 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
16619 /* maximum-prefix. */
16620 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
16621 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
16622 peer
->pmax
[afi
][safi
]);
16624 if (peer
->pmax_threshold
[afi
][safi
]
16625 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
16626 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
16627 if (peer_af_flag_check(peer
, afi
, safi
,
16628 PEER_FLAG_MAX_PREFIX_WARNING
))
16629 vty_out(vty
, " warning-only");
16630 if (peer
->pmax_restart
[afi
][safi
])
16631 vty_out(vty
, " restart %u",
16632 peer
->pmax_restart
[afi
][safi
]);
16633 if (peer_af_flag_check(peer
, afi
, safi
,
16634 PEER_FLAG_MAX_PREFIX_FORCE
))
16635 vty_out(vty
, " force");
16637 vty_out(vty
, "\n");
16640 /* maximum-prefix-out */
16641 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
16642 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
16643 addr
, peer
->pmax_out
[afi
][safi
]);
16645 /* Route server client. */
16646 if (peergroup_af_flag_check(peer
, afi
, safi
,
16647 PEER_FLAG_RSERVER_CLIENT
)) {
16648 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
16651 /* Nexthop-local unchanged. */
16652 if (peergroup_af_flag_check(peer
, afi
, safi
,
16653 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
16654 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
16657 /* allowas-in <1-10> */
16658 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
16659 if (peer_af_flag_check(peer
, afi
, safi
,
16660 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
16661 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
16662 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
16663 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
16665 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
16666 peer
->allowas_in
[afi
][safi
]);
16671 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
16672 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
16673 peer
->weight
[afi
][safi
]);
16676 bgp_config_write_filter(vty
, peer
, afi
, safi
);
16678 /* atribute-unchanged. */
16679 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
16680 || (safi
!= SAFI_EVPN
16681 && peer_af_flag_check(peer
, afi
, safi
,
16682 PEER_FLAG_NEXTHOP_UNCHANGED
))
16683 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
16685 if (!peer_group_active(peer
)
16686 || peergroup_af_flag_check(peer
, afi
, safi
,
16687 PEER_FLAG_AS_PATH_UNCHANGED
)
16688 || peergroup_af_flag_check(peer
, afi
, safi
,
16689 PEER_FLAG_NEXTHOP_UNCHANGED
)
16690 || peergroup_af_flag_check(peer
, afi
, safi
,
16691 PEER_FLAG_MED_UNCHANGED
)) {
16694 " neighbor %s attribute-unchanged%s%s%s\n",
16696 peer_af_flag_check(peer
, afi
, safi
,
16697 PEER_FLAG_AS_PATH_UNCHANGED
)
16700 peer_af_flag_check(peer
, afi
, safi
,
16701 PEER_FLAG_NEXTHOP_UNCHANGED
)
16704 peer_af_flag_check(peer
, afi
, safi
,
16705 PEER_FLAG_MED_UNCHANGED
)
16712 /* Address family based peer configuration display. */
16713 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
16717 struct peer_group
*group
;
16718 struct listnode
*node
, *nnode
;
16721 vty_frame(vty
, " !\n address-family ");
16722 if (afi
== AFI_IP
) {
16723 if (safi
== SAFI_UNICAST
)
16724 vty_frame(vty
, "ipv4 unicast");
16725 else if (safi
== SAFI_LABELED_UNICAST
)
16726 vty_frame(vty
, "ipv4 labeled-unicast");
16727 else if (safi
== SAFI_MULTICAST
)
16728 vty_frame(vty
, "ipv4 multicast");
16729 else if (safi
== SAFI_MPLS_VPN
)
16730 vty_frame(vty
, "ipv4 vpn");
16731 else if (safi
== SAFI_ENCAP
)
16732 vty_frame(vty
, "ipv4 encap");
16733 else if (safi
== SAFI_FLOWSPEC
)
16734 vty_frame(vty
, "ipv4 flowspec");
16735 } else if (afi
== AFI_IP6
) {
16736 if (safi
== SAFI_UNICAST
)
16737 vty_frame(vty
, "ipv6 unicast");
16738 else if (safi
== SAFI_LABELED_UNICAST
)
16739 vty_frame(vty
, "ipv6 labeled-unicast");
16740 else if (safi
== SAFI_MULTICAST
)
16741 vty_frame(vty
, "ipv6 multicast");
16742 else if (safi
== SAFI_MPLS_VPN
)
16743 vty_frame(vty
, "ipv6 vpn");
16744 else if (safi
== SAFI_ENCAP
)
16745 vty_frame(vty
, "ipv6 encap");
16746 else if (safi
== SAFI_FLOWSPEC
)
16747 vty_frame(vty
, "ipv6 flowspec");
16748 } else if (afi
== AFI_L2VPN
) {
16749 if (safi
== SAFI_EVPN
)
16750 vty_frame(vty
, "l2vpn evpn");
16752 vty_frame(vty
, "\n");
16754 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
16756 bgp_config_write_network(vty
, bgp
, afi
, safi
);
16758 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
16760 /* BGP flag dampening. */
16761 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
16762 bgp_config_write_damp(vty
, afi
, safi
);
16764 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
16765 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
16767 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
16768 /* Do not display doppelganger peers */
16769 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
16770 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
16773 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
16774 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
16776 if (safi
== SAFI_EVPN
)
16777 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
16779 if (safi
== SAFI_FLOWSPEC
)
16780 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
16782 if (safi
== SAFI_UNICAST
) {
16783 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
16784 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
16785 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
16787 vty_out(vty
, " export vpn\n");
16789 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
16790 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
16792 vty_out(vty
, " import vpn\n");
16794 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
16795 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
16798 for (ALL_LIST_ELEMENTS_RO(
16799 bgp
->vpn_policy
[afi
].import_vrf
, node
,
16801 vty_out(vty
, " import vrf %s\n", name
);
16805 vty_endframe(vty
, " exit-address-family\n");
16808 int bgp_config_write(struct vty
*vty
)
16811 struct peer_group
*group
;
16813 struct listnode
*node
, *nnode
;
16814 struct listnode
*mnode
, *mnnode
;
16818 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
16819 vty_out(vty
, "bgp route-map delay-timer %u\n",
16820 bm
->rmap_update_timer
);
16822 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
16823 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
16824 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
16825 vty_out(vty
, " %d", bm
->v_establish_wait
);
16826 vty_out(vty
, "\n");
16829 if (bm
->wait_for_fib
)
16830 vty_out(vty
, "bgp suppress-fib-pending\n");
16832 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
16833 vty_out(vty
, "bgp graceful-shutdown\n");
16835 /* No-RIB (Zebra) option flag configuration */
16836 if (bgp_option_check(BGP_OPT_NO_FIB
))
16837 vty_out(vty
, "bgp no-rib\n");
16839 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
16840 vty_out(vty
, "no bgp send-extra-data zebra\n");
16842 /* BGP configuration. */
16843 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
16845 /* skip all auto created vrf as they dont have user config */
16846 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
16849 /* Router bgp ASN */
16850 vty_out(vty
, "router bgp %u", bgp
->as
);
16853 vty_out(vty
, " %s %s",
16854 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
16855 ? "view" : "vrf", bgp
->name
);
16856 vty_out(vty
, "\n");
16858 /* BGP fast-external-failover. */
16859 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
16860 vty_out(vty
, " no bgp fast-external-failover\n");
16862 /* BGP router ID. */
16863 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
16864 vty_out(vty
, " bgp router-id %pI4\n",
16865 &bgp
->router_id_static
);
16867 /* Suppress fib pending */
16868 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
16869 vty_out(vty
, " bgp suppress-fib-pending\n");
16871 /* BGP log-neighbor-changes. */
16872 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
16873 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
16874 vty_out(vty
, " %sbgp log-neighbor-changes\n",
16875 CHECK_FLAG(bgp
->flags
,
16876 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
16880 /* BGP configuration. */
16881 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
16882 vty_out(vty
, " bgp always-compare-med\n");
16884 /* RFC8212 default eBGP policy. */
16885 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
16886 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
16887 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
16888 CHECK_FLAG(bgp
->flags
,
16889 BGP_FLAG_EBGP_REQUIRES_POLICY
)
16893 /* draft-ietf-idr-deprecate-as-set-confed-set */
16894 if (bgp
->reject_as_sets
)
16895 vty_out(vty
, " bgp reject-as-sets\n");
16897 /* Suppress duplicate updates if the route actually not changed
16899 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
16900 != SAVE_BGP_SUPPRESS_DUPLICATES
)
16901 vty_out(vty
, " %sbgp suppress-duplicates\n",
16902 CHECK_FLAG(bgp
->flags
,
16903 BGP_FLAG_SUPPRESS_DUPLICATES
)
16907 /* BGP default <afi>-<safi> */
16908 FOREACH_AFI_SAFI (afi
, safi
) {
16909 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
16910 if (!bgp
->default_af
[afi
][safi
])
16911 vty_out(vty
, " no bgp default %s\n",
16912 get_bgp_default_af_flag(afi
,
16914 } else if (bgp
->default_af
[afi
][safi
])
16915 vty_out(vty
, " bgp default %s\n",
16916 get_bgp_default_af_flag(afi
, safi
));
16919 /* BGP default local-preference. */
16920 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
16921 vty_out(vty
, " bgp default local-preference %u\n",
16922 bgp
->default_local_pref
);
16924 /* BGP default show-hostname */
16925 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
16926 != SAVE_BGP_SHOW_HOSTNAME
)
16927 vty_out(vty
, " %sbgp default show-hostname\n",
16928 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
16932 /* BGP default show-nexthop-hostname */
16933 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
16934 != SAVE_BGP_SHOW_HOSTNAME
)
16935 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
16936 CHECK_FLAG(bgp
->flags
,
16937 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
16941 /* BGP default subgroup-pkt-queue-max. */
16942 if (bgp
->default_subgroup_pkt_queue_max
16943 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
16944 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
16945 bgp
->default_subgroup_pkt_queue_max
);
16947 /* BGP client-to-client reflection. */
16948 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
16949 vty_out(vty
, " no bgp client-to-client reflection\n");
16951 /* BGP cluster ID. */
16952 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
16953 vty_out(vty
, " bgp cluster-id %pI4\n",
16956 /* Disable ebgp connected nexthop check */
16957 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
16959 " bgp disable-ebgp-connected-route-check\n");
16961 /* Confederation identifier*/
16962 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
16963 vty_out(vty
, " bgp confederation identifier %u\n",
16966 /* Confederation peer */
16967 if (bgp
->confed_peers_cnt
> 0) {
16970 vty_out(vty
, " bgp confederation peers");
16972 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
16973 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
16975 vty_out(vty
, "\n");
16978 /* BGP deterministic-med. */
16979 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
16980 != SAVE_BGP_DETERMINISTIC_MED
)
16981 vty_out(vty
, " %sbgp deterministic-med\n",
16982 CHECK_FLAG(bgp
->flags
,
16983 BGP_FLAG_DETERMINISTIC_MED
)
16987 /* BGP update-delay. */
16988 bgp_config_write_update_delay(vty
, bgp
);
16990 if (bgp
->v_maxmed_onstartup
16991 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
16992 vty_out(vty
, " bgp max-med on-startup %u",
16993 bgp
->v_maxmed_onstartup
);
16994 if (bgp
->maxmed_onstartup_value
16995 != BGP_MAXMED_VALUE_DEFAULT
)
16996 vty_out(vty
, " %u",
16997 bgp
->maxmed_onstartup_value
);
16998 vty_out(vty
, "\n");
17000 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17001 vty_out(vty
, " bgp max-med administrative");
17002 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17003 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17004 vty_out(vty
, "\n");
17008 bgp_config_write_wpkt_quanta(vty
, bgp
);
17010 bgp_config_write_rpkt_quanta(vty
, bgp
);
17012 /* coalesce time */
17013 bgp_config_write_coalesce_time(vty
, bgp
);
17015 /* BGP per-instance graceful-shutdown */
17016 /* BGP-wide settings and per-instance settings are mutually
17019 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17020 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17021 vty_out(vty
, " bgp graceful-shutdown\n");
17023 /* BGP graceful-restart. */
17024 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17026 " bgp graceful-restart stalepath-time %u\n",
17027 bgp
->stalepath_time
);
17029 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17030 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17031 bgp
->restart_time
);
17033 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17035 " bgp graceful-restart select-defer-time %u\n",
17036 bgp
->select_defer_time
);
17038 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17039 vty_out(vty
, " bgp graceful-restart\n");
17041 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17042 vty_out(vty
, " bgp graceful-restart-disable\n");
17044 /* BGP graceful-restart Preserve State F bit. */
17045 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17047 " bgp graceful-restart preserve-fw-state\n");
17049 /* Stale timer for RIB */
17050 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17052 " bgp graceful-restart rib-stale-time %u\n",
17053 bgp
->rib_stale_time
);
17055 /* BGP bestpath method. */
17056 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17057 vty_out(vty
, " bgp bestpath as-path ignore\n");
17058 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17059 vty_out(vty
, " bgp bestpath as-path confed\n");
17061 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17062 if (CHECK_FLAG(bgp
->flags
,
17063 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17065 " bgp bestpath as-path multipath-relax as-set\n");
17068 " bgp bestpath as-path multipath-relax\n");
17072 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17074 " bgp route-reflector allow-outbound-policy\n");
17076 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17077 vty_out(vty
, " bgp bestpath compare-routerid\n");
17078 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17079 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17080 vty_out(vty
, " bgp bestpath med");
17081 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17082 vty_out(vty
, " confed");
17083 if (CHECK_FLAG(bgp
->flags
,
17084 BGP_FLAG_MED_MISSING_AS_WORST
))
17085 vty_out(vty
, " missing-as-worst");
17086 vty_out(vty
, "\n");
17089 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
17091 " bgp bestpath peer-type multipath-relax\n");
17093 /* Link bandwidth handling. */
17094 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17095 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17096 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17097 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17098 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17099 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17101 /* BGP network import check. */
17102 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17103 != SAVE_BGP_IMPORT_CHECK
)
17104 vty_out(vty
, " %sbgp network import-check\n",
17105 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17109 /* BGP timers configuration. */
17110 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17111 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17112 vty_out(vty
, " timers bgp %u %u\n",
17113 bgp
->default_keepalive
, bgp
->default_holdtime
);
17115 /* Conditional advertisement timer configuration */
17116 if (bgp
->condition_check_period
17117 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
17119 " bgp conditional-advertisement timer %u\n",
17120 bgp
->condition_check_period
);
17123 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17124 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17127 /* Normal neighbor configuration. */
17128 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17129 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17130 bgp_config_write_peer_global(vty
, bgp
, peer
);
17133 /* listen range and limit for dynamic BGP neighbors */
17134 bgp_config_write_listen(vty
, bgp
);
17137 * BGP default autoshutdown neighbors
17139 * This must be placed after any peer and peer-group
17140 * configuration, to avoid setting all peers to shutdown after
17141 * a daemon restart, which is undesired behavior. (see #2286)
17143 if (bgp
->autoshutdown
)
17144 vty_out(vty
, " bgp default shutdown\n");
17146 /* BGP instance administrative shutdown */
17147 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17148 vty_out(vty
, " bgp shutdown\n");
17150 if (bgp
->srv6_enabled
) {
17151 vty_frame(vty
, " !\n segment-routing srv6\n");
17152 if (strlen(bgp
->srv6_locator_name
))
17153 vty_out(vty
, " locator %s\n",
17154 bgp
->srv6_locator_name
);
17158 /* IPv4 unicast configuration. */
17159 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17161 /* IPv4 multicast configuration. */
17162 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17164 /* IPv4 labeled-unicast configuration. */
17165 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17167 /* IPv4 VPN configuration. */
17168 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17170 /* ENCAPv4 configuration. */
17171 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17173 /* FLOWSPEC v4 configuration. */
17174 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17176 /* IPv6 unicast configuration. */
17177 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17179 /* IPv6 multicast configuration. */
17180 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17182 /* IPv6 labeled-unicast configuration. */
17183 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17184 SAFI_LABELED_UNICAST
);
17186 /* IPv6 VPN configuration. */
17187 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17189 /* ENCAPv6 configuration. */
17190 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17192 /* FLOWSPEC v6 configuration. */
17193 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17195 /* EVPN configuration. */
17196 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17198 hook_call(bgp_inst_config_write
, bgp
, vty
);
17200 #ifdef ENABLE_BGP_VNC
17201 bgp_rfapi_cfg_write(vty
, bgp
);
17204 vty_out(vty
, "!\n");
17210 /* BGP node structure. */
17211 static struct cmd_node bgp_node
= {
17214 .parent_node
= CONFIG_NODE
,
17215 .prompt
= "%s(config-router)# ",
17216 .config_write
= bgp_config_write
,
17219 static struct cmd_node bgp_ipv4_unicast_node
= {
17220 .name
= "bgp ipv4 unicast",
17221 .node
= BGP_IPV4_NODE
,
17222 .parent_node
= BGP_NODE
,
17223 .prompt
= "%s(config-router-af)# ",
17226 static struct cmd_node bgp_ipv4_multicast_node
= {
17227 .name
= "bgp ipv4 multicast",
17228 .node
= BGP_IPV4M_NODE
,
17229 .parent_node
= BGP_NODE
,
17230 .prompt
= "%s(config-router-af)# ",
17233 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
17234 .name
= "bgp ipv4 labeled unicast",
17235 .node
= BGP_IPV4L_NODE
,
17236 .parent_node
= BGP_NODE
,
17237 .prompt
= "%s(config-router-af)# ",
17240 static struct cmd_node bgp_ipv6_unicast_node
= {
17241 .name
= "bgp ipv6 unicast",
17242 .node
= BGP_IPV6_NODE
,
17243 .parent_node
= BGP_NODE
,
17244 .prompt
= "%s(config-router-af)# ",
17247 static struct cmd_node bgp_ipv6_multicast_node
= {
17248 .name
= "bgp ipv6 multicast",
17249 .node
= BGP_IPV6M_NODE
,
17250 .parent_node
= BGP_NODE
,
17251 .prompt
= "%s(config-router-af)# ",
17254 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
17255 .name
= "bgp ipv6 labeled unicast",
17256 .node
= BGP_IPV6L_NODE
,
17257 .parent_node
= BGP_NODE
,
17258 .prompt
= "%s(config-router-af)# ",
17261 static struct cmd_node bgp_vpnv4_node
= {
17262 .name
= "bgp vpnv4",
17263 .node
= BGP_VPNV4_NODE
,
17264 .parent_node
= BGP_NODE
,
17265 .prompt
= "%s(config-router-af)# ",
17268 static struct cmd_node bgp_vpnv6_node
= {
17269 .name
= "bgp vpnv6",
17270 .node
= BGP_VPNV6_NODE
,
17271 .parent_node
= BGP_NODE
,
17272 .prompt
= "%s(config-router-af-vpnv6)# ",
17275 static struct cmd_node bgp_evpn_node
= {
17276 .name
= "bgp evpn",
17277 .node
= BGP_EVPN_NODE
,
17278 .parent_node
= BGP_NODE
,
17279 .prompt
= "%s(config-router-evpn)# ",
17282 static struct cmd_node bgp_evpn_vni_node
= {
17283 .name
= "bgp evpn vni",
17284 .node
= BGP_EVPN_VNI_NODE
,
17285 .parent_node
= BGP_EVPN_NODE
,
17286 .prompt
= "%s(config-router-af-vni)# ",
17289 static struct cmd_node bgp_flowspecv4_node
= {
17290 .name
= "bgp ipv4 flowspec",
17291 .node
= BGP_FLOWSPECV4_NODE
,
17292 .parent_node
= BGP_NODE
,
17293 .prompt
= "%s(config-router-af)# ",
17296 static struct cmd_node bgp_flowspecv6_node
= {
17297 .name
= "bgp ipv6 flowspec",
17298 .node
= BGP_FLOWSPECV6_NODE
,
17299 .parent_node
= BGP_NODE
,
17300 .prompt
= "%s(config-router-af-vpnv6)# ",
17303 static struct cmd_node bgp_srv6_node
= {
17304 .name
= "bgp srv6",
17305 .node
= BGP_SRV6_NODE
,
17306 .parent_node
= BGP_NODE
,
17307 .prompt
= "%s(config-router-srv6)# ",
17310 static void community_list_vty(void);
17312 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
17316 struct listnode
*lnbgp
, *lnpeer
;
17318 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17319 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
17320 /* only provide suggestions on the appropriate input
17322 * they'll otherwise show up multiple times */
17323 enum cmd_token_type match_type
;
17324 char *name
= peer
->host
;
17326 if (peer
->conf_if
) {
17327 match_type
= VARIABLE_TKN
;
17328 name
= peer
->conf_if
;
17329 } else if (strchr(peer
->host
, ':'))
17330 match_type
= IPV6_TKN
;
17332 match_type
= IPV4_TKN
;
17334 if (token
->type
!= match_type
)
17337 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
17342 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
17343 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
17344 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
17345 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
17346 {.completions
= NULL
}};
17348 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
17351 struct peer_group
*group
;
17352 struct listnode
*lnbgp
, *lnpeer
;
17354 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17355 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
17356 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
17361 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
17362 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
17363 {.completions
= NULL
} };
17365 void bgp_vty_init(void)
17367 cmd_variable_handler_register(bgp_var_neighbor
);
17368 cmd_variable_handler_register(bgp_var_peergroup
);
17370 /* Install bgp top node. */
17371 install_node(&bgp_node
);
17372 install_node(&bgp_ipv4_unicast_node
);
17373 install_node(&bgp_ipv4_multicast_node
);
17374 install_node(&bgp_ipv4_labeled_unicast_node
);
17375 install_node(&bgp_ipv6_unicast_node
);
17376 install_node(&bgp_ipv6_multicast_node
);
17377 install_node(&bgp_ipv6_labeled_unicast_node
);
17378 install_node(&bgp_vpnv4_node
);
17379 install_node(&bgp_vpnv6_node
);
17380 install_node(&bgp_evpn_node
);
17381 install_node(&bgp_evpn_vni_node
);
17382 install_node(&bgp_flowspecv4_node
);
17383 install_node(&bgp_flowspecv6_node
);
17384 install_node(&bgp_srv6_node
);
17386 /* Install default VTY commands to new nodes. */
17387 install_default(BGP_NODE
);
17388 install_default(BGP_IPV4_NODE
);
17389 install_default(BGP_IPV4M_NODE
);
17390 install_default(BGP_IPV4L_NODE
);
17391 install_default(BGP_IPV6_NODE
);
17392 install_default(BGP_IPV6M_NODE
);
17393 install_default(BGP_IPV6L_NODE
);
17394 install_default(BGP_VPNV4_NODE
);
17395 install_default(BGP_VPNV6_NODE
);
17396 install_default(BGP_FLOWSPECV4_NODE
);
17397 install_default(BGP_FLOWSPECV6_NODE
);
17398 install_default(BGP_EVPN_NODE
);
17399 install_default(BGP_EVPN_VNI_NODE
);
17400 install_default(BGP_SRV6_NODE
);
17402 /* "bgp local-mac" hidden commands. */
17403 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
17404 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
17406 /* "bgp suppress-fib-pending" global */
17407 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
17409 /* bgp route-map delay-timer commands. */
17410 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17411 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17413 /* global bgp update-delay command */
17414 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
17415 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
17417 /* global bgp graceful-shutdown command */
17418 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
17419 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
17421 /* Dummy commands (Currently not supported) */
17422 install_element(BGP_NODE
, &no_synchronization_cmd
);
17423 install_element(BGP_NODE
, &no_auto_summary_cmd
);
17425 /* "router bgp" commands. */
17426 install_element(CONFIG_NODE
, &router_bgp_cmd
);
17428 /* "no router bgp" commands. */
17429 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
17431 /* "bgp router-id" commands. */
17432 install_element(BGP_NODE
, &bgp_router_id_cmd
);
17433 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
17435 /* "bgp suppress-fib-pending" command */
17436 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
17438 /* "bgp cluster-id" commands. */
17439 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
17440 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
17442 /* "bgp no-rib" commands. */
17443 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
17444 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
17446 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
17448 /* "bgp confederation" commands. */
17449 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
17450 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
17452 /* "bgp confederation peers" commands. */
17453 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
17454 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
17456 /* bgp max-med command */
17457 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
17458 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
17459 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
17460 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
17461 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
17463 /* bgp disable-ebgp-connected-nh-check */
17464 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
17465 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
17467 /* bgp update-delay command */
17468 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
17469 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
17471 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
17472 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
17474 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
17475 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
17477 /* "maximum-paths" commands. */
17478 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
17479 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
17480 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
17481 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
17482 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
17483 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
17484 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
17485 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
17486 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
17487 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
17488 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17489 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17490 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
17491 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17492 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17494 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
17495 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
17496 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17497 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17498 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17499 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
17500 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
17501 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17502 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17503 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17505 /* "timers bgp" commands. */
17506 install_element(BGP_NODE
, &bgp_timers_cmd
);
17507 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
17509 /* route-map delay-timer commands - per instance for backwards compat.
17511 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17512 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17514 /* "bgp client-to-client reflection" commands */
17515 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
17516 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
17518 /* "bgp always-compare-med" commands */
17519 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
17520 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
17522 /* bgp ebgp-requires-policy */
17523 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
17524 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
17526 /* bgp suppress-duplicates */
17527 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
17528 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
17530 /* bgp reject-as-sets */
17531 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
17532 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
17534 /* "bgp deterministic-med" commands */
17535 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
17536 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
17538 /* "bgp graceful-restart" command */
17539 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
17540 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
17542 /* "bgp graceful-restart-disable" command */
17543 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
17544 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
17546 /* "neighbor a:b:c:d graceful-restart" command */
17547 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
17548 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
17550 /* "neighbor a:b:c:d graceful-restart-disable" command */
17551 install_element(BGP_NODE
,
17552 &bgp_neighbor_graceful_restart_disable_set_cmd
);
17553 install_element(BGP_NODE
,
17554 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
17556 /* "neighbor a:b:c:d graceful-restart-helper" command */
17557 install_element(BGP_NODE
,
17558 &bgp_neighbor_graceful_restart_helper_set_cmd
);
17559 install_element(BGP_NODE
,
17560 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
17562 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
17563 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
17564 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
17565 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
17566 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
17567 install_element(BGP_NODE
,
17568 &no_bgp_graceful_restart_select_defer_time_cmd
);
17569 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
17570 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
17572 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
17573 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
17574 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
17575 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
17577 /* "bgp graceful-shutdown" commands */
17578 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
17579 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
17581 /* "bgp fast-external-failover" commands */
17582 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
17583 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
17585 /* "bgp bestpath compare-routerid" commands */
17586 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
17587 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
17589 /* "bgp bestpath as-path ignore" commands */
17590 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
17591 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
17593 /* "bgp bestpath as-path confed" commands */
17594 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
17595 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
17597 /* "bgp bestpath as-path multipath-relax" commands */
17598 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
17599 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
17601 /* "bgp bestpath peer-type multipath-relax" commands */
17602 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
17603 install_element(BGP_NODE
,
17604 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
17606 /* "bgp log-neighbor-changes" commands */
17607 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
17608 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
17610 /* "bgp bestpath med" commands */
17611 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
17612 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
17614 /* "bgp bestpath bandwidth" commands */
17615 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
17616 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
17618 /* "no bgp default <afi>-<safi>" commands. */
17619 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
17621 /* "bgp network import-check" commands. */
17622 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
17623 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
17624 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
17626 /* "bgp default local-preference" commands. */
17627 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
17628 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
17630 /* bgp default show-hostname */
17631 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
17632 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
17634 /* bgp default show-nexthop-hostname */
17635 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
17636 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
17638 /* "bgp default subgroup-pkt-queue-max" commands. */
17639 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
17640 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
17642 /* bgp ibgp-allow-policy-mods command */
17643 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
17644 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
17646 /* "bgp listen limit" commands. */
17647 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
17648 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
17650 /* "bgp listen range" commands. */
17651 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
17652 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
17654 /* "bgp default shutdown" command */
17655 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
17657 /* "bgp shutdown" commands */
17658 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
17659 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
17660 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
17661 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
17663 /* "neighbor remote-as" commands. */
17664 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
17665 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
17666 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
17667 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
17668 install_element(BGP_NODE
,
17669 &neighbor_interface_v6only_config_remote_as_cmd
);
17670 install_element(BGP_NODE
, &no_neighbor_cmd
);
17671 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
17673 /* "neighbor peer-group" commands. */
17674 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
17675 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
17676 install_element(BGP_NODE
,
17677 &no_neighbor_interface_peer_group_remote_as_cmd
);
17679 /* "neighbor local-as" commands. */
17680 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
17681 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
17682 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
17683 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
17685 /* "neighbor solo" commands. */
17686 install_element(BGP_NODE
, &neighbor_solo_cmd
);
17687 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
17689 /* "neighbor password" commands. */
17690 install_element(BGP_NODE
, &neighbor_password_cmd
);
17691 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
17693 /* "neighbor activate" commands. */
17694 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
17695 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
17696 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
17697 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
17698 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
17699 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
17700 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
17701 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
17702 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
17703 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
17704 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
17705 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
17707 /* "no neighbor activate" commands. */
17708 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
17709 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
17710 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
17711 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
17712 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
17713 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
17714 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
17715 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
17716 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
17717 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
17718 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
17719 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
17721 /* "neighbor peer-group" set commands. */
17722 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
17723 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17724 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17725 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17726 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17727 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17728 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17729 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17730 install_element(BGP_FLOWSPECV4_NODE
,
17731 &neighbor_set_peer_group_hidden_cmd
);
17732 install_element(BGP_FLOWSPECV6_NODE
,
17733 &neighbor_set_peer_group_hidden_cmd
);
17735 /* "no neighbor peer-group unset" commands. */
17736 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
17737 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17738 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17739 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17740 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17741 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17742 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17743 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17744 install_element(BGP_FLOWSPECV4_NODE
,
17745 &no_neighbor_set_peer_group_hidden_cmd
);
17746 install_element(BGP_FLOWSPECV6_NODE
,
17747 &no_neighbor_set_peer_group_hidden_cmd
);
17749 /* "neighbor softreconfiguration inbound" commands.*/
17750 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
17751 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
17752 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
17753 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17754 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
17755 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17756 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
17757 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17758 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
17759 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17760 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
17761 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17762 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
17763 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17764 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
17765 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17766 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
17767 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17768 install_element(BGP_FLOWSPECV4_NODE
,
17769 &neighbor_soft_reconfiguration_cmd
);
17770 install_element(BGP_FLOWSPECV4_NODE
,
17771 &no_neighbor_soft_reconfiguration_cmd
);
17772 install_element(BGP_FLOWSPECV6_NODE
,
17773 &neighbor_soft_reconfiguration_cmd
);
17774 install_element(BGP_FLOWSPECV6_NODE
,
17775 &no_neighbor_soft_reconfiguration_cmd
);
17776 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
17777 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17779 /* "neighbor attribute-unchanged" commands. */
17780 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
17781 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
17782 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
17783 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
17784 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
17785 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
17786 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
17787 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
17788 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
17789 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
17790 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
17791 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
17792 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
17793 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
17794 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
17795 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
17796 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
17797 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
17799 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
17800 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
17802 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
17803 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
17804 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
17805 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
17807 /* "nexthop-local unchanged" commands */
17808 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
17809 install_element(BGP_IPV6_NODE
,
17810 &no_neighbor_nexthop_local_unchanged_cmd
);
17812 /* "neighbor next-hop-self" commands. */
17813 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
17814 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
17815 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
17816 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
17817 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
17818 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
17819 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
17820 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
17821 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
17822 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
17823 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
17824 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
17825 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
17826 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
17827 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
17828 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
17829 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
17830 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
17831 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
17832 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
17834 /* "neighbor next-hop-self force" commands. */
17835 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
17836 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
17837 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17838 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
17839 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
17840 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17841 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17842 install_element(BGP_IPV4_NODE
,
17843 &no_neighbor_nexthop_self_all_hidden_cmd
);
17844 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
17845 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17846 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17847 install_element(BGP_IPV4M_NODE
,
17848 &no_neighbor_nexthop_self_all_hidden_cmd
);
17849 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
17850 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17851 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17852 install_element(BGP_IPV4L_NODE
,
17853 &no_neighbor_nexthop_self_all_hidden_cmd
);
17854 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
17855 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17856 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17857 install_element(BGP_IPV6_NODE
,
17858 &no_neighbor_nexthop_self_all_hidden_cmd
);
17859 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
17860 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17861 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17862 install_element(BGP_IPV6M_NODE
,
17863 &no_neighbor_nexthop_self_all_hidden_cmd
);
17864 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
17865 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17866 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17867 install_element(BGP_IPV6L_NODE
,
17868 &no_neighbor_nexthop_self_all_hidden_cmd
);
17869 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
17870 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17871 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17872 install_element(BGP_VPNV4_NODE
,
17873 &no_neighbor_nexthop_self_all_hidden_cmd
);
17874 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
17875 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17876 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17877 install_element(BGP_VPNV6_NODE
,
17878 &no_neighbor_nexthop_self_all_hidden_cmd
);
17879 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
17880 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17882 /* "neighbor as-override" commands. */
17883 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
17884 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
17885 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
17886 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
17887 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
17888 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
17889 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
17890 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
17891 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
17892 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
17893 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
17894 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
17895 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
17896 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
17897 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
17898 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
17899 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
17900 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
17902 /* "neighbor remove-private-AS" commands. */
17903 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
17904 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
17905 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
17906 install_element(BGP_NODE
,
17907 &no_neighbor_remove_private_as_all_hidden_cmd
);
17908 install_element(BGP_NODE
,
17909 &neighbor_remove_private_as_replace_as_hidden_cmd
);
17910 install_element(BGP_NODE
,
17911 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
17912 install_element(BGP_NODE
,
17913 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
17916 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
17917 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
17918 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
17919 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
17920 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
17921 install_element(BGP_IPV4_NODE
,
17922 &neighbor_remove_private_as_replace_as_cmd
);
17923 install_element(BGP_IPV4_NODE
,
17924 &no_neighbor_remove_private_as_replace_as_cmd
);
17925 install_element(BGP_IPV4_NODE
,
17926 &neighbor_remove_private_as_all_replace_as_cmd
);
17927 install_element(BGP_IPV4_NODE
,
17928 &no_neighbor_remove_private_as_all_replace_as_cmd
);
17929 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
17930 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
17931 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
17932 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
17933 install_element(BGP_IPV4M_NODE
,
17934 &neighbor_remove_private_as_replace_as_cmd
);
17935 install_element(BGP_IPV4M_NODE
,
17936 &no_neighbor_remove_private_as_replace_as_cmd
);
17937 install_element(BGP_IPV4M_NODE
,
17938 &neighbor_remove_private_as_all_replace_as_cmd
);
17939 install_element(BGP_IPV4M_NODE
,
17940 &no_neighbor_remove_private_as_all_replace_as_cmd
);
17941 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
17942 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
17943 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
17944 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
17945 install_element(BGP_IPV4L_NODE
,
17946 &neighbor_remove_private_as_replace_as_cmd
);
17947 install_element(BGP_IPV4L_NODE
,
17948 &no_neighbor_remove_private_as_replace_as_cmd
);
17949 install_element(BGP_IPV4L_NODE
,
17950 &neighbor_remove_private_as_all_replace_as_cmd
);
17951 install_element(BGP_IPV4L_NODE
,
17952 &no_neighbor_remove_private_as_all_replace_as_cmd
);
17953 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
17954 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
17955 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
17956 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
17957 install_element(BGP_IPV6_NODE
,
17958 &neighbor_remove_private_as_replace_as_cmd
);
17959 install_element(BGP_IPV6_NODE
,
17960 &no_neighbor_remove_private_as_replace_as_cmd
);
17961 install_element(BGP_IPV6_NODE
,
17962 &neighbor_remove_private_as_all_replace_as_cmd
);
17963 install_element(BGP_IPV6_NODE
,
17964 &no_neighbor_remove_private_as_all_replace_as_cmd
);
17965 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
17966 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
17967 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
17968 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
17969 install_element(BGP_IPV6M_NODE
,
17970 &neighbor_remove_private_as_replace_as_cmd
);
17971 install_element(BGP_IPV6M_NODE
,
17972 &no_neighbor_remove_private_as_replace_as_cmd
);
17973 install_element(BGP_IPV6M_NODE
,
17974 &neighbor_remove_private_as_all_replace_as_cmd
);
17975 install_element(BGP_IPV6M_NODE
,
17976 &no_neighbor_remove_private_as_all_replace_as_cmd
);
17977 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
17978 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
17979 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
17980 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
17981 install_element(BGP_IPV6L_NODE
,
17982 &neighbor_remove_private_as_replace_as_cmd
);
17983 install_element(BGP_IPV6L_NODE
,
17984 &no_neighbor_remove_private_as_replace_as_cmd
);
17985 install_element(BGP_IPV6L_NODE
,
17986 &neighbor_remove_private_as_all_replace_as_cmd
);
17987 install_element(BGP_IPV6L_NODE
,
17988 &no_neighbor_remove_private_as_all_replace_as_cmd
);
17989 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
17990 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
17991 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
17992 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
17993 install_element(BGP_VPNV4_NODE
,
17994 &neighbor_remove_private_as_replace_as_cmd
);
17995 install_element(BGP_VPNV4_NODE
,
17996 &no_neighbor_remove_private_as_replace_as_cmd
);
17997 install_element(BGP_VPNV4_NODE
,
17998 &neighbor_remove_private_as_all_replace_as_cmd
);
17999 install_element(BGP_VPNV4_NODE
,
18000 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18001 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
18002 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18003 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18004 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18005 install_element(BGP_VPNV6_NODE
,
18006 &neighbor_remove_private_as_replace_as_cmd
);
18007 install_element(BGP_VPNV6_NODE
,
18008 &no_neighbor_remove_private_as_replace_as_cmd
);
18009 install_element(BGP_VPNV6_NODE
,
18010 &neighbor_remove_private_as_all_replace_as_cmd
);
18011 install_element(BGP_VPNV6_NODE
,
18012 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18014 /* "neighbor send-community" commands.*/
18015 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
18016 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
18017 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
18018 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
18019 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
18020 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
18021 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
18022 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
18023 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
18024 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
18025 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
18026 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
18027 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
18028 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
18029 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
18030 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
18031 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
18032 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
18033 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
18034 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
18035 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
18036 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
18037 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
18038 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
18039 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
18040 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
18041 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
18042 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
18043 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
18044 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
18045 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
18046 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
18047 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
18048 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
18049 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
18050 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
18052 /* "neighbor route-reflector" commands.*/
18053 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
18054 install_element(BGP_NODE
,
18055 &no_neighbor_route_reflector_client_hidden_cmd
);
18056 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
18057 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
18058 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
18059 install_element(BGP_IPV4M_NODE
,
18060 &no_neighbor_route_reflector_client_cmd
);
18061 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
18062 install_element(BGP_IPV4L_NODE
,
18063 &no_neighbor_route_reflector_client_cmd
);
18064 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
18065 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
18066 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
18067 install_element(BGP_IPV6M_NODE
,
18068 &no_neighbor_route_reflector_client_cmd
);
18069 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
18070 install_element(BGP_IPV6L_NODE
,
18071 &no_neighbor_route_reflector_client_cmd
);
18072 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
18073 install_element(BGP_VPNV4_NODE
,
18074 &no_neighbor_route_reflector_client_cmd
);
18075 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
18076 install_element(BGP_VPNV6_NODE
,
18077 &no_neighbor_route_reflector_client_cmd
);
18078 install_element(BGP_FLOWSPECV4_NODE
,
18079 &neighbor_route_reflector_client_cmd
);
18080 install_element(BGP_FLOWSPECV4_NODE
,
18081 &no_neighbor_route_reflector_client_cmd
);
18082 install_element(BGP_FLOWSPECV6_NODE
,
18083 &neighbor_route_reflector_client_cmd
);
18084 install_element(BGP_FLOWSPECV6_NODE
,
18085 &no_neighbor_route_reflector_client_cmd
);
18086 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
18087 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
18089 /* "neighbor route-server" commands.*/
18090 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
18091 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
18092 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
18093 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
18094 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
18095 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
18096 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
18097 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
18098 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
18099 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
18100 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
18101 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
18102 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
18103 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
18104 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
18105 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
18106 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
18107 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
18108 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
18109 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
18110 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
18111 install_element(BGP_FLOWSPECV4_NODE
,
18112 &no_neighbor_route_server_client_cmd
);
18113 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
18114 install_element(BGP_FLOWSPECV6_NODE
,
18115 &no_neighbor_route_server_client_cmd
);
18117 /* "neighbor addpath-tx-all-paths" commands.*/
18118 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
18119 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
18120 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18121 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18122 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18123 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18124 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18125 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18126 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18127 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18128 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18129 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18130 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18131 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18132 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18133 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18134 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18135 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18137 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
18138 install_element(BGP_NODE
,
18139 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18140 install_element(BGP_NODE
,
18141 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18142 install_element(BGP_IPV4_NODE
,
18143 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18144 install_element(BGP_IPV4_NODE
,
18145 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18146 install_element(BGP_IPV4M_NODE
,
18147 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18148 install_element(BGP_IPV4M_NODE
,
18149 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18150 install_element(BGP_IPV4L_NODE
,
18151 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18152 install_element(BGP_IPV4L_NODE
,
18153 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18154 install_element(BGP_IPV6_NODE
,
18155 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18156 install_element(BGP_IPV6_NODE
,
18157 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18158 install_element(BGP_IPV6M_NODE
,
18159 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18160 install_element(BGP_IPV6M_NODE
,
18161 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18162 install_element(BGP_IPV6L_NODE
,
18163 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18164 install_element(BGP_IPV6L_NODE
,
18165 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18166 install_element(BGP_VPNV4_NODE
,
18167 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18168 install_element(BGP_VPNV4_NODE
,
18169 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18170 install_element(BGP_VPNV6_NODE
,
18171 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18172 install_element(BGP_VPNV6_NODE
,
18173 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18175 /* "neighbor sender-as-path-loop-detection" commands. */
18176 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
18177 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
18179 /* "neighbor passive" commands. */
18180 install_element(BGP_NODE
, &neighbor_passive_cmd
);
18181 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
18184 /* "neighbor shutdown" commands. */
18185 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
18186 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
18187 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
18188 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
18189 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
18190 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
18192 /* "neighbor capability extended-nexthop" commands.*/
18193 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
18194 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
18196 /* "neighbor capability orf prefix-list" commands.*/
18197 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
18198 install_element(BGP_NODE
,
18199 &no_neighbor_capability_orf_prefix_hidden_cmd
);
18200 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
18201 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18202 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18203 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18204 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18205 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18206 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
18207 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18208 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18209 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18210 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18211 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18213 /* "neighbor capability dynamic" commands.*/
18214 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
18215 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
18217 /* "neighbor dont-capability-negotiate" commands. */
18218 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
18219 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
18221 /* "neighbor ebgp-multihop" commands. */
18222 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
18223 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
18224 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
18226 /* "neighbor disable-connected-check" commands. */
18227 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
18228 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
18230 /* "neighbor enforce-first-as" commands. */
18231 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
18232 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
18234 /* "neighbor description" commands. */
18235 install_element(BGP_NODE
, &neighbor_description_cmd
);
18236 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
18237 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
18239 /* "neighbor update-source" commands. "*/
18240 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
18241 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
18243 /* "neighbor default-originate" commands. */
18244 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
18245 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
18246 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
18247 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
18248 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
18249 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
18250 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
18251 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
18252 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
18253 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
18254 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
18255 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
18256 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
18257 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
18258 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
18259 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
18260 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
18261 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
18262 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
18263 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
18264 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
18266 /* "neighbor port" commands. */
18267 install_element(BGP_NODE
, &neighbor_port_cmd
);
18268 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
18270 /* "neighbor weight" commands. */
18271 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
18272 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
18274 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
18275 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
18276 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
18277 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
18278 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
18279 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
18280 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
18281 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
18282 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
18283 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
18284 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
18285 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
18286 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
18287 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
18288 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
18289 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
18291 /* "neighbor override-capability" commands. */
18292 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
18293 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
18295 /* "neighbor strict-capability-match" commands. */
18296 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
18297 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
18299 /* "neighbor timers" commands. */
18300 install_element(BGP_NODE
, &neighbor_timers_cmd
);
18301 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
18303 /* "neighbor timers connect" commands. */
18304 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
18305 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
18307 /* "neighbor timers delayopen" commands. */
18308 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
18309 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
18311 /* "neighbor advertisement-interval" commands. */
18312 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
18313 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
18315 /* "neighbor interface" commands. */
18316 install_element(BGP_NODE
, &neighbor_interface_cmd
);
18317 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
18319 /* "neighbor distribute" commands. */
18320 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
18321 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
18322 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
18323 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
18324 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
18325 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
18326 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
18327 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
18328 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
18329 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
18330 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
18331 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
18332 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
18333 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
18334 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
18335 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
18336 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
18337 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
18339 /* "neighbor prefix-list" commands. */
18340 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
18341 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
18342 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
18343 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
18344 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
18345 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
18346 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
18347 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
18348 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
18349 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
18350 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
18351 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
18352 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
18353 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
18354 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
18355 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
18356 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
18357 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
18358 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
18359 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
18360 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
18361 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
18363 /* "neighbor filter-list" commands. */
18364 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
18365 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
18366 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
18367 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
18368 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
18369 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
18370 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
18371 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
18372 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
18373 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
18374 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
18375 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
18376 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
18377 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
18378 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
18379 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
18380 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
18381 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
18382 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
18383 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
18384 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
18385 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
18387 /* "neighbor route-map" commands. */
18388 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
18389 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
18390 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
18391 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
18392 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
18393 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
18394 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
18395 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
18396 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
18397 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
18398 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
18399 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
18400 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
18401 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
18402 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
18403 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
18404 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
18405 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
18406 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
18407 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
18408 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
18409 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
18410 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
18411 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
18413 /* "neighbor unsuppress-map" commands. */
18414 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
18415 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
18416 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
18417 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18418 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
18419 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18420 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
18421 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18422 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
18423 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18424 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
18425 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18426 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
18427 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18428 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
18429 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18430 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
18431 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18433 /* "neighbor advertise-map" commands. */
18434 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
18435 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
18436 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
18437 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
18438 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
18439 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
18440 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
18441 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
18442 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
18443 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
18445 /* neighbor maximum-prefix-out commands. */
18446 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
18447 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18448 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18449 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18450 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18451 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18452 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18453 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18454 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18455 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18456 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18457 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18458 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18459 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18460 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18461 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18462 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18463 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18465 /* "neighbor maximum-prefix" commands. */
18466 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
18467 install_element(BGP_NODE
,
18468 &neighbor_maximum_prefix_threshold_hidden_cmd
);
18469 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
18470 install_element(BGP_NODE
,
18471 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
18472 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
18473 install_element(BGP_NODE
,
18474 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
18475 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
18476 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
18477 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18478 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18479 install_element(BGP_IPV4_NODE
,
18480 &neighbor_maximum_prefix_threshold_warning_cmd
);
18481 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18482 install_element(BGP_IPV4_NODE
,
18483 &neighbor_maximum_prefix_threshold_restart_cmd
);
18484 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18485 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
18486 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18487 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18488 install_element(BGP_IPV4M_NODE
,
18489 &neighbor_maximum_prefix_threshold_warning_cmd
);
18490 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18491 install_element(BGP_IPV4M_NODE
,
18492 &neighbor_maximum_prefix_threshold_restart_cmd
);
18493 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18494 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
18495 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18496 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18497 install_element(BGP_IPV4L_NODE
,
18498 &neighbor_maximum_prefix_threshold_warning_cmd
);
18499 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18500 install_element(BGP_IPV4L_NODE
,
18501 &neighbor_maximum_prefix_threshold_restart_cmd
);
18502 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18503 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
18504 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18505 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18506 install_element(BGP_IPV6_NODE
,
18507 &neighbor_maximum_prefix_threshold_warning_cmd
);
18508 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18509 install_element(BGP_IPV6_NODE
,
18510 &neighbor_maximum_prefix_threshold_restart_cmd
);
18511 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18512 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
18513 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18514 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18515 install_element(BGP_IPV6M_NODE
,
18516 &neighbor_maximum_prefix_threshold_warning_cmd
);
18517 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18518 install_element(BGP_IPV6M_NODE
,
18519 &neighbor_maximum_prefix_threshold_restart_cmd
);
18520 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18521 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
18522 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18523 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18524 install_element(BGP_IPV6L_NODE
,
18525 &neighbor_maximum_prefix_threshold_warning_cmd
);
18526 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18527 install_element(BGP_IPV6L_NODE
,
18528 &neighbor_maximum_prefix_threshold_restart_cmd
);
18529 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18530 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
18531 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18532 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18533 install_element(BGP_VPNV4_NODE
,
18534 &neighbor_maximum_prefix_threshold_warning_cmd
);
18535 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18536 install_element(BGP_VPNV4_NODE
,
18537 &neighbor_maximum_prefix_threshold_restart_cmd
);
18538 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18539 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
18540 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18541 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18542 install_element(BGP_VPNV6_NODE
,
18543 &neighbor_maximum_prefix_threshold_warning_cmd
);
18544 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18545 install_element(BGP_VPNV6_NODE
,
18546 &neighbor_maximum_prefix_threshold_restart_cmd
);
18547 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18549 /* "neighbor allowas-in" */
18550 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
18551 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
18552 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
18553 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
18554 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
18555 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
18556 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
18557 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
18558 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
18559 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
18560 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
18561 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
18562 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
18563 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
18564 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
18565 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
18566 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
18567 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
18568 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
18569 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
18571 /* address-family commands. */
18572 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
18573 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
18574 #ifdef KEEP_OLD_VPN_COMMANDS
18575 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
18576 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
18577 #endif /* KEEP_OLD_VPN_COMMANDS */
18579 install_element(BGP_NODE
, &address_family_evpn_cmd
);
18581 /* "exit-address-family" command. */
18582 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
18583 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
18584 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
18585 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
18586 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
18587 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
18588 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
18589 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
18590 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
18591 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
18592 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
18594 /* "clear ip bgp commands" */
18595 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
18597 /* clear ip bgp prefix */
18598 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
18599 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
18600 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
18602 /* "show [ip] bgp summary" commands. */
18603 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
18604 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
18605 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
18606 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
18607 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
18608 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
18609 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
18611 /* "show [ip] bgp neighbors" commands. */
18612 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
18614 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
18616 /* "show [ip] bgp peer-group" commands. */
18617 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
18619 /* "show [ip] bgp paths" commands. */
18620 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
18622 /* "show [ip] bgp community" commands. */
18623 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
18625 /* "show ip bgp large-community" commands. */
18626 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
18627 /* "show [ip] bgp attribute-info" commands. */
18628 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
18629 /* "show [ip] bgp route-leak" command */
18630 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
18632 /* "redistribute" commands. */
18633 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
18634 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
18635 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
18636 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
18637 install_element(BGP_NODE
,
18638 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
18639 install_element(BGP_NODE
,
18640 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
18641 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
18642 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
18643 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
18644 install_element(BGP_NODE
,
18645 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
18646 install_element(BGP_NODE
,
18647 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
18648 install_element(BGP_NODE
,
18649 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
18650 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
18651 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
18652 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
18653 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
18654 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
18655 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
18656 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
18657 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
18658 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
18659 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
18660 install_element(BGP_IPV4_NODE
,
18661 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
18662 install_element(BGP_IPV4_NODE
,
18663 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
18664 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
18665 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
18666 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
18667 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
18668 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
18669 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
18671 /* import|export vpn [route-map WORD] */
18672 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
18673 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
18675 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
18676 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
18678 /* ttl_security commands */
18679 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
18680 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
18682 /* "show [ip] bgp memory" commands. */
18683 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
18685 /* "show bgp martian next-hop" */
18686 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
18688 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
18690 /* "show [ip] bgp views" commands. */
18691 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
18693 /* "show [ip] bgp vrfs" commands. */
18694 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
18696 /* Community-list. */
18697 community_list_vty();
18699 community_alias_vty();
18701 /* vpn-policy commands */
18702 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
18703 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
18704 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
18705 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
18706 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
18707 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
18708 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
18709 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
18710 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
18711 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
18712 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
18713 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
18715 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
18716 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
18718 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
18719 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
18720 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
18721 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
18722 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
18723 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
18724 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
18725 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
18726 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
18727 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
18729 /* tcp-mss command */
18730 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
18731 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
18733 /* srv6 commands */
18734 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
18735 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
18736 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
18737 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
18738 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
18741 #include "memory.h"
18742 #include "bgp_regex.h"
18743 #include "bgp_clist.h"
18744 #include "bgp_ecommunity.h"
18746 /* VTY functions. */
18748 /* Direction value to string conversion. */
18749 static const char *community_direct_str(int direct
)
18752 case COMMUNITY_DENY
:
18754 case COMMUNITY_PERMIT
:
18761 /* Display error string. */
18762 static void community_list_perror(struct vty
*vty
, int ret
)
18765 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
18766 vty_out(vty
, "%% Can't find community-list\n");
18768 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
18769 vty_out(vty
, "%% Malformed community-list value\n");
18771 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
18773 "%% Community name conflict, previously defined as standard community\n");
18775 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
18777 "%% Community name conflict, previously defined as expanded community\n");
18782 /* "community-list" keyword help string. */
18783 #define COMMUNITY_LIST_STR "Add a community list entry\n"
18785 /*community-list standard */
18786 DEFUN (community_list_standard
,
18787 bgp_community_list_standard_cmd
,
18788 "bgp community-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
18791 "Community list number (standard)\n"
18792 "Add an standard community-list entry\n"
18793 "Community list name\n"
18794 "Sequence number of an entry\n"
18795 "Sequence number\n"
18796 "Specify community to reject\n"
18797 "Specify community to accept\n"
18800 char *cl_name_or_number
= NULL
;
18803 int style
= COMMUNITY_LIST_STANDARD
;
18806 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
18808 seq
= argv
[idx
]->arg
;
18811 argv_find(argv
, argc
, "(1-99)", &idx
);
18812 argv_find(argv
, argc
, "WORD", &idx
);
18813 cl_name_or_number
= argv
[idx
]->arg
;
18814 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
18816 argv_find(argv
, argc
, "AA:NN", &idx
);
18817 char *str
= argv_concat(argv
, argc
, idx
);
18819 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
18822 XFREE(MTYPE_TMP
, str
);
18825 /* Display error string. */
18826 community_list_perror(vty
, ret
);
18827 return CMD_WARNING_CONFIG_FAILED
;
18830 return CMD_SUCCESS
;
18833 DEFUN (no_community_list_standard_all
,
18834 no_bgp_community_list_standard_all_cmd
,
18835 "no bgp community-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
18839 "Community list number (standard)\n"
18840 "Add an standard community-list entry\n"
18841 "Community list name\n"
18842 "Sequence number of an entry\n"
18843 "Sequence number\n"
18844 "Specify community to reject\n"
18845 "Specify community to accept\n"
18848 char *cl_name_or_number
= NULL
;
18851 int style
= COMMUNITY_LIST_STANDARD
;
18855 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
18857 seq
= argv
[idx
]->arg
;
18860 argv_find(argv
, argc
, "permit", &idx
);
18861 argv_find(argv
, argc
, "deny", &idx
);
18864 direct
= argv_find(argv
, argc
, "permit", &idx
)
18869 argv_find(argv
, argc
, "AA:NN", &idx
);
18870 str
= argv_concat(argv
, argc
, idx
);
18874 argv_find(argv
, argc
, "(1-99)", &idx
);
18875 argv_find(argv
, argc
, "WORD", &idx
);
18876 cl_name_or_number
= argv
[idx
]->arg
;
18878 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
18881 XFREE(MTYPE_TMP
, str
);
18884 community_list_perror(vty
, ret
);
18885 return CMD_WARNING_CONFIG_FAILED
;
18888 return CMD_SUCCESS
;
18891 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
18892 "no bgp community-list <(1-99)|standard WORD>",
18893 NO_STR BGP_STR COMMUNITY_LIST_STR
18894 "Community list number (standard)\n"
18895 "Add an standard community-list entry\n"
18896 "Community list name\n")
18898 /*community-list expanded */
18899 DEFUN (community_list_expanded_all
,
18900 bgp_community_list_expanded_all_cmd
,
18901 "bgp community-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
18904 "Community list number (expanded)\n"
18905 "Add an expanded community-list entry\n"
18906 "Community list name\n"
18907 "Sequence number of an entry\n"
18908 "Sequence number\n"
18909 "Specify community to reject\n"
18910 "Specify community to accept\n"
18913 char *cl_name_or_number
= NULL
;
18916 int style
= COMMUNITY_LIST_EXPANDED
;
18919 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
18921 seq
= argv
[idx
]->arg
;
18925 argv_find(argv
, argc
, "(100-500)", &idx
);
18926 argv_find(argv
, argc
, "WORD", &idx
);
18927 cl_name_or_number
= argv
[idx
]->arg
;
18928 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
18930 argv_find(argv
, argc
, "AA:NN", &idx
);
18931 char *str
= argv_concat(argv
, argc
, idx
);
18933 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
18936 XFREE(MTYPE_TMP
, str
);
18939 /* Display error string. */
18940 community_list_perror(vty
, ret
);
18941 return CMD_WARNING_CONFIG_FAILED
;
18944 return CMD_SUCCESS
;
18947 DEFUN (no_community_list_expanded_all
,
18948 no_bgp_community_list_expanded_all_cmd
,
18949 "no bgp community-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
18953 "Community list number (expanded)\n"
18954 "Add an expanded community-list entry\n"
18955 "Community list name\n"
18956 "Sequence number of an entry\n"
18957 "Sequence number\n"
18958 "Specify community to reject\n"
18959 "Specify community to accept\n"
18962 char *cl_name_or_number
= NULL
;
18966 int style
= COMMUNITY_LIST_EXPANDED
;
18969 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
18971 seq
= argv
[idx
]->arg
;
18974 argv_find(argv
, argc
, "permit", &idx
);
18975 argv_find(argv
, argc
, "deny", &idx
);
18978 direct
= argv_find(argv
, argc
, "permit", &idx
)
18983 argv_find(argv
, argc
, "AA:NN", &idx
);
18984 str
= argv_concat(argv
, argc
, idx
);
18988 argv_find(argv
, argc
, "(100-500)", &idx
);
18989 argv_find(argv
, argc
, "WORD", &idx
);
18990 cl_name_or_number
= argv
[idx
]->arg
;
18992 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
18995 XFREE(MTYPE_TMP
, str
);
18998 community_list_perror(vty
, ret
);
18999 return CMD_WARNING_CONFIG_FAILED
;
19002 return CMD_SUCCESS
;
19005 ALIAS(no_community_list_expanded_all
,
19006 no_bgp_community_list_expanded_all_list_cmd
,
19007 "no bgp community-list <(100-500)|expanded WORD>",
19008 NO_STR BGP_STR COMMUNITY_LIST_STR
19009 "Community list number (expanded)\n"
19010 "Add an expanded community-list entry\n"
19011 "Community list name\n")
19013 /* Return configuration string of community-list entry. */
19014 static const char *community_list_config_str(struct community_entry
*entry
)
19021 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
19022 str
= community_str(entry
->u
.com
, false);
19023 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
19024 str
= lcommunity_str(entry
->u
.lcom
, false);
19026 str
= entry
->config
;
19031 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
19033 struct community_entry
*entry
;
19035 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19036 if (entry
== list
->head
) {
19037 if (all_digit(list
->name
))
19038 vty_out(vty
, "Community %s list %s\n",
19039 entry
->style
== COMMUNITY_LIST_STANDARD
19041 : "(expanded) access",
19044 vty_out(vty
, "Named Community %s list %s\n",
19045 entry
->style
== COMMUNITY_LIST_STANDARD
19051 vty_out(vty
, " %s\n",
19052 community_direct_str(entry
->direct
));
19054 vty_out(vty
, " %s %s\n",
19055 community_direct_str(entry
->direct
),
19056 community_list_config_str(entry
));
19060 DEFUN (show_community_list
,
19061 show_bgp_community_list_cmd
,
19062 "show bgp community-list",
19065 "List community-list\n")
19067 struct community_list
*list
;
19068 struct community_list_master
*cm
;
19070 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19072 return CMD_SUCCESS
;
19074 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19075 community_list_show(vty
, list
);
19077 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19078 community_list_show(vty
, list
);
19080 return CMD_SUCCESS
;
19083 DEFUN (show_community_list_arg
,
19084 show_bgp_community_list_arg_cmd
,
19085 "show bgp community-list <(1-500)|WORD> detail",
19088 "List community-list\n"
19089 "Community-list number\n"
19090 "Community-list name\n"
19091 "Detailed information on community-list\n")
19093 int idx_comm_list
= 3;
19094 struct community_list
*list
;
19096 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
19097 COMMUNITY_LIST_MASTER
);
19099 vty_out(vty
, "%% Can't find community-list\n");
19100 return CMD_WARNING
;
19103 community_list_show(vty
, list
);
19105 return CMD_SUCCESS
;
19109 * Large Community code.
19111 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
19112 struct cmd_token
**argv
, int style
,
19113 int reject_all_digit_name
)
19122 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19123 seq
= argv
[idx
]->arg
;
19126 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19129 /* All digit name check. */
19131 argv_find(argv
, argc
, "WORD", &idx
);
19132 argv_find(argv
, argc
, "(1-99)", &idx
);
19133 argv_find(argv
, argc
, "(100-500)", &idx
);
19134 cl_name
= argv
[idx
]->arg
;
19135 if (reject_all_digit_name
&& all_digit(cl_name
)) {
19136 vty_out(vty
, "%% Community name cannot have all digits\n");
19137 return CMD_WARNING_CONFIG_FAILED
;
19141 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
19142 argv_find(argv
, argc
, "LINE", &idx
);
19143 /* Concat community string argument. */
19145 str
= argv_concat(argv
, argc
, idx
);
19149 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
19151 /* Free temporary community list string allocated by
19153 XFREE(MTYPE_TMP
, str
);
19156 community_list_perror(vty
, ret
);
19157 return CMD_WARNING_CONFIG_FAILED
;
19159 return CMD_SUCCESS
;
19162 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
19163 struct cmd_token
**argv
, int style
)
19171 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19172 seq
= argv
[idx
]->arg
;
19175 argv_find(argv
, argc
, "permit", &idx
);
19176 argv_find(argv
, argc
, "deny", &idx
);
19179 /* Check the list direct. */
19180 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
19181 direct
= COMMUNITY_PERMIT
;
19183 direct
= COMMUNITY_DENY
;
19186 argv_find(argv
, argc
, "LINE", &idx
);
19187 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
19188 /* Concat community string argument. */
19189 str
= argv_concat(argv
, argc
, idx
);
19193 argv_find(argv
, argc
, "(1-99)", &idx
);
19194 argv_find(argv
, argc
, "(100-500)", &idx
);
19195 argv_find(argv
, argc
, "WORD", &idx
);
19197 /* Unset community list. */
19198 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
19201 /* Free temporary community list string allocated by
19203 XFREE(MTYPE_TMP
, str
);
19206 community_list_perror(vty
, ret
);
19207 return CMD_WARNING_CONFIG_FAILED
;
19210 return CMD_SUCCESS
;
19213 /* "large-community-list" keyword help string. */
19214 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
19215 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
19217 DEFUN (lcommunity_list_standard
,
19218 bgp_lcommunity_list_standard_cmd
,
19219 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
19221 LCOMMUNITY_LIST_STR
19222 "Large Community list number (standard)\n"
19223 "Sequence number of an entry\n"
19224 "Sequence number\n"
19225 "Specify large community to reject\n"
19226 "Specify large community to accept\n"
19227 LCOMMUNITY_VAL_STR
)
19229 return lcommunity_list_set_vty(vty
, argc
, argv
,
19230 LARGE_COMMUNITY_LIST_STANDARD
, 0);
19233 DEFUN (lcommunity_list_expanded
,
19234 bgp_lcommunity_list_expanded_cmd
,
19235 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
19237 LCOMMUNITY_LIST_STR
19238 "Large Community list number (expanded)\n"
19239 "Sequence number of an entry\n"
19240 "Sequence number\n"
19241 "Specify large community to reject\n"
19242 "Specify large community to accept\n"
19243 "An ordered list as a regular-expression\n")
19245 return lcommunity_list_set_vty(vty
, argc
, argv
,
19246 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
19249 DEFUN (lcommunity_list_name_standard
,
19250 bgp_lcommunity_list_name_standard_cmd
,
19251 "bgp large-community-list standard WORD [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
19253 LCOMMUNITY_LIST_STR
19254 "Specify standard large-community-list\n"
19255 "Large Community list name\n"
19256 "Sequence number of an entry\n"
19257 "Sequence number\n"
19258 "Specify large community to reject\n"
19259 "Specify large community to accept\n"
19260 LCOMMUNITY_VAL_STR
)
19262 return lcommunity_list_set_vty(vty
, argc
, argv
,
19263 LARGE_COMMUNITY_LIST_STANDARD
, 1);
19266 DEFUN (lcommunity_list_name_expanded
,
19267 bgp_lcommunity_list_name_expanded_cmd
,
19268 "bgp large-community-list expanded WORD [seq (0-4294967295)] <deny|permit> LINE...",
19270 LCOMMUNITY_LIST_STR
19271 "Specify expanded large-community-list\n"
19272 "Large Community list name\n"
19273 "Sequence number of an entry\n"
19274 "Sequence number\n"
19275 "Specify large community to reject\n"
19276 "Specify large community to accept\n"
19277 "An ordered list as a regular-expression\n")
19279 return lcommunity_list_set_vty(vty
, argc
, argv
,
19280 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
19283 DEFUN (no_lcommunity_list_all
,
19284 no_bgp_lcommunity_list_all_cmd
,
19285 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
19288 LCOMMUNITY_LIST_STR
19289 "Large Community list number (standard)\n"
19290 "Large Community list number (expanded)\n"
19291 "Large Community list name\n")
19293 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19294 LARGE_COMMUNITY_LIST_STANDARD
);
19297 DEFUN (no_lcommunity_list_name_standard_all
,
19298 no_bgp_lcommunity_list_name_standard_all_cmd
,
19299 "no bgp large-community-list standard WORD",
19302 LCOMMUNITY_LIST_STR
19303 "Specify standard large-community-list\n"
19304 "Large Community list name\n")
19306 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19307 LARGE_COMMUNITY_LIST_STANDARD
);
19310 DEFUN (no_lcommunity_list_name_expanded_all
,
19311 no_bgp_lcommunity_list_name_expanded_all_cmd
,
19312 "no bgp large-community-list expanded WORD",
19315 LCOMMUNITY_LIST_STR
19316 "Specify expanded large-community-list\n"
19317 "Large Community list name\n")
19319 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19320 LARGE_COMMUNITY_LIST_EXPANDED
);
19323 DEFUN (no_lcommunity_list_standard
,
19324 no_bgp_lcommunity_list_standard_cmd
,
19325 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
19328 LCOMMUNITY_LIST_STR
19329 "Large Community list number (standard)\n"
19330 "Sequence number of an entry\n"
19331 "Sequence number\n"
19332 "Specify large community to reject\n"
19333 "Specify large community to accept\n"
19334 LCOMMUNITY_VAL_STR
)
19336 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19337 LARGE_COMMUNITY_LIST_STANDARD
);
19340 DEFUN (no_lcommunity_list_expanded
,
19341 no_bgp_lcommunity_list_expanded_cmd
,
19342 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
19345 LCOMMUNITY_LIST_STR
19346 "Large Community list number (expanded)\n"
19347 "Sequence number of an entry\n"
19348 "Sequence number\n"
19349 "Specify large community to reject\n"
19350 "Specify large community to accept\n"
19351 "An ordered list as a regular-expression\n")
19353 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19354 LARGE_COMMUNITY_LIST_EXPANDED
);
19357 DEFUN (no_lcommunity_list_name_standard
,
19358 no_bgp_lcommunity_list_name_standard_cmd
,
19359 "no bgp large-community-list standard WORD [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
19362 LCOMMUNITY_LIST_STR
19363 "Specify standard large-community-list\n"
19364 "Large Community list name\n"
19365 "Sequence number of an entry\n"
19366 "Sequence number\n"
19367 "Specify large community to reject\n"
19368 "Specify large community to accept\n"
19369 LCOMMUNITY_VAL_STR
)
19371 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19372 LARGE_COMMUNITY_LIST_STANDARD
);
19375 DEFUN (no_lcommunity_list_name_expanded
,
19376 no_bgp_lcommunity_list_name_expanded_cmd
,
19377 "no bgp large-community-list expanded WORD [seq (0-4294967295)] <deny|permit> LINE...",
19380 LCOMMUNITY_LIST_STR
19381 "Specify expanded large-community-list\n"
19382 "Large community list name\n"
19383 "Sequence number of an entry\n"
19384 "Sequence number\n"
19385 "Specify large community to reject\n"
19386 "Specify large community to accept\n"
19387 "An ordered list as a regular-expression\n")
19389 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19390 LARGE_COMMUNITY_LIST_EXPANDED
);
19393 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
19395 struct community_entry
*entry
;
19397 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19398 if (entry
== list
->head
) {
19399 if (all_digit(list
->name
))
19400 vty_out(vty
, "Large community %s list %s\n",
19402 LARGE_COMMUNITY_LIST_STANDARD
19404 : "(expanded) access",
19408 "Named large community %s list %s\n",
19410 LARGE_COMMUNITY_LIST_STANDARD
19416 vty_out(vty
, " %s\n",
19417 community_direct_str(entry
->direct
));
19419 vty_out(vty
, " %s %s\n",
19420 community_direct_str(entry
->direct
),
19421 community_list_config_str(entry
));
19425 DEFUN (show_lcommunity_list
,
19426 show_bgp_lcommunity_list_cmd
,
19427 "show bgp large-community-list",
19430 "List large-community list\n")
19432 struct community_list
*list
;
19433 struct community_list_master
*cm
;
19435 cm
= community_list_master_lookup(bgp_clist
,
19436 LARGE_COMMUNITY_LIST_MASTER
);
19438 return CMD_SUCCESS
;
19440 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19441 lcommunity_list_show(vty
, list
);
19443 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19444 lcommunity_list_show(vty
, list
);
19446 return CMD_SUCCESS
;
19449 DEFUN (show_lcommunity_list_arg
,
19450 show_bgp_lcommunity_list_arg_cmd
,
19451 "show bgp large-community-list <(1-500)|WORD> detail",
19454 "List large-community list\n"
19455 "Large-community-list number\n"
19456 "Large-community-list name\n"
19457 "Detailed information on large-community-list\n")
19459 struct community_list
*list
;
19461 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
19462 LARGE_COMMUNITY_LIST_MASTER
);
19464 vty_out(vty
, "%% Can't find large-community-list\n");
19465 return CMD_WARNING
;
19468 lcommunity_list_show(vty
, list
);
19470 return CMD_SUCCESS
;
19473 /* "extcommunity-list" keyword help string. */
19474 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
19475 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
19477 DEFUN (extcommunity_list_standard
,
19478 bgp_extcommunity_list_standard_cmd
,
19479 "bgp extcommunity-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
19481 EXTCOMMUNITY_LIST_STR
19482 "Extended Community list number (standard)\n"
19483 "Specify standard extcommunity-list\n"
19484 "Community list name\n"
19485 "Sequence number of an entry\n"
19486 "Sequence number\n"
19487 "Specify community to reject\n"
19488 "Specify community to accept\n"
19489 EXTCOMMUNITY_VAL_STR
)
19491 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19493 char *cl_number_or_name
= NULL
;
19498 argv_find(argv
, argc
, "(1-99)", &idx
);
19499 argv_find(argv
, argc
, "WORD", &idx
);
19500 cl_number_or_name
= argv
[idx
]->arg
;
19502 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19503 seq
= argv
[idx
]->arg
;
19505 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19507 argv_find(argv
, argc
, "AA:NN", &idx
);
19508 char *str
= argv_concat(argv
, argc
, idx
);
19510 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19513 XFREE(MTYPE_TMP
, str
);
19516 community_list_perror(vty
, ret
);
19517 return CMD_WARNING_CONFIG_FAILED
;
19520 return CMD_SUCCESS
;
19523 DEFUN (extcommunity_list_name_expanded
,
19524 bgp_extcommunity_list_name_expanded_cmd
,
19525 "bgp extcommunity-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> LINE...",
19527 EXTCOMMUNITY_LIST_STR
19528 "Extended Community list number (expanded)\n"
19529 "Specify expanded extcommunity-list\n"
19530 "Extended Community list name\n"
19531 "Sequence number of an entry\n"
19532 "Sequence number\n"
19533 "Specify community to reject\n"
19534 "Specify community to accept\n"
19535 "An ordered list as a regular-expression\n")
19537 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
19539 char *cl_number_or_name
= NULL
;
19543 argv_find(argv
, argc
, "(100-500)", &idx
);
19544 argv_find(argv
, argc
, "WORD", &idx
);
19545 cl_number_or_name
= argv
[idx
]->arg
;
19547 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19548 seq
= argv
[idx
]->arg
;
19550 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19552 argv_find(argv
, argc
, "LINE", &idx
);
19553 char *str
= argv_concat(argv
, argc
, idx
);
19555 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19558 XFREE(MTYPE_TMP
, str
);
19561 community_list_perror(vty
, ret
);
19562 return CMD_WARNING_CONFIG_FAILED
;
19565 return CMD_SUCCESS
;
19568 DEFUN (no_extcommunity_list_standard_all
,
19569 no_bgp_extcommunity_list_standard_all_cmd
,
19570 "no bgp extcommunity-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
19573 EXTCOMMUNITY_LIST_STR
19574 "Extended Community list number (standard)\n"
19575 "Specify standard extcommunity-list\n"
19576 "Community list name\n"
19577 "Sequence number of an entry\n"
19578 "Sequence number\n"
19579 "Specify community to reject\n"
19580 "Specify community to accept\n"
19581 EXTCOMMUNITY_VAL_STR
)
19583 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19585 char *cl_number_or_name
= NULL
;
19590 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19591 seq
= argv
[idx
]->arg
;
19594 argv_find(argv
, argc
, "permit", &idx
);
19595 argv_find(argv
, argc
, "deny", &idx
);
19597 direct
= argv_find(argv
, argc
, "permit", &idx
)
19602 argv_find(argv
, argc
, "AA:NN", &idx
);
19603 str
= argv_concat(argv
, argc
, idx
);
19607 argv_find(argv
, argc
, "(1-99)", &idx
);
19608 argv_find(argv
, argc
, "WORD", &idx
);
19609 cl_number_or_name
= argv
[idx
]->arg
;
19611 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
19612 seq
, direct
, style
);
19614 XFREE(MTYPE_TMP
, str
);
19617 community_list_perror(vty
, ret
);
19618 return CMD_WARNING_CONFIG_FAILED
;
19621 return CMD_SUCCESS
;
19624 ALIAS(no_extcommunity_list_standard_all
,
19625 no_bgp_extcommunity_list_standard_all_list_cmd
,
19626 "no bgp extcommunity-list <(1-99)|standard WORD>",
19627 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
19628 "Extended Community list number (standard)\n"
19629 "Specify standard extcommunity-list\n"
19630 "Community list name\n")
19632 DEFUN (no_extcommunity_list_expanded_all
,
19633 no_bgp_extcommunity_list_expanded_all_cmd
,
19634 "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> LINE...",
19637 EXTCOMMUNITY_LIST_STR
19638 "Extended Community list number (expanded)\n"
19639 "Specify expanded extcommunity-list\n"
19640 "Extended Community list name\n"
19641 "Sequence number of an entry\n"
19642 "Sequence number\n"
19643 "Specify community to reject\n"
19644 "Specify community to accept\n"
19645 "An ordered list as a regular-expression\n")
19647 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
19649 char *cl_number_or_name
= NULL
;
19654 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19655 seq
= argv
[idx
]->arg
;
19658 argv_find(argv
, argc
, "permit", &idx
);
19659 argv_find(argv
, argc
, "deny", &idx
);
19662 direct
= argv_find(argv
, argc
, "permit", &idx
)
19667 argv_find(argv
, argc
, "LINE", &idx
);
19668 str
= argv_concat(argv
, argc
, idx
);
19672 argv_find(argv
, argc
, "(100-500)", &idx
);
19673 argv_find(argv
, argc
, "WORD", &idx
);
19674 cl_number_or_name
= argv
[idx
]->arg
;
19676 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
19677 seq
, direct
, style
);
19679 XFREE(MTYPE_TMP
, str
);
19682 community_list_perror(vty
, ret
);
19683 return CMD_WARNING_CONFIG_FAILED
;
19686 return CMD_SUCCESS
;
19689 ALIAS(no_extcommunity_list_expanded_all
,
19690 no_bgp_extcommunity_list_expanded_all_list_cmd
,
19691 "no bgp extcommunity-list <(100-500)|expanded WORD>",
19692 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
19693 "Extended Community list number (expanded)\n"
19694 "Specify expanded extcommunity-list\n"
19695 "Extended Community list name\n")
19697 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
19699 struct community_entry
*entry
;
19701 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19702 if (entry
== list
->head
) {
19703 if (all_digit(list
->name
))
19704 vty_out(vty
, "Extended community %s list %s\n",
19705 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
19707 : "(expanded) access",
19711 "Named extended community %s list %s\n",
19712 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
19718 vty_out(vty
, " %s\n",
19719 community_direct_str(entry
->direct
));
19721 vty_out(vty
, " %s %s\n",
19722 community_direct_str(entry
->direct
),
19723 community_list_config_str(entry
));
19727 DEFUN (show_extcommunity_list
,
19728 show_bgp_extcommunity_list_cmd
,
19729 "show bgp extcommunity-list",
19732 "List extended-community list\n")
19734 struct community_list
*list
;
19735 struct community_list_master
*cm
;
19737 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
19739 return CMD_SUCCESS
;
19741 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19742 extcommunity_list_show(vty
, list
);
19744 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19745 extcommunity_list_show(vty
, list
);
19747 return CMD_SUCCESS
;
19750 DEFUN (show_extcommunity_list_arg
,
19751 show_bgp_extcommunity_list_arg_cmd
,
19752 "show bgp extcommunity-list <(1-500)|WORD> detail",
19755 "List extended-community list\n"
19756 "Extcommunity-list number\n"
19757 "Extcommunity-list name\n"
19758 "Detailed information on extcommunity-list\n")
19760 int idx_comm_list
= 3;
19761 struct community_list
*list
;
19763 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
19764 EXTCOMMUNITY_LIST_MASTER
);
19766 vty_out(vty
, "%% Can't find extcommunity-list\n");
19767 return CMD_WARNING
;
19770 extcommunity_list_show(vty
, list
);
19772 return CMD_SUCCESS
;
19775 /* Display community-list and extcommunity-list configuration. */
19776 static int community_list_config_write(struct vty
*vty
)
19778 struct community_list
*list
;
19779 struct community_entry
*entry
;
19780 struct community_list_master
*cm
;
19783 /* Community-list. */
19784 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19786 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19787 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19789 "bgp community-list %s seq %" PRId64
" %s %s\n",
19790 list
->name
, entry
->seq
,
19791 community_direct_str(entry
->direct
),
19792 community_list_config_str(entry
));
19795 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19796 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19798 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
19799 entry
->style
== COMMUNITY_LIST_STANDARD
19802 list
->name
, entry
->seq
,
19803 community_direct_str(entry
->direct
),
19804 community_list_config_str(entry
));
19808 /* Extcommunity-list. */
19809 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
19811 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19812 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19814 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
19815 list
->name
, entry
->seq
,
19816 community_direct_str(entry
->direct
),
19817 community_list_config_str(entry
));
19820 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19821 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19823 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
19824 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
19827 list
->name
, entry
->seq
,
19828 community_direct_str(entry
->direct
),
19829 community_list_config_str(entry
));
19834 /* lcommunity-list. */
19835 cm
= community_list_master_lookup(bgp_clist
,
19836 LARGE_COMMUNITY_LIST_MASTER
);
19838 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19839 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19841 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
19842 list
->name
, entry
->seq
,
19843 community_direct_str(entry
->direct
),
19844 community_list_config_str(entry
));
19847 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19848 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19850 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
19852 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
19855 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
19856 community_list_config_str(entry
));
19863 static int community_list_config_write(struct vty
*vty
);
19864 static struct cmd_node community_list_node
= {
19865 .name
= "community list",
19866 .node
= COMMUNITY_LIST_NODE
,
19868 .config_write
= community_list_config_write
,
19871 static void community_list_vty(void)
19873 install_node(&community_list_node
);
19875 /* Community-list. */
19876 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
19877 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
19878 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
19879 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
19880 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
19881 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
19882 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
19883 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
19885 /* Extcommunity-list. */
19886 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
19887 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
19888 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
19889 install_element(CONFIG_NODE
,
19890 &no_bgp_extcommunity_list_standard_all_list_cmd
);
19891 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
19892 install_element(CONFIG_NODE
,
19893 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
19894 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
19895 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
19897 /* Large Community List */
19898 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
19899 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
19900 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
19901 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
19902 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
19903 install_element(CONFIG_NODE
,
19904 &no_bgp_lcommunity_list_name_standard_all_cmd
);
19905 install_element(CONFIG_NODE
,
19906 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
19907 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
19908 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
19909 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
19910 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
19911 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
19912 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
19915 static struct cmd_node community_alias_node
= {
19916 .name
= "community alias",
19917 .node
= COMMUNITY_ALIAS_NODE
,
19919 .config_write
= bgp_community_alias_write
,
19922 void community_alias_vty(void)
19924 install_node(&community_alias_node
);
19926 /* Community-list. */
19927 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
19929 bgp_community_alias_command_completion_setup();