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"
82 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
85 .match_profile
= "traditional",
86 .match_version
= "< 7.4",
90 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
91 { .val_bool
= true, .match_profile
= "datacenter", },
92 { .val_bool
= false },
94 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
95 { .val_bool
= true, .match_profile
= "datacenter", },
96 { .val_bool
= false },
98 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
99 { .val_bool
= true, .match_profile
= "datacenter", },
100 { .val_bool
= false },
102 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
103 { .val_bool
= true, .match_profile
= "datacenter", },
104 { .val_bool
= false },
106 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
107 { .val_ulong
= 10, .match_profile
= "datacenter", },
108 { .val_ulong
= 120 },
110 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
111 { .val_ulong
= 9, .match_profile
= "datacenter", },
112 { .val_ulong
= 180 },
114 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
115 { .val_ulong
= 3, .match_profile
= "datacenter", },
118 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
119 { .val_bool
= false, .match_profile
= "datacenter", },
120 { .val_bool
= false, .match_version
= "< 7.4", },
121 { .val_bool
= true },
123 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
124 { .val_bool
= false, .match_version
= "< 7.6", },
125 { .val_bool
= true },
127 FRR_CFG_DEFAULT_BOOL(BGP_GRACEFUL_NOTIFICATION
,
128 { .val_bool
= false, .match_version
= "< 8.3", },
129 { .val_bool
= true },
131 FRR_CFG_DEFAULT_BOOL(BGP_HARD_ADMIN_RESET
,
132 { .val_bool
= false, .match_version
= "< 8.3", },
133 { .val_bool
= true },
136 DEFINE_HOOK(bgp_inst_config_write
,
137 (struct bgp
*bgp
, struct vty
*vty
),
139 DEFINE_HOOK(bgp_snmp_update_last_changed
, (struct bgp
*bgp
), (bgp
));
140 DEFINE_HOOK(bgp_snmp_init_stats
, (struct bgp
*bgp
), (bgp
));
142 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
143 struct prefix
*range
, int exact
);
145 /* Show BGP peer's information. */
155 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
156 struct prefix
*range
, int exact
);
158 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
161 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
164 afi_t afi
, bool use_json
);
166 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
172 return BGP_IPV4_NODE
;
174 return BGP_IPV4M_NODE
;
175 case SAFI_LABELED_UNICAST
:
176 return BGP_IPV4L_NODE
;
178 return BGP_VPNV4_NODE
;
180 return BGP_FLOWSPECV4_NODE
;
186 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
;
205 /* not expected and the return value seems wrong */
206 return BGP_IPV4_NODE
;
210 return BGP_EVPN_NODE
;
213 // We should never be here but to clarify the switch statement..
214 return BGP_IPV4_NODE
;
217 // Impossible to happen
218 return BGP_IPV4_NODE
;
221 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
224 if (safi
== SAFI_UNICAST
)
225 return "IPv4 Unicast";
226 if (safi
== SAFI_MULTICAST
)
227 return "IPv4 Multicast";
228 if (safi
== SAFI_LABELED_UNICAST
)
229 return "IPv4 Labeled Unicast";
230 if (safi
== SAFI_MPLS_VPN
)
232 if (safi
== SAFI_ENCAP
)
234 if (safi
== SAFI_FLOWSPEC
)
235 return "IPv4 Flowspec";
236 } else if (afi
== AFI_IP6
) {
237 if (safi
== SAFI_UNICAST
)
238 return "IPv6 Unicast";
239 if (safi
== SAFI_MULTICAST
)
240 return "IPv6 Multicast";
241 if (safi
== SAFI_LABELED_UNICAST
)
242 return "IPv6 Labeled Unicast";
243 if (safi
== SAFI_MPLS_VPN
)
245 if (safi
== SAFI_ENCAP
)
247 if (safi
== SAFI_FLOWSPEC
)
248 return "IPv6 Flowspec";
249 } else if (afi
== AFI_L2VPN
) {
250 if (safi
== SAFI_EVPN
)
258 * Please note that we have intentionally camelCased
259 * the return strings here. So if you want
260 * to use this function, please ensure you
261 * are doing this within json output
263 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
266 if (safi
== SAFI_UNICAST
)
267 return "ipv4Unicast";
268 if (safi
== SAFI_MULTICAST
)
269 return "ipv4Multicast";
270 if (safi
== SAFI_LABELED_UNICAST
)
271 return "ipv4LabeledUnicast";
272 if (safi
== SAFI_MPLS_VPN
)
274 if (safi
== SAFI_ENCAP
)
276 if (safi
== SAFI_FLOWSPEC
)
277 return "ipv4Flowspec";
278 } else if (afi
== AFI_IP6
) {
279 if (safi
== SAFI_UNICAST
)
280 return "ipv6Unicast";
281 if (safi
== SAFI_MULTICAST
)
282 return "ipv6Multicast";
283 if (safi
== SAFI_LABELED_UNICAST
)
284 return "ipv6LabeledUnicast";
285 if (safi
== SAFI_MPLS_VPN
)
287 if (safi
== SAFI_ENCAP
)
289 if (safi
== SAFI_FLOWSPEC
)
290 return "ipv6Flowspec";
291 } else if (afi
== AFI_L2VPN
) {
292 if (safi
== SAFI_EVPN
)
299 /* unset srv6 locator */
300 static int bgp_srv6_locator_unset(struct bgp
*bgp
)
303 struct listnode
*node
, *nnode
;
304 struct srv6_locator_chunk
*chunk
;
305 struct bgp_srv6_function
*func
;
308 /* release chunk notification via ZAPI */
309 ret
= bgp_zebra_srv6_manager_release_locator_chunk(
310 bgp
->srv6_locator_name
);
315 for (ALL_LIST_ELEMENTS(bgp
->srv6_locator_chunks
, node
, nnode
, chunk
)) {
316 listnode_delete(bgp
->srv6_locator_chunks
, chunk
);
317 srv6_locator_chunk_free(&chunk
);
320 /* refresh functions */
321 for (ALL_LIST_ELEMENTS(bgp
->srv6_functions
, node
, nnode
, func
)) {
322 listnode_delete(bgp
->srv6_functions
, func
);
323 XFREE(MTYPE_BGP_SRV6_FUNCTION
, func
);
326 /* refresh tovpn_sid */
327 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
328 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
331 /* refresh vpnv4 tovpn_sid */
332 XFREE(MTYPE_BGP_SRV6_SID
,
333 bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid
);
335 /* refresh vpnv6 tovpn_sid */
336 XFREE(MTYPE_BGP_SRV6_SID
,
337 bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid
);
339 /* refresh per-vrf tovpn_sid */
340 XFREE(MTYPE_BGP_SRV6_SID
, bgp_vrf
->tovpn_sid
);
343 /* update vpn bgp processes */
344 vpn_leak_postchange_all();
346 /* refresh tovpn_sid_locator */
347 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp_vrf
)) {
348 if (bgp_vrf
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
351 /* refresh vpnv4 tovpn_sid_locator */
352 srv6_locator_chunk_free(
353 &bgp_vrf
->vpn_policy
[AFI_IP
].tovpn_sid_locator
);
355 /* refresh vpnv6 tovpn_sid_locator */
356 srv6_locator_chunk_free(
357 &bgp_vrf
->vpn_policy
[AFI_IP6
].tovpn_sid_locator
);
359 /* refresh per-vrf tovpn_sid_locator */
360 srv6_locator_chunk_free(&bgp_vrf
->tovpn_sid_locator
);
363 /* clear locator name */
364 memset(bgp
->srv6_locator_name
, 0, sizeof(bgp
->srv6_locator_name
));
369 /* Utility function to get address family from current node. */
370 afi_t
bgp_node_afi(struct vty
*vty
)
378 case BGP_FLOWSPECV6_NODE
:
391 /* Utility function to get subsequent address family from current
393 safi_t
bgp_node_safi(struct vty
*vty
)
399 safi
= SAFI_MPLS_VPN
;
403 safi
= SAFI_MULTICAST
;
410 safi
= SAFI_LABELED_UNICAST
;
412 case BGP_FLOWSPECV4_NODE
:
413 case BGP_FLOWSPECV6_NODE
:
414 safi
= SAFI_FLOWSPEC
;
424 * Converts an AFI in string form to afi_t
426 * @param afi string, one of
430 * @return the corresponding afi_t
432 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
434 afi_t afi
= AFI_MAX
; /* unknown */
435 if (strmatch(afi_str
, "ipv4"))
437 else if (strmatch(afi_str
, "ipv6"))
439 else if (strmatch(afi_str
, "l2vpn"))
444 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
448 if (argv_find(argv
, argc
, "ipv4", index
)) {
452 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
456 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
464 /* supports <unicast|multicast|vpn|labeled-unicast> */
465 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
467 safi_t safi
= SAFI_MAX
; /* unknown */
468 if (strmatch(safi_str
, "multicast"))
469 safi
= SAFI_MULTICAST
;
470 else if (strmatch(safi_str
, "unicast"))
472 else if (strmatch(safi_str
, "vpn"))
473 safi
= SAFI_MPLS_VPN
;
474 else if (strmatch(safi_str
, "evpn"))
476 else if (strmatch(safi_str
, "labeled-unicast"))
477 safi
= SAFI_LABELED_UNICAST
;
478 else if (strmatch(safi_str
, "flowspec"))
479 safi
= SAFI_FLOWSPEC
;
483 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
487 if (argv_find(argv
, argc
, "unicast", index
)) {
490 *safi
= SAFI_UNICAST
;
491 } else if (argv_find(argv
, argc
, "multicast", index
)) {
494 *safi
= SAFI_MULTICAST
;
495 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
498 *safi
= SAFI_LABELED_UNICAST
;
499 } else if (argv_find(argv
, argc
, "vpn", index
)) {
502 *safi
= SAFI_MPLS_VPN
;
503 } else if (argv_find(argv
, argc
, "evpn", index
)) {
507 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
510 *safi
= SAFI_FLOWSPEC
;
516 * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag.
519 * address-family identifier
522 * subsequent address-family identifier
525 * default_af string corresponding to the supplied afi/safi pair.
526 * If afi/safi is invalid or if flag for afi/safi doesn't exist,
529 static const char *get_bgp_default_af_flag(afi_t afi
, safi_t safi
)
535 return "ipv4-unicast";
537 return "ipv4-multicast";
542 case SAFI_LABELED_UNICAST
:
543 return "ipv4-labeled-unicast";
545 return "ipv4-flowspec";
549 return "unknown-afi/safi";
555 return "ipv6-unicast";
557 return "ipv6-multicast";
562 case SAFI_LABELED_UNICAST
:
563 return "ipv6-labeled-unicast";
565 return "ipv6-flowspec";
569 return "unknown-afi/safi";
580 case SAFI_LABELED_UNICAST
:
584 return "unknown-afi/safi";
589 return "unknown-afi/safi";
591 /* all AFIs are accounted for above, so this shouldn't happen */
593 assert(!"Reached end of function where we did not expect to");
596 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
597 enum bgp_instance_type inst_type
)
599 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
601 if (ret
== BGP_CREATED
) {
602 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
603 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
605 if (DFLT_BGP_IMPORT_CHECK
)
606 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
607 if (DFLT_BGP_SHOW_HOSTNAME
)
608 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
609 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
610 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
611 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
612 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
613 if (DFLT_BGP_DETERMINISTIC_MED
)
614 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
615 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
616 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
617 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
618 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
619 if (DFLT_BGP_GRACEFUL_NOTIFICATION
)
620 SET_FLAG((*bgp
)->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
621 if (DFLT_BGP_HARD_ADMIN_RESET
)
622 SET_FLAG((*bgp
)->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
630 * bgp_vty_find_and_parse_afi_safi_bgp
632 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
633 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
634 * to appropriate values for the calling function. This is to allow the
635 * calling function to make decisions appropriate for the show command
636 * that is being parsed.
638 * The show commands are generally of the form:
639 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
640 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
642 * Since we use argv_find if the show command in particular doesn't have:
644 * [<view|vrf> VIEWVRFNAME]
645 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
646 * The command parsing should still be ok.
648 * vty -> The vty for the command so we can output some useful data in
649 * the event of a parse error in the vrf.
650 * argv -> The command tokens
651 * argc -> How many command tokens we have
652 * idx -> The current place in the command, generally should be 0 for this
654 * afi -> The parsed afi if it was included in the show command, returned here
655 * safi -> The parsed safi if it was included in the show command, returned here
656 * bgp -> Pointer to the bgp data structure we need to fill in.
657 * use_json -> json is configured or not
659 * The function returns the correct location in the parse tree for the
662 * Returns 0 for failure to parse correctly, else the idx position of where
663 * it found the last token.
665 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
666 struct cmd_token
**argv
, int argc
,
667 int *idx
, afi_t
*afi
, safi_t
*safi
,
668 struct bgp
**bgp
, bool use_json
)
670 char *vrf_name
= NULL
;
676 if (argv_find(argv
, argc
, "ip", idx
))
679 if (argv_find(argv
, argc
, "view", idx
))
680 vrf_name
= argv
[*idx
+ 1]->arg
;
681 else if (argv_find(argv
, argc
, "vrf", idx
)) {
682 vrf_name
= argv
[*idx
+ 1]->arg
;
683 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
687 if (strmatch(vrf_name
, "all"))
690 *bgp
= bgp_lookup_by_name(vrf_name
);
693 json_object
*json
= NULL
;
694 json
= json_object_new_object();
695 json_object_string_add(
697 "View/Vrf is unknown");
701 vty_out(vty
, "View/Vrf %s is unknown\n",
708 *bgp
= bgp_get_default();
711 json_object
*json
= NULL
;
712 json
= json_object_new_object();
713 json_object_string_add(
715 "Default BGP instance not found");
720 "Default BGP instance not found\n");
726 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
727 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
733 static bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
735 struct interface
*ifp
= NULL
;
736 struct listnode
*node
;
737 struct bgp_listener
*listener
;
738 union sockunion all_su
;
740 if (su
->sa
.sa_family
== AF_INET
) {
741 (void)str2sockunion("0.0.0.0", &all_su
);
742 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
743 } else if (su
->sa
.sa_family
== AF_INET6
) {
744 (void)str2sockunion("::", &all_su
);
745 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
746 su
->sin6
.sin6_scope_id
,
751 for (ALL_LIST_ELEMENTS_RO(bm
->listen_sockets
, node
, listener
)) {
752 if (sockunion_family(su
) !=
753 sockunion_family(&listener
->su
))
756 /* If 0.0.0.0/:: is a listener, then treat as self and
759 if (!sockunion_cmp(&listener
->su
, su
) ||
760 !sockunion_cmp(&listener
->su
, &all_su
))
768 /* Utility function for looking up peer from VTY. */
769 /* This is used only for configuration, so disallow if attempted on
770 * a dynamic neighbor.
772 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
774 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
783 ret
= str2sockunion(ip_str
, &su
);
785 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
787 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
790 "%% Malformed address or name: %s\n",
796 peer
= peer_lookup(bgp
, &su
);
799 "%% Specify remote-as or peer-group commands first\n");
802 if (peer_dynamic_neighbor(peer
)) {
804 "%% Operation not allowed on a dynamic neighbor\n");
811 /* Utility function for looking up peer or peer group. */
812 /* This is used only for configuration, so disallow if attempted on
813 * a dynamic neighbor.
815 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
817 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
820 struct peer
*peer
= NULL
;
821 struct peer_group
*group
= NULL
;
827 ret
= str2sockunion(peer_str
, &su
);
829 /* IP address, locate peer. */
830 peer
= peer_lookup(bgp
, &su
);
832 /* Not IP, could match either peer configured on interface or a
834 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
836 group
= peer_group_lookup(bgp
, peer_str
);
840 if (peer_dynamic_neighbor(peer
)) {
842 "%pBP: Operation not allowed on a dynamic neighbor",
845 "%% Operation not allowed on a dynamic neighbor\n");
855 zlog_warn("Specify remote-as or peer-group commands first before: %s",
857 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
862 int bgp_vty_return(struct vty
*vty
, enum bgp_create_error_code ret
)
864 const char *str
= NULL
;
869 case BGP_GR_NO_OPERATION
:
871 case BGP_ERR_INVALID_VALUE
:
872 str
= "Invalid value";
874 case BGP_ERR_INVALID_FLAG
:
875 str
= "Invalid flag";
877 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
878 str
= "Peer-group has been shutdown. Activate the peer-group first";
880 case BGP_ERR_PEER_FLAG_CONFLICT
:
881 str
= "Can't set override-capability and strict-capability-match at the same time";
883 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
884 str
= "Specify remote-as or peer-group remote AS first";
886 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
887 str
= "Cannot change the peer-group. Deconfigure first";
889 case BGP_ERR_PEER_GROUP_MISMATCH
:
890 str
= "Peer is not a member of this peer-group";
892 case BGP_ERR_PEER_FILTER_CONFLICT
:
893 str
= "Prefix/distribute list can not co-exist";
895 case BGP_ERR_NOT_INTERNAL_PEER
:
896 str
= "Invalid command. Not an internal neighbor";
898 case BGP_ERR_REMOVE_PRIVATE_AS
:
899 str
= "remove-private-AS cannot be configured for IBGP peers";
901 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
902 str
= "Cannot have local-as same as BGP AS number";
904 case BGP_ERR_TCPSIG_FAILED
:
905 str
= "Error while applying TCP-Sig to session(s)";
907 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
908 str
= "ebgp-multihop and ttl-security cannot be configured together";
910 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
911 str
= "ttl-security only allowed for EBGP peers";
913 case BGP_ERR_AS_OVERRIDE
:
914 str
= "as-override cannot be configured for IBGP peers";
916 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
917 str
= "Invalid limit for number of dynamic neighbors";
919 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
920 str
= "Dynamic neighbor listen range already exists";
922 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
923 str
= "Operation not allowed on a dynamic neighbor";
925 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
926 str
= "Operation not allowed on a directly connected neighbor";
928 case BGP_ERR_PEER_SAFI_CONFLICT
:
929 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
931 case BGP_ERR_GR_INVALID_CMD
:
932 str
= "The Graceful Restart command used is not valid at this moment.";
934 case BGP_ERR_GR_OPERATION_FAILED
:
935 str
= "The Graceful Restart Operation failed due to an err.";
937 case BGP_ERR_PEER_GROUP_MEMBER
:
938 str
= "Peer-group member cannot override remote-as of peer-group.";
940 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
941 str
= "Peer-group members must be all internal or all external.";
943 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND
:
944 str
= "Range specified cannot be deleted because it is not part of current config.";
946 case BGP_ERR_INSTANCE_MISMATCH
:
947 str
= "Instance specified does not match the current instance.";
949 case BGP_ERR_NO_INTERFACE_CONFIG
:
950 str
= "Interface specified is not being used for interface based peer.";
952 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
953 str
= "No configuration already specified for soft reconfiguration.";
955 case BGP_ERR_AS_MISMATCH
:
956 str
= "BGP is already running.";
958 case BGP_ERR_AF_UNCONFIGURED
:
959 str
= "AFI/SAFI specified is not currently configured.";
961 case BGP_ERR_INVALID_AS
:
962 str
= "Confederation AS specified is the same AS as our AS.";
964 case BGP_ERR_INVALID_ROLE_NAME
:
965 str
= "Invalid role name";
967 case BGP_ERR_INVALID_INTERNAL_ROLE
:
968 str
= "External roles can be set only on eBGP session";
972 vty_out(vty
, "%% %s\n", str
);
973 return CMD_WARNING_CONFIG_FAILED
;
978 /* BGP clear sort. */
987 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
988 safi_t safi
, int error
)
991 case BGP_ERR_AF_UNCONFIGURED
:
994 "%% BGP: Enable %s address family for the neighbor %s\n",
995 get_afi_safi_str(afi
, safi
, false), peer
->host
);
998 "%% BGP: Enable %s address family for the neighbor %s",
999 get_afi_safi_str(afi
, safi
, false), peer
->host
);
1001 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
1004 "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
1008 "%% BGP: Inbound soft reconfig for %s not possible as it has neither refresh capability, nor inbound soft reconfig",
1016 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
1017 struct listnode
**nnode
, enum bgp_clear_type stype
)
1020 struct peer_af
*paf
;
1022 /* if afi/.safi not specified, spin thru all of them */
1023 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
1026 enum bgp_af_index index
;
1028 for (index
= BGP_AF_START
; index
< BGP_AF_MAX
; index
++) {
1029 paf
= peer
->peer_af_array
[index
];
1033 if (paf
&& paf
->subgroup
)
1034 SET_FLAG(paf
->subgroup
->sflags
,
1035 SUBGRP_STATUS_FORCE_UPDATES
);
1038 tmp_safi
= paf
->safi
;
1039 if (!peer
->afc
[tmp_afi
][tmp_safi
])
1042 if (stype
== BGP_CLEAR_SOFT_NONE
)
1043 ret
= peer_clear(peer
, nnode
);
1045 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
1048 /* if afi specified and safi not, spin thru safis on this afi */
1049 } else if (safi
== SAFI_UNSPEC
) {
1052 for (tmp_safi
= SAFI_UNICAST
;
1053 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
1054 if (!peer
->afc
[afi
][tmp_safi
])
1057 paf
= peer_af_find(peer
, afi
, tmp_safi
);
1058 if (paf
&& paf
->subgroup
)
1059 SET_FLAG(paf
->subgroup
->sflags
,
1060 SUBGRP_STATUS_FORCE_UPDATES
);
1062 if (stype
== BGP_CLEAR_SOFT_NONE
)
1063 ret
= peer_clear(peer
, nnode
);
1065 ret
= peer_clear_soft(peer
, afi
,
1068 /* both afi/safi specified, let the caller know if not defined */
1070 if (!peer
->afc
[afi
][safi
])
1073 paf
= peer_af_find(peer
, afi
, safi
);
1074 if (paf
&& paf
->subgroup
)
1075 SET_FLAG(paf
->subgroup
->sflags
,
1076 SUBGRP_STATUS_FORCE_UPDATES
);
1078 if (stype
== BGP_CLEAR_SOFT_NONE
)
1079 ret
= peer_clear(peer
, nnode
);
1081 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
1087 /* `clear ip bgp' functions. */
1088 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1089 enum clear_sort sort
, enum bgp_clear_type stype
,
1096 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
1098 /* Clear all neighbors. */
1100 * Pass along pointer to next node to peer_clear() when walking all
1101 * nodes on the BGP instance as that may get freed if it is a
1104 if (sort
== clear_all
) {
1105 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1107 bgp_peer_gr_flags_update(peer
);
1109 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1110 gr_router_detected
= true;
1112 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
1116 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1119 if (gr_router_detected
1120 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1121 bgp_zebra_send_capabilities(bgp
, false);
1122 } else if (!gr_router_detected
1123 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1124 bgp_zebra_send_capabilities(bgp
, true);
1127 /* This is to apply read-only mode on this clear. */
1128 if (stype
== BGP_CLEAR_SOFT_NONE
)
1129 bgp
->update_delay_over
= 0;
1134 /* Clear specified neighbor. */
1135 if (sort
== clear_peer
) {
1138 /* Make sockunion for lookup. */
1139 ret
= str2sockunion(arg
, &su
);
1141 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1143 peer
= peer_lookup_by_hostname(bgp
, arg
);
1146 "Malformed address or name: %s\n",
1152 peer
= peer_lookup(bgp
, &su
);
1155 "%% BGP: Unknown neighbor - \"%s\"\n",
1161 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1162 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1164 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1166 /* if afi/safi not defined for this peer, let caller know */
1168 ret
= BGP_ERR_AF_UNCONFIGURED
;
1171 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1176 /* Clear all neighbors belonging to a specific peer-group. */
1177 if (sort
== clear_group
) {
1178 struct peer_group
*group
;
1180 group
= peer_group_lookup(bgp
, arg
);
1182 vty_out(vty
, "%% BGP: No such peer-group %s\n", arg
);
1186 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1187 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1190 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1197 "%% BGP: No %s peer belonging to peer-group %s is configured\n",
1198 get_afi_safi_str(afi
, safi
, false), arg
);
1203 /* Clear all external (eBGP) neighbors. */
1204 if (sort
== clear_external
) {
1205 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1206 if (peer
->sort
== BGP_PEER_IBGP
)
1209 bgp_peer_gr_flags_update(peer
);
1211 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1212 gr_router_detected
= true;
1214 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1217 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1222 if (gr_router_detected
1223 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1224 bgp_zebra_send_capabilities(bgp
, false);
1225 } else if (!gr_router_detected
1226 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1227 bgp_zebra_send_capabilities(bgp
, true);
1232 "%% BGP: No external %s peer is configured\n",
1233 get_afi_safi_str(afi
, safi
, false));
1238 /* Clear all neighbors belonging to a specific AS. */
1239 if (sort
== clear_as
) {
1240 as_t as
= strtoul(arg
, NULL
, 10);
1242 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1246 bgp_peer_gr_flags_update(peer
);
1248 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1249 gr_router_detected
= true;
1251 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1254 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
1259 if (gr_router_detected
1260 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1261 bgp_zebra_send_capabilities(bgp
, false);
1262 } else if (!gr_router_detected
1263 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1264 bgp_zebra_send_capabilities(bgp
, true);
1269 "%% BGP: No %s peer is configured with AS %s\n",
1270 get_afi_safi_str(afi
, safi
, false), arg
);
1278 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1279 safi_t safi
, enum clear_sort sort
,
1280 enum bgp_clear_type stype
, const char *arg
)
1284 /* BGP structure lookup. */
1286 bgp
= bgp_lookup_by_name(name
);
1288 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1292 bgp
= bgp_get_default();
1294 vty_out(vty
, "No BGP process is configured\n");
1299 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1302 /* clear soft inbound */
1303 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1308 FOREACH_AFI_SAFI (afi
, safi
)
1309 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1310 BGP_CLEAR_SOFT_IN
, NULL
);
1313 /* clear soft outbound */
1314 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1319 FOREACH_AFI_SAFI (afi
, safi
)
1320 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1321 BGP_CLEAR_SOFT_OUT
, NULL
);
1325 void bgp_clear_soft_in(struct bgp
*bgp
, afi_t afi
, safi_t safi
)
1327 bgp_clear(NULL
, bgp
, afi
, safi
, clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
1330 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
1331 uint64_t flag
, int set
)
1336 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
1338 return CMD_WARNING_CONFIG_FAILED
;
1341 * If 'neighbor <interface>', then this is for directly connected peers,
1342 * we should not accept disable-connected-check.
1344 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
1346 "%s is directly connected peer, cannot accept disable-connected-check\n",
1348 return CMD_WARNING_CONFIG_FAILED
;
1351 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
1352 peer_tx_shutdown_message_unset(peer
);
1355 ret
= peer_flag_set(peer
, flag
);
1357 ret
= peer_flag_unset(peer
, flag
);
1359 return bgp_vty_return(vty
, ret
);
1362 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint64_t flag
)
1364 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
1367 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
1370 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
1373 #include "bgpd/bgp_vty_clippy.c"
1375 DEFUN_HIDDEN (bgp_local_mac
,
1377 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1379 "Local MAC config\n"
1380 "VxLAN Network Identifier\n"
1384 "mac-mobility sequence\n"
1394 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1395 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1396 vty_out(vty
, "%% Malformed MAC address\n");
1399 memset(&ip
, 0, sizeof(ip
));
1400 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1402 bgp
= bgp_get_default();
1404 vty_out(vty
, "Default BGP instance is not there\n");
1408 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1411 vty_out(vty
, "Internal error\n");
1418 DEFUN_HIDDEN (no_bgp_local_mac
,
1419 no_bgp_local_mac_cmd
,
1420 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1423 "Local MAC config\n"
1424 "VxLAN Network Identifier\n"
1435 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1436 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1437 vty_out(vty
, "%% Malformed MAC address\n");
1440 memset(&ip
, 0, sizeof(ip
));
1442 bgp
= bgp_get_default();
1444 vty_out(vty
, "Default BGP instance is not there\n");
1448 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1450 vty_out(vty
, "Internal error\n");
1457 DEFUN (no_synchronization
,
1458 no_synchronization_cmd
,
1459 "no synchronization",
1461 "Perform IGP synchronization\n")
1466 DEFUN (no_auto_summary
,
1467 no_auto_summary_cmd
,
1470 "Enable automatic network number summarization\n")
1475 /* "router bgp" commands. */
1476 DEFUN_NOSH (router_bgp
,
1478 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1482 BGP_INSTANCE_HELP_STR
)
1485 int idx_view_vrf
= 3;
1491 const char *name
= NULL
;
1492 enum bgp_instance_type inst_type
;
1494 // "router bgp" without an ASN
1496 // Pending: Make VRF option available for ASN less config
1497 bgp
= bgp_get_default();
1500 vty_out(vty
, "%% No BGP process is configured\n");
1501 return CMD_WARNING_CONFIG_FAILED
;
1504 if (listcount(bm
->bgp
) > 1) {
1505 vty_out(vty
, "%% Please specify ASN and VRF\n");
1506 return CMD_WARNING_CONFIG_FAILED
;
1512 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1514 if (as
== BGP_PRIVATE_AS_MAX
|| as
== BGP_AS4_MAX
)
1515 vty_out(vty
, "Reserved AS used (%u|%u); AS is %u\n",
1516 BGP_PRIVATE_AS_MAX
, BGP_AS4_MAX
, as
);
1518 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1520 name
= argv
[idx_vrf
]->arg
;
1522 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1523 if (strmatch(name
, VRF_DEFAULT_NAME
))
1526 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1527 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1528 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1531 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1532 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1534 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1536 case BGP_ERR_AS_MISMATCH
:
1537 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1538 return CMD_WARNING_CONFIG_FAILED
;
1539 case BGP_ERR_INSTANCE_MISMATCH
:
1541 "BGP instance name and AS number mismatch\n");
1543 "BGP instance is already running; AS is %u\n",
1545 return CMD_WARNING_CONFIG_FAILED
;
1549 * If we just instantiated the default instance, complete
1550 * any pending VRF-VPN leaking that was configured via
1551 * earlier "router bgp X vrf FOO" blocks.
1553 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1554 vpn_leak_postchange_all();
1556 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1557 bgp_vpn_leak_export(bgp
);
1558 /* Pending: handle when user tries to change a view to vrf n vv.
1562 /* unset the auto created flag as the user config is now present */
1563 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1564 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1569 /* "no router bgp" commands. */
1570 DEFUN (no_router_bgp
,
1572 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1577 BGP_INSTANCE_HELP_STR
)
1583 const char *name
= NULL
;
1585 // "no router bgp" without an ASN
1587 // Pending: Make VRF option available for ASN less config
1588 bgp
= bgp_get_default();
1591 vty_out(vty
, "%% No BGP process is configured\n");
1592 return CMD_WARNING_CONFIG_FAILED
;
1595 if (listcount(bm
->bgp
) > 1) {
1596 vty_out(vty
, "%% Please specify ASN and VRF\n");
1597 return CMD_WARNING_CONFIG_FAILED
;
1601 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1603 return CMD_WARNING_CONFIG_FAILED
;
1606 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1609 name
= argv
[idx_vrf
]->arg
;
1610 if (strmatch(argv
[idx_vrf
- 1]->text
, "vrf")
1611 && strmatch(name
, VRF_DEFAULT_NAME
))
1615 /* Lookup bgp structure. */
1616 bgp
= bgp_lookup(as
, name
);
1618 vty_out(vty
, "%% Can't find BGP instance\n");
1619 return CMD_WARNING_CONFIG_FAILED
;
1623 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1625 return CMD_WARNING_CONFIG_FAILED
;
1628 /* Cannot delete default instance if vrf instances exist */
1629 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1630 struct listnode
*node
;
1631 struct bgp
*tmp_bgp
;
1633 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1634 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1636 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1637 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1638 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1639 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1640 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1641 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1642 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1643 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1644 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1645 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1646 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1647 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1648 (bgp
== bgp_get_evpn() &&
1649 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1650 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST
) ||
1651 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1652 BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP
) ||
1653 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1654 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST
) ||
1655 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1656 BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP
))) ||
1657 (hashcount(tmp_bgp
->vnihash
))) {
1659 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1660 return CMD_WARNING_CONFIG_FAILED
;
1671 /* bgp session-dscp */
1673 DEFPY (bgp_session_dscp
,
1674 bgp_session_dscp_cmd
,
1675 "bgp session-dscp (0-63)$dscp",
1677 "Override default (C6) bgp TCP session DSCP value\n"
1678 "Manually configured dscp parameter\n")
1680 bm
->tcp_dscp
= dscp
<< 2;
1685 DEFPY (no_bgp_session_dscp
,
1686 no_bgp_session_dscp_cmd
,
1687 "no bgp session-dscp [(0-63)]",
1690 "Override default (C6) bgp TCP session DSCP value\n"
1691 "Manually configured dscp parameter\n")
1693 bm
->tcp_dscp
= IPTOS_PREC_INTERNETCONTROL
;
1698 /* BGP router-id. */
1700 DEFPY (bgp_router_id
,
1702 "bgp router-id A.B.C.D",
1704 "Override configured router identifier\n"
1705 "Manually configured router identifier\n")
1707 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1708 bgp_router_id_static_set(bgp
, router_id
);
1712 DEFPY (no_bgp_router_id
,
1713 no_bgp_router_id_cmd
,
1714 "no bgp router-id [A.B.C.D]",
1717 "Override configured router identifier\n"
1718 "Manually configured router identifier\n")
1720 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1722 if (router_id_str
) {
1723 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1724 vty_out(vty
, "%% BGP router-id doesn't match\n");
1725 return CMD_WARNING_CONFIG_FAILED
;
1729 router_id
.s_addr
= 0;
1730 bgp_router_id_static_set(bgp
, router_id
);
1735 DEFPY(bgp_community_alias
, bgp_community_alias_cmd
,
1736 "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name",
1738 "Add community specific parameters\n"
1739 "Create an alias for a community\n"
1740 "Community (AA:BB or AA:BB:CC)\n"
1743 struct community_alias ca
= {};
1744 struct community_alias
*lookup_community
;
1745 struct community_alias
*lookup_alias
;
1746 struct community
*comm
;
1747 struct lcommunity
*lcomm
;
1748 uint8_t invalid
= 0;
1750 comm
= community_str2com(community
);
1753 community_free(&comm
);
1755 lcomm
= lcommunity_str2com(community
);
1758 lcommunity_free(&lcomm
);
1761 vty_out(vty
, "Invalid community format\n");
1765 strlcpy(ca
.community
, community
, sizeof(ca
.community
));
1766 strlcpy(ca
.alias
, alias_name
, sizeof(ca
.alias
));
1768 lookup_community
= bgp_ca_community_lookup(&ca
);
1769 lookup_alias
= bgp_ca_alias_lookup(&ca
);
1772 bgp_ca_alias_delete(&ca
);
1773 bgp_ca_community_delete(&ca
);
1776 /* Lookup if community hash table has an item
1777 * with the same alias name.
1779 strlcpy(ca
.community
, lookup_alias
->community
,
1780 sizeof(ca
.community
));
1781 if (bgp_ca_community_lookup(&ca
)) {
1783 "community (%s) already has this alias (%s)\n",
1784 lookup_alias
->community
,
1785 lookup_alias
->alias
);
1788 bgp_ca_alias_delete(&ca
);
1791 if (lookup_community
) {
1792 /* Lookup if alias hash table has an item
1793 * with the same community.
1795 strlcpy(ca
.alias
, lookup_community
->alias
,
1797 if (bgp_ca_alias_lookup(&ca
)) {
1799 "alias (%s) already has this community (%s)\n",
1800 lookup_community
->alias
,
1801 lookup_community
->community
);
1804 bgp_ca_community_delete(&ca
);
1807 bgp_ca_alias_insert(&ca
);
1808 bgp_ca_community_insert(&ca
);
1814 DEFPY (bgp_global_suppress_fib_pending
,
1815 bgp_global_suppress_fib_pending_cmd
,
1816 "[no] bgp suppress-fib-pending",
1819 "Advertise only routes that are programmed in kernel to peers globally\n")
1821 bm_wait_for_fib_set(!no
);
1826 DEFPY (bgp_suppress_fib_pending
,
1827 bgp_suppress_fib_pending_cmd
,
1828 "[no] bgp suppress-fib-pending",
1831 "Advertise only routes that are programmed in kernel to peers\n")
1833 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1835 bgp_suppress_fib_pending_set(bgp
, !no
);
1840 /* BGP Cluster ID. */
1841 DEFUN (bgp_cluster_id
,
1843 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1845 "Configure Route-Reflector Cluster-id\n"
1846 "Route-Reflector Cluster-id in IP address format\n"
1847 "Route-Reflector Cluster-id as 32 bit quantity\n")
1849 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1852 struct in_addr cluster
;
1854 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1856 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1857 return CMD_WARNING_CONFIG_FAILED
;
1860 bgp_cluster_id_set(bgp
, &cluster
);
1861 bgp_clear_star_soft_out(vty
, bgp
->name
);
1866 DEFUN (no_bgp_cluster_id
,
1867 no_bgp_cluster_id_cmd
,
1868 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1871 "Configure Route-Reflector Cluster-id\n"
1872 "Route-Reflector Cluster-id in IP address format\n"
1873 "Route-Reflector Cluster-id as 32 bit quantity\n")
1875 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1876 bgp_cluster_id_unset(bgp
);
1877 bgp_clear_star_soft_out(vty
, bgp
->name
);
1886 "Disable BGP route installation to RIB (Zebra)\n")
1888 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1890 "%% No-RIB option is already set, nothing to do here.\n");
1894 bgp_option_norib_set_runtime();
1899 DEFPY (no_bgp_norib
,
1904 "Disable BGP route installation to RIB (Zebra)\n")
1906 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1908 "%% No-RIB option is not set, nothing to do here.\n");
1912 bgp_option_norib_unset_runtime();
1917 DEFPY (no_bgp_send_extra_data
,
1918 no_bgp_send_extra_data_cmd
,
1919 "[no] bgp send-extra-data zebra",
1922 "Extra data to Zebra for display/use\n"
1926 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1928 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1933 DEFUN (bgp_confederation_identifier
,
1934 bgp_confederation_identifier_cmd
,
1935 "bgp confederation identifier (1-4294967295)",
1937 "AS confederation parameters\n"
1939 "Set routing domain confederation AS\n")
1941 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1945 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1947 bgp_confederation_id_set(bgp
, as
);
1952 DEFUN (no_bgp_confederation_identifier
,
1953 no_bgp_confederation_identifier_cmd
,
1954 "no bgp confederation identifier [(1-4294967295)]",
1957 "AS confederation parameters\n"
1959 "Set routing domain confederation AS\n")
1961 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1962 bgp_confederation_id_unset(bgp
);
1967 DEFUN (bgp_confederation_peers
,
1968 bgp_confederation_peers_cmd
,
1969 "bgp confederation peers (1-4294967295)...",
1971 "AS confederation parameters\n"
1972 "Peer ASs in BGP confederation\n"
1975 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1980 for (i
= idx_asn
; i
< argc
; i
++) {
1981 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1982 bgp_confederation_peers_add(bgp
, as
);
1987 DEFUN (no_bgp_confederation_peers
,
1988 no_bgp_confederation_peers_cmd
,
1989 "no bgp confederation peers (1-4294967295)...",
1992 "AS confederation parameters\n"
1993 "Peer ASs in BGP confederation\n"
1996 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2001 for (i
= idx_asn
; i
< argc
; i
++) {
2002 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
2004 bgp_confederation_peers_remove(bgp
, as
);
2010 * Central routine for maximum-paths configuration.
2011 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
2012 * @set: 1 for setting values, 0 for removing the max-paths config.
2014 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
2015 const char *mpaths
, uint16_t options
,
2018 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2019 uint16_t maxpaths
= 0;
2024 afi
= bgp_node_afi(vty
);
2025 safi
= bgp_node_safi(vty
);
2028 maxpaths
= strtol(mpaths
, NULL
, 10);
2029 if (maxpaths
> multipath_num
) {
2031 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
2032 maxpaths
, multipath_num
);
2033 return CMD_WARNING_CONFIG_FAILED
;
2035 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
2038 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
2042 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
2043 (set
== 1) ? "" : "un",
2044 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
2045 maxpaths
, afi
, safi
);
2046 return CMD_WARNING_CONFIG_FAILED
;
2049 bgp_recalculate_all_bestpaths(bgp
);
2054 DEFUN (bgp_maxmed_admin
,
2055 bgp_maxmed_admin_cmd
,
2056 "bgp max-med administrative ",
2058 "Advertise routes with max-med\n"
2059 "Administratively applied, for an indefinite period\n")
2061 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2063 bgp
->v_maxmed_admin
= 1;
2064 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2066 bgp_maxmed_update(bgp
);
2071 DEFUN (bgp_maxmed_admin_medv
,
2072 bgp_maxmed_admin_medv_cmd
,
2073 "bgp max-med administrative (0-4294967295)",
2075 "Advertise routes with max-med\n"
2076 "Administratively applied, for an indefinite period\n"
2077 "Max MED value to be used\n")
2079 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2082 bgp
->v_maxmed_admin
= 1;
2083 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2085 bgp_maxmed_update(bgp
);
2090 DEFUN (no_bgp_maxmed_admin
,
2091 no_bgp_maxmed_admin_cmd
,
2092 "no bgp max-med administrative [(0-4294967295)]",
2095 "Advertise routes with max-med\n"
2096 "Administratively applied, for an indefinite period\n"
2097 "Max MED value to be used\n")
2099 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2100 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
2101 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
2102 bgp_maxmed_update(bgp
);
2107 DEFUN (bgp_maxmed_onstartup
,
2108 bgp_maxmed_onstartup_cmd
,
2109 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
2111 "Advertise routes with max-med\n"
2112 "Effective on a startup\n"
2113 "Time (seconds) period for max-med\n"
2114 "Max MED value to be used\n")
2116 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2119 if (argv_find(argv
, argc
, "(5-86400)", &idx
))
2120 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2121 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2122 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2124 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2126 bgp_maxmed_update(bgp
);
2131 DEFUN (no_bgp_maxmed_onstartup
,
2132 no_bgp_maxmed_onstartup_cmd
,
2133 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
2136 "Advertise routes with max-med\n"
2137 "Effective on a startup\n"
2138 "Time (seconds) period for max-med\n"
2139 "Max MED value to be used\n")
2141 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2143 /* Cancel max-med onstartup if its on */
2144 if (bgp
->t_maxmed_onstartup
) {
2145 THREAD_OFF(bgp
->t_maxmed_onstartup
);
2146 bgp
->maxmed_onstartup_over
= 1;
2149 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
2150 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
2152 bgp_maxmed_update(bgp
);
2157 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
2158 uint16_t update_delay
,
2159 uint16_t establish_wait
)
2161 struct listnode
*node
, *nnode
;
2163 bool vrf_cfg
= false;
2166 * See if update-delay is set per-vrf and warn user to delete it
2167 * Note that we only need to check this if this is the first time
2168 * setting the global config.
2170 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
2171 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2172 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
2174 "%% update-delay configuration found in vrf %s\n",
2175 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
2185 "%%Failed: global update-delay config not permitted\n");
2189 if (!establish_wait
) { /* update-delay <delay> */
2190 bm
->v_update_delay
= update_delay
;
2191 bm
->v_establish_wait
= bm
->v_update_delay
;
2193 /* update-delay <delay> <establish-wait> */
2194 if (update_delay
< establish_wait
) {
2196 "%%Failed: update-delay less than the establish-wait!\n");
2197 return CMD_WARNING_CONFIG_FAILED
;
2200 bm
->v_update_delay
= update_delay
;
2201 bm
->v_establish_wait
= establish_wait
;
2204 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2205 bgp
->v_update_delay
= bm
->v_update_delay
;
2206 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2212 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
2214 struct listnode
*node
, *nnode
;
2217 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2218 bm
->v_establish_wait
= bm
->v_update_delay
;
2220 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2221 bgp
->v_update_delay
= bm
->v_update_delay
;
2222 bgp
->v_establish_wait
= bm
->v_establish_wait
;
2228 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2229 uint16_t establish_wait
)
2231 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2233 /* if configured globally, per-instance config is not allowed */
2234 if (bm
->v_update_delay
) {
2236 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2237 return CMD_WARNING_CONFIG_FAILED
;
2241 if (!establish_wait
) /* update-delay <delay> */
2243 bgp
->v_update_delay
= update_delay
;
2244 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2248 /* update-delay <delay> <establish-wait> */
2249 if (update_delay
< establish_wait
) {
2251 "%%Failed: update-delay less than the establish-wait!\n");
2252 return CMD_WARNING_CONFIG_FAILED
;
2255 bgp
->v_update_delay
= update_delay
;
2256 bgp
->v_establish_wait
= establish_wait
;
2261 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2263 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2265 /* If configured globally, cannot remove from one bgp instance */
2266 if (bm
->v_update_delay
) {
2268 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2269 return CMD_WARNING_CONFIG_FAILED
;
2271 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2272 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2277 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2279 /* If configured globally, no need to display per-instance value */
2280 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2281 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2282 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2283 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2288 /* Global update-delay configuration */
2289 DEFPY (bgp_global_update_delay
,
2290 bgp_global_update_delay_cmd
,
2291 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2293 "Force initial delay for best-path and updates for all bgp instances\n"
2294 "Max delay in seconds\n"
2295 "Establish wait in seconds\n")
2297 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2300 /* Global update-delay deconfiguration */
2301 DEFPY (no_bgp_global_update_delay
,
2302 no_bgp_global_update_delay_cmd
,
2303 "no bgp update-delay [(0-3600) [(1-3600)]]",
2306 "Force initial delay for best-path and updates\n"
2307 "Max delay in seconds\n"
2308 "Establish wait in seconds\n")
2310 return bgp_global_update_delay_deconfig_vty(vty
);
2313 /* Update-delay configuration */
2315 DEFPY (bgp_update_delay
,
2316 bgp_update_delay_cmd
,
2317 "update-delay (0-3600)$delay [(1-3600)$wait]",
2318 "Force initial delay for best-path and updates\n"
2319 "Max delay in seconds\n"
2320 "Establish wait in seconds\n")
2322 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2325 /* Update-delay deconfiguration */
2326 DEFPY (no_bgp_update_delay
,
2327 no_bgp_update_delay_cmd
,
2328 "no update-delay [(0-3600) [(1-3600)]]",
2330 "Force initial delay for best-path and updates\n"
2331 "Max delay in seconds\n"
2332 "Establish wait in seconds\n")
2334 return bgp_update_delay_deconfig_vty(vty
);
2338 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2341 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2343 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2344 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2349 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
2352 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2354 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2355 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2360 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2363 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2364 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2365 vty_out(vty
, " write-quanta %d\n", quanta
);
2368 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2371 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2372 if (quanta
!= BGP_READ_PACKET_MAX
)
2373 vty_out(vty
, " read-quanta %d\n", quanta
);
2376 /* Packet quanta configuration
2378 * XXX: The value set here controls the size of a stack buffer in the IO
2379 * thread. When changing these limits be careful to prevent stack overflow.
2381 * Furthermore, the maximums used here should correspond to
2382 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2384 DEFPY (bgp_wpkt_quanta
,
2385 bgp_wpkt_quanta_cmd
,
2386 "[no] write-quanta (1-64)$quanta",
2388 "How many packets to write to peer socket per run\n"
2389 "Number of packets\n")
2391 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
2394 DEFPY (bgp_rpkt_quanta
,
2395 bgp_rpkt_quanta_cmd
,
2396 "[no] read-quanta (1-10)$quanta",
2398 "How many packets to read from peer socket per I/O cycle\n"
2399 "Number of packets\n")
2401 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
2404 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2406 if (!bgp
->heuristic_coalesce
)
2407 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2410 /* BGP TCP keepalive */
2411 static void bgp_config_tcp_keepalive(struct vty
*vty
, struct bgp
*bgp
)
2413 if (bgp
->tcp_keepalive_idle
) {
2414 vty_out(vty
, " bgp tcp-keepalive %u %u %u\n",
2415 bgp
->tcp_keepalive_idle
, bgp
->tcp_keepalive_intvl
,
2416 bgp
->tcp_keepalive_probes
);
2420 DEFUN (bgp_coalesce_time
,
2421 bgp_coalesce_time_cmd
,
2422 "coalesce-time (0-4294967295)",
2423 "Subgroup coalesce timer\n"
2424 "Subgroup coalesce timer value (in ms)\n")
2426 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2430 bgp
->heuristic_coalesce
= false;
2432 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
2433 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
2438 DEFUN (no_bgp_coalesce_time
,
2439 no_bgp_coalesce_time_cmd
,
2440 "no coalesce-time (0-4294967295)",
2442 "Subgroup coalesce timer\n"
2443 "Subgroup coalesce timer value (in ms)\n")
2445 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2447 bgp
->heuristic_coalesce
= true;
2448 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
2452 /* Maximum-paths configuration */
2453 DEFUN (bgp_maxpaths
,
2455 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2456 "Forward packets over multiple paths\n"
2457 "Number of paths\n")
2460 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
2461 argv
[idx_number
]->arg
, 0, 1);
2464 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2465 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2466 "Forward packets over multiple paths\n"
2467 "Number of paths\n")
2469 DEFUN (bgp_maxpaths_ibgp
,
2470 bgp_maxpaths_ibgp_cmd
,
2471 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2472 "Forward packets over multiple paths\n"
2474 "Number of paths\n")
2477 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2478 argv
[idx_number
]->arg
, 0, 1);
2481 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2482 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2483 "Forward packets over multiple paths\n"
2485 "Number of paths\n")
2487 DEFUN (bgp_maxpaths_ibgp_cluster
,
2488 bgp_maxpaths_ibgp_cluster_cmd
,
2489 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2490 "Forward packets over multiple paths\n"
2493 "Match the cluster length\n")
2496 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2497 argv
[idx_number
]->arg
, true, 1);
2500 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2501 "maximum-paths ibgp " CMD_RANGE_STR(
2502 1, MULTIPATH_NUM
) " equal-cluster-length",
2503 "Forward packets over multiple paths\n"
2506 "Match the cluster length\n")
2508 DEFUN (no_bgp_maxpaths
,
2509 no_bgp_maxpaths_cmd
,
2510 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2512 "Forward packets over multiple paths\n"
2513 "Number of paths\n")
2515 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
2518 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2519 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2520 "Forward packets over multiple paths\n"
2521 "Number of paths\n")
2523 DEFUN (no_bgp_maxpaths_ibgp
,
2524 no_bgp_maxpaths_ibgp_cmd
,
2525 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2527 "Forward packets over multiple paths\n"
2530 "Match the cluster length\n")
2532 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
2535 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2536 "no maximum-paths ibgp [" CMD_RANGE_STR(
2537 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2539 "Forward packets over multiple paths\n"
2542 "Match the cluster length\n")
2544 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2545 afi_t afi
, safi_t safi
)
2547 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2548 vty_out(vty
, " maximum-paths %d\n",
2549 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2552 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2553 vty_out(vty
, " maximum-paths ibgp %d",
2554 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2555 if (bgp
->maxpaths
[afi
][safi
].same_clusterlen
)
2556 vty_out(vty
, " equal-cluster-length");
2565 "timers bgp (0-65535) (0-65535)",
2566 "Adjust routing timers\n"
2568 "Keepalive interval\n"
2571 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2573 int idx_number_2
= 3;
2574 unsigned long keepalive
= 0;
2575 unsigned long holdtime
= 0;
2577 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2578 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2580 /* Holdtime value check. */
2581 if (holdtime
< 3 && holdtime
!= 0) {
2583 "%% hold time value must be either 0 or greater than 3\n");
2584 return CMD_WARNING_CONFIG_FAILED
;
2587 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
,
2588 BGP_DEFAULT_DELAYOPEN
);
2593 DEFUN (no_bgp_timers
,
2595 "no timers bgp [(0-65535) (0-65535)]",
2597 "Adjust routing timers\n"
2599 "Keepalive interval\n"
2602 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2603 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
2604 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
2609 /* BGP minimum holdtime. */
2611 DEFUN(bgp_minimum_holdtime
, bgp_minimum_holdtime_cmd
,
2612 "bgp minimum-holdtime (1-65535)",
2613 "BGP specific commands\n"
2614 "BGP minimum holdtime\n"
2617 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2619 unsigned long min_holdtime
;
2621 min_holdtime
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2623 bgp
->default_min_holdtime
= min_holdtime
;
2628 DEFUN(no_bgp_minimum_holdtime
, no_bgp_minimum_holdtime_cmd
,
2629 "no bgp minimum-holdtime [(1-65535)]",
2631 "BGP specific commands\n"
2632 "BGP minimum holdtime\n"
2635 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2637 bgp
->default_min_holdtime
= 0;
2642 DEFPY(bgp_tcp_keepalive
, bgp_tcp_keepalive_cmd
,
2643 "bgp tcp-keepalive (1-65535)$idle (1-65535)$intvl (1-30)$probes",
2645 "TCP keepalive parameters\n"
2646 "TCP keepalive idle time (seconds)\n"
2647 "TCP keepalive interval (seconds)\n"
2648 "TCP keepalive maximum probes\n")
2650 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2652 bgp_tcp_keepalive_set(bgp
, (uint16_t)idle
, (uint16_t)intvl
,
2658 DEFPY(no_bgp_tcp_keepalive
, no_bgp_tcp_keepalive_cmd
,
2659 "no bgp tcp-keepalive [(1-65535) (1-65535) (1-30)]",
2662 "TCP keepalive parameters\n"
2663 "TCP keepalive idle time (seconds)\n"
2664 "TCP keepalive interval (seconds)\n"
2665 "TCP keepalive maximum probes\n")
2667 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2669 bgp_tcp_keepalive_unset(bgp
);
2674 DEFUN (bgp_client_to_client_reflection
,
2675 bgp_client_to_client_reflection_cmd
,
2676 "bgp client-to-client reflection",
2678 "Configure client to client route reflection\n"
2679 "reflection of routes allowed\n")
2681 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2682 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2683 bgp_clear_star_soft_out(vty
, bgp
->name
);
2688 DEFUN (no_bgp_client_to_client_reflection
,
2689 no_bgp_client_to_client_reflection_cmd
,
2690 "no bgp client-to-client reflection",
2693 "Configure client to client route reflection\n"
2694 "reflection of routes allowed\n")
2696 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2697 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2698 bgp_clear_star_soft_out(vty
, bgp
->name
);
2703 /* "bgp always-compare-med" configuration. */
2704 DEFUN (bgp_always_compare_med
,
2705 bgp_always_compare_med_cmd
,
2706 "bgp always-compare-med",
2708 "Allow comparing MED from different neighbors\n")
2710 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2711 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2712 bgp_recalculate_all_bestpaths(bgp
);
2717 DEFUN (no_bgp_always_compare_med
,
2718 no_bgp_always_compare_med_cmd
,
2719 "no bgp always-compare-med",
2722 "Allow comparing MED from different neighbors\n")
2724 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2725 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2726 bgp_recalculate_all_bestpaths(bgp
);
2732 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2733 "bgp ebgp-requires-policy",
2735 "Require in and out policy for eBGP peers (RFC8212)\n")
2737 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2738 SET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2742 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2743 "no bgp ebgp-requires-policy",
2746 "Require in and out policy for eBGP peers (RFC8212)\n")
2748 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2749 UNSET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2753 DEFUN(bgp_suppress_duplicates
, bgp_suppress_duplicates_cmd
,
2754 "bgp suppress-duplicates",
2756 "Suppress duplicate updates if the route actually not changed\n")
2758 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2759 SET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2763 DEFUN(no_bgp_suppress_duplicates
, no_bgp_suppress_duplicates_cmd
,
2764 "no bgp suppress-duplicates",
2767 "Suppress duplicate updates if the route actually not changed\n")
2769 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2770 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
2774 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2775 "bgp reject-as-sets",
2777 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2779 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2780 struct listnode
*node
, *nnode
;
2783 bgp
->reject_as_sets
= true;
2785 /* Reset existing BGP sessions to reject routes
2786 * with aspath containing AS_SET or AS_CONFED_SET.
2788 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2789 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2790 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2791 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2792 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2799 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2800 "no bgp reject-as-sets",
2803 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2805 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2806 struct listnode
*node
, *nnode
;
2809 bgp
->reject_as_sets
= false;
2811 /* Reset existing BGP sessions to reject routes
2812 * with aspath containing AS_SET or AS_CONFED_SET.
2814 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2815 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2816 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2817 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2818 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2825 /* "bgp deterministic-med" configuration. */
2826 DEFUN (bgp_deterministic_med
,
2827 bgp_deterministic_med_cmd
,
2828 "bgp deterministic-med",
2830 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2832 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2834 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2835 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2836 bgp_recalculate_all_bestpaths(bgp
);
2842 DEFUN (no_bgp_deterministic_med
,
2843 no_bgp_deterministic_med_cmd
,
2844 "no bgp deterministic-med",
2847 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2849 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2850 int bestpath_per_as_used
;
2854 struct listnode
*node
, *nnode
;
2856 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2857 bestpath_per_as_used
= 0;
2859 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2860 FOREACH_AFI_SAFI (afi
, safi
)
2861 if (bgp_addpath_dmed_required(
2862 peer
->addpath_type
[afi
][safi
])) {
2863 bestpath_per_as_used
= 1;
2867 if (bestpath_per_as_used
)
2871 if (bestpath_per_as_used
) {
2873 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2874 return CMD_WARNING_CONFIG_FAILED
;
2876 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2877 bgp_recalculate_all_bestpaths(bgp
);
2884 /* "bgp graceful-restart mode" configuration. */
2885 DEFUN (bgp_graceful_restart
,
2886 bgp_graceful_restart_cmd
,
2887 "bgp graceful-restart",
2892 int ret
= BGP_GR_FAILURE
;
2894 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2895 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2897 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2899 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2901 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2904 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2905 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2907 "Graceful restart configuration changed, reset all peers to take effect\n");
2908 return bgp_vty_return(vty
, ret
);
2911 DEFUN (no_bgp_graceful_restart
,
2912 no_bgp_graceful_restart_cmd
,
2913 "no bgp graceful-restart",
2919 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2921 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2922 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2924 int ret
= BGP_GR_FAILURE
;
2926 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2928 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2931 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2932 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2934 "Graceful restart configuration changed, reset all peers to take effect\n");
2936 return bgp_vty_return(vty
, ret
);
2939 DEFUN (bgp_graceful_restart_stalepath_time
,
2940 bgp_graceful_restart_stalepath_time_cmd
,
2941 "bgp graceful-restart stalepath-time (1-4095)",
2943 "Graceful restart capability parameters\n"
2944 "Set the max time to hold onto restarting peer's stale paths\n"
2945 "Delay value (seconds)\n")
2947 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2951 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2952 bgp
->stalepath_time
= stalepath
;
2956 DEFUN (bgp_graceful_restart_restart_time
,
2957 bgp_graceful_restart_restart_time_cmd
,
2958 "bgp graceful-restart restart-time (0-4095)",
2960 "Graceful restart capability parameters\n"
2961 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2962 "Delay value (seconds)\n")
2964 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2968 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2969 bgp
->restart_time
= restart
;
2973 DEFUN (bgp_graceful_restart_select_defer_time
,
2974 bgp_graceful_restart_select_defer_time_cmd
,
2975 "bgp graceful-restart select-defer-time (0-3600)",
2977 "Graceful restart capability parameters\n"
2978 "Set the time to defer the BGP route selection after restart\n"
2979 "Delay value (seconds, 0 - disable)\n")
2981 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2983 uint32_t defer_time
;
2985 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2986 bgp
->select_defer_time
= defer_time
;
2987 if (defer_time
== 0)
2988 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2990 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2995 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2996 no_bgp_graceful_restart_stalepath_time_cmd
,
2997 "no bgp graceful-restart stalepath-time [(1-4095)]",
3000 "Graceful restart capability parameters\n"
3001 "Set the max time to hold onto restarting peer's stale paths\n"
3002 "Delay value (seconds)\n")
3004 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3006 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
3010 DEFUN (no_bgp_graceful_restart_restart_time
,
3011 no_bgp_graceful_restart_restart_time_cmd
,
3012 "no bgp graceful-restart restart-time [(0-4095)]",
3015 "Graceful restart capability parameters\n"
3016 "Set the time to wait to delete stale routes before a BGP open message is received\n"
3017 "Delay value (seconds)\n")
3019 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3021 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
3025 DEFUN (no_bgp_graceful_restart_select_defer_time
,
3026 no_bgp_graceful_restart_select_defer_time_cmd
,
3027 "no bgp graceful-restart select-defer-time [(0-3600)]",
3030 "Graceful restart capability parameters\n"
3031 "Set the time to defer the BGP route selection after restart\n"
3032 "Delay value (seconds)\n")
3034 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3036 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
3037 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
3042 DEFUN (bgp_graceful_restart_preserve_fw
,
3043 bgp_graceful_restart_preserve_fw_cmd
,
3044 "bgp graceful-restart preserve-fw-state",
3046 "Graceful restart capability parameters\n"
3047 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
3049 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3050 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
3054 DEFUN (no_bgp_graceful_restart_preserve_fw
,
3055 no_bgp_graceful_restart_preserve_fw_cmd
,
3056 "no bgp graceful-restart preserve-fw-state",
3059 "Graceful restart capability parameters\n"
3060 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
3062 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3063 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
3067 DEFPY (bgp_graceful_restart_notification
,
3068 bgp_graceful_restart_notification_cmd
,
3069 "[no$no] bgp graceful-restart notification",
3072 "Graceful restart capability parameters\n"
3073 "Indicate Graceful Restart support for BGP NOTIFICATION messages\n")
3075 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3078 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3080 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
);
3085 DEFPY (bgp_administrative_reset
,
3086 bgp_administrative_reset_cmd
,
3087 "[no$no] bgp hard-administrative-reset",
3090 "Send Hard Reset CEASE Notification for 'Administrative Reset'\n")
3092 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3095 UNSET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3097 SET_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
);
3102 DEFUN (bgp_graceful_restart_disable
,
3103 bgp_graceful_restart_disable_cmd
,
3104 "bgp graceful-restart-disable",
3108 int ret
= BGP_GR_FAILURE
;
3110 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3112 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
3114 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3116 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
3118 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
3121 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3123 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
3125 "Graceful restart configuration changed, reset all peers to take effect\n");
3127 return bgp_vty_return(vty
, ret
);
3130 DEFUN (no_bgp_graceful_restart_disable
,
3131 no_bgp_graceful_restart_disable_cmd
,
3132 "no bgp graceful-restart-disable",
3138 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3140 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3142 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
3144 int ret
= BGP_GR_FAILURE
;
3146 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
3148 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
3151 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3153 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
3155 "Graceful restart configuration changed, reset all peers to take effect\n");
3157 return bgp_vty_return(vty
, ret
);
3160 DEFUN (bgp_neighbor_graceful_restart_set
,
3161 bgp_neighbor_graceful_restart_set_cmd
,
3162 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3170 int ret
= BGP_GR_FAILURE
;
3172 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3174 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3176 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
3178 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3180 return CMD_WARNING_CONFIG_FAILED
;
3182 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
3184 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3185 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3187 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3189 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
3191 "Graceful restart configuration changed, reset this peer to take effect\n");
3193 return bgp_vty_return(vty
, ret
);
3196 DEFUN (no_bgp_neighbor_graceful_restart
,
3197 no_bgp_neighbor_graceful_restart_set_cmd
,
3198 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3206 int ret
= BGP_GR_FAILURE
;
3209 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3211 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3213 return CMD_WARNING_CONFIG_FAILED
;
3215 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3217 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3219 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
3221 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3222 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3224 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3226 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3228 "Graceful restart configuration changed, reset this peer to take effect\n");
3230 return bgp_vty_return(vty
, ret
);
3233 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3234 bgp_neighbor_graceful_restart_helper_set_cmd
,
3235 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3238 GR_NEIGHBOR_HELPER_CMD
3243 int ret
= BGP_GR_FAILURE
;
3245 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3247 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3249 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3251 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3254 return CMD_WARNING_CONFIG_FAILED
;
3257 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3259 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3260 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3262 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3264 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3266 "Graceful restart configuration changed, reset this peer to take effect\n");
3268 return bgp_vty_return(vty
, ret
);
3271 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3272 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3273 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3277 NO_GR_NEIGHBOR_HELPER_CMD
3281 int ret
= BGP_GR_FAILURE
;
3284 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3286 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3288 return CMD_WARNING_CONFIG_FAILED
;
3290 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3292 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3294 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3296 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3297 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3299 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3301 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3303 "Graceful restart configuration changed, reset this peer to take effect\n");
3305 return bgp_vty_return(vty
, ret
);
3308 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3309 bgp_neighbor_graceful_restart_disable_set_cmd
,
3310 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3313 GR_NEIGHBOR_DISABLE_CMD
3318 int ret
= BGP_GR_FAILURE
;
3320 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3322 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3324 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3326 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3328 return CMD_WARNING_CONFIG_FAILED
;
3330 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3332 if (peer
->bgp
->t_startup
)
3333 bgp_peer_gr_flags_update(peer
);
3335 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3336 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3338 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3340 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3342 "Graceful restart configuration changed, reset this peer to take effect\n");
3344 return bgp_vty_return(vty
, ret
);
3347 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3348 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3349 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3353 NO_GR_NEIGHBOR_DISABLE_CMD
3357 int ret
= BGP_GR_FAILURE
;
3360 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3362 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3364 return CMD_WARNING_CONFIG_FAILED
;
3366 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3368 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3370 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3372 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3373 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3375 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3377 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3379 "Graceful restart configuration changed, reset this peer to take effect\n");
3381 return bgp_vty_return(vty
, ret
);
3384 DEFPY (neighbor_graceful_shutdown
,
3385 neighbor_graceful_shutdown_cmd
,
3386 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor graceful-shutdown",
3390 "Graceful shutdown\n")
3395 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3398 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
3400 return CMD_WARNING_CONFIG_FAILED
;
3403 ret
= peer_flag_unset_vty(vty
, neighbor
,
3404 PEER_FLAG_GRACEFUL_SHUTDOWN
);
3406 ret
= peer_flag_set_vty(vty
, neighbor
,
3407 PEER_FLAG_GRACEFUL_SHUTDOWN
);
3409 FOREACH_AFI_SAFI (afi
, safi
) {
3410 if (!peer
->afc
[afi
][safi
])
3413 bgp_clear(vty
, bgp
, afi
, safi
, clear_peer
, BGP_CLEAR_SOFT_IN
,
3420 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3421 bgp_graceful_restart_disable_eor_cmd
,
3422 "bgp graceful-restart disable-eor",
3424 "Graceful restart configuration parameters\n"
3425 "Disable EOR Check\n")
3427 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3428 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3433 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3434 no_bgp_graceful_restart_disable_eor_cmd
,
3435 "no bgp graceful-restart disable-eor",
3438 "Graceful restart configuration parameters\n"
3439 "Disable EOR Check\n")
3441 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3442 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3447 DEFUN (bgp_graceful_restart_rib_stale_time
,
3448 bgp_graceful_restart_rib_stale_time_cmd
,
3449 "bgp graceful-restart rib-stale-time (1-3600)",
3451 "Graceful restart configuration parameters\n"
3452 "Specify the stale route removal timer in rib\n"
3453 "Delay value (seconds)\n")
3455 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3457 uint32_t stale_time
;
3459 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3460 bgp
->rib_stale_time
= stale_time
;
3461 /* Send the stale timer update message to RIB */
3462 if (bgp_zebra_stale_timer_update(bgp
))
3468 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3469 no_bgp_graceful_restart_rib_stale_time_cmd
,
3470 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3473 "Graceful restart configuration parameters\n"
3474 "Specify the stale route removal timer in rib\n"
3475 "Delay value (seconds)\n")
3477 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3479 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3480 /* Send the stale timer update message to RIB */
3481 if (bgp_zebra_stale_timer_update(bgp
))
3487 DEFUN(bgp_llgr_stalepath_time
, bgp_llgr_stalepath_time_cmd
,
3488 "bgp long-lived-graceful-restart stale-time (1-16777215)",
3490 "Enable Long-lived Graceful Restart\n"
3491 "Specifies maximum time to wait before purging long-lived stale routes\n"
3492 "Stale time value (seconds)\n")
3494 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3496 uint32_t llgr_stale_time
;
3498 llgr_stale_time
= strtoul(argv
[3]->arg
, NULL
, 10);
3499 bgp
->llgr_stale_time
= llgr_stale_time
;
3504 DEFUN(no_bgp_llgr_stalepath_time
, no_bgp_llgr_stalepath_time_cmd
,
3505 "no bgp long-lived-graceful-restart stale-time [(1-16777215)]",
3507 "Enable Long-lived Graceful Restart\n"
3508 "Specifies maximum time to wait before purging long-lived stale routes\n"
3509 "Stale time value (seconds)\n")
3511 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3513 bgp
->llgr_stale_time
= BGP_DEFAULT_LLGR_STALE_TIME
;
3518 static inline void bgp_initiate_graceful_shut_unshut(struct vty
*vty
,
3521 bgp_static_redo_import_check(bgp
);
3522 bgp_redistribute_redo(bgp
);
3523 bgp_clear_star_soft_out(vty
, bgp
->name
);
3524 bgp_clear_star_soft_in(vty
, bgp
->name
);
3527 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3529 struct listnode
*node
, *nnode
;
3531 bool vrf_cfg
= false;
3533 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3536 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3537 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3538 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3540 "%% graceful-shutdown configuration found in vrf %s\n",
3541 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3542 VRF_DEFAULT_NAME
: bgp
->name
);
3549 "%%Failed: global graceful-shutdown not permitted\n");
3553 /* Set flag globally */
3554 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3556 /* Initiate processing for all BGP instances. */
3557 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3558 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3563 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3565 struct listnode
*node
, *nnode
;
3568 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3571 /* Unset flag globally */
3572 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3574 /* Initiate processing for all BGP instances. */
3575 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
3576 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3581 /* "bgp graceful-shutdown" configuration */
3582 DEFUN (bgp_graceful_shutdown
,
3583 bgp_graceful_shutdown_cmd
,
3584 "bgp graceful-shutdown",
3586 "Graceful shutdown parameters\n")
3588 if (vty
->node
== CONFIG_NODE
)
3589 return bgp_global_graceful_shutdown_config_vty(vty
);
3591 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3593 /* if configured globally, per-instance config is not allowed */
3594 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3596 "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n");
3597 return CMD_WARNING_CONFIG_FAILED
;
3600 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3601 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3602 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3608 DEFUN (no_bgp_graceful_shutdown
,
3609 no_bgp_graceful_shutdown_cmd
,
3610 "no bgp graceful-shutdown",
3613 "Graceful shutdown parameters\n")
3615 if (vty
->node
== CONFIG_NODE
)
3616 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3618 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3620 /* If configured globally, cannot remove from one bgp instance */
3621 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
)) {
3623 "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n");
3624 return CMD_WARNING_CONFIG_FAILED
;
3627 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3628 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
3629 bgp_initiate_graceful_shut_unshut(vty
, bgp
);
3635 /* "bgp fast-external-failover" configuration. */
3636 DEFUN (bgp_fast_external_failover
,
3637 bgp_fast_external_failover_cmd
,
3638 "bgp fast-external-failover",
3640 "Immediately reset session if a link to a directly connected external peer goes down\n")
3642 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3643 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3647 DEFUN (no_bgp_fast_external_failover
,
3648 no_bgp_fast_external_failover_cmd
,
3649 "no bgp fast-external-failover",
3652 "Immediately reset session if a link to a directly connected external peer goes down\n")
3654 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3655 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
3659 DEFPY (bgp_bestpath_aigp
,
3660 bgp_bestpath_aigp_cmd
,
3661 "[no$no] bgp bestpath aigp",
3664 "Change the default bestpath selection\n"
3665 "Evaluate the AIGP attribute during the best path selection process\n")
3667 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3670 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_AIGP
);
3672 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_AIGP
);
3674 bgp_recalculate_all_bestpaths(bgp
);
3679 /* "bgp bestpath compare-routerid" configuration. */
3680 DEFUN (bgp_bestpath_compare_router_id
,
3681 bgp_bestpath_compare_router_id_cmd
,
3682 "bgp bestpath compare-routerid",
3684 "Change the default bestpath selection\n"
3685 "Compare router-id for identical EBGP paths\n")
3687 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3688 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3689 bgp_recalculate_all_bestpaths(bgp
);
3694 DEFUN (no_bgp_bestpath_compare_router_id
,
3695 no_bgp_bestpath_compare_router_id_cmd
,
3696 "no bgp bestpath compare-routerid",
3699 "Change the default bestpath selection\n"
3700 "Compare router-id for identical EBGP paths\n")
3702 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3703 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
3704 bgp_recalculate_all_bestpaths(bgp
);
3709 /* "bgp bestpath as-path ignore" configuration. */
3710 DEFUN (bgp_bestpath_aspath_ignore
,
3711 bgp_bestpath_aspath_ignore_cmd
,
3712 "bgp bestpath as-path ignore",
3714 "Change the default bestpath selection\n"
3715 "AS-path attribute\n"
3716 "Ignore as-path length in selecting a route\n")
3718 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3719 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3720 bgp_recalculate_all_bestpaths(bgp
);
3725 DEFUN (no_bgp_bestpath_aspath_ignore
,
3726 no_bgp_bestpath_aspath_ignore_cmd
,
3727 "no bgp bestpath as-path ignore",
3730 "Change the default bestpath selection\n"
3731 "AS-path attribute\n"
3732 "Ignore as-path length in selecting a route\n")
3734 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3735 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
3736 bgp_recalculate_all_bestpaths(bgp
);
3741 /* "bgp bestpath as-path confed" configuration. */
3742 DEFUN (bgp_bestpath_aspath_confed
,
3743 bgp_bestpath_aspath_confed_cmd
,
3744 "bgp bestpath as-path confed",
3746 "Change the default bestpath selection\n"
3747 "AS-path attribute\n"
3748 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3750 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3751 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3752 bgp_recalculate_all_bestpaths(bgp
);
3757 DEFUN (no_bgp_bestpath_aspath_confed
,
3758 no_bgp_bestpath_aspath_confed_cmd
,
3759 "no bgp bestpath as-path confed",
3762 "Change the default bestpath selection\n"
3763 "AS-path attribute\n"
3764 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3766 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3767 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
3768 bgp_recalculate_all_bestpaths(bgp
);
3773 /* "bgp bestpath as-path multipath-relax" configuration. */
3774 DEFUN (bgp_bestpath_aspath_multipath_relax
,
3775 bgp_bestpath_aspath_multipath_relax_cmd
,
3776 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3778 "Change the default bestpath selection\n"
3779 "AS-path attribute\n"
3780 "Allow load sharing across routes that have different AS paths (but same length)\n"
3781 "Generate an AS_SET\n"
3782 "Do not generate an AS_SET\n")
3784 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3786 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3788 /* no-as-set is now the default behavior so we can silently
3790 if (argv_find(argv
, argc
, "as-set", &idx
))
3791 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3793 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3795 bgp_recalculate_all_bestpaths(bgp
);
3800 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
3801 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3802 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3805 "Change the default bestpath selection\n"
3806 "AS-path attribute\n"
3807 "Allow load sharing across routes that have different AS paths (but same length)\n"
3808 "Generate an AS_SET\n"
3809 "Do not generate an AS_SET\n")
3811 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3812 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
3813 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
3814 bgp_recalculate_all_bestpaths(bgp
);
3819 /* "bgp bestpath peer-type multipath-relax" configuration. */
3820 DEFUN(bgp_bestpath_peer_type_multipath_relax
,
3821 bgp_bestpath_peer_type_multipath_relax_cmd
,
3822 "bgp bestpath peer-type multipath-relax",
3824 "Change the default bestpath selection\n"
3826 "Allow load sharing across routes learned from different peer types\n")
3828 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3829 SET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3830 bgp_recalculate_all_bestpaths(bgp
);
3835 DEFUN(no_bgp_bestpath_peer_type_multipath_relax
,
3836 no_bgp_bestpath_peer_type_multipath_relax_cmd
,
3837 "no bgp bestpath peer-type multipath-relax",
3839 "Change the default bestpath selection\n"
3841 "Allow load sharing across routes learned from different peer types\n")
3843 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3844 UNSET_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
);
3845 bgp_recalculate_all_bestpaths(bgp
);
3850 /* "bgp log-neighbor-changes" configuration. */
3851 DEFUN (bgp_log_neighbor_changes
,
3852 bgp_log_neighbor_changes_cmd
,
3853 "bgp log-neighbor-changes",
3855 "Log neighbor up/down and reset reason\n")
3857 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3858 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3862 DEFUN (no_bgp_log_neighbor_changes
,
3863 no_bgp_log_neighbor_changes_cmd
,
3864 "no bgp log-neighbor-changes",
3867 "Log neighbor up/down and reset reason\n")
3869 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3870 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
3874 /* "bgp bestpath med" configuration. */
3875 DEFUN (bgp_bestpath_med
,
3876 bgp_bestpath_med_cmd
,
3877 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3879 "Change the default bestpath selection\n"
3881 "Compare MED among confederation paths\n"
3882 "Treat missing MED as the least preferred one\n"
3883 "Treat missing MED as the least preferred one\n"
3884 "Compare MED among confederation paths\n")
3886 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3889 if (argv_find(argv
, argc
, "confed", &idx
))
3890 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3892 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3893 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3895 bgp_recalculate_all_bestpaths(bgp
);
3900 DEFUN (no_bgp_bestpath_med
,
3901 no_bgp_bestpath_med_cmd
,
3902 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3905 "Change the default bestpath selection\n"
3907 "Compare MED among confederation paths\n"
3908 "Treat missing MED as the least preferred one\n"
3909 "Treat missing MED as the least preferred one\n"
3910 "Compare MED among confederation paths\n")
3912 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3915 if (argv_find(argv
, argc
, "confed", &idx
))
3916 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
3918 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3919 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
3921 bgp_recalculate_all_bestpaths(bgp
);
3926 /* "bgp bestpath bandwidth" configuration. */
3927 DEFPY (bgp_bestpath_bw
,
3928 bgp_bestpath_bw_cmd
,
3929 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3931 "Change the default bestpath selection\n"
3932 "Link Bandwidth attribute\n"
3933 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3934 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3935 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3937 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3942 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3943 return CMD_ERR_INCOMPLETE
;
3945 if (!strcmp(bw_cfg
, "ignore"))
3946 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3947 else if (!strcmp(bw_cfg
, "skip-missing"))
3948 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3949 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3950 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3952 return CMD_ERR_NO_MATCH
;
3954 /* This config is used in route install, so redo that. */
3955 FOREACH_AFI_SAFI (afi
, safi
) {
3956 if (!bgp_fibupd_safi(safi
))
3958 bgp_zebra_announce_table(bgp
, afi
, safi
);
3964 DEFPY (no_bgp_bestpath_bw
,
3965 no_bgp_bestpath_bw_cmd
,
3966 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3969 "Change the default bestpath selection\n"
3970 "Link Bandwidth attribute\n"
3971 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3972 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3973 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3975 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3979 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3981 /* This config is used in route install, so redo that. */
3982 FOREACH_AFI_SAFI (afi
, safi
) {
3983 if (!bgp_fibupd_safi(safi
))
3985 bgp_zebra_announce_table(bgp
, afi
, safi
);
3990 DEFPY(bgp_default_afi_safi
, bgp_default_afi_safi_cmd
,
3991 "[no] bgp default <ipv4-unicast|"
3994 "ipv4-labeled-unicast|"
3999 "ipv6-labeled-unicast|"
4001 "l2vpn-evpn>$afi_safi",
4004 "Configure BGP defaults\n"
4005 "Activate ipv4-unicast for a peer by default\n"
4006 "Activate ipv4-multicast for a peer by default\n"
4007 "Activate ipv4-vpn for a peer by default\n"
4008 "Activate ipv4-labeled-unicast for a peer by default\n"
4009 "Activate ipv4-flowspec for a peer by default\n"
4010 "Activate ipv6-unicast for a peer by default\n"
4011 "Activate ipv6-multicast for a peer by default\n"
4012 "Activate ipv6-vpn for a peer by default\n"
4013 "Activate ipv6-labeled-unicast for a peer by default\n"
4014 "Activate ipv6-flowspec for a peer by default\n"
4015 "Activate l2vpn-evpn for a peer by default\n")
4017 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4018 char afi_safi_str
[strlen(afi_safi
) + 1];
4019 char *afi_safi_str_tok
;
4021 strlcpy(afi_safi_str
, afi_safi
, sizeof(afi_safi_str
));
4022 char *afi_str
= strtok_r(afi_safi_str
, "-", &afi_safi_str_tok
);
4023 char *safi_str
= strtok_r(NULL
, "-", &afi_safi_str_tok
);
4024 afi_t afi
= bgp_vty_afi_from_str(afi_str
);
4028 * Impossible situation but making coverity happy
4030 assert(afi
!= AFI_MAX
);
4032 if (strmatch(safi_str
, "labeled"))
4033 safi
= bgp_vty_safi_from_str("labeled-unicast");
4035 safi
= bgp_vty_safi_from_str(safi_str
);
4037 assert(safi
!= SAFI_MAX
);
4039 bgp
->default_af
[afi
][safi
] = false;
4041 if ((safi
== SAFI_LABELED_UNICAST
4042 && bgp
->default_af
[afi
][SAFI_UNICAST
])
4043 || (safi
== SAFI_UNICAST
4044 && bgp
->default_af
[afi
][SAFI_LABELED_UNICAST
]))
4045 bgp_vty_return(vty
, BGP_ERR_PEER_SAFI_CONFLICT
);
4047 bgp
->default_af
[afi
][safi
] = true;
4053 /* Display hostname in certain command outputs */
4054 DEFUN (bgp_default_show_hostname
,
4055 bgp_default_show_hostname_cmd
,
4056 "bgp default show-hostname",
4058 "Configure BGP defaults\n"
4059 "Show hostname in certain command outputs\n")
4061 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4062 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
4066 DEFUN (no_bgp_default_show_hostname
,
4067 no_bgp_default_show_hostname_cmd
,
4068 "no bgp default show-hostname",
4071 "Configure BGP defaults\n"
4072 "Show hostname in certain command outputs\n")
4074 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4075 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
4079 /* Display hostname in certain command outputs */
4080 DEFUN (bgp_default_show_nexthop_hostname
,
4081 bgp_default_show_nexthop_hostname_cmd
,
4082 "bgp default show-nexthop-hostname",
4084 "Configure BGP defaults\n"
4085 "Show hostname for nexthop in certain command outputs\n")
4087 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4088 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
4092 DEFUN (no_bgp_default_show_nexthop_hostname
,
4093 no_bgp_default_show_nexthop_hostname_cmd
,
4094 "no bgp default show-nexthop-hostname",
4097 "Configure BGP defaults\n"
4098 "Show hostname for nexthop in certain command outputs\n")
4100 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4101 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
4105 /* "bgp network import-check" configuration. */
4106 DEFUN (bgp_network_import_check
,
4107 bgp_network_import_check_cmd
,
4108 "bgp network import-check",
4110 "BGP network command\n"
4111 "Check BGP network route exists in IGP\n")
4113 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4114 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4115 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4116 bgp_static_redo_import_check(bgp
);
4122 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
4123 "bgp network import-check exact",
4125 "BGP network command\n"
4126 "Check BGP network route exists in IGP\n"
4127 "Match route precisely\n")
4129 DEFUN (no_bgp_network_import_check
,
4130 no_bgp_network_import_check_cmd
,
4131 "no bgp network import-check",
4134 "BGP network command\n"
4135 "Check BGP network route exists in IGP\n")
4137 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4138 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
4139 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
4140 bgp_static_redo_import_check(bgp
);
4146 DEFUN (bgp_default_local_preference
,
4147 bgp_default_local_preference_cmd
,
4148 "bgp default local-preference (0-4294967295)",
4150 "Configure BGP defaults\n"
4151 "local preference (higher=more preferred)\n"
4152 "Configure default local preference value\n")
4154 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4156 uint32_t local_pref
;
4158 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4160 bgp_default_local_preference_set(bgp
, local_pref
);
4161 bgp_clear_star_soft_in(vty
, bgp
->name
);
4166 DEFUN (no_bgp_default_local_preference
,
4167 no_bgp_default_local_preference_cmd
,
4168 "no bgp default local-preference [(0-4294967295)]",
4171 "Configure BGP defaults\n"
4172 "local preference (higher=more preferred)\n"
4173 "Configure default local preference value\n")
4175 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4176 bgp_default_local_preference_unset(bgp
);
4177 bgp_clear_star_soft_in(vty
, bgp
->name
);
4183 DEFUN (bgp_default_subgroup_pkt_queue_max
,
4184 bgp_default_subgroup_pkt_queue_max_cmd
,
4185 "bgp default subgroup-pkt-queue-max (20-100)",
4187 "Configure BGP defaults\n"
4188 "subgroup-pkt-queue-max\n"
4189 "Configure subgroup packet queue max\n")
4191 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4195 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4197 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
4202 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
4203 no_bgp_default_subgroup_pkt_queue_max_cmd
,
4204 "no bgp default subgroup-pkt-queue-max [(20-100)]",
4207 "Configure BGP defaults\n"
4208 "subgroup-pkt-queue-max\n"
4209 "Configure subgroup packet queue max\n")
4211 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4212 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
4217 DEFUN (bgp_rr_allow_outbound_policy
,
4218 bgp_rr_allow_outbound_policy_cmd
,
4219 "bgp route-reflector allow-outbound-policy",
4221 "Allow modifications made by out route-map\n"
4222 "on ibgp neighbors\n")
4224 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4226 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4227 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4228 update_group_announce_rrclients(bgp
);
4229 bgp_clear_star_soft_out(vty
, bgp
->name
);
4235 DEFUN (no_bgp_rr_allow_outbound_policy
,
4236 no_bgp_rr_allow_outbound_policy_cmd
,
4237 "no bgp route-reflector allow-outbound-policy",
4240 "Allow modifications made by out route-map\n"
4241 "on ibgp neighbors\n")
4243 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4245 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
4246 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
4247 update_group_announce_rrclients(bgp
);
4248 bgp_clear_star_soft_out(vty
, bgp
->name
);
4254 DEFUN (bgp_listen_limit
,
4255 bgp_listen_limit_cmd
,
4256 "bgp listen limit (1-65535)",
4258 "BGP Dynamic Neighbors listen commands\n"
4259 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4260 "Configure Dynamic Neighbors listen limit value\n")
4262 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4266 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4268 bgp_listen_limit_set(bgp
, listen_limit
);
4273 DEFUN (no_bgp_listen_limit
,
4274 no_bgp_listen_limit_cmd
,
4275 "no bgp listen limit [(1-65535)]",
4278 "BGP Dynamic Neighbors listen commands\n"
4279 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4280 "Configure Dynamic Neighbors listen limit value\n")
4282 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4283 bgp_listen_limit_unset(bgp
);
4289 * Check if this listen range is already configured. Check for exact
4290 * match or overlap based on input.
4292 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4293 struct prefix
*range
, int exact
)
4295 struct listnode
*node
, *nnode
;
4296 struct listnode
*node1
, *nnode1
;
4297 struct peer_group
*group
;
4302 afi
= family2afi(range
->family
);
4303 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4304 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4307 match
= prefix_same(range
, lr
);
4309 match
= (prefix_match(range
, lr
)
4310 || prefix_match(lr
, range
));
4319 DEFUN (bgp_listen_range
,
4320 bgp_listen_range_cmd
,
4321 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4323 "Configure BGP dynamic neighbors listen range\n"
4324 "Configure BGP dynamic neighbors listen range\n"
4326 "Member of the peer-group\n"
4327 "Peer-group name\n")
4329 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4330 struct prefix range
;
4331 struct peer_group
*group
, *existing_group
;
4336 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4337 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4338 char *prefix
= argv
[idx
]->arg
;
4339 argv_find(argv
, argc
, "PGNAME", &idx
);
4340 char *peergroup
= argv
[idx
]->arg
;
4342 /* Convert IP prefix string to struct prefix. */
4343 ret
= str2prefix(prefix
, &range
);
4345 vty_out(vty
, "%% Malformed listen range\n");
4346 return CMD_WARNING_CONFIG_FAILED
;
4349 afi
= family2afi(range
.family
);
4351 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4353 "%% Malformed listen range (link-local address)\n");
4354 return CMD_WARNING_CONFIG_FAILED
;
4359 /* Check if same listen range is already configured. */
4360 existing_group
= listen_range_exists(bgp
, &range
, 1);
4361 if (existing_group
) {
4362 if (strcmp(existing_group
->name
, peergroup
) == 0)
4366 "%% Same listen range is attached to peer-group %s\n",
4367 existing_group
->name
);
4368 return CMD_WARNING_CONFIG_FAILED
;
4372 /* Check if an overlapping listen range exists. */
4373 if (listen_range_exists(bgp
, &range
, 0)) {
4375 "%% Listen range overlaps with existing listen range\n");
4376 return CMD_WARNING_CONFIG_FAILED
;
4379 group
= peer_group_lookup(bgp
, peergroup
);
4381 vty_out(vty
, "%% Configure the peer-group first\n");
4382 return CMD_WARNING_CONFIG_FAILED
;
4385 ret
= peer_group_listen_range_add(group
, &range
);
4386 return bgp_vty_return(vty
, ret
);
4389 DEFUN (no_bgp_listen_range
,
4390 no_bgp_listen_range_cmd
,
4391 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4394 "Unconfigure BGP dynamic neighbors listen range\n"
4395 "Unconfigure BGP dynamic neighbors listen range\n"
4397 "Member of the peer-group\n"
4398 "Peer-group name\n")
4400 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4401 struct prefix range
;
4402 struct peer_group
*group
;
4407 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4408 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4409 char *prefix
= argv
[idx
]->arg
;
4410 argv_find(argv
, argc
, "PGNAME", &idx
);
4411 char *peergroup
= argv
[idx
]->arg
;
4413 /* Convert IP prefix string to struct prefix. */
4414 ret
= str2prefix(prefix
, &range
);
4416 vty_out(vty
, "%% Malformed listen range\n");
4417 return CMD_WARNING_CONFIG_FAILED
;
4420 afi
= family2afi(range
.family
);
4422 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4424 "%% Malformed listen range (link-local address)\n");
4425 return CMD_WARNING_CONFIG_FAILED
;
4430 group
= peer_group_lookup(bgp
, peergroup
);
4432 vty_out(vty
, "%% Peer-group does not exist\n");
4433 return CMD_WARNING_CONFIG_FAILED
;
4436 ret
= peer_group_listen_range_del(group
, &range
);
4437 return bgp_vty_return(vty
, ret
);
4440 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4442 struct peer_group
*group
;
4443 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4444 struct prefix
*range
;
4447 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4448 vty_out(vty
, " bgp listen limit %d\n",
4449 bgp
->dynamic_neighbors_limit
);
4451 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4452 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4453 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4456 " bgp listen range %pFX peer-group %s\n",
4457 range
, group
->name
);
4464 DEFUN (bgp_disable_connected_route_check
,
4465 bgp_disable_connected_route_check_cmd
,
4466 "bgp disable-ebgp-connected-route-check",
4468 "Disable checking if nexthop is connected on ebgp sessions\n")
4470 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4471 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4472 bgp_clear_star_soft_in(vty
, bgp
->name
);
4477 DEFUN (no_bgp_disable_connected_route_check
,
4478 no_bgp_disable_connected_route_check_cmd
,
4479 "no bgp disable-ebgp-connected-route-check",
4482 "Disable checking if nexthop is connected on ebgp sessions\n")
4484 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4485 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
4486 bgp_clear_star_soft_in(vty
, bgp
->name
);
4492 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
4495 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4498 int as_type
= AS_SPECIFIED
;
4501 if (as_str
[0] == 'i') {
4503 as_type
= AS_INTERNAL
;
4504 } else if (as_str
[0] == 'e') {
4506 as_type
= AS_EXTERNAL
;
4508 /* Get AS number. */
4509 as
= strtoul(as_str
, NULL
, 10);
4512 /* If peer is peer group or interface peer, call proper function. */
4513 ret
= str2sockunion(peer_str
, &su
);
4517 /* Check if existing interface peer */
4518 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
4520 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
);
4522 /* if not interface peer, check peer-group settings */
4523 if (ret
< 0 && !peer
) {
4524 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
4527 "%% Create the peer-group or interface first\n");
4528 return CMD_WARNING_CONFIG_FAILED
;
4533 if (peer_address_self_check(bgp
, &su
)) {
4535 "%% Can not configure the local system as neighbor\n");
4536 return CMD_WARNING_CONFIG_FAILED
;
4538 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
);
4541 return bgp_vty_return(vty
, ret
);
4544 DEFUN (bgp_default_shutdown
,
4545 bgp_default_shutdown_cmd
,
4546 "[no] bgp default shutdown",
4549 "Configure BGP defaults\n"
4550 "Apply administrative shutdown to newly configured peers\n")
4552 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4553 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
4557 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4559 "Administrative shutdown of the BGP instance\n"
4560 "Add a shutdown message (RFC 8203)\n"
4561 "Shutdown message\n")
4563 char *msgstr
= NULL
;
4565 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4568 msgstr
= argv_concat(argv
, argc
, 3);
4570 if (msgstr
&& strlen(msgstr
) > BGP_ADMIN_SHUTDOWN_MSG_LEN
) {
4571 vty_out(vty
, "%% Shutdown message size exceeded %d\n",
4572 BGP_ADMIN_SHUTDOWN_MSG_LEN
);
4573 return CMD_WARNING_CONFIG_FAILED
;
4576 bgp_shutdown_enable(bgp
, msgstr
);
4577 XFREE(MTYPE_TMP
, msgstr
);
4582 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4583 BGP_STR
"Administrative shutdown of the BGP instance\n")
4585 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4587 bgp_shutdown_enable(bgp
, NULL
);
4592 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4593 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4595 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4597 bgp_shutdown_disable(bgp
);
4602 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4603 "no bgp shutdown message MSG...", NO_STR BGP_STR
4604 "Administrative shutdown of the BGP instance\n"
4605 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4607 DEFUN (neighbor_remote_as
,
4608 neighbor_remote_as_cmd
,
4609 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4612 "Specify a BGP neighbor\n"
4614 "Internal BGP peer\n"
4615 "External BGP peer\n")
4618 int idx_remote_as
= 3;
4619 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
4620 argv
[idx_remote_as
]->arg
);
4623 DEFPY (bgp_allow_martian
,
4624 bgp_allow_martian_cmd
,
4625 "[no]$no bgp allow-martian-nexthop",
4628 "Allow Martian nexthops to be received in the NLRI from a peer\n")
4630 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4633 bgp
->allow_martian
= false;
4635 bgp
->allow_martian
= true;
4640 /* Enable fast convergence of bgp sessions. If this is enabled, bgp
4641 * sessions do not wait for hold timer expiry to bring down the sessions
4642 * when nexthop becomes unreachable
4644 DEFUN(bgp_fast_convergence
, bgp_fast_convergence_cmd
, "bgp fast-convergence",
4645 BGP_STR
"Fast convergence for bgp sessions\n")
4647 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4648 bgp
->fast_convergence
= true;
4653 DEFUN(no_bgp_fast_convergence
, no_bgp_fast_convergence_cmd
,
4654 "no bgp fast-convergence",
4655 NO_STR BGP_STR
"Fast convergence for bgp sessions\n")
4657 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4658 bgp
->fast_convergence
= false;
4663 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
4665 const char *peer_group_name
,
4668 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4670 int as_type
= AS_UNSPECIFIED
;
4672 struct peer_group
*group
;
4675 group
= peer_group_lookup(bgp
, conf_if
);
4678 vty_out(vty
, "%% Name conflict with peer-group \n");
4679 return CMD_WARNING_CONFIG_FAILED
;
4683 if (as_str
[0] == 'i') {
4684 as_type
= AS_INTERNAL
;
4685 } else if (as_str
[0] == 'e') {
4686 as_type
= AS_EXTERNAL
;
4688 /* Get AS number. */
4689 as
= strtoul(as_str
, NULL
, 10);
4690 as_type
= AS_SPECIFIED
;
4694 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4697 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4699 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4703 vty_out(vty
, "%% BGP failed to create peer\n");
4704 return CMD_WARNING_CONFIG_FAILED
;
4708 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4710 /* Request zebra to initiate IPv6 RAs on this interface. We do
4712 * any unnumbered peer in order to not worry about run-time
4714 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4716 * gets deleted later etc.)
4719 bgp_zebra_initiate_radv(bgp
, peer
);
4722 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4723 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4725 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4727 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4729 /* v6only flag changed. Reset bgp seesion */
4730 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4731 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4732 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4733 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4735 bgp_session_reset(peer
);
4738 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4739 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4740 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4741 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4744 if (peer_group_name
) {
4745 group
= peer_group_lookup(bgp
, peer_group_name
);
4747 vty_out(vty
, "%% Configure the peer-group first\n");
4748 return CMD_WARNING_CONFIG_FAILED
;
4751 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4754 return bgp_vty_return(vty
, ret
);
4757 DEFUN (neighbor_interface_config
,
4758 neighbor_interface_config_cmd
,
4759 "neighbor WORD interface [peer-group PGNAME]",
4761 "Interface name or neighbor tag\n"
4762 "Enable BGP on interface\n"
4763 "Member of the peer-group\n"
4764 "Peer-group name\n")
4767 int idx_peer_group_word
= 4;
4769 if (argc
> idx_peer_group_word
)
4770 return peer_conf_interface_get(
4771 vty
, argv
[idx_word
]->arg
, 0,
4772 argv
[idx_peer_group_word
]->arg
, NULL
);
4774 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0,
4778 DEFUN (neighbor_interface_config_v6only
,
4779 neighbor_interface_config_v6only_cmd
,
4780 "neighbor WORD interface v6only [peer-group PGNAME]",
4782 "Interface name or neighbor tag\n"
4783 "Enable BGP on interface\n"
4784 "Enable BGP with v6 link-local only\n"
4785 "Member of the peer-group\n"
4786 "Peer-group name\n")
4789 int idx_peer_group_word
= 5;
4791 if (argc
> idx_peer_group_word
)
4792 return peer_conf_interface_get(
4793 vty
, argv
[idx_word
]->arg
, 1,
4794 argv
[idx_peer_group_word
]->arg
, NULL
);
4796 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
, NULL
);
4800 DEFUN (neighbor_interface_config_remote_as
,
4801 neighbor_interface_config_remote_as_cmd
,
4802 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4804 "Interface name or neighbor tag\n"
4805 "Enable BGP on interface\n"
4806 "Specify a BGP neighbor\n"
4808 "Internal BGP peer\n"
4809 "External BGP peer\n")
4812 int idx_remote_as
= 4;
4813 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 0, NULL
,
4814 argv
[idx_remote_as
]->arg
);
4817 DEFUN (neighbor_interface_v6only_config_remote_as
,
4818 neighbor_interface_v6only_config_remote_as_cmd
,
4819 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4821 "Interface name or neighbor tag\n"
4822 "Enable BGP with v6 link-local only\n"
4823 "Enable BGP on interface\n"
4824 "Specify a BGP neighbor\n"
4826 "Internal BGP peer\n"
4827 "External BGP peer\n")
4830 int idx_remote_as
= 5;
4831 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, 1, NULL
,
4832 argv
[idx_remote_as
]->arg
);
4835 DEFUN (neighbor_peer_group
,
4836 neighbor_peer_group_cmd
,
4837 "neighbor WORD peer-group",
4839 "Interface name or neighbor tag\n"
4840 "Configure peer-group\n")
4842 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4845 struct peer_group
*group
;
4847 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4849 vty_out(vty
, "%% Name conflict with interface: \n");
4850 return CMD_WARNING_CONFIG_FAILED
;
4853 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
4855 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
4856 return CMD_WARNING_CONFIG_FAILED
;
4864 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4868 "Specify a BGP neighbor\n"
4870 "Internal BGP peer\n"
4871 "External BGP peer\n")
4873 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4877 struct peer_group
*group
;
4881 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4883 /* look up for neighbor by interface name config. */
4884 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4886 /* Request zebra to terminate IPv6 RAs on this
4889 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4890 peer_notify_unconfig(peer
);
4895 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
4897 peer_group_notify_unconfig(group
);
4898 peer_group_delete(group
);
4900 vty_out(vty
, "%% Create the peer-group first\n");
4901 return CMD_WARNING_CONFIG_FAILED
;
4904 peer
= peer_lookup(bgp
, &su
);
4906 if (peer_dynamic_neighbor(peer
)) {
4908 "%% Operation not allowed on a dynamic neighbor\n");
4909 return CMD_WARNING_CONFIG_FAILED
;
4912 other
= peer
->doppelganger
;
4914 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4915 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4917 peer_notify_unconfig(peer
);
4919 if (other
&& other
->status
!= Deleted
) {
4920 peer_notify_unconfig(other
);
4929 DEFUN (no_neighbor_interface_config
,
4930 no_neighbor_interface_config_cmd
,
4931 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4935 "Configure BGP on interface\n"
4936 "Enable BGP with v6 link-local only\n"
4937 "Member of the peer-group\n"
4939 "Specify a BGP neighbor\n"
4941 "Internal BGP peer\n"
4942 "External BGP peer\n")
4944 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4948 /* look up for neighbor by interface name config. */
4949 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4951 /* Request zebra to terminate IPv6 RAs on this interface. */
4953 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4954 peer_notify_unconfig(peer
);
4957 vty_out(vty
, "%% Create the bgp interface first\n");
4958 return CMD_WARNING_CONFIG_FAILED
;
4963 DEFUN (no_neighbor_peer_group
,
4964 no_neighbor_peer_group_cmd
,
4965 "no neighbor WORD peer-group",
4969 "Configure peer-group\n")
4971 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4973 struct peer_group
*group
;
4975 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4977 peer_group_notify_unconfig(group
);
4978 peer_group_delete(group
);
4980 vty_out(vty
, "%% Create the peer-group first\n");
4981 return CMD_WARNING_CONFIG_FAILED
;
4986 DEFUN (no_neighbor_interface_peer_group_remote_as
,
4987 no_neighbor_interface_peer_group_remote_as_cmd
,
4988 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4991 "Interface name or neighbor tag\n"
4992 "Specify a BGP neighbor\n"
4994 "Internal BGP peer\n"
4995 "External BGP peer\n")
4997 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4999 struct peer_group
*group
;
5002 /* look up for neighbor by interface name config. */
5003 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
5005 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
5009 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5011 peer_group_remote_as_delete(group
);
5013 vty_out(vty
, "%% Create the peer-group or interface first\n");
5014 return CMD_WARNING_CONFIG_FAILED
;
5019 DEFUN (neighbor_local_as
,
5020 neighbor_local_as_cmd
,
5021 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
5024 "Specify a local-as number\n"
5025 "AS number used as local AS\n")
5033 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5035 return CMD_WARNING_CONFIG_FAILED
;
5037 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5038 ret
= peer_local_as_set(peer
, as
, 0, 0);
5039 return bgp_vty_return(vty
, ret
);
5042 DEFUN (neighbor_local_as_no_prepend
,
5043 neighbor_local_as_no_prepend_cmd
,
5044 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
5047 "Specify a local-as number\n"
5048 "AS number used as local AS\n"
5049 "Do not prepend local-as to updates from ebgp peers\n")
5057 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5059 return CMD_WARNING_CONFIG_FAILED
;
5061 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5062 ret
= peer_local_as_set(peer
, as
, 1, 0);
5063 return bgp_vty_return(vty
, ret
);
5066 DEFUN (neighbor_local_as_no_prepend_replace_as
,
5067 neighbor_local_as_no_prepend_replace_as_cmd
,
5068 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
5071 "Specify a local-as number\n"
5072 "AS number used as local AS\n"
5073 "Do not prepend local-as to updates from ebgp peers\n"
5074 "Do not prepend local-as to updates from ibgp peers\n")
5082 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5084 return CMD_WARNING_CONFIG_FAILED
;
5086 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5087 ret
= peer_local_as_set(peer
, as
, 1, 1);
5088 return bgp_vty_return(vty
, ret
);
5091 DEFUN (no_neighbor_local_as
,
5092 no_neighbor_local_as_cmd
,
5093 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
5097 "Specify a local-as number\n"
5098 "AS number used as local AS\n"
5099 "Do not prepend local-as to updates from ebgp peers\n"
5100 "Do not prepend local-as to updates from ibgp peers\n")
5106 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5108 return CMD_WARNING_CONFIG_FAILED
;
5110 ret
= peer_local_as_unset(peer
);
5111 return bgp_vty_return(vty
, ret
);
5115 DEFUN (neighbor_solo
,
5117 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5120 "Solo peer - part of its own update group\n")
5126 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5128 return CMD_WARNING_CONFIG_FAILED
;
5130 ret
= update_group_adjust_soloness(peer
, 1);
5131 return bgp_vty_return(vty
, ret
);
5134 DEFUN (no_neighbor_solo
,
5135 no_neighbor_solo_cmd
,
5136 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
5140 "Solo peer - part of its own update group\n")
5146 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5148 return CMD_WARNING_CONFIG_FAILED
;
5150 ret
= update_group_adjust_soloness(peer
, 0);
5151 return bgp_vty_return(vty
, ret
);
5154 DEFUN (neighbor_password
,
5155 neighbor_password_cmd
,
5156 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
5167 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5169 return CMD_WARNING_CONFIG_FAILED
;
5171 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
5172 return bgp_vty_return(vty
, ret
);
5175 DEFUN (no_neighbor_password
,
5176 no_neighbor_password_cmd
,
5177 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
5188 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5190 return CMD_WARNING_CONFIG_FAILED
;
5192 ret
= peer_password_unset(peer
);
5193 return bgp_vty_return(vty
, ret
);
5196 DEFUN (neighbor_activate
,
5197 neighbor_activate_cmd
,
5198 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5201 "Enable the Address Family for this Neighbor\n")
5207 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5209 return CMD_WARNING_CONFIG_FAILED
;
5211 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5212 return bgp_vty_return(vty
, ret
);
5215 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
5216 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5217 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5218 "Enable the Address Family for this Neighbor\n")
5220 DEFUN (no_neighbor_activate
,
5221 no_neighbor_activate_cmd
,
5222 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5226 "Enable the Address Family for this Neighbor\n")
5233 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5235 return CMD_WARNING_CONFIG_FAILED
;
5237 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
5238 return bgp_vty_return(vty
, ret
);
5241 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
5242 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
5243 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5244 "Enable the Address Family for this Neighbor\n")
5246 DEFUN (neighbor_set_peer_group
,
5247 neighbor_set_peer_group_cmd
,
5248 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5251 "Member of the peer-group\n"
5252 "Peer-group name\n")
5254 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5261 struct peer_group
*group
;
5263 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
5265 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
5267 vty_out(vty
, "%% Malformed address or name: %s\n",
5268 argv
[idx_peer
]->arg
);
5269 return CMD_WARNING_CONFIG_FAILED
;
5272 if (peer_address_self_check(bgp
, &su
)) {
5274 "%% Can not configure the local system as neighbor\n");
5275 return CMD_WARNING_CONFIG_FAILED
;
5278 /* Disallow for dynamic neighbor. */
5279 peer
= peer_lookup(bgp
, &su
);
5280 if (peer
&& peer_dynamic_neighbor(peer
)) {
5282 "%% Operation not allowed on a dynamic neighbor\n");
5283 return CMD_WARNING_CONFIG_FAILED
;
5287 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5289 vty_out(vty
, "%% Configure the peer-group first\n");
5290 return CMD_WARNING_CONFIG_FAILED
;
5293 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5295 return bgp_vty_return(vty
, ret
);
5298 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5299 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5300 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5301 "Member of the peer-group\n"
5302 "Peer-group name\n")
5304 DEFUN (no_neighbor_set_peer_group
,
5305 no_neighbor_set_peer_group_cmd
,
5306 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5310 "Member of the peer-group\n"
5311 "Peer-group name\n")
5313 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5318 struct peer_group
*group
;
5320 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5322 return CMD_WARNING_CONFIG_FAILED
;
5324 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5326 vty_out(vty
, "%% Configure the peer-group first\n");
5327 return CMD_WARNING_CONFIG_FAILED
;
5330 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
5331 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
5333 peer_notify_unconfig(peer
);
5334 ret
= peer_delete(peer
);
5336 return bgp_vty_return(vty
, ret
);
5339 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5340 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5341 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5342 "Member of the peer-group\n"
5343 "Peer-group name\n")
5345 /* neighbor passive. */
5346 DEFUN (neighbor_passive
,
5347 neighbor_passive_cmd
,
5348 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5351 "Don't send open messages to this neighbor\n")
5354 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5357 DEFUN (no_neighbor_passive
,
5358 no_neighbor_passive_cmd
,
5359 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5363 "Don't send open messages to this neighbor\n")
5366 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
5369 /* neighbor shutdown. */
5370 DEFUN (neighbor_shutdown_msg
,
5371 neighbor_shutdown_msg_cmd
,
5372 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5375 "Administratively shut down this neighbor\n"
5376 "Add a shutdown message (RFC 8203)\n"
5377 "Shutdown message\n")
5383 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5387 return CMD_WARNING_CONFIG_FAILED
;
5388 message
= argv_concat(argv
, argc
, 4);
5389 peer_tx_shutdown_message_set(peer
, message
);
5390 XFREE(MTYPE_TMP
, message
);
5393 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
5396 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5397 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5398 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5399 "Administratively shut down this neighbor\n")
5401 DEFUN (no_neighbor_shutdown_msg
,
5402 no_neighbor_shutdown_msg_cmd
,
5403 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5407 "Administratively shut down this neighbor\n"
5408 "Remove a shutdown message (RFC 8203)\n"
5409 "Shutdown message\n")
5413 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5414 PEER_FLAG_SHUTDOWN
);
5417 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5418 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5419 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5420 "Administratively shut down this neighbor\n")
5422 DEFUN(neighbor_shutdown_rtt
,
5423 neighbor_shutdown_rtt_cmd
,
5424 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5427 "Administratively shut down this neighbor\n"
5428 "Shutdown if round-trip-time is higher than expected\n"
5429 "Round-trip-time in milliseconds\n"
5430 "Specify the number of keepalives before shutdown\n"
5431 "The number of keepalives with higher RTT to shutdown\n")
5438 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5441 return CMD_WARNING_CONFIG_FAILED
;
5443 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5445 if (argv_find(argv
, argc
, "count", &idx_count
))
5446 peer
->rtt_keepalive_conf
=
5447 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5449 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5450 PEER_FLAG_RTT_SHUTDOWN
);
5453 DEFUN(no_neighbor_shutdown_rtt
,
5454 no_neighbor_shutdown_rtt_cmd
,
5455 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5459 "Administratively shut down this neighbor\n"
5460 "Shutdown if round-trip-time is higher than expected\n"
5461 "Round-trip-time in milliseconds\n"
5462 "Specify the number of keepalives before shutdown\n"
5463 "The number of keepalives with higher RTT to shutdown\n")
5468 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5471 return CMD_WARNING_CONFIG_FAILED
;
5473 peer
->rtt_expected
= 0;
5474 peer
->rtt_keepalive_conf
= 1;
5476 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5477 PEER_FLAG_RTT_SHUTDOWN
);
5480 /* neighbor capability dynamic. */
5481 DEFUN (neighbor_capability_dynamic
,
5482 neighbor_capability_dynamic_cmd
,
5483 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5486 "Advertise capability to the peer\n"
5487 "Advertise dynamic capability to this neighbor\n")
5490 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5491 PEER_FLAG_DYNAMIC_CAPABILITY
);
5494 DEFUN (no_neighbor_capability_dynamic
,
5495 no_neighbor_capability_dynamic_cmd
,
5496 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5500 "Advertise capability to the peer\n"
5501 "Advertise dynamic capability to this neighbor\n")
5504 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5505 PEER_FLAG_DYNAMIC_CAPABILITY
);
5508 /* neighbor dont-capability-negotiate */
5509 DEFUN (neighbor_dont_capability_negotiate
,
5510 neighbor_dont_capability_negotiate_cmd
,
5511 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5514 "Do not perform capability negotiation\n")
5517 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5518 PEER_FLAG_DONT_CAPABILITY
);
5521 DEFUN (no_neighbor_dont_capability_negotiate
,
5522 no_neighbor_dont_capability_negotiate_cmd
,
5523 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5527 "Do not perform capability negotiation\n")
5530 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5531 PEER_FLAG_DONT_CAPABILITY
);
5534 /* neighbor capability extended next hop encoding */
5535 DEFUN (neighbor_capability_enhe
,
5536 neighbor_capability_enhe_cmd
,
5537 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5540 "Advertise capability to the peer\n"
5541 "Advertise extended next-hop capability to the peer\n")
5546 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5547 if (peer
&& peer
->conf_if
)
5550 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5551 PEER_FLAG_CAPABILITY_ENHE
);
5554 DEFUN (no_neighbor_capability_enhe
,
5555 no_neighbor_capability_enhe_cmd
,
5556 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5560 "Advertise capability to the peer\n"
5561 "Advertise extended next-hop capability to the peer\n")
5566 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5567 if (peer
&& peer
->conf_if
) {
5569 "Peer %s cannot have capability extended-nexthop turned off\n",
5570 argv
[idx_peer
]->arg
);
5571 return CMD_WARNING_CONFIG_FAILED
;
5574 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5575 PEER_FLAG_CAPABILITY_ENHE
);
5578 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5579 afi_t afi
, safi_t safi
, uint32_t flag
,
5585 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5587 return CMD_WARNING_CONFIG_FAILED
;
5590 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5592 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5594 return bgp_vty_return(vty
, ret
);
5597 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5598 afi_t afi
, safi_t safi
, uint32_t flag
)
5600 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5603 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5604 afi_t afi
, safi_t safi
, uint32_t flag
)
5606 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5609 /* neighbor capability orf prefix-list. */
5610 DEFUN (neighbor_capability_orf_prefix
,
5611 neighbor_capability_orf_prefix_cmd
,
5612 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5615 "Advertise capability to the peer\n"
5616 "Advertise ORF capability to the peer\n"
5617 "Advertise prefixlist ORF capability to this neighbor\n"
5618 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5619 "Capability to RECEIVE the ORF from this neighbor\n"
5620 "Capability to SEND the ORF to this neighbor\n")
5622 int idx_send_recv
= 5;
5623 char *peer_str
= argv
[1]->arg
;
5625 afi_t afi
= bgp_node_afi(vty
);
5626 safi_t safi
= bgp_node_safi(vty
);
5628 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5630 return CMD_WARNING_CONFIG_FAILED
;
5632 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5633 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5634 PEER_FLAG_ORF_PREFIX_SM
);
5636 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5637 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5638 PEER_FLAG_ORF_PREFIX_RM
);
5640 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5641 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5642 PEER_FLAG_ORF_PREFIX_SM
)
5643 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5644 PEER_FLAG_ORF_PREFIX_RM
);
5646 return CMD_WARNING_CONFIG_FAILED
;
5650 neighbor_capability_orf_prefix
,
5651 neighbor_capability_orf_prefix_hidden_cmd
,
5652 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5653 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5654 "Advertise capability to the peer\n"
5655 "Advertise ORF capability to the peer\n"
5656 "Advertise prefixlist ORF capability to this neighbor\n"
5657 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5658 "Capability to RECEIVE the ORF from this neighbor\n"
5659 "Capability to SEND the ORF to this neighbor\n")
5661 DEFUN (no_neighbor_capability_orf_prefix
,
5662 no_neighbor_capability_orf_prefix_cmd
,
5663 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5667 "Advertise capability to the peer\n"
5668 "Advertise ORF capability to the peer\n"
5669 "Advertise prefixlist ORF capability to this neighbor\n"
5670 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5671 "Capability to RECEIVE the ORF from this neighbor\n"
5672 "Capability to SEND the ORF to this neighbor\n")
5674 int idx_send_recv
= 6;
5675 char *peer_str
= argv
[2]->arg
;
5677 afi_t afi
= bgp_node_afi(vty
);
5678 safi_t safi
= bgp_node_safi(vty
);
5680 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5682 return CMD_WARNING_CONFIG_FAILED
;
5684 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5685 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5686 PEER_FLAG_ORF_PREFIX_SM
);
5688 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5689 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5690 PEER_FLAG_ORF_PREFIX_RM
);
5692 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5693 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5694 PEER_FLAG_ORF_PREFIX_SM
)
5695 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5696 PEER_FLAG_ORF_PREFIX_RM
);
5698 return CMD_WARNING_CONFIG_FAILED
;
5702 no_neighbor_capability_orf_prefix
,
5703 no_neighbor_capability_orf_prefix_hidden_cmd
,
5704 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5705 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5706 "Advertise capability to the peer\n"
5707 "Advertise ORF capability to the peer\n"
5708 "Advertise prefixlist ORF capability to this neighbor\n"
5709 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5710 "Capability to RECEIVE the ORF from this neighbor\n"
5711 "Capability to SEND the ORF to this neighbor\n")
5713 /* neighbor next-hop-self. */
5714 DEFUN (neighbor_nexthop_self
,
5715 neighbor_nexthop_self_cmd
,
5716 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5719 "Disable the next hop calculation for this neighbor\n")
5722 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5723 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
5726 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5727 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5728 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5729 "Disable the next hop calculation for this neighbor\n")
5731 /* neighbor next-hop-self. */
5732 DEFUN (neighbor_nexthop_self_force
,
5733 neighbor_nexthop_self_force_cmd
,
5734 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5737 "Disable the next hop calculation for this neighbor\n"
5738 "Set the next hop to self for reflected routes\n")
5741 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5743 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5746 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5747 neighbor_nexthop_self_force_hidden_cmd
,
5748 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5749 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5750 "Disable the next hop calculation for this neighbor\n"
5751 "Set the next hop to self for reflected routes\n")
5753 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5754 neighbor_nexthop_self_all_hidden_cmd
,
5755 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5756 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5757 "Disable the next hop calculation for this neighbor\n"
5758 "Set the next hop to self for reflected routes\n")
5760 DEFUN (no_neighbor_nexthop_self
,
5761 no_neighbor_nexthop_self_cmd
,
5762 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5766 "Disable the next hop calculation for this neighbor\n")
5769 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5770 bgp_node_afi(vty
), bgp_node_safi(vty
),
5771 PEER_FLAG_NEXTHOP_SELF
);
5774 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5775 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5776 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5777 "Disable the next hop calculation for this neighbor\n")
5779 DEFUN (no_neighbor_nexthop_self_force
,
5780 no_neighbor_nexthop_self_force_cmd
,
5781 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5785 "Disable the next hop calculation for this neighbor\n"
5786 "Set the next hop to self for reflected routes\n")
5789 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5790 bgp_node_afi(vty
), bgp_node_safi(vty
),
5791 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5794 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5795 no_neighbor_nexthop_self_force_hidden_cmd
,
5796 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5797 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5798 "Disable the next hop calculation for this neighbor\n"
5799 "Set the next hop to self for reflected routes\n")
5801 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5802 no_neighbor_nexthop_self_all_hidden_cmd
,
5803 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5804 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5805 "Disable the next hop calculation for this neighbor\n"
5806 "Set the next hop to self for reflected routes\n")
5808 /* neighbor as-override */
5809 DEFUN (neighbor_as_override
,
5810 neighbor_as_override_cmd
,
5811 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5814 "Override ASNs in outbound updates if aspath equals remote-as\n")
5817 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5818 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
5821 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5822 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5823 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5824 "Override ASNs in outbound updates if aspath equals remote-as\n")
5826 DEFUN (no_neighbor_as_override
,
5827 no_neighbor_as_override_cmd
,
5828 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5832 "Override ASNs in outbound updates if aspath equals remote-as\n")
5835 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5836 bgp_node_afi(vty
), bgp_node_safi(vty
),
5837 PEER_FLAG_AS_OVERRIDE
);
5840 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5841 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5842 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5843 "Override ASNs in outbound updates if aspath equals remote-as\n")
5845 /* neighbor remove-private-AS. */
5846 DEFUN (neighbor_remove_private_as
,
5847 neighbor_remove_private_as_cmd
,
5848 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5851 "Remove private ASNs in outbound updates\n")
5854 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5856 PEER_FLAG_REMOVE_PRIVATE_AS
);
5859 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5860 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5861 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5862 "Remove private ASNs in outbound updates\n")
5864 DEFUN (neighbor_remove_private_as_all
,
5865 neighbor_remove_private_as_all_cmd
,
5866 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5869 "Remove private ASNs in outbound updates\n"
5870 "Apply to all AS numbers\n")
5873 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5875 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5878 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5879 neighbor_remove_private_as_all_hidden_cmd
,
5880 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5881 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5882 "Remove private ASNs in outbound updates\n"
5883 "Apply to all AS numbers\n")
5885 DEFUN (neighbor_remove_private_as_replace_as
,
5886 neighbor_remove_private_as_replace_as_cmd
,
5887 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5890 "Remove private ASNs in outbound updates\n"
5891 "Replace private ASNs with our ASN in outbound updates\n")
5894 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5896 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5899 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5900 neighbor_remove_private_as_replace_as_hidden_cmd
,
5901 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5902 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5903 "Remove private ASNs in outbound updates\n"
5904 "Replace private ASNs with our ASN in outbound updates\n")
5906 DEFUN (neighbor_remove_private_as_all_replace_as
,
5907 neighbor_remove_private_as_all_replace_as_cmd
,
5908 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5911 "Remove private ASNs in outbound updates\n"
5912 "Apply to all AS numbers\n"
5913 "Replace private ASNs with our ASN in outbound updates\n")
5916 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5918 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5922 neighbor_remove_private_as_all_replace_as
,
5923 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5924 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5925 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5926 "Remove private ASNs in outbound updates\n"
5927 "Apply to all AS numbers\n"
5928 "Replace private ASNs with our ASN in outbound updates\n")
5930 DEFUN (no_neighbor_remove_private_as
,
5931 no_neighbor_remove_private_as_cmd
,
5932 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5936 "Remove private ASNs in outbound updates\n")
5939 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5940 bgp_node_afi(vty
), bgp_node_safi(vty
),
5941 PEER_FLAG_REMOVE_PRIVATE_AS
);
5944 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5945 no_neighbor_remove_private_as_hidden_cmd
,
5946 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5947 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5948 "Remove private ASNs in outbound updates\n")
5950 DEFUN (no_neighbor_remove_private_as_all
,
5951 no_neighbor_remove_private_as_all_cmd
,
5952 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5956 "Remove private ASNs in outbound updates\n"
5957 "Apply to all AS numbers\n")
5960 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5961 bgp_node_afi(vty
), bgp_node_safi(vty
),
5962 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5965 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5966 no_neighbor_remove_private_as_all_hidden_cmd
,
5967 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5968 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5969 "Remove private ASNs in outbound updates\n"
5970 "Apply to all AS numbers\n")
5972 DEFUN (no_neighbor_remove_private_as_replace_as
,
5973 no_neighbor_remove_private_as_replace_as_cmd
,
5974 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5978 "Remove private ASNs in outbound updates\n"
5979 "Replace private ASNs with our ASN in outbound updates\n")
5982 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5983 bgp_node_afi(vty
), bgp_node_safi(vty
),
5984 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5987 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
5988 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
5989 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5990 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5991 "Remove private ASNs in outbound updates\n"
5992 "Replace private ASNs with our ASN in outbound updates\n")
5994 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
5995 no_neighbor_remove_private_as_all_replace_as_cmd
,
5996 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6000 "Remove private ASNs in outbound updates\n"
6001 "Apply to all AS numbers\n"
6002 "Replace private ASNs with our ASN in outbound updates\n")
6005 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6006 bgp_node_afi(vty
), bgp_node_safi(vty
),
6007 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
6011 no_neighbor_remove_private_as_all_replace_as
,
6012 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
6013 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6014 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6015 "Remove private ASNs in outbound updates\n"
6016 "Apply to all AS numbers\n"
6017 "Replace private ASNs with our ASN in outbound updates\n")
6020 /* neighbor send-community. */
6021 DEFUN (neighbor_send_community
,
6022 neighbor_send_community_cmd
,
6023 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6026 "Send Community attribute to this neighbor\n")
6030 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6032 PEER_FLAG_SEND_COMMUNITY
);
6035 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
6036 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6037 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6038 "Send Community attribute to this neighbor\n")
6040 DEFUN (no_neighbor_send_community
,
6041 no_neighbor_send_community_cmd
,
6042 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6046 "Send Community attribute to this neighbor\n")
6050 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6051 bgp_node_afi(vty
), bgp_node_safi(vty
),
6052 PEER_FLAG_SEND_COMMUNITY
);
6055 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
6056 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6057 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6058 "Send Community attribute to this neighbor\n")
6060 /* neighbor send-community extended. */
6061 DEFUN (neighbor_send_community_type
,
6062 neighbor_send_community_type_cmd
,
6063 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6066 "Send Community attribute to this neighbor\n"
6067 "Send Standard and Extended Community attributes\n"
6068 "Send Standard, Large and Extended Community attributes\n"
6069 "Send Extended Community attributes\n"
6070 "Send Standard Community attributes\n"
6071 "Send Large Community attributes\n")
6073 const char *type
= argv
[argc
- 1]->text
;
6074 char *peer_str
= argv
[1]->arg
;
6076 afi_t afi
= bgp_node_afi(vty
);
6077 safi_t safi
= bgp_node_safi(vty
);
6079 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6081 return CMD_WARNING_CONFIG_FAILED
;
6083 if (strmatch(type
, "standard"))
6084 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6085 PEER_FLAG_SEND_COMMUNITY
);
6087 if (strmatch(type
, "extended"))
6088 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6089 PEER_FLAG_SEND_EXT_COMMUNITY
);
6091 if (strmatch(type
, "large"))
6092 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6093 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6095 if (strmatch(type
, "both")) {
6096 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6097 PEER_FLAG_SEND_COMMUNITY
)
6098 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6099 PEER_FLAG_SEND_EXT_COMMUNITY
);
6101 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6102 PEER_FLAG_SEND_COMMUNITY
)
6103 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6104 PEER_FLAG_SEND_EXT_COMMUNITY
)
6105 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6106 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6110 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6111 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6112 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6113 "Send Community attribute to this neighbor\n"
6114 "Send Standard and Extended Community attributes\n"
6115 "Send Standard, Large and Extended Community attributes\n"
6116 "Send Extended Community attributes\n"
6117 "Send Standard Community attributes\n"
6118 "Send Large Community attributes\n")
6120 DEFUN (no_neighbor_send_community_type
,
6121 no_neighbor_send_community_type_cmd
,
6122 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6126 "Send Community attribute to this neighbor\n"
6127 "Send Standard and Extended Community attributes\n"
6128 "Send Standard, Large and Extended Community attributes\n"
6129 "Send Extended Community attributes\n"
6130 "Send Standard Community attributes\n"
6131 "Send Large Community attributes\n")
6133 const char *type
= argv
[argc
- 1]->text
;
6134 char *peer_str
= argv
[2]->arg
;
6136 afi_t afi
= bgp_node_afi(vty
);
6137 safi_t safi
= bgp_node_safi(vty
);
6139 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6141 return CMD_WARNING_CONFIG_FAILED
;
6143 if (strmatch(type
, "standard"))
6144 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6145 PEER_FLAG_SEND_COMMUNITY
);
6147 if (strmatch(type
, "extended"))
6148 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6149 PEER_FLAG_SEND_EXT_COMMUNITY
);
6151 if (strmatch(type
, "large"))
6152 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6153 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6155 if (strmatch(type
, "both")) {
6157 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6158 PEER_FLAG_SEND_COMMUNITY
)
6159 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6160 PEER_FLAG_SEND_EXT_COMMUNITY
);
6163 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6164 PEER_FLAG_SEND_COMMUNITY
)
6165 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6166 PEER_FLAG_SEND_EXT_COMMUNITY
)
6167 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6168 PEER_FLAG_SEND_LARGE_COMMUNITY
);
6172 no_neighbor_send_community_type
,
6173 no_neighbor_send_community_type_hidden_cmd
,
6174 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6175 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6176 "Send Community attribute to this neighbor\n"
6177 "Send Standard and Extended Community attributes\n"
6178 "Send Standard, Large and Extended Community attributes\n"
6179 "Send Extended Community attributes\n"
6180 "Send Standard Community attributes\n"
6181 "Send Large Community attributes\n")
6183 /* neighbor soft-reconfig. */
6184 DEFUN (neighbor_soft_reconfiguration
,
6185 neighbor_soft_reconfiguration_cmd
,
6186 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6189 "Per neighbor soft reconfiguration\n"
6190 "Allow inbound soft reconfiguration for this neighbor\n")
6193 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6195 PEER_FLAG_SOFT_RECONFIG
);
6198 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6199 neighbor_soft_reconfiguration_hidden_cmd
,
6200 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6201 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6202 "Per neighbor soft reconfiguration\n"
6203 "Allow inbound soft reconfiguration for this neighbor\n")
6205 DEFUN (no_neighbor_soft_reconfiguration
,
6206 no_neighbor_soft_reconfiguration_cmd
,
6207 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6211 "Per neighbor soft reconfiguration\n"
6212 "Allow inbound soft reconfiguration for this neighbor\n")
6215 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6216 bgp_node_afi(vty
), bgp_node_safi(vty
),
6217 PEER_FLAG_SOFT_RECONFIG
);
6220 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6221 no_neighbor_soft_reconfiguration_hidden_cmd
,
6222 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6223 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6224 "Per neighbor soft reconfiguration\n"
6225 "Allow inbound soft reconfiguration for this neighbor\n")
6227 DEFUN (neighbor_route_reflector_client
,
6228 neighbor_route_reflector_client_cmd
,
6229 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6232 "Configure a neighbor as Route Reflector client\n")
6238 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6240 return CMD_WARNING_CONFIG_FAILED
;
6242 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6244 PEER_FLAG_REFLECTOR_CLIENT
);
6247 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6248 neighbor_route_reflector_client_hidden_cmd
,
6249 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6250 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6251 "Configure a neighbor as Route Reflector client\n")
6253 DEFUN (no_neighbor_route_reflector_client
,
6254 no_neighbor_route_reflector_client_cmd
,
6255 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6259 "Configure a neighbor as Route Reflector client\n")
6262 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6263 bgp_node_afi(vty
), bgp_node_safi(vty
),
6264 PEER_FLAG_REFLECTOR_CLIENT
);
6267 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6268 no_neighbor_route_reflector_client_hidden_cmd
,
6269 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6270 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6271 "Configure a neighbor as Route Reflector client\n")
6273 /* neighbor route-server-client. */
6274 DEFUN (neighbor_route_server_client
,
6275 neighbor_route_server_client_cmd
,
6276 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6279 "Configure a neighbor as Route Server client\n")
6284 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6286 return CMD_WARNING_CONFIG_FAILED
;
6287 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6289 PEER_FLAG_RSERVER_CLIENT
);
6292 ALIAS_HIDDEN(neighbor_route_server_client
,
6293 neighbor_route_server_client_hidden_cmd
,
6294 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6295 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6296 "Configure a neighbor as Route Server client\n")
6298 DEFUN (no_neighbor_route_server_client
,
6299 no_neighbor_route_server_client_cmd
,
6300 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6304 "Configure a neighbor as Route Server client\n")
6307 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6308 bgp_node_afi(vty
), bgp_node_safi(vty
),
6309 PEER_FLAG_RSERVER_CLIENT
);
6312 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6313 no_neighbor_route_server_client_hidden_cmd
,
6314 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6315 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6316 "Configure a neighbor as Route Server client\n")
6318 DEFUN (neighbor_nexthop_local_unchanged
,
6319 neighbor_nexthop_local_unchanged_cmd
,
6320 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6323 "Configure treatment of outgoing link-local nexthop attribute\n"
6324 "Leave link-local nexthop unchanged for this peer\n")
6327 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6329 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6332 DEFUN (no_neighbor_nexthop_local_unchanged
,
6333 no_neighbor_nexthop_local_unchanged_cmd
,
6334 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6338 "Configure treatment of outgoing link-local-nexthop attribute\n"
6339 "Leave link-local nexthop unchanged for this peer\n")
6342 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6343 bgp_node_afi(vty
), bgp_node_safi(vty
),
6344 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6347 DEFUN (neighbor_attr_unchanged
,
6348 neighbor_attr_unchanged_cmd
,
6349 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6352 "BGP attribute is propagated unchanged to this neighbor\n"
6353 "As-path attribute\n"
6354 "Nexthop attribute\n"
6358 char *peer_str
= argv
[1]->arg
;
6360 bool aspath
= false;
6361 bool nexthop
= false;
6363 afi_t afi
= bgp_node_afi(vty
);
6364 safi_t safi
= bgp_node_safi(vty
);
6367 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6369 return CMD_WARNING_CONFIG_FAILED
;
6371 if (argv_find(argv
, argc
, "as-path", &idx
))
6375 if (argv_find(argv
, argc
, "next-hop", &idx
))
6379 if (argv_find(argv
, argc
, "med", &idx
))
6382 /* no flags means all of them! */
6383 if (!aspath
&& !nexthop
&& !med
) {
6384 ret
= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6385 PEER_FLAG_AS_PATH_UNCHANGED
);
6386 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6387 PEER_FLAG_NEXTHOP_UNCHANGED
);
6388 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6389 PEER_FLAG_MED_UNCHANGED
);
6392 if (peer_af_flag_check(peer
, afi
, safi
,
6393 PEER_FLAG_AS_PATH_UNCHANGED
)) {
6394 ret
|= peer_af_flag_unset_vty(
6395 vty
, peer_str
, afi
, safi
,
6396 PEER_FLAG_AS_PATH_UNCHANGED
);
6399 ret
|= peer_af_flag_set_vty(
6400 vty
, peer_str
, afi
, safi
,
6401 PEER_FLAG_AS_PATH_UNCHANGED
);
6404 if (peer_af_flag_check(peer
, afi
, safi
,
6405 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
6406 ret
|= peer_af_flag_unset_vty(
6407 vty
, peer_str
, afi
, safi
,
6408 PEER_FLAG_NEXTHOP_UNCHANGED
);
6411 ret
|= peer_af_flag_set_vty(
6412 vty
, peer_str
, afi
, safi
,
6413 PEER_FLAG_NEXTHOP_UNCHANGED
);
6416 if (peer_af_flag_check(peer
, afi
, safi
,
6417 PEER_FLAG_MED_UNCHANGED
)) {
6418 ret
|= peer_af_flag_unset_vty(
6419 vty
, peer_str
, afi
, safi
,
6420 PEER_FLAG_MED_UNCHANGED
);
6423 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
6424 PEER_FLAG_MED_UNCHANGED
);
6431 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6432 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6433 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6434 "BGP attribute is propagated unchanged to this neighbor\n"
6435 "As-path attribute\n"
6436 "Nexthop attribute\n"
6439 DEFUN (no_neighbor_attr_unchanged
,
6440 no_neighbor_attr_unchanged_cmd
,
6441 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6445 "BGP attribute is propagated unchanged to this neighbor\n"
6446 "As-path attribute\n"
6447 "Nexthop attribute\n"
6451 char *peer_str
= argv
[2]->arg
;
6453 bool aspath
= false;
6454 bool nexthop
= false;
6456 afi_t afi
= bgp_node_afi(vty
);
6457 safi_t safi
= bgp_node_safi(vty
);
6460 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6462 return CMD_WARNING_CONFIG_FAILED
;
6464 if (argv_find(argv
, argc
, "as-path", &idx
))
6468 if (argv_find(argv
, argc
, "next-hop", &idx
))
6472 if (argv_find(argv
, argc
, "med", &idx
))
6475 if (!aspath
&& !nexthop
&& !med
) // no flags means all of them!
6476 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6477 PEER_FLAG_AS_PATH_UNCHANGED
)
6478 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6479 PEER_FLAG_NEXTHOP_UNCHANGED
)
6480 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6481 PEER_FLAG_MED_UNCHANGED
);
6484 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6485 PEER_FLAG_AS_PATH_UNCHANGED
);
6488 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6489 PEER_FLAG_NEXTHOP_UNCHANGED
);
6492 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
6493 PEER_FLAG_MED_UNCHANGED
);
6499 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6500 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6501 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6502 "BGP attribute is propagated unchanged to this neighbor\n"
6503 "As-path attribute\n"
6504 "Nexthop attribute\n"
6507 /* EBGP multihop configuration. */
6508 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
6509 const char *ttl_str
)
6514 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6516 return CMD_WARNING_CONFIG_FAILED
;
6519 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
6524 ttl
= strtoul(ttl_str
, NULL
, 10);
6526 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
6529 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
6533 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6535 return CMD_WARNING_CONFIG_FAILED
;
6537 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
6540 /* neighbor ebgp-multihop. */
6541 DEFUN (neighbor_ebgp_multihop
,
6542 neighbor_ebgp_multihop_cmd
,
6543 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6546 "Allow EBGP neighbors not on directly connected networks\n")
6549 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6552 DEFUN (neighbor_ebgp_multihop_ttl
,
6553 neighbor_ebgp_multihop_ttl_cmd
,
6554 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6557 "Allow EBGP neighbors not on directly connected networks\n"
6558 "maximum hop count\n")
6562 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
6563 argv
[idx_number
]->arg
);
6566 DEFUN (no_neighbor_ebgp_multihop
,
6567 no_neighbor_ebgp_multihop_cmd
,
6568 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6572 "Allow EBGP neighbors not on directly connected networks\n"
6573 "maximum hop count\n")
6576 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
6579 DEFPY (neighbor_aigp
,
6581 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor aigp",
6585 "Enable send and receive of the AIGP attribute per neighbor\n")
6589 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
6591 return CMD_WARNING_CONFIG_FAILED
;
6594 return peer_flag_unset_vty(vty
, neighbor
, PEER_FLAG_AIGP
);
6596 return peer_flag_set_vty(vty
, neighbor
, PEER_FLAG_AIGP
);
6599 static uint8_t get_role_by_name(const char *role_str
)
6601 if (strncmp(role_str
, "peer", 2) == 0)
6603 if (strncmp(role_str
, "provider", 2) == 0)
6604 return ROLE_PROVIDER
;
6605 if (strncmp(role_str
, "customer", 2) == 0)
6606 return ROLE_CUSTOMER
;
6607 if (strncmp(role_str
, "rs-server", 4) == 0)
6608 return ROLE_RS_SERVER
;
6609 if (strncmp(role_str
, "rs-client", 4) == 0)
6610 return ROLE_RS_CLIENT
;
6611 return ROLE_UNDEFINED
;
6614 static int peer_role_set_vty(struct vty
*vty
, const char *ip_str
,
6615 const char *role_str
, bool strict_mode
)
6619 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6621 return CMD_WARNING_CONFIG_FAILED
;
6622 uint8_t role
= get_role_by_name(role_str
);
6624 if (role
== ROLE_UNDEFINED
)
6625 return bgp_vty_return(vty
, BGP_ERR_INVALID_ROLE_NAME
);
6626 return bgp_vty_return(vty
, peer_role_set(peer
, role
, strict_mode
));
6629 static int peer_role_unset_vty(struct vty
*vty
, const char *ip_str
)
6633 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6635 return CMD_WARNING_CONFIG_FAILED
;
6636 return bgp_vty_return(vty
, peer_role_unset(peer
));
6639 DEFPY(neighbor_role
,
6641 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer>",
6644 "Set session role\n"
6650 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6654 DEFPY(neighbor_role_strict
,
6655 neighbor_role_strict_cmd
,
6656 "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> strict-mode",
6659 "Set session role\n"
6661 "Use additional restriction on peer\n")
6666 return peer_role_set_vty(vty
, argv
[idx_peer
]->arg
, argv
[idx_role
]->arg
,
6670 DEFPY(no_neighbor_role
,
6671 no_neighbor_role_cmd
,
6672 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]",
6676 "Set session role\n"
6678 "Use additional restriction on peer\n")
6682 return peer_role_unset_vty(vty
, argv
[idx_peer
]->arg
);
6685 /* disable-connected-check */
6686 DEFUN (neighbor_disable_connected_check
,
6687 neighbor_disable_connected_check_cmd
,
6688 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6691 "one-hop away EBGP peer using loopback address\n"
6692 "Enforce EBGP neighbors perform multihop\n")
6695 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6696 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6699 DEFUN (no_neighbor_disable_connected_check
,
6700 no_neighbor_disable_connected_check_cmd
,
6701 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6705 "one-hop away EBGP peer using loopback address\n"
6706 "Enforce EBGP neighbors perform multihop\n")
6709 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6710 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6713 /* disable-link-bw-encoding-ieee */
6714 DEFUN(neighbor_disable_link_bw_encoding_ieee
,
6715 neighbor_disable_link_bw_encoding_ieee_cmd
,
6716 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6717 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6718 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6722 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6723 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6726 DEFUN(no_neighbor_disable_link_bw_encoding_ieee
,
6727 no_neighbor_disable_link_bw_encoding_ieee_cmd
,
6728 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee",
6729 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6730 "Disable IEEE floating-point encoding for extended community bandwidth\n")
6734 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6735 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
);
6738 /* extended-optional-parameters */
6739 DEFUN(neighbor_extended_optional_parameters
,
6740 neighbor_extended_optional_parameters_cmd
,
6741 "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6742 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6743 "Force the extended optional parameters format for OPEN messages\n")
6747 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6748 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6751 DEFUN(no_neighbor_extended_optional_parameters
,
6752 no_neighbor_extended_optional_parameters_cmd
,
6753 "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters",
6754 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6755 "Force the extended optional parameters format for OPEN messages\n")
6759 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6760 PEER_FLAG_EXTENDED_OPT_PARAMS
);
6763 /* enforce-first-as */
6764 DEFUN (neighbor_enforce_first_as
,
6765 neighbor_enforce_first_as_cmd
,
6766 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6769 "Enforce the first AS for EBGP routes\n")
6773 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6774 PEER_FLAG_ENFORCE_FIRST_AS
);
6777 DEFUN (no_neighbor_enforce_first_as
,
6778 no_neighbor_enforce_first_as_cmd
,
6779 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6783 "Enforce the first AS for EBGP routes\n")
6787 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6788 PEER_FLAG_ENFORCE_FIRST_AS
);
6792 DEFUN (neighbor_description
,
6793 neighbor_description_cmd
,
6794 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6797 "Neighbor specific description\n"
6798 "Up to 80 characters describing this neighbor\n")
6805 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6807 return CMD_WARNING_CONFIG_FAILED
;
6809 str
= argv_concat(argv
, argc
, idx_line
);
6811 peer_description_set(peer
, str
);
6813 XFREE(MTYPE_TMP
, str
);
6818 DEFUN (no_neighbor_description
,
6819 no_neighbor_description_cmd
,
6820 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6824 "Neighbor specific description\n")
6829 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6831 return CMD_WARNING_CONFIG_FAILED
;
6833 peer_description_unset(peer
);
6838 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6839 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6840 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6841 "Neighbor specific description\n"
6842 "Up to 80 characters describing this neighbor\n")
6844 /* Neighbor update-source. */
6845 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
6846 const char *source_str
)
6852 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6854 return CMD_WARNING_CONFIG_FAILED
;
6860 if (str2sockunion(source_str
, &su
) == 0)
6861 peer_update_source_addr_set(peer
, &su
);
6863 if (str2prefix(source_str
, &p
)) {
6865 "%% Invalid update-source, remove prefix length \n");
6866 return CMD_WARNING_CONFIG_FAILED
;
6868 peer_update_source_if_set(peer
, source_str
);
6871 peer_update_source_unset(peer
);
6876 #define BGP_UPDATE_SOURCE_HELP_STR \
6879 "Interface name (requires zebra to be running)\n"
6881 DEFUN (neighbor_update_source
,
6882 neighbor_update_source_cmd
,
6883 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6886 "Source of routing updates\n"
6887 BGP_UPDATE_SOURCE_HELP_STR
)
6891 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
6892 argv
[idx_peer_2
]->arg
);
6895 DEFUN (no_neighbor_update_source
,
6896 no_neighbor_update_source_cmd
,
6897 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6901 "Source of routing updates\n"
6902 BGP_UPDATE_SOURCE_HELP_STR
)
6905 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6908 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
6909 afi_t afi
, safi_t safi
,
6910 const char *rmap
, int set
)
6914 struct route_map
*route_map
= NULL
;
6916 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6918 return CMD_WARNING_CONFIG_FAILED
;
6922 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
6923 ret
= peer_default_originate_set(peer
, afi
, safi
,
6926 ret
= peer_default_originate_unset(peer
, afi
, safi
);
6928 return bgp_vty_return(vty
, ret
);
6931 /* neighbor default-originate. */
6932 DEFUN (neighbor_default_originate
,
6933 neighbor_default_originate_cmd
,
6934 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6937 "Originate default route to this neighbor\n")
6940 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6942 bgp_node_safi(vty
), NULL
, 1);
6945 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
6946 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6947 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6948 "Originate default route to this neighbor\n")
6950 DEFUN (neighbor_default_originate_rmap
,
6951 neighbor_default_originate_rmap_cmd
,
6952 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6955 "Originate default route to this neighbor\n"
6956 "Route-map to specify criteria to originate default\n"
6961 return peer_default_originate_set_vty(
6962 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6963 argv
[idx_word
]->arg
, 1);
6967 neighbor_default_originate_rmap
,
6968 neighbor_default_originate_rmap_hidden_cmd
,
6969 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME",
6970 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6971 "Originate default route to this neighbor\n"
6972 "Route-map to specify criteria to originate default\n"
6975 DEFUN (no_neighbor_default_originate
,
6976 no_neighbor_default_originate_cmd
,
6977 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6981 "Originate default route to this neighbor\n"
6982 "Route-map to specify criteria to originate default\n"
6986 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6988 bgp_node_safi(vty
), NULL
, 0);
6992 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
6993 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]",
6994 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6995 "Originate default route to this neighbor\n"
6996 "Route-map to specify criteria to originate default\n"
7000 /* Set neighbor's BGP port. */
7001 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
7002 const char *port_str
)
7008 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7010 return CMD_WARNING_CONFIG_FAILED
;
7013 sp
= getservbyname("bgp", "tcp");
7014 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
7016 port
= strtoul(port_str
, NULL
, 10);
7019 peer_port_set(peer
, port
);
7024 /* Set specified peer's BGP port. */
7025 DEFUN (neighbor_port
,
7027 "neighbor <A.B.C.D|X:X::X:X|WORD> port (0-65535)",
7030 "Neighbor's BGP port\n"
7031 "TCP port number\n")
7035 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
7036 argv
[idx_number
]->arg
);
7039 DEFUN (no_neighbor_port
,
7040 no_neighbor_port_cmd
,
7041 "no neighbor <A.B.C.D|X:X::X:X|WORD> port [(0-65535)]",
7045 "Neighbor's BGP port\n"
7046 "TCP port number\n")
7049 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
7053 /* neighbor weight. */
7054 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7055 safi_t safi
, const char *weight_str
)
7059 unsigned long weight
;
7061 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7063 return CMD_WARNING_CONFIG_FAILED
;
7065 weight
= strtoul(weight_str
, NULL
, 10);
7067 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
7068 return bgp_vty_return(vty
, ret
);
7071 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7077 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7079 return CMD_WARNING_CONFIG_FAILED
;
7081 ret
= peer_weight_unset(peer
, afi
, safi
);
7082 return bgp_vty_return(vty
, ret
);
7085 DEFUN (neighbor_weight
,
7086 neighbor_weight_cmd
,
7087 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7090 "Set default weight for routes from this neighbor\n"
7095 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7096 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
7099 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
7100 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7101 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7102 "Set default weight for routes from this neighbor\n"
7105 DEFUN (no_neighbor_weight
,
7106 no_neighbor_weight_cmd
,
7107 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7111 "Set default weight for routes from this neighbor\n"
7115 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
7116 bgp_node_afi(vty
), bgp_node_safi(vty
));
7119 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
7120 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7121 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7122 "Set default weight for routes from this neighbor\n"
7126 /* Override capability negotiation. */
7127 DEFUN (neighbor_override_capability
,
7128 neighbor_override_capability_cmd
,
7129 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7132 "Override capability negotiation result\n")
7135 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7136 PEER_FLAG_OVERRIDE_CAPABILITY
);
7139 DEFUN (no_neighbor_override_capability
,
7140 no_neighbor_override_capability_cmd
,
7141 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7145 "Override capability negotiation result\n")
7148 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7149 PEER_FLAG_OVERRIDE_CAPABILITY
);
7152 DEFUN (neighbor_strict_capability
,
7153 neighbor_strict_capability_cmd
,
7154 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7157 "Strict capability negotiation match\n")
7161 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
7162 PEER_FLAG_STRICT_CAP_MATCH
);
7165 DEFUN (no_neighbor_strict_capability
,
7166 no_neighbor_strict_capability_cmd
,
7167 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7171 "Strict capability negotiation match\n")
7175 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
7176 PEER_FLAG_STRICT_CAP_MATCH
);
7179 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
7180 const char *keep_str
, const char *hold_str
)
7187 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7189 return CMD_WARNING_CONFIG_FAILED
;
7191 keepalive
= strtoul(keep_str
, NULL
, 10);
7192 holdtime
= strtoul(hold_str
, NULL
, 10);
7194 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
7196 return bgp_vty_return(vty
, ret
);
7199 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
7204 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7206 return CMD_WARNING_CONFIG_FAILED
;
7208 ret
= peer_timers_unset(peer
);
7210 return bgp_vty_return(vty
, ret
);
7213 DEFUN (neighbor_timers
,
7214 neighbor_timers_cmd
,
7215 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7218 "BGP per neighbor timers\n"
7219 "Keepalive interval\n"
7224 int idx_number_2
= 4;
7225 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
7226 argv
[idx_number
]->arg
,
7227 argv
[idx_number_2
]->arg
);
7230 DEFUN (no_neighbor_timers
,
7231 no_neighbor_timers_cmd
,
7232 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7236 "BGP per neighbor timers\n"
7237 "Keepalive interval\n"
7241 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
7245 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
7246 const char *time_str
)
7252 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7254 return CMD_WARNING_CONFIG_FAILED
;
7256 connect
= strtoul(time_str
, NULL
, 10);
7258 ret
= peer_timers_connect_set(peer
, connect
);
7260 return bgp_vty_return(vty
, ret
);
7263 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
7268 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7270 return CMD_WARNING_CONFIG_FAILED
;
7272 ret
= peer_timers_connect_unset(peer
);
7274 return bgp_vty_return(vty
, ret
);
7277 DEFUN (neighbor_timers_connect
,
7278 neighbor_timers_connect_cmd
,
7279 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7282 "BGP per neighbor timers\n"
7283 "BGP connect timer\n"
7288 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
7289 argv
[idx_number
]->arg
);
7292 DEFUN (no_neighbor_timers_connect
,
7293 no_neighbor_timers_connect_cmd
,
7294 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7298 "BGP per neighbor timers\n"
7299 "BGP connect timer\n"
7303 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
7306 DEFPY (neighbor_timers_delayopen
,
7307 neighbor_timers_delayopen_cmd
,
7308 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7311 "BGP per neighbor timers\n"
7312 "RFC 4271 DelayOpenTimer\n"
7313 "DelayOpenTime timer interval\n")
7317 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7319 return CMD_WARNING_CONFIG_FAILED
;
7322 if (peer_timers_delayopen_unset(peer
))
7323 return CMD_WARNING_CONFIG_FAILED
;
7325 if (peer_timers_delayopen_set(peer
, interval
))
7326 return CMD_WARNING_CONFIG_FAILED
;
7332 DEFPY (no_neighbor_timers_delayopen
,
7333 no_neighbor_timers_delayopen_cmd
,
7334 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7338 "BGP per neighbor timers\n"
7339 "RFC 4271 DelayOpenTimer\n"
7340 "DelayOpenTime timer interval\n")
7344 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7346 return CMD_WARNING_CONFIG_FAILED
;
7348 if (peer_timers_delayopen_unset(peer
))
7349 return CMD_WARNING_CONFIG_FAILED
;
7354 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
7355 const char *time_str
, int set
)
7359 uint32_t routeadv
= 0;
7361 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7363 return CMD_WARNING_CONFIG_FAILED
;
7366 routeadv
= strtoul(time_str
, NULL
, 10);
7369 ret
= peer_advertise_interval_set(peer
, routeadv
);
7371 ret
= peer_advertise_interval_unset(peer
);
7373 return bgp_vty_return(vty
, ret
);
7376 DEFUN (neighbor_advertise_interval
,
7377 neighbor_advertise_interval_cmd
,
7378 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7381 "Minimum interval between sending BGP routing updates\n"
7382 "time in seconds\n")
7386 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
7387 argv
[idx_number
]->arg
, 1);
7390 DEFUN (no_neighbor_advertise_interval
,
7391 no_neighbor_advertise_interval_cmd
,
7392 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7396 "Minimum interval between sending BGP routing updates\n"
7397 "time in seconds\n")
7400 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
7404 /* Time to wait before processing route-map updates */
7405 DEFUN (bgp_set_route_map_delay_timer
,
7406 bgp_set_route_map_delay_timer_cmd
,
7407 "bgp route-map delay-timer (0-600)",
7409 "BGP route-map delay timer\n"
7410 "Time in secs to wait before processing route-map changes\n"
7411 "0 disables the timer, no route updates happen when route-maps change\n")
7414 uint32_t rmap_delay_timer
;
7416 if (argv
[idx_number
]->arg
) {
7417 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7418 bm
->rmap_update_timer
= rmap_delay_timer
;
7420 /* if the dynamic update handling is being disabled, and a timer
7422 * running, stop the timer and act as if the timer has already
7425 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7426 THREAD_OFF(bm
->t_rmap_update
);
7427 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7432 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7433 return CMD_WARNING_CONFIG_FAILED
;
7437 DEFUN (no_bgp_set_route_map_delay_timer
,
7438 no_bgp_set_route_map_delay_timer_cmd
,
7439 "no bgp route-map delay-timer [(0-600)]",
7442 "Default BGP route-map delay timer\n"
7443 "Reset to default time to wait for processing route-map changes\n"
7444 "0 disables the timer, no route updates happen when route-maps change\n")
7447 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7452 /* neighbor interface */
7453 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
7458 peer
= peer_lookup_vty(vty
, ip_str
);
7459 if (!peer
|| peer
->conf_if
) {
7460 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
7461 return CMD_WARNING_CONFIG_FAILED
;
7465 peer_interface_set(peer
, str
);
7467 peer_interface_unset(peer
);
7472 DEFUN (neighbor_interface
,
7473 neighbor_interface_cmd
,
7474 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7483 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
7486 DEFUN (no_neighbor_interface
,
7487 no_neighbor_interface_cmd
,
7488 "no neighbor <A.B.C.D|X:X::X:X> interface WORD",
7497 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
7500 DEFUN (neighbor_distribute_list
,
7501 neighbor_distribute_list_cmd
,
7502 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7505 "Filter updates to/from this neighbor\n"
7506 "IP Access-list name\n"
7507 "Filter incoming updates\n"
7508 "Filter outgoing updates\n")
7515 const char *pstr
= argv
[idx_peer
]->arg
;
7516 const char *acl
= argv
[idx_acl
]->arg
;
7517 const char *inout
= argv
[argc
- 1]->text
;
7519 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7521 return CMD_WARNING_CONFIG_FAILED
;
7523 /* Check filter direction. */
7524 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7525 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7528 return bgp_vty_return(vty
, ret
);
7532 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7533 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7534 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7535 "Filter updates to/from this neighbor\n"
7536 "IP Access-list name\n"
7537 "Filter incoming updates\n"
7538 "Filter outgoing updates\n")
7540 DEFUN (no_neighbor_distribute_list
,
7541 no_neighbor_distribute_list_cmd
,
7542 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7546 "Filter updates to/from this neighbor\n"
7547 "IP Access-list name\n"
7548 "Filter incoming updates\n"
7549 "Filter outgoing updates\n")
7555 const char *pstr
= argv
[idx_peer
]->arg
;
7556 const char *inout
= argv
[argc
- 1]->text
;
7558 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7560 return CMD_WARNING_CONFIG_FAILED
;
7562 /* Check filter direction. */
7563 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7564 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7567 return bgp_vty_return(vty
, ret
);
7571 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7572 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>",
7573 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7574 "Filter updates to/from this neighbor\n"
7575 "IP Access-list name\n"
7576 "Filter incoming updates\n"
7577 "Filter outgoing updates\n")
7579 /* Set prefix list to the peer. */
7580 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7581 afi_t afi
, safi_t safi
,
7582 const char *name_str
,
7583 const char *direct_str
)
7586 int direct
= FILTER_IN
;
7589 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7591 return CMD_WARNING_CONFIG_FAILED
;
7593 /* Check filter direction. */
7594 if (strncmp(direct_str
, "i", 1) == 0)
7596 else if (strncmp(direct_str
, "o", 1) == 0)
7597 direct
= FILTER_OUT
;
7599 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7601 return bgp_vty_return(vty
, ret
);
7604 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7605 afi_t afi
, safi_t safi
,
7606 const char *direct_str
)
7610 int direct
= FILTER_IN
;
7612 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7614 return CMD_WARNING_CONFIG_FAILED
;
7616 /* Check filter direction. */
7617 if (strncmp(direct_str
, "i", 1) == 0)
7619 else if (strncmp(direct_str
, "o", 1) == 0)
7620 direct
= FILTER_OUT
;
7622 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7624 return bgp_vty_return(vty
, ret
);
7627 DEFUN (neighbor_prefix_list
,
7628 neighbor_prefix_list_cmd
,
7629 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7632 "Filter updates to/from this neighbor\n"
7633 "Name of a prefix list\n"
7634 "Filter incoming updates\n"
7635 "Filter outgoing updates\n")
7640 return peer_prefix_list_set_vty(
7641 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7642 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7645 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7646 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7647 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7648 "Filter updates to/from this neighbor\n"
7649 "Name of a prefix list\n"
7650 "Filter incoming updates\n"
7651 "Filter outgoing updates\n")
7653 DEFUN (no_neighbor_prefix_list
,
7654 no_neighbor_prefix_list_cmd
,
7655 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7659 "Filter updates to/from this neighbor\n"
7660 "Name of a prefix list\n"
7661 "Filter incoming updates\n"
7662 "Filter outgoing updates\n")
7666 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7667 bgp_node_afi(vty
), bgp_node_safi(vty
),
7668 argv
[idx_in_out
]->arg
);
7671 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7672 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7673 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7674 "Filter updates to/from this neighbor\n"
7675 "Name of a prefix list\n"
7676 "Filter incoming updates\n"
7677 "Filter outgoing updates\n")
7679 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7680 safi_t safi
, const char *name_str
,
7681 const char *direct_str
)
7685 int direct
= FILTER_IN
;
7687 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7689 return CMD_WARNING_CONFIG_FAILED
;
7691 /* Check filter direction. */
7692 if (strncmp(direct_str
, "i", 1) == 0)
7694 else if (strncmp(direct_str
, "o", 1) == 0)
7695 direct
= FILTER_OUT
;
7697 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7699 return bgp_vty_return(vty
, ret
);
7702 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7703 safi_t safi
, const char *direct_str
)
7707 int direct
= FILTER_IN
;
7709 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7711 return CMD_WARNING_CONFIG_FAILED
;
7713 /* Check filter direction. */
7714 if (strncmp(direct_str
, "i", 1) == 0)
7716 else if (strncmp(direct_str
, "o", 1) == 0)
7717 direct
= FILTER_OUT
;
7719 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7721 return bgp_vty_return(vty
, ret
);
7724 DEFUN (neighbor_filter_list
,
7725 neighbor_filter_list_cmd
,
7726 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7729 "Establish BGP filters\n"
7730 "AS path access-list name\n"
7731 "Filter incoming routes\n"
7732 "Filter outgoing routes\n")
7737 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7738 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7739 argv
[idx_in_out
]->arg
);
7742 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7743 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7744 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7745 "Establish BGP filters\n"
7746 "AS path access-list name\n"
7747 "Filter incoming routes\n"
7748 "Filter outgoing routes\n")
7750 DEFUN (no_neighbor_filter_list
,
7751 no_neighbor_filter_list_cmd
,
7752 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7756 "Establish BGP filters\n"
7757 "AS path access-list name\n"
7758 "Filter incoming routes\n"
7759 "Filter outgoing routes\n")
7763 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7764 bgp_node_afi(vty
), bgp_node_safi(vty
),
7765 argv
[idx_in_out
]->arg
);
7768 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7769 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>",
7770 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7771 "Establish BGP filters\n"
7772 "AS path access-list name\n"
7773 "Filter incoming routes\n"
7774 "Filter outgoing routes\n")
7776 /* Set advertise-map to the peer. */
7777 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7778 afi_t afi
, safi_t safi
,
7779 const char *advertise_str
,
7780 const char *condition_str
, bool condition
,
7783 int ret
= CMD_WARNING_CONFIG_FAILED
;
7785 struct route_map
*advertise_map
;
7786 struct route_map
*condition_map
;
7788 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7792 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7793 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7796 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7797 advertise_map
, condition_str
,
7798 condition_map
, condition
);
7800 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7801 advertise_map
, condition_str
,
7802 condition_map
, condition
);
7804 return bgp_vty_return(vty
, ret
);
7807 DEFPY (bgp_condadv_period
,
7808 bgp_condadv_period_cmd
,
7809 "[no$no] bgp conditional-advertisement timer (5-240)$period",
7812 "Conditional advertisement settings\n"
7813 "Set period to rescan BGP table to check if condition is met\n"
7814 "Period between BGP table scans, in seconds; default 60\n")
7816 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7818 bgp
->condition_check_period
=
7819 no
? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
: period
;
7824 DEFPY (neighbor_advertise_map
,
7825 neighbor_advertise_map_cmd
,
7826 "[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",
7830 "Route-map to conditionally advertise routes\n"
7831 "Name of advertise map\n"
7832 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7833 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7834 "Name of the exist or non exist map\n")
7836 bool condition
= CONDITION_EXIST
;
7838 if (!strcmp(exist
, "non-exist-map"))
7839 condition
= CONDITION_NON_EXIST
;
7841 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7842 bgp_node_safi(vty
), advertise_str
,
7843 condition_str
, condition
, !no
);
7846 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7847 "[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",
7848 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7849 "Route-map to conditionally advertise routes\n"
7850 "Name of advertise map\n"
7851 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7852 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7853 "Name of the exist or non exist map\n")
7855 /* Set route-map to the peer. */
7856 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7857 afi_t afi
, safi_t safi
, const char *name_str
,
7858 const char *direct_str
)
7862 int direct
= RMAP_IN
;
7863 struct route_map
*route_map
;
7865 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7867 return CMD_WARNING_CONFIG_FAILED
;
7869 /* Check filter direction. */
7870 if (strncmp(direct_str
, "in", 2) == 0)
7872 else if (strncmp(direct_str
, "o", 1) == 0)
7875 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7876 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7878 return bgp_vty_return(vty
, ret
);
7881 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7882 afi_t afi
, safi_t safi
,
7883 const char *direct_str
)
7887 int direct
= RMAP_IN
;
7889 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7891 return CMD_WARNING_CONFIG_FAILED
;
7893 /* Check filter direction. */
7894 if (strncmp(direct_str
, "in", 2) == 0)
7896 else if (strncmp(direct_str
, "o", 1) == 0)
7899 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7901 return bgp_vty_return(vty
, ret
);
7904 DEFUN (neighbor_route_map
,
7905 neighbor_route_map_cmd
,
7906 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7909 "Apply route map to neighbor\n"
7910 "Name of route map\n"
7911 "Apply map to incoming routes\n"
7912 "Apply map to outbound routes\n")
7917 return peer_route_map_set_vty(
7918 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7919 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7922 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7923 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7924 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7925 "Apply route map to neighbor\n"
7926 "Name of route map\n"
7927 "Apply map to incoming routes\n"
7928 "Apply map to outbound routes\n")
7930 DEFUN (no_neighbor_route_map
,
7931 no_neighbor_route_map_cmd
,
7932 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7936 "Apply route map to neighbor\n"
7937 "Name of route map\n"
7938 "Apply map to incoming routes\n"
7939 "Apply map to outbound routes\n")
7943 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7944 bgp_node_afi(vty
), bgp_node_safi(vty
),
7945 argv
[idx_in_out
]->arg
);
7948 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7949 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>",
7950 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7951 "Apply route map to neighbor\n"
7952 "Name of route map\n"
7953 "Apply map to incoming routes\n"
7954 "Apply map to outbound routes\n")
7956 /* Set unsuppress-map to the peer. */
7957 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
7958 afi_t afi
, safi_t safi
,
7959 const char *name_str
)
7963 struct route_map
*route_map
;
7965 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7967 return CMD_WARNING_CONFIG_FAILED
;
7969 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7970 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
7972 return bgp_vty_return(vty
, ret
);
7975 /* Unset route-map from the peer. */
7976 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7977 afi_t afi
, safi_t safi
)
7982 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7984 return CMD_WARNING_CONFIG_FAILED
;
7986 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
7988 return bgp_vty_return(vty
, ret
);
7991 DEFUN (neighbor_unsuppress_map
,
7992 neighbor_unsuppress_map_cmd
,
7993 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7996 "Route-map to selectively unsuppress suppressed routes\n"
7997 "Name of route map\n")
8001 return peer_unsuppress_map_set_vty(
8002 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8003 argv
[idx_word
]->arg
);
8006 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
8007 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8008 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8009 "Route-map to selectively unsuppress suppressed routes\n"
8010 "Name of route map\n")
8012 DEFUN (no_neighbor_unsuppress_map
,
8013 no_neighbor_unsuppress_map_cmd
,
8014 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8018 "Route-map to selectively unsuppress suppressed routes\n"
8019 "Name of route map\n")
8022 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
8024 bgp_node_safi(vty
));
8027 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
8028 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8029 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8030 "Route-map to selectively unsuppress suppressed routes\n"
8031 "Name of route map\n")
8033 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
8034 afi_t afi
, safi_t safi
,
8035 const char *num_str
,
8036 const char *threshold_str
, int warning
,
8037 const char *restart_str
,
8038 const char *force_str
)
8046 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8048 return CMD_WARNING_CONFIG_FAILED
;
8050 max
= strtoul(num_str
, NULL
, 10);
8052 threshold
= atoi(threshold_str
);
8054 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
8057 restart
= atoi(restart_str
);
8061 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
8062 restart
, force_str
? true : false);
8064 return bgp_vty_return(vty
, ret
);
8067 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
8068 afi_t afi
, safi_t safi
)
8073 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8075 return CMD_WARNING_CONFIG_FAILED
;
8077 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
8079 return bgp_vty_return(vty
, ret
);
8082 /* Maximum number of prefix to be sent to the neighbor. */
8083 DEFUN(neighbor_maximum_prefix_out
,
8084 neighbor_maximum_prefix_out_cmd
,
8085 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
8088 "Maximum number of prefixes to be sent to this peer\n"
8089 "Maximum no. of prefix limit\n")
8096 afi_t afi
= bgp_node_afi(vty
);
8097 safi_t safi
= bgp_node_safi(vty
);
8099 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8101 return CMD_WARNING_CONFIG_FAILED
;
8103 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8105 ret
= peer_maximum_prefix_out_set(peer
, afi
, safi
, max
);
8107 return bgp_vty_return(vty
, ret
);
8110 DEFUN(no_neighbor_maximum_prefix_out
,
8111 no_neighbor_maximum_prefix_out_cmd
,
8112 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]",
8116 "Maximum number of prefixes to be sent to this peer\n"
8117 "Maximum no. of prefix limit\n")
8122 afi_t afi
= bgp_node_afi(vty
);
8123 safi_t safi
= bgp_node_safi(vty
);
8125 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8127 return CMD_WARNING_CONFIG_FAILED
;
8129 ret
= peer_maximum_prefix_out_unset(peer
, afi
, safi
);
8131 return bgp_vty_return(vty
, ret
);
8134 /* Maximum number of prefix configuration. Prefix count is different
8135 for each peer configuration. So this configuration can be set for
8136 each peer configuration. */
8137 DEFUN (neighbor_maximum_prefix
,
8138 neighbor_maximum_prefix_cmd
,
8139 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8142 "Maximum number of prefix accept from this peer\n"
8143 "maximum no. of prefix limit\n"
8144 "Force checking all received routes not only accepted\n")
8151 if (argv_find(argv
, argc
, "force", &idx_force
))
8152 force
= argv
[idx_force
]->arg
;
8154 return peer_maximum_prefix_set_vty(
8155 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8156 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
8159 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8160 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8161 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8162 "Maximum number of prefix accept from this peer\n"
8163 "maximum no. of prefix limit\n"
8164 "Force checking all received routes not only accepted\n")
8166 DEFUN (neighbor_maximum_prefix_threshold
,
8167 neighbor_maximum_prefix_threshold_cmd
,
8168 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8171 "Maximum number of prefix accept from this peer\n"
8172 "maximum no. of prefix limit\n"
8173 "Threshold value (%) at which to generate a warning msg\n"
8174 "Force checking all received routes not only accepted\n")
8178 int idx_number_2
= 4;
8182 if (argv_find(argv
, argc
, "force", &idx_force
))
8183 force
= argv
[idx_force
]->arg
;
8185 return peer_maximum_prefix_set_vty(
8186 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8187 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
8191 neighbor_maximum_prefix_threshold
,
8192 neighbor_maximum_prefix_threshold_hidden_cmd
,
8193 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8194 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8195 "Maximum number of prefix accept from this peer\n"
8196 "maximum no. of prefix limit\n"
8197 "Threshold value (%) at which to generate a warning msg\n"
8198 "Force checking all received routes not only accepted\n")
8200 DEFUN (neighbor_maximum_prefix_warning
,
8201 neighbor_maximum_prefix_warning_cmd
,
8202 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8205 "Maximum number of prefix accept from this peer\n"
8206 "maximum no. of prefix limit\n"
8207 "Only give warning message when limit is exceeded\n"
8208 "Force checking all received routes not only accepted\n")
8215 if (argv_find(argv
, argc
, "force", &idx_force
))
8216 force
= argv
[idx_force
]->arg
;
8218 return peer_maximum_prefix_set_vty(
8219 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8220 argv
[idx_number
]->arg
, NULL
, 1, NULL
, force
);
8224 neighbor_maximum_prefix_warning
,
8225 neighbor_maximum_prefix_warning_hidden_cmd
,
8226 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8227 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8228 "Maximum number of prefix accept from this peer\n"
8229 "maximum no. of prefix limit\n"
8230 "Only give warning message when limit is exceeded\n"
8231 "Force checking all received routes not only accepted\n")
8233 DEFUN (neighbor_maximum_prefix_threshold_warning
,
8234 neighbor_maximum_prefix_threshold_warning_cmd
,
8235 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8238 "Maximum number of prefix accept from this peer\n"
8239 "maximum no. of prefix limit\n"
8240 "Threshold value (%) at which to generate a warning msg\n"
8241 "Only give warning message when limit is exceeded\n"
8242 "Force checking all received routes not only accepted\n")
8246 int idx_number_2
= 4;
8250 if (argv_find(argv
, argc
, "force", &idx_force
))
8251 force
= argv
[idx_force
]->arg
;
8253 return peer_maximum_prefix_set_vty(
8254 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8255 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
8259 neighbor_maximum_prefix_threshold_warning
,
8260 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8261 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8262 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8263 "Maximum number of prefix accept from this peer\n"
8264 "maximum no. of prefix limit\n"
8265 "Threshold value (%) at which to generate a warning msg\n"
8266 "Only give warning message when limit is exceeded\n"
8267 "Force checking all received routes not only accepted\n")
8269 DEFUN (neighbor_maximum_prefix_restart
,
8270 neighbor_maximum_prefix_restart_cmd
,
8271 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8274 "Maximum number of prefix accept from this peer\n"
8275 "maximum no. of prefix limit\n"
8276 "Restart bgp connection after limit is exceeded\n"
8277 "Restart interval in minutes\n"
8278 "Force checking all received routes not only accepted\n")
8282 int idx_number_2
= 5;
8286 if (argv_find(argv
, argc
, "force", &idx_force
))
8287 force
= argv
[idx_force
]->arg
;
8289 return peer_maximum_prefix_set_vty(
8290 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8291 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
8295 neighbor_maximum_prefix_restart
,
8296 neighbor_maximum_prefix_restart_hidden_cmd
,
8297 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8298 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8299 "Maximum number of prefix accept from this peer\n"
8300 "maximum no. of prefix limit\n"
8301 "Restart bgp connection after limit is exceeded\n"
8302 "Restart interval in minutes\n"
8303 "Force checking all received routes not only accepted\n")
8305 DEFUN (neighbor_maximum_prefix_threshold_restart
,
8306 neighbor_maximum_prefix_threshold_restart_cmd
,
8307 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8310 "Maximum number of prefixes to accept from this peer\n"
8311 "maximum no. of prefix limit\n"
8312 "Threshold value (%) at which to generate a warning msg\n"
8313 "Restart bgp connection after limit is exceeded\n"
8314 "Restart interval in minutes\n"
8315 "Force checking all received routes not only accepted\n")
8319 int idx_number_2
= 4;
8320 int idx_number_3
= 6;
8324 if (argv_find(argv
, argc
, "force", &idx_force
))
8325 force
= argv
[idx_force
]->arg
;
8327 return peer_maximum_prefix_set_vty(
8328 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8329 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
8330 argv
[idx_number_3
]->arg
, force
);
8334 neighbor_maximum_prefix_threshold_restart
,
8335 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8336 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8337 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8338 "Maximum number of prefixes to accept from this peer\n"
8339 "maximum no. of prefix limit\n"
8340 "Threshold value (%) at which to generate a warning msg\n"
8341 "Restart bgp connection after limit is exceeded\n"
8342 "Restart interval in minutes\n"
8343 "Force checking all received routes not only accepted\n")
8345 DEFUN (no_neighbor_maximum_prefix
,
8346 no_neighbor_maximum_prefix_cmd
,
8347 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8351 "Maximum number of prefixes to accept from this peer\n"
8352 "maximum no. of prefix limit\n"
8353 "Threshold value (%) at which to generate a warning msg\n"
8354 "Restart bgp connection after limit is exceeded\n"
8355 "Restart interval in minutes\n"
8356 "Only give warning message when limit is exceeded\n"
8357 "Force checking all received routes not only accepted\n")
8360 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
8362 bgp_node_safi(vty
));
8366 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8367 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8368 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8369 "Maximum number of prefixes to accept from this peer\n"
8370 "maximum no. of prefix limit\n"
8371 "Threshold value (%) at which to generate a warning msg\n"
8372 "Restart bgp connection after limit is exceeded\n"
8373 "Restart interval in minutes\n"
8374 "Only give warning message when limit is exceeded\n"
8375 "Force checking all received routes not only accepted\n")
8377 /* "neighbor accept-own" */
8378 DEFPY (neighbor_accept_own
,
8379 neighbor_accept_own_cmd
,
8380 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor accept-own",
8384 "Enable handling of self-originated VPN routes containing ACCEPT_OWN community\n")
8387 afi_t afi
= bgp_node_afi(vty
);
8388 safi_t safi
= bgp_node_safi(vty
);
8391 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8393 return CMD_WARNING_CONFIG_FAILED
;
8396 ret
= peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
);
8398 ret
= peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
);
8400 return bgp_vty_return(vty
, ret
);
8403 /* "neighbor soo" */
8404 DEFPY (neighbor_soo
,
8406 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo ASN:NN_OR_IP-ADDRESS:NN$soo",
8409 "Set the Site-of-Origin (SoO) extended community\n"
8410 "VPN extended community\n")
8413 afi_t afi
= bgp_node_afi(vty
);
8414 safi_t safi
= bgp_node_safi(vty
);
8415 struct ecommunity
*ecomm_soo
;
8417 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8419 return CMD_WARNING_CONFIG_FAILED
;
8421 ecomm_soo
= ecommunity_str2com(soo
, ECOMMUNITY_SITE_ORIGIN
, 0);
8423 vty_out(vty
, "%% Malformed SoO extended community\n");
8426 ecommunity_str(ecomm_soo
);
8428 if (!ecommunity_match(peer
->soo
[afi
][safi
], ecomm_soo
)) {
8429 ecommunity_free(&peer
->soo
[afi
][safi
]);
8430 peer
->soo
[afi
][safi
] = ecomm_soo
;
8431 peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
);
8434 return bgp_vty_return(vty
,
8435 peer_af_flag_set(peer
, afi
, safi
, PEER_FLAG_SOO
));
8438 DEFPY (no_neighbor_soo
,
8439 no_neighbor_soo_cmd
,
8440 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo [ASN:NN_OR_IP-ADDRESS:NN$soo]",
8444 "Set the Site-of-Origin (SoO) extended community\n"
8445 "VPN extended community\n")
8448 afi_t afi
= bgp_node_afi(vty
);
8449 safi_t safi
= bgp_node_safi(vty
);
8451 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8453 return CMD_WARNING_CONFIG_FAILED
;
8455 ecommunity_free(&peer
->soo
[afi
][safi
]);
8457 return bgp_vty_return(
8458 vty
, peer_af_flag_unset(peer
, afi
, safi
, PEER_FLAG_SOO
));
8461 /* "neighbor allowas-in" */
8462 DEFUN (neighbor_allowas_in
,
8463 neighbor_allowas_in_cmd
,
8464 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8467 "Accept as-path with my AS present in it\n"
8468 "Number of occurrences of AS number\n"
8469 "Only accept my AS in the as-path if the route was originated in my AS\n")
8472 int idx_number_origin
= 3;
8478 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8480 return CMD_WARNING_CONFIG_FAILED
;
8482 if (argc
<= idx_number_origin
)
8485 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8488 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8491 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8494 return bgp_vty_return(vty
, ret
);
8498 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8499 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8500 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8501 "Accept as-path with my AS present in it\n"
8502 "Number of occurrences of AS number\n"
8503 "Only accept my AS in the as-path if the route was originated in my AS\n")
8505 DEFUN (no_neighbor_allowas_in
,
8506 no_neighbor_allowas_in_cmd
,
8507 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8511 "allow local ASN appears in aspath attribute\n"
8512 "Number of occurrences of AS number\n"
8513 "Only accept my AS in the as-path if the route was originated in my AS\n")
8519 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8521 return CMD_WARNING_CONFIG_FAILED
;
8523 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8524 bgp_node_safi(vty
));
8526 return bgp_vty_return(vty
, ret
);
8530 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8531 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8532 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8533 "allow local ASN appears in aspath attribute\n"
8534 "Number of occurrences of AS number\n"
8535 "Only accept my AS in the as-path if the route was originated in my AS\n")
8537 DEFUN (neighbor_ttl_security
,
8538 neighbor_ttl_security_cmd
,
8539 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8542 "BGP ttl-security parameters\n"
8543 "Specify the maximum number of hops to the BGP peer\n"
8544 "Number of hops to BGP peer\n")
8551 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8553 return CMD_WARNING_CONFIG_FAILED
;
8555 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8558 * If 'neighbor swpX', then this is for directly connected peers,
8559 * we should not accept a ttl-security hops value greater than 1.
8561 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
8563 "%s is directly connected peer, hops cannot exceed 1\n",
8564 argv
[idx_peer
]->arg
);
8565 return CMD_WARNING_CONFIG_FAILED
;
8568 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
8571 DEFUN (no_neighbor_ttl_security
,
8572 no_neighbor_ttl_security_cmd
,
8573 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8577 "BGP ttl-security parameters\n"
8578 "Specify the maximum number of hops to the BGP peer\n"
8579 "Number of hops to BGP peer\n")
8584 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8586 return CMD_WARNING_CONFIG_FAILED
;
8588 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
8591 /* disable-addpath-rx */
8592 DEFUN(neighbor_disable_addpath_rx
,
8593 neighbor_disable_addpath_rx_cmd
,
8594 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8597 "Do not accept additional paths\n")
8599 char *peer_str
= argv
[1]->arg
;
8601 afi_t afi
= bgp_node_afi(vty
);
8602 safi_t safi
= bgp_node_safi(vty
);
8604 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8606 return CMD_WARNING_CONFIG_FAILED
;
8608 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
8609 PEER_FLAG_DISABLE_ADDPATH_RX
);
8612 DEFUN(no_neighbor_disable_addpath_rx
,
8613 no_neighbor_disable_addpath_rx_cmd
,
8614 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx",
8618 "Do not accept additional paths\n")
8620 char *peer_str
= argv
[2]->arg
;
8622 afi_t afi
= bgp_node_afi(vty
);
8623 safi_t safi
= bgp_node_safi(vty
);
8625 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
8627 return CMD_WARNING_CONFIG_FAILED
;
8629 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
8630 PEER_FLAG_DISABLE_ADDPATH_RX
);
8633 DEFUN (neighbor_addpath_tx_all_paths
,
8634 neighbor_addpath_tx_all_paths_cmd
,
8635 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8638 "Use addpath to advertise all paths to a neighbor\n")
8643 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8645 return CMD_WARNING_CONFIG_FAILED
;
8647 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8652 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8653 neighbor_addpath_tx_all_paths_hidden_cmd
,
8654 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8655 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8656 "Use addpath to advertise all paths to a neighbor\n")
8658 DEFUN (no_neighbor_addpath_tx_all_paths
,
8659 no_neighbor_addpath_tx_all_paths_cmd
,
8660 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8664 "Use addpath to advertise all paths to a neighbor\n")
8669 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8671 return CMD_WARNING_CONFIG_FAILED
;
8673 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8674 != BGP_ADDPATH_ALL
) {
8676 "%% Peer not currently configured to transmit all paths.");
8677 return CMD_WARNING_CONFIG_FAILED
;
8680 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8686 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8687 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8688 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8689 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8690 "Use addpath to advertise all paths to a neighbor\n")
8692 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8693 neighbor_addpath_tx_bestpath_per_as_cmd
,
8694 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8697 "Use addpath to advertise the bestpath per each neighboring AS\n")
8702 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8704 return CMD_WARNING_CONFIG_FAILED
;
8706 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8707 BGP_ADDPATH_BEST_PER_AS
);
8712 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8713 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8714 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8715 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8716 "Use addpath to advertise the bestpath per each neighboring AS\n")
8718 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8719 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8720 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8724 "Use addpath to advertise the bestpath per each neighboring AS\n")
8729 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8731 return CMD_WARNING_CONFIG_FAILED
;
8733 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8734 != BGP_ADDPATH_BEST_PER_AS
) {
8736 "%% Peer not currently configured to transmit all best path per as.");
8737 return CMD_WARNING_CONFIG_FAILED
;
8740 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8746 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8747 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8748 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8749 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8750 "Use addpath to advertise the bestpath per each neighboring AS\n")
8753 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8754 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8757 "Detect AS loops before sending to neighbor\n")
8761 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8763 return CMD_WARNING_CONFIG_FAILED
;
8765 peer
->as_path_loop_detection
= true;
8771 no_neighbor_aspath_loop_detection
,
8772 no_neighbor_aspath_loop_detection_cmd
,
8773 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8777 "Detect AS loops before sending to neighbor\n")
8781 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8783 return CMD_WARNING_CONFIG_FAILED
;
8785 peer
->as_path_loop_detection
= false;
8790 DEFPY(neighbor_path_attribute_discard
,
8791 neighbor_path_attribute_discard_cmd
,
8792 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor path-attribute discard (1-255)...",
8795 "Manipulate path attributes from incoming UPDATE messages\n"
8796 "Drop specified attributes from incoming UPDATE messages\n"
8797 "Attribute number\n")
8801 const char *discard_attrs
= NULL
;
8803 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8805 return CMD_WARNING_CONFIG_FAILED
;
8807 argv_find(argv
, argc
, "(1-255)", &idx
);
8809 discard_attrs
= argv_concat(argv
, argc
, idx
);
8811 bgp_path_attribute_discard_vty(vty
, peer
, discard_attrs
, true);
8816 DEFPY(no_neighbor_path_attribute_discard
,
8817 no_neighbor_path_attribute_discard_cmd
,
8818 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor path-attribute discard [(1-255)]",
8822 "Manipulate path attributes from incoming UPDATE messages\n"
8823 "Drop specified attributes from incoming UPDATE messages\n"
8824 "Attribute number\n")
8828 const char *discard_attrs
= NULL
;
8830 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8832 return CMD_WARNING_CONFIG_FAILED
;
8834 argv_find(argv
, argc
, "(1-255)", &idx
);
8836 discard_attrs
= argv
[idx
]->arg
;
8838 bgp_path_attribute_discard_vty(vty
, peer
, discard_attrs
, false);
8843 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8844 struct ecommunity
**list
, bool is_rt6
)
8846 struct ecommunity
*ecom
= NULL
;
8847 struct ecommunity
*ecomadd
;
8849 for (; argc
; --argc
, ++argv
) {
8851 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8852 ECOMMUNITY_ROUTE_TARGET
,
8855 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8856 ECOMMUNITY_ROUTE_TARGET
,
8859 vty_out(vty
, "Malformed community-list value\n");
8861 ecommunity_free(&ecom
);
8862 return CMD_WARNING_CONFIG_FAILED
;
8866 ecommunity_merge(ecom
, ecomadd
);
8867 ecommunity_free(&ecomadd
);
8874 ecommunity_free(&*list
);
8882 * v2vimport is true if we are handling a `import vrf ...` command
8884 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8888 switch (vty
->node
) {
8897 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8902 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8903 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8904 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8905 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8907 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8911 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8912 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8913 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8914 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8916 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8923 DEFPY (af_rd_vpn_export
,
8924 af_rd_vpn_export_cmd
,
8925 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8927 "Specify route distinguisher\n"
8928 "Between current address-family and vpn\n"
8929 "For routes leaked from current address-family to vpn\n"
8930 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8932 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8933 struct prefix_rd prd
;
8939 if (argv_find(argv
, argc
, "no", &idx
))
8943 ret
= str2prefix_rd(rd_str
, &prd
);
8945 vty_out(vty
, "%% Malformed rd\n");
8946 return CMD_WARNING_CONFIG_FAILED
;
8950 afi
= vpn_policy_getafi(vty
, bgp
, false);
8952 return CMD_WARNING_CONFIG_FAILED
;
8955 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8957 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8958 bgp_get_default(), bgp
);
8961 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
8962 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8963 BGP_VPN_POLICY_TOVPN_RD_SET
);
8965 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8966 BGP_VPN_POLICY_TOVPN_RD_SET
);
8969 /* post-change: re-export vpn routes */
8970 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8971 bgp_get_default(), bgp
);
8976 ALIAS (af_rd_vpn_export
,
8977 af_no_rd_vpn_export_cmd
,
8980 "Specify route distinguisher\n"
8981 "Between current address-family and vpn\n"
8982 "For routes leaked from current address-family to vpn\n")
8984 DEFPY (af_label_vpn_export
,
8985 af_label_vpn_export_cmd
,
8986 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
8988 "label value for VRF\n"
8989 "Between current address-family and vpn\n"
8990 "For routes leaked from current address-family to vpn\n"
8991 "Label Value <0-1048575>\n"
8992 "Automatically assign a label\n")
8994 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8995 mpls_label_t label
= MPLS_LABEL_NONE
;
9000 if (argv_find(argv
, argc
, "no", &idx
))
9003 /* If "no ...", squash trailing parameter */
9009 label
= label_val
; /* parser should force unsigned */
9012 afi
= vpn_policy_getafi(vty
, bgp
, false);
9014 return CMD_WARNING_CONFIG_FAILED
;
9017 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9018 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
9023 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9025 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9026 bgp_get_default(), bgp
);
9028 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9029 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
9031 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
9034 * label has previously been automatically
9035 * assigned by labelpool: release it
9037 * NB if tovpn_label == MPLS_LABEL_NONE it
9038 * means the automatic assignment is in flight
9039 * and therefore the labelpool callback must
9040 * detect that the auto label is not needed.
9043 bgp_lp_release(LP_TYPE_VRF
,
9044 &bgp
->vpn_policy
[afi
],
9045 bgp
->vpn_policy
[afi
].tovpn_label
);
9047 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9048 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9051 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
9053 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9054 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9055 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
9056 vpn_leak_label_callback
);
9059 /* post-change: re-export vpn routes */
9060 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9061 bgp_get_default(), bgp
);
9063 hook_call(bgp_snmp_update_last_changed
, bgp
);
9067 DEFPY (af_sid_vpn_export
,
9068 af_sid_vpn_export_cmd
,
9069 "[no] sid vpn export <(1-1048575)$sid_idx|auto$sid_auto>",
9071 "sid value for VRF\n"
9072 "Between current address-family and vpn\n"
9073 "For routes leaked from current address-family to vpn\n"
9074 "Sid allocation index\n"
9075 "Automatically assign a label\n")
9077 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9083 if (argv_find(argv
, argc
, "no", &idx
))
9085 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
9086 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
9088 afi
= vpn_policy_getafi(vty
, bgp
, false);
9090 return CMD_WARNING_CONFIG_FAILED
;
9094 vty_out(vty
, "It's not implemented\n");
9095 return CMD_WARNING_CONFIG_FAILED
;
9098 if (bgp
->tovpn_sid_index
!= 0 ||
9099 CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)) {
9101 "per-vrf sid and per-af sid are mutually exclusive\n"
9102 "Failed: per-vrf sid is configured. Remove per-vrf sid before configuring per-af sid\n");
9103 return CMD_WARNING_CONFIG_FAILED
;
9106 /* skip when it's already configured */
9107 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9108 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9109 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
9113 * mode change between sid_idx and sid_auto isn't supported.
9114 * user must negate sid vpn export when they want to change the mode
9116 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9117 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9118 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
9119 vty_out(vty
, "it's already configured as %s.\n",
9120 sid_auto
? "auto-mode" : "idx-mode");
9121 return CMD_WARNING_CONFIG_FAILED
;
9125 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9126 bgp_get_default(), bgp
);
9129 /* SID allocation auto-mode */
9131 zlog_debug("%s: auto sid alloc.", __func__
);
9132 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9133 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
9135 /* SID allocation index-mode */
9137 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
9138 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
9142 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9143 bgp_get_default(), bgp
);
9147 DEFPY (bgp_sid_vpn_export
,
9148 bgp_sid_vpn_export_cmd
,
9149 "[no] sid vpn per-vrf export <(1-1048575)$sid_idx|auto$sid_auto>",
9151 "sid value for VRF\n"
9152 "Between current vrf and vpn\n"
9153 "sid per-VRF (both IPv4 and IPv6 address families)\n"
9154 "For routes leaked from current vrf to vpn\n"
9155 "Sid allocation index\n"
9156 "Automatically assign a label\n")
9158 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9161 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
9162 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
9165 /* when per-VRF SID is not set, do nothing */
9166 if (bgp
->tovpn_sid_index
== 0 &&
9167 !CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
))
9172 bgp
->tovpn_sid_index
= 0;
9173 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
);
9176 if (bgp
->vpn_policy
[AFI_IP
].tovpn_sid_index
!= 0 ||
9177 CHECK_FLAG(bgp
->vpn_policy
[AFI_IP
].flags
,
9178 BGP_VPN_POLICY_TOVPN_SID_AUTO
) ||
9179 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid_index
!= 0 ||
9180 CHECK_FLAG(bgp
->vpn_policy
[AFI_IP6
].flags
,
9181 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
9183 "per-vrf sid and per-af sid are mutually exclusive\n"
9184 "Failed: per-af sid is configured. Remove per-af sid before configuring per-vrf sid\n");
9185 return CMD_WARNING_CONFIG_FAILED
;
9188 /* skip when it's already configured */
9189 if ((sid_idx
!= 0 && bgp
->tovpn_sid_index
!= 0) ||
9190 (sid_auto
&& CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)))
9194 * mode change between sid_idx and sid_auto isn't supported.
9195 * user must negate sid vpn export when they want to change the mode
9197 if ((sid_auto
&& bgp
->tovpn_sid_index
!= 0) ||
9199 CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
))) {
9200 vty_out(vty
, "it's already configured as %s.\n",
9201 sid_auto
? "auto-mode" : "idx-mode");
9202 return CMD_WARNING_CONFIG_FAILED
;
9206 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP
, bgp_get_default(),
9208 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP6
, bgp_get_default(),
9212 /* SID allocation auto-mode */
9214 zlog_debug("%s: auto per-vrf sid alloc.", __func__
);
9215 SET_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
);
9216 } else if (sid_idx
!= 0) {
9217 /* SID allocation index-mode */
9219 zlog_debug("%s: idx %ld per-vrf sid alloc.", __func__
,
9221 bgp
->tovpn_sid_index
= sid_idx
;
9225 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP
, bgp_get_default(),
9227 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP6
,
9228 bgp_get_default(), bgp
);
9233 ALIAS (af_label_vpn_export
,
9234 af_no_label_vpn_export_cmd
,
9235 "no label vpn export",
9237 "label value for VRF\n"
9238 "Between current address-family and vpn\n"
9239 "For routes leaked from current address-family to vpn\n")
9241 ALIAS (bgp_sid_vpn_export
,
9242 no_bgp_sid_vpn_export_cmd
,
9243 "no$no sid vpn per-vrf export",
9245 "sid value for VRF\n"
9246 "Between current vrf and vpn\n"
9247 "sid per-VRF (both IPv4 and IPv6 address families)\n"
9248 "For routes leaked from current vrf to vpn\n")
9250 DEFPY (af_nexthop_vpn_export
,
9251 af_nexthop_vpn_export_cmd
,
9252 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
9254 "Specify next hop to use for VRF advertised prefixes\n"
9255 "Between current address-family and vpn\n"
9256 "For routes leaked from current address-family to vpn\n"
9260 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9266 vty_out(vty
, "%% Nexthop required\n");
9267 return CMD_WARNING_CONFIG_FAILED
;
9269 if (!sockunion2hostprefix(nexthop_su
, &p
))
9270 return CMD_WARNING_CONFIG_FAILED
;
9273 afi
= vpn_policy_getafi(vty
, bgp
, false);
9275 return CMD_WARNING_CONFIG_FAILED
;
9278 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9280 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9281 bgp_get_default(), bgp
);
9284 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
9285 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9286 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9288 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9289 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9292 /* post-change: re-export vpn routes */
9293 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9294 bgp_get_default(), bgp
);
9299 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9301 if (!strcmp(dstr
, "import")) {
9302 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9303 } else if (!strcmp(dstr
, "export")) {
9304 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9305 } else if (!strcmp(dstr
, "both")) {
9306 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9307 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9309 vty_out(vty
, "%% direction parse error\n");
9310 return CMD_WARNING_CONFIG_FAILED
;
9315 DEFPY (af_rt_vpn_imexport
,
9316 af_rt_vpn_imexport_cmd
,
9317 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9319 "Specify route target list\n"
9320 "Specify route target list\n"
9321 "Between current address-family and vpn\n"
9322 "For routes leaked from vpn to current address-family: match any\n"
9323 "For routes leaked from current address-family to vpn: set\n"
9324 "both import: match any and export: set\n"
9325 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9327 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9329 struct ecommunity
*ecom
= NULL
;
9330 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9331 enum vpn_policy_direction dir
;
9336 if (argv_find(argv
, argc
, "no", &idx
))
9339 afi
= vpn_policy_getafi(vty
, bgp
, false);
9341 return CMD_WARNING_CONFIG_FAILED
;
9343 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9344 if (ret
!= CMD_SUCCESS
)
9348 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9349 vty_out(vty
, "%% Missing RTLIST\n");
9350 return CMD_WARNING_CONFIG_FAILED
;
9352 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9353 if (ret
!= CMD_SUCCESS
) {
9358 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9362 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9365 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9367 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9368 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9369 ecommunity_dup(ecom
);
9371 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9373 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9374 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9377 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9381 ecommunity_free(&ecom
);
9386 ALIAS (af_rt_vpn_imexport
,
9387 af_no_rt_vpn_imexport_cmd
,
9388 "no <rt|route-target> vpn <import|export|both>$direction_str",
9390 "Specify route target list\n"
9391 "Specify route target list\n"
9392 "Between current address-family and vpn\n"
9393 "For routes leaked from vpn to current address-family\n"
9394 "For routes leaked from current address-family to vpn\n"
9395 "both import and export\n")
9397 DEFPY (af_route_map_vpn_imexport
,
9398 af_route_map_vpn_imexport_cmd
,
9399 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9400 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9402 "Specify route map\n"
9403 "Between current address-family and vpn\n"
9404 "For routes leaked from vpn to current address-family\n"
9405 "For routes leaked from current address-family to vpn\n"
9406 "name of route-map\n")
9408 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9410 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9411 enum vpn_policy_direction dir
;
9416 if (argv_find(argv
, argc
, "no", &idx
))
9419 afi
= vpn_policy_getafi(vty
, bgp
, false);
9421 return CMD_WARNING_CONFIG_FAILED
;
9423 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9424 if (ret
!= CMD_SUCCESS
)
9427 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9431 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9434 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9435 XFREE(MTYPE_ROUTE_MAP_NAME
,
9436 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9437 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
9438 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9439 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9440 route_map_lookup_warn_noexist(vty
, rmap_str
);
9441 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9444 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9445 XFREE(MTYPE_ROUTE_MAP_NAME
,
9446 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9447 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9448 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9451 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9457 ALIAS (af_route_map_vpn_imexport
,
9458 af_no_route_map_vpn_imexport_cmd
,
9459 "no route-map vpn <import|export>$direction_str",
9461 "Specify route map\n"
9462 "Between current address-family and vpn\n"
9463 "For routes leaked from vpn to current address-family\n"
9464 "For routes leaked from current address-family to vpn\n")
9466 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9467 "import vrf route-map RMAP$rmap_str",
9468 "Import routes from another VRF\n"
9469 "Vrf routes being filtered\n"
9470 "Specify route map\n"
9471 "name of route-map\n")
9473 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9474 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9476 struct bgp
*bgp_default
;
9478 afi
= vpn_policy_getafi(vty
, bgp
, true);
9480 return CMD_WARNING_CONFIG_FAILED
;
9482 bgp_default
= bgp_get_default();
9487 /* Auto-create assuming the same AS */
9488 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9489 BGP_INSTANCE_TYPE_DEFAULT
);
9493 "VRF default is not configured as a bgp instance\n");
9498 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9500 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9501 XFREE(MTYPE_ROUTE_MAP_NAME
,
9502 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9503 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9504 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9505 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9506 route_map_lookup_warn_noexist(vty
, rmap_str
);
9507 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9510 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9511 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9513 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9518 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9519 "no import vrf route-map [RMAP$rmap_str]",
9521 "Import routes from another VRF\n"
9522 "Vrf routes being filtered\n"
9523 "Specify route map\n"
9524 "name of route-map\n")
9526 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9527 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9530 afi
= vpn_policy_getafi(vty
, bgp
, true);
9532 return CMD_WARNING_CONFIG_FAILED
;
9534 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9536 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9537 XFREE(MTYPE_ROUTE_MAP_NAME
,
9538 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9539 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9540 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9542 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9543 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9544 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9546 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9551 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
9552 "[no] import vrf VIEWVRFNAME$import_name",
9554 "Import routes from another VRF\n"
9555 "VRF to import from\n"
9556 "The name of the VRF\n")
9558 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9559 struct listnode
*node
;
9560 struct bgp
*vrf_bgp
, *bgp_default
;
9563 bool remove
= false;
9566 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
9570 if (import_name
== NULL
) {
9571 vty_out(vty
, "%% Missing import name\n");
9575 if (strcmp(import_name
, "route-map") == 0) {
9576 vty_out(vty
, "%% Must include route-map name\n");
9580 if (argv_find(argv
, argc
, "no", &idx
))
9583 afi
= vpn_policy_getafi(vty
, bgp
, true);
9585 return CMD_WARNING_CONFIG_FAILED
;
9587 safi
= bgp_node_safi(vty
);
9589 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
9590 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
9591 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
9592 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
9593 remove
? "unimport" : "import", import_name
);
9597 bgp_default
= bgp_get_default();
9599 /* Auto-create assuming the same AS */
9600 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9601 BGP_INSTANCE_TYPE_DEFAULT
);
9605 "VRF default is not configured as a bgp instance\n");
9610 vrf_bgp
= bgp_lookup_by_name(import_name
);
9612 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
9613 vrf_bgp
= bgp_default
;
9615 /* Auto-create assuming the same AS */
9616 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
9620 "VRF %s is not configured as a bgp instance\n",
9627 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9629 /* Already importing from "import_vrf"? */
9630 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
9632 if (strcmp(vname
, import_name
) == 0)
9636 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9642 /* This command is valid only in a bgp vrf instance or the default instance */
9643 DEFPY (bgp_imexport_vpn
,
9644 bgp_imexport_vpn_cmd
,
9645 "[no] <import|export>$direction_str vpn",
9647 "Import routes to this address-family\n"
9648 "Export routes from this address-family\n"
9649 "to/from default instance VPN RIB\n")
9651 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9658 enum vpn_policy_direction dir
;
9660 if (argv_find(argv
, argc
, "no", &idx
))
9663 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
9664 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
9666 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
9667 return CMD_WARNING_CONFIG_FAILED
;
9670 afi
= bgp_node_afi(vty
);
9671 safi
= bgp_node_safi(vty
);
9672 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
9673 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
9674 return CMD_WARNING_CONFIG_FAILED
;
9677 if (!strcmp(direction_str
, "import")) {
9678 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
9679 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9680 } else if (!strcmp(direction_str
, "export")) {
9681 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
9682 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
9684 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9685 return CMD_WARNING_CONFIG_FAILED
;
9688 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9691 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9692 if (!previous_state
) {
9693 /* trigger export current vrf */
9694 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9697 if (previous_state
) {
9698 /* trigger un-export current vrf */
9699 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9701 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9704 hook_call(bgp_snmp_init_stats
, bgp
);
9709 DEFPY (af_routetarget_import
,
9710 af_routetarget_import_cmd
,
9711 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9713 "Specify route target list\n"
9714 "Specify route target list\n"
9715 "Specify route target list\n"
9716 "Specify route target list\n"
9717 "Flow-spec redirect type route target\n"
9718 "Import routes to this address-family\n"
9719 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9721 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9723 struct ecommunity
*ecom
= NULL
;
9725 int idx
= 0, idx_unused
= 0;
9729 if (argv_find(argv
, argc
, "no", &idx
))
9732 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9733 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9736 afi
= vpn_policy_getafi(vty
, bgp
, false);
9738 return CMD_WARNING_CONFIG_FAILED
;
9740 if (rt6
&& afi
!= AFI_IP6
)
9741 return CMD_WARNING_CONFIG_FAILED
;
9744 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9745 vty_out(vty
, "%% Missing RTLIST\n");
9746 return CMD_WARNING_CONFIG_FAILED
;
9748 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9749 if (ret
!= CMD_SUCCESS
)
9754 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9755 ecommunity_free(&bgp
->vpn_policy
[afi
]
9756 .import_redirect_rtlist
);
9757 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9758 ecommunity_dup(ecom
);
9760 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9761 ecommunity_free(&bgp
->vpn_policy
[afi
]
9762 .import_redirect_rtlist
);
9763 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9767 ecommunity_free(&ecom
);
9772 DEFUN_NOSH (address_family_ipv4_safi
,
9773 address_family_ipv4_safi_cmd
,
9774 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9775 "Enter Address Family command mode\n"
9777 BGP_SAFI_WITH_LABEL_HELP_STR
)
9781 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9782 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9783 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9784 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9785 && safi
!= SAFI_EVPN
) {
9787 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9788 return CMD_WARNING_CONFIG_FAILED
;
9790 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9792 vty
->node
= BGP_IPV4_NODE
;
9797 DEFUN_NOSH (address_family_ipv6_safi
,
9798 address_family_ipv6_safi_cmd
,
9799 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9800 "Enter Address Family command mode\n"
9802 BGP_SAFI_WITH_LABEL_HELP_STR
)
9805 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9806 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9807 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9808 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9809 && safi
!= SAFI_EVPN
) {
9811 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9812 return CMD_WARNING_CONFIG_FAILED
;
9814 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9816 vty
->node
= BGP_IPV6_NODE
;
9821 #ifdef KEEP_OLD_VPN_COMMANDS
9822 DEFUN_NOSH (address_family_vpnv4
,
9823 address_family_vpnv4_cmd
,
9824 "address-family vpnv4 [unicast]",
9825 "Enter Address Family command mode\n"
9827 BGP_AF_MODIFIER_STR
)
9829 vty
->node
= BGP_VPNV4_NODE
;
9833 DEFUN_NOSH (address_family_vpnv6
,
9834 address_family_vpnv6_cmd
,
9835 "address-family vpnv6 [unicast]",
9836 "Enter Address Family command mode\n"
9838 BGP_AF_MODIFIER_STR
)
9840 vty
->node
= BGP_VPNV6_NODE
;
9843 #endif /* KEEP_OLD_VPN_COMMANDS */
9845 DEFUN_NOSH (address_family_evpn
,
9846 address_family_evpn_cmd
,
9847 "address-family l2vpn evpn",
9848 "Enter Address Family command mode\n"
9850 BGP_AF_MODIFIER_STR
)
9852 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9853 vty
->node
= BGP_EVPN_NODE
;
9857 DEFUN_NOSH (bgp_segment_routing_srv6
,
9858 bgp_segment_routing_srv6_cmd
,
9859 "segment-routing srv6",
9860 "Segment-Routing configuration\n"
9861 "Segment-Routing SRv6 configuration\n")
9863 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9864 bgp
->srv6_enabled
= true;
9865 vty
->node
= BGP_SRV6_NODE
;
9869 DEFUN (no_bgp_segment_routing_srv6
,
9870 no_bgp_segment_routing_srv6_cmd
,
9871 "no segment-routing srv6",
9873 "Segment-Routing configuration\n"
9874 "Segment-Routing SRv6 configuration\n")
9876 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9878 if (strlen(bgp
->srv6_locator_name
) > 0)
9879 if (bgp_srv6_locator_unset(bgp
) < 0)
9880 return CMD_WARNING_CONFIG_FAILED
;
9882 bgp
->srv6_enabled
= false;
9886 DEFPY (bgp_srv6_locator
,
9887 bgp_srv6_locator_cmd
,
9888 "locator NAME$name",
9889 "Specify SRv6 locator\n"
9890 "Specify SRv6 locator\n")
9892 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9895 if (strlen(bgp
->srv6_locator_name
) > 0
9896 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9897 vty_out(vty
, "srv6 locator is already configured\n");
9898 return CMD_WARNING_CONFIG_FAILED
;
9901 snprintf(bgp
->srv6_locator_name
,
9902 sizeof(bgp
->srv6_locator_name
), "%s", name
);
9904 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
9906 return CMD_WARNING_CONFIG_FAILED
;
9911 DEFPY (no_bgp_srv6_locator
,
9912 no_bgp_srv6_locator_cmd
,
9913 "no locator NAME$name",
9915 "Specify SRv6 locator\n"
9916 "Specify SRv6 locator\n")
9918 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9920 /* when locator isn't configured, do nothing */
9921 if (strlen(bgp
->srv6_locator_name
) < 1)
9924 /* name validation */
9925 if (strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9926 vty_out(vty
, "%% No srv6 locator is configured\n");
9927 return CMD_WARNING_CONFIG_FAILED
;
9931 if (bgp_srv6_locator_unset(bgp
) < 0)
9932 return CMD_WARNING_CONFIG_FAILED
;
9937 DEFPY (show_bgp_srv6
,
9939 "show bgp segment-routing srv6",
9942 "BGP Segment Routing\n"
9943 "BGP Segment Routing SRv6\n")
9946 struct listnode
*node
;
9947 struct srv6_locator_chunk
*chunk
;
9948 struct bgp_srv6_function
*func
;
9950 bgp
= bgp_get_default();
9954 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
9955 vty_out(vty
, "locator_chunks:\n");
9956 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
)) {
9957 vty_out(vty
, "- %pFX\n", &chunk
->prefix
);
9958 vty_out(vty
, " block-length: %d\n", chunk
->block_bits_length
);
9959 vty_out(vty
, " node-length: %d\n", chunk
->node_bits_length
);
9960 vty_out(vty
, " func-length: %d\n",
9961 chunk
->function_bits_length
);
9962 vty_out(vty
, " arg-length: %d\n", chunk
->argument_bits_length
);
9965 vty_out(vty
, "functions:\n");
9966 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
9967 vty_out(vty
, "- sid: %pI6\n", &func
->sid
);
9968 vty_out(vty
, " locator: %s\n", func
->locator_name
);
9971 vty_out(vty
, "bgps:\n");
9972 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
9973 vty_out(vty
, "- name: %s\n",
9974 bgp
->name
? bgp
->name
: "default");
9976 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %pI6\n",
9977 bgp
->vpn_policy
[AFI_IP
].tovpn_sid
);
9978 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %pI6\n",
9979 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
);
9980 vty_out(vty
, " per-vrf tovpn_sid: %pI6\n", bgp
->tovpn_sid
);
9986 DEFUN_NOSH (exit_address_family
,
9987 exit_address_family_cmd
,
9988 "exit-address-family",
9989 "Exit from Address Family configuration mode\n")
9991 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9992 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9993 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9994 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9995 || vty
->node
== BGP_EVPN_NODE
9996 || vty
->node
== BGP_FLOWSPECV4_NODE
9997 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9998 vty
->node
= BGP_NODE
;
10002 /* Recalculate bestpath and re-advertise a prefix */
10003 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
10004 const char *ip_str
, afi_t afi
, safi_t safi
,
10005 struct prefix_rd
*prd
)
10008 struct prefix match
;
10009 struct bgp_dest
*dest
;
10010 struct bgp_dest
*rm
;
10012 struct bgp_table
*table
;
10013 struct bgp_table
*rib
;
10015 /* BGP structure lookup. */
10017 bgp
= bgp_lookup_by_name(view_name
);
10019 vty_out(vty
, "%% Can't find BGP instance %s\n",
10021 return CMD_WARNING
;
10024 bgp
= bgp_get_default();
10026 vty_out(vty
, "%% No BGP process is configured\n");
10027 return CMD_WARNING
;
10031 /* Check IP address argument. */
10032 ret
= str2prefix(ip_str
, &match
);
10034 vty_out(vty
, "%% address is malformed\n");
10035 return CMD_WARNING
;
10038 match
.family
= afi2family(afi
);
10039 rib
= bgp
->rib
[afi
][safi
];
10041 if (safi
== SAFI_MPLS_VPN
) {
10042 for (dest
= bgp_table_top(rib
); dest
;
10043 dest
= bgp_route_next(dest
)) {
10044 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
10046 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
10049 table
= bgp_dest_get_bgp_table_info(dest
);
10053 rm
= bgp_node_match(table
, &match
);
10055 const struct prefix
*rm_p
=
10056 bgp_dest_get_prefix(rm
);
10058 if (rm_p
->prefixlen
== match
.prefixlen
) {
10059 SET_FLAG(rm
->flags
,
10060 BGP_NODE_USER_CLEAR
);
10061 bgp_process(bgp
, rm
, afi
, safi
);
10063 bgp_dest_unlock_node(rm
);
10067 dest
= bgp_node_match(rib
, &match
);
10068 if (dest
!= NULL
) {
10069 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
10071 if (dest_p
->prefixlen
== match
.prefixlen
) {
10072 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
10073 bgp_process(bgp
, dest
, afi
, safi
);
10075 bgp_dest_unlock_node(dest
);
10079 return CMD_SUCCESS
;
10082 /* one clear bgp command to rule them all */
10083 DEFUN (clear_ip_bgp_all
,
10084 clear_ip_bgp_all_cmd
,
10085 "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>]",
10089 BGP_INSTANCE_HELP_STR
10092 BGP_SAFI_WITH_LABEL_HELP_STR
10093 BGP_AF_MODIFIER_STR
10094 "Clear all peers\n"
10095 "BGP IPv4 neighbor to clear\n"
10096 "BGP IPv6 neighbor to clear\n"
10097 "BGP neighbor on interface to clear\n"
10098 "Clear peers with the AS number\n"
10099 "Clear all external peers\n"
10100 "Clear all members of peer-group\n"
10101 "BGP peer-group name\n"
10106 "Push out prefix-list ORF and do inbound soft reconfig\n"
10108 "Reset message statistics\n")
10112 afi_t afi
= AFI_UNSPEC
;
10113 safi_t safi
= SAFI_UNSPEC
;
10114 enum clear_sort clr_sort
= clear_peer
;
10115 enum bgp_clear_type clr_type
;
10116 char *clr_arg
= NULL
;
10120 /* clear [ip] bgp */
10121 if (argv_find(argv
, argc
, "ip", &idx
))
10124 /* [<vrf> VIEWVRFNAME] */
10125 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10126 vrf
= argv
[idx
+ 1]->arg
;
10128 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10130 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10131 /* [<view> VIEWVRFNAME] */
10132 vrf
= argv
[idx
+ 1]->arg
;
10135 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
10136 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
10137 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
10139 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
10140 if (argv_find(argv
, argc
, "*", &idx
)) {
10141 clr_sort
= clear_all
;
10142 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
10143 clr_sort
= clear_peer
;
10144 clr_arg
= argv
[idx
]->arg
;
10145 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
10146 clr_sort
= clear_peer
;
10147 clr_arg
= argv
[idx
]->arg
;
10148 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
10149 clr_sort
= clear_group
;
10151 clr_arg
= argv
[idx
]->arg
;
10152 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
10153 clr_sort
= clear_peer
;
10154 clr_arg
= argv
[idx
]->arg
;
10155 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
10156 clr_sort
= clear_peer
;
10157 clr_arg
= argv
[idx
]->arg
;
10158 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
10159 clr_sort
= clear_as
;
10160 clr_arg
= argv
[idx
]->arg
;
10161 } else if (argv_find(argv
, argc
, "external", &idx
)) {
10162 clr_sort
= clear_external
;
10165 /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */
10166 if (argv_find(argv
, argc
, "soft", &idx
)) {
10167 if (argv_find(argv
, argc
, "in", &idx
)
10168 || argv_find(argv
, argc
, "out", &idx
))
10169 clr_type
= strmatch(argv
[idx
]->text
, "in")
10170 ? BGP_CLEAR_SOFT_IN
10171 : BGP_CLEAR_SOFT_OUT
;
10173 clr_type
= BGP_CLEAR_SOFT_BOTH
;
10174 } else if (argv_find(argv
, argc
, "in", &idx
)) {
10175 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
10176 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
10177 : BGP_CLEAR_SOFT_IN
;
10178 } else if (argv_find(argv
, argc
, "out", &idx
)) {
10179 clr_type
= BGP_CLEAR_SOFT_OUT
;
10180 } else if (argv_find(argv
, argc
, "message-stats", &idx
)) {
10181 clr_type
= BGP_CLEAR_MESSAGE_STATS
;
10183 clr_type
= BGP_CLEAR_SOFT_NONE
;
10185 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
10188 DEFUN (clear_ip_bgp_prefix
,
10189 clear_ip_bgp_prefix_cmd
,
10190 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
10194 BGP_INSTANCE_HELP_STR
10195 "Clear bestpath and re-advertise\n"
10199 char *prefix
= NULL
;
10203 /* [<view|vrf> VIEWVRFNAME] */
10204 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10205 vrf
= argv
[idx
+ 1]->arg
;
10207 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10209 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10210 /* [<view> VIEWVRFNAME] */
10211 vrf
= argv
[idx
+ 1]->arg
;
10215 prefix
= argv
[argc
- 1]->arg
;
10217 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
10220 DEFUN (clear_bgp_ipv6_safi_prefix
,
10221 clear_bgp_ipv6_safi_prefix_cmd
,
10222 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10228 "Clear bestpath and re-advertise\n"
10232 int idx_ipv6_prefix
= 0;
10233 safi_t safi
= SAFI_UNICAST
;
10234 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10235 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10237 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10238 return bgp_clear_prefix(
10239 vty
, NULL
, prefix
, AFI_IP6
,
10243 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
10244 clear_bgp_instance_ipv6_safi_prefix_cmd
,
10245 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10249 BGP_INSTANCE_HELP_STR
10252 "Clear bestpath and re-advertise\n"
10256 int idx_vrfview
= 0;
10257 int idx_ipv6_prefix
= 0;
10258 safi_t safi
= SAFI_UNICAST
;
10259 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10260 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10261 char *vrfview
= NULL
;
10263 /* [<view|vrf> VIEWVRFNAME] */
10264 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
10265 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10266 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
10268 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
10269 /* [<view> VIEWVRFNAME] */
10270 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10272 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10274 return bgp_clear_prefix(
10275 vty
, vrfview
, prefix
,
10276 AFI_IP6
, safi
, NULL
);
10279 DEFUN (show_bgp_views
,
10280 show_bgp_views_cmd
,
10281 "show [ip] bgp views",
10285 "Show the defined BGP views\n")
10287 struct list
*inst
= bm
->bgp
;
10288 struct listnode
*node
;
10291 vty_out(vty
, "Defined BGP views:\n");
10292 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10294 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10296 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
10300 return CMD_SUCCESS
;
10303 static inline void calc_peers_cfgd_estbd(struct bgp
*bgp
, int *peers_cfgd
,
10307 struct listnode
*node
;
10309 *peers_cfgd
= *peers_estbd
= 0;
10310 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, node
, peer
)) {
10311 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10314 if (peer_established(peer
))
10319 static void print_bgp_vrfs(struct bgp
*bgp
, struct vty
*vty
, json_object
*json
,
10322 int peers_cfg
, peers_estb
;
10324 calc_peers_cfgd_estbd(bgp
, &peers_cfg
, &peers_estb
);
10327 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10329 : (int64_t)bgp
->vrf_id
;
10330 json_object_string_add(json
, "type", type
);
10331 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10332 json_object_string_addf(json
, "routerId", "%pI4",
10334 json_object_int_add(json
, "numConfiguredPeers", peers_cfg
);
10335 json_object_int_add(json
, "numEstablishedPeers", peers_estb
);
10336 json_object_int_add(json
, "l3vni", bgp
->l3vni
);
10337 json_object_string_addf(json
, "rmac", "%pEA", &bgp
->rmac
);
10338 json_object_string_add(
10340 ifindex2ifname(bgp
->l3vni_svi_ifindex
, bgp
->vrf_id
));
10344 static int show_bgp_vrfs_detail_common(struct vty
*vty
, struct bgp
*bgp
,
10345 json_object
*json
, const char *name
,
10346 const char *type
, bool use_vrf
)
10348 int peers_cfg
, peers_estb
;
10350 calc_peers_cfgd_estbd(bgp
, &peers_cfg
, &peers_estb
);
10354 print_bgp_vrfs(bgp
, vty
, json
, type
);
10356 vty_out(vty
, "BGP instance %s VRF id %d\n",
10358 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10359 : (int)bgp
->vrf_id
);
10360 vty_out(vty
, "Router Id %pI4\n", &bgp
->router_id
);
10362 "Num Configured Peers %d, Established %d\n",
10363 peers_cfg
, peers_estb
);
10366 "L3VNI %u, L3VNI-SVI %s, Router MAC %pEA\n",
10368 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10375 print_bgp_vrfs(bgp
, vty
, json
, type
);
10377 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10379 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10380 : (int)bgp
->vrf_id
,
10381 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10382 vty_out(vty
, "%11s %-16u %-21pEA %-20s\n", " ",
10383 bgp
->l3vni
, &bgp
->rmac
,
10384 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10389 return CMD_SUCCESS
;
10392 DEFPY (show_bgp_vrfs
,
10394 "show [ip] bgp vrfs [<VRFNAME$vrf_name>] [json]",
10399 "Specific VRF name\n"
10402 struct list
*inst
= bm
->bgp
;
10403 struct listnode
*node
;
10405 bool uj
= use_json(argc
, argv
);
10406 json_object
*json
= NULL
;
10407 json_object
*json_vrfs
= NULL
;
10408 json_object
*json_vrf
= NULL
;
10410 const char *name
= vrf_name
;
10414 json
= json_object_new_object();
10417 if (strmatch(name
, VRF_DEFAULT_NAME
)) {
10418 bgp
= bgp_get_default();
10421 bgp
= bgp_lookup_by_name(name
);
10426 vty_json(vty
, json
);
10429 "%% Specified BGP instance not found\n");
10431 return CMD_WARNING
;
10437 json_vrf
= json_object_new_object();
10439 show_bgp_vrfs_detail_common(vty
, bgp
, json_vrf
, name
, type
,
10443 json_object_object_add(json
, name
, json_vrf
);
10444 vty_json(vty
, json
);
10447 return CMD_SUCCESS
;
10451 json_vrfs
= json_object_new_object();
10453 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10457 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10461 if (!uj
&& count
== 1) {
10463 "%4s %-5s %-16s %9s %10s %-37s\n",
10464 "Type", "Id", "routerId", "#PeersCfg",
10465 "#PeersEstb", "Name");
10466 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10467 "L3-VNI", "RouterMAC", "Interface");
10470 json_vrf
= json_object_new_object();
10472 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10473 name
= VRF_DEFAULT_NAME
;
10480 show_bgp_vrfs_detail_common(vty
, bgp
, json_vrf
, name
, type
,
10484 json_object_object_add(json_vrfs
, name
, json_vrf
);
10488 json_object_object_add(json
, "vrfs", json_vrfs
);
10489 json_object_int_add(json
, "totalVrfs", count
);
10490 vty_json(vty
, json
);
10494 "\nTotal number of VRFs (including default): %d\n",
10498 return CMD_SUCCESS
;
10501 DEFUN (show_bgp_mac_hash
,
10502 show_bgp_mac_hash_cmd
,
10503 "show bgp mac hash",
10507 "Mac Address database\n")
10509 bgp_mac_dump_table(vty
);
10511 return CMD_SUCCESS
;
10514 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10516 struct vty
*vty
= (struct vty
*)args
;
10517 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10519 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10522 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10524 vty_out(vty
, "self nexthop database:\n");
10525 bgp_nexthop_show_address_hash(vty
, bgp
);
10527 vty_out(vty
, "Tunnel-ip database:\n");
10528 hash_iterate(bgp
->tip_hash
,
10529 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10533 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10534 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10535 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10536 "martian next-hops\n"
10537 "martian next-hop database\n")
10539 struct bgp
*bgp
= NULL
;
10543 /* [<vrf> VIEWVRFNAME] */
10544 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10545 name
= argv
[idx
+ 1]->arg
;
10546 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10548 } else if (argv_find(argv
, argc
, "view", &idx
))
10549 /* [<view> VIEWVRFNAME] */
10550 name
= argv
[idx
+ 1]->arg
;
10552 bgp
= bgp_lookup_by_name(name
);
10554 bgp
= bgp_get_default();
10557 vty_out(vty
, "%% No BGP process is configured\n");
10558 return CMD_WARNING
;
10560 bgp_show_martian_nexthops(vty
, bgp
);
10562 return CMD_SUCCESS
;
10565 DEFUN (show_bgp_memory
,
10566 show_bgp_memory_cmd
,
10567 "show [ip] bgp memory",
10571 "Global BGP memory statistics\n")
10573 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10574 unsigned long count
;
10576 /* RIB related usage stats */
10577 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10578 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10579 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10580 count
* sizeof(struct bgp_dest
)));
10582 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10583 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10584 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10585 count
* sizeof(struct bgp_path_info
)));
10586 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10587 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10590 memstrbuf
, sizeof(memstrbuf
),
10591 count
* sizeof(struct bgp_path_info_extra
)));
10593 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10594 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10595 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10596 count
* sizeof(struct bgp_static
)));
10598 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10599 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10600 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10601 count
* sizeof(struct bpacket
)));
10604 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10605 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10606 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10607 count
* sizeof(struct bgp_adj_in
)));
10608 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10609 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10610 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10611 count
* sizeof(struct bgp_adj_out
)));
10613 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10614 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10616 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10617 count
* sizeof(struct bgp_nexthop_cache
)));
10619 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10620 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10622 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10623 count
* sizeof(struct bgp_damp_info
)));
10626 count
= attr_count();
10627 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10628 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10629 count
* sizeof(struct attr
)));
10631 if ((count
= attr_unknown_count()))
10632 vty_out(vty
, "%ld unknown attributes\n", count
);
10634 /* AS_PATH attributes */
10635 count
= aspath_count();
10636 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10637 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10638 count
* sizeof(struct aspath
)));
10640 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10641 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10642 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10643 count
* sizeof(struct assegment
)));
10645 /* Other attributes */
10646 if ((count
= community_count()))
10647 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10648 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10649 count
* sizeof(struct community
)));
10650 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10652 "%ld BGP ext-community entries, using %s of memory\n",
10654 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10655 count
* sizeof(struct ecommunity
)));
10656 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10658 "%ld BGP large-community entries, using %s of memory\n",
10659 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10660 count
* sizeof(struct lcommunity
)));
10662 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10663 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10664 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10665 count
* sizeof(struct cluster_list
)));
10667 /* Peer related usage */
10668 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10669 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10670 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10671 count
* sizeof(struct peer
)));
10673 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10674 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10675 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10676 count
* sizeof(struct peer_group
)));
10679 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10680 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10681 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10682 count
* sizeof(regex_t
)));
10683 return CMD_SUCCESS
;
10686 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10688 json_object
*bestpath
= json_object_new_object();
10690 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10691 json_object_string_add(bestpath
, "asPath", "ignore");
10693 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10694 json_object_string_add(bestpath
, "asPath", "confed");
10696 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10697 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10698 json_object_string_add(bestpath
, "multiPathRelax",
10701 json_object_string_add(bestpath
, "multiPathRelax",
10704 json_object_string_add(bestpath
, "multiPathRelax", "false");
10706 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10707 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10709 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10710 json_object_string_add(bestpath
, "compareRouterId", "true");
10711 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10712 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10713 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10714 json_object_string_add(bestpath
, "med", "confed");
10715 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10716 json_object_string_add(bestpath
, "med",
10717 "missing-as-worst");
10719 json_object_string_add(bestpath
, "med", "true");
10722 json_object_object_add(json
, "bestPath", bestpath
);
10725 /* Print the error code/subcode for why the peer is down */
10726 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10727 json_object
*json_peer
, bool use_json
)
10729 const char *code_str
;
10730 const char *subcode_str
;
10733 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10734 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10735 char errorcodesubcode_hexstr
[5];
10736 char errorcodesubcode_str
[256];
10738 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10739 subcode_str
= bgp_notify_subcode_str(
10741 peer
->notify
.subcode
);
10743 snprintf(errorcodesubcode_hexstr
,
10744 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10745 peer
->notify
.code
, peer
->notify
.subcode
);
10746 json_object_string_add(json_peer
,
10747 "lastErrorCodeSubcode",
10748 errorcodesubcode_hexstr
);
10749 snprintf(errorcodesubcode_str
, 255, "%s%s",
10750 code_str
, subcode_str
);
10751 json_object_string_add(json_peer
,
10752 "lastNotificationReason",
10753 errorcodesubcode_str
);
10754 json_object_boolean_add(json_peer
,
10755 "lastNotificationHardReset",
10756 peer
->notify
.hard_reset
);
10757 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10758 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10759 && (peer
->notify
.subcode
10760 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10761 || peer
->notify
.subcode
10762 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10763 && peer
->notify
.length
) {
10765 const char *msg_str
;
10767 msg_str
= bgp_notify_admin_message(
10768 msgbuf
, sizeof(msgbuf
),
10769 (uint8_t *)peer
->notify
.data
,
10770 peer
->notify
.length
);
10772 json_object_string_add(
10774 "lastShutdownDescription",
10779 json_object_string_add(json_peer
, "lastResetDueTo",
10780 peer_down_str
[(int)peer
->last_reset
]);
10781 json_object_int_add(json_peer
, "lastResetCode",
10784 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10785 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10786 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10788 bgp_notify_subcode_str(peer
->notify
.code
,
10789 peer
->notify
.subcode
);
10790 vty_out(vty
, " Notification %s (%s%s%s)\n",
10791 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10794 code_str
, subcode_str
,
10795 peer
->notify
.hard_reset
10796 ? bgp_notify_subcode_str(
10798 BGP_NOTIFY_CEASE_HARD_RESET
)
10801 vty_out(vty
, " %s\n",
10802 peer_down_str
[(int)peer
->last_reset
]);
10807 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10810 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10813 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10814 struct peer
*peer
, json_object
*json_peer
,
10815 int max_neighbor_width
, bool use_json
)
10817 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10821 if (peer_dynamic_neighbor(peer
))
10822 json_object_boolean_true_add(json_peer
,
10824 if (peer
->hostname
)
10825 json_object_string_add(json_peer
, "hostname",
10828 if (peer
->domainname
)
10829 json_object_string_add(json_peer
, "domainname",
10831 json_object_int_add(json_peer
, "connectionsEstablished",
10832 peer
->established
);
10833 json_object_int_add(json_peer
, "connectionsDropped",
10835 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10836 use_json
, json_peer
);
10837 if (peer_established(peer
))
10838 json_object_string_add(json_peer
, "lastResetDueTo",
10839 "AFI/SAFI Not Negotiated");
10841 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10844 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10846 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10847 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10848 peer
->hostname
, peer
->host
);
10850 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10852 /* pad the neighbor column with spaces */
10853 if (len
< max_neighbor_width
)
10854 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10856 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10858 peer_uptime(peer
->uptime
, timebuf
,
10859 BGP_UPTIME_LEN
, 0, NULL
));
10860 if (peer_established(peer
))
10861 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10863 bgp_show_peer_reset(vty
, peer
, NULL
,
10868 /* Strip peer's description to the given size. */
10869 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10871 static char stripped
[BUFSIZ
];
10873 uint32_t last_space
= 0;
10876 if (*(desc
+ i
) == 0) {
10877 stripped
[i
] = '\0';
10880 if (i
!= 0 && *(desc
+ i
) == ' ' && last_space
!= i
- 1)
10882 stripped
[i
] = *(desc
+ i
);
10886 if (last_space
> size
)
10887 stripped
[size
+ 1] = '\0';
10889 stripped
[last_space
] = '\0';
10894 /* Determine whether var peer should be filtered out of the summary. */
10895 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10896 struct peer
*fpeer
, int as_type
,
10900 /* filter neighbor XXXX */
10901 if (fpeer
&& fpeer
!= peer
)
10904 /* filter remote-as (internal|external) */
10905 if (as_type
!= AS_UNSPECIFIED
) {
10906 if (peer
->as_type
== AS_SPECIFIED
) {
10907 if (as_type
== AS_INTERNAL
) {
10908 if (peer
->as
!= peer
->local_as
)
10910 } else if (peer
->as
== peer
->local_as
)
10912 } else if (as_type
!= peer
->as_type
)
10914 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10920 /* Show BGP peer's summary information.
10922 * Peer's description is stripped according to if `wide` option is given
10925 * When adding new columns to `show bgp summary` output, please make
10926 * sure `Desc` is the lastest column to show because it can contain
10927 * whitespaces and the whole output will be tricky.
10929 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10930 struct peer
*fpeer
, int as_type
, as_t as
,
10931 uint16_t show_flags
)
10934 struct listnode
*node
, *nnode
;
10935 unsigned int count
= 0, dn_count
= 0;
10936 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10937 char neighbor_buf
[VTY_BUFSIZ
];
10938 int neighbor_col_default_width
= 16;
10939 int len
, failed_count
= 0;
10940 unsigned int filtered_count
= 0;
10941 int max_neighbor_width
= 0;
10943 json_object
*json
= NULL
;
10944 json_object
*json_peer
= NULL
;
10945 json_object
*json_peers
= NULL
;
10946 struct peer_af
*paf
;
10947 struct bgp_filter
*filter
;
10948 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10949 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10950 bool show_established
=
10951 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10952 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10953 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
10955 /* labeled-unicast routes are installed in the unicast table so in order
10957 * display the correct PfxRcd value we must look at SAFI_UNICAST
10960 if (safi
== SAFI_LABELED_UNICAST
)
10961 pfx_rcd_safi
= SAFI_UNICAST
;
10963 pfx_rcd_safi
= safi
;
10966 json
= json_object_new_object();
10967 json_peers
= json_object_new_object();
10968 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10969 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
10976 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10979 if (peer
->afc
[afi
][safi
]) {
10980 /* See if we have at least a single failed peer */
10981 if (bgp_has_peer_failed(peer
, afi
, safi
))
10985 if (peer_dynamic_neighbor(peer
))
10990 /* Loop over all neighbors that will be displayed to determine
10992 * characters are needed for the Neighbor column
10994 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10995 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11002 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11005 if (peer
->afc
[afi
][safi
]) {
11006 memset(dn_flag
, '\0', sizeof(dn_flag
));
11007 if (peer_dynamic_neighbor(peer
))
11011 && CHECK_FLAG(bgp
->flags
,
11012 BGP_FLAG_SHOW_HOSTNAME
))
11013 snprintf(neighbor_buf
,
11014 sizeof(neighbor_buf
),
11015 "%s%s(%s) ", dn_flag
,
11016 peer
->hostname
, peer
->host
);
11018 snprintf(neighbor_buf
,
11019 sizeof(neighbor_buf
), "%s%s ",
11020 dn_flag
, peer
->host
);
11022 len
= strlen(neighbor_buf
);
11024 if (len
> max_neighbor_width
)
11025 max_neighbor_width
= len
;
11027 /* See if we have at least a single failed peer */
11028 if (bgp_has_peer_failed(peer
, afi
, safi
))
11034 /* Originally we displayed the Neighbor column as 16
11035 * characters wide so make that the default
11037 if (max_neighbor_width
< neighbor_col_default_width
)
11038 max_neighbor_width
= neighbor_col_default_width
;
11041 if (show_failed
&& !failed_count
) {
11043 json_object_int_add(json
, "failedPeersCount", 0);
11044 json_object_int_add(json
, "dynamicPeers", dn_count
);
11045 json_object_int_add(json
, "totalPeers", count
);
11047 vty_json(vty
, json
);
11049 vty_out(vty
, "%% No failed BGP neighbors found\n");
11051 return CMD_SUCCESS
;
11054 count
= 0; /* Reset the value as its used again */
11055 filtered_count
= 0;
11057 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11058 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11061 if (!peer
->afc
[afi
][safi
])
11065 unsigned long ents
;
11066 char memstrbuf
[MTYPE_MEMSTR_LEN
];
11069 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
11071 : (int64_t)bgp
->vrf_id
;
11073 /* Usage summary and header */
11075 json_object_string_addf(json
, "routerId",
11078 json_object_int_add(json
, "as", bgp
->as
);
11079 json_object_int_add(json
, "vrfId", vrf_id_ui
);
11080 json_object_string_add(
11083 == BGP_INSTANCE_TYPE_DEFAULT
)
11088 "BGP router identifier %pI4, local AS number %u vrf-id %d",
11089 &bgp
->router_id
, bgp
->as
,
11090 bgp
->vrf_id
== VRF_UNKNOWN
11092 : (int)bgp
->vrf_id
);
11093 vty_out(vty
, "\n");
11096 if (bgp_update_delay_configured(bgp
)) {
11098 json_object_int_add(
11099 json
, "updateDelayLimit",
11100 bgp
->v_update_delay
);
11102 if (bgp
->v_update_delay
11103 != bgp
->v_establish_wait
)
11104 json_object_int_add(
11106 "updateDelayEstablishWait",
11107 bgp
->v_establish_wait
);
11109 if (bgp_update_delay_active(bgp
)) {
11110 json_object_string_add(
11112 "updateDelayFirstNeighbor",
11113 bgp
->update_delay_begin_time
);
11114 json_object_boolean_true_add(
11116 "updateDelayInProgress");
11118 if (bgp
->update_delay_over
) {
11119 json_object_string_add(
11121 "updateDelayFirstNeighbor",
11122 bgp
->update_delay_begin_time
);
11123 json_object_string_add(
11125 "updateDelayBestpathResumed",
11126 bgp
->update_delay_end_time
);
11127 json_object_string_add(
11129 "updateDelayZebraUpdateResume",
11130 bgp
->update_delay_zebra_resume_time
);
11131 json_object_string_add(
11133 "updateDelayPeerUpdateResume",
11134 bgp
->update_delay_peers_resume_time
);
11139 "Read-only mode update-delay limit: %d seconds\n",
11140 bgp
->v_update_delay
);
11141 if (bgp
->v_update_delay
11142 != bgp
->v_establish_wait
)
11144 " Establish wait: %d seconds\n",
11145 bgp
->v_establish_wait
);
11147 if (bgp_update_delay_active(bgp
)) {
11149 " First neighbor established: %s\n",
11150 bgp
->update_delay_begin_time
);
11152 " Delay in progress\n");
11154 if (bgp
->update_delay_over
) {
11156 " First neighbor established: %s\n",
11157 bgp
->update_delay_begin_time
);
11159 " Best-paths resumed: %s\n",
11160 bgp
->update_delay_end_time
);
11162 " zebra update resumed: %s\n",
11163 bgp
->update_delay_zebra_resume_time
);
11165 " peers update resumed: %s\n",
11166 bgp
->update_delay_peers_resume_time
);
11173 if (bgp_maxmed_onstartup_configured(bgp
)
11174 && bgp
->maxmed_active
)
11175 json_object_boolean_true_add(
11176 json
, "maxMedOnStartup");
11177 if (bgp
->v_maxmed_admin
)
11178 json_object_boolean_true_add(
11179 json
, "maxMedAdministrative");
11181 json_object_int_add(
11182 json
, "tableVersion",
11183 bgp_table_version(bgp
->rib
[afi
][safi
]));
11185 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
11186 json_object_int_add(json
, "ribCount", ents
);
11187 json_object_int_add(
11189 ents
* sizeof(struct bgp_dest
));
11191 ents
= bgp
->af_peer_count
[afi
][safi
];
11192 json_object_int_add(json
, "peerCount", ents
);
11193 json_object_int_add(json
, "peerMemory",
11194 ents
* sizeof(struct peer
));
11196 if ((ents
= listcount(bgp
->group
))) {
11197 json_object_int_add(
11198 json
, "peerGroupCount", ents
);
11199 json_object_int_add(
11200 json
, "peerGroupMemory",
11201 ents
* sizeof(struct
11205 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11206 BGP_CONFIG_DAMPENING
))
11207 json_object_boolean_true_add(
11208 json
, "dampeningEnabled");
11211 if (bgp_maxmed_onstartup_configured(bgp
)
11212 && bgp
->maxmed_active
)
11214 "Max-med on-startup active\n");
11215 if (bgp
->v_maxmed_admin
)
11217 "Max-med administrative active\n");
11220 "BGP table version %" PRIu64
11223 bgp
->rib
[afi
][safi
]));
11225 ents
= bgp_table_count(
11226 bgp
->rib
[afi
][safi
]);
11228 "RIB entries %ld, using %s of memory\n",
11238 /* Peer related usage */
11239 ents
= bgp
->af_peer_count
[afi
][safi
];
11241 "Peers %ld, using %s of memory\n",
11251 if ((ents
= listcount(bgp
->group
)))
11253 "Peer groups %ld, using %s of memory\n",
11263 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11264 BGP_CONFIG_DAMPENING
))
11266 "Dampening enabled.\n");
11269 vty_out(vty
, "\n");
11271 /* Subtract 8 here because 'Neighbor' is
11273 vty_out(vty
, "Neighbor");
11274 vty_out(vty
, "%*s",
11275 max_neighbor_width
- 8, " ");
11277 BGP_SHOW_SUMMARY_HEADER_FAILED
);
11282 paf
= peer_af_find(peer
, afi
, safi
);
11283 filter
= &peer
->filter
[afi
][safi
];
11286 /* Works for both failed & successful cases */
11287 if (peer_dynamic_neighbor(peer
))
11292 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11298 bgp_has_peer_failed(peer
, afi
, safi
)) {
11299 json_peer
= json_object_new_object();
11300 bgp_show_failed_summary(vty
, bgp
, peer
,
11301 json_peer
, 0, use_json
);
11302 } else if (!show_failed
) {
11303 if (show_established
11304 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11309 json_peer
= json_object_new_object();
11310 if (peer_dynamic_neighbor(peer
)) {
11311 json_object_boolean_true_add(json_peer
,
11315 if (peer
->hostname
)
11316 json_object_string_add(json_peer
, "hostname",
11319 if (peer
->domainname
)
11320 json_object_string_add(json_peer
, "domainname",
11323 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
11324 json_object_int_add(
11325 json_peer
, "localAs",
11326 peer
->change_local_as
11327 ? peer
->change_local_as
11329 json_object_int_add(json_peer
, "version", 4);
11330 json_object_int_add(json_peer
, "msgRcvd",
11331 PEER_TOTAL_RX(peer
));
11332 json_object_int_add(json_peer
, "msgSent",
11333 PEER_TOTAL_TX(peer
));
11335 atomic_size_t outq_count
, inq_count
;
11336 outq_count
= atomic_load_explicit(
11337 &peer
->obuf
->count
,
11338 memory_order_relaxed
);
11339 inq_count
= atomic_load_explicit(
11340 &peer
->ibuf
->count
,
11341 memory_order_relaxed
);
11343 json_object_int_add(json_peer
, "tableVersion",
11344 peer
->version
[afi
][safi
]);
11345 json_object_int_add(json_peer
, "outq",
11347 json_object_int_add(json_peer
, "inq",
11349 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
11350 use_json
, json_peer
);
11352 json_object_int_add(json_peer
, "pfxRcd",
11353 peer
->pcount
[afi
][pfx_rcd_safi
]);
11355 if (paf
&& PAF_SUBGRP(paf
))
11356 json_object_int_add(
11357 json_peer
, "pfxSnt",
11358 (PAF_SUBGRP(paf
))->scount
);
11360 json_object_int_add(json_peer
, "pfxSnt",
11363 /* BGP FSM state */
11364 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11365 || CHECK_FLAG(peer
->bgp
->flags
,
11366 BGP_FLAG_SHUTDOWN
))
11367 json_object_string_add(json_peer
,
11370 else if (peer
->afc_recv
[afi
][safi
])
11371 json_object_string_add(
11372 json_peer
, "state",
11373 lookup_msg(bgp_status_msg
,
11374 peer
->status
, NULL
));
11375 else if (CHECK_FLAG(
11377 PEER_STATUS_PREFIX_OVERFLOW
))
11378 json_object_string_add(json_peer
,
11382 json_object_string_add(
11383 json_peer
, "state",
11384 lookup_msg(bgp_status_msg
,
11385 peer
->status
, NULL
));
11387 /* BGP peer state */
11388 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11389 || CHECK_FLAG(peer
->bgp
->flags
,
11390 BGP_FLAG_SHUTDOWN
))
11391 json_object_string_add(json_peer
,
11394 else if (CHECK_FLAG(
11396 PEER_STATUS_PREFIX_OVERFLOW
))
11397 json_object_string_add(json_peer
,
11400 else if (CHECK_FLAG(peer
->flags
,
11401 PEER_FLAG_PASSIVE
))
11402 json_object_string_add(json_peer
,
11405 else if (CHECK_FLAG(peer
->sflags
,
11406 PEER_STATUS_NSF_WAIT
))
11407 json_object_string_add(json_peer
,
11410 else if (CHECK_FLAG(
11412 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11413 && (!bgp_inbound_policy_exists(peer
,
11415 || !bgp_outbound_policy_exists(
11417 json_object_string_add(json_peer
,
11421 json_object_string_add(
11422 json_peer
, "peerState", "OK");
11424 json_object_int_add(json_peer
, "connectionsEstablished",
11425 peer
->established
);
11426 json_object_int_add(json_peer
, "connectionsDropped",
11429 json_object_string_add(
11430 json_peer
, "desc", peer
->desc
);
11432 /* Avoid creating empty peer dicts in JSON */
11433 if (json_peer
== NULL
)
11437 json_object_string_add(json_peer
, "idType",
11439 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11440 json_object_string_add(json_peer
, "idType",
11442 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11443 json_object_string_add(json_peer
, "idType",
11445 json_object_object_add(json_peers
, peer
->host
,
11448 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11454 bgp_has_peer_failed(peer
, afi
, safi
)) {
11455 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11456 max_neighbor_width
,
11458 } else if (!show_failed
) {
11459 if (show_established
11460 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11465 if ((count
- filtered_count
) == 1) {
11466 /* display headline before the first
11468 vty_out(vty
, "\n");
11470 /* Subtract 8 here because 'Neighbor' is
11472 vty_out(vty
, "Neighbor");
11473 vty_out(vty
, "%*s",
11474 max_neighbor_width
- 8, " ");
11477 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
11478 : BGP_SHOW_SUMMARY_HEADER_ALL
);
11481 memset(dn_flag
, '\0', sizeof(dn_flag
));
11482 if (peer_dynamic_neighbor(peer
)) {
11487 && CHECK_FLAG(bgp
->flags
,
11488 BGP_FLAG_SHOW_HOSTNAME
))
11489 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11493 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11495 /* pad the neighbor column with spaces */
11496 if (len
< max_neighbor_width
)
11497 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11500 atomic_size_t outq_count
, inq_count
;
11501 outq_count
= atomic_load_explicit(
11502 &peer
->obuf
->count
,
11503 memory_order_relaxed
);
11504 inq_count
= atomic_load_explicit(
11505 &peer
->ibuf
->count
,
11506 memory_order_relaxed
);
11510 "4 %10u %10u %9u %9u %8" PRIu64
11513 peer
->change_local_as
11514 ? peer
->change_local_as
11516 PEER_TOTAL_RX(peer
),
11517 PEER_TOTAL_TX(peer
),
11518 peer
->version
[afi
][safi
],
11519 inq_count
, outq_count
,
11520 peer_uptime(peer
->uptime
,
11525 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11527 peer
->as
, PEER_TOTAL_RX(peer
),
11528 PEER_TOTAL_TX(peer
),
11529 peer
->version
[afi
][safi
],
11530 inq_count
, outq_count
,
11531 peer_uptime(peer
->uptime
,
11536 if (peer_established(peer
)) {
11537 if (peer
->afc_recv
[afi
][safi
]) {
11540 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11541 && !bgp_inbound_policy_exists(
11543 vty_out(vty
, " %12s",
11552 vty_out(vty
, " NoNeg");
11555 if (paf
&& PAF_SUBGRP(paf
)) {
11558 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11559 && !bgp_outbound_policy_exists(
11561 vty_out(vty
, " %8s",
11570 vty_out(vty
, " NoNeg");
11573 if (CHECK_FLAG(peer
->flags
,
11574 PEER_FLAG_SHUTDOWN
)
11575 || CHECK_FLAG(peer
->bgp
->flags
,
11576 BGP_FLAG_SHUTDOWN
))
11577 vty_out(vty
, " Idle (Admin)");
11578 else if (CHECK_FLAG(
11580 PEER_STATUS_PREFIX_OVERFLOW
))
11581 vty_out(vty
, " Idle (PfxCt)");
11583 vty_out(vty
, " %12s",
11584 lookup_msg(bgp_status_msg
,
11585 peer
->status
, NULL
));
11587 vty_out(vty
, " %8u", 0);
11589 /* Make sure `Desc` column is the lastest in
11593 vty_out(vty
, " %s",
11594 bgp_peer_description_stripped(
11596 show_wide
? 64 : 20));
11598 vty_out(vty
, " N/A");
11599 vty_out(vty
, "\n");
11606 json_object_object_add(json
, "peers", json_peers
);
11607 json_object_int_add(json
, "failedPeers", failed_count
);
11608 json_object_int_add(json
, "displayedPeers",
11609 count
- filtered_count
);
11610 json_object_int_add(json
, "totalPeers", count
);
11611 json_object_int_add(json
, "dynamicPeers", dn_count
);
11614 bgp_show_bestpath_json(bgp
, json
);
11616 vty_json(vty
, json
);
11619 if (filtered_count
== count
)
11620 vty_out(vty
, "\n%% No matching neighbor\n");
11623 vty_out(vty
, "\nDisplayed neighbors %d",
11625 else if (as_type
!= AS_UNSPECIFIED
|| as
11626 || fpeer
|| show_established
)
11627 vty_out(vty
, "\nDisplayed neighbors %d",
11628 count
- filtered_count
);
11630 vty_out(vty
, "\nTotal number of neighbors %d\n",
11634 vty_out(vty
, "No %s neighbor is configured\n",
11635 get_afi_safi_str(afi
, safi
, false));
11639 vty_out(vty
, "* - dynamic neighbor\n");
11640 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11641 dn_count
, bgp
->dynamic_neighbors_limit
);
11645 return CMD_SUCCESS
;
11648 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11649 int safi
, struct peer
*fpeer
, int as_type
,
11650 as_t as
, uint16_t show_flags
)
11653 int afi_wildcard
= (afi
== AFI_MAX
);
11654 int safi_wildcard
= (safi
== SAFI_MAX
);
11655 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11656 bool nbr_output
= false;
11657 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11659 if (use_json
&& is_wildcard
)
11660 vty_out(vty
, "{\n");
11662 afi
= 1; /* AFI_IP */
11663 while (afi
< AFI_MAX
) {
11665 safi
= 1; /* SAFI_UNICAST */
11666 while (safi
< SAFI_MAX
) {
11667 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11672 * So limit output to those afi/safi
11674 * actualy have something interesting in
11679 vty_out(vty
, ",\n");
11683 vty_out(vty
, "\"%s\":",
11684 get_afi_safi_str(afi
,
11689 "\n%s Summary (%s):\n",
11690 get_afi_safi_str(afi
,
11696 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11697 as_type
, as
, show_flags
);
11700 if (!safi_wildcard
)
11708 if (use_json
&& is_wildcard
)
11709 vty_out(vty
, "}\n");
11710 else if (!nbr_output
) {
11712 vty_out(vty
, "{}\n");
11714 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11719 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11721 const char *neighbor
,
11722 int as_type
, as_t as
,
11723 uint16_t show_flags
)
11725 struct listnode
*node
, *nnode
;
11727 struct peer
*fpeer
= NULL
;
11729 bool nbr_output
= false;
11730 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11733 vty_out(vty
, "{\n");
11735 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11739 vty_out(vty
, ",\n");
11743 vty_out(vty
, "\"%s\":",
11744 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11749 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11754 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11759 vty_out(vty
, "}\n");
11760 else if (!nbr_output
)
11761 vty_out(vty
, "%% BGP instance not found\n");
11764 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11765 safi_t safi
, const char *neighbor
, int as_type
,
11766 as_t as
, uint16_t show_flags
)
11769 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11770 struct peer
*fpeer
= NULL
;
11773 if (strmatch(name
, "all")) {
11774 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11777 return CMD_SUCCESS
;
11779 bgp
= bgp_lookup_by_name(name
);
11783 vty_out(vty
, "{}\n");
11786 "%% BGP instance not found\n");
11787 return CMD_WARNING
;
11791 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11794 return CMD_WARNING
;
11796 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11797 as_type
, as
, show_flags
);
11798 return CMD_SUCCESS
;
11802 bgp
= bgp_get_default();
11806 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11809 return CMD_WARNING
;
11811 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11815 vty_out(vty
, "{}\n");
11817 vty_out(vty
, "%% BGP instance not found\n");
11818 return CMD_WARNING
;
11821 return CMD_SUCCESS
;
11824 /* `show [ip] bgp summary' commands. */
11825 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11826 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11827 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11828 "]] [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]",
11829 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11830 BGP_SAFI_WITH_LABEL_HELP_STR
11831 "Display the entries for all address families\n"
11832 "Summary of BGP neighbor status\n"
11833 "Show only sessions in Established state\n"
11834 "Show only sessions not in Established state\n"
11835 "Show only the specified neighbor session\n"
11836 "Neighbor to display information about\n"
11837 "Neighbor to display information about\n"
11838 "Neighbor on BGP configured interface\n"
11839 "Show only the specified remote AS sessions\n"
11841 "Internal (iBGP) AS sessions\n"
11842 "External (eBGP) AS sessions\n"
11843 "Shorten the information on BGP instances\n"
11844 "Increase table width for longer output\n" JSON_STR
)
11847 afi_t afi
= AFI_MAX
;
11848 safi_t safi
= SAFI_MAX
;
11849 as_t as
= 0; /* 0 means AS filter not set */
11850 int as_type
= AS_UNSPECIFIED
;
11851 uint16_t show_flags
= 0;
11855 /* show [ip] bgp */
11856 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11858 /* [<vrf> VIEWVRFNAME] */
11859 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11860 vrf
= argv
[idx
+ 1]->arg
;
11861 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11863 } else if (argv_find(argv
, argc
, "view", &idx
))
11864 /* [<view> VIEWVRFNAME] */
11865 vrf
= argv
[idx
+ 1]->arg
;
11866 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11867 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11868 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11871 if (argv_find(argv
, argc
, "failed", &idx
))
11872 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11874 if (argv_find(argv
, argc
, "established", &idx
))
11875 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11877 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11878 if (argv
[idx
+ 1]->arg
[0] == 'i')
11879 as_type
= AS_INTERNAL
;
11880 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11881 as_type
= AS_EXTERNAL
;
11883 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11886 if (argv_find(argv
, argc
, "terse", &idx
))
11887 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11889 if (argv_find(argv
, argc
, "wide", &idx
))
11890 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11892 if (argv_find(argv
, argc
, "json", &idx
))
11893 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11895 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11899 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11902 return get_afi_safi_json_str(afi
, safi
);
11904 return get_afi_safi_vty_str(afi
, safi
);
11908 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11909 afi_t afi
, safi_t safi
,
11910 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11911 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11912 bool use_json
, json_object
*json_pref
)
11915 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11916 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11918 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11919 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11920 json_object_string_add(json_pref
, "sendMode",
11921 "advertisedAndReceived");
11922 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11923 json_object_string_add(json_pref
, "sendMode",
11925 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11926 json_object_string_add(json_pref
, "sendMode",
11929 vty_out(vty
, " Send-mode: ");
11930 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11931 vty_out(vty
, "advertised");
11932 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11933 vty_out(vty
, "%sreceived",
11934 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11938 vty_out(vty
, "\n");
11943 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11944 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11946 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11947 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11948 json_object_string_add(json_pref
, "recvMode",
11949 "advertisedAndReceived");
11950 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11951 json_object_string_add(json_pref
, "recvMode",
11953 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11954 json_object_string_add(json_pref
, "recvMode",
11957 vty_out(vty
, " Receive-mode: ");
11958 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11959 vty_out(vty
, "advertised");
11960 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11961 vty_out(vty
, "%sreceived",
11962 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11966 vty_out(vty
, "\n");
11971 static void bgp_show_neighnor_graceful_restart_flags(struct vty
*vty
,
11978 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11979 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11980 && (peer_established(p
))) {
11981 rbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV
);
11982 nbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV
);
11986 json_object_boolean_add(json
, "rBit", rbit
);
11987 json_object_boolean_add(json
, "nBit", nbit
);
11989 vty_out(vty
, "\n R bit: %s", rbit
? "True" : "False");
11990 vty_out(vty
, "\n N bit: %s\n", nbit
? "True" : "False");
11994 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11998 const char *mode
= "NotApplicable";
12001 vty_out(vty
, "\n Remote GR Mode: ");
12003 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
12004 && (peer_established(peer
))) {
12006 if ((peer
->nsf_af_count
== 0)
12007 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
12011 } else if (peer
->nsf_af_count
== 0
12012 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
12016 } else if (peer
->nsf_af_count
!= 0
12017 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
12024 json_object_string_add(json
, "remoteGrMode", mode
);
12026 vty_out(vty
, "%s\n", mode
);
12029 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
12033 const char *mode
= "Invalid";
12036 vty_out(vty
, " Local GR Mode: ");
12038 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
12040 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
12042 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
12044 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
12045 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
12047 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
12049 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
12056 json_object_string_add(json
, "localGrMode", mode
);
12058 vty_out(vty
, "%s\n", mode
);
12061 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
12062 struct vty
*vty
, struct peer
*peer
, json_object
*json
)
12066 json_object
*json_afi_safi
= NULL
;
12067 json_object
*json_timer
= NULL
;
12068 json_object
*json_endofrib_status
= NULL
;
12069 bool eor_flag
= false;
12071 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
12072 if (!peer
->afc
[afi
][safi
])
12075 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
12076 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
12080 json_afi_safi
= json_object_new_object();
12081 json_endofrib_status
= json_object_new_object();
12082 json_timer
= json_object_new_object();
12085 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
12091 vty_out(vty
, " %s:\n",
12092 get_afi_safi_str(afi
, safi
, false));
12094 vty_out(vty
, " F bit: ");
12097 if (peer
->nsf
[afi
][safi
] &&
12098 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
12099 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
12102 json_object_boolean_true_add(json_afi_safi
,
12105 vty_out(vty
, "True\n");
12108 json_object_boolean_false_add(json_afi_safi
,
12111 vty_out(vty
, "False\n");
12115 vty_out(vty
, " End-of-RIB sent: ");
12117 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
12118 PEER_STATUS_EOR_SEND
)) {
12120 json_object_boolean_true_add(
12121 json_endofrib_status
, "endOfRibSend");
12123 PRINT_EOR_JSON(eor_flag
);
12125 vty_out(vty
, "Yes\n");
12127 " End-of-RIB sent after update: ");
12129 PRINT_EOR(eor_flag
);
12133 json_object_boolean_false_add(
12134 json_endofrib_status
, "endOfRibSend");
12135 json_object_boolean_false_add(
12136 json_endofrib_status
,
12137 "endOfRibSentAfterUpdate");
12139 vty_out(vty
, "No\n");
12141 " End-of-RIB sent after update: ");
12142 vty_out(vty
, "No\n");
12147 vty_out(vty
, " End-of-RIB received: ");
12149 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
12150 PEER_STATUS_EOR_RECEIVED
)) {
12152 json_object_boolean_true_add(
12153 json_endofrib_status
, "endOfRibRecv");
12155 vty_out(vty
, "Yes\n");
12158 json_object_boolean_false_add(
12159 json_endofrib_status
, "endOfRibRecv");
12161 vty_out(vty
, "No\n");
12165 json_object_int_add(json_timer
, "stalePathTimer",
12166 peer
->bgp
->stalepath_time
);
12168 if (peer
->t_gr_stale
!= NULL
) {
12169 json_object_int_add(json_timer
,
12170 "stalePathTimerRemaining",
12171 thread_timer_remain_second(
12172 peer
->t_gr_stale
));
12175 /* Display Configured Selection
12176 * Deferral only when when
12177 * Gr mode is enabled.
12179 if (CHECK_FLAG(peer
->flags
,
12180 PEER_FLAG_GRACEFUL_RESTART
)) {
12181 json_object_int_add(json_timer
,
12182 "selectionDeferralTimer",
12183 peer
->bgp
->stalepath_time
);
12186 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
12189 json_object_int_add(
12191 "selectionDeferralTimerRemaining",
12192 thread_timer_remain_second(
12193 peer
->bgp
->gr_info
[afi
][safi
]
12194 .t_select_deferral
));
12197 vty_out(vty
, " Timers:\n");
12199 " Configured Stale Path Time(sec): %u\n",
12200 peer
->bgp
->stalepath_time
);
12202 if (peer
->t_gr_stale
!= NULL
)
12204 " Stale Path Remaining(sec): %ld\n",
12205 thread_timer_remain_second(
12206 peer
->t_gr_stale
));
12207 /* Display Configured Selection
12208 * Deferral only when when
12209 * Gr mode is enabled.
12211 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
12213 " Configured Selection Deferral Time(sec): %u\n",
12214 peer
->bgp
->select_defer_time
);
12216 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
12219 " Selection Deferral Time Remaining(sec): %ld\n",
12220 thread_timer_remain_second(
12221 peer
->bgp
->gr_info
[afi
][safi
]
12222 .t_select_deferral
));
12225 json_object_object_add(json_afi_safi
, "endOfRibStatus",
12226 json_endofrib_status
);
12227 json_object_object_add(json_afi_safi
, "timers",
12229 json_object_object_add(
12230 json
, get_afi_safi_str(afi
, safi
, true),
12236 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
12241 json_object
*json_timer
= NULL
;
12243 json_timer
= json_object_new_object();
12245 json_object_int_add(json_timer
, "configuredRestartTimer",
12246 p
->bgp
->restart_time
);
12248 json_object_int_add(json_timer
, "receivedRestartTimer",
12251 if (p
->t_gr_restart
!= NULL
)
12252 json_object_int_add(
12253 json_timer
, "restartTimerRemaining",
12254 thread_timer_remain_second(p
->t_gr_restart
));
12256 json_object_object_add(json
, "timers", json_timer
);
12259 vty_out(vty
, " Timers:\n");
12260 vty_out(vty
, " Configured Restart Time(sec): %u\n",
12261 p
->bgp
->restart_time
);
12263 vty_out(vty
, " Received Restart Time(sec): %u\n",
12265 if (p
->t_gr_restart
!= NULL
)
12266 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12267 thread_timer_remain_second(p
->t_gr_restart
));
12268 if (p
->t_gr_restart
!= NULL
) {
12269 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12270 thread_timer_remain_second(p
->t_gr_restart
));
12275 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
12278 char dn_flag
[2] = {0};
12279 /* '*' + v6 address of neighbor */
12280 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
12282 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12287 json_object_string_addf(json
, "neighborAddr", "%pSU",
12290 vty_out(vty
, "BGP neighbor on %s: %pSU\n", p
->conf_if
,
12293 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
12297 json_object_string_add(json
, "neighborAddr",
12300 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
12303 /* more gr info in new format */
12304 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, json
);
12307 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
12308 safi_t safi
, bool use_json
,
12309 json_object
*json_neigh
)
12311 struct bgp_filter
*filter
;
12312 struct peer_af
*paf
;
12313 char orf_pfx_name
[BUFSIZ
];
12315 json_object
*json_af
= NULL
;
12316 json_object
*json_prefA
= NULL
;
12317 json_object
*json_prefB
= NULL
;
12318 json_object
*json_addr
= NULL
;
12319 json_object
*json_advmap
= NULL
;
12322 json_addr
= json_object_new_object();
12323 json_af
= json_object_new_object();
12324 filter
= &p
->filter
[afi
][safi
];
12326 if (peer_group_active(p
))
12327 json_object_string_add(json_addr
, "peerGroupMember",
12330 paf
= peer_af_find(p
, afi
, safi
);
12331 if (paf
&& PAF_SUBGRP(paf
)) {
12332 json_object_int_add(json_addr
, "updateGroupId",
12333 PAF_UPDGRP(paf
)->id
);
12334 json_object_int_add(json_addr
, "subGroupId",
12335 PAF_SUBGRP(paf
)->id
);
12336 json_object_int_add(json_addr
, "packetQueueLength",
12337 bpacket_queue_virtual_length(paf
));
12340 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12341 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12342 PEER_CAP_ORF_PREFIX_SM_RCV
)
12343 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12344 PEER_CAP_ORF_PREFIX_RM_ADV
)
12345 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12346 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12347 json_object_int_add(json_af
, "orfType",
12349 json_prefA
= json_object_new_object();
12350 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
12351 PEER_CAP_ORF_PREFIX_SM_ADV
,
12352 PEER_CAP_ORF_PREFIX_RM_ADV
,
12353 PEER_CAP_ORF_PREFIX_SM_RCV
,
12354 PEER_CAP_ORF_PREFIX_RM_RCV
,
12355 use_json
, json_prefA
);
12356 json_object_object_add(json_af
, "orfPrefixList",
12360 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12361 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12362 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12363 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12364 PEER_CAP_ORF_PREFIX_RM_ADV
)
12365 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12366 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12367 json_object_int_add(json_af
, "orfOldType",
12368 ORF_TYPE_PREFIX_OLD
);
12369 json_prefB
= json_object_new_object();
12370 bgp_show_peer_afi_orf_cap(
12371 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12372 PEER_CAP_ORF_PREFIX_RM_ADV
,
12373 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12374 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
12376 json_object_object_add(json_af
, "orfOldPrefixList",
12380 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12381 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12382 PEER_CAP_ORF_PREFIX_SM_RCV
)
12383 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12384 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12385 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12386 PEER_CAP_ORF_PREFIX_RM_ADV
)
12387 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12388 PEER_CAP_ORF_PREFIX_RM_RCV
)
12389 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12390 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12391 json_object_object_add(json_addr
, "afDependentCap",
12394 json_object_free(json_af
);
12396 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12397 p
->host
, afi
, safi
);
12398 orf_pfx_count
= prefix_bgp_show_prefix_list(
12399 NULL
, afi
, orf_pfx_name
, use_json
);
12401 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12402 PEER_STATUS_ORF_PREFIX_SEND
)
12403 || orf_pfx_count
) {
12404 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12405 PEER_STATUS_ORF_PREFIX_SEND
))
12406 json_object_boolean_true_add(json_neigh
,
12409 json_object_int_add(json_addr
, "orfRecvCounter",
12412 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12413 PEER_STATUS_ORF_WAIT_REFRESH
))
12414 json_object_string_add(
12415 json_addr
, "orfFirstUpdate",
12416 "deferredUntilORFOrRouteRefreshRecvd");
12418 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12419 PEER_FLAG_REFLECTOR_CLIENT
))
12420 json_object_boolean_true_add(json_addr
,
12421 "routeReflectorClient");
12422 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12423 PEER_FLAG_RSERVER_CLIENT
))
12424 json_object_boolean_true_add(json_addr
,
12425 "routeServerClient");
12426 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12427 json_object_boolean_true_add(json_addr
,
12428 "inboundSoftConfigPermit");
12430 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12431 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12432 json_object_boolean_true_add(
12434 "privateAsNumsAllReplacedInUpdatesToNbr");
12435 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12436 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12437 json_object_boolean_true_add(
12439 "privateAsNumsReplacedInUpdatesToNbr");
12440 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12441 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12442 json_object_boolean_true_add(
12444 "privateAsNumsAllRemovedInUpdatesToNbr");
12445 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12446 PEER_FLAG_REMOVE_PRIVATE_AS
))
12447 json_object_boolean_true_add(
12449 "privateAsNumsRemovedInUpdatesToNbr");
12451 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN
)) {
12452 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12453 PEER_FLAG_ALLOWAS_IN_ORIGIN
))
12454 json_object_boolean_true_add(json_addr
,
12455 "allowAsInOrigin");
12457 json_object_int_add(json_addr
, "allowAsInCount",
12458 p
->allowas_in
[afi
][safi
]);
12461 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12462 json_object_boolean_true_add(
12464 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12467 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12468 json_object_string_add(json_addr
,
12469 "overrideASNsInOutboundUpdates",
12470 "ifAspathEqualRemoteAs");
12472 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12473 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12474 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12475 json_object_boolean_true_add(json_addr
,
12476 "routerAlwaysNextHop");
12477 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12478 PEER_FLAG_AS_PATH_UNCHANGED
))
12479 json_object_boolean_true_add(
12480 json_addr
, "unchangedAsPathPropogatedToNbr");
12481 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12482 PEER_FLAG_NEXTHOP_UNCHANGED
))
12483 json_object_boolean_true_add(
12484 json_addr
, "unchangedNextHopPropogatedToNbr");
12485 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12486 json_object_boolean_true_add(
12487 json_addr
, "unchangedMedPropogatedToNbr");
12488 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12489 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12490 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12491 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12492 PEER_FLAG_SEND_COMMUNITY
)
12493 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12494 PEER_FLAG_SEND_EXT_COMMUNITY
))
12495 json_object_string_add(json_addr
,
12496 "commAttriSentToNbr",
12497 "extendedAndStandard");
12498 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12499 PEER_FLAG_SEND_EXT_COMMUNITY
))
12500 json_object_string_add(json_addr
,
12501 "commAttriSentToNbr",
12504 json_object_string_add(json_addr
,
12505 "commAttriSentToNbr",
12508 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12509 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12510 if (p
->default_rmap
[afi
][safi
].name
)
12511 json_object_string_add(
12512 json_addr
, "defaultRouteMap",
12513 p
->default_rmap
[afi
][safi
].name
);
12515 if (paf
&& PAF_SUBGRP(paf
)
12516 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12517 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12518 json_object_boolean_true_add(json_addr
,
12521 json_object_boolean_true_add(json_addr
,
12525 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12526 if (is_evpn_enabled())
12527 json_object_boolean_true_add(
12528 json_addr
, "advertiseAllVnis");
12531 if (filter
->plist
[FILTER_IN
].name
12532 || filter
->dlist
[FILTER_IN
].name
12533 || filter
->aslist
[FILTER_IN
].name
12534 || filter
->map
[RMAP_IN
].name
)
12535 json_object_boolean_true_add(json_addr
,
12536 "inboundPathPolicyConfig");
12537 if (filter
->plist
[FILTER_OUT
].name
12538 || filter
->dlist
[FILTER_OUT
].name
12539 || filter
->aslist
[FILTER_OUT
].name
12540 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12541 json_object_boolean_true_add(
12542 json_addr
, "outboundPathPolicyConfig");
12545 if (filter
->plist
[FILTER_IN
].name
)
12546 json_object_string_add(json_addr
,
12547 "incomingUpdatePrefixFilterList",
12548 filter
->plist
[FILTER_IN
].name
);
12549 if (filter
->plist
[FILTER_OUT
].name
)
12550 json_object_string_add(json_addr
,
12551 "outgoingUpdatePrefixFilterList",
12552 filter
->plist
[FILTER_OUT
].name
);
12554 /* distribute-list */
12555 if (filter
->dlist
[FILTER_IN
].name
)
12556 json_object_string_add(
12557 json_addr
, "incomingUpdateNetworkFilterList",
12558 filter
->dlist
[FILTER_IN
].name
);
12559 if (filter
->dlist
[FILTER_OUT
].name
)
12560 json_object_string_add(
12561 json_addr
, "outgoingUpdateNetworkFilterList",
12562 filter
->dlist
[FILTER_OUT
].name
);
12565 if (filter
->aslist
[FILTER_IN
].name
)
12566 json_object_string_add(json_addr
,
12567 "incomingUpdateAsPathFilterList",
12568 filter
->aslist
[FILTER_IN
].name
);
12569 if (filter
->aslist
[FILTER_OUT
].name
)
12570 json_object_string_add(json_addr
,
12571 "outgoingUpdateAsPathFilterList",
12572 filter
->aslist
[FILTER_OUT
].name
);
12575 if (filter
->map
[RMAP_IN
].name
)
12576 json_object_string_add(
12577 json_addr
, "routeMapForIncomingAdvertisements",
12578 filter
->map
[RMAP_IN
].name
);
12579 if (filter
->map
[RMAP_OUT
].name
)
12580 json_object_string_add(
12581 json_addr
, "routeMapForOutgoingAdvertisements",
12582 filter
->map
[RMAP_OUT
].name
);
12584 /* ebgp-requires-policy (inbound) */
12585 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12586 && !bgp_inbound_policy_exists(p
, filter
))
12587 json_object_string_add(
12588 json_addr
, "inboundEbgpRequiresPolicy",
12589 "Inbound updates discarded due to missing policy");
12591 /* ebgp-requires-policy (outbound) */
12592 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12593 && (!bgp_outbound_policy_exists(p
, filter
)))
12594 json_object_string_add(
12595 json_addr
, "outboundEbgpRequiresPolicy",
12596 "Outbound updates discarded due to missing policy");
12598 /* unsuppress-map */
12599 if (filter
->usmap
.name
)
12600 json_object_string_add(json_addr
,
12601 "selectiveUnsuppressRouteMap",
12602 filter
->usmap
.name
);
12604 /* advertise-map */
12605 if (filter
->advmap
.aname
) {
12606 json_advmap
= json_object_new_object();
12607 json_object_string_add(json_advmap
, "condition",
12608 filter
->advmap
.condition
12611 json_object_string_add(json_advmap
, "conditionMap",
12612 filter
->advmap
.cname
);
12613 json_object_string_add(json_advmap
, "advertiseMap",
12614 filter
->advmap
.aname
);
12615 json_object_string_add(
12616 json_advmap
, "advertiseStatus",
12617 filter
->advmap
.update_type
==
12618 UPDATE_TYPE_ADVERTISE
12621 json_object_object_add(json_addr
, "advertiseMap",
12625 /* Receive prefix count */
12626 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12627 p
->pcount
[afi
][safi
]);
12628 if (paf
&& PAF_SUBGRP(paf
))
12629 json_object_int_add(json_addr
, "sentPrefixCounter",
12630 (PAF_SUBGRP(paf
))->scount
);
12632 /* Maximum prefix */
12633 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12634 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12635 p
->pmax_out
[afi
][safi
]);
12637 /* Maximum prefix */
12638 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12639 json_object_int_add(json_addr
, "prefixAllowedMax",
12640 p
->pmax
[afi
][safi
]);
12641 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12642 PEER_FLAG_MAX_PREFIX_WARNING
))
12643 json_object_boolean_true_add(
12644 json_addr
, "prefixAllowedMaxWarning");
12645 json_object_int_add(json_addr
,
12646 "prefixAllowedWarningThresh",
12647 p
->pmax_threshold
[afi
][safi
]);
12648 if (p
->pmax_restart
[afi
][safi
])
12649 json_object_int_add(
12651 "prefixAllowedRestartIntervalMsecs",
12652 p
->pmax_restart
[afi
][safi
] * 60000);
12654 json_object_object_add(json_neigh
,
12655 get_afi_safi_str(afi
, safi
, true),
12659 filter
= &p
->filter
[afi
][safi
];
12661 vty_out(vty
, " For address family: %s\n",
12662 get_afi_safi_str(afi
, safi
, false));
12664 if (peer_group_active(p
))
12665 vty_out(vty
, " %s peer-group member\n",
12668 paf
= peer_af_find(p
, afi
, safi
);
12669 if (paf
&& PAF_SUBGRP(paf
)) {
12670 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12671 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12672 vty_out(vty
, " Packet Queue length %d\n",
12673 bpacket_queue_virtual_length(paf
));
12675 vty_out(vty
, " Not part of any update group\n");
12677 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12678 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12679 PEER_CAP_ORF_PREFIX_SM_RCV
)
12680 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12681 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12682 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12683 PEER_CAP_ORF_PREFIX_RM_ADV
)
12684 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12685 PEER_CAP_ORF_PREFIX_RM_RCV
)
12686 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12687 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12688 vty_out(vty
, " AF-dependant capabilities:\n");
12690 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12691 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12692 PEER_CAP_ORF_PREFIX_SM_RCV
)
12693 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12694 PEER_CAP_ORF_PREFIX_RM_ADV
)
12695 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12696 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12698 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12700 bgp_show_peer_afi_orf_cap(
12701 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12702 PEER_CAP_ORF_PREFIX_RM_ADV
,
12703 PEER_CAP_ORF_PREFIX_SM_RCV
,
12704 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12706 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12707 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12708 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12709 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12710 PEER_CAP_ORF_PREFIX_RM_ADV
)
12711 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12712 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12714 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12715 ORF_TYPE_PREFIX_OLD
);
12716 bgp_show_peer_afi_orf_cap(
12717 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12718 PEER_CAP_ORF_PREFIX_RM_ADV
,
12719 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12720 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12723 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12724 p
->host
, afi
, safi
);
12725 orf_pfx_count
= prefix_bgp_show_prefix_list(
12726 NULL
, afi
, orf_pfx_name
, use_json
);
12728 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12729 PEER_STATUS_ORF_PREFIX_SEND
)
12730 || orf_pfx_count
) {
12731 vty_out(vty
, " Outbound Route Filter (ORF):");
12732 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12733 PEER_STATUS_ORF_PREFIX_SEND
))
12734 vty_out(vty
, " sent;");
12736 vty_out(vty
, " received (%d entries)",
12738 vty_out(vty
, "\n");
12740 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12741 PEER_STATUS_ORF_WAIT_REFRESH
))
12743 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12745 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12746 PEER_FLAG_REFLECTOR_CLIENT
))
12747 vty_out(vty
, " Route-Reflector Client\n");
12748 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12749 PEER_FLAG_RSERVER_CLIENT
))
12750 vty_out(vty
, " Route-Server Client\n");
12751 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12753 " Inbound soft reconfiguration allowed\n");
12755 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12756 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12758 " Private AS numbers (all) replaced in updates to this neighbor\n");
12759 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12760 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12762 " Private AS numbers replaced in updates to this neighbor\n");
12763 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12764 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12766 " Private AS numbers (all) removed in updates to this neighbor\n");
12767 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12768 PEER_FLAG_REMOVE_PRIVATE_AS
))
12770 " Private AS numbers removed in updates to this neighbor\n");
12772 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN
)) {
12773 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12774 PEER_FLAG_ALLOWAS_IN_ORIGIN
))
12776 " Local AS allowed as path origin\n");
12779 " Local AS allowed in path, %d occurrences\n",
12780 p
->allowas_in
[afi
][safi
]);
12783 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12784 vty_out(vty
, " %s\n",
12785 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12786 ->human_description
);
12788 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12790 " Override ASNs in outbound updates if aspath equals remote-as\n");
12792 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12793 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12794 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12795 vty_out(vty
, " NEXT_HOP is always this router\n");
12796 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12797 PEER_FLAG_AS_PATH_UNCHANGED
))
12799 " AS_PATH is propagated unchanged to this neighbor\n");
12800 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12801 PEER_FLAG_NEXTHOP_UNCHANGED
))
12803 " NEXT_HOP is propagated unchanged to this neighbor\n");
12804 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12806 " MED is propagated unchanged to this neighbor\n");
12807 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12808 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12809 PEER_FLAG_SEND_EXT_COMMUNITY
)
12810 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12811 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12813 " Community attribute sent to this neighbor");
12814 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12815 PEER_FLAG_SEND_COMMUNITY
)
12816 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12817 PEER_FLAG_SEND_EXT_COMMUNITY
)
12818 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12819 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12820 vty_out(vty
, "(all)\n");
12821 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12822 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12823 vty_out(vty
, "(large)\n");
12824 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12825 PEER_FLAG_SEND_EXT_COMMUNITY
))
12826 vty_out(vty
, "(extended)\n");
12828 vty_out(vty
, "(standard)\n");
12830 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12831 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12832 vty_out(vty
, " Default information originate,");
12834 if (p
->default_rmap
[afi
][safi
].name
)
12835 vty_out(vty
, " default route-map %s%s,",
12836 p
->default_rmap
[afi
][safi
].map
? "*"
12838 p
->default_rmap
[afi
][safi
].name
);
12839 if (paf
&& PAF_SUBGRP(paf
)
12840 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12841 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12842 vty_out(vty
, " default sent\n");
12844 vty_out(vty
, " default not sent\n");
12847 /* advertise-vni-all */
12848 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12849 if (is_evpn_enabled())
12850 vty_out(vty
, " advertise-all-vni\n");
12853 if (filter
->plist
[FILTER_IN
].name
12854 || filter
->dlist
[FILTER_IN
].name
12855 || filter
->aslist
[FILTER_IN
].name
12856 || filter
->map
[RMAP_IN
].name
)
12857 vty_out(vty
, " Inbound path policy configured\n");
12858 if (filter
->plist
[FILTER_OUT
].name
12859 || filter
->dlist
[FILTER_OUT
].name
12860 || filter
->aslist
[FILTER_OUT
].name
12861 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12862 vty_out(vty
, " Outbound path policy configured\n");
12865 if (filter
->plist
[FILTER_IN
].name
)
12867 " Incoming update prefix filter list is %s%s\n",
12868 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12869 filter
->plist
[FILTER_IN
].name
);
12870 if (filter
->plist
[FILTER_OUT
].name
)
12872 " Outgoing update prefix filter list is %s%s\n",
12873 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12874 filter
->plist
[FILTER_OUT
].name
);
12876 /* distribute-list */
12877 if (filter
->dlist
[FILTER_IN
].name
)
12879 " Incoming update network filter list is %s%s\n",
12880 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12881 filter
->dlist
[FILTER_IN
].name
);
12882 if (filter
->dlist
[FILTER_OUT
].name
)
12884 " Outgoing update network filter list is %s%s\n",
12885 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12886 filter
->dlist
[FILTER_OUT
].name
);
12889 if (filter
->aslist
[FILTER_IN
].name
)
12891 " Incoming update AS path filter list is %s%s\n",
12892 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12893 filter
->aslist
[FILTER_IN
].name
);
12894 if (filter
->aslist
[FILTER_OUT
].name
)
12896 " Outgoing update AS path filter list is %s%s\n",
12897 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12898 filter
->aslist
[FILTER_OUT
].name
);
12901 if (filter
->map
[RMAP_IN
].name
)
12903 " Route map for incoming advertisements is %s%s\n",
12904 filter
->map
[RMAP_IN
].map
? "*" : "",
12905 filter
->map
[RMAP_IN
].name
);
12906 if (filter
->map
[RMAP_OUT
].name
)
12908 " Route map for outgoing advertisements is %s%s\n",
12909 filter
->map
[RMAP_OUT
].map
? "*" : "",
12910 filter
->map
[RMAP_OUT
].name
);
12912 /* ebgp-requires-policy (inbound) */
12913 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12914 && !bgp_inbound_policy_exists(p
, filter
))
12916 " Inbound updates discarded due to missing policy\n");
12918 /* ebgp-requires-policy (outbound) */
12919 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12920 && !bgp_outbound_policy_exists(p
, filter
))
12922 " Outbound updates discarded due to missing policy\n");
12924 /* unsuppress-map */
12925 if (filter
->usmap
.name
)
12927 " Route map for selective unsuppress is %s%s\n",
12928 filter
->usmap
.map
? "*" : "",
12929 filter
->usmap
.name
);
12931 /* advertise-map */
12932 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12934 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12935 filter
->advmap
.condition
? "EXIST"
12937 filter
->advmap
.cmap
? "*" : "",
12938 filter
->advmap
.cname
,
12939 filter
->advmap
.amap
? "*" : "",
12940 filter
->advmap
.aname
,
12941 filter
->advmap
.update_type
==
12942 UPDATE_TYPE_ADVERTISE
12946 /* Receive prefix count */
12947 vty_out(vty
, " %u accepted prefixes\n",
12948 p
->pcount
[afi
][safi
]);
12950 /* maximum-prefix-out */
12951 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12952 PEER_FLAG_MAX_PREFIX_OUT
))
12954 " Maximum allowed prefixes sent %u\n",
12955 p
->pmax_out
[afi
][safi
]);
12957 /* Maximum prefix */
12958 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12960 " Maximum prefixes allowed %u%s\n",
12961 p
->pmax
[afi
][safi
],
12962 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12963 PEER_FLAG_MAX_PREFIX_WARNING
)
12964 ? " (warning-only)"
12966 vty_out(vty
, " Threshold for warning message %d%%",
12967 p
->pmax_threshold
[afi
][safi
]);
12968 if (p
->pmax_restart
[afi
][safi
])
12969 vty_out(vty
, ", restart interval %d min",
12970 p
->pmax_restart
[afi
][safi
]);
12971 vty_out(vty
, "\n");
12974 vty_out(vty
, "\n");
12978 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12982 char timebuf
[BGP_UPTIME_LEN
];
12988 json_object
*json_neigh
= NULL
;
12990 uint32_t sync_tcp_mss
;
12995 json_neigh
= json_object_new_object();
12997 memset(dn_flag
, '\0', sizeof(dn_flag
));
12998 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
13002 if (p
->conf_if
) /* Configured interface name. */
13003 vty_out(vty
, "BGP neighbor on %s: %pSU, ", p
->conf_if
,
13005 else /* Configured IP address. */
13006 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
13011 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
13012 json_object_string_add(json_neigh
, "bgpNeighborAddr",
13014 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
13015 json_object_string_addf(json_neigh
, "bgpNeighborAddr",
13018 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
13020 if (p
->change_local_as
)
13021 json_object_int_add(json_neigh
, "localAs",
13022 p
->change_local_as
);
13024 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
13026 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
13027 json_object_boolean_true_add(json_neigh
,
13028 "localAsNoPrepend");
13030 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
13031 json_object_boolean_true_add(json_neigh
,
13032 "localAsReplaceAs");
13034 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
13035 || (p
->as_type
== AS_INTERNAL
))
13036 vty_out(vty
, "remote AS %u, ", p
->as
);
13038 vty_out(vty
, "remote AS Unspecified, ");
13039 vty_out(vty
, "local AS %u%s%s, ",
13040 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
13041 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
13044 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
13048 /* peer type internal or confed-internal */
13049 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
13051 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13052 json_object_boolean_true_add(
13053 json_neigh
, "nbrConfedInternalLink");
13055 json_object_boolean_true_add(json_neigh
,
13056 "nbrInternalLink");
13058 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13059 vty_out(vty
, "confed-internal link\n");
13061 vty_out(vty
, "internal link\n");
13063 /* peer type external or confed-external */
13064 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
13066 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13067 json_object_boolean_true_add(
13068 json_neigh
, "nbrConfedExternalLink");
13070 json_object_boolean_true_add(json_neigh
,
13071 "nbrExternalLink");
13073 if (bgp_confederation_peers_check(bgp
, p
->as
))
13074 vty_out(vty
, "confed-external link\n");
13076 vty_out(vty
, "external link\n");
13080 json_object_boolean_true_add(json_neigh
,
13081 "nbrUnspecifiedLink");
13083 vty_out(vty
, "unspecified link\n");
13088 json_object_string_add(json_neigh
, "localRole",
13089 bgp_get_name_by_role(p
->local_role
));
13090 json_object_string_add(json_neigh
, "remoteRole",
13091 bgp_get_name_by_role(p
->remote_role
));
13093 vty_out(vty
, " Local Role: %s\n",
13094 bgp_get_name_by_role(p
->local_role
));
13095 vty_out(vty
, " Remote Role: %s\n",
13096 bgp_get_name_by_role(p
->remote_role
));
13103 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
13105 vty_out(vty
, " Description: %s\n", p
->desc
);
13110 json_object_string_add(json_neigh
, "hostname",
13114 json_object_string_add(json_neigh
, "domainname",
13117 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
13118 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
13121 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
13125 json_object_string_add(json_neigh
, "hostname",
13132 json_object_string_add(json_neigh
, "peerGroup",
13136 struct prefix prefix
, *range
= NULL
;
13138 if (sockunion2hostprefix(&(p
->su
), &prefix
))
13139 range
= peer_group_lookup_dynamic_neighbor_range(
13140 p
->group
, &prefix
);
13143 json_object_string_addf(
13145 "peerSubnetRangeGroup", "%pFX",
13151 " Member of peer-group %s for session parameters\n",
13155 struct prefix prefix
, *range
= NULL
;
13157 if (sockunion2hostprefix(&(p
->su
), &prefix
))
13158 range
= peer_group_lookup_dynamic_neighbor_range(
13159 p
->group
, &prefix
);
13163 " Belongs to the subnet range group: %pFX\n",
13171 /* Administrative shutdown. */
13172 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13173 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13174 json_object_boolean_true_add(json_neigh
,
13178 json_object_int_add(json_neigh
, "bgpVersion", 4);
13179 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
13181 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
13184 /* Confederation */
13185 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13186 && bgp_confederation_peers_check(bgp
, p
->as
))
13187 json_object_boolean_true_add(json_neigh
,
13191 json_object_string_add(
13192 json_neigh
, "bgpState",
13193 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13195 if (peer_established(p
)) {
13198 uptime
= monotime(NULL
);
13199 uptime
-= p
->uptime
;
13200 epoch_tbuf
= time(NULL
) - uptime
;
13202 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
13204 json_object_string_add(json_neigh
, "bgpTimerUpString",
13205 peer_uptime(p
->uptime
, timebuf
,
13208 json_object_int_add(json_neigh
,
13209 "bgpTimerUpEstablishedEpoch",
13213 else if (p
->status
== Active
) {
13214 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13215 json_object_string_add(json_neigh
, "bgpStateIs",
13217 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13218 json_object_string_add(json_neigh
, "bgpStateIs",
13226 uptime
= monotime(NULL
);
13227 uptime
-= p
->readtime
;
13228 gmtime_r(&uptime
, &tm
);
13230 json_object_int_add(json_neigh
, "bgpTimerLastRead",
13231 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13232 + (tm
.tm_hour
* 3600000));
13234 uptime
= monotime(NULL
);
13235 uptime
-= p
->last_write
;
13236 gmtime_r(&uptime
, &tm
);
13238 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
13239 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13240 + (tm
.tm_hour
* 3600000));
13242 uptime
= monotime(NULL
);
13243 uptime
-= p
->update_time
;
13244 gmtime_r(&uptime
, &tm
);
13246 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
13247 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13248 + (tm
.tm_hour
* 3600000));
13250 /* Configured timer values. */
13251 json_object_int_add(json_neigh
,
13252 "bgpTimerConfiguredHoldTimeMsecs",
13253 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13254 ? p
->holdtime
* 1000
13255 : bgp
->default_holdtime
* 1000);
13256 json_object_int_add(json_neigh
,
13257 "bgpTimerConfiguredKeepAliveIntervalMsecs",
13258 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13259 ? p
->keepalive
* 1000
13260 : bgp
->default_keepalive
* 1000);
13261 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
13262 p
->v_holdtime
* 1000);
13263 json_object_int_add(json_neigh
,
13264 "bgpTimerKeepAliveIntervalMsecs",
13265 p
->v_keepalive
* 1000);
13266 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
13267 json_object_int_add(json_neigh
,
13268 "bgpTimerDelayOpenTimeMsecs",
13269 p
->v_delayopen
* 1000);
13272 /* Configured and Synced tcp-mss value for peer */
13273 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13274 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13275 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
13277 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
13281 /* Extended Optional Parameters Length for BGP OPEN Message */
13282 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
13283 json_object_boolean_true_add(
13284 json_neigh
, "extendedOptionalParametersLength");
13286 json_object_boolean_false_add(
13287 json_neigh
, "extendedOptionalParametersLength");
13289 /* Conditional advertisements */
13290 json_object_int_add(
13292 "bgpTimerConfiguredConditionalAdvertisementsSec",
13293 bgp
->condition_check_period
);
13294 if (thread_is_scheduled(bgp
->t_condition_check
))
13295 json_object_int_add(
13297 "bgpTimerUntilConditionalAdvertisementsSec",
13298 thread_timer_remain_second(
13299 bgp
->t_condition_check
));
13301 /* Administrative shutdown. */
13302 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13303 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13304 vty_out(vty
, " Administratively shut down\n");
13307 vty_out(vty
, " BGP version 4");
13308 vty_out(vty
, ", remote router ID %pI4", &p
->remote_id
);
13309 vty_out(vty
, ", local router ID %pI4\n", &bgp
->router_id
);
13311 /* Confederation */
13312 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13313 && bgp_confederation_peers_check(bgp
, p
->as
))
13315 " Neighbor under common administration\n");
13318 vty_out(vty
, " BGP state = %s",
13319 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13321 if (peer_established(p
))
13322 vty_out(vty
, ", up for %8s",
13323 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
13326 else if (p
->status
== Active
) {
13327 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13328 vty_out(vty
, " (passive)");
13329 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13330 vty_out(vty
, " (NSF passive)");
13332 vty_out(vty
, "\n");
13335 vty_out(vty
, " Last read %s",
13336 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
13338 vty_out(vty
, ", Last write %s\n",
13339 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
13342 /* Configured timer values. */
13344 " Hold time is %d seconds, keepalive interval is %d seconds\n",
13345 p
->v_holdtime
, p
->v_keepalive
);
13346 vty_out(vty
, " Configured hold time is %d seconds",
13347 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13349 : bgp
->default_holdtime
);
13350 vty_out(vty
, ", keepalive interval is %d seconds\n",
13351 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13353 : bgp
->default_keepalive
);
13354 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
13356 " Configured DelayOpenTime is %d seconds\n",
13359 /* Configured and synced tcp-mss value for peer */
13360 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13361 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13362 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
13363 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
13366 /* Extended Optional Parameters Length for BGP OPEN Message */
13367 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
13369 " Extended Optional Parameters Length is enabled\n");
13371 /* Conditional advertisements */
13373 " Configured conditional advertisements interval is %d seconds\n",
13374 bgp
->condition_check_period
);
13375 if (thread_is_scheduled(bgp
->t_condition_check
))
13377 " Time until conditional advertisements begin is %lu seconds\n",
13378 thread_timer_remain_second(
13379 bgp
->t_condition_check
));
13382 if (peer_established(p
) &&
13383 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
13385 json_object
*json_cap
= NULL
;
13387 json_cap
= json_object_new_object();
13390 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13391 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13392 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
13393 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13394 json_object_string_add(
13395 json_cap
, "4byteAs",
13396 "advertisedAndReceived");
13397 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13398 json_object_string_add(json_cap
,
13401 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13402 json_object_string_add(json_cap
,
13407 /* Extended Message Support */
13408 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
13409 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
13410 json_object_string_add(json_cap
,
13412 "advertisedAndReceived");
13413 else if (CHECK_FLAG(p
->cap
,
13414 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13415 json_object_string_add(json_cap
,
13418 else if (CHECK_FLAG(p
->cap
,
13419 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13420 json_object_string_add(json_cap
,
13425 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13426 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13427 json_object
*json_add
= NULL
;
13428 const char *print_store
;
13430 json_add
= json_object_new_object();
13432 FOREACH_AFI_SAFI (afi
, safi
) {
13433 json_object
*json_sub
= NULL
;
13434 json_sub
= json_object_new_object();
13435 print_store
= get_afi_safi_str(
13439 p
->af_cap
[afi
][safi
],
13440 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13442 p
->af_cap
[afi
][safi
],
13443 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13447 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
13451 PEER_CAP_ADDPATH_AF_TX_RCV
))
13452 json_object_boolean_true_add(
13454 "txAdvertisedAndReceived");
13459 PEER_CAP_ADDPATH_AF_TX_ADV
))
13460 json_object_boolean_true_add(
13467 PEER_CAP_ADDPATH_AF_TX_RCV
))
13468 json_object_boolean_true_add(
13474 p
->af_cap
[afi
][safi
],
13475 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13477 p
->af_cap
[afi
][safi
],
13478 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13482 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
13486 PEER_CAP_ADDPATH_AF_RX_RCV
))
13487 json_object_boolean_true_add(
13489 "rxAdvertisedAndReceived");
13494 PEER_CAP_ADDPATH_AF_RX_ADV
))
13495 json_object_boolean_true_add(
13502 PEER_CAP_ADDPATH_AF_RX_RCV
))
13503 json_object_boolean_true_add(
13509 p
->af_cap
[afi
][safi
],
13510 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13512 p
->af_cap
[afi
][safi
],
13513 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
13515 p
->af_cap
[afi
][safi
],
13516 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13518 p
->af_cap
[afi
][safi
],
13519 PEER_CAP_ADDPATH_AF_RX_RCV
))
13520 json_object_object_add(
13521 json_add
, print_store
,
13524 json_object_free(json_sub
);
13527 json_object_object_add(json_cap
, "addPath",
13532 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13533 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13534 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
13535 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13536 json_object_string_add(
13537 json_cap
, "dynamic",
13538 "advertisedAndReceived");
13539 else if (CHECK_FLAG(p
->cap
,
13540 PEER_CAP_DYNAMIC_ADV
))
13541 json_object_string_add(json_cap
,
13544 else if (CHECK_FLAG(p
->cap
,
13545 PEER_CAP_DYNAMIC_RCV
))
13546 json_object_string_add(json_cap
,
13552 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13553 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13554 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
) &&
13555 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13556 json_object_string_add(
13558 "advertisedAndReceived");
13559 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13560 json_object_string_add(json_cap
, "role",
13562 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13563 json_object_string_add(json_cap
, "role",
13567 /* Extended nexthop */
13568 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13569 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13570 json_object
*json_nxt
= NULL
;
13571 const char *print_store
;
13574 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
13575 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13576 json_object_string_add(
13577 json_cap
, "extendedNexthop",
13578 "advertisedAndReceived");
13579 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13580 json_object_string_add(
13581 json_cap
, "extendedNexthop",
13583 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13584 json_object_string_add(
13585 json_cap
, "extendedNexthop",
13588 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13589 json_nxt
= json_object_new_object();
13591 for (safi
= SAFI_UNICAST
;
13592 safi
< SAFI_MAX
; safi
++) {
13596 PEER_CAP_ENHE_AF_RCV
)) {
13602 json_object_string_add(
13605 "recieved"); /* misspelled for compatibility */
13608 json_object_object_add(
13610 "extendedNexthopFamililesByPeer",
13615 /* Long-lived Graceful Restart */
13616 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13617 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13618 json_object
*json_llgr
= NULL
;
13619 const char *afi_safi_str
;
13621 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
13622 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13623 json_object_string_add(
13625 "longLivedGracefulRestart",
13626 "advertisedAndReceived");
13627 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13628 json_object_string_add(
13630 "longLivedGracefulRestart",
13632 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13633 json_object_string_add(
13635 "longLivedGracefulRestart",
13638 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13639 json_llgr
= json_object_new_object();
13641 FOREACH_AFI_SAFI (afi
, safi
) {
13645 PEER_CAP_ENHE_AF_RCV
)) {
13651 json_object_string_add(
13657 json_object_object_add(
13659 "longLivedGracefulRestartByPeer",
13664 /* Route Refresh */
13665 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13666 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13667 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13668 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
13669 (CHECK_FLAG(p
->cap
,
13670 PEER_CAP_REFRESH_NEW_RCV
) ||
13672 PEER_CAP_REFRESH_OLD_RCV
))) {
13675 PEER_CAP_REFRESH_OLD_RCV
) &&
13678 PEER_CAP_REFRESH_NEW_RCV
))
13679 json_object_string_add(
13682 "advertisedAndReceivedOldNew");
13686 PEER_CAP_REFRESH_OLD_RCV
))
13687 json_object_string_add(
13690 "advertisedAndReceivedOld");
13692 json_object_string_add(
13695 "advertisedAndReceivedNew");
13697 } else if (CHECK_FLAG(p
->cap
,
13698 PEER_CAP_REFRESH_ADV
))
13699 json_object_string_add(json_cap
,
13702 else if (CHECK_FLAG(p
->cap
,
13703 PEER_CAP_REFRESH_NEW_RCV
) ||
13705 PEER_CAP_REFRESH_OLD_RCV
))
13706 json_object_string_add(json_cap
,
13711 /* Enhanced Route Refresh */
13712 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13713 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13714 if (CHECK_FLAG(p
->cap
,
13715 PEER_CAP_ENHANCED_RR_ADV
) &&
13717 PEER_CAP_ENHANCED_RR_RCV
))
13718 json_object_string_add(
13720 "enhancedRouteRefresh",
13721 "advertisedAndReceived");
13722 else if (CHECK_FLAG(p
->cap
,
13723 PEER_CAP_ENHANCED_RR_ADV
))
13724 json_object_string_add(
13726 "enhancedRouteRefresh",
13728 else if (CHECK_FLAG(p
->cap
,
13729 PEER_CAP_ENHANCED_RR_RCV
))
13730 json_object_string_add(
13732 "enhancedRouteRefresh",
13736 /* Multiprotocol Extensions */
13737 json_object
*json_multi
= NULL
;
13739 json_multi
= json_object_new_object();
13741 FOREACH_AFI_SAFI (afi
, safi
) {
13742 if (p
->afc_adv
[afi
][safi
] ||
13743 p
->afc_recv
[afi
][safi
]) {
13744 json_object
*json_exten
= NULL
;
13745 json_exten
= json_object_new_object();
13747 if (p
->afc_adv
[afi
][safi
] &&
13748 p
->afc_recv
[afi
][safi
])
13749 json_object_boolean_true_add(
13751 "advertisedAndReceived");
13752 else if (p
->afc_adv
[afi
][safi
])
13753 json_object_boolean_true_add(
13756 else if (p
->afc_recv
[afi
][safi
])
13757 json_object_boolean_true_add(
13758 json_exten
, "received");
13760 json_object_object_add(
13762 get_afi_safi_str(afi
, safi
,
13767 json_object_object_add(json_cap
,
13768 "multiprotocolExtensions",
13771 /* Hostname capabilities */
13772 json_object
*json_hname
= NULL
;
13774 json_hname
= json_object_new_object();
13776 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13777 json_object_string_add(
13778 json_hname
, "advHostName",
13779 bgp
->peer_self
->hostname
13780 ? bgp
->peer_self
->hostname
13782 json_object_string_add(
13783 json_hname
, "advDomainName",
13784 bgp
->peer_self
->domainname
13785 ? bgp
->peer_self
->domainname
13790 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13791 json_object_string_add(
13792 json_hname
, "rcvHostName",
13793 p
->hostname
? p
->hostname
: "n/a");
13794 json_object_string_add(
13795 json_hname
, "rcvDomainName",
13796 p
->domainname
? p
->domainname
: "n/a");
13799 json_object_object_add(json_cap
, "hostName",
13802 /* Graceful Restart */
13803 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13804 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13805 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13806 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13807 json_object_string_add(
13808 json_cap
, "gracefulRestart",
13809 "advertisedAndReceived");
13810 else if (CHECK_FLAG(p
->cap
,
13811 PEER_CAP_RESTART_ADV
))
13812 json_object_string_add(
13814 "gracefulRestartCapability",
13816 else if (CHECK_FLAG(p
->cap
,
13817 PEER_CAP_RESTART_RCV
))
13818 json_object_string_add(
13820 "gracefulRestartCapability",
13823 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13824 int restart_af_count
= 0;
13825 json_object
*json_restart
= NULL
;
13826 json_restart
= json_object_new_object();
13828 json_object_int_add(
13830 "gracefulRestartRemoteTimerMsecs",
13831 p
->v_gr_restart
* 1000);
13833 FOREACH_AFI_SAFI (afi
, safi
) {
13837 PEER_CAP_RESTART_AF_RCV
)) {
13838 json_object
*json_sub
=
13841 json_object_new_object();
13847 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13848 json_object_boolean_true_add(
13851 restart_af_count
++;
13852 json_object_object_add(
13861 if (!restart_af_count
) {
13862 json_object_string_add(
13864 "addressFamiliesByPeer",
13866 json_object_free(json_restart
);
13868 json_object_object_add(
13870 "addressFamiliesByPeer",
13874 json_object_object_add(
13875 json_neigh
, "neighborCapabilities", json_cap
);
13877 vty_out(vty
, " Neighbor capabilities:\n");
13880 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13881 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13882 vty_out(vty
, " 4 Byte AS:");
13883 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13884 vty_out(vty
, " advertised");
13885 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13886 vty_out(vty
, " %sreceived",
13891 vty_out(vty
, "\n");
13894 /* Extended Message Support */
13895 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13896 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13897 vty_out(vty
, " Extended Message:");
13898 if (CHECK_FLAG(p
->cap
,
13899 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13900 vty_out(vty
, " advertised");
13901 if (CHECK_FLAG(p
->cap
,
13902 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13903 vty_out(vty
, " %sreceived",
13906 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13909 vty_out(vty
, "\n");
13913 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13914 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13915 vty_out(vty
, " AddPath:\n");
13917 FOREACH_AFI_SAFI (afi
, safi
) {
13919 p
->af_cap
[afi
][safi
],
13920 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13922 p
->af_cap
[afi
][safi
],
13923 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13924 vty_out(vty
, " %s: TX ",
13932 PEER_CAP_ADDPATH_AF_TX_ADV
))
13939 PEER_CAP_ADDPATH_AF_TX_RCV
))
13946 PEER_CAP_ADDPATH_AF_TX_ADV
)
13950 vty_out(vty
, "\n");
13954 p
->af_cap
[afi
][safi
],
13955 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13957 p
->af_cap
[afi
][safi
],
13958 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13959 vty_out(vty
, " %s: RX ",
13967 PEER_CAP_ADDPATH_AF_RX_ADV
))
13974 PEER_CAP_ADDPATH_AF_RX_RCV
))
13981 PEER_CAP_ADDPATH_AF_RX_ADV
)
13985 vty_out(vty
, "\n");
13991 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13992 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13993 vty_out(vty
, " Dynamic:");
13994 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
13995 vty_out(vty
, " advertised");
13996 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13997 vty_out(vty
, " %sreceived",
13999 PEER_CAP_DYNAMIC_ADV
)
14002 vty_out(vty
, "\n");
14006 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
14007 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
14008 vty_out(vty
, " Role:");
14009 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
14010 vty_out(vty
, " advertised");
14011 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
14012 vty_out(vty
, " %sreceived",
14017 vty_out(vty
, "\n");
14020 /* Extended nexthop */
14021 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
14022 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
14023 vty_out(vty
, " Extended nexthop:");
14024 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
14025 vty_out(vty
, " advertised");
14026 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
14027 vty_out(vty
, " %sreceived",
14032 vty_out(vty
, "\n");
14034 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
14036 " Address families by peer:\n ");
14037 for (safi
= SAFI_UNICAST
;
14038 safi
< SAFI_MAX
; safi
++)
14042 PEER_CAP_ENHE_AF_RCV
))
14052 /* Long-lived Graceful Restart */
14053 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
14054 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
14056 " Long-lived Graceful Restart:");
14057 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
14058 vty_out(vty
, " advertised");
14059 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
14060 vty_out(vty
, " %sreceived",
14065 vty_out(vty
, "\n");
14067 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
14069 " Address families by peer:\n");
14070 FOREACH_AFI_SAFI (afi
, safi
)
14074 PEER_CAP_LLGR_AF_RCV
))
14084 /* Route Refresh */
14085 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
14086 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
14087 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
14088 vty_out(vty
, " Route refresh:");
14089 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
14090 vty_out(vty
, " advertised");
14091 if (CHECK_FLAG(p
->cap
,
14092 PEER_CAP_REFRESH_NEW_RCV
) ||
14094 PEER_CAP_REFRESH_OLD_RCV
))
14095 vty_out(vty
, " %sreceived(%s)",
14097 PEER_CAP_REFRESH_ADV
)
14102 PEER_CAP_REFRESH_OLD_RCV
) &&
14105 PEER_CAP_REFRESH_NEW_RCV
))
14109 PEER_CAP_REFRESH_OLD_RCV
)
14113 vty_out(vty
, "\n");
14116 /* Enhanced Route Refresh */
14117 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
14118 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
14119 vty_out(vty
, " Enhanced Route Refresh:");
14120 if (CHECK_FLAG(p
->cap
,
14121 PEER_CAP_ENHANCED_RR_ADV
))
14122 vty_out(vty
, " advertised");
14123 if (CHECK_FLAG(p
->cap
,
14124 PEER_CAP_ENHANCED_RR_RCV
))
14125 vty_out(vty
, " %sreceived",
14127 PEER_CAP_REFRESH_ADV
)
14130 vty_out(vty
, "\n");
14133 /* Multiprotocol Extensions */
14134 FOREACH_AFI_SAFI (afi
, safi
)
14135 if (p
->afc_adv
[afi
][safi
] ||
14136 p
->afc_recv
[afi
][safi
]) {
14137 vty_out(vty
, " Address Family %s:",
14138 get_afi_safi_str(afi
, safi
,
14140 if (p
->afc_adv
[afi
][safi
])
14141 vty_out(vty
, " advertised");
14142 if (p
->afc_recv
[afi
][safi
])
14143 vty_out(vty
, " %sreceived",
14144 p
->afc_adv
[afi
][safi
]
14147 vty_out(vty
, "\n");
14150 /* Hostname capability */
14151 vty_out(vty
, " Hostname Capability:");
14153 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
14155 " advertised (name: %s,domain name: %s)",
14156 bgp
->peer_self
->hostname
14157 ? bgp
->peer_self
->hostname
14159 bgp
->peer_self
->domainname
14160 ? bgp
->peer_self
->domainname
14163 vty_out(vty
, " not advertised");
14166 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
14168 " received (name: %s,domain name: %s)",
14169 p
->hostname
? p
->hostname
: "n/a",
14170 p
->domainname
? p
->domainname
: "n/a");
14172 vty_out(vty
, " not received");
14175 vty_out(vty
, "\n");
14177 /* Graceful Restart */
14178 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
14179 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
14181 " Graceful Restart Capability:");
14182 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
14183 vty_out(vty
, " advertised");
14184 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
14185 vty_out(vty
, " %sreceived",
14187 PEER_CAP_RESTART_ADV
)
14190 vty_out(vty
, "\n");
14192 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14193 int restart_af_count
= 0;
14196 " Remote Restart timer is %d seconds\n",
14199 " Address families by peer:\n ");
14201 FOREACH_AFI_SAFI (afi
, safi
)
14205 PEER_CAP_RESTART_AF_RCV
)) {
14206 vty_out(vty
, "%s%s(%s)",
14218 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
14220 : "not preserved");
14221 restart_af_count
++;
14223 if (!restart_af_count
)
14224 vty_out(vty
, "none");
14225 vty_out(vty
, "\n");
14227 } /* Graceful Restart */
14231 /* graceful restart information */
14232 json_object
*json_grace
= NULL
;
14233 json_object
*json_grace_send
= NULL
;
14234 json_object
*json_grace_recv
= NULL
;
14235 int eor_send_af_count
= 0;
14236 int eor_receive_af_count
= 0;
14239 json_grace
= json_object_new_object();
14240 json_grace_send
= json_object_new_object();
14241 json_grace_recv
= json_object_new_object();
14243 if ((peer_established(p
)) &&
14244 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14245 FOREACH_AFI_SAFI (afi
, safi
) {
14246 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14247 PEER_STATUS_EOR_SEND
)) {
14248 json_object_boolean_true_add(
14250 get_afi_safi_str(afi
, safi
,
14252 eor_send_af_count
++;
14255 FOREACH_AFI_SAFI (afi
, safi
) {
14256 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14257 PEER_STATUS_EOR_RECEIVED
)) {
14258 json_object_boolean_true_add(
14260 get_afi_safi_str(afi
, safi
,
14262 eor_receive_af_count
++;
14266 json_object_object_add(json_grace
, "endOfRibSend",
14268 json_object_object_add(json_grace
, "endOfRibRecv",
14272 if (p
->t_gr_restart
)
14273 json_object_int_add(
14274 json_grace
, "gracefulRestartTimerMsecs",
14275 thread_timer_remain_second(p
->t_gr_restart
) *
14279 json_object_int_add(
14280 json_grace
, "gracefulStalepathTimerMsecs",
14281 thread_timer_remain_second(p
->t_gr_stale
) *
14283 /* more gr info in new format */
14284 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, json_grace
);
14285 json_object_object_add(json_neigh
, "gracefulRestartInfo",
14288 vty_out(vty
, " Graceful restart information:\n");
14289 if ((peer_established(p
)) &&
14290 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14292 vty_out(vty
, " End-of-RIB send: ");
14293 FOREACH_AFI_SAFI (afi
, safi
) {
14294 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14295 PEER_STATUS_EOR_SEND
)) {
14296 vty_out(vty
, "%s%s",
14297 eor_send_af_count
? ", " : "",
14298 get_afi_safi_str(afi
, safi
,
14300 eor_send_af_count
++;
14303 vty_out(vty
, "\n");
14304 vty_out(vty
, " End-of-RIB received: ");
14305 FOREACH_AFI_SAFI (afi
, safi
) {
14306 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14307 PEER_STATUS_EOR_RECEIVED
)) {
14308 vty_out(vty
, "%s%s",
14309 eor_receive_af_count
? ", "
14311 get_afi_safi_str(afi
, safi
,
14313 eor_receive_af_count
++;
14316 vty_out(vty
, "\n");
14319 if (p
->t_gr_restart
)
14321 " The remaining time of restart timer is %ld\n",
14322 thread_timer_remain_second(p
->t_gr_restart
));
14326 " The remaining time of stalepath timer is %ld\n",
14327 thread_timer_remain_second(p
->t_gr_stale
));
14329 /* more gr info in new format */
14330 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, NULL
);
14334 json_object
*json_stat
= NULL
;
14335 json_stat
= json_object_new_object();
14336 /* Packet counts. */
14338 atomic_size_t outq_count
, inq_count
;
14339 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14340 memory_order_relaxed
);
14341 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14342 memory_order_relaxed
);
14344 json_object_int_add(json_stat
, "depthInq",
14345 (unsigned long)inq_count
);
14346 json_object_int_add(json_stat
, "depthOutq",
14347 (unsigned long)outq_count
);
14348 json_object_int_add(json_stat
, "opensSent",
14349 atomic_load_explicit(&p
->open_out
,
14350 memory_order_relaxed
));
14351 json_object_int_add(json_stat
, "opensRecv",
14352 atomic_load_explicit(&p
->open_in
,
14353 memory_order_relaxed
));
14354 json_object_int_add(json_stat
, "notificationsSent",
14355 atomic_load_explicit(&p
->notify_out
,
14356 memory_order_relaxed
));
14357 json_object_int_add(json_stat
, "notificationsRecv",
14358 atomic_load_explicit(&p
->notify_in
,
14359 memory_order_relaxed
));
14360 json_object_int_add(json_stat
, "updatesSent",
14361 atomic_load_explicit(&p
->update_out
,
14362 memory_order_relaxed
));
14363 json_object_int_add(json_stat
, "updatesRecv",
14364 atomic_load_explicit(&p
->update_in
,
14365 memory_order_relaxed
));
14366 json_object_int_add(json_stat
, "keepalivesSent",
14367 atomic_load_explicit(&p
->keepalive_out
,
14368 memory_order_relaxed
));
14369 json_object_int_add(json_stat
, "keepalivesRecv",
14370 atomic_load_explicit(&p
->keepalive_in
,
14371 memory_order_relaxed
));
14372 json_object_int_add(json_stat
, "routeRefreshSent",
14373 atomic_load_explicit(&p
->refresh_out
,
14374 memory_order_relaxed
));
14375 json_object_int_add(json_stat
, "routeRefreshRecv",
14376 atomic_load_explicit(&p
->refresh_in
,
14377 memory_order_relaxed
));
14378 json_object_int_add(json_stat
, "capabilitySent",
14379 atomic_load_explicit(&p
->dynamic_cap_out
,
14380 memory_order_relaxed
));
14381 json_object_int_add(json_stat
, "capabilityRecv",
14382 atomic_load_explicit(&p
->dynamic_cap_in
,
14383 memory_order_relaxed
));
14384 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
14385 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
14386 json_object_object_add(json_neigh
, "messageStats", json_stat
);
14388 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
14389 notify_out
, notify_in
, update_out
, update_in
,
14390 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
14391 dynamic_cap_out
, dynamic_cap_in
;
14392 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14393 memory_order_relaxed
);
14394 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14395 memory_order_relaxed
);
14396 open_out
= atomic_load_explicit(&p
->open_out
,
14397 memory_order_relaxed
);
14399 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
14400 notify_out
= atomic_load_explicit(&p
->notify_out
,
14401 memory_order_relaxed
);
14402 notify_in
= atomic_load_explicit(&p
->notify_in
,
14403 memory_order_relaxed
);
14404 update_out
= atomic_load_explicit(&p
->update_out
,
14405 memory_order_relaxed
);
14406 update_in
= atomic_load_explicit(&p
->update_in
,
14407 memory_order_relaxed
);
14408 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
14409 memory_order_relaxed
);
14410 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
14411 memory_order_relaxed
);
14412 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
14413 memory_order_relaxed
);
14414 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
14415 memory_order_relaxed
);
14416 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
14417 memory_order_relaxed
);
14418 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
14419 memory_order_relaxed
);
14421 /* Packet counts. */
14422 vty_out(vty
, " Message statistics:\n");
14423 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
14424 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
14425 vty_out(vty
, " Sent Rcvd\n");
14426 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
14428 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
14430 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
14432 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
14434 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
14436 vty_out(vty
, " Capability: %10zu %10zu\n",
14437 dynamic_cap_out
, dynamic_cap_in
);
14438 vty_out(vty
, " Total: %10u %10u\n",
14439 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
14443 /* advertisement-interval */
14444 json_object_int_add(json_neigh
,
14445 "minBtwnAdvertisementRunsTimerMsecs",
14446 p
->v_routeadv
* 1000);
14448 /* Update-source. */
14449 if (p
->update_if
|| p
->update_source
) {
14451 json_object_string_add(json_neigh
,
14454 else if (p
->update_source
)
14455 json_object_string_addf(json_neigh
,
14456 "updateSource", "%pSU",
14460 /* advertisement-interval */
14462 " Minimum time between advertisement runs is %d seconds\n",
14465 /* Update-source. */
14466 if (p
->update_if
|| p
->update_source
) {
14467 vty_out(vty
, " Update source is ");
14469 vty_out(vty
, "%s", p
->update_if
);
14470 else if (p
->update_source
)
14471 vty_out(vty
, "%pSU", p
->update_source
);
14472 vty_out(vty
, "\n");
14475 vty_out(vty
, "\n");
14478 /* Address Family Information */
14479 json_object
*json_hold
= NULL
;
14482 json_hold
= json_object_new_object();
14484 FOREACH_AFI_SAFI (afi
, safi
)
14485 if (p
->afc
[afi
][safi
])
14486 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14490 json_object_object_add(json_neigh
, "addressFamilyInfo",
14492 json_object_int_add(json_neigh
, "connectionsEstablished",
14494 json_object_int_add(json_neigh
, "connectionsDropped",
14497 vty_out(vty
, " Connections established %d; dropped %d\n",
14498 p
->established
, p
->dropped
);
14500 if (!p
->last_reset
) {
14502 json_object_string_add(json_neigh
, "lastReset",
14505 vty_out(vty
, " Last reset never\n");
14511 uptime
= monotime(NULL
);
14512 uptime
-= p
->resettime
;
14513 gmtime_r(&uptime
, &tm
);
14515 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14517 + (tm
.tm_min
* 60000)
14518 + (tm
.tm_hour
* 3600000));
14519 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14521 vty_out(vty
, " Last reset %s, ",
14522 peer_uptime(p
->resettime
, timebuf
,
14523 BGP_UPTIME_LEN
, 0, NULL
));
14525 bgp_show_peer_reset(vty
, p
, NULL
, false);
14526 if (p
->last_reset_cause_size
) {
14527 msg
= p
->last_reset_cause
;
14529 " Message received that caused BGP to send a NOTIFICATION:\n ");
14530 for (i
= 1; i
<= p
->last_reset_cause_size
;
14532 vty_out(vty
, "%02X", *msg
++);
14534 if (i
!= p
->last_reset_cause_size
) {
14536 vty_out(vty
, "\n ");
14537 } else if (i
% 4 == 0) {
14542 vty_out(vty
, "\n");
14547 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14549 json_object_boolean_true_add(json_neigh
,
14550 "prefixesConfigExceedMax");
14553 " Peer had exceeded the max. no. of prefixes configured.\n");
14555 if (p
->t_pmax_restart
) {
14557 json_object_boolean_true_add(
14558 json_neigh
, "reducePrefixNumFrom");
14559 json_object_int_add(json_neigh
,
14560 "restartInTimerMsec",
14561 thread_timer_remain_second(
14566 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14567 p
->host
, thread_timer_remain_second(
14568 p
->t_pmax_restart
));
14571 json_object_boolean_true_add(
14573 "reducePrefixNumAndClearIpBgp");
14576 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14581 /* EBGP Multihop and GTSM */
14582 if (p
->sort
!= BGP_PEER_IBGP
) {
14584 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14585 json_object_int_add(json_neigh
,
14586 "externalBgpNbrMaxHopsAway",
14589 json_object_int_add(json_neigh
,
14590 "externalBgpNbrMaxHopsAway",
14593 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14595 " External BGP neighbor may be up to %d hops away.\n",
14599 " External BGP neighbor may be up to %d hops away.\n",
14604 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14605 json_object_int_add(json_neigh
,
14606 "internalBgpNbrMaxHopsAway",
14609 json_object_int_add(json_neigh
,
14610 "internalBgpNbrMaxHopsAway",
14613 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14615 " Internal BGP neighbor may be up to %d hops away.\n",
14619 " Internal BGP neighbor may be up to %d hops away.\n",
14624 /* Local address. */
14627 json_object_string_addf(json_neigh
, "hostLocal", "%pSU",
14629 json_object_int_add(json_neigh
, "portLocal",
14630 ntohs(p
->su_local
->sin
.sin_port
));
14632 vty_out(vty
, "Local host: %pSU, Local port: %d\n",
14633 p
->su_local
, ntohs(p
->su_local
->sin
.sin_port
));
14636 json_object_string_add(json_neigh
, "hostLocal",
14638 json_object_int_add(json_neigh
, "portLocal", -1);
14642 /* Remote address. */
14643 if (p
->su_remote
) {
14645 json_object_string_addf(json_neigh
, "hostForeign",
14646 "%pSU", p
->su_remote
);
14647 json_object_int_add(json_neigh
, "portForeign",
14648 ntohs(p
->su_remote
->sin
.sin_port
));
14650 vty_out(vty
, "Foreign host: %pSU, Foreign port: %d\n",
14652 ntohs(p
->su_remote
->sin
.sin_port
));
14655 json_object_string_add(json_neigh
, "hostForeign",
14657 json_object_int_add(json_neigh
, "portForeign", -1);
14661 /* Nexthop display. */
14664 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
14666 json_object_string_addf(json_neigh
, "nexthopGlobal",
14667 "%pI6", &p
->nexthop
.v6_global
);
14668 json_object_string_addf(json_neigh
, "nexthopLocal",
14669 "%pI6", &p
->nexthop
.v6_local
);
14670 if (p
->shared_network
)
14671 json_object_string_add(json_neigh
,
14675 json_object_string_add(json_neigh
,
14677 "nonSharedNetwork");
14679 vty_out(vty
, "Nexthop: %pI4\n", &p
->nexthop
.v4
);
14680 vty_out(vty
, "Nexthop global: %pI6\n",
14681 &p
->nexthop
.v6_global
);
14682 vty_out(vty
, "Nexthop local: %pI6\n",
14683 &p
->nexthop
.v6_local
);
14684 vty_out(vty
, "BGP connection: %s\n",
14685 p
->shared_network
? "shared network"
14686 : "non shared network");
14690 json_object_string_add(json_neigh
, "nexthop",
14692 json_object_string_add(json_neigh
, "nexthopGlobal",
14694 json_object_string_add(json_neigh
, "nexthopLocal",
14696 json_object_string_add(json_neigh
, "bgpConnection",
14701 /* Timer information. */
14703 json_object_int_add(json_neigh
, "connectRetryTimer",
14705 if (peer_established(p
)) {
14706 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14708 if (CHECK_FLAG(p
->flags
, PEER_FLAG_RTT_SHUTDOWN
)) {
14709 json_object_int_add(json_neigh
,
14710 "shutdownRttInMsecs",
14712 json_object_int_add(json_neigh
,
14713 "shutdownRttAfterCount",
14714 p
->rtt_keepalive_rcv
);
14718 json_object_int_add(
14719 json_neigh
, "nextStartTimerDueInMsecs",
14720 thread_timer_remain_second(p
->t_start
) * 1000);
14722 json_object_int_add(
14723 json_neigh
, "nextConnectTimerDueInMsecs",
14724 thread_timer_remain_second(p
->t_connect
)
14726 if (p
->t_routeadv
) {
14727 json_object_int_add(json_neigh
, "mraiInterval",
14729 json_object_int_add(
14730 json_neigh
, "mraiTimerExpireInMsecs",
14731 thread_timer_remain_second(p
->t_routeadv
)
14735 json_object_int_add(json_neigh
, "authenticationEnabled",
14739 json_object_string_add(json_neigh
, "readThread", "on");
14741 json_object_string_add(json_neigh
, "readThread", "off");
14743 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14744 json_object_string_add(json_neigh
, "writeThread", "on");
14746 json_object_string_add(json_neigh
, "writeThread",
14749 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14751 if (peer_established(p
)) {
14752 vty_out(vty
, "Estimated round trip time: %d ms\n",
14754 if (CHECK_FLAG(p
->flags
, PEER_FLAG_RTT_SHUTDOWN
))
14756 "Shutdown when RTT > %dms, count > %u\n",
14757 p
->rtt_expected
, p
->rtt_keepalive_rcv
);
14760 vty_out(vty
, "Next start timer due in %ld seconds\n",
14761 thread_timer_remain_second(p
->t_start
));
14763 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14764 thread_timer_remain_second(p
->t_connect
));
14767 "MRAI (interval %u) timer expires in %ld seconds\n",
14769 thread_timer_remain_second(p
->t_routeadv
));
14771 vty_out(vty
, "Peer Authentication Enabled\n");
14773 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14774 p
->t_read
? "on" : "off",
14775 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14780 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14781 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14782 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14785 vty_out(vty
, "\n");
14787 /* BFD information. */
14789 bgp_bfd_show_info(vty
, p
, json_neigh
);
14792 if (p
->conf_if
) /* Configured interface name. */
14793 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14794 else /* Configured IP address. */
14795 json_object_object_add(json
, p
->host
, json_neigh
);
14799 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14800 enum show_type type
,
14801 union sockunion
*su
,
14802 const char *conf_if
, afi_t afi
,
14805 struct listnode
*node
, *nnode
;
14807 bool found
= false;
14808 safi_t safi
= SAFI_UNICAST
;
14809 json_object
*json_neighbor
= NULL
;
14811 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14813 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14816 if ((peer
->afc
[afi
][safi
]) == 0)
14820 json_neighbor
= json_object_new_object();
14822 if (type
== show_all
) {
14823 bgp_show_peer_gr_status(vty
, peer
, json_neighbor
);
14826 json_object_object_add(json
, peer
->host
,
14829 } else if (type
== show_peer
) {
14832 && !strcmp(peer
->conf_if
, conf_if
))
14834 && !strcmp(peer
->hostname
, conf_if
))) {
14836 bgp_show_peer_gr_status(vty
, peer
,
14840 if (sockunion_same(&peer
->su
, su
)) {
14842 bgp_show_peer_gr_status(vty
, peer
,
14848 json_object_object_add(json
, peer
->host
,
14851 json_object_free(json_neighbor
);
14859 if (type
== show_peer
&& !found
) {
14861 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14863 vty_out(vty
, "%% No such neighbor\n");
14867 vty_out(vty
, "\n");
14869 return CMD_SUCCESS
;
14872 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14873 enum show_type type
, union sockunion
*su
,
14874 const char *conf_if
, bool use_json
,
14877 struct listnode
*node
, *nnode
;
14880 bool nbr_output
= false;
14881 afi_t afi
= AFI_MAX
;
14882 safi_t safi
= SAFI_MAX
;
14884 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14886 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14890 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14891 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14896 bgp_show_peer(vty
, peer
, use_json
, json
);
14902 && !strcmp(peer
->conf_if
, conf_if
))
14904 && !strcmp(peer
->hostname
, conf_if
))) {
14906 bgp_show_peer(vty
, peer
, use_json
,
14910 if (sockunion_same(&peer
->su
, su
)) {
14912 bgp_show_peer(vty
, peer
, use_json
,
14917 case show_ipv4_peer
:
14918 case show_ipv6_peer
:
14919 FOREACH_SAFI (safi
) {
14920 if (peer
->afc
[afi
][safi
]) {
14923 && !strcmp(peer
->conf_if
, conf_if
))
14925 && !strcmp(peer
->hostname
, conf_if
))) {
14927 bgp_show_peer(vty
, peer
, use_json
,
14932 if (sockunion_same(&peer
->su
, su
)) {
14934 bgp_show_peer(vty
, peer
, use_json
,
14942 case show_ipv4_all
:
14943 case show_ipv6_all
:
14944 FOREACH_SAFI (safi
) {
14945 if (peer
->afc
[afi
][safi
]) {
14946 bgp_show_peer(vty
, peer
, use_json
, json
);
14955 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14956 type
== show_ipv6_peer
) && !find
) {
14958 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14960 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14963 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14964 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14965 vty_out(vty
, "%% No BGP neighbors found\n");
14968 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14969 json
, JSON_C_TO_STRING_PRETTY
));
14971 vty_out(vty
, "\n");
14974 return CMD_SUCCESS
;
14977 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14978 enum show_type type
,
14979 const char *ip_str
,
14980 afi_t afi
, json_object
*json
)
14985 union sockunion su
;
14987 bgp
= bgp_get_default();
14993 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
);
14996 ret
= str2sockunion(ip_str
, &su
);
14998 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
,
14999 ip_str
, afi
, json
);
15001 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
15004 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
15008 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
15009 enum show_type type
,
15010 const char *ip_str
,
15013 struct listnode
*node
, *nnode
;
15015 union sockunion su
;
15016 json_object
*json
= NULL
;
15017 int ret
, is_first
= 1;
15018 bool nbr_output
= false;
15021 vty_out(vty
, "{\n");
15023 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15026 if (!(json
= json_object_new_object())) {
15028 EC_BGP_JSON_MEM_ERROR
,
15029 "Unable to allocate memory for JSON object");
15031 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
15035 json_object_int_add(json
, "vrfId",
15036 (bgp
->vrf_id
== VRF_UNKNOWN
)
15038 : (int64_t)bgp
->vrf_id
);
15039 json_object_string_add(
15041 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15046 vty_out(vty
, ",\n");
15050 vty_out(vty
, "\"%s\":",
15051 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15055 vty_out(vty
, "\nInstance %s:\n",
15056 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15061 if (type
== show_peer
|| type
== show_ipv4_peer
||
15062 type
== show_ipv6_peer
) {
15063 ret
= str2sockunion(ip_str
, &su
);
15065 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
15068 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
15071 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
15074 json_object_free(json
);
15079 vty_out(vty
, "}\n");
15080 else if (!nbr_output
)
15081 vty_out(vty
, "%% BGP instance not found\n");
15084 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
15085 enum show_type type
, const char *ip_str
,
15090 union sockunion su
;
15091 json_object
*json
= NULL
;
15094 if (strmatch(name
, "all")) {
15095 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
15097 return CMD_SUCCESS
;
15099 bgp
= bgp_lookup_by_name(name
);
15102 json
= json_object_new_object();
15103 vty_json(vty
, json
);
15106 "%% BGP instance not found\n");
15108 return CMD_WARNING
;
15112 bgp
= bgp_get_default();
15116 json
= json_object_new_object();
15118 ret
= str2sockunion(ip_str
, &su
);
15120 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
15123 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
15126 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
15129 json_object_free(json
);
15132 vty_out(vty
, "{}\n");
15134 vty_out(vty
, "%% BGP instance not found\n");
15137 return CMD_SUCCESS
;
15142 /* "show [ip] bgp neighbors graceful-restart" commands. */
15143 DEFUN (show_ip_bgp_neighbors_graceful_restart
,
15144 show_ip_bgp_neighbors_graceful_restart_cmd
,
15145 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
15151 "Neighbor to display information about\n"
15152 "Neighbor to display information about\n"
15153 "Neighbor on BGP configured interface\n"
15157 char *sh_arg
= NULL
;
15158 enum show_type sh_type
;
15160 afi_t afi
= AFI_MAX
;
15161 bool uj
= use_json(argc
, argv
);
15163 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15168 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
15169 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
15170 || argv_find(argv
, argc
, "WORD", &idx
)) {
15171 sh_type
= show_peer
;
15172 sh_arg
= argv
[idx
]->arg
;
15174 sh_type
= show_all
;
15176 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
15177 return CMD_SUCCESS
;
15180 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
15184 /* "show [ip] bgp neighbors" commands. */
15185 DEFUN (show_ip_bgp_neighbors
,
15186 show_ip_bgp_neighbors_cmd
,
15187 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
15191 BGP_INSTANCE_HELP_STR
15194 "Detailed information on TCP and BGP neighbor connections\n"
15195 "Neighbor to display information about\n"
15196 "Neighbor to display information about\n"
15197 "Neighbor on BGP configured interface\n"
15201 char *sh_arg
= NULL
;
15202 enum show_type sh_type
;
15203 afi_t afi
= AFI_MAX
;
15205 bool uj
= use_json(argc
, argv
);
15209 /* [<vrf> VIEWVRFNAME] */
15210 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15211 vrf
= argv
[idx
+ 1]->arg
;
15212 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15214 } else if (argv_find(argv
, argc
, "view", &idx
))
15215 /* [<view> VIEWVRFNAME] */
15216 vrf
= argv
[idx
+ 1]->arg
;
15220 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
15221 sh_type
= show_ipv4_all
;
15223 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
15224 sh_type
= show_ipv6_all
;
15227 sh_type
= show_all
;
15230 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
15231 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
15232 || argv_find(argv
, argc
, "WORD", &idx
)) {
15233 sh_type
= show_peer
;
15234 sh_arg
= argv
[idx
]->arg
;
15237 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
15238 sh_type
= show_ipv4_peer
;
15239 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
15240 sh_type
= show_ipv6_peer
;
15243 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
15246 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
15247 paths' and `show ip mbgp paths'. Those functions results are the
15249 DEFUN (show_ip_bgp_paths
,
15250 show_ip_bgp_paths_cmd
,
15251 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
15256 "Path information\n")
15258 vty_out(vty
, "Address Refcnt Path\n");
15259 aspath_print_all_vty(vty
);
15260 return CMD_SUCCESS
;
15265 static void community_show_all_iterator(struct hash_bucket
*bucket
,
15268 struct community
*com
;
15270 com
= (struct community
*)bucket
->data
;
15271 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
15272 community_str(com
, false, false));
15275 /* Show BGP's community internal data. */
15276 DEFUN (show_ip_bgp_community_info
,
15277 show_ip_bgp_community_info_cmd
,
15278 "show [ip] bgp community-info",
15282 "List all bgp community information\n")
15284 vty_out(vty
, "Address Refcnt Community\n");
15286 hash_iterate(community_hash(),
15287 (void (*)(struct hash_bucket
*,
15288 void *))community_show_all_iterator
,
15291 return CMD_SUCCESS
;
15294 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
15297 struct lcommunity
*lcom
;
15299 lcom
= (struct lcommunity
*)bucket
->data
;
15300 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
15301 lcommunity_str(lcom
, false, false));
15304 /* Show BGP's community internal data. */
15305 DEFUN (show_ip_bgp_lcommunity_info
,
15306 show_ip_bgp_lcommunity_info_cmd
,
15307 "show ip bgp large-community-info",
15311 "List all bgp large-community information\n")
15313 vty_out(vty
, "Address Refcnt Large-community\n");
15315 hash_iterate(lcommunity_hash(),
15316 (void (*)(struct hash_bucket
*,
15317 void *))lcommunity_show_all_iterator
,
15320 return CMD_SUCCESS
;
15322 /* Graceful Restart */
15324 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
15329 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
15331 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
15333 switch (bgp_global_gr_mode
) {
15335 case GLOBAL_HELPER
:
15336 vty_out(vty
, "Global BGP GR Mode : Helper\n");
15340 vty_out(vty
, "Global BGP GR Mode : Restart\n");
15343 case GLOBAL_DISABLE
:
15344 vty_out(vty
, "Global BGP GR Mode : Disable\n");
15347 case GLOBAL_INVALID
:
15349 "Global BGP GR Mode Invalid\n");
15352 vty_out(vty
, "\n");
15355 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
15356 enum show_type type
,
15357 const char *ip_str
,
15358 afi_t afi
, bool use_json
)
15360 json_object
*json
= NULL
;
15363 json
= json_object_new_object();
15365 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
15368 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
15370 bgp_show_neighbor_graceful_restart_vty(
15371 vty
, type
, ip_str
, afi
, json
);
15374 } else if (afi
!= AFI_MAX
) {
15375 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
15379 json_object_free(json
);
15380 return CMD_ERR_INCOMPLETE
;
15384 vty_json(vty
, json
);
15386 return CMD_SUCCESS
;
15388 /* Graceful Restart */
15390 DEFUN (show_ip_bgp_attr_info
,
15391 show_ip_bgp_attr_info_cmd
,
15392 "show [ip] bgp attribute-info",
15396 "List all bgp attribute information\n")
15398 attr_show_all(vty
);
15399 return CMD_SUCCESS
;
15402 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
15403 afi_t afi
, safi_t safi
,
15404 bool use_json
, json_object
*json
)
15407 struct listnode
*node
;
15410 enum vpn_policy_direction dir
;
15413 json_object
*json_import_vrfs
= NULL
;
15414 json_object
*json_export_vrfs
= NULL
;
15416 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15419 vty_json(vty
, json
);
15421 return CMD_WARNING
;
15424 /* Provide context for the block */
15425 json_object_string_add(json
, "vrf", name
? name
: "default");
15426 json_object_string_add(json
, "afiSafi",
15427 get_afi_safi_str(afi
, safi
, true));
15429 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15430 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15431 json_object_string_add(json
, "importFromVrfs", "none");
15432 json_object_string_add(json
, "importRts", "none");
15434 json_import_vrfs
= json_object_new_array();
15436 for (ALL_LIST_ELEMENTS_RO(
15437 bgp
->vpn_policy
[afi
].import_vrf
,
15439 json_object_array_add(json_import_vrfs
,
15440 json_object_new_string(vname
));
15442 json_object_object_add(json
, "importFromVrfs",
15444 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15445 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15446 ecom_str
= ecommunity_ecom2str(
15447 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15448 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15449 json_object_string_add(json
, "importRts",
15451 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15453 json_object_string_add(json
, "importRts",
15457 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15458 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15459 json_object_string_add(json
, "exportToVrfs", "none");
15460 json_object_string_add(json
, "routeDistinguisher",
15462 json_object_string_add(json
, "exportRts", "none");
15464 json_export_vrfs
= json_object_new_array();
15466 for (ALL_LIST_ELEMENTS_RO(
15467 bgp
->vpn_policy
[afi
].export_vrf
,
15469 json_object_array_add(json_export_vrfs
,
15470 json_object_new_string(vname
));
15471 json_object_object_add(json
, "exportToVrfs",
15473 json_object_string_addf(json
, "routeDistinguisher",
15475 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15477 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15478 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15479 ecom_str
= ecommunity_ecom2str(
15480 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15481 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15482 json_object_string_add(json
, "exportRts",
15484 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15486 json_object_string_add(json
, "exportRts",
15491 vty_json(vty
, json
);
15494 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15497 vty_out(vty
, "%% No such BGP instance exist\n");
15498 return CMD_WARNING
;
15501 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15502 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15504 "This VRF is not importing %s routes from any other VRF\n",
15505 get_afi_safi_str(afi
, safi
, false));
15508 "This VRF is importing %s routes from the following VRFs:\n",
15509 get_afi_safi_str(afi
, safi
, false));
15511 for (ALL_LIST_ELEMENTS_RO(
15512 bgp
->vpn_policy
[afi
].import_vrf
,
15514 vty_out(vty
, " %s\n", vname
);
15516 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15518 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15519 ecom_str
= ecommunity_ecom2str(
15520 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15521 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15522 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15524 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15526 vty_out(vty
, "Import RT(s):\n");
15529 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15530 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15532 "This VRF is not exporting %s routes to any other VRF\n",
15533 get_afi_safi_str(afi
, safi
, false));
15536 "This VRF is exporting %s routes to the following VRFs:\n",
15537 get_afi_safi_str(afi
, safi
, false));
15539 for (ALL_LIST_ELEMENTS_RO(
15540 bgp
->vpn_policy
[afi
].export_vrf
,
15542 vty_out(vty
, " %s\n", vname
);
15544 vty_out(vty
, "RD: %pRD\n",
15545 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15547 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15548 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15549 ecom_str
= ecommunity_ecom2str(
15550 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15551 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15552 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15553 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15555 vty_out(vty
, "Import RT(s):\n");
15559 return CMD_SUCCESS
;
15562 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15563 safi_t safi
, bool use_json
)
15565 struct listnode
*node
, *nnode
;
15567 char *vrf_name
= NULL
;
15568 json_object
*json
= NULL
;
15569 json_object
*json_vrf
= NULL
;
15570 json_object
*json_vrfs
= NULL
;
15573 json
= json_object_new_object();
15574 json_vrfs
= json_object_new_object();
15577 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15579 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15580 vrf_name
= bgp
->name
;
15583 json_vrf
= json_object_new_object();
15585 vty_out(vty
, "\nInstance %s:\n",
15586 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15587 ? VRF_DEFAULT_NAME
: bgp
->name
);
15589 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15591 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15592 json_object_object_add(json_vrfs
,
15593 VRF_DEFAULT_NAME
, json_vrf
);
15595 json_object_object_add(json_vrfs
, vrf_name
,
15601 json_object_object_add(json
, "vrfs", json_vrfs
);
15602 vty_json(vty
, json
);
15605 return CMD_SUCCESS
;
15608 /* "show [ip] bgp route-leak" command. */
15609 DEFUN (show_ip_bgp_route_leak
,
15610 show_ip_bgp_route_leak_cmd
,
15611 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15615 BGP_INSTANCE_HELP_STR
15618 "Route leaking information\n"
15622 afi_t afi
= AFI_MAX
;
15623 safi_t safi
= SAFI_MAX
;
15625 bool uj
= use_json(argc
, argv
);
15627 json_object
*json
= NULL
;
15629 /* show [ip] bgp */
15630 if (argv_find(argv
, argc
, "ip", &idx
)) {
15632 safi
= SAFI_UNICAST
;
15634 /* [vrf VIEWVRFNAME] */
15635 if (argv_find(argv
, argc
, "view", &idx
)) {
15637 "%% This command is not applicable to BGP views\n");
15638 return CMD_WARNING
;
15641 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15642 vrf
= argv
[idx
+ 1]->arg
;
15643 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15646 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15647 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15648 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15650 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15652 "%% This command is applicable only for unicast ipv4|ipv6\n");
15653 return CMD_WARNING
;
15656 if (vrf
&& strmatch(vrf
, "all"))
15657 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15660 json
= json_object_new_object();
15662 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15665 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15666 safi_t safi
, bool uj
)
15668 struct listnode
*node
, *nnode
;
15671 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15673 vty_out(vty
, "\nInstance %s:\n",
15674 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15678 update_group_show(bgp
, afi
, safi
, vty
, 0, uj
);
15682 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15683 int safi
, uint64_t subgrp_id
, bool uj
)
15688 if (strmatch(name
, "all")) {
15689 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
, uj
);
15690 return CMD_SUCCESS
;
15692 bgp
= bgp_lookup_by_name(name
);
15695 bgp
= bgp_get_default();
15699 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
, uj
);
15700 return CMD_SUCCESS
;
15703 DEFUN (show_ip_bgp_updgrps
,
15704 show_ip_bgp_updgrps_cmd
,
15705 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID] [json]",
15709 BGP_INSTANCE_HELP_STR
15711 BGP_SAFI_WITH_LABEL_HELP_STR
15712 "Detailed info about dynamic update groups\n"
15713 "Specific subgroup to display detailed info for\n"
15717 afi_t afi
= AFI_IP6
;
15718 safi_t safi
= SAFI_UNICAST
;
15719 uint64_t subgrp_id
= 0;
15723 bool uj
= use_json(argc
, argv
);
15725 /* show [ip] bgp */
15726 if (argv_find(argv
, argc
, "ip", &idx
))
15728 /* [<vrf> VIEWVRFNAME] */
15729 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15730 vrf
= argv
[idx
+ 1]->arg
;
15731 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15733 } else if (argv_find(argv
, argc
, "view", &idx
))
15734 /* [<view> VIEWVRFNAME] */
15735 vrf
= argv
[idx
+ 1]->arg
;
15736 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15737 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15738 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15741 /* get subgroup id, if provided */
15743 if (argv
[idx
]->type
== VARIABLE_TKN
)
15744 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15746 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
, uj
));
15749 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15750 show_bgp_instance_all_ipv6_updgrps_cmd
,
15751 "show [ip] bgp <view|vrf> all update-groups [json]",
15755 BGP_INSTANCE_ALL_HELP_STR
15756 "Detailed info about dynamic update groups\n"
15759 bool uj
= use_json(argc
, argv
);
15761 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
, uj
);
15762 return CMD_SUCCESS
;
15765 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15766 show_bgp_l2vpn_evpn_updgrps_cmd
,
15767 "show [ip] bgp l2vpn evpn update-groups",
15771 "l2vpn address family\n"
15772 "evpn sub-address family\n"
15773 "Detailed info about dynamic update groups\n")
15776 uint64_t subgrp_id
= 0;
15778 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
, 0);
15779 return CMD_SUCCESS
;
15782 DEFUN (show_bgp_updgrps_stats
,
15783 show_bgp_updgrps_stats_cmd
,
15784 "show [ip] bgp update-groups statistics",
15788 "Detailed info about dynamic update groups\n"
15793 bgp
= bgp_get_default();
15795 update_group_show_stats(bgp
, vty
);
15797 return CMD_SUCCESS
;
15800 DEFUN (show_bgp_instance_updgrps_stats
,
15801 show_bgp_instance_updgrps_stats_cmd
,
15802 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15806 BGP_INSTANCE_HELP_STR
15807 "Detailed info about dynamic update groups\n"
15813 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15815 update_group_show_stats(bgp
, vty
);
15817 return CMD_SUCCESS
;
15820 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15821 afi_t afi
, safi_t safi
,
15822 const char *what
, uint64_t subgrp_id
)
15827 bgp
= bgp_lookup_by_name(name
);
15829 bgp
= bgp_get_default();
15832 if (!strcmp(what
, "advertise-queue"))
15833 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15835 else if (!strcmp(what
, "advertised-routes"))
15836 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15838 else if (!strcmp(what
, "packet-queue"))
15839 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15844 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15845 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15846 "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",
15847 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15849 "Detailed info about dynamic update groups\n"
15850 "Specific subgroup to display info for\n"
15851 "Advertisement queue\n"
15852 "Announced routes\n"
15855 uint64_t subgrp_id
= 0;
15859 subgrp_id
= strtoull(sgid
, NULL
, 10);
15864 afiz
= bgp_vty_afi_from_str(afi
);
15868 afiz
= bgp_vty_afi_from_str(afi
);
15869 if (afiz
!= AFI_IP
)
15871 "%% Cannot specify both 'ip' and 'ipv6'\n");
15872 return CMD_WARNING
;
15875 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15877 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15878 return CMD_SUCCESS
;
15881 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15884 struct listnode
*node
, *nnode
;
15885 struct prefix
*range
;
15890 const char *peer_status
;
15894 json_object
*json_peer_group
= NULL
;
15895 json_object
*json_peer_group_afc
= NULL
;
15896 json_object
*json_peer_group_members
= NULL
;
15897 json_object
*json_peer_group_dynamic
= NULL
;
15898 json_object
*json_peer_group_dynamic_af
= NULL
;
15899 json_object
*json_peer_group_ranges
= NULL
;
15901 conf
= group
->conf
;
15904 json_peer_group
= json_object_new_object();
15905 json_peer_group_afc
= json_object_new_array();
15908 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15910 json_object_int_add(json_peer_group
, "remoteAs",
15913 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15914 group
->name
, conf
->as
);
15915 } else if (conf
->as_type
== AS_INTERNAL
) {
15917 json_object_int_add(json_peer_group
, "remoteAs",
15920 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15921 group
->name
, group
->bgp
->as
);
15924 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15927 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15929 json_object_string_add(json_peer_group
, "type",
15932 vty_out(vty
, " Peer-group type is internal\n");
15935 json_object_string_add(json_peer_group
, "type",
15938 vty_out(vty
, " Peer-group type is external\n");
15941 /* Display AFs configured. */
15943 vty_out(vty
, " Configured address-families:");
15945 FOREACH_AFI_SAFI (afi
, safi
) {
15946 if (conf
->afc
[afi
][safi
]) {
15949 json_object_array_add(
15950 json_peer_group_afc
,
15951 json_object_new_string(get_afi_safi_str(
15952 afi
, safi
, false)));
15954 vty_out(vty
, " %s;",
15955 get_afi_safi_str(afi
, safi
, false));
15960 json_object_object_add(json_peer_group
,
15961 "addressFamiliesConfigured",
15962 json_peer_group_afc
);
15965 vty_out(vty
, " none\n");
15967 vty_out(vty
, "\n");
15970 /* Display listen ranges (for dynamic neighbors), if any */
15971 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15972 lr_count
= listcount(group
->listen_range
[afi
]);
15975 if (!json_peer_group_dynamic
)
15976 json_peer_group_dynamic
=
15977 json_object_new_object();
15979 json_peer_group_dynamic_af
=
15980 json_object_new_object();
15981 json_peer_group_ranges
=
15982 json_object_new_array();
15983 json_object_int_add(json_peer_group_dynamic_af
,
15984 "count", lr_count
);
15986 vty_out(vty
, " %d %s listen range(s)\n",
15987 lr_count
, afi2str(afi
));
15990 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15995 snprintfrr(buf
, sizeof(buf
), "%pFX",
15998 json_object_array_add(
15999 json_peer_group_ranges
,
16000 json_object_new_string(buf
));
16002 vty_out(vty
, " %pFX\n", range
);
16007 json_object_object_add(
16008 json_peer_group_dynamic_af
, "ranges",
16009 json_peer_group_ranges
);
16011 json_object_object_add(
16012 json_peer_group_dynamic
, afi2str(afi
),
16013 json_peer_group_dynamic_af
);
16018 if (json_peer_group_dynamic
)
16019 json_object_object_add(json_peer_group
, "dynamicRanges",
16020 json_peer_group_dynamic
);
16022 /* Display group members and their status */
16023 if (listcount(group
->peer
)) {
16025 json_peer_group_members
= json_object_new_object();
16027 vty_out(vty
, " Peer-group members:\n");
16028 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
16029 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
16030 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
16031 peer_status
= "Idle (Admin)";
16032 else if (CHECK_FLAG(peer
->sflags
,
16033 PEER_STATUS_PREFIX_OVERFLOW
))
16034 peer_status
= "Idle (PfxCt)";
16036 peer_status
= lookup_msg(bgp_status_msg
,
16037 peer
->status
, NULL
);
16039 dynamic
= peer_dynamic_neighbor(peer
);
16042 json_object
*json_peer_group_member
=
16043 json_object_new_object();
16045 json_object_string_add(json_peer_group_member
,
16046 "status", peer_status
);
16049 json_object_boolean_true_add(
16050 json_peer_group_member
,
16053 json_object_object_add(json_peer_group_members
,
16055 json_peer_group_member
);
16057 vty_out(vty
, " %s %s %s \n", peer
->host
,
16058 dynamic
? "(dynamic)" : "",
16063 json_object_object_add(json_peer_group
, "members",
16064 json_peer_group_members
);
16068 json_object_object_add(json
, group
->name
, json_peer_group
);
16070 return CMD_SUCCESS
;
16073 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
16074 const char *group_name
, bool uj
)
16077 struct listnode
*node
, *nnode
;
16078 struct peer_group
*group
;
16079 bool found
= false;
16080 json_object
*json
= NULL
;
16083 json
= json_object_new_object();
16085 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
16089 vty_json(vty
, json
);
16091 vty_out(vty
, "%% BGP instance not found\n");
16093 return CMD_WARNING
;
16096 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
16098 if (strmatch(group
->name
, group_name
)) {
16099 bgp_show_one_peer_group(vty
, group
, json
);
16104 bgp_show_one_peer_group(vty
, group
, json
);
16108 if (group_name
&& !found
&& !uj
)
16109 vty_out(vty
, "%% No such peer-group\n");
16112 vty_json(vty
, json
);
16114 return CMD_SUCCESS
;
16117 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
16118 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
16119 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
16120 "Detailed information on BGP peer groups\n"
16121 "Peer group name\n" JSON_STR
)
16125 bool uj
= use_json(argc
, argv
);
16127 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
16129 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
16131 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
16135 /* Redistribute VTY commands. */
16137 DEFUN (bgp_redistribute_ipv4
,
16138 bgp_redistribute_ipv4_cmd
,
16139 "redistribute " FRR_IP_REDIST_STR_BGPD
,
16140 "Redistribute information from another routing protocol\n"
16141 FRR_IP_REDIST_HELP_STR_BGPD
)
16143 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16144 int idx_protocol
= 1;
16147 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16149 vty_out(vty
, "%% Invalid route type\n");
16150 return CMD_WARNING_CONFIG_FAILED
;
16153 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16154 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
16158 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
16159 "redistribute " FRR_IP_REDIST_STR_BGPD
,
16160 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
16162 DEFUN (bgp_redistribute_ipv4_rmap
,
16163 bgp_redistribute_ipv4_rmap_cmd
,
16164 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
16165 "Redistribute information from another routing protocol\n"
16166 FRR_IP_REDIST_HELP_STR_BGPD
16167 "Route map reference\n"
16168 "Pointer to route-map entries\n")
16170 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16171 int idx_protocol
= 1;
16174 struct bgp_redist
*red
;
16176 struct route_map
*route_map
= route_map_lookup_warn_noexist(
16177 vty
, argv
[idx_word
]->arg
);
16179 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16181 vty_out(vty
, "%% Invalid route type\n");
16182 return CMD_WARNING_CONFIG_FAILED
;
16185 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16187 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16188 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16192 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
16193 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
16194 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16195 "Route map reference\n"
16196 "Pointer to route-map entries\n")
16198 DEFUN (bgp_redistribute_ipv4_metric
,
16199 bgp_redistribute_ipv4_metric_cmd
,
16200 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16201 "Redistribute information from another routing protocol\n"
16202 FRR_IP_REDIST_HELP_STR_BGPD
16203 "Metric for redistributed routes\n"
16204 "Default metric\n")
16206 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16207 int idx_protocol
= 1;
16208 int idx_number
= 3;
16211 struct bgp_redist
*red
;
16214 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16216 vty_out(vty
, "%% Invalid route type\n");
16217 return CMD_WARNING_CONFIG_FAILED
;
16219 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16221 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16222 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16223 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16227 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
16228 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16229 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16230 "Metric for redistributed routes\n"
16231 "Default metric\n")
16233 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
16234 bgp_redistribute_ipv4_rmap_metric_cmd
,
16235 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16236 "Redistribute information from another routing protocol\n"
16237 FRR_IP_REDIST_HELP_STR_BGPD
16238 "Route map reference\n"
16239 "Pointer to route-map entries\n"
16240 "Metric for redistributed routes\n"
16241 "Default metric\n")
16243 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16244 int idx_protocol
= 1;
16246 int idx_number
= 5;
16249 struct bgp_redist
*red
;
16251 struct route_map
*route_map
=
16252 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16254 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16256 vty_out(vty
, "%% Invalid route type\n");
16257 return CMD_WARNING_CONFIG_FAILED
;
16259 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16261 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16263 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16264 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16265 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16269 bgp_redistribute_ipv4_rmap_metric
,
16270 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
16271 "redistribute " FRR_IP_REDIST_STR_BGPD
16272 " route-map RMAP_NAME metric (0-4294967295)",
16273 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16274 "Route map reference\n"
16275 "Pointer to route-map entries\n"
16276 "Metric for redistributed routes\n"
16277 "Default metric\n")
16279 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
16280 bgp_redistribute_ipv4_metric_rmap_cmd
,
16281 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16282 "Redistribute information from another routing protocol\n"
16283 FRR_IP_REDIST_HELP_STR_BGPD
16284 "Metric for redistributed routes\n"
16286 "Route map reference\n"
16287 "Pointer to route-map entries\n")
16289 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16290 int idx_protocol
= 1;
16291 int idx_number
= 3;
16295 struct bgp_redist
*red
;
16297 struct route_map
*route_map
=
16298 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16300 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16302 vty_out(vty
, "%% Invalid route type\n");
16303 return CMD_WARNING_CONFIG_FAILED
;
16305 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16307 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16308 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16310 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16311 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16315 bgp_redistribute_ipv4_metric_rmap
,
16316 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
16317 "redistribute " FRR_IP_REDIST_STR_BGPD
16318 " metric (0-4294967295) route-map RMAP_NAME",
16319 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16320 "Metric for redistributed routes\n"
16322 "Route map reference\n"
16323 "Pointer to route-map entries\n")
16325 DEFUN (bgp_redistribute_ipv4_ospf
,
16326 bgp_redistribute_ipv4_ospf_cmd
,
16327 "redistribute <ospf|table> (1-65535)",
16328 "Redistribute information from another routing protocol\n"
16329 "Open Shortest Path First (OSPFv2)\n"
16330 "Non-main Kernel Routing Table\n"
16331 "Instance ID/Table ID\n")
16333 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16334 int idx_ospf_table
= 1;
16335 int idx_number
= 2;
16336 unsigned short instance
;
16337 unsigned short protocol
;
16339 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16341 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16342 protocol
= ZEBRA_ROUTE_OSPF
;
16344 protocol
= ZEBRA_ROUTE_TABLE
;
16346 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16347 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
16350 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
16351 "redistribute <ospf|table> (1-65535)",
16352 "Redistribute information from another routing protocol\n"
16353 "Open Shortest Path First (OSPFv2)\n"
16354 "Non-main Kernel Routing Table\n"
16355 "Instance ID/Table ID\n")
16357 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
16358 bgp_redistribute_ipv4_ospf_rmap_cmd
,
16359 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16360 "Redistribute information from another routing protocol\n"
16361 "Open Shortest Path First (OSPFv2)\n"
16362 "Non-main Kernel Routing Table\n"
16363 "Instance ID/Table ID\n"
16364 "Route map reference\n"
16365 "Pointer to route-map entries\n")
16367 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16368 int idx_ospf_table
= 1;
16369 int idx_number
= 2;
16371 struct bgp_redist
*red
;
16372 unsigned short instance
;
16375 struct route_map
*route_map
=
16376 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16378 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16379 protocol
= ZEBRA_ROUTE_OSPF
;
16381 protocol
= ZEBRA_ROUTE_TABLE
;
16383 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16384 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16386 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16387 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16390 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
16391 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
16392 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16393 "Redistribute information from another routing protocol\n"
16394 "Open Shortest Path First (OSPFv2)\n"
16395 "Non-main Kernel Routing Table\n"
16396 "Instance ID/Table ID\n"
16397 "Route map reference\n"
16398 "Pointer to route-map entries\n")
16400 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
16401 bgp_redistribute_ipv4_ospf_metric_cmd
,
16402 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16403 "Redistribute information from another routing protocol\n"
16404 "Open Shortest Path First (OSPFv2)\n"
16405 "Non-main Kernel Routing Table\n"
16406 "Instance ID/Table ID\n"
16407 "Metric for redistributed routes\n"
16408 "Default metric\n")
16410 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16411 int idx_ospf_table
= 1;
16412 int idx_number
= 2;
16413 int idx_number_2
= 4;
16415 struct bgp_redist
*red
;
16416 unsigned short instance
;
16420 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16421 protocol
= ZEBRA_ROUTE_OSPF
;
16423 protocol
= ZEBRA_ROUTE_TABLE
;
16425 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16426 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16428 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16429 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16431 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16434 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
16435 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
16436 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16437 "Redistribute information from another routing protocol\n"
16438 "Open Shortest Path First (OSPFv2)\n"
16439 "Non-main Kernel Routing Table\n"
16440 "Instance ID/Table ID\n"
16441 "Metric for redistributed routes\n"
16442 "Default metric\n")
16444 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
16445 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
16446 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16447 "Redistribute information from another routing protocol\n"
16448 "Open Shortest Path First (OSPFv2)\n"
16449 "Non-main Kernel Routing Table\n"
16450 "Instance ID/Table ID\n"
16451 "Route map reference\n"
16452 "Pointer to route-map entries\n"
16453 "Metric for redistributed routes\n"
16454 "Default metric\n")
16456 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16457 int idx_ospf_table
= 1;
16458 int idx_number
= 2;
16460 int idx_number_2
= 6;
16462 struct bgp_redist
*red
;
16463 unsigned short instance
;
16466 struct route_map
*route_map
=
16467 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16469 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16470 protocol
= ZEBRA_ROUTE_OSPF
;
16472 protocol
= ZEBRA_ROUTE_TABLE
;
16474 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16475 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16477 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16479 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16480 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16482 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16486 bgp_redistribute_ipv4_ospf_rmap_metric
,
16487 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
16488 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16489 "Redistribute information from another routing protocol\n"
16490 "Open Shortest Path First (OSPFv2)\n"
16491 "Non-main Kernel Routing Table\n"
16492 "Instance ID/Table ID\n"
16493 "Route map reference\n"
16494 "Pointer to route-map entries\n"
16495 "Metric for redistributed routes\n"
16496 "Default metric\n")
16498 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
16499 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
16500 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16501 "Redistribute information from another routing protocol\n"
16502 "Open Shortest Path First (OSPFv2)\n"
16503 "Non-main Kernel Routing Table\n"
16504 "Instance ID/Table ID\n"
16505 "Metric for redistributed routes\n"
16507 "Route map reference\n"
16508 "Pointer to route-map entries\n")
16510 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16511 int idx_ospf_table
= 1;
16512 int idx_number
= 2;
16513 int idx_number_2
= 4;
16516 struct bgp_redist
*red
;
16517 unsigned short instance
;
16520 struct route_map
*route_map
=
16521 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16523 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16524 protocol
= ZEBRA_ROUTE_OSPF
;
16526 protocol
= ZEBRA_ROUTE_TABLE
;
16528 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16529 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16531 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16532 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16535 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16536 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16540 bgp_redistribute_ipv4_ospf_metric_rmap
,
16541 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16542 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16543 "Redistribute information from another routing protocol\n"
16544 "Open Shortest Path First (OSPFv2)\n"
16545 "Non-main Kernel Routing Table\n"
16546 "Instance ID/Table ID\n"
16547 "Metric for redistributed routes\n"
16549 "Route map reference\n"
16550 "Pointer to route-map entries\n")
16552 DEFUN (no_bgp_redistribute_ipv4_ospf
,
16553 no_bgp_redistribute_ipv4_ospf_cmd
,
16554 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16556 "Redistribute information from another routing protocol\n"
16557 "Open Shortest Path First (OSPFv2)\n"
16558 "Non-main Kernel Routing Table\n"
16559 "Instance ID/Table ID\n"
16560 "Metric for redistributed routes\n"
16562 "Route map reference\n"
16563 "Pointer to route-map entries\n")
16565 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16566 int idx_ospf_table
= 2;
16567 int idx_number
= 3;
16568 unsigned short instance
;
16571 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16572 protocol
= ZEBRA_ROUTE_OSPF
;
16574 protocol
= ZEBRA_ROUTE_TABLE
;
16576 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16577 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
16581 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16582 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16584 "Redistribute information from another routing protocol\n"
16585 "Open Shortest Path First (OSPFv2)\n"
16586 "Non-main Kernel Routing Table\n"
16587 "Instance ID/Table ID\n"
16588 "Metric for redistributed routes\n"
16590 "Route map reference\n"
16591 "Pointer to route-map entries\n")
16593 DEFUN (no_bgp_redistribute_ipv4
,
16594 no_bgp_redistribute_ipv4_cmd
,
16595 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16597 "Redistribute information from another routing protocol\n"
16598 FRR_IP_REDIST_HELP_STR_BGPD
16599 "Metric for redistributed routes\n"
16601 "Route map reference\n"
16602 "Pointer to route-map entries\n")
16604 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16605 int idx_protocol
= 2;
16608 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16610 vty_out(vty
, "%% Invalid route type\n");
16611 return CMD_WARNING_CONFIG_FAILED
;
16613 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
16617 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16618 "no redistribute " FRR_IP_REDIST_STR_BGPD
16619 " [{metric (0-4294967295)|route-map RMAP_NAME}]",
16621 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16622 "Metric for redistributed routes\n"
16624 "Route map reference\n"
16625 "Pointer to route-map entries\n")
16627 DEFUN (bgp_redistribute_ipv6
,
16628 bgp_redistribute_ipv6_cmd
,
16629 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16630 "Redistribute information from another routing protocol\n"
16631 FRR_IP6_REDIST_HELP_STR_BGPD
)
16633 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16634 int idx_protocol
= 1;
16637 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16639 vty_out(vty
, "%% Invalid route type\n");
16640 return CMD_WARNING_CONFIG_FAILED
;
16643 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16644 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
16647 DEFUN (bgp_redistribute_ipv6_rmap
,
16648 bgp_redistribute_ipv6_rmap_cmd
,
16649 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME",
16650 "Redistribute information from another routing protocol\n"
16651 FRR_IP6_REDIST_HELP_STR_BGPD
16652 "Route map reference\n"
16653 "Pointer to route-map entries\n")
16655 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16656 int idx_protocol
= 1;
16659 struct bgp_redist
*red
;
16661 struct route_map
*route_map
=
16662 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16664 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16666 vty_out(vty
, "%% Invalid route type\n");
16667 return CMD_WARNING_CONFIG_FAILED
;
16670 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16672 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16673 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16676 DEFUN (bgp_redistribute_ipv6_metric
,
16677 bgp_redistribute_ipv6_metric_cmd
,
16678 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16679 "Redistribute information from another routing protocol\n"
16680 FRR_IP6_REDIST_HELP_STR_BGPD
16681 "Metric for redistributed routes\n"
16682 "Default metric\n")
16684 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16685 int idx_protocol
= 1;
16686 int idx_number
= 3;
16689 struct bgp_redist
*red
;
16692 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16694 vty_out(vty
, "%% Invalid route type\n");
16695 return CMD_WARNING_CONFIG_FAILED
;
16697 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16699 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16700 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
16701 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16704 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
16705 bgp_redistribute_ipv6_rmap_metric_cmd
,
16706 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16707 "Redistribute information from another routing protocol\n"
16708 FRR_IP6_REDIST_HELP_STR_BGPD
16709 "Route map reference\n"
16710 "Pointer to route-map entries\n"
16711 "Metric for redistributed routes\n"
16712 "Default metric\n")
16714 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16715 int idx_protocol
= 1;
16717 int idx_number
= 5;
16720 struct bgp_redist
*red
;
16722 struct route_map
*route_map
=
16723 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16725 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16727 vty_out(vty
, "%% Invalid route type\n");
16728 return CMD_WARNING_CONFIG_FAILED
;
16730 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16732 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16734 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16735 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
16737 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16740 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
16741 bgp_redistribute_ipv6_metric_rmap_cmd
,
16742 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16743 "Redistribute information from another routing protocol\n"
16744 FRR_IP6_REDIST_HELP_STR_BGPD
16745 "Metric for redistributed routes\n"
16747 "Route map reference\n"
16748 "Pointer to route-map entries\n")
16750 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16751 int idx_protocol
= 1;
16752 int idx_number
= 3;
16756 struct bgp_redist
*red
;
16758 struct route_map
*route_map
=
16759 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16761 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16763 vty_out(vty
, "%% Invalid route type\n");
16764 return CMD_WARNING_CONFIG_FAILED
;
16766 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16768 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16769 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
16772 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16773 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16776 DEFUN (no_bgp_redistribute_ipv6
,
16777 no_bgp_redistribute_ipv6_cmd
,
16778 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16780 "Redistribute information from another routing protocol\n"
16781 FRR_IP6_REDIST_HELP_STR_BGPD
16782 "Metric for redistributed routes\n"
16784 "Route map reference\n"
16785 "Pointer to route-map entries\n")
16787 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16788 int idx_protocol
= 2;
16791 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16793 vty_out(vty
, "%% Invalid route type\n");
16794 return CMD_WARNING_CONFIG_FAILED
;
16797 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
16800 /* Neighbor update tcp-mss. */
16801 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16802 const char *tcp_mss_str
)
16805 uint32_t tcp_mss_val
= 0;
16807 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16809 return CMD_WARNING_CONFIG_FAILED
;
16812 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16813 peer_tcp_mss_set(peer
, tcp_mss_val
);
16815 peer_tcp_mss_unset(peer
);
16818 return CMD_SUCCESS
;
16821 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16822 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16823 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16824 "TCP max segment size\n"
16827 int peer_index
= 1;
16831 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16832 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16833 argv
[mss_index
]->arg
);
16836 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16837 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16838 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16839 "TCP max segment size\n"
16842 int peer_index
= 2;
16845 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16846 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16849 DEFPY(bgp_retain_route_target
, bgp_retain_route_target_cmd
,
16850 "[no$no] bgp retain route-target all",
16852 "Retain BGP updates\n"
16853 "Retain BGP updates based on route-target values\n"
16854 "Retain all BGP updates\n")
16857 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
16859 check
= CHECK_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)][bgp_node_safi(vty
)],
16860 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16861 if (check
!= !no
) {
16863 SET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16864 [bgp_node_safi(vty
)],
16865 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16867 UNSET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16868 [bgp_node_safi(vty
)],
16869 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16870 /* trigger a flush to re-sync with ADJ-RIB-in */
16871 bgp_clear(vty
, bgp
, bgp_node_afi(vty
), bgp_node_safi(vty
),
16872 clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
16874 return CMD_SUCCESS
;
16877 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16878 afi_t afi
, safi_t safi
)
16882 /* Unicast redistribution only. */
16883 if (safi
!= SAFI_UNICAST
)
16886 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16887 /* Redistribute BGP does not make sense. */
16888 if (i
!= ZEBRA_ROUTE_BGP
) {
16889 struct list
*red_list
;
16890 struct listnode
*node
;
16891 struct bgp_redist
*red
;
16893 red_list
= bgp
->redist
[afi
][i
];
16897 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16898 /* "redistribute" configuration. */
16899 vty_out(vty
, " redistribute %s",
16900 zebra_route_string(i
));
16902 vty_out(vty
, " %d", red
->instance
);
16903 if (red
->redist_metric_flag
)
16904 vty_out(vty
, " metric %u",
16905 red
->redist_metric
);
16906 if (red
->rmap
.name
)
16907 vty_out(vty
, " route-map %s",
16909 vty_out(vty
, "\n");
16915 /* peer-group helpers for config-write */
16917 static bool peergroup_flag_check(struct peer
*peer
, uint64_t flag
)
16919 if (!peer_group_active(peer
)) {
16920 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16921 return !CHECK_FLAG(peer
->flags
, flag
);
16923 return !!CHECK_FLAG(peer
->flags
, flag
);
16926 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16929 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16932 if (!peer_group_active(peer
)) {
16933 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16934 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16936 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16939 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16942 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16943 uint8_t type
, int direct
)
16945 struct bgp_filter
*filter
;
16947 if (peer_group_active(peer
))
16948 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16951 filter
= &peer
->filter
[afi
][safi
];
16953 case PEER_FT_DISTRIBUTE_LIST
:
16954 return !!(filter
->dlist
[direct
].name
);
16955 case PEER_FT_FILTER_LIST
:
16956 return !!(filter
->aslist
[direct
].name
);
16957 case PEER_FT_PREFIX_LIST
:
16958 return !!(filter
->plist
[direct
].name
);
16959 case PEER_FT_ROUTE_MAP
:
16960 return !!(filter
->map
[direct
].name
);
16961 case PEER_FT_UNSUPPRESS_MAP
:
16962 return !!(filter
->usmap
.name
);
16963 case PEER_FT_ADVERTISE_MAP
:
16964 return !!(filter
->advmap
.aname
16965 && ((filter
->advmap
.condition
== direct
)
16966 && filter
->advmap
.cname
));
16972 /* Return true if the addpath type is set for peer and different from
16975 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16978 enum bgp_addpath_strat type
, g_type
;
16980 type
= peer
->addpath_type
[afi
][safi
];
16982 if (type
!= BGP_ADDPATH_NONE
) {
16983 if (peer_group_active(peer
)) {
16984 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16986 if (type
!= g_type
)
16998 /* This is part of the address-family block (unicast only) */
16999 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
17003 uint32_t tovpn_sid_index
= 0;
17005 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
17006 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
17007 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
17008 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
17009 bgp
->vpn_policy
[afi
]
17010 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
17012 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
17013 bgp
->vpn_policy
[afi
]
17014 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
17016 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
17017 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
17018 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
17019 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
17022 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17023 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
17025 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
17028 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
17029 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
17030 bgp
->vpn_policy
[afi
].tovpn_label
);
17034 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
17035 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17036 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
17037 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
17038 } else if (tovpn_sid_index
!= 0) {
17039 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
17043 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
, BGP_VPN_POLICY_TOVPN_RD_SET
))
17044 vty_out(vty
, "%*srd vpn export %pRD\n", indent
, "",
17045 &bgp
->vpn_policy
[afi
].tovpn_rd
);
17047 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17048 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
17050 char buf
[PREFIX_STRLEN
];
17051 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
17052 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
17055 vty_out(vty
, "%*snexthop vpn export %s\n",
17059 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
17060 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
17062 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
17063 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
17065 char *b
= ecommunity_ecom2str(
17066 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
17067 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
17068 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
17069 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17071 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
17072 char *b
= ecommunity_ecom2str(
17073 bgp
->vpn_policy
[afi
]
17074 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
17075 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17076 ECOMMUNITY_ROUTE_TARGET
);
17077 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
17078 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17080 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
17081 char *b
= ecommunity_ecom2str(
17082 bgp
->vpn_policy
[afi
]
17083 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
17084 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17085 ECOMMUNITY_ROUTE_TARGET
);
17086 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
17087 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17091 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
17092 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
17093 bgp
->vpn_policy
[afi
]
17094 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
17096 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
17097 char *b
= ecommunity_ecom2str(
17098 bgp
->vpn_policy
[afi
]
17099 .import_redirect_rtlist
,
17100 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17101 ECOMMUNITY_ROUTE_TARGET
);
17103 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
17104 != ECOMMUNITY_SIZE
)
17105 vty_out(vty
, "%*srt6 redirect import %s\n",
17108 vty_out(vty
, "%*srt redirect import %s\n",
17110 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17114 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
17115 afi_t afi
, safi_t safi
)
17117 struct bgp_filter
*filter
;
17121 filter
= &peer
->filter
[afi
][safi
];
17123 /* distribute-list. */
17124 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
17126 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
17127 filter
->dlist
[FILTER_IN
].name
);
17129 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
17131 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
17132 filter
->dlist
[FILTER_OUT
].name
);
17135 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
17137 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
17138 filter
->plist
[FILTER_IN
].name
);
17140 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
17142 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
17143 filter
->plist
[FILTER_OUT
].name
);
17146 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
17147 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
17148 filter
->map
[RMAP_IN
].name
);
17150 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
17152 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
17153 filter
->map
[RMAP_OUT
].name
);
17155 /* unsuppress-map */
17156 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
17157 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
17158 filter
->usmap
.name
);
17160 /* advertise-map : always applied in OUT direction*/
17161 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
17162 CONDITION_NON_EXIST
))
17164 " neighbor %s advertise-map %s non-exist-map %s\n",
17165 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
17167 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
17169 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
17170 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
17173 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
17175 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
17176 filter
->aslist
[FILTER_IN
].name
);
17178 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
17180 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
17181 filter
->aslist
[FILTER_OUT
].name
);
17184 /* BGP peer configuration display function. */
17185 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
17188 struct peer
*g_peer
= NULL
;
17190 int if_pg_printed
= false;
17191 int if_ras_printed
= false;
17193 /* Skip dynamic neighbors. */
17194 if (peer_dynamic_neighbor(peer
))
17198 addr
= peer
->conf_if
;
17202 /************************************
17203 ****** Global to the neighbor ******
17204 ************************************/
17205 if (peer
->conf_if
) {
17206 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
17207 vty_out(vty
, " neighbor %s interface v6only", addr
);
17209 vty_out(vty
, " neighbor %s interface", addr
);
17211 if (peer_group_active(peer
)) {
17212 vty_out(vty
, " peer-group %s", peer
->group
->name
);
17213 if_pg_printed
= true;
17214 } else if (peer
->as_type
== AS_SPECIFIED
) {
17215 vty_out(vty
, " remote-as %u", peer
->as
);
17216 if_ras_printed
= true;
17217 } else if (peer
->as_type
== AS_INTERNAL
) {
17218 vty_out(vty
, " remote-as internal");
17219 if_ras_printed
= true;
17220 } else if (peer
->as_type
== AS_EXTERNAL
) {
17221 vty_out(vty
, " remote-as external");
17222 if_ras_printed
= true;
17225 vty_out(vty
, "\n");
17228 /* remote-as and peer-group */
17229 /* peer is a member of a peer-group */
17230 if (peer_group_active(peer
)) {
17231 g_peer
= peer
->group
->conf
;
17233 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
17234 if (peer
->as_type
== AS_SPECIFIED
) {
17235 vty_out(vty
, " neighbor %s remote-as %u\n",
17237 } else if (peer
->as_type
== AS_INTERNAL
) {
17239 " neighbor %s remote-as internal\n",
17241 } else if (peer
->as_type
== AS_EXTERNAL
) {
17243 " neighbor %s remote-as external\n",
17248 /* For swpX peers we displayed the peer-group
17249 * via 'neighbor swpX interface peer-group PGNAME' */
17250 if (!if_pg_printed
)
17251 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
17252 peer
->group
->name
);
17255 /* peer is NOT a member of a peer-group */
17257 /* peer is a peer-group, declare the peer-group */
17258 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
17259 vty_out(vty
, " neighbor %s peer-group\n", addr
);
17262 if (!if_ras_printed
) {
17263 if (peer
->as_type
== AS_SPECIFIED
) {
17264 vty_out(vty
, " neighbor %s remote-as %u\n",
17266 } else if (peer
->as_type
== AS_INTERNAL
) {
17268 " neighbor %s remote-as internal\n",
17270 } else if (peer
->as_type
== AS_EXTERNAL
) {
17272 " neighbor %s remote-as external\n",
17279 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
17280 vty_out(vty
, " neighbor %s local-as %u", addr
,
17281 peer
->change_local_as
);
17282 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
17283 vty_out(vty
, " no-prepend");
17284 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
17285 vty_out(vty
, " replace-as");
17286 vty_out(vty
, "\n");
17291 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
17295 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
17296 if (peer
->tx_shutdown_message
)
17297 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
17298 peer
->tx_shutdown_message
);
17300 vty_out(vty
, " neighbor %s shutdown\n", addr
);
17303 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
17304 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
17305 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
17308 if (peer
->bfd_config
)
17309 bgp_bfd_peer_config_write(vty
, peer
, addr
);
17312 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
17313 vty_out(vty
, " neighbor %s password %s\n", addr
,
17316 /* neighbor solo */
17317 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
17318 if (!peer_group_active(peer
)) {
17319 vty_out(vty
, " neighbor %s solo\n", addr
);
17324 if (peer
->port
!= BGP_PORT_DEFAULT
) {
17325 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
17328 /* Local interface name */
17329 if (peer
->ifname
) {
17330 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
17333 /* TCP max segment size */
17334 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
17335 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
17338 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
17339 vty_out(vty
, " neighbor %s passive\n", addr
);
17341 /* ebgp-multihop */
17342 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
17343 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
17344 && peer
->ttl
== MAXTTL
)) {
17345 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
17346 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
17352 if (peergroup_flag_check(peer
, PEER_FLAG_AIGP
))
17353 vty_out(vty
, " neighbor %s aigp\n", addr
);
17355 /* graceful-shutdown */
17356 if (peergroup_flag_check(peer
, PEER_FLAG_GRACEFUL_SHUTDOWN
))
17357 vty_out(vty
, " neighbor %s graceful-shutdown\n", addr
);
17360 if (peergroup_flag_check(peer
, PEER_FLAG_ROLE
) &&
17361 peer
->local_role
!= ROLE_UNDEFINED
)
17362 vty_out(vty
, " neighbor %s local-role %s%s\n", addr
,
17363 bgp_get_name_by_role(peer
->local_role
),
17364 CHECK_FLAG(peer
->flags
, PEER_FLAG_ROLE_STRICT_MODE
)
17368 /* ttl-security hops */
17369 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
17370 if (!peer_group_active(peer
)
17371 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
17372 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
17373 addr
, peer
->gtsm_hops
);
17377 /* disable-connected-check */
17378 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
17379 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
17381 /* link-bw-encoding-ieee */
17382 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
17383 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
17386 /* extended-optional-parameters */
17387 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
17388 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
17391 /* enforce-first-as */
17392 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
17393 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
17395 /* update-source */
17396 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
17397 if (peer
->update_source
)
17398 vty_out(vty
, " neighbor %s update-source %pSU\n", addr
,
17399 peer
->update_source
);
17400 else if (peer
->update_if
)
17401 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
17405 /* advertisement-interval */
17406 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
17407 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
17411 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
17412 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
17413 peer
->keepalive
, peer
->holdtime
);
17415 /* timers connect */
17416 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
17417 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17419 /* need special-case handling for changed default values due to
17420 * config profile / version (because there is no "timers bgp connect"
17421 * command, we need to save this per-peer :/)
17423 else if (!peer_group_active(peer
) && !peer
->connect
&&
17424 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
17425 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17426 peer
->bgp
->default_connect_retry
);
17428 /* timers delayopen */
17429 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
17430 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17432 /* Save config even though flag is not set if default values have been
17435 else if (!peer_group_active(peer
) && !peer
->delayopen
17436 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
17437 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17438 peer
->bgp
->default_delayopen
);
17440 /* capability dynamic */
17441 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
17442 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
17444 /* capability extended-nexthop */
17445 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
17446 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
) &&
17449 " no neighbor %s capability extended-nexthop\n",
17451 else if (!peer
->conf_if
)
17453 " neighbor %s capability extended-nexthop\n",
17457 /* dont-capability-negotiation */
17458 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
17459 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
17461 /* override-capability */
17462 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
17463 vty_out(vty
, " neighbor %s override-capability\n", addr
);
17465 /* strict-capability-match */
17466 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
17467 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
17469 /* Sender side AS path loop detection. */
17470 if (peer
->as_path_loop_detection
)
17471 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
17474 /* path-attribute discard */
17475 char discard_attrs_str
[BUFSIZ
] = {0};
17476 bool discard_attrs
= bgp_path_attribute_discard(
17477 peer
, discard_attrs_str
, sizeof(discard_attrs_str
));
17480 vty_out(vty
, " neighbor %s path-attribute discard %s\n", addr
,
17481 discard_attrs_str
);
17483 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17484 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
17486 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17487 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
17489 " neighbor %s graceful-restart-helper\n", addr
);
17490 } else if (CHECK_FLAG(
17491 peer
->peer_gr_new_status_flag
,
17492 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
17494 " neighbor %s graceful-restart\n", addr
);
17496 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17497 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
17499 peer
->peer_gr_new_status_flag
,
17500 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
17501 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
17507 /* BGP peer configuration display function. */
17508 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
17509 struct peer
*peer
, afi_t afi
, safi_t safi
)
17511 struct peer
*g_peer
= NULL
;
17513 bool flag_scomm
, flag_secomm
, flag_slcomm
;
17515 /* Skip dynamic neighbors. */
17516 if (peer_dynamic_neighbor(peer
))
17520 addr
= peer
->conf_if
;
17524 /************************************
17525 ****** Per AF to the neighbor ******
17526 ************************************/
17527 if (peer_group_active(peer
)) {
17528 g_peer
= peer
->group
->conf
;
17530 /* If the peer-group is active but peer is not, print a 'no
17532 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
17533 vty_out(vty
, " no neighbor %s activate\n", addr
);
17536 /* If the peer-group is not active but peer is, print an
17538 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
17539 vty_out(vty
, " neighbor %s activate\n", addr
);
17542 if (peer
->afc
[afi
][safi
]) {
17543 if (safi
== SAFI_ENCAP
)
17544 vty_out(vty
, " neighbor %s activate\n", addr
);
17545 else if (!bgp
->default_af
[afi
][safi
])
17546 vty_out(vty
, " neighbor %s activate\n", addr
);
17548 if (bgp
->default_af
[afi
][safi
])
17549 vty_out(vty
, " no neighbor %s activate\n",
17554 /* addpath TX knobs */
17555 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
17556 switch (peer
->addpath_type
[afi
][safi
]) {
17557 case BGP_ADDPATH_ALL
:
17558 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
17561 case BGP_ADDPATH_BEST_PER_AS
:
17563 " neighbor %s addpath-tx-bestpath-per-AS\n",
17566 case BGP_ADDPATH_MAX
:
17567 case BGP_ADDPATH_NONE
:
17572 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
17573 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
17575 /* ORF capability. */
17576 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17577 || peergroup_af_flag_check(peer
, afi
, safi
,
17578 PEER_FLAG_ORF_PREFIX_RM
)) {
17579 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17581 if (peergroup_af_flag_check(peer
, afi
, safi
,
17582 PEER_FLAG_ORF_PREFIX_SM
)
17583 && peergroup_af_flag_check(peer
, afi
, safi
,
17584 PEER_FLAG_ORF_PREFIX_RM
))
17585 vty_out(vty
, " both");
17586 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17587 PEER_FLAG_ORF_PREFIX_SM
))
17588 vty_out(vty
, " send");
17590 vty_out(vty
, " receive");
17591 vty_out(vty
, "\n");
17594 /* Route reflector client. */
17595 if (peergroup_af_flag_check(peer
, afi
, safi
,
17596 PEER_FLAG_REFLECTOR_CLIENT
)) {
17597 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17600 /* next-hop-self force */
17601 if (peergroup_af_flag_check(peer
, afi
, safi
,
17602 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17603 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17606 /* next-hop-self */
17607 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17608 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17611 /* remove-private-AS */
17612 if (peergroup_af_flag_check(peer
, afi
, safi
,
17613 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17614 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17618 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17619 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17620 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17624 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17625 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17626 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17629 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17630 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17631 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17635 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17636 vty_out(vty
, " neighbor %s as-override\n", addr
);
17639 /* send-community print. */
17640 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17641 PEER_FLAG_SEND_COMMUNITY
);
17642 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17643 PEER_FLAG_SEND_EXT_COMMUNITY
);
17644 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17645 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17647 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17648 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17651 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17654 " no neighbor %s send-community extended\n",
17658 vty_out(vty
, " no neighbor %s send-community large\n",
17662 /* Default information */
17663 if (peergroup_af_flag_check(peer
, afi
, safi
,
17664 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17665 vty_out(vty
, " neighbor %s default-originate", addr
);
17667 if (peer
->default_rmap
[afi
][safi
].name
)
17668 vty_out(vty
, " route-map %s",
17669 peer
->default_rmap
[afi
][safi
].name
);
17671 vty_out(vty
, "\n");
17674 /* Soft reconfiguration inbound. */
17675 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17676 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17680 /* maximum-prefix. */
17681 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17682 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17683 peer
->pmax
[afi
][safi
]);
17685 if (peer
->pmax_threshold
[afi
][safi
]
17686 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17687 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17688 if (peer_af_flag_check(peer
, afi
, safi
,
17689 PEER_FLAG_MAX_PREFIX_WARNING
))
17690 vty_out(vty
, " warning-only");
17691 if (peer
->pmax_restart
[afi
][safi
])
17692 vty_out(vty
, " restart %u",
17693 peer
->pmax_restart
[afi
][safi
]);
17694 if (peer_af_flag_check(peer
, afi
, safi
,
17695 PEER_FLAG_MAX_PREFIX_FORCE
))
17696 vty_out(vty
, " force");
17698 vty_out(vty
, "\n");
17701 /* maximum-prefix-out */
17702 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17703 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17704 addr
, peer
->pmax_out
[afi
][safi
]);
17706 /* Route server client. */
17707 if (peergroup_af_flag_check(peer
, afi
, safi
,
17708 PEER_FLAG_RSERVER_CLIENT
)) {
17709 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17712 /* Nexthop-local unchanged. */
17713 if (peergroup_af_flag_check(peer
, afi
, safi
,
17714 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17715 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17718 /* allowas-in <1-10> */
17719 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17720 if (peer_af_flag_check(peer
, afi
, safi
,
17721 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17722 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17723 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17724 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17726 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17727 peer
->allowas_in
[afi
][safi
]);
17732 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
))
17733 vty_out(vty
, " neighbor %s accept-own\n", addr
);
17736 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOO
)) {
17737 char *soo_str
= ecommunity_ecom2str(
17738 peer
->soo
[afi
][safi
], ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
17740 vty_out(vty
, " neighbor %s soo %s\n", addr
, soo_str
);
17741 XFREE(MTYPE_ECOMMUNITY_STR
, soo_str
);
17745 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17746 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17747 peer
->weight
[afi
][safi
]);
17750 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17752 /* atribute-unchanged. */
17753 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17754 || (safi
!= SAFI_EVPN
17755 && peer_af_flag_check(peer
, afi
, safi
,
17756 PEER_FLAG_NEXTHOP_UNCHANGED
))
17757 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17759 if (!peer_group_active(peer
)
17760 || peergroup_af_flag_check(peer
, afi
, safi
,
17761 PEER_FLAG_AS_PATH_UNCHANGED
)
17762 || peergroup_af_flag_check(peer
, afi
, safi
,
17763 PEER_FLAG_NEXTHOP_UNCHANGED
)
17764 || peergroup_af_flag_check(peer
, afi
, safi
,
17765 PEER_FLAG_MED_UNCHANGED
)) {
17768 " neighbor %s attribute-unchanged%s%s%s\n",
17770 peer_af_flag_check(peer
, afi
, safi
,
17771 PEER_FLAG_AS_PATH_UNCHANGED
)
17774 peer_af_flag_check(peer
, afi
, safi
,
17775 PEER_FLAG_NEXTHOP_UNCHANGED
)
17778 peer_af_flag_check(peer
, afi
, safi
,
17779 PEER_FLAG_MED_UNCHANGED
)
17786 static void bgp_vpn_config_write(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17789 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17790 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
))
17791 vty_out(vty
, " no bgp retain route-target all\n");
17794 /* Address family based peer configuration display. */
17795 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17799 struct peer_group
*group
;
17800 struct listnode
*node
, *nnode
;
17803 vty_frame(vty
, " !\n address-family ");
17804 if (afi
== AFI_IP
) {
17805 if (safi
== SAFI_UNICAST
)
17806 vty_frame(vty
, "ipv4 unicast");
17807 else if (safi
== SAFI_LABELED_UNICAST
)
17808 vty_frame(vty
, "ipv4 labeled-unicast");
17809 else if (safi
== SAFI_MULTICAST
)
17810 vty_frame(vty
, "ipv4 multicast");
17811 else if (safi
== SAFI_MPLS_VPN
)
17812 vty_frame(vty
, "ipv4 vpn");
17813 else if (safi
== SAFI_ENCAP
)
17814 vty_frame(vty
, "ipv4 encap");
17815 else if (safi
== SAFI_FLOWSPEC
)
17816 vty_frame(vty
, "ipv4 flowspec");
17817 } else if (afi
== AFI_IP6
) {
17818 if (safi
== SAFI_UNICAST
)
17819 vty_frame(vty
, "ipv6 unicast");
17820 else if (safi
== SAFI_LABELED_UNICAST
)
17821 vty_frame(vty
, "ipv6 labeled-unicast");
17822 else if (safi
== SAFI_MULTICAST
)
17823 vty_frame(vty
, "ipv6 multicast");
17824 else if (safi
== SAFI_MPLS_VPN
)
17825 vty_frame(vty
, "ipv6 vpn");
17826 else if (safi
== SAFI_ENCAP
)
17827 vty_frame(vty
, "ipv6 encap");
17828 else if (safi
== SAFI_FLOWSPEC
)
17829 vty_frame(vty
, "ipv6 flowspec");
17830 } else if (afi
== AFI_L2VPN
) {
17831 if (safi
== SAFI_EVPN
)
17832 vty_frame(vty
, "l2vpn evpn");
17834 vty_frame(vty
, "\n");
17836 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17838 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17840 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17842 /* BGP flag dampening. */
17843 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17844 bgp_config_write_damp(vty
, afi
, safi
);
17846 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17847 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17849 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17850 /* Do not display doppelganger peers */
17851 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17852 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17855 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17856 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17858 if (safi
== SAFI_EVPN
)
17859 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17861 if (safi
== SAFI_FLOWSPEC
)
17862 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17864 if (safi
== SAFI_MPLS_VPN
)
17865 bgp_vpn_config_write(vty
, bgp
, afi
, safi
);
17867 if (safi
== SAFI_UNICAST
) {
17868 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17869 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17870 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17872 vty_out(vty
, " export vpn\n");
17874 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17875 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17877 vty_out(vty
, " import vpn\n");
17879 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17880 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17883 for (ALL_LIST_ELEMENTS_RO(
17884 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17886 vty_out(vty
, " import vrf %s\n", name
);
17890 vty_endframe(vty
, " exit-address-family\n");
17893 int bgp_config_write(struct vty
*vty
)
17896 struct peer_group
*group
;
17898 struct listnode
*node
, *nnode
;
17899 struct listnode
*mnode
, *mnnode
;
17902 uint32_t tovpn_sid_index
= 0;
17904 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17905 vty_out(vty
, "bgp route-map delay-timer %u\n",
17906 bm
->rmap_update_timer
);
17908 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17909 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17910 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17911 vty_out(vty
, " %d", bm
->v_establish_wait
);
17912 vty_out(vty
, "\n");
17915 if (bm
->wait_for_fib
)
17916 vty_out(vty
, "bgp suppress-fib-pending\n");
17918 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17919 vty_out(vty
, "bgp graceful-shutdown\n");
17921 /* No-RIB (Zebra) option flag configuration */
17922 if (bgp_option_check(BGP_OPT_NO_FIB
))
17923 vty_out(vty
, "bgp no-rib\n");
17925 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17926 vty_out(vty
, "bgp send-extra-data zebra\n");
17928 /* BGP session DSCP value */
17929 if (bm
->tcp_dscp
!= IPTOS_PREC_INTERNETCONTROL
)
17930 vty_out(vty
, "bgp session-dscp %u\n", bm
->tcp_dscp
>> 2);
17932 /* BGP InQ limit */
17933 if (bm
->inq_limit
!= BM_DEFAULT_Q_LIMIT
)
17934 vty_out(vty
, "bgp input-queue-limit %u\n", bm
->inq_limit
);
17936 if (bm
->outq_limit
!= BM_DEFAULT_Q_LIMIT
)
17937 vty_out(vty
, "bgp output-queue-limit %u\n", bm
->outq_limit
);
17939 /* BGP configuration. */
17940 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17942 /* skip all auto created vrf as they dont have user config */
17943 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17946 /* Router bgp ASN */
17947 vty_out(vty
, "router bgp %u", bgp
->as
);
17950 vty_out(vty
, " %s %s",
17951 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17952 ? "view" : "vrf", bgp
->name
);
17953 vty_out(vty
, "\n");
17955 /* BGP fast-external-failover. */
17956 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17957 vty_out(vty
, " no bgp fast-external-failover\n");
17959 /* BGP router ID. */
17960 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17961 vty_out(vty
, " bgp router-id %pI4\n",
17962 &bgp
->router_id_static
);
17964 /* Suppress fib pending */
17965 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17966 vty_out(vty
, " bgp suppress-fib-pending\n");
17968 /* BGP log-neighbor-changes. */
17969 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17970 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17971 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17972 CHECK_FLAG(bgp
->flags
,
17973 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17977 /* BGP configuration. */
17978 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17979 vty_out(vty
, " bgp always-compare-med\n");
17981 /* RFC8212 default eBGP policy. */
17982 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17983 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17984 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17985 CHECK_FLAG(bgp
->flags
,
17986 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17990 /* draft-ietf-idr-deprecate-as-set-confed-set */
17991 if (bgp
->reject_as_sets
)
17992 vty_out(vty
, " bgp reject-as-sets\n");
17994 /* Suppress duplicate updates if the route actually not changed
17996 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17997 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17998 vty_out(vty
, " %sbgp suppress-duplicates\n",
17999 CHECK_FLAG(bgp
->flags
,
18000 BGP_FLAG_SUPPRESS_DUPLICATES
)
18004 /* Send Hard Reset CEASE Notification for 'Administrative Reset'
18006 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
) !=
18007 SAVE_BGP_HARD_ADMIN_RESET
)
18008 vty_out(vty
, " %sbgp hard-administrative-reset\n",
18009 CHECK_FLAG(bgp
->flags
,
18010 BGP_FLAG_HARD_ADMIN_RESET
)
18014 /* BGP default <afi>-<safi> */
18015 FOREACH_AFI_SAFI (afi
, safi
) {
18016 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
18017 if (!bgp
->default_af
[afi
][safi
])
18018 vty_out(vty
, " no bgp default %s\n",
18019 get_bgp_default_af_flag(afi
,
18021 } else if (bgp
->default_af
[afi
][safi
])
18022 vty_out(vty
, " bgp default %s\n",
18023 get_bgp_default_af_flag(afi
, safi
));
18026 /* BGP default local-preference. */
18027 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
18028 vty_out(vty
, " bgp default local-preference %u\n",
18029 bgp
->default_local_pref
);
18031 /* BGP default show-hostname */
18032 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
18033 != SAVE_BGP_SHOW_HOSTNAME
)
18034 vty_out(vty
, " %sbgp default show-hostname\n",
18035 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
18039 /* BGP default show-nexthop-hostname */
18040 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
18041 != SAVE_BGP_SHOW_HOSTNAME
)
18042 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
18043 CHECK_FLAG(bgp
->flags
,
18044 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
18048 /* BGP default subgroup-pkt-queue-max. */
18049 if (bgp
->default_subgroup_pkt_queue_max
18050 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
18051 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
18052 bgp
->default_subgroup_pkt_queue_max
);
18054 /* BGP client-to-client reflection. */
18055 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
18056 vty_out(vty
, " no bgp client-to-client reflection\n");
18058 /* BGP cluster ID. */
18059 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
18060 vty_out(vty
, " bgp cluster-id %pI4\n",
18063 /* Disable ebgp connected nexthop check */
18064 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
18066 " bgp disable-ebgp-connected-route-check\n");
18068 /* Confederation identifier*/
18069 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
18070 vty_out(vty
, " bgp confederation identifier %u\n",
18073 /* Confederation peer */
18074 if (bgp
->confed_peers_cnt
> 0) {
18077 vty_out(vty
, " bgp confederation peers");
18079 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
18080 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
18082 vty_out(vty
, "\n");
18085 /* BGP deterministic-med. */
18086 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
18087 != SAVE_BGP_DETERMINISTIC_MED
)
18088 vty_out(vty
, " %sbgp deterministic-med\n",
18089 CHECK_FLAG(bgp
->flags
,
18090 BGP_FLAG_DETERMINISTIC_MED
)
18094 /* BGP update-delay. */
18095 bgp_config_write_update_delay(vty
, bgp
);
18097 if (bgp
->v_maxmed_onstartup
18098 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
18099 vty_out(vty
, " bgp max-med on-startup %u",
18100 bgp
->v_maxmed_onstartup
);
18101 if (bgp
->maxmed_onstartup_value
18102 != BGP_MAXMED_VALUE_DEFAULT
)
18103 vty_out(vty
, " %u",
18104 bgp
->maxmed_onstartup_value
);
18105 vty_out(vty
, "\n");
18107 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
18108 vty_out(vty
, " bgp max-med administrative");
18109 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
18110 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
18111 vty_out(vty
, "\n");
18115 bgp_config_write_wpkt_quanta(vty
, bgp
);
18117 bgp_config_write_rpkt_quanta(vty
, bgp
);
18119 /* coalesce time */
18120 bgp_config_write_coalesce_time(vty
, bgp
);
18122 /* BGP per-instance graceful-shutdown */
18123 /* BGP-wide settings and per-instance settings are mutually
18126 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
18127 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
18128 vty_out(vty
, " bgp graceful-shutdown\n");
18130 /* Long-lived Graceful Restart */
18131 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
18133 " bgp long-lived-graceful-restart stale-time %u\n",
18134 bgp
->llgr_stale_time
);
18136 /* BGP graceful-restart. */
18137 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
18139 " bgp graceful-restart stalepath-time %u\n",
18140 bgp
->stalepath_time
);
18142 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
18143 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
18144 bgp
->restart_time
);
18146 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
) !=
18147 SAVE_BGP_GRACEFUL_NOTIFICATION
)
18148 vty_out(vty
, " %sbgp graceful-restart notification\n",
18149 CHECK_FLAG(bgp
->flags
,
18150 BGP_FLAG_GRACEFUL_NOTIFICATION
)
18154 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
18156 " bgp graceful-restart select-defer-time %u\n",
18157 bgp
->select_defer_time
);
18159 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
18160 vty_out(vty
, " bgp graceful-restart\n");
18162 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
18163 vty_out(vty
, " bgp graceful-restart-disable\n");
18165 /* BGP graceful-restart Preserve State F bit. */
18166 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
18168 " bgp graceful-restart preserve-fw-state\n");
18170 /* BGP TCP keepalive */
18171 bgp_config_tcp_keepalive(vty
, bgp
);
18173 /* Stale timer for RIB */
18174 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
18176 " bgp graceful-restart rib-stale-time %u\n",
18177 bgp
->rib_stale_time
);
18179 /* BGP bestpath method. */
18180 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
18181 vty_out(vty
, " bgp bestpath as-path ignore\n");
18182 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
18183 vty_out(vty
, " bgp bestpath as-path confed\n");
18185 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
18186 if (CHECK_FLAG(bgp
->flags
,
18187 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
18189 " bgp bestpath as-path multipath-relax as-set\n");
18192 " bgp bestpath as-path multipath-relax\n");
18196 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
18198 " bgp route-reflector allow-outbound-policy\n");
18200 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
18201 vty_out(vty
, " bgp bestpath compare-routerid\n");
18202 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_AIGP
))
18203 vty_out(vty
, " bgp bestpath aigp\n");
18204 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
18205 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
18206 vty_out(vty
, " bgp bestpath med");
18207 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
18208 vty_out(vty
, " confed");
18209 if (CHECK_FLAG(bgp
->flags
,
18210 BGP_FLAG_MED_MISSING_AS_WORST
))
18211 vty_out(vty
, " missing-as-worst");
18212 vty_out(vty
, "\n");
18215 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
18217 " bgp bestpath peer-type multipath-relax\n");
18219 /* Link bandwidth handling. */
18220 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
18221 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
18222 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
18223 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
18224 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
18225 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
18227 /* BGP network import check. */
18228 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18229 != SAVE_BGP_IMPORT_CHECK
)
18230 vty_out(vty
, " %sbgp network import-check\n",
18231 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18235 /* BGP timers configuration. */
18236 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
18237 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
18238 vty_out(vty
, " timers bgp %u %u\n",
18239 bgp
->default_keepalive
, bgp
->default_holdtime
);
18241 /* BGP minimum holdtime configuration. */
18242 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
18243 && bgp
->default_min_holdtime
!= 0)
18244 vty_out(vty
, " bgp minimum-holdtime %u\n",
18245 bgp
->default_min_holdtime
);
18247 /* Conditional advertisement timer configuration */
18248 if (bgp
->condition_check_period
18249 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
18251 " bgp conditional-advertisement timer %u\n",
18252 bgp
->condition_check_period
);
18255 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
18256 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
18259 /* Normal neighbor configuration. */
18260 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
18261 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
18262 bgp_config_write_peer_global(vty
, bgp
, peer
);
18265 /* listen range and limit for dynamic BGP neighbors */
18266 bgp_config_write_listen(vty
, bgp
);
18269 * BGP default autoshutdown neighbors
18271 * This must be placed after any peer and peer-group
18272 * configuration, to avoid setting all peers to shutdown after
18273 * a daemon restart, which is undesired behavior. (see #2286)
18275 if (bgp
->autoshutdown
)
18276 vty_out(vty
, " bgp default shutdown\n");
18278 /* BGP instance administrative shutdown */
18279 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
18280 vty_out(vty
, " bgp shutdown\n");
18282 if (bgp
->allow_martian
)
18283 vty_out(vty
, " bgp allow-martian-nexthop\n");
18285 if (bgp
->fast_convergence
)
18286 vty_out(vty
, " bgp fast-convergence\n");
18288 if (bgp
->srv6_enabled
) {
18289 vty_frame(vty
, " !\n segment-routing srv6\n");
18290 if (strlen(bgp
->srv6_locator_name
))
18291 vty_out(vty
, " locator %s\n",
18292 bgp
->srv6_locator_name
);
18293 vty_endframe(vty
, " exit\n");
18296 tovpn_sid_index
= bgp
->tovpn_sid_index
;
18297 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)) {
18298 vty_out(vty
, " sid vpn per-vrf export auto\n");
18299 } else if (tovpn_sid_index
!= 0) {
18300 vty_out(vty
, " sid vpn per-vrf export %d\n",
18304 /* IPv4 unicast configuration. */
18305 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
18307 /* IPv4 multicast configuration. */
18308 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
18310 /* IPv4 labeled-unicast configuration. */
18311 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
18313 /* IPv4 VPN configuration. */
18314 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
18316 /* ENCAPv4 configuration. */
18317 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
18319 /* FLOWSPEC v4 configuration. */
18320 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
18322 /* IPv6 unicast configuration. */
18323 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
18325 /* IPv6 multicast configuration. */
18326 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
18328 /* IPv6 labeled-unicast configuration. */
18329 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
18330 SAFI_LABELED_UNICAST
);
18332 /* IPv6 VPN configuration. */
18333 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
18335 /* ENCAPv6 configuration. */
18336 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
18338 /* FLOWSPEC v6 configuration. */
18339 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
18341 /* EVPN configuration. */
18342 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
18344 hook_call(bgp_inst_config_write
, bgp
, vty
);
18346 #ifdef ENABLE_BGP_VNC
18347 bgp_rfapi_cfg_write(vty
, bgp
);
18350 vty_out(vty
, "exit\n");
18351 vty_out(vty
, "!\n");
18357 /* BGP node structure. */
18358 static struct cmd_node bgp_node
= {
18361 .parent_node
= CONFIG_NODE
,
18362 .prompt
= "%s(config-router)# ",
18363 .config_write
= bgp_config_write
,
18366 static struct cmd_node bgp_ipv4_unicast_node
= {
18367 .name
= "bgp ipv4 unicast",
18368 .node
= BGP_IPV4_NODE
,
18369 .parent_node
= BGP_NODE
,
18370 .prompt
= "%s(config-router-af)# ",
18374 static struct cmd_node bgp_ipv4_multicast_node
= {
18375 .name
= "bgp ipv4 multicast",
18376 .node
= BGP_IPV4M_NODE
,
18377 .parent_node
= BGP_NODE
,
18378 .prompt
= "%s(config-router-af)# ",
18382 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
18383 .name
= "bgp ipv4 labeled unicast",
18384 .node
= BGP_IPV4L_NODE
,
18385 .parent_node
= BGP_NODE
,
18386 .prompt
= "%s(config-router-af)# ",
18390 static struct cmd_node bgp_ipv6_unicast_node
= {
18391 .name
= "bgp ipv6 unicast",
18392 .node
= BGP_IPV6_NODE
,
18393 .parent_node
= BGP_NODE
,
18394 .prompt
= "%s(config-router-af)# ",
18398 static struct cmd_node bgp_ipv6_multicast_node
= {
18399 .name
= "bgp ipv6 multicast",
18400 .node
= BGP_IPV6M_NODE
,
18401 .parent_node
= BGP_NODE
,
18402 .prompt
= "%s(config-router-af)# ",
18406 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
18407 .name
= "bgp ipv6 labeled unicast",
18408 .node
= BGP_IPV6L_NODE
,
18409 .parent_node
= BGP_NODE
,
18410 .prompt
= "%s(config-router-af)# ",
18414 static struct cmd_node bgp_vpnv4_node
= {
18415 .name
= "bgp vpnv4",
18416 .node
= BGP_VPNV4_NODE
,
18417 .parent_node
= BGP_NODE
,
18418 .prompt
= "%s(config-router-af)# ",
18422 static struct cmd_node bgp_vpnv6_node
= {
18423 .name
= "bgp vpnv6",
18424 .node
= BGP_VPNV6_NODE
,
18425 .parent_node
= BGP_NODE
,
18426 .prompt
= "%s(config-router-af-vpnv6)# ",
18430 static struct cmd_node bgp_evpn_node
= {
18431 .name
= "bgp evpn",
18432 .node
= BGP_EVPN_NODE
,
18433 .parent_node
= BGP_NODE
,
18434 .prompt
= "%s(config-router-evpn)# ",
18438 static struct cmd_node bgp_evpn_vni_node
= {
18439 .name
= "bgp evpn vni",
18440 .node
= BGP_EVPN_VNI_NODE
,
18441 .parent_node
= BGP_EVPN_NODE
,
18442 .prompt
= "%s(config-router-af-vni)# ",
18445 static struct cmd_node bgp_flowspecv4_node
= {
18446 .name
= "bgp ipv4 flowspec",
18447 .node
= BGP_FLOWSPECV4_NODE
,
18448 .parent_node
= BGP_NODE
,
18449 .prompt
= "%s(config-router-af)# ",
18453 static struct cmd_node bgp_flowspecv6_node
= {
18454 .name
= "bgp ipv6 flowspec",
18455 .node
= BGP_FLOWSPECV6_NODE
,
18456 .parent_node
= BGP_NODE
,
18457 .prompt
= "%s(config-router-af-vpnv6)# ",
18461 static struct cmd_node bgp_srv6_node
= {
18462 .name
= "bgp srv6",
18463 .node
= BGP_SRV6_NODE
,
18464 .parent_node
= BGP_NODE
,
18465 .prompt
= "%s(config-router-srv6)# ",
18468 static void community_list_vty(void);
18470 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
18473 struct peer_group
*group
;
18474 struct listnode
*lnbgp
, *lnpeer
;
18476 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18477 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
18479 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
18483 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
18487 struct listnode
*lnbgp
, *lnpeer
;
18489 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18490 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
18491 /* only provide suggestions on the appropriate input
18493 * they'll otherwise show up multiple times */
18494 enum cmd_token_type match_type
;
18495 char *name
= peer
->host
;
18497 if (peer
->conf_if
) {
18498 match_type
= VARIABLE_TKN
;
18499 name
= peer
->conf_if
;
18500 } else if (strchr(peer
->host
, ':'))
18501 match_type
= IPV6_TKN
;
18503 match_type
= IPV4_TKN
;
18505 if (token
->type
!= match_type
)
18508 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
18513 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
18515 bgp_ac_peer(comps
, token
);
18517 if (token
->type
== VARIABLE_TKN
)
18518 bgp_ac_peergroup(comps
, token
);
18521 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
18522 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
18523 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
18524 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
18525 {.completions
= NULL
}};
18527 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
18528 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
18529 {.completions
= NULL
} };
18531 DEFINE_HOOK(bgp_config_end
, (struct bgp
*bgp
), (bgp
));
18533 static struct thread
*t_bgp_cfg
;
18535 bool bgp_config_inprocess(void)
18537 return thread_is_scheduled(t_bgp_cfg
);
18540 static void bgp_config_finish(struct thread
*t
)
18542 struct listnode
*node
;
18545 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
))
18546 hook_call(bgp_config_end
, bgp
);
18549 static void bgp_config_start(void)
18551 #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
18552 THREAD_OFF(t_bgp_cfg
);
18553 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18554 BGP_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_bgp_cfg
);
18557 /* When we receive a hook the configuration is read,
18558 * we start a timer to make sure we postpone sending
18559 * EoR before route-maps are processed.
18560 * This is especially valid if using `bgp route-map delay-timer`.
18562 static void bgp_config_end(void)
18564 #define BGP_POST_CONFIG_DELAY_SECONDS 1
18565 uint32_t bgp_post_config_delay
=
18566 thread_is_scheduled(bm
->t_rmap_update
)
18567 ? thread_timer_remain_second(bm
->t_rmap_update
)
18568 : BGP_POST_CONFIG_DELAY_SECONDS
;
18570 /* If BGP config processing thread isn't running, then
18571 * we can return and rely it's properly handled.
18573 if (!bgp_config_inprocess())
18576 THREAD_OFF(t_bgp_cfg
);
18578 /* Start a new timer to make sure we don't send EoR
18579 * before route-maps are processed.
18581 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18582 bgp_post_config_delay
, &t_bgp_cfg
);
18585 static int config_write_interface_one(struct vty
*vty
, struct vrf
*vrf
)
18588 struct interface
*ifp
;
18589 struct bgp_interface
*iifp
;
18591 FOR_ALL_INTERFACES (vrf
, ifp
) {
18596 if_vty_config_start(vty
, ifp
);
18598 if (CHECK_FLAG(iifp
->flags
,
18599 BGP_INTERFACE_MPLS_BGP_FORWARDING
)) {
18600 vty_out(vty
, " mpls bgp forwarding\n");
18604 if_vty_config_end(vty
);
18610 /* Configuration write function for bgpd. */
18611 static int config_write_interface(struct vty
*vty
)
18614 struct vrf
*vrf
= NULL
;
18616 /* Display all VRF aware OSPF interface configuration */
18617 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
18618 write
+= config_write_interface_one(vty
, vrf
);
18624 DEFPY(mpls_bgp_forwarding
, mpls_bgp_forwarding_cmd
,
18625 "[no$no] mpls bgp forwarding",
18626 NO_STR MPLS_STR BGP_STR
18627 "Enable MPLS forwarding for eBGP directly connected peers\n")
18630 struct bgp_interface
*iifp
;
18632 VTY_DECLVAR_CONTEXT(interface
, ifp
);
18635 vty_out(vty
, "Interface %s not available\n", ifp
->name
);
18636 return CMD_WARNING_CONFIG_FAILED
;
18638 check
= CHECK_FLAG(iifp
->flags
, BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18639 if (check
!= !no
) {
18641 UNSET_FLAG(iifp
->flags
,
18642 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18644 SET_FLAG(iifp
->flags
,
18645 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18646 /* trigger a nht update on eBGP sessions */
18647 if (if_is_operative(ifp
))
18648 bgp_nht_ifp_up(ifp
);
18650 return CMD_SUCCESS
;
18653 DEFPY (bgp_inq_limit
,
18655 "bgp input-queue-limit (1-4294967295)$limit",
18657 "Set the BGP Input Queue limit for all peers when message parsing\n"
18658 "Input-Queue limit\n")
18660 bm
->inq_limit
= limit
;
18662 return CMD_SUCCESS
;
18665 DEFPY (no_bgp_inq_limit
,
18666 no_bgp_inq_limit_cmd
,
18667 "no bgp input-queue-limit [(1-4294967295)$limit]",
18670 "Set the BGP Input Queue limit for all peers when message parsing\n"
18671 "Input-Queue limit\n")
18673 bm
->inq_limit
= BM_DEFAULT_Q_LIMIT
;
18675 return CMD_SUCCESS
;
18678 DEFPY (bgp_outq_limit
,
18679 bgp_outq_limit_cmd
,
18680 "bgp output-queue-limit (1-4294967295)$limit",
18682 "Set the BGP Output Queue limit for all peers when message parsing\n"
18683 "Output-Queue limit\n")
18685 bm
->outq_limit
= limit
;
18687 return CMD_SUCCESS
;
18690 DEFPY (no_bgp_outq_limit
,
18691 no_bgp_outq_limit_cmd
,
18692 "no bgp output-queue-limit [(1-4294967295)$limit]",
18695 "Set the BGP Output Queue limit for all peers when message parsing\n"
18696 "Output-Queue limit\n")
18698 bm
->outq_limit
= BM_DEFAULT_Q_LIMIT
;
18700 return CMD_SUCCESS
;
18704 /* Initialization of BGP interface. */
18705 static void bgp_vty_if_init(void)
18707 /* Install interface node. */
18708 if_cmd_init(config_write_interface
);
18710 /* "mpls bgp forwarding" commands. */
18711 install_element(INTERFACE_NODE
, &mpls_bgp_forwarding_cmd
);
18714 void bgp_vty_init(void)
18716 cmd_variable_handler_register(bgp_var_neighbor
);
18717 cmd_variable_handler_register(bgp_var_peergroup
);
18719 cmd_init_config_callbacks(bgp_config_start
, bgp_config_end
);
18721 /* Install bgp top node. */
18722 install_node(&bgp_node
);
18723 install_node(&bgp_ipv4_unicast_node
);
18724 install_node(&bgp_ipv4_multicast_node
);
18725 install_node(&bgp_ipv4_labeled_unicast_node
);
18726 install_node(&bgp_ipv6_unicast_node
);
18727 install_node(&bgp_ipv6_multicast_node
);
18728 install_node(&bgp_ipv6_labeled_unicast_node
);
18729 install_node(&bgp_vpnv4_node
);
18730 install_node(&bgp_vpnv6_node
);
18731 install_node(&bgp_evpn_node
);
18732 install_node(&bgp_evpn_vni_node
);
18733 install_node(&bgp_flowspecv4_node
);
18734 install_node(&bgp_flowspecv6_node
);
18735 install_node(&bgp_srv6_node
);
18737 /* Install default VTY commands to new nodes. */
18738 install_default(BGP_NODE
);
18739 install_default(BGP_IPV4_NODE
);
18740 install_default(BGP_IPV4M_NODE
);
18741 install_default(BGP_IPV4L_NODE
);
18742 install_default(BGP_IPV6_NODE
);
18743 install_default(BGP_IPV6M_NODE
);
18744 install_default(BGP_IPV6L_NODE
);
18745 install_default(BGP_VPNV4_NODE
);
18746 install_default(BGP_VPNV6_NODE
);
18747 install_default(BGP_FLOWSPECV4_NODE
);
18748 install_default(BGP_FLOWSPECV6_NODE
);
18749 install_default(BGP_EVPN_NODE
);
18750 install_default(BGP_EVPN_VNI_NODE
);
18751 install_default(BGP_SRV6_NODE
);
18753 /* "global bgp inq-limit command */
18754 install_element(CONFIG_NODE
, &bgp_inq_limit_cmd
);
18755 install_element(CONFIG_NODE
, &no_bgp_inq_limit_cmd
);
18756 install_element(CONFIG_NODE
, &bgp_outq_limit_cmd
);
18757 install_element(CONFIG_NODE
, &no_bgp_outq_limit_cmd
);
18759 /* "bgp local-mac" hidden commands. */
18760 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
18761 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
18763 /* "bgp suppress-fib-pending" global */
18764 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
18766 /* bgp route-map delay-timer commands. */
18767 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18768 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18770 install_element(BGP_NODE
, &bgp_allow_martian_cmd
);
18772 /* bgp fast-convergence command */
18773 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
18774 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
18776 /* global bgp update-delay command */
18777 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
18778 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
18780 /* global bgp graceful-shutdown command */
18781 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
18782 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
18784 /* Dummy commands (Currently not supported) */
18785 install_element(BGP_NODE
, &no_synchronization_cmd
);
18786 install_element(BGP_NODE
, &no_auto_summary_cmd
);
18788 /* "router bgp" commands. */
18789 install_element(CONFIG_NODE
, &router_bgp_cmd
);
18791 /* "no router bgp" commands. */
18792 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
18794 /* "bgp session-dscp command */
18795 install_element(CONFIG_NODE
, &bgp_session_dscp_cmd
);
18796 install_element(CONFIG_NODE
, &no_bgp_session_dscp_cmd
);
18798 /* "bgp router-id" commands. */
18799 install_element(BGP_NODE
, &bgp_router_id_cmd
);
18800 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
18802 /* "bgp suppress-fib-pending" command */
18803 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
18805 /* "bgp cluster-id" commands. */
18806 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
18807 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
18809 /* "bgp no-rib" commands. */
18810 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
18811 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
18813 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
18815 /* "bgp confederation" commands. */
18816 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
18817 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
18819 /* "bgp confederation peers" commands. */
18820 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
18821 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
18823 /* bgp max-med command */
18824 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
18825 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
18826 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
18827 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
18828 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
18830 /* "neighbor role" commands. */
18831 install_element(BGP_NODE
, &neighbor_role_cmd
);
18832 install_element(BGP_NODE
, &neighbor_role_strict_cmd
);
18833 install_element(BGP_NODE
, &no_neighbor_role_cmd
);
18835 /* "neighbor aigp" commands. */
18836 install_element(BGP_NODE
, &neighbor_aigp_cmd
);
18838 /* "neighbor graceful-shutdown" command */
18839 install_element(BGP_NODE
, &neighbor_graceful_shutdown_cmd
);
18841 /* bgp disable-ebgp-connected-nh-check */
18842 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
18843 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
18845 /* bgp update-delay command */
18846 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
18847 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
18849 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
18850 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
18852 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
18853 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
18855 /* "maximum-paths" commands. */
18856 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
18857 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
18858 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
18859 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
18860 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
18861 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
18862 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
18863 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
18864 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
18865 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
18866 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18867 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18868 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
18869 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18870 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18872 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
18873 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
18874 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18875 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18876 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18877 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
18878 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
18879 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18880 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18881 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18883 /* "timers bgp" commands. */
18884 install_element(BGP_NODE
, &bgp_timers_cmd
);
18885 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
18887 /* "minimum-holdtime" commands. */
18888 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
18889 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
18891 /* route-map delay-timer commands - per instance for backwards compat.
18893 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18894 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18896 /* "bgp client-to-client reflection" commands */
18897 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
18898 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
18900 /* "bgp always-compare-med" commands */
18901 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
18902 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
18904 /* bgp ebgp-requires-policy */
18905 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
18906 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
18908 /* bgp suppress-duplicates */
18909 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
18910 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
18912 /* bgp reject-as-sets */
18913 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
18914 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
18916 /* "bgp deterministic-med" commands */
18917 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
18918 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
18920 /* "bgp graceful-restart" command */
18921 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
18922 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
18924 /* "bgp graceful-restart-disable" command */
18925 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
18926 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
18928 /* "neighbor a:b:c:d graceful-restart" command */
18929 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
18930 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
18932 /* "neighbor a:b:c:d graceful-restart-disable" command */
18933 install_element(BGP_NODE
,
18934 &bgp_neighbor_graceful_restart_disable_set_cmd
);
18935 install_element(BGP_NODE
,
18936 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
18938 /* "neighbor a:b:c:d graceful-restart-helper" command */
18939 install_element(BGP_NODE
,
18940 &bgp_neighbor_graceful_restart_helper_set_cmd
);
18941 install_element(BGP_NODE
,
18942 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
18944 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
18945 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
18946 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
18947 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
18948 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
18949 install_element(BGP_NODE
,
18950 &no_bgp_graceful_restart_select_defer_time_cmd
);
18951 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
18952 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
18953 install_element(BGP_NODE
, &bgp_graceful_restart_notification_cmd
);
18955 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
18956 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
18957 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
18958 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
18960 /* "bgp graceful-shutdown" commands */
18961 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
18962 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
18964 /* "bgp hard-administrative-reset" commands */
18965 install_element(BGP_NODE
, &bgp_administrative_reset_cmd
);
18967 /* "bgp long-lived-graceful-restart" commands */
18968 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
18969 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
18971 /* "bgp fast-external-failover" commands */
18972 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
18973 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
18975 /* "bgp bestpath aigp" commands */
18976 install_element(BGP_NODE
, &bgp_bestpath_aigp_cmd
);
18978 /* "bgp bestpath compare-routerid" commands */
18979 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
18980 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
18982 /* "bgp bestpath as-path ignore" commands */
18983 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
18984 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
18986 /* "bgp bestpath as-path confed" commands */
18987 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
18988 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
18990 /* "bgp bestpath as-path multipath-relax" commands */
18991 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
18992 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
18994 /* "bgp bestpath peer-type multipath-relax" commands */
18995 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
18996 install_element(BGP_NODE
,
18997 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
18999 /* "bgp log-neighbor-changes" commands */
19000 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
19001 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
19003 /* "bgp bestpath med" commands */
19004 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
19005 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
19007 /* "bgp bestpath bandwidth" commands */
19008 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
19009 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
19011 /* "no bgp default <afi>-<safi>" commands. */
19012 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
19014 /* "bgp network import-check" commands. */
19015 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
19016 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
19017 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
19019 /* "bgp default local-preference" commands. */
19020 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
19021 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
19023 /* bgp default show-hostname */
19024 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
19025 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
19027 /* bgp default show-nexthop-hostname */
19028 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
19029 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
19031 /* "bgp default subgroup-pkt-queue-max" commands. */
19032 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
19033 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
19035 /* bgp ibgp-allow-policy-mods command */
19036 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
19037 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
19039 /* "bgp listen limit" commands. */
19040 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
19041 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
19043 /* "bgp listen range" commands. */
19044 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
19045 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
19047 /* "bgp default shutdown" command */
19048 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
19050 /* "bgp shutdown" commands */
19051 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
19052 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
19053 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
19054 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
19056 /* "neighbor remote-as" commands. */
19057 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
19058 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
19059 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
19060 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
19061 install_element(BGP_NODE
,
19062 &neighbor_interface_v6only_config_remote_as_cmd
);
19063 install_element(BGP_NODE
, &no_neighbor_cmd
);
19064 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
19066 /* "neighbor peer-group" commands. */
19067 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
19068 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
19069 install_element(BGP_NODE
,
19070 &no_neighbor_interface_peer_group_remote_as_cmd
);
19072 /* "neighbor local-as" commands. */
19073 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
19074 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
19075 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
19076 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
19078 /* "neighbor solo" commands. */
19079 install_element(BGP_NODE
, &neighbor_solo_cmd
);
19080 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
19082 /* "neighbor password" commands. */
19083 install_element(BGP_NODE
, &neighbor_password_cmd
);
19084 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
19086 /* "neighbor activate" commands. */
19087 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
19088 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
19089 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
19090 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
19091 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
19092 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
19093 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
19094 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
19095 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
19096 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
19097 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
19098 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
19100 /* "no neighbor activate" commands. */
19101 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
19102 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
19103 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
19104 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
19105 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
19106 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
19107 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
19108 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
19109 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
19110 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
19111 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
19112 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
19114 /* "neighbor peer-group" set commands. */
19115 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
19116 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19117 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19118 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19119 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19120 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19121 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19122 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19123 install_element(BGP_FLOWSPECV4_NODE
,
19124 &neighbor_set_peer_group_hidden_cmd
);
19125 install_element(BGP_FLOWSPECV6_NODE
,
19126 &neighbor_set_peer_group_hidden_cmd
);
19128 /* "no neighbor peer-group unset" commands. */
19129 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
19130 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19131 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19132 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19133 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19134 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19135 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19136 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19137 install_element(BGP_FLOWSPECV4_NODE
,
19138 &no_neighbor_set_peer_group_hidden_cmd
);
19139 install_element(BGP_FLOWSPECV6_NODE
,
19140 &no_neighbor_set_peer_group_hidden_cmd
);
19142 /* "neighbor softreconfiguration inbound" commands.*/
19143 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
19144 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
19145 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
19146 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19147 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
19148 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19149 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
19150 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19151 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
19152 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19153 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
19154 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19155 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
19156 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19157 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
19158 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19159 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
19160 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19161 install_element(BGP_FLOWSPECV4_NODE
,
19162 &neighbor_soft_reconfiguration_cmd
);
19163 install_element(BGP_FLOWSPECV4_NODE
,
19164 &no_neighbor_soft_reconfiguration_cmd
);
19165 install_element(BGP_FLOWSPECV6_NODE
,
19166 &neighbor_soft_reconfiguration_cmd
);
19167 install_element(BGP_FLOWSPECV6_NODE
,
19168 &no_neighbor_soft_reconfiguration_cmd
);
19169 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
19170 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19172 /* "neighbor attribute-unchanged" commands. */
19173 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
19174 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
19175 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
19176 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19177 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
19178 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
19179 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
19180 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
19181 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
19182 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19183 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
19184 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
19185 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
19186 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
19187 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
19188 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19189 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
19190 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19192 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
19193 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
19195 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
19196 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19197 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
19198 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19200 /* "nexthop-local unchanged" commands */
19201 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
19202 install_element(BGP_IPV6_NODE
,
19203 &no_neighbor_nexthop_local_unchanged_cmd
);
19205 /* "neighbor next-hop-self" commands. */
19206 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
19207 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
19208 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
19209 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
19210 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
19211 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
19212 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
19213 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
19214 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
19215 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
19216 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
19217 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
19218 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
19219 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
19220 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
19221 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
19222 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
19223 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
19224 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
19225 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
19227 /* "neighbor next-hop-self force" commands. */
19228 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
19229 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
19230 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19231 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
19232 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
19233 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19234 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19235 install_element(BGP_IPV4_NODE
,
19236 &no_neighbor_nexthop_self_all_hidden_cmd
);
19237 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
19238 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19239 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19240 install_element(BGP_IPV4M_NODE
,
19241 &no_neighbor_nexthop_self_all_hidden_cmd
);
19242 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
19243 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19244 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19245 install_element(BGP_IPV4L_NODE
,
19246 &no_neighbor_nexthop_self_all_hidden_cmd
);
19247 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
19248 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19249 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19250 install_element(BGP_IPV6_NODE
,
19251 &no_neighbor_nexthop_self_all_hidden_cmd
);
19252 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
19253 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19254 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19255 install_element(BGP_IPV6M_NODE
,
19256 &no_neighbor_nexthop_self_all_hidden_cmd
);
19257 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
19258 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19259 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19260 install_element(BGP_IPV6L_NODE
,
19261 &no_neighbor_nexthop_self_all_hidden_cmd
);
19262 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
19263 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19264 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19265 install_element(BGP_VPNV4_NODE
,
19266 &no_neighbor_nexthop_self_all_hidden_cmd
);
19267 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
19268 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19269 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19270 install_element(BGP_VPNV6_NODE
,
19271 &no_neighbor_nexthop_self_all_hidden_cmd
);
19272 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
19273 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19275 /* "neighbor as-override" commands. */
19276 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
19277 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
19278 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
19279 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
19280 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
19281 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
19282 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
19283 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
19284 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
19285 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
19286 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
19287 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
19288 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
19289 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
19290 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
19291 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
19292 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
19293 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
19295 /* "neighbor remove-private-AS" commands. */
19296 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
19297 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
19298 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
19299 install_element(BGP_NODE
,
19300 &no_neighbor_remove_private_as_all_hidden_cmd
);
19301 install_element(BGP_NODE
,
19302 &neighbor_remove_private_as_replace_as_hidden_cmd
);
19303 install_element(BGP_NODE
,
19304 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
19305 install_element(BGP_NODE
,
19306 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
19309 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
19310 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
19311 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
19312 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
19313 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19314 install_element(BGP_IPV4_NODE
,
19315 &neighbor_remove_private_as_replace_as_cmd
);
19316 install_element(BGP_IPV4_NODE
,
19317 &no_neighbor_remove_private_as_replace_as_cmd
);
19318 install_element(BGP_IPV4_NODE
,
19319 &neighbor_remove_private_as_all_replace_as_cmd
);
19320 install_element(BGP_IPV4_NODE
,
19321 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19322 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
19323 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
19324 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
19325 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19326 install_element(BGP_IPV4M_NODE
,
19327 &neighbor_remove_private_as_replace_as_cmd
);
19328 install_element(BGP_IPV4M_NODE
,
19329 &no_neighbor_remove_private_as_replace_as_cmd
);
19330 install_element(BGP_IPV4M_NODE
,
19331 &neighbor_remove_private_as_all_replace_as_cmd
);
19332 install_element(BGP_IPV4M_NODE
,
19333 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19334 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
19335 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
19336 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
19337 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19338 install_element(BGP_IPV4L_NODE
,
19339 &neighbor_remove_private_as_replace_as_cmd
);
19340 install_element(BGP_IPV4L_NODE
,
19341 &no_neighbor_remove_private_as_replace_as_cmd
);
19342 install_element(BGP_IPV4L_NODE
,
19343 &neighbor_remove_private_as_all_replace_as_cmd
);
19344 install_element(BGP_IPV4L_NODE
,
19345 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19346 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
19347 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19348 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19349 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19350 install_element(BGP_IPV6_NODE
,
19351 &neighbor_remove_private_as_replace_as_cmd
);
19352 install_element(BGP_IPV6_NODE
,
19353 &no_neighbor_remove_private_as_replace_as_cmd
);
19354 install_element(BGP_IPV6_NODE
,
19355 &neighbor_remove_private_as_all_replace_as_cmd
);
19356 install_element(BGP_IPV6_NODE
,
19357 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19358 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
19359 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
19360 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
19361 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19362 install_element(BGP_IPV6M_NODE
,
19363 &neighbor_remove_private_as_replace_as_cmd
);
19364 install_element(BGP_IPV6M_NODE
,
19365 &no_neighbor_remove_private_as_replace_as_cmd
);
19366 install_element(BGP_IPV6M_NODE
,
19367 &neighbor_remove_private_as_all_replace_as_cmd
);
19368 install_element(BGP_IPV6M_NODE
,
19369 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19370 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
19371 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
19372 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
19373 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19374 install_element(BGP_IPV6L_NODE
,
19375 &neighbor_remove_private_as_replace_as_cmd
);
19376 install_element(BGP_IPV6L_NODE
,
19377 &no_neighbor_remove_private_as_replace_as_cmd
);
19378 install_element(BGP_IPV6L_NODE
,
19379 &neighbor_remove_private_as_all_replace_as_cmd
);
19380 install_element(BGP_IPV6L_NODE
,
19381 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19382 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
19383 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
19384 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
19385 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19386 install_element(BGP_VPNV4_NODE
,
19387 &neighbor_remove_private_as_replace_as_cmd
);
19388 install_element(BGP_VPNV4_NODE
,
19389 &no_neighbor_remove_private_as_replace_as_cmd
);
19390 install_element(BGP_VPNV4_NODE
,
19391 &neighbor_remove_private_as_all_replace_as_cmd
);
19392 install_element(BGP_VPNV4_NODE
,
19393 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19394 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
19395 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19396 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19397 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19398 install_element(BGP_VPNV6_NODE
,
19399 &neighbor_remove_private_as_replace_as_cmd
);
19400 install_element(BGP_VPNV6_NODE
,
19401 &no_neighbor_remove_private_as_replace_as_cmd
);
19402 install_element(BGP_VPNV6_NODE
,
19403 &neighbor_remove_private_as_all_replace_as_cmd
);
19404 install_element(BGP_VPNV6_NODE
,
19405 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19407 /* "neighbor send-community" commands.*/
19408 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
19409 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
19410 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
19411 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
19412 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
19413 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
19414 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
19415 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
19416 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
19417 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
19418 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
19419 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
19420 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
19421 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
19422 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
19423 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
19424 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
19425 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
19426 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
19427 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
19428 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
19429 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
19430 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
19431 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
19432 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
19433 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
19434 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
19435 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
19436 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
19437 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
19438 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
19439 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
19440 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
19441 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
19442 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
19443 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
19445 /* "neighbor route-reflector" commands.*/
19446 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
19447 install_element(BGP_NODE
,
19448 &no_neighbor_route_reflector_client_hidden_cmd
);
19449 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
19450 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
19451 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
19452 install_element(BGP_IPV4M_NODE
,
19453 &no_neighbor_route_reflector_client_cmd
);
19454 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
19455 install_element(BGP_IPV4L_NODE
,
19456 &no_neighbor_route_reflector_client_cmd
);
19457 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
19458 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
19459 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
19460 install_element(BGP_IPV6M_NODE
,
19461 &no_neighbor_route_reflector_client_cmd
);
19462 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
19463 install_element(BGP_IPV6L_NODE
,
19464 &no_neighbor_route_reflector_client_cmd
);
19465 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
19466 install_element(BGP_VPNV4_NODE
,
19467 &no_neighbor_route_reflector_client_cmd
);
19468 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
19469 install_element(BGP_VPNV6_NODE
,
19470 &no_neighbor_route_reflector_client_cmd
);
19471 install_element(BGP_FLOWSPECV4_NODE
,
19472 &neighbor_route_reflector_client_cmd
);
19473 install_element(BGP_FLOWSPECV4_NODE
,
19474 &no_neighbor_route_reflector_client_cmd
);
19475 install_element(BGP_FLOWSPECV6_NODE
,
19476 &neighbor_route_reflector_client_cmd
);
19477 install_element(BGP_FLOWSPECV6_NODE
,
19478 &no_neighbor_route_reflector_client_cmd
);
19479 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
19480 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
19482 /* "neighbor route-server" commands.*/
19483 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
19484 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
19485 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
19486 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
19487 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
19488 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
19489 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
19490 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
19491 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
19492 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
19493 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
19494 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
19495 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
19496 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
19497 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
19498 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
19499 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
19500 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
19501 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
19502 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
19503 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
19504 install_element(BGP_FLOWSPECV4_NODE
,
19505 &no_neighbor_route_server_client_cmd
);
19506 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
19507 install_element(BGP_FLOWSPECV6_NODE
,
19508 &no_neighbor_route_server_client_cmd
);
19510 /* "neighbor disable-addpath-rx" commands. */
19511 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19512 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19513 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19514 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19515 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19516 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19517 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19518 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19519 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19520 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19521 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19522 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19523 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19524 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19525 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19526 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19528 /* "neighbor addpath-tx-all-paths" commands.*/
19529 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
19530 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
19531 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19532 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19533 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19534 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19535 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19536 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19537 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19538 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19539 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19540 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19541 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19542 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19543 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19544 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19545 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19546 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19548 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
19549 install_element(BGP_NODE
,
19550 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19551 install_element(BGP_NODE
,
19552 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19553 install_element(BGP_IPV4_NODE
,
19554 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19555 install_element(BGP_IPV4_NODE
,
19556 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19557 install_element(BGP_IPV4M_NODE
,
19558 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19559 install_element(BGP_IPV4M_NODE
,
19560 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19561 install_element(BGP_IPV4L_NODE
,
19562 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19563 install_element(BGP_IPV4L_NODE
,
19564 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19565 install_element(BGP_IPV6_NODE
,
19566 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19567 install_element(BGP_IPV6_NODE
,
19568 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19569 install_element(BGP_IPV6M_NODE
,
19570 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19571 install_element(BGP_IPV6M_NODE
,
19572 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19573 install_element(BGP_IPV6L_NODE
,
19574 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19575 install_element(BGP_IPV6L_NODE
,
19576 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19577 install_element(BGP_VPNV4_NODE
,
19578 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19579 install_element(BGP_VPNV4_NODE
,
19580 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19581 install_element(BGP_VPNV6_NODE
,
19582 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19583 install_element(BGP_VPNV6_NODE
,
19584 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19586 /* "neighbor sender-as-path-loop-detection" commands. */
19587 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
19588 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
19590 /* "neighbor path-attribute discard" commands. */
19591 install_element(BGP_NODE
, &neighbor_path_attribute_discard_cmd
);
19592 install_element(BGP_NODE
, &no_neighbor_path_attribute_discard_cmd
);
19594 /* "neighbor passive" commands. */
19595 install_element(BGP_NODE
, &neighbor_passive_cmd
);
19596 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
19599 /* "neighbor shutdown" commands. */
19600 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
19601 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
19602 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
19603 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
19604 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
19605 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
19607 /* "neighbor capability extended-nexthop" commands.*/
19608 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
19609 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
19611 /* "neighbor capability orf prefix-list" commands.*/
19612 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
19613 install_element(BGP_NODE
,
19614 &no_neighbor_capability_orf_prefix_hidden_cmd
);
19615 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
19616 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19617 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19618 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19619 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19620 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19621 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
19622 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19623 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19624 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19625 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19626 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19628 /* "neighbor capability dynamic" commands.*/
19629 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
19630 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
19632 /* "neighbor dont-capability-negotiate" commands. */
19633 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
19634 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
19636 /* "neighbor ebgp-multihop" commands. */
19637 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
19638 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
19639 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
19641 /* "neighbor disable-connected-check" commands. */
19642 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
19643 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
19645 /* "neighbor disable-link-bw-encoding-ieee" commands. */
19646 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
19647 install_element(BGP_NODE
,
19648 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
19650 /* "neighbor extended-optional-parameters" commands. */
19651 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
19652 install_element(BGP_NODE
,
19653 &no_neighbor_extended_optional_parameters_cmd
);
19655 /* "neighbor enforce-first-as" commands. */
19656 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
19657 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
19659 /* "neighbor description" commands. */
19660 install_element(BGP_NODE
, &neighbor_description_cmd
);
19661 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
19662 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
19664 /* "neighbor update-source" commands. "*/
19665 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
19666 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
19668 /* "neighbor default-originate" commands. */
19669 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
19670 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
19671 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
19672 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
19673 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
19674 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
19675 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
19676 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
19677 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
19678 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
19679 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
19680 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
19681 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
19682 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
19683 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
19684 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
19685 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
19686 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
19687 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
19688 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
19689 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
19691 /* "neighbor port" commands. */
19692 install_element(BGP_NODE
, &neighbor_port_cmd
);
19693 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
19695 /* "neighbor weight" commands. */
19696 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
19697 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
19699 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
19700 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
19701 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
19702 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
19703 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
19704 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
19705 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
19706 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
19707 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
19708 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
19709 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
19710 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
19711 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
19712 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
19713 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
19714 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
19716 /* "neighbor override-capability" commands. */
19717 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
19718 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
19720 /* "neighbor strict-capability-match" commands. */
19721 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
19722 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
19724 /* "neighbor timers" commands. */
19725 install_element(BGP_NODE
, &neighbor_timers_cmd
);
19726 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
19728 /* "neighbor timers connect" commands. */
19729 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
19730 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
19732 /* "neighbor timers delayopen" commands. */
19733 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
19734 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
19736 /* "neighbor advertisement-interval" commands. */
19737 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
19738 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
19740 /* "neighbor interface" commands. */
19741 install_element(BGP_NODE
, &neighbor_interface_cmd
);
19742 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
19744 /* "neighbor distribute" commands. */
19745 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
19746 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
19747 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
19748 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
19749 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
19750 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
19751 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
19752 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
19753 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
19754 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
19755 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
19756 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
19757 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
19758 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
19759 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
19760 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
19761 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
19762 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
19764 /* "neighbor prefix-list" commands. */
19765 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
19766 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
19767 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
19768 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
19769 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
19770 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
19771 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
19772 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
19773 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
19774 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
19775 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
19776 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
19777 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
19778 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
19779 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
19780 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
19781 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
19782 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
19783 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
19784 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
19785 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
19786 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
19788 /* "neighbor filter-list" commands. */
19789 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
19790 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
19791 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
19792 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
19793 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
19794 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
19795 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
19796 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
19797 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
19798 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
19799 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
19800 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
19801 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
19802 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
19803 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
19804 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
19805 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
19806 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
19807 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
19808 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
19809 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
19810 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
19812 /* "neighbor route-map" commands. */
19813 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
19814 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
19815 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
19816 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
19817 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
19818 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
19819 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
19820 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
19821 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
19822 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
19823 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
19824 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
19825 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
19826 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
19827 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
19828 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
19829 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
19830 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
19831 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
19832 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
19833 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
19834 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
19835 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
19836 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
19838 /* "neighbor unsuppress-map" commands. */
19839 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
19840 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
19841 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
19842 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19843 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
19844 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19845 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
19846 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19847 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
19848 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19849 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
19850 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19851 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
19852 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19853 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
19854 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19855 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
19856 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19858 /* "neighbor advertise-map" commands. */
19859 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
19860 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
19861 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
19862 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
19863 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
19864 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
19865 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
19866 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
19867 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
19868 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
19870 /* neighbor maximum-prefix-out commands. */
19871 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
19872 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19873 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19874 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19875 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19876 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19877 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19878 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19879 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19880 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19881 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19882 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19883 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19884 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19885 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19886 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19887 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19888 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19890 /* "neighbor maximum-prefix" commands. */
19891 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
19892 install_element(BGP_NODE
,
19893 &neighbor_maximum_prefix_threshold_hidden_cmd
);
19894 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
19895 install_element(BGP_NODE
,
19896 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
19897 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
19898 install_element(BGP_NODE
,
19899 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
19900 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
19901 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
19902 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19903 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19904 install_element(BGP_IPV4_NODE
,
19905 &neighbor_maximum_prefix_threshold_warning_cmd
);
19906 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19907 install_element(BGP_IPV4_NODE
,
19908 &neighbor_maximum_prefix_threshold_restart_cmd
);
19909 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19910 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
19911 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19912 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19913 install_element(BGP_IPV4M_NODE
,
19914 &neighbor_maximum_prefix_threshold_warning_cmd
);
19915 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19916 install_element(BGP_IPV4M_NODE
,
19917 &neighbor_maximum_prefix_threshold_restart_cmd
);
19918 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19919 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
19920 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19921 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19922 install_element(BGP_IPV4L_NODE
,
19923 &neighbor_maximum_prefix_threshold_warning_cmd
);
19924 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19925 install_element(BGP_IPV4L_NODE
,
19926 &neighbor_maximum_prefix_threshold_restart_cmd
);
19927 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19928 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
19929 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19930 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19931 install_element(BGP_IPV6_NODE
,
19932 &neighbor_maximum_prefix_threshold_warning_cmd
);
19933 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19934 install_element(BGP_IPV6_NODE
,
19935 &neighbor_maximum_prefix_threshold_restart_cmd
);
19936 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19937 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
19938 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19939 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19940 install_element(BGP_IPV6M_NODE
,
19941 &neighbor_maximum_prefix_threshold_warning_cmd
);
19942 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19943 install_element(BGP_IPV6M_NODE
,
19944 &neighbor_maximum_prefix_threshold_restart_cmd
);
19945 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19946 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
19947 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19948 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19949 install_element(BGP_IPV6L_NODE
,
19950 &neighbor_maximum_prefix_threshold_warning_cmd
);
19951 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19952 install_element(BGP_IPV6L_NODE
,
19953 &neighbor_maximum_prefix_threshold_restart_cmd
);
19954 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19955 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
19956 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19957 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19958 install_element(BGP_VPNV4_NODE
,
19959 &neighbor_maximum_prefix_threshold_warning_cmd
);
19960 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19961 install_element(BGP_VPNV4_NODE
,
19962 &neighbor_maximum_prefix_threshold_restart_cmd
);
19963 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19964 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
19965 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19966 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19967 install_element(BGP_VPNV6_NODE
,
19968 &neighbor_maximum_prefix_threshold_warning_cmd
);
19969 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19970 install_element(BGP_VPNV6_NODE
,
19971 &neighbor_maximum_prefix_threshold_restart_cmd
);
19972 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19974 /* "neighbor allowas-in" */
19975 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
19976 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
19977 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
19978 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
19979 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
19980 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
19981 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
19982 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
19983 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
19984 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
19985 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
19986 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
19987 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
19988 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
19989 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
19990 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
19991 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
19992 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
19993 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
19994 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
19996 /* neighbor accept-own */
19997 install_element(BGP_VPNV4_NODE
, &neighbor_accept_own_cmd
);
19998 install_element(BGP_VPNV6_NODE
, &neighbor_accept_own_cmd
);
20000 /* "neighbor soo" */
20001 install_element(BGP_IPV4_NODE
, &neighbor_soo_cmd
);
20002 install_element(BGP_IPV4_NODE
, &no_neighbor_soo_cmd
);
20003 install_element(BGP_IPV4M_NODE
, &neighbor_soo_cmd
);
20004 install_element(BGP_IPV4M_NODE
, &no_neighbor_soo_cmd
);
20005 install_element(BGP_IPV4L_NODE
, &neighbor_soo_cmd
);
20006 install_element(BGP_IPV4L_NODE
, &no_neighbor_soo_cmd
);
20007 install_element(BGP_IPV6_NODE
, &neighbor_soo_cmd
);
20008 install_element(BGP_IPV6_NODE
, &no_neighbor_soo_cmd
);
20009 install_element(BGP_IPV6M_NODE
, &neighbor_soo_cmd
);
20010 install_element(BGP_IPV6M_NODE
, &no_neighbor_soo_cmd
);
20011 install_element(BGP_IPV6L_NODE
, &neighbor_soo_cmd
);
20012 install_element(BGP_IPV6L_NODE
, &no_neighbor_soo_cmd
);
20013 install_element(BGP_VPNV4_NODE
, &neighbor_soo_cmd
);
20014 install_element(BGP_VPNV4_NODE
, &no_neighbor_soo_cmd
);
20015 install_element(BGP_VPNV6_NODE
, &neighbor_soo_cmd
);
20016 install_element(BGP_VPNV6_NODE
, &no_neighbor_soo_cmd
);
20017 install_element(BGP_EVPN_NODE
, &neighbor_soo_cmd
);
20018 install_element(BGP_EVPN_NODE
, &no_neighbor_soo_cmd
);
20020 /* address-family commands. */
20021 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
20022 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
20023 #ifdef KEEP_OLD_VPN_COMMANDS
20024 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
20025 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
20026 #endif /* KEEP_OLD_VPN_COMMANDS */
20028 install_element(BGP_NODE
, &address_family_evpn_cmd
);
20030 /* "exit-address-family" command. */
20031 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
20032 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
20033 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
20034 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
20035 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
20036 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
20037 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
20038 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
20039 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
20040 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
20041 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
20043 /* BGP retain all route-target */
20044 install_element(BGP_VPNV4_NODE
, &bgp_retain_route_target_cmd
);
20045 install_element(BGP_VPNV6_NODE
, &bgp_retain_route_target_cmd
);
20047 /* "clear ip bgp commands" */
20048 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
20050 /* clear ip bgp prefix */
20051 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
20052 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
20053 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
20055 /* "show [ip] bgp summary" commands. */
20056 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
20057 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
20058 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
20059 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
20060 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
20061 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
20062 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
20064 /* "show [ip] bgp neighbors" commands. */
20065 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
20067 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
20069 /* "show [ip] bgp peer-group" commands. */
20070 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
20072 /* "show [ip] bgp paths" commands. */
20073 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
20075 /* "show [ip] bgp community" commands. */
20076 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
20078 /* "show ip bgp large-community" commands. */
20079 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
20080 /* "show [ip] bgp attribute-info" commands. */
20081 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
20082 /* "show [ip] bgp route-leak" command */
20083 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
20085 /* "redistribute" commands. */
20086 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
20087 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
20088 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
20089 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
20090 install_element(BGP_NODE
,
20091 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
20092 install_element(BGP_NODE
,
20093 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
20094 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
20095 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
20096 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
20097 install_element(BGP_NODE
,
20098 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
20099 install_element(BGP_NODE
,
20100 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
20101 install_element(BGP_NODE
,
20102 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
20103 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
20104 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
20105 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
20106 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
20107 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
20108 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
20109 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
20110 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
20111 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
20112 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
20113 install_element(BGP_IPV4_NODE
,
20114 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
20115 install_element(BGP_IPV4_NODE
,
20116 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
20117 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
20118 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
20119 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
20120 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
20121 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
20122 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
20124 /* import|export vpn [route-map RMAP_NAME] */
20125 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
20126 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
20128 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
20129 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
20131 /* ttl_security commands */
20132 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
20133 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
20135 /* "bgp tcp-keepalive" commands */
20136 install_element(BGP_NODE
, &bgp_tcp_keepalive_cmd
);
20137 install_element(BGP_NODE
, &no_bgp_tcp_keepalive_cmd
);
20139 /* "show [ip] bgp memory" commands. */
20140 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
20142 /* "show bgp martian next-hop" */
20143 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
20145 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
20147 /* "show [ip] bgp views" commands. */
20148 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
20150 /* "show [ip] bgp vrfs" commands. */
20151 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
20153 /* Community-list. */
20154 community_list_vty();
20156 community_alias_vty();
20158 /* vpn-policy commands */
20159 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
20160 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
20161 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
20162 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
20163 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
20164 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
20165 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
20166 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
20167 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
20168 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
20169 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
20170 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
20172 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
20173 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
20175 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
20176 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
20177 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
20178 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
20179 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
20180 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
20181 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
20182 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
20183 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
20184 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
20186 /* tcp-mss command */
20187 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
20188 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
20190 /* srv6 commands */
20191 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
20192 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
20193 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
20194 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
20195 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
20196 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
20197 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
20198 install_element(BGP_NODE
, &bgp_sid_vpn_export_cmd
);
20199 install_element(BGP_NODE
, &no_bgp_sid_vpn_export_cmd
);
20204 #include "memory.h"
20205 #include "bgp_regex.h"
20206 #include "bgp_clist.h"
20207 #include "bgp_ecommunity.h"
20209 /* VTY functions. */
20211 /* Direction value to string conversion. */
20212 static const char *community_direct_str(int direct
)
20215 case COMMUNITY_DENY
:
20217 case COMMUNITY_PERMIT
:
20224 /* Display error string. */
20225 static void community_list_perror(struct vty
*vty
, int ret
)
20228 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
20229 vty_out(vty
, "%% Can't find community-list\n");
20231 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
20232 vty_out(vty
, "%% Malformed community-list value\n");
20234 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
20236 "%% Community name conflict, previously defined as standard community\n");
20238 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
20240 "%% Community name conflict, previously defined as expanded community\n");
20245 /* "community-list" keyword help string. */
20246 #define COMMUNITY_LIST_STR "Add a community list entry\n"
20248 /*community-list standard */
20249 DEFUN (community_list_standard
,
20250 bgp_community_list_standard_cmd
,
20251 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20254 "Community list number (standard)\n"
20255 "Add an standard community-list entry\n"
20256 "Community list name\n"
20257 "Sequence number of an entry\n"
20258 "Sequence number\n"
20259 "Specify community to reject\n"
20260 "Specify community to accept\n"
20263 char *cl_name_or_number
= NULL
;
20266 int style
= COMMUNITY_LIST_STANDARD
;
20269 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20270 seq
= argv
[idx
]->arg
;
20273 argv_find(argv
, argc
, "(1-99)", &idx
);
20274 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20275 cl_name_or_number
= argv
[idx
]->arg
;
20276 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20278 argv_find(argv
, argc
, "AA:NN", &idx
);
20279 char *str
= argv_concat(argv
, argc
, idx
);
20281 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
20284 XFREE(MTYPE_TMP
, str
);
20287 /* Display error string. */
20288 community_list_perror(vty
, ret
);
20289 return CMD_WARNING_CONFIG_FAILED
;
20292 return CMD_SUCCESS
;
20295 DEFUN (no_community_list_standard_all
,
20296 no_bgp_community_list_standard_all_cmd
,
20297 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20301 "Community list number (standard)\n"
20302 "Add an standard community-list entry\n"
20303 "Community list name\n"
20304 "Sequence number of an entry\n"
20305 "Sequence number\n"
20306 "Specify community to reject\n"
20307 "Specify community to accept\n"
20310 char *cl_name_or_number
= NULL
;
20313 int style
= COMMUNITY_LIST_STANDARD
;
20317 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20318 seq
= argv
[idx
]->arg
;
20321 argv_find(argv
, argc
, "permit", &idx
);
20322 argv_find(argv
, argc
, "deny", &idx
);
20325 direct
= argv_find(argv
, argc
, "permit", &idx
)
20330 argv_find(argv
, argc
, "AA:NN", &idx
);
20331 str
= argv_concat(argv
, argc
, idx
);
20335 argv_find(argv
, argc
, "(1-99)", &idx
);
20336 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20337 cl_name_or_number
= argv
[idx
]->arg
;
20339 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20342 XFREE(MTYPE_TMP
, str
);
20345 community_list_perror(vty
, ret
);
20346 return CMD_WARNING_CONFIG_FAILED
;
20349 return CMD_SUCCESS
;
20352 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
20353 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
20354 NO_STR BGP_STR COMMUNITY_LIST_STR
20355 "Community list number (standard)\n"
20356 "Add an standard community-list entry\n"
20357 "Community list name\n")
20359 /*community-list expanded */
20360 DEFUN (community_list_expanded_all
,
20361 bgp_community_list_expanded_all_cmd
,
20362 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20365 "Community list number (expanded)\n"
20366 "Add an expanded community-list entry\n"
20367 "Community list name\n"
20368 "Sequence number of an entry\n"
20369 "Sequence number\n"
20370 "Specify community to reject\n"
20371 "Specify community to accept\n"
20374 char *cl_name_or_number
= NULL
;
20377 int style
= COMMUNITY_LIST_EXPANDED
;
20380 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20381 seq
= argv
[idx
]->arg
;
20385 argv_find(argv
, argc
, "(100-500)", &idx
);
20386 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20387 cl_name_or_number
= argv
[idx
]->arg
;
20388 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20390 argv_find(argv
, argc
, "AA:NN", &idx
);
20391 char *str
= argv_concat(argv
, argc
, idx
);
20393 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
20396 XFREE(MTYPE_TMP
, str
);
20399 /* Display error string. */
20400 community_list_perror(vty
, ret
);
20401 return CMD_WARNING_CONFIG_FAILED
;
20404 return CMD_SUCCESS
;
20407 DEFUN (no_community_list_expanded_all
,
20408 no_bgp_community_list_expanded_all_cmd
,
20409 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20413 "Community list number (expanded)\n"
20414 "Add an expanded community-list entry\n"
20415 "Community list name\n"
20416 "Sequence number of an entry\n"
20417 "Sequence number\n"
20418 "Specify community to reject\n"
20419 "Specify community to accept\n"
20422 char *cl_name_or_number
= NULL
;
20426 int style
= COMMUNITY_LIST_EXPANDED
;
20429 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20430 seq
= argv
[idx
]->arg
;
20433 argv_find(argv
, argc
, "permit", &idx
);
20434 argv_find(argv
, argc
, "deny", &idx
);
20437 direct
= argv_find(argv
, argc
, "permit", &idx
)
20442 argv_find(argv
, argc
, "AA:NN", &idx
);
20443 str
= argv_concat(argv
, argc
, idx
);
20447 argv_find(argv
, argc
, "(100-500)", &idx
);
20448 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20449 cl_name_or_number
= argv
[idx
]->arg
;
20451 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20454 XFREE(MTYPE_TMP
, str
);
20457 community_list_perror(vty
, ret
);
20458 return CMD_WARNING_CONFIG_FAILED
;
20461 return CMD_SUCCESS
;
20464 ALIAS(no_community_list_expanded_all
,
20465 no_bgp_community_list_expanded_all_list_cmd
,
20466 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
20467 NO_STR BGP_STR COMMUNITY_LIST_STR
20468 "Community list number (expanded)\n"
20469 "Add an expanded community-list entry\n"
20470 "Community list name\n")
20472 /* Return configuration string of community-list entry. */
20473 static const char *community_list_config_str(struct community_entry
*entry
)
20480 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
20481 str
= community_str(entry
->u
.com
, false, false);
20482 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
20483 str
= lcommunity_str(entry
->u
.lcom
, false, false);
20485 str
= entry
->config
;
20490 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
20492 struct community_entry
*entry
;
20494 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20495 if (entry
== list
->head
) {
20496 if (all_digit(list
->name
))
20497 vty_out(vty
, "Community %s list %s\n",
20498 entry
->style
== COMMUNITY_LIST_STANDARD
20500 : "(expanded) access",
20503 vty_out(vty
, "Named Community %s list %s\n",
20504 entry
->style
== COMMUNITY_LIST_STANDARD
20510 vty_out(vty
, " %s\n",
20511 community_direct_str(entry
->direct
));
20513 vty_out(vty
, " %s %s\n",
20514 community_direct_str(entry
->direct
),
20515 community_list_config_str(entry
));
20519 DEFUN (show_community_list
,
20520 show_bgp_community_list_cmd
,
20521 "show bgp community-list",
20524 "List community-list\n")
20526 struct community_list
*list
;
20527 struct community_list_master
*cm
;
20529 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20531 return CMD_SUCCESS
;
20533 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20534 community_list_show(vty
, list
);
20536 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20537 community_list_show(vty
, list
);
20539 return CMD_SUCCESS
;
20542 DEFUN (show_community_list_arg
,
20543 show_bgp_community_list_arg_cmd
,
20544 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
20547 "List community-list\n"
20548 "Community-list number\n"
20549 "Community-list name\n"
20550 "Detailed information on community-list\n")
20552 int idx_comm_list
= 3;
20553 struct community_list
*list
;
20555 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20556 COMMUNITY_LIST_MASTER
);
20558 vty_out(vty
, "%% Can't find community-list\n");
20559 return CMD_WARNING
;
20562 community_list_show(vty
, list
);
20564 return CMD_SUCCESS
;
20568 * Large Community code.
20570 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
20571 struct cmd_token
**argv
, int style
,
20572 int reject_all_digit_name
)
20581 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20582 seq
= argv
[idx
]->arg
;
20585 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20588 /* All digit name check. */
20590 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20591 argv_find(argv
, argc
, "(1-99)", &idx
);
20592 argv_find(argv
, argc
, "(100-500)", &idx
);
20593 cl_name
= argv
[idx
]->arg
;
20594 if (reject_all_digit_name
&& all_digit(cl_name
)) {
20595 vty_out(vty
, "%% Community name cannot have all digits\n");
20596 return CMD_WARNING_CONFIG_FAILED
;
20600 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
20601 argv_find(argv
, argc
, "LINE", &idx
);
20602 /* Concat community string argument. */
20604 str
= argv_concat(argv
, argc
, idx
);
20608 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
20610 /* Free temporary community list string allocated by
20612 XFREE(MTYPE_TMP
, str
);
20615 community_list_perror(vty
, ret
);
20616 return CMD_WARNING_CONFIG_FAILED
;
20618 return CMD_SUCCESS
;
20621 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
20622 struct cmd_token
**argv
, int style
)
20630 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20631 seq
= argv
[idx
]->arg
;
20634 argv_find(argv
, argc
, "permit", &idx
);
20635 argv_find(argv
, argc
, "deny", &idx
);
20638 /* Check the list direct. */
20639 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
20640 direct
= COMMUNITY_PERMIT
;
20642 direct
= COMMUNITY_DENY
;
20645 argv_find(argv
, argc
, "LINE", &idx
);
20646 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
20647 /* Concat community string argument. */
20648 str
= argv_concat(argv
, argc
, idx
);
20652 argv_find(argv
, argc
, "(1-99)", &idx
);
20653 argv_find(argv
, argc
, "(100-500)", &idx
);
20654 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20656 /* Unset community list. */
20657 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
20660 /* Free temporary community list string allocated by
20662 XFREE(MTYPE_TMP
, str
);
20665 community_list_perror(vty
, ret
);
20666 return CMD_WARNING_CONFIG_FAILED
;
20669 return CMD_SUCCESS
;
20672 /* "large-community-list" keyword help string. */
20673 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
20674 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
20676 DEFUN (lcommunity_list_standard
,
20677 bgp_lcommunity_list_standard_cmd
,
20678 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20680 LCOMMUNITY_LIST_STR
20681 "Large Community list number (standard)\n"
20682 "Sequence number of an entry\n"
20683 "Sequence number\n"
20684 "Specify large community to reject\n"
20685 "Specify large community to accept\n"
20686 LCOMMUNITY_VAL_STR
)
20688 return lcommunity_list_set_vty(vty
, argc
, argv
,
20689 LARGE_COMMUNITY_LIST_STANDARD
, 0);
20692 DEFUN (lcommunity_list_expanded
,
20693 bgp_lcommunity_list_expanded_cmd
,
20694 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20696 LCOMMUNITY_LIST_STR
20697 "Large Community list number (expanded)\n"
20698 "Sequence number of an entry\n"
20699 "Sequence number\n"
20700 "Specify large community to reject\n"
20701 "Specify large community to accept\n"
20702 "An ordered list as a regular-expression\n")
20704 return lcommunity_list_set_vty(vty
, argc
, argv
,
20705 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
20708 DEFUN (lcommunity_list_name_standard
,
20709 bgp_lcommunity_list_name_standard_cmd
,
20710 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20712 LCOMMUNITY_LIST_STR
20713 "Specify standard large-community-list\n"
20714 "Large Community list name\n"
20715 "Sequence number of an entry\n"
20716 "Sequence number\n"
20717 "Specify large community to reject\n"
20718 "Specify large community to accept\n"
20719 LCOMMUNITY_VAL_STR
)
20721 return lcommunity_list_set_vty(vty
, argc
, argv
,
20722 LARGE_COMMUNITY_LIST_STANDARD
, 1);
20725 DEFUN (lcommunity_list_name_expanded
,
20726 bgp_lcommunity_list_name_expanded_cmd
,
20727 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20729 LCOMMUNITY_LIST_STR
20730 "Specify expanded large-community-list\n"
20731 "Large Community list name\n"
20732 "Sequence number of an entry\n"
20733 "Sequence number\n"
20734 "Specify large community to reject\n"
20735 "Specify large community to accept\n"
20736 "An ordered list as a regular-expression\n")
20738 return lcommunity_list_set_vty(vty
, argc
, argv
,
20739 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
20742 DEFUN (no_lcommunity_list_all
,
20743 no_bgp_lcommunity_list_all_cmd
,
20744 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
20747 LCOMMUNITY_LIST_STR
20748 "Large Community list number (standard)\n"
20749 "Large Community list number (expanded)\n"
20750 "Large Community list name\n")
20752 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20753 LARGE_COMMUNITY_LIST_STANDARD
);
20756 DEFUN (no_lcommunity_list_name_standard_all
,
20757 no_bgp_lcommunity_list_name_standard_all_cmd
,
20758 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
20761 LCOMMUNITY_LIST_STR
20762 "Specify standard large-community-list\n"
20763 "Large Community list name\n")
20765 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20766 LARGE_COMMUNITY_LIST_STANDARD
);
20769 DEFUN (no_lcommunity_list_name_expanded_all
,
20770 no_bgp_lcommunity_list_name_expanded_all_cmd
,
20771 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
20774 LCOMMUNITY_LIST_STR
20775 "Specify expanded large-community-list\n"
20776 "Large Community list name\n")
20778 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20779 LARGE_COMMUNITY_LIST_EXPANDED
);
20782 DEFUN (no_lcommunity_list_standard
,
20783 no_bgp_lcommunity_list_standard_cmd
,
20784 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20787 LCOMMUNITY_LIST_STR
20788 "Large Community list number (standard)\n"
20789 "Sequence number of an entry\n"
20790 "Sequence number\n"
20791 "Specify large community to reject\n"
20792 "Specify large community to accept\n"
20793 LCOMMUNITY_VAL_STR
)
20795 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20796 LARGE_COMMUNITY_LIST_STANDARD
);
20799 DEFUN (no_lcommunity_list_expanded
,
20800 no_bgp_lcommunity_list_expanded_cmd
,
20801 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20804 LCOMMUNITY_LIST_STR
20805 "Large Community list number (expanded)\n"
20806 "Sequence number of an entry\n"
20807 "Sequence number\n"
20808 "Specify large community to reject\n"
20809 "Specify large community to accept\n"
20810 "An ordered list as a regular-expression\n")
20812 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20813 LARGE_COMMUNITY_LIST_EXPANDED
);
20816 DEFUN (no_lcommunity_list_name_standard
,
20817 no_bgp_lcommunity_list_name_standard_cmd
,
20818 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20821 LCOMMUNITY_LIST_STR
20822 "Specify standard large-community-list\n"
20823 "Large Community list name\n"
20824 "Sequence number of an entry\n"
20825 "Sequence number\n"
20826 "Specify large community to reject\n"
20827 "Specify large community to accept\n"
20828 LCOMMUNITY_VAL_STR
)
20830 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20831 LARGE_COMMUNITY_LIST_STANDARD
);
20834 DEFUN (no_lcommunity_list_name_expanded
,
20835 no_bgp_lcommunity_list_name_expanded_cmd
,
20836 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20839 LCOMMUNITY_LIST_STR
20840 "Specify expanded large-community-list\n"
20841 "Large community list name\n"
20842 "Sequence number of an entry\n"
20843 "Sequence number\n"
20844 "Specify large community to reject\n"
20845 "Specify large community to accept\n"
20846 "An ordered list as a regular-expression\n")
20848 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20849 LARGE_COMMUNITY_LIST_EXPANDED
);
20852 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20854 struct community_entry
*entry
;
20856 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20857 if (entry
== list
->head
) {
20858 if (all_digit(list
->name
))
20859 vty_out(vty
, "Large community %s list %s\n",
20861 LARGE_COMMUNITY_LIST_STANDARD
20863 : "(expanded) access",
20867 "Named large community %s list %s\n",
20869 LARGE_COMMUNITY_LIST_STANDARD
20875 vty_out(vty
, " %s\n",
20876 community_direct_str(entry
->direct
));
20878 vty_out(vty
, " %s %s\n",
20879 community_direct_str(entry
->direct
),
20880 community_list_config_str(entry
));
20884 DEFUN (show_lcommunity_list
,
20885 show_bgp_lcommunity_list_cmd
,
20886 "show bgp large-community-list",
20889 "List large-community list\n")
20891 struct community_list
*list
;
20892 struct community_list_master
*cm
;
20894 cm
= community_list_master_lookup(bgp_clist
,
20895 LARGE_COMMUNITY_LIST_MASTER
);
20897 return CMD_SUCCESS
;
20899 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20900 lcommunity_list_show(vty
, list
);
20902 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20903 lcommunity_list_show(vty
, list
);
20905 return CMD_SUCCESS
;
20908 DEFUN (show_lcommunity_list_arg
,
20909 show_bgp_lcommunity_list_arg_cmd
,
20910 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
20913 "List large-community list\n"
20914 "Large-community-list number\n"
20915 "Large-community-list name\n"
20916 "Detailed information on large-community-list\n")
20918 struct community_list
*list
;
20920 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
20921 LARGE_COMMUNITY_LIST_MASTER
);
20923 vty_out(vty
, "%% Can't find large-community-list\n");
20924 return CMD_WARNING
;
20927 lcommunity_list_show(vty
, list
);
20929 return CMD_SUCCESS
;
20932 /* "extcommunity-list" keyword help string. */
20933 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
20934 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
20936 DEFUN (extcommunity_list_standard
,
20937 bgp_extcommunity_list_standard_cmd
,
20938 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20940 EXTCOMMUNITY_LIST_STR
20941 "Extended Community list number (standard)\n"
20942 "Specify standard extcommunity-list\n"
20943 "Community list name\n"
20944 "Sequence number of an entry\n"
20945 "Sequence number\n"
20946 "Specify community to reject\n"
20947 "Specify community to accept\n"
20948 EXTCOMMUNITY_VAL_STR
)
20950 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20952 char *cl_number_or_name
= NULL
;
20957 argv_find(argv
, argc
, "(1-99)", &idx
);
20958 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
20959 cl_number_or_name
= argv
[idx
]->arg
;
20961 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20962 seq
= argv
[idx
]->arg
;
20964 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20966 argv_find(argv
, argc
, "AA:NN", &idx
);
20967 char *str
= argv_concat(argv
, argc
, idx
);
20969 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20972 XFREE(MTYPE_TMP
, str
);
20975 community_list_perror(vty
, ret
);
20976 return CMD_WARNING_CONFIG_FAILED
;
20979 return CMD_SUCCESS
;
20982 DEFUN (extcommunity_list_name_expanded
,
20983 bgp_extcommunity_list_name_expanded_cmd
,
20984 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
20986 EXTCOMMUNITY_LIST_STR
20987 "Extended Community list number (expanded)\n"
20988 "Specify expanded extcommunity-list\n"
20989 "Extended Community list name\n"
20990 "Sequence number of an entry\n"
20991 "Sequence number\n"
20992 "Specify community to reject\n"
20993 "Specify community to accept\n"
20994 "An ordered list as a regular-expression\n")
20996 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20998 char *cl_number_or_name
= NULL
;
21002 argv_find(argv
, argc
, "(100-500)", &idx
);
21003 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21004 cl_number_or_name
= argv
[idx
]->arg
;
21006 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21007 seq
= argv
[idx
]->arg
;
21009 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
21011 argv_find(argv
, argc
, "LINE", &idx
);
21012 char *str
= argv_concat(argv
, argc
, idx
);
21014 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
21017 XFREE(MTYPE_TMP
, str
);
21020 community_list_perror(vty
, ret
);
21021 return CMD_WARNING_CONFIG_FAILED
;
21024 return CMD_SUCCESS
;
21027 DEFUN (no_extcommunity_list_standard_all
,
21028 no_bgp_extcommunity_list_standard_all_cmd
,
21029 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
21032 EXTCOMMUNITY_LIST_STR
21033 "Extended Community list number (standard)\n"
21034 "Specify standard extcommunity-list\n"
21035 "Community list name\n"
21036 "Sequence number of an entry\n"
21037 "Sequence number\n"
21038 "Specify community to reject\n"
21039 "Specify community to accept\n"
21040 EXTCOMMUNITY_VAL_STR
)
21042 int style
= EXTCOMMUNITY_LIST_STANDARD
;
21044 char *cl_number_or_name
= NULL
;
21049 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21050 seq
= argv
[idx
]->arg
;
21053 argv_find(argv
, argc
, "permit", &idx
);
21054 argv_find(argv
, argc
, "deny", &idx
);
21056 direct
= argv_find(argv
, argc
, "permit", &idx
)
21061 argv_find(argv
, argc
, "AA:NN", &idx
);
21062 str
= argv_concat(argv
, argc
, idx
);
21066 argv_find(argv
, argc
, "(1-99)", &idx
);
21067 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21068 cl_number_or_name
= argv
[idx
]->arg
;
21070 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
21071 seq
, direct
, style
);
21073 XFREE(MTYPE_TMP
, str
);
21076 community_list_perror(vty
, ret
);
21077 return CMD_WARNING_CONFIG_FAILED
;
21080 return CMD_SUCCESS
;
21083 ALIAS(no_extcommunity_list_standard_all
,
21084 no_bgp_extcommunity_list_standard_all_list_cmd
,
21085 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
21086 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
21087 "Extended Community list number (standard)\n"
21088 "Specify standard extcommunity-list\n"
21089 "Community list name\n")
21091 DEFUN (no_extcommunity_list_expanded_all
,
21092 no_bgp_extcommunity_list_expanded_all_cmd
,
21093 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
21096 EXTCOMMUNITY_LIST_STR
21097 "Extended Community list number (expanded)\n"
21098 "Specify expanded extcommunity-list\n"
21099 "Extended Community list name\n"
21100 "Sequence number of an entry\n"
21101 "Sequence number\n"
21102 "Specify community to reject\n"
21103 "Specify community to accept\n"
21104 "An ordered list as a regular-expression\n")
21106 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
21108 char *cl_number_or_name
= NULL
;
21113 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21114 seq
= argv
[idx
]->arg
;
21117 argv_find(argv
, argc
, "permit", &idx
);
21118 argv_find(argv
, argc
, "deny", &idx
);
21121 direct
= argv_find(argv
, argc
, "permit", &idx
)
21126 argv_find(argv
, argc
, "LINE", &idx
);
21127 str
= argv_concat(argv
, argc
, idx
);
21131 argv_find(argv
, argc
, "(100-500)", &idx
);
21132 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21133 cl_number_or_name
= argv
[idx
]->arg
;
21135 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
21136 seq
, direct
, style
);
21138 XFREE(MTYPE_TMP
, str
);
21141 community_list_perror(vty
, ret
);
21142 return CMD_WARNING_CONFIG_FAILED
;
21145 return CMD_SUCCESS
;
21148 ALIAS(no_extcommunity_list_expanded_all
,
21149 no_bgp_extcommunity_list_expanded_all_list_cmd
,
21150 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
21151 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
21152 "Extended Community list number (expanded)\n"
21153 "Specify expanded extcommunity-list\n"
21154 "Extended Community list name\n")
21156 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
21158 struct community_entry
*entry
;
21160 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21161 if (entry
== list
->head
) {
21162 if (all_digit(list
->name
))
21163 vty_out(vty
, "Extended community %s list %s\n",
21164 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21166 : "(expanded) access",
21170 "Named extended community %s list %s\n",
21171 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21177 vty_out(vty
, " %s\n",
21178 community_direct_str(entry
->direct
));
21180 vty_out(vty
, " %s %s\n",
21181 community_direct_str(entry
->direct
),
21182 community_list_config_str(entry
));
21186 DEFUN (show_extcommunity_list
,
21187 show_bgp_extcommunity_list_cmd
,
21188 "show bgp extcommunity-list",
21191 "List extended-community list\n")
21193 struct community_list
*list
;
21194 struct community_list_master
*cm
;
21196 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
21198 return CMD_SUCCESS
;
21200 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21201 extcommunity_list_show(vty
, list
);
21203 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21204 extcommunity_list_show(vty
, list
);
21206 return CMD_SUCCESS
;
21209 DEFUN (show_extcommunity_list_arg
,
21210 show_bgp_extcommunity_list_arg_cmd
,
21211 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
21214 "List extended-community list\n"
21215 "Extcommunity-list number\n"
21216 "Extcommunity-list name\n"
21217 "Detailed information on extcommunity-list\n")
21219 int idx_comm_list
= 3;
21220 struct community_list
*list
;
21222 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
21223 EXTCOMMUNITY_LIST_MASTER
);
21225 vty_out(vty
, "%% Can't find extcommunity-list\n");
21226 return CMD_WARNING
;
21229 extcommunity_list_show(vty
, list
);
21231 return CMD_SUCCESS
;
21234 /* Display community-list and extcommunity-list configuration. */
21235 static int community_list_config_write(struct vty
*vty
)
21237 struct community_list
*list
;
21238 struct community_entry
*entry
;
21239 struct community_list_master
*cm
;
21242 /* Community-list. */
21243 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
21245 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21246 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21248 "bgp community-list %s seq %" PRId64
" %s %s\n",
21249 list
->name
, entry
->seq
,
21250 community_direct_str(entry
->direct
),
21251 community_list_config_str(entry
));
21254 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21255 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21257 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
21258 entry
->style
== COMMUNITY_LIST_STANDARD
21261 list
->name
, entry
->seq
,
21262 community_direct_str(entry
->direct
),
21263 community_list_config_str(entry
));
21267 /* Extcommunity-list. */
21268 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
21270 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21271 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21273 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
21274 list
->name
, entry
->seq
,
21275 community_direct_str(entry
->direct
),
21276 community_list_config_str(entry
));
21279 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21280 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21282 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
21283 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21286 list
->name
, entry
->seq
,
21287 community_direct_str(entry
->direct
),
21288 community_list_config_str(entry
));
21293 /* lcommunity-list. */
21294 cm
= community_list_master_lookup(bgp_clist
,
21295 LARGE_COMMUNITY_LIST_MASTER
);
21297 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21298 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21300 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
21301 list
->name
, entry
->seq
,
21302 community_direct_str(entry
->direct
),
21303 community_list_config_str(entry
));
21306 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21307 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21309 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
21311 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
21314 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
21315 community_list_config_str(entry
));
21322 static int community_list_config_write(struct vty
*vty
);
21323 static struct cmd_node community_list_node
= {
21324 .name
= "community list",
21325 .node
= COMMUNITY_LIST_NODE
,
21327 .config_write
= community_list_config_write
,
21330 static void community_list_vty(void)
21332 install_node(&community_list_node
);
21334 /* Community-list. */
21335 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
21336 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
21337 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
21338 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
21339 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
21340 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
21341 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
21342 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
21344 /* Extcommunity-list. */
21345 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
21346 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
21347 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
21348 install_element(CONFIG_NODE
,
21349 &no_bgp_extcommunity_list_standard_all_list_cmd
);
21350 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
21351 install_element(CONFIG_NODE
,
21352 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
21353 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
21354 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
21356 /* Large Community List */
21357 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
21358 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
21359 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
21360 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
21361 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
21362 install_element(CONFIG_NODE
,
21363 &no_bgp_lcommunity_list_name_standard_all_cmd
);
21364 install_element(CONFIG_NODE
,
21365 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
21366 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
21367 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
21368 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
21369 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
21370 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
21371 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
21373 bgp_community_list_command_completion_setup();
21376 static struct cmd_node community_alias_node
= {
21377 .name
= "community alias",
21378 .node
= COMMUNITY_ALIAS_NODE
,
21380 .config_write
= bgp_community_alias_write
,
21383 void community_alias_vty(void)
21385 install_node(&community_alias_node
);
21387 /* Community-list. */
21388 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
21390 bgp_community_alias_command_completion_setup();