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_nht.h"
57 #include "bgpd/bgp_nexthop.h"
58 #include "bgpd/bgp_network.h"
59 #include "bgpd/bgp_open.h"
60 #include "bgpd/bgp_regex.h"
61 #include "bgpd/bgp_route.h"
62 #include "bgpd/bgp_mplsvpn.h"
63 #include "bgpd/bgp_zebra.h"
64 #include "bgpd/bgp_table.h"
65 #include "bgpd/bgp_vty.h"
66 #include "bgpd/bgp_mpath.h"
67 #include "bgpd/bgp_packet.h"
68 #include "bgpd/bgp_updgrp.h"
69 #include "bgpd/bgp_bfd.h"
70 #include "bgpd/bgp_io.h"
71 #include "bgpd/bgp_evpn.h"
72 #include "bgpd/bgp_evpn_vty.h"
73 #include "bgpd/bgp_evpn_mh.h"
74 #include "bgpd/bgp_addpath.h"
75 #include "bgpd/bgp_mac.h"
76 #include "bgpd/bgp_flowspec.h"
77 #include "bgpd/bgp_conditional_adv.h"
79 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
81 #include "bgpd/bgp_orr.h"
84 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
87 .match_profile
= "traditional",
88 .match_version
= "< 7.4",
92 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
93 { .val_bool
= true, .match_profile
= "datacenter", },
94 { .val_bool
= false },
96 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
97 { .val_bool
= true, .match_profile
= "datacenter", },
98 { .val_bool
= false },
100 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
101 { .val_bool
= true, .match_profile
= "datacenter", },
102 { .val_bool
= false },
104 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
105 { .val_bool
= true, .match_profile
= "datacenter", },
106 { .val_bool
= false },
108 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
109 { .val_ulong
= 10, .match_profile
= "datacenter", },
110 { .val_ulong
= 120 },
112 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
113 { .val_ulong
= 9, .match_profile
= "datacenter", },
114 { .val_ulong
= 180 },
116 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
117 { .val_ulong
= 3, .match_profile
= "datacenter", },
120 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
121 { .val_bool
= false, .match_profile
= "datacenter", },
122 { .val_bool
= false, .match_version
= "< 7.4", },
123 { .val_bool
= true },
125 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
126 { .val_bool
= false, .match_version
= "< 7.6", },
127 { .val_bool
= true },
129 FRR_CFG_DEFAULT_BOOL(BGP_GRACEFUL_NOTIFICATION
,
130 { .val_bool
= false, .match_version
= "< 8.3", },
131 { .val_bool
= true },
133 FRR_CFG_DEFAULT_BOOL(BGP_HARD_ADMIN_RESET
,
134 { .val_bool
= false, .match_version
= "< 8.3", },
135 { .val_bool
= true },
138 DEFINE_HOOK(bgp_inst_config_write
,
139 (struct bgp
*bgp
, struct vty
*vty
),
141 DEFINE_HOOK(bgp_snmp_update_last_changed
, (struct bgp
*bgp
), (bgp
));
142 DEFINE_HOOK(bgp_snmp_init_stats
, (struct bgp
*bgp
), (bgp
));
144 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
145 struct prefix
*range
, int exact
);
147 /* Show BGP peer's information. */
157 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
158 struct prefix
*range
, int exact
);
160 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
165 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
168 afi_t afi
, bool use_json
);
170 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
176 return BGP_IPV4_NODE
;
178 return BGP_IPV4M_NODE
;
179 case SAFI_LABELED_UNICAST
:
180 return BGP_IPV4L_NODE
;
182 return BGP_VPNV4_NODE
;
184 return BGP_FLOWSPECV4_NODE
;
187 return BGP_IPV4_NODE
;
192 return BGP_IPV6_NODE
;
194 return BGP_IPV6M_NODE
;
195 case SAFI_LABELED_UNICAST
:
196 return BGP_IPV6L_NODE
;
198 return BGP_VPNV6_NODE
;
200 return BGP_FLOWSPECV6_NODE
;
203 return BGP_IPV4_NODE
;
206 return BGP_EVPN_NODE
;
209 // We should never be here but to clarify the switch statement..
210 return BGP_IPV4_NODE
;
213 // Impossible to happen
214 return BGP_IPV4_NODE
;
217 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
220 if (safi
== SAFI_UNICAST
)
221 return "IPv4 Unicast";
222 if (safi
== SAFI_MULTICAST
)
223 return "IPv4 Multicast";
224 if (safi
== SAFI_LABELED_UNICAST
)
225 return "IPv4 Labeled Unicast";
226 if (safi
== SAFI_MPLS_VPN
)
228 if (safi
== SAFI_ENCAP
)
230 if (safi
== SAFI_FLOWSPEC
)
231 return "IPv4 Flowspec";
232 } else if (afi
== AFI_IP6
) {
233 if (safi
== SAFI_UNICAST
)
234 return "IPv6 Unicast";
235 if (safi
== SAFI_MULTICAST
)
236 return "IPv6 Multicast";
237 if (safi
== SAFI_LABELED_UNICAST
)
238 return "IPv6 Labeled Unicast";
239 if (safi
== SAFI_MPLS_VPN
)
241 if (safi
== SAFI_ENCAP
)
243 if (safi
== SAFI_FLOWSPEC
)
244 return "IPv6 Flowspec";
245 } else if (afi
== AFI_L2VPN
) {
246 if (safi
== SAFI_EVPN
)
254 * Please note that we have intentionally camelCased
255 * the return strings here. So if you want
256 * to use this function, please ensure you
257 * are doing this within json output
259 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
262 if (safi
== SAFI_UNICAST
)
263 return "ipv4Unicast";
264 if (safi
== SAFI_MULTICAST
)
265 return "ipv4Multicast";
266 if (safi
== SAFI_LABELED_UNICAST
)
267 return "ipv4LabeledUnicast";
268 if (safi
== SAFI_MPLS_VPN
)
270 if (safi
== SAFI_ENCAP
)
272 if (safi
== SAFI_FLOWSPEC
)
273 return "ipv4Flowspec";
274 } else if (afi
== AFI_IP6
) {
275 if (safi
== SAFI_UNICAST
)
276 return "ipv6Unicast";
277 if (safi
== SAFI_MULTICAST
)
278 return "ipv6Multicast";
279 if (safi
== SAFI_LABELED_UNICAST
)
280 return "ipv6LabeledUnicast";
281 if (safi
== SAFI_MPLS_VPN
)
283 if (safi
== SAFI_ENCAP
)
285 if (safi
== SAFI_FLOWSPEC
)
286 return "ipv6Flowspec";
287 } else if (afi
== AFI_L2VPN
) {
288 if (safi
== SAFI_EVPN
)
295 /* unset srv6 locator */
296 static int bgp_srv6_locator_unset(struct bgp
*bgp
)
299 struct listnode
*node
, *nnode
;
300 struct srv6_locator_chunk
*chunk
, *tovpn_sid_locator
;
301 struct bgp_srv6_function
*func
;
304 /* release chunk notification via ZAPI */
305 ret
= bgp_zebra_srv6_manager_release_locator_chunk(
306 bgp
->srv6_locator_name
);
311 for (ALL_LIST_ELEMENTS(bgp
->srv6_locator_chunks
, node
, nnode
, chunk
)) {
312 listnode_delete(bgp
->srv6_locator_chunks
, chunk
);
313 srv6_locator_chunk_free(chunk
);
316 /* refresh functions */
317 for (ALL_LIST_ELEMENTS(bgp
->srv6_functions
, node
, nnode
, func
)) {
318 listnode_delete(bgp
->srv6_functions
, func
);
319 XFREE(MTYPE_BGP_SRV6_FUNCTION
, func
);
322 /* refresh tovpn_sid */
323 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
324 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
327 /* refresh vpnv4 tovpn_sid */
328 XFREE(MTYPE_BGP_SRV6_SID
,
329 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid
);
331 /* refresh vpnv6 tovpn_sid */
332 XFREE(MTYPE_BGP_SRV6_SID
,
333 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid
);
336 /* update vpn bgp processes */
337 vpn_leak_postchange_all();
339 /* refresh tovpn_sid_locator */
340 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
341 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
344 /* refresh vpnv4 tovpn_sid_locator */
346 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid_locator
;
347 if (tovpn_sid_locator
) {
348 srv6_locator_chunk_free(tovpn_sid_locator
);
349 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid_locator
= NULL
;
352 /* refresh vpnv6 tovpn_sid_locator */
354 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid_locator
;
355 if (tovpn_sid_locator
) {
356 srv6_locator_chunk_free(tovpn_sid_locator
);
357 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid_locator
= NULL
;
361 /* clear locator name */
362 memset(bgp
->srv6_locator_name
, 0, sizeof(bgp
->srv6_locator_name
));
367 /* Utility function to get address family from current node. */
368 afi_t
bgp_node_afi(struct vty
*vty
)
376 case BGP_FLOWSPECV6_NODE
:
389 /* Utility function to get subsequent address family from current
391 safi_t
bgp_node_safi(struct vty
*vty
)
397 safi
= SAFI_MPLS_VPN
;
401 safi
= SAFI_MULTICAST
;
408 safi
= SAFI_LABELED_UNICAST
;
410 case BGP_FLOWSPECV4_NODE
:
411 case BGP_FLOWSPECV6_NODE
:
412 safi
= SAFI_FLOWSPEC
;
422 * Converts an AFI in string form to afi_t
424 * @param afi string, one of
428 * @return the corresponding afi_t
430 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
432 afi_t afi
= AFI_MAX
; /* unknown */
433 if (strmatch(afi_str
, "ipv4"))
435 else if (strmatch(afi_str
, "ipv6"))
437 else if (strmatch(afi_str
, "l2vpn"))
442 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
446 if (argv_find(argv
, argc
, "ipv4", index
)) {
450 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
454 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
462 /* supports <unicast|multicast|vpn|labeled-unicast> */
463 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
465 safi_t safi
= SAFI_MAX
; /* unknown */
466 if (strmatch(safi_str
, "multicast"))
467 safi
= SAFI_MULTICAST
;
468 else if (strmatch(safi_str
, "unicast"))
470 else if (strmatch(safi_str
, "vpn"))
471 safi
= SAFI_MPLS_VPN
;
472 else if (strmatch(safi_str
, "evpn"))
474 else if (strmatch(safi_str
, "labeled-unicast"))
475 safi
= SAFI_LABELED_UNICAST
;
476 else if (strmatch(safi_str
, "flowspec"))
477 safi
= SAFI_FLOWSPEC
;
481 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
485 if (argv_find(argv
, argc
, "unicast", index
)) {
488 *safi
= SAFI_UNICAST
;
489 } else if (argv_find(argv
, argc
, "multicast", index
)) {
492 *safi
= SAFI_MULTICAST
;
493 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
496 *safi
= SAFI_LABELED_UNICAST
;
497 } else if (argv_find(argv
, argc
, "vpn", index
)) {
500 *safi
= SAFI_MPLS_VPN
;
501 } else if (argv_find(argv
, argc
, "evpn", index
)) {
505 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
508 *safi
= SAFI_FLOWSPEC
;
514 * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag.
517 * address-family identifier
520 * subsequent address-family identifier
523 * default_af string corresponding to the supplied afi/safi pair.
524 * If afi/safi is invalid or if flag for afi/safi doesn't exist,
527 static const char *get_bgp_default_af_flag(afi_t afi
, safi_t safi
)
533 return "ipv4-unicast";
535 return "ipv4-multicast";
540 case SAFI_LABELED_UNICAST
:
541 return "ipv4-labeled-unicast";
543 return "ipv4-flowspec";
545 return "unknown-afi/safi";
551 return "ipv6-unicast";
553 return "ipv6-multicast";
558 case SAFI_LABELED_UNICAST
:
559 return "ipv6-labeled-unicast";
561 return "ipv6-flowspec";
563 return "unknown-afi/safi";
571 return "unknown-afi/safi";
575 return "unknown-afi/safi";
577 /* all AFIs are accounted for above, so this shouldn't happen */
578 return "unknown-afi/safi";
581 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
582 enum bgp_instance_type inst_type
)
584 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
586 if (ret
== BGP_CREATED
) {
587 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
588 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
590 if (DFLT_BGP_IMPORT_CHECK
)
591 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
592 if (DFLT_BGP_SHOW_HOSTNAME
)
593 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
594 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
595 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
596 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
597 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
598 if (DFLT_BGP_DETERMINISTIC_MED
)
599 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
600 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
601 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
602 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
603 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
604 if (DFLT_BGP_GRACEFUL_NOTIFICATION
)
605 SET_FLAG((*bgp
)->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
606 if (DFLT_BGP_HARD_ADMIN_RESET
)
607 SET_FLAG((*bgp
)->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
615 * bgp_vty_find_and_parse_afi_safi_bgp
617 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
618 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
619 * to appropriate values for the calling function. This is to allow the
620 * calling function to make decisions appropriate for the show command
621 * that is being parsed.
623 * The show commands are generally of the form:
624 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
625 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
627 * Since we use argv_find if the show command in particular doesn't have:
629 * [<view|vrf> VIEWVRFNAME]
630 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
631 * The command parsing should still be ok.
633 * vty -> The vty for the command so we can output some useful data in
634 * the event of a parse error in the vrf.
635 * argv -> The command tokens
636 * argc -> How many command tokens we have
637 * idx -> The current place in the command, generally should be 0 for this
639 * afi -> The parsed afi if it was included in the show command, returned here
640 * safi -> The parsed safi if it was included in the show command, returned here
641 * bgp -> Pointer to the bgp data structure we need to fill in.
642 * use_json -> json is configured or not
644 * The function returns the correct location in the parse tree for the
647 * Returns 0 for failure to parse correctly, else the idx position of where
648 * it found the last token.
650 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
651 struct cmd_token
**argv
, int argc
,
652 int *idx
, afi_t
*afi
, safi_t
*safi
,
653 struct bgp
**bgp
, bool use_json
)
655 char *vrf_name
= NULL
;
661 if (argv_find(argv
, argc
, "ip", idx
))
664 if (argv_find(argv
, argc
, "view", idx
))
665 vrf_name
= argv
[*idx
+ 1]->arg
;
666 else if (argv_find(argv
, argc
, "vrf", idx
)) {
667 vrf_name
= argv
[*idx
+ 1]->arg
;
668 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
672 if (strmatch(vrf_name
, "all"))
675 *bgp
= bgp_lookup_by_name(vrf_name
);
678 json_object
*json
= NULL
;
679 json
= json_object_new_object();
680 json_object_string_add(
682 "View/Vrf is unknown");
686 vty_out(vty
, "View/Vrf %s is unknown\n",
693 *bgp
= bgp_get_default();
696 json_object
*json
= NULL
;
697 json
= json_object_new_object();
698 json_object_string_add(
700 "Default BGP instance not found");
705 "Default BGP instance not found\n");
711 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
712 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
718 static bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
720 struct interface
*ifp
= NULL
;
721 struct listnode
*node
;
722 struct bgp_listener
*listener
;
723 union sockunion all_su
;
725 if (su
->sa
.sa_family
== AF_INET
) {
726 (void)str2sockunion("0.0.0.0", &all_su
);
727 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
728 } else if (su
->sa
.sa_family
== AF_INET6
) {
729 (void)str2sockunion("::", &all_su
);
730 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
731 su
->sin6
.sin6_scope_id
,
736 for (ALL_LIST_ELEMENTS_RO(bm
->listen_sockets
, node
, listener
)) {
737 if (sockunion_family(su
) !=
738 sockunion_family(&listener
->su
))
741 /* If 0.0.0.0/:: is a listener, then treat as self and
744 if (!sockunion_cmp(&listener
->su
, su
) ||
745 !sockunion_cmp(&listener
->su
, &all_su
))
753 /* Utility function for looking up peer from VTY. */
754 /* This is used only for configuration, so disallow if attempted on
755 * a dynamic neighbor.
757 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
759 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
768 ret
= str2sockunion(ip_str
, &su
);
770 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
772 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
775 "%% Malformed address or name: %s\n",
781 peer
= peer_lookup(bgp
, &su
);
784 "%% Specify remote-as or peer-group commands first\n");
787 if (peer_dynamic_neighbor(peer
)) {
789 "%% Operation not allowed on a dynamic neighbor\n");
796 /* Utility function for looking up peer or peer group. */
797 /* This is used only for configuration, so disallow if attempted on
798 * a dynamic neighbor.
800 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
802 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
805 struct peer
*peer
= NULL
;
806 struct peer_group
*group
= NULL
;
812 ret
= str2sockunion(peer_str
, &su
);
814 /* IP address, locate peer. */
815 peer
= peer_lookup(bgp
, &su
);
817 /* Not IP, could match either peer configured on interface or a
819 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
821 group
= peer_group_lookup(bgp
, peer_str
);
825 if (peer_dynamic_neighbor(peer
)) {
827 "%% Operation not allowed on a dynamic neighbor\n");
837 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
842 int bgp_vty_return(struct vty
*vty
, enum bgp_create_error_code ret
)
844 const char *str
= NULL
;
849 case BGP_GR_NO_OPERATION
:
851 case BGP_ERR_INVALID_VALUE
:
852 str
= "Invalid value";
854 case BGP_ERR_INVALID_FLAG
:
855 str
= "Invalid flag";
857 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
858 str
= "Peer-group has been shutdown. Activate the peer-group first";
860 case BGP_ERR_PEER_FLAG_CONFLICT
:
861 str
= "Can't set override-capability and strict-capability-match at the same time";
863 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
864 str
= "Specify remote-as or peer-group remote AS first";
866 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
867 str
= "Cannot change the peer-group. Deconfigure first";
869 case BGP_ERR_PEER_GROUP_MISMATCH
:
870 str
= "Peer is not a member of this peer-group";
872 case BGP_ERR_PEER_FILTER_CONFLICT
:
873 str
= "Prefix/distribute list can not co-exist";
875 case BGP_ERR_NOT_INTERNAL_PEER
:
876 str
= "Invalid command. Not an internal neighbor";
878 case BGP_ERR_REMOVE_PRIVATE_AS
:
879 str
= "remove-private-AS cannot be configured for IBGP peers";
881 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
882 str
= "Cannot have local-as same as BGP AS number";
884 case BGP_ERR_TCPSIG_FAILED
:
885 str
= "Error while applying TCP-Sig to session(s)";
887 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
888 str
= "ebgp-multihop and ttl-security cannot be configured together";
890 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
891 str
= "ttl-security only allowed for EBGP peers";
893 case BGP_ERR_AS_OVERRIDE
:
894 str
= "as-override cannot be configured for IBGP peers";
896 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
897 str
= "Invalid limit for number of dynamic neighbors";
899 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
900 str
= "Dynamic neighbor listen range already exists";
902 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
903 str
= "Operation not allowed on a dynamic neighbor";
905 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
906 str
= "Operation not allowed on a directly connected neighbor";
908 case BGP_ERR_PEER_SAFI_CONFLICT
:
909 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
911 case BGP_ERR_GR_INVALID_CMD
:
912 str
= "The Graceful Restart command used is not valid at this moment.";
914 case BGP_ERR_GR_OPERATION_FAILED
:
915 str
= "The Graceful Restart Operation failed due to an err.";
917 case BGP_ERR_PEER_GROUP_MEMBER
:
918 str
= "Peer-group member cannot override remote-as of peer-group.";
920 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
921 str
= "Peer-group members must be all internal or all external.";
923 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND
:
924 str
= "Range specified cannot be deleted because it is not part of current config.";
926 case BGP_ERR_INSTANCE_MISMATCH
:
927 str
= "Instance specified does not match the current instance.";
929 case BGP_ERR_NO_INTERFACE_CONFIG
:
930 str
= "Interface specified is not being used for interface based peer.";
932 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
933 str
= "No configuration already specified for soft reconfiguration.";
935 case BGP_ERR_AS_MISMATCH
:
936 str
= "BGP is already running.";
938 case BGP_ERR_AF_UNCONFIGURED
:
939 str
= "AFI/SAFI specified is not currently configured.";
941 case BGP_ERR_INVALID_AS
:
942 str
= "Confederation AS specified is the same AS as our AS.";
944 case BGP_ERR_INVALID_ROLE_NAME
:
945 str
= "Invalid role name";
947 case BGP_ERR_INVALID_INTERNAL_ROLE
:
948 str
= "External roles can be set only on eBGP session";
950 case BGP_ERR_PEER_ORR_CONFIGURED
:
951 str
= "Deconfigure optimal-route-reflection on this peer first";
955 vty_out(vty
, "%% %s\n", str
);
956 return CMD_WARNING_CONFIG_FAILED
;
961 /* BGP clear sort. */
970 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
971 safi_t safi
, int error
)
974 case BGP_ERR_AF_UNCONFIGURED
:
977 "%% BGP: Enable %s address family for the neighbor %s\n",
978 get_afi_safi_str(afi
, safi
, false), peer
->host
);
981 "%% BGP: Enable %s address family for the neighbor %s",
982 get_afi_safi_str(afi
, safi
, false), peer
->host
);
984 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
987 "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
991 "%% BGP: Inbound soft reconfig for %s not possible as it has neither refresh capability, nor inbound soft reconfig",
999 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
1000 struct listnode
**nnode
, enum bgp_clear_type stype
)
1003 struct peer_af
*paf
;
1005 /* if afi/.safi not specified, spin thru all of them */
1006 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
1009 enum bgp_af_index index
;
1011 for (index
= BGP_AF_START
; index
< BGP_AF_MAX
; index
++) {
1012 paf
= peer
->peer_af_array
[index
];
1016 if (paf
&& paf
->subgroup
)
1017 SET_FLAG(paf
->subgroup
->sflags
,
1018 SUBGRP_STATUS_FORCE_UPDATES
);
1021 tmp_safi
= paf
->safi
;
1022 if (!peer
->afc
[tmp_afi
][tmp_safi
])
1025 if (stype
== BGP_CLEAR_SOFT_NONE
)
1026 ret
= peer_clear(peer
, nnode
);
1028 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
1031 /* if afi specified and safi not, spin thru safis on this afi */
1032 } else if (safi
== SAFI_UNSPEC
) {
1035 for (tmp_safi
= SAFI_UNICAST
;
1036 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
1037 if (!peer
->afc
[afi
][tmp_safi
])
1040 paf
= peer_af_find(peer
, afi
, tmp_safi
);
1041 if (paf
&& paf
->subgroup
)
1042 SET_FLAG(paf
->subgroup
->sflags
,
1043 SUBGRP_STATUS_FORCE_UPDATES
);
1045 if (stype
== BGP_CLEAR_SOFT_NONE
)
1046 ret
= peer_clear(peer
, nnode
);
1048 ret
= peer_clear_soft(peer
, afi
,
1051 /* both afi/safi specified, let the caller know if not defined */
1053 if (!peer
->afc
[afi
][safi
])
1056 paf
= peer_af_find(peer
, afi
, safi
);
1057 if (paf
&& paf
->subgroup
)
1058 SET_FLAG(paf
->subgroup
->sflags
,
1059 SUBGRP_STATUS_FORCE_UPDATES
);
1061 if (stype
== BGP_CLEAR_SOFT_NONE
)
1062 ret
= peer_clear(peer
, nnode
);
1064 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
1070 /* `clear ip bgp' functions. */
1071 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1072 enum clear_sort sort
, enum bgp_clear_type stype
,
1079 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
1081 /* Clear all neighbors. */
1083 * Pass along pointer to next node to peer_clear() when walking all
1084 * nodes on the BGP instance as that may get freed if it is a
1087 if (sort
== clear_all
) {
1088 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1090 bgp_peer_gr_flags_update(peer
);
1092 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1093 gr_router_detected
= true;
1095 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
1099 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1102 if (gr_router_detected
1103 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1104 bgp_zebra_send_capabilities(bgp
, false);
1105 } else if (!gr_router_detected
1106 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1107 bgp_zebra_send_capabilities(bgp
, true);
1110 /* This is to apply read-only mode on this clear. */
1111 if (stype
== BGP_CLEAR_SOFT_NONE
)
1112 bgp
->update_delay_over
= 0;
1117 /* Clear specified neighbor. */
1118 if (sort
== clear_peer
) {
1121 /* Make sockunion for lookup. */
1122 ret
= str2sockunion(arg
, &su
);
1124 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1126 peer
= peer_lookup_by_hostname(bgp
, arg
);
1129 "Malformed address or name: %s\n",
1135 peer
= peer_lookup(bgp
, &su
);
1138 "%% BGP: Unknown neighbor - \"%s\"\n",
1144 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1145 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1147 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1149 /* if afi/safi not defined for this peer, let caller know */
1151 ret
= BGP_ERR_AF_UNCONFIGURED
;
1154 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1159 /* Clear all neighbors belonging to a specific peer-group. */
1160 if (sort
== clear_group
) {
1161 struct peer_group
*group
;
1163 group
= peer_group_lookup(bgp
, arg
);
1165 vty_out(vty
, "%% BGP: No such peer-group %s\n", arg
);
1169 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1170 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1173 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1180 "%% BGP: No %s peer belonging to peer-group %s is configured\n",
1181 get_afi_safi_str(afi
, safi
, false), arg
);
1186 /* Clear all external (eBGP) neighbors. */
1187 if (sort
== clear_external
) {
1188 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1189 if (peer
->sort
== BGP_PEER_IBGP
)
1192 bgp_peer_gr_flags_update(peer
);
1194 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1195 gr_router_detected
= true;
1197 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1200 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1205 if (gr_router_detected
1206 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1207 bgp_zebra_send_capabilities(bgp
, false);
1208 } else if (!gr_router_detected
1209 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1210 bgp_zebra_send_capabilities(bgp
, true);
1215 "%% BGP: No external %s peer is configured\n",
1216 get_afi_safi_str(afi
, safi
, false));
1221 /* Clear all neighbors belonging to a specific AS. */
1222 if (sort
== clear_as
) {
1223 as_t as
= strtoul(arg
, NULL
, 10);
1225 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1229 bgp_peer_gr_flags_update(peer
);
1231 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1232 gr_router_detected
= true;
1234 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1237 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1242 if (gr_router_detected
1243 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1244 bgp_zebra_send_capabilities(bgp
, false);
1245 } else if (!gr_router_detected
1246 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1247 bgp_zebra_send_capabilities(bgp
, true);
1252 "%% BGP: No %s peer is configured with AS %s\n",
1253 get_afi_safi_str(afi
, safi
, false), arg
);
1261 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1262 safi_t safi
, enum clear_sort sort
,
1263 enum bgp_clear_type stype
, const char *arg
)
1267 /* BGP structure lookup. */
1269 bgp
= bgp_lookup_by_name(name
);
1271 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1275 bgp
= bgp_get_default();
1277 vty_out(vty
, "No BGP process is configured\n");
1282 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1285 /* clear soft inbound */
1286 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1291 FOREACH_AFI_SAFI (afi
, safi
)
1292 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1293 BGP_CLEAR_SOFT_IN
, NULL
);
1296 /* clear soft outbound */
1297 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1302 FOREACH_AFI_SAFI (afi
, safi
)
1303 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1304 BGP_CLEAR_SOFT_OUT
, NULL
);
1308 void bgp_clear_soft_in(struct bgp
*bgp
, afi_t afi
, safi_t safi
)
1310 bgp_clear(NULL
, bgp
, afi
, safi
, clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
1313 #ifndef VTYSH_EXTRACT_PL
1314 #include "bgpd/bgp_vty_clippy.c"
1317 DEFUN_HIDDEN (bgp_local_mac
,
1319 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1321 "Local MAC config\n"
1322 "VxLAN Network Identifier\n"
1326 "mac-mobility sequence\n"
1336 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1337 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1338 vty_out(vty
, "%% Malformed MAC address\n");
1341 memset(&ip
, 0, sizeof(ip
));
1342 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1344 bgp
= bgp_get_default();
1346 vty_out(vty
, "Default BGP instance is not there\n");
1350 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1353 vty_out(vty
, "Internal error\n");
1360 DEFUN_HIDDEN (no_bgp_local_mac
,
1361 no_bgp_local_mac_cmd
,
1362 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1365 "Local MAC config\n"
1366 "VxLAN Network Identifier\n"
1377 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1378 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1379 vty_out(vty
, "%% Malformed MAC address\n");
1382 memset(&ip
, 0, sizeof(ip
));
1384 bgp
= bgp_get_default();
1386 vty_out(vty
, "Default BGP instance is not there\n");
1390 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1392 vty_out(vty
, "Internal error\n");
1399 DEFUN (no_synchronization
,
1400 no_synchronization_cmd
,
1401 "no synchronization",
1403 "Perform IGP synchronization\n")
1408 DEFUN (no_auto_summary
,
1409 no_auto_summary_cmd
,
1412 "Enable automatic network number summarization\n")
1417 /* "router bgp" commands. */
1418 DEFUN_NOSH (router_bgp
,
1420 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1424 BGP_INSTANCE_HELP_STR
)
1427 int idx_view_vrf
= 3;
1433 const char *name
= NULL
;
1434 enum bgp_instance_type inst_type
;
1436 // "router bgp" without an ASN
1438 // Pending: Make VRF option available for ASN less config
1439 bgp
= bgp_get_default();
1442 vty_out(vty
, "%% No BGP process is configured\n");
1443 return CMD_WARNING_CONFIG_FAILED
;
1446 if (listcount(bm
->bgp
) > 1) {
1447 vty_out(vty
, "%% Please specify ASN and VRF\n");
1448 return CMD_WARNING_CONFIG_FAILED
;
1454 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1456 if (as
== BGP_PRIVATE_AS_MAX
|| as
== BGP_AS4_MAX
)
1457 vty_out(vty
, "Reserved AS used (%u|%u); AS is %u\n",
1458 BGP_PRIVATE_AS_MAX
, BGP_AS4_MAX
, as
);
1460 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1462 name
= argv
[idx_vrf
]->arg
;
1464 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1465 if (strmatch(name
, VRF_DEFAULT_NAME
))
1468 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1469 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1470 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1473 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1474 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1476 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1478 case BGP_ERR_AS_MISMATCH
:
1479 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1480 return CMD_WARNING_CONFIG_FAILED
;
1481 case BGP_ERR_INSTANCE_MISMATCH
:
1483 "BGP instance name and AS number mismatch\n");
1485 "BGP instance is already running; AS is %u\n",
1487 return CMD_WARNING_CONFIG_FAILED
;
1491 * If we just instantiated the default instance, complete
1492 * any pending VRF-VPN leaking that was configured via
1493 * earlier "router bgp X vrf FOO" blocks.
1495 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1496 vpn_leak_postchange_all();
1498 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1499 bgp_vpn_leak_export(bgp
);
1500 /* Pending: handle when user tries to change a view to vrf n vv.
1504 /* unset the auto created flag as the user config is now present */
1505 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1506 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1511 /* "no router bgp" commands. */
1512 DEFUN (no_router_bgp
,
1514 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1519 BGP_INSTANCE_HELP_STR
)
1525 const char *name
= NULL
;
1527 // "no router bgp" without an ASN
1529 // Pending: Make VRF option available for ASN less config
1530 bgp
= bgp_get_default();
1533 vty_out(vty
, "%% No BGP process is configured\n");
1534 return CMD_WARNING_CONFIG_FAILED
;
1537 if (listcount(bm
->bgp
) > 1) {
1538 vty_out(vty
, "%% Please specify ASN and VRF\n");
1539 return CMD_WARNING_CONFIG_FAILED
;
1543 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1545 return CMD_WARNING_CONFIG_FAILED
;
1548 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1551 name
= argv
[idx_vrf
]->arg
;
1552 if (strmatch(argv
[idx_vrf
- 1]->text
, "vrf")
1553 && strmatch(name
, VRF_DEFAULT_NAME
))
1557 /* Lookup bgp structure. */
1558 bgp
= bgp_lookup(as
, name
);
1560 vty_out(vty
, "%% Can't find BGP instance\n");
1561 return CMD_WARNING_CONFIG_FAILED
;
1565 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1567 return CMD_WARNING_CONFIG_FAILED
;
1570 /* Cannot delete default instance if vrf instances exist */
1571 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1572 struct listnode
*node
;
1573 struct bgp
*tmp_bgp
;
1575 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1576 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1578 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1579 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1580 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1581 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1582 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1583 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1584 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1585 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1586 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1587 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1588 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1589 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1590 (bgp
== bgp_get_evpn() &&
1591 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1592 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST
) ||
1593 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1594 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP
) ||
1595 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1596 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST
) ||
1597 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1598 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP
))) ||
1599 (hashcount(tmp_bgp
->vnihash
))) {
1601 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1602 return CMD_WARNING_CONFIG_FAILED
;
1613 /* bgp session-dscp */
1615 DEFPY (bgp_session_dscp
,
1616 bgp_session_dscp_cmd
,
1617 "bgp session-dscp (0-63)$dscp",
1619 "Override default (C6) bgp TCP session DSCP value\n"
1620 "Manually configured dscp parameter\n")
1622 bm
->tcp_dscp
= dscp
<< 2;
1627 DEFPY (no_bgp_session_dscp
,
1628 no_bgp_session_dscp_cmd
,
1629 "no bgp session-dscp [(0-63)]",
1632 "Override default (C6) bgp TCP session DSCP value\n"
1633 "Manually configured dscp parameter\n")
1635 bm
->tcp_dscp
= IPTOS_PREC_INTERNETCONTROL
;
1640 /* BGP router-id. */
1642 DEFPY (bgp_router_id
,
1644 "bgp router-id A.B.C.D",
1646 "Override configured router identifier\n"
1647 "Manually configured router identifier\n")
1649 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1650 bgp_router_id_static_set(bgp
, router_id
);
1654 DEFPY (no_bgp_router_id
,
1655 no_bgp_router_id_cmd
,
1656 "no bgp router-id [A.B.C.D]",
1659 "Override configured router identifier\n"
1660 "Manually configured router identifier\n")
1662 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1664 if (router_id_str
) {
1665 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1666 vty_out(vty
, "%% BGP router-id doesn't match\n");
1667 return CMD_WARNING_CONFIG_FAILED
;
1671 router_id
.s_addr
= 0;
1672 bgp_router_id_static_set(bgp
, router_id
);
1677 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1678 "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name",
1680 "Add community specific parameters\n"
1681 "Create an alias for a community\n"
1682 "Community (AA:BB or AA:BB:CC)\n"
1685 struct community_alias ca
= {};
1686 struct community_alias
*lookup_community
;
1687 struct community_alias
*lookup_alias
;
1688 struct community
*comm
;
1689 struct lcommunity
*lcomm
;
1690 uint8_t invalid
= 0;
1692 comm
= community_str2com(community
);
1695 community_free(&comm
);
1697 lcomm
= lcommunity_str2com(community
);
1700 lcommunity_free(&lcomm
);
1703 vty_out(vty
, "Invalid community format\n");
1707 strlcpy(ca
.community
, community
, sizeof(ca
.community
));
1708 strlcpy(ca
.alias
, alias_name
, sizeof(ca
.alias
));
1710 lookup_community
= bgp_ca_community_lookup(&ca
);
1711 lookup_alias
= bgp_ca_alias_lookup(&ca
);
1714 bgp_ca_alias_delete(&ca
);
1715 bgp_ca_community_delete(&ca
);
1718 /* Lookup if community hash table has an item
1719 * with the same alias name.
1721 strlcpy(ca
.community
, lookup_alias
->community
,
1722 sizeof(ca
.community
));
1723 if (bgp_ca_community_lookup(&ca
)) {
1725 "community (%s) already has this alias (%s)\n",
1726 lookup_alias
->community
,
1727 lookup_alias
->alias
);
1730 bgp_ca_alias_delete(&ca
);
1733 if (lookup_community
) {
1734 /* Lookup if alias hash table has an item
1735 * with the same community.
1737 strlcpy(ca
.alias
, lookup_community
->alias
,
1739 if (bgp_ca_alias_lookup(&ca
)) {
1741 "alias (%s) already has this community (%s)\n",
1742 lookup_community
->alias
,
1743 lookup_community
->community
);
1746 bgp_ca_community_delete(&ca
);
1749 bgp_ca_alias_insert(&ca
);
1750 bgp_ca_community_insert(&ca
);
1756 DEFPY (bgp_global_suppress_fib_pending
,
1757 bgp_global_suppress_fib_pending_cmd
,
1758 "[no] bgp suppress-fib-pending",
1761 "Advertise only routes that are programmed in kernel to peers globally\n")
1763 bm_wait_for_fib_set(!no
);
1768 DEFPY (bgp_suppress_fib_pending
,
1769 bgp_suppress_fib_pending_cmd
,
1770 "[no] bgp suppress-fib-pending",
1773 "Advertise only routes that are programmed in kernel to peers\n")
1775 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1777 bgp_suppress_fib_pending_set(bgp
, !no
);
1782 /* BGP Cluster ID. */
1783 DEFUN (bgp_cluster_id
,
1785 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1787 "Configure Route-Reflector Cluster-id\n"
1788 "Route-Reflector Cluster-id in IP address format\n"
1789 "Route-Reflector Cluster-id as 32 bit quantity\n")
1791 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1794 struct in_addr cluster
;
1796 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1798 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1799 return CMD_WARNING_CONFIG_FAILED
;
1802 bgp_cluster_id_set(bgp
, &cluster
);
1803 bgp_clear_star_soft_out(vty
, bgp
->name
);
1808 DEFUN (no_bgp_cluster_id
,
1809 no_bgp_cluster_id_cmd
,
1810 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1813 "Configure Route-Reflector Cluster-id\n"
1814 "Route-Reflector Cluster-id in IP address format\n"
1815 "Route-Reflector Cluster-id as 32 bit quantity\n")
1817 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1818 bgp_cluster_id_unset(bgp
);
1819 bgp_clear_star_soft_out(vty
, bgp
->name
);
1828 "Disable BGP route installation to RIB (Zebra)\n")
1830 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1832 "%% No-RIB option is already set, nothing to do here.\n");
1836 bgp_option_norib_set_runtime();
1841 DEFPY (no_bgp_norib
,
1846 "Disable BGP route installation to RIB (Zebra)\n")
1848 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1850 "%% No-RIB option is not set, nothing to do here.\n");
1854 bgp_option_norib_unset_runtime();
1859 DEFPY (no_bgp_send_extra_data
,
1860 no_bgp_send_extra_data_cmd
,
1861 "[no] bgp send-extra-data zebra",
1864 "Extra data to Zebra for display/use\n"
1868 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1870 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1875 DEFUN (bgp_confederation_identifier
,
1876 bgp_confederation_identifier_cmd
,
1877 "bgp confederation identifier (1-4294967295)",
1879 "AS confederation parameters\n"
1881 "Set routing domain confederation AS\n")
1883 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1887 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1889 bgp_confederation_id_set(bgp
, as
);
1894 DEFUN (no_bgp_confederation_identifier
,
1895 no_bgp_confederation_identifier_cmd
,
1896 "no bgp confederation identifier [(1-4294967295)]",
1899 "AS confederation parameters\n"
1901 "Set routing domain confederation AS\n")
1903 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1904 bgp_confederation_id_unset(bgp
);
1909 DEFUN (bgp_confederation_peers
,
1910 bgp_confederation_peers_cmd
,
1911 "bgp confederation peers (1-4294967295)...",
1913 "AS confederation parameters\n"
1914 "Peer ASs in BGP confederation\n"
1917 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1922 for (i
= idx_asn
; i
< argc
; i
++) {
1923 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1925 if (bgp
->as
== as
) {
1927 "%% Local member-AS not allowed in confed peer list\n");
1931 bgp_confederation_peers_add(bgp
, as
);
1936 DEFUN (no_bgp_confederation_peers
,
1937 no_bgp_confederation_peers_cmd
,
1938 "no bgp confederation peers (1-4294967295)...",
1941 "AS confederation parameters\n"
1942 "Peer ASs in BGP confederation\n"
1945 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1950 for (i
= idx_asn
; i
< argc
; i
++) {
1951 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1953 bgp_confederation_peers_remove(bgp
, as
);
1959 * Central routine for maximum-paths configuration.
1960 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1961 * @set: 1 for setting values, 0 for removing the max-paths config.
1963 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1964 const char *mpaths
, uint16_t options
,
1967 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1968 uint16_t maxpaths
= 0;
1973 afi
= bgp_node_afi(vty
);
1974 safi
= bgp_node_safi(vty
);
1977 maxpaths
= strtol(mpaths
, NULL
, 10);
1978 if (maxpaths
> multipath_num
) {
1980 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1981 maxpaths
, multipath_num
);
1982 return CMD_WARNING_CONFIG_FAILED
;
1984 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1987 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1991 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1992 (set
== 1) ? "" : "un",
1993 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1994 maxpaths
, afi
, safi
);
1995 return CMD_WARNING_CONFIG_FAILED
;
1998 bgp_recalculate_all_bestpaths(bgp
);
2003 DEFUN (bgp_maxmed_admin
,
2004 bgp_maxmed_admin_cmd
,
2005 "bgp max-med administrative ",
2007 "Advertise routes with max-med\n"
2008 "Administratively applied, for an indefinite period\n")
2010 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2012 bgp
->v_maxmed_admin
= 1;
2013 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2015 bgp_maxmed_update(bgp
);
2020 DEFUN (bgp_maxmed_admin_medv
,
2021 bgp_maxmed_admin_medv_cmd
,
2022 "bgp max-med administrative (0-4294967295)",
2024 "Advertise routes with max-med\n"
2025 "Administratively applied, for an indefinite period\n"
2026 "Max MED value to be used\n")
2028 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2031 bgp
->v_maxmed_admin
= 1;
2032 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2034 bgp_maxmed_update(bgp
);
2039 DEFUN (no_bgp_maxmed_admin
,
2040 no_bgp_maxmed_admin_cmd
,
2041 "no bgp max-med administrative [(0-4294967295)]",
2044 "Advertise routes with max-med\n"
2045 "Administratively applied, for an indefinite period\n"
2046 "Max MED value to be used\n")
2048 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2049 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
2050 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2051 bgp_maxmed_update(bgp
);
2056 DEFUN (bgp_maxmed_onstartup
,
2057 bgp_maxmed_onstartup_cmd
,
2058 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
2060 "Advertise routes with max-med\n"
2061 "Effective on a startup\n"
2062 "Time (seconds) period for max-med\n"
2063 "Max MED value to be used\n")
2065 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2068 if (argv_find(argv
, argc
, "(5-86400)", &idx
))
2069 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2070 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2071 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2073 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2075 bgp_maxmed_update(bgp
);
2080 DEFUN (no_bgp_maxmed_onstartup
,
2081 no_bgp_maxmed_onstartup_cmd
,
2082 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
2085 "Advertise routes with max-med\n"
2086 "Effective on a startup\n"
2087 "Time (seconds) period for max-med\n"
2088 "Max MED value to be used\n")
2090 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2092 /* Cancel max-med onstartup if its on */
2093 if (bgp
->t_maxmed_onstartup
) {
2094 THREAD_OFF(bgp
->t_maxmed_onstartup
);
2095 bgp
->maxmed_onstartup_over
= 1;
2098 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
2099 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2101 bgp_maxmed_update(bgp
);
2106 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
2107 uint16_t update_delay
,
2108 uint16_t establish_wait
)
2110 struct listnode
*node
, *nnode
;
2112 bool vrf_cfg
= false;
2115 * See if update-delay is set per-vrf and warn user to delete it
2116 * Note that we only need to check this if this is the first time
2117 * setting the global config.
2119 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
2120 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2121 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
2123 "%% update-delay configuration found in vrf %s\n",
2124 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
2134 "%%Failed: global update-delay config not permitted\n");
2138 if (!establish_wait
) { /* update-delay <delay> */
2139 bm
->v_update_delay
= update_delay
;
2140 bm
->v_establish_wait
= bm
->v_update_delay
;
2142 /* update-delay <delay> <establish-wait> */
2143 if (update_delay
< establish_wait
) {
2145 "%%Failed: update-delay less than the establish-wait!\n");
2146 return CMD_WARNING_CONFIG_FAILED
;
2149 bm
->v_update_delay
= update_delay
;
2150 bm
->v_establish_wait
= establish_wait
;
2153 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2154 bgp
->v_update_delay
= bm
->v_update_delay
;
2155 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2161 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
2163 struct listnode
*node
, *nnode
;
2166 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2167 bm
->v_establish_wait
= bm
->v_update_delay
;
2169 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2170 bgp
->v_update_delay
= bm
->v_update_delay
;
2171 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2177 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2178 uint16_t establish_wait
)
2180 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2182 /* if configured globally, per-instance config is not allowed */
2183 if (bm
->v_update_delay
) {
2185 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2186 return CMD_WARNING_CONFIG_FAILED
;
2190 if (!establish_wait
) /* update-delay <delay> */
2192 bgp
->v_update_delay
= update_delay
;
2193 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2197 /* update-delay <delay> <establish-wait> */
2198 if (update_delay
< establish_wait
) {
2200 "%%Failed: update-delay less than the establish-wait!\n");
2201 return CMD_WARNING_CONFIG_FAILED
;
2204 bgp
->v_update_delay
= update_delay
;
2205 bgp
->v_establish_wait
= establish_wait
;
2210 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2212 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2214 /* If configured globally, cannot remove from one bgp instance */
2215 if (bm
->v_update_delay
) {
2217 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2218 return CMD_WARNING_CONFIG_FAILED
;
2220 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2221 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2226 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2228 /* If configured globally, no need to display per-instance value */
2229 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2230 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2231 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2232 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2237 /* Global update-delay configuration */
2238 DEFPY (bgp_global_update_delay
,
2239 bgp_global_update_delay_cmd
,
2240 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2242 "Force initial delay for best-path and updates for all bgp instances\n"
2243 "Max delay in seconds\n"
2244 "Establish wait in seconds\n")
2246 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2249 /* Global update-delay deconfiguration */
2250 DEFPY (no_bgp_global_update_delay
,
2251 no_bgp_global_update_delay_cmd
,
2252 "no bgp update-delay [(0-3600) [(1-3600)]]",
2255 "Force initial delay for best-path and updates\n"
2256 "Max delay in seconds\n"
2257 "Establish wait in seconds\n")
2259 return bgp_global_update_delay_deconfig_vty(vty
);
2262 /* Update-delay configuration */
2264 DEFPY (bgp_update_delay
,
2265 bgp_update_delay_cmd
,
2266 "update-delay (0-3600)$delay [(1-3600)$wait]",
2267 "Force initial delay for best-path and updates\n"
2268 "Max delay in seconds\n"
2269 "Establish wait in seconds\n")
2271 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2274 /* Update-delay deconfiguration */
2275 DEFPY (no_bgp_update_delay
,
2276 no_bgp_update_delay_cmd
,
2277 "no update-delay [(0-3600) [(1-3600)]]",
2279 "Force initial delay for best-path and updates\n"
2280 "Max delay in seconds\n"
2281 "Establish wait in seconds\n")
2283 return bgp_update_delay_deconfig_vty(vty
);
2287 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2290 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2292 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2293 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2298 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2301 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2303 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2304 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2309 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2312 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2313 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2314 vty_out(vty
, " write-quanta %d\n", quanta
);
2317 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2320 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2321 if (quanta
!= BGP_READ_PACKET_MAX
)
2322 vty_out(vty
, " read-quanta %d\n", quanta
);
2325 /* Packet quanta configuration
2327 * XXX: The value set here controls the size of a stack buffer in the IO
2328 * thread. When changing these limits be careful to prevent stack overflow.
2330 * Furthermore, the maximums used here should correspond to
2331 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2333 DEFPY (bgp_wpkt_quanta
,
2334 bgp_wpkt_quanta_cmd
,
2335 "[no] write-quanta (1-64)$quanta",
2337 "How many packets to write to peer socket per run\n"
2338 "Number of packets\n")
2340 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
2343 DEFPY (bgp_rpkt_quanta
,
2344 bgp_rpkt_quanta_cmd
,
2345 "[no] read-quanta (1-10)$quanta",
2347 "How many packets to read from peer socket per I/O cycle\n"
2348 "Number of packets\n")
2350 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
2353 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2355 if (!bgp
->heuristic_coalesce
)
2356 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2359 /* BGP TCP keepalive */
2360 static void bgp_config_tcp_keepalive(struct vty
*vty
, struct bgp
*bgp
)
2362 if (bgp
->tcp_keepalive_idle
) {
2363 vty_out(vty
, " bgp tcp-keepalive %u %u %u\n",
2364 bgp
->tcp_keepalive_idle
, bgp
->tcp_keepalive_intvl
,
2365 bgp
->tcp_keepalive_probes
);
2369 DEFUN (bgp_coalesce_time
,
2370 bgp_coalesce_time_cmd
,
2371 "coalesce-time (0-4294967295)",
2372 "Subgroup coalesce timer\n"
2373 "Subgroup coalesce timer value (in ms)\n")
2375 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2379 bgp
->heuristic_coalesce
= false;
2381 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2382 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2387 DEFUN (no_bgp_coalesce_time
,
2388 no_bgp_coalesce_time_cmd
,
2389 "no coalesce-time (0-4294967295)",
2391 "Subgroup coalesce timer\n"
2392 "Subgroup coalesce timer value (in ms)\n")
2394 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2396 bgp
->heuristic_coalesce
= true;
2397 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
2401 /* Maximum-paths configuration */
2402 DEFUN (bgp_maxpaths
,
2404 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2405 "Forward packets over multiple paths\n"
2406 "Number of paths\n")
2409 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
2410 argv
[idx_number
]->arg
, 0, 1);
2413 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2414 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2415 "Forward packets over multiple paths\n"
2416 "Number of paths\n")
2418 DEFUN (bgp_maxpaths_ibgp
,
2419 bgp_maxpaths_ibgp_cmd
,
2420 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2421 "Forward packets over multiple paths\n"
2423 "Number of paths\n")
2426 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2427 argv
[idx_number
]->arg
, 0, 1);
2430 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2431 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2432 "Forward packets over multiple paths\n"
2434 "Number of paths\n")
2436 DEFUN (bgp_maxpaths_ibgp_cluster
,
2437 bgp_maxpaths_ibgp_cluster_cmd
,
2438 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2439 "Forward packets over multiple paths\n"
2442 "Match the cluster length\n")
2445 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2446 argv
[idx_number
]->arg
, true, 1);
2449 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2450 "maximum-paths ibgp " CMD_RANGE_STR(
2451 1, MULTIPATH_NUM
) " equal-cluster-length",
2452 "Forward packets over multiple paths\n"
2455 "Match the cluster length\n")
2457 DEFUN (no_bgp_maxpaths
,
2458 no_bgp_maxpaths_cmd
,
2459 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2461 "Forward packets over multiple paths\n"
2462 "Number of paths\n")
2464 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
2467 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2468 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2469 "Forward packets over multiple paths\n"
2470 "Number of paths\n")
2472 DEFUN (no_bgp_maxpaths_ibgp
,
2473 no_bgp_maxpaths_ibgp_cmd
,
2474 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2476 "Forward packets over multiple paths\n"
2479 "Match the cluster length\n")
2481 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
2484 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2485 "no maximum-paths ibgp [" CMD_RANGE_STR(
2486 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2488 "Forward packets over multiple paths\n"
2491 "Match the cluster length\n")
2493 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2494 afi_t afi
, safi_t safi
)
2496 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2497 vty_out(vty
, " maximum-paths %d\n",
2498 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2501 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2502 vty_out(vty
, " maximum-paths ibgp %d",
2503 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2504 if (bgp
->maxpaths
[afi
][safi
].same_clusterlen
)
2505 vty_out(vty
, " equal-cluster-length");
2514 "timers bgp (0-65535) (0-65535)",
2515 "Adjust routing timers\n"
2517 "Keepalive interval\n"
2520 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2522 int idx_number_2
= 3;
2523 unsigned long keepalive
= 0;
2524 unsigned long holdtime
= 0;
2526 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2527 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2529 /* Holdtime value check. */
2530 if (holdtime
< 3 && holdtime
!= 0) {
2532 "%% hold time value must be either 0 or greater than 3\n");
2533 return CMD_WARNING_CONFIG_FAILED
;
2536 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
,
2537 BGP_DEFAULT_DELAYOPEN
);
2542 DEFUN (no_bgp_timers
,
2544 "no timers bgp [(0-65535) (0-65535)]",
2546 "Adjust routing timers\n"
2548 "Keepalive interval\n"
2551 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2552 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
2553 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
2558 /* BGP minimum holdtime. */
2560 DEFUN(bgp_minimum_holdtime
, bgp_minimum_holdtime_cmd
,
2561 "bgp minimum-holdtime (1-65535)",
2562 "BGP specific commands\n"
2563 "BGP minimum holdtime\n"
2566 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2568 unsigned long min_holdtime
;
2570 min_holdtime
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2572 bgp
->default_min_holdtime
= min_holdtime
;
2577 DEFUN(no_bgp_minimum_holdtime
, no_bgp_minimum_holdtime_cmd
,
2578 "no bgp minimum-holdtime [(1-65535)]",
2580 "BGP specific commands\n"
2581 "BGP minimum holdtime\n"
2584 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2586 bgp
->default_min_holdtime
= 0;
2591 DEFPY(bgp_tcp_keepalive
, bgp_tcp_keepalive_cmd
,
2592 "bgp tcp-keepalive (1-65535)$idle (1-65535)$intvl (1-30)$probes",
2594 "TCP keepalive parameters\n"
2595 "TCP keepalive idle time (seconds)\n"
2596 "TCP keepalive interval (seconds)\n"
2597 "TCP keepalive maximum probes\n")
2599 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2601 bgp_tcp_keepalive_set(bgp
, (uint16_t)idle
, (uint16_t)intvl
,
2607 DEFPY(no_bgp_tcp_keepalive
, no_bgp_tcp_keepalive_cmd
,
2608 "no bgp tcp-keepalive [(1-65535) (1-65535) (1-30)]",
2611 "TCP keepalive parameters\n"
2612 "TCP keepalive idle time (seconds)\n"
2613 "TCP keepalive interval (seconds)\n"
2614 "TCP keepalive maximum probes\n")
2616 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2618 bgp_tcp_keepalive_unset(bgp
);
2623 DEFUN (bgp_client_to_client_reflection
,
2624 bgp_client_to_client_reflection_cmd
,
2625 "bgp client-to-client reflection",
2627 "Configure client to client route reflection\n"
2628 "reflection of routes allowed\n")
2630 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2631 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2632 bgp_clear_star_soft_out(vty
, bgp
->name
);
2637 DEFUN (no_bgp_client_to_client_reflection
,
2638 no_bgp_client_to_client_reflection_cmd
,
2639 "no bgp client-to-client reflection",
2642 "Configure client to client route reflection\n"
2643 "reflection of routes allowed\n")
2645 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2646 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2647 bgp_clear_star_soft_out(vty
, bgp
->name
);
2652 /* "bgp always-compare-med" configuration. */
2653 DEFUN (bgp_always_compare_med
,
2654 bgp_always_compare_med_cmd
,
2655 "bgp always-compare-med",
2657 "Allow comparing MED from different neighbors\n")
2659 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2660 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2661 bgp_recalculate_all_bestpaths(bgp
);
2666 DEFUN (no_bgp_always_compare_med
,
2667 no_bgp_always_compare_med_cmd
,
2668 "no bgp always-compare-med",
2671 "Allow comparing MED from different neighbors\n")
2673 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2674 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2675 bgp_recalculate_all_bestpaths(bgp
);
2681 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2682 "bgp ebgp-requires-policy",
2684 "Require in and out policy for eBGP peers (RFC8212)\n")
2686 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2687 SET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2691 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2692 "no bgp ebgp-requires-policy",
2695 "Require in and out policy for eBGP peers (RFC8212)\n")
2697 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2698 UNSET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2702 DEFUN(bgp_suppress_duplicates
, bgp_suppress_duplicates_cmd
,
2703 "bgp suppress-duplicates",
2705 "Suppress duplicate updates if the route actually not changed\n")
2707 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2708 SET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2712 DEFUN(no_bgp_suppress_duplicates
, no_bgp_suppress_duplicates_cmd
,
2713 "no bgp suppress-duplicates",
2716 "Suppress duplicate updates if the route actually not changed\n")
2718 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2719 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2723 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2724 "bgp reject-as-sets",
2726 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2728 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2729 struct listnode
*node
, *nnode
;
2732 bgp
->reject_as_sets
= true;
2734 /* Reset existing BGP sessions to reject routes
2735 * with aspath containing AS_SET or AS_CONFED_SET.
2737 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2738 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2739 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2740 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2741 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2748 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2749 "no bgp reject-as-sets",
2752 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2754 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2755 struct listnode
*node
, *nnode
;
2758 bgp
->reject_as_sets
= false;
2760 /* Reset existing BGP sessions to reject routes
2761 * with aspath containing AS_SET or AS_CONFED_SET.
2763 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2764 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2765 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2766 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2767 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2774 /* "bgp deterministic-med" configuration. */
2775 DEFUN (bgp_deterministic_med
,
2776 bgp_deterministic_med_cmd
,
2777 "bgp deterministic-med",
2779 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2781 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2783 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2784 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2785 bgp_recalculate_all_bestpaths(bgp
);
2791 DEFUN (no_bgp_deterministic_med
,
2792 no_bgp_deterministic_med_cmd
,
2793 "no bgp deterministic-med",
2796 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2798 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2799 int bestpath_per_as_used
;
2803 struct listnode
*node
, *nnode
;
2805 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2806 bestpath_per_as_used
= 0;
2808 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2809 FOREACH_AFI_SAFI (afi
, safi
)
2810 if (bgp_addpath_dmed_required(
2811 peer
->addpath_type
[afi
][safi
])) {
2812 bestpath_per_as_used
= 1;
2816 if (bestpath_per_as_used
)
2820 if (bestpath_per_as_used
) {
2822 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2823 return CMD_WARNING_CONFIG_FAILED
;
2825 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2826 bgp_recalculate_all_bestpaths(bgp
);
2833 /* "bgp graceful-restart mode" configuration. */
2834 DEFUN (bgp_graceful_restart
,
2835 bgp_graceful_restart_cmd
,
2836 "bgp graceful-restart",
2841 int ret
= BGP_GR_FAILURE
;
2843 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2844 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2846 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2848 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2850 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2853 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2854 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2856 "Graceful restart configuration changed, reset all peers to take effect\n");
2857 return bgp_vty_return(vty
, ret
);
2860 DEFUN (no_bgp_graceful_restart
,
2861 no_bgp_graceful_restart_cmd
,
2862 "no bgp graceful-restart",
2868 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2870 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2871 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2873 int ret
= BGP_GR_FAILURE
;
2875 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2877 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2880 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2881 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2883 "Graceful restart configuration changed, reset all peers to take effect\n");
2885 return bgp_vty_return(vty
, ret
);
2888 DEFUN (bgp_graceful_restart_stalepath_time
,
2889 bgp_graceful_restart_stalepath_time_cmd
,
2890 "bgp graceful-restart stalepath-time (1-4095)",
2892 "Graceful restart capability parameters\n"
2893 "Set the max time to hold onto restarting peer's stale paths\n"
2894 "Delay value (seconds)\n")
2896 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2900 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2901 bgp
->stalepath_time
= stalepath
;
2905 DEFUN (bgp_graceful_restart_restart_time
,
2906 bgp_graceful_restart_restart_time_cmd
,
2907 "bgp graceful-restart restart-time (0-4095)",
2909 "Graceful restart capability parameters\n"
2910 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2911 "Delay value (seconds)\n")
2913 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2917 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2918 bgp
->restart_time
= restart
;
2922 DEFUN (bgp_graceful_restart_select_defer_time
,
2923 bgp_graceful_restart_select_defer_time_cmd
,
2924 "bgp graceful-restart select-defer-time (0-3600)",
2926 "Graceful restart capability parameters\n"
2927 "Set the time to defer the BGP route selection after restart\n"
2928 "Delay value (seconds, 0 - disable)\n")
2930 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2932 uint32_t defer_time
;
2934 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2935 bgp
->select_defer_time
= defer_time
;
2936 if (defer_time
== 0)
2937 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2939 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2944 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2945 no_bgp_graceful_restart_stalepath_time_cmd
,
2946 "no bgp graceful-restart stalepath-time [(1-4095)]",
2949 "Graceful restart capability parameters\n"
2950 "Set the max time to hold onto restarting peer's stale paths\n"
2951 "Delay value (seconds)\n")
2953 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2955 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2959 DEFUN (no_bgp_graceful_restart_restart_time
,
2960 no_bgp_graceful_restart_restart_time_cmd
,
2961 "no bgp graceful-restart restart-time [(0-4095)]",
2964 "Graceful restart capability parameters\n"
2965 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2966 "Delay value (seconds)\n")
2968 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2970 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2974 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2975 no_bgp_graceful_restart_select_defer_time_cmd
,
2976 "no bgp graceful-restart select-defer-time [(0-3600)]",
2979 "Graceful restart capability parameters\n"
2980 "Set the time to defer the BGP route selection after restart\n"
2981 "Delay value (seconds)\n")
2983 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2985 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2986 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2991 DEFUN (bgp_graceful_restart_preserve_fw
,
2992 bgp_graceful_restart_preserve_fw_cmd
,
2993 "bgp graceful-restart preserve-fw-state",
2995 "Graceful restart capability parameters\n"
2996 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2998 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2999 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
3003 DEFUN (no_bgp_graceful_restart_preserve_fw
,
3004 no_bgp_graceful_restart_preserve_fw_cmd
,
3005 "no bgp graceful-restart preserve-fw-state",
3008 "Graceful restart capability parameters\n"
3009 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
3011 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3012 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
3016 DEFPY (bgp_graceful_restart_notification
,
3017 bgp_graceful_restart_notification_cmd
,
3018 "[no$no] bgp graceful-restart notification",
3021 "Graceful restart capability parameters\n"
3022 "Indicate Graceful Restart support for BGP NOTIFICATION messages\n")
3024 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3027 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3029 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3034 DEFPY (bgp_administrative_reset
,
3035 bgp_administrative_reset_cmd
,
3036 "[no$no] bgp hard-administrative-reset",
3039 "Send Hard Reset CEASE Notification for 'Administrative Reset'\n")
3041 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3044 UNSET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3046 SET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3051 DEFUN (bgp_graceful_restart_disable
,
3052 bgp_graceful_restart_disable_cmd
,
3053 "bgp graceful-restart-disable",
3057 int ret
= BGP_GR_FAILURE
;
3059 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3061 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
3063 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3065 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
3067 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
3070 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3072 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
3074 "Graceful restart configuration changed, reset all peers to take effect\n");
3076 return bgp_vty_return(vty
, ret
);
3079 DEFUN (no_bgp_graceful_restart_disable
,
3080 no_bgp_graceful_restart_disable_cmd
,
3081 "no bgp graceful-restart-disable",
3087 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3089 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3091 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
3093 int ret
= BGP_GR_FAILURE
;
3095 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
3097 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
3100 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3102 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
3104 "Graceful restart configuration changed, reset all peers to take effect\n");
3106 return bgp_vty_return(vty
, ret
);
3109 DEFUN (bgp_neighbor_graceful_restart_set
,
3110 bgp_neighbor_graceful_restart_set_cmd
,
3111 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3119 int ret
= BGP_GR_FAILURE
;
3121 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3123 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3125 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
3127 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3129 return CMD_WARNING_CONFIG_FAILED
;
3131 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
3133 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3134 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3136 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3138 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
3140 "Graceful restart configuration changed, reset this peer to take effect\n");
3142 return bgp_vty_return(vty
, ret
);
3145 DEFUN (no_bgp_neighbor_graceful_restart
,
3146 no_bgp_neighbor_graceful_restart_set_cmd
,
3147 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3155 int ret
= BGP_GR_FAILURE
;
3158 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3160 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3162 return CMD_WARNING_CONFIG_FAILED
;
3164 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3166 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3168 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
3170 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3171 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3173 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3175 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3177 "Graceful restart configuration changed, reset this peer to take effect\n");
3179 return bgp_vty_return(vty
, ret
);
3182 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3183 bgp_neighbor_graceful_restart_helper_set_cmd
,
3184 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3187 GR_NEIGHBOR_HELPER_CMD
3192 int ret
= BGP_GR_FAILURE
;
3194 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3196 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3198 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3200 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3203 return CMD_WARNING_CONFIG_FAILED
;
3206 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3208 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3209 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3211 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3213 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3215 "Graceful restart configuration changed, reset this peer to take effect\n");
3217 return bgp_vty_return(vty
, ret
);
3220 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3221 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3222 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3226 NO_GR_NEIGHBOR_HELPER_CMD
3230 int ret
= BGP_GR_FAILURE
;
3233 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3235 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3237 return CMD_WARNING_CONFIG_FAILED
;
3239 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3241 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3243 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3245 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3246 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3248 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3250 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3252 "Graceful restart configuration changed, reset this peer to take effect\n");
3254 return bgp_vty_return(vty
, ret
);
3257 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3258 bgp_neighbor_graceful_restart_disable_set_cmd
,
3259 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3262 GR_NEIGHBOR_DISABLE_CMD
3267 int ret
= BGP_GR_FAILURE
;
3269 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3271 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3273 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3275 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3277 return CMD_WARNING_CONFIG_FAILED
;
3279 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3281 if (peer
->bgp
->t_startup
)
3282 bgp_peer_gr_flags_update(peer
);
3284 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3285 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3287 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3289 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3291 "Graceful restart configuration changed, reset this peer to take effect\n");
3293 return bgp_vty_return(vty
, ret
);
3296 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3297 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3298 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3302 NO_GR_NEIGHBOR_DISABLE_CMD
3306 int ret
= BGP_GR_FAILURE
;
3309 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3311 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3313 return CMD_WARNING_CONFIG_FAILED
;
3315 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3317 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3319 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3321 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3322 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3324 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3326 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3328 "Graceful restart configuration changed, reset this peer to take effect\n");
3330 return bgp_vty_return(vty
, ret
);
3333 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3334 bgp_graceful_restart_disable_eor_cmd
,
3335 "bgp graceful-restart disable-eor",
3337 "Graceful restart configuration parameters\n"
3338 "Disable EOR Check\n")
3340 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3341 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3346 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3347 no_bgp_graceful_restart_disable_eor_cmd
,
3348 "no bgp graceful-restart disable-eor",
3351 "Graceful restart configuration parameters\n"
3352 "Disable EOR Check\n")
3354 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3355 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3360 DEFUN (bgp_graceful_restart_rib_stale_time
,
3361 bgp_graceful_restart_rib_stale_time_cmd
,
3362 "bgp graceful-restart rib-stale-time (1-3600)",
3364 "Graceful restart configuration parameters\n"
3365 "Specify the stale route removal timer in rib\n"
3366 "Delay value (seconds)\n")
3368 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3370 uint32_t stale_time
;
3372 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3373 bgp
->rib_stale_time
= stale_time
;
3374 /* Send the stale timer update message to RIB */
3375 if (bgp_zebra_stale_timer_update(bgp
))
3381 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3382 no_bgp_graceful_restart_rib_stale_time_cmd
,
3383 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3386 "Graceful restart configuration parameters\n"
3387 "Specify the stale route removal timer in rib\n"
3388 "Delay value (seconds)\n")
3390 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3392 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3393 /* Send the stale timer update message to RIB */
3394 if (bgp_zebra_stale_timer_update(bgp
))
3400 DEFUN(bgp_llgr_stalepath_time
, bgp_llgr_stalepath_time_cmd
,
3401 "bgp long-lived-graceful-restart stale-time (1-4294967295)",
3403 "Enable Long-lived Graceful Restart\n"
3404 "Specifies maximum time to wait before purging long-lived stale routes\n"
3405 "Stale time value (seconds)\n")
3407 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3409 uint32_t llgr_stale_time
;
3411 llgr_stale_time
= strtoul(argv
[3]->arg
, NULL
, 10);
3412 bgp
->llgr_stale_time
= llgr_stale_time
;
3417 DEFUN(no_bgp_llgr_stalepath_time
, no_bgp_llgr_stalepath_time_cmd
,
3418 "no bgp long-lived-graceful-restart stale-time [(1-4294967295)]",
3420 "Enable Long-lived Graceful Restart\n"
3421 "Specifies maximum time to wait before purging long-lived stale routes\n"
3422 "Stale time value (seconds)\n")
3424 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3426 bgp
->llgr_stale_time
= BGP_DEFAULT_LLGR_STALE_TIME
;
3431 static inline void bgp_initiate_graceful_shut_unshut(struct vty
*vty
,
3434 bgp_static_redo_import_check(bgp
);
3435 bgp_redistribute_redo(bgp
);
3436 bgp_clear_star_soft_out(vty
, bgp
->name
);
3437 bgp_clear_star_soft_in(vty
, bgp
->name
);
3440 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3442 struct listnode
*node
, *nnode
;
3444 bool vrf_cfg
= false;
3446 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3449 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3450 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3451 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3453 "%% graceful-shutdown configuration found in vrf %s\n",
3454 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3455 VRF_DEFAULT_NAME
: bgp
->name
);
3462 "%%Failed: global graceful-shutdown not permitted\n");
3466 /* Set flag globally */
3467 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3469 /* Initiate processing for all BGP instances. */
3470 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3471 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3476 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3478 struct listnode
*node
, *nnode
;
3481 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3484 /* Unset flag globally */
3485 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3487 /* Initiate processing for all BGP instances. */
3488 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3489 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3494 /* "bgp graceful-shutdown" configuration */
3495 DEFUN (bgp_graceful_shutdown
,
3496 bgp_graceful_shutdown_cmd
,
3497 "bgp graceful-shutdown",
3499 "Graceful shutdown parameters\n")
3501 if (vty
->node
== CONFIG_NODE
)
3502 return bgp_global_graceful_shutdown_config_vty(vty
);
3504 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3506 /* if configured globally, per-instance config is not allowed */
3507 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3509 "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n");
3510 return CMD_WARNING_CONFIG_FAILED
;
3513 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3514 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3515 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3521 DEFUN (no_bgp_graceful_shutdown
,
3522 no_bgp_graceful_shutdown_cmd
,
3523 "no bgp graceful-shutdown",
3526 "Graceful shutdown parameters\n")
3528 if (vty
->node
== CONFIG_NODE
)
3529 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3531 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3533 /* If configured globally, cannot remove from one bgp instance */
3534 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3536 "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n");
3537 return CMD_WARNING_CONFIG_FAILED
;
3540 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3541 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3542 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3548 /* "bgp fast-external-failover" configuration. */
3549 DEFUN (bgp_fast_external_failover
,
3550 bgp_fast_external_failover_cmd
,
3551 "bgp fast-external-failover",
3553 "Immediately reset session if a link to a directly connected external peer goes down\n")
3555 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3556 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3560 DEFUN (no_bgp_fast_external_failover
,
3561 no_bgp_fast_external_failover_cmd
,
3562 "no bgp fast-external-failover",
3565 "Immediately reset session if a link to a directly connected external peer goes down\n")
3567 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3568 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3572 /* "bgp bestpath compare-routerid" configuration. */
3573 DEFUN (bgp_bestpath_compare_router_id
,
3574 bgp_bestpath_compare_router_id_cmd
,
3575 "bgp bestpath compare-routerid",
3577 "Change the default bestpath selection\n"
3578 "Compare router-id for identical EBGP paths\n")
3580 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3581 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3582 bgp_recalculate_all_bestpaths(bgp
);
3587 DEFUN (no_bgp_bestpath_compare_router_id
,
3588 no_bgp_bestpath_compare_router_id_cmd
,
3589 "no bgp bestpath compare-routerid",
3592 "Change the default bestpath selection\n"
3593 "Compare router-id for identical EBGP paths\n")
3595 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3596 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3597 bgp_recalculate_all_bestpaths(bgp
);
3602 /* "bgp bestpath as-path ignore" configuration. */
3603 DEFUN (bgp_bestpath_aspath_ignore
,
3604 bgp_bestpath_aspath_ignore_cmd
,
3605 "bgp bestpath as-path ignore",
3607 "Change the default bestpath selection\n"
3608 "AS-path attribute\n"
3609 "Ignore as-path length in selecting a route\n")
3611 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3612 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3613 bgp_recalculate_all_bestpaths(bgp
);
3618 DEFUN (no_bgp_bestpath_aspath_ignore
,
3619 no_bgp_bestpath_aspath_ignore_cmd
,
3620 "no bgp bestpath as-path ignore",
3623 "Change the default bestpath selection\n"
3624 "AS-path attribute\n"
3625 "Ignore as-path length in selecting a route\n")
3627 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3628 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3629 bgp_recalculate_all_bestpaths(bgp
);
3634 /* "bgp bestpath as-path confed" configuration. */
3635 DEFUN (bgp_bestpath_aspath_confed
,
3636 bgp_bestpath_aspath_confed_cmd
,
3637 "bgp bestpath as-path confed",
3639 "Change the default bestpath selection\n"
3640 "AS-path attribute\n"
3641 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3643 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3644 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3645 bgp_recalculate_all_bestpaths(bgp
);
3650 DEFUN (no_bgp_bestpath_aspath_confed
,
3651 no_bgp_bestpath_aspath_confed_cmd
,
3652 "no bgp bestpath as-path confed",
3655 "Change the default bestpath selection\n"
3656 "AS-path attribute\n"
3657 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3659 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3660 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3661 bgp_recalculate_all_bestpaths(bgp
);
3666 /* "bgp bestpath as-path multipath-relax" configuration. */
3667 DEFUN (bgp_bestpath_aspath_multipath_relax
,
3668 bgp_bestpath_aspath_multipath_relax_cmd
,
3669 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3671 "Change the default bestpath selection\n"
3672 "AS-path attribute\n"
3673 "Allow load sharing across routes that have different AS paths (but same length)\n"
3674 "Generate an AS_SET\n"
3675 "Do not generate an AS_SET\n")
3677 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3679 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3681 /* no-as-set is now the default behavior so we can silently
3683 if (argv_find(argv
, argc
, "as-set", &idx
))
3684 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3686 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3688 bgp_recalculate_all_bestpaths(bgp
);
3693 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
3694 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3695 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3698 "Change the default bestpath selection\n"
3699 "AS-path attribute\n"
3700 "Allow load sharing across routes that have different AS paths (but same length)\n"
3701 "Generate an AS_SET\n"
3702 "Do not generate an AS_SET\n")
3704 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3705 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3706 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3707 bgp_recalculate_all_bestpaths(bgp
);
3712 /* "bgp bestpath peer-type multipath-relax" configuration. */
3713 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3714 bgp_bestpath_peer_type_multipath_relax_cmd
,
3715 "bgp bestpath peer-type multipath-relax",
3717 "Change the default bestpath selection\n"
3719 "Allow load sharing across routes learned from different peer types\n")
3721 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3722 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3723 bgp_recalculate_all_bestpaths(bgp
);
3728 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3729 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3730 "no bgp bestpath peer-type multipath-relax",
3732 "Change the default bestpath selection\n"
3734 "Allow load sharing across routes learned from different peer types\n")
3736 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3737 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3738 bgp_recalculate_all_bestpaths(bgp
);
3743 /* "bgp log-neighbor-changes" configuration. */
3744 DEFUN (bgp_log_neighbor_changes
,
3745 bgp_log_neighbor_changes_cmd
,
3746 "bgp log-neighbor-changes",
3748 "Log neighbor up/down and reset reason\n")
3750 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3751 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3755 DEFUN (no_bgp_log_neighbor_changes
,
3756 no_bgp_log_neighbor_changes_cmd
,
3757 "no bgp log-neighbor-changes",
3760 "Log neighbor up/down and reset reason\n")
3762 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3763 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3767 /* "bgp bestpath med" configuration. */
3768 DEFUN (bgp_bestpath_med
,
3769 bgp_bestpath_med_cmd
,
3770 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3772 "Change the default bestpath selection\n"
3774 "Compare MED among confederation paths\n"
3775 "Treat missing MED as the least preferred one\n"
3776 "Treat missing MED as the least preferred one\n"
3777 "Compare MED among confederation paths\n")
3779 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3782 if (argv_find(argv
, argc
, "confed", &idx
))
3783 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3785 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3786 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3788 bgp_recalculate_all_bestpaths(bgp
);
3793 DEFUN (no_bgp_bestpath_med
,
3794 no_bgp_bestpath_med_cmd
,
3795 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3798 "Change the default bestpath selection\n"
3800 "Compare MED among confederation paths\n"
3801 "Treat missing MED as the least preferred one\n"
3802 "Treat missing MED as the least preferred one\n"
3803 "Compare MED among confederation paths\n")
3805 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3808 if (argv_find(argv
, argc
, "confed", &idx
))
3809 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3811 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3812 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3814 bgp_recalculate_all_bestpaths(bgp
);
3819 /* "bgp bestpath bandwidth" configuration. */
3820 DEFPY (bgp_bestpath_bw
,
3821 bgp_bestpath_bw_cmd
,
3822 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3824 "Change the default bestpath selection\n"
3825 "Link Bandwidth attribute\n"
3826 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3827 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3828 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3830 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3835 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3836 return CMD_ERR_INCOMPLETE
;
3838 if (!strcmp(bw_cfg
, "ignore"))
3839 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3840 else if (!strcmp(bw_cfg
, "skip-missing"))
3841 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3842 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3843 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3845 return CMD_ERR_NO_MATCH
;
3847 /* This config is used in route install, so redo that. */
3848 FOREACH_AFI_SAFI (afi
, safi
) {
3849 if (!bgp_fibupd_safi(safi
))
3851 bgp_zebra_announce_table(bgp
, afi
, safi
);
3857 DEFPY (no_bgp_bestpath_bw
,
3858 no_bgp_bestpath_bw_cmd
,
3859 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3862 "Change the default bestpath selection\n"
3863 "Link Bandwidth attribute\n"
3864 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3865 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3866 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3868 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3872 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3874 /* This config is used in route install, so redo that. */
3875 FOREACH_AFI_SAFI (afi
, safi
) {
3876 if (!bgp_fibupd_safi(safi
))
3878 bgp_zebra_announce_table(bgp
, afi
, safi
);
3883 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
3884 "[no] bgp default <ipv4-unicast|"
3887 "ipv4-labeled-unicast|"
3892 "ipv6-labeled-unicast|"
3894 "l2vpn-evpn>$afi_safi",
3897 "Configure BGP defaults\n"
3898 "Activate ipv4-unicast for a peer by default\n"
3899 "Activate ipv4-multicast for a peer by default\n"
3900 "Activate ipv4-vpn for a peer by default\n"
3901 "Activate ipv4-labeled-unicast for a peer by default\n"
3902 "Activate ipv4-flowspec for a peer by default\n"
3903 "Activate ipv6-unicast for a peer by default\n"
3904 "Activate ipv6-multicast for a peer by default\n"
3905 "Activate ipv6-vpn for a peer by default\n"
3906 "Activate ipv6-labeled-unicast for a peer by default\n"
3907 "Activate ipv6-flowspec for a peer by default\n"
3908 "Activate l2vpn-evpn for a peer by default\n")
3910 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3911 char afi_safi_str
[strlen(afi_safi
) + 1];
3912 char *afi_safi_str_tok
;
3914 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
3915 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
3916 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
3917 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
3921 * Impossible situation but making coverity happy
3923 assert(afi
!= AFI_MAX
);
3925 if (strmatch(safi_str
, "labeled"))
3926 safi
= bgp_vty_safi_from_str("labeled-unicast");
3928 safi
= bgp_vty_safi_from_str(safi_str
);
3930 assert(safi
!= SAFI_MAX
);
3932 bgp
->default_af
[afi
][safi
] = false;
3934 if ((safi
== SAFI_LABELED_UNICAST
3935 && bgp
->default_af
[afi
][SAFI_UNICAST
])
3936 || (safi
== SAFI_UNICAST
3937 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
3938 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
3940 bgp
->default_af
[afi
][safi
] = true;
3946 /* Display hostname in certain command outputs */
3947 DEFUN (bgp_default_show_hostname
,
3948 bgp_default_show_hostname_cmd
,
3949 "bgp default show-hostname",
3951 "Configure BGP defaults\n"
3952 "Show hostname in certain command outputs\n")
3954 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3955 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3959 DEFUN (no_bgp_default_show_hostname
,
3960 no_bgp_default_show_hostname_cmd
,
3961 "no bgp default show-hostname",
3964 "Configure BGP defaults\n"
3965 "Show hostname in certain command outputs\n")
3967 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3968 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3972 /* Display hostname in certain command outputs */
3973 DEFUN (bgp_default_show_nexthop_hostname
,
3974 bgp_default_show_nexthop_hostname_cmd
,
3975 "bgp default show-nexthop-hostname",
3977 "Configure BGP defaults\n"
3978 "Show hostname for nexthop in certain command outputs\n")
3980 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3981 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3985 DEFUN (no_bgp_default_show_nexthop_hostname
,
3986 no_bgp_default_show_nexthop_hostname_cmd
,
3987 "no bgp default show-nexthop-hostname",
3990 "Configure BGP defaults\n"
3991 "Show hostname for nexthop in certain command outputs\n")
3993 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3994 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3998 /* "bgp network import-check" configuration. */
3999 DEFUN (bgp_network_import_check
,
4000 bgp_network_import_check_cmd
,
4001 "bgp network import-check",
4003 "BGP network command\n"
4004 "Check BGP network route exists in IGP\n")
4006 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4007 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4008 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4009 bgp_static_redo_import_check(bgp
);
4015 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
4016 "bgp network import-check exact",
4018 "BGP network command\n"
4019 "Check BGP network route exists in IGP\n"
4020 "Match route precisely\n")
4022 DEFUN (no_bgp_network_import_check
,
4023 no_bgp_network_import_check_cmd
,
4024 "no bgp network import-check",
4027 "BGP network command\n"
4028 "Check BGP network route exists in IGP\n")
4030 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4031 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4032 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4033 bgp_static_redo_import_check(bgp
);
4039 DEFUN (bgp_default_local_preference
,
4040 bgp_default_local_preference_cmd
,
4041 "bgp default local-preference (0-4294967295)",
4043 "Configure BGP defaults\n"
4044 "local preference (higher=more preferred)\n"
4045 "Configure default local preference value\n")
4047 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4049 uint32_t local_pref
;
4051 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4053 bgp_default_local_preference_set(bgp
, local_pref
);
4054 bgp_clear_star_soft_in(vty
, bgp
->name
);
4059 DEFUN (no_bgp_default_local_preference
,
4060 no_bgp_default_local_preference_cmd
,
4061 "no bgp default local-preference [(0-4294967295)]",
4064 "Configure BGP defaults\n"
4065 "local preference (higher=more preferred)\n"
4066 "Configure default local preference value\n")
4068 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4069 bgp_default_local_preference_unset(bgp
);
4070 bgp_clear_star_soft_in(vty
, bgp
->name
);
4076 DEFUN (bgp_default_subgroup_pkt_queue_max
,
4077 bgp_default_subgroup_pkt_queue_max_cmd
,
4078 "bgp default subgroup-pkt-queue-max (20-100)",
4080 "Configure BGP defaults\n"
4081 "subgroup-pkt-queue-max\n"
4082 "Configure subgroup packet queue max\n")
4084 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4088 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4090 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
4095 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
4096 no_bgp_default_subgroup_pkt_queue_max_cmd
,
4097 "no bgp default subgroup-pkt-queue-max [(20-100)]",
4100 "Configure BGP defaults\n"
4101 "subgroup-pkt-queue-max\n"
4102 "Configure subgroup packet queue max\n")
4104 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4105 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
4110 DEFUN (bgp_rr_allow_outbound_policy
,
4111 bgp_rr_allow_outbound_policy_cmd
,
4112 "bgp route-reflector allow-outbound-policy",
4114 "Allow modifications made by out route-map\n"
4115 "on ibgp neighbors\n")
4117 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4119 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4120 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4121 update_group_announce_rrclients(bgp
);
4122 bgp_clear_star_soft_out(vty
, bgp
->name
);
4128 DEFUN (no_bgp_rr_allow_outbound_policy
,
4129 no_bgp_rr_allow_outbound_policy_cmd
,
4130 "no bgp route-reflector allow-outbound-policy",
4133 "Allow modifications made by out route-map\n"
4134 "on ibgp neighbors\n")
4136 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4138 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4139 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4140 update_group_announce_rrclients(bgp
);
4141 bgp_clear_star_soft_out(vty
, bgp
->name
);
4147 DEFUN (bgp_listen_limit
,
4148 bgp_listen_limit_cmd
,
4149 "bgp listen limit (1-65535)",
4151 "BGP Dynamic Neighbors listen commands\n"
4152 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4153 "Configure Dynamic Neighbors listen limit value\n")
4155 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4159 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4161 bgp_listen_limit_set(bgp
, listen_limit
);
4166 DEFUN (no_bgp_listen_limit
,
4167 no_bgp_listen_limit_cmd
,
4168 "no bgp listen limit [(1-65535)]",
4171 "BGP Dynamic Neighbors listen commands\n"
4172 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4173 "Configure Dynamic Neighbors listen limit value\n")
4175 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4176 bgp_listen_limit_unset(bgp
);
4182 * Check if this listen range is already configured. Check for exact
4183 * match or overlap based on input.
4185 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4186 struct prefix
*range
, int exact
)
4188 struct listnode
*node
, *nnode
;
4189 struct listnode
*node1
, *nnode1
;
4190 struct peer_group
*group
;
4195 afi
= family2afi(range
->family
);
4196 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4197 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4200 match
= prefix_same(range
, lr
);
4202 match
= (prefix_match(range
, lr
)
4203 || prefix_match(lr
, range
));
4212 DEFUN (bgp_listen_range
,
4213 bgp_listen_range_cmd
,
4214 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4216 "Configure BGP dynamic neighbors listen range\n"
4217 "Configure BGP dynamic neighbors listen range\n"
4219 "Member of the peer-group\n"
4220 "Peer-group name\n")
4222 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4223 struct prefix range
;
4224 struct peer_group
*group
, *existing_group
;
4229 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4230 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4231 char *prefix
= argv
[idx
]->arg
;
4232 argv_find(argv
, argc
, "PGNAME", &idx
);
4233 char *peergroup
= argv
[idx
]->arg
;
4235 /* Convert IP prefix string to struct prefix. */
4236 ret
= str2prefix(prefix
, &range
);
4238 vty_out(vty
, "%% Malformed listen range\n");
4239 return CMD_WARNING_CONFIG_FAILED
;
4242 afi
= family2afi(range
.family
);
4244 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4246 "%% Malformed listen range (link-local address)\n");
4247 return CMD_WARNING_CONFIG_FAILED
;
4252 /* Check if same listen range is already configured. */
4253 existing_group
= listen_range_exists(bgp
, &range
, 1);
4254 if (existing_group
) {
4255 if (strcmp(existing_group
->name
, peergroup
) == 0)
4259 "%% Same listen range is attached to peer-group %s\n",
4260 existing_group
->name
);
4261 return CMD_WARNING_CONFIG_FAILED
;
4265 /* Check if an overlapping listen range exists. */
4266 if (listen_range_exists(bgp
, &range
, 0)) {
4268 "%% Listen range overlaps with existing listen range\n");
4269 return CMD_WARNING_CONFIG_FAILED
;
4272 group
= peer_group_lookup(bgp
, peergroup
);
4274 vty_out(vty
, "%% Configure the peer-group first\n");
4275 return CMD_WARNING_CONFIG_FAILED
;
4278 ret
= peer_group_listen_range_add(group
, &range
);
4279 return bgp_vty_return(vty
, ret
);
4282 DEFUN (no_bgp_listen_range
,
4283 no_bgp_listen_range_cmd
,
4284 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4287 "Unconfigure BGP dynamic neighbors listen range\n"
4288 "Unconfigure BGP dynamic neighbors listen range\n"
4290 "Member of the peer-group\n"
4291 "Peer-group name\n")
4293 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4294 struct prefix range
;
4295 struct peer_group
*group
;
4300 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4301 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4302 char *prefix
= argv
[idx
]->arg
;
4303 argv_find(argv
, argc
, "PGNAME", &idx
);
4304 char *peergroup
= argv
[idx
]->arg
;
4306 /* Convert IP prefix string to struct prefix. */
4307 ret
= str2prefix(prefix
, &range
);
4309 vty_out(vty
, "%% Malformed listen range\n");
4310 return CMD_WARNING_CONFIG_FAILED
;
4313 afi
= family2afi(range
.family
);
4315 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4317 "%% Malformed listen range (link-local address)\n");
4318 return CMD_WARNING_CONFIG_FAILED
;
4323 group
= peer_group_lookup(bgp
, peergroup
);
4325 vty_out(vty
, "%% Peer-group does not exist\n");
4326 return CMD_WARNING_CONFIG_FAILED
;
4329 ret
= peer_group_listen_range_del(group
, &range
);
4330 return bgp_vty_return(vty
, ret
);
4333 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4335 struct peer_group
*group
;
4336 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4337 struct prefix
*range
;
4340 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4341 vty_out(vty
, " bgp listen limit %d\n",
4342 bgp
->dynamic_neighbors_limit
);
4344 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4345 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4346 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4349 " bgp listen range %pFX peer-group %s\n",
4350 range
, group
->name
);
4357 DEFUN (bgp_disable_connected_route_check
,
4358 bgp_disable_connected_route_check_cmd
,
4359 "bgp disable-ebgp-connected-route-check",
4361 "Disable checking if nexthop is connected on ebgp sessions\n")
4363 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4364 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4365 bgp_clear_star_soft_in(vty
, bgp
->name
);
4370 DEFUN (no_bgp_disable_connected_route_check
,
4371 no_bgp_disable_connected_route_check_cmd
,
4372 "no bgp disable-ebgp-connected-route-check",
4375 "Disable checking if nexthop is connected on ebgp sessions\n")
4377 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4378 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4379 bgp_clear_star_soft_in(vty
, bgp
->name
);
4385 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
4388 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4391 int as_type
= AS_SPECIFIED
;
4394 if (as_str
[0] == 'i') {
4396 as_type
= AS_INTERNAL
;
4397 } else if (as_str
[0] == 'e') {
4399 as_type
= AS_EXTERNAL
;
4401 /* Get AS number. */
4402 as
= strtoul(as_str
, NULL
, 10);
4405 /* If peer is peer group or interface peer, call proper function. */
4406 ret
= str2sockunion(peer_str
, &su
);
4410 /* Check if existing interface peer */
4411 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
4413 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
);
4415 /* if not interface peer, check peer-group settings */
4416 if (ret
< 0 && !peer
) {
4417 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
4420 "%% Create the peer-group or interface first\n");
4421 return CMD_WARNING_CONFIG_FAILED
;
4426 if (peer_address_self_check(bgp
, &su
)) {
4428 "%% Can not configure the local system as neighbor\n");
4429 return CMD_WARNING_CONFIG_FAILED
;
4431 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
);
4434 return bgp_vty_return(vty
, ret
);
4437 DEFUN (bgp_default_shutdown
,
4438 bgp_default_shutdown_cmd
,
4439 "[no] bgp default shutdown",
4442 "Configure BGP defaults\n"
4443 "Apply administrative shutdown to newly configured peers\n")
4445 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4446 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
4450 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4452 "Administrative shutdown of the BGP instance\n"
4453 "Add a shutdown message (RFC 8203)\n"
4454 "Shutdown message\n")
4456 char *msgstr
= NULL
;
4458 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4461 msgstr
= argv_concat(argv
, argc
, 3);
4463 if (msgstr
&& strlen(msgstr
) > BGP_ADMIN_SHUTDOWN_MSG_LEN
) {
4464 vty_out(vty
, "%% Shutdown message size exceeded %d\n",
4465 BGP_ADMIN_SHUTDOWN_MSG_LEN
);
4466 return CMD_WARNING_CONFIG_FAILED
;
4469 bgp_shutdown_enable(bgp
, msgstr
);
4470 XFREE(MTYPE_TMP
, msgstr
);
4475 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4476 BGP_STR
"Administrative shutdown of the BGP instance\n")
4478 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4480 bgp_shutdown_enable(bgp
, NULL
);
4485 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4486 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4488 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4490 bgp_shutdown_disable(bgp
);
4495 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4496 "no bgp shutdown message MSG...", NO_STR BGP_STR
4497 "Administrative shutdown of the BGP instance\n"
4498 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4500 DEFUN (neighbor_remote_as
,
4501 neighbor_remote_as_cmd
,
4502 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4505 "Specify a BGP neighbor\n"
4507 "Internal BGP peer\n"
4508 "External BGP peer\n")
4511 int idx_remote_as
= 3;
4512 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
4513 argv
[idx_remote_as
]->arg
);
4516 DEFPY (bgp_allow_martian
,
4517 bgp_allow_martian_cmd
,
4518 "[no]$no bgp allow-martian-nexthop",
4521 "Allow Martian nexthops to be received in the NLRI from a peer\n")
4523 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4526 bgp
->allow_martian
= false;
4528 bgp
->allow_martian
= true;
4533 /* Enable fast convergence of bgp sessions. If this is enabled, bgp
4534 * sessions do not wait for hold timer expiry to bring down the sessions
4535 * when nexthop becomes unreachable
4537 DEFUN(bgp_fast_convergence
, bgp_fast_convergence_cmd
, "bgp fast-convergence",
4538 BGP_STR
"Fast convergence for bgp sessions\n")
4540 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4541 bgp
->fast_convergence
= true;
4546 DEFUN(no_bgp_fast_convergence
, no_bgp_fast_convergence_cmd
,
4547 "no bgp fast-convergence",
4548 NO_STR BGP_STR
"Fast convergence for bgp sessions\n")
4550 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4551 bgp
->fast_convergence
= false;
4556 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
4558 const char *peer_group_name
,
4561 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4563 int as_type
= AS_UNSPECIFIED
;
4565 struct peer_group
*group
;
4568 group
= peer_group_lookup(bgp
, conf_if
);
4571 vty_out(vty
, "%% Name conflict with peer-group \n");
4572 return CMD_WARNING_CONFIG_FAILED
;
4576 if (as_str
[0] == 'i') {
4577 as_type
= AS_INTERNAL
;
4578 } else if (as_str
[0] == 'e') {
4579 as_type
= AS_EXTERNAL
;
4581 /* Get AS number. */
4582 as
= strtoul(as_str
, NULL
, 10);
4583 as_type
= AS_SPECIFIED
;
4587 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4590 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4592 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4596 vty_out(vty
, "%% BGP failed to create peer\n");
4597 return CMD_WARNING_CONFIG_FAILED
;
4601 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4603 /* Request zebra to initiate IPv6 RAs on this interface. We do
4605 * any unnumbered peer in order to not worry about run-time
4607 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4609 * gets deleted later etc.)
4612 bgp_zebra_initiate_radv(bgp
, peer
);
4615 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4616 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4618 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4620 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4622 /* v6only flag changed. Reset bgp seesion */
4623 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4624 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4625 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4626 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4628 bgp_session_reset(peer
);
4631 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4632 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4633 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4634 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4637 if (peer_group_name
) {
4638 group
= peer_group_lookup(bgp
, peer_group_name
);
4640 vty_out(vty
, "%% Configure the peer-group first\n");
4641 return CMD_WARNING_CONFIG_FAILED
;
4644 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4647 return bgp_vty_return(vty
, ret
);
4650 DEFUN (neighbor_interface_config
,
4651 neighbor_interface_config_cmd
,
4652 "neighbor WORD interface [peer-group PGNAME]",
4654 "Interface name or neighbor tag\n"
4655 "Enable BGP on interface\n"
4656 "Member of the peer-group\n"
4657 "Peer-group name\n")
4660 int idx_peer_group_word
= 4;
4662 if (argc
> idx_peer_group_word
)
4663 return peer_conf_interface_get(
4664 vty
, argv
[idx_word
]->arg
, 0,
4665 argv
[idx_peer_group_word
]->arg
, NULL
);
4667 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0,
4671 DEFUN (neighbor_interface_config_v6only
,
4672 neighbor_interface_config_v6only_cmd
,
4673 "neighbor WORD interface v6only [peer-group PGNAME]",
4675 "Interface name or neighbor tag\n"
4676 "Enable BGP on interface\n"
4677 "Enable BGP with v6 link-local only\n"
4678 "Member of the peer-group\n"
4679 "Peer-group name\n")
4682 int idx_peer_group_word
= 5;
4684 if (argc
> idx_peer_group_word
)
4685 return peer_conf_interface_get(
4686 vty
, argv
[idx_word
]->arg
, 1,
4687 argv
[idx_peer_group_word
]->arg
, NULL
);
4689 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
, NULL
);
4693 DEFUN (neighbor_interface_config_remote_as
,
4694 neighbor_interface_config_remote_as_cmd
,
4695 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4697 "Interface name or neighbor tag\n"
4698 "Enable BGP on interface\n"
4699 "Specify a BGP neighbor\n"
4701 "Internal BGP peer\n"
4702 "External BGP peer\n")
4705 int idx_remote_as
= 4;
4706 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0, NULL
,
4707 argv
[idx_remote_as
]->arg
);
4710 DEFUN (neighbor_interface_v6only_config_remote_as
,
4711 neighbor_interface_v6only_config_remote_as_cmd
,
4712 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4714 "Interface name or neighbor tag\n"
4715 "Enable BGP with v6 link-local only\n"
4716 "Enable BGP on interface\n"
4717 "Specify a BGP neighbor\n"
4719 "Internal BGP peer\n"
4720 "External BGP peer\n")
4723 int idx_remote_as
= 5;
4724 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
,
4725 argv
[idx_remote_as
]->arg
);
4728 DEFUN (neighbor_peer_group
,
4729 neighbor_peer_group_cmd
,
4730 "neighbor WORD peer-group",
4732 "Interface name or neighbor tag\n"
4733 "Configure peer-group\n")
4735 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4738 struct peer_group
*group
;
4740 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4742 vty_out(vty
, "%% Name conflict with interface: \n");
4743 return CMD_WARNING_CONFIG_FAILED
;
4746 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
4748 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
4749 return CMD_WARNING_CONFIG_FAILED
;
4757 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4761 "Specify a BGP neighbor\n"
4763 "Internal BGP peer\n"
4764 "External BGP peer\n")
4766 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4770 struct peer_group
*group
;
4774 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4776 /* look up for neighbor by interface name config. */
4777 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4779 /* Request zebra to terminate IPv6 RAs on this
4782 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4783 peer_notify_unconfig(peer
);
4788 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
4790 peer_group_notify_unconfig(group
);
4791 peer_group_delete(group
);
4793 vty_out(vty
, "%% Create the peer-group first\n");
4794 return CMD_WARNING_CONFIG_FAILED
;
4797 peer
= peer_lookup(bgp
, &su
);
4799 if (peer_dynamic_neighbor(peer
)) {
4801 "%% Operation not allowed on a dynamic neighbor\n");
4802 return CMD_WARNING_CONFIG_FAILED
;
4805 other
= peer
->doppelganger
;
4807 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4808 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4810 peer_notify_unconfig(peer
);
4812 if (other
&& other
->status
!= Deleted
) {
4813 peer_notify_unconfig(other
);
4822 DEFUN (no_neighbor_interface_config
,
4823 no_neighbor_interface_config_cmd
,
4824 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4828 "Configure BGP on interface\n"
4829 "Enable BGP with v6 link-local only\n"
4830 "Member of the peer-group\n"
4832 "Specify a BGP neighbor\n"
4834 "Internal BGP peer\n"
4835 "External BGP peer\n")
4837 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4841 /* look up for neighbor by interface name config. */
4842 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4844 /* Request zebra to terminate IPv6 RAs on this interface. */
4846 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4847 peer_notify_unconfig(peer
);
4850 vty_out(vty
, "%% Create the bgp interface first\n");
4851 return CMD_WARNING_CONFIG_FAILED
;
4856 DEFUN (no_neighbor_peer_group
,
4857 no_neighbor_peer_group_cmd
,
4858 "no neighbor WORD peer-group",
4862 "Configure peer-group\n")
4864 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4866 struct peer_group
*group
;
4868 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4870 peer_group_notify_unconfig(group
);
4871 peer_group_delete(group
);
4873 vty_out(vty
, "%% Create the peer-group first\n");
4874 return CMD_WARNING_CONFIG_FAILED
;
4879 DEFUN (no_neighbor_interface_peer_group_remote_as
,
4880 no_neighbor_interface_peer_group_remote_as_cmd
,
4881 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4884 "Interface name or neighbor tag\n"
4885 "Specify a BGP neighbor\n"
4887 "Internal BGP peer\n"
4888 "External BGP peer\n")
4890 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4892 struct peer_group
*group
;
4895 /* look up for neighbor by interface name config. */
4896 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4898 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
4902 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4904 peer_group_remote_as_delete(group
);
4906 vty_out(vty
, "%% Create the peer-group or interface first\n");
4907 return CMD_WARNING_CONFIG_FAILED
;
4912 DEFUN (neighbor_local_as
,
4913 neighbor_local_as_cmd
,
4914 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4917 "Specify a local-as number\n"
4918 "AS number used as local AS\n")
4926 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4928 return CMD_WARNING_CONFIG_FAILED
;
4930 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4931 ret
= peer_local_as_set(peer
, as
, 0, 0);
4932 return bgp_vty_return(vty
, ret
);
4935 DEFUN (neighbor_local_as_no_prepend
,
4936 neighbor_local_as_no_prepend_cmd
,
4937 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4940 "Specify a local-as number\n"
4941 "AS number used as local AS\n"
4942 "Do not prepend local-as to updates from ebgp peers\n")
4950 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4952 return CMD_WARNING_CONFIG_FAILED
;
4954 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4955 ret
= peer_local_as_set(peer
, as
, 1, 0);
4956 return bgp_vty_return(vty
, ret
);
4959 DEFUN (neighbor_local_as_no_prepend_replace_as
,
4960 neighbor_local_as_no_prepend_replace_as_cmd
,
4961 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4964 "Specify a local-as number\n"
4965 "AS number used as local AS\n"
4966 "Do not prepend local-as to updates from ebgp peers\n"
4967 "Do not prepend local-as to updates from ibgp peers\n")
4975 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4977 return CMD_WARNING_CONFIG_FAILED
;
4979 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4980 ret
= peer_local_as_set(peer
, as
, 1, 1);
4981 return bgp_vty_return(vty
, ret
);
4984 DEFUN (no_neighbor_local_as
,
4985 no_neighbor_local_as_cmd
,
4986 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4990 "Specify a local-as number\n"
4991 "AS number used as local AS\n"
4992 "Do not prepend local-as to updates from ebgp peers\n"
4993 "Do not prepend local-as to updates from ibgp peers\n")
4999 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5001 return CMD_WARNING_CONFIG_FAILED
;
5003 ret
= peer_local_as_unset(peer
);
5004 return bgp_vty_return(vty
, ret
);
5008 DEFUN (neighbor_solo
,
5010 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5013 "Solo peer - part of its own update group\n")
5019 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5021 return CMD_WARNING_CONFIG_FAILED
;
5023 ret
= update_group_adjust_soloness(peer
, 1);
5024 return bgp_vty_return(vty
, ret
);
5027 DEFUN (no_neighbor_solo
,
5028 no_neighbor_solo_cmd
,
5029 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5033 "Solo peer - part of its own update group\n")
5039 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5041 return CMD_WARNING_CONFIG_FAILED
;
5043 ret
= update_group_adjust_soloness(peer
, 0);
5044 return bgp_vty_return(vty
, ret
);
5047 DEFUN (neighbor_password
,
5048 neighbor_password_cmd
,
5049 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
5060 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5062 return CMD_WARNING_CONFIG_FAILED
;
5064 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
5065 return bgp_vty_return(vty
, ret
);
5068 DEFUN (no_neighbor_password
,
5069 no_neighbor_password_cmd
,
5070 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
5081 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5083 return CMD_WARNING_CONFIG_FAILED
;
5085 ret
= peer_password_unset(peer
);
5086 return bgp_vty_return(vty
, ret
);
5089 DEFUN (neighbor_activate
,
5090 neighbor_activate_cmd
,
5091 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5094 "Enable the Address Family for this Neighbor\n")
5100 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5102 return CMD_WARNING_CONFIG_FAILED
;
5104 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5105 return bgp_vty_return(vty
, ret
);
5108 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
5109 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5110 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5111 "Enable the Address Family for this Neighbor\n")
5113 DEFUN (no_neighbor_activate
,
5114 no_neighbor_activate_cmd
,
5115 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5119 "Enable the Address Family for this Neighbor\n")
5126 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5128 return CMD_WARNING_CONFIG_FAILED
;
5130 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5131 return bgp_vty_return(vty
, ret
);
5134 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
5135 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5136 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5137 "Enable the Address Family for this Neighbor\n")
5139 DEFUN (neighbor_set_peer_group
,
5140 neighbor_set_peer_group_cmd
,
5141 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5144 "Member of the peer-group\n"
5145 "Peer-group name\n")
5147 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5154 struct peer_group
*group
;
5156 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
5158 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
5160 vty_out(vty
, "%% Malformed address or name: %s\n",
5161 argv
[idx_peer
]->arg
);
5162 return CMD_WARNING_CONFIG_FAILED
;
5165 if (peer_address_self_check(bgp
, &su
)) {
5167 "%% Can not configure the local system as neighbor\n");
5168 return CMD_WARNING_CONFIG_FAILED
;
5171 /* Disallow for dynamic neighbor. */
5172 peer
= peer_lookup(bgp
, &su
);
5173 if (peer
&& peer_dynamic_neighbor(peer
)) {
5175 "%% Operation not allowed on a dynamic neighbor\n");
5176 return CMD_WARNING_CONFIG_FAILED
;
5180 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5182 vty_out(vty
, "%% Configure the peer-group first\n");
5183 return CMD_WARNING_CONFIG_FAILED
;
5186 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5188 return bgp_vty_return(vty
, ret
);
5191 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5192 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5193 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5194 "Member of the peer-group\n"
5195 "Peer-group name\n")
5197 DEFUN (no_neighbor_set_peer_group
,
5198 no_neighbor_set_peer_group_cmd
,
5199 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5203 "Member of the peer-group\n"
5204 "Peer-group name\n")
5206 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5211 struct peer_group
*group
;
5213 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5215 return CMD_WARNING_CONFIG_FAILED
;
5217 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5219 vty_out(vty
, "%% Configure the peer-group first\n");
5220 return CMD_WARNING_CONFIG_FAILED
;
5223 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
5224 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
5226 peer_notify_unconfig(peer
);
5227 ret
= peer_delete(peer
);
5229 return bgp_vty_return(vty
, ret
);
5232 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5233 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5234 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5235 "Member of the peer-group\n"
5236 "Peer-group name\n")
5238 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
5239 uint64_t flag
, int set
)
5244 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5246 return CMD_WARNING_CONFIG_FAILED
;
5249 * If 'neighbor <interface>', then this is for directly connected peers,
5250 * we should not accept disable-connected-check.
5252 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5254 "%s is directly connected peer, cannot accept disable-connected-check\n",
5256 return CMD_WARNING_CONFIG_FAILED
;
5259 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5260 peer_tx_shutdown_message_unset(peer
);
5263 ret
= peer_flag_set(peer
, flag
);
5265 ret
= peer_flag_unset(peer
, flag
);
5267 return bgp_vty_return(vty
, ret
);
5270 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint64_t flag
)
5272 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
5275 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
5278 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
5281 /* neighbor passive. */
5282 DEFUN (neighbor_passive
,
5283 neighbor_passive_cmd
,
5284 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5287 "Don't send open messages to this neighbor\n")
5290 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5293 DEFUN (no_neighbor_passive
,
5294 no_neighbor_passive_cmd
,
5295 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5299 "Don't send open messages to this neighbor\n")
5302 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5305 /* neighbor shutdown. */
5306 DEFUN (neighbor_shutdown_msg
,
5307 neighbor_shutdown_msg_cmd
,
5308 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5311 "Administratively shut down this neighbor\n"
5312 "Add a shutdown message (RFC 8203)\n"
5313 "Shutdown message\n")
5319 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5323 return CMD_WARNING_CONFIG_FAILED
;
5324 message
= argv_concat(argv
, argc
, 4);
5325 peer_tx_shutdown_message_set(peer
, message
);
5326 XFREE(MTYPE_TMP
, message
);
5329 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
5332 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5333 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5334 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5335 "Administratively shut down this neighbor\n")
5337 DEFUN (no_neighbor_shutdown_msg
,
5338 no_neighbor_shutdown_msg_cmd
,
5339 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5343 "Administratively shut down this neighbor\n"
5344 "Remove a shutdown message (RFC 8203)\n"
5345 "Shutdown message\n")
5349 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5350 PEER_FLAG_SHUTDOWN
);
5353 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5354 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5355 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5356 "Administratively shut down this neighbor\n")
5358 DEFUN(neighbor_shutdown_rtt
,
5359 neighbor_shutdown_rtt_cmd
,
5360 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5363 "Administratively shut down this neighbor\n"
5364 "Shutdown if round-trip-time is higher than expected\n"
5365 "Round-trip-time in milliseconds\n"
5366 "Specify the number of keepalives before shutdown\n"
5367 "The number of keepalives with higher RTT to shutdown\n")
5374 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5377 return CMD_WARNING_CONFIG_FAILED
;
5379 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5381 if (argv_find(argv
, argc
, "count", &idx_count
))
5382 peer
->rtt_keepalive_conf
=
5383 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5385 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5386 PEER_FLAG_RTT_SHUTDOWN
);
5389 DEFUN(no_neighbor_shutdown_rtt
,
5390 no_neighbor_shutdown_rtt_cmd
,
5391 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5395 "Administratively shut down this neighbor\n"
5396 "Shutdown if round-trip-time is higher than expected\n"
5397 "Round-trip-time in milliseconds\n"
5398 "Specify the number of keepalives before shutdown\n"
5399 "The number of keepalives with higher RTT to shutdown\n")
5404 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5407 return CMD_WARNING_CONFIG_FAILED
;
5409 peer
->rtt_expected
= 0;
5410 peer
->rtt_keepalive_conf
= 1;
5412 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5413 PEER_FLAG_RTT_SHUTDOWN
);
5416 /* neighbor capability dynamic. */
5417 DEFUN (neighbor_capability_dynamic
,
5418 neighbor_capability_dynamic_cmd
,
5419 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5422 "Advertise capability to the peer\n"
5423 "Advertise dynamic capability to this neighbor\n")
5426 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5427 PEER_FLAG_DYNAMIC_CAPABILITY
);
5430 DEFUN (no_neighbor_capability_dynamic
,
5431 no_neighbor_capability_dynamic_cmd
,
5432 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5436 "Advertise capability to the peer\n"
5437 "Advertise dynamic capability to this neighbor\n")
5440 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5441 PEER_FLAG_DYNAMIC_CAPABILITY
);
5444 /* neighbor dont-capability-negotiate */
5445 DEFUN (neighbor_dont_capability_negotiate
,
5446 neighbor_dont_capability_negotiate_cmd
,
5447 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5450 "Do not perform capability negotiation\n")
5453 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5454 PEER_FLAG_DONT_CAPABILITY
);
5457 DEFUN (no_neighbor_dont_capability_negotiate
,
5458 no_neighbor_dont_capability_negotiate_cmd
,
5459 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5463 "Do not perform capability negotiation\n")
5466 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5467 PEER_FLAG_DONT_CAPABILITY
);
5470 /* neighbor capability extended next hop encoding */
5471 DEFUN (neighbor_capability_enhe
,
5472 neighbor_capability_enhe_cmd
,
5473 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5476 "Advertise capability to the peer\n"
5477 "Advertise extended next-hop capability to the peer\n")
5482 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5483 if (peer
&& peer
->conf_if
)
5486 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5487 PEER_FLAG_CAPABILITY_ENHE
);
5490 DEFUN (no_neighbor_capability_enhe
,
5491 no_neighbor_capability_enhe_cmd
,
5492 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5496 "Advertise capability to the peer\n"
5497 "Advertise extended next-hop capability to the peer\n")
5502 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5503 if (peer
&& peer
->conf_if
) {
5505 "Peer %s cannot have capability extended-nexthop turned off\n",
5506 argv
[idx_peer
]->arg
);
5507 return CMD_WARNING_CONFIG_FAILED
;
5510 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5511 PEER_FLAG_CAPABILITY_ENHE
);
5514 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5515 afi_t afi
, safi_t safi
, uint32_t flag
,
5521 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5523 return CMD_WARNING_CONFIG_FAILED
;
5526 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5528 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5530 return bgp_vty_return(vty
, ret
);
5533 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5534 afi_t afi
, safi_t safi
, uint32_t flag
)
5536 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5539 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5540 afi_t afi
, safi_t safi
, uint32_t flag
)
5542 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5545 /* neighbor capability orf prefix-list. */
5546 DEFUN (neighbor_capability_orf_prefix
,
5547 neighbor_capability_orf_prefix_cmd
,
5548 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5551 "Advertise capability to the peer\n"
5552 "Advertise ORF capability to the peer\n"
5553 "Advertise prefixlist ORF capability to this neighbor\n"
5554 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5555 "Capability to RECEIVE the ORF from this neighbor\n"
5556 "Capability to SEND the ORF to this neighbor\n")
5558 int idx_send_recv
= 5;
5559 char *peer_str
= argv
[1]->arg
;
5561 afi_t afi
= bgp_node_afi(vty
);
5562 safi_t safi
= bgp_node_safi(vty
);
5564 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5566 return CMD_WARNING_CONFIG_FAILED
;
5568 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5569 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5570 PEER_FLAG_ORF_PREFIX_SM
);
5572 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5573 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5574 PEER_FLAG_ORF_PREFIX_RM
);
5576 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5577 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5578 PEER_FLAG_ORF_PREFIX_SM
)
5579 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5580 PEER_FLAG_ORF_PREFIX_RM
);
5582 return CMD_WARNING_CONFIG_FAILED
;
5586 neighbor_capability_orf_prefix
,
5587 neighbor_capability_orf_prefix_hidden_cmd
,
5588 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5589 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5590 "Advertise capability to the peer\n"
5591 "Advertise ORF capability to the peer\n"
5592 "Advertise prefixlist ORF capability to this neighbor\n"
5593 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5594 "Capability to RECEIVE the ORF from this neighbor\n"
5595 "Capability to SEND the ORF to this neighbor\n")
5597 DEFUN (no_neighbor_capability_orf_prefix
,
5598 no_neighbor_capability_orf_prefix_cmd
,
5599 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5603 "Advertise capability to the peer\n"
5604 "Advertise ORF capability to the peer\n"
5605 "Advertise prefixlist ORF capability to this neighbor\n"
5606 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5607 "Capability to RECEIVE the ORF from this neighbor\n"
5608 "Capability to SEND the ORF to this neighbor\n")
5610 int idx_send_recv
= 6;
5611 char *peer_str
= argv
[2]->arg
;
5613 afi_t afi
= bgp_node_afi(vty
);
5614 safi_t safi
= bgp_node_safi(vty
);
5616 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5618 return CMD_WARNING_CONFIG_FAILED
;
5620 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5621 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5622 PEER_FLAG_ORF_PREFIX_SM
);
5624 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5625 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5626 PEER_FLAG_ORF_PREFIX_RM
);
5628 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5629 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5630 PEER_FLAG_ORF_PREFIX_SM
)
5631 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5632 PEER_FLAG_ORF_PREFIX_RM
);
5634 return CMD_WARNING_CONFIG_FAILED
;
5638 no_neighbor_capability_orf_prefix
,
5639 no_neighbor_capability_orf_prefix_hidden_cmd
,
5640 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5641 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5642 "Advertise capability to the peer\n"
5643 "Advertise ORF capability to the peer\n"
5644 "Advertise prefixlist ORF capability to this neighbor\n"
5645 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5646 "Capability to RECEIVE the ORF from this neighbor\n"
5647 "Capability to SEND the ORF to this neighbor\n")
5649 /* neighbor next-hop-self. */
5650 DEFUN (neighbor_nexthop_self
,
5651 neighbor_nexthop_self_cmd
,
5652 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5655 "Disable the next hop calculation for this neighbor\n")
5658 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5659 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
5662 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5663 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5664 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5665 "Disable the next hop calculation for this neighbor\n")
5667 /* neighbor next-hop-self. */
5668 DEFUN (neighbor_nexthop_self_force
,
5669 neighbor_nexthop_self_force_cmd
,
5670 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5673 "Disable the next hop calculation for this neighbor\n"
5674 "Set the next hop to self for reflected routes\n")
5677 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5679 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5682 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5683 neighbor_nexthop_self_force_hidden_cmd
,
5684 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5685 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5686 "Disable the next hop calculation for this neighbor\n"
5687 "Set the next hop to self for reflected routes\n")
5689 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5690 neighbor_nexthop_self_all_hidden_cmd
,
5691 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5692 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5693 "Disable the next hop calculation for this neighbor\n"
5694 "Set the next hop to self for reflected routes\n")
5696 DEFUN (no_neighbor_nexthop_self
,
5697 no_neighbor_nexthop_self_cmd
,
5698 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5702 "Disable the next hop calculation for this neighbor\n")
5705 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5706 bgp_node_afi(vty
), bgp_node_safi(vty
),
5707 PEER_FLAG_NEXTHOP_SELF
);
5710 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5711 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5712 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5713 "Disable the next hop calculation for this neighbor\n")
5715 DEFUN (no_neighbor_nexthop_self_force
,
5716 no_neighbor_nexthop_self_force_cmd
,
5717 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5721 "Disable the next hop calculation for this neighbor\n"
5722 "Set the next hop to self for reflected routes\n")
5725 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5726 bgp_node_afi(vty
), bgp_node_safi(vty
),
5727 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5730 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5731 no_neighbor_nexthop_self_force_hidden_cmd
,
5732 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5733 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5734 "Disable the next hop calculation for this neighbor\n"
5735 "Set the next hop to self for reflected routes\n")
5737 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5738 no_neighbor_nexthop_self_all_hidden_cmd
,
5739 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5740 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5741 "Disable the next hop calculation for this neighbor\n"
5742 "Set the next hop to self for reflected routes\n")
5744 /* neighbor as-override */
5745 DEFUN (neighbor_as_override
,
5746 neighbor_as_override_cmd
,
5747 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5750 "Override ASNs in outbound updates if aspath equals remote-as\n")
5753 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5754 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
5757 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5758 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5759 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5760 "Override ASNs in outbound updates if aspath equals remote-as\n")
5762 DEFUN (no_neighbor_as_override
,
5763 no_neighbor_as_override_cmd
,
5764 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5768 "Override ASNs in outbound updates if aspath equals remote-as\n")
5771 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5772 bgp_node_afi(vty
), bgp_node_safi(vty
),
5773 PEER_FLAG_AS_OVERRIDE
);
5776 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5777 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5778 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5779 "Override ASNs in outbound updates if aspath equals remote-as\n")
5781 /* neighbor remove-private-AS. */
5782 DEFUN (neighbor_remove_private_as
,
5783 neighbor_remove_private_as_cmd
,
5784 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5787 "Remove private ASNs in outbound updates\n")
5790 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5792 PEER_FLAG_REMOVE_PRIVATE_AS
);
5795 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5796 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5797 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5798 "Remove private ASNs in outbound updates\n")
5800 DEFUN (neighbor_remove_private_as_all
,
5801 neighbor_remove_private_as_all_cmd
,
5802 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5805 "Remove private ASNs in outbound updates\n"
5806 "Apply to all AS numbers\n")
5809 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5811 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5814 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5815 neighbor_remove_private_as_all_hidden_cmd
,
5816 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5817 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5818 "Remove private ASNs in outbound updates\n"
5819 "Apply to all AS numbers\n")
5821 DEFUN (neighbor_remove_private_as_replace_as
,
5822 neighbor_remove_private_as_replace_as_cmd
,
5823 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5826 "Remove private ASNs in outbound updates\n"
5827 "Replace private ASNs with our ASN in outbound updates\n")
5830 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5832 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5835 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5836 neighbor_remove_private_as_replace_as_hidden_cmd
,
5837 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5838 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5839 "Remove private ASNs in outbound updates\n"
5840 "Replace private ASNs with our ASN in outbound updates\n")
5842 DEFUN (neighbor_remove_private_as_all_replace_as
,
5843 neighbor_remove_private_as_all_replace_as_cmd
,
5844 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5847 "Remove private ASNs in outbound updates\n"
5848 "Apply to all AS numbers\n"
5849 "Replace private ASNs with our ASN in outbound updates\n")
5852 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5854 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5858 neighbor_remove_private_as_all_replace_as
,
5859 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5860 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5861 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5862 "Remove private ASNs in outbound updates\n"
5863 "Apply to all AS numbers\n"
5864 "Replace private ASNs with our ASN in outbound updates\n")
5866 DEFUN (no_neighbor_remove_private_as
,
5867 no_neighbor_remove_private_as_cmd
,
5868 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5872 "Remove private ASNs in outbound updates\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_REMOVE_PRIVATE_AS
);
5880 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5881 no_neighbor_remove_private_as_hidden_cmd
,
5882 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5883 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5884 "Remove private ASNs in outbound updates\n")
5886 DEFUN (no_neighbor_remove_private_as_all
,
5887 no_neighbor_remove_private_as_all_cmd
,
5888 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5892 "Remove private ASNs in outbound updates\n"
5893 "Apply to all AS numbers\n")
5896 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5897 bgp_node_afi(vty
), bgp_node_safi(vty
),
5898 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5901 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5902 no_neighbor_remove_private_as_all_hidden_cmd
,
5903 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5904 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5905 "Remove private ASNs in outbound updates\n"
5906 "Apply to all AS numbers\n")
5908 DEFUN (no_neighbor_remove_private_as_replace_as
,
5909 no_neighbor_remove_private_as_replace_as_cmd
,
5910 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5914 "Remove private ASNs in outbound updates\n"
5915 "Replace private ASNs with our ASN in outbound updates\n")
5918 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5919 bgp_node_afi(vty
), bgp_node_safi(vty
),
5920 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5923 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
5924 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
5925 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5926 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5927 "Remove private ASNs in outbound updates\n"
5928 "Replace private ASNs with our ASN in outbound updates\n")
5930 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
5931 no_neighbor_remove_private_as_all_replace_as_cmd
,
5932 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5936 "Remove private ASNs in outbound updates\n"
5937 "Apply to all AS numbers\n"
5938 "Replace private ASNs with our ASN in outbound updates\n")
5941 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5942 bgp_node_afi(vty
), bgp_node_safi(vty
),
5943 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5947 no_neighbor_remove_private_as_all_replace_as
,
5948 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5949 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5950 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5951 "Remove private ASNs in outbound updates\n"
5952 "Apply to all AS numbers\n"
5953 "Replace private ASNs with our ASN in outbound updates\n")
5956 /* neighbor send-community. */
5957 DEFUN (neighbor_send_community
,
5958 neighbor_send_community_cmd
,
5959 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5962 "Send Community attribute to this neighbor\n")
5966 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5968 PEER_FLAG_SEND_COMMUNITY
);
5971 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
5972 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5973 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5974 "Send Community attribute to this neighbor\n")
5976 DEFUN (no_neighbor_send_community
,
5977 no_neighbor_send_community_cmd
,
5978 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5982 "Send Community attribute to this neighbor\n")
5986 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5987 bgp_node_afi(vty
), bgp_node_safi(vty
),
5988 PEER_FLAG_SEND_COMMUNITY
);
5991 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
5992 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5993 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5994 "Send Community attribute to this neighbor\n")
5996 /* neighbor send-community extended. */
5997 DEFUN (neighbor_send_community_type
,
5998 neighbor_send_community_type_cmd
,
5999 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6002 "Send Community attribute to this neighbor\n"
6003 "Send Standard and Extended Community attributes\n"
6004 "Send Standard, Large and Extended Community attributes\n"
6005 "Send Extended Community attributes\n"
6006 "Send Standard Community attributes\n"
6007 "Send Large Community attributes\n")
6009 const char *type
= argv
[argc
- 1]->text
;
6010 char *peer_str
= argv
[1]->arg
;
6012 afi_t afi
= bgp_node_afi(vty
);
6013 safi_t safi
= bgp_node_safi(vty
);
6015 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6017 return CMD_WARNING_CONFIG_FAILED
;
6019 if (strmatch(type
, "standard"))
6020 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6021 PEER_FLAG_SEND_COMMUNITY
);
6023 if (strmatch(type
, "extended"))
6024 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6025 PEER_FLAG_SEND_EXT_COMMUNITY
);
6027 if (strmatch(type
, "large"))
6028 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6029 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6031 if (strmatch(type
, "both")) {
6032 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6033 PEER_FLAG_SEND_COMMUNITY
)
6034 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6035 PEER_FLAG_SEND_EXT_COMMUNITY
);
6037 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6038 PEER_FLAG_SEND_COMMUNITY
)
6039 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6040 PEER_FLAG_SEND_EXT_COMMUNITY
)
6041 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6042 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6046 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6047 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6048 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6049 "Send Community attribute to this neighbor\n"
6050 "Send Standard and Extended Community attributes\n"
6051 "Send Standard, Large and Extended Community attributes\n"
6052 "Send Extended Community attributes\n"
6053 "Send Standard Community attributes\n"
6054 "Send Large Community attributes\n")
6056 DEFUN (no_neighbor_send_community_type
,
6057 no_neighbor_send_community_type_cmd
,
6058 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6062 "Send Community attribute to this neighbor\n"
6063 "Send Standard and Extended Community attributes\n"
6064 "Send Standard, Large and Extended Community attributes\n"
6065 "Send Extended Community attributes\n"
6066 "Send Standard Community attributes\n"
6067 "Send Large Community attributes\n")
6069 const char *type
= argv
[argc
- 1]->text
;
6070 char *peer_str
= argv
[2]->arg
;
6072 afi_t afi
= bgp_node_afi(vty
);
6073 safi_t safi
= bgp_node_safi(vty
);
6075 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6077 return CMD_WARNING_CONFIG_FAILED
;
6079 if (strmatch(type
, "standard"))
6080 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6081 PEER_FLAG_SEND_COMMUNITY
);
6083 if (strmatch(type
, "extended"))
6084 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6085 PEER_FLAG_SEND_EXT_COMMUNITY
);
6087 if (strmatch(type
, "large"))
6088 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6089 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6091 if (strmatch(type
, "both")) {
6093 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6094 PEER_FLAG_SEND_COMMUNITY
)
6095 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6096 PEER_FLAG_SEND_EXT_COMMUNITY
);
6099 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6100 PEER_FLAG_SEND_COMMUNITY
)
6101 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6102 PEER_FLAG_SEND_EXT_COMMUNITY
)
6103 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6104 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6108 no_neighbor_send_community_type
,
6109 no_neighbor_send_community_type_hidden_cmd
,
6110 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6111 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6112 "Send Community attribute to this neighbor\n"
6113 "Send Standard and Extended Community attributes\n"
6114 "Send Standard, Large and Extended Community attributes\n"
6115 "Send Extended Community attributes\n"
6116 "Send Standard Community attributes\n"
6117 "Send Large Community attributes\n")
6119 /* neighbor soft-reconfig. */
6120 DEFUN (neighbor_soft_reconfiguration
,
6121 neighbor_soft_reconfiguration_cmd
,
6122 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6125 "Per neighbor soft reconfiguration\n"
6126 "Allow inbound soft reconfiguration for this neighbor\n")
6129 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6131 PEER_FLAG_SOFT_RECONFIG
);
6134 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6135 neighbor_soft_reconfiguration_hidden_cmd
,
6136 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6137 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6138 "Per neighbor soft reconfiguration\n"
6139 "Allow inbound soft reconfiguration for this neighbor\n")
6141 DEFUN (no_neighbor_soft_reconfiguration
,
6142 no_neighbor_soft_reconfiguration_cmd
,
6143 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6147 "Per neighbor soft reconfiguration\n"
6148 "Allow inbound soft reconfiguration for this neighbor\n")
6151 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6152 bgp_node_afi(vty
), bgp_node_safi(vty
),
6153 PEER_FLAG_SOFT_RECONFIG
);
6156 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6157 no_neighbor_soft_reconfiguration_hidden_cmd
,
6158 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6159 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6160 "Per neighbor soft reconfiguration\n"
6161 "Allow inbound soft reconfiguration for this neighbor\n")
6163 DEFUN (neighbor_route_reflector_client
,
6164 neighbor_route_reflector_client_cmd
,
6165 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6168 "Configure a neighbor as Route Reflector client\n")
6174 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6176 return CMD_WARNING_CONFIG_FAILED
;
6178 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6180 PEER_FLAG_REFLECTOR_CLIENT
);
6183 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6184 neighbor_route_reflector_client_hidden_cmd
,
6185 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6186 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6187 "Configure a neighbor as Route Reflector client\n")
6189 DEFUN (no_neighbor_route_reflector_client
,
6190 no_neighbor_route_reflector_client_cmd
,
6191 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6195 "Configure a neighbor as Route Reflector client\n")
6198 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6199 bgp_node_afi(vty
), bgp_node_safi(vty
),
6200 PEER_FLAG_REFLECTOR_CLIENT
);
6203 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6204 no_neighbor_route_reflector_client_hidden_cmd
,
6205 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6206 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6207 "Configure a neighbor as Route Reflector client\n")
6209 /* optimal-route-reflection Root Routers configuration */
6210 DEFPY (optimal_route_reflection
,
6211 optimal_route_reflection_cmd
,
6212 "[no$no] optimal-route-reflection WORD$orr_group [<A.B.C.D|X:X::X:X>$primary [<A.B.C.D|X:X::X:X>$secondary [<A.B.C.D|X:X::X:X>$tertiary]]]",
6214 "Create ORR group and assign root router(s)\n"
6216 "Primary Root address\n"
6217 "Primary Root IPv6 address\n"
6218 "Secondary Root address\n"
6219 "Secondary Root IPv6 address\n"
6220 "Tertiary Root address\n"
6221 "Tertiary Root IPv6 address\n")
6223 if (!no
&& !primary
) {
6224 vty_out(vty
, "%% Specify Primary Root address\n");
6225 return CMD_WARNING_CONFIG_FAILED
;
6227 return bgp_afi_safi_orr_group_set_vty(
6228 vty
, bgp_node_afi(vty
), bgp_node_safi(vty
), orr_group
,
6229 primary_str
, secondary_str
, tertiary_str
, !!no
);
6232 /* neighbor optimal-route-reflection group*/
6233 DEFPY (neighbor_optimal_route_reflection
,
6234 neighbor_optimal_route_reflection_cmd
,
6235 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor optimal-route-reflection WORD$orr_group",
6239 "Apply ORR group configuration to the neighbor\n"
6242 return peer_orr_group_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
6243 bgp_node_safi(vty
), orr_group
, !!no
);
6246 /* neighbor route-server-client. */
6247 DEFUN (neighbor_route_server_client
,
6248 neighbor_route_server_client_cmd
,
6249 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6252 "Configure a neighbor as Route Server client\n")
6257 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6259 return CMD_WARNING_CONFIG_FAILED
;
6260 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6262 PEER_FLAG_RSERVER_CLIENT
);
6265 ALIAS_HIDDEN(neighbor_route_server_client
,
6266 neighbor_route_server_client_hidden_cmd
,
6267 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6268 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6269 "Configure a neighbor as Route Server client\n")
6271 DEFUN (no_neighbor_route_server_client
,
6272 no_neighbor_route_server_client_cmd
,
6273 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6277 "Configure a neighbor as Route Server client\n")
6280 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6281 bgp_node_afi(vty
), bgp_node_safi(vty
),
6282 PEER_FLAG_RSERVER_CLIENT
);
6285 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6286 no_neighbor_route_server_client_hidden_cmd
,
6287 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6288 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6289 "Configure a neighbor as Route Server client\n")
6291 DEFUN (neighbor_nexthop_local_unchanged
,
6292 neighbor_nexthop_local_unchanged_cmd
,
6293 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6296 "Configure treatment of outgoing link-local nexthop attribute\n"
6297 "Leave link-local nexthop unchanged for this peer\n")
6300 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6302 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6305 DEFUN (no_neighbor_nexthop_local_unchanged
,
6306 no_neighbor_nexthop_local_unchanged_cmd
,
6307 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6311 "Configure treatment of outgoing link-local-nexthop attribute\n"
6312 "Leave link-local nexthop unchanged for this peer\n")
6315 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6316 bgp_node_afi(vty
), bgp_node_safi(vty
),
6317 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6320 DEFUN (neighbor_attr_unchanged
,
6321 neighbor_attr_unchanged_cmd
,
6322 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6325 "BGP attribute is propagated unchanged to this neighbor\n"
6326 "As-path attribute\n"
6327 "Nexthop attribute\n"
6331 char *peer_str
= argv
[1]->arg
;
6333 bool aspath
= false;
6334 bool nexthop
= false;
6336 afi_t afi
= bgp_node_afi(vty
);
6337 safi_t safi
= bgp_node_safi(vty
);
6340 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6342 return CMD_WARNING_CONFIG_FAILED
;
6344 if (argv_find(argv
, argc
, "as-path", &idx
))
6348 if (argv_find(argv
, argc
, "next-hop", &idx
))
6352 if (argv_find(argv
, argc
, "med", &idx
))
6355 /* no flags means all of them! */
6356 if (!aspath
&& !nexthop
&& !med
) {
6357 ret
= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6358 PEER_FLAG_AS_PATH_UNCHANGED
);
6359 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6360 PEER_FLAG_NEXTHOP_UNCHANGED
);
6361 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6362 PEER_FLAG_MED_UNCHANGED
);
6365 if (peer_af_flag_check(peer
, afi
, safi
,
6366 PEER_FLAG_AS_PATH_UNCHANGED
)) {
6367 ret
|= peer_af_flag_unset_vty(
6368 vty
, peer_str
, afi
, safi
,
6369 PEER_FLAG_AS_PATH_UNCHANGED
);
6372 ret
|= peer_af_flag_set_vty(
6373 vty
, peer_str
, afi
, safi
,
6374 PEER_FLAG_AS_PATH_UNCHANGED
);
6377 if (peer_af_flag_check(peer
, afi
, safi
,
6378 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
6379 ret
|= peer_af_flag_unset_vty(
6380 vty
, peer_str
, afi
, safi
,
6381 PEER_FLAG_NEXTHOP_UNCHANGED
);
6384 ret
|= peer_af_flag_set_vty(
6385 vty
, peer_str
, afi
, safi
,
6386 PEER_FLAG_NEXTHOP_UNCHANGED
);
6389 if (peer_af_flag_check(peer
, afi
, safi
,
6390 PEER_FLAG_MED_UNCHANGED
)) {
6391 ret
|= peer_af_flag_unset_vty(
6392 vty
, peer_str
, afi
, safi
,
6393 PEER_FLAG_MED_UNCHANGED
);
6396 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6397 PEER_FLAG_MED_UNCHANGED
);
6404 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6405 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6406 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6407 "BGP attribute is propagated unchanged to this neighbor\n"
6408 "As-path attribute\n"
6409 "Nexthop attribute\n"
6412 DEFUN (no_neighbor_attr_unchanged
,
6413 no_neighbor_attr_unchanged_cmd
,
6414 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6418 "BGP attribute is propagated unchanged to this neighbor\n"
6419 "As-path attribute\n"
6420 "Nexthop attribute\n"
6424 char *peer_str
= argv
[2]->arg
;
6426 bool aspath
= false;
6427 bool nexthop
= false;
6429 afi_t afi
= bgp_node_afi(vty
);
6430 safi_t safi
= bgp_node_safi(vty
);
6433 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6435 return CMD_WARNING_CONFIG_FAILED
;
6437 if (argv_find(argv
, argc
, "as-path", &idx
))
6441 if (argv_find(argv
, argc
, "next-hop", &idx
))
6445 if (argv_find(argv
, argc
, "med", &idx
))
6448 if (!aspath
&& !nexthop
&& !med
) // no flags means all of them!
6449 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6450 PEER_FLAG_AS_PATH_UNCHANGED
)
6451 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6452 PEER_FLAG_NEXTHOP_UNCHANGED
)
6453 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6454 PEER_FLAG_MED_UNCHANGED
);
6457 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6458 PEER_FLAG_AS_PATH_UNCHANGED
);
6461 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6462 PEER_FLAG_NEXTHOP_UNCHANGED
);
6465 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6466 PEER_FLAG_MED_UNCHANGED
);
6472 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6473 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6474 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6475 "BGP attribute is propagated unchanged to this neighbor\n"
6476 "As-path attribute\n"
6477 "Nexthop attribute\n"
6480 /* EBGP multihop configuration. */
6481 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
6482 const char *ttl_str
)
6487 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6489 return CMD_WARNING_CONFIG_FAILED
;
6492 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
6497 ttl
= strtoul(ttl_str
, NULL
, 10);
6499 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
6502 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
6506 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6508 return CMD_WARNING_CONFIG_FAILED
;
6510 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
6513 /* neighbor ebgp-multihop. */
6514 DEFUN (neighbor_ebgp_multihop
,
6515 neighbor_ebgp_multihop_cmd
,
6516 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6519 "Allow EBGP neighbors not on directly connected networks\n")
6522 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6525 DEFUN (neighbor_ebgp_multihop_ttl
,
6526 neighbor_ebgp_multihop_ttl_cmd
,
6527 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6530 "Allow EBGP neighbors not on directly connected networks\n"
6531 "maximum hop count\n")
6535 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
6536 argv
[idx_number
]->arg
);
6539 DEFUN (no_neighbor_ebgp_multihop
,
6540 no_neighbor_ebgp_multihop_cmd
,
6541 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6545 "Allow EBGP neighbors not on directly connected networks\n"
6546 "maximum hop count\n")
6549 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
6552 static uint8_t get_role_by_name(const char *role_str
)
6554 if (strncmp(role_str
, "peer", 2) == 0)
6556 if (strncmp(role_str
, "provider", 2) == 0)
6557 return ROLE_PROVIDER
;
6558 if (strncmp(role_str
, "customer", 2) == 0)
6559 return ROLE_CUSTOMER
;
6560 if (strncmp(role_str
, "rs-server", 4) == 0)
6561 return ROLE_RS_SERVER
;
6562 if (strncmp(role_str
, "rs-client", 4) == 0)
6563 return ROLE_RS_CLIENT
;
6564 return ROLE_UNDEFINED
;
6567 static int peer_role_set_vty(struct vty
*vty
, const char *ip_str
,
6568 const char *role_str
, bool strict_mode
)
6572 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6574 return CMD_WARNING_CONFIG_FAILED
;
6575 uint8_t role
= get_role_by_name(role_str
);
6577 if (role
== ROLE_UNDEFINED
)
6578 return bgp_vty_return(vty
, BGP_ERR_INVALID_ROLE_NAME
);
6579 return bgp_vty_return(vty
, peer_role_set(peer
, role
, strict_mode
));
6582 static int peer_role_unset_vty(struct vty
*vty
, const char *ip_str
)
6586 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6588 return CMD_WARNING_CONFIG_FAILED
;
6589 return bgp_vty_return(vty
, peer_role_unset(peer
));
6592 DEFPY(neighbor_role
,
6594 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer>",
6597 "Set session role\n"
6603 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6607 DEFPY(neighbor_role_strict
,
6608 neighbor_role_strict_cmd
,
6609 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> strict-mode",
6612 "Set session role\n"
6614 "Use additional restriction on peer\n")
6619 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6623 DEFPY(no_neighbor_role
,
6624 no_neighbor_role_cmd
,
6625 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]",
6629 "Set session role\n"
6631 "Use additional restriction on peer\n")
6635 return peer_role_unset_vty(vty
, argv
[idx_peer
]->arg
);
6638 /* disable-connected-check */
6639 DEFUN (neighbor_disable_connected_check
,
6640 neighbor_disable_connected_check_cmd
,
6641 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6644 "one-hop away EBGP peer using loopback address\n"
6645 "Enforce EBGP neighbors perform multihop\n")
6648 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6649 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6652 DEFUN (no_neighbor_disable_connected_check
,
6653 no_neighbor_disable_connected_check_cmd
,
6654 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6658 "one-hop away EBGP peer using loopback address\n"
6659 "Enforce EBGP neighbors perform multihop\n")
6662 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6663 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6666 /* disable-link-bw-encoding-ieee */
6667 DEFUN(neighbor_disable_link_bw_encoding_ieee
,
6668 neighbor_disable_link_bw_encoding_ieee_cmd
,
6669 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6670 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6671 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6675 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6676 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6679 DEFUN(no_neighbor_disable_link_bw_encoding_ieee
,
6680 no_neighbor_disable_link_bw_encoding_ieee_cmd
,
6681 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6682 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6683 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6687 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6688 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6691 /* extended-optional-parameters */
6692 DEFUN(neighbor_extended_optional_parameters
,
6693 neighbor_extended_optional_parameters_cmd
,
6694 "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6695 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6696 "Force the extended optional parameters format for OPEN messages\n")
6700 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6701 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6704 DEFUN(no_neighbor_extended_optional_parameters
,
6705 no_neighbor_extended_optional_parameters_cmd
,
6706 "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6707 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6708 "Force the extended optional parameters format for OPEN messages\n")
6712 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6713 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6716 /* enforce-first-as */
6717 DEFUN (neighbor_enforce_first_as
,
6718 neighbor_enforce_first_as_cmd
,
6719 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6722 "Enforce the first AS for EBGP routes\n")
6726 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6727 PEER_FLAG_ENFORCE_FIRST_AS
);
6730 DEFUN (no_neighbor_enforce_first_as
,
6731 no_neighbor_enforce_first_as_cmd
,
6732 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6736 "Enforce the first AS for EBGP routes\n")
6740 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6741 PEER_FLAG_ENFORCE_FIRST_AS
);
6745 DEFUN (neighbor_description
,
6746 neighbor_description_cmd
,
6747 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6750 "Neighbor specific description\n"
6751 "Up to 80 characters describing this neighbor\n")
6758 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6760 return CMD_WARNING_CONFIG_FAILED
;
6762 str
= argv_concat(argv
, argc
, idx_line
);
6764 peer_description_set(peer
, str
);
6766 XFREE(MTYPE_TMP
, str
);
6771 DEFUN (no_neighbor_description
,
6772 no_neighbor_description_cmd
,
6773 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6777 "Neighbor specific description\n")
6782 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6784 return CMD_WARNING_CONFIG_FAILED
;
6786 peer_description_unset(peer
);
6791 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6792 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6793 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6794 "Neighbor specific description\n"
6795 "Up to 80 characters describing this neighbor\n")
6797 /* Neighbor update-source. */
6798 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
6799 const char *source_str
)
6805 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6807 return CMD_WARNING_CONFIG_FAILED
;
6813 if (str2sockunion(source_str
, &su
) == 0)
6814 peer_update_source_addr_set(peer
, &su
);
6816 if (str2prefix(source_str
, &p
)) {
6818 "%% Invalid update-source, remove prefix length \n");
6819 return CMD_WARNING_CONFIG_FAILED
;
6821 peer_update_source_if_set(peer
, source_str
);
6824 peer_update_source_unset(peer
);
6829 #define BGP_UPDATE_SOURCE_HELP_STR \
6832 "Interface name (requires zebra to be running)\n"
6834 DEFUN (neighbor_update_source
,
6835 neighbor_update_source_cmd
,
6836 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6839 "Source of routing updates\n"
6840 BGP_UPDATE_SOURCE_HELP_STR
)
6844 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
6845 argv
[idx_peer_2
]->arg
);
6848 DEFUN (no_neighbor_update_source
,
6849 no_neighbor_update_source_cmd
,
6850 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6854 "Source of routing updates\n"
6855 BGP_UPDATE_SOURCE_HELP_STR
)
6858 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6861 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
6862 afi_t afi
, safi_t safi
,
6863 const char *rmap
, int set
)
6867 struct route_map
*route_map
= NULL
;
6869 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6871 return CMD_WARNING_CONFIG_FAILED
;
6875 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
6876 ret
= peer_default_originate_set(peer
, afi
, safi
,
6879 ret
= peer_default_originate_unset(peer
, afi
, safi
);
6881 return bgp_vty_return(vty
, ret
);
6884 /* neighbor default-originate. */
6885 DEFUN (neighbor_default_originate
,
6886 neighbor_default_originate_cmd
,
6887 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6890 "Originate default route to this neighbor\n")
6893 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6895 bgp_node_safi(vty
), NULL
, 1);
6898 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
6899 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6900 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6901 "Originate default route to this neighbor\n")
6903 DEFUN (neighbor_default_originate_rmap
,
6904 neighbor_default_originate_rmap_cmd
,
6905 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6908 "Originate default route to this neighbor\n"
6909 "Route-map to specify criteria to originate default\n"
6914 return peer_default_originate_set_vty(
6915 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6916 argv
[idx_word
]->arg
, 1);
6920 neighbor_default_originate_rmap
,
6921 neighbor_default_originate_rmap_hidden_cmd
,
6922 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6923 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6924 "Originate default route to this neighbor\n"
6925 "Route-map to specify criteria to originate default\n"
6928 DEFUN (no_neighbor_default_originate
,
6929 no_neighbor_default_originate_cmd
,
6930 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6934 "Originate default route to this neighbor\n"
6935 "Route-map to specify criteria to originate default\n"
6939 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6941 bgp_node_safi(vty
), NULL
, 0);
6945 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
6946 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6947 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6948 "Originate default route to this neighbor\n"
6949 "Route-map to specify criteria to originate default\n"
6953 /* Set neighbor's BGP port. */
6954 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
6955 const char *port_str
)
6961 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6963 return CMD_WARNING_CONFIG_FAILED
;
6966 sp
= getservbyname("bgp", "tcp");
6967 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
6969 port
= strtoul(port_str
, NULL
, 10);
6972 peer_port_set(peer
, port
);
6977 /* Set specified peer's BGP port. */
6978 DEFUN (neighbor_port
,
6980 "neighbor <A.B.C.D|X:X::X:X|WORD> port (0-65535)",
6983 "Neighbor's BGP port\n"
6984 "TCP port number\n")
6988 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
6989 argv
[idx_number
]->arg
);
6992 DEFUN (no_neighbor_port
,
6993 no_neighbor_port_cmd
,
6994 "no neighbor <A.B.C.D|X:X::X:X|WORD> port [(0-65535)]",
6998 "Neighbor's BGP port\n"
6999 "TCP port number\n")
7002 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
7006 /* neighbor weight. */
7007 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7008 safi_t safi
, const char *weight_str
)
7012 unsigned long weight
;
7014 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7016 return CMD_WARNING_CONFIG_FAILED
;
7018 weight
= strtoul(weight_str
, NULL
, 10);
7020 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
7021 return bgp_vty_return(vty
, ret
);
7024 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7030 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7032 return CMD_WARNING_CONFIG_FAILED
;
7034 ret
= peer_weight_unset(peer
, afi
, safi
);
7035 return bgp_vty_return(vty
, ret
);
7038 DEFUN (neighbor_weight
,
7039 neighbor_weight_cmd
,
7040 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7043 "Set default weight for routes from this neighbor\n"
7048 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7049 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
7052 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
7053 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7054 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7055 "Set default weight for routes from this neighbor\n"
7058 DEFUN (no_neighbor_weight
,
7059 no_neighbor_weight_cmd
,
7060 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7064 "Set default weight for routes from this neighbor\n"
7068 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
7069 bgp_node_afi(vty
), bgp_node_safi(vty
));
7072 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
7073 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7074 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7075 "Set default weight for routes from this neighbor\n"
7079 /* Override capability negotiation. */
7080 DEFUN (neighbor_override_capability
,
7081 neighbor_override_capability_cmd
,
7082 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7085 "Override capability negotiation result\n")
7088 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7089 PEER_FLAG_OVERRIDE_CAPABILITY
);
7092 DEFUN (no_neighbor_override_capability
,
7093 no_neighbor_override_capability_cmd
,
7094 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7098 "Override capability negotiation result\n")
7101 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7102 PEER_FLAG_OVERRIDE_CAPABILITY
);
7105 DEFUN (neighbor_strict_capability
,
7106 neighbor_strict_capability_cmd
,
7107 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7110 "Strict capability negotiation match\n")
7114 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7115 PEER_FLAG_STRICT_CAP_MATCH
);
7118 DEFUN (no_neighbor_strict_capability
,
7119 no_neighbor_strict_capability_cmd
,
7120 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7124 "Strict capability negotiation match\n")
7128 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7129 PEER_FLAG_STRICT_CAP_MATCH
);
7132 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
7133 const char *keep_str
, const char *hold_str
)
7140 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7142 return CMD_WARNING_CONFIG_FAILED
;
7144 keepalive
= strtoul(keep_str
, NULL
, 10);
7145 holdtime
= strtoul(hold_str
, NULL
, 10);
7147 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
7149 return bgp_vty_return(vty
, ret
);
7152 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
7157 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7159 return CMD_WARNING_CONFIG_FAILED
;
7161 ret
= peer_timers_unset(peer
);
7163 return bgp_vty_return(vty
, ret
);
7166 DEFUN (neighbor_timers
,
7167 neighbor_timers_cmd
,
7168 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7171 "BGP per neighbor timers\n"
7172 "Keepalive interval\n"
7177 int idx_number_2
= 4;
7178 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
7179 argv
[idx_number
]->arg
,
7180 argv
[idx_number_2
]->arg
);
7183 DEFUN (no_neighbor_timers
,
7184 no_neighbor_timers_cmd
,
7185 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7189 "BGP per neighbor timers\n"
7190 "Keepalive interval\n"
7194 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
7198 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
7199 const char *time_str
)
7205 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7207 return CMD_WARNING_CONFIG_FAILED
;
7209 connect
= strtoul(time_str
, NULL
, 10);
7211 ret
= peer_timers_connect_set(peer
, connect
);
7213 return bgp_vty_return(vty
, ret
);
7216 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
7221 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7223 return CMD_WARNING_CONFIG_FAILED
;
7225 ret
= peer_timers_connect_unset(peer
);
7227 return bgp_vty_return(vty
, ret
);
7230 DEFUN (neighbor_timers_connect
,
7231 neighbor_timers_connect_cmd
,
7232 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7235 "BGP per neighbor timers\n"
7236 "BGP connect timer\n"
7241 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
7242 argv
[idx_number
]->arg
);
7245 DEFUN (no_neighbor_timers_connect
,
7246 no_neighbor_timers_connect_cmd
,
7247 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7251 "BGP per neighbor timers\n"
7252 "BGP connect timer\n"
7256 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
7259 DEFPY (neighbor_timers_delayopen
,
7260 neighbor_timers_delayopen_cmd
,
7261 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7264 "BGP per neighbor timers\n"
7265 "RFC 4271 DelayOpenTimer\n"
7266 "DelayOpenTime timer interval\n")
7270 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7272 return CMD_WARNING_CONFIG_FAILED
;
7275 if (peer_timers_delayopen_unset(peer
))
7276 return CMD_WARNING_CONFIG_FAILED
;
7278 if (peer_timers_delayopen_set(peer
, interval
))
7279 return CMD_WARNING_CONFIG_FAILED
;
7285 DEFPY (no_neighbor_timers_delayopen
,
7286 no_neighbor_timers_delayopen_cmd
,
7287 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7291 "BGP per neighbor timers\n"
7292 "RFC 4271 DelayOpenTimer\n"
7293 "DelayOpenTime timer interval\n")
7297 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7299 return CMD_WARNING_CONFIG_FAILED
;
7301 if (peer_timers_delayopen_unset(peer
))
7302 return CMD_WARNING_CONFIG_FAILED
;
7307 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
7308 const char *time_str
, int set
)
7312 uint32_t routeadv
= 0;
7314 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7316 return CMD_WARNING_CONFIG_FAILED
;
7319 routeadv
= strtoul(time_str
, NULL
, 10);
7322 ret
= peer_advertise_interval_set(peer
, routeadv
);
7324 ret
= peer_advertise_interval_unset(peer
);
7326 return bgp_vty_return(vty
, ret
);
7329 DEFUN (neighbor_advertise_interval
,
7330 neighbor_advertise_interval_cmd
,
7331 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7334 "Minimum interval between sending BGP routing updates\n"
7335 "time in seconds\n")
7339 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
7340 argv
[idx_number
]->arg
, 1);
7343 DEFUN (no_neighbor_advertise_interval
,
7344 no_neighbor_advertise_interval_cmd
,
7345 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7349 "Minimum interval between sending BGP routing updates\n"
7350 "time in seconds\n")
7353 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
7357 /* Time to wait before processing route-map updates */
7358 DEFUN (bgp_set_route_map_delay_timer
,
7359 bgp_set_route_map_delay_timer_cmd
,
7360 "bgp route-map delay-timer (0-600)",
7362 "BGP route-map delay timer\n"
7363 "Time in secs to wait before processing route-map changes\n"
7364 "0 disables the timer, no route updates happen when route-maps change\n")
7367 uint32_t rmap_delay_timer
;
7369 if (argv
[idx_number
]->arg
) {
7370 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7371 bm
->rmap_update_timer
= rmap_delay_timer
;
7373 /* if the dynamic update handling is being disabled, and a timer
7375 * running, stop the timer and act as if the timer has already
7378 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7379 THREAD_OFF(bm
->t_rmap_update
);
7380 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7385 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7386 return CMD_WARNING_CONFIG_FAILED
;
7390 DEFUN (no_bgp_set_route_map_delay_timer
,
7391 no_bgp_set_route_map_delay_timer_cmd
,
7392 "no bgp route-map delay-timer [(0-600)]",
7395 "Default BGP route-map delay timer\n"
7396 "Reset to default time to wait for processing route-map changes\n"
7397 "0 disables the timer, no route updates happen when route-maps change\n")
7400 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7405 /* neighbor interface */
7406 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
7411 peer
= peer_lookup_vty(vty
, ip_str
);
7412 if (!peer
|| peer
->conf_if
) {
7413 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
7414 return CMD_WARNING_CONFIG_FAILED
;
7418 peer_interface_set(peer
, str
);
7420 peer_interface_unset(peer
);
7425 DEFUN (neighbor_interface
,
7426 neighbor_interface_cmd
,
7427 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7436 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
7439 DEFUN (no_neighbor_interface
,
7440 no_neighbor_interface_cmd
,
7441 "no neighbor <A.B.C.D|X:X::X:X> interface WORD",
7450 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
7453 DEFUN (neighbor_distribute_list
,
7454 neighbor_distribute_list_cmd
,
7455 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7458 "Filter updates to/from this neighbor\n"
7459 "IP Access-list name\n"
7460 "Filter incoming updates\n"
7461 "Filter outgoing updates\n")
7468 const char *pstr
= argv
[idx_peer
]->arg
;
7469 const char *acl
= argv
[idx_acl
]->arg
;
7470 const char *inout
= argv
[argc
- 1]->text
;
7472 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7474 return CMD_WARNING_CONFIG_FAILED
;
7476 /* Check filter direction. */
7477 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7478 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7481 return bgp_vty_return(vty
, ret
);
7485 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7486 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7487 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7488 "Filter updates to/from this neighbor\n"
7489 "IP Access-list name\n"
7490 "Filter incoming updates\n"
7491 "Filter outgoing updates\n")
7493 DEFUN (no_neighbor_distribute_list
,
7494 no_neighbor_distribute_list_cmd
,
7495 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7499 "Filter updates to/from this neighbor\n"
7500 "IP Access-list name\n"
7501 "Filter incoming updates\n"
7502 "Filter outgoing updates\n")
7508 const char *pstr
= argv
[idx_peer
]->arg
;
7509 const char *inout
= argv
[argc
- 1]->text
;
7511 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7513 return CMD_WARNING_CONFIG_FAILED
;
7515 /* Check filter direction. */
7516 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7517 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7520 return bgp_vty_return(vty
, ret
);
7524 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7525 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7526 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7527 "Filter updates to/from this neighbor\n"
7528 "IP Access-list name\n"
7529 "Filter incoming updates\n"
7530 "Filter outgoing updates\n")
7532 /* Set prefix list to the peer. */
7533 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7534 afi_t afi
, safi_t safi
,
7535 const char *name_str
,
7536 const char *direct_str
)
7539 int direct
= FILTER_IN
;
7542 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7544 return CMD_WARNING_CONFIG_FAILED
;
7546 /* Check filter direction. */
7547 if (strncmp(direct_str
, "i", 1) == 0)
7549 else if (strncmp(direct_str
, "o", 1) == 0)
7550 direct
= FILTER_OUT
;
7552 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7554 return bgp_vty_return(vty
, ret
);
7557 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7558 afi_t afi
, safi_t safi
,
7559 const char *direct_str
)
7563 int direct
= FILTER_IN
;
7565 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7567 return CMD_WARNING_CONFIG_FAILED
;
7569 /* Check filter direction. */
7570 if (strncmp(direct_str
, "i", 1) == 0)
7572 else if (strncmp(direct_str
, "o", 1) == 0)
7573 direct
= FILTER_OUT
;
7575 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7577 return bgp_vty_return(vty
, ret
);
7580 DEFUN (neighbor_prefix_list
,
7581 neighbor_prefix_list_cmd
,
7582 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7585 "Filter updates to/from this neighbor\n"
7586 "Name of a prefix list\n"
7587 "Filter incoming updates\n"
7588 "Filter outgoing updates\n")
7593 return peer_prefix_list_set_vty(
7594 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7595 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7598 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7599 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7600 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7601 "Filter updates to/from this neighbor\n"
7602 "Name of a prefix list\n"
7603 "Filter incoming updates\n"
7604 "Filter outgoing updates\n")
7606 DEFUN (no_neighbor_prefix_list
,
7607 no_neighbor_prefix_list_cmd
,
7608 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7612 "Filter updates to/from this neighbor\n"
7613 "Name of a prefix list\n"
7614 "Filter incoming updates\n"
7615 "Filter outgoing updates\n")
7619 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7620 bgp_node_afi(vty
), bgp_node_safi(vty
),
7621 argv
[idx_in_out
]->arg
);
7624 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7625 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7626 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7627 "Filter updates to/from this neighbor\n"
7628 "Name of a prefix list\n"
7629 "Filter incoming updates\n"
7630 "Filter outgoing updates\n")
7632 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7633 safi_t safi
, const char *name_str
,
7634 const char *direct_str
)
7638 int direct
= FILTER_IN
;
7640 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7642 return CMD_WARNING_CONFIG_FAILED
;
7644 /* Check filter direction. */
7645 if (strncmp(direct_str
, "i", 1) == 0)
7647 else if (strncmp(direct_str
, "o", 1) == 0)
7648 direct
= FILTER_OUT
;
7650 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7652 return bgp_vty_return(vty
, ret
);
7655 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7656 safi_t safi
, const char *direct_str
)
7660 int direct
= FILTER_IN
;
7662 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7664 return CMD_WARNING_CONFIG_FAILED
;
7666 /* Check filter direction. */
7667 if (strncmp(direct_str
, "i", 1) == 0)
7669 else if (strncmp(direct_str
, "o", 1) == 0)
7670 direct
= FILTER_OUT
;
7672 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7674 return bgp_vty_return(vty
, ret
);
7677 DEFUN (neighbor_filter_list
,
7678 neighbor_filter_list_cmd
,
7679 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7682 "Establish BGP filters\n"
7683 "AS path access-list name\n"
7684 "Filter incoming routes\n"
7685 "Filter outgoing routes\n")
7690 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7691 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7692 argv
[idx_in_out
]->arg
);
7695 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7696 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7697 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7698 "Establish BGP filters\n"
7699 "AS path access-list name\n"
7700 "Filter incoming routes\n"
7701 "Filter outgoing routes\n")
7703 DEFUN (no_neighbor_filter_list
,
7704 no_neighbor_filter_list_cmd
,
7705 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7709 "Establish BGP filters\n"
7710 "AS path access-list name\n"
7711 "Filter incoming routes\n"
7712 "Filter outgoing routes\n")
7716 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7717 bgp_node_afi(vty
), bgp_node_safi(vty
),
7718 argv
[idx_in_out
]->arg
);
7721 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7722 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7723 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7724 "Establish BGP filters\n"
7725 "AS path access-list name\n"
7726 "Filter incoming routes\n"
7727 "Filter outgoing routes\n")
7729 /* Set advertise-map to the peer. */
7730 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7731 afi_t afi
, safi_t safi
,
7732 const char *advertise_str
,
7733 const char *condition_str
, bool condition
,
7736 int ret
= CMD_WARNING_CONFIG_FAILED
;
7738 struct route_map
*advertise_map
;
7739 struct route_map
*condition_map
;
7741 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7745 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7746 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7749 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7750 advertise_map
, condition_str
,
7751 condition_map
, condition
);
7753 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7754 advertise_map
, condition_str
,
7755 condition_map
, condition
);
7757 return bgp_vty_return(vty
, ret
);
7760 DEFPY (bgp_condadv_period
,
7761 bgp_condadv_period_cmd
,
7762 "[no$no] bgp conditional-advertisement timer (5-240)$period",
7765 "Conditional advertisement settings\n"
7766 "Set period to rescan BGP table to check if condition is met\n"
7767 "Period between BGP table scans, in seconds; default 60\n")
7769 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7771 bgp
->condition_check_period
=
7772 no
? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
: period
;
7777 DEFPY (neighbor_advertise_map
,
7778 neighbor_advertise_map_cmd
,
7779 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor advertise-map RMAP_NAME$advertise_str <exist-map|non-exist-map>$exist RMAP_NAME$condition_str",
7783 "Route-map to conditionally advertise routes\n"
7784 "Name of advertise map\n"
7785 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7786 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7787 "Name of the exist or non exist map\n")
7789 bool condition
= CONDITION_EXIST
;
7791 if (!strcmp(exist
, "non-exist-map"))
7792 condition
= CONDITION_NON_EXIST
;
7794 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7795 bgp_node_safi(vty
), advertise_str
,
7796 condition_str
, condition
, !no
);
7799 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7800 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor advertise-map RMAP_NAME$advertise_str <exist-map|non-exist-map>$exist RMAP_NAME$condition_str",
7801 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7802 "Route-map to conditionally advertise routes\n"
7803 "Name of advertise map\n"
7804 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7805 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7806 "Name of the exist or non exist map\n")
7808 /* Set route-map to the peer. */
7809 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7810 afi_t afi
, safi_t safi
, const char *name_str
,
7811 const char *direct_str
)
7815 int direct
= RMAP_IN
;
7816 struct route_map
*route_map
;
7818 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7820 return CMD_WARNING_CONFIG_FAILED
;
7822 /* Check filter direction. */
7823 if (strncmp(direct_str
, "in", 2) == 0)
7825 else if (strncmp(direct_str
, "o", 1) == 0)
7828 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7829 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7831 return bgp_vty_return(vty
, ret
);
7834 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7835 afi_t afi
, safi_t safi
,
7836 const char *direct_str
)
7840 int direct
= RMAP_IN
;
7842 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7844 return CMD_WARNING_CONFIG_FAILED
;
7846 /* Check filter direction. */
7847 if (strncmp(direct_str
, "in", 2) == 0)
7849 else if (strncmp(direct_str
, "o", 1) == 0)
7852 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7854 return bgp_vty_return(vty
, ret
);
7857 DEFUN (neighbor_route_map
,
7858 neighbor_route_map_cmd
,
7859 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7862 "Apply route map to neighbor\n"
7863 "Name of route map\n"
7864 "Apply map to incoming routes\n"
7865 "Apply map to outbound routes\n")
7870 return peer_route_map_set_vty(
7871 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7872 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7875 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7876 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7877 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7878 "Apply route map to neighbor\n"
7879 "Name of route map\n"
7880 "Apply map to incoming routes\n"
7881 "Apply map to outbound routes\n")
7883 DEFUN (no_neighbor_route_map
,
7884 no_neighbor_route_map_cmd
,
7885 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7889 "Apply route map to neighbor\n"
7890 "Name of route map\n"
7891 "Apply map to incoming routes\n"
7892 "Apply map to outbound routes\n")
7896 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7897 bgp_node_afi(vty
), bgp_node_safi(vty
),
7898 argv
[idx_in_out
]->arg
);
7901 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7902 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7903 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7904 "Apply route map to neighbor\n"
7905 "Name of route map\n"
7906 "Apply map to incoming routes\n"
7907 "Apply map to outbound routes\n")
7909 /* Set unsuppress-map to the peer. */
7910 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
7911 afi_t afi
, safi_t safi
,
7912 const char *name_str
)
7916 struct route_map
*route_map
;
7918 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7920 return CMD_WARNING_CONFIG_FAILED
;
7922 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7923 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
7925 return bgp_vty_return(vty
, ret
);
7928 /* Unset route-map from the peer. */
7929 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7930 afi_t afi
, safi_t safi
)
7935 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7937 return CMD_WARNING_CONFIG_FAILED
;
7939 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
7941 return bgp_vty_return(vty
, ret
);
7944 DEFUN (neighbor_unsuppress_map
,
7945 neighbor_unsuppress_map_cmd
,
7946 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7949 "Route-map to selectively unsuppress suppressed routes\n"
7950 "Name of route map\n")
7954 return peer_unsuppress_map_set_vty(
7955 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7956 argv
[idx_word
]->arg
);
7959 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
7960 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7961 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7962 "Route-map to selectively unsuppress suppressed routes\n"
7963 "Name of route map\n")
7965 DEFUN (no_neighbor_unsuppress_map
,
7966 no_neighbor_unsuppress_map_cmd
,
7967 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7971 "Route-map to selectively unsuppress suppressed routes\n"
7972 "Name of route map\n")
7975 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7977 bgp_node_safi(vty
));
7980 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
7981 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7982 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7983 "Route-map to selectively unsuppress suppressed routes\n"
7984 "Name of route map\n")
7986 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
7987 afi_t afi
, safi_t safi
,
7988 const char *num_str
,
7989 const char *threshold_str
, int warning
,
7990 const char *restart_str
,
7991 const char *force_str
)
7999 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8001 return CMD_WARNING_CONFIG_FAILED
;
8003 max
= strtoul(num_str
, NULL
, 10);
8005 threshold
= atoi(threshold_str
);
8007 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
8010 restart
= atoi(restart_str
);
8014 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
8015 restart
, force_str
? true : false);
8017 return bgp_vty_return(vty
, ret
);
8020 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
8021 afi_t afi
, safi_t safi
)
8026 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8028 return CMD_WARNING_CONFIG_FAILED
;
8030 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
8032 return bgp_vty_return(vty
, ret
);
8035 /* Maximum number of prefix to be sent to the neighbor. */
8036 DEFUN(neighbor_maximum_prefix_out
,
8037 neighbor_maximum_prefix_out_cmd
,
8038 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
8041 "Maximum number of prefixes to be sent to this peer\n"
8042 "Maximum no. of prefix limit\n")
8049 afi_t afi
= bgp_node_afi(vty
);
8050 safi_t safi
= bgp_node_safi(vty
);
8052 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8054 return CMD_WARNING_CONFIG_FAILED
;
8056 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8058 ret
= peer_maximum_prefix_out_set(peer
, afi
, safi
, max
);
8060 return bgp_vty_return(vty
, ret
);
8063 DEFUN(no_neighbor_maximum_prefix_out
,
8064 no_neighbor_maximum_prefix_out_cmd
,
8065 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]",
8069 "Maximum number of prefixes to be sent to this peer\n"
8070 "Maximum no. of prefix limit\n")
8075 afi_t afi
= bgp_node_afi(vty
);
8076 safi_t safi
= bgp_node_safi(vty
);
8078 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8080 return CMD_WARNING_CONFIG_FAILED
;
8082 ret
= peer_maximum_prefix_out_unset(peer
, afi
, safi
);
8084 return bgp_vty_return(vty
, ret
);
8087 /* Maximum number of prefix configuration. Prefix count is different
8088 for each peer configuration. So this configuration can be set for
8089 each peer configuration. */
8090 DEFUN (neighbor_maximum_prefix
,
8091 neighbor_maximum_prefix_cmd
,
8092 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8095 "Maximum number of prefix accept from this peer\n"
8096 "maximum no. of prefix limit\n"
8097 "Force checking all received routes not only accepted\n")
8104 if (argv_find(argv
, argc
, "force", &idx_force
))
8105 force
= argv
[idx_force
]->arg
;
8107 return peer_maximum_prefix_set_vty(
8108 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8109 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
8112 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8113 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8114 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8115 "Maximum number of prefix accept from this peer\n"
8116 "maximum no. of prefix limit\n"
8117 "Force checking all received routes not only accepted\n")
8119 DEFUN (neighbor_maximum_prefix_threshold
,
8120 neighbor_maximum_prefix_threshold_cmd
,
8121 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8124 "Maximum number of prefix accept from this peer\n"
8125 "maximum no. of prefix limit\n"
8126 "Threshold value (%) at which to generate a warning msg\n"
8127 "Force checking all received routes not only accepted\n")
8131 int idx_number_2
= 4;
8135 if (argv_find(argv
, argc
, "force", &idx_force
))
8136 force
= argv
[idx_force
]->arg
;
8138 return peer_maximum_prefix_set_vty(
8139 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8140 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
8144 neighbor_maximum_prefix_threshold
,
8145 neighbor_maximum_prefix_threshold_hidden_cmd
,
8146 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8147 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8148 "Maximum number of prefix accept from this peer\n"
8149 "maximum no. of prefix limit\n"
8150 "Threshold value (%) at which to generate a warning msg\n"
8151 "Force checking all received routes not only accepted\n")
8153 DEFUN (neighbor_maximum_prefix_warning
,
8154 neighbor_maximum_prefix_warning_cmd
,
8155 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8158 "Maximum number of prefix accept from this peer\n"
8159 "maximum no. of prefix limit\n"
8160 "Only give warning message when limit is exceeded\n"
8161 "Force checking all received routes not only accepted\n")
8168 if (argv_find(argv
, argc
, "force", &idx_force
))
8169 force
= argv
[idx_force
]->arg
;
8171 return peer_maximum_prefix_set_vty(
8172 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8173 argv
[idx_number
]->arg
, NULL
, 1, NULL
, force
);
8177 neighbor_maximum_prefix_warning
,
8178 neighbor_maximum_prefix_warning_hidden_cmd
,
8179 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8180 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8181 "Maximum number of prefix accept from this peer\n"
8182 "maximum no. of prefix limit\n"
8183 "Only give warning message when limit is exceeded\n"
8184 "Force checking all received routes not only accepted\n")
8186 DEFUN (neighbor_maximum_prefix_threshold_warning
,
8187 neighbor_maximum_prefix_threshold_warning_cmd
,
8188 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8191 "Maximum number of prefix accept from this peer\n"
8192 "maximum no. of prefix limit\n"
8193 "Threshold value (%) at which to generate a warning msg\n"
8194 "Only give warning message when limit is exceeded\n"
8195 "Force checking all received routes not only accepted\n")
8199 int idx_number_2
= 4;
8203 if (argv_find(argv
, argc
, "force", &idx_force
))
8204 force
= argv
[idx_force
]->arg
;
8206 return peer_maximum_prefix_set_vty(
8207 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8208 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
8212 neighbor_maximum_prefix_threshold_warning
,
8213 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8214 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8215 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8216 "Maximum number of prefix accept from this peer\n"
8217 "maximum no. of prefix limit\n"
8218 "Threshold value (%) at which to generate a warning msg\n"
8219 "Only give warning message when limit is exceeded\n"
8220 "Force checking all received routes not only accepted\n")
8222 DEFUN (neighbor_maximum_prefix_restart
,
8223 neighbor_maximum_prefix_restart_cmd
,
8224 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8227 "Maximum number of prefix accept from this peer\n"
8228 "maximum no. of prefix limit\n"
8229 "Restart bgp connection after limit is exceeded\n"
8230 "Restart interval in minutes\n"
8231 "Force checking all received routes not only accepted\n")
8235 int idx_number_2
= 5;
8239 if (argv_find(argv
, argc
, "force", &idx_force
))
8240 force
= argv
[idx_force
]->arg
;
8242 return peer_maximum_prefix_set_vty(
8243 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8244 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
8248 neighbor_maximum_prefix_restart
,
8249 neighbor_maximum_prefix_restart_hidden_cmd
,
8250 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8251 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8252 "Maximum number of prefix accept from this peer\n"
8253 "maximum no. of prefix limit\n"
8254 "Restart bgp connection after limit is exceeded\n"
8255 "Restart interval in minutes\n"
8256 "Force checking all received routes not only accepted\n")
8258 DEFUN (neighbor_maximum_prefix_threshold_restart
,
8259 neighbor_maximum_prefix_threshold_restart_cmd
,
8260 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8263 "Maximum number of prefixes to accept from this peer\n"
8264 "maximum no. of prefix limit\n"
8265 "Threshold value (%) at which to generate a warning msg\n"
8266 "Restart bgp connection after limit is exceeded\n"
8267 "Restart interval in minutes\n"
8268 "Force checking all received routes not only accepted\n")
8272 int idx_number_2
= 4;
8273 int idx_number_3
= 6;
8277 if (argv_find(argv
, argc
, "force", &idx_force
))
8278 force
= argv
[idx_force
]->arg
;
8280 return peer_maximum_prefix_set_vty(
8281 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8282 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
8283 argv
[idx_number_3
]->arg
, force
);
8287 neighbor_maximum_prefix_threshold_restart
,
8288 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8289 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8290 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8291 "Maximum number of prefixes to accept from this peer\n"
8292 "maximum no. of prefix limit\n"
8293 "Threshold value (%) at which to generate a warning msg\n"
8294 "Restart bgp connection after limit is exceeded\n"
8295 "Restart interval in minutes\n"
8296 "Force checking all received routes not only accepted\n")
8298 DEFUN (no_neighbor_maximum_prefix
,
8299 no_neighbor_maximum_prefix_cmd
,
8300 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8304 "Maximum number of prefixes to accept from this peer\n"
8305 "maximum no. of prefix limit\n"
8306 "Threshold value (%) at which to generate a warning msg\n"
8307 "Restart bgp connection after limit is exceeded\n"
8308 "Restart interval in minutes\n"
8309 "Only give warning message when limit is exceeded\n"
8310 "Force checking all received routes not only accepted\n")
8313 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
8315 bgp_node_safi(vty
));
8319 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8320 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8321 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8322 "Maximum number of prefixes to accept from this peer\n"
8323 "maximum no. of prefix limit\n"
8324 "Threshold value (%) at which to generate a warning msg\n"
8325 "Restart bgp connection after limit is exceeded\n"
8326 "Restart interval in minutes\n"
8327 "Only give warning message when limit is exceeded\n"
8328 "Force checking all received routes not only accepted\n")
8330 /* "neighbor accept-own" */
8331 DEFPY (neighbor_accept_own
,
8332 neighbor_accept_own_cmd
,
8333 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor accept-own",
8337 "Enable handling of self-originated VPN routes containing ACCEPT_OWN community\n")
8340 afi_t afi
= bgp_node_afi(vty
);
8341 safi_t safi
= bgp_node_safi(vty
);
8344 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8346 return CMD_WARNING_CONFIG_FAILED
;
8349 ret
= peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
);
8351 ret
= peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
);
8353 return bgp_vty_return(vty
, ret
);
8356 /* "neighbor soo" */
8357 DEFPY (neighbor_soo
,
8359 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo ASN:NN_OR_IP-ADDRESS:NN$soo",
8362 "Set the Site-of-Origin (SoO) extended community\n"
8363 "VPN extended community\n")
8366 afi_t afi
= bgp_node_afi(vty
);
8367 safi_t safi
= bgp_node_safi(vty
);
8368 struct ecommunity
*ecomm_soo
;
8370 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8372 return CMD_WARNING_CONFIG_FAILED
;
8374 ecomm_soo
= ecommunity_str2com(soo
, ECOMMUNITY_SITE_ORIGIN
, 0);
8376 vty_out(vty
, "%% Malformed SoO extended community\n");
8379 ecommunity_str(ecomm_soo
);
8381 if (!ecommunity_match(peer
->soo
[afi
][safi
], ecomm_soo
)) {
8382 ecommunity_free(&peer
->soo
[afi
][safi
]);
8383 peer
->soo
[afi
][safi
] = ecomm_soo
;
8384 peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
);
8387 return bgp_vty_return(vty
,
8388 peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_SOO
));
8391 DEFPY (no_neighbor_soo
,
8392 no_neighbor_soo_cmd
,
8393 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo [ASN:NN_OR_IP-ADDRESS:NN$soo]",
8397 "Set the Site-of-Origin (SoO) extended community\n"
8398 "VPN extended community\n")
8401 afi_t afi
= bgp_node_afi(vty
);
8402 safi_t safi
= bgp_node_safi(vty
);
8404 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8406 return CMD_WARNING_CONFIG_FAILED
;
8408 ecommunity_free(&peer
->soo
[afi
][safi
]);
8410 return bgp_vty_return(
8411 vty
, peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
));
8414 /* "neighbor allowas-in" */
8415 DEFUN (neighbor_allowas_in
,
8416 neighbor_allowas_in_cmd
,
8417 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8420 "Accept as-path with my AS present in it\n"
8421 "Number of occurrences of AS number\n"
8422 "Only accept my AS in the as-path if the route was originated in my AS\n")
8425 int idx_number_origin
= 3;
8431 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8433 return CMD_WARNING_CONFIG_FAILED
;
8435 if (argc
<= idx_number_origin
)
8438 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8441 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8444 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8447 return bgp_vty_return(vty
, ret
);
8451 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8452 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8453 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8454 "Accept as-path with my AS present in it\n"
8455 "Number of occurrences of AS number\n"
8456 "Only accept my AS in the as-path if the route was originated in my AS\n")
8458 DEFUN (no_neighbor_allowas_in
,
8459 no_neighbor_allowas_in_cmd
,
8460 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8464 "allow local ASN appears in aspath attribute\n"
8465 "Number of occurrences of AS number\n"
8466 "Only accept my AS in the as-path if the route was originated in my AS\n")
8472 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8474 return CMD_WARNING_CONFIG_FAILED
;
8476 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8477 bgp_node_safi(vty
));
8479 return bgp_vty_return(vty
, ret
);
8483 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8484 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8485 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8486 "allow local ASN appears in aspath attribute\n"
8487 "Number of occurrences of AS number\n"
8488 "Only accept my AS in the as-path if the route was originated in my AS\n")
8490 DEFUN (neighbor_ttl_security
,
8491 neighbor_ttl_security_cmd
,
8492 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8495 "BGP ttl-security parameters\n"
8496 "Specify the maximum number of hops to the BGP peer\n"
8497 "Number of hops to BGP peer\n")
8504 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8506 return CMD_WARNING_CONFIG_FAILED
;
8508 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8511 * If 'neighbor swpX', then this is for directly connected peers,
8512 * we should not accept a ttl-security hops value greater than 1.
8514 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
8516 "%s is directly connected peer, hops cannot exceed 1\n",
8517 argv
[idx_peer
]->arg
);
8518 return CMD_WARNING_CONFIG_FAILED
;
8521 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
8524 DEFUN (no_neighbor_ttl_security
,
8525 no_neighbor_ttl_security_cmd
,
8526 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8530 "BGP ttl-security parameters\n"
8531 "Specify the maximum number of hops to the BGP peer\n"
8532 "Number of hops to BGP peer\n")
8537 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8539 return CMD_WARNING_CONFIG_FAILED
;
8541 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
8544 /* disable-addpath-rx */
8545 DEFUN(neighbor_disable_addpath_rx
,
8546 neighbor_disable_addpath_rx_cmd
,
8547 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8550 "Do not accept additional paths\n")
8552 char *peer_str
= argv
[1]->arg
;
8554 afi_t afi
= bgp_node_afi(vty
);
8555 safi_t safi
= bgp_node_safi(vty
);
8557 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8559 return CMD_WARNING_CONFIG_FAILED
;
8561 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
8562 PEER_FLAG_DISABLE_ADDPATH_RX
);
8565 DEFUN(no_neighbor_disable_addpath_rx
,
8566 no_neighbor_disable_addpath_rx_cmd
,
8567 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8571 "Do not accept additional paths\n")
8573 char *peer_str
= argv
[2]->arg
;
8575 afi_t afi
= bgp_node_afi(vty
);
8576 safi_t safi
= bgp_node_safi(vty
);
8578 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8580 return CMD_WARNING_CONFIG_FAILED
;
8582 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
8583 PEER_FLAG_DISABLE_ADDPATH_RX
);
8586 DEFUN (neighbor_addpath_tx_all_paths
,
8587 neighbor_addpath_tx_all_paths_cmd
,
8588 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8591 "Use addpath to advertise all paths to a neighbor\n")
8596 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8598 return CMD_WARNING_CONFIG_FAILED
;
8600 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8605 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8606 neighbor_addpath_tx_all_paths_hidden_cmd
,
8607 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8608 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8609 "Use addpath to advertise all paths to a neighbor\n")
8611 DEFUN (no_neighbor_addpath_tx_all_paths
,
8612 no_neighbor_addpath_tx_all_paths_cmd
,
8613 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8617 "Use addpath to advertise all paths to a neighbor\n")
8622 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8624 return CMD_WARNING_CONFIG_FAILED
;
8626 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8627 != BGP_ADDPATH_ALL
) {
8629 "%% Peer not currently configured to transmit all paths.");
8630 return CMD_WARNING_CONFIG_FAILED
;
8633 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8639 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8640 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8641 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8642 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8643 "Use addpath to advertise all paths to a neighbor\n")
8645 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8646 neighbor_addpath_tx_bestpath_per_as_cmd
,
8647 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8650 "Use addpath to advertise the bestpath per each neighboring AS\n")
8655 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8657 return CMD_WARNING_CONFIG_FAILED
;
8659 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8660 BGP_ADDPATH_BEST_PER_AS
);
8665 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8666 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8667 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8668 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8669 "Use addpath to advertise the bestpath per each neighboring AS\n")
8671 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8672 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8673 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8677 "Use addpath to advertise the bestpath per each neighboring AS\n")
8682 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8684 return CMD_WARNING_CONFIG_FAILED
;
8686 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8687 != BGP_ADDPATH_BEST_PER_AS
) {
8689 "%% Peer not currently configured to transmit all best path per as.");
8690 return CMD_WARNING_CONFIG_FAILED
;
8693 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8699 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8700 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8701 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8702 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8703 "Use addpath to advertise the bestpath per each neighboring AS\n")
8706 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8707 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8710 "Detect AS loops before sending to neighbor\n")
8714 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8716 return CMD_WARNING_CONFIG_FAILED
;
8718 peer
->as_path_loop_detection
= true;
8724 no_neighbor_aspath_loop_detection
,
8725 no_neighbor_aspath_loop_detection_cmd
,
8726 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8730 "Detect AS loops before sending to neighbor\n")
8734 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8736 return CMD_WARNING_CONFIG_FAILED
;
8738 peer
->as_path_loop_detection
= false;
8743 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8744 struct ecommunity
**list
, bool is_rt6
)
8746 struct ecommunity
*ecom
= NULL
;
8747 struct ecommunity
*ecomadd
;
8749 for (; argc
; --argc
, ++argv
) {
8751 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8752 ECOMMUNITY_ROUTE_TARGET
,
8755 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8756 ECOMMUNITY_ROUTE_TARGET
,
8759 vty_out(vty
, "Malformed community-list value\n");
8761 ecommunity_free(&ecom
);
8762 return CMD_WARNING_CONFIG_FAILED
;
8766 ecommunity_merge(ecom
, ecomadd
);
8767 ecommunity_free(&ecomadd
);
8774 ecommunity_free(&*list
);
8782 * v2vimport is true if we are handling a `import vrf ...` command
8784 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8788 switch (vty
->node
) {
8797 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8802 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8803 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8804 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8805 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8807 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8811 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8812 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8813 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8814 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8816 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8823 DEFPY (af_rd_vpn_export
,
8824 af_rd_vpn_export_cmd
,
8825 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8827 "Specify route distinguisher\n"
8828 "Between current address-family and vpn\n"
8829 "For routes leaked from current address-family to vpn\n"
8830 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8832 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8833 struct prefix_rd prd
;
8839 if (argv_find(argv
, argc
, "no", &idx
))
8843 ret
= str2prefix_rd(rd_str
, &prd
);
8845 vty_out(vty
, "%% Malformed rd\n");
8846 return CMD_WARNING_CONFIG_FAILED
;
8850 afi
= vpn_policy_getafi(vty
, bgp
, false);
8852 return CMD_WARNING_CONFIG_FAILED
;
8855 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8857 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8858 bgp_get_default(), bgp
);
8861 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
8862 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8863 BGP_VPN_POLICY_TOVPN_RD_SET
);
8865 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8866 BGP_VPN_POLICY_TOVPN_RD_SET
);
8869 /* post-change: re-export vpn routes */
8870 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8871 bgp_get_default(), bgp
);
8876 ALIAS (af_rd_vpn_export
,
8877 af_no_rd_vpn_export_cmd
,
8880 "Specify route distinguisher\n"
8881 "Between current address-family and vpn\n"
8882 "For routes leaked from current address-family to vpn\n")
8884 DEFPY (af_label_vpn_export
,
8885 af_label_vpn_export_cmd
,
8886 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
8888 "label value for VRF\n"
8889 "Between current address-family and vpn\n"
8890 "For routes leaked from current address-family to vpn\n"
8891 "Label Value <0-1048575>\n"
8892 "Automatically assign a label\n")
8894 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8895 mpls_label_t label
= MPLS_LABEL_NONE
;
8900 if (argv_find(argv
, argc
, "no", &idx
))
8903 /* If "no ...", squash trailing parameter */
8909 label
= label_val
; /* parser should force unsigned */
8912 afi
= vpn_policy_getafi(vty
, bgp
, false);
8914 return CMD_WARNING_CONFIG_FAILED
;
8917 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8918 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
8923 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8925 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8926 bgp_get_default(), bgp
);
8928 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8929 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
8931 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
8934 * label has previously been automatically
8935 * assigned by labelpool: release it
8937 * NB if tovpn_label == MPLS_LABEL_NONE it
8938 * means the automatic assignment is in flight
8939 * and therefore the labelpool callback must
8940 * detect that the auto label is not needed.
8943 bgp_lp_release(LP_TYPE_VRF
,
8944 &bgp
->vpn_policy
[afi
],
8945 bgp
->vpn_policy
[afi
].tovpn_label
);
8947 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8948 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8951 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
8953 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8954 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8955 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
8956 vpn_leak_label_callback
);
8959 /* post-change: re-export vpn routes */
8960 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8961 bgp_get_default(), bgp
);
8963 hook_call(bgp_snmp_update_last_changed
, bgp
);
8967 DEFPY (af_sid_vpn_export
,
8968 af_sid_vpn_export_cmd
,
8969 "[no] sid vpn export <(1-1048575)$sid_idx|auto$sid_auto>",
8971 "sid value for VRF\n"
8972 "Between current address-family and vpn\n"
8973 "For routes leaked from current address-family to vpn\n"
8974 "Sid allocation index\n"
8975 "Automatically assign a label\n")
8977 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8983 if (argv_find(argv
, argc
, "no", &idx
))
8985 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
8986 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
8988 afi
= vpn_policy_getafi(vty
, bgp
, false);
8990 return CMD_WARNING_CONFIG_FAILED
;
8994 vty_out(vty
, "It's not implemented\n");
8995 return CMD_WARNING_CONFIG_FAILED
;
8998 /* skip when it's already configured */
8999 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9000 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9001 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
9005 * mode change between sid_idx and sid_auto isn't supported.
9006 * user must negate sid vpn export when they want to change the mode
9008 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9009 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9010 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
9011 vty_out(vty
, "it's already configured as %s.\n",
9012 sid_auto
? "auto-mode" : "idx-mode");
9013 return CMD_WARNING_CONFIG_FAILED
;
9017 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9018 bgp_get_default(), bgp
);
9021 /* SID allocation auto-mode */
9023 zlog_debug("%s: auto sid alloc.", __func__
);
9024 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9025 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
9027 /* SID allocation index-mode */
9029 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
9030 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
9034 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9035 bgp_get_default(), bgp
);
9039 ALIAS (af_label_vpn_export
,
9040 af_no_label_vpn_export_cmd
,
9041 "no label vpn export",
9043 "label value for VRF\n"
9044 "Between current address-family and vpn\n"
9045 "For routes leaked from current address-family to vpn\n")
9047 DEFPY (af_nexthop_vpn_export
,
9048 af_nexthop_vpn_export_cmd
,
9049 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
9051 "Specify next hop to use for VRF advertised prefixes\n"
9052 "Between current address-family and vpn\n"
9053 "For routes leaked from current address-family to vpn\n"
9057 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9063 vty_out(vty
, "%% Nexthop required\n");
9064 return CMD_WARNING_CONFIG_FAILED
;
9066 if (!sockunion2hostprefix(nexthop_su
, &p
))
9067 return CMD_WARNING_CONFIG_FAILED
;
9070 afi
= vpn_policy_getafi(vty
, bgp
, false);
9072 return CMD_WARNING_CONFIG_FAILED
;
9075 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9077 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9078 bgp_get_default(), bgp
);
9081 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
9082 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9083 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9085 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9086 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9089 /* post-change: re-export vpn routes */
9090 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9091 bgp_get_default(), bgp
);
9096 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9098 if (!strcmp(dstr
, "import")) {
9099 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9100 } else if (!strcmp(dstr
, "export")) {
9101 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9102 } else if (!strcmp(dstr
, "both")) {
9103 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9104 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9106 vty_out(vty
, "%% direction parse error\n");
9107 return CMD_WARNING_CONFIG_FAILED
;
9112 DEFPY (af_rt_vpn_imexport
,
9113 af_rt_vpn_imexport_cmd
,
9114 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9116 "Specify route target list\n"
9117 "Specify route target list\n"
9118 "Between current address-family and vpn\n"
9119 "For routes leaked from vpn to current address-family: match any\n"
9120 "For routes leaked from current address-family to vpn: set\n"
9121 "both import: match any and export: set\n"
9122 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9124 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9126 struct ecommunity
*ecom
= NULL
;
9127 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9128 enum vpn_policy_direction dir
;
9133 if (argv_find(argv
, argc
, "no", &idx
))
9136 afi
= vpn_policy_getafi(vty
, bgp
, false);
9138 return CMD_WARNING_CONFIG_FAILED
;
9140 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9141 if (ret
!= CMD_SUCCESS
)
9145 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9146 vty_out(vty
, "%% Missing RTLIST\n");
9147 return CMD_WARNING_CONFIG_FAILED
;
9149 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9150 if (ret
!= CMD_SUCCESS
) {
9155 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9159 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9162 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9164 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9165 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9166 ecommunity_dup(ecom
);
9168 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9170 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9171 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9174 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9178 ecommunity_free(&ecom
);
9183 ALIAS (af_rt_vpn_imexport
,
9184 af_no_rt_vpn_imexport_cmd
,
9185 "no <rt|route-target> vpn <import|export|both>$direction_str",
9187 "Specify route target list\n"
9188 "Specify route target list\n"
9189 "Between current address-family and vpn\n"
9190 "For routes leaked from vpn to current address-family\n"
9191 "For routes leaked from current address-family to vpn\n"
9192 "both import and export\n")
9194 DEFPY (af_route_map_vpn_imexport
,
9195 af_route_map_vpn_imexport_cmd
,
9196 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9197 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9199 "Specify route map\n"
9200 "Between current address-family and vpn\n"
9201 "For routes leaked from vpn to current address-family\n"
9202 "For routes leaked from current address-family to vpn\n"
9203 "name of route-map\n")
9205 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9207 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9208 enum vpn_policy_direction dir
;
9213 if (argv_find(argv
, argc
, "no", &idx
))
9216 afi
= vpn_policy_getafi(vty
, bgp
, false);
9218 return CMD_WARNING_CONFIG_FAILED
;
9220 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9221 if (ret
!= CMD_SUCCESS
)
9224 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9228 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9231 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9232 XFREE(MTYPE_ROUTE_MAP_NAME
,
9233 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9234 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
9235 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9236 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9237 route_map_lookup_warn_noexist(vty
, rmap_str
);
9238 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9241 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9242 XFREE(MTYPE_ROUTE_MAP_NAME
,
9243 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9244 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9245 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9248 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9254 ALIAS (af_route_map_vpn_imexport
,
9255 af_no_route_map_vpn_imexport_cmd
,
9256 "no route-map vpn <import|export>$direction_str",
9258 "Specify route map\n"
9259 "Between current address-family and vpn\n"
9260 "For routes leaked from vpn to current address-family\n"
9261 "For routes leaked from current address-family to vpn\n")
9263 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9264 "import vrf route-map RMAP$rmap_str",
9265 "Import routes from another VRF\n"
9266 "Vrf routes being filtered\n"
9267 "Specify route map\n"
9268 "name of route-map\n")
9270 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9271 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9273 struct bgp
*bgp_default
;
9275 afi
= vpn_policy_getafi(vty
, bgp
, true);
9277 return CMD_WARNING_CONFIG_FAILED
;
9279 bgp_default
= bgp_get_default();
9284 /* Auto-create assuming the same AS */
9285 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9286 BGP_INSTANCE_TYPE_DEFAULT
);
9290 "VRF default is not configured as a bgp instance\n");
9295 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9297 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9298 XFREE(MTYPE_ROUTE_MAP_NAME
,
9299 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9300 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9301 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9302 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9303 route_map_lookup_warn_noexist(vty
, rmap_str
);
9304 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9307 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9308 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9310 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9315 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9316 "no import vrf route-map [RMAP$rmap_str]",
9318 "Import routes from another VRF\n"
9319 "Vrf routes being filtered\n"
9320 "Specify route map\n"
9321 "name of route-map\n")
9323 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9324 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9327 afi
= vpn_policy_getafi(vty
, bgp
, true);
9329 return CMD_WARNING_CONFIG_FAILED
;
9331 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9333 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9334 XFREE(MTYPE_ROUTE_MAP_NAME
,
9335 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9336 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9337 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9339 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9340 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9341 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9343 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9348 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
9349 "[no] import vrf VIEWVRFNAME$import_name",
9351 "Import routes from another VRF\n"
9352 "VRF to import from\n"
9353 "The name of the VRF\n")
9355 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9356 struct listnode
*node
;
9357 struct bgp
*vrf_bgp
, *bgp_default
;
9360 bool remove
= false;
9363 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
9367 if (import_name
== NULL
) {
9368 vty_out(vty
, "%% Missing import name\n");
9372 if (strcmp(import_name
, "route-map") == 0) {
9373 vty_out(vty
, "%% Must include route-map name\n");
9377 if (argv_find(argv
, argc
, "no", &idx
))
9380 afi
= vpn_policy_getafi(vty
, bgp
, true);
9382 return CMD_WARNING_CONFIG_FAILED
;
9384 safi
= bgp_node_safi(vty
);
9386 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
9387 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
9388 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
9389 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
9390 remove
? "unimport" : "import", import_name
);
9394 bgp_default
= bgp_get_default();
9396 /* Auto-create assuming the same AS */
9397 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9398 BGP_INSTANCE_TYPE_DEFAULT
);
9402 "VRF default is not configured as a bgp instance\n");
9407 vrf_bgp
= bgp_lookup_by_name(import_name
);
9409 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
9410 vrf_bgp
= bgp_default
;
9412 /* Auto-create assuming the same AS */
9413 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
9417 "VRF %s is not configured as a bgp instance\n",
9424 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9426 /* Already importing from "import_vrf"? */
9427 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
9429 if (strcmp(vname
, import_name
) == 0)
9433 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9439 /* This command is valid only in a bgp vrf instance or the default instance */
9440 DEFPY (bgp_imexport_vpn
,
9441 bgp_imexport_vpn_cmd
,
9442 "[no] <import|export>$direction_str vpn",
9444 "Import routes to this address-family\n"
9445 "Export routes from this address-family\n"
9446 "to/from default instance VPN RIB\n")
9448 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9455 enum vpn_policy_direction dir
;
9457 if (argv_find(argv
, argc
, "no", &idx
))
9460 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
9461 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
9463 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
9464 return CMD_WARNING_CONFIG_FAILED
;
9467 afi
= bgp_node_afi(vty
);
9468 safi
= bgp_node_safi(vty
);
9469 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
9470 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
9471 return CMD_WARNING_CONFIG_FAILED
;
9474 if (!strcmp(direction_str
, "import")) {
9475 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
9476 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9477 } else if (!strcmp(direction_str
, "export")) {
9478 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
9479 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
9481 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9482 return CMD_WARNING_CONFIG_FAILED
;
9485 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9488 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9489 if (!previous_state
) {
9490 /* trigger export current vrf */
9491 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9494 if (previous_state
) {
9495 /* trigger un-export current vrf */
9496 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9498 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9501 hook_call(bgp_snmp_init_stats
, bgp
);
9506 DEFPY (af_routetarget_import
,
9507 af_routetarget_import_cmd
,
9508 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9510 "Specify route target list\n"
9511 "Specify route target list\n"
9512 "Specify route target list\n"
9513 "Specify route target list\n"
9514 "Flow-spec redirect type route target\n"
9515 "Import routes to this address-family\n"
9516 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9518 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9520 struct ecommunity
*ecom
= NULL
;
9522 int idx
= 0, idx_unused
= 0;
9526 if (argv_find(argv
, argc
, "no", &idx
))
9529 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9530 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9533 afi
= vpn_policy_getafi(vty
, bgp
, false);
9535 return CMD_WARNING_CONFIG_FAILED
;
9537 if (rt6
&& afi
!= AFI_IP6
)
9538 return CMD_WARNING_CONFIG_FAILED
;
9541 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9542 vty_out(vty
, "%% Missing RTLIST\n");
9543 return CMD_WARNING_CONFIG_FAILED
;
9545 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9546 if (ret
!= CMD_SUCCESS
)
9551 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9552 ecommunity_free(&bgp
->vpn_policy
[afi
]
9553 .import_redirect_rtlist
);
9554 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9555 ecommunity_dup(ecom
);
9557 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9558 ecommunity_free(&bgp
->vpn_policy
[afi
]
9559 .import_redirect_rtlist
);
9560 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9564 ecommunity_free(&ecom
);
9569 DEFUN_NOSH (address_family_ipv4_safi
,
9570 address_family_ipv4_safi_cmd
,
9571 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9572 "Enter Address Family command mode\n"
9574 BGP_SAFI_WITH_LABEL_HELP_STR
)
9578 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9579 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9580 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9581 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9582 && safi
!= SAFI_EVPN
) {
9584 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9585 return CMD_WARNING_CONFIG_FAILED
;
9587 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9589 vty
->node
= BGP_IPV4_NODE
;
9594 DEFUN_NOSH (address_family_ipv6_safi
,
9595 address_family_ipv6_safi_cmd
,
9596 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9597 "Enter Address Family command mode\n"
9599 BGP_SAFI_WITH_LABEL_HELP_STR
)
9602 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9603 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9604 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9605 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9606 && safi
!= SAFI_EVPN
) {
9608 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9609 return CMD_WARNING_CONFIG_FAILED
;
9611 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9613 vty
->node
= BGP_IPV6_NODE
;
9618 #ifdef KEEP_OLD_VPN_COMMANDS
9619 DEFUN_NOSH (address_family_vpnv4
,
9620 address_family_vpnv4_cmd
,
9621 "address-family vpnv4 [unicast]",
9622 "Enter Address Family command mode\n"
9624 BGP_AF_MODIFIER_STR
)
9626 vty
->node
= BGP_VPNV4_NODE
;
9630 DEFUN_NOSH (address_family_vpnv6
,
9631 address_family_vpnv6_cmd
,
9632 "address-family vpnv6 [unicast]",
9633 "Enter Address Family command mode\n"
9635 BGP_AF_MODIFIER_STR
)
9637 vty
->node
= BGP_VPNV6_NODE
;
9640 #endif /* KEEP_OLD_VPN_COMMANDS */
9642 DEFUN_NOSH (address_family_evpn
,
9643 address_family_evpn_cmd
,
9644 "address-family l2vpn evpn",
9645 "Enter Address Family command mode\n"
9647 BGP_AF_MODIFIER_STR
)
9649 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9650 vty
->node
= BGP_EVPN_NODE
;
9654 DEFUN_NOSH (bgp_segment_routing_srv6
,
9655 bgp_segment_routing_srv6_cmd
,
9656 "segment-routing srv6",
9657 "Segment-Routing configuration\n"
9658 "Segment-Routing SRv6 configuration\n")
9660 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9661 bgp
->srv6_enabled
= true;
9662 vty
->node
= BGP_SRV6_NODE
;
9666 DEFUN (no_bgp_segment_routing_srv6
,
9667 no_bgp_segment_routing_srv6_cmd
,
9668 "no segment-routing srv6",
9670 "Segment-Routing configuration\n"
9671 "Segment-Routing SRv6 configuration\n")
9673 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9675 if (strlen(bgp
->srv6_locator_name
) > 0)
9676 if (bgp_srv6_locator_unset(bgp
) < 0)
9677 return CMD_WARNING_CONFIG_FAILED
;
9679 bgp
->srv6_enabled
= false;
9683 DEFPY (bgp_srv6_locator
,
9684 bgp_srv6_locator_cmd
,
9685 "locator NAME$name",
9686 "Specify SRv6 locator\n"
9687 "Specify SRv6 locator\n")
9689 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9692 if (strlen(bgp
->srv6_locator_name
) > 0
9693 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9694 vty_out(vty
, "srv6 locator is already configured\n");
9695 return CMD_WARNING_CONFIG_FAILED
;
9698 snprintf(bgp
->srv6_locator_name
,
9699 sizeof(bgp
->srv6_locator_name
), "%s", name
);
9701 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
9703 return CMD_WARNING_CONFIG_FAILED
;
9708 DEFPY (no_bgp_srv6_locator
,
9709 no_bgp_srv6_locator_cmd
,
9710 "no locator NAME$name",
9712 "Specify SRv6 locator\n"
9713 "Specify SRv6 locator\n")
9715 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9717 /* when locator isn't configured, do nothing */
9718 if (strlen(bgp
->srv6_locator_name
) < 1)
9721 /* name validation */
9722 if (strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9723 vty_out(vty
, "%% No srv6 locator is configured\n");
9724 return CMD_WARNING_CONFIG_FAILED
;
9728 if (bgp_srv6_locator_unset(bgp
) < 0)
9729 return CMD_WARNING_CONFIG_FAILED
;
9734 DEFPY (show_bgp_srv6
,
9736 "show bgp segment-routing srv6",
9739 "BGP Segment Routing\n"
9740 "BGP Segment Routing SRv6\n")
9743 struct listnode
*node
;
9744 struct srv6_locator_chunk
*chunk
;
9745 struct bgp_srv6_function
*func
;
9748 bgp
= bgp_get_default();
9752 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
9753 vty_out(vty
, "locator_chunks:\n");
9754 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
))
9755 vty_out(vty
, "- %pFX\n", &chunk
->prefix
);
9757 vty_out(vty
, "functions:\n");
9758 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
9759 inet_ntop(AF_INET6
, &func
->sid
, buf
, sizeof(buf
));
9760 vty_out(vty
, "- sid: %s\n", buf
);
9761 vty_out(vty
, " locator: %s\n", func
->locator_name
);
9764 vty_out(vty
, "bgps:\n");
9765 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
9766 vty_out(vty
, "- name: %s\n",
9767 bgp
->name
? bgp
->name
: "default");
9769 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %pI6\n",
9770 bgp
->vpn_policy
[AFI_IP
].tovpn_sid
);
9771 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %pI6\n",
9772 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
);
9778 DEFUN_NOSH (exit_address_family
,
9779 exit_address_family_cmd
,
9780 "exit-address-family",
9781 "Exit from Address Family configuration mode\n")
9783 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9784 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9785 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9786 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9787 || vty
->node
== BGP_EVPN_NODE
9788 || vty
->node
== BGP_FLOWSPECV4_NODE
9789 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9790 vty
->node
= BGP_NODE
;
9794 /* Recalculate bestpath and re-advertise a prefix */
9795 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9796 const char *ip_str
, afi_t afi
, safi_t safi
,
9797 struct prefix_rd
*prd
)
9800 struct prefix match
;
9801 struct bgp_dest
*dest
;
9802 struct bgp_dest
*rm
;
9804 struct bgp_table
*table
;
9805 struct bgp_table
*rib
;
9807 /* BGP structure lookup. */
9809 bgp
= bgp_lookup_by_name(view_name
);
9811 vty_out(vty
, "%% Can't find BGP instance %s\n",
9816 bgp
= bgp_get_default();
9818 vty_out(vty
, "%% No BGP process is configured\n");
9823 /* Check IP address argument. */
9824 ret
= str2prefix(ip_str
, &match
);
9826 vty_out(vty
, "%% address is malformed\n");
9830 match
.family
= afi2family(afi
);
9831 rib
= bgp
->rib
[afi
][safi
];
9833 if (safi
== SAFI_MPLS_VPN
) {
9834 for (dest
= bgp_table_top(rib
); dest
;
9835 dest
= bgp_route_next(dest
)) {
9836 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9838 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9841 table
= bgp_dest_get_bgp_table_info(dest
);
9845 rm
= bgp_node_match(table
, &match
);
9847 const struct prefix
*rm_p
=
9848 bgp_dest_get_prefix(rm
);
9850 if (rm_p
->prefixlen
== match
.prefixlen
) {
9852 BGP_NODE_USER_CLEAR
);
9853 bgp_process(bgp
, rm
, afi
, safi
);
9855 bgp_dest_unlock_node(rm
);
9859 dest
= bgp_node_match(rib
, &match
);
9861 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9863 if (dest_p
->prefixlen
== match
.prefixlen
) {
9864 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9865 bgp_process(bgp
, dest
, afi
, safi
);
9867 bgp_dest_unlock_node(dest
);
9874 /* one clear bgp command to rule them all */
9875 DEFUN (clear_ip_bgp_all
,
9876 clear_ip_bgp_all_cmd
,
9877 "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|message-stats>]",
9881 BGP_INSTANCE_HELP_STR
9884 BGP_SAFI_WITH_LABEL_HELP_STR
9887 "BGP IPv4 neighbor to clear\n"
9888 "BGP IPv6 neighbor to clear\n"
9889 "BGP neighbor on interface to clear\n"
9890 "Clear peers with the AS number\n"
9891 "Clear all external peers\n"
9892 "Clear all members of peer-group\n"
9893 "BGP peer-group name\n"
9898 "Push out prefix-list ORF and do inbound soft reconfig\n"
9900 "Reset message statistics\n")
9904 afi_t afi
= AFI_UNSPEC
;
9905 safi_t safi
= SAFI_UNSPEC
;
9906 enum clear_sort clr_sort
= clear_peer
;
9907 enum bgp_clear_type clr_type
;
9908 char *clr_arg
= NULL
;
9912 /* clear [ip] bgp */
9913 if (argv_find(argv
, argc
, "ip", &idx
))
9916 /* [<vrf> VIEWVRFNAME] */
9917 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9918 vrf
= argv
[idx
+ 1]->arg
;
9920 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9922 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9923 /* [<view> VIEWVRFNAME] */
9924 vrf
= argv
[idx
+ 1]->arg
;
9927 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9928 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
9929 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
9931 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
9932 if (argv_find(argv
, argc
, "*", &idx
)) {
9933 clr_sort
= clear_all
;
9934 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
9935 clr_sort
= clear_peer
;
9936 clr_arg
= argv
[idx
]->arg
;
9937 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
9938 clr_sort
= clear_peer
;
9939 clr_arg
= argv
[idx
]->arg
;
9940 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
9941 clr_sort
= clear_group
;
9943 clr_arg
= argv
[idx
]->arg
;
9944 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
9945 clr_sort
= clear_peer
;
9946 clr_arg
= argv
[idx
]->arg
;
9947 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
9948 clr_sort
= clear_peer
;
9949 clr_arg
= argv
[idx
]->arg
;
9950 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
9951 clr_sort
= clear_as
;
9952 clr_arg
= argv
[idx
]->arg
;
9953 } else if (argv_find(argv
, argc
, "external", &idx
)) {
9954 clr_sort
= clear_external
;
9957 /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */
9958 if (argv_find(argv
, argc
, "soft", &idx
)) {
9959 if (argv_find(argv
, argc
, "in", &idx
)
9960 || argv_find(argv
, argc
, "out", &idx
))
9961 clr_type
= strmatch(argv
[idx
]->text
, "in")
9963 : BGP_CLEAR_SOFT_OUT
;
9965 clr_type
= BGP_CLEAR_SOFT_BOTH
;
9966 } else if (argv_find(argv
, argc
, "in", &idx
)) {
9967 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
9968 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
9969 : BGP_CLEAR_SOFT_IN
;
9970 } else if (argv_find(argv
, argc
, "out", &idx
)) {
9971 clr_type
= BGP_CLEAR_SOFT_OUT
;
9972 } else if (argv_find(argv
, argc
, "message-stats", &idx
)) {
9973 clr_type
= BGP_CLEAR_MESSAGE_STATS
;
9975 clr_type
= BGP_CLEAR_SOFT_NONE
;
9977 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
9980 DEFUN (clear_ip_bgp_prefix
,
9981 clear_ip_bgp_prefix_cmd
,
9982 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
9986 BGP_INSTANCE_HELP_STR
9987 "Clear bestpath and re-advertise\n"
9991 char *prefix
= NULL
;
9995 /* [<view|vrf> VIEWVRFNAME] */
9996 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9997 vrf
= argv
[idx
+ 1]->arg
;
9999 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10001 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10002 /* [<view> VIEWVRFNAME] */
10003 vrf
= argv
[idx
+ 1]->arg
;
10007 prefix
= argv
[argc
- 1]->arg
;
10009 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
10012 DEFUN (clear_bgp_ipv6_safi_prefix
,
10013 clear_bgp_ipv6_safi_prefix_cmd
,
10014 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10020 "Clear bestpath and re-advertise\n"
10024 int idx_ipv6_prefix
= 0;
10025 safi_t safi
= SAFI_UNICAST
;
10026 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10027 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10029 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10030 return bgp_clear_prefix(
10031 vty
, NULL
, prefix
, AFI_IP6
,
10035 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
10036 clear_bgp_instance_ipv6_safi_prefix_cmd
,
10037 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10041 BGP_INSTANCE_HELP_STR
10044 "Clear bestpath and re-advertise\n"
10048 int idx_vrfview
= 0;
10049 int idx_ipv6_prefix
= 0;
10050 safi_t safi
= SAFI_UNICAST
;
10051 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10052 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10053 char *vrfview
= NULL
;
10055 /* [<view|vrf> VIEWVRFNAME] */
10056 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
10057 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10058 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
10060 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
10061 /* [<view> VIEWVRFNAME] */
10062 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10064 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10066 return bgp_clear_prefix(
10067 vty
, vrfview
, prefix
,
10068 AFI_IP6
, safi
, NULL
);
10071 DEFUN (show_bgp_views
,
10072 show_bgp_views_cmd
,
10073 "show [ip] bgp views",
10077 "Show the defined BGP views\n")
10079 struct list
*inst
= bm
->bgp
;
10080 struct listnode
*node
;
10083 vty_out(vty
, "Defined BGP views:\n");
10084 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10086 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10088 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
10092 return CMD_SUCCESS
;
10095 DEFUN (show_bgp_vrfs
,
10097 "show [ip] bgp vrfs [json]",
10104 char buf
[ETHER_ADDR_STRLEN
];
10105 struct list
*inst
= bm
->bgp
;
10106 struct listnode
*node
;
10108 bool uj
= use_json(argc
, argv
);
10109 json_object
*json
= NULL
;
10110 json_object
*json_vrfs
= NULL
;
10114 json
= json_object_new_object();
10115 json_vrfs
= json_object_new_object();
10118 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10119 const char *name
, *type
;
10121 struct listnode
*node2
, *nnode2
;
10122 int peers_cfg
, peers_estb
;
10123 json_object
*json_vrf
= NULL
;
10126 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10130 if (!uj
&& count
== 1) {
10132 "%4s %-5s %-16s %9s %10s %-37s\n",
10133 "Type", "Id", "routerId", "#PeersCfg",
10134 "#PeersEstb", "Name");
10135 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10136 "L3-VNI", "RouterMAC", "Interface");
10139 peers_cfg
= peers_estb
= 0;
10141 json_vrf
= json_object_new_object();
10144 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
10145 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10148 if (peer_established(peer
))
10152 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10153 name
= VRF_DEFAULT_NAME
;
10162 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10164 : (int64_t)bgp
->vrf_id
;
10165 char buf
[BUFSIZ
] = {0};
10167 json_object_string_add(json_vrf
, "type", type
);
10168 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
10169 json_object_string_addf(json_vrf
, "routerId", "%pI4",
10171 json_object_int_add(json_vrf
, "numConfiguredPeers",
10173 json_object_int_add(json_vrf
, "numEstablishedPeers",
10176 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
10177 json_object_string_add(
10179 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
10180 json_object_string_add(json_vrf
, "interface",
10181 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10183 json_object_object_add(json_vrfs
, name
, json_vrf
);
10185 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10187 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10188 : (int)bgp
->vrf_id
,
10189 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10190 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
10192 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
10193 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10199 json_object_object_add(json
, "vrfs", json_vrfs
);
10201 json_object_int_add(json
, "totalVrfs", count
);
10203 vty_json(vty
, json
);
10207 "\nTotal number of VRFs (including default): %d\n",
10211 return CMD_SUCCESS
;
10214 DEFUN (show_bgp_mac_hash
,
10215 show_bgp_mac_hash_cmd
,
10216 "show bgp mac hash",
10220 "Mac Address database\n")
10222 bgp_mac_dump_table(vty
);
10224 return CMD_SUCCESS
;
10227 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10229 struct vty
*vty
= (struct vty
*)args
;
10230 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10232 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10235 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10237 vty_out(vty
, "self nexthop database:\n");
10238 bgp_nexthop_show_address_hash(vty
, bgp
);
10240 vty_out(vty
, "Tunnel-ip database:\n");
10241 hash_iterate(bgp
->tip_hash
,
10242 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10246 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10247 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10248 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10249 "martian next-hops\n"
10250 "martian next-hop database\n")
10252 struct bgp
*bgp
= NULL
;
10256 /* [<vrf> VIEWVRFNAME] */
10257 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10258 name
= argv
[idx
+ 1]->arg
;
10259 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10261 } else if (argv_find(argv
, argc
, "view", &idx
))
10262 /* [<view> VIEWVRFNAME] */
10263 name
= argv
[idx
+ 1]->arg
;
10265 bgp
= bgp_lookup_by_name(name
);
10267 bgp
= bgp_get_default();
10270 vty_out(vty
, "%% No BGP process is configured\n");
10271 return CMD_WARNING
;
10273 bgp_show_martian_nexthops(vty
, bgp
);
10275 return CMD_SUCCESS
;
10278 DEFUN (show_bgp_memory
,
10279 show_bgp_memory_cmd
,
10280 "show [ip] bgp memory",
10284 "Global BGP memory statistics\n")
10286 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10287 unsigned long count
;
10289 /* RIB related usage stats */
10290 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10291 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10292 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10293 count
* sizeof(struct bgp_dest
)));
10295 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10296 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10297 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10298 count
* sizeof(struct bgp_path_info
)));
10299 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10300 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10303 memstrbuf
, sizeof(memstrbuf
),
10304 count
* sizeof(struct bgp_path_info_extra
)));
10306 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10307 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10308 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10309 count
* sizeof(struct bgp_static
)));
10311 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10312 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10313 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10314 count
* sizeof(struct bpacket
)));
10317 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10318 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10319 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10320 count
* sizeof(struct bgp_adj_in
)));
10321 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10322 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10323 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10324 count
* sizeof(struct bgp_adj_out
)));
10326 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10327 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10329 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10330 count
* sizeof(struct bgp_nexthop_cache
)));
10332 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10333 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10335 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10336 count
* sizeof(struct bgp_damp_info
)));
10339 count
= attr_count();
10340 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10341 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10342 count
* sizeof(struct attr
)));
10344 if ((count
= attr_unknown_count()))
10345 vty_out(vty
, "%ld unknown attributes\n", count
);
10347 /* AS_PATH attributes */
10348 count
= aspath_count();
10349 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10350 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10351 count
* sizeof(struct aspath
)));
10353 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10354 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10355 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10356 count
* sizeof(struct assegment
)));
10358 /* Other attributes */
10359 if ((count
= community_count()))
10360 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10361 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10362 count
* sizeof(struct community
)));
10363 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10365 "%ld BGP ext-community entries, using %s of memory\n",
10367 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10368 count
* sizeof(struct ecommunity
)));
10369 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10371 "%ld BGP large-community entries, using %s of memory\n",
10372 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10373 count
* sizeof(struct lcommunity
)));
10375 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10376 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10377 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10378 count
* sizeof(struct cluster_list
)));
10380 /* Peer related usage */
10381 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10382 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10383 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10384 count
* sizeof(struct peer
)));
10386 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10387 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10388 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10389 count
* sizeof(struct peer_group
)));
10392 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10393 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10394 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10395 count
* sizeof(regex_t
)));
10396 return CMD_SUCCESS
;
10399 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10401 json_object
*bestpath
= json_object_new_object();
10403 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10404 json_object_string_add(bestpath
, "asPath", "ignore");
10406 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10407 json_object_string_add(bestpath
, "asPath", "confed");
10409 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10410 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10411 json_object_string_add(bestpath
, "multiPathRelax",
10414 json_object_string_add(bestpath
, "multiPathRelax",
10417 json_object_string_add(bestpath
, "multiPathRelax", "false");
10419 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10420 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10422 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10423 json_object_string_add(bestpath
, "compareRouterId", "true");
10424 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10425 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10426 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10427 json_object_string_add(bestpath
, "med", "confed");
10428 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10429 json_object_string_add(bestpath
, "med",
10430 "missing-as-worst");
10432 json_object_string_add(bestpath
, "med", "true");
10435 json_object_object_add(json
, "bestPath", bestpath
);
10438 /* Print the error code/subcode for why the peer is down */
10439 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10440 json_object
*json_peer
, bool use_json
)
10442 const char *code_str
;
10443 const char *subcode_str
;
10446 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10447 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10448 char errorcodesubcode_hexstr
[5];
10449 char errorcodesubcode_str
[256];
10451 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10452 subcode_str
= bgp_notify_subcode_str(
10454 peer
->notify
.subcode
);
10456 snprintf(errorcodesubcode_hexstr
,
10457 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10458 peer
->notify
.code
, peer
->notify
.subcode
);
10459 json_object_string_add(json_peer
,
10460 "lastErrorCodeSubcode",
10461 errorcodesubcode_hexstr
);
10462 snprintf(errorcodesubcode_str
, 255, "%s%s",
10463 code_str
, subcode_str
);
10464 json_object_string_add(json_peer
,
10465 "lastNotificationReason",
10466 errorcodesubcode_str
);
10467 json_object_boolean_add(json_peer
,
10468 "lastNotificationHardReset",
10469 peer
->notify
.hard_reset
);
10470 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10471 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10472 && (peer
->notify
.subcode
10473 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10474 || peer
->notify
.subcode
10475 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10476 && peer
->notify
.length
) {
10478 const char *msg_str
;
10480 msg_str
= bgp_notify_admin_message(
10481 msgbuf
, sizeof(msgbuf
),
10482 (uint8_t *)peer
->notify
.data
,
10483 peer
->notify
.length
);
10485 json_object_string_add(
10487 "lastShutdownDescription",
10492 json_object_string_add(json_peer
, "lastResetDueTo",
10493 peer_down_str
[(int)peer
->last_reset
]);
10494 json_object_int_add(json_peer
, "lastResetCode",
10497 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10498 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10499 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10501 bgp_notify_subcode_str(peer
->notify
.code
,
10502 peer
->notify
.subcode
);
10503 vty_out(vty
, " Notification %s (%s%s%s)\n",
10504 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10507 code_str
, subcode_str
,
10508 peer
->notify
.hard_reset
10509 ? bgp_notify_subcode_str(
10511 BGP_NOTIFY_CEASE_HARD_RESET
)
10514 vty_out(vty
, " %s\n",
10515 peer_down_str
[(int)peer
->last_reset
]);
10520 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10523 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10526 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10527 struct peer
*peer
, json_object
*json_peer
,
10528 int max_neighbor_width
, bool use_json
)
10530 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10534 if (peer_dynamic_neighbor(peer
))
10535 json_object_boolean_true_add(json_peer
,
10537 if (peer
->hostname
)
10538 json_object_string_add(json_peer
, "hostname",
10541 if (peer
->domainname
)
10542 json_object_string_add(json_peer
, "domainname",
10544 json_object_int_add(json_peer
, "connectionsEstablished",
10545 peer
->established
);
10546 json_object_int_add(json_peer
, "connectionsDropped",
10548 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10549 use_json
, json_peer
);
10550 if (peer_established(peer
))
10551 json_object_string_add(json_peer
, "lastResetDueTo",
10552 "AFI/SAFI Not Negotiated");
10554 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10557 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10559 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10560 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10561 peer
->hostname
, peer
->host
);
10563 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10565 /* pad the neighbor column with spaces */
10566 if (len
< max_neighbor_width
)
10567 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10569 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10571 peer_uptime(peer
->uptime
, timebuf
,
10572 BGP_UPTIME_LEN
, 0, NULL
));
10573 if (peer_established(peer
))
10574 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10576 bgp_show_peer_reset(vty
, peer
, NULL
,
10581 /* Strip peer's description to the given size. */
10582 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10584 static char stripped
[BUFSIZ
];
10586 uint32_t last_space
= 0;
10589 if (*(desc
+ i
) == 0) {
10590 stripped
[i
] = '\0';
10593 if (i
!= 0 && *(desc
+ i
) == ' ' && last_space
!= i
- 1)
10595 stripped
[i
] = *(desc
+ i
);
10599 if (last_space
> size
)
10600 stripped
[size
+ 1] = '\0';
10602 stripped
[last_space
] = '\0';
10607 /* Determine whether var peer should be filtered out of the summary. */
10608 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10609 struct peer
*fpeer
, int as_type
,
10613 /* filter neighbor XXXX */
10614 if (fpeer
&& fpeer
!= peer
)
10617 /* filter remote-as (internal|external) */
10618 if (as_type
!= AS_UNSPECIFIED
) {
10619 if (peer
->as_type
== AS_SPECIFIED
) {
10620 if (as_type
== AS_INTERNAL
) {
10621 if (peer
->as
!= peer
->local_as
)
10623 } else if (peer
->as
== peer
->local_as
)
10625 } else if (as_type
!= peer
->as_type
)
10627 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10633 /* Show BGP peer's summary information.
10635 * Peer's description is stripped according to if `wide` option is given
10638 * When adding new columns to `show bgp summary` output, please make
10639 * sure `Desc` is the lastest column to show because it can contain
10640 * whitespaces and the whole output will be tricky.
10642 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10643 struct peer
*fpeer
, int as_type
, as_t as
,
10644 uint16_t show_flags
)
10647 struct listnode
*node
, *nnode
;
10648 unsigned int count
= 0, dn_count
= 0;
10649 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10650 char neighbor_buf
[VTY_BUFSIZ
];
10651 int neighbor_col_default_width
= 16;
10652 int len
, failed_count
= 0;
10653 unsigned int filtered_count
= 0;
10654 int max_neighbor_width
= 0;
10656 json_object
*json
= NULL
;
10657 json_object
*json_peer
= NULL
;
10658 json_object
*json_peers
= NULL
;
10659 struct peer_af
*paf
;
10660 struct bgp_filter
*filter
;
10661 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10662 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10663 bool show_established
=
10664 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10665 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10666 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
10668 /* labeled-unicast routes are installed in the unicast table so in order
10670 * display the correct PfxRcd value we must look at SAFI_UNICAST
10673 if (safi
== SAFI_LABELED_UNICAST
)
10674 pfx_rcd_safi
= SAFI_UNICAST
;
10676 pfx_rcd_safi
= safi
;
10679 json
= json_object_new_object();
10680 json_peers
= json_object_new_object();
10681 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10682 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10689 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10692 if (peer
->afc
[afi
][safi
]) {
10693 /* See if we have at least a single failed peer */
10694 if (bgp_has_peer_failed(peer
, afi
, safi
))
10698 if (peer_dynamic_neighbor(peer
))
10703 /* Loop over all neighbors that will be displayed to determine
10705 * characters are needed for the Neighbor column
10707 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10708 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10715 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10718 if (peer
->afc
[afi
][safi
]) {
10719 memset(dn_flag
, '\0', sizeof(dn_flag
));
10720 if (peer_dynamic_neighbor(peer
))
10724 && CHECK_FLAG(bgp
->flags
,
10725 BGP_FLAG_SHOW_HOSTNAME
))
10726 snprintf(neighbor_buf
,
10727 sizeof(neighbor_buf
),
10728 "%s%s(%s) ", dn_flag
,
10729 peer
->hostname
, peer
->host
);
10731 snprintf(neighbor_buf
,
10732 sizeof(neighbor_buf
), "%s%s ",
10733 dn_flag
, peer
->host
);
10735 len
= strlen(neighbor_buf
);
10737 if (len
> max_neighbor_width
)
10738 max_neighbor_width
= len
;
10740 /* See if we have at least a single failed peer */
10741 if (bgp_has_peer_failed(peer
, afi
, safi
))
10747 /* Originally we displayed the Neighbor column as 16
10748 * characters wide so make that the default
10750 if (max_neighbor_width
< neighbor_col_default_width
)
10751 max_neighbor_width
= neighbor_col_default_width
;
10754 if (show_failed
&& !failed_count
) {
10756 json_object_int_add(json
, "failedPeersCount", 0);
10757 json_object_int_add(json
, "dynamicPeers", dn_count
);
10758 json_object_int_add(json
, "totalPeers", count
);
10760 vty_json(vty
, json
);
10762 vty_out(vty
, "%% No failed BGP neighbors found\n");
10764 return CMD_SUCCESS
;
10767 count
= 0; /* Reset the value as its used again */
10768 filtered_count
= 0;
10770 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10771 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10774 if (!peer
->afc
[afi
][safi
])
10778 unsigned long ents
;
10779 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10782 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10784 : (int64_t)bgp
->vrf_id
;
10786 /* Usage summary and header */
10788 json_object_string_addf(json
, "routerId",
10791 json_object_int_add(json
, "as", bgp
->as
);
10792 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10793 json_object_string_add(
10796 == BGP_INSTANCE_TYPE_DEFAULT
)
10801 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10802 &bgp
->router_id
, bgp
->as
,
10803 bgp
->vrf_id
== VRF_UNKNOWN
10805 : (int)bgp
->vrf_id
);
10806 vty_out(vty
, "\n");
10809 if (bgp_update_delay_configured(bgp
)) {
10811 json_object_int_add(
10812 json
, "updateDelayLimit",
10813 bgp
->v_update_delay
);
10815 if (bgp
->v_update_delay
10816 != bgp
->v_establish_wait
)
10817 json_object_int_add(
10819 "updateDelayEstablishWait",
10820 bgp
->v_establish_wait
);
10822 if (bgp_update_delay_active(bgp
)) {
10823 json_object_string_add(
10825 "updateDelayFirstNeighbor",
10826 bgp
->update_delay_begin_time
);
10827 json_object_boolean_true_add(
10829 "updateDelayInProgress");
10831 if (bgp
->update_delay_over
) {
10832 json_object_string_add(
10834 "updateDelayFirstNeighbor",
10835 bgp
->update_delay_begin_time
);
10836 json_object_string_add(
10838 "updateDelayBestpathResumed",
10839 bgp
->update_delay_end_time
);
10840 json_object_string_add(
10842 "updateDelayZebraUpdateResume",
10843 bgp
->update_delay_zebra_resume_time
);
10844 json_object_string_add(
10846 "updateDelayPeerUpdateResume",
10847 bgp
->update_delay_peers_resume_time
);
10852 "Read-only mode update-delay limit: %d seconds\n",
10853 bgp
->v_update_delay
);
10854 if (bgp
->v_update_delay
10855 != bgp
->v_establish_wait
)
10857 " Establish wait: %d seconds\n",
10858 bgp
->v_establish_wait
);
10860 if (bgp_update_delay_active(bgp
)) {
10862 " First neighbor established: %s\n",
10863 bgp
->update_delay_begin_time
);
10865 " Delay in progress\n");
10867 if (bgp
->update_delay_over
) {
10869 " First neighbor established: %s\n",
10870 bgp
->update_delay_begin_time
);
10872 " Best-paths resumed: %s\n",
10873 bgp
->update_delay_end_time
);
10875 " zebra update resumed: %s\n",
10876 bgp
->update_delay_zebra_resume_time
);
10878 " peers update resumed: %s\n",
10879 bgp
->update_delay_peers_resume_time
);
10886 if (bgp_maxmed_onstartup_configured(bgp
)
10887 && bgp
->maxmed_active
)
10888 json_object_boolean_true_add(
10889 json
, "maxMedOnStartup");
10890 if (bgp
->v_maxmed_admin
)
10891 json_object_boolean_true_add(
10892 json
, "maxMedAdministrative");
10894 json_object_int_add(
10895 json
, "tableVersion",
10896 bgp_table_version(bgp
->rib
[afi
][safi
]));
10898 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10899 json_object_int_add(json
, "ribCount", ents
);
10900 json_object_int_add(
10902 ents
* sizeof(struct bgp_dest
));
10904 ents
= bgp
->af_peer_count
[afi
][safi
];
10905 json_object_int_add(json
, "peerCount", ents
);
10906 json_object_int_add(json
, "peerMemory",
10907 ents
* sizeof(struct peer
));
10909 if ((ents
= listcount(bgp
->group
))) {
10910 json_object_int_add(
10911 json
, "peerGroupCount", ents
);
10912 json_object_int_add(
10913 json
, "peerGroupMemory",
10914 ents
* sizeof(struct
10918 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10919 BGP_CONFIG_DAMPENING
))
10920 json_object_boolean_true_add(
10921 json
, "dampeningEnabled");
10924 if (bgp_maxmed_onstartup_configured(bgp
)
10925 && bgp
->maxmed_active
)
10927 "Max-med on-startup active\n");
10928 if (bgp
->v_maxmed_admin
)
10930 "Max-med administrative active\n");
10933 "BGP table version %" PRIu64
10936 bgp
->rib
[afi
][safi
]));
10938 ents
= bgp_table_count(
10939 bgp
->rib
[afi
][safi
]);
10941 "RIB entries %ld, using %s of memory\n",
10951 /* Peer related usage */
10952 ents
= bgp
->af_peer_count
[afi
][safi
];
10954 "Peers %ld, using %s of memory\n",
10964 if ((ents
= listcount(bgp
->group
)))
10966 "Peer groups %ld, using %s of memory\n",
10976 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10977 BGP_CONFIG_DAMPENING
))
10979 "Dampening enabled.\n");
10982 vty_out(vty
, "\n");
10984 /* Subtract 8 here because 'Neighbor' is
10986 vty_out(vty
, "Neighbor");
10987 vty_out(vty
, "%*s",
10988 max_neighbor_width
- 8, " ");
10990 BGP_SHOW_SUMMARY_HEADER_FAILED
);
10995 paf
= peer_af_find(peer
, afi
, safi
);
10996 filter
= &peer
->filter
[afi
][safi
];
10999 /* Works for both failed & successful cases */
11000 if (peer_dynamic_neighbor(peer
))
11005 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11011 bgp_has_peer_failed(peer
, afi
, safi
)) {
11012 json_peer
= json_object_new_object();
11013 bgp_show_failed_summary(vty
, bgp
, peer
,
11014 json_peer
, 0, use_json
);
11015 } else if (!show_failed
) {
11016 if (show_established
11017 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11022 json_peer
= json_object_new_object();
11023 if (peer_dynamic_neighbor(peer
)) {
11024 json_object_boolean_true_add(json_peer
,
11028 if (peer
->hostname
)
11029 json_object_string_add(json_peer
, "hostname",
11032 if (peer
->domainname
)
11033 json_object_string_add(json_peer
, "domainname",
11036 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
11037 json_object_int_add(
11038 json_peer
, "localAs",
11039 peer
->change_local_as
11040 ? peer
->change_local_as
11042 json_object_int_add(json_peer
, "version", 4);
11043 json_object_int_add(json_peer
, "msgRcvd",
11044 PEER_TOTAL_RX(peer
));
11045 json_object_int_add(json_peer
, "msgSent",
11046 PEER_TOTAL_TX(peer
));
11048 atomic_size_t outq_count
, inq_count
;
11049 outq_count
= atomic_load_explicit(
11050 &peer
->obuf
->count
,
11051 memory_order_relaxed
);
11052 inq_count
= atomic_load_explicit(
11053 &peer
->ibuf
->count
,
11054 memory_order_relaxed
);
11056 json_object_int_add(json_peer
, "tableVersion",
11057 peer
->version
[afi
][safi
]);
11058 json_object_int_add(json_peer
, "outq",
11060 json_object_int_add(json_peer
, "inq",
11062 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
11063 use_json
, json_peer
);
11065 json_object_int_add(json_peer
, "pfxRcd",
11066 peer
->pcount
[afi
][pfx_rcd_safi
]);
11068 if (paf
&& PAF_SUBGRP(paf
))
11069 json_object_int_add(
11070 json_peer
, "pfxSnt",
11071 (PAF_SUBGRP(paf
))->scount
);
11073 json_object_int_add(json_peer
, "pfxSnt",
11076 /* BGP FSM state */
11077 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11078 || CHECK_FLAG(peer
->bgp
->flags
,
11079 BGP_FLAG_SHUTDOWN
))
11080 json_object_string_add(json_peer
,
11083 else if (peer
->afc_recv
[afi
][safi
])
11084 json_object_string_add(
11085 json_peer
, "state",
11086 lookup_msg(bgp_status_msg
,
11087 peer
->status
, NULL
));
11088 else if (CHECK_FLAG(
11090 PEER_STATUS_PREFIX_OVERFLOW
))
11091 json_object_string_add(json_peer
,
11095 json_object_string_add(
11096 json_peer
, "state",
11097 lookup_msg(bgp_status_msg
,
11098 peer
->status
, NULL
));
11100 /* BGP peer state */
11101 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11102 || CHECK_FLAG(peer
->bgp
->flags
,
11103 BGP_FLAG_SHUTDOWN
))
11104 json_object_string_add(json_peer
,
11107 else if (CHECK_FLAG(
11109 PEER_STATUS_PREFIX_OVERFLOW
))
11110 json_object_string_add(json_peer
,
11113 else if (CHECK_FLAG(peer
->flags
,
11114 PEER_FLAG_PASSIVE
))
11115 json_object_string_add(json_peer
,
11118 else if (CHECK_FLAG(peer
->sflags
,
11119 PEER_STATUS_NSF_WAIT
))
11120 json_object_string_add(json_peer
,
11123 else if (CHECK_FLAG(
11125 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11126 && (!bgp_inbound_policy_exists(peer
,
11128 || !bgp_outbound_policy_exists(
11130 json_object_string_add(json_peer
,
11134 json_object_string_add(
11135 json_peer
, "peerState", "OK");
11137 json_object_int_add(json_peer
, "connectionsEstablished",
11138 peer
->established
);
11139 json_object_int_add(json_peer
, "connectionsDropped",
11142 json_object_string_add(
11143 json_peer
, "desc", peer
->desc
);
11145 /* Avoid creating empty peer dicts in JSON */
11146 if (json_peer
== NULL
)
11150 json_object_string_add(json_peer
, "idType",
11152 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11153 json_object_string_add(json_peer
, "idType",
11155 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11156 json_object_string_add(json_peer
, "idType",
11158 json_object_object_add(json_peers
, peer
->host
,
11161 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11167 bgp_has_peer_failed(peer
, afi
, safi
)) {
11168 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11169 max_neighbor_width
,
11171 } else if (!show_failed
) {
11172 if (show_established
11173 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11178 if ((count
- filtered_count
) == 1) {
11179 /* display headline before the first
11181 vty_out(vty
, "\n");
11183 /* Subtract 8 here because 'Neighbor' is
11185 vty_out(vty
, "Neighbor");
11186 vty_out(vty
, "%*s",
11187 max_neighbor_width
- 8, " ");
11190 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
11191 : BGP_SHOW_SUMMARY_HEADER_ALL
);
11194 memset(dn_flag
, '\0', sizeof(dn_flag
));
11195 if (peer_dynamic_neighbor(peer
)) {
11200 && CHECK_FLAG(bgp
->flags
,
11201 BGP_FLAG_SHOW_HOSTNAME
))
11202 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11206 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11208 /* pad the neighbor column with spaces */
11209 if (len
< max_neighbor_width
)
11210 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11213 atomic_size_t outq_count
, inq_count
;
11214 outq_count
= atomic_load_explicit(
11215 &peer
->obuf
->count
,
11216 memory_order_relaxed
);
11217 inq_count
= atomic_load_explicit(
11218 &peer
->ibuf
->count
,
11219 memory_order_relaxed
);
11223 "4 %10u %10u %9u %9u %8" PRIu64
11226 peer
->change_local_as
11227 ? peer
->change_local_as
11229 PEER_TOTAL_RX(peer
),
11230 PEER_TOTAL_TX(peer
),
11231 peer
->version
[afi
][safi
],
11232 inq_count
, outq_count
,
11233 peer_uptime(peer
->uptime
,
11238 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11240 peer
->as
, PEER_TOTAL_RX(peer
),
11241 PEER_TOTAL_TX(peer
),
11242 peer
->version
[afi
][safi
],
11243 inq_count
, outq_count
,
11244 peer_uptime(peer
->uptime
,
11249 if (peer_established(peer
)) {
11250 if (peer
->afc_recv
[afi
][safi
]) {
11253 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11254 && !bgp_inbound_policy_exists(
11256 vty_out(vty
, " %12s",
11265 vty_out(vty
, " NoNeg");
11268 if (paf
&& PAF_SUBGRP(paf
)) {
11271 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11272 && !bgp_outbound_policy_exists(
11274 vty_out(vty
, " %8s",
11283 vty_out(vty
, " NoNeg");
11286 if (CHECK_FLAG(peer
->flags
,
11287 PEER_FLAG_SHUTDOWN
)
11288 || CHECK_FLAG(peer
->bgp
->flags
,
11289 BGP_FLAG_SHUTDOWN
))
11290 vty_out(vty
, " Idle (Admin)");
11291 else if (CHECK_FLAG(
11293 PEER_STATUS_PREFIX_OVERFLOW
))
11294 vty_out(vty
, " Idle (PfxCt)");
11296 vty_out(vty
, " %12s",
11297 lookup_msg(bgp_status_msg
,
11298 peer
->status
, NULL
));
11300 vty_out(vty
, " %8u", 0);
11302 /* Make sure `Desc` column is the lastest in
11306 vty_out(vty
, " %s",
11307 bgp_peer_description_stripped(
11309 show_wide
? 64 : 20));
11311 vty_out(vty
, " N/A");
11312 vty_out(vty
, "\n");
11319 json_object_object_add(json
, "peers", json_peers
);
11320 json_object_int_add(json
, "failedPeers", failed_count
);
11321 json_object_int_add(json
, "displayedPeers",
11322 count
- filtered_count
);
11323 json_object_int_add(json
, "totalPeers", count
);
11324 json_object_int_add(json
, "dynamicPeers", dn_count
);
11327 bgp_show_bestpath_json(bgp
, json
);
11329 vty_json(vty
, json
);
11332 if (filtered_count
== count
)
11333 vty_out(vty
, "\n%% No matching neighbor\n");
11336 vty_out(vty
, "\nDisplayed neighbors %d",
11338 else if (as_type
!= AS_UNSPECIFIED
|| as
11339 || fpeer
|| show_established
)
11340 vty_out(vty
, "\nDisplayed neighbors %d",
11341 count
- filtered_count
);
11343 vty_out(vty
, "\nTotal number of neighbors %d\n",
11347 vty_out(vty
, "No %s neighbor is configured\n",
11348 get_afi_safi_str(afi
, safi
, false));
11352 vty_out(vty
, "* - dynamic neighbor\n");
11353 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11354 dn_count
, bgp
->dynamic_neighbors_limit
);
11358 return CMD_SUCCESS
;
11361 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11362 int safi
, struct peer
*fpeer
, int as_type
,
11363 as_t as
, uint16_t show_flags
)
11366 int afi_wildcard
= (afi
== AFI_MAX
);
11367 int safi_wildcard
= (safi
== SAFI_MAX
);
11368 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11369 bool nbr_output
= false;
11370 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11372 if (use_json
&& is_wildcard
)
11373 vty_out(vty
, "{\n");
11375 afi
= 1; /* AFI_IP */
11376 while (afi
< AFI_MAX
) {
11378 safi
= 1; /* SAFI_UNICAST */
11379 while (safi
< SAFI_MAX
) {
11380 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11385 * So limit output to those afi/safi
11387 * actualy have something interesting in
11392 vty_out(vty
, ",\n");
11396 vty_out(vty
, "\"%s\":",
11397 get_afi_safi_str(afi
,
11402 "\n%s Summary (%s):\n",
11403 get_afi_safi_str(afi
,
11409 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11410 as_type
, as
, show_flags
);
11413 if (!safi_wildcard
)
11421 if (use_json
&& is_wildcard
)
11422 vty_out(vty
, "}\n");
11423 else if (!nbr_output
) {
11425 vty_out(vty
, "{}\n");
11427 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11432 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11434 const char *neighbor
,
11435 int as_type
, as_t as
,
11436 uint16_t show_flags
)
11438 struct listnode
*node
, *nnode
;
11440 struct peer
*fpeer
= NULL
;
11442 bool nbr_output
= false;
11443 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11446 vty_out(vty
, "{\n");
11448 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11452 vty_out(vty
, ",\n");
11456 vty_out(vty
, "\"%s\":",
11457 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11462 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11467 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11472 vty_out(vty
, "}\n");
11473 else if (!nbr_output
)
11474 vty_out(vty
, "%% BGP instance not found\n");
11477 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11478 safi_t safi
, const char *neighbor
, int as_type
,
11479 as_t as
, uint16_t show_flags
)
11482 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11483 struct peer
*fpeer
= NULL
;
11486 if (strmatch(name
, "all")) {
11487 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11490 return CMD_SUCCESS
;
11492 bgp
= bgp_lookup_by_name(name
);
11496 vty_out(vty
, "{}\n");
11499 "%% BGP instance not found\n");
11500 return CMD_WARNING
;
11504 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11507 return CMD_WARNING
;
11509 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11510 as_type
, as
, show_flags
);
11511 return CMD_SUCCESS
;
11515 bgp
= bgp_get_default();
11519 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11522 return CMD_WARNING
;
11524 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11528 vty_out(vty
, "{}\n");
11530 vty_out(vty
, "%% BGP instance not found\n");
11531 return CMD_WARNING
;
11534 return CMD_SUCCESS
;
11537 /* `show [ip] bgp summary' commands. */
11538 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11539 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11540 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11541 "]] [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]",
11542 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11543 BGP_SAFI_WITH_LABEL_HELP_STR
11544 "Display the entries for all address families\n"
11545 "Summary of BGP neighbor status\n"
11546 "Show only sessions in Established state\n"
11547 "Show only sessions not in Established state\n"
11548 "Show only the specified neighbor session\n"
11549 "Neighbor to display information about\n"
11550 "Neighbor to display information about\n"
11551 "Neighbor on BGP configured interface\n"
11552 "Show only the specified remote AS sessions\n"
11554 "Internal (iBGP) AS sessions\n"
11555 "External (eBGP) AS sessions\n"
11556 "Shorten the information on BGP instances\n"
11557 "Increase table width for longer output\n" JSON_STR
)
11560 afi_t afi
= AFI_MAX
;
11561 safi_t safi
= SAFI_MAX
;
11562 as_t as
= 0; /* 0 means AS filter not set */
11563 int as_type
= AS_UNSPECIFIED
;
11564 uint16_t show_flags
= 0;
11568 /* show [ip] bgp */
11569 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11571 /* [<vrf> VIEWVRFNAME] */
11572 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11573 vrf
= argv
[idx
+ 1]->arg
;
11574 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11576 } else if (argv_find(argv
, argc
, "view", &idx
))
11577 /* [<view> VIEWVRFNAME] */
11578 vrf
= argv
[idx
+ 1]->arg
;
11579 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11580 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11581 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11584 if (argv_find(argv
, argc
, "failed", &idx
))
11585 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11587 if (argv_find(argv
, argc
, "established", &idx
))
11588 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11590 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11591 if (argv
[idx
+ 1]->arg
[0] == 'i')
11592 as_type
= AS_INTERNAL
;
11593 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11594 as_type
= AS_EXTERNAL
;
11596 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11599 if (argv_find(argv
, argc
, "terse", &idx
))
11600 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11602 if (argv_find(argv
, argc
, "wide", &idx
))
11603 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11605 if (argv_find(argv
, argc
, "json", &idx
))
11606 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11608 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11612 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11615 return get_afi_safi_json_str(afi
, safi
);
11617 return get_afi_safi_vty_str(afi
, safi
);
11621 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11622 afi_t afi
, safi_t safi
,
11623 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11624 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11625 bool use_json
, json_object
*json_pref
)
11628 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11629 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11631 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11632 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11633 json_object_string_add(json_pref
, "sendMode",
11634 "advertisedAndReceived");
11635 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11636 json_object_string_add(json_pref
, "sendMode",
11638 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11639 json_object_string_add(json_pref
, "sendMode",
11642 vty_out(vty
, " Send-mode: ");
11643 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11644 vty_out(vty
, "advertised");
11645 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11646 vty_out(vty
, "%sreceived",
11647 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11651 vty_out(vty
, "\n");
11656 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11657 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11659 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11660 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11661 json_object_string_add(json_pref
, "recvMode",
11662 "advertisedAndReceived");
11663 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11664 json_object_string_add(json_pref
, "recvMode",
11666 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11667 json_object_string_add(json_pref
, "recvMode",
11670 vty_out(vty
, " Receive-mode: ");
11671 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11672 vty_out(vty
, "advertised");
11673 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11674 vty_out(vty
, "%sreceived",
11675 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11679 vty_out(vty
, "\n");
11684 static void bgp_show_neighnor_graceful_restart_flags(struct vty
*vty
,
11692 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11693 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11694 && (peer_established(p
))) {
11695 rbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV
);
11696 nbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV
);
11700 json_object_boolean_add(json
, "rBit", rbit
);
11701 json_object_boolean_add(json
, "nBit", nbit
);
11703 vty_out(vty
, "\n R bit: %s", rbit
? "True" : "False");
11704 vty_out(vty
, "\n N bit: %s\n", nbit
? "True" : "False");
11708 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11713 const char *mode
= "NotApplicable";
11716 vty_out(vty
, "\n Remote GR Mode: ");
11718 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11719 && (peer_established(peer
))) {
11721 if ((peer
->nsf_af_count
== 0)
11722 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11726 } else if (peer
->nsf_af_count
== 0
11727 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11731 } else if (peer
->nsf_af_count
!= 0
11732 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11739 json_object_string_add(json
, "remoteGrMode", mode
);
11741 vty_out(vty
, mode
, "\n");
11744 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11749 const char *mode
= "Invalid";
11752 vty_out(vty
, " Local GR Mode: ");
11754 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11756 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11758 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11760 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11761 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11763 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11765 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11772 json_object_string_add(json
, "localGrMode", mode
);
11774 vty_out(vty
, mode
, "\n");
11778 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11779 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11783 json_object
*json_afi_safi
= NULL
;
11784 json_object
*json_timer
= NULL
;
11785 json_object
*json_endofrib_status
= NULL
;
11786 bool eor_flag
= false;
11788 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
11789 if (!peer
->afc
[afi
][safi
])
11792 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
11793 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11797 json_afi_safi
= json_object_new_object();
11798 json_endofrib_status
= json_object_new_object();
11799 json_timer
= json_object_new_object();
11802 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
11808 vty_out(vty
, " %s:\n",
11809 get_afi_safi_str(afi
, safi
, false));
11811 vty_out(vty
, " F bit: ");
11814 if (peer
->nsf
[afi
][safi
] &&
11815 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11816 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11819 json_object_boolean_true_add(json_afi_safi
,
11822 vty_out(vty
, "True\n");
11825 json_object_boolean_false_add(json_afi_safi
,
11828 vty_out(vty
, "False\n");
11832 vty_out(vty
, " End-of-RIB sent: ");
11834 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11835 PEER_STATUS_EOR_SEND
)) {
11837 json_object_boolean_true_add(
11838 json_endofrib_status
, "endOfRibSend");
11840 PRINT_EOR_JSON(eor_flag
);
11842 vty_out(vty
, "Yes\n");
11844 " End-of-RIB sent after update: ");
11846 PRINT_EOR(eor_flag
);
11850 json_object_boolean_false_add(
11851 json_endofrib_status
, "endOfRibSend");
11852 json_object_boolean_false_add(
11853 json_endofrib_status
,
11854 "endOfRibSentAfterUpdate");
11856 vty_out(vty
, "No\n");
11858 " End-of-RIB sent after update: ");
11859 vty_out(vty
, "No\n");
11864 vty_out(vty
, " End-of-RIB received: ");
11866 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11867 PEER_STATUS_EOR_RECEIVED
)) {
11869 json_object_boolean_true_add(
11870 json_endofrib_status
, "endOfRibRecv");
11872 vty_out(vty
, "Yes\n");
11875 json_object_boolean_false_add(
11876 json_endofrib_status
, "endOfRibRecv");
11878 vty_out(vty
, "No\n");
11882 json_object_int_add(json_timer
, "stalePathTimer",
11883 peer
->bgp
->stalepath_time
);
11885 if (peer
->t_gr_stale
!= NULL
) {
11886 json_object_int_add(json_timer
,
11887 "stalePathTimerRemaining",
11888 thread_timer_remain_second(
11889 peer
->t_gr_stale
));
11892 /* Display Configured Selection
11893 * Deferral only when when
11894 * Gr mode is enabled.
11896 if (CHECK_FLAG(peer
->flags
,
11897 PEER_FLAG_GRACEFUL_RESTART
)) {
11898 json_object_int_add(json_timer
,
11899 "selectionDeferralTimer",
11900 peer
->bgp
->stalepath_time
);
11903 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11906 json_object_int_add(
11908 "selectionDeferralTimerRemaining",
11909 thread_timer_remain_second(
11910 peer
->bgp
->gr_info
[afi
][safi
]
11911 .t_select_deferral
));
11914 vty_out(vty
, " Timers:\n");
11916 " Configured Stale Path Time(sec): %u\n",
11917 peer
->bgp
->stalepath_time
);
11919 if (peer
->t_gr_stale
!= NULL
)
11921 " Stale Path Remaining(sec): %ld\n",
11922 thread_timer_remain_second(
11923 peer
->t_gr_stale
));
11924 /* Display Configured Selection
11925 * Deferral only when when
11926 * Gr mode is enabled.
11928 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
11930 " Configured Selection Deferral Time(sec): %u\n",
11931 peer
->bgp
->select_defer_time
);
11933 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
11936 " Selection Deferral Time Remaining(sec): %ld\n",
11937 thread_timer_remain_second(
11938 peer
->bgp
->gr_info
[afi
][safi
]
11939 .t_select_deferral
));
11942 json_object_object_add(json_afi_safi
, "endOfRibStatus",
11943 json_endofrib_status
);
11944 json_object_object_add(json_afi_safi
, "timers",
11946 json_object_object_add(
11947 json
, get_afi_safi_str(afi
, safi
, true),
11953 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
11959 json_object
*json_timer
= NULL
;
11961 json_timer
= json_object_new_object();
11963 json_object_int_add(json_timer
, "configuredRestartTimer",
11964 p
->bgp
->restart_time
);
11966 json_object_int_add(json_timer
, "receivedRestartTimer",
11969 if (p
->t_gr_restart
!= NULL
)
11970 json_object_int_add(
11971 json_timer
, "restartTimerRemaining",
11972 thread_timer_remain_second(p
->t_gr_restart
));
11974 json_object_object_add(json
, "timers", json_timer
);
11977 vty_out(vty
, " Timers:\n");
11978 vty_out(vty
, " Configured Restart Time(sec): %u\n",
11979 p
->bgp
->restart_time
);
11981 vty_out(vty
, " Received Restart Time(sec): %u\n",
11983 if (p
->t_gr_restart
!= NULL
)
11984 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11985 thread_timer_remain_second(p
->t_gr_restart
));
11986 if (p
->t_gr_restart
!= NULL
) {
11987 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11988 thread_timer_remain_second(p
->t_gr_restart
));
11993 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
11994 bool use_json
, json_object
*json
)
11996 char dn_flag
[2] = {0};
11997 /* '*' + v6 address of neighbor */
11998 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
12000 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12005 json_object_string_addf(json
, "neighborAddr", "%pSU",
12008 vty_out(vty
, "BGP neighbor on %s: %pSU\n", p
->conf_if
,
12011 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
12015 json_object_string_add(json
, "neighborAddr",
12018 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
12021 /* more gr info in new format */
12022 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
12025 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
12026 safi_t safi
, bool use_json
,
12027 json_object
*json_neigh
)
12029 struct bgp_filter
*filter
;
12030 struct peer_af
*paf
;
12031 char orf_pfx_name
[BUFSIZ
];
12033 json_object
*json_af
= NULL
;
12034 json_object
*json_prefA
= NULL
;
12035 json_object
*json_prefB
= NULL
;
12036 json_object
*json_addr
= NULL
;
12037 json_object
*json_advmap
= NULL
;
12040 json_addr
= json_object_new_object();
12041 json_af
= json_object_new_object();
12042 filter
= &p
->filter
[afi
][safi
];
12044 if (peer_group_active(p
))
12045 json_object_string_add(json_addr
, "peerGroupMember",
12048 paf
= peer_af_find(p
, afi
, safi
);
12049 if (paf
&& PAF_SUBGRP(paf
)) {
12050 json_object_int_add(json_addr
, "updateGroupId",
12051 PAF_UPDGRP(paf
)->id
);
12052 json_object_int_add(json_addr
, "subGroupId",
12053 PAF_SUBGRP(paf
)->id
);
12054 json_object_int_add(json_addr
, "packetQueueLength",
12055 bpacket_queue_virtual_length(paf
));
12058 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12059 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12060 PEER_CAP_ORF_PREFIX_SM_RCV
)
12061 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12062 PEER_CAP_ORF_PREFIX_RM_ADV
)
12063 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12064 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12065 json_object_int_add(json_af
, "orfType",
12067 json_prefA
= json_object_new_object();
12068 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
12069 PEER_CAP_ORF_PREFIX_SM_ADV
,
12070 PEER_CAP_ORF_PREFIX_RM_ADV
,
12071 PEER_CAP_ORF_PREFIX_SM_RCV
,
12072 PEER_CAP_ORF_PREFIX_RM_RCV
,
12073 use_json
, json_prefA
);
12074 json_object_object_add(json_af
, "orfPrefixList",
12078 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12079 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12080 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12081 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12082 PEER_CAP_ORF_PREFIX_RM_ADV
)
12083 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12084 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12085 json_object_int_add(json_af
, "orfOldType",
12086 ORF_TYPE_PREFIX_OLD
);
12087 json_prefB
= json_object_new_object();
12088 bgp_show_peer_afi_orf_cap(
12089 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12090 PEER_CAP_ORF_PREFIX_RM_ADV
,
12091 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12092 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
12094 json_object_object_add(json_af
, "orfOldPrefixList",
12098 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12099 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12100 PEER_CAP_ORF_PREFIX_SM_RCV
)
12101 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12102 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12103 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12104 PEER_CAP_ORF_PREFIX_RM_ADV
)
12105 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12106 PEER_CAP_ORF_PREFIX_RM_RCV
)
12107 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12108 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12109 json_object_object_add(json_addr
, "afDependentCap",
12112 json_object_free(json_af
);
12114 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12115 p
->host
, afi
, safi
);
12116 orf_pfx_count
= prefix_bgp_show_prefix_list(
12117 NULL
, afi
, orf_pfx_name
, use_json
);
12119 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12120 PEER_STATUS_ORF_PREFIX_SEND
)
12121 || orf_pfx_count
) {
12122 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12123 PEER_STATUS_ORF_PREFIX_SEND
))
12124 json_object_boolean_true_add(json_neigh
,
12127 json_object_int_add(json_addr
, "orfRecvCounter",
12130 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12131 PEER_STATUS_ORF_WAIT_REFRESH
))
12132 json_object_string_add(
12133 json_addr
, "orfFirstUpdate",
12134 "deferredUntilORFOrRouteRefreshRecvd");
12136 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12137 PEER_FLAG_REFLECTOR_CLIENT
))
12138 json_object_boolean_true_add(json_addr
,
12139 "routeReflectorClient");
12140 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12141 PEER_FLAG_RSERVER_CLIENT
))
12142 json_object_boolean_true_add(json_addr
,
12143 "routeServerClient");
12144 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12145 json_object_boolean_true_add(json_addr
,
12146 "inboundSoftConfigPermit");
12148 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12149 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12150 json_object_boolean_true_add(
12152 "privateAsNumsAllReplacedInUpdatesToNbr");
12153 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12154 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12155 json_object_boolean_true_add(
12157 "privateAsNumsReplacedInUpdatesToNbr");
12158 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12159 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12160 json_object_boolean_true_add(
12162 "privateAsNumsAllRemovedInUpdatesToNbr");
12163 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12164 PEER_FLAG_REMOVE_PRIVATE_AS
))
12165 json_object_boolean_true_add(
12167 "privateAsNumsRemovedInUpdatesToNbr");
12169 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12170 json_object_boolean_true_add(
12172 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12175 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12176 json_object_string_add(json_addr
,
12177 "overrideASNsInOutboundUpdates",
12178 "ifAspathEqualRemoteAs");
12180 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12181 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12182 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12183 json_object_boolean_true_add(json_addr
,
12184 "routerAlwaysNextHop");
12185 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12186 PEER_FLAG_AS_PATH_UNCHANGED
))
12187 json_object_boolean_true_add(
12188 json_addr
, "unchangedAsPathPropogatedToNbr");
12189 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12190 PEER_FLAG_NEXTHOP_UNCHANGED
))
12191 json_object_boolean_true_add(
12192 json_addr
, "unchangedNextHopPropogatedToNbr");
12193 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12194 json_object_boolean_true_add(
12195 json_addr
, "unchangedMedPropogatedToNbr");
12196 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12197 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12198 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12199 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12200 PEER_FLAG_SEND_COMMUNITY
)
12201 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12202 PEER_FLAG_SEND_EXT_COMMUNITY
))
12203 json_object_string_add(json_addr
,
12204 "commAttriSentToNbr",
12205 "extendedAndStandard");
12206 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12207 PEER_FLAG_SEND_EXT_COMMUNITY
))
12208 json_object_string_add(json_addr
,
12209 "commAttriSentToNbr",
12212 json_object_string_add(json_addr
,
12213 "commAttriSentToNbr",
12216 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12217 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12218 if (p
->default_rmap
[afi
][safi
].name
)
12219 json_object_string_add(
12220 json_addr
, "defaultRouteMap",
12221 p
->default_rmap
[afi
][safi
].name
);
12223 if (paf
&& PAF_SUBGRP(paf
)
12224 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12225 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12226 json_object_boolean_true_add(json_addr
,
12229 json_object_boolean_true_add(json_addr
,
12233 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12234 if (is_evpn_enabled())
12235 json_object_boolean_true_add(
12236 json_addr
, "advertiseAllVnis");
12239 if (filter
->plist
[FILTER_IN
].name
12240 || filter
->dlist
[FILTER_IN
].name
12241 || filter
->aslist
[FILTER_IN
].name
12242 || filter
->map
[RMAP_IN
].name
)
12243 json_object_boolean_true_add(json_addr
,
12244 "inboundPathPolicyConfig");
12245 if (filter
->plist
[FILTER_OUT
].name
12246 || filter
->dlist
[FILTER_OUT
].name
12247 || filter
->aslist
[FILTER_OUT
].name
12248 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12249 json_object_boolean_true_add(
12250 json_addr
, "outboundPathPolicyConfig");
12253 if (filter
->plist
[FILTER_IN
].name
)
12254 json_object_string_add(json_addr
,
12255 "incomingUpdatePrefixFilterList",
12256 filter
->plist
[FILTER_IN
].name
);
12257 if (filter
->plist
[FILTER_OUT
].name
)
12258 json_object_string_add(json_addr
,
12259 "outgoingUpdatePrefixFilterList",
12260 filter
->plist
[FILTER_OUT
].name
);
12262 /* distribute-list */
12263 if (filter
->dlist
[FILTER_IN
].name
)
12264 json_object_string_add(
12265 json_addr
, "incomingUpdateNetworkFilterList",
12266 filter
->dlist
[FILTER_IN
].name
);
12267 if (filter
->dlist
[FILTER_OUT
].name
)
12268 json_object_string_add(
12269 json_addr
, "outgoingUpdateNetworkFilterList",
12270 filter
->dlist
[FILTER_OUT
].name
);
12273 if (filter
->aslist
[FILTER_IN
].name
)
12274 json_object_string_add(json_addr
,
12275 "incomingUpdateAsPathFilterList",
12276 filter
->aslist
[FILTER_IN
].name
);
12277 if (filter
->aslist
[FILTER_OUT
].name
)
12278 json_object_string_add(json_addr
,
12279 "outgoingUpdateAsPathFilterList",
12280 filter
->aslist
[FILTER_OUT
].name
);
12283 if (filter
->map
[RMAP_IN
].name
)
12284 json_object_string_add(
12285 json_addr
, "routeMapForIncomingAdvertisements",
12286 filter
->map
[RMAP_IN
].name
);
12287 if (filter
->map
[RMAP_OUT
].name
)
12288 json_object_string_add(
12289 json_addr
, "routeMapForOutgoingAdvertisements",
12290 filter
->map
[RMAP_OUT
].name
);
12292 /* ebgp-requires-policy (inbound) */
12293 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12294 && !bgp_inbound_policy_exists(p
, filter
))
12295 json_object_string_add(
12296 json_addr
, "inboundEbgpRequiresPolicy",
12297 "Inbound updates discarded due to missing policy");
12299 /* ebgp-requires-policy (outbound) */
12300 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12301 && (!bgp_outbound_policy_exists(p
, filter
)))
12302 json_object_string_add(
12303 json_addr
, "outboundEbgpRequiresPolicy",
12304 "Outbound updates discarded due to missing policy");
12306 /* unsuppress-map */
12307 if (filter
->usmap
.name
)
12308 json_object_string_add(json_addr
,
12309 "selectiveUnsuppressRouteMap",
12310 filter
->usmap
.name
);
12312 /* advertise-map */
12313 if (filter
->advmap
.aname
) {
12314 json_advmap
= json_object_new_object();
12315 json_object_string_add(json_advmap
, "condition",
12316 filter
->advmap
.condition
12319 json_object_string_add(json_advmap
, "conditionMap",
12320 filter
->advmap
.cname
);
12321 json_object_string_add(json_advmap
, "advertiseMap",
12322 filter
->advmap
.aname
);
12323 json_object_string_add(
12324 json_advmap
, "advertiseStatus",
12325 filter
->advmap
.update_type
==
12326 UPDATE_TYPE_ADVERTISE
12329 json_object_object_add(json_addr
, "advertiseMap",
12333 /* Receive prefix count */
12334 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12335 p
->pcount
[afi
][safi
]);
12336 if (paf
&& PAF_SUBGRP(paf
))
12337 json_object_int_add(json_addr
, "sentPrefixCounter",
12338 (PAF_SUBGRP(paf
))->scount
);
12340 /* Maximum prefix */
12341 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12342 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12343 p
->pmax_out
[afi
][safi
]);
12345 /* Maximum prefix */
12346 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12347 json_object_int_add(json_addr
, "prefixAllowedMax",
12348 p
->pmax
[afi
][safi
]);
12349 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12350 PEER_FLAG_MAX_PREFIX_WARNING
))
12351 json_object_boolean_true_add(
12352 json_addr
, "prefixAllowedMaxWarning");
12353 json_object_int_add(json_addr
,
12354 "prefixAllowedWarningThresh",
12355 p
->pmax_threshold
[afi
][safi
]);
12356 if (p
->pmax_restart
[afi
][safi
])
12357 json_object_int_add(
12359 "prefixAllowedRestartIntervalMsecs",
12360 p
->pmax_restart
[afi
][safi
] * 60000);
12362 json_object_object_add(json_neigh
,
12363 get_afi_safi_str(afi
, safi
, true),
12367 filter
= &p
->filter
[afi
][safi
];
12369 vty_out(vty
, " For address family: %s\n",
12370 get_afi_safi_str(afi
, safi
, false));
12372 if (peer_group_active(p
))
12373 vty_out(vty
, " %s peer-group member\n",
12376 paf
= peer_af_find(p
, afi
, safi
);
12377 if (paf
&& PAF_SUBGRP(paf
)) {
12378 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12379 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12380 vty_out(vty
, " Packet Queue length %d\n",
12381 bpacket_queue_virtual_length(paf
));
12383 vty_out(vty
, " Not part of any update group\n");
12385 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12386 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12387 PEER_CAP_ORF_PREFIX_SM_RCV
)
12388 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12389 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12390 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12391 PEER_CAP_ORF_PREFIX_RM_ADV
)
12392 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12393 PEER_CAP_ORF_PREFIX_RM_RCV
)
12394 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12395 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12396 vty_out(vty
, " AF-dependant capabilities:\n");
12398 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12399 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12400 PEER_CAP_ORF_PREFIX_SM_RCV
)
12401 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12402 PEER_CAP_ORF_PREFIX_RM_ADV
)
12403 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12404 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12406 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12408 bgp_show_peer_afi_orf_cap(
12409 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12410 PEER_CAP_ORF_PREFIX_RM_ADV
,
12411 PEER_CAP_ORF_PREFIX_SM_RCV
,
12412 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12414 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12415 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12416 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12417 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12418 PEER_CAP_ORF_PREFIX_RM_ADV
)
12419 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12420 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12422 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12423 ORF_TYPE_PREFIX_OLD
);
12424 bgp_show_peer_afi_orf_cap(
12425 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12426 PEER_CAP_ORF_PREFIX_RM_ADV
,
12427 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12428 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12431 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12432 p
->host
, afi
, safi
);
12433 orf_pfx_count
= prefix_bgp_show_prefix_list(
12434 NULL
, afi
, orf_pfx_name
, use_json
);
12436 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12437 PEER_STATUS_ORF_PREFIX_SEND
)
12438 || orf_pfx_count
) {
12439 vty_out(vty
, " Outbound Route Filter (ORF):");
12440 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12441 PEER_STATUS_ORF_PREFIX_SEND
))
12442 vty_out(vty
, " sent;");
12444 vty_out(vty
, " received (%d entries)",
12446 vty_out(vty
, "\n");
12448 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12449 PEER_STATUS_ORF_WAIT_REFRESH
))
12451 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12453 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12454 PEER_FLAG_REFLECTOR_CLIENT
))
12455 vty_out(vty
, " Route-Reflector Client\n");
12456 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12457 PEER_FLAG_RSERVER_CLIENT
))
12458 vty_out(vty
, " Route-Server Client\n");
12460 if (peer_af_flag_check(p
, afi
, safi
, PEER_FLAG_ORR_GROUP
))
12461 vty_out(vty
, " ORR group (configured) : %s\n",
12462 p
->orr_group_name
[afi
][safi
]);
12464 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12466 " Inbound soft reconfiguration allowed\n");
12468 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12469 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12471 " Private AS numbers (all) replaced in updates to this neighbor\n");
12472 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12473 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12475 " Private AS numbers replaced in updates to this neighbor\n");
12476 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12477 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12479 " Private AS numbers (all) removed in updates to this neighbor\n");
12480 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12481 PEER_FLAG_REMOVE_PRIVATE_AS
))
12483 " Private AS numbers removed in updates to this neighbor\n");
12485 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12486 vty_out(vty
, " %s\n",
12487 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12488 ->human_description
);
12490 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12492 " Override ASNs in outbound updates if aspath equals remote-as\n");
12494 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12495 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12496 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12497 vty_out(vty
, " NEXT_HOP is always this router\n");
12498 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12499 PEER_FLAG_AS_PATH_UNCHANGED
))
12501 " AS_PATH is propagated unchanged to this neighbor\n");
12502 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12503 PEER_FLAG_NEXTHOP_UNCHANGED
))
12505 " NEXT_HOP is propagated unchanged to this neighbor\n");
12506 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12508 " MED is propagated unchanged to this neighbor\n");
12509 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12510 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12511 PEER_FLAG_SEND_EXT_COMMUNITY
)
12512 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12513 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12515 " Community attribute sent to this neighbor");
12516 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12517 PEER_FLAG_SEND_COMMUNITY
)
12518 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12519 PEER_FLAG_SEND_EXT_COMMUNITY
)
12520 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12521 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12522 vty_out(vty
, "(all)\n");
12523 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12524 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12525 vty_out(vty
, "(large)\n");
12526 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12527 PEER_FLAG_SEND_EXT_COMMUNITY
))
12528 vty_out(vty
, "(extended)\n");
12530 vty_out(vty
, "(standard)\n");
12532 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12533 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12534 vty_out(vty
, " Default information originate,");
12536 if (p
->default_rmap
[afi
][safi
].name
)
12537 vty_out(vty
, " default route-map %s%s,",
12538 p
->default_rmap
[afi
][safi
].map
? "*"
12540 p
->default_rmap
[afi
][safi
].name
);
12541 if (paf
&& PAF_SUBGRP(paf
)
12542 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12543 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12544 vty_out(vty
, " default sent\n");
12546 vty_out(vty
, " default not sent\n");
12549 /* advertise-vni-all */
12550 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12551 if (is_evpn_enabled())
12552 vty_out(vty
, " advertise-all-vni\n");
12555 if (filter
->plist
[FILTER_IN
].name
12556 || filter
->dlist
[FILTER_IN
].name
12557 || filter
->aslist
[FILTER_IN
].name
12558 || filter
->map
[RMAP_IN
].name
)
12559 vty_out(vty
, " Inbound path policy configured\n");
12560 if (filter
->plist
[FILTER_OUT
].name
12561 || filter
->dlist
[FILTER_OUT
].name
12562 || filter
->aslist
[FILTER_OUT
].name
12563 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12564 vty_out(vty
, " Outbound path policy configured\n");
12567 if (filter
->plist
[FILTER_IN
].name
)
12569 " Incoming update prefix filter list is %s%s\n",
12570 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12571 filter
->plist
[FILTER_IN
].name
);
12572 if (filter
->plist
[FILTER_OUT
].name
)
12574 " Outgoing update prefix filter list is %s%s\n",
12575 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12576 filter
->plist
[FILTER_OUT
].name
);
12578 /* distribute-list */
12579 if (filter
->dlist
[FILTER_IN
].name
)
12581 " Incoming update network filter list is %s%s\n",
12582 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12583 filter
->dlist
[FILTER_IN
].name
);
12584 if (filter
->dlist
[FILTER_OUT
].name
)
12586 " Outgoing update network filter list is %s%s\n",
12587 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12588 filter
->dlist
[FILTER_OUT
].name
);
12591 if (filter
->aslist
[FILTER_IN
].name
)
12593 " Incoming update AS path filter list is %s%s\n",
12594 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12595 filter
->aslist
[FILTER_IN
].name
);
12596 if (filter
->aslist
[FILTER_OUT
].name
)
12598 " Outgoing update AS path filter list is %s%s\n",
12599 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12600 filter
->aslist
[FILTER_OUT
].name
);
12603 if (filter
->map
[RMAP_IN
].name
)
12605 " Route map for incoming advertisements is %s%s\n",
12606 filter
->map
[RMAP_IN
].map
? "*" : "",
12607 filter
->map
[RMAP_IN
].name
);
12608 if (filter
->map
[RMAP_OUT
].name
)
12610 " Route map for outgoing advertisements is %s%s\n",
12611 filter
->map
[RMAP_OUT
].map
? "*" : "",
12612 filter
->map
[RMAP_OUT
].name
);
12614 /* ebgp-requires-policy (inbound) */
12615 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12616 && !bgp_inbound_policy_exists(p
, filter
))
12618 " Inbound updates discarded due to missing policy\n");
12620 /* ebgp-requires-policy (outbound) */
12621 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12622 && !bgp_outbound_policy_exists(p
, filter
))
12624 " Outbound updates discarded due to missing policy\n");
12626 /* unsuppress-map */
12627 if (filter
->usmap
.name
)
12629 " Route map for selective unsuppress is %s%s\n",
12630 filter
->usmap
.map
? "*" : "",
12631 filter
->usmap
.name
);
12633 /* advertise-map */
12634 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12636 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12637 filter
->advmap
.condition
? "EXIST"
12639 filter
->advmap
.cmap
? "*" : "",
12640 filter
->advmap
.cname
,
12641 filter
->advmap
.amap
? "*" : "",
12642 filter
->advmap
.aname
,
12643 filter
->advmap
.update_type
==
12644 UPDATE_TYPE_ADVERTISE
12648 /* Receive prefix count */
12649 vty_out(vty
, " %u accepted prefixes\n",
12650 p
->pcount
[afi
][safi
]);
12652 /* maximum-prefix-out */
12653 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12654 PEER_FLAG_MAX_PREFIX_OUT
))
12656 " Maximum allowed prefixes sent %u\n",
12657 p
->pmax_out
[afi
][safi
]);
12659 /* Maximum prefix */
12660 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12662 " Maximum prefixes allowed %u%s\n",
12663 p
->pmax
[afi
][safi
],
12664 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12665 PEER_FLAG_MAX_PREFIX_WARNING
)
12666 ? " (warning-only)"
12668 vty_out(vty
, " Threshold for warning message %d%%",
12669 p
->pmax_threshold
[afi
][safi
]);
12670 if (p
->pmax_restart
[afi
][safi
])
12671 vty_out(vty
, ", restart interval %d min",
12672 p
->pmax_restart
[afi
][safi
]);
12673 vty_out(vty
, "\n");
12676 vty_out(vty
, "\n");
12680 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12684 char buf1
[PREFIX2STR_BUFFER
];
12685 char timebuf
[BGP_UPTIME_LEN
];
12691 json_object
*json_neigh
= NULL
;
12693 uint32_t sync_tcp_mss
;
12698 json_neigh
= json_object_new_object();
12700 memset(dn_flag
, '\0', sizeof(dn_flag
));
12701 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12705 if (p
->conf_if
) /* Configured interface name. */
12706 vty_out(vty
, "BGP neighbor on %s: %pSU, ", p
->conf_if
,
12708 else /* Configured IP address. */
12709 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12714 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12715 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12717 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12718 json_object_string_addf(json_neigh
, "bgpNeighborAddr",
12721 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12723 if (p
->change_local_as
)
12724 json_object_int_add(json_neigh
, "localAs",
12725 p
->change_local_as
);
12727 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12729 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12730 json_object_boolean_true_add(json_neigh
,
12731 "localAsNoPrepend");
12733 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12734 json_object_boolean_true_add(json_neigh
,
12735 "localAsReplaceAs");
12737 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12738 || (p
->as_type
== AS_INTERNAL
))
12739 vty_out(vty
, "remote AS %u, ", p
->as
);
12741 vty_out(vty
, "remote AS Unspecified, ");
12742 vty_out(vty
, "local AS %u%s%s, ",
12743 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12744 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12747 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12751 /* peer type internal or confed-internal */
12752 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12754 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12755 json_object_boolean_true_add(
12756 json_neigh
, "nbrConfedInternalLink");
12758 json_object_boolean_true_add(json_neigh
,
12759 "nbrInternalLink");
12761 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12762 vty_out(vty
, "confed-internal link\n");
12764 vty_out(vty
, "internal link\n");
12766 /* peer type external or confed-external */
12767 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12769 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12770 json_object_boolean_true_add(
12771 json_neigh
, "nbrConfedExternalLink");
12773 json_object_boolean_true_add(json_neigh
,
12774 "nbrExternalLink");
12776 if (bgp_confederation_peers_check(bgp
, p
->as
))
12777 vty_out(vty
, "confed-external link\n");
12779 vty_out(vty
, "external link\n");
12783 json_object_boolean_true_add(json_neigh
,
12784 "nbrUnspecifiedLink");
12786 vty_out(vty
, "unspecified link\n");
12791 json_object_string_add(json_neigh
, "localRole",
12792 bgp_get_name_by_role(p
->local_role
));
12793 json_object_string_add(json_neigh
, "remoteRole",
12794 bgp_get_name_by_role(p
->remote_role
));
12796 vty_out(vty
, " Local Role: %s\n",
12797 bgp_get_name_by_role(p
->local_role
));
12798 vty_out(vty
, " Remote Role: %s\n",
12799 bgp_get_name_by_role(p
->remote_role
));
12806 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12808 vty_out(vty
, " Description: %s\n", p
->desc
);
12814 json_object_string_add(json_neigh
, "hostname",
12818 json_object_string_add(json_neigh
, "domainname",
12821 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12822 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12825 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12832 json_object_string_add(json_neigh
, "peerGroup",
12836 struct prefix prefix
, *range
= NULL
;
12838 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12839 range
= peer_group_lookup_dynamic_neighbor_range(
12840 p
->group
, &prefix
);
12843 json_object_string_addf(
12845 "peerSubnetRangeGroup", "%pFX",
12851 " Member of peer-group %s for session parameters\n",
12855 struct prefix prefix
, *range
= NULL
;
12857 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12858 range
= peer_group_lookup_dynamic_neighbor_range(
12859 p
->group
, &prefix
);
12863 " Belongs to the subnet range group: %pFX\n",
12871 /* Administrative shutdown. */
12872 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12873 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12874 json_object_boolean_true_add(json_neigh
,
12878 json_object_int_add(json_neigh
, "bgpVersion", 4);
12879 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
12881 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
12884 /* Confederation */
12885 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12886 && bgp_confederation_peers_check(bgp
, p
->as
))
12887 json_object_boolean_true_add(json_neigh
,
12891 json_object_string_add(
12892 json_neigh
, "bgpState",
12893 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12895 if (peer_established(p
)) {
12898 uptime
= monotime(NULL
);
12899 uptime
-= p
->uptime
;
12900 epoch_tbuf
= time(NULL
) - uptime
;
12902 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
12904 json_object_string_add(json_neigh
, "bgpTimerUpString",
12905 peer_uptime(p
->uptime
, timebuf
,
12908 json_object_int_add(json_neigh
,
12909 "bgpTimerUpEstablishedEpoch",
12913 else if (p
->status
== Active
) {
12914 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12915 json_object_string_add(json_neigh
, "bgpStateIs",
12917 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12918 json_object_string_add(json_neigh
, "bgpStateIs",
12926 uptime
= monotime(NULL
);
12927 uptime
-= p
->readtime
;
12928 gmtime_r(&uptime
, &tm
);
12930 json_object_int_add(json_neigh
, "bgpTimerLastRead",
12931 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12932 + (tm
.tm_hour
* 3600000));
12934 uptime
= monotime(NULL
);
12935 uptime
-= p
->last_write
;
12936 gmtime_r(&uptime
, &tm
);
12938 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
12939 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12940 + (tm
.tm_hour
* 3600000));
12942 uptime
= monotime(NULL
);
12943 uptime
-= p
->update_time
;
12944 gmtime_r(&uptime
, &tm
);
12946 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
12947 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12948 + (tm
.tm_hour
* 3600000));
12950 /* Configured timer values. */
12951 json_object_int_add(json_neigh
,
12952 "bgpTimerConfiguredHoldTimeMsecs",
12953 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12954 ? p
->holdtime
* 1000
12955 : bgp
->default_holdtime
* 1000);
12956 json_object_int_add(json_neigh
,
12957 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12958 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
12959 ? p
->keepalive
* 1000
12960 : bgp
->default_keepalive
* 1000);
12961 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
12962 p
->v_holdtime
* 1000);
12963 json_object_int_add(json_neigh
,
12964 "bgpTimerKeepAliveIntervalMsecs",
12965 p
->v_keepalive
* 1000);
12966 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
12967 json_object_int_add(json_neigh
,
12968 "bgpTimerDelayOpenTimeMsecs",
12969 p
->v_delayopen
* 1000);
12972 /* Configured and Synced tcp-mss value for peer */
12973 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
12974 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
12975 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
12977 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
12981 /* Extended Optional Parameters Length for BGP OPEN Message */
12982 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
12983 json_object_boolean_true_add(
12984 json_neigh
, "extendedOptionalParametersLength");
12986 json_object_boolean_false_add(
12987 json_neigh
, "extendedOptionalParametersLength");
12989 /* Conditional advertisements */
12990 json_object_int_add(
12992 "bgpTimerConfiguredConditionalAdvertisementsSec",
12993 bgp
->condition_check_period
);
12994 if (thread_is_scheduled(bgp
->t_condition_check
))
12995 json_object_int_add(
12997 "bgpTimerUntilConditionalAdvertisementsSec",
12998 thread_timer_remain_second(
12999 bgp
->t_condition_check
));
13001 /* Administrative shutdown. */
13002 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13003 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13004 vty_out(vty
, " Administratively shut down\n");
13007 vty_out(vty
, " BGP version 4");
13008 vty_out(vty
, ", remote router ID %s",
13009 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
13010 vty_out(vty
, ", local router ID %s\n",
13011 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
13014 /* Confederation */
13015 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13016 && bgp_confederation_peers_check(bgp
, p
->as
))
13018 " Neighbor under common administration\n");
13021 vty_out(vty
, " BGP state = %s",
13022 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13024 if (peer_established(p
))
13025 vty_out(vty
, ", up for %8s",
13026 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
13029 else if (p
->status
== Active
) {
13030 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13031 vty_out(vty
, " (passive)");
13032 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13033 vty_out(vty
, " (NSF passive)");
13035 vty_out(vty
, "\n");
13038 vty_out(vty
, " Last read %s",
13039 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
13041 vty_out(vty
, ", Last write %s\n",
13042 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
13045 /* Configured timer values. */
13047 " Hold time is %d seconds, keepalive interval is %d seconds\n",
13048 p
->v_holdtime
, p
->v_keepalive
);
13049 vty_out(vty
, " Configured hold time is %d seconds",
13050 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13052 : bgp
->default_holdtime
);
13053 vty_out(vty
, ", keepalive interval is %d seconds\n",
13054 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13056 : bgp
->default_keepalive
);
13057 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
13059 " Configured DelayOpenTime is %d seconds\n",
13062 /* Configured and synced tcp-mss value for peer */
13063 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13064 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13065 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
13066 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
13069 /* Extended Optional Parameters Length for BGP OPEN Message */
13070 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
13072 " Extended Optional Parameters Length is enabled\n");
13074 /* Conditional advertisements */
13076 " Configured conditional advertisements interval is %d seconds\n",
13077 bgp
->condition_check_period
);
13078 if (thread_is_scheduled(bgp
->t_condition_check
))
13080 " Time until conditional advertisements begin is %lu seconds\n",
13081 thread_timer_remain_second(
13082 bgp
->t_condition_check
));
13085 if (peer_established(p
) &&
13086 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
13088 json_object
*json_cap
= NULL
;
13090 json_cap
= json_object_new_object();
13093 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13094 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13095 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
13096 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13097 json_object_string_add(
13098 json_cap
, "4byteAs",
13099 "advertisedAndReceived");
13100 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13101 json_object_string_add(json_cap
,
13104 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13105 json_object_string_add(json_cap
,
13110 /* Extended Message Support */
13111 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
13112 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
13113 json_object_string_add(json_cap
,
13115 "advertisedAndReceived");
13116 else if (CHECK_FLAG(p
->cap
,
13117 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13118 json_object_string_add(json_cap
,
13121 else if (CHECK_FLAG(p
->cap
,
13122 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13123 json_object_string_add(json_cap
,
13128 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13129 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13130 json_object
*json_add
= NULL
;
13131 const char *print_store
;
13133 json_add
= json_object_new_object();
13135 FOREACH_AFI_SAFI (afi
, safi
) {
13136 json_object
*json_sub
= NULL
;
13137 json_sub
= json_object_new_object();
13138 print_store
= get_afi_safi_str(
13142 p
->af_cap
[afi
][safi
],
13143 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13145 p
->af_cap
[afi
][safi
],
13146 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13150 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
13154 PEER_CAP_ADDPATH_AF_TX_RCV
))
13155 json_object_boolean_true_add(
13157 "txAdvertisedAndReceived");
13162 PEER_CAP_ADDPATH_AF_TX_ADV
))
13163 json_object_boolean_true_add(
13170 PEER_CAP_ADDPATH_AF_TX_RCV
))
13171 json_object_boolean_true_add(
13177 p
->af_cap
[afi
][safi
],
13178 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13180 p
->af_cap
[afi
][safi
],
13181 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13185 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
13189 PEER_CAP_ADDPATH_AF_RX_RCV
))
13190 json_object_boolean_true_add(
13192 "rxAdvertisedAndReceived");
13197 PEER_CAP_ADDPATH_AF_RX_ADV
))
13198 json_object_boolean_true_add(
13205 PEER_CAP_ADDPATH_AF_RX_RCV
))
13206 json_object_boolean_true_add(
13212 p
->af_cap
[afi
][safi
],
13213 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13215 p
->af_cap
[afi
][safi
],
13216 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
13218 p
->af_cap
[afi
][safi
],
13219 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13221 p
->af_cap
[afi
][safi
],
13222 PEER_CAP_ADDPATH_AF_RX_RCV
))
13223 json_object_object_add(
13224 json_add
, print_store
,
13227 json_object_free(json_sub
);
13230 json_object_object_add(json_cap
, "addPath",
13235 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13236 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13237 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
13238 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13239 json_object_string_add(
13240 json_cap
, "dynamic",
13241 "advertisedAndReceived");
13242 else if (CHECK_FLAG(p
->cap
,
13243 PEER_CAP_DYNAMIC_ADV
))
13244 json_object_string_add(json_cap
,
13247 else if (CHECK_FLAG(p
->cap
,
13248 PEER_CAP_DYNAMIC_RCV
))
13249 json_object_string_add(json_cap
,
13255 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13256 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13257 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
) &&
13258 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13259 json_object_string_add(
13261 "advertisedAndReceived");
13262 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13263 json_object_string_add(json_cap
, "role",
13265 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13266 json_object_string_add(json_cap
, "role",
13270 /* Extended nexthop */
13271 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13272 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13273 json_object
*json_nxt
= NULL
;
13274 const char *print_store
;
13277 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
13278 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13279 json_object_string_add(
13280 json_cap
, "extendedNexthop",
13281 "advertisedAndReceived");
13282 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13283 json_object_string_add(
13284 json_cap
, "extendedNexthop",
13286 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13287 json_object_string_add(
13288 json_cap
, "extendedNexthop",
13291 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13292 json_nxt
= json_object_new_object();
13294 for (safi
= SAFI_UNICAST
;
13295 safi
< SAFI_MAX
; safi
++) {
13299 PEER_CAP_ENHE_AF_RCV
)) {
13305 json_object_string_add(
13308 "recieved"); /* misspelled for compatibility */
13311 json_object_object_add(
13313 "extendedNexthopFamililesByPeer",
13318 /* Long-lived Graceful Restart */
13319 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13320 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13321 json_object
*json_llgr
= NULL
;
13322 const char *afi_safi_str
;
13324 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
13325 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13326 json_object_string_add(
13328 "longLivedGracefulRestart",
13329 "advertisedAndReceived");
13330 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13331 json_object_string_add(
13333 "longLivedGracefulRestart",
13335 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13336 json_object_string_add(
13338 "longLivedGracefulRestart",
13341 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13342 json_llgr
= json_object_new_object();
13344 FOREACH_AFI_SAFI (afi
, safi
) {
13348 PEER_CAP_ENHE_AF_RCV
)) {
13354 json_object_string_add(
13360 json_object_object_add(
13362 "longLivedGracefulRestartByPeer",
13367 /* Route Refresh */
13368 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13369 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13370 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13371 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
13372 (CHECK_FLAG(p
->cap
,
13373 PEER_CAP_REFRESH_NEW_RCV
) ||
13375 PEER_CAP_REFRESH_OLD_RCV
))) {
13378 PEER_CAP_REFRESH_OLD_RCV
) &&
13381 PEER_CAP_REFRESH_NEW_RCV
))
13382 json_object_string_add(
13385 "advertisedAndReceivedOldNew");
13389 PEER_CAP_REFRESH_OLD_RCV
))
13390 json_object_string_add(
13393 "advertisedAndReceivedOld");
13395 json_object_string_add(
13398 "advertisedAndReceivedNew");
13400 } else if (CHECK_FLAG(p
->cap
,
13401 PEER_CAP_REFRESH_ADV
))
13402 json_object_string_add(json_cap
,
13405 else if (CHECK_FLAG(p
->cap
,
13406 PEER_CAP_REFRESH_NEW_RCV
) ||
13408 PEER_CAP_REFRESH_OLD_RCV
))
13409 json_object_string_add(json_cap
,
13414 /* Enhanced Route Refresh */
13415 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13416 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13417 if (CHECK_FLAG(p
->cap
,
13418 PEER_CAP_ENHANCED_RR_ADV
) &&
13420 PEER_CAP_ENHANCED_RR_RCV
))
13421 json_object_string_add(
13423 "enhancedRouteRefresh",
13424 "advertisedAndReceived");
13425 else if (CHECK_FLAG(p
->cap
,
13426 PEER_CAP_ENHANCED_RR_ADV
))
13427 json_object_string_add(
13429 "enhancedRouteRefresh",
13431 else if (CHECK_FLAG(p
->cap
,
13432 PEER_CAP_ENHANCED_RR_RCV
))
13433 json_object_string_add(
13435 "enhancedRouteRefresh",
13439 /* Multiprotocol Extensions */
13440 json_object
*json_multi
= NULL
;
13442 json_multi
= json_object_new_object();
13444 FOREACH_AFI_SAFI (afi
, safi
) {
13445 if (p
->afc_adv
[afi
][safi
] ||
13446 p
->afc_recv
[afi
][safi
]) {
13447 json_object
*json_exten
= NULL
;
13448 json_exten
= json_object_new_object();
13450 if (p
->afc_adv
[afi
][safi
] &&
13451 p
->afc_recv
[afi
][safi
])
13452 json_object_boolean_true_add(
13454 "advertisedAndReceived");
13455 else if (p
->afc_adv
[afi
][safi
])
13456 json_object_boolean_true_add(
13459 else if (p
->afc_recv
[afi
][safi
])
13460 json_object_boolean_true_add(
13461 json_exten
, "received");
13463 json_object_object_add(
13465 get_afi_safi_str(afi
, safi
,
13470 json_object_object_add(json_cap
,
13471 "multiprotocolExtensions",
13474 /* Hostname capabilities */
13475 json_object
*json_hname
= NULL
;
13477 json_hname
= json_object_new_object();
13479 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13480 json_object_string_add(
13481 json_hname
, "advHostName",
13482 bgp
->peer_self
->hostname
13483 ? bgp
->peer_self
->hostname
13485 json_object_string_add(
13486 json_hname
, "advDomainName",
13487 bgp
->peer_self
->domainname
13488 ? bgp
->peer_self
->domainname
13493 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13494 json_object_string_add(
13495 json_hname
, "rcvHostName",
13496 p
->hostname
? p
->hostname
: "n/a");
13497 json_object_string_add(
13498 json_hname
, "rcvDomainName",
13499 p
->domainname
? p
->domainname
: "n/a");
13502 json_object_object_add(json_cap
, "hostName",
13505 /* Graceful Restart */
13506 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13507 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13508 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13509 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13510 json_object_string_add(
13511 json_cap
, "gracefulRestart",
13512 "advertisedAndReceived");
13513 else if (CHECK_FLAG(p
->cap
,
13514 PEER_CAP_RESTART_ADV
))
13515 json_object_string_add(
13517 "gracefulRestartCapability",
13519 else if (CHECK_FLAG(p
->cap
,
13520 PEER_CAP_RESTART_RCV
))
13521 json_object_string_add(
13523 "gracefulRestartCapability",
13526 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13527 int restart_af_count
= 0;
13528 json_object
*json_restart
= NULL
;
13529 json_restart
= json_object_new_object();
13531 json_object_int_add(
13533 "gracefulRestartRemoteTimerMsecs",
13534 p
->v_gr_restart
* 1000);
13536 FOREACH_AFI_SAFI (afi
, safi
) {
13540 PEER_CAP_RESTART_AF_RCV
)) {
13541 json_object
*json_sub
=
13544 json_object_new_object();
13550 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13551 json_object_boolean_true_add(
13554 restart_af_count
++;
13555 json_object_object_add(
13564 if (!restart_af_count
) {
13565 json_object_string_add(
13567 "addressFamiliesByPeer",
13569 json_object_free(json_restart
);
13571 json_object_object_add(
13573 "addressFamiliesByPeer",
13577 json_object_object_add(
13578 json_neigh
, "neighborCapabilities", json_cap
);
13580 vty_out(vty
, " Neighbor capabilities:\n");
13583 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13584 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13585 vty_out(vty
, " 4 Byte AS:");
13586 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13587 vty_out(vty
, " advertised");
13588 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13589 vty_out(vty
, " %sreceived",
13594 vty_out(vty
, "\n");
13597 /* Extended Message Support */
13598 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13599 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13600 vty_out(vty
, " Extended Message:");
13601 if (CHECK_FLAG(p
->cap
,
13602 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13603 vty_out(vty
, " advertised");
13604 if (CHECK_FLAG(p
->cap
,
13605 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13606 vty_out(vty
, " %sreceived",
13609 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13612 vty_out(vty
, "\n");
13616 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13617 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13618 vty_out(vty
, " AddPath:\n");
13620 FOREACH_AFI_SAFI (afi
, safi
) {
13622 p
->af_cap
[afi
][safi
],
13623 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13625 p
->af_cap
[afi
][safi
],
13626 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13627 vty_out(vty
, " %s: TX ",
13635 PEER_CAP_ADDPATH_AF_TX_ADV
))
13642 PEER_CAP_ADDPATH_AF_TX_RCV
))
13649 PEER_CAP_ADDPATH_AF_TX_ADV
)
13653 vty_out(vty
, "\n");
13657 p
->af_cap
[afi
][safi
],
13658 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13660 p
->af_cap
[afi
][safi
],
13661 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13662 vty_out(vty
, " %s: RX ",
13670 PEER_CAP_ADDPATH_AF_RX_ADV
))
13677 PEER_CAP_ADDPATH_AF_RX_RCV
))
13684 PEER_CAP_ADDPATH_AF_RX_ADV
)
13688 vty_out(vty
, "\n");
13694 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13695 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13696 vty_out(vty
, " Dynamic:");
13697 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
13698 vty_out(vty
, " advertised");
13699 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13700 vty_out(vty
, " %sreceived",
13702 PEER_CAP_DYNAMIC_ADV
)
13705 vty_out(vty
, "\n");
13709 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13710 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13711 vty_out(vty
, " Role:");
13712 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13713 vty_out(vty
, " advertised");
13714 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13715 vty_out(vty
, " %sreceived",
13720 vty_out(vty
, "\n");
13723 /* Extended nexthop */
13724 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13725 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13726 vty_out(vty
, " Extended nexthop:");
13727 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13728 vty_out(vty
, " advertised");
13729 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13730 vty_out(vty
, " %sreceived",
13735 vty_out(vty
, "\n");
13737 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13739 " Address families by peer:\n ");
13740 for (safi
= SAFI_UNICAST
;
13741 safi
< SAFI_MAX
; safi
++)
13745 PEER_CAP_ENHE_AF_RCV
))
13755 /* Long-lived Graceful Restart */
13756 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13757 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13759 " Long-lived Graceful Restart:");
13760 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13761 vty_out(vty
, " advertised");
13762 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13763 vty_out(vty
, " %sreceived",
13768 vty_out(vty
, "\n");
13770 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13772 " Address families by peer:\n");
13773 FOREACH_AFI_SAFI (afi
, safi
)
13777 PEER_CAP_LLGR_AF_RCV
))
13787 /* Route Refresh */
13788 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13789 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13790 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13791 vty_out(vty
, " Route refresh:");
13792 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
13793 vty_out(vty
, " advertised");
13794 if (CHECK_FLAG(p
->cap
,
13795 PEER_CAP_REFRESH_NEW_RCV
) ||
13797 PEER_CAP_REFRESH_OLD_RCV
))
13798 vty_out(vty
, " %sreceived(%s)",
13800 PEER_CAP_REFRESH_ADV
)
13805 PEER_CAP_REFRESH_OLD_RCV
) &&
13808 PEER_CAP_REFRESH_NEW_RCV
))
13812 PEER_CAP_REFRESH_OLD_RCV
)
13816 vty_out(vty
, "\n");
13819 /* Enhanced Route Refresh */
13820 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13821 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13822 vty_out(vty
, " Enhanced Route Refresh:");
13823 if (CHECK_FLAG(p
->cap
,
13824 PEER_CAP_ENHANCED_RR_ADV
))
13825 vty_out(vty
, " advertised");
13826 if (CHECK_FLAG(p
->cap
,
13827 PEER_CAP_ENHANCED_RR_RCV
))
13828 vty_out(vty
, " %sreceived",
13830 PEER_CAP_REFRESH_ADV
)
13833 vty_out(vty
, "\n");
13836 /* Multiprotocol Extensions */
13837 FOREACH_AFI_SAFI (afi
, safi
)
13838 if (p
->afc_adv
[afi
][safi
] ||
13839 p
->afc_recv
[afi
][safi
]) {
13840 vty_out(vty
, " Address Family %s:",
13841 get_afi_safi_str(afi
, safi
,
13843 if (p
->afc_adv
[afi
][safi
])
13844 vty_out(vty
, " advertised");
13845 if (p
->afc_recv
[afi
][safi
])
13846 vty_out(vty
, " %sreceived",
13847 p
->afc_adv
[afi
][safi
]
13850 vty_out(vty
, "\n");
13853 /* Hostname capability */
13854 vty_out(vty
, " Hostname Capability:");
13856 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13858 " advertised (name: %s,domain name: %s)",
13859 bgp
->peer_self
->hostname
13860 ? bgp
->peer_self
->hostname
13862 bgp
->peer_self
->domainname
13863 ? bgp
->peer_self
->domainname
13866 vty_out(vty
, " not advertised");
13869 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13871 " received (name: %s,domain name: %s)",
13872 p
->hostname
? p
->hostname
: "n/a",
13873 p
->domainname
? p
->domainname
: "n/a");
13875 vty_out(vty
, " not received");
13878 vty_out(vty
, "\n");
13880 /* Graceful Restart */
13881 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13882 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13884 " Graceful Restart Capability:");
13885 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
13886 vty_out(vty
, " advertised");
13887 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13888 vty_out(vty
, " %sreceived",
13890 PEER_CAP_RESTART_ADV
)
13893 vty_out(vty
, "\n");
13895 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13896 int restart_af_count
= 0;
13899 " Remote Restart timer is %d seconds\n",
13902 " Address families by peer:\n ");
13904 FOREACH_AFI_SAFI (afi
, safi
)
13908 PEER_CAP_RESTART_AF_RCV
)) {
13909 vty_out(vty
, "%s%s(%s)",
13921 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13923 : "not preserved");
13924 restart_af_count
++;
13926 if (!restart_af_count
)
13927 vty_out(vty
, "none");
13928 vty_out(vty
, "\n");
13930 } /* Graceful Restart */
13934 /* graceful restart information */
13935 json_object
*json_grace
= NULL
;
13936 json_object
*json_grace_send
= NULL
;
13937 json_object
*json_grace_recv
= NULL
;
13938 int eor_send_af_count
= 0;
13939 int eor_receive_af_count
= 0;
13942 json_grace
= json_object_new_object();
13943 json_grace_send
= json_object_new_object();
13944 json_grace_recv
= json_object_new_object();
13946 if ((peer_established(p
)) &&
13947 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13948 FOREACH_AFI_SAFI (afi
, safi
) {
13949 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13950 PEER_STATUS_EOR_SEND
)) {
13951 json_object_boolean_true_add(
13953 get_afi_safi_str(afi
, safi
,
13955 eor_send_af_count
++;
13958 FOREACH_AFI_SAFI (afi
, safi
) {
13959 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13960 PEER_STATUS_EOR_RECEIVED
)) {
13961 json_object_boolean_true_add(
13963 get_afi_safi_str(afi
, safi
,
13965 eor_receive_af_count
++;
13969 json_object_object_add(json_grace
, "endOfRibSend",
13971 json_object_object_add(json_grace
, "endOfRibRecv",
13975 if (p
->t_gr_restart
)
13976 json_object_int_add(
13977 json_grace
, "gracefulRestartTimerMsecs",
13978 thread_timer_remain_second(p
->t_gr_restart
) *
13982 json_object_int_add(
13983 json_grace
, "gracefulStalepathTimerMsecs",
13984 thread_timer_remain_second(p
->t_gr_stale
) *
13986 /* more gr info in new format */
13987 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json_grace
);
13988 json_object_object_add(json_neigh
, "gracefulRestartInfo",
13991 vty_out(vty
, " Graceful restart information:\n");
13992 if ((peer_established(p
)) &&
13993 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13995 vty_out(vty
, " End-of-RIB send: ");
13996 FOREACH_AFI_SAFI (afi
, safi
) {
13997 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13998 PEER_STATUS_EOR_SEND
)) {
13999 vty_out(vty
, "%s%s",
14000 eor_send_af_count
? ", " : "",
14001 get_afi_safi_str(afi
, safi
,
14003 eor_send_af_count
++;
14006 vty_out(vty
, "\n");
14007 vty_out(vty
, " End-of-RIB received: ");
14008 FOREACH_AFI_SAFI (afi
, safi
) {
14009 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14010 PEER_STATUS_EOR_RECEIVED
)) {
14011 vty_out(vty
, "%s%s",
14012 eor_receive_af_count
? ", "
14014 get_afi_safi_str(afi
, safi
,
14016 eor_receive_af_count
++;
14019 vty_out(vty
, "\n");
14022 if (p
->t_gr_restart
)
14024 " The remaining time of restart timer is %ld\n",
14025 thread_timer_remain_second(p
->t_gr_restart
));
14029 " The remaining time of stalepath timer is %ld\n",
14030 thread_timer_remain_second(p
->t_gr_stale
));
14032 /* more gr info in new format */
14033 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
14037 json_object
*json_stat
= NULL
;
14038 json_stat
= json_object_new_object();
14039 /* Packet counts. */
14041 atomic_size_t outq_count
, inq_count
;
14042 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14043 memory_order_relaxed
);
14044 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14045 memory_order_relaxed
);
14047 json_object_int_add(json_stat
, "depthInq",
14048 (unsigned long)inq_count
);
14049 json_object_int_add(json_stat
, "depthOutq",
14050 (unsigned long)outq_count
);
14051 json_object_int_add(json_stat
, "opensSent",
14052 atomic_load_explicit(&p
->open_out
,
14053 memory_order_relaxed
));
14054 json_object_int_add(json_stat
, "opensRecv",
14055 atomic_load_explicit(&p
->open_in
,
14056 memory_order_relaxed
));
14057 json_object_int_add(json_stat
, "notificationsSent",
14058 atomic_load_explicit(&p
->notify_out
,
14059 memory_order_relaxed
));
14060 json_object_int_add(json_stat
, "notificationsRecv",
14061 atomic_load_explicit(&p
->notify_in
,
14062 memory_order_relaxed
));
14063 json_object_int_add(json_stat
, "updatesSent",
14064 atomic_load_explicit(&p
->update_out
,
14065 memory_order_relaxed
));
14066 json_object_int_add(json_stat
, "updatesRecv",
14067 atomic_load_explicit(&p
->update_in
,
14068 memory_order_relaxed
));
14069 json_object_int_add(json_stat
, "keepalivesSent",
14070 atomic_load_explicit(&p
->keepalive_out
,
14071 memory_order_relaxed
));
14072 json_object_int_add(json_stat
, "keepalivesRecv",
14073 atomic_load_explicit(&p
->keepalive_in
,
14074 memory_order_relaxed
));
14075 json_object_int_add(json_stat
, "routeRefreshSent",
14076 atomic_load_explicit(&p
->refresh_out
,
14077 memory_order_relaxed
));
14078 json_object_int_add(json_stat
, "routeRefreshRecv",
14079 atomic_load_explicit(&p
->refresh_in
,
14080 memory_order_relaxed
));
14081 json_object_int_add(json_stat
, "capabilitySent",
14082 atomic_load_explicit(&p
->dynamic_cap_out
,
14083 memory_order_relaxed
));
14084 json_object_int_add(json_stat
, "capabilityRecv",
14085 atomic_load_explicit(&p
->dynamic_cap_in
,
14086 memory_order_relaxed
));
14087 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
14088 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
14089 json_object_object_add(json_neigh
, "messageStats", json_stat
);
14091 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
14092 notify_out
, notify_in
, update_out
, update_in
,
14093 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
14094 dynamic_cap_out
, dynamic_cap_in
;
14095 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14096 memory_order_relaxed
);
14097 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14098 memory_order_relaxed
);
14099 open_out
= atomic_load_explicit(&p
->open_out
,
14100 memory_order_relaxed
);
14102 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
14103 notify_out
= atomic_load_explicit(&p
->notify_out
,
14104 memory_order_relaxed
);
14105 notify_in
= atomic_load_explicit(&p
->notify_in
,
14106 memory_order_relaxed
);
14107 update_out
= atomic_load_explicit(&p
->update_out
,
14108 memory_order_relaxed
);
14109 update_in
= atomic_load_explicit(&p
->update_in
,
14110 memory_order_relaxed
);
14111 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
14112 memory_order_relaxed
);
14113 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
14114 memory_order_relaxed
);
14115 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
14116 memory_order_relaxed
);
14117 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
14118 memory_order_relaxed
);
14119 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
14120 memory_order_relaxed
);
14121 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
14122 memory_order_relaxed
);
14124 /* Packet counts. */
14125 vty_out(vty
, " Message statistics:\n");
14126 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
14127 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
14128 vty_out(vty
, " Sent Rcvd\n");
14129 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
14131 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
14133 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
14135 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
14137 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
14139 vty_out(vty
, " Capability: %10zu %10zu\n",
14140 dynamic_cap_out
, dynamic_cap_in
);
14141 vty_out(vty
, " Total: %10u %10u\n",
14142 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
14146 /* advertisement-interval */
14147 json_object_int_add(json_neigh
,
14148 "minBtwnAdvertisementRunsTimerMsecs",
14149 p
->v_routeadv
* 1000);
14151 /* Update-source. */
14152 if (p
->update_if
|| p
->update_source
) {
14154 json_object_string_add(json_neigh
,
14157 else if (p
->update_source
)
14158 json_object_string_addf(json_neigh
,
14159 "updateSource", "%pSU",
14163 /* advertisement-interval */
14165 " Minimum time between advertisement runs is %d seconds\n",
14168 /* Update-source. */
14169 if (p
->update_if
|| p
->update_source
) {
14170 vty_out(vty
, " Update source is ");
14172 vty_out(vty
, "%s", p
->update_if
);
14173 else if (p
->update_source
)
14174 vty_out(vty
, "%pSU", p
->update_source
);
14175 vty_out(vty
, "\n");
14178 vty_out(vty
, "\n");
14181 /* Address Family Information */
14182 json_object
*json_hold
= NULL
;
14185 json_hold
= json_object_new_object();
14187 FOREACH_AFI_SAFI (afi
, safi
)
14188 if (p
->afc
[afi
][safi
])
14189 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14193 json_object_object_add(json_neigh
, "addressFamilyInfo",
14195 json_object_int_add(json_neigh
, "connectionsEstablished",
14197 json_object_int_add(json_neigh
, "connectionsDropped",
14200 vty_out(vty
, " Connections established %d; dropped %d\n",
14201 p
->established
, p
->dropped
);
14203 if (!p
->last_reset
) {
14205 json_object_string_add(json_neigh
, "lastReset",
14208 vty_out(vty
, " Last reset never\n");
14214 uptime
= monotime(NULL
);
14215 uptime
-= p
->resettime
;
14216 gmtime_r(&uptime
, &tm
);
14218 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14220 + (tm
.tm_min
* 60000)
14221 + (tm
.tm_hour
* 3600000));
14222 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14224 vty_out(vty
, " Last reset %s, ",
14225 peer_uptime(p
->resettime
, timebuf
,
14226 BGP_UPTIME_LEN
, 0, NULL
));
14228 bgp_show_peer_reset(vty
, p
, NULL
, false);
14229 if (p
->last_reset_cause_size
) {
14230 msg
= p
->last_reset_cause
;
14232 " Message received that caused BGP to send a NOTIFICATION:\n ");
14233 for (i
= 1; i
<= p
->last_reset_cause_size
;
14235 vty_out(vty
, "%02X", *msg
++);
14237 if (i
!= p
->last_reset_cause_size
) {
14239 vty_out(vty
, "\n ");
14240 } else if (i
% 4 == 0) {
14245 vty_out(vty
, "\n");
14250 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14252 json_object_boolean_true_add(json_neigh
,
14253 "prefixesConfigExceedMax");
14256 " Peer had exceeded the max. no. of prefixes configured.\n");
14258 if (p
->t_pmax_restart
) {
14260 json_object_boolean_true_add(
14261 json_neigh
, "reducePrefixNumFrom");
14262 json_object_int_add(json_neigh
,
14263 "restartInTimerMsec",
14264 thread_timer_remain_second(
14269 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14270 p
->host
, thread_timer_remain_second(
14271 p
->t_pmax_restart
));
14274 json_object_boolean_true_add(
14276 "reducePrefixNumAndClearIpBgp");
14279 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14284 /* EBGP Multihop and GTSM */
14285 if (p
->sort
!= BGP_PEER_IBGP
) {
14287 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14288 json_object_int_add(json_neigh
,
14289 "externalBgpNbrMaxHopsAway",
14292 json_object_int_add(json_neigh
,
14293 "externalBgpNbrMaxHopsAway",
14296 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14298 " External BGP neighbor may be up to %d hops away.\n",
14302 " External BGP neighbor may be up to %d hops away.\n",
14307 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14308 json_object_int_add(json_neigh
,
14309 "internalBgpNbrMaxHopsAway",
14312 json_object_int_add(json_neigh
,
14313 "internalBgpNbrMaxHopsAway",
14316 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14318 " Internal BGP neighbor may be up to %d hops away.\n",
14322 " Internal BGP neighbor may be up to %d hops away.\n",
14327 /* Local address. */
14330 json_object_string_addf(json_neigh
, "hostLocal", "%pSU",
14332 json_object_int_add(json_neigh
, "portLocal",
14333 ntohs(p
->su_local
->sin
.sin_port
));
14335 vty_out(vty
, "Local host: %pSU, Local port: %d\n",
14336 p
->su_local
, ntohs(p
->su_local
->sin
.sin_port
));
14339 json_object_string_add(json_neigh
, "hostLocal",
14341 json_object_int_add(json_neigh
, "portLocal", -1);
14345 /* Remote address. */
14346 if (p
->su_remote
) {
14348 json_object_string_addf(json_neigh
, "hostForeign",
14349 "%pSU", p
->su_remote
);
14350 json_object_int_add(json_neigh
, "portForeign",
14351 ntohs(p
->su_remote
->sin
.sin_port
));
14353 vty_out(vty
, "Foreign host: %pSU, Foreign port: %d\n",
14355 ntohs(p
->su_remote
->sin
.sin_port
));
14358 json_object_string_add(json_neigh
, "hostForeign",
14360 json_object_int_add(json_neigh
, "portForeign", -1);
14364 /* Nexthop display. */
14367 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
14369 json_object_string_addf(json_neigh
, "nexthopGlobal",
14370 "%pI6", &p
->nexthop
.v6_global
);
14371 json_object_string_addf(json_neigh
, "nexthopLocal",
14372 "%pI6", &p
->nexthop
.v6_local
);
14373 if (p
->shared_network
)
14374 json_object_string_add(json_neigh
,
14378 json_object_string_add(json_neigh
,
14380 "nonSharedNetwork");
14382 vty_out(vty
, "Nexthop: %s\n",
14383 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
14385 vty_out(vty
, "Nexthop global: %s\n",
14386 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
14388 vty_out(vty
, "Nexthop local: %s\n",
14389 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
14391 vty_out(vty
, "BGP connection: %s\n",
14392 p
->shared_network
? "shared network"
14393 : "non shared network");
14397 /* Timer information. */
14399 json_object_int_add(json_neigh
, "connectRetryTimer",
14401 if (peer_established(p
) && p
->rtt
)
14402 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14405 json_object_int_add(
14406 json_neigh
, "nextStartTimerDueInMsecs",
14407 thread_timer_remain_second(p
->t_start
) * 1000);
14409 json_object_int_add(
14410 json_neigh
, "nextConnectTimerDueInMsecs",
14411 thread_timer_remain_second(p
->t_connect
)
14413 if (p
->t_routeadv
) {
14414 json_object_int_add(json_neigh
, "mraiInterval",
14416 json_object_int_add(
14417 json_neigh
, "mraiTimerExpireInMsecs",
14418 thread_timer_remain_second(p
->t_routeadv
)
14422 json_object_int_add(json_neigh
, "authenticationEnabled",
14426 json_object_string_add(json_neigh
, "readThread", "on");
14428 json_object_string_add(json_neigh
, "readThread", "off");
14430 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14431 json_object_string_add(json_neigh
, "writeThread", "on");
14433 json_object_string_add(json_neigh
, "writeThread",
14436 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14438 if (peer_established(p
) && p
->rtt
)
14439 vty_out(vty
, "Estimated round trip time: %d ms\n",
14442 vty_out(vty
, "Next start timer due in %ld seconds\n",
14443 thread_timer_remain_second(p
->t_start
));
14445 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14446 thread_timer_remain_second(p
->t_connect
));
14449 "MRAI (interval %u) timer expires in %ld seconds\n",
14451 thread_timer_remain_second(p
->t_routeadv
));
14453 vty_out(vty
, "Peer Authentication Enabled\n");
14455 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14456 p
->t_read
? "on" : "off",
14457 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14462 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14463 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14464 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14467 vty_out(vty
, "\n");
14469 /* BFD information. */
14471 bgp_bfd_show_info(vty
, p
, json_neigh
);
14474 if (p
->conf_if
) /* Configured interface name. */
14475 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14476 else /* Configured IP address. */
14477 json_object_object_add(json
, p
->host
, json_neigh
);
14481 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14482 enum show_type type
,
14483 union sockunion
*su
,
14484 const char *conf_if
, afi_t afi
,
14487 struct listnode
*node
, *nnode
;
14490 safi_t safi
= SAFI_UNICAST
;
14491 json_object
*json
= NULL
;
14492 json_object
*json_neighbor
= NULL
;
14495 json
= json_object_new_object();
14496 json_neighbor
= json_object_new_object();
14499 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14501 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14504 if ((peer
->afc
[afi
][safi
]) == 0)
14507 if (type
== show_all
) {
14508 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14512 json_object_object_add(json
, peer
->host
,
14514 json_neighbor
= NULL
;
14517 } else if (type
== show_peer
) {
14520 && !strcmp(peer
->conf_if
, conf_if
))
14522 && !strcmp(peer
->hostname
, conf_if
))) {
14524 bgp_show_peer_gr_status(vty
, peer
,
14529 if (sockunion_same(&peer
->su
, su
)) {
14531 bgp_show_peer_gr_status(vty
, peer
,
14536 if (use_json
&& find
)
14537 json_object_object_add(json
, peer
->host
,
14542 json_neighbor
= NULL
;
14547 if (type
== show_peer
&& !find
) {
14549 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14551 vty_out(vty
, "%% No such neighbor\n");
14555 json_object_free(json_neighbor
);
14556 vty_json(vty
, json
);
14558 vty_out(vty
, "\n");
14561 return CMD_SUCCESS
;
14564 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14565 enum show_type type
, union sockunion
*su
,
14566 const char *conf_if
, bool use_json
,
14569 struct listnode
*node
, *nnode
;
14572 bool nbr_output
= false;
14573 afi_t afi
= AFI_MAX
;
14574 safi_t safi
= SAFI_MAX
;
14576 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14578 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14582 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14583 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14588 bgp_show_peer(vty
, peer
, use_json
, json
);
14594 && !strcmp(peer
->conf_if
, conf_if
))
14596 && !strcmp(peer
->hostname
, conf_if
))) {
14598 bgp_show_peer(vty
, peer
, use_json
,
14602 if (sockunion_same(&peer
->su
, su
)) {
14604 bgp_show_peer(vty
, peer
, use_json
,
14609 case show_ipv4_peer
:
14610 case show_ipv6_peer
:
14611 FOREACH_SAFI (safi
) {
14612 if (peer
->afc
[afi
][safi
]) {
14615 && !strcmp(peer
->conf_if
, conf_if
))
14617 && !strcmp(peer
->hostname
, conf_if
))) {
14619 bgp_show_peer(vty
, peer
, use_json
,
14624 if (sockunion_same(&peer
->su
, su
)) {
14626 bgp_show_peer(vty
, peer
, use_json
,
14634 case show_ipv4_all
:
14635 case show_ipv6_all
:
14636 FOREACH_SAFI (safi
) {
14637 if (peer
->afc
[afi
][safi
]) {
14638 bgp_show_peer(vty
, peer
, use_json
, json
);
14647 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14648 type
== show_ipv6_peer
) && !find
) {
14650 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14652 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14655 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14656 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14657 vty_out(vty
, "%% No BGP neighbors found\n");
14660 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14661 json
, JSON_C_TO_STRING_PRETTY
));
14663 vty_out(vty
, "\n");
14666 return CMD_SUCCESS
;
14669 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14670 enum show_type type
,
14671 const char *ip_str
,
14672 afi_t afi
, bool use_json
)
14677 union sockunion su
;
14679 bgp
= bgp_get_default();
14685 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14689 ret
= str2sockunion(ip_str
, &su
);
14691 bgp_show_neighbor_graceful_restart(
14692 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14694 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14695 NULL
, afi
, use_json
);
14697 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14701 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14702 enum show_type type
,
14703 const char *ip_str
,
14706 struct listnode
*node
, *nnode
;
14708 union sockunion su
;
14709 json_object
*json
= NULL
;
14710 int ret
, is_first
= 1;
14711 bool nbr_output
= false;
14714 vty_out(vty
, "{\n");
14716 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14719 if (!(json
= json_object_new_object())) {
14721 EC_BGP_JSON_MEM_ERROR
,
14722 "Unable to allocate memory for JSON object");
14724 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14728 json_object_int_add(json
, "vrfId",
14729 (bgp
->vrf_id
== VRF_UNKNOWN
)
14731 : (int64_t)bgp
->vrf_id
);
14732 json_object_string_add(
14734 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14739 vty_out(vty
, ",\n");
14743 vty_out(vty
, "\"%s\":",
14744 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14748 vty_out(vty
, "\nInstance %s:\n",
14749 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14754 if (type
== show_peer
|| type
== show_ipv4_peer
||
14755 type
== show_ipv6_peer
) {
14756 ret
= str2sockunion(ip_str
, &su
);
14758 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14761 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14764 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14767 json_object_free(json
);
14772 vty_out(vty
, "}\n");
14773 else if (!nbr_output
)
14774 vty_out(vty
, "%% BGP instance not found\n");
14777 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14778 enum show_type type
, const char *ip_str
,
14783 union sockunion su
;
14784 json_object
*json
= NULL
;
14787 if (strmatch(name
, "all")) {
14788 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14790 return CMD_SUCCESS
;
14792 bgp
= bgp_lookup_by_name(name
);
14795 json
= json_object_new_object();
14796 vty_json(vty
, json
);
14799 "%% BGP instance not found\n");
14801 return CMD_WARNING
;
14805 bgp
= bgp_get_default();
14809 json
= json_object_new_object();
14811 ret
= str2sockunion(ip_str
, &su
);
14813 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14816 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14819 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14822 json_object_free(json
);
14825 vty_out(vty
, "{}\n");
14827 vty_out(vty
, "%% BGP instance not found\n");
14830 return CMD_SUCCESS
;
14835 /* "show [ip] bgp neighbors graceful-restart" commands. */
14836 DEFUN (show_ip_bgp_neighbors_graceful_restart
,
14837 show_ip_bgp_neighbors_graceful_restart_cmd
,
14838 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14844 "Neighbor to display information about\n"
14845 "Neighbor to display information about\n"
14846 "Neighbor on BGP configured interface\n"
14850 char *sh_arg
= NULL
;
14851 enum show_type sh_type
;
14853 afi_t afi
= AFI_MAX
;
14854 bool uj
= use_json(argc
, argv
);
14856 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14861 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14862 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14863 || argv_find(argv
, argc
, "WORD", &idx
)) {
14864 sh_type
= show_peer
;
14865 sh_arg
= argv
[idx
]->arg
;
14867 sh_type
= show_all
;
14869 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14870 return CMD_SUCCESS
;
14873 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14877 /* "show [ip] bgp neighbors" commands. */
14878 DEFUN (show_ip_bgp_neighbors
,
14879 show_ip_bgp_neighbors_cmd
,
14880 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14884 BGP_INSTANCE_HELP_STR
14887 "Detailed information on TCP and BGP neighbor connections\n"
14888 "Neighbor to display information about\n"
14889 "Neighbor to display information about\n"
14890 "Neighbor on BGP configured interface\n"
14894 char *sh_arg
= NULL
;
14895 enum show_type sh_type
;
14896 afi_t afi
= AFI_MAX
;
14898 bool uj
= use_json(argc
, argv
);
14902 /* [<vrf> VIEWVRFNAME] */
14903 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14904 vrf
= argv
[idx
+ 1]->arg
;
14905 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14907 } else if (argv_find(argv
, argc
, "view", &idx
))
14908 /* [<view> VIEWVRFNAME] */
14909 vrf
= argv
[idx
+ 1]->arg
;
14913 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14914 sh_type
= show_ipv4_all
;
14916 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14917 sh_type
= show_ipv6_all
;
14920 sh_type
= show_all
;
14923 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14924 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14925 || argv_find(argv
, argc
, "WORD", &idx
)) {
14926 sh_type
= show_peer
;
14927 sh_arg
= argv
[idx
]->arg
;
14930 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14931 sh_type
= show_ipv4_peer
;
14932 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14933 sh_type
= show_ipv6_peer
;
14936 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14939 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14940 paths' and `show ip mbgp paths'. Those functions results are the
14942 DEFUN (show_ip_bgp_paths
,
14943 show_ip_bgp_paths_cmd
,
14944 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14949 "Path information\n")
14951 vty_out(vty
, "Address Refcnt Path\n");
14952 aspath_print_all_vty(vty
);
14953 return CMD_SUCCESS
;
14958 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14961 struct community
*com
;
14963 com
= (struct community
*)bucket
->data
;
14964 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14965 community_str(com
, false, false));
14968 /* Show BGP's community internal data. */
14969 DEFUN (show_ip_bgp_community_info
,
14970 show_ip_bgp_community_info_cmd
,
14971 "show [ip] bgp community-info",
14975 "List all bgp community information\n")
14977 vty_out(vty
, "Address Refcnt Community\n");
14979 hash_iterate(community_hash(),
14980 (void (*)(struct hash_bucket
*,
14981 void *))community_show_all_iterator
,
14984 return CMD_SUCCESS
;
14987 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14990 struct lcommunity
*lcom
;
14992 lcom
= (struct lcommunity
*)bucket
->data
;
14993 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14994 lcommunity_str(lcom
, false, false));
14997 /* Show BGP's community internal data. */
14998 DEFUN (show_ip_bgp_lcommunity_info
,
14999 show_ip_bgp_lcommunity_info_cmd
,
15000 "show ip bgp large-community-info",
15004 "List all bgp large-community information\n")
15006 vty_out(vty
, "Address Refcnt Large-community\n");
15008 hash_iterate(lcommunity_hash(),
15009 (void (*)(struct hash_bucket
*,
15010 void *))lcommunity_show_all_iterator
,
15013 return CMD_SUCCESS
;
15015 /* Graceful Restart */
15017 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
15024 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
15026 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
15028 switch (bgp_global_gr_mode
) {
15030 case GLOBAL_HELPER
:
15031 vty_out(vty
, "Global BGP GR Mode : Helper\n");
15035 vty_out(vty
, "Global BGP GR Mode : Restart\n");
15038 case GLOBAL_DISABLE
:
15039 vty_out(vty
, "Global BGP GR Mode : Disable\n");
15042 case GLOBAL_INVALID
:
15044 "Global BGP GR Mode Invalid\n");
15047 vty_out(vty
, "\n");
15050 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
15051 enum show_type type
,
15052 const char *ip_str
,
15053 afi_t afi
, bool use_json
)
15055 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
15058 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
15060 bgp_show_neighbor_graceful_restart_vty(
15061 vty
, type
, ip_str
, afi
, use_json
);
15064 } else if (afi
!= AFI_MAX
) {
15065 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
15068 return CMD_ERR_INCOMPLETE
;
15071 return CMD_SUCCESS
;
15073 /* Graceful Restart */
15075 DEFUN (show_ip_bgp_attr_info
,
15076 show_ip_bgp_attr_info_cmd
,
15077 "show [ip] bgp attribute-info",
15081 "List all bgp attribute information\n")
15083 attr_show_all(vty
);
15084 return CMD_SUCCESS
;
15087 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
15088 afi_t afi
, safi_t safi
,
15089 bool use_json
, json_object
*json
)
15092 struct listnode
*node
;
15095 enum vpn_policy_direction dir
;
15098 json_object
*json_import_vrfs
= NULL
;
15099 json_object
*json_export_vrfs
= NULL
;
15101 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15104 vty_json(vty
, json
);
15106 return CMD_WARNING
;
15109 /* Provide context for the block */
15110 json_object_string_add(json
, "vrf", name
? name
: "default");
15111 json_object_string_add(json
, "afiSafi",
15112 get_afi_safi_str(afi
, safi
, true));
15114 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15115 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15116 json_object_string_add(json
, "importFromVrfs", "none");
15117 json_object_string_add(json
, "importRts", "none");
15119 json_import_vrfs
= json_object_new_array();
15121 for (ALL_LIST_ELEMENTS_RO(
15122 bgp
->vpn_policy
[afi
].import_vrf
,
15124 json_object_array_add(json_import_vrfs
,
15125 json_object_new_string(vname
));
15127 json_object_object_add(json
, "importFromVrfs",
15129 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15130 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15131 ecom_str
= ecommunity_ecom2str(
15132 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15133 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15134 json_object_string_add(json
, "importRts",
15136 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15138 json_object_string_add(json
, "importRts",
15142 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15143 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15144 json_object_string_add(json
, "exportToVrfs", "none");
15145 json_object_string_add(json
, "routeDistinguisher",
15147 json_object_string_add(json
, "exportRts", "none");
15149 json_export_vrfs
= json_object_new_array();
15151 for (ALL_LIST_ELEMENTS_RO(
15152 bgp
->vpn_policy
[afi
].export_vrf
,
15154 json_object_array_add(json_export_vrfs
,
15155 json_object_new_string(vname
));
15156 json_object_object_add(json
, "exportToVrfs",
15158 json_object_string_addf(json
, "routeDistinguisher",
15160 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15162 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15163 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15164 ecom_str
= ecommunity_ecom2str(
15165 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15166 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15167 json_object_string_add(json
, "exportRts",
15169 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15171 json_object_string_add(json
, "exportRts",
15176 vty_json(vty
, json
);
15179 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15182 vty_out(vty
, "%% No such BGP instance exist\n");
15183 return CMD_WARNING
;
15186 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15187 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15189 "This VRF is not importing %s routes from any other VRF\n",
15190 get_afi_safi_str(afi
, safi
, false));
15193 "This VRF is importing %s routes from the following VRFs:\n",
15194 get_afi_safi_str(afi
, safi
, false));
15196 for (ALL_LIST_ELEMENTS_RO(
15197 bgp
->vpn_policy
[afi
].import_vrf
,
15199 vty_out(vty
, " %s\n", vname
);
15201 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15203 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15204 ecom_str
= ecommunity_ecom2str(
15205 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15206 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15207 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15209 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15211 vty_out(vty
, "Import RT(s):\n");
15214 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15215 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15217 "This VRF is not exporting %s routes to any other VRF\n",
15218 get_afi_safi_str(afi
, safi
, false));
15221 "This VRF is exporting %s routes to the following VRFs:\n",
15222 get_afi_safi_str(afi
, safi
, false));
15224 for (ALL_LIST_ELEMENTS_RO(
15225 bgp
->vpn_policy
[afi
].export_vrf
,
15227 vty_out(vty
, " %s\n", vname
);
15229 vty_out(vty
, "RD: %pRD\n",
15230 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15232 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15233 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15234 ecom_str
= ecommunity_ecom2str(
15235 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15236 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15237 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15238 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15240 vty_out(vty
, "Import RT(s):\n");
15244 return CMD_SUCCESS
;
15247 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15248 safi_t safi
, bool use_json
)
15250 struct listnode
*node
, *nnode
;
15252 char *vrf_name
= NULL
;
15253 json_object
*json
= NULL
;
15254 json_object
*json_vrf
= NULL
;
15255 json_object
*json_vrfs
= NULL
;
15258 json
= json_object_new_object();
15259 json_vrfs
= json_object_new_object();
15262 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15264 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15265 vrf_name
= bgp
->name
;
15268 json_vrf
= json_object_new_object();
15270 vty_out(vty
, "\nInstance %s:\n",
15271 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15272 ? VRF_DEFAULT_NAME
: bgp
->name
);
15274 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15276 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15277 json_object_object_add(json_vrfs
,
15278 VRF_DEFAULT_NAME
, json_vrf
);
15280 json_object_object_add(json_vrfs
, vrf_name
,
15286 json_object_object_add(json
, "vrfs", json_vrfs
);
15287 vty_json(vty
, json
);
15290 return CMD_SUCCESS
;
15293 /* "show [ip] bgp route-leak" command. */
15294 DEFUN (show_ip_bgp_route_leak
,
15295 show_ip_bgp_route_leak_cmd
,
15296 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15300 BGP_INSTANCE_HELP_STR
15303 "Route leaking information\n"
15307 afi_t afi
= AFI_MAX
;
15308 safi_t safi
= SAFI_MAX
;
15310 bool uj
= use_json(argc
, argv
);
15312 json_object
*json
= NULL
;
15314 /* show [ip] bgp */
15315 if (argv_find(argv
, argc
, "ip", &idx
)) {
15317 safi
= SAFI_UNICAST
;
15319 /* [vrf VIEWVRFNAME] */
15320 if (argv_find(argv
, argc
, "view", &idx
)) {
15322 "%% This command is not applicable to BGP views\n");
15323 return CMD_WARNING
;
15326 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15327 vrf
= argv
[idx
+ 1]->arg
;
15328 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15331 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15332 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15333 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15335 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15337 "%% This command is applicable only for unicast ipv4|ipv6\n");
15338 return CMD_WARNING
;
15341 if (vrf
&& strmatch(vrf
, "all"))
15342 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15345 json
= json_object_new_object();
15347 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15350 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15353 struct listnode
*node
, *nnode
;
15356 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15357 vty_out(vty
, "\nInstance %s:\n",
15358 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15361 update_group_show(bgp
, afi
, safi
, vty
, 0);
15365 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15366 int safi
, uint64_t subgrp_id
)
15371 if (strmatch(name
, "all")) {
15372 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
15373 return CMD_SUCCESS
;
15375 bgp
= bgp_lookup_by_name(name
);
15378 bgp
= bgp_get_default();
15382 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
15383 return CMD_SUCCESS
;
15386 DEFUN (show_ip_bgp_updgrps
,
15387 show_ip_bgp_updgrps_cmd
,
15388 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
15392 BGP_INSTANCE_HELP_STR
15394 BGP_SAFI_WITH_LABEL_HELP_STR
15395 "Detailed info about dynamic update groups\n"
15396 "Specific subgroup to display detailed info for\n")
15399 afi_t afi
= AFI_IP6
;
15400 safi_t safi
= SAFI_UNICAST
;
15401 uint64_t subgrp_id
= 0;
15405 /* show [ip] bgp */
15406 if (argv_find(argv
, argc
, "ip", &idx
))
15408 /* [<vrf> VIEWVRFNAME] */
15409 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15410 vrf
= argv
[idx
+ 1]->arg
;
15411 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15413 } else if (argv_find(argv
, argc
, "view", &idx
))
15414 /* [<view> VIEWVRFNAME] */
15415 vrf
= argv
[idx
+ 1]->arg
;
15416 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15417 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15418 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15421 /* get subgroup id, if provided */
15423 if (argv
[idx
]->type
== VARIABLE_TKN
)
15424 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15426 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
15429 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15430 show_bgp_instance_all_ipv6_updgrps_cmd
,
15431 "show [ip] bgp <view|vrf> all update-groups",
15435 BGP_INSTANCE_ALL_HELP_STR
15436 "Detailed info about dynamic update groups\n")
15438 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15439 return CMD_SUCCESS
;
15442 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15443 show_bgp_l2vpn_evpn_updgrps_cmd
,
15444 "show [ip] bgp l2vpn evpn update-groups",
15448 "l2vpn address family\n"
15449 "evpn sub-address family\n"
15450 "Detailed info about dynamic update groups\n")
15453 uint64_t subgrp_id
= 0;
15455 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15456 return CMD_SUCCESS
;
15459 DEFUN (show_bgp_updgrps_stats
,
15460 show_bgp_updgrps_stats_cmd
,
15461 "show [ip] bgp update-groups statistics",
15465 "Detailed info about dynamic update groups\n"
15470 bgp
= bgp_get_default();
15472 update_group_show_stats(bgp
, vty
);
15474 return CMD_SUCCESS
;
15477 DEFUN (show_bgp_instance_updgrps_stats
,
15478 show_bgp_instance_updgrps_stats_cmd
,
15479 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15483 BGP_INSTANCE_HELP_STR
15484 "Detailed info about dynamic update groups\n"
15490 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15492 update_group_show_stats(bgp
, vty
);
15494 return CMD_SUCCESS
;
15497 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15498 afi_t afi
, safi_t safi
,
15499 const char *what
, uint64_t subgrp_id
)
15504 bgp
= bgp_lookup_by_name(name
);
15506 bgp
= bgp_get_default();
15509 if (!strcmp(what
, "advertise-queue"))
15510 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15512 else if (!strcmp(what
, "advertised-routes"))
15513 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15515 else if (!strcmp(what
, "packet-queue"))
15516 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15521 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15522 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15523 "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",
15524 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15526 "Detailed info about dynamic update groups\n"
15527 "Specific subgroup to display info for\n"
15528 "Advertisement queue\n"
15529 "Announced routes\n"
15532 uint64_t subgrp_id
= 0;
15536 subgrp_id
= strtoull(sgid
, NULL
, 10);
15541 afiz
= bgp_vty_afi_from_str(afi
);
15545 afiz
= bgp_vty_afi_from_str(afi
);
15546 if (afiz
!= AFI_IP
)
15548 "%% Cannot specify both 'ip' and 'ipv6'\n");
15549 return CMD_WARNING
;
15552 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15554 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15555 return CMD_SUCCESS
;
15558 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15561 struct listnode
*node
, *nnode
;
15562 struct prefix
*range
;
15567 const char *peer_status
;
15571 json_object
*json_peer_group
= NULL
;
15572 json_object
*json_peer_group_afc
= NULL
;
15573 json_object
*json_peer_group_members
= NULL
;
15574 json_object
*json_peer_group_dynamic
= NULL
;
15575 json_object
*json_peer_group_dynamic_af
= NULL
;
15576 json_object
*json_peer_group_ranges
= NULL
;
15578 conf
= group
->conf
;
15581 json_peer_group
= json_object_new_object();
15582 json_peer_group_afc
= json_object_new_array();
15585 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15587 json_object_int_add(json_peer_group
, "remoteAs",
15590 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15591 group
->name
, conf
->as
);
15592 } else if (conf
->as_type
== AS_INTERNAL
) {
15594 json_object_int_add(json_peer_group
, "remoteAs",
15597 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15598 group
->name
, group
->bgp
->as
);
15601 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15604 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15606 json_object_string_add(json_peer_group
, "type",
15609 vty_out(vty
, " Peer-group type is internal\n");
15612 json_object_string_add(json_peer_group
, "type",
15615 vty_out(vty
, " Peer-group type is external\n");
15618 /* Display AFs configured. */
15620 vty_out(vty
, " Configured address-families:");
15622 FOREACH_AFI_SAFI (afi
, safi
) {
15623 if (conf
->afc
[afi
][safi
]) {
15626 json_object_array_add(
15627 json_peer_group_afc
,
15628 json_object_new_string(get_afi_safi_str(
15629 afi
, safi
, false)));
15631 vty_out(vty
, " %s;",
15632 get_afi_safi_str(afi
, safi
, false));
15637 json_object_object_add(json_peer_group
,
15638 "addressFamiliesConfigured",
15639 json_peer_group_afc
);
15642 vty_out(vty
, " none\n");
15644 vty_out(vty
, "\n");
15647 /* Display listen ranges (for dynamic neighbors), if any */
15648 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15649 lr_count
= listcount(group
->listen_range
[afi
]);
15652 if (!json_peer_group_dynamic
)
15653 json_peer_group_dynamic
=
15654 json_object_new_object();
15656 json_peer_group_dynamic_af
=
15657 json_object_new_object();
15658 json_peer_group_ranges
=
15659 json_object_new_array();
15660 json_object_int_add(json_peer_group_dynamic_af
,
15661 "count", lr_count
);
15663 vty_out(vty
, " %d %s listen range(s)\n",
15664 lr_count
, afi2str(afi
));
15667 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15672 snprintfrr(buf
, sizeof(buf
), "%pFX",
15675 json_object_array_add(
15676 json_peer_group_ranges
,
15677 json_object_new_string(buf
));
15679 vty_out(vty
, " %pFX\n", range
);
15684 json_object_object_add(
15685 json_peer_group_dynamic_af
, "ranges",
15686 json_peer_group_ranges
);
15688 json_object_object_add(
15689 json_peer_group_dynamic
, afi2str(afi
),
15690 json_peer_group_dynamic_af
);
15695 if (json_peer_group_dynamic
)
15696 json_object_object_add(json_peer_group
, "dynamicRanges",
15697 json_peer_group_dynamic
);
15699 /* Display group members and their status */
15700 if (listcount(group
->peer
)) {
15702 json_peer_group_members
= json_object_new_object();
15704 vty_out(vty
, " Peer-group members:\n");
15705 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15706 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15707 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15708 peer_status
= "Idle (Admin)";
15709 else if (CHECK_FLAG(peer
->sflags
,
15710 PEER_STATUS_PREFIX_OVERFLOW
))
15711 peer_status
= "Idle (PfxCt)";
15713 peer_status
= lookup_msg(bgp_status_msg
,
15714 peer
->status
, NULL
);
15716 dynamic
= peer_dynamic_neighbor(peer
);
15719 json_object
*json_peer_group_member
=
15720 json_object_new_object();
15722 json_object_string_add(json_peer_group_member
,
15723 "status", peer_status
);
15726 json_object_boolean_true_add(
15727 json_peer_group_member
,
15730 json_object_object_add(json_peer_group_members
,
15732 json_peer_group_member
);
15734 vty_out(vty
, " %s %s %s \n", peer
->host
,
15735 dynamic
? "(dynamic)" : "",
15740 json_object_object_add(json_peer_group
, "members",
15741 json_peer_group_members
);
15745 json_object_object_add(json
, group
->name
, json_peer_group
);
15747 return CMD_SUCCESS
;
15750 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15751 const char *group_name
, bool uj
)
15754 struct listnode
*node
, *nnode
;
15755 struct peer_group
*group
;
15756 bool found
= false;
15757 json_object
*json
= NULL
;
15760 json
= json_object_new_object();
15762 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15766 vty_json(vty
, json
);
15768 vty_out(vty
, "%% BGP instance not found\n");
15770 return CMD_WARNING
;
15773 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15775 if (strmatch(group
->name
, group_name
)) {
15776 bgp_show_one_peer_group(vty
, group
, json
);
15781 bgp_show_one_peer_group(vty
, group
, json
);
15785 if (group_name
&& !found
&& !uj
)
15786 vty_out(vty
, "%% No such peer-group\n");
15789 vty_json(vty
, json
);
15791 return CMD_SUCCESS
;
15794 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
15795 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
15796 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
15797 "Detailed information on BGP peer groups\n"
15798 "Peer group name\n" JSON_STR
)
15802 bool uj
= use_json(argc
, argv
);
15804 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15806 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15808 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
15812 /* Redistribute VTY commands. */
15814 DEFUN (bgp_redistribute_ipv4
,
15815 bgp_redistribute_ipv4_cmd
,
15816 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15817 "Redistribute information from another routing protocol\n"
15818 FRR_IP_REDIST_HELP_STR_BGPD
)
15820 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15821 int idx_protocol
= 1;
15824 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15826 vty_out(vty
, "%% Invalid route type\n");
15827 return CMD_WARNING_CONFIG_FAILED
;
15830 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15831 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
15835 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15836 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15837 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15839 DEFUN (bgp_redistribute_ipv4_rmap
,
15840 bgp_redistribute_ipv4_rmap_cmd
,
15841 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15842 "Redistribute information from another routing protocol\n"
15843 FRR_IP_REDIST_HELP_STR_BGPD
15844 "Route map reference\n"
15845 "Pointer to route-map entries\n")
15847 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15848 int idx_protocol
= 1;
15851 struct bgp_redist
*red
;
15853 struct route_map
*route_map
= route_map_lookup_warn_noexist(
15854 vty
, argv
[idx_word
]->arg
);
15856 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15858 vty_out(vty
, "%% Invalid route type\n");
15859 return CMD_WARNING_CONFIG_FAILED
;
15862 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15864 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15865 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15869 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15870 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
15871 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15872 "Route map reference\n"
15873 "Pointer to route-map entries\n")
15875 DEFUN (bgp_redistribute_ipv4_metric
,
15876 bgp_redistribute_ipv4_metric_cmd
,
15877 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15878 "Redistribute information from another routing protocol\n"
15879 FRR_IP_REDIST_HELP_STR_BGPD
15880 "Metric for redistributed routes\n"
15881 "Default metric\n")
15883 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15884 int idx_protocol
= 1;
15885 int idx_number
= 3;
15888 struct bgp_redist
*red
;
15891 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15893 vty_out(vty
, "%% Invalid route type\n");
15894 return CMD_WARNING_CONFIG_FAILED
;
15896 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15898 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15899 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15900 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15904 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15905 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15906 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15907 "Metric for redistributed routes\n"
15908 "Default metric\n")
15910 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
15911 bgp_redistribute_ipv4_rmap_metric_cmd
,
15912 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
15913 "Redistribute information from another routing protocol\n"
15914 FRR_IP_REDIST_HELP_STR_BGPD
15915 "Route map reference\n"
15916 "Pointer to route-map entries\n"
15917 "Metric for redistributed routes\n"
15918 "Default metric\n")
15920 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15921 int idx_protocol
= 1;
15923 int idx_number
= 5;
15926 struct bgp_redist
*red
;
15928 struct route_map
*route_map
=
15929 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15931 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15933 vty_out(vty
, "%% Invalid route type\n");
15934 return CMD_WARNING_CONFIG_FAILED
;
15936 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15938 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15940 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15941 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15942 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15946 bgp_redistribute_ipv4_rmap_metric
,
15947 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15948 "redistribute " FRR_IP_REDIST_STR_BGPD
15949 " route-map RMAP_NAME metric (0-4294967295)",
15950 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15951 "Route map reference\n"
15952 "Pointer to route-map entries\n"
15953 "Metric for redistributed routes\n"
15954 "Default metric\n")
15956 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
15957 bgp_redistribute_ipv4_metric_rmap_cmd
,
15958 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
15959 "Redistribute information from another routing protocol\n"
15960 FRR_IP_REDIST_HELP_STR_BGPD
15961 "Metric for redistributed routes\n"
15963 "Route map reference\n"
15964 "Pointer to route-map entries\n")
15966 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
15967 int idx_protocol
= 1;
15968 int idx_number
= 3;
15972 struct bgp_redist
*red
;
15974 struct route_map
*route_map
=
15975 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
15977 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
15979 vty_out(vty
, "%% Invalid route type\n");
15980 return CMD_WARNING_CONFIG_FAILED
;
15982 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
15984 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
15985 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
15987 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
15988 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
15992 bgp_redistribute_ipv4_metric_rmap
,
15993 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15994 "redistribute " FRR_IP_REDIST_STR_BGPD
15995 " metric (0-4294967295) route-map RMAP_NAME",
15996 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15997 "Metric for redistributed routes\n"
15999 "Route map reference\n"
16000 "Pointer to route-map entries\n")
16002 DEFUN (bgp_redistribute_ipv4_ospf
,
16003 bgp_redistribute_ipv4_ospf_cmd
,
16004 "redistribute <ospf|table> (1-65535)",
16005 "Redistribute information from another routing protocol\n"
16006 "Open Shortest Path First (OSPFv2)\n"
16007 "Non-main Kernel Routing Table\n"
16008 "Instance ID/Table ID\n")
16010 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16011 int idx_ospf_table
= 1;
16012 int idx_number
= 2;
16013 unsigned short instance
;
16014 unsigned short protocol
;
16016 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16018 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16019 protocol
= ZEBRA_ROUTE_OSPF
;
16021 protocol
= ZEBRA_ROUTE_TABLE
;
16023 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16024 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
16027 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
16028 "redistribute <ospf|table> (1-65535)",
16029 "Redistribute information from another routing protocol\n"
16030 "Open Shortest Path First (OSPFv2)\n"
16031 "Non-main Kernel Routing Table\n"
16032 "Instance ID/Table ID\n")
16034 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
16035 bgp_redistribute_ipv4_ospf_rmap_cmd
,
16036 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16037 "Redistribute information from another routing protocol\n"
16038 "Open Shortest Path First (OSPFv2)\n"
16039 "Non-main Kernel Routing Table\n"
16040 "Instance ID/Table ID\n"
16041 "Route map reference\n"
16042 "Pointer to route-map entries\n")
16044 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16045 int idx_ospf_table
= 1;
16046 int idx_number
= 2;
16048 struct bgp_redist
*red
;
16049 unsigned short instance
;
16052 struct route_map
*route_map
=
16053 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16055 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16056 protocol
= ZEBRA_ROUTE_OSPF
;
16058 protocol
= ZEBRA_ROUTE_TABLE
;
16060 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16061 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16063 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16064 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16067 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
16068 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
16069 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16070 "Redistribute information from another routing protocol\n"
16071 "Open Shortest Path First (OSPFv2)\n"
16072 "Non-main Kernel Routing Table\n"
16073 "Instance ID/Table ID\n"
16074 "Route map reference\n"
16075 "Pointer to route-map entries\n")
16077 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
16078 bgp_redistribute_ipv4_ospf_metric_cmd
,
16079 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16080 "Redistribute information from another routing protocol\n"
16081 "Open Shortest Path First (OSPFv2)\n"
16082 "Non-main Kernel Routing Table\n"
16083 "Instance ID/Table ID\n"
16084 "Metric for redistributed routes\n"
16085 "Default metric\n")
16087 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16088 int idx_ospf_table
= 1;
16089 int idx_number
= 2;
16090 int idx_number_2
= 4;
16092 struct bgp_redist
*red
;
16093 unsigned short instance
;
16097 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16098 protocol
= ZEBRA_ROUTE_OSPF
;
16100 protocol
= ZEBRA_ROUTE_TABLE
;
16102 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16103 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16105 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16106 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16108 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16111 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
16112 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
16113 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16114 "Redistribute information from another routing protocol\n"
16115 "Open Shortest Path First (OSPFv2)\n"
16116 "Non-main Kernel Routing Table\n"
16117 "Instance ID/Table ID\n"
16118 "Metric for redistributed routes\n"
16119 "Default metric\n")
16121 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
16122 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
16123 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16124 "Redistribute information from another routing protocol\n"
16125 "Open Shortest Path First (OSPFv2)\n"
16126 "Non-main Kernel Routing Table\n"
16127 "Instance ID/Table ID\n"
16128 "Route map reference\n"
16129 "Pointer to route-map entries\n"
16130 "Metric for redistributed routes\n"
16131 "Default metric\n")
16133 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16134 int idx_ospf_table
= 1;
16135 int idx_number
= 2;
16137 int idx_number_2
= 6;
16139 struct bgp_redist
*red
;
16140 unsigned short instance
;
16143 struct route_map
*route_map
=
16144 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16146 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16147 protocol
= ZEBRA_ROUTE_OSPF
;
16149 protocol
= ZEBRA_ROUTE_TABLE
;
16151 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16152 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16154 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16156 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16157 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16159 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16163 bgp_redistribute_ipv4_ospf_rmap_metric
,
16164 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
16165 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16166 "Redistribute information from another routing protocol\n"
16167 "Open Shortest Path First (OSPFv2)\n"
16168 "Non-main Kernel Routing Table\n"
16169 "Instance ID/Table ID\n"
16170 "Route map reference\n"
16171 "Pointer to route-map entries\n"
16172 "Metric for redistributed routes\n"
16173 "Default metric\n")
16175 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
16176 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
16177 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16178 "Redistribute information from another routing protocol\n"
16179 "Open Shortest Path First (OSPFv2)\n"
16180 "Non-main Kernel Routing Table\n"
16181 "Instance ID/Table ID\n"
16182 "Metric for redistributed routes\n"
16184 "Route map reference\n"
16185 "Pointer to route-map entries\n")
16187 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16188 int idx_ospf_table
= 1;
16189 int idx_number
= 2;
16190 int idx_number_2
= 4;
16193 struct bgp_redist
*red
;
16194 unsigned short instance
;
16197 struct route_map
*route_map
=
16198 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16200 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16201 protocol
= ZEBRA_ROUTE_OSPF
;
16203 protocol
= ZEBRA_ROUTE_TABLE
;
16205 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16206 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16208 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16209 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16212 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16213 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16217 bgp_redistribute_ipv4_ospf_metric_rmap
,
16218 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16219 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16220 "Redistribute information from another routing protocol\n"
16221 "Open Shortest Path First (OSPFv2)\n"
16222 "Non-main Kernel Routing Table\n"
16223 "Instance ID/Table ID\n"
16224 "Metric for redistributed routes\n"
16226 "Route map reference\n"
16227 "Pointer to route-map entries\n")
16229 DEFUN (no_bgp_redistribute_ipv4_ospf
,
16230 no_bgp_redistribute_ipv4_ospf_cmd
,
16231 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16233 "Redistribute information from another routing protocol\n"
16234 "Open Shortest Path First (OSPFv2)\n"
16235 "Non-main Kernel Routing Table\n"
16236 "Instance ID/Table ID\n"
16237 "Metric for redistributed routes\n"
16239 "Route map reference\n"
16240 "Pointer to route-map entries\n")
16242 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16243 int idx_ospf_table
= 2;
16244 int idx_number
= 3;
16245 unsigned short instance
;
16248 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16249 protocol
= ZEBRA_ROUTE_OSPF
;
16251 protocol
= ZEBRA_ROUTE_TABLE
;
16253 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16254 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
16258 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16259 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16261 "Redistribute information from another routing protocol\n"
16262 "Open Shortest Path First (OSPFv2)\n"
16263 "Non-main Kernel Routing Table\n"
16264 "Instance ID/Table ID\n"
16265 "Metric for redistributed routes\n"
16267 "Route map reference\n"
16268 "Pointer to route-map entries\n")
16270 DEFUN (no_bgp_redistribute_ipv4
,
16271 no_bgp_redistribute_ipv4_cmd
,
16272 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16274 "Redistribute information from another routing protocol\n"
16275 FRR_IP_REDIST_HELP_STR_BGPD
16276 "Metric for redistributed routes\n"
16278 "Route map reference\n"
16279 "Pointer to route-map entries\n")
16281 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16282 int idx_protocol
= 2;
16285 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16287 vty_out(vty
, "%% Invalid route type\n");
16288 return CMD_WARNING_CONFIG_FAILED
;
16290 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
16294 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16295 "no redistribute " FRR_IP_REDIST_STR_BGPD
16296 " [{metric (0-4294967295)|route-map RMAP_NAME}]",
16298 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16299 "Metric for redistributed routes\n"
16301 "Route map reference\n"
16302 "Pointer to route-map entries\n")
16304 DEFUN (bgp_redistribute_ipv6
,
16305 bgp_redistribute_ipv6_cmd
,
16306 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16307 "Redistribute information from another routing protocol\n"
16308 FRR_IP6_REDIST_HELP_STR_BGPD
)
16310 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16311 int idx_protocol
= 1;
16314 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16316 vty_out(vty
, "%% Invalid route type\n");
16317 return CMD_WARNING_CONFIG_FAILED
;
16320 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16321 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
16324 DEFUN (bgp_redistribute_ipv6_rmap
,
16325 bgp_redistribute_ipv6_rmap_cmd
,
16326 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME",
16327 "Redistribute information from another routing protocol\n"
16328 FRR_IP6_REDIST_HELP_STR_BGPD
16329 "Route map reference\n"
16330 "Pointer to route-map entries\n")
16332 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16333 int idx_protocol
= 1;
16336 struct bgp_redist
*red
;
16338 struct route_map
*route_map
=
16339 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16341 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16343 vty_out(vty
, "%% Invalid route type\n");
16344 return CMD_WARNING_CONFIG_FAILED
;
16347 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16349 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16350 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16353 DEFUN (bgp_redistribute_ipv6_metric
,
16354 bgp_redistribute_ipv6_metric_cmd
,
16355 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16356 "Redistribute information from another routing protocol\n"
16357 FRR_IP6_REDIST_HELP_STR_BGPD
16358 "Metric for redistributed routes\n"
16359 "Default metric\n")
16361 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16362 int idx_protocol
= 1;
16363 int idx_number
= 3;
16366 struct bgp_redist
*red
;
16369 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16371 vty_out(vty
, "%% Invalid route type\n");
16372 return CMD_WARNING_CONFIG_FAILED
;
16374 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16376 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16377 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
16378 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16381 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
16382 bgp_redistribute_ipv6_rmap_metric_cmd
,
16383 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16384 "Redistribute information from another routing protocol\n"
16385 FRR_IP6_REDIST_HELP_STR_BGPD
16386 "Route map reference\n"
16387 "Pointer to route-map entries\n"
16388 "Metric for redistributed routes\n"
16389 "Default metric\n")
16391 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16392 int idx_protocol
= 1;
16394 int idx_number
= 5;
16397 struct bgp_redist
*red
;
16399 struct route_map
*route_map
=
16400 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16402 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16404 vty_out(vty
, "%% Invalid route type\n");
16405 return CMD_WARNING_CONFIG_FAILED
;
16407 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16409 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16411 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16412 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
16414 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16417 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
16418 bgp_redistribute_ipv6_metric_rmap_cmd
,
16419 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16420 "Redistribute information from another routing protocol\n"
16421 FRR_IP6_REDIST_HELP_STR_BGPD
16422 "Metric for redistributed routes\n"
16424 "Route map reference\n"
16425 "Pointer to route-map entries\n")
16427 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16428 int idx_protocol
= 1;
16429 int idx_number
= 3;
16433 struct bgp_redist
*red
;
16435 struct route_map
*route_map
=
16436 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16438 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16440 vty_out(vty
, "%% Invalid route type\n");
16441 return CMD_WARNING_CONFIG_FAILED
;
16443 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16445 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16446 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
16449 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16450 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16453 DEFUN (no_bgp_redistribute_ipv6
,
16454 no_bgp_redistribute_ipv6_cmd
,
16455 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16457 "Redistribute information from another routing protocol\n"
16458 FRR_IP6_REDIST_HELP_STR_BGPD
16459 "Metric for redistributed routes\n"
16461 "Route map reference\n"
16462 "Pointer to route-map entries\n")
16464 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16465 int idx_protocol
= 2;
16468 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16470 vty_out(vty
, "%% Invalid route type\n");
16471 return CMD_WARNING_CONFIG_FAILED
;
16474 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
16477 /* Neighbor update tcp-mss. */
16478 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16479 const char *tcp_mss_str
)
16482 uint32_t tcp_mss_val
= 0;
16484 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16486 return CMD_WARNING_CONFIG_FAILED
;
16489 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16490 peer_tcp_mss_set(peer
, tcp_mss_val
);
16492 peer_tcp_mss_unset(peer
);
16495 return CMD_SUCCESS
;
16498 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16499 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16500 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16501 "TCP max segment size\n"
16504 int peer_index
= 1;
16508 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16509 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16510 argv
[mss_index
]->arg
);
16513 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16514 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16515 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16516 "TCP max segment size\n"
16519 int peer_index
= 2;
16522 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16523 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16526 DEFPY(bgp_retain_route_target
, bgp_retain_route_target_cmd
,
16527 "[no$no] bgp retain route-target all",
16529 "Retain BGP updates\n"
16530 "Retain BGP updates based on route-target values\n"
16531 "Retain all BGP updates\n")
16534 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
16536 check
= CHECK_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)][bgp_node_safi(vty
)],
16537 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16538 if (check
!= !no
) {
16540 SET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16541 [bgp_node_safi(vty
)],
16542 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16544 UNSET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16545 [bgp_node_safi(vty
)],
16546 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16547 /* trigger a flush to re-sync with ADJ-RIB-in */
16548 bgp_clear(vty
, bgp
, bgp_node_afi(vty
), bgp_node_safi(vty
),
16549 clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
16551 return CMD_SUCCESS
;
16554 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16555 afi_t afi
, safi_t safi
)
16559 /* Unicast redistribution only. */
16560 if (safi
!= SAFI_UNICAST
)
16563 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16564 /* Redistribute BGP does not make sense. */
16565 if (i
!= ZEBRA_ROUTE_BGP
) {
16566 struct list
*red_list
;
16567 struct listnode
*node
;
16568 struct bgp_redist
*red
;
16570 red_list
= bgp
->redist
[afi
][i
];
16574 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16575 /* "redistribute" configuration. */
16576 vty_out(vty
, " redistribute %s",
16577 zebra_route_string(i
));
16579 vty_out(vty
, " %d", red
->instance
);
16580 if (red
->redist_metric_flag
)
16581 vty_out(vty
, " metric %u",
16582 red
->redist_metric
);
16583 if (red
->rmap
.name
)
16584 vty_out(vty
, " route-map %s",
16586 vty_out(vty
, "\n");
16592 /* peer-group helpers for config-write */
16594 static bool peergroup_flag_check(struct peer
*peer
, uint64_t flag
)
16596 if (!peer_group_active(peer
)) {
16597 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16598 return !CHECK_FLAG(peer
->flags
, flag
);
16600 return !!CHECK_FLAG(peer
->flags
, flag
);
16603 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16606 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16609 if (!peer_group_active(peer
)) {
16610 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16611 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16613 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16616 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16619 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16620 uint8_t type
, int direct
)
16622 struct bgp_filter
*filter
;
16624 if (peer_group_active(peer
))
16625 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16628 filter
= &peer
->filter
[afi
][safi
];
16630 case PEER_FT_DISTRIBUTE_LIST
:
16631 return !!(filter
->dlist
[direct
].name
);
16632 case PEER_FT_FILTER_LIST
:
16633 return !!(filter
->aslist
[direct
].name
);
16634 case PEER_FT_PREFIX_LIST
:
16635 return !!(filter
->plist
[direct
].name
);
16636 case PEER_FT_ROUTE_MAP
:
16637 return !!(filter
->map
[direct
].name
);
16638 case PEER_FT_UNSUPPRESS_MAP
:
16639 return !!(filter
->usmap
.name
);
16640 case PEER_FT_ADVERTISE_MAP
:
16641 return !!(filter
->advmap
.aname
16642 && ((filter
->advmap
.condition
== direct
)
16643 && filter
->advmap
.cname
));
16649 /* Return true if the addpath type is set for peer and different from
16652 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16655 enum bgp_addpath_strat type
, g_type
;
16657 type
= peer
->addpath_type
[afi
][safi
];
16659 if (type
!= BGP_ADDPATH_NONE
) {
16660 if (peer_group_active(peer
)) {
16661 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16663 if (type
!= g_type
)
16675 /* This is part of the address-family block (unicast only) */
16676 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16680 uint32_t tovpn_sid_index
= 0;
16682 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16683 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16684 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16685 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16686 bgp
->vpn_policy
[afi
]
16687 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16689 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16690 bgp
->vpn_policy
[afi
]
16691 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16693 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16694 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16695 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16696 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16699 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16700 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16702 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16705 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16706 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16707 bgp
->vpn_policy
[afi
].tovpn_label
);
16711 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
16712 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16713 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
16714 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
16715 } else if (tovpn_sid_index
!= 0) {
16716 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
16720 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
, BGP_VPN_POLICY_TOVPN_RD_SET
))
16721 vty_out(vty
, "%*srd vpn export %pRD\n", indent
, "",
16722 &bgp
->vpn_policy
[afi
].tovpn_rd
);
16724 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16725 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16727 char buf
[PREFIX_STRLEN
];
16728 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16729 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16732 vty_out(vty
, "%*snexthop vpn export %s\n",
16736 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16737 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16739 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16740 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16742 char *b
= ecommunity_ecom2str(
16743 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16744 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16745 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16746 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16748 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16749 char *b
= ecommunity_ecom2str(
16750 bgp
->vpn_policy
[afi
]
16751 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16752 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16753 ECOMMUNITY_ROUTE_TARGET
);
16754 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16755 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16757 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16758 char *b
= ecommunity_ecom2str(
16759 bgp
->vpn_policy
[afi
]
16760 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16761 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16762 ECOMMUNITY_ROUTE_TARGET
);
16763 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16764 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16768 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16769 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16770 bgp
->vpn_policy
[afi
]
16771 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16773 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16774 char *b
= ecommunity_ecom2str(
16775 bgp
->vpn_policy
[afi
]
16776 .import_redirect_rtlist
,
16777 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16778 ECOMMUNITY_ROUTE_TARGET
);
16780 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16781 != ECOMMUNITY_SIZE
)
16782 vty_out(vty
, "%*srt6 redirect import %s\n",
16785 vty_out(vty
, "%*srt redirect import %s\n",
16787 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16791 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16792 afi_t afi
, safi_t safi
)
16794 struct bgp_filter
*filter
;
16798 filter
= &peer
->filter
[afi
][safi
];
16800 /* distribute-list. */
16801 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16803 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16804 filter
->dlist
[FILTER_IN
].name
);
16806 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16808 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16809 filter
->dlist
[FILTER_OUT
].name
);
16812 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16814 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16815 filter
->plist
[FILTER_IN
].name
);
16817 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16819 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16820 filter
->plist
[FILTER_OUT
].name
);
16823 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16824 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16825 filter
->map
[RMAP_IN
].name
);
16827 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16829 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16830 filter
->map
[RMAP_OUT
].name
);
16832 /* unsuppress-map */
16833 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16834 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16835 filter
->usmap
.name
);
16837 /* advertise-map : always applied in OUT direction*/
16838 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16839 CONDITION_NON_EXIST
))
16841 " neighbor %s advertise-map %s non-exist-map %s\n",
16842 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16844 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16846 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16847 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16850 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16852 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16853 filter
->aslist
[FILTER_IN
].name
);
16855 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16857 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16858 filter
->aslist
[FILTER_OUT
].name
);
16861 /* BGP peer configuration display function. */
16862 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16865 struct peer
*g_peer
= NULL
;
16867 int if_pg_printed
= false;
16868 int if_ras_printed
= false;
16870 /* Skip dynamic neighbors. */
16871 if (peer_dynamic_neighbor(peer
))
16875 addr
= peer
->conf_if
;
16879 /************************************
16880 ****** Global to the neighbor ******
16881 ************************************/
16882 if (peer
->conf_if
) {
16883 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16884 vty_out(vty
, " neighbor %s interface v6only", addr
);
16886 vty_out(vty
, " neighbor %s interface", addr
);
16888 if (peer_group_active(peer
)) {
16889 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16890 if_pg_printed
= true;
16891 } else if (peer
->as_type
== AS_SPECIFIED
) {
16892 vty_out(vty
, " remote-as %u", peer
->as
);
16893 if_ras_printed
= true;
16894 } else if (peer
->as_type
== AS_INTERNAL
) {
16895 vty_out(vty
, " remote-as internal");
16896 if_ras_printed
= true;
16897 } else if (peer
->as_type
== AS_EXTERNAL
) {
16898 vty_out(vty
, " remote-as external");
16899 if_ras_printed
= true;
16902 vty_out(vty
, "\n");
16905 /* remote-as and peer-group */
16906 /* peer is a member of a peer-group */
16907 if (peer_group_active(peer
)) {
16908 g_peer
= peer
->group
->conf
;
16910 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16911 if (peer
->as_type
== AS_SPECIFIED
) {
16912 vty_out(vty
, " neighbor %s remote-as %u\n",
16914 } else if (peer
->as_type
== AS_INTERNAL
) {
16916 " neighbor %s remote-as internal\n",
16918 } else if (peer
->as_type
== AS_EXTERNAL
) {
16920 " neighbor %s remote-as external\n",
16925 /* For swpX peers we displayed the peer-group
16926 * via 'neighbor swpX interface peer-group PGNAME' */
16927 if (!if_pg_printed
)
16928 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16929 peer
->group
->name
);
16932 /* peer is NOT a member of a peer-group */
16934 /* peer is a peer-group, declare the peer-group */
16935 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16936 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16939 if (!if_ras_printed
) {
16940 if (peer
->as_type
== AS_SPECIFIED
) {
16941 vty_out(vty
, " neighbor %s remote-as %u\n",
16943 } else if (peer
->as_type
== AS_INTERNAL
) {
16945 " neighbor %s remote-as internal\n",
16947 } else if (peer
->as_type
== AS_EXTERNAL
) {
16949 " neighbor %s remote-as external\n",
16956 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16957 vty_out(vty
, " neighbor %s local-as %u", addr
,
16958 peer
->change_local_as
);
16959 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16960 vty_out(vty
, " no-prepend");
16961 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16962 vty_out(vty
, " replace-as");
16963 vty_out(vty
, "\n");
16968 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16972 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16973 if (peer
->tx_shutdown_message
)
16974 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16975 peer
->tx_shutdown_message
);
16977 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16980 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16981 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16982 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16985 if (peer
->bfd_config
)
16986 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16989 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16990 vty_out(vty
, " neighbor %s password %s\n", addr
,
16993 /* neighbor solo */
16994 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16995 if (!peer_group_active(peer
)) {
16996 vty_out(vty
, " neighbor %s solo\n", addr
);
17001 if (peer
->port
!= BGP_PORT_DEFAULT
) {
17002 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
17005 /* Local interface name */
17006 if (peer
->ifname
) {
17007 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
17010 /* TCP max segment size */
17011 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
17012 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
17015 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
17016 vty_out(vty
, " neighbor %s passive\n", addr
);
17018 /* ebgp-multihop */
17019 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
17020 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
17021 && peer
->ttl
== MAXTTL
)) {
17022 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
17023 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
17029 if (peergroup_flag_check(peer
, PEER_FLAG_ROLE
) &&
17030 peer
->local_role
!= ROLE_UNDEFINED
)
17031 vty_out(vty
, " neighbor %s local-role %s%s\n", addr
,
17032 bgp_get_name_by_role(peer
->local_role
),
17033 CHECK_FLAG(peer
->flags
, PEER_FLAG_ROLE_STRICT_MODE
)
17037 /* ttl-security hops */
17038 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
17039 if (!peer_group_active(peer
)
17040 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
17041 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
17042 addr
, peer
->gtsm_hops
);
17046 /* disable-connected-check */
17047 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
17048 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
17050 /* link-bw-encoding-ieee */
17051 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
17052 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
17055 /* extended-optional-parameters */
17056 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
17057 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
17060 /* enforce-first-as */
17061 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
17062 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
17064 /* update-source */
17065 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
17066 if (peer
->update_source
)
17067 vty_out(vty
, " neighbor %s update-source %pSU\n", addr
,
17068 peer
->update_source
);
17069 else if (peer
->update_if
)
17070 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
17074 /* advertisement-interval */
17075 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
17076 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
17080 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
17081 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
17082 peer
->keepalive
, peer
->holdtime
);
17084 /* timers connect */
17085 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
17086 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17088 /* need special-case handling for changed default values due to
17089 * config profile / version (because there is no "timers bgp connect"
17090 * command, we need to save this per-peer :/)
17092 else if (!peer_group_active(peer
) && !peer
->connect
&&
17093 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
17094 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17095 peer
->bgp
->default_connect_retry
);
17097 /* timers delayopen */
17098 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
17099 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17101 /* Save config even though flag is not set if default values have been
17104 else if (!peer_group_active(peer
) && !peer
->delayopen
17105 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
17106 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17107 peer
->bgp
->default_delayopen
);
17109 /* capability dynamic */
17110 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
17111 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
17113 /* capability extended-nexthop */
17114 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
17115 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
) &&
17118 " no neighbor %s capability extended-nexthop\n",
17120 else if (!peer
->conf_if
)
17122 " neighbor %s capability extended-nexthop\n",
17126 /* dont-capability-negotiation */
17127 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
17128 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
17130 /* override-capability */
17131 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
17132 vty_out(vty
, " neighbor %s override-capability\n", addr
);
17134 /* strict-capability-match */
17135 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
17136 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
17138 /* Sender side AS path loop detection. */
17139 if (peer
->as_path_loop_detection
)
17140 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
17143 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17144 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
17146 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17147 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
17149 " neighbor %s graceful-restart-helper\n", addr
);
17150 } else if (CHECK_FLAG(
17151 peer
->peer_gr_new_status_flag
,
17152 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
17154 " neighbor %s graceful-restart\n", addr
);
17156 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17157 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
17159 peer
->peer_gr_new_status_flag
,
17160 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
17161 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
17167 /* BGP peer configuration display function. */
17168 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
17169 struct peer
*peer
, afi_t afi
, safi_t safi
)
17171 struct peer
*g_peer
= NULL
;
17173 bool flag_scomm
, flag_secomm
, flag_slcomm
;
17175 /* Skip dynamic neighbors. */
17176 if (peer_dynamic_neighbor(peer
))
17180 addr
= peer
->conf_if
;
17184 /************************************
17185 ****** Per AF to the neighbor ******
17186 ************************************/
17187 if (peer_group_active(peer
)) {
17188 g_peer
= peer
->group
->conf
;
17190 /* If the peer-group is active but peer is not, print a 'no
17192 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
17193 vty_out(vty
, " no neighbor %s activate\n", addr
);
17196 /* If the peer-group is not active but peer is, print an
17198 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
17199 vty_out(vty
, " neighbor %s activate\n", addr
);
17202 if (peer
->afc
[afi
][safi
]) {
17203 if (safi
== SAFI_ENCAP
)
17204 vty_out(vty
, " neighbor %s activate\n", addr
);
17205 else if (!bgp
->default_af
[afi
][safi
])
17206 vty_out(vty
, " neighbor %s activate\n", addr
);
17208 if (bgp
->default_af
[afi
][safi
])
17209 vty_out(vty
, " no neighbor %s activate\n",
17214 /* addpath TX knobs */
17215 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
17216 switch (peer
->addpath_type
[afi
][safi
]) {
17217 case BGP_ADDPATH_ALL
:
17218 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
17221 case BGP_ADDPATH_BEST_PER_AS
:
17223 " neighbor %s addpath-tx-bestpath-per-AS\n",
17226 case BGP_ADDPATH_MAX
:
17227 case BGP_ADDPATH_NONE
:
17232 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
17233 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
17235 /* ORF capability. */
17236 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17237 || peergroup_af_flag_check(peer
, afi
, safi
,
17238 PEER_FLAG_ORF_PREFIX_RM
)) {
17239 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17241 if (peergroup_af_flag_check(peer
, afi
, safi
,
17242 PEER_FLAG_ORF_PREFIX_SM
)
17243 && peergroup_af_flag_check(peer
, afi
, safi
,
17244 PEER_FLAG_ORF_PREFIX_RM
))
17245 vty_out(vty
, " both");
17246 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17247 PEER_FLAG_ORF_PREFIX_SM
))
17248 vty_out(vty
, " send");
17250 vty_out(vty
, " receive");
17251 vty_out(vty
, "\n");
17254 /* Route reflector client. */
17255 if (peergroup_af_flag_check(peer
, afi
, safi
,
17256 PEER_FLAG_REFLECTOR_CLIENT
)) {
17257 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17260 /* next-hop-self force */
17261 if (peergroup_af_flag_check(peer
, afi
, safi
,
17262 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17263 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17266 /* next-hop-self */
17267 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17268 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17271 /* remove-private-AS */
17272 if (peergroup_af_flag_check(peer
, afi
, safi
,
17273 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17274 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17278 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17279 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17280 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17284 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17285 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17286 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17289 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17290 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17291 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17295 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17296 vty_out(vty
, " neighbor %s as-override\n", addr
);
17299 /* send-community print. */
17300 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17301 PEER_FLAG_SEND_COMMUNITY
);
17302 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17303 PEER_FLAG_SEND_EXT_COMMUNITY
);
17304 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17305 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17307 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17308 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17311 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17314 " no neighbor %s send-community extended\n",
17318 vty_out(vty
, " no neighbor %s send-community large\n",
17322 /* Default information */
17323 if (peergroup_af_flag_check(peer
, afi
, safi
,
17324 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17325 vty_out(vty
, " neighbor %s default-originate", addr
);
17327 if (peer
->default_rmap
[afi
][safi
].name
)
17328 vty_out(vty
, " route-map %s",
17329 peer
->default_rmap
[afi
][safi
].name
);
17331 vty_out(vty
, "\n");
17334 /* Soft reconfiguration inbound. */
17335 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17336 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17340 /* maximum-prefix. */
17341 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17342 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17343 peer
->pmax
[afi
][safi
]);
17345 if (peer
->pmax_threshold
[afi
][safi
]
17346 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17347 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17348 if (peer_af_flag_check(peer
, afi
, safi
,
17349 PEER_FLAG_MAX_PREFIX_WARNING
))
17350 vty_out(vty
, " warning-only");
17351 if (peer
->pmax_restart
[afi
][safi
])
17352 vty_out(vty
, " restart %u",
17353 peer
->pmax_restart
[afi
][safi
]);
17354 if (peer_af_flag_check(peer
, afi
, safi
,
17355 PEER_FLAG_MAX_PREFIX_FORCE
))
17356 vty_out(vty
, " force");
17358 vty_out(vty
, "\n");
17361 /* maximum-prefix-out */
17362 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17363 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17364 addr
, peer
->pmax_out
[afi
][safi
]);
17366 /* Route server client. */
17367 if (peergroup_af_flag_check(peer
, afi
, safi
,
17368 PEER_FLAG_RSERVER_CLIENT
)) {
17369 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17372 /* Nexthop-local unchanged. */
17373 if (peergroup_af_flag_check(peer
, afi
, safi
,
17374 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17375 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17378 /* allowas-in <1-10> */
17379 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17380 if (peer_af_flag_check(peer
, afi
, safi
,
17381 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17382 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17383 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17384 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17386 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17387 peer
->allowas_in
[afi
][safi
]);
17392 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
))
17393 vty_out(vty
, " neighbor %s accept-own\n", addr
);
17396 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOO
)) {
17397 char *soo_str
= ecommunity_ecom2str(
17398 peer
->soo
[afi
][safi
], ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
17400 vty_out(vty
, " neighbor %s soo %s\n", addr
, soo_str
);
17401 XFREE(MTYPE_ECOMMUNITY_STR
, soo_str
);
17405 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17406 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17407 peer
->weight
[afi
][safi
]);
17410 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17412 /* atribute-unchanged. */
17413 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17414 || (safi
!= SAFI_EVPN
17415 && peer_af_flag_check(peer
, afi
, safi
,
17416 PEER_FLAG_NEXTHOP_UNCHANGED
))
17417 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17419 if (!peer_group_active(peer
)
17420 || peergroup_af_flag_check(peer
, afi
, safi
,
17421 PEER_FLAG_AS_PATH_UNCHANGED
)
17422 || peergroup_af_flag_check(peer
, afi
, safi
,
17423 PEER_FLAG_NEXTHOP_UNCHANGED
)
17424 || peergroup_af_flag_check(peer
, afi
, safi
,
17425 PEER_FLAG_MED_UNCHANGED
)) {
17428 " neighbor %s attribute-unchanged%s%s%s\n",
17430 peer_af_flag_check(peer
, afi
, safi
,
17431 PEER_FLAG_AS_PATH_UNCHANGED
)
17434 peer_af_flag_check(peer
, afi
, safi
,
17435 PEER_FLAG_NEXTHOP_UNCHANGED
)
17438 peer_af_flag_check(peer
, afi
, safi
,
17439 PEER_FLAG_MED_UNCHANGED
)
17445 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORR_GROUP
))
17446 vty_out(vty
, " neighbor %s optimal-route-reflection %s\n",
17447 addr
, peer
->orr_group_name
[afi
][safi
]);
17450 static void bgp_vpn_config_write(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17453 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17454 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
))
17455 vty_out(vty
, " no bgp retain route-target all\n");
17458 /* Address family based peer configuration display. */
17459 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17463 struct peer_group
*group
;
17464 struct listnode
*node
, *nnode
;
17467 vty_frame(vty
, " !\n address-family ");
17468 if (afi
== AFI_IP
) {
17469 if (safi
== SAFI_UNICAST
)
17470 vty_frame(vty
, "ipv4 unicast");
17471 else if (safi
== SAFI_LABELED_UNICAST
)
17472 vty_frame(vty
, "ipv4 labeled-unicast");
17473 else if (safi
== SAFI_MULTICAST
)
17474 vty_frame(vty
, "ipv4 multicast");
17475 else if (safi
== SAFI_MPLS_VPN
)
17476 vty_frame(vty
, "ipv4 vpn");
17477 else if (safi
== SAFI_ENCAP
)
17478 vty_frame(vty
, "ipv4 encap");
17479 else if (safi
== SAFI_FLOWSPEC
)
17480 vty_frame(vty
, "ipv4 flowspec");
17481 } else if (afi
== AFI_IP6
) {
17482 if (safi
== SAFI_UNICAST
)
17483 vty_frame(vty
, "ipv6 unicast");
17484 else if (safi
== SAFI_LABELED_UNICAST
)
17485 vty_frame(vty
, "ipv6 labeled-unicast");
17486 else if (safi
== SAFI_MULTICAST
)
17487 vty_frame(vty
, "ipv6 multicast");
17488 else if (safi
== SAFI_MPLS_VPN
)
17489 vty_frame(vty
, "ipv6 vpn");
17490 else if (safi
== SAFI_ENCAP
)
17491 vty_frame(vty
, "ipv6 encap");
17492 else if (safi
== SAFI_FLOWSPEC
)
17493 vty_frame(vty
, "ipv6 flowspec");
17494 } else if (afi
== AFI_L2VPN
) {
17495 if (safi
== SAFI_EVPN
)
17496 vty_frame(vty
, "l2vpn evpn");
17498 vty_frame(vty
, "\n");
17500 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17502 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17504 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17506 /* BGP flag dampening. */
17507 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17508 bgp_config_write_damp(vty
, afi
, safi
);
17510 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17511 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17513 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17514 /* Do not display doppelganger peers */
17515 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17516 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17519 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17520 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17522 if (safi
== SAFI_EVPN
)
17523 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17525 if (safi
== SAFI_FLOWSPEC
)
17526 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17528 if (safi
== SAFI_MPLS_VPN
)
17529 bgp_vpn_config_write(vty
, bgp
, afi
, safi
);
17531 if (safi
== SAFI_UNICAST
) {
17532 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17533 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17534 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17536 vty_out(vty
, " export vpn\n");
17538 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17539 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17541 vty_out(vty
, " import vpn\n");
17543 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17544 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17547 for (ALL_LIST_ELEMENTS_RO(
17548 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17550 vty_out(vty
, " import vrf %s\n", name
);
17554 /* Optimal Route Reflection */
17555 bgp_config_write_orr(vty
, bgp
, afi
, safi
);
17557 vty_endframe(vty
, " exit-address-family\n");
17560 int bgp_config_write(struct vty
*vty
)
17563 struct peer_group
*group
;
17565 struct listnode
*node
, *nnode
;
17566 struct listnode
*mnode
, *mnnode
;
17570 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17571 vty_out(vty
, "bgp route-map delay-timer %u\n",
17572 bm
->rmap_update_timer
);
17574 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17575 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17576 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17577 vty_out(vty
, " %d", bm
->v_establish_wait
);
17578 vty_out(vty
, "\n");
17581 if (bm
->wait_for_fib
)
17582 vty_out(vty
, "bgp suppress-fib-pending\n");
17584 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17585 vty_out(vty
, "bgp graceful-shutdown\n");
17587 /* No-RIB (Zebra) option flag configuration */
17588 if (bgp_option_check(BGP_OPT_NO_FIB
))
17589 vty_out(vty
, "bgp no-rib\n");
17591 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17592 vty_out(vty
, "bgp send-extra-data zebra\n");
17594 /* BGP session DSCP value */
17595 if (bm
->tcp_dscp
!= IPTOS_PREC_INTERNETCONTROL
)
17596 vty_out(vty
, "bgp session-dscp %u\n", bm
->tcp_dscp
>> 2);
17598 /* BGP configuration. */
17599 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17601 /* skip all auto created vrf as they dont have user config */
17602 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17605 /* Router bgp ASN */
17606 vty_out(vty
, "router bgp %u", bgp
->as
);
17609 vty_out(vty
, " %s %s",
17610 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17611 ? "view" : "vrf", bgp
->name
);
17612 vty_out(vty
, "\n");
17614 /* BGP fast-external-failover. */
17615 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17616 vty_out(vty
, " no bgp fast-external-failover\n");
17618 /* BGP router ID. */
17619 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17620 vty_out(vty
, " bgp router-id %pI4\n",
17621 &bgp
->router_id_static
);
17623 /* Suppress fib pending */
17624 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17625 vty_out(vty
, " bgp suppress-fib-pending\n");
17627 /* BGP log-neighbor-changes. */
17628 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17629 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17630 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17631 CHECK_FLAG(bgp
->flags
,
17632 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17636 /* BGP configuration. */
17637 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17638 vty_out(vty
, " bgp always-compare-med\n");
17640 /* RFC8212 default eBGP policy. */
17641 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17642 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17643 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17644 CHECK_FLAG(bgp
->flags
,
17645 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17649 /* draft-ietf-idr-deprecate-as-set-confed-set */
17650 if (bgp
->reject_as_sets
)
17651 vty_out(vty
, " bgp reject-as-sets\n");
17653 /* Suppress duplicate updates if the route actually not changed
17655 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17656 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17657 vty_out(vty
, " %sbgp suppress-duplicates\n",
17658 CHECK_FLAG(bgp
->flags
,
17659 BGP_FLAG_SUPPRESS_DUPLICATES
)
17663 /* Send Hard Reset CEASE Notification for 'Administrative Reset'
17665 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
) !=
17666 SAVE_BGP_HARD_ADMIN_RESET
)
17667 vty_out(vty
, " %sbgp hard-administrative-reset\n",
17668 CHECK_FLAG(bgp
->flags
,
17669 BGP_FLAG_HARD_ADMIN_RESET
)
17673 /* BGP default <afi>-<safi> */
17674 FOREACH_AFI_SAFI (afi
, safi
) {
17675 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
17676 if (!bgp
->default_af
[afi
][safi
])
17677 vty_out(vty
, " no bgp default %s\n",
17678 get_bgp_default_af_flag(afi
,
17680 } else if (bgp
->default_af
[afi
][safi
])
17681 vty_out(vty
, " bgp default %s\n",
17682 get_bgp_default_af_flag(afi
, safi
));
17685 /* BGP default local-preference. */
17686 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17687 vty_out(vty
, " bgp default local-preference %u\n",
17688 bgp
->default_local_pref
);
17690 /* BGP default show-hostname */
17691 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17692 != SAVE_BGP_SHOW_HOSTNAME
)
17693 vty_out(vty
, " %sbgp default show-hostname\n",
17694 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17698 /* BGP default show-nexthop-hostname */
17699 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17700 != SAVE_BGP_SHOW_HOSTNAME
)
17701 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17702 CHECK_FLAG(bgp
->flags
,
17703 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17707 /* BGP default subgroup-pkt-queue-max. */
17708 if (bgp
->default_subgroup_pkt_queue_max
17709 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17710 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17711 bgp
->default_subgroup_pkt_queue_max
);
17713 /* BGP client-to-client reflection. */
17714 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17715 vty_out(vty
, " no bgp client-to-client reflection\n");
17717 /* BGP cluster ID. */
17718 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17719 vty_out(vty
, " bgp cluster-id %pI4\n",
17722 /* Disable ebgp connected nexthop check */
17723 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17725 " bgp disable-ebgp-connected-route-check\n");
17727 /* Confederation identifier*/
17728 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17729 vty_out(vty
, " bgp confederation identifier %u\n",
17732 /* Confederation peer */
17733 if (bgp
->confed_peers_cnt
> 0) {
17736 vty_out(vty
, " bgp confederation peers");
17738 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17739 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17741 vty_out(vty
, "\n");
17744 /* BGP deterministic-med. */
17745 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17746 != SAVE_BGP_DETERMINISTIC_MED
)
17747 vty_out(vty
, " %sbgp deterministic-med\n",
17748 CHECK_FLAG(bgp
->flags
,
17749 BGP_FLAG_DETERMINISTIC_MED
)
17753 /* BGP update-delay. */
17754 bgp_config_write_update_delay(vty
, bgp
);
17756 if (bgp
->v_maxmed_onstartup
17757 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17758 vty_out(vty
, " bgp max-med on-startup %u",
17759 bgp
->v_maxmed_onstartup
);
17760 if (bgp
->maxmed_onstartup_value
17761 != BGP_MAXMED_VALUE_DEFAULT
)
17762 vty_out(vty
, " %u",
17763 bgp
->maxmed_onstartup_value
);
17764 vty_out(vty
, "\n");
17766 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17767 vty_out(vty
, " bgp max-med administrative");
17768 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17769 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17770 vty_out(vty
, "\n");
17774 bgp_config_write_wpkt_quanta(vty
, bgp
);
17776 bgp_config_write_rpkt_quanta(vty
, bgp
);
17778 /* coalesce time */
17779 bgp_config_write_coalesce_time(vty
, bgp
);
17781 /* BGP per-instance graceful-shutdown */
17782 /* BGP-wide settings and per-instance settings are mutually
17785 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17786 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17787 vty_out(vty
, " bgp graceful-shutdown\n");
17789 /* Long-lived Graceful Restart */
17790 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
17792 " bgp long-lived-graceful-restart stale-time %u\n",
17793 bgp
->llgr_stale_time
);
17795 /* BGP graceful-restart. */
17796 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17798 " bgp graceful-restart stalepath-time %u\n",
17799 bgp
->stalepath_time
);
17801 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17802 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17803 bgp
->restart_time
);
17805 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
) !=
17806 SAVE_BGP_GRACEFUL_NOTIFICATION
)
17807 vty_out(vty
, " %sbgp graceful-restart notification\n",
17808 CHECK_FLAG(bgp
->flags
,
17809 BGP_FLAG_GRACEFUL_NOTIFICATION
)
17813 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17815 " bgp graceful-restart select-defer-time %u\n",
17816 bgp
->select_defer_time
);
17818 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17819 vty_out(vty
, " bgp graceful-restart\n");
17821 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17822 vty_out(vty
, " bgp graceful-restart-disable\n");
17824 /* BGP graceful-restart Preserve State F bit. */
17825 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17827 " bgp graceful-restart preserve-fw-state\n");
17829 /* BGP TCP keepalive */
17830 bgp_config_tcp_keepalive(vty
, bgp
);
17832 /* Stale timer for RIB */
17833 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17835 " bgp graceful-restart rib-stale-time %u\n",
17836 bgp
->rib_stale_time
);
17838 /* BGP bestpath method. */
17839 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17840 vty_out(vty
, " bgp bestpath as-path ignore\n");
17841 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17842 vty_out(vty
, " bgp bestpath as-path confed\n");
17844 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17845 if (CHECK_FLAG(bgp
->flags
,
17846 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17848 " bgp bestpath as-path multipath-relax as-set\n");
17851 " bgp bestpath as-path multipath-relax\n");
17855 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17857 " bgp route-reflector allow-outbound-policy\n");
17859 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17860 vty_out(vty
, " bgp bestpath compare-routerid\n");
17861 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17862 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17863 vty_out(vty
, " bgp bestpath med");
17864 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17865 vty_out(vty
, " confed");
17866 if (CHECK_FLAG(bgp
->flags
,
17867 BGP_FLAG_MED_MISSING_AS_WORST
))
17868 vty_out(vty
, " missing-as-worst");
17869 vty_out(vty
, "\n");
17872 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
17874 " bgp bestpath peer-type multipath-relax\n");
17876 /* Link bandwidth handling. */
17877 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17878 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17879 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17880 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17881 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17882 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17884 /* BGP network import check. */
17885 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17886 != SAVE_BGP_IMPORT_CHECK
)
17887 vty_out(vty
, " %sbgp network import-check\n",
17888 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17892 /* BGP timers configuration. */
17893 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17894 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17895 vty_out(vty
, " timers bgp %u %u\n",
17896 bgp
->default_keepalive
, bgp
->default_holdtime
);
17898 /* BGP minimum holdtime configuration. */
17899 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
17900 && bgp
->default_min_holdtime
!= 0)
17901 vty_out(vty
, " bgp minimum-holdtime %u\n",
17902 bgp
->default_min_holdtime
);
17904 /* Conditional advertisement timer configuration */
17905 if (bgp
->condition_check_period
17906 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
17908 " bgp conditional-advertisement timer %u\n",
17909 bgp
->condition_check_period
);
17912 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17913 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17916 /* Normal neighbor configuration. */
17917 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17918 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17919 bgp_config_write_peer_global(vty
, bgp
, peer
);
17922 /* listen range and limit for dynamic BGP neighbors */
17923 bgp_config_write_listen(vty
, bgp
);
17926 * BGP default autoshutdown neighbors
17928 * This must be placed after any peer and peer-group
17929 * configuration, to avoid setting all peers to shutdown after
17930 * a daemon restart, which is undesired behavior. (see #2286)
17932 if (bgp
->autoshutdown
)
17933 vty_out(vty
, " bgp default shutdown\n");
17935 /* BGP instance administrative shutdown */
17936 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17937 vty_out(vty
, " bgp shutdown\n");
17939 if (bgp
->allow_martian
)
17940 vty_out(vty
, " bgp allow-martian-nexthop\n");
17942 if (bgp
->fast_convergence
)
17943 vty_out(vty
, " bgp fast-convergence\n");
17945 if (bgp
->srv6_enabled
) {
17946 vty_frame(vty
, " !\n segment-routing srv6\n");
17947 if (strlen(bgp
->srv6_locator_name
))
17948 vty_out(vty
, " locator %s\n",
17949 bgp
->srv6_locator_name
);
17950 vty_endframe(vty
, " exit\n");
17954 /* IPv4 unicast configuration. */
17955 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17957 /* IPv4 multicast configuration. */
17958 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17960 /* IPv4 labeled-unicast configuration. */
17961 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17963 /* IPv4 VPN configuration. */
17964 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17966 /* ENCAPv4 configuration. */
17967 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17969 /* FLOWSPEC v4 configuration. */
17970 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17972 /* IPv6 unicast configuration. */
17973 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17975 /* IPv6 multicast configuration. */
17976 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17978 /* IPv6 labeled-unicast configuration. */
17979 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17980 SAFI_LABELED_UNICAST
);
17982 /* IPv6 VPN configuration. */
17983 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17985 /* ENCAPv6 configuration. */
17986 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17988 /* FLOWSPEC v6 configuration. */
17989 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17991 /* EVPN configuration. */
17992 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17994 hook_call(bgp_inst_config_write
, bgp
, vty
);
17996 #ifdef ENABLE_BGP_VNC
17997 bgp_rfapi_cfg_write(vty
, bgp
);
18000 vty_out(vty
, "exit\n");
18001 vty_out(vty
, "!\n");
18007 /* BGP node structure. */
18008 static struct cmd_node bgp_node
= {
18011 .parent_node
= CONFIG_NODE
,
18012 .prompt
= "%s(config-router)# ",
18013 .config_write
= bgp_config_write
,
18016 static struct cmd_node bgp_ipv4_unicast_node
= {
18017 .name
= "bgp ipv4 unicast",
18018 .node
= BGP_IPV4_NODE
,
18019 .parent_node
= BGP_NODE
,
18020 .prompt
= "%s(config-router-af)# ",
18024 static struct cmd_node bgp_ipv4_multicast_node
= {
18025 .name
= "bgp ipv4 multicast",
18026 .node
= BGP_IPV4M_NODE
,
18027 .parent_node
= BGP_NODE
,
18028 .prompt
= "%s(config-router-af)# ",
18032 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
18033 .name
= "bgp ipv4 labeled unicast",
18034 .node
= BGP_IPV4L_NODE
,
18035 .parent_node
= BGP_NODE
,
18036 .prompt
= "%s(config-router-af)# ",
18040 static struct cmd_node bgp_ipv6_unicast_node
= {
18041 .name
= "bgp ipv6 unicast",
18042 .node
= BGP_IPV6_NODE
,
18043 .parent_node
= BGP_NODE
,
18044 .prompt
= "%s(config-router-af)# ",
18048 static struct cmd_node bgp_ipv6_multicast_node
= {
18049 .name
= "bgp ipv6 multicast",
18050 .node
= BGP_IPV6M_NODE
,
18051 .parent_node
= BGP_NODE
,
18052 .prompt
= "%s(config-router-af)# ",
18056 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
18057 .name
= "bgp ipv6 labeled unicast",
18058 .node
= BGP_IPV6L_NODE
,
18059 .parent_node
= BGP_NODE
,
18060 .prompt
= "%s(config-router-af)# ",
18064 static struct cmd_node bgp_vpnv4_node
= {
18065 .name
= "bgp vpnv4",
18066 .node
= BGP_VPNV4_NODE
,
18067 .parent_node
= BGP_NODE
,
18068 .prompt
= "%s(config-router-af)# ",
18072 static struct cmd_node bgp_vpnv6_node
= {
18073 .name
= "bgp vpnv6",
18074 .node
= BGP_VPNV6_NODE
,
18075 .parent_node
= BGP_NODE
,
18076 .prompt
= "%s(config-router-af-vpnv6)# ",
18080 static struct cmd_node bgp_evpn_node
= {
18081 .name
= "bgp evpn",
18082 .node
= BGP_EVPN_NODE
,
18083 .parent_node
= BGP_NODE
,
18084 .prompt
= "%s(config-router-evpn)# ",
18088 static struct cmd_node bgp_evpn_vni_node
= {
18089 .name
= "bgp evpn vni",
18090 .node
= BGP_EVPN_VNI_NODE
,
18091 .parent_node
= BGP_EVPN_NODE
,
18092 .prompt
= "%s(config-router-af-vni)# ",
18095 static struct cmd_node bgp_flowspecv4_node
= {
18096 .name
= "bgp ipv4 flowspec",
18097 .node
= BGP_FLOWSPECV4_NODE
,
18098 .parent_node
= BGP_NODE
,
18099 .prompt
= "%s(config-router-af)# ",
18103 static struct cmd_node bgp_flowspecv6_node
= {
18104 .name
= "bgp ipv6 flowspec",
18105 .node
= BGP_FLOWSPECV6_NODE
,
18106 .parent_node
= BGP_NODE
,
18107 .prompt
= "%s(config-router-af-vpnv6)# ",
18111 static struct cmd_node bgp_srv6_node
= {
18112 .name
= "bgp srv6",
18113 .node
= BGP_SRV6_NODE
,
18114 .parent_node
= BGP_NODE
,
18115 .prompt
= "%s(config-router-srv6)# ",
18118 static void community_list_vty(void);
18120 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
18123 struct peer_group
*group
;
18124 struct listnode
*lnbgp
, *lnpeer
;
18126 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18127 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
18129 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
18133 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
18137 struct listnode
*lnbgp
, *lnpeer
;
18139 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18140 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
18141 /* only provide suggestions on the appropriate input
18143 * they'll otherwise show up multiple times */
18144 enum cmd_token_type match_type
;
18145 char *name
= peer
->host
;
18147 if (peer
->conf_if
) {
18148 match_type
= VARIABLE_TKN
;
18149 name
= peer
->conf_if
;
18150 } else if (strchr(peer
->host
, ':'))
18151 match_type
= IPV6_TKN
;
18153 match_type
= IPV4_TKN
;
18155 if (token
->type
!= match_type
)
18158 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
18163 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
18165 bgp_ac_peer(comps
, token
);
18167 if (token
->type
== VARIABLE_TKN
)
18168 bgp_ac_peergroup(comps
, token
);
18171 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
18172 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
18173 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
18174 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
18175 {.completions
= NULL
}};
18177 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
18178 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
18179 {.completions
= NULL
} };
18181 DEFINE_HOOK(bgp_config_end
, (struct bgp
*bgp
), (bgp
));
18183 static struct thread
*t_bgp_cfg
;
18185 bool bgp_config_inprocess(void)
18187 return thread_is_scheduled(t_bgp_cfg
);
18190 static void bgp_config_finish(struct thread
*t
)
18192 struct listnode
*node
;
18195 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
))
18196 hook_call(bgp_config_end
, bgp
);
18199 static void bgp_config_start(void)
18201 #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
18202 THREAD_OFF(t_bgp_cfg
);
18203 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18204 BGP_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_bgp_cfg
);
18207 /* When we receive a hook the configuration is read,
18208 * we start a timer to make sure we postpone sending
18209 * EoR before route-maps are processed.
18210 * This is especially valid if using `bgp route-map delay-timer`.
18212 static void bgp_config_end(void)
18214 #define BGP_POST_CONFIG_DELAY_SECONDS 1
18215 uint32_t bgp_post_config_delay
=
18216 thread_is_scheduled(bm
->t_rmap_update
)
18217 ? thread_timer_remain_second(bm
->t_rmap_update
)
18218 : BGP_POST_CONFIG_DELAY_SECONDS
;
18220 /* If BGP config processing thread isn't running, then
18221 * we can return and rely it's properly handled.
18223 if (!bgp_config_inprocess())
18226 THREAD_OFF(t_bgp_cfg
);
18228 /* Start a new timer to make sure we don't send EoR
18229 * before route-maps are processed.
18231 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18232 bgp_post_config_delay
, &t_bgp_cfg
);
18235 static int config_write_interface_one(struct vty
*vty
, struct vrf
*vrf
)
18238 struct interface
*ifp
;
18239 struct bgp_interface
*iifp
;
18241 FOR_ALL_INTERFACES (vrf
, ifp
) {
18246 if_vty_config_start(vty
, ifp
);
18248 if (CHECK_FLAG(iifp
->flags
,
18249 BGP_INTERFACE_MPLS_BGP_FORWARDING
)) {
18250 vty_out(vty
, " mpls bgp forwarding\n");
18254 if_vty_config_end(vty
);
18260 /* Configuration write function for bgpd. */
18261 static int config_write_interface(struct vty
*vty
)
18264 struct vrf
*vrf
= NULL
;
18266 /* Display all VRF aware OSPF interface configuration */
18267 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
18268 write
+= config_write_interface_one(vty
, vrf
);
18274 DEFPY(mpls_bgp_forwarding
, mpls_bgp_forwarding_cmd
,
18275 "[no$no] mpls bgp forwarding",
18276 NO_STR MPLS_STR BGP_STR
18277 "Enable MPLS forwarding for eBGP directly connected peers\n")
18280 struct bgp_interface
*iifp
;
18282 VTY_DECLVAR_CONTEXT(interface
, ifp
);
18285 vty_out(vty
, "Interface %s not available\n", ifp
->name
);
18286 return CMD_WARNING_CONFIG_FAILED
;
18288 check
= CHECK_FLAG(iifp
->flags
, BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18289 if (check
!= !no
) {
18291 UNSET_FLAG(iifp
->flags
,
18292 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18294 SET_FLAG(iifp
->flags
,
18295 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18296 /* trigger a nht update on eBGP sessions */
18297 if (if_is_operative(ifp
))
18298 bgp_nht_ifp_up(ifp
);
18300 return CMD_SUCCESS
;
18303 /* Initialization of BGP interface. */
18304 static void bgp_vty_if_init(void)
18306 /* Install interface node. */
18307 if_cmd_init(config_write_interface
);
18309 /* "mpls bgp forwarding" commands. */
18310 install_element(INTERFACE_NODE
, &mpls_bgp_forwarding_cmd
);
18313 void bgp_vty_init(void)
18315 cmd_variable_handler_register(bgp_var_neighbor
);
18316 cmd_variable_handler_register(bgp_var_peergroup
);
18318 cmd_init_config_callbacks(bgp_config_start
, bgp_config_end
);
18320 /* Install bgp top node. */
18321 install_node(&bgp_node
);
18322 install_node(&bgp_ipv4_unicast_node
);
18323 install_node(&bgp_ipv4_multicast_node
);
18324 install_node(&bgp_ipv4_labeled_unicast_node
);
18325 install_node(&bgp_ipv6_unicast_node
);
18326 install_node(&bgp_ipv6_multicast_node
);
18327 install_node(&bgp_ipv6_labeled_unicast_node
);
18328 install_node(&bgp_vpnv4_node
);
18329 install_node(&bgp_vpnv6_node
);
18330 install_node(&bgp_evpn_node
);
18331 install_node(&bgp_evpn_vni_node
);
18332 install_node(&bgp_flowspecv4_node
);
18333 install_node(&bgp_flowspecv6_node
);
18334 install_node(&bgp_srv6_node
);
18336 /* Install default VTY commands to new nodes. */
18337 install_default(BGP_NODE
);
18338 install_default(BGP_IPV4_NODE
);
18339 install_default(BGP_IPV4M_NODE
);
18340 install_default(BGP_IPV4L_NODE
);
18341 install_default(BGP_IPV6_NODE
);
18342 install_default(BGP_IPV6M_NODE
);
18343 install_default(BGP_IPV6L_NODE
);
18344 install_default(BGP_VPNV4_NODE
);
18345 install_default(BGP_VPNV6_NODE
);
18346 install_default(BGP_FLOWSPECV4_NODE
);
18347 install_default(BGP_FLOWSPECV6_NODE
);
18348 install_default(BGP_EVPN_NODE
);
18349 install_default(BGP_EVPN_VNI_NODE
);
18350 install_default(BGP_SRV6_NODE
);
18352 /* "bgp local-mac" hidden commands. */
18353 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
18354 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
18356 /* "bgp suppress-fib-pending" global */
18357 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
18359 /* bgp route-map delay-timer commands. */
18360 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18361 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18363 install_element(BGP_NODE
, &bgp_allow_martian_cmd
);
18365 /* bgp fast-convergence command */
18366 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
18367 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
18369 /* global bgp update-delay command */
18370 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
18371 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
18373 /* global bgp graceful-shutdown command */
18374 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
18375 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
18377 /* Dummy commands (Currently not supported) */
18378 install_element(BGP_NODE
, &no_synchronization_cmd
);
18379 install_element(BGP_NODE
, &no_auto_summary_cmd
);
18381 /* "router bgp" commands. */
18382 install_element(CONFIG_NODE
, &router_bgp_cmd
);
18384 /* "no router bgp" commands. */
18385 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
18387 /* "bgp session-dscp command */
18388 install_element(CONFIG_NODE
, &bgp_session_dscp_cmd
);
18389 install_element(CONFIG_NODE
, &no_bgp_session_dscp_cmd
);
18391 /* "bgp router-id" commands. */
18392 install_element(BGP_NODE
, &bgp_router_id_cmd
);
18393 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
18395 /* "bgp suppress-fib-pending" command */
18396 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
18398 /* "bgp cluster-id" commands. */
18399 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
18400 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
18402 /* "bgp no-rib" commands. */
18403 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
18404 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
18406 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
18408 /* "bgp confederation" commands. */
18409 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
18410 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
18412 /* "bgp confederation peers" commands. */
18413 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
18414 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
18416 /* bgp max-med command */
18417 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
18418 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
18419 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
18420 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
18421 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
18423 /* "neighbor role" commands. */
18424 install_element(BGP_NODE
, &neighbor_role_cmd
);
18425 install_element(BGP_NODE
, &neighbor_role_strict_cmd
);
18426 install_element(BGP_NODE
, &no_neighbor_role_cmd
);
18428 /* bgp disable-ebgp-connected-nh-check */
18429 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
18430 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
18432 /* bgp update-delay command */
18433 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
18434 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
18436 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
18437 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
18439 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
18440 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
18442 /* "maximum-paths" commands. */
18443 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
18444 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
18445 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
18446 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
18447 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
18448 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
18449 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
18450 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
18451 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
18452 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
18453 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18454 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18455 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
18456 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18457 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18459 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
18460 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
18461 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18462 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18463 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18464 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
18465 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
18466 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18467 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18468 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18470 /* "timers bgp" commands. */
18471 install_element(BGP_NODE
, &bgp_timers_cmd
);
18472 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
18474 /* "minimum-holdtime" commands. */
18475 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
18476 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
18478 /* route-map delay-timer commands - per instance for backwards compat.
18480 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18481 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18483 /* "bgp client-to-client reflection" commands */
18484 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
18485 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
18487 /* "bgp always-compare-med" commands */
18488 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
18489 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
18491 /* bgp ebgp-requires-policy */
18492 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
18493 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
18495 /* bgp suppress-duplicates */
18496 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
18497 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
18499 /* bgp reject-as-sets */
18500 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
18501 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
18503 /* "bgp deterministic-med" commands */
18504 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
18505 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
18507 /* "bgp graceful-restart" command */
18508 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
18509 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
18511 /* "bgp graceful-restart-disable" command */
18512 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
18513 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
18515 /* "neighbor a:b:c:d graceful-restart" command */
18516 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
18517 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
18519 /* "neighbor a:b:c:d graceful-restart-disable" command */
18520 install_element(BGP_NODE
,
18521 &bgp_neighbor_graceful_restart_disable_set_cmd
);
18522 install_element(BGP_NODE
,
18523 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
18525 /* "neighbor a:b:c:d graceful-restart-helper" command */
18526 install_element(BGP_NODE
,
18527 &bgp_neighbor_graceful_restart_helper_set_cmd
);
18528 install_element(BGP_NODE
,
18529 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
18531 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
18532 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
18533 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
18534 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
18535 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
18536 install_element(BGP_NODE
,
18537 &no_bgp_graceful_restart_select_defer_time_cmd
);
18538 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
18539 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
18540 install_element(BGP_NODE
, &bgp_graceful_restart_notification_cmd
);
18542 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
18543 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
18544 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
18545 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
18547 /* "bgp graceful-shutdown" commands */
18548 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
18549 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
18551 /* "bgp hard-administrative-reset" commands */
18552 install_element(BGP_NODE
, &bgp_administrative_reset_cmd
);
18554 /* "bgp long-lived-graceful-restart" commands */
18555 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
18556 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
18558 /* "bgp fast-external-failover" commands */
18559 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
18560 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
18562 /* "bgp bestpath compare-routerid" commands */
18563 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
18564 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
18566 /* "bgp bestpath as-path ignore" commands */
18567 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
18568 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
18570 /* "bgp bestpath as-path confed" commands */
18571 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
18572 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
18574 /* "bgp bestpath as-path multipath-relax" commands */
18575 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
18576 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
18578 /* "bgp bestpath peer-type multipath-relax" commands */
18579 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
18580 install_element(BGP_NODE
,
18581 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
18583 /* "bgp log-neighbor-changes" commands */
18584 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
18585 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
18587 /* "bgp bestpath med" commands */
18588 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
18589 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
18591 /* "bgp bestpath bandwidth" commands */
18592 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
18593 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
18595 /* "no bgp default <afi>-<safi>" commands. */
18596 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
18598 /* "bgp network import-check" commands. */
18599 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
18600 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
18601 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
18603 /* "bgp default local-preference" commands. */
18604 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
18605 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
18607 /* bgp default show-hostname */
18608 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
18609 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
18611 /* bgp default show-nexthop-hostname */
18612 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
18613 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
18615 /* "bgp default subgroup-pkt-queue-max" commands. */
18616 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
18617 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
18619 /* bgp ibgp-allow-policy-mods command */
18620 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
18621 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
18623 /* "bgp listen limit" commands. */
18624 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
18625 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
18627 /* "bgp listen range" commands. */
18628 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
18629 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
18631 /* "bgp default shutdown" command */
18632 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
18634 /* "bgp shutdown" commands */
18635 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
18636 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
18637 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
18638 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
18640 /* "neighbor remote-as" commands. */
18641 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
18642 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
18643 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
18644 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
18645 install_element(BGP_NODE
,
18646 &neighbor_interface_v6only_config_remote_as_cmd
);
18647 install_element(BGP_NODE
, &no_neighbor_cmd
);
18648 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
18650 /* "neighbor peer-group" commands. */
18651 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
18652 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
18653 install_element(BGP_NODE
,
18654 &no_neighbor_interface_peer_group_remote_as_cmd
);
18656 /* "neighbor local-as" commands. */
18657 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
18658 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
18659 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
18660 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
18662 /* "neighbor solo" commands. */
18663 install_element(BGP_NODE
, &neighbor_solo_cmd
);
18664 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
18666 /* "neighbor password" commands. */
18667 install_element(BGP_NODE
, &neighbor_password_cmd
);
18668 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
18670 /* "neighbor activate" commands. */
18671 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
18672 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
18673 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
18674 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
18675 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
18676 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
18677 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
18678 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
18679 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
18680 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
18681 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
18682 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
18684 /* "no neighbor activate" commands. */
18685 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
18686 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
18687 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
18688 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
18689 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
18690 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
18691 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
18692 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
18693 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
18694 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
18695 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
18696 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
18698 /* "neighbor peer-group" set commands. */
18699 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
18700 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18701 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18702 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18703 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18704 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18705 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18706 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18707 install_element(BGP_FLOWSPECV4_NODE
,
18708 &neighbor_set_peer_group_hidden_cmd
);
18709 install_element(BGP_FLOWSPECV6_NODE
,
18710 &neighbor_set_peer_group_hidden_cmd
);
18712 /* "no neighbor peer-group unset" commands. */
18713 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
18714 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18715 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18716 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18717 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18718 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18719 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18720 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18721 install_element(BGP_FLOWSPECV4_NODE
,
18722 &no_neighbor_set_peer_group_hidden_cmd
);
18723 install_element(BGP_FLOWSPECV6_NODE
,
18724 &no_neighbor_set_peer_group_hidden_cmd
);
18726 /* "neighbor softreconfiguration inbound" commands.*/
18727 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
18728 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
18729 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18730 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18731 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18732 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18733 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18734 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18735 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18736 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18737 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18738 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18739 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18740 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18741 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18742 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18743 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18744 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18745 install_element(BGP_FLOWSPECV4_NODE
,
18746 &neighbor_soft_reconfiguration_cmd
);
18747 install_element(BGP_FLOWSPECV4_NODE
,
18748 &no_neighbor_soft_reconfiguration_cmd
);
18749 install_element(BGP_FLOWSPECV6_NODE
,
18750 &neighbor_soft_reconfiguration_cmd
);
18751 install_element(BGP_FLOWSPECV6_NODE
,
18752 &no_neighbor_soft_reconfiguration_cmd
);
18753 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
18754 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18756 /* "neighbor attribute-unchanged" commands. */
18757 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
18758 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
18759 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
18760 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18761 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
18762 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18763 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
18764 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18765 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
18766 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18767 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
18768 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18769 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
18770 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18771 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
18772 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18773 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
18774 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18776 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
18777 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
18779 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
18780 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18781 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
18782 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18784 /* "nexthop-local unchanged" commands */
18785 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
18786 install_element(BGP_IPV6_NODE
,
18787 &no_neighbor_nexthop_local_unchanged_cmd
);
18789 /* "neighbor next-hop-self" commands. */
18790 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
18791 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
18792 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
18793 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18794 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
18795 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
18796 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
18797 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
18798 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
18799 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18800 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
18801 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
18802 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
18803 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
18804 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
18805 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18806 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
18807 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18808 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
18809 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
18811 /* "neighbor next-hop-self force" commands. */
18812 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
18813 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
18814 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18815 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
18816 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18817 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18818 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18819 install_element(BGP_IPV4_NODE
,
18820 &no_neighbor_nexthop_self_all_hidden_cmd
);
18821 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
18822 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18823 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18824 install_element(BGP_IPV4M_NODE
,
18825 &no_neighbor_nexthop_self_all_hidden_cmd
);
18826 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
18827 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18828 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18829 install_element(BGP_IPV4L_NODE
,
18830 &no_neighbor_nexthop_self_all_hidden_cmd
);
18831 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18832 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18833 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18834 install_element(BGP_IPV6_NODE
,
18835 &no_neighbor_nexthop_self_all_hidden_cmd
);
18836 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
18837 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18838 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18839 install_element(BGP_IPV6M_NODE
,
18840 &no_neighbor_nexthop_self_all_hidden_cmd
);
18841 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
18842 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18843 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18844 install_element(BGP_IPV6L_NODE
,
18845 &no_neighbor_nexthop_self_all_hidden_cmd
);
18846 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18847 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18848 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18849 install_element(BGP_VPNV4_NODE
,
18850 &no_neighbor_nexthop_self_all_hidden_cmd
);
18851 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18852 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18853 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18854 install_element(BGP_VPNV6_NODE
,
18855 &no_neighbor_nexthop_self_all_hidden_cmd
);
18856 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
18857 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18859 /* "neighbor as-override" commands. */
18860 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
18861 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
18862 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
18863 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
18864 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
18865 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
18866 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
18867 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
18868 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
18869 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
18870 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
18871 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
18872 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
18873 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
18874 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
18875 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
18876 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
18877 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
18879 /* "neighbor remove-private-AS" commands. */
18880 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
18881 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
18882 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
18883 install_element(BGP_NODE
,
18884 &no_neighbor_remove_private_as_all_hidden_cmd
);
18885 install_element(BGP_NODE
,
18886 &neighbor_remove_private_as_replace_as_hidden_cmd
);
18887 install_element(BGP_NODE
,
18888 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
18889 install_element(BGP_NODE
,
18890 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18893 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18894 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
18895 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18896 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18897 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18898 install_element(BGP_IPV4_NODE
,
18899 &neighbor_remove_private_as_replace_as_cmd
);
18900 install_element(BGP_IPV4_NODE
,
18901 &no_neighbor_remove_private_as_replace_as_cmd
);
18902 install_element(BGP_IPV4_NODE
,
18903 &neighbor_remove_private_as_all_replace_as_cmd
);
18904 install_element(BGP_IPV4_NODE
,
18905 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18906 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
18907 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
18908 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
18909 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18910 install_element(BGP_IPV4M_NODE
,
18911 &neighbor_remove_private_as_replace_as_cmd
);
18912 install_element(BGP_IPV4M_NODE
,
18913 &no_neighbor_remove_private_as_replace_as_cmd
);
18914 install_element(BGP_IPV4M_NODE
,
18915 &neighbor_remove_private_as_all_replace_as_cmd
);
18916 install_element(BGP_IPV4M_NODE
,
18917 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18918 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
18919 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
18920 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
18921 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18922 install_element(BGP_IPV4L_NODE
,
18923 &neighbor_remove_private_as_replace_as_cmd
);
18924 install_element(BGP_IPV4L_NODE
,
18925 &no_neighbor_remove_private_as_replace_as_cmd
);
18926 install_element(BGP_IPV4L_NODE
,
18927 &neighbor_remove_private_as_all_replace_as_cmd
);
18928 install_element(BGP_IPV4L_NODE
,
18929 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18930 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
18931 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18932 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18933 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18934 install_element(BGP_IPV6_NODE
,
18935 &neighbor_remove_private_as_replace_as_cmd
);
18936 install_element(BGP_IPV6_NODE
,
18937 &no_neighbor_remove_private_as_replace_as_cmd
);
18938 install_element(BGP_IPV6_NODE
,
18939 &neighbor_remove_private_as_all_replace_as_cmd
);
18940 install_element(BGP_IPV6_NODE
,
18941 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18942 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
18943 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
18944 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
18945 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18946 install_element(BGP_IPV6M_NODE
,
18947 &neighbor_remove_private_as_replace_as_cmd
);
18948 install_element(BGP_IPV6M_NODE
,
18949 &no_neighbor_remove_private_as_replace_as_cmd
);
18950 install_element(BGP_IPV6M_NODE
,
18951 &neighbor_remove_private_as_all_replace_as_cmd
);
18952 install_element(BGP_IPV6M_NODE
,
18953 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18954 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
18955 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
18956 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
18957 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18958 install_element(BGP_IPV6L_NODE
,
18959 &neighbor_remove_private_as_replace_as_cmd
);
18960 install_element(BGP_IPV6L_NODE
,
18961 &no_neighbor_remove_private_as_replace_as_cmd
);
18962 install_element(BGP_IPV6L_NODE
,
18963 &neighbor_remove_private_as_all_replace_as_cmd
);
18964 install_element(BGP_IPV6L_NODE
,
18965 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18966 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
18967 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18968 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18969 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18970 install_element(BGP_VPNV4_NODE
,
18971 &neighbor_remove_private_as_replace_as_cmd
);
18972 install_element(BGP_VPNV4_NODE
,
18973 &no_neighbor_remove_private_as_replace_as_cmd
);
18974 install_element(BGP_VPNV4_NODE
,
18975 &neighbor_remove_private_as_all_replace_as_cmd
);
18976 install_element(BGP_VPNV4_NODE
,
18977 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18978 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
18979 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18980 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18981 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18982 install_element(BGP_VPNV6_NODE
,
18983 &neighbor_remove_private_as_replace_as_cmd
);
18984 install_element(BGP_VPNV6_NODE
,
18985 &no_neighbor_remove_private_as_replace_as_cmd
);
18986 install_element(BGP_VPNV6_NODE
,
18987 &neighbor_remove_private_as_all_replace_as_cmd
);
18988 install_element(BGP_VPNV6_NODE
,
18989 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18991 /* "neighbor send-community" commands.*/
18992 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
18993 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
18994 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
18995 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
18996 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
18997 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
18998 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
18999 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
19000 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
19001 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
19002 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
19003 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
19004 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
19005 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
19006 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
19007 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
19008 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
19009 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
19010 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
19011 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
19012 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
19013 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
19014 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
19015 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
19016 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
19017 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
19018 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
19019 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
19020 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
19021 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
19022 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
19023 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
19024 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
19025 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
19026 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
19027 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
19029 /* "neighbor route-reflector" commands.*/
19030 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
19031 install_element(BGP_NODE
,
19032 &no_neighbor_route_reflector_client_hidden_cmd
);
19033 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
19034 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
19035 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
19036 install_element(BGP_IPV4M_NODE
,
19037 &no_neighbor_route_reflector_client_cmd
);
19038 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
19039 install_element(BGP_IPV4L_NODE
,
19040 &no_neighbor_route_reflector_client_cmd
);
19041 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
19042 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
19043 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
19044 install_element(BGP_IPV6M_NODE
,
19045 &no_neighbor_route_reflector_client_cmd
);
19046 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
19047 install_element(BGP_IPV6L_NODE
,
19048 &no_neighbor_route_reflector_client_cmd
);
19049 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
19050 install_element(BGP_VPNV4_NODE
,
19051 &no_neighbor_route_reflector_client_cmd
);
19052 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
19053 install_element(BGP_VPNV6_NODE
,
19054 &no_neighbor_route_reflector_client_cmd
);
19055 install_element(BGP_FLOWSPECV4_NODE
,
19056 &neighbor_route_reflector_client_cmd
);
19057 install_element(BGP_FLOWSPECV4_NODE
,
19058 &no_neighbor_route_reflector_client_cmd
);
19059 install_element(BGP_FLOWSPECV6_NODE
,
19060 &neighbor_route_reflector_client_cmd
);
19061 install_element(BGP_FLOWSPECV6_NODE
,
19062 &no_neighbor_route_reflector_client_cmd
);
19063 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
19064 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
19066 /* "optimal-route-reflection" commands */
19067 install_element(BGP_IPV4_NODE
, &optimal_route_reflection_cmd
);
19068 install_element(BGP_IPV4M_NODE
, &optimal_route_reflection_cmd
);
19069 install_element(BGP_IPV4L_NODE
, &optimal_route_reflection_cmd
);
19070 install_element(BGP_IPV6_NODE
, &optimal_route_reflection_cmd
);
19071 install_element(BGP_IPV6M_NODE
, &optimal_route_reflection_cmd
);
19072 install_element(BGP_IPV6L_NODE
, &optimal_route_reflection_cmd
);
19073 install_element(BGP_VPNV4_NODE
, &optimal_route_reflection_cmd
);
19074 install_element(BGP_VPNV6_NODE
, &optimal_route_reflection_cmd
);
19075 install_element(BGP_FLOWSPECV4_NODE
, &optimal_route_reflection_cmd
);
19076 install_element(BGP_FLOWSPECV6_NODE
, &optimal_route_reflection_cmd
);
19077 install_element(BGP_EVPN_NODE
, &optimal_route_reflection_cmd
);
19079 /* "neighbor optimal-route-reflection" commands */
19080 install_element(BGP_IPV4_NODE
, &neighbor_optimal_route_reflection_cmd
);
19081 install_element(BGP_IPV4M_NODE
, &neighbor_optimal_route_reflection_cmd
);
19082 install_element(BGP_IPV4L_NODE
, &neighbor_optimal_route_reflection_cmd
);
19083 install_element(BGP_IPV6_NODE
, &neighbor_optimal_route_reflection_cmd
);
19084 install_element(BGP_IPV6M_NODE
, &neighbor_optimal_route_reflection_cmd
);
19085 install_element(BGP_IPV6L_NODE
, &neighbor_optimal_route_reflection_cmd
);
19086 install_element(BGP_VPNV4_NODE
, &neighbor_optimal_route_reflection_cmd
);
19087 install_element(BGP_VPNV6_NODE
, &neighbor_optimal_route_reflection_cmd
);
19088 install_element(BGP_FLOWSPECV4_NODE
,
19089 &neighbor_optimal_route_reflection_cmd
);
19090 install_element(BGP_FLOWSPECV6_NODE
,
19091 &neighbor_optimal_route_reflection_cmd
);
19092 install_element(BGP_EVPN_NODE
, &neighbor_optimal_route_reflection_cmd
);
19094 /* "neighbor route-server" commands.*/
19095 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
19096 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
19097 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
19098 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
19099 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
19100 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
19101 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
19102 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
19103 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
19104 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
19105 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
19106 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
19107 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
19108 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
19109 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
19110 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
19111 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
19112 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
19113 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
19114 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
19115 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
19116 install_element(BGP_FLOWSPECV4_NODE
,
19117 &no_neighbor_route_server_client_cmd
);
19118 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
19119 install_element(BGP_FLOWSPECV6_NODE
,
19120 &no_neighbor_route_server_client_cmd
);
19122 /* "neighbor disable-addpath-rx" commands. */
19123 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19124 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19125 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19126 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19127 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19128 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19129 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19130 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19131 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19132 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19133 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19134 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19135 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19136 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19137 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19138 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19140 /* "neighbor addpath-tx-all-paths" commands.*/
19141 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
19142 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
19143 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19144 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19145 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19146 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19147 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19148 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19149 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19150 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19151 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19152 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19153 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19154 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19155 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19156 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19157 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19158 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19160 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
19161 install_element(BGP_NODE
,
19162 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19163 install_element(BGP_NODE
,
19164 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19165 install_element(BGP_IPV4_NODE
,
19166 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19167 install_element(BGP_IPV4_NODE
,
19168 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19169 install_element(BGP_IPV4M_NODE
,
19170 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19171 install_element(BGP_IPV4M_NODE
,
19172 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19173 install_element(BGP_IPV4L_NODE
,
19174 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19175 install_element(BGP_IPV4L_NODE
,
19176 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19177 install_element(BGP_IPV6_NODE
,
19178 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19179 install_element(BGP_IPV6_NODE
,
19180 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19181 install_element(BGP_IPV6M_NODE
,
19182 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19183 install_element(BGP_IPV6M_NODE
,
19184 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19185 install_element(BGP_IPV6L_NODE
,
19186 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19187 install_element(BGP_IPV6L_NODE
,
19188 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19189 install_element(BGP_VPNV4_NODE
,
19190 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19191 install_element(BGP_VPNV4_NODE
,
19192 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19193 install_element(BGP_VPNV6_NODE
,
19194 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19195 install_element(BGP_VPNV6_NODE
,
19196 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19198 /* "neighbor sender-as-path-loop-detection" commands. */
19199 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
19200 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
19202 /* "neighbor passive" commands. */
19203 install_element(BGP_NODE
, &neighbor_passive_cmd
);
19204 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
19207 /* "neighbor shutdown" commands. */
19208 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
19209 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
19210 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
19211 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
19212 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
19213 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
19215 /* "neighbor capability extended-nexthop" commands.*/
19216 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
19217 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
19219 /* "neighbor capability orf prefix-list" commands.*/
19220 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
19221 install_element(BGP_NODE
,
19222 &no_neighbor_capability_orf_prefix_hidden_cmd
);
19223 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
19224 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19225 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19226 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19227 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19228 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19229 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
19230 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19231 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19232 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19233 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19234 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19236 /* "neighbor capability dynamic" commands.*/
19237 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
19238 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
19240 /* "neighbor dont-capability-negotiate" commands. */
19241 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
19242 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
19244 /* "neighbor ebgp-multihop" commands. */
19245 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
19246 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
19247 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
19249 /* "neighbor disable-connected-check" commands. */
19250 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
19251 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
19253 /* "neighbor disable-link-bw-encoding-ieee" commands. */
19254 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
19255 install_element(BGP_NODE
,
19256 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
19258 /* "neighbor extended-optional-parameters" commands. */
19259 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
19260 install_element(BGP_NODE
,
19261 &no_neighbor_extended_optional_parameters_cmd
);
19263 /* "neighbor enforce-first-as" commands. */
19264 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
19265 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
19267 /* "neighbor description" commands. */
19268 install_element(BGP_NODE
, &neighbor_description_cmd
);
19269 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
19270 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
19272 /* "neighbor update-source" commands. "*/
19273 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
19274 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
19276 /* "neighbor default-originate" commands. */
19277 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
19278 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
19279 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
19280 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
19281 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
19282 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
19283 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
19284 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
19285 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
19286 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
19287 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
19288 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
19289 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
19290 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
19291 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
19292 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
19293 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
19294 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
19295 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
19296 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
19297 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
19299 /* "neighbor port" commands. */
19300 install_element(BGP_NODE
, &neighbor_port_cmd
);
19301 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
19303 /* "neighbor weight" commands. */
19304 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
19305 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
19307 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
19308 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
19309 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
19310 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
19311 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
19312 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
19313 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
19314 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
19315 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
19316 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
19317 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
19318 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
19319 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
19320 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
19321 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
19322 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
19324 /* "neighbor override-capability" commands. */
19325 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
19326 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
19328 /* "neighbor strict-capability-match" commands. */
19329 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
19330 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
19332 /* "neighbor timers" commands. */
19333 install_element(BGP_NODE
, &neighbor_timers_cmd
);
19334 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
19336 /* "neighbor timers connect" commands. */
19337 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
19338 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
19340 /* "neighbor timers delayopen" commands. */
19341 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
19342 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
19344 /* "neighbor advertisement-interval" commands. */
19345 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
19346 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
19348 /* "neighbor interface" commands. */
19349 install_element(BGP_NODE
, &neighbor_interface_cmd
);
19350 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
19352 /* "neighbor distribute" commands. */
19353 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
19354 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
19355 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
19356 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
19357 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
19358 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
19359 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
19360 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
19361 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
19362 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
19363 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
19364 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
19365 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
19366 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
19367 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
19368 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
19369 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
19370 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
19372 /* "neighbor prefix-list" commands. */
19373 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
19374 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
19375 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
19376 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
19377 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
19378 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
19379 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
19380 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
19381 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
19382 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
19383 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
19384 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
19385 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
19386 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
19387 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
19388 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
19389 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
19390 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
19391 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
19392 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
19393 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
19394 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
19396 /* "neighbor filter-list" commands. */
19397 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
19398 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
19399 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
19400 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
19401 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
19402 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
19403 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
19404 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
19405 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
19406 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
19407 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
19408 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
19409 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
19410 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
19411 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
19412 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
19413 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
19414 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
19415 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
19416 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
19417 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
19418 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
19420 /* "neighbor route-map" commands. */
19421 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
19422 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
19423 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
19424 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
19425 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
19426 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
19427 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
19428 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
19429 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
19430 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
19431 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
19432 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
19433 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
19434 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
19435 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
19436 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
19437 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
19438 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
19439 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
19440 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
19441 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
19442 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
19443 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
19444 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
19446 /* "neighbor unsuppress-map" commands. */
19447 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
19448 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
19449 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
19450 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19451 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
19452 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19453 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
19454 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19455 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
19456 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19457 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
19458 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19459 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
19460 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19461 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
19462 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19463 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
19464 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19466 /* "neighbor advertise-map" commands. */
19467 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
19468 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
19469 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
19470 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
19471 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
19472 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
19473 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
19474 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
19475 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
19476 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
19478 /* neighbor maximum-prefix-out commands. */
19479 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
19480 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19481 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19482 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19483 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19484 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19485 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19486 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19487 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19488 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19489 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19490 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19491 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19492 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19493 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19494 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19495 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19496 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19498 /* "neighbor maximum-prefix" commands. */
19499 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
19500 install_element(BGP_NODE
,
19501 &neighbor_maximum_prefix_threshold_hidden_cmd
);
19502 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
19503 install_element(BGP_NODE
,
19504 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
19505 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
19506 install_element(BGP_NODE
,
19507 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
19508 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
19509 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
19510 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19511 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19512 install_element(BGP_IPV4_NODE
,
19513 &neighbor_maximum_prefix_threshold_warning_cmd
);
19514 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19515 install_element(BGP_IPV4_NODE
,
19516 &neighbor_maximum_prefix_threshold_restart_cmd
);
19517 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19518 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
19519 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19520 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19521 install_element(BGP_IPV4M_NODE
,
19522 &neighbor_maximum_prefix_threshold_warning_cmd
);
19523 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19524 install_element(BGP_IPV4M_NODE
,
19525 &neighbor_maximum_prefix_threshold_restart_cmd
);
19526 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19527 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
19528 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19529 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19530 install_element(BGP_IPV4L_NODE
,
19531 &neighbor_maximum_prefix_threshold_warning_cmd
);
19532 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19533 install_element(BGP_IPV4L_NODE
,
19534 &neighbor_maximum_prefix_threshold_restart_cmd
);
19535 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19536 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
19537 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19538 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19539 install_element(BGP_IPV6_NODE
,
19540 &neighbor_maximum_prefix_threshold_warning_cmd
);
19541 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19542 install_element(BGP_IPV6_NODE
,
19543 &neighbor_maximum_prefix_threshold_restart_cmd
);
19544 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19545 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
19546 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19547 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19548 install_element(BGP_IPV6M_NODE
,
19549 &neighbor_maximum_prefix_threshold_warning_cmd
);
19550 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19551 install_element(BGP_IPV6M_NODE
,
19552 &neighbor_maximum_prefix_threshold_restart_cmd
);
19553 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19554 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
19555 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19556 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19557 install_element(BGP_IPV6L_NODE
,
19558 &neighbor_maximum_prefix_threshold_warning_cmd
);
19559 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19560 install_element(BGP_IPV6L_NODE
,
19561 &neighbor_maximum_prefix_threshold_restart_cmd
);
19562 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19563 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
19564 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19565 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19566 install_element(BGP_VPNV4_NODE
,
19567 &neighbor_maximum_prefix_threshold_warning_cmd
);
19568 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19569 install_element(BGP_VPNV4_NODE
,
19570 &neighbor_maximum_prefix_threshold_restart_cmd
);
19571 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19572 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
19573 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19574 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19575 install_element(BGP_VPNV6_NODE
,
19576 &neighbor_maximum_prefix_threshold_warning_cmd
);
19577 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19578 install_element(BGP_VPNV6_NODE
,
19579 &neighbor_maximum_prefix_threshold_restart_cmd
);
19580 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19582 /* "neighbor allowas-in" */
19583 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
19584 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
19585 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
19586 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
19587 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
19588 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
19589 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
19590 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
19591 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
19592 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
19593 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
19594 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
19595 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
19596 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
19597 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
19598 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
19599 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
19600 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
19601 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
19602 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
19604 /* neighbor accept-own */
19605 install_element(BGP_VPNV4_NODE
, &neighbor_accept_own_cmd
);
19606 install_element(BGP_VPNV6_NODE
, &neighbor_accept_own_cmd
);
19608 /* "neighbor soo" */
19609 install_element(BGP_IPV4_NODE
, &neighbor_soo_cmd
);
19610 install_element(BGP_IPV4_NODE
, &no_neighbor_soo_cmd
);
19611 install_element(BGP_IPV4M_NODE
, &neighbor_soo_cmd
);
19612 install_element(BGP_IPV4M_NODE
, &no_neighbor_soo_cmd
);
19613 install_element(BGP_IPV4L_NODE
, &neighbor_soo_cmd
);
19614 install_element(BGP_IPV4L_NODE
, &no_neighbor_soo_cmd
);
19615 install_element(BGP_IPV6_NODE
, &neighbor_soo_cmd
);
19616 install_element(BGP_IPV6_NODE
, &no_neighbor_soo_cmd
);
19617 install_element(BGP_IPV6M_NODE
, &neighbor_soo_cmd
);
19618 install_element(BGP_IPV6M_NODE
, &no_neighbor_soo_cmd
);
19619 install_element(BGP_IPV6L_NODE
, &neighbor_soo_cmd
);
19620 install_element(BGP_IPV6L_NODE
, &no_neighbor_soo_cmd
);
19621 install_element(BGP_VPNV4_NODE
, &neighbor_soo_cmd
);
19622 install_element(BGP_VPNV4_NODE
, &no_neighbor_soo_cmd
);
19623 install_element(BGP_VPNV6_NODE
, &neighbor_soo_cmd
);
19624 install_element(BGP_VPNV6_NODE
, &no_neighbor_soo_cmd
);
19625 install_element(BGP_EVPN_NODE
, &neighbor_soo_cmd
);
19626 install_element(BGP_EVPN_NODE
, &no_neighbor_soo_cmd
);
19628 /* address-family commands. */
19629 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
19630 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
19631 #ifdef KEEP_OLD_VPN_COMMANDS
19632 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
19633 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
19634 #endif /* KEEP_OLD_VPN_COMMANDS */
19636 install_element(BGP_NODE
, &address_family_evpn_cmd
);
19638 /* "exit-address-family" command. */
19639 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
19640 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
19641 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
19642 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
19643 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
19644 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
19645 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
19646 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
19647 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
19648 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
19649 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
19651 /* BGP retain all route-target */
19652 install_element(BGP_VPNV4_NODE
, &bgp_retain_route_target_cmd
);
19653 install_element(BGP_VPNV6_NODE
, &bgp_retain_route_target_cmd
);
19655 /* "clear ip bgp commands" */
19656 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
19658 /* clear ip bgp prefix */
19659 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
19660 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
19661 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
19663 /* "show [ip] bgp summary" commands. */
19664 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
19665 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
19666 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
19667 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
19668 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
19669 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
19670 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
19672 /* "show [ip] bgp neighbors" commands. */
19673 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
19675 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
19677 /* "show [ip] bgp peer-group" commands. */
19678 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
19680 /* "show [ip] bgp paths" commands. */
19681 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
19683 /* "show [ip] bgp community" commands. */
19684 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
19686 /* "show ip bgp large-community" commands. */
19687 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
19688 /* "show [ip] bgp attribute-info" commands. */
19689 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
19690 /* "show [ip] bgp route-leak" command */
19691 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
19693 /* "redistribute" commands. */
19694 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
19695 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
19696 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
19697 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
19698 install_element(BGP_NODE
,
19699 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
19700 install_element(BGP_NODE
,
19701 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
19702 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
19703 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
19704 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
19705 install_element(BGP_NODE
,
19706 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
19707 install_element(BGP_NODE
,
19708 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
19709 install_element(BGP_NODE
,
19710 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
19711 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
19712 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
19713 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
19714 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
19715 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
19716 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
19717 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
19718 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
19719 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
19720 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
19721 install_element(BGP_IPV4_NODE
,
19722 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
19723 install_element(BGP_IPV4_NODE
,
19724 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
19725 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
19726 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
19727 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
19728 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
19729 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
19730 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
19732 /* import|export vpn [route-map RMAP_NAME] */
19733 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
19734 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
19736 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
19737 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
19739 /* ttl_security commands */
19740 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
19741 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
19743 /* "bgp tcp-keepalive" commands */
19744 install_element(BGP_NODE
, &bgp_tcp_keepalive_cmd
);
19745 install_element(BGP_NODE
, &no_bgp_tcp_keepalive_cmd
);
19747 /* "show [ip] bgp memory" commands. */
19748 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
19750 /* "show bgp martian next-hop" */
19751 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
19753 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
19755 /* "show [ip] bgp views" commands. */
19756 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
19758 /* "show [ip] bgp vrfs" commands. */
19759 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
19761 /* Community-list. */
19762 community_list_vty();
19764 community_alias_vty();
19766 /* vpn-policy commands */
19767 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
19768 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
19769 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
19770 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
19771 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
19772 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
19773 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
19774 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
19775 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
19776 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
19777 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
19778 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
19780 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
19781 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
19783 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
19784 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
19785 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
19786 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
19787 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
19788 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
19789 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19790 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19791 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
19792 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
19794 /* tcp-mss command */
19795 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
19796 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
19798 /* srv6 commands */
19799 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
19800 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
19801 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
19802 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
19803 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
19804 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
19805 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
19810 #include "memory.h"
19811 #include "bgp_regex.h"
19812 #include "bgp_clist.h"
19813 #include "bgp_ecommunity.h"
19815 /* VTY functions. */
19817 /* Direction value to string conversion. */
19818 static const char *community_direct_str(int direct
)
19821 case COMMUNITY_DENY
:
19823 case COMMUNITY_PERMIT
:
19830 /* Display error string. */
19831 static void community_list_perror(struct vty
*vty
, int ret
)
19834 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
19835 vty_out(vty
, "%% Can't find community-list\n");
19837 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
19838 vty_out(vty
, "%% Malformed community-list value\n");
19840 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
19842 "%% Community name conflict, previously defined as standard community\n");
19844 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
19846 "%% Community name conflict, previously defined as expanded community\n");
19851 /* "community-list" keyword help string. */
19852 #define COMMUNITY_LIST_STR "Add a community list entry\n"
19854 /*community-list standard */
19855 DEFUN (community_list_standard
,
19856 bgp_community_list_standard_cmd
,
19857 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19860 "Community list number (standard)\n"
19861 "Add an standard community-list entry\n"
19862 "Community list name\n"
19863 "Sequence number of an entry\n"
19864 "Sequence number\n"
19865 "Specify community to reject\n"
19866 "Specify community to accept\n"
19869 char *cl_name_or_number
= NULL
;
19872 int style
= COMMUNITY_LIST_STANDARD
;
19875 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19876 seq
= argv
[idx
]->arg
;
19879 argv_find(argv
, argc
, "(1-99)", &idx
);
19880 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19881 cl_name_or_number
= argv
[idx
]->arg
;
19882 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19884 argv_find(argv
, argc
, "AA:NN", &idx
);
19885 char *str
= argv_concat(argv
, argc
, idx
);
19887 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19890 XFREE(MTYPE_TMP
, str
);
19893 /* Display error string. */
19894 community_list_perror(vty
, ret
);
19895 return CMD_WARNING_CONFIG_FAILED
;
19898 return CMD_SUCCESS
;
19901 DEFUN (no_community_list_standard_all
,
19902 no_bgp_community_list_standard_all_cmd
,
19903 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19907 "Community list number (standard)\n"
19908 "Add an standard community-list entry\n"
19909 "Community list name\n"
19910 "Sequence number of an entry\n"
19911 "Sequence number\n"
19912 "Specify community to reject\n"
19913 "Specify community to accept\n"
19916 char *cl_name_or_number
= NULL
;
19919 int style
= COMMUNITY_LIST_STANDARD
;
19923 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19924 seq
= argv
[idx
]->arg
;
19927 argv_find(argv
, argc
, "permit", &idx
);
19928 argv_find(argv
, argc
, "deny", &idx
);
19931 direct
= argv_find(argv
, argc
, "permit", &idx
)
19936 argv_find(argv
, argc
, "AA:NN", &idx
);
19937 str
= argv_concat(argv
, argc
, idx
);
19941 argv_find(argv
, argc
, "(1-99)", &idx
);
19942 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19943 cl_name_or_number
= argv
[idx
]->arg
;
19945 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19948 XFREE(MTYPE_TMP
, str
);
19951 community_list_perror(vty
, ret
);
19952 return CMD_WARNING_CONFIG_FAILED
;
19955 return CMD_SUCCESS
;
19958 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
19959 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
19960 NO_STR BGP_STR COMMUNITY_LIST_STR
19961 "Community list number (standard)\n"
19962 "Add an standard community-list entry\n"
19963 "Community list name\n")
19965 /*community-list expanded */
19966 DEFUN (community_list_expanded_all
,
19967 bgp_community_list_expanded_all_cmd
,
19968 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
19971 "Community list number (expanded)\n"
19972 "Add an expanded community-list entry\n"
19973 "Community list name\n"
19974 "Sequence number of an entry\n"
19975 "Sequence number\n"
19976 "Specify community to reject\n"
19977 "Specify community to accept\n"
19980 char *cl_name_or_number
= NULL
;
19983 int style
= COMMUNITY_LIST_EXPANDED
;
19986 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19987 seq
= argv
[idx
]->arg
;
19991 argv_find(argv
, argc
, "(100-500)", &idx
);
19992 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
19993 cl_name_or_number
= argv
[idx
]->arg
;
19994 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19996 argv_find(argv
, argc
, "AA:NN", &idx
);
19997 char *str
= argv_concat(argv
, argc
, idx
);
19999 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
20002 XFREE(MTYPE_TMP
, str
);
20005 /* Display error string. */
20006 community_list_perror(vty
, ret
);
20007 return CMD_WARNING_CONFIG_FAILED
;
20010 return CMD_SUCCESS
;
20013 DEFUN (no_community_list_expanded_all
,
20014 no_bgp_community_list_expanded_all_cmd
,
20015 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20019 "Community list number (expanded)\n"
20020 "Add an expanded community-list entry\n"
20021 "Community list name\n"
20022 "Sequence number of an entry\n"
20023 "Sequence number\n"
20024 "Specify community to reject\n"
20025 "Specify community to accept\n"
20028 char *cl_name_or_number
= NULL
;
20032 int style
= COMMUNITY_LIST_EXPANDED
;
20035 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20036 seq
= argv
[idx
]->arg
;
20039 argv_find(argv
, argc
, "permit", &idx
);
20040 argv_find(argv
, argc
, "deny", &idx
);
20043 direct
= argv_find(argv
, argc
, "permit", &idx
)
20048 argv_find(argv
, argc
, "AA:NN", &idx
);
20049 str
= argv_concat(argv
, argc
, idx
);
20053 argv_find(argv
, argc
, "(100-500)", &idx
);
20054 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20055 cl_name_or_number
= argv
[idx
]->arg
;
20057 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20060 XFREE(MTYPE_TMP
, str
);
20063 community_list_perror(vty
, ret
);
20064 return CMD_WARNING_CONFIG_FAILED
;
20067 return CMD_SUCCESS
;
20070 ALIAS(no_community_list_expanded_all
,
20071 no_bgp_community_list_expanded_all_list_cmd
,
20072 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
20073 NO_STR BGP_STR COMMUNITY_LIST_STR
20074 "Community list number (expanded)\n"
20075 "Add an expanded community-list entry\n"
20076 "Community list name\n")
20078 /* Return configuration string of community-list entry. */
20079 static const char *community_list_config_str(struct community_entry
*entry
)
20086 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
20087 str
= community_str(entry
->u
.com
, false, false);
20088 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
20089 str
= lcommunity_str(entry
->u
.lcom
, false, false);
20091 str
= entry
->config
;
20096 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
20098 struct community_entry
*entry
;
20100 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20101 if (entry
== list
->head
) {
20102 if (all_digit(list
->name
))
20103 vty_out(vty
, "Community %s list %s\n",
20104 entry
->style
== COMMUNITY_LIST_STANDARD
20106 : "(expanded) access",
20109 vty_out(vty
, "Named Community %s list %s\n",
20110 entry
->style
== COMMUNITY_LIST_STANDARD
20116 vty_out(vty
, " %s\n",
20117 community_direct_str(entry
->direct
));
20119 vty_out(vty
, " %s %s\n",
20120 community_direct_str(entry
->direct
),
20121 community_list_config_str(entry
));
20125 DEFUN (show_community_list
,
20126 show_bgp_community_list_cmd
,
20127 "show bgp community-list",
20130 "List community-list\n")
20132 struct community_list
*list
;
20133 struct community_list_master
*cm
;
20135 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20137 return CMD_SUCCESS
;
20139 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20140 community_list_show(vty
, list
);
20142 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20143 community_list_show(vty
, list
);
20145 return CMD_SUCCESS
;
20148 DEFUN (show_community_list_arg
,
20149 show_bgp_community_list_arg_cmd
,
20150 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
20153 "List community-list\n"
20154 "Community-list number\n"
20155 "Community-list name\n"
20156 "Detailed information on community-list\n")
20158 int idx_comm_list
= 3;
20159 struct community_list
*list
;
20161 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20162 COMMUNITY_LIST_MASTER
);
20164 vty_out(vty
, "%% Can't find community-list\n");
20165 return CMD_WARNING
;
20168 community_list_show(vty
, list
);
20170 return CMD_SUCCESS
;
20174 * Large Community code.
20176 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
20177 struct cmd_token
**argv
, int style
,
20178 int reject_all_digit_name
)
20187 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20188 seq
= argv
[idx
]->arg
;
20191 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20194 /* All digit name check. */
20196 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20197 argv_find(argv
, argc
, "(1-99)", &idx
);
20198 argv_find(argv
, argc
, "(100-500)", &idx
);
20199 cl_name
= argv
[idx
]->arg
;
20200 if (reject_all_digit_name
&& all_digit(cl_name
)) {
20201 vty_out(vty
, "%% Community name cannot have all digits\n");
20202 return CMD_WARNING_CONFIG_FAILED
;
20206 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
20207 argv_find(argv
, argc
, "LINE", &idx
);
20208 /* Concat community string argument. */
20210 str
= argv_concat(argv
, argc
, idx
);
20214 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
20216 /* Free temporary community list string allocated by
20218 XFREE(MTYPE_TMP
, str
);
20221 community_list_perror(vty
, ret
);
20222 return CMD_WARNING_CONFIG_FAILED
;
20224 return CMD_SUCCESS
;
20227 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
20228 struct cmd_token
**argv
, int style
)
20236 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20237 seq
= argv
[idx
]->arg
;
20240 argv_find(argv
, argc
, "permit", &idx
);
20241 argv_find(argv
, argc
, "deny", &idx
);
20244 /* Check the list direct. */
20245 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
20246 direct
= COMMUNITY_PERMIT
;
20248 direct
= COMMUNITY_DENY
;
20251 argv_find(argv
, argc
, "LINE", &idx
);
20252 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
20253 /* Concat community string argument. */
20254 str
= argv_concat(argv
, argc
, idx
);
20258 argv_find(argv
, argc
, "(1-99)", &idx
);
20259 argv_find(argv
, argc
, "(100-500)", &idx
);
20260 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20262 /* Unset community list. */
20263 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
20266 /* Free temporary community list string allocated by
20268 XFREE(MTYPE_TMP
, str
);
20271 community_list_perror(vty
, ret
);
20272 return CMD_WARNING_CONFIG_FAILED
;
20275 return CMD_SUCCESS
;
20278 /* "large-community-list" keyword help string. */
20279 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
20280 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
20282 DEFUN (lcommunity_list_standard
,
20283 bgp_lcommunity_list_standard_cmd
,
20284 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20286 LCOMMUNITY_LIST_STR
20287 "Large Community list number (standard)\n"
20288 "Sequence number of an entry\n"
20289 "Sequence number\n"
20290 "Specify large community to reject\n"
20291 "Specify large community to accept\n"
20292 LCOMMUNITY_VAL_STR
)
20294 return lcommunity_list_set_vty(vty
, argc
, argv
,
20295 LARGE_COMMUNITY_LIST_STANDARD
, 0);
20298 DEFUN (lcommunity_list_expanded
,
20299 bgp_lcommunity_list_expanded_cmd
,
20300 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20302 LCOMMUNITY_LIST_STR
20303 "Large Community list number (expanded)\n"
20304 "Sequence number of an entry\n"
20305 "Sequence number\n"
20306 "Specify large community to reject\n"
20307 "Specify large community to accept\n"
20308 "An ordered list as a regular-expression\n")
20310 return lcommunity_list_set_vty(vty
, argc
, argv
,
20311 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
20314 DEFUN (lcommunity_list_name_standard
,
20315 bgp_lcommunity_list_name_standard_cmd
,
20316 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20318 LCOMMUNITY_LIST_STR
20319 "Specify standard large-community-list\n"
20320 "Large Community list name\n"
20321 "Sequence number of an entry\n"
20322 "Sequence number\n"
20323 "Specify large community to reject\n"
20324 "Specify large community to accept\n"
20325 LCOMMUNITY_VAL_STR
)
20327 return lcommunity_list_set_vty(vty
, argc
, argv
,
20328 LARGE_COMMUNITY_LIST_STANDARD
, 1);
20331 DEFUN (lcommunity_list_name_expanded
,
20332 bgp_lcommunity_list_name_expanded_cmd
,
20333 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20335 LCOMMUNITY_LIST_STR
20336 "Specify expanded large-community-list\n"
20337 "Large Community list name\n"
20338 "Sequence number of an entry\n"
20339 "Sequence number\n"
20340 "Specify large community to reject\n"
20341 "Specify large community to accept\n"
20342 "An ordered list as a regular-expression\n")
20344 return lcommunity_list_set_vty(vty
, argc
, argv
,
20345 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
20348 DEFUN (no_lcommunity_list_all
,
20349 no_bgp_lcommunity_list_all_cmd
,
20350 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
20353 LCOMMUNITY_LIST_STR
20354 "Large Community list number (standard)\n"
20355 "Large Community list number (expanded)\n"
20356 "Large Community list name\n")
20358 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20359 LARGE_COMMUNITY_LIST_STANDARD
);
20362 DEFUN (no_lcommunity_list_name_standard_all
,
20363 no_bgp_lcommunity_list_name_standard_all_cmd
,
20364 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
20367 LCOMMUNITY_LIST_STR
20368 "Specify standard large-community-list\n"
20369 "Large Community list name\n")
20371 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20372 LARGE_COMMUNITY_LIST_STANDARD
);
20375 DEFUN (no_lcommunity_list_name_expanded_all
,
20376 no_bgp_lcommunity_list_name_expanded_all_cmd
,
20377 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
20380 LCOMMUNITY_LIST_STR
20381 "Specify expanded large-community-list\n"
20382 "Large Community list name\n")
20384 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20385 LARGE_COMMUNITY_LIST_EXPANDED
);
20388 DEFUN (no_lcommunity_list_standard
,
20389 no_bgp_lcommunity_list_standard_cmd
,
20390 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20393 LCOMMUNITY_LIST_STR
20394 "Large Community list number (standard)\n"
20395 "Sequence number of an entry\n"
20396 "Sequence number\n"
20397 "Specify large community to reject\n"
20398 "Specify large community to accept\n"
20399 LCOMMUNITY_VAL_STR
)
20401 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20402 LARGE_COMMUNITY_LIST_STANDARD
);
20405 DEFUN (no_lcommunity_list_expanded
,
20406 no_bgp_lcommunity_list_expanded_cmd
,
20407 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20410 LCOMMUNITY_LIST_STR
20411 "Large Community list number (expanded)\n"
20412 "Sequence number of an entry\n"
20413 "Sequence number\n"
20414 "Specify large community to reject\n"
20415 "Specify large community to accept\n"
20416 "An ordered list as a regular-expression\n")
20418 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20419 LARGE_COMMUNITY_LIST_EXPANDED
);
20422 DEFUN (no_lcommunity_list_name_standard
,
20423 no_bgp_lcommunity_list_name_standard_cmd
,
20424 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20427 LCOMMUNITY_LIST_STR
20428 "Specify standard large-community-list\n"
20429 "Large Community list name\n"
20430 "Sequence number of an entry\n"
20431 "Sequence number\n"
20432 "Specify large community to reject\n"
20433 "Specify large community to accept\n"
20434 LCOMMUNITY_VAL_STR
)
20436 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20437 LARGE_COMMUNITY_LIST_STANDARD
);
20440 DEFUN (no_lcommunity_list_name_expanded
,
20441 no_bgp_lcommunity_list_name_expanded_cmd
,
20442 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20445 LCOMMUNITY_LIST_STR
20446 "Specify expanded large-community-list\n"
20447 "Large community list name\n"
20448 "Sequence number of an entry\n"
20449 "Sequence number\n"
20450 "Specify large community to reject\n"
20451 "Specify large community to accept\n"
20452 "An ordered list as a regular-expression\n")
20454 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20455 LARGE_COMMUNITY_LIST_EXPANDED
);
20458 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20460 struct community_entry
*entry
;
20462 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20463 if (entry
== list
->head
) {
20464 if (all_digit(list
->name
))
20465 vty_out(vty
, "Large community %s list %s\n",
20467 LARGE_COMMUNITY_LIST_STANDARD
20469 : "(expanded) access",
20473 "Named large community %s list %s\n",
20475 LARGE_COMMUNITY_LIST_STANDARD
20481 vty_out(vty
, " %s\n",
20482 community_direct_str(entry
->direct
));
20484 vty_out(vty
, " %s %s\n",
20485 community_direct_str(entry
->direct
),
20486 community_list_config_str(entry
));
20490 DEFUN (show_lcommunity_list
,
20491 show_bgp_lcommunity_list_cmd
,
20492 "show bgp large-community-list",
20495 "List large-community list\n")
20497 struct community_list
*list
;
20498 struct community_list_master
*cm
;
20500 cm
= community_list_master_lookup(bgp_clist
,
20501 LARGE_COMMUNITY_LIST_MASTER
);
20503 return CMD_SUCCESS
;
20505 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20506 lcommunity_list_show(vty
, list
);
20508 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20509 lcommunity_list_show(vty
, list
);
20511 return CMD_SUCCESS
;
20514 DEFUN (show_lcommunity_list_arg
,
20515 show_bgp_lcommunity_list_arg_cmd
,
20516 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
20519 "List large-community list\n"
20520 "Large-community-list number\n"
20521 "Large-community-list name\n"
20522 "Detailed information on large-community-list\n")
20524 struct community_list
*list
;
20526 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
20527 LARGE_COMMUNITY_LIST_MASTER
);
20529 vty_out(vty
, "%% Can't find large-community-list\n");
20530 return CMD_WARNING
;
20533 lcommunity_list_show(vty
, list
);
20535 return CMD_SUCCESS
;
20538 /* "extcommunity-list" keyword help string. */
20539 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
20540 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
20542 DEFUN (extcommunity_list_standard
,
20543 bgp_extcommunity_list_standard_cmd
,
20544 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20546 EXTCOMMUNITY_LIST_STR
20547 "Extended Community list number (standard)\n"
20548 "Specify standard extcommunity-list\n"
20549 "Community list name\n"
20550 "Sequence number of an entry\n"
20551 "Sequence number\n"
20552 "Specify community to reject\n"
20553 "Specify community to accept\n"
20554 EXTCOMMUNITY_VAL_STR
)
20556 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20558 char *cl_number_or_name
= NULL
;
20563 argv_find(argv
, argc
, "(1-99)", &idx
);
20564 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20565 cl_number_or_name
= argv
[idx
]->arg
;
20567 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20568 seq
= argv
[idx
]->arg
;
20570 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20572 argv_find(argv
, argc
, "AA:NN", &idx
);
20573 char *str
= argv_concat(argv
, argc
, idx
);
20575 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20578 XFREE(MTYPE_TMP
, str
);
20581 community_list_perror(vty
, ret
);
20582 return CMD_WARNING_CONFIG_FAILED
;
20585 return CMD_SUCCESS
;
20588 DEFUN (extcommunity_list_name_expanded
,
20589 bgp_extcommunity_list_name_expanded_cmd
,
20590 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20592 EXTCOMMUNITY_LIST_STR
20593 "Extended Community list number (expanded)\n"
20594 "Specify expanded extcommunity-list\n"
20595 "Extended Community list name\n"
20596 "Sequence number of an entry\n"
20597 "Sequence number\n"
20598 "Specify community to reject\n"
20599 "Specify community to accept\n"
20600 "An ordered list as a regular-expression\n")
20602 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20604 char *cl_number_or_name
= NULL
;
20608 argv_find(argv
, argc
, "(100-500)", &idx
);
20609 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20610 cl_number_or_name
= argv
[idx
]->arg
;
20612 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20613 seq
= argv
[idx
]->arg
;
20615 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20617 argv_find(argv
, argc
, "LINE", &idx
);
20618 char *str
= argv_concat(argv
, argc
, idx
);
20620 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20623 XFREE(MTYPE_TMP
, str
);
20626 community_list_perror(vty
, ret
);
20627 return CMD_WARNING_CONFIG_FAILED
;
20630 return CMD_SUCCESS
;
20633 DEFUN (no_extcommunity_list_standard_all
,
20634 no_bgp_extcommunity_list_standard_all_cmd
,
20635 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20638 EXTCOMMUNITY_LIST_STR
20639 "Extended Community list number (standard)\n"
20640 "Specify standard extcommunity-list\n"
20641 "Community list name\n"
20642 "Sequence number of an entry\n"
20643 "Sequence number\n"
20644 "Specify community to reject\n"
20645 "Specify community to accept\n"
20646 EXTCOMMUNITY_VAL_STR
)
20648 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20650 char *cl_number_or_name
= NULL
;
20655 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20656 seq
= argv
[idx
]->arg
;
20659 argv_find(argv
, argc
, "permit", &idx
);
20660 argv_find(argv
, argc
, "deny", &idx
);
20662 direct
= argv_find(argv
, argc
, "permit", &idx
)
20667 argv_find(argv
, argc
, "AA:NN", &idx
);
20668 str
= argv_concat(argv
, argc
, idx
);
20672 argv_find(argv
, argc
, "(1-99)", &idx
);
20673 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20674 cl_number_or_name
= argv
[idx
]->arg
;
20676 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20677 seq
, direct
, style
);
20679 XFREE(MTYPE_TMP
, str
);
20682 community_list_perror(vty
, ret
);
20683 return CMD_WARNING_CONFIG_FAILED
;
20686 return CMD_SUCCESS
;
20689 ALIAS(no_extcommunity_list_standard_all
,
20690 no_bgp_extcommunity_list_standard_all_list_cmd
,
20691 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
20692 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20693 "Extended Community list number (standard)\n"
20694 "Specify standard extcommunity-list\n"
20695 "Community list name\n")
20697 DEFUN (no_extcommunity_list_expanded_all
,
20698 no_bgp_extcommunity_list_expanded_all_cmd
,
20699 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20702 EXTCOMMUNITY_LIST_STR
20703 "Extended Community list number (expanded)\n"
20704 "Specify expanded extcommunity-list\n"
20705 "Extended Community list name\n"
20706 "Sequence number of an entry\n"
20707 "Sequence number\n"
20708 "Specify community to reject\n"
20709 "Specify community to accept\n"
20710 "An ordered list as a regular-expression\n")
20712 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20714 char *cl_number_or_name
= NULL
;
20719 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20720 seq
= argv
[idx
]->arg
;
20723 argv_find(argv
, argc
, "permit", &idx
);
20724 argv_find(argv
, argc
, "deny", &idx
);
20727 direct
= argv_find(argv
, argc
, "permit", &idx
)
20732 argv_find(argv
, argc
, "LINE", &idx
);
20733 str
= argv_concat(argv
, argc
, idx
);
20737 argv_find(argv
, argc
, "(100-500)", &idx
);
20738 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20739 cl_number_or_name
= argv
[idx
]->arg
;
20741 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20742 seq
, direct
, style
);
20744 XFREE(MTYPE_TMP
, str
);
20747 community_list_perror(vty
, ret
);
20748 return CMD_WARNING_CONFIG_FAILED
;
20751 return CMD_SUCCESS
;
20754 ALIAS(no_extcommunity_list_expanded_all
,
20755 no_bgp_extcommunity_list_expanded_all_list_cmd
,
20756 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
20757 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20758 "Extended Community list number (expanded)\n"
20759 "Specify expanded extcommunity-list\n"
20760 "Extended Community list name\n")
20762 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20764 struct community_entry
*entry
;
20766 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20767 if (entry
== list
->head
) {
20768 if (all_digit(list
->name
))
20769 vty_out(vty
, "Extended community %s list %s\n",
20770 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20772 : "(expanded) access",
20776 "Named extended community %s list %s\n",
20777 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20783 vty_out(vty
, " %s\n",
20784 community_direct_str(entry
->direct
));
20786 vty_out(vty
, " %s %s\n",
20787 community_direct_str(entry
->direct
),
20788 community_list_config_str(entry
));
20792 DEFUN (show_extcommunity_list
,
20793 show_bgp_extcommunity_list_cmd
,
20794 "show bgp extcommunity-list",
20797 "List extended-community list\n")
20799 struct community_list
*list
;
20800 struct community_list_master
*cm
;
20802 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20804 return CMD_SUCCESS
;
20806 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20807 extcommunity_list_show(vty
, list
);
20809 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20810 extcommunity_list_show(vty
, list
);
20812 return CMD_SUCCESS
;
20815 DEFUN (show_extcommunity_list_arg
,
20816 show_bgp_extcommunity_list_arg_cmd
,
20817 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
20820 "List extended-community list\n"
20821 "Extcommunity-list number\n"
20822 "Extcommunity-list name\n"
20823 "Detailed information on extcommunity-list\n")
20825 int idx_comm_list
= 3;
20826 struct community_list
*list
;
20828 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20829 EXTCOMMUNITY_LIST_MASTER
);
20831 vty_out(vty
, "%% Can't find extcommunity-list\n");
20832 return CMD_WARNING
;
20835 extcommunity_list_show(vty
, list
);
20837 return CMD_SUCCESS
;
20840 /* Display community-list and extcommunity-list configuration. */
20841 static int community_list_config_write(struct vty
*vty
)
20843 struct community_list
*list
;
20844 struct community_entry
*entry
;
20845 struct community_list_master
*cm
;
20848 /* Community-list. */
20849 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20851 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20852 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20854 "bgp community-list %s seq %" PRId64
" %s %s\n",
20855 list
->name
, entry
->seq
,
20856 community_direct_str(entry
->direct
),
20857 community_list_config_str(entry
));
20860 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20861 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20863 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
20864 entry
->style
== COMMUNITY_LIST_STANDARD
20867 list
->name
, entry
->seq
,
20868 community_direct_str(entry
->direct
),
20869 community_list_config_str(entry
));
20873 /* Extcommunity-list. */
20874 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20876 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20877 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20879 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
20880 list
->name
, entry
->seq
,
20881 community_direct_str(entry
->direct
),
20882 community_list_config_str(entry
));
20885 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20886 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20888 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
20889 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20892 list
->name
, entry
->seq
,
20893 community_direct_str(entry
->direct
),
20894 community_list_config_str(entry
));
20899 /* lcommunity-list. */
20900 cm
= community_list_master_lookup(bgp_clist
,
20901 LARGE_COMMUNITY_LIST_MASTER
);
20903 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20904 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20906 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
20907 list
->name
, entry
->seq
,
20908 community_direct_str(entry
->direct
),
20909 community_list_config_str(entry
));
20912 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20913 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20915 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
20917 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
20920 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
20921 community_list_config_str(entry
));
20928 static int community_list_config_write(struct vty
*vty
);
20929 static struct cmd_node community_list_node
= {
20930 .name
= "community list",
20931 .node
= COMMUNITY_LIST_NODE
,
20933 .config_write
= community_list_config_write
,
20936 static void community_list_vty(void)
20938 install_node(&community_list_node
);
20940 /* Community-list. */
20941 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
20942 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
20943 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
20944 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
20945 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
20946 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
20947 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
20948 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
20950 /* Extcommunity-list. */
20951 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
20952 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
20953 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
20954 install_element(CONFIG_NODE
,
20955 &no_bgp_extcommunity_list_standard_all_list_cmd
);
20956 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
20957 install_element(CONFIG_NODE
,
20958 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
20959 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
20960 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
20962 /* Large Community List */
20963 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
20964 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
20965 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
20966 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
20967 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
20968 install_element(CONFIG_NODE
,
20969 &no_bgp_lcommunity_list_name_standard_all_cmd
);
20970 install_element(CONFIG_NODE
,
20971 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
20972 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
20973 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
20974 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
20975 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
20976 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
20977 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
20979 bgp_community_list_command_completion_setup();
20982 static struct cmd_node community_alias_node
= {
20983 .name
= "community alias",
20984 .node
= COMMUNITY_ALIAS_NODE
,
20986 .config_write
= bgp_community_alias_write
,
20989 void community_alias_vty(void)
20991 install_node(&community_alias_node
);
20993 /* Community-list. */
20994 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
20996 bgp_community_alias_command_completion_setup();