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 DEFPY(neighbor_path_attribute_treat_as_withdraw
,
8844 neighbor_path_attribute_treat_as_withdraw_cmd
,
8845 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor path-attribute treat-as-withdraw (1-255)...",
8848 "Manipulate path attributes from incoming UPDATE messages\n"
8849 "Treat-as-withdraw any incoming BGP UPDATE messages that contain the specified attribute\n"
8850 "Attribute number\n")
8854 const char *withdraw_attrs
= NULL
;
8856 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8858 return CMD_WARNING_CONFIG_FAILED
;
8860 argv_find(argv
, argc
, "(1-255)", &idx
);
8862 withdraw_attrs
= argv_concat(argv
, argc
, idx
);
8864 bgp_path_attribute_withdraw_vty(vty
, peer
, withdraw_attrs
, true);
8869 DEFPY(no_neighbor_path_attribute_treat_as_withdraw
,
8870 no_neighbor_path_attribute_treat_as_withdraw_cmd
,
8871 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor path-attribute treat-as-withdraw (1-255)...",
8875 "Manipulate path attributes from incoming UPDATE messages\n"
8876 "Treat-as-withdraw any incoming BGP UPDATE messages that contain the specified attribute\n"
8877 "Attribute number\n")
8881 const char *withdraw_attrs
= NULL
;
8883 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8885 return CMD_WARNING_CONFIG_FAILED
;
8887 argv_find(argv
, argc
, "(1-255)", &idx
);
8889 withdraw_attrs
= argv_concat(argv
, argc
, idx
);
8891 bgp_path_attribute_withdraw_vty(vty
, peer
, withdraw_attrs
, false);
8896 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8897 struct ecommunity
**list
, bool is_rt6
)
8899 struct ecommunity
*ecom
= NULL
;
8900 struct ecommunity
*ecomadd
;
8902 for (; argc
; --argc
, ++argv
) {
8904 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8905 ECOMMUNITY_ROUTE_TARGET
,
8908 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8909 ECOMMUNITY_ROUTE_TARGET
,
8912 vty_out(vty
, "Malformed community-list value\n");
8914 ecommunity_free(&ecom
);
8915 return CMD_WARNING_CONFIG_FAILED
;
8919 ecommunity_merge(ecom
, ecomadd
);
8920 ecommunity_free(&ecomadd
);
8927 ecommunity_free(&*list
);
8935 * v2vimport is true if we are handling a `import vrf ...` command
8937 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8941 switch (vty
->node
) {
8950 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8955 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8956 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8957 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8958 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8960 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8964 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8965 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8966 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8967 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8969 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8976 DEFPY (af_rd_vpn_export
,
8977 af_rd_vpn_export_cmd
,
8978 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8980 "Specify route distinguisher\n"
8981 "Between current address-family and vpn\n"
8982 "For routes leaked from current address-family to vpn\n"
8983 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8985 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8986 struct prefix_rd prd
;
8992 if (argv_find(argv
, argc
, "no", &idx
))
8996 ret
= str2prefix_rd(rd_str
, &prd
);
8998 vty_out(vty
, "%% Malformed rd\n");
8999 return CMD_WARNING_CONFIG_FAILED
;
9003 afi
= vpn_policy_getafi(vty
, bgp
, false);
9005 return CMD_WARNING_CONFIG_FAILED
;
9008 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9010 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9011 bgp_get_default(), bgp
);
9014 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
9015 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9016 BGP_VPN_POLICY_TOVPN_RD_SET
);
9018 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9019 BGP_VPN_POLICY_TOVPN_RD_SET
);
9022 /* post-change: re-export vpn routes */
9023 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9024 bgp_get_default(), bgp
);
9029 ALIAS (af_rd_vpn_export
,
9030 af_no_rd_vpn_export_cmd
,
9033 "Specify route distinguisher\n"
9034 "Between current address-family and vpn\n"
9035 "For routes leaked from current address-family to vpn\n")
9037 DEFPY (af_label_vpn_export
,
9038 af_label_vpn_export_cmd
,
9039 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
9041 "label value for VRF\n"
9042 "Between current address-family and vpn\n"
9043 "For routes leaked from current address-family to vpn\n"
9044 "Label Value <0-1048575>\n"
9045 "Automatically assign a label\n")
9047 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9048 mpls_label_t label
= MPLS_LABEL_NONE
;
9053 if (argv_find(argv
, argc
, "no", &idx
))
9056 /* If "no ...", squash trailing parameter */
9062 label
= label_val
; /* parser should force unsigned */
9065 afi
= vpn_policy_getafi(vty
, bgp
, false);
9067 return CMD_WARNING_CONFIG_FAILED
;
9070 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9071 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
9076 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9078 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9079 bgp_get_default(), bgp
);
9081 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9082 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
9084 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
9087 * label has previously been automatically
9088 * assigned by labelpool: release it
9090 * NB if tovpn_label == MPLS_LABEL_NONE it
9091 * means the automatic assignment is in flight
9092 * and therefore the labelpool callback must
9093 * detect that the auto label is not needed.
9096 bgp_lp_release(LP_TYPE_VRF
,
9097 &bgp
->vpn_policy
[afi
],
9098 bgp
->vpn_policy
[afi
].tovpn_label
);
9100 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9101 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9104 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
9106 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9107 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9108 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
9109 vpn_leak_label_callback
);
9112 /* post-change: re-export vpn routes */
9113 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9114 bgp_get_default(), bgp
);
9116 hook_call(bgp_snmp_update_last_changed
, bgp
);
9120 DEFPY (af_sid_vpn_export
,
9121 af_sid_vpn_export_cmd
,
9122 "[no] sid vpn export <(1-1048575)$sid_idx|auto$sid_auto>",
9124 "sid value for VRF\n"
9125 "Between current address-family and vpn\n"
9126 "For routes leaked from current address-family to vpn\n"
9127 "Sid allocation index\n"
9128 "Automatically assign a label\n")
9130 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9136 if (argv_find(argv
, argc
, "no", &idx
))
9138 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
9139 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
9141 afi
= vpn_policy_getafi(vty
, bgp
, false);
9143 return CMD_WARNING_CONFIG_FAILED
;
9147 vty_out(vty
, "It's not implemented\n");
9148 return CMD_WARNING_CONFIG_FAILED
;
9151 if (bgp
->tovpn_sid_index
!= 0 ||
9152 CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)) {
9154 "per-vrf sid and per-af sid are mutually exclusive\n"
9155 "Failed: per-vrf sid is configured. Remove per-vrf sid before configuring per-af sid\n");
9156 return CMD_WARNING_CONFIG_FAILED
;
9159 /* skip when it's already configured */
9160 if ((sid_idx
!= 0 && bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9161 || (sid_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9162 BGP_VPN_POLICY_TOVPN_SID_AUTO
)))
9166 * mode change between sid_idx and sid_auto isn't supported.
9167 * user must negate sid vpn export when they want to change the mode
9169 if ((sid_auto
&& bgp
->vpn_policy
[afi
].tovpn_sid_index
!= 0)
9170 || (sid_idx
!= 0 && CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9171 BGP_VPN_POLICY_TOVPN_SID_AUTO
))) {
9172 vty_out(vty
, "it's already configured as %s.\n",
9173 sid_auto
? "auto-mode" : "idx-mode");
9174 return CMD_WARNING_CONFIG_FAILED
;
9178 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9179 bgp_get_default(), bgp
);
9182 /* SID allocation auto-mode */
9184 zlog_debug("%s: auto sid alloc.", __func__
);
9185 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9186 BGP_VPN_POLICY_TOVPN_SID_AUTO
);
9188 /* SID allocation index-mode */
9190 zlog_debug("%s: idx %ld sid alloc.", __func__
, sid_idx
);
9191 bgp
->vpn_policy
[afi
].tovpn_sid_index
= sid_idx
;
9195 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9196 bgp_get_default(), bgp
);
9200 DEFPY (bgp_sid_vpn_export
,
9201 bgp_sid_vpn_export_cmd
,
9202 "[no] sid vpn per-vrf export <(1-1048575)$sid_idx|auto$sid_auto>",
9204 "sid value for VRF\n"
9205 "Between current vrf and vpn\n"
9206 "sid per-VRF (both IPv4 and IPv6 address families)\n"
9207 "For routes leaked from current vrf to vpn\n"
9208 "Sid allocation index\n"
9209 "Automatically assign a label\n")
9211 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9214 debug
= (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
) |
9215 BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
));
9218 /* when per-VRF SID is not set, do nothing */
9219 if (bgp
->tovpn_sid_index
== 0 &&
9220 !CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
))
9225 bgp
->tovpn_sid_index
= 0;
9226 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
);
9229 if (bgp
->vpn_policy
[AFI_IP
].tovpn_sid_index
!= 0 ||
9230 CHECK_FLAG(bgp
->vpn_policy
[AFI_IP
].flags
,
9231 BGP_VPN_POLICY_TOVPN_SID_AUTO
) ||
9232 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid_index
!= 0 ||
9233 CHECK_FLAG(bgp
->vpn_policy
[AFI_IP6
].flags
,
9234 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
9236 "per-vrf sid and per-af sid are mutually exclusive\n"
9237 "Failed: per-af sid is configured. Remove per-af sid before configuring per-vrf sid\n");
9238 return CMD_WARNING_CONFIG_FAILED
;
9241 /* skip when it's already configured */
9242 if ((sid_idx
!= 0 && bgp
->tovpn_sid_index
!= 0) ||
9243 (sid_auto
&& CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)))
9247 * mode change between sid_idx and sid_auto isn't supported.
9248 * user must negate sid vpn export when they want to change the mode
9250 if ((sid_auto
&& bgp
->tovpn_sid_index
!= 0) ||
9252 CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
))) {
9253 vty_out(vty
, "it's already configured as %s.\n",
9254 sid_auto
? "auto-mode" : "idx-mode");
9255 return CMD_WARNING_CONFIG_FAILED
;
9259 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP
, bgp_get_default(),
9261 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP6
, bgp_get_default(),
9265 /* SID allocation auto-mode */
9267 zlog_debug("%s: auto per-vrf sid alloc.", __func__
);
9268 SET_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
);
9269 } else if (sid_idx
!= 0) {
9270 /* SID allocation index-mode */
9272 zlog_debug("%s: idx %ld per-vrf sid alloc.", __func__
,
9274 bgp
->tovpn_sid_index
= sid_idx
;
9278 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP
, bgp_get_default(),
9280 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, AFI_IP6
,
9281 bgp_get_default(), bgp
);
9286 ALIAS (af_label_vpn_export
,
9287 af_no_label_vpn_export_cmd
,
9288 "no label vpn export",
9290 "label value for VRF\n"
9291 "Between current address-family and vpn\n"
9292 "For routes leaked from current address-family to vpn\n")
9294 ALIAS (bgp_sid_vpn_export
,
9295 no_bgp_sid_vpn_export_cmd
,
9296 "no$no sid vpn per-vrf export",
9298 "sid value for VRF\n"
9299 "Between current vrf and vpn\n"
9300 "sid per-VRF (both IPv4 and IPv6 address families)\n"
9301 "For routes leaked from current vrf to vpn\n")
9303 DEFPY (af_nexthop_vpn_export
,
9304 af_nexthop_vpn_export_cmd
,
9305 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
9307 "Specify next hop to use for VRF advertised prefixes\n"
9308 "Between current address-family and vpn\n"
9309 "For routes leaked from current address-family to vpn\n"
9313 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9319 vty_out(vty
, "%% Nexthop required\n");
9320 return CMD_WARNING_CONFIG_FAILED
;
9322 if (!sockunion2hostprefix(nexthop_su
, &p
))
9323 return CMD_WARNING_CONFIG_FAILED
;
9326 afi
= vpn_policy_getafi(vty
, bgp
, false);
9328 return CMD_WARNING_CONFIG_FAILED
;
9331 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9333 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9334 bgp_get_default(), bgp
);
9337 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
9338 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9339 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9341 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9342 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
9345 /* post-change: re-export vpn routes */
9346 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9347 bgp_get_default(), bgp
);
9352 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9354 if (!strcmp(dstr
, "import")) {
9355 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9356 } else if (!strcmp(dstr
, "export")) {
9357 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9358 } else if (!strcmp(dstr
, "both")) {
9359 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9360 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9362 vty_out(vty
, "%% direction parse error\n");
9363 return CMD_WARNING_CONFIG_FAILED
;
9368 DEFPY (af_rt_vpn_imexport
,
9369 af_rt_vpn_imexport_cmd
,
9370 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9372 "Specify route target list\n"
9373 "Specify route target list\n"
9374 "Between current address-family and vpn\n"
9375 "For routes leaked from vpn to current address-family: match any\n"
9376 "For routes leaked from current address-family to vpn: set\n"
9377 "both import: match any and export: set\n"
9378 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9380 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9382 struct ecommunity
*ecom
= NULL
;
9383 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9384 enum vpn_policy_direction dir
;
9389 if (argv_find(argv
, argc
, "no", &idx
))
9392 afi
= vpn_policy_getafi(vty
, bgp
, false);
9394 return CMD_WARNING_CONFIG_FAILED
;
9396 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9397 if (ret
!= CMD_SUCCESS
)
9401 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9402 vty_out(vty
, "%% Missing RTLIST\n");
9403 return CMD_WARNING_CONFIG_FAILED
;
9405 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9406 if (ret
!= CMD_SUCCESS
) {
9411 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9415 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9418 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9420 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9421 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9422 ecommunity_dup(ecom
);
9424 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9426 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9427 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9430 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9434 ecommunity_free(&ecom
);
9439 ALIAS (af_rt_vpn_imexport
,
9440 af_no_rt_vpn_imexport_cmd
,
9441 "no <rt|route-target> vpn <import|export|both>$direction_str",
9443 "Specify route target list\n"
9444 "Specify route target list\n"
9445 "Between current address-family and vpn\n"
9446 "For routes leaked from vpn to current address-family\n"
9447 "For routes leaked from current address-family to vpn\n"
9448 "both import and export\n")
9450 DEFPY (af_route_map_vpn_imexport
,
9451 af_route_map_vpn_imexport_cmd
,
9452 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9453 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9455 "Specify route map\n"
9456 "Between current address-family and vpn\n"
9457 "For routes leaked from vpn to current address-family\n"
9458 "For routes leaked from current address-family to vpn\n"
9459 "name of route-map\n")
9461 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9463 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9464 enum vpn_policy_direction dir
;
9469 if (argv_find(argv
, argc
, "no", &idx
))
9472 afi
= vpn_policy_getafi(vty
, bgp
, false);
9474 return CMD_WARNING_CONFIG_FAILED
;
9476 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9477 if (ret
!= CMD_SUCCESS
)
9480 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9484 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9487 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9488 XFREE(MTYPE_ROUTE_MAP_NAME
,
9489 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9490 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
9491 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9492 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9493 route_map_lookup_warn_noexist(vty
, rmap_str
);
9494 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9497 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9498 XFREE(MTYPE_ROUTE_MAP_NAME
,
9499 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9500 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9501 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9504 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9510 ALIAS (af_route_map_vpn_imexport
,
9511 af_no_route_map_vpn_imexport_cmd
,
9512 "no route-map vpn <import|export>$direction_str",
9514 "Specify route map\n"
9515 "Between current address-family and vpn\n"
9516 "For routes leaked from vpn to current address-family\n"
9517 "For routes leaked from current address-family to vpn\n")
9519 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9520 "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
;
9529 struct bgp
*bgp_default
;
9531 afi
= vpn_policy_getafi(vty
, bgp
, true);
9533 return CMD_WARNING_CONFIG_FAILED
;
9535 bgp_default
= bgp_get_default();
9540 /* Auto-create assuming the same AS */
9541 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9542 BGP_INSTANCE_TYPE_DEFAULT
);
9546 "VRF default is not configured as a bgp instance\n");
9551 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9553 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9554 XFREE(MTYPE_ROUTE_MAP_NAME
,
9555 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9556 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9557 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9558 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9559 route_map_lookup_warn_noexist(vty
, rmap_str
);
9560 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9563 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9564 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9566 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9571 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9572 "no import vrf route-map [RMAP$rmap_str]",
9574 "Import routes from another VRF\n"
9575 "Vrf routes being filtered\n"
9576 "Specify route map\n"
9577 "name of route-map\n")
9579 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9580 enum vpn_policy_direction dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9583 afi
= vpn_policy_getafi(vty
, bgp
, true);
9585 return CMD_WARNING_CONFIG_FAILED
;
9587 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9589 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9590 XFREE(MTYPE_ROUTE_MAP_NAME
,
9591 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9592 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9593 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9595 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9596 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9597 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9599 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9604 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
9605 "[no] import vrf VIEWVRFNAME$import_name",
9607 "Import routes from another VRF\n"
9608 "VRF to import from\n"
9609 "The name of the VRF\n")
9611 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9612 struct listnode
*node
;
9613 struct bgp
*vrf_bgp
, *bgp_default
;
9616 bool remove
= false;
9619 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
9623 if (import_name
== NULL
) {
9624 vty_out(vty
, "%% Missing import name\n");
9628 if (strcmp(import_name
, "route-map") == 0) {
9629 vty_out(vty
, "%% Must include route-map name\n");
9633 if (argv_find(argv
, argc
, "no", &idx
))
9636 afi
= vpn_policy_getafi(vty
, bgp
, true);
9638 return CMD_WARNING_CONFIG_FAILED
;
9640 safi
= bgp_node_safi(vty
);
9642 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
9643 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
9644 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
9645 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
9646 remove
? "unimport" : "import", import_name
);
9650 bgp_default
= bgp_get_default();
9652 /* Auto-create assuming the same AS */
9653 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9654 BGP_INSTANCE_TYPE_DEFAULT
);
9658 "VRF default is not configured as a bgp instance\n");
9663 vrf_bgp
= bgp_lookup_by_name(import_name
);
9665 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
9666 vrf_bgp
= bgp_default
;
9668 /* Auto-create assuming the same AS */
9669 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
9673 "VRF %s is not configured as a bgp instance\n",
9680 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9682 /* Already importing from "import_vrf"? */
9683 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
9685 if (strcmp(vname
, import_name
) == 0)
9689 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
9695 /* This command is valid only in a bgp vrf instance or the default instance */
9696 DEFPY (bgp_imexport_vpn
,
9697 bgp_imexport_vpn_cmd
,
9698 "[no] <import|export>$direction_str vpn",
9700 "Import routes to this address-family\n"
9701 "Export routes from this address-family\n"
9702 "to/from default instance VPN RIB\n")
9704 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9711 enum vpn_policy_direction dir
;
9713 if (argv_find(argv
, argc
, "no", &idx
))
9716 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
9717 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
9719 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
9720 return CMD_WARNING_CONFIG_FAILED
;
9723 afi
= bgp_node_afi(vty
);
9724 safi
= bgp_node_safi(vty
);
9725 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
9726 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
9727 return CMD_WARNING_CONFIG_FAILED
;
9730 if (!strcmp(direction_str
, "import")) {
9731 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
9732 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9733 } else if (!strcmp(direction_str
, "export")) {
9734 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
9735 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
9737 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9738 return CMD_WARNING_CONFIG_FAILED
;
9741 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9744 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9745 if (!previous_state
) {
9746 /* trigger export current vrf */
9747 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9750 if (previous_state
) {
9751 /* trigger un-export current vrf */
9752 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9754 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
9757 hook_call(bgp_snmp_init_stats
, bgp
);
9762 DEFPY (af_routetarget_import
,
9763 af_routetarget_import_cmd
,
9764 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9766 "Specify route target list\n"
9767 "Specify route target list\n"
9768 "Specify route target list\n"
9769 "Specify route target list\n"
9770 "Flow-spec redirect type route target\n"
9771 "Import routes to this address-family\n"
9772 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9774 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9776 struct ecommunity
*ecom
= NULL
;
9778 int idx
= 0, idx_unused
= 0;
9782 if (argv_find(argv
, argc
, "no", &idx
))
9785 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9786 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9789 afi
= vpn_policy_getafi(vty
, bgp
, false);
9791 return CMD_WARNING_CONFIG_FAILED
;
9793 if (rt6
&& afi
!= AFI_IP6
)
9794 return CMD_WARNING_CONFIG_FAILED
;
9797 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9798 vty_out(vty
, "%% Missing RTLIST\n");
9799 return CMD_WARNING_CONFIG_FAILED
;
9801 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9802 if (ret
!= CMD_SUCCESS
)
9807 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9808 ecommunity_free(&bgp
->vpn_policy
[afi
]
9809 .import_redirect_rtlist
);
9810 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9811 ecommunity_dup(ecom
);
9813 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9814 ecommunity_free(&bgp
->vpn_policy
[afi
]
9815 .import_redirect_rtlist
);
9816 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9820 ecommunity_free(&ecom
);
9825 DEFUN_NOSH (address_family_ipv4_safi
,
9826 address_family_ipv4_safi_cmd
,
9827 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9828 "Enter Address Family command mode\n"
9830 BGP_SAFI_WITH_LABEL_HELP_STR
)
9834 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9835 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9836 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9837 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9838 && safi
!= SAFI_EVPN
) {
9840 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9841 return CMD_WARNING_CONFIG_FAILED
;
9843 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9845 vty
->node
= BGP_IPV4_NODE
;
9850 DEFUN_NOSH (address_family_ipv6_safi
,
9851 address_family_ipv6_safi_cmd
,
9852 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9853 "Enter Address Family command mode\n"
9855 BGP_SAFI_WITH_LABEL_HELP_STR
)
9858 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9859 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9860 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
9861 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9862 && safi
!= SAFI_EVPN
) {
9864 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9865 return CMD_WARNING_CONFIG_FAILED
;
9867 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9869 vty
->node
= BGP_IPV6_NODE
;
9874 #ifdef KEEP_OLD_VPN_COMMANDS
9875 DEFUN_NOSH (address_family_vpnv4
,
9876 address_family_vpnv4_cmd
,
9877 "address-family vpnv4 [unicast]",
9878 "Enter Address Family command mode\n"
9880 BGP_AF_MODIFIER_STR
)
9882 vty
->node
= BGP_VPNV4_NODE
;
9886 DEFUN_NOSH (address_family_vpnv6
,
9887 address_family_vpnv6_cmd
,
9888 "address-family vpnv6 [unicast]",
9889 "Enter Address Family command mode\n"
9891 BGP_AF_MODIFIER_STR
)
9893 vty
->node
= BGP_VPNV6_NODE
;
9896 #endif /* KEEP_OLD_VPN_COMMANDS */
9898 DEFUN_NOSH (address_family_evpn
,
9899 address_family_evpn_cmd
,
9900 "address-family l2vpn evpn",
9901 "Enter Address Family command mode\n"
9903 BGP_AF_MODIFIER_STR
)
9905 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9906 vty
->node
= BGP_EVPN_NODE
;
9910 DEFUN_NOSH (bgp_segment_routing_srv6
,
9911 bgp_segment_routing_srv6_cmd
,
9912 "segment-routing srv6",
9913 "Segment-Routing configuration\n"
9914 "Segment-Routing SRv6 configuration\n")
9916 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9917 bgp
->srv6_enabled
= true;
9918 vty
->node
= BGP_SRV6_NODE
;
9922 DEFUN (no_bgp_segment_routing_srv6
,
9923 no_bgp_segment_routing_srv6_cmd
,
9924 "no segment-routing srv6",
9926 "Segment-Routing configuration\n"
9927 "Segment-Routing SRv6 configuration\n")
9929 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9931 if (strlen(bgp
->srv6_locator_name
) > 0)
9932 if (bgp_srv6_locator_unset(bgp
) < 0)
9933 return CMD_WARNING_CONFIG_FAILED
;
9935 bgp
->srv6_enabled
= false;
9939 DEFPY (bgp_srv6_locator
,
9940 bgp_srv6_locator_cmd
,
9941 "locator NAME$name",
9942 "Specify SRv6 locator\n"
9943 "Specify SRv6 locator\n")
9945 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9948 if (strlen(bgp
->srv6_locator_name
) > 0
9949 && strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9950 vty_out(vty
, "srv6 locator is already configured\n");
9951 return CMD_WARNING_CONFIG_FAILED
;
9954 snprintf(bgp
->srv6_locator_name
,
9955 sizeof(bgp
->srv6_locator_name
), "%s", name
);
9957 ret
= bgp_zebra_srv6_manager_get_locator_chunk(name
);
9959 return CMD_WARNING_CONFIG_FAILED
;
9964 DEFPY (no_bgp_srv6_locator
,
9965 no_bgp_srv6_locator_cmd
,
9966 "no locator NAME$name",
9968 "Specify SRv6 locator\n"
9969 "Specify SRv6 locator\n")
9971 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9973 /* when locator isn't configured, do nothing */
9974 if (strlen(bgp
->srv6_locator_name
) < 1)
9977 /* name validation */
9978 if (strcmp(name
, bgp
->srv6_locator_name
) != 0) {
9979 vty_out(vty
, "%% No srv6 locator is configured\n");
9980 return CMD_WARNING_CONFIG_FAILED
;
9984 if (bgp_srv6_locator_unset(bgp
) < 0)
9985 return CMD_WARNING_CONFIG_FAILED
;
9990 DEFPY (show_bgp_srv6
,
9992 "show bgp segment-routing srv6",
9995 "BGP Segment Routing\n"
9996 "BGP Segment Routing SRv6\n")
9999 struct listnode
*node
;
10000 struct srv6_locator_chunk
*chunk
;
10001 struct bgp_srv6_function
*func
;
10003 bgp
= bgp_get_default();
10005 return CMD_SUCCESS
;
10007 vty_out(vty
, "locator_name: %s\n", bgp
->srv6_locator_name
);
10008 vty_out(vty
, "locator_chunks:\n");
10009 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_locator_chunks
, node
, chunk
)) {
10010 vty_out(vty
, "- %pFX\n", &chunk
->prefix
);
10011 vty_out(vty
, " block-length: %d\n", chunk
->block_bits_length
);
10012 vty_out(vty
, " node-length: %d\n", chunk
->node_bits_length
);
10013 vty_out(vty
, " func-length: %d\n",
10014 chunk
->function_bits_length
);
10015 vty_out(vty
, " arg-length: %d\n", chunk
->argument_bits_length
);
10018 vty_out(vty
, "functions:\n");
10019 for (ALL_LIST_ELEMENTS_RO(bgp
->srv6_functions
, node
, func
)) {
10020 vty_out(vty
, "- sid: %pI6\n", &func
->sid
);
10021 vty_out(vty
, " locator: %s\n", func
->locator_name
);
10024 vty_out(vty
, "bgps:\n");
10025 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
)) {
10026 vty_out(vty
, "- name: %s\n",
10027 bgp
->name
? bgp
->name
: "default");
10029 vty_out(vty
, " vpn_policy[AFI_IP].tovpn_sid: %pI6\n",
10030 bgp
->vpn_policy
[AFI_IP
].tovpn_sid
);
10031 vty_out(vty
, " vpn_policy[AFI_IP6].tovpn_sid: %pI6\n",
10032 bgp
->vpn_policy
[AFI_IP6
].tovpn_sid
);
10033 vty_out(vty
, " per-vrf tovpn_sid: %pI6\n", bgp
->tovpn_sid
);
10036 return CMD_SUCCESS
;
10039 DEFUN_NOSH (exit_address_family
,
10040 exit_address_family_cmd
,
10041 "exit-address-family",
10042 "Exit from Address Family configuration mode\n")
10044 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
10045 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
10046 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
10047 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
10048 || vty
->node
== BGP_EVPN_NODE
10049 || vty
->node
== BGP_FLOWSPECV4_NODE
10050 || vty
->node
== BGP_FLOWSPECV6_NODE
)
10051 vty
->node
= BGP_NODE
;
10052 return CMD_SUCCESS
;
10055 /* Recalculate bestpath and re-advertise a prefix */
10056 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
10057 const char *ip_str
, afi_t afi
, safi_t safi
,
10058 struct prefix_rd
*prd
)
10061 struct prefix match
;
10062 struct bgp_dest
*dest
;
10063 struct bgp_dest
*rm
;
10065 struct bgp_table
*table
;
10066 struct bgp_table
*rib
;
10068 /* BGP structure lookup. */
10070 bgp
= bgp_lookup_by_name(view_name
);
10072 vty_out(vty
, "%% Can't find BGP instance %s\n",
10074 return CMD_WARNING
;
10077 bgp
= bgp_get_default();
10079 vty_out(vty
, "%% No BGP process is configured\n");
10080 return CMD_WARNING
;
10084 /* Check IP address argument. */
10085 ret
= str2prefix(ip_str
, &match
);
10087 vty_out(vty
, "%% address is malformed\n");
10088 return CMD_WARNING
;
10091 match
.family
= afi2family(afi
);
10092 rib
= bgp
->rib
[afi
][safi
];
10094 if (safi
== SAFI_MPLS_VPN
) {
10095 for (dest
= bgp_table_top(rib
); dest
;
10096 dest
= bgp_route_next(dest
)) {
10097 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
10099 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
10102 table
= bgp_dest_get_bgp_table_info(dest
);
10106 rm
= bgp_node_match(table
, &match
);
10108 const struct prefix
*rm_p
=
10109 bgp_dest_get_prefix(rm
);
10111 if (rm_p
->prefixlen
== match
.prefixlen
) {
10112 SET_FLAG(rm
->flags
,
10113 BGP_NODE_USER_CLEAR
);
10114 bgp_process(bgp
, rm
, afi
, safi
);
10116 bgp_dest_unlock_node(rm
);
10120 dest
= bgp_node_match(rib
, &match
);
10121 if (dest
!= NULL
) {
10122 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
10124 if (dest_p
->prefixlen
== match
.prefixlen
) {
10125 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
10126 bgp_process(bgp
, dest
, afi
, safi
);
10128 bgp_dest_unlock_node(dest
);
10132 return CMD_SUCCESS
;
10135 /* one clear bgp command to rule them all */
10136 DEFUN (clear_ip_bgp_all
,
10137 clear_ip_bgp_all_cmd
,
10138 "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>]",
10142 BGP_INSTANCE_HELP_STR
10145 BGP_SAFI_WITH_LABEL_HELP_STR
10146 BGP_AF_MODIFIER_STR
10147 "Clear all peers\n"
10148 "BGP IPv4 neighbor to clear\n"
10149 "BGP IPv6 neighbor to clear\n"
10150 "BGP neighbor on interface to clear\n"
10151 "Clear peers with the AS number\n"
10152 "Clear all external peers\n"
10153 "Clear all members of peer-group\n"
10154 "BGP peer-group name\n"
10159 "Push out prefix-list ORF and do inbound soft reconfig\n"
10161 "Reset message statistics\n")
10165 afi_t afi
= AFI_UNSPEC
;
10166 safi_t safi
= SAFI_UNSPEC
;
10167 enum clear_sort clr_sort
= clear_peer
;
10168 enum bgp_clear_type clr_type
;
10169 char *clr_arg
= NULL
;
10173 /* clear [ip] bgp */
10174 if (argv_find(argv
, argc
, "ip", &idx
))
10177 /* [<vrf> VIEWVRFNAME] */
10178 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10179 vrf
= argv
[idx
+ 1]->arg
;
10181 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10183 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10184 /* [<view> VIEWVRFNAME] */
10185 vrf
= argv
[idx
+ 1]->arg
;
10188 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
10189 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
10190 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
10192 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
10193 if (argv_find(argv
, argc
, "*", &idx
)) {
10194 clr_sort
= clear_all
;
10195 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
10196 clr_sort
= clear_peer
;
10197 clr_arg
= argv
[idx
]->arg
;
10198 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
10199 clr_sort
= clear_peer
;
10200 clr_arg
= argv
[idx
]->arg
;
10201 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
10202 clr_sort
= clear_group
;
10204 clr_arg
= argv
[idx
]->arg
;
10205 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
10206 clr_sort
= clear_peer
;
10207 clr_arg
= argv
[idx
]->arg
;
10208 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
10209 clr_sort
= clear_peer
;
10210 clr_arg
= argv
[idx
]->arg
;
10211 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
10212 clr_sort
= clear_as
;
10213 clr_arg
= argv
[idx
]->arg
;
10214 } else if (argv_find(argv
, argc
, "external", &idx
)) {
10215 clr_sort
= clear_external
;
10218 /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */
10219 if (argv_find(argv
, argc
, "soft", &idx
)) {
10220 if (argv_find(argv
, argc
, "in", &idx
)
10221 || argv_find(argv
, argc
, "out", &idx
))
10222 clr_type
= strmatch(argv
[idx
]->text
, "in")
10223 ? BGP_CLEAR_SOFT_IN
10224 : BGP_CLEAR_SOFT_OUT
;
10226 clr_type
= BGP_CLEAR_SOFT_BOTH
;
10227 } else if (argv_find(argv
, argc
, "in", &idx
)) {
10228 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
10229 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
10230 : BGP_CLEAR_SOFT_IN
;
10231 } else if (argv_find(argv
, argc
, "out", &idx
)) {
10232 clr_type
= BGP_CLEAR_SOFT_OUT
;
10233 } else if (argv_find(argv
, argc
, "message-stats", &idx
)) {
10234 clr_type
= BGP_CLEAR_MESSAGE_STATS
;
10236 clr_type
= BGP_CLEAR_SOFT_NONE
;
10238 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
10241 DEFUN (clear_ip_bgp_prefix
,
10242 clear_ip_bgp_prefix_cmd
,
10243 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
10247 BGP_INSTANCE_HELP_STR
10248 "Clear bestpath and re-advertise\n"
10252 char *prefix
= NULL
;
10256 /* [<view|vrf> VIEWVRFNAME] */
10257 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10258 vrf
= argv
[idx
+ 1]->arg
;
10260 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10262 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10263 /* [<view> VIEWVRFNAME] */
10264 vrf
= argv
[idx
+ 1]->arg
;
10268 prefix
= argv
[argc
- 1]->arg
;
10270 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
10273 DEFUN (clear_bgp_ipv6_safi_prefix
,
10274 clear_bgp_ipv6_safi_prefix_cmd
,
10275 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10281 "Clear bestpath and re-advertise\n"
10285 int idx_ipv6_prefix
= 0;
10286 safi_t safi
= SAFI_UNICAST
;
10287 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10288 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10290 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10291 return bgp_clear_prefix(
10292 vty
, NULL
, prefix
, AFI_IP6
,
10296 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
10297 clear_bgp_instance_ipv6_safi_prefix_cmd
,
10298 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10302 BGP_INSTANCE_HELP_STR
10305 "Clear bestpath and re-advertise\n"
10309 int idx_vrfview
= 0;
10310 int idx_ipv6_prefix
= 0;
10311 safi_t safi
= SAFI_UNICAST
;
10312 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10313 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10314 char *vrfview
= NULL
;
10316 /* [<view|vrf> VIEWVRFNAME] */
10317 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
10318 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10319 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
10321 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
10322 /* [<view> VIEWVRFNAME] */
10323 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10325 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10327 return bgp_clear_prefix(
10328 vty
, vrfview
, prefix
,
10329 AFI_IP6
, safi
, NULL
);
10332 DEFUN (show_bgp_views
,
10333 show_bgp_views_cmd
,
10334 "show [ip] bgp views",
10338 "Show the defined BGP views\n")
10340 struct list
*inst
= bm
->bgp
;
10341 struct listnode
*node
;
10344 vty_out(vty
, "Defined BGP views:\n");
10345 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10347 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10349 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
10353 return CMD_SUCCESS
;
10356 static inline void calc_peers_cfgd_estbd(struct bgp
*bgp
, int *peers_cfgd
,
10360 struct listnode
*node
;
10362 *peers_cfgd
= *peers_estbd
= 0;
10363 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, node
, peer
)) {
10364 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10367 if (peer_established(peer
))
10372 static void print_bgp_vrfs(struct bgp
*bgp
, struct vty
*vty
, json_object
*json
,
10375 int peers_cfg
, peers_estb
;
10377 calc_peers_cfgd_estbd(bgp
, &peers_cfg
, &peers_estb
);
10380 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10382 : (int64_t)bgp
->vrf_id
;
10383 json_object_string_add(json
, "type", type
);
10384 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10385 json_object_string_addf(json
, "routerId", "%pI4",
10387 json_object_int_add(json
, "numConfiguredPeers", peers_cfg
);
10388 json_object_int_add(json
, "numEstablishedPeers", peers_estb
);
10389 json_object_int_add(json
, "l3vni", bgp
->l3vni
);
10390 json_object_string_addf(json
, "rmac", "%pEA", &bgp
->rmac
);
10391 json_object_string_add(
10393 ifindex2ifname(bgp
->l3vni_svi_ifindex
, bgp
->vrf_id
));
10397 static int show_bgp_vrfs_detail_common(struct vty
*vty
, struct bgp
*bgp
,
10398 json_object
*json
, const char *name
,
10399 const char *type
, bool use_vrf
)
10401 int peers_cfg
, peers_estb
;
10403 calc_peers_cfgd_estbd(bgp
, &peers_cfg
, &peers_estb
);
10407 print_bgp_vrfs(bgp
, vty
, json
, type
);
10409 vty_out(vty
, "BGP instance %s VRF id %d\n",
10411 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10412 : (int)bgp
->vrf_id
);
10413 vty_out(vty
, "Router Id %pI4\n", &bgp
->router_id
);
10415 "Num Configured Peers %d, Established %d\n",
10416 peers_cfg
, peers_estb
);
10419 "L3VNI %u, L3VNI-SVI %s, Router MAC %pEA\n",
10421 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10428 print_bgp_vrfs(bgp
, vty
, json
, type
);
10430 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10432 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10433 : (int)bgp
->vrf_id
,
10434 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10435 vty_out(vty
, "%11s %-16u %-21pEA %-20s\n", " ",
10436 bgp
->l3vni
, &bgp
->rmac
,
10437 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10442 return CMD_SUCCESS
;
10445 DEFPY (show_bgp_vrfs
,
10447 "show [ip] bgp vrfs [<VRFNAME$vrf_name>] [json]",
10452 "Specific VRF name\n"
10455 struct list
*inst
= bm
->bgp
;
10456 struct listnode
*node
;
10458 bool uj
= use_json(argc
, argv
);
10459 json_object
*json
= NULL
;
10460 json_object
*json_vrfs
= NULL
;
10461 json_object
*json_vrf
= NULL
;
10463 const char *name
= vrf_name
;
10467 json
= json_object_new_object();
10470 if (strmatch(name
, VRF_DEFAULT_NAME
)) {
10471 bgp
= bgp_get_default();
10474 bgp
= bgp_lookup_by_name(name
);
10479 vty_json(vty
, json
);
10482 "%% Specified BGP instance not found\n");
10484 return CMD_WARNING
;
10490 json_vrf
= json_object_new_object();
10492 show_bgp_vrfs_detail_common(vty
, bgp
, json_vrf
, name
, type
,
10496 json_object_object_add(json
, name
, json_vrf
);
10497 vty_json(vty
, json
);
10500 return CMD_SUCCESS
;
10504 json_vrfs
= json_object_new_object();
10506 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10510 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10514 if (!uj
&& count
== 1) {
10516 "%4s %-5s %-16s %9s %10s %-37s\n",
10517 "Type", "Id", "routerId", "#PeersCfg",
10518 "#PeersEstb", "Name");
10519 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10520 "L3-VNI", "RouterMAC", "Interface");
10523 json_vrf
= json_object_new_object();
10525 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10526 name
= VRF_DEFAULT_NAME
;
10533 show_bgp_vrfs_detail_common(vty
, bgp
, json_vrf
, name
, type
,
10537 json_object_object_add(json_vrfs
, name
, json_vrf
);
10541 json_object_object_add(json
, "vrfs", json_vrfs
);
10542 json_object_int_add(json
, "totalVrfs", count
);
10543 vty_json(vty
, json
);
10547 "\nTotal number of VRFs (including default): %d\n",
10551 return CMD_SUCCESS
;
10554 DEFUN (show_bgp_mac_hash
,
10555 show_bgp_mac_hash_cmd
,
10556 "show bgp mac hash",
10560 "Mac Address database\n")
10562 bgp_mac_dump_table(vty
);
10564 return CMD_SUCCESS
;
10567 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10569 struct vty
*vty
= (struct vty
*)args
;
10570 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10572 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10575 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10577 vty_out(vty
, "self nexthop database:\n");
10578 bgp_nexthop_show_address_hash(vty
, bgp
);
10580 vty_out(vty
, "Tunnel-ip database:\n");
10581 hash_iterate(bgp
->tip_hash
,
10582 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10586 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10587 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10588 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10589 "martian next-hops\n"
10590 "martian next-hop database\n")
10592 struct bgp
*bgp
= NULL
;
10596 /* [<vrf> VIEWVRFNAME] */
10597 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10598 name
= argv
[idx
+ 1]->arg
;
10599 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10601 } else if (argv_find(argv
, argc
, "view", &idx
))
10602 /* [<view> VIEWVRFNAME] */
10603 name
= argv
[idx
+ 1]->arg
;
10605 bgp
= bgp_lookup_by_name(name
);
10607 bgp
= bgp_get_default();
10610 vty_out(vty
, "%% No BGP process is configured\n");
10611 return CMD_WARNING
;
10613 bgp_show_martian_nexthops(vty
, bgp
);
10615 return CMD_SUCCESS
;
10618 DEFUN (show_bgp_memory
,
10619 show_bgp_memory_cmd
,
10620 "show [ip] bgp memory",
10624 "Global BGP memory statistics\n")
10626 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10627 unsigned long count
;
10629 /* RIB related usage stats */
10630 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10631 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10632 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10633 count
* sizeof(struct bgp_dest
)));
10635 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10636 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10637 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10638 count
* sizeof(struct bgp_path_info
)));
10639 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10640 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10643 memstrbuf
, sizeof(memstrbuf
),
10644 count
* sizeof(struct bgp_path_info_extra
)));
10646 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10647 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10648 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10649 count
* sizeof(struct bgp_static
)));
10651 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10652 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10653 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10654 count
* sizeof(struct bpacket
)));
10657 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10658 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10659 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10660 count
* sizeof(struct bgp_adj_in
)));
10661 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10662 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10663 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10664 count
* sizeof(struct bgp_adj_out
)));
10666 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10667 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10669 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10670 count
* sizeof(struct bgp_nexthop_cache
)));
10672 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10673 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10675 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10676 count
* sizeof(struct bgp_damp_info
)));
10679 count
= attr_count();
10680 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10681 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10682 count
* sizeof(struct attr
)));
10684 if ((count
= attr_unknown_count()))
10685 vty_out(vty
, "%ld unknown attributes\n", count
);
10687 /* AS_PATH attributes */
10688 count
= aspath_count();
10689 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10690 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10691 count
* sizeof(struct aspath
)));
10693 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10694 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10695 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10696 count
* sizeof(struct assegment
)));
10698 /* Other attributes */
10699 if ((count
= community_count()))
10700 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10701 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10702 count
* sizeof(struct community
)));
10703 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10705 "%ld BGP ext-community entries, using %s of memory\n",
10707 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10708 count
* sizeof(struct ecommunity
)));
10709 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10711 "%ld BGP large-community entries, using %s of memory\n",
10712 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10713 count
* sizeof(struct lcommunity
)));
10715 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10716 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10717 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10718 count
* sizeof(struct cluster_list
)));
10720 /* Peer related usage */
10721 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10722 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10723 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10724 count
* sizeof(struct peer
)));
10726 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10727 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10728 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10729 count
* sizeof(struct peer_group
)));
10732 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10733 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10734 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10735 count
* sizeof(regex_t
)));
10736 return CMD_SUCCESS
;
10739 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10741 json_object
*bestpath
= json_object_new_object();
10743 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10744 json_object_string_add(bestpath
, "asPath", "ignore");
10746 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10747 json_object_string_add(bestpath
, "asPath", "confed");
10749 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10750 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10751 json_object_string_add(bestpath
, "multiPathRelax",
10754 json_object_string_add(bestpath
, "multiPathRelax",
10757 json_object_string_add(bestpath
, "multiPathRelax", "false");
10759 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
10760 json_object_boolean_true_add(bestpath
, "peerTypeRelax");
10762 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10763 json_object_string_add(bestpath
, "compareRouterId", "true");
10764 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10765 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10766 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10767 json_object_string_add(bestpath
, "med", "confed");
10768 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10769 json_object_string_add(bestpath
, "med",
10770 "missing-as-worst");
10772 json_object_string_add(bestpath
, "med", "true");
10775 json_object_object_add(json
, "bestPath", bestpath
);
10778 /* Print the error code/subcode for why the peer is down */
10779 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10780 json_object
*json_peer
, bool use_json
)
10782 const char *code_str
;
10783 const char *subcode_str
;
10786 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10787 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10788 char errorcodesubcode_hexstr
[5];
10789 char errorcodesubcode_str
[256];
10791 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10792 subcode_str
= bgp_notify_subcode_str(
10794 peer
->notify
.subcode
);
10796 snprintf(errorcodesubcode_hexstr
,
10797 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10798 peer
->notify
.code
, peer
->notify
.subcode
);
10799 json_object_string_add(json_peer
,
10800 "lastErrorCodeSubcode",
10801 errorcodesubcode_hexstr
);
10802 snprintf(errorcodesubcode_str
, 255, "%s%s",
10803 code_str
, subcode_str
);
10804 json_object_string_add(json_peer
,
10805 "lastNotificationReason",
10806 errorcodesubcode_str
);
10807 json_object_boolean_add(json_peer
,
10808 "lastNotificationHardReset",
10809 peer
->notify
.hard_reset
);
10810 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10811 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10812 && (peer
->notify
.subcode
10813 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10814 || peer
->notify
.subcode
10815 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10816 && peer
->notify
.length
) {
10818 const char *msg_str
;
10820 msg_str
= bgp_notify_admin_message(
10821 msgbuf
, sizeof(msgbuf
),
10822 (uint8_t *)peer
->notify
.data
,
10823 peer
->notify
.length
);
10825 json_object_string_add(
10827 "lastShutdownDescription",
10832 json_object_string_add(json_peer
, "lastResetDueTo",
10833 peer_down_str
[(int)peer
->last_reset
]);
10834 json_object_int_add(json_peer
, "lastResetCode",
10837 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10838 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10839 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10841 bgp_notify_subcode_str(peer
->notify
.code
,
10842 peer
->notify
.subcode
);
10843 vty_out(vty
, " Notification %s (%s%s%s)\n",
10844 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10847 code_str
, subcode_str
,
10848 peer
->notify
.hard_reset
10849 ? bgp_notify_subcode_str(
10851 BGP_NOTIFY_CEASE_HARD_RESET
)
10854 vty_out(vty
, " %s\n",
10855 peer_down_str
[(int)peer
->last_reset
]);
10860 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10863 return ((!peer_established(peer
)) || !peer
->afc_recv
[afi
][safi
]);
10866 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10867 struct peer
*peer
, json_object
*json_peer
,
10868 int max_neighbor_width
, bool use_json
)
10870 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10874 if (peer_dynamic_neighbor(peer
))
10875 json_object_boolean_true_add(json_peer
,
10877 if (peer
->hostname
)
10878 json_object_string_add(json_peer
, "hostname",
10881 if (peer
->domainname
)
10882 json_object_string_add(json_peer
, "domainname",
10884 json_object_int_add(json_peer
, "connectionsEstablished",
10885 peer
->established
);
10886 json_object_int_add(json_peer
, "connectionsDropped",
10888 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10889 use_json
, json_peer
);
10890 if (peer_established(peer
))
10891 json_object_string_add(json_peer
, "lastResetDueTo",
10892 "AFI/SAFI Not Negotiated");
10894 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10897 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10899 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10900 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10901 peer
->hostname
, peer
->host
);
10903 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10905 /* pad the neighbor column with spaces */
10906 if (len
< max_neighbor_width
)
10907 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10909 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10911 peer_uptime(peer
->uptime
, timebuf
,
10912 BGP_UPTIME_LEN
, 0, NULL
));
10913 if (peer_established(peer
))
10914 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10916 bgp_show_peer_reset(vty
, peer
, NULL
,
10921 /* Strip peer's description to the given size. */
10922 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10924 static char stripped
[BUFSIZ
];
10926 uint32_t last_space
= 0;
10929 if (*(desc
+ i
) == 0) {
10930 stripped
[i
] = '\0';
10933 if (i
!= 0 && *(desc
+ i
) == ' ' && last_space
!= i
- 1)
10935 stripped
[i
] = *(desc
+ i
);
10939 if (last_space
> size
)
10940 stripped
[size
+ 1] = '\0';
10942 stripped
[last_space
] = '\0';
10947 /* Determine whether var peer should be filtered out of the summary. */
10948 static bool bgp_show_summary_is_peer_filtered(struct peer
*peer
,
10949 struct peer
*fpeer
, int as_type
,
10953 /* filter neighbor XXXX */
10954 if (fpeer
&& fpeer
!= peer
)
10957 /* filter remote-as (internal|external) */
10958 if (as_type
!= AS_UNSPECIFIED
) {
10959 if (peer
->as_type
== AS_SPECIFIED
) {
10960 if (as_type
== AS_INTERNAL
) {
10961 if (peer
->as
!= peer
->local_as
)
10963 } else if (peer
->as
== peer
->local_as
)
10965 } else if (as_type
!= peer
->as_type
)
10967 } else if (as
&& as
!= peer
->as
) /* filter remote-as XXX */
10973 /* Show BGP peer's summary information.
10975 * Peer's description is stripped according to if `wide` option is given
10978 * When adding new columns to `show bgp summary` output, please make
10979 * sure `Desc` is the lastest column to show because it can contain
10980 * whitespaces and the whole output will be tricky.
10982 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10983 struct peer
*fpeer
, int as_type
, as_t as
,
10984 uint16_t show_flags
)
10987 struct listnode
*node
, *nnode
;
10988 unsigned int count
= 0, dn_count
= 0;
10989 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10990 char neighbor_buf
[VTY_BUFSIZ
];
10991 int neighbor_col_default_width
= 16;
10992 int len
, failed_count
= 0;
10993 unsigned int filtered_count
= 0;
10994 int max_neighbor_width
= 0;
10996 json_object
*json
= NULL
;
10997 json_object
*json_peer
= NULL
;
10998 json_object
*json_peers
= NULL
;
10999 struct peer_af
*paf
;
11000 struct bgp_filter
*filter
;
11001 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11002 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11003 bool show_established
=
11004 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11005 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11006 bool show_terse
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11008 /* labeled-unicast routes are installed in the unicast table so in order
11010 * display the correct PfxRcd value we must look at SAFI_UNICAST
11013 if (safi
== SAFI_LABELED_UNICAST
)
11014 pfx_rcd_safi
= SAFI_UNICAST
;
11016 pfx_rcd_safi
= safi
;
11019 json
= json_object_new_object();
11020 json_peers
= json_object_new_object();
11021 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11022 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11029 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11032 if (peer
->afc
[afi
][safi
]) {
11033 /* See if we have at least a single failed peer */
11034 if (bgp_has_peer_failed(peer
, afi
, safi
))
11038 if (peer_dynamic_neighbor(peer
))
11043 /* Loop over all neighbors that will be displayed to determine
11045 * characters are needed for the Neighbor column
11047 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11048 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11055 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11058 if (peer
->afc
[afi
][safi
]) {
11059 memset(dn_flag
, '\0', sizeof(dn_flag
));
11060 if (peer_dynamic_neighbor(peer
))
11064 && CHECK_FLAG(bgp
->flags
,
11065 BGP_FLAG_SHOW_HOSTNAME
))
11066 snprintf(neighbor_buf
,
11067 sizeof(neighbor_buf
),
11068 "%s%s(%s) ", dn_flag
,
11069 peer
->hostname
, peer
->host
);
11071 snprintf(neighbor_buf
,
11072 sizeof(neighbor_buf
), "%s%s ",
11073 dn_flag
, peer
->host
);
11075 len
= strlen(neighbor_buf
);
11077 if (len
> max_neighbor_width
)
11078 max_neighbor_width
= len
;
11080 /* See if we have at least a single failed peer */
11081 if (bgp_has_peer_failed(peer
, afi
, safi
))
11087 /* Originally we displayed the Neighbor column as 16
11088 * characters wide so make that the default
11090 if (max_neighbor_width
< neighbor_col_default_width
)
11091 max_neighbor_width
= neighbor_col_default_width
;
11094 if (show_failed
&& !failed_count
) {
11096 json_object_int_add(json
, "failedPeersCount", 0);
11097 json_object_int_add(json
, "dynamicPeers", dn_count
);
11098 json_object_int_add(json
, "totalPeers", count
);
11100 vty_json(vty
, json
);
11102 vty_out(vty
, "%% No failed BGP neighbors found\n");
11104 return CMD_SUCCESS
;
11107 count
= 0; /* Reset the value as its used again */
11108 filtered_count
= 0;
11110 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11111 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11114 if (!peer
->afc
[afi
][safi
])
11118 unsigned long ents
;
11119 char memstrbuf
[MTYPE_MEMSTR_LEN
];
11122 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
11124 : (int64_t)bgp
->vrf_id
;
11126 /* Usage summary and header */
11128 json_object_string_addf(json
, "routerId",
11131 json_object_int_add(json
, "as", bgp
->as
);
11132 json_object_int_add(json
, "vrfId", vrf_id_ui
);
11133 json_object_string_add(
11136 == BGP_INSTANCE_TYPE_DEFAULT
)
11141 "BGP router identifier %pI4, local AS number %u vrf-id %d",
11142 &bgp
->router_id
, bgp
->as
,
11143 bgp
->vrf_id
== VRF_UNKNOWN
11145 : (int)bgp
->vrf_id
);
11146 vty_out(vty
, "\n");
11149 if (bgp_update_delay_configured(bgp
)) {
11151 json_object_int_add(
11152 json
, "updateDelayLimit",
11153 bgp
->v_update_delay
);
11155 if (bgp
->v_update_delay
11156 != bgp
->v_establish_wait
)
11157 json_object_int_add(
11159 "updateDelayEstablishWait",
11160 bgp
->v_establish_wait
);
11162 if (bgp_update_delay_active(bgp
)) {
11163 json_object_string_add(
11165 "updateDelayFirstNeighbor",
11166 bgp
->update_delay_begin_time
);
11167 json_object_boolean_true_add(
11169 "updateDelayInProgress");
11171 if (bgp
->update_delay_over
) {
11172 json_object_string_add(
11174 "updateDelayFirstNeighbor",
11175 bgp
->update_delay_begin_time
);
11176 json_object_string_add(
11178 "updateDelayBestpathResumed",
11179 bgp
->update_delay_end_time
);
11180 json_object_string_add(
11182 "updateDelayZebraUpdateResume",
11183 bgp
->update_delay_zebra_resume_time
);
11184 json_object_string_add(
11186 "updateDelayPeerUpdateResume",
11187 bgp
->update_delay_peers_resume_time
);
11192 "Read-only mode update-delay limit: %d seconds\n",
11193 bgp
->v_update_delay
);
11194 if (bgp
->v_update_delay
11195 != bgp
->v_establish_wait
)
11197 " Establish wait: %d seconds\n",
11198 bgp
->v_establish_wait
);
11200 if (bgp_update_delay_active(bgp
)) {
11202 " First neighbor established: %s\n",
11203 bgp
->update_delay_begin_time
);
11205 " Delay in progress\n");
11207 if (bgp
->update_delay_over
) {
11209 " First neighbor established: %s\n",
11210 bgp
->update_delay_begin_time
);
11212 " Best-paths resumed: %s\n",
11213 bgp
->update_delay_end_time
);
11215 " zebra update resumed: %s\n",
11216 bgp
->update_delay_zebra_resume_time
);
11218 " peers update resumed: %s\n",
11219 bgp
->update_delay_peers_resume_time
);
11226 if (bgp_maxmed_onstartup_configured(bgp
)
11227 && bgp
->maxmed_active
)
11228 json_object_boolean_true_add(
11229 json
, "maxMedOnStartup");
11230 if (bgp
->v_maxmed_admin
)
11231 json_object_boolean_true_add(
11232 json
, "maxMedAdministrative");
11234 json_object_int_add(
11235 json
, "tableVersion",
11236 bgp_table_version(bgp
->rib
[afi
][safi
]));
11238 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
11239 json_object_int_add(json
, "ribCount", ents
);
11240 json_object_int_add(
11242 ents
* sizeof(struct bgp_dest
));
11244 ents
= bgp
->af_peer_count
[afi
][safi
];
11245 json_object_int_add(json
, "peerCount", ents
);
11246 json_object_int_add(json
, "peerMemory",
11247 ents
* sizeof(struct peer
));
11249 if ((ents
= listcount(bgp
->group
))) {
11250 json_object_int_add(
11251 json
, "peerGroupCount", ents
);
11252 json_object_int_add(
11253 json
, "peerGroupMemory",
11254 ents
* sizeof(struct
11258 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11259 BGP_CONFIG_DAMPENING
))
11260 json_object_boolean_true_add(
11261 json
, "dampeningEnabled");
11264 if (bgp_maxmed_onstartup_configured(bgp
)
11265 && bgp
->maxmed_active
)
11267 "Max-med on-startup active\n");
11268 if (bgp
->v_maxmed_admin
)
11270 "Max-med administrative active\n");
11273 "BGP table version %" PRIu64
11276 bgp
->rib
[afi
][safi
]));
11278 ents
= bgp_table_count(
11279 bgp
->rib
[afi
][safi
]);
11281 "RIB entries %ld, using %s of memory\n",
11291 /* Peer related usage */
11292 ents
= bgp
->af_peer_count
[afi
][safi
];
11294 "Peers %ld, using %s of memory\n",
11304 if ((ents
= listcount(bgp
->group
)))
11306 "Peer groups %ld, using %s of memory\n",
11316 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11317 BGP_CONFIG_DAMPENING
))
11319 "Dampening enabled.\n");
11322 vty_out(vty
, "\n");
11324 /* Subtract 8 here because 'Neighbor' is
11326 vty_out(vty
, "Neighbor");
11327 vty_out(vty
, "%*s",
11328 max_neighbor_width
- 8, " ");
11330 BGP_SHOW_SUMMARY_HEADER_FAILED
);
11335 paf
= peer_af_find(peer
, afi
, safi
);
11336 filter
= &peer
->filter
[afi
][safi
];
11339 /* Works for both failed & successful cases */
11340 if (peer_dynamic_neighbor(peer
))
11345 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11351 bgp_has_peer_failed(peer
, afi
, safi
)) {
11352 json_peer
= json_object_new_object();
11353 bgp_show_failed_summary(vty
, bgp
, peer
,
11354 json_peer
, 0, use_json
);
11355 } else if (!show_failed
) {
11356 if (show_established
11357 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11362 json_peer
= json_object_new_object();
11363 if (peer_dynamic_neighbor(peer
)) {
11364 json_object_boolean_true_add(json_peer
,
11368 if (peer
->hostname
)
11369 json_object_string_add(json_peer
, "hostname",
11372 if (peer
->domainname
)
11373 json_object_string_add(json_peer
, "domainname",
11376 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
11377 json_object_int_add(
11378 json_peer
, "localAs",
11379 peer
->change_local_as
11380 ? peer
->change_local_as
11382 json_object_int_add(json_peer
, "version", 4);
11383 json_object_int_add(json_peer
, "msgRcvd",
11384 PEER_TOTAL_RX(peer
));
11385 json_object_int_add(json_peer
, "msgSent",
11386 PEER_TOTAL_TX(peer
));
11388 atomic_size_t outq_count
, inq_count
;
11389 outq_count
= atomic_load_explicit(
11390 &peer
->obuf
->count
,
11391 memory_order_relaxed
);
11392 inq_count
= atomic_load_explicit(
11393 &peer
->ibuf
->count
,
11394 memory_order_relaxed
);
11396 json_object_int_add(json_peer
, "tableVersion",
11397 peer
->version
[afi
][safi
]);
11398 json_object_int_add(json_peer
, "outq",
11400 json_object_int_add(json_peer
, "inq",
11402 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
11403 use_json
, json_peer
);
11405 json_object_int_add(json_peer
, "pfxRcd",
11406 peer
->pcount
[afi
][pfx_rcd_safi
]);
11408 if (paf
&& PAF_SUBGRP(paf
))
11409 json_object_int_add(
11410 json_peer
, "pfxSnt",
11411 (PAF_SUBGRP(paf
))->scount
);
11413 json_object_int_add(json_peer
, "pfxSnt",
11416 /* BGP FSM state */
11417 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11418 || CHECK_FLAG(peer
->bgp
->flags
,
11419 BGP_FLAG_SHUTDOWN
))
11420 json_object_string_add(json_peer
,
11423 else if (peer
->afc_recv
[afi
][safi
])
11424 json_object_string_add(
11425 json_peer
, "state",
11426 lookup_msg(bgp_status_msg
,
11427 peer
->status
, NULL
));
11428 else if (CHECK_FLAG(
11430 PEER_STATUS_PREFIX_OVERFLOW
))
11431 json_object_string_add(json_peer
,
11435 json_object_string_add(
11436 json_peer
, "state",
11437 lookup_msg(bgp_status_msg
,
11438 peer
->status
, NULL
));
11440 /* BGP peer state */
11441 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11442 || CHECK_FLAG(peer
->bgp
->flags
,
11443 BGP_FLAG_SHUTDOWN
))
11444 json_object_string_add(json_peer
,
11447 else if (CHECK_FLAG(
11449 PEER_STATUS_PREFIX_OVERFLOW
))
11450 json_object_string_add(json_peer
,
11453 else if (CHECK_FLAG(peer
->flags
,
11454 PEER_FLAG_PASSIVE
))
11455 json_object_string_add(json_peer
,
11458 else if (CHECK_FLAG(peer
->sflags
,
11459 PEER_STATUS_NSF_WAIT
))
11460 json_object_string_add(json_peer
,
11463 else if (CHECK_FLAG(
11465 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11466 && (!bgp_inbound_policy_exists(peer
,
11468 || !bgp_outbound_policy_exists(
11470 json_object_string_add(json_peer
,
11474 json_object_string_add(
11475 json_peer
, "peerState", "OK");
11477 json_object_int_add(json_peer
, "connectionsEstablished",
11478 peer
->established
);
11479 json_object_int_add(json_peer
, "connectionsDropped",
11482 json_object_string_add(
11483 json_peer
, "desc", peer
->desc
);
11485 /* Avoid creating empty peer dicts in JSON */
11486 if (json_peer
== NULL
)
11490 json_object_string_add(json_peer
, "idType",
11492 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11493 json_object_string_add(json_peer
, "idType",
11495 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11496 json_object_string_add(json_peer
, "idType",
11498 json_object_object_add(json_peers
, peer
->host
,
11501 if (bgp_show_summary_is_peer_filtered(peer
, fpeer
,
11507 bgp_has_peer_failed(peer
, afi
, safi
)) {
11508 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11509 max_neighbor_width
,
11511 } else if (!show_failed
) {
11512 if (show_established
11513 && bgp_has_peer_failed(peer
, afi
, safi
)) {
11518 if ((count
- filtered_count
) == 1) {
11519 /* display headline before the first
11521 vty_out(vty
, "\n");
11523 /* Subtract 8 here because 'Neighbor' is
11525 vty_out(vty
, "Neighbor");
11526 vty_out(vty
, "%*s",
11527 max_neighbor_width
- 8, " ");
11530 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
11531 : BGP_SHOW_SUMMARY_HEADER_ALL
);
11534 memset(dn_flag
, '\0', sizeof(dn_flag
));
11535 if (peer_dynamic_neighbor(peer
)) {
11540 && CHECK_FLAG(bgp
->flags
,
11541 BGP_FLAG_SHOW_HOSTNAME
))
11542 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11546 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11548 /* pad the neighbor column with spaces */
11549 if (len
< max_neighbor_width
)
11550 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11553 atomic_size_t outq_count
, inq_count
;
11554 outq_count
= atomic_load_explicit(
11555 &peer
->obuf
->count
,
11556 memory_order_relaxed
);
11557 inq_count
= atomic_load_explicit(
11558 &peer
->ibuf
->count
,
11559 memory_order_relaxed
);
11563 "4 %10u %10u %9u %9u %8" PRIu64
11566 peer
->change_local_as
11567 ? peer
->change_local_as
11569 PEER_TOTAL_RX(peer
),
11570 PEER_TOTAL_TX(peer
),
11571 peer
->version
[afi
][safi
],
11572 inq_count
, outq_count
,
11573 peer_uptime(peer
->uptime
,
11578 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11580 peer
->as
, PEER_TOTAL_RX(peer
),
11581 PEER_TOTAL_TX(peer
),
11582 peer
->version
[afi
][safi
],
11583 inq_count
, outq_count
,
11584 peer_uptime(peer
->uptime
,
11589 if (peer_established(peer
)) {
11590 if (peer
->afc_recv
[afi
][safi
]) {
11593 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11594 && !bgp_inbound_policy_exists(
11596 vty_out(vty
, " %12s",
11605 vty_out(vty
, " NoNeg");
11608 if (paf
&& PAF_SUBGRP(paf
)) {
11611 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11612 && !bgp_outbound_policy_exists(
11614 vty_out(vty
, " %8s",
11623 vty_out(vty
, " NoNeg");
11626 if (CHECK_FLAG(peer
->flags
,
11627 PEER_FLAG_SHUTDOWN
)
11628 || CHECK_FLAG(peer
->bgp
->flags
,
11629 BGP_FLAG_SHUTDOWN
))
11630 vty_out(vty
, " Idle (Admin)");
11631 else if (CHECK_FLAG(
11633 PEER_STATUS_PREFIX_OVERFLOW
))
11634 vty_out(vty
, " Idle (PfxCt)");
11636 vty_out(vty
, " %12s",
11637 lookup_msg(bgp_status_msg
,
11638 peer
->status
, NULL
));
11640 vty_out(vty
, " %8u", 0);
11642 /* Make sure `Desc` column is the lastest in
11646 vty_out(vty
, " %s",
11647 bgp_peer_description_stripped(
11649 show_wide
? 64 : 20));
11651 vty_out(vty
, " N/A");
11652 vty_out(vty
, "\n");
11659 json_object_object_add(json
, "peers", json_peers
);
11660 json_object_int_add(json
, "failedPeers", failed_count
);
11661 json_object_int_add(json
, "displayedPeers",
11662 count
- filtered_count
);
11663 json_object_int_add(json
, "totalPeers", count
);
11664 json_object_int_add(json
, "dynamicPeers", dn_count
);
11667 bgp_show_bestpath_json(bgp
, json
);
11669 vty_json(vty
, json
);
11672 if (filtered_count
== count
)
11673 vty_out(vty
, "\n%% No matching neighbor\n");
11676 vty_out(vty
, "\nDisplayed neighbors %d",
11678 else if (as_type
!= AS_UNSPECIFIED
|| as
11679 || fpeer
|| show_established
)
11680 vty_out(vty
, "\nDisplayed neighbors %d",
11681 count
- filtered_count
);
11683 vty_out(vty
, "\nTotal number of neighbors %d\n",
11687 vty_out(vty
, "No %s neighbor is configured\n",
11688 get_afi_safi_str(afi
, safi
, false));
11692 vty_out(vty
, "* - dynamic neighbor\n");
11693 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11694 dn_count
, bgp
->dynamic_neighbors_limit
);
11698 return CMD_SUCCESS
;
11701 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11702 int safi
, struct peer
*fpeer
, int as_type
,
11703 as_t as
, uint16_t show_flags
)
11706 int afi_wildcard
= (afi
== AFI_MAX
);
11707 int safi_wildcard
= (safi
== SAFI_MAX
);
11708 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11709 bool nbr_output
= false;
11710 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11712 if (use_json
&& is_wildcard
)
11713 vty_out(vty
, "{\n");
11715 afi
= 1; /* AFI_IP */
11716 while (afi
< AFI_MAX
) {
11718 safi
= 1; /* SAFI_UNICAST */
11719 while (safi
< SAFI_MAX
) {
11720 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11725 * So limit output to those afi/safi
11727 * actualy have something interesting in
11732 vty_out(vty
, ",\n");
11736 vty_out(vty
, "\"%s\":",
11737 get_afi_safi_str(afi
,
11742 "\n%s Summary (%s):\n",
11743 get_afi_safi_str(afi
,
11749 bgp_show_summary(vty
, bgp
, afi
, safi
, fpeer
,
11750 as_type
, as
, show_flags
);
11753 if (!safi_wildcard
)
11761 if (use_json
&& is_wildcard
)
11762 vty_out(vty
, "}\n");
11763 else if (!nbr_output
) {
11765 vty_out(vty
, "{}\n");
11767 vty_out(vty
, "%% No BGP neighbors found in %s\n",
11772 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11774 const char *neighbor
,
11775 int as_type
, as_t as
,
11776 uint16_t show_flags
)
11778 struct listnode
*node
, *nnode
;
11780 struct peer
*fpeer
= NULL
;
11782 bool nbr_output
= false;
11783 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11786 vty_out(vty
, "{\n");
11788 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11792 vty_out(vty
, ",\n");
11796 vty_out(vty
, "\"%s\":",
11797 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11802 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11807 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11812 vty_out(vty
, "}\n");
11813 else if (!nbr_output
)
11814 vty_out(vty
, "%% BGP instance not found\n");
11817 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11818 safi_t safi
, const char *neighbor
, int as_type
,
11819 as_t as
, uint16_t show_flags
)
11822 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11823 struct peer
*fpeer
= NULL
;
11826 if (strmatch(name
, "all")) {
11827 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11830 return CMD_SUCCESS
;
11832 bgp
= bgp_lookup_by_name(name
);
11836 vty_out(vty
, "{}\n");
11839 "%% BGP instance not found\n");
11840 return CMD_WARNING
;
11844 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11847 return CMD_WARNING
;
11849 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
,
11850 as_type
, as
, show_flags
);
11851 return CMD_SUCCESS
;
11855 bgp
= bgp_get_default();
11859 fpeer
= peer_lookup_in_view(vty
, bgp
, neighbor
,
11862 return CMD_WARNING
;
11864 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, fpeer
, as_type
,
11868 vty_out(vty
, "{}\n");
11870 vty_out(vty
, "%% BGP instance not found\n");
11871 return CMD_WARNING
;
11874 return CMD_SUCCESS
;
11877 /* `show [ip] bgp summary' commands. */
11878 DEFPY(show_ip_bgp_summary
, show_ip_bgp_summary_cmd
,
11879 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR
11880 " [" BGP_SAFI_WITH_LABEL_CMD_STR
11881 "]] [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]",
11882 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11883 BGP_SAFI_WITH_LABEL_HELP_STR
11884 "Display the entries for all address families\n"
11885 "Summary of BGP neighbor status\n"
11886 "Show only sessions in Established state\n"
11887 "Show only sessions not in Established state\n"
11888 "Show only the specified neighbor session\n"
11889 "Neighbor to display information about\n"
11890 "Neighbor to display information about\n"
11891 "Neighbor on BGP configured interface\n"
11892 "Show only the specified remote AS sessions\n"
11894 "Internal (iBGP) AS sessions\n"
11895 "External (eBGP) AS sessions\n"
11896 "Shorten the information on BGP instances\n"
11897 "Increase table width for longer output\n" JSON_STR
)
11900 afi_t afi
= AFI_MAX
;
11901 safi_t safi
= SAFI_MAX
;
11902 as_t as
= 0; /* 0 means AS filter not set */
11903 int as_type
= AS_UNSPECIFIED
;
11904 uint16_t show_flags
= 0;
11908 /* show [ip] bgp */
11909 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11911 /* [<vrf> VIEWVRFNAME] */
11912 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11913 vrf
= argv
[idx
+ 1]->arg
;
11914 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11916 } else if (argv_find(argv
, argc
, "view", &idx
))
11917 /* [<view> VIEWVRFNAME] */
11918 vrf
= argv
[idx
+ 1]->arg
;
11919 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11920 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11921 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11924 if (argv_find(argv
, argc
, "failed", &idx
))
11925 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11927 if (argv_find(argv
, argc
, "established", &idx
))
11928 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11930 if (argv_find(argv
, argc
, "remote-as", &idx
)) {
11931 if (argv
[idx
+ 1]->arg
[0] == 'i')
11932 as_type
= AS_INTERNAL
;
11933 else if (argv
[idx
+ 1]->arg
[0] == 'e')
11934 as_type
= AS_EXTERNAL
;
11936 as
= (as_t
)atoi(argv
[idx
+ 1]->arg
);
11939 if (argv_find(argv
, argc
, "terse", &idx
))
11940 SET_FLAG(show_flags
, BGP_SHOW_OPT_TERSE
);
11942 if (argv_find(argv
, argc
, "wide", &idx
))
11943 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11945 if (argv_find(argv
, argc
, "json", &idx
))
11946 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11948 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, neighbor
, as_type
, as
,
11952 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11955 return get_afi_safi_json_str(afi
, safi
);
11957 return get_afi_safi_vty_str(afi
, safi
);
11961 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11962 afi_t afi
, safi_t safi
,
11963 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11964 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11965 bool use_json
, json_object
*json_pref
)
11968 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11969 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11971 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11972 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11973 json_object_string_add(json_pref
, "sendMode",
11974 "advertisedAndReceived");
11975 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11976 json_object_string_add(json_pref
, "sendMode",
11978 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11979 json_object_string_add(json_pref
, "sendMode",
11982 vty_out(vty
, " Send-mode: ");
11983 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11984 vty_out(vty
, "advertised");
11985 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11986 vty_out(vty
, "%sreceived",
11987 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11991 vty_out(vty
, "\n");
11996 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11997 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11999 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
12000 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
12001 json_object_string_add(json_pref
, "recvMode",
12002 "advertisedAndReceived");
12003 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
12004 json_object_string_add(json_pref
, "recvMode",
12006 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
12007 json_object_string_add(json_pref
, "recvMode",
12010 vty_out(vty
, " Receive-mode: ");
12011 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
12012 vty_out(vty
, "advertised");
12013 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
12014 vty_out(vty
, "%sreceived",
12015 CHECK_FLAG(p
->af_cap
[afi
][safi
],
12019 vty_out(vty
, "\n");
12024 static void bgp_show_neighnor_graceful_restart_flags(struct vty
*vty
,
12031 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
12032 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
12033 && (peer_established(p
))) {
12034 rbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV
);
12035 nbit
= CHECK_FLAG(p
->cap
, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV
);
12039 json_object_boolean_add(json
, "rBit", rbit
);
12040 json_object_boolean_add(json
, "nBit", nbit
);
12042 vty_out(vty
, "\n R bit: %s", rbit
? "True" : "False");
12043 vty_out(vty
, "\n N bit: %s\n", nbit
? "True" : "False");
12047 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
12051 const char *mode
= "NotApplicable";
12054 vty_out(vty
, "\n Remote GR Mode: ");
12056 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
12057 && (peer_established(peer
))) {
12059 if ((peer
->nsf_af_count
== 0)
12060 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
12064 } else if (peer
->nsf_af_count
== 0
12065 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
12069 } else if (peer
->nsf_af_count
!= 0
12070 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
12077 json_object_string_add(json
, "remoteGrMode", mode
);
12079 vty_out(vty
, "%s\n", mode
);
12082 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
12086 const char *mode
= "Invalid";
12089 vty_out(vty
, " Local GR Mode: ");
12091 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
12093 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
12095 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
12097 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
12098 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
12100 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
12102 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
12109 json_object_string_add(json
, "localGrMode", mode
);
12111 vty_out(vty
, "%s\n", mode
);
12114 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
12115 struct vty
*vty
, struct peer
*peer
, json_object
*json
)
12119 json_object
*json_afi_safi
= NULL
;
12120 json_object
*json_timer
= NULL
;
12121 json_object
*json_endofrib_status
= NULL
;
12122 bool eor_flag
= false;
12124 FOREACH_AFI_SAFI_NSF (afi
, safi
) {
12125 if (!peer
->afc
[afi
][safi
])
12128 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
) ||
12129 !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
12133 json_afi_safi
= json_object_new_object();
12134 json_endofrib_status
= json_object_new_object();
12135 json_timer
= json_object_new_object();
12138 if (peer
->eor_stime
[afi
][safi
] >= peer
->pkt_stime
[afi
][safi
])
12144 vty_out(vty
, " %s:\n",
12145 get_afi_safi_str(afi
, safi
, false));
12147 vty_out(vty
, " F bit: ");
12150 if (peer
->nsf
[afi
][safi
] &&
12151 CHECK_FLAG(peer
->af_cap
[afi
][safi
],
12152 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
12155 json_object_boolean_true_add(json_afi_safi
,
12158 vty_out(vty
, "True\n");
12161 json_object_boolean_false_add(json_afi_safi
,
12164 vty_out(vty
, "False\n");
12168 vty_out(vty
, " End-of-RIB sent: ");
12170 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
12171 PEER_STATUS_EOR_SEND
)) {
12173 json_object_boolean_true_add(
12174 json_endofrib_status
, "endOfRibSend");
12176 PRINT_EOR_JSON(eor_flag
);
12178 vty_out(vty
, "Yes\n");
12180 " End-of-RIB sent after update: ");
12182 PRINT_EOR(eor_flag
);
12186 json_object_boolean_false_add(
12187 json_endofrib_status
, "endOfRibSend");
12188 json_object_boolean_false_add(
12189 json_endofrib_status
,
12190 "endOfRibSentAfterUpdate");
12192 vty_out(vty
, "No\n");
12194 " End-of-RIB sent after update: ");
12195 vty_out(vty
, "No\n");
12200 vty_out(vty
, " End-of-RIB received: ");
12202 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
12203 PEER_STATUS_EOR_RECEIVED
)) {
12205 json_object_boolean_true_add(
12206 json_endofrib_status
, "endOfRibRecv");
12208 vty_out(vty
, "Yes\n");
12211 json_object_boolean_false_add(
12212 json_endofrib_status
, "endOfRibRecv");
12214 vty_out(vty
, "No\n");
12218 json_object_int_add(json_timer
, "stalePathTimer",
12219 peer
->bgp
->stalepath_time
);
12221 if (peer
->t_gr_stale
!= NULL
) {
12222 json_object_int_add(json_timer
,
12223 "stalePathTimerRemaining",
12224 thread_timer_remain_second(
12225 peer
->t_gr_stale
));
12228 /* Display Configured Selection
12229 * Deferral only when when
12230 * Gr mode is enabled.
12232 if (CHECK_FLAG(peer
->flags
,
12233 PEER_FLAG_GRACEFUL_RESTART
)) {
12234 json_object_int_add(json_timer
,
12235 "selectionDeferralTimer",
12236 peer
->bgp
->stalepath_time
);
12239 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
12242 json_object_int_add(
12244 "selectionDeferralTimerRemaining",
12245 thread_timer_remain_second(
12246 peer
->bgp
->gr_info
[afi
][safi
]
12247 .t_select_deferral
));
12250 vty_out(vty
, " Timers:\n");
12252 " Configured Stale Path Time(sec): %u\n",
12253 peer
->bgp
->stalepath_time
);
12255 if (peer
->t_gr_stale
!= NULL
)
12257 " Stale Path Remaining(sec): %ld\n",
12258 thread_timer_remain_second(
12259 peer
->t_gr_stale
));
12260 /* Display Configured Selection
12261 * Deferral only when when
12262 * Gr mode is enabled.
12264 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
12266 " Configured Selection Deferral Time(sec): %u\n",
12267 peer
->bgp
->select_defer_time
);
12269 if (peer
->bgp
->gr_info
[afi
][safi
].t_select_deferral
!=
12272 " Selection Deferral Time Remaining(sec): %ld\n",
12273 thread_timer_remain_second(
12274 peer
->bgp
->gr_info
[afi
][safi
]
12275 .t_select_deferral
));
12278 json_object_object_add(json_afi_safi
, "endOfRibStatus",
12279 json_endofrib_status
);
12280 json_object_object_add(json_afi_safi
, "timers",
12282 json_object_object_add(
12283 json
, get_afi_safi_str(afi
, safi
, true),
12289 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
12294 json_object
*json_timer
= NULL
;
12296 json_timer
= json_object_new_object();
12298 json_object_int_add(json_timer
, "configuredRestartTimer",
12299 p
->bgp
->restart_time
);
12301 json_object_int_add(json_timer
, "receivedRestartTimer",
12304 if (p
->t_gr_restart
!= NULL
)
12305 json_object_int_add(
12306 json_timer
, "restartTimerRemaining",
12307 thread_timer_remain_second(p
->t_gr_restart
));
12309 json_object_object_add(json
, "timers", json_timer
);
12312 vty_out(vty
, " Timers:\n");
12313 vty_out(vty
, " Configured Restart Time(sec): %u\n",
12314 p
->bgp
->restart_time
);
12316 vty_out(vty
, " Received Restart Time(sec): %u\n",
12318 if (p
->t_gr_restart
!= NULL
)
12319 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12320 thread_timer_remain_second(p
->t_gr_restart
));
12321 if (p
->t_gr_restart
!= NULL
) {
12322 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
12323 thread_timer_remain_second(p
->t_gr_restart
));
12328 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
12331 char dn_flag
[2] = {0};
12332 /* '*' + v6 address of neighbor */
12333 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
12335 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12340 json_object_string_addf(json
, "neighborAddr", "%pSU",
12343 vty_out(vty
, "BGP neighbor on %s: %pSU\n", p
->conf_if
,
12346 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
12350 json_object_string_add(json
, "neighborAddr",
12353 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
12356 /* more gr info in new format */
12357 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, json
);
12360 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
12361 safi_t safi
, bool use_json
,
12362 json_object
*json_neigh
)
12364 struct bgp_filter
*filter
;
12365 struct peer_af
*paf
;
12366 char orf_pfx_name
[BUFSIZ
];
12368 json_object
*json_af
= NULL
;
12369 json_object
*json_prefA
= NULL
;
12370 json_object
*json_prefB
= NULL
;
12371 json_object
*json_addr
= NULL
;
12372 json_object
*json_advmap
= NULL
;
12375 json_addr
= json_object_new_object();
12376 json_af
= json_object_new_object();
12377 filter
= &p
->filter
[afi
][safi
];
12379 if (peer_group_active(p
))
12380 json_object_string_add(json_addr
, "peerGroupMember",
12383 paf
= peer_af_find(p
, afi
, safi
);
12384 if (paf
&& PAF_SUBGRP(paf
)) {
12385 json_object_int_add(json_addr
, "updateGroupId",
12386 PAF_UPDGRP(paf
)->id
);
12387 json_object_int_add(json_addr
, "subGroupId",
12388 PAF_SUBGRP(paf
)->id
);
12389 json_object_int_add(json_addr
, "packetQueueLength",
12390 bpacket_queue_virtual_length(paf
));
12393 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12394 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12395 PEER_CAP_ORF_PREFIX_SM_RCV
)
12396 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12397 PEER_CAP_ORF_PREFIX_RM_ADV
)
12398 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12399 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12400 json_object_int_add(json_af
, "orfType",
12402 json_prefA
= json_object_new_object();
12403 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
12404 PEER_CAP_ORF_PREFIX_SM_ADV
,
12405 PEER_CAP_ORF_PREFIX_RM_ADV
,
12406 PEER_CAP_ORF_PREFIX_SM_RCV
,
12407 PEER_CAP_ORF_PREFIX_RM_RCV
,
12408 use_json
, json_prefA
);
12409 json_object_object_add(json_af
, "orfPrefixList",
12413 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12414 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12415 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12416 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12417 PEER_CAP_ORF_PREFIX_RM_ADV
)
12418 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12419 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12420 json_object_int_add(json_af
, "orfOldType",
12421 ORF_TYPE_PREFIX_OLD
);
12422 json_prefB
= json_object_new_object();
12423 bgp_show_peer_afi_orf_cap(
12424 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12425 PEER_CAP_ORF_PREFIX_RM_ADV
,
12426 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12427 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
12429 json_object_object_add(json_af
, "orfOldPrefixList",
12433 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12434 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12435 PEER_CAP_ORF_PREFIX_SM_RCV
)
12436 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12437 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12438 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12439 PEER_CAP_ORF_PREFIX_RM_ADV
)
12440 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12441 PEER_CAP_ORF_PREFIX_RM_RCV
)
12442 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12443 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12444 json_object_object_add(json_addr
, "afDependentCap",
12447 json_object_free(json_af
);
12449 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12450 p
->host
, afi
, safi
);
12451 orf_pfx_count
= prefix_bgp_show_prefix_list(
12452 NULL
, afi
, orf_pfx_name
, use_json
);
12454 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12455 PEER_STATUS_ORF_PREFIX_SEND
)
12456 || orf_pfx_count
) {
12457 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12458 PEER_STATUS_ORF_PREFIX_SEND
))
12459 json_object_boolean_true_add(json_neigh
,
12462 json_object_int_add(json_addr
, "orfRecvCounter",
12465 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12466 PEER_STATUS_ORF_WAIT_REFRESH
))
12467 json_object_string_add(
12468 json_addr
, "orfFirstUpdate",
12469 "deferredUntilORFOrRouteRefreshRecvd");
12471 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12472 PEER_FLAG_REFLECTOR_CLIENT
))
12473 json_object_boolean_true_add(json_addr
,
12474 "routeReflectorClient");
12475 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12476 PEER_FLAG_RSERVER_CLIENT
))
12477 json_object_boolean_true_add(json_addr
,
12478 "routeServerClient");
12479 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12480 json_object_boolean_true_add(json_addr
,
12481 "inboundSoftConfigPermit");
12483 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12484 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12485 json_object_boolean_true_add(
12487 "privateAsNumsAllReplacedInUpdatesToNbr");
12488 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12489 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12490 json_object_boolean_true_add(
12492 "privateAsNumsReplacedInUpdatesToNbr");
12493 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12494 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12495 json_object_boolean_true_add(
12497 "privateAsNumsAllRemovedInUpdatesToNbr");
12498 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12499 PEER_FLAG_REMOVE_PRIVATE_AS
))
12500 json_object_boolean_true_add(
12502 "privateAsNumsRemovedInUpdatesToNbr");
12504 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN
)) {
12505 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12506 PEER_FLAG_ALLOWAS_IN_ORIGIN
))
12507 json_object_boolean_true_add(json_addr
,
12508 "allowAsInOrigin");
12510 json_object_int_add(json_addr
, "allowAsInCount",
12511 p
->allowas_in
[afi
][safi
]);
12514 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12515 json_object_boolean_true_add(
12517 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12520 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12521 json_object_string_add(json_addr
,
12522 "overrideASNsInOutboundUpdates",
12523 "ifAspathEqualRemoteAs");
12525 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12526 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12527 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12528 json_object_boolean_true_add(json_addr
,
12529 "routerAlwaysNextHop");
12530 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12531 PEER_FLAG_AS_PATH_UNCHANGED
))
12532 json_object_boolean_true_add(
12533 json_addr
, "unchangedAsPathPropogatedToNbr");
12534 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12535 PEER_FLAG_NEXTHOP_UNCHANGED
))
12536 json_object_boolean_true_add(
12537 json_addr
, "unchangedNextHopPropogatedToNbr");
12538 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12539 json_object_boolean_true_add(
12540 json_addr
, "unchangedMedPropogatedToNbr");
12541 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12542 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12543 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12544 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12545 PEER_FLAG_SEND_COMMUNITY
)
12546 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12547 PEER_FLAG_SEND_EXT_COMMUNITY
))
12548 json_object_string_add(json_addr
,
12549 "commAttriSentToNbr",
12550 "extendedAndStandard");
12551 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12552 PEER_FLAG_SEND_EXT_COMMUNITY
))
12553 json_object_string_add(json_addr
,
12554 "commAttriSentToNbr",
12557 json_object_string_add(json_addr
,
12558 "commAttriSentToNbr",
12561 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12562 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12563 if (p
->default_rmap
[afi
][safi
].name
)
12564 json_object_string_add(
12565 json_addr
, "defaultRouteMap",
12566 p
->default_rmap
[afi
][safi
].name
);
12568 if (paf
&& PAF_SUBGRP(paf
)
12569 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12570 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12571 json_object_boolean_true_add(json_addr
,
12574 json_object_boolean_true_add(json_addr
,
12578 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12579 if (is_evpn_enabled())
12580 json_object_boolean_true_add(
12581 json_addr
, "advertiseAllVnis");
12584 if (filter
->plist
[FILTER_IN
].name
12585 || filter
->dlist
[FILTER_IN
].name
12586 || filter
->aslist
[FILTER_IN
].name
12587 || filter
->map
[RMAP_IN
].name
)
12588 json_object_boolean_true_add(json_addr
,
12589 "inboundPathPolicyConfig");
12590 if (filter
->plist
[FILTER_OUT
].name
12591 || filter
->dlist
[FILTER_OUT
].name
12592 || filter
->aslist
[FILTER_OUT
].name
12593 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12594 json_object_boolean_true_add(
12595 json_addr
, "outboundPathPolicyConfig");
12598 if (filter
->plist
[FILTER_IN
].name
)
12599 json_object_string_add(json_addr
,
12600 "incomingUpdatePrefixFilterList",
12601 filter
->plist
[FILTER_IN
].name
);
12602 if (filter
->plist
[FILTER_OUT
].name
)
12603 json_object_string_add(json_addr
,
12604 "outgoingUpdatePrefixFilterList",
12605 filter
->plist
[FILTER_OUT
].name
);
12607 /* distribute-list */
12608 if (filter
->dlist
[FILTER_IN
].name
)
12609 json_object_string_add(
12610 json_addr
, "incomingUpdateNetworkFilterList",
12611 filter
->dlist
[FILTER_IN
].name
);
12612 if (filter
->dlist
[FILTER_OUT
].name
)
12613 json_object_string_add(
12614 json_addr
, "outgoingUpdateNetworkFilterList",
12615 filter
->dlist
[FILTER_OUT
].name
);
12618 if (filter
->aslist
[FILTER_IN
].name
)
12619 json_object_string_add(json_addr
,
12620 "incomingUpdateAsPathFilterList",
12621 filter
->aslist
[FILTER_IN
].name
);
12622 if (filter
->aslist
[FILTER_OUT
].name
)
12623 json_object_string_add(json_addr
,
12624 "outgoingUpdateAsPathFilterList",
12625 filter
->aslist
[FILTER_OUT
].name
);
12628 if (filter
->map
[RMAP_IN
].name
)
12629 json_object_string_add(
12630 json_addr
, "routeMapForIncomingAdvertisements",
12631 filter
->map
[RMAP_IN
].name
);
12632 if (filter
->map
[RMAP_OUT
].name
)
12633 json_object_string_add(
12634 json_addr
, "routeMapForOutgoingAdvertisements",
12635 filter
->map
[RMAP_OUT
].name
);
12637 /* ebgp-requires-policy (inbound) */
12638 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12639 && !bgp_inbound_policy_exists(p
, filter
))
12640 json_object_string_add(
12641 json_addr
, "inboundEbgpRequiresPolicy",
12642 "Inbound updates discarded due to missing policy");
12644 /* ebgp-requires-policy (outbound) */
12645 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12646 && (!bgp_outbound_policy_exists(p
, filter
)))
12647 json_object_string_add(
12648 json_addr
, "outboundEbgpRequiresPolicy",
12649 "Outbound updates discarded due to missing policy");
12651 /* unsuppress-map */
12652 if (filter
->usmap
.name
)
12653 json_object_string_add(json_addr
,
12654 "selectiveUnsuppressRouteMap",
12655 filter
->usmap
.name
);
12657 /* advertise-map */
12658 if (filter
->advmap
.aname
) {
12659 json_advmap
= json_object_new_object();
12660 json_object_string_add(json_advmap
, "condition",
12661 filter
->advmap
.condition
12664 json_object_string_add(json_advmap
, "conditionMap",
12665 filter
->advmap
.cname
);
12666 json_object_string_add(json_advmap
, "advertiseMap",
12667 filter
->advmap
.aname
);
12668 json_object_string_add(
12669 json_advmap
, "advertiseStatus",
12670 filter
->advmap
.update_type
==
12671 UPDATE_TYPE_ADVERTISE
12674 json_object_object_add(json_addr
, "advertiseMap",
12678 /* Receive prefix count */
12679 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12680 p
->pcount
[afi
][safi
]);
12681 if (paf
&& PAF_SUBGRP(paf
))
12682 json_object_int_add(json_addr
, "sentPrefixCounter",
12683 (PAF_SUBGRP(paf
))->scount
);
12685 /* Maximum prefix */
12686 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12687 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12688 p
->pmax_out
[afi
][safi
]);
12690 /* Maximum prefix */
12691 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12692 json_object_int_add(json_addr
, "prefixAllowedMax",
12693 p
->pmax
[afi
][safi
]);
12694 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12695 PEER_FLAG_MAX_PREFIX_WARNING
))
12696 json_object_boolean_true_add(
12697 json_addr
, "prefixAllowedMaxWarning");
12698 json_object_int_add(json_addr
,
12699 "prefixAllowedWarningThresh",
12700 p
->pmax_threshold
[afi
][safi
]);
12701 if (p
->pmax_restart
[afi
][safi
])
12702 json_object_int_add(
12704 "prefixAllowedRestartIntervalMsecs",
12705 p
->pmax_restart
[afi
][safi
] * 60000);
12707 json_object_object_add(json_neigh
,
12708 get_afi_safi_str(afi
, safi
, true),
12712 filter
= &p
->filter
[afi
][safi
];
12714 vty_out(vty
, " For address family: %s\n",
12715 get_afi_safi_str(afi
, safi
, false));
12717 if (peer_group_active(p
))
12718 vty_out(vty
, " %s peer-group member\n",
12721 paf
= peer_af_find(p
, afi
, safi
);
12722 if (paf
&& PAF_SUBGRP(paf
)) {
12723 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12724 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12725 vty_out(vty
, " Packet Queue length %d\n",
12726 bpacket_queue_virtual_length(paf
));
12728 vty_out(vty
, " Not part of any update group\n");
12730 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12731 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12732 PEER_CAP_ORF_PREFIX_SM_RCV
)
12733 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12734 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12735 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12736 PEER_CAP_ORF_PREFIX_RM_ADV
)
12737 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12738 PEER_CAP_ORF_PREFIX_RM_RCV
)
12739 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12740 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12741 vty_out(vty
, " AF-dependant capabilities:\n");
12743 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12744 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12745 PEER_CAP_ORF_PREFIX_SM_RCV
)
12746 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12747 PEER_CAP_ORF_PREFIX_RM_ADV
)
12748 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12749 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12751 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12753 bgp_show_peer_afi_orf_cap(
12754 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12755 PEER_CAP_ORF_PREFIX_RM_ADV
,
12756 PEER_CAP_ORF_PREFIX_SM_RCV
,
12757 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12759 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12760 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12761 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12762 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12763 PEER_CAP_ORF_PREFIX_RM_ADV
)
12764 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12765 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12767 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12768 ORF_TYPE_PREFIX_OLD
);
12769 bgp_show_peer_afi_orf_cap(
12770 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12771 PEER_CAP_ORF_PREFIX_RM_ADV
,
12772 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12773 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12776 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12777 p
->host
, afi
, safi
);
12778 orf_pfx_count
= prefix_bgp_show_prefix_list(
12779 NULL
, afi
, orf_pfx_name
, use_json
);
12781 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12782 PEER_STATUS_ORF_PREFIX_SEND
)
12783 || orf_pfx_count
) {
12784 vty_out(vty
, " Outbound Route Filter (ORF):");
12785 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12786 PEER_STATUS_ORF_PREFIX_SEND
))
12787 vty_out(vty
, " sent;");
12789 vty_out(vty
, " received (%d entries)",
12791 vty_out(vty
, "\n");
12793 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12794 PEER_STATUS_ORF_WAIT_REFRESH
))
12796 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12798 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12799 PEER_FLAG_REFLECTOR_CLIENT
))
12800 vty_out(vty
, " Route-Reflector Client\n");
12801 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12802 PEER_FLAG_RSERVER_CLIENT
))
12803 vty_out(vty
, " Route-Server Client\n");
12804 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12806 " Inbound soft reconfiguration allowed\n");
12808 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12809 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12811 " Private AS numbers (all) replaced in updates to this neighbor\n");
12812 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12813 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12815 " Private AS numbers replaced in updates to this neighbor\n");
12816 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12817 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12819 " Private AS numbers (all) removed in updates to this neighbor\n");
12820 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12821 PEER_FLAG_REMOVE_PRIVATE_AS
))
12823 " Private AS numbers removed in updates to this neighbor\n");
12825 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN
)) {
12826 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12827 PEER_FLAG_ALLOWAS_IN_ORIGIN
))
12829 " Local AS allowed as path origin\n");
12832 " Local AS allowed in path, %d occurrences\n",
12833 p
->allowas_in
[afi
][safi
]);
12836 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12837 vty_out(vty
, " %s\n",
12838 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12839 ->human_description
);
12841 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12843 " Override ASNs in outbound updates if aspath equals remote-as\n");
12845 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12846 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12847 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12848 vty_out(vty
, " NEXT_HOP is always this router\n");
12849 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12850 PEER_FLAG_AS_PATH_UNCHANGED
))
12852 " AS_PATH is propagated unchanged to this neighbor\n");
12853 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12854 PEER_FLAG_NEXTHOP_UNCHANGED
))
12856 " NEXT_HOP is propagated unchanged to this neighbor\n");
12857 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12859 " MED is propagated unchanged to this neighbor\n");
12860 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12861 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12862 PEER_FLAG_SEND_EXT_COMMUNITY
)
12863 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12864 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12866 " Community attribute sent to this neighbor");
12867 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12868 PEER_FLAG_SEND_COMMUNITY
)
12869 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12870 PEER_FLAG_SEND_EXT_COMMUNITY
)
12871 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12872 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12873 vty_out(vty
, "(all)\n");
12874 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12875 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12876 vty_out(vty
, "(large)\n");
12877 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12878 PEER_FLAG_SEND_EXT_COMMUNITY
))
12879 vty_out(vty
, "(extended)\n");
12881 vty_out(vty
, "(standard)\n");
12883 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12884 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12885 vty_out(vty
, " Default information originate,");
12887 if (p
->default_rmap
[afi
][safi
].name
)
12888 vty_out(vty
, " default route-map %s%s,",
12889 p
->default_rmap
[afi
][safi
].map
? "*"
12891 p
->default_rmap
[afi
][safi
].name
);
12892 if (paf
&& PAF_SUBGRP(paf
)
12893 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12894 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12895 vty_out(vty
, " default sent\n");
12897 vty_out(vty
, " default not sent\n");
12900 /* advertise-vni-all */
12901 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12902 if (is_evpn_enabled())
12903 vty_out(vty
, " advertise-all-vni\n");
12906 if (filter
->plist
[FILTER_IN
].name
12907 || filter
->dlist
[FILTER_IN
].name
12908 || filter
->aslist
[FILTER_IN
].name
12909 || filter
->map
[RMAP_IN
].name
)
12910 vty_out(vty
, " Inbound path policy configured\n");
12911 if (filter
->plist
[FILTER_OUT
].name
12912 || filter
->dlist
[FILTER_OUT
].name
12913 || filter
->aslist
[FILTER_OUT
].name
12914 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12915 vty_out(vty
, " Outbound path policy configured\n");
12918 if (filter
->plist
[FILTER_IN
].name
)
12920 " Incoming update prefix filter list is %s%s\n",
12921 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12922 filter
->plist
[FILTER_IN
].name
);
12923 if (filter
->plist
[FILTER_OUT
].name
)
12925 " Outgoing update prefix filter list is %s%s\n",
12926 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12927 filter
->plist
[FILTER_OUT
].name
);
12929 /* distribute-list */
12930 if (filter
->dlist
[FILTER_IN
].name
)
12932 " Incoming update network filter list is %s%s\n",
12933 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12934 filter
->dlist
[FILTER_IN
].name
);
12935 if (filter
->dlist
[FILTER_OUT
].name
)
12937 " Outgoing update network filter list is %s%s\n",
12938 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12939 filter
->dlist
[FILTER_OUT
].name
);
12942 if (filter
->aslist
[FILTER_IN
].name
)
12944 " Incoming update AS path filter list is %s%s\n",
12945 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12946 filter
->aslist
[FILTER_IN
].name
);
12947 if (filter
->aslist
[FILTER_OUT
].name
)
12949 " Outgoing update AS path filter list is %s%s\n",
12950 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12951 filter
->aslist
[FILTER_OUT
].name
);
12954 if (filter
->map
[RMAP_IN
].name
)
12956 " Route map for incoming advertisements is %s%s\n",
12957 filter
->map
[RMAP_IN
].map
? "*" : "",
12958 filter
->map
[RMAP_IN
].name
);
12959 if (filter
->map
[RMAP_OUT
].name
)
12961 " Route map for outgoing advertisements is %s%s\n",
12962 filter
->map
[RMAP_OUT
].map
? "*" : "",
12963 filter
->map
[RMAP_OUT
].name
);
12965 /* ebgp-requires-policy (inbound) */
12966 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12967 && !bgp_inbound_policy_exists(p
, filter
))
12969 " Inbound updates discarded due to missing policy\n");
12971 /* ebgp-requires-policy (outbound) */
12972 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12973 && !bgp_outbound_policy_exists(p
, filter
))
12975 " Outbound updates discarded due to missing policy\n");
12977 /* unsuppress-map */
12978 if (filter
->usmap
.name
)
12980 " Route map for selective unsuppress is %s%s\n",
12981 filter
->usmap
.map
? "*" : "",
12982 filter
->usmap
.name
);
12984 /* advertise-map */
12985 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12987 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12988 filter
->advmap
.condition
? "EXIST"
12990 filter
->advmap
.cmap
? "*" : "",
12991 filter
->advmap
.cname
,
12992 filter
->advmap
.amap
? "*" : "",
12993 filter
->advmap
.aname
,
12994 filter
->advmap
.update_type
==
12995 UPDATE_TYPE_ADVERTISE
12999 /* Receive prefix count */
13000 vty_out(vty
, " %u accepted prefixes\n",
13001 p
->pcount
[afi
][safi
]);
13003 /* maximum-prefix-out */
13004 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
13005 PEER_FLAG_MAX_PREFIX_OUT
))
13007 " Maximum allowed prefixes sent %u\n",
13008 p
->pmax_out
[afi
][safi
]);
13010 /* Maximum prefix */
13011 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
13013 " Maximum prefixes allowed %u%s\n",
13014 p
->pmax
[afi
][safi
],
13015 CHECK_FLAG(p
->af_flags
[afi
][safi
],
13016 PEER_FLAG_MAX_PREFIX_WARNING
)
13017 ? " (warning-only)"
13019 vty_out(vty
, " Threshold for warning message %d%%",
13020 p
->pmax_threshold
[afi
][safi
]);
13021 if (p
->pmax_restart
[afi
][safi
])
13022 vty_out(vty
, ", restart interval %d min",
13023 p
->pmax_restart
[afi
][safi
]);
13024 vty_out(vty
, "\n");
13027 vty_out(vty
, "\n");
13031 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
13035 char timebuf
[BGP_UPTIME_LEN
];
13041 json_object
*json_neigh
= NULL
;
13043 uint32_t sync_tcp_mss
;
13048 json_neigh
= json_object_new_object();
13050 memset(dn_flag
, '\0', sizeof(dn_flag
));
13051 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
13055 if (p
->conf_if
) /* Configured interface name. */
13056 vty_out(vty
, "BGP neighbor on %s: %pSU, ", p
->conf_if
,
13058 else /* Configured IP address. */
13059 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
13064 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
13065 json_object_string_add(json_neigh
, "bgpNeighborAddr",
13067 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
13068 json_object_string_addf(json_neigh
, "bgpNeighborAddr",
13071 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
13073 if (p
->change_local_as
)
13074 json_object_int_add(json_neigh
, "localAs",
13075 p
->change_local_as
);
13077 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
13079 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
13080 json_object_boolean_true_add(json_neigh
,
13081 "localAsNoPrepend");
13083 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
13084 json_object_boolean_true_add(json_neigh
,
13085 "localAsReplaceAs");
13087 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
13088 || (p
->as_type
== AS_INTERNAL
))
13089 vty_out(vty
, "remote AS %u, ", p
->as
);
13091 vty_out(vty
, "remote AS Unspecified, ");
13092 vty_out(vty
, "local AS %u%s%s, ",
13093 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
13094 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
13097 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
13101 /* peer type internal or confed-internal */
13102 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
13104 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13105 json_object_boolean_true_add(
13106 json_neigh
, "nbrConfedInternalLink");
13108 json_object_boolean_true_add(json_neigh
,
13109 "nbrInternalLink");
13111 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13112 vty_out(vty
, "confed-internal link\n");
13114 vty_out(vty
, "internal link\n");
13116 /* peer type external or confed-external */
13117 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
13119 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
13120 json_object_boolean_true_add(
13121 json_neigh
, "nbrConfedExternalLink");
13123 json_object_boolean_true_add(json_neigh
,
13124 "nbrExternalLink");
13126 if (bgp_confederation_peers_check(bgp
, p
->as
))
13127 vty_out(vty
, "confed-external link\n");
13129 vty_out(vty
, "external link\n");
13133 json_object_boolean_true_add(json_neigh
,
13134 "nbrUnspecifiedLink");
13136 vty_out(vty
, "unspecified link\n");
13141 json_object_string_add(json_neigh
, "localRole",
13142 bgp_get_name_by_role(p
->local_role
));
13143 json_object_string_add(json_neigh
, "remoteRole",
13144 bgp_get_name_by_role(p
->remote_role
));
13146 vty_out(vty
, " Local Role: %s\n",
13147 bgp_get_name_by_role(p
->local_role
));
13148 vty_out(vty
, " Remote Role: %s\n",
13149 bgp_get_name_by_role(p
->remote_role
));
13156 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
13158 vty_out(vty
, " Description: %s\n", p
->desc
);
13163 json_object_string_add(json_neigh
, "hostname",
13167 json_object_string_add(json_neigh
, "domainname",
13170 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
13171 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
13174 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
13178 json_object_string_add(json_neigh
, "hostname",
13185 json_object_string_add(json_neigh
, "peerGroup",
13189 struct prefix prefix
, *range
= NULL
;
13191 if (sockunion2hostprefix(&(p
->su
), &prefix
))
13192 range
= peer_group_lookup_dynamic_neighbor_range(
13193 p
->group
, &prefix
);
13196 json_object_string_addf(
13198 "peerSubnetRangeGroup", "%pFX",
13204 " Member of peer-group %s for session parameters\n",
13208 struct prefix prefix
, *range
= NULL
;
13210 if (sockunion2hostprefix(&(p
->su
), &prefix
))
13211 range
= peer_group_lookup_dynamic_neighbor_range(
13212 p
->group
, &prefix
);
13216 " Belongs to the subnet range group: %pFX\n",
13224 /* Administrative shutdown. */
13225 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13226 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13227 json_object_boolean_true_add(json_neigh
,
13231 json_object_int_add(json_neigh
, "bgpVersion", 4);
13232 json_object_string_addf(json_neigh
, "remoteRouterId", "%pI4",
13234 json_object_string_addf(json_neigh
, "localRouterId", "%pI4",
13237 /* Confederation */
13238 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13239 && bgp_confederation_peers_check(bgp
, p
->as
))
13240 json_object_boolean_true_add(json_neigh
,
13244 json_object_string_add(
13245 json_neigh
, "bgpState",
13246 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13248 if (peer_established(p
)) {
13251 uptime
= monotime(NULL
);
13252 uptime
-= p
->uptime
;
13253 epoch_tbuf
= time(NULL
) - uptime
;
13255 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
13257 json_object_string_add(json_neigh
, "bgpTimerUpString",
13258 peer_uptime(p
->uptime
, timebuf
,
13261 json_object_int_add(json_neigh
,
13262 "bgpTimerUpEstablishedEpoch",
13266 else if (p
->status
== Active
) {
13267 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13268 json_object_string_add(json_neigh
, "bgpStateIs",
13270 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13271 json_object_string_add(json_neigh
, "bgpStateIs",
13279 uptime
= monotime(NULL
);
13280 uptime
-= p
->readtime
;
13281 gmtime_r(&uptime
, &tm
);
13283 json_object_int_add(json_neigh
, "bgpTimerLastRead",
13284 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13285 + (tm
.tm_hour
* 3600000));
13287 uptime
= monotime(NULL
);
13288 uptime
-= p
->last_write
;
13289 gmtime_r(&uptime
, &tm
);
13291 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
13292 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13293 + (tm
.tm_hour
* 3600000));
13295 uptime
= monotime(NULL
);
13296 uptime
-= p
->update_time
;
13297 gmtime_r(&uptime
, &tm
);
13299 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
13300 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
13301 + (tm
.tm_hour
* 3600000));
13303 /* Configured timer values. */
13304 json_object_int_add(json_neigh
,
13305 "bgpTimerConfiguredHoldTimeMsecs",
13306 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13307 ? p
->holdtime
* 1000
13308 : bgp
->default_holdtime
* 1000);
13309 json_object_int_add(json_neigh
,
13310 "bgpTimerConfiguredKeepAliveIntervalMsecs",
13311 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13312 ? p
->keepalive
* 1000
13313 : bgp
->default_keepalive
* 1000);
13314 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
13315 p
->v_holdtime
* 1000);
13316 json_object_int_add(json_neigh
,
13317 "bgpTimerKeepAliveIntervalMsecs",
13318 p
->v_keepalive
* 1000);
13319 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
13320 json_object_int_add(json_neigh
,
13321 "bgpTimerDelayOpenTimeMsecs",
13322 p
->v_delayopen
* 1000);
13325 /* Configured and Synced tcp-mss value for peer */
13326 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13327 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13328 json_object_int_add(json_neigh
, "bgpTcpMssConfigured",
13330 json_object_int_add(json_neigh
, "bgpTcpMssSynced",
13334 /* Extended Optional Parameters Length for BGP OPEN Message */
13335 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
13336 json_object_boolean_true_add(
13337 json_neigh
, "extendedOptionalParametersLength");
13339 json_object_boolean_false_add(
13340 json_neigh
, "extendedOptionalParametersLength");
13342 /* Conditional advertisements */
13343 json_object_int_add(
13345 "bgpTimerConfiguredConditionalAdvertisementsSec",
13346 bgp
->condition_check_period
);
13347 if (thread_is_scheduled(bgp
->t_condition_check
))
13348 json_object_int_add(
13350 "bgpTimerUntilConditionalAdvertisementsSec",
13351 thread_timer_remain_second(
13352 bgp
->t_condition_check
));
13354 /* Administrative shutdown. */
13355 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
13356 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13357 vty_out(vty
, " Administratively shut down\n");
13360 vty_out(vty
, " BGP version 4");
13361 vty_out(vty
, ", remote router ID %pI4", &p
->remote_id
);
13362 vty_out(vty
, ", local router ID %pI4\n", &bgp
->router_id
);
13364 /* Confederation */
13365 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
13366 && bgp_confederation_peers_check(bgp
, p
->as
))
13368 " Neighbor under common administration\n");
13371 vty_out(vty
, " BGP state = %s",
13372 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
13374 if (peer_established(p
))
13375 vty_out(vty
, ", up for %8s",
13376 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
13379 else if (p
->status
== Active
) {
13380 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
13381 vty_out(vty
, " (passive)");
13382 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
13383 vty_out(vty
, " (NSF passive)");
13385 vty_out(vty
, "\n");
13388 vty_out(vty
, " Last read %s",
13389 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
13391 vty_out(vty
, ", Last write %s\n",
13392 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
13395 /* Configured timer values. */
13397 " Hold time is %d seconds, keepalive interval is %d seconds\n",
13398 p
->v_holdtime
, p
->v_keepalive
);
13399 vty_out(vty
, " Configured hold time is %d seconds",
13400 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13402 : bgp
->default_holdtime
);
13403 vty_out(vty
, ", keepalive interval is %d seconds\n",
13404 CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)
13406 : bgp
->default_keepalive
);
13407 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
13409 " Configured DelayOpenTime is %d seconds\n",
13412 /* Configured and synced tcp-mss value for peer */
13413 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TCP_MSS
)) {
13414 sync_tcp_mss
= sockopt_tcp_mss_get(p
->fd
);
13415 vty_out(vty
, " Configured tcp-mss is %d", p
->tcp_mss
);
13416 vty_out(vty
, ", synced tcp-mss is %d\n", sync_tcp_mss
);
13419 /* Extended Optional Parameters Length for BGP OPEN Message */
13420 if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p
))
13422 " Extended Optional Parameters Length is enabled\n");
13424 /* Conditional advertisements */
13426 " Configured conditional advertisements interval is %d seconds\n",
13427 bgp
->condition_check_period
);
13428 if (thread_is_scheduled(bgp
->t_condition_check
))
13430 " Time until conditional advertisements begin is %lu seconds\n",
13431 thread_timer_remain_second(
13432 bgp
->t_condition_check
));
13435 if (peer_established(p
) &&
13436 (p
->cap
|| peer_afc_advertised(p
) || peer_afc_received(p
))) {
13438 json_object
*json_cap
= NULL
;
13440 json_cap
= json_object_new_object();
13443 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13444 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13445 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
) &&
13446 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13447 json_object_string_add(
13448 json_cap
, "4byteAs",
13449 "advertisedAndReceived");
13450 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13451 json_object_string_add(json_cap
,
13454 else if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13455 json_object_string_add(json_cap
,
13460 /* Extended Message Support */
13461 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
) &&
13462 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
))
13463 json_object_string_add(json_cap
,
13465 "advertisedAndReceived");
13466 else if (CHECK_FLAG(p
->cap
,
13467 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13468 json_object_string_add(json_cap
,
13471 else if (CHECK_FLAG(p
->cap
,
13472 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13473 json_object_string_add(json_cap
,
13478 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13479 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13480 json_object
*json_add
= NULL
;
13481 const char *print_store
;
13483 json_add
= json_object_new_object();
13485 FOREACH_AFI_SAFI (afi
, safi
) {
13486 json_object
*json_sub
= NULL
;
13487 json_sub
= json_object_new_object();
13488 print_store
= get_afi_safi_str(
13492 p
->af_cap
[afi
][safi
],
13493 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13495 p
->af_cap
[afi
][safi
],
13496 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13500 PEER_CAP_ADDPATH_AF_TX_ADV
) &&
13504 PEER_CAP_ADDPATH_AF_TX_RCV
))
13505 json_object_boolean_true_add(
13507 "txAdvertisedAndReceived");
13512 PEER_CAP_ADDPATH_AF_TX_ADV
))
13513 json_object_boolean_true_add(
13520 PEER_CAP_ADDPATH_AF_TX_RCV
))
13521 json_object_boolean_true_add(
13527 p
->af_cap
[afi
][safi
],
13528 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13530 p
->af_cap
[afi
][safi
],
13531 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13535 PEER_CAP_ADDPATH_AF_RX_ADV
) &&
13539 PEER_CAP_ADDPATH_AF_RX_RCV
))
13540 json_object_boolean_true_add(
13542 "rxAdvertisedAndReceived");
13547 PEER_CAP_ADDPATH_AF_RX_ADV
))
13548 json_object_boolean_true_add(
13555 PEER_CAP_ADDPATH_AF_RX_RCV
))
13556 json_object_boolean_true_add(
13562 p
->af_cap
[afi
][safi
],
13563 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13565 p
->af_cap
[afi
][safi
],
13566 PEER_CAP_ADDPATH_AF_TX_RCV
) ||
13568 p
->af_cap
[afi
][safi
],
13569 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
13571 p
->af_cap
[afi
][safi
],
13572 PEER_CAP_ADDPATH_AF_RX_RCV
))
13573 json_object_object_add(
13574 json_add
, print_store
,
13577 json_object_free(json_sub
);
13580 json_object_object_add(json_cap
, "addPath",
13585 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
13586 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
13587 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
) &&
13588 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
13589 json_object_string_add(
13590 json_cap
, "dynamic",
13591 "advertisedAndReceived");
13592 else if (CHECK_FLAG(p
->cap
,
13593 PEER_CAP_DYNAMIC_ADV
))
13594 json_object_string_add(json_cap
,
13597 else if (CHECK_FLAG(p
->cap
,
13598 PEER_CAP_DYNAMIC_RCV
))
13599 json_object_string_add(json_cap
,
13605 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
13606 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
13607 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
) &&
13608 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13609 json_object_string_add(
13611 "advertisedAndReceived");
13612 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
13613 json_object_string_add(json_cap
, "role",
13615 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
13616 json_object_string_add(json_cap
, "role",
13620 /* Extended nexthop */
13621 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
13622 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13623 json_object
*json_nxt
= NULL
;
13624 const char *print_store
;
13627 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
) &&
13628 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13629 json_object_string_add(
13630 json_cap
, "extendedNexthop",
13631 "advertisedAndReceived");
13632 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
13633 json_object_string_add(
13634 json_cap
, "extendedNexthop",
13636 else if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
13637 json_object_string_add(
13638 json_cap
, "extendedNexthop",
13641 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
13642 json_nxt
= json_object_new_object();
13644 for (safi
= SAFI_UNICAST
;
13645 safi
< SAFI_MAX
; safi
++) {
13649 PEER_CAP_ENHE_AF_RCV
)) {
13655 json_object_string_add(
13658 "recieved"); /* misspelled for compatibility */
13661 json_object_object_add(
13663 "extendedNexthopFamililesByPeer",
13668 /* Long-lived Graceful Restart */
13669 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
13670 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
13671 json_object
*json_llgr
= NULL
;
13672 const char *afi_safi_str
;
13674 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
) &&
13675 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13676 json_object_string_add(
13678 "longLivedGracefulRestart",
13679 "advertisedAndReceived");
13680 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
13681 json_object_string_add(
13683 "longLivedGracefulRestart",
13685 else if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
13686 json_object_string_add(
13688 "longLivedGracefulRestart",
13691 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
13692 json_llgr
= json_object_new_object();
13694 FOREACH_AFI_SAFI (afi
, safi
) {
13698 PEER_CAP_ENHE_AF_RCV
)) {
13704 json_object_string_add(
13710 json_object_object_add(
13712 "longLivedGracefulRestartByPeer",
13717 /* Route Refresh */
13718 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
13719 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
13720 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
13721 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) &&
13722 (CHECK_FLAG(p
->cap
,
13723 PEER_CAP_REFRESH_NEW_RCV
) ||
13725 PEER_CAP_REFRESH_OLD_RCV
))) {
13728 PEER_CAP_REFRESH_OLD_RCV
) &&
13731 PEER_CAP_REFRESH_NEW_RCV
))
13732 json_object_string_add(
13735 "advertisedAndReceivedOldNew");
13739 PEER_CAP_REFRESH_OLD_RCV
))
13740 json_object_string_add(
13743 "advertisedAndReceivedOld");
13745 json_object_string_add(
13748 "advertisedAndReceivedNew");
13750 } else if (CHECK_FLAG(p
->cap
,
13751 PEER_CAP_REFRESH_ADV
))
13752 json_object_string_add(json_cap
,
13755 else if (CHECK_FLAG(p
->cap
,
13756 PEER_CAP_REFRESH_NEW_RCV
) ||
13758 PEER_CAP_REFRESH_OLD_RCV
))
13759 json_object_string_add(json_cap
,
13764 /* Enhanced Route Refresh */
13765 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
13766 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
13767 if (CHECK_FLAG(p
->cap
,
13768 PEER_CAP_ENHANCED_RR_ADV
) &&
13770 PEER_CAP_ENHANCED_RR_RCV
))
13771 json_object_string_add(
13773 "enhancedRouteRefresh",
13774 "advertisedAndReceived");
13775 else if (CHECK_FLAG(p
->cap
,
13776 PEER_CAP_ENHANCED_RR_ADV
))
13777 json_object_string_add(
13779 "enhancedRouteRefresh",
13781 else if (CHECK_FLAG(p
->cap
,
13782 PEER_CAP_ENHANCED_RR_RCV
))
13783 json_object_string_add(
13785 "enhancedRouteRefresh",
13789 /* Multiprotocol Extensions */
13790 json_object
*json_multi
= NULL
;
13792 json_multi
= json_object_new_object();
13794 FOREACH_AFI_SAFI (afi
, safi
) {
13795 if (p
->afc_adv
[afi
][safi
] ||
13796 p
->afc_recv
[afi
][safi
]) {
13797 json_object
*json_exten
= NULL
;
13798 json_exten
= json_object_new_object();
13800 if (p
->afc_adv
[afi
][safi
] &&
13801 p
->afc_recv
[afi
][safi
])
13802 json_object_boolean_true_add(
13804 "advertisedAndReceived");
13805 else if (p
->afc_adv
[afi
][safi
])
13806 json_object_boolean_true_add(
13809 else if (p
->afc_recv
[afi
][safi
])
13810 json_object_boolean_true_add(
13811 json_exten
, "received");
13813 json_object_object_add(
13815 get_afi_safi_str(afi
, safi
,
13820 json_object_object_add(json_cap
,
13821 "multiprotocolExtensions",
13824 /* Hostname capabilities */
13825 json_object
*json_hname
= NULL
;
13827 json_hname
= json_object_new_object();
13829 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13830 json_object_string_add(
13831 json_hname
, "advHostName",
13832 bgp
->peer_self
->hostname
13833 ? bgp
->peer_self
->hostname
13835 json_object_string_add(
13836 json_hname
, "advDomainName",
13837 bgp
->peer_self
->domainname
13838 ? bgp
->peer_self
->domainname
13843 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13844 json_object_string_add(
13845 json_hname
, "rcvHostName",
13846 p
->hostname
? p
->hostname
: "n/a");
13847 json_object_string_add(
13848 json_hname
, "rcvDomainName",
13849 p
->domainname
? p
->domainname
: "n/a");
13852 json_object_object_add(json_cap
, "hostName",
13855 /* Graceful Restart */
13856 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
13857 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
13858 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
) &&
13859 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
13860 json_object_string_add(
13861 json_cap
, "gracefulRestart",
13862 "advertisedAndReceived");
13863 else if (CHECK_FLAG(p
->cap
,
13864 PEER_CAP_RESTART_ADV
))
13865 json_object_string_add(
13867 "gracefulRestartCapability",
13869 else if (CHECK_FLAG(p
->cap
,
13870 PEER_CAP_RESTART_RCV
))
13871 json_object_string_add(
13873 "gracefulRestartCapability",
13876 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13877 int restart_af_count
= 0;
13878 json_object
*json_restart
= NULL
;
13879 json_restart
= json_object_new_object();
13881 json_object_int_add(
13883 "gracefulRestartRemoteTimerMsecs",
13884 p
->v_gr_restart
* 1000);
13886 FOREACH_AFI_SAFI (afi
, safi
) {
13890 PEER_CAP_RESTART_AF_RCV
)) {
13891 json_object
*json_sub
=
13894 json_object_new_object();
13900 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13901 json_object_boolean_true_add(
13904 restart_af_count
++;
13905 json_object_object_add(
13914 if (!restart_af_count
) {
13915 json_object_string_add(
13917 "addressFamiliesByPeer",
13919 json_object_free(json_restart
);
13921 json_object_object_add(
13923 "addressFamiliesByPeer",
13927 json_object_object_add(
13928 json_neigh
, "neighborCapabilities", json_cap
);
13930 vty_out(vty
, " Neighbor capabilities:\n");
13933 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
) ||
13934 CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13935 vty_out(vty
, " 4 Byte AS:");
13936 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
))
13937 vty_out(vty
, " advertised");
13938 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
))
13939 vty_out(vty
, " %sreceived",
13944 vty_out(vty
, "\n");
13947 /* Extended Message Support */
13948 if (CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_RCV
) ||
13949 CHECK_FLAG(p
->cap
, PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13950 vty_out(vty
, " Extended Message:");
13951 if (CHECK_FLAG(p
->cap
,
13952 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13953 vty_out(vty
, " advertised");
13954 if (CHECK_FLAG(p
->cap
,
13955 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13956 vty_out(vty
, " %sreceived",
13959 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13962 vty_out(vty
, "\n");
13966 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
) ||
13967 CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_ADV
)) {
13968 vty_out(vty
, " AddPath:\n");
13970 FOREACH_AFI_SAFI (afi
, safi
) {
13972 p
->af_cap
[afi
][safi
],
13973 PEER_CAP_ADDPATH_AF_TX_ADV
) ||
13975 p
->af_cap
[afi
][safi
],
13976 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13977 vty_out(vty
, " %s: TX ",
13985 PEER_CAP_ADDPATH_AF_TX_ADV
))
13992 PEER_CAP_ADDPATH_AF_TX_RCV
))
13999 PEER_CAP_ADDPATH_AF_TX_ADV
)
14003 vty_out(vty
, "\n");
14007 p
->af_cap
[afi
][safi
],
14008 PEER_CAP_ADDPATH_AF_RX_ADV
) ||
14010 p
->af_cap
[afi
][safi
],
14011 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
14012 vty_out(vty
, " %s: RX ",
14020 PEER_CAP_ADDPATH_AF_RX_ADV
))
14027 PEER_CAP_ADDPATH_AF_RX_RCV
))
14034 PEER_CAP_ADDPATH_AF_RX_ADV
)
14038 vty_out(vty
, "\n");
14044 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
) ||
14045 CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
)) {
14046 vty_out(vty
, " Dynamic:");
14047 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_ADV
))
14048 vty_out(vty
, " advertised");
14049 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
))
14050 vty_out(vty
, " %sreceived",
14052 PEER_CAP_DYNAMIC_ADV
)
14055 vty_out(vty
, "\n");
14059 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
) ||
14060 CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
)) {
14061 vty_out(vty
, " Role:");
14062 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_ADV
))
14063 vty_out(vty
, " advertised");
14064 if (CHECK_FLAG(p
->cap
, PEER_CAP_ROLE_RCV
))
14065 vty_out(vty
, " %sreceived",
14070 vty_out(vty
, "\n");
14073 /* Extended nexthop */
14074 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
) ||
14075 CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
14076 vty_out(vty
, " Extended nexthop:");
14077 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
))
14078 vty_out(vty
, " advertised");
14079 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
))
14080 vty_out(vty
, " %sreceived",
14085 vty_out(vty
, "\n");
14087 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)) {
14089 " Address families by peer:\n ");
14090 for (safi
= SAFI_UNICAST
;
14091 safi
< SAFI_MAX
; safi
++)
14095 PEER_CAP_ENHE_AF_RCV
))
14105 /* Long-lived Graceful Restart */
14106 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
) ||
14107 CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
)) {
14109 " Long-lived Graceful Restart:");
14110 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_ADV
))
14111 vty_out(vty
, " advertised");
14112 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
))
14113 vty_out(vty
, " %sreceived",
14118 vty_out(vty
, "\n");
14120 if (CHECK_FLAG(p
->cap
, PEER_CAP_LLGR_RCV
)) {
14122 " Address families by peer:\n");
14123 FOREACH_AFI_SAFI (afi
, safi
)
14127 PEER_CAP_LLGR_AF_RCV
))
14137 /* Route Refresh */
14138 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
) ||
14139 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ||
14140 CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_OLD_RCV
)) {
14141 vty_out(vty
, " Route refresh:");
14142 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
))
14143 vty_out(vty
, " advertised");
14144 if (CHECK_FLAG(p
->cap
,
14145 PEER_CAP_REFRESH_NEW_RCV
) ||
14147 PEER_CAP_REFRESH_OLD_RCV
))
14148 vty_out(vty
, " %sreceived(%s)",
14150 PEER_CAP_REFRESH_ADV
)
14155 PEER_CAP_REFRESH_OLD_RCV
) &&
14158 PEER_CAP_REFRESH_NEW_RCV
))
14162 PEER_CAP_REFRESH_OLD_RCV
)
14166 vty_out(vty
, "\n");
14169 /* Enhanced Route Refresh */
14170 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
) ||
14171 CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_RCV
)) {
14172 vty_out(vty
, " Enhanced Route Refresh:");
14173 if (CHECK_FLAG(p
->cap
,
14174 PEER_CAP_ENHANCED_RR_ADV
))
14175 vty_out(vty
, " advertised");
14176 if (CHECK_FLAG(p
->cap
,
14177 PEER_CAP_ENHANCED_RR_RCV
))
14178 vty_out(vty
, " %sreceived",
14180 PEER_CAP_REFRESH_ADV
)
14183 vty_out(vty
, "\n");
14186 /* Multiprotocol Extensions */
14187 FOREACH_AFI_SAFI (afi
, safi
)
14188 if (p
->afc_adv
[afi
][safi
] ||
14189 p
->afc_recv
[afi
][safi
]) {
14190 vty_out(vty
, " Address Family %s:",
14191 get_afi_safi_str(afi
, safi
,
14193 if (p
->afc_adv
[afi
][safi
])
14194 vty_out(vty
, " advertised");
14195 if (p
->afc_recv
[afi
][safi
])
14196 vty_out(vty
, " %sreceived",
14197 p
->afc_adv
[afi
][safi
]
14200 vty_out(vty
, "\n");
14203 /* Hostname capability */
14204 vty_out(vty
, " Hostname Capability:");
14206 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
14208 " advertised (name: %s,domain name: %s)",
14209 bgp
->peer_self
->hostname
14210 ? bgp
->peer_self
->hostname
14212 bgp
->peer_self
->domainname
14213 ? bgp
->peer_self
->domainname
14216 vty_out(vty
, " not advertised");
14219 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
14221 " received (name: %s,domain name: %s)",
14222 p
->hostname
? p
->hostname
: "n/a",
14223 p
->domainname
? p
->domainname
: "n/a");
14225 vty_out(vty
, " not received");
14228 vty_out(vty
, "\n");
14230 /* Graceful Restart */
14231 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) ||
14232 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)) {
14234 " Graceful Restart Capability:");
14235 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
))
14236 vty_out(vty
, " advertised");
14237 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
14238 vty_out(vty
, " %sreceived",
14240 PEER_CAP_RESTART_ADV
)
14243 vty_out(vty
, "\n");
14245 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14246 int restart_af_count
= 0;
14249 " Remote Restart timer is %d seconds\n",
14252 " Address families by peer:\n ");
14254 FOREACH_AFI_SAFI (afi
, safi
)
14258 PEER_CAP_RESTART_AF_RCV
)) {
14259 vty_out(vty
, "%s%s(%s)",
14271 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
14273 : "not preserved");
14274 restart_af_count
++;
14276 if (!restart_af_count
)
14277 vty_out(vty
, "none");
14278 vty_out(vty
, "\n");
14280 } /* Graceful Restart */
14284 /* graceful restart information */
14285 json_object
*json_grace
= NULL
;
14286 json_object
*json_grace_send
= NULL
;
14287 json_object
*json_grace_recv
= NULL
;
14288 int eor_send_af_count
= 0;
14289 int eor_receive_af_count
= 0;
14292 json_grace
= json_object_new_object();
14293 json_grace_send
= json_object_new_object();
14294 json_grace_recv
= json_object_new_object();
14296 if ((peer_established(p
)) &&
14297 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14298 FOREACH_AFI_SAFI (afi
, safi
) {
14299 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14300 PEER_STATUS_EOR_SEND
)) {
14301 json_object_boolean_true_add(
14303 get_afi_safi_str(afi
, safi
,
14305 eor_send_af_count
++;
14308 FOREACH_AFI_SAFI (afi
, safi
) {
14309 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14310 PEER_STATUS_EOR_RECEIVED
)) {
14311 json_object_boolean_true_add(
14313 get_afi_safi_str(afi
, safi
,
14315 eor_receive_af_count
++;
14319 json_object_object_add(json_grace
, "endOfRibSend",
14321 json_object_object_add(json_grace
, "endOfRibRecv",
14325 if (p
->t_gr_restart
)
14326 json_object_int_add(
14327 json_grace
, "gracefulRestartTimerMsecs",
14328 thread_timer_remain_second(p
->t_gr_restart
) *
14332 json_object_int_add(
14333 json_grace
, "gracefulStalepathTimerMsecs",
14334 thread_timer_remain_second(p
->t_gr_stale
) *
14336 /* more gr info in new format */
14337 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, json_grace
);
14338 json_object_object_add(json_neigh
, "gracefulRestartInfo",
14341 vty_out(vty
, " Graceful restart information:\n");
14342 if ((peer_established(p
)) &&
14343 CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
14345 vty_out(vty
, " End-of-RIB send: ");
14346 FOREACH_AFI_SAFI (afi
, safi
) {
14347 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14348 PEER_STATUS_EOR_SEND
)) {
14349 vty_out(vty
, "%s%s",
14350 eor_send_af_count
? ", " : "",
14351 get_afi_safi_str(afi
, safi
,
14353 eor_send_af_count
++;
14356 vty_out(vty
, "\n");
14357 vty_out(vty
, " End-of-RIB received: ");
14358 FOREACH_AFI_SAFI (afi
, safi
) {
14359 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
14360 PEER_STATUS_EOR_RECEIVED
)) {
14361 vty_out(vty
, "%s%s",
14362 eor_receive_af_count
? ", "
14364 get_afi_safi_str(afi
, safi
,
14366 eor_receive_af_count
++;
14369 vty_out(vty
, "\n");
14372 if (p
->t_gr_restart
)
14374 " The remaining time of restart timer is %ld\n",
14375 thread_timer_remain_second(p
->t_gr_restart
));
14379 " The remaining time of stalepath timer is %ld\n",
14380 thread_timer_remain_second(p
->t_gr_stale
));
14382 /* more gr info in new format */
14383 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, NULL
);
14387 json_object
*json_stat
= NULL
;
14388 json_stat
= json_object_new_object();
14389 /* Packet counts. */
14391 atomic_size_t outq_count
, inq_count
;
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
);
14397 json_object_int_add(json_stat
, "depthInq",
14398 (unsigned long)inq_count
);
14399 json_object_int_add(json_stat
, "depthOutq",
14400 (unsigned long)outq_count
);
14401 json_object_int_add(json_stat
, "opensSent",
14402 atomic_load_explicit(&p
->open_out
,
14403 memory_order_relaxed
));
14404 json_object_int_add(json_stat
, "opensRecv",
14405 atomic_load_explicit(&p
->open_in
,
14406 memory_order_relaxed
));
14407 json_object_int_add(json_stat
, "notificationsSent",
14408 atomic_load_explicit(&p
->notify_out
,
14409 memory_order_relaxed
));
14410 json_object_int_add(json_stat
, "notificationsRecv",
14411 atomic_load_explicit(&p
->notify_in
,
14412 memory_order_relaxed
));
14413 json_object_int_add(json_stat
, "updatesSent",
14414 atomic_load_explicit(&p
->update_out
,
14415 memory_order_relaxed
));
14416 json_object_int_add(json_stat
, "updatesRecv",
14417 atomic_load_explicit(&p
->update_in
,
14418 memory_order_relaxed
));
14419 json_object_int_add(json_stat
, "keepalivesSent",
14420 atomic_load_explicit(&p
->keepalive_out
,
14421 memory_order_relaxed
));
14422 json_object_int_add(json_stat
, "keepalivesRecv",
14423 atomic_load_explicit(&p
->keepalive_in
,
14424 memory_order_relaxed
));
14425 json_object_int_add(json_stat
, "routeRefreshSent",
14426 atomic_load_explicit(&p
->refresh_out
,
14427 memory_order_relaxed
));
14428 json_object_int_add(json_stat
, "routeRefreshRecv",
14429 atomic_load_explicit(&p
->refresh_in
,
14430 memory_order_relaxed
));
14431 json_object_int_add(json_stat
, "capabilitySent",
14432 atomic_load_explicit(&p
->dynamic_cap_out
,
14433 memory_order_relaxed
));
14434 json_object_int_add(json_stat
, "capabilityRecv",
14435 atomic_load_explicit(&p
->dynamic_cap_in
,
14436 memory_order_relaxed
));
14437 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
14438 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
14439 json_object_object_add(json_neigh
, "messageStats", json_stat
);
14441 atomic_size_t outq_count
, inq_count
, open_out
, open_in
,
14442 notify_out
, notify_in
, update_out
, update_in
,
14443 keepalive_out
, keepalive_in
, refresh_out
, refresh_in
,
14444 dynamic_cap_out
, dynamic_cap_in
;
14445 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14446 memory_order_relaxed
);
14447 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14448 memory_order_relaxed
);
14449 open_out
= atomic_load_explicit(&p
->open_out
,
14450 memory_order_relaxed
);
14452 atomic_load_explicit(&p
->open_in
, memory_order_relaxed
);
14453 notify_out
= atomic_load_explicit(&p
->notify_out
,
14454 memory_order_relaxed
);
14455 notify_in
= atomic_load_explicit(&p
->notify_in
,
14456 memory_order_relaxed
);
14457 update_out
= atomic_load_explicit(&p
->update_out
,
14458 memory_order_relaxed
);
14459 update_in
= atomic_load_explicit(&p
->update_in
,
14460 memory_order_relaxed
);
14461 keepalive_out
= atomic_load_explicit(&p
->keepalive_out
,
14462 memory_order_relaxed
);
14463 keepalive_in
= atomic_load_explicit(&p
->keepalive_in
,
14464 memory_order_relaxed
);
14465 refresh_out
= atomic_load_explicit(&p
->refresh_out
,
14466 memory_order_relaxed
);
14467 refresh_in
= atomic_load_explicit(&p
->refresh_in
,
14468 memory_order_relaxed
);
14469 dynamic_cap_out
= atomic_load_explicit(&p
->dynamic_cap_out
,
14470 memory_order_relaxed
);
14471 dynamic_cap_in
= atomic_load_explicit(&p
->dynamic_cap_in
,
14472 memory_order_relaxed
);
14474 /* Packet counts. */
14475 vty_out(vty
, " Message statistics:\n");
14476 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
14477 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
14478 vty_out(vty
, " Sent Rcvd\n");
14479 vty_out(vty
, " Opens: %10zu %10zu\n", open_out
,
14481 vty_out(vty
, " Notifications: %10zu %10zu\n", notify_out
,
14483 vty_out(vty
, " Updates: %10zu %10zu\n", update_out
,
14485 vty_out(vty
, " Keepalives: %10zu %10zu\n", keepalive_out
,
14487 vty_out(vty
, " Route Refresh: %10zu %10zu\n", refresh_out
,
14489 vty_out(vty
, " Capability: %10zu %10zu\n",
14490 dynamic_cap_out
, dynamic_cap_in
);
14491 vty_out(vty
, " Total: %10u %10u\n",
14492 (uint32_t)PEER_TOTAL_TX(p
), (uint32_t)PEER_TOTAL_RX(p
));
14496 /* advertisement-interval */
14497 json_object_int_add(json_neigh
,
14498 "minBtwnAdvertisementRunsTimerMsecs",
14499 p
->v_routeadv
* 1000);
14501 /* Update-source. */
14502 if (p
->update_if
|| p
->update_source
) {
14504 json_object_string_add(json_neigh
,
14507 else if (p
->update_source
)
14508 json_object_string_addf(json_neigh
,
14509 "updateSource", "%pSU",
14513 /* advertisement-interval */
14515 " Minimum time between advertisement runs is %d seconds\n",
14518 /* Update-source. */
14519 if (p
->update_if
|| p
->update_source
) {
14520 vty_out(vty
, " Update source is ");
14522 vty_out(vty
, "%s", p
->update_if
);
14523 else if (p
->update_source
)
14524 vty_out(vty
, "%pSU", p
->update_source
);
14525 vty_out(vty
, "\n");
14528 vty_out(vty
, "\n");
14531 /* Address Family Information */
14532 json_object
*json_hold
= NULL
;
14535 json_hold
= json_object_new_object();
14537 FOREACH_AFI_SAFI (afi
, safi
)
14538 if (p
->afc
[afi
][safi
])
14539 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14543 json_object_object_add(json_neigh
, "addressFamilyInfo",
14545 json_object_int_add(json_neigh
, "connectionsEstablished",
14547 json_object_int_add(json_neigh
, "connectionsDropped",
14550 vty_out(vty
, " Connections established %d; dropped %d\n",
14551 p
->established
, p
->dropped
);
14553 if (!p
->last_reset
) {
14555 json_object_string_add(json_neigh
, "lastReset",
14558 vty_out(vty
, " Last reset never\n");
14564 uptime
= monotime(NULL
);
14565 uptime
-= p
->resettime
;
14566 gmtime_r(&uptime
, &tm
);
14568 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14570 + (tm
.tm_min
* 60000)
14571 + (tm
.tm_hour
* 3600000));
14572 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14574 vty_out(vty
, " Last reset %s, ",
14575 peer_uptime(p
->resettime
, timebuf
,
14576 BGP_UPTIME_LEN
, 0, NULL
));
14578 bgp_show_peer_reset(vty
, p
, NULL
, false);
14579 if (p
->last_reset_cause_size
) {
14580 msg
= p
->last_reset_cause
;
14582 " Message received that caused BGP to send a NOTIFICATION:\n ");
14583 for (i
= 1; i
<= p
->last_reset_cause_size
;
14585 vty_out(vty
, "%02X", *msg
++);
14587 if (i
!= p
->last_reset_cause_size
) {
14589 vty_out(vty
, "\n ");
14590 } else if (i
% 4 == 0) {
14595 vty_out(vty
, "\n");
14600 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14602 json_object_boolean_true_add(json_neigh
,
14603 "prefixesConfigExceedMax");
14606 " Peer had exceeded the max. no. of prefixes configured.\n");
14608 if (p
->t_pmax_restart
) {
14610 json_object_boolean_true_add(
14611 json_neigh
, "reducePrefixNumFrom");
14612 json_object_int_add(json_neigh
,
14613 "restartInTimerMsec",
14614 thread_timer_remain_second(
14619 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14620 p
->host
, thread_timer_remain_second(
14621 p
->t_pmax_restart
));
14624 json_object_boolean_true_add(
14626 "reducePrefixNumAndClearIpBgp");
14629 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14634 /* EBGP Multihop and GTSM */
14635 if (p
->sort
!= BGP_PEER_IBGP
) {
14637 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14638 json_object_int_add(json_neigh
,
14639 "externalBgpNbrMaxHopsAway",
14642 json_object_int_add(json_neigh
,
14643 "externalBgpNbrMaxHopsAway",
14646 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14648 " External BGP neighbor may be up to %d hops away.\n",
14652 " External BGP neighbor may be up to %d hops away.\n",
14657 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14658 json_object_int_add(json_neigh
,
14659 "internalBgpNbrMaxHopsAway",
14662 json_object_int_add(json_neigh
,
14663 "internalBgpNbrMaxHopsAway",
14666 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14668 " Internal BGP neighbor may be up to %d hops away.\n",
14672 " Internal BGP neighbor may be up to %d hops away.\n",
14677 /* Local address. */
14680 json_object_string_addf(json_neigh
, "hostLocal", "%pSU",
14682 json_object_int_add(json_neigh
, "portLocal",
14683 ntohs(p
->su_local
->sin
.sin_port
));
14685 vty_out(vty
, "Local host: %pSU, Local port: %d\n",
14686 p
->su_local
, ntohs(p
->su_local
->sin
.sin_port
));
14689 json_object_string_add(json_neigh
, "hostLocal",
14691 json_object_int_add(json_neigh
, "portLocal", -1);
14695 /* Remote address. */
14696 if (p
->su_remote
) {
14698 json_object_string_addf(json_neigh
, "hostForeign",
14699 "%pSU", p
->su_remote
);
14700 json_object_int_add(json_neigh
, "portForeign",
14701 ntohs(p
->su_remote
->sin
.sin_port
));
14703 vty_out(vty
, "Foreign host: %pSU, Foreign port: %d\n",
14705 ntohs(p
->su_remote
->sin
.sin_port
));
14708 json_object_string_add(json_neigh
, "hostForeign",
14710 json_object_int_add(json_neigh
, "portForeign", -1);
14714 /* Nexthop display. */
14717 json_object_string_addf(json_neigh
, "nexthop", "%pI4",
14719 json_object_string_addf(json_neigh
, "nexthopGlobal",
14720 "%pI6", &p
->nexthop
.v6_global
);
14721 json_object_string_addf(json_neigh
, "nexthopLocal",
14722 "%pI6", &p
->nexthop
.v6_local
);
14723 if (p
->shared_network
)
14724 json_object_string_add(json_neigh
,
14728 json_object_string_add(json_neigh
,
14730 "nonSharedNetwork");
14732 vty_out(vty
, "Nexthop: %pI4\n", &p
->nexthop
.v4
);
14733 vty_out(vty
, "Nexthop global: %pI6\n",
14734 &p
->nexthop
.v6_global
);
14735 vty_out(vty
, "Nexthop local: %pI6\n",
14736 &p
->nexthop
.v6_local
);
14737 vty_out(vty
, "BGP connection: %s\n",
14738 p
->shared_network
? "shared network"
14739 : "non shared network");
14743 json_object_string_add(json_neigh
, "nexthop",
14745 json_object_string_add(json_neigh
, "nexthopGlobal",
14747 json_object_string_add(json_neigh
, "nexthopLocal",
14749 json_object_string_add(json_neigh
, "bgpConnection",
14754 /* Timer information. */
14756 json_object_int_add(json_neigh
, "connectRetryTimer",
14758 if (peer_established(p
)) {
14759 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14761 if (CHECK_FLAG(p
->flags
, PEER_FLAG_RTT_SHUTDOWN
)) {
14762 json_object_int_add(json_neigh
,
14763 "shutdownRttInMsecs",
14765 json_object_int_add(json_neigh
,
14766 "shutdownRttAfterCount",
14767 p
->rtt_keepalive_rcv
);
14771 json_object_int_add(
14772 json_neigh
, "nextStartTimerDueInMsecs",
14773 thread_timer_remain_second(p
->t_start
) * 1000);
14775 json_object_int_add(
14776 json_neigh
, "nextConnectTimerDueInMsecs",
14777 thread_timer_remain_second(p
->t_connect
)
14779 if (p
->t_routeadv
) {
14780 json_object_int_add(json_neigh
, "mraiInterval",
14782 json_object_int_add(
14783 json_neigh
, "mraiTimerExpireInMsecs",
14784 thread_timer_remain_second(p
->t_routeadv
)
14788 json_object_int_add(json_neigh
, "authenticationEnabled",
14792 json_object_string_add(json_neigh
, "readThread", "on");
14794 json_object_string_add(json_neigh
, "readThread", "off");
14796 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14797 json_object_string_add(json_neigh
, "writeThread", "on");
14799 json_object_string_add(json_neigh
, "writeThread",
14802 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14804 if (peer_established(p
)) {
14805 vty_out(vty
, "Estimated round trip time: %d ms\n",
14807 if (CHECK_FLAG(p
->flags
, PEER_FLAG_RTT_SHUTDOWN
))
14809 "Shutdown when RTT > %dms, count > %u\n",
14810 p
->rtt_expected
, p
->rtt_keepalive_rcv
);
14813 vty_out(vty
, "Next start timer due in %ld seconds\n",
14814 thread_timer_remain_second(p
->t_start
));
14816 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14817 thread_timer_remain_second(p
->t_connect
));
14820 "MRAI (interval %u) timer expires in %ld seconds\n",
14822 thread_timer_remain_second(p
->t_routeadv
));
14824 vty_out(vty
, "Peer Authentication Enabled\n");
14826 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14827 p
->t_read
? "on" : "off",
14828 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14833 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14834 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14835 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14838 vty_out(vty
, "\n");
14840 /* BFD information. */
14842 bgp_bfd_show_info(vty
, p
, json_neigh
);
14845 if (p
->conf_if
) /* Configured interface name. */
14846 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14847 else /* Configured IP address. */
14848 json_object_object_add(json
, p
->host
, json_neigh
);
14852 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14853 enum show_type type
,
14854 union sockunion
*su
,
14855 const char *conf_if
, afi_t afi
,
14858 struct listnode
*node
, *nnode
;
14860 bool found
= false;
14861 safi_t safi
= SAFI_UNICAST
;
14862 json_object
*json_neighbor
= NULL
;
14864 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14866 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14869 if ((peer
->afc
[afi
][safi
]) == 0)
14873 json_neighbor
= json_object_new_object();
14875 if (type
== show_all
) {
14876 bgp_show_peer_gr_status(vty
, peer
, json_neighbor
);
14879 json_object_object_add(json
, peer
->host
,
14882 } else if (type
== show_peer
) {
14885 && !strcmp(peer
->conf_if
, conf_if
))
14887 && !strcmp(peer
->hostname
, conf_if
))) {
14889 bgp_show_peer_gr_status(vty
, peer
,
14893 if (sockunion_same(&peer
->su
, su
)) {
14895 bgp_show_peer_gr_status(vty
, peer
,
14901 json_object_object_add(json
, peer
->host
,
14904 json_object_free(json_neighbor
);
14912 if (type
== show_peer
&& !found
) {
14914 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14916 vty_out(vty
, "%% No such neighbor\n");
14920 vty_out(vty
, "\n");
14922 return CMD_SUCCESS
;
14925 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14926 enum show_type type
, union sockunion
*su
,
14927 const char *conf_if
, bool use_json
,
14930 struct listnode
*node
, *nnode
;
14933 bool nbr_output
= false;
14934 afi_t afi
= AFI_MAX
;
14935 safi_t safi
= SAFI_MAX
;
14937 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14939 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14943 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14944 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14949 bgp_show_peer(vty
, peer
, use_json
, json
);
14955 && !strcmp(peer
->conf_if
, conf_if
))
14957 && !strcmp(peer
->hostname
, conf_if
))) {
14959 bgp_show_peer(vty
, peer
, use_json
,
14963 if (sockunion_same(&peer
->su
, su
)) {
14965 bgp_show_peer(vty
, peer
, use_json
,
14970 case show_ipv4_peer
:
14971 case show_ipv6_peer
:
14972 FOREACH_SAFI (safi
) {
14973 if (peer
->afc
[afi
][safi
]) {
14976 && !strcmp(peer
->conf_if
, conf_if
))
14978 && !strcmp(peer
->hostname
, conf_if
))) {
14980 bgp_show_peer(vty
, peer
, use_json
,
14985 if (sockunion_same(&peer
->su
, su
)) {
14987 bgp_show_peer(vty
, peer
, use_json
,
14995 case show_ipv4_all
:
14996 case show_ipv6_all
:
14997 FOREACH_SAFI (safi
) {
14998 if (peer
->afc
[afi
][safi
]) {
14999 bgp_show_peer(vty
, peer
, use_json
, json
);
15008 if ((type
== show_peer
|| type
== show_ipv4_peer
||
15009 type
== show_ipv6_peer
) && !find
) {
15011 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
15013 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
15016 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
15017 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
15018 vty_out(vty
, "%% No BGP neighbors found\n");
15021 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
15022 json
, JSON_C_TO_STRING_PRETTY
));
15024 vty_out(vty
, "\n");
15027 return CMD_SUCCESS
;
15030 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
15031 enum show_type type
,
15032 const char *ip_str
,
15033 afi_t afi
, json_object
*json
)
15038 union sockunion su
;
15040 bgp
= bgp_get_default();
15046 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
);
15049 ret
= str2sockunion(ip_str
, &su
);
15051 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
,
15052 ip_str
, afi
, json
);
15054 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
15057 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
15061 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
15062 enum show_type type
,
15063 const char *ip_str
,
15066 struct listnode
*node
, *nnode
;
15068 union sockunion su
;
15069 json_object
*json
= NULL
;
15070 int ret
, is_first
= 1;
15071 bool nbr_output
= false;
15074 vty_out(vty
, "{\n");
15076 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15079 if (!(json
= json_object_new_object())) {
15081 EC_BGP_JSON_MEM_ERROR
,
15082 "Unable to allocate memory for JSON object");
15084 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
15088 json_object_int_add(json
, "vrfId",
15089 (bgp
->vrf_id
== VRF_UNKNOWN
)
15091 : (int64_t)bgp
->vrf_id
);
15092 json_object_string_add(
15094 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15099 vty_out(vty
, ",\n");
15103 vty_out(vty
, "\"%s\":",
15104 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15108 vty_out(vty
, "\nInstance %s:\n",
15109 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15114 if (type
== show_peer
|| type
== show_ipv4_peer
||
15115 type
== show_ipv6_peer
) {
15116 ret
= str2sockunion(ip_str
, &su
);
15118 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
15121 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
15124 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
15127 json_object_free(json
);
15132 vty_out(vty
, "}\n");
15133 else if (!nbr_output
)
15134 vty_out(vty
, "%% BGP instance not found\n");
15137 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
15138 enum show_type type
, const char *ip_str
,
15143 union sockunion su
;
15144 json_object
*json
= NULL
;
15147 if (strmatch(name
, "all")) {
15148 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
15150 return CMD_SUCCESS
;
15152 bgp
= bgp_lookup_by_name(name
);
15155 json
= json_object_new_object();
15156 vty_json(vty
, json
);
15159 "%% BGP instance not found\n");
15161 return CMD_WARNING
;
15165 bgp
= bgp_get_default();
15169 json
= json_object_new_object();
15171 ret
= str2sockunion(ip_str
, &su
);
15173 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
15176 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
15179 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
15182 json_object_free(json
);
15185 vty_out(vty
, "{}\n");
15187 vty_out(vty
, "%% BGP instance not found\n");
15190 return CMD_SUCCESS
;
15195 /* "show [ip] bgp neighbors graceful-restart" commands. */
15196 DEFUN (show_ip_bgp_neighbors_graceful_restart
,
15197 show_ip_bgp_neighbors_graceful_restart_cmd
,
15198 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
15204 "Neighbor to display information about\n"
15205 "Neighbor to display information about\n"
15206 "Neighbor on BGP configured interface\n"
15210 char *sh_arg
= NULL
;
15211 enum show_type sh_type
;
15213 afi_t afi
= AFI_MAX
;
15214 bool uj
= use_json(argc
, argv
);
15216 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15221 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
15222 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
15223 || argv_find(argv
, argc
, "WORD", &idx
)) {
15224 sh_type
= show_peer
;
15225 sh_arg
= argv
[idx
]->arg
;
15227 sh_type
= show_all
;
15229 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
15230 return CMD_SUCCESS
;
15233 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
15237 /* "show [ip] bgp neighbors" commands. */
15238 DEFUN (show_ip_bgp_neighbors
,
15239 show_ip_bgp_neighbors_cmd
,
15240 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
15244 BGP_INSTANCE_HELP_STR
15247 "Detailed information on TCP and BGP neighbor connections\n"
15248 "Neighbor to display information about\n"
15249 "Neighbor to display information about\n"
15250 "Neighbor on BGP configured interface\n"
15254 char *sh_arg
= NULL
;
15255 enum show_type sh_type
;
15256 afi_t afi
= AFI_MAX
;
15258 bool uj
= use_json(argc
, argv
);
15262 /* [<vrf> VIEWVRFNAME] */
15263 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15264 vrf
= argv
[idx
+ 1]->arg
;
15265 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15267 } else if (argv_find(argv
, argc
, "view", &idx
))
15268 /* [<view> VIEWVRFNAME] */
15269 vrf
= argv
[idx
+ 1]->arg
;
15273 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
15274 sh_type
= show_ipv4_all
;
15276 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
15277 sh_type
= show_ipv6_all
;
15280 sh_type
= show_all
;
15283 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
15284 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
15285 || argv_find(argv
, argc
, "WORD", &idx
)) {
15286 sh_type
= show_peer
;
15287 sh_arg
= argv
[idx
]->arg
;
15290 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
15291 sh_type
= show_ipv4_peer
;
15292 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
15293 sh_type
= show_ipv6_peer
;
15296 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
15299 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
15300 paths' and `show ip mbgp paths'. Those functions results are the
15302 DEFUN (show_ip_bgp_paths
,
15303 show_ip_bgp_paths_cmd
,
15304 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
15309 "Path information\n")
15311 vty_out(vty
, "Address Refcnt Path\n");
15312 aspath_print_all_vty(vty
);
15313 return CMD_SUCCESS
;
15318 static void community_show_all_iterator(struct hash_bucket
*bucket
,
15321 struct community
*com
;
15323 com
= (struct community
*)bucket
->data
;
15324 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
15325 community_str(com
, false, false));
15328 /* Show BGP's community internal data. */
15329 DEFUN (show_ip_bgp_community_info
,
15330 show_ip_bgp_community_info_cmd
,
15331 "show [ip] bgp community-info",
15335 "List all bgp community information\n")
15337 vty_out(vty
, "Address Refcnt Community\n");
15339 hash_iterate(community_hash(),
15340 (void (*)(struct hash_bucket
*,
15341 void *))community_show_all_iterator
,
15344 return CMD_SUCCESS
;
15347 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
15350 struct lcommunity
*lcom
;
15352 lcom
= (struct lcommunity
*)bucket
->data
;
15353 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
15354 lcommunity_str(lcom
, false, false));
15357 /* Show BGP's community internal data. */
15358 DEFUN (show_ip_bgp_lcommunity_info
,
15359 show_ip_bgp_lcommunity_info_cmd
,
15360 "show ip bgp large-community-info",
15364 "List all bgp large-community information\n")
15366 vty_out(vty
, "Address Refcnt Large-community\n");
15368 hash_iterate(lcommunity_hash(),
15369 (void (*)(struct hash_bucket
*,
15370 void *))lcommunity_show_all_iterator
,
15373 return CMD_SUCCESS
;
15375 /* Graceful Restart */
15377 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
15382 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
15384 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
15386 switch (bgp_global_gr_mode
) {
15388 case GLOBAL_HELPER
:
15389 vty_out(vty
, "Global BGP GR Mode : Helper\n");
15393 vty_out(vty
, "Global BGP GR Mode : Restart\n");
15396 case GLOBAL_DISABLE
:
15397 vty_out(vty
, "Global BGP GR Mode : Disable\n");
15400 case GLOBAL_INVALID
:
15402 "Global BGP GR Mode Invalid\n");
15405 vty_out(vty
, "\n");
15408 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
15409 enum show_type type
,
15410 const char *ip_str
,
15411 afi_t afi
, bool use_json
)
15413 json_object
*json
= NULL
;
15416 json
= json_object_new_object();
15418 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
15421 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
15423 bgp_show_neighbor_graceful_restart_vty(
15424 vty
, type
, ip_str
, afi
, json
);
15427 } else if (afi
!= AFI_MAX
) {
15428 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
15432 json_object_free(json
);
15433 return CMD_ERR_INCOMPLETE
;
15437 vty_json(vty
, json
);
15439 return CMD_SUCCESS
;
15441 /* Graceful Restart */
15443 DEFUN (show_ip_bgp_attr_info
,
15444 show_ip_bgp_attr_info_cmd
,
15445 "show [ip] bgp attribute-info",
15449 "List all bgp attribute information\n")
15451 attr_show_all(vty
);
15452 return CMD_SUCCESS
;
15455 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
15456 afi_t afi
, safi_t safi
,
15457 bool use_json
, json_object
*json
)
15460 struct listnode
*node
;
15463 enum vpn_policy_direction dir
;
15466 json_object
*json_import_vrfs
= NULL
;
15467 json_object
*json_export_vrfs
= NULL
;
15469 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15472 vty_json(vty
, json
);
15474 return CMD_WARNING
;
15477 /* Provide context for the block */
15478 json_object_string_add(json
, "vrf", name
? name
: "default");
15479 json_object_string_add(json
, "afiSafi",
15480 get_afi_safi_str(afi
, safi
, true));
15482 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15483 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15484 json_object_string_add(json
, "importFromVrfs", "none");
15485 json_object_string_add(json
, "importRts", "none");
15487 json_import_vrfs
= json_object_new_array();
15489 for (ALL_LIST_ELEMENTS_RO(
15490 bgp
->vpn_policy
[afi
].import_vrf
,
15492 json_object_array_add(json_import_vrfs
,
15493 json_object_new_string(vname
));
15495 json_object_object_add(json
, "importFromVrfs",
15497 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15498 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15499 ecom_str
= ecommunity_ecom2str(
15500 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15501 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15502 json_object_string_add(json
, "importRts",
15504 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15506 json_object_string_add(json
, "importRts",
15510 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15511 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15512 json_object_string_add(json
, "exportToVrfs", "none");
15513 json_object_string_add(json
, "routeDistinguisher",
15515 json_object_string_add(json
, "exportRts", "none");
15517 json_export_vrfs
= json_object_new_array();
15519 for (ALL_LIST_ELEMENTS_RO(
15520 bgp
->vpn_policy
[afi
].export_vrf
,
15522 json_object_array_add(json_export_vrfs
,
15523 json_object_new_string(vname
));
15524 json_object_object_add(json
, "exportToVrfs",
15526 json_object_string_addf(json
, "routeDistinguisher",
15528 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15530 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15531 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15532 ecom_str
= ecommunity_ecom2str(
15533 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15534 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15535 json_object_string_add(json
, "exportRts",
15537 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15539 json_object_string_add(json
, "exportRts",
15544 vty_json(vty
, json
);
15547 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15550 vty_out(vty
, "%% No such BGP instance exist\n");
15551 return CMD_WARNING
;
15554 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15555 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15557 "This VRF is not importing %s routes from any other VRF\n",
15558 get_afi_safi_str(afi
, safi
, false));
15561 "This VRF is importing %s routes from the following VRFs:\n",
15562 get_afi_safi_str(afi
, safi
, false));
15564 for (ALL_LIST_ELEMENTS_RO(
15565 bgp
->vpn_policy
[afi
].import_vrf
,
15567 vty_out(vty
, " %s\n", vname
);
15569 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15571 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15572 ecom_str
= ecommunity_ecom2str(
15573 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15574 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15575 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15577 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15579 vty_out(vty
, "Import RT(s):\n");
15582 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15583 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15585 "This VRF is not exporting %s routes to any other VRF\n",
15586 get_afi_safi_str(afi
, safi
, false));
15589 "This VRF is exporting %s routes to the following VRFs:\n",
15590 get_afi_safi_str(afi
, safi
, false));
15592 for (ALL_LIST_ELEMENTS_RO(
15593 bgp
->vpn_policy
[afi
].export_vrf
,
15595 vty_out(vty
, " %s\n", vname
);
15597 vty_out(vty
, "RD: %pRD\n",
15598 &bgp
->vpn_policy
[afi
].tovpn_rd
);
15600 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15601 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15602 ecom_str
= ecommunity_ecom2str(
15603 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15604 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15605 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15606 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15608 vty_out(vty
, "Import RT(s):\n");
15612 return CMD_SUCCESS
;
15615 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15616 safi_t safi
, bool use_json
)
15618 struct listnode
*node
, *nnode
;
15620 char *vrf_name
= NULL
;
15621 json_object
*json
= NULL
;
15622 json_object
*json_vrf
= NULL
;
15623 json_object
*json_vrfs
= NULL
;
15626 json
= json_object_new_object();
15627 json_vrfs
= json_object_new_object();
15630 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15632 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15633 vrf_name
= bgp
->name
;
15636 json_vrf
= json_object_new_object();
15638 vty_out(vty
, "\nInstance %s:\n",
15639 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15640 ? VRF_DEFAULT_NAME
: bgp
->name
);
15642 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15644 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15645 json_object_object_add(json_vrfs
,
15646 VRF_DEFAULT_NAME
, json_vrf
);
15648 json_object_object_add(json_vrfs
, vrf_name
,
15654 json_object_object_add(json
, "vrfs", json_vrfs
);
15655 vty_json(vty
, json
);
15658 return CMD_SUCCESS
;
15661 /* "show [ip] bgp route-leak" command. */
15662 DEFUN (show_ip_bgp_route_leak
,
15663 show_ip_bgp_route_leak_cmd
,
15664 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15668 BGP_INSTANCE_HELP_STR
15671 "Route leaking information\n"
15675 afi_t afi
= AFI_MAX
;
15676 safi_t safi
= SAFI_MAX
;
15678 bool uj
= use_json(argc
, argv
);
15680 json_object
*json
= NULL
;
15682 /* show [ip] bgp */
15683 if (argv_find(argv
, argc
, "ip", &idx
)) {
15685 safi
= SAFI_UNICAST
;
15687 /* [vrf VIEWVRFNAME] */
15688 if (argv_find(argv
, argc
, "view", &idx
)) {
15690 "%% This command is not applicable to BGP views\n");
15691 return CMD_WARNING
;
15694 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15695 vrf
= argv
[idx
+ 1]->arg
;
15696 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15699 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15700 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
15701 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15703 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15705 "%% This command is applicable only for unicast ipv4|ipv6\n");
15706 return CMD_WARNING
;
15709 if (vrf
&& strmatch(vrf
, "all"))
15710 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15713 json
= json_object_new_object();
15715 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15718 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15719 safi_t safi
, bool uj
)
15721 struct listnode
*node
, *nnode
;
15724 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15726 vty_out(vty
, "\nInstance %s:\n",
15727 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15731 update_group_show(bgp
, afi
, safi
, vty
, 0, uj
);
15735 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15736 int safi
, uint64_t subgrp_id
, bool uj
)
15741 if (strmatch(name
, "all")) {
15742 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
, uj
);
15743 return CMD_SUCCESS
;
15745 bgp
= bgp_lookup_by_name(name
);
15748 bgp
= bgp_get_default();
15752 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
, uj
);
15753 return CMD_SUCCESS
;
15756 DEFUN (show_ip_bgp_updgrps
,
15757 show_ip_bgp_updgrps_cmd
,
15758 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID] [json]",
15762 BGP_INSTANCE_HELP_STR
15764 BGP_SAFI_WITH_LABEL_HELP_STR
15765 "Detailed info about dynamic update groups\n"
15766 "Specific subgroup to display detailed info for\n"
15770 afi_t afi
= AFI_IP6
;
15771 safi_t safi
= SAFI_UNICAST
;
15772 uint64_t subgrp_id
= 0;
15776 bool uj
= use_json(argc
, argv
);
15778 /* show [ip] bgp */
15779 if (argv_find(argv
, argc
, "ip", &idx
))
15781 /* [<vrf> VIEWVRFNAME] */
15782 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15783 vrf
= argv
[idx
+ 1]->arg
;
15784 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15786 } else if (argv_find(argv
, argc
, "view", &idx
))
15787 /* [<view> VIEWVRFNAME] */
15788 vrf
= argv
[idx
+ 1]->arg
;
15789 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15790 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15791 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15794 /* get subgroup id, if provided */
15796 if (argv
[idx
]->type
== VARIABLE_TKN
)
15797 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15799 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
, uj
));
15802 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15803 show_bgp_instance_all_ipv6_updgrps_cmd
,
15804 "show [ip] bgp <view|vrf> all update-groups [json]",
15808 BGP_INSTANCE_ALL_HELP_STR
15809 "Detailed info about dynamic update groups\n"
15812 bool uj
= use_json(argc
, argv
);
15814 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
, uj
);
15815 return CMD_SUCCESS
;
15818 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15819 show_bgp_l2vpn_evpn_updgrps_cmd
,
15820 "show [ip] bgp l2vpn evpn update-groups",
15824 "l2vpn address family\n"
15825 "evpn sub-address family\n"
15826 "Detailed info about dynamic update groups\n")
15829 uint64_t subgrp_id
= 0;
15831 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
, 0);
15832 return CMD_SUCCESS
;
15835 DEFUN (show_bgp_updgrps_stats
,
15836 show_bgp_updgrps_stats_cmd
,
15837 "show [ip] bgp update-groups statistics",
15841 "Detailed info about dynamic update groups\n"
15846 bgp
= bgp_get_default();
15848 update_group_show_stats(bgp
, vty
);
15850 return CMD_SUCCESS
;
15853 DEFUN (show_bgp_instance_updgrps_stats
,
15854 show_bgp_instance_updgrps_stats_cmd
,
15855 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15859 BGP_INSTANCE_HELP_STR
15860 "Detailed info about dynamic update groups\n"
15866 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15868 update_group_show_stats(bgp
, vty
);
15870 return CMD_SUCCESS
;
15873 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15874 afi_t afi
, safi_t safi
,
15875 const char *what
, uint64_t subgrp_id
)
15880 bgp
= bgp_lookup_by_name(name
);
15882 bgp
= bgp_get_default();
15885 if (!strcmp(what
, "advertise-queue"))
15886 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15888 else if (!strcmp(what
, "advertised-routes"))
15889 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15891 else if (!strcmp(what
, "packet-queue"))
15892 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15897 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15898 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15899 "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",
15900 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15902 "Detailed info about dynamic update groups\n"
15903 "Specific subgroup to display info for\n"
15904 "Advertisement queue\n"
15905 "Announced routes\n"
15908 uint64_t subgrp_id
= 0;
15912 subgrp_id
= strtoull(sgid
, NULL
, 10);
15917 afiz
= bgp_vty_afi_from_str(afi
);
15921 afiz
= bgp_vty_afi_from_str(afi
);
15922 if (afiz
!= AFI_IP
)
15924 "%% Cannot specify both 'ip' and 'ipv6'\n");
15925 return CMD_WARNING
;
15928 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15930 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15931 return CMD_SUCCESS
;
15934 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15937 struct listnode
*node
, *nnode
;
15938 struct prefix
*range
;
15943 const char *peer_status
;
15947 json_object
*json_peer_group
= NULL
;
15948 json_object
*json_peer_group_afc
= NULL
;
15949 json_object
*json_peer_group_members
= NULL
;
15950 json_object
*json_peer_group_dynamic
= NULL
;
15951 json_object
*json_peer_group_dynamic_af
= NULL
;
15952 json_object
*json_peer_group_ranges
= NULL
;
15954 conf
= group
->conf
;
15957 json_peer_group
= json_object_new_object();
15958 json_peer_group_afc
= json_object_new_array();
15961 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15963 json_object_int_add(json_peer_group
, "remoteAs",
15966 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15967 group
->name
, conf
->as
);
15968 } else if (conf
->as_type
== AS_INTERNAL
) {
15970 json_object_int_add(json_peer_group
, "remoteAs",
15973 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15974 group
->name
, group
->bgp
->as
);
15977 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15980 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15982 json_object_string_add(json_peer_group
, "type",
15985 vty_out(vty
, " Peer-group type is internal\n");
15988 json_object_string_add(json_peer_group
, "type",
15991 vty_out(vty
, " Peer-group type is external\n");
15994 /* Display AFs configured. */
15996 vty_out(vty
, " Configured address-families:");
15998 FOREACH_AFI_SAFI (afi
, safi
) {
15999 if (conf
->afc
[afi
][safi
]) {
16002 json_object_array_add(
16003 json_peer_group_afc
,
16004 json_object_new_string(get_afi_safi_str(
16005 afi
, safi
, false)));
16007 vty_out(vty
, " %s;",
16008 get_afi_safi_str(afi
, safi
, false));
16013 json_object_object_add(json_peer_group
,
16014 "addressFamiliesConfigured",
16015 json_peer_group_afc
);
16018 vty_out(vty
, " none\n");
16020 vty_out(vty
, "\n");
16023 /* Display listen ranges (for dynamic neighbors), if any */
16024 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
16025 lr_count
= listcount(group
->listen_range
[afi
]);
16028 if (!json_peer_group_dynamic
)
16029 json_peer_group_dynamic
=
16030 json_object_new_object();
16032 json_peer_group_dynamic_af
=
16033 json_object_new_object();
16034 json_peer_group_ranges
=
16035 json_object_new_array();
16036 json_object_int_add(json_peer_group_dynamic_af
,
16037 "count", lr_count
);
16039 vty_out(vty
, " %d %s listen range(s)\n",
16040 lr_count
, afi2str(afi
));
16043 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
16048 snprintfrr(buf
, sizeof(buf
), "%pFX",
16051 json_object_array_add(
16052 json_peer_group_ranges
,
16053 json_object_new_string(buf
));
16055 vty_out(vty
, " %pFX\n", range
);
16060 json_object_object_add(
16061 json_peer_group_dynamic_af
, "ranges",
16062 json_peer_group_ranges
);
16064 json_object_object_add(
16065 json_peer_group_dynamic
, afi2str(afi
),
16066 json_peer_group_dynamic_af
);
16071 if (json_peer_group_dynamic
)
16072 json_object_object_add(json_peer_group
, "dynamicRanges",
16073 json_peer_group_dynamic
);
16075 /* Display group members and their status */
16076 if (listcount(group
->peer
)) {
16078 json_peer_group_members
= json_object_new_object();
16080 vty_out(vty
, " Peer-group members:\n");
16081 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
16082 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
16083 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
16084 peer_status
= "Idle (Admin)";
16085 else if (CHECK_FLAG(peer
->sflags
,
16086 PEER_STATUS_PREFIX_OVERFLOW
))
16087 peer_status
= "Idle (PfxCt)";
16089 peer_status
= lookup_msg(bgp_status_msg
,
16090 peer
->status
, NULL
);
16092 dynamic
= peer_dynamic_neighbor(peer
);
16095 json_object
*json_peer_group_member
=
16096 json_object_new_object();
16098 json_object_string_add(json_peer_group_member
,
16099 "status", peer_status
);
16102 json_object_boolean_true_add(
16103 json_peer_group_member
,
16106 json_object_object_add(json_peer_group_members
,
16108 json_peer_group_member
);
16110 vty_out(vty
, " %s %s %s \n", peer
->host
,
16111 dynamic
? "(dynamic)" : "",
16116 json_object_object_add(json_peer_group
, "members",
16117 json_peer_group_members
);
16121 json_object_object_add(json
, group
->name
, json_peer_group
);
16123 return CMD_SUCCESS
;
16126 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
16127 const char *group_name
, bool uj
)
16130 struct listnode
*node
, *nnode
;
16131 struct peer_group
*group
;
16132 bool found
= false;
16133 json_object
*json
= NULL
;
16136 json
= json_object_new_object();
16138 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
16142 vty_json(vty
, json
);
16144 vty_out(vty
, "%% BGP instance not found\n");
16146 return CMD_WARNING
;
16149 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
16151 if (strmatch(group
->name
, group_name
)) {
16152 bgp_show_one_peer_group(vty
, group
, json
);
16157 bgp_show_one_peer_group(vty
, group
, json
);
16161 if (group_name
&& !found
&& !uj
)
16162 vty_out(vty
, "%% No such peer-group\n");
16165 vty_json(vty
, json
);
16167 return CMD_SUCCESS
;
16170 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
16171 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
16172 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
16173 "Detailed information on BGP peer groups\n"
16174 "Peer group name\n" JSON_STR
)
16178 bool uj
= use_json(argc
, argv
);
16180 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
16182 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
16184 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
16188 /* Redistribute VTY commands. */
16190 DEFUN (bgp_redistribute_ipv4
,
16191 bgp_redistribute_ipv4_cmd
,
16192 "redistribute " FRR_IP_REDIST_STR_BGPD
,
16193 "Redistribute information from another routing protocol\n"
16194 FRR_IP_REDIST_HELP_STR_BGPD
)
16196 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16197 int idx_protocol
= 1;
16200 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16202 vty_out(vty
, "%% Invalid route type\n");
16203 return CMD_WARNING_CONFIG_FAILED
;
16206 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16207 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
16211 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
16212 "redistribute " FRR_IP_REDIST_STR_BGPD
,
16213 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
16215 DEFUN (bgp_redistribute_ipv4_rmap
,
16216 bgp_redistribute_ipv4_rmap_cmd
,
16217 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
16218 "Redistribute information from another routing protocol\n"
16219 FRR_IP_REDIST_HELP_STR_BGPD
16220 "Route map reference\n"
16221 "Pointer to route-map entries\n")
16223 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16224 int idx_protocol
= 1;
16227 struct bgp_redist
*red
;
16229 struct route_map
*route_map
= route_map_lookup_warn_noexist(
16230 vty
, argv
[idx_word
]->arg
);
16232 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16234 vty_out(vty
, "%% Invalid route type\n");
16235 return CMD_WARNING_CONFIG_FAILED
;
16238 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16240 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16241 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16245 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
16246 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME",
16247 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16248 "Route map reference\n"
16249 "Pointer to route-map entries\n")
16251 DEFUN (bgp_redistribute_ipv4_metric
,
16252 bgp_redistribute_ipv4_metric_cmd
,
16253 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16254 "Redistribute information from another routing protocol\n"
16255 FRR_IP_REDIST_HELP_STR_BGPD
16256 "Metric for redistributed routes\n"
16257 "Default metric\n")
16259 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16260 int idx_protocol
= 1;
16261 int idx_number
= 3;
16264 struct bgp_redist
*red
;
16267 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16269 vty_out(vty
, "%% Invalid route type\n");
16270 return CMD_WARNING_CONFIG_FAILED
;
16272 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16274 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16275 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16276 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16280 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
16281 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
16282 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16283 "Metric for redistributed routes\n"
16284 "Default metric\n")
16286 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
16287 bgp_redistribute_ipv4_rmap_metric_cmd
,
16288 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16289 "Redistribute information from another routing protocol\n"
16290 FRR_IP_REDIST_HELP_STR_BGPD
16291 "Route map reference\n"
16292 "Pointer to route-map entries\n"
16293 "Metric for redistributed routes\n"
16294 "Default metric\n")
16296 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16297 int idx_protocol
= 1;
16299 int idx_number
= 5;
16302 struct bgp_redist
*red
;
16304 struct route_map
*route_map
=
16305 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16307 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16309 vty_out(vty
, "%% Invalid route type\n");
16310 return CMD_WARNING_CONFIG_FAILED
;
16312 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16314 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16316 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16317 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16318 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16322 bgp_redistribute_ipv4_rmap_metric
,
16323 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
16324 "redistribute " FRR_IP_REDIST_STR_BGPD
16325 " route-map RMAP_NAME metric (0-4294967295)",
16326 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16327 "Route map reference\n"
16328 "Pointer to route-map entries\n"
16329 "Metric for redistributed routes\n"
16330 "Default metric\n")
16332 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
16333 bgp_redistribute_ipv4_metric_rmap_cmd
,
16334 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16335 "Redistribute information from another routing protocol\n"
16336 FRR_IP_REDIST_HELP_STR_BGPD
16337 "Metric for redistributed routes\n"
16339 "Route map reference\n"
16340 "Pointer to route-map entries\n")
16342 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16343 int idx_protocol
= 1;
16344 int idx_number
= 3;
16348 struct bgp_redist
*red
;
16350 struct route_map
*route_map
=
16351 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16353 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16355 vty_out(vty
, "%% Invalid route type\n");
16356 return CMD_WARNING_CONFIG_FAILED
;
16358 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16360 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
16361 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
16363 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16364 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
16368 bgp_redistribute_ipv4_metric_rmap
,
16369 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
16370 "redistribute " FRR_IP_REDIST_STR_BGPD
16371 " metric (0-4294967295) route-map RMAP_NAME",
16372 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16373 "Metric for redistributed routes\n"
16375 "Route map reference\n"
16376 "Pointer to route-map entries\n")
16378 DEFUN (bgp_redistribute_ipv4_ospf
,
16379 bgp_redistribute_ipv4_ospf_cmd
,
16380 "redistribute <ospf|table> (1-65535)",
16381 "Redistribute information from another routing protocol\n"
16382 "Open Shortest Path First (OSPFv2)\n"
16383 "Non-main Kernel Routing Table\n"
16384 "Instance ID/Table ID\n")
16386 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16387 int idx_ospf_table
= 1;
16388 int idx_number
= 2;
16389 unsigned short instance
;
16390 unsigned short protocol
;
16392 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16394 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16395 protocol
= ZEBRA_ROUTE_OSPF
;
16397 protocol
= ZEBRA_ROUTE_TABLE
;
16399 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16400 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
16403 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
16404 "redistribute <ospf|table> (1-65535)",
16405 "Redistribute information from another routing protocol\n"
16406 "Open Shortest Path First (OSPFv2)\n"
16407 "Non-main Kernel Routing Table\n"
16408 "Instance ID/Table ID\n")
16410 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
16411 bgp_redistribute_ipv4_ospf_rmap_cmd
,
16412 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16413 "Redistribute information from another routing protocol\n"
16414 "Open Shortest Path First (OSPFv2)\n"
16415 "Non-main Kernel Routing Table\n"
16416 "Instance ID/Table ID\n"
16417 "Route map reference\n"
16418 "Pointer to route-map entries\n")
16420 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16421 int idx_ospf_table
= 1;
16422 int idx_number
= 2;
16424 struct bgp_redist
*red
;
16425 unsigned short instance
;
16428 struct route_map
*route_map
=
16429 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16431 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16432 protocol
= ZEBRA_ROUTE_OSPF
;
16434 protocol
= ZEBRA_ROUTE_TABLE
;
16436 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16437 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16439 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16440 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16443 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
16444 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
16445 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME",
16446 "Redistribute information from another routing protocol\n"
16447 "Open Shortest Path First (OSPFv2)\n"
16448 "Non-main Kernel Routing Table\n"
16449 "Instance ID/Table ID\n"
16450 "Route map reference\n"
16451 "Pointer to route-map entries\n")
16453 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
16454 bgp_redistribute_ipv4_ospf_metric_cmd
,
16455 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16456 "Redistribute information from another routing protocol\n"
16457 "Open Shortest Path First (OSPFv2)\n"
16458 "Non-main Kernel Routing Table\n"
16459 "Instance ID/Table ID\n"
16460 "Metric for redistributed routes\n"
16461 "Default metric\n")
16463 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16464 int idx_ospf_table
= 1;
16465 int idx_number
= 2;
16466 int idx_number_2
= 4;
16468 struct bgp_redist
*red
;
16469 unsigned short instance
;
16473 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16474 protocol
= ZEBRA_ROUTE_OSPF
;
16476 protocol
= ZEBRA_ROUTE_TABLE
;
16478 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16479 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16481 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16482 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16484 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16487 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
16488 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
16489 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16490 "Redistribute information from another routing protocol\n"
16491 "Open Shortest Path First (OSPFv2)\n"
16492 "Non-main Kernel Routing Table\n"
16493 "Instance ID/Table ID\n"
16494 "Metric for redistributed routes\n"
16495 "Default metric\n")
16497 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
16498 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
16499 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16500 "Redistribute information from another routing protocol\n"
16501 "Open Shortest Path First (OSPFv2)\n"
16502 "Non-main Kernel Routing Table\n"
16503 "Instance ID/Table ID\n"
16504 "Route map reference\n"
16505 "Pointer to route-map entries\n"
16506 "Metric for redistributed routes\n"
16507 "Default metric\n")
16509 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16510 int idx_ospf_table
= 1;
16511 int idx_number
= 2;
16513 int idx_number_2
= 6;
16515 struct bgp_redist
*red
;
16516 unsigned short instance
;
16519 struct route_map
*route_map
=
16520 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16522 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16523 protocol
= ZEBRA_ROUTE_OSPF
;
16525 protocol
= ZEBRA_ROUTE_TABLE
;
16527 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16528 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16530 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16532 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16533 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16535 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16539 bgp_redistribute_ipv4_ospf_rmap_metric
,
16540 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
16541 "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)",
16542 "Redistribute information from another routing protocol\n"
16543 "Open Shortest Path First (OSPFv2)\n"
16544 "Non-main Kernel Routing Table\n"
16545 "Instance ID/Table ID\n"
16546 "Route map reference\n"
16547 "Pointer to route-map entries\n"
16548 "Metric for redistributed routes\n"
16549 "Default metric\n")
16551 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
16552 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
16553 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16554 "Redistribute information from another routing protocol\n"
16555 "Open Shortest Path First (OSPFv2)\n"
16556 "Non-main Kernel Routing Table\n"
16557 "Instance ID/Table ID\n"
16558 "Metric for redistributed routes\n"
16560 "Route map reference\n"
16561 "Pointer to route-map entries\n")
16563 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16564 int idx_ospf_table
= 1;
16565 int idx_number
= 2;
16566 int idx_number_2
= 4;
16569 struct bgp_redist
*red
;
16570 unsigned short instance
;
16573 struct route_map
*route_map
=
16574 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16576 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16577 protocol
= ZEBRA_ROUTE_OSPF
;
16579 protocol
= ZEBRA_ROUTE_TABLE
;
16581 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16582 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
16584 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
16585 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
16588 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16589 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
16593 bgp_redistribute_ipv4_ospf_metric_rmap
,
16594 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16595 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME",
16596 "Redistribute information from another routing protocol\n"
16597 "Open Shortest Path First (OSPFv2)\n"
16598 "Non-main Kernel Routing Table\n"
16599 "Instance ID/Table ID\n"
16600 "Metric for redistributed routes\n"
16602 "Route map reference\n"
16603 "Pointer to route-map entries\n")
16605 DEFUN (no_bgp_redistribute_ipv4_ospf
,
16606 no_bgp_redistribute_ipv4_ospf_cmd
,
16607 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16609 "Redistribute information from another routing protocol\n"
16610 "Open Shortest Path First (OSPFv2)\n"
16611 "Non-main Kernel Routing Table\n"
16612 "Instance ID/Table ID\n"
16613 "Metric for redistributed routes\n"
16615 "Route map reference\n"
16616 "Pointer to route-map entries\n")
16618 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16619 int idx_ospf_table
= 2;
16620 int idx_number
= 3;
16621 unsigned short instance
;
16624 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
16625 protocol
= ZEBRA_ROUTE_OSPF
;
16627 protocol
= ZEBRA_ROUTE_TABLE
;
16629 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16630 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
16634 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16635 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]",
16637 "Redistribute information from another routing protocol\n"
16638 "Open Shortest Path First (OSPFv2)\n"
16639 "Non-main Kernel Routing Table\n"
16640 "Instance ID/Table ID\n"
16641 "Metric for redistributed routes\n"
16643 "Route map reference\n"
16644 "Pointer to route-map entries\n")
16646 DEFUN (no_bgp_redistribute_ipv4
,
16647 no_bgp_redistribute_ipv4_cmd
,
16648 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16650 "Redistribute information from another routing protocol\n"
16651 FRR_IP_REDIST_HELP_STR_BGPD
16652 "Metric for redistributed routes\n"
16654 "Route map reference\n"
16655 "Pointer to route-map entries\n")
16657 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16658 int idx_protocol
= 2;
16661 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
16663 vty_out(vty
, "%% Invalid route type\n");
16664 return CMD_WARNING_CONFIG_FAILED
;
16666 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
16670 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16671 "no redistribute " FRR_IP_REDIST_STR_BGPD
16672 " [{metric (0-4294967295)|route-map RMAP_NAME}]",
16674 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16675 "Metric for redistributed routes\n"
16677 "Route map reference\n"
16678 "Pointer to route-map entries\n")
16680 DEFUN (bgp_redistribute_ipv6
,
16681 bgp_redistribute_ipv6_cmd
,
16682 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16683 "Redistribute information from another routing protocol\n"
16684 FRR_IP6_REDIST_HELP_STR_BGPD
)
16686 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16687 int idx_protocol
= 1;
16690 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16692 vty_out(vty
, "%% Invalid route type\n");
16693 return CMD_WARNING_CONFIG_FAILED
;
16696 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16697 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
16700 DEFUN (bgp_redistribute_ipv6_rmap
,
16701 bgp_redistribute_ipv6_rmap_cmd
,
16702 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME",
16703 "Redistribute information from another routing protocol\n"
16704 FRR_IP6_REDIST_HELP_STR_BGPD
16705 "Route map reference\n"
16706 "Pointer to route-map entries\n")
16708 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16709 int idx_protocol
= 1;
16712 struct bgp_redist
*red
;
16714 struct route_map
*route_map
=
16715 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16717 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16719 vty_out(vty
, "%% Invalid route type\n");
16720 return CMD_WARNING_CONFIG_FAILED
;
16723 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16725 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16726 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16729 DEFUN (bgp_redistribute_ipv6_metric
,
16730 bgp_redistribute_ipv6_metric_cmd
,
16731 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16732 "Redistribute information from another routing protocol\n"
16733 FRR_IP6_REDIST_HELP_STR_BGPD
16734 "Metric for redistributed routes\n"
16735 "Default metric\n")
16737 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16738 int idx_protocol
= 1;
16739 int idx_number
= 3;
16742 struct bgp_redist
*red
;
16745 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16747 vty_out(vty
, "%% Invalid route type\n");
16748 return CMD_WARNING_CONFIG_FAILED
;
16750 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16752 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16753 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
16754 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16757 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
16758 bgp_redistribute_ipv6_rmap_metric_cmd
,
16759 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map RMAP_NAME metric (0-4294967295)",
16760 "Redistribute information from another routing protocol\n"
16761 FRR_IP6_REDIST_HELP_STR_BGPD
16762 "Route map reference\n"
16763 "Pointer to route-map entries\n"
16764 "Metric for redistributed routes\n"
16765 "Default metric\n")
16767 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16768 int idx_protocol
= 1;
16770 int idx_number
= 5;
16773 struct bgp_redist
*red
;
16775 struct route_map
*route_map
=
16776 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16778 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16780 vty_out(vty
, "%% Invalid route type\n");
16781 return CMD_WARNING_CONFIG_FAILED
;
16783 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16785 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16787 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16788 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
16790 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16793 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
16794 bgp_redistribute_ipv6_metric_rmap_cmd
,
16795 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map RMAP_NAME",
16796 "Redistribute information from another routing protocol\n"
16797 FRR_IP6_REDIST_HELP_STR_BGPD
16798 "Metric for redistributed routes\n"
16800 "Route map reference\n"
16801 "Pointer to route-map entries\n")
16803 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16804 int idx_protocol
= 1;
16805 int idx_number
= 3;
16809 struct bgp_redist
*red
;
16811 struct route_map
*route_map
=
16812 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
16814 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16816 vty_out(vty
, "%% Invalid route type\n");
16817 return CMD_WARNING_CONFIG_FAILED
;
16819 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
16821 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
16822 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
16825 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
16826 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
16829 DEFUN (no_bgp_redistribute_ipv6
,
16830 no_bgp_redistribute_ipv6_cmd
,
16831 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map RMAP_NAME}]",
16833 "Redistribute information from another routing protocol\n"
16834 FRR_IP6_REDIST_HELP_STR_BGPD
16835 "Metric for redistributed routes\n"
16837 "Route map reference\n"
16838 "Pointer to route-map entries\n")
16840 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
16841 int idx_protocol
= 2;
16844 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
16846 vty_out(vty
, "%% Invalid route type\n");
16847 return CMD_WARNING_CONFIG_FAILED
;
16850 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
16853 /* Neighbor update tcp-mss. */
16854 static int peer_tcp_mss_vty(struct vty
*vty
, const char *peer_str
,
16855 const char *tcp_mss_str
)
16858 uint32_t tcp_mss_val
= 0;
16860 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
16862 return CMD_WARNING_CONFIG_FAILED
;
16865 tcp_mss_val
= strtoul(tcp_mss_str
, NULL
, 10);
16866 peer_tcp_mss_set(peer
, tcp_mss_val
);
16868 peer_tcp_mss_unset(peer
);
16871 return CMD_SUCCESS
;
16874 DEFUN(neighbor_tcp_mss
, neighbor_tcp_mss_cmd
,
16875 "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)",
16876 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16877 "TCP max segment size\n"
16880 int peer_index
= 1;
16884 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16885 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
,
16886 argv
[mss_index
]->arg
);
16889 DEFUN(no_neighbor_tcp_mss
, no_neighbor_tcp_mss_cmd
,
16890 "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]",
16891 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
16892 "TCP max segment size\n"
16895 int peer_index
= 2;
16898 " Warning: Reset BGP session for tcp-mss value to take effect\n");
16899 return peer_tcp_mss_vty(vty
, argv
[peer_index
]->arg
, NULL
);
16902 DEFPY(bgp_retain_route_target
, bgp_retain_route_target_cmd
,
16903 "[no$no] bgp retain route-target all",
16905 "Retain BGP updates\n"
16906 "Retain BGP updates based on route-target values\n"
16907 "Retain all BGP updates\n")
16910 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
16912 check
= CHECK_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)][bgp_node_safi(vty
)],
16913 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16914 if (check
!= !no
) {
16916 SET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16917 [bgp_node_safi(vty
)],
16918 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16920 UNSET_FLAG(bgp
->af_flags
[bgp_node_afi(vty
)]
16921 [bgp_node_safi(vty
)],
16922 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
);
16923 /* trigger a flush to re-sync with ADJ-RIB-in */
16924 bgp_clear(vty
, bgp
, bgp_node_afi(vty
), bgp_node_safi(vty
),
16925 clear_all
, BGP_CLEAR_SOFT_IN
, NULL
);
16927 return CMD_SUCCESS
;
16930 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16931 afi_t afi
, safi_t safi
)
16935 /* Unicast redistribution only. */
16936 if (safi
!= SAFI_UNICAST
)
16939 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16940 /* Redistribute BGP does not make sense. */
16941 if (i
!= ZEBRA_ROUTE_BGP
) {
16942 struct list
*red_list
;
16943 struct listnode
*node
;
16944 struct bgp_redist
*red
;
16946 red_list
= bgp
->redist
[afi
][i
];
16950 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16951 /* "redistribute" configuration. */
16952 vty_out(vty
, " redistribute %s",
16953 zebra_route_string(i
));
16955 vty_out(vty
, " %d", red
->instance
);
16956 if (red
->redist_metric_flag
)
16957 vty_out(vty
, " metric %u",
16958 red
->redist_metric
);
16959 if (red
->rmap
.name
)
16960 vty_out(vty
, " route-map %s",
16962 vty_out(vty
, "\n");
16968 /* peer-group helpers for config-write */
16970 static bool peergroup_flag_check(struct peer
*peer
, uint64_t flag
)
16972 if (!peer_group_active(peer
)) {
16973 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16974 return !CHECK_FLAG(peer
->flags
, flag
);
16976 return !!CHECK_FLAG(peer
->flags
, flag
);
16979 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16982 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16985 if (!peer_group_active(peer
)) {
16986 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16987 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16989 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16992 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16995 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16996 uint8_t type
, int direct
)
16998 struct bgp_filter
*filter
;
17000 if (peer_group_active(peer
))
17001 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
17004 filter
= &peer
->filter
[afi
][safi
];
17006 case PEER_FT_DISTRIBUTE_LIST
:
17007 return !!(filter
->dlist
[direct
].name
);
17008 case PEER_FT_FILTER_LIST
:
17009 return !!(filter
->aslist
[direct
].name
);
17010 case PEER_FT_PREFIX_LIST
:
17011 return !!(filter
->plist
[direct
].name
);
17012 case PEER_FT_ROUTE_MAP
:
17013 return !!(filter
->map
[direct
].name
);
17014 case PEER_FT_UNSUPPRESS_MAP
:
17015 return !!(filter
->usmap
.name
);
17016 case PEER_FT_ADVERTISE_MAP
:
17017 return !!(filter
->advmap
.aname
17018 && ((filter
->advmap
.condition
== direct
)
17019 && filter
->advmap
.cname
));
17025 /* Return true if the addpath type is set for peer and different from
17028 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
17031 enum bgp_addpath_strat type
, g_type
;
17033 type
= peer
->addpath_type
[afi
][safi
];
17035 if (type
!= BGP_ADDPATH_NONE
) {
17036 if (peer_group_active(peer
)) {
17037 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
17039 if (type
!= g_type
)
17051 /* This is part of the address-family block (unicast only) */
17052 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
17056 uint32_t tovpn_sid_index
= 0;
17058 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
17059 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
17060 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
17061 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
17062 bgp
->vpn_policy
[afi
]
17063 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
17065 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
17066 bgp
->vpn_policy
[afi
]
17067 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
17069 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
17070 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
17071 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
17072 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
17075 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17076 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
17078 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
17081 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
17082 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
17083 bgp
->vpn_policy
[afi
].tovpn_label
);
17087 tovpn_sid_index
= bgp
->vpn_policy
[afi
].tovpn_sid_index
;
17088 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17089 BGP_VPN_POLICY_TOVPN_SID_AUTO
)) {
17090 vty_out(vty
, "%*ssid vpn export %s\n", indent
, "", "auto");
17091 } else if (tovpn_sid_index
!= 0) {
17092 vty_out(vty
, "%*ssid vpn export %d\n", indent
, "",
17096 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
, BGP_VPN_POLICY_TOVPN_RD_SET
))
17097 vty_out(vty
, "%*srd vpn export %pRD\n", indent
, "",
17098 &bgp
->vpn_policy
[afi
].tovpn_rd
);
17100 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
17101 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
17103 char buf
[PREFIX_STRLEN
];
17104 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
17105 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
17108 vty_out(vty
, "%*snexthop vpn export %s\n",
17112 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
17113 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
17115 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
17116 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
17118 char *b
= ecommunity_ecom2str(
17119 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
17120 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
17121 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
17122 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17124 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
17125 char *b
= ecommunity_ecom2str(
17126 bgp
->vpn_policy
[afi
]
17127 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
17128 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17129 ECOMMUNITY_ROUTE_TARGET
);
17130 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
17131 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17133 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
17134 char *b
= ecommunity_ecom2str(
17135 bgp
->vpn_policy
[afi
]
17136 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
17137 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17138 ECOMMUNITY_ROUTE_TARGET
);
17139 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
17140 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17144 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
17145 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
17146 bgp
->vpn_policy
[afi
]
17147 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
17149 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
17150 char *b
= ecommunity_ecom2str(
17151 bgp
->vpn_policy
[afi
]
17152 .import_redirect_rtlist
,
17153 ECOMMUNITY_FORMAT_ROUTE_MAP
,
17154 ECOMMUNITY_ROUTE_TARGET
);
17156 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
17157 != ECOMMUNITY_SIZE
)
17158 vty_out(vty
, "%*srt6 redirect import %s\n",
17161 vty_out(vty
, "%*srt redirect import %s\n",
17163 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
17167 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
17168 afi_t afi
, safi_t safi
)
17170 struct bgp_filter
*filter
;
17174 filter
= &peer
->filter
[afi
][safi
];
17176 /* distribute-list. */
17177 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
17179 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
17180 filter
->dlist
[FILTER_IN
].name
);
17182 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
17184 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
17185 filter
->dlist
[FILTER_OUT
].name
);
17188 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
17190 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
17191 filter
->plist
[FILTER_IN
].name
);
17193 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
17195 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
17196 filter
->plist
[FILTER_OUT
].name
);
17199 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
17200 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
17201 filter
->map
[RMAP_IN
].name
);
17203 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
17205 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
17206 filter
->map
[RMAP_OUT
].name
);
17208 /* unsuppress-map */
17209 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
17210 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
17211 filter
->usmap
.name
);
17213 /* advertise-map : always applied in OUT direction*/
17214 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
17215 CONDITION_NON_EXIST
))
17217 " neighbor %s advertise-map %s non-exist-map %s\n",
17218 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
17220 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
17222 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
17223 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
17226 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
17228 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
17229 filter
->aslist
[FILTER_IN
].name
);
17231 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
17233 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
17234 filter
->aslist
[FILTER_OUT
].name
);
17237 /* BGP peer configuration display function. */
17238 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
17241 struct peer
*g_peer
= NULL
;
17243 int if_pg_printed
= false;
17244 int if_ras_printed
= false;
17246 /* Skip dynamic neighbors. */
17247 if (peer_dynamic_neighbor(peer
))
17251 addr
= peer
->conf_if
;
17255 /************************************
17256 ****** Global to the neighbor ******
17257 ************************************/
17258 if (peer
->conf_if
) {
17259 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
17260 vty_out(vty
, " neighbor %s interface v6only", addr
);
17262 vty_out(vty
, " neighbor %s interface", addr
);
17264 if (peer_group_active(peer
)) {
17265 vty_out(vty
, " peer-group %s", peer
->group
->name
);
17266 if_pg_printed
= true;
17267 } else if (peer
->as_type
== AS_SPECIFIED
) {
17268 vty_out(vty
, " remote-as %u", peer
->as
);
17269 if_ras_printed
= true;
17270 } else if (peer
->as_type
== AS_INTERNAL
) {
17271 vty_out(vty
, " remote-as internal");
17272 if_ras_printed
= true;
17273 } else if (peer
->as_type
== AS_EXTERNAL
) {
17274 vty_out(vty
, " remote-as external");
17275 if_ras_printed
= true;
17278 vty_out(vty
, "\n");
17281 /* remote-as and peer-group */
17282 /* peer is a member of a peer-group */
17283 if (peer_group_active(peer
)) {
17284 g_peer
= peer
->group
->conf
;
17286 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
17287 if (peer
->as_type
== AS_SPECIFIED
) {
17288 vty_out(vty
, " neighbor %s remote-as %u\n",
17290 } else if (peer
->as_type
== AS_INTERNAL
) {
17292 " neighbor %s remote-as internal\n",
17294 } else if (peer
->as_type
== AS_EXTERNAL
) {
17296 " neighbor %s remote-as external\n",
17301 /* For swpX peers we displayed the peer-group
17302 * via 'neighbor swpX interface peer-group PGNAME' */
17303 if (!if_pg_printed
)
17304 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
17305 peer
->group
->name
);
17308 /* peer is NOT a member of a peer-group */
17310 /* peer is a peer-group, declare the peer-group */
17311 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
17312 vty_out(vty
, " neighbor %s peer-group\n", addr
);
17315 if (!if_ras_printed
) {
17316 if (peer
->as_type
== AS_SPECIFIED
) {
17317 vty_out(vty
, " neighbor %s remote-as %u\n",
17319 } else if (peer
->as_type
== AS_INTERNAL
) {
17321 " neighbor %s remote-as internal\n",
17323 } else if (peer
->as_type
== AS_EXTERNAL
) {
17325 " neighbor %s remote-as external\n",
17332 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
17333 vty_out(vty
, " neighbor %s local-as %u", addr
,
17334 peer
->change_local_as
);
17335 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
17336 vty_out(vty
, " no-prepend");
17337 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
17338 vty_out(vty
, " replace-as");
17339 vty_out(vty
, "\n");
17344 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
17348 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
17349 if (peer
->tx_shutdown_message
)
17350 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
17351 peer
->tx_shutdown_message
);
17353 vty_out(vty
, " neighbor %s shutdown\n", addr
);
17356 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
17357 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
17358 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
17361 if (peer
->bfd_config
)
17362 bgp_bfd_peer_config_write(vty
, peer
, addr
);
17365 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
17366 vty_out(vty
, " neighbor %s password %s\n", addr
,
17369 /* neighbor solo */
17370 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
17371 if (!peer_group_active(peer
)) {
17372 vty_out(vty
, " neighbor %s solo\n", addr
);
17377 if (peer
->port
!= BGP_PORT_DEFAULT
) {
17378 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
17381 /* Local interface name */
17382 if (peer
->ifname
) {
17383 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
17386 /* TCP max segment size */
17387 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_TCP_MSS
))
17388 vty_out(vty
, " neighbor %s tcp-mss %d\n", addr
, peer
->tcp_mss
);
17391 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
17392 vty_out(vty
, " neighbor %s passive\n", addr
);
17394 /* ebgp-multihop */
17395 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
17396 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
17397 && peer
->ttl
== MAXTTL
)) {
17398 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
17399 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
17405 if (peergroup_flag_check(peer
, PEER_FLAG_AIGP
))
17406 vty_out(vty
, " neighbor %s aigp\n", addr
);
17408 /* graceful-shutdown */
17409 if (peergroup_flag_check(peer
, PEER_FLAG_GRACEFUL_SHUTDOWN
))
17410 vty_out(vty
, " neighbor %s graceful-shutdown\n", addr
);
17413 if (peergroup_flag_check(peer
, PEER_FLAG_ROLE
) &&
17414 peer
->local_role
!= ROLE_UNDEFINED
)
17415 vty_out(vty
, " neighbor %s local-role %s%s\n", addr
,
17416 bgp_get_name_by_role(peer
->local_role
),
17417 CHECK_FLAG(peer
->flags
, PEER_FLAG_ROLE_STRICT_MODE
)
17421 /* ttl-security hops */
17422 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
17423 if (!peer_group_active(peer
)
17424 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
17425 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
17426 addr
, peer
->gtsm_hops
);
17430 /* disable-connected-check */
17431 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
17432 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
17434 /* link-bw-encoding-ieee */
17435 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
))
17436 vty_out(vty
, " neighbor %s disable-link-bw-encoding-ieee\n",
17439 /* extended-optional-parameters */
17440 if (peergroup_flag_check(peer
, PEER_FLAG_EXTENDED_OPT_PARAMS
))
17441 vty_out(vty
, " neighbor %s extended-optional-parameters\n",
17444 /* enforce-first-as */
17445 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
17446 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
17448 /* update-source */
17449 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
17450 if (peer
->update_source
)
17451 vty_out(vty
, " neighbor %s update-source %pSU\n", addr
,
17452 peer
->update_source
);
17453 else if (peer
->update_if
)
17454 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
17458 /* advertisement-interval */
17459 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
17460 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
17464 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
17465 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
17466 peer
->keepalive
, peer
->holdtime
);
17468 /* timers connect */
17469 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
17470 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17472 /* need special-case handling for changed default values due to
17473 * config profile / version (because there is no "timers bgp connect"
17474 * command, we need to save this per-peer :/)
17476 else if (!peer_group_active(peer
) && !peer
->connect
&&
17477 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
17478 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
17479 peer
->bgp
->default_connect_retry
);
17481 /* timers delayopen */
17482 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
17483 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17485 /* Save config even though flag is not set if default values have been
17488 else if (!peer_group_active(peer
) && !peer
->delayopen
17489 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
17490 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
17491 peer
->bgp
->default_delayopen
);
17493 /* capability dynamic */
17494 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
17495 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
17497 /* capability extended-nexthop */
17498 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
17499 if (CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
) &&
17502 " no neighbor %s capability extended-nexthop\n",
17504 else if (!peer
->conf_if
)
17506 " neighbor %s capability extended-nexthop\n",
17510 /* dont-capability-negotiation */
17511 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
17512 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
17514 /* override-capability */
17515 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
17516 vty_out(vty
, " neighbor %s override-capability\n", addr
);
17518 /* strict-capability-match */
17519 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
17520 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
17522 /* Sender side AS path loop detection. */
17523 if (peer
->as_path_loop_detection
)
17524 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
17527 /* path-attribute discard */
17528 char discard_attrs_str
[BUFSIZ
] = {0};
17529 bool discard_attrs
= bgp_path_attribute_discard(
17530 peer
, discard_attrs_str
, sizeof(discard_attrs_str
));
17533 vty_out(vty
, " neighbor %s path-attribute discard %s\n", addr
,
17534 discard_attrs_str
);
17536 /* path-attribute treat-as-withdraw */
17537 char withdraw_attrs_str
[BUFSIZ
] = {0};
17538 bool withdraw_attrs
= bgp_path_attribute_treat_as_withdraw(
17539 peer
, withdraw_attrs_str
, sizeof(withdraw_attrs_str
));
17541 if (withdraw_attrs
)
17543 " neighbor %s path-attribute treat-as-withdraw %s\n",
17544 addr
, withdraw_attrs_str
);
17546 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17547 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
17549 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17550 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
17552 " neighbor %s graceful-restart-helper\n", addr
);
17553 } else if (CHECK_FLAG(
17554 peer
->peer_gr_new_status_flag
,
17555 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
17557 " neighbor %s graceful-restart\n", addr
);
17559 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
17560 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
17562 peer
->peer_gr_new_status_flag
,
17563 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
17564 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
17570 /* BGP peer configuration display function. */
17571 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
17572 struct peer
*peer
, afi_t afi
, safi_t safi
)
17574 struct peer
*g_peer
= NULL
;
17576 bool flag_scomm
, flag_secomm
, flag_slcomm
;
17578 /* Skip dynamic neighbors. */
17579 if (peer_dynamic_neighbor(peer
))
17583 addr
= peer
->conf_if
;
17587 /************************************
17588 ****** Per AF to the neighbor ******
17589 ************************************/
17590 if (peer_group_active(peer
)) {
17591 g_peer
= peer
->group
->conf
;
17593 /* If the peer-group is active but peer is not, print a 'no
17595 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
17596 vty_out(vty
, " no neighbor %s activate\n", addr
);
17599 /* If the peer-group is not active but peer is, print an
17601 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
17602 vty_out(vty
, " neighbor %s activate\n", addr
);
17605 if (peer
->afc
[afi
][safi
]) {
17606 if (safi
== SAFI_ENCAP
)
17607 vty_out(vty
, " neighbor %s activate\n", addr
);
17608 else if (!bgp
->default_af
[afi
][safi
])
17609 vty_out(vty
, " neighbor %s activate\n", addr
);
17611 if (bgp
->default_af
[afi
][safi
])
17612 vty_out(vty
, " no neighbor %s activate\n",
17617 /* addpath TX knobs */
17618 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
17619 switch (peer
->addpath_type
[afi
][safi
]) {
17620 case BGP_ADDPATH_ALL
:
17621 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
17624 case BGP_ADDPATH_BEST_PER_AS
:
17626 " neighbor %s addpath-tx-bestpath-per-AS\n",
17629 case BGP_ADDPATH_MAX
:
17630 case BGP_ADDPATH_NONE
:
17635 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_DISABLE_ADDPATH_RX
))
17636 vty_out(vty
, " neighbor %s disable-addpath-rx\n", addr
);
17638 /* ORF capability. */
17639 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17640 || peergroup_af_flag_check(peer
, afi
, safi
,
17641 PEER_FLAG_ORF_PREFIX_RM
)) {
17642 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17644 if (peergroup_af_flag_check(peer
, afi
, safi
,
17645 PEER_FLAG_ORF_PREFIX_SM
)
17646 && peergroup_af_flag_check(peer
, afi
, safi
,
17647 PEER_FLAG_ORF_PREFIX_RM
))
17648 vty_out(vty
, " both");
17649 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17650 PEER_FLAG_ORF_PREFIX_SM
))
17651 vty_out(vty
, " send");
17653 vty_out(vty
, " receive");
17654 vty_out(vty
, "\n");
17657 /* Route reflector client. */
17658 if (peergroup_af_flag_check(peer
, afi
, safi
,
17659 PEER_FLAG_REFLECTOR_CLIENT
)) {
17660 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17663 /* next-hop-self force */
17664 if (peergroup_af_flag_check(peer
, afi
, safi
,
17665 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17666 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17669 /* next-hop-self */
17670 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17671 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17674 /* remove-private-AS */
17675 if (peergroup_af_flag_check(peer
, afi
, safi
,
17676 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17677 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17681 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17682 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17683 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17687 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17688 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17689 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17692 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17693 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17694 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17698 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17699 vty_out(vty
, " neighbor %s as-override\n", addr
);
17702 /* send-community print. */
17703 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17704 PEER_FLAG_SEND_COMMUNITY
);
17705 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17706 PEER_FLAG_SEND_EXT_COMMUNITY
);
17707 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17708 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17710 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17711 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17714 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17717 " no neighbor %s send-community extended\n",
17721 vty_out(vty
, " no neighbor %s send-community large\n",
17725 /* Default information */
17726 if (peergroup_af_flag_check(peer
, afi
, safi
,
17727 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17728 vty_out(vty
, " neighbor %s default-originate", addr
);
17730 if (peer
->default_rmap
[afi
][safi
].name
)
17731 vty_out(vty
, " route-map %s",
17732 peer
->default_rmap
[afi
][safi
].name
);
17734 vty_out(vty
, "\n");
17737 /* Soft reconfiguration inbound. */
17738 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17739 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17743 /* maximum-prefix. */
17744 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17745 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17746 peer
->pmax
[afi
][safi
]);
17748 if (peer
->pmax_threshold
[afi
][safi
]
17749 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17750 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17751 if (peer_af_flag_check(peer
, afi
, safi
,
17752 PEER_FLAG_MAX_PREFIX_WARNING
))
17753 vty_out(vty
, " warning-only");
17754 if (peer
->pmax_restart
[afi
][safi
])
17755 vty_out(vty
, " restart %u",
17756 peer
->pmax_restart
[afi
][safi
]);
17757 if (peer_af_flag_check(peer
, afi
, safi
,
17758 PEER_FLAG_MAX_PREFIX_FORCE
))
17759 vty_out(vty
, " force");
17761 vty_out(vty
, "\n");
17764 /* maximum-prefix-out */
17765 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17766 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17767 addr
, peer
->pmax_out
[afi
][safi
]);
17769 /* Route server client. */
17770 if (peergroup_af_flag_check(peer
, afi
, safi
,
17771 PEER_FLAG_RSERVER_CLIENT
)) {
17772 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17775 /* Nexthop-local unchanged. */
17776 if (peergroup_af_flag_check(peer
, afi
, safi
,
17777 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17778 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17781 /* allowas-in <1-10> */
17782 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17783 if (peer_af_flag_check(peer
, afi
, safi
,
17784 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17785 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17786 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17787 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17789 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17790 peer
->allowas_in
[afi
][safi
]);
17795 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ACCEPT_OWN
))
17796 vty_out(vty
, " neighbor %s accept-own\n", addr
);
17799 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOO
)) {
17800 char *soo_str
= ecommunity_ecom2str(
17801 peer
->soo
[afi
][safi
], ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
17803 vty_out(vty
, " neighbor %s soo %s\n", addr
, soo_str
);
17804 XFREE(MTYPE_ECOMMUNITY_STR
, soo_str
);
17808 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17809 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17810 peer
->weight
[afi
][safi
]);
17813 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17815 /* atribute-unchanged. */
17816 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17817 || (safi
!= SAFI_EVPN
17818 && peer_af_flag_check(peer
, afi
, safi
,
17819 PEER_FLAG_NEXTHOP_UNCHANGED
))
17820 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17822 if (!peer_group_active(peer
)
17823 || peergroup_af_flag_check(peer
, afi
, safi
,
17824 PEER_FLAG_AS_PATH_UNCHANGED
)
17825 || peergroup_af_flag_check(peer
, afi
, safi
,
17826 PEER_FLAG_NEXTHOP_UNCHANGED
)
17827 || peergroup_af_flag_check(peer
, afi
, safi
,
17828 PEER_FLAG_MED_UNCHANGED
)) {
17831 " neighbor %s attribute-unchanged%s%s%s\n",
17833 peer_af_flag_check(peer
, afi
, safi
,
17834 PEER_FLAG_AS_PATH_UNCHANGED
)
17837 peer_af_flag_check(peer
, afi
, safi
,
17838 PEER_FLAG_NEXTHOP_UNCHANGED
)
17841 peer_af_flag_check(peer
, afi
, safi
,
17842 PEER_FLAG_MED_UNCHANGED
)
17849 static void bgp_vpn_config_write(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17852 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17853 BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL
))
17854 vty_out(vty
, " no bgp retain route-target all\n");
17857 /* Address family based peer configuration display. */
17858 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17862 struct peer_group
*group
;
17863 struct listnode
*node
, *nnode
;
17866 vty_frame(vty
, " !\n address-family ");
17867 if (afi
== AFI_IP
) {
17868 if (safi
== SAFI_UNICAST
)
17869 vty_frame(vty
, "ipv4 unicast");
17870 else if (safi
== SAFI_LABELED_UNICAST
)
17871 vty_frame(vty
, "ipv4 labeled-unicast");
17872 else if (safi
== SAFI_MULTICAST
)
17873 vty_frame(vty
, "ipv4 multicast");
17874 else if (safi
== SAFI_MPLS_VPN
)
17875 vty_frame(vty
, "ipv4 vpn");
17876 else if (safi
== SAFI_ENCAP
)
17877 vty_frame(vty
, "ipv4 encap");
17878 else if (safi
== SAFI_FLOWSPEC
)
17879 vty_frame(vty
, "ipv4 flowspec");
17880 } else if (afi
== AFI_IP6
) {
17881 if (safi
== SAFI_UNICAST
)
17882 vty_frame(vty
, "ipv6 unicast");
17883 else if (safi
== SAFI_LABELED_UNICAST
)
17884 vty_frame(vty
, "ipv6 labeled-unicast");
17885 else if (safi
== SAFI_MULTICAST
)
17886 vty_frame(vty
, "ipv6 multicast");
17887 else if (safi
== SAFI_MPLS_VPN
)
17888 vty_frame(vty
, "ipv6 vpn");
17889 else if (safi
== SAFI_ENCAP
)
17890 vty_frame(vty
, "ipv6 encap");
17891 else if (safi
== SAFI_FLOWSPEC
)
17892 vty_frame(vty
, "ipv6 flowspec");
17893 } else if (afi
== AFI_L2VPN
) {
17894 if (safi
== SAFI_EVPN
)
17895 vty_frame(vty
, "l2vpn evpn");
17897 vty_frame(vty
, "\n");
17899 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17901 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17903 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17905 /* BGP flag dampening. */
17906 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17907 bgp_config_write_damp(vty
, afi
, safi
);
17909 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17910 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17912 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17913 /* Do not display doppelganger peers */
17914 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17915 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17918 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17919 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17921 if (safi
== SAFI_EVPN
)
17922 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17924 if (safi
== SAFI_FLOWSPEC
)
17925 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17927 if (safi
== SAFI_MPLS_VPN
)
17928 bgp_vpn_config_write(vty
, bgp
, afi
, safi
);
17930 if (safi
== SAFI_UNICAST
) {
17931 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17932 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17933 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17935 vty_out(vty
, " export vpn\n");
17937 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17938 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17940 vty_out(vty
, " import vpn\n");
17942 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17943 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17946 for (ALL_LIST_ELEMENTS_RO(
17947 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17949 vty_out(vty
, " import vrf %s\n", name
);
17953 vty_endframe(vty
, " exit-address-family\n");
17956 int bgp_config_write(struct vty
*vty
)
17959 struct peer_group
*group
;
17961 struct listnode
*node
, *nnode
;
17962 struct listnode
*mnode
, *mnnode
;
17965 uint32_t tovpn_sid_index
= 0;
17967 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17968 vty_out(vty
, "bgp route-map delay-timer %u\n",
17969 bm
->rmap_update_timer
);
17971 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17972 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17973 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17974 vty_out(vty
, " %d", bm
->v_establish_wait
);
17975 vty_out(vty
, "\n");
17978 if (bm
->wait_for_fib
)
17979 vty_out(vty
, "bgp suppress-fib-pending\n");
17981 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17982 vty_out(vty
, "bgp graceful-shutdown\n");
17984 /* No-RIB (Zebra) option flag configuration */
17985 if (bgp_option_check(BGP_OPT_NO_FIB
))
17986 vty_out(vty
, "bgp no-rib\n");
17988 if (CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17989 vty_out(vty
, "bgp send-extra-data zebra\n");
17991 /* BGP session DSCP value */
17992 if (bm
->tcp_dscp
!= IPTOS_PREC_INTERNETCONTROL
)
17993 vty_out(vty
, "bgp session-dscp %u\n", bm
->tcp_dscp
>> 2);
17995 /* BGP InQ limit */
17996 if (bm
->inq_limit
!= BM_DEFAULT_Q_LIMIT
)
17997 vty_out(vty
, "bgp input-queue-limit %u\n", bm
->inq_limit
);
17999 if (bm
->outq_limit
!= BM_DEFAULT_Q_LIMIT
)
18000 vty_out(vty
, "bgp output-queue-limit %u\n", bm
->outq_limit
);
18002 /* BGP configuration. */
18003 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
18005 /* skip all auto created vrf as they dont have user config */
18006 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
18009 /* Router bgp ASN */
18010 vty_out(vty
, "router bgp %u", bgp
->as
);
18013 vty_out(vty
, " %s %s",
18014 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
18015 ? "view" : "vrf", bgp
->name
);
18016 vty_out(vty
, "\n");
18018 /* BGP fast-external-failover. */
18019 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
18020 vty_out(vty
, " no bgp fast-external-failover\n");
18022 /* BGP router ID. */
18023 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
18024 vty_out(vty
, " bgp router-id %pI4\n",
18025 &bgp
->router_id_static
);
18027 /* Suppress fib pending */
18028 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
18029 vty_out(vty
, " bgp suppress-fib-pending\n");
18031 /* BGP log-neighbor-changes. */
18032 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
18033 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
18034 vty_out(vty
, " %sbgp log-neighbor-changes\n",
18035 CHECK_FLAG(bgp
->flags
,
18036 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
18040 /* BGP configuration. */
18041 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
18042 vty_out(vty
, " bgp always-compare-med\n");
18044 /* RFC8212 default eBGP policy. */
18045 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
18046 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
18047 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
18048 CHECK_FLAG(bgp
->flags
,
18049 BGP_FLAG_EBGP_REQUIRES_POLICY
)
18053 /* draft-ietf-idr-deprecate-as-set-confed-set */
18054 if (bgp
->reject_as_sets
)
18055 vty_out(vty
, " bgp reject-as-sets\n");
18057 /* Suppress duplicate updates if the route actually not changed
18059 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
18060 != SAVE_BGP_SUPPRESS_DUPLICATES
)
18061 vty_out(vty
, " %sbgp suppress-duplicates\n",
18062 CHECK_FLAG(bgp
->flags
,
18063 BGP_FLAG_SUPPRESS_DUPLICATES
)
18067 /* Send Hard Reset CEASE Notification for 'Administrative Reset'
18069 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_HARD_ADMIN_RESET
) !=
18070 SAVE_BGP_HARD_ADMIN_RESET
)
18071 vty_out(vty
, " %sbgp hard-administrative-reset\n",
18072 CHECK_FLAG(bgp
->flags
,
18073 BGP_FLAG_HARD_ADMIN_RESET
)
18077 /* BGP default <afi>-<safi> */
18078 FOREACH_AFI_SAFI (afi
, safi
) {
18079 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
) {
18080 if (!bgp
->default_af
[afi
][safi
])
18081 vty_out(vty
, " no bgp default %s\n",
18082 get_bgp_default_af_flag(afi
,
18084 } else if (bgp
->default_af
[afi
][safi
])
18085 vty_out(vty
, " bgp default %s\n",
18086 get_bgp_default_af_flag(afi
, safi
));
18089 /* BGP default local-preference. */
18090 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
18091 vty_out(vty
, " bgp default local-preference %u\n",
18092 bgp
->default_local_pref
);
18094 /* BGP default show-hostname */
18095 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
18096 != SAVE_BGP_SHOW_HOSTNAME
)
18097 vty_out(vty
, " %sbgp default show-hostname\n",
18098 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
18102 /* BGP default show-nexthop-hostname */
18103 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
18104 != SAVE_BGP_SHOW_HOSTNAME
)
18105 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
18106 CHECK_FLAG(bgp
->flags
,
18107 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
18111 /* BGP default subgroup-pkt-queue-max. */
18112 if (bgp
->default_subgroup_pkt_queue_max
18113 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
18114 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
18115 bgp
->default_subgroup_pkt_queue_max
);
18117 /* BGP client-to-client reflection. */
18118 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
18119 vty_out(vty
, " no bgp client-to-client reflection\n");
18121 /* BGP cluster ID. */
18122 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
18123 vty_out(vty
, " bgp cluster-id %pI4\n",
18126 /* Disable ebgp connected nexthop check */
18127 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
18129 " bgp disable-ebgp-connected-route-check\n");
18131 /* Confederation identifier*/
18132 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
18133 vty_out(vty
, " bgp confederation identifier %u\n",
18136 /* Confederation peer */
18137 if (bgp
->confed_peers_cnt
> 0) {
18140 vty_out(vty
, " bgp confederation peers");
18142 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
18143 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
18145 vty_out(vty
, "\n");
18148 /* BGP deterministic-med. */
18149 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
18150 != SAVE_BGP_DETERMINISTIC_MED
)
18151 vty_out(vty
, " %sbgp deterministic-med\n",
18152 CHECK_FLAG(bgp
->flags
,
18153 BGP_FLAG_DETERMINISTIC_MED
)
18157 /* BGP update-delay. */
18158 bgp_config_write_update_delay(vty
, bgp
);
18160 if (bgp
->v_maxmed_onstartup
18161 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
18162 vty_out(vty
, " bgp max-med on-startup %u",
18163 bgp
->v_maxmed_onstartup
);
18164 if (bgp
->maxmed_onstartup_value
18165 != BGP_MAXMED_VALUE_DEFAULT
)
18166 vty_out(vty
, " %u",
18167 bgp
->maxmed_onstartup_value
);
18168 vty_out(vty
, "\n");
18170 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
18171 vty_out(vty
, " bgp max-med administrative");
18172 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
18173 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
18174 vty_out(vty
, "\n");
18178 bgp_config_write_wpkt_quanta(vty
, bgp
);
18180 bgp_config_write_rpkt_quanta(vty
, bgp
);
18182 /* coalesce time */
18183 bgp_config_write_coalesce_time(vty
, bgp
);
18185 /* BGP per-instance graceful-shutdown */
18186 /* BGP-wide settings and per-instance settings are mutually
18189 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
18190 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
18191 vty_out(vty
, " bgp graceful-shutdown\n");
18193 /* Long-lived Graceful Restart */
18194 if (bgp
->llgr_stale_time
!= BGP_DEFAULT_LLGR_STALE_TIME
)
18196 " bgp long-lived-graceful-restart stale-time %u\n",
18197 bgp
->llgr_stale_time
);
18199 /* BGP graceful-restart. */
18200 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
18202 " bgp graceful-restart stalepath-time %u\n",
18203 bgp
->stalepath_time
);
18205 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
18206 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
18207 bgp
->restart_time
);
18209 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_NOTIFICATION
) !=
18210 SAVE_BGP_GRACEFUL_NOTIFICATION
)
18211 vty_out(vty
, " %sbgp graceful-restart notification\n",
18212 CHECK_FLAG(bgp
->flags
,
18213 BGP_FLAG_GRACEFUL_NOTIFICATION
)
18217 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
18219 " bgp graceful-restart select-defer-time %u\n",
18220 bgp
->select_defer_time
);
18222 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
18223 vty_out(vty
, " bgp graceful-restart\n");
18225 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
18226 vty_out(vty
, " bgp graceful-restart-disable\n");
18228 /* BGP graceful-restart Preserve State F bit. */
18229 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
18231 " bgp graceful-restart preserve-fw-state\n");
18233 /* BGP TCP keepalive */
18234 bgp_config_tcp_keepalive(vty
, bgp
);
18236 /* Stale timer for RIB */
18237 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
18239 " bgp graceful-restart rib-stale-time %u\n",
18240 bgp
->rib_stale_time
);
18242 /* BGP bestpath method. */
18243 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
18244 vty_out(vty
, " bgp bestpath as-path ignore\n");
18245 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
18246 vty_out(vty
, " bgp bestpath as-path confed\n");
18248 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
18249 if (CHECK_FLAG(bgp
->flags
,
18250 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
18252 " bgp bestpath as-path multipath-relax as-set\n");
18255 " bgp bestpath as-path multipath-relax\n");
18259 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
18261 " bgp route-reflector allow-outbound-policy\n");
18263 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
18264 vty_out(vty
, " bgp bestpath compare-routerid\n");
18265 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_AIGP
))
18266 vty_out(vty
, " bgp bestpath aigp\n");
18267 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
18268 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
18269 vty_out(vty
, " bgp bestpath med");
18270 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
18271 vty_out(vty
, " confed");
18272 if (CHECK_FLAG(bgp
->flags
,
18273 BGP_FLAG_MED_MISSING_AS_WORST
))
18274 vty_out(vty
, " missing-as-worst");
18275 vty_out(vty
, "\n");
18278 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX
))
18280 " bgp bestpath peer-type multipath-relax\n");
18282 /* Link bandwidth handling. */
18283 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
18284 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
18285 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
18286 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
18287 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
18288 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
18290 /* BGP network import check. */
18291 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18292 != SAVE_BGP_IMPORT_CHECK
)
18293 vty_out(vty
, " %sbgp network import-check\n",
18294 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
18298 /* BGP timers configuration. */
18299 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
18300 || bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
18301 vty_out(vty
, " timers bgp %u %u\n",
18302 bgp
->default_keepalive
, bgp
->default_holdtime
);
18304 /* BGP minimum holdtime configuration. */
18305 if (bgp
->default_min_holdtime
!= SAVE_BGP_HOLDTIME
18306 && bgp
->default_min_holdtime
!= 0)
18307 vty_out(vty
, " bgp minimum-holdtime %u\n",
18308 bgp
->default_min_holdtime
);
18310 /* Conditional advertisement timer configuration */
18311 if (bgp
->condition_check_period
18312 != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME
)
18314 " bgp conditional-advertisement timer %u\n",
18315 bgp
->condition_check_period
);
18318 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
18319 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
18322 /* Normal neighbor configuration. */
18323 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
18324 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
18325 bgp_config_write_peer_global(vty
, bgp
, peer
);
18328 /* listen range and limit for dynamic BGP neighbors */
18329 bgp_config_write_listen(vty
, bgp
);
18332 * BGP default autoshutdown neighbors
18334 * This must be placed after any peer and peer-group
18335 * configuration, to avoid setting all peers to shutdown after
18336 * a daemon restart, which is undesired behavior. (see #2286)
18338 if (bgp
->autoshutdown
)
18339 vty_out(vty
, " bgp default shutdown\n");
18341 /* BGP instance administrative shutdown */
18342 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
18343 vty_out(vty
, " bgp shutdown\n");
18345 if (bgp
->allow_martian
)
18346 vty_out(vty
, " bgp allow-martian-nexthop\n");
18348 if (bgp
->fast_convergence
)
18349 vty_out(vty
, " bgp fast-convergence\n");
18351 if (bgp
->srv6_enabled
) {
18352 vty_frame(vty
, " !\n segment-routing srv6\n");
18353 if (strlen(bgp
->srv6_locator_name
))
18354 vty_out(vty
, " locator %s\n",
18355 bgp
->srv6_locator_name
);
18356 vty_endframe(vty
, " exit\n");
18359 tovpn_sid_index
= bgp
->tovpn_sid_index
;
18360 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_TOVPN_SID_AUTO
)) {
18361 vty_out(vty
, " sid vpn per-vrf export auto\n");
18362 } else if (tovpn_sid_index
!= 0) {
18363 vty_out(vty
, " sid vpn per-vrf export %d\n",
18367 /* IPv4 unicast configuration. */
18368 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
18370 /* IPv4 multicast configuration. */
18371 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
18373 /* IPv4 labeled-unicast configuration. */
18374 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
18376 /* IPv4 VPN configuration. */
18377 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
18379 /* ENCAPv4 configuration. */
18380 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
18382 /* FLOWSPEC v4 configuration. */
18383 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
18385 /* IPv6 unicast configuration. */
18386 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
18388 /* IPv6 multicast configuration. */
18389 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
18391 /* IPv6 labeled-unicast configuration. */
18392 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
18393 SAFI_LABELED_UNICAST
);
18395 /* IPv6 VPN configuration. */
18396 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
18398 /* ENCAPv6 configuration. */
18399 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
18401 /* FLOWSPEC v6 configuration. */
18402 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
18404 /* EVPN configuration. */
18405 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
18407 hook_call(bgp_inst_config_write
, bgp
, vty
);
18409 #ifdef ENABLE_BGP_VNC
18410 bgp_rfapi_cfg_write(vty
, bgp
);
18413 vty_out(vty
, "exit\n");
18414 vty_out(vty
, "!\n");
18420 /* BGP node structure. */
18421 static struct cmd_node bgp_node
= {
18424 .parent_node
= CONFIG_NODE
,
18425 .prompt
= "%s(config-router)# ",
18426 .config_write
= bgp_config_write
,
18429 static struct cmd_node bgp_ipv4_unicast_node
= {
18430 .name
= "bgp ipv4 unicast",
18431 .node
= BGP_IPV4_NODE
,
18432 .parent_node
= BGP_NODE
,
18433 .prompt
= "%s(config-router-af)# ",
18437 static struct cmd_node bgp_ipv4_multicast_node
= {
18438 .name
= "bgp ipv4 multicast",
18439 .node
= BGP_IPV4M_NODE
,
18440 .parent_node
= BGP_NODE
,
18441 .prompt
= "%s(config-router-af)# ",
18445 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
18446 .name
= "bgp ipv4 labeled unicast",
18447 .node
= BGP_IPV4L_NODE
,
18448 .parent_node
= BGP_NODE
,
18449 .prompt
= "%s(config-router-af)# ",
18453 static struct cmd_node bgp_ipv6_unicast_node
= {
18454 .name
= "bgp ipv6 unicast",
18455 .node
= BGP_IPV6_NODE
,
18456 .parent_node
= BGP_NODE
,
18457 .prompt
= "%s(config-router-af)# ",
18461 static struct cmd_node bgp_ipv6_multicast_node
= {
18462 .name
= "bgp ipv6 multicast",
18463 .node
= BGP_IPV6M_NODE
,
18464 .parent_node
= BGP_NODE
,
18465 .prompt
= "%s(config-router-af)# ",
18469 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
18470 .name
= "bgp ipv6 labeled unicast",
18471 .node
= BGP_IPV6L_NODE
,
18472 .parent_node
= BGP_NODE
,
18473 .prompt
= "%s(config-router-af)# ",
18477 static struct cmd_node bgp_vpnv4_node
= {
18478 .name
= "bgp vpnv4",
18479 .node
= BGP_VPNV4_NODE
,
18480 .parent_node
= BGP_NODE
,
18481 .prompt
= "%s(config-router-af)# ",
18485 static struct cmd_node bgp_vpnv6_node
= {
18486 .name
= "bgp vpnv6",
18487 .node
= BGP_VPNV6_NODE
,
18488 .parent_node
= BGP_NODE
,
18489 .prompt
= "%s(config-router-af-vpnv6)# ",
18493 static struct cmd_node bgp_evpn_node
= {
18494 .name
= "bgp evpn",
18495 .node
= BGP_EVPN_NODE
,
18496 .parent_node
= BGP_NODE
,
18497 .prompt
= "%s(config-router-evpn)# ",
18501 static struct cmd_node bgp_evpn_vni_node
= {
18502 .name
= "bgp evpn vni",
18503 .node
= BGP_EVPN_VNI_NODE
,
18504 .parent_node
= BGP_EVPN_NODE
,
18505 .prompt
= "%s(config-router-af-vni)# ",
18508 static struct cmd_node bgp_flowspecv4_node
= {
18509 .name
= "bgp ipv4 flowspec",
18510 .node
= BGP_FLOWSPECV4_NODE
,
18511 .parent_node
= BGP_NODE
,
18512 .prompt
= "%s(config-router-af)# ",
18516 static struct cmd_node bgp_flowspecv6_node
= {
18517 .name
= "bgp ipv6 flowspec",
18518 .node
= BGP_FLOWSPECV6_NODE
,
18519 .parent_node
= BGP_NODE
,
18520 .prompt
= "%s(config-router-af-vpnv6)# ",
18524 static struct cmd_node bgp_srv6_node
= {
18525 .name
= "bgp srv6",
18526 .node
= BGP_SRV6_NODE
,
18527 .parent_node
= BGP_NODE
,
18528 .prompt
= "%s(config-router-srv6)# ",
18531 static void community_list_vty(void);
18533 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
18536 struct peer_group
*group
;
18537 struct listnode
*lnbgp
, *lnpeer
;
18539 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18540 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
18542 XSTRDUP(MTYPE_COMPLETION
, group
->name
));
18546 static void bgp_ac_peer(vector comps
, struct cmd_token
*token
)
18550 struct listnode
*lnbgp
, *lnpeer
;
18552 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
18553 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
18554 /* only provide suggestions on the appropriate input
18556 * they'll otherwise show up multiple times */
18557 enum cmd_token_type match_type
;
18558 char *name
= peer
->host
;
18560 if (peer
->conf_if
) {
18561 match_type
= VARIABLE_TKN
;
18562 name
= peer
->conf_if
;
18563 } else if (strchr(peer
->host
, ':'))
18564 match_type
= IPV6_TKN
;
18566 match_type
= IPV4_TKN
;
18568 if (token
->type
!= match_type
)
18571 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
18576 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
18578 bgp_ac_peer(comps
, token
);
18580 if (token
->type
== VARIABLE_TKN
)
18581 bgp_ac_peergroup(comps
, token
);
18584 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
18585 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
18586 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
18587 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
18588 {.completions
= NULL
}};
18590 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
18591 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
18592 {.completions
= NULL
} };
18594 DEFINE_HOOK(bgp_config_end
, (struct bgp
*bgp
), (bgp
));
18596 static struct thread
*t_bgp_cfg
;
18598 bool bgp_config_inprocess(void)
18600 return thread_is_scheduled(t_bgp_cfg
);
18603 static void bgp_config_finish(struct thread
*t
)
18605 struct listnode
*node
;
18608 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, bgp
))
18609 hook_call(bgp_config_end
, bgp
);
18612 static void bgp_config_start(void)
18614 #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600
18615 THREAD_OFF(t_bgp_cfg
);
18616 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18617 BGP_PRE_CONFIG_MAX_WAIT_SECONDS
, &t_bgp_cfg
);
18620 /* When we receive a hook the configuration is read,
18621 * we start a timer to make sure we postpone sending
18622 * EoR before route-maps are processed.
18623 * This is especially valid if using `bgp route-map delay-timer`.
18625 static void bgp_config_end(void)
18627 #define BGP_POST_CONFIG_DELAY_SECONDS 1
18628 uint32_t bgp_post_config_delay
=
18629 thread_is_scheduled(bm
->t_rmap_update
)
18630 ? thread_timer_remain_second(bm
->t_rmap_update
)
18631 : BGP_POST_CONFIG_DELAY_SECONDS
;
18633 /* If BGP config processing thread isn't running, then
18634 * we can return and rely it's properly handled.
18636 if (!bgp_config_inprocess())
18639 THREAD_OFF(t_bgp_cfg
);
18641 /* Start a new timer to make sure we don't send EoR
18642 * before route-maps are processed.
18644 thread_add_timer(bm
->master
, bgp_config_finish
, NULL
,
18645 bgp_post_config_delay
, &t_bgp_cfg
);
18648 static int config_write_interface_one(struct vty
*vty
, struct vrf
*vrf
)
18651 struct interface
*ifp
;
18652 struct bgp_interface
*iifp
;
18654 FOR_ALL_INTERFACES (vrf
, ifp
) {
18659 if_vty_config_start(vty
, ifp
);
18661 if (CHECK_FLAG(iifp
->flags
,
18662 BGP_INTERFACE_MPLS_BGP_FORWARDING
)) {
18663 vty_out(vty
, " mpls bgp forwarding\n");
18667 if_vty_config_end(vty
);
18673 /* Configuration write function for bgpd. */
18674 static int config_write_interface(struct vty
*vty
)
18677 struct vrf
*vrf
= NULL
;
18679 /* Display all VRF aware OSPF interface configuration */
18680 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
18681 write
+= config_write_interface_one(vty
, vrf
);
18687 DEFPY(mpls_bgp_forwarding
, mpls_bgp_forwarding_cmd
,
18688 "[no$no] mpls bgp forwarding",
18689 NO_STR MPLS_STR BGP_STR
18690 "Enable MPLS forwarding for eBGP directly connected peers\n")
18693 struct bgp_interface
*iifp
;
18695 VTY_DECLVAR_CONTEXT(interface
, ifp
);
18698 vty_out(vty
, "Interface %s not available\n", ifp
->name
);
18699 return CMD_WARNING_CONFIG_FAILED
;
18701 check
= CHECK_FLAG(iifp
->flags
, BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18702 if (check
!= !no
) {
18704 UNSET_FLAG(iifp
->flags
,
18705 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18707 SET_FLAG(iifp
->flags
,
18708 BGP_INTERFACE_MPLS_BGP_FORWARDING
);
18709 /* trigger a nht update on eBGP sessions */
18710 if (if_is_operative(ifp
))
18711 bgp_nht_ifp_up(ifp
);
18713 return CMD_SUCCESS
;
18716 DEFPY (bgp_inq_limit
,
18718 "bgp input-queue-limit (1-4294967295)$limit",
18720 "Set the BGP Input Queue limit for all peers when message parsing\n"
18721 "Input-Queue limit\n")
18723 bm
->inq_limit
= limit
;
18725 return CMD_SUCCESS
;
18728 DEFPY (no_bgp_inq_limit
,
18729 no_bgp_inq_limit_cmd
,
18730 "no bgp input-queue-limit [(1-4294967295)$limit]",
18733 "Set the BGP Input Queue limit for all peers when message parsing\n"
18734 "Input-Queue limit\n")
18736 bm
->inq_limit
= BM_DEFAULT_Q_LIMIT
;
18738 return CMD_SUCCESS
;
18741 DEFPY (bgp_outq_limit
,
18742 bgp_outq_limit_cmd
,
18743 "bgp output-queue-limit (1-4294967295)$limit",
18745 "Set the BGP Output Queue limit for all peers when message parsing\n"
18746 "Output-Queue limit\n")
18748 bm
->outq_limit
= limit
;
18750 return CMD_SUCCESS
;
18753 DEFPY (no_bgp_outq_limit
,
18754 no_bgp_outq_limit_cmd
,
18755 "no bgp output-queue-limit [(1-4294967295)$limit]",
18758 "Set the BGP Output Queue limit for all peers when message parsing\n"
18759 "Output-Queue limit\n")
18761 bm
->outq_limit
= BM_DEFAULT_Q_LIMIT
;
18763 return CMD_SUCCESS
;
18767 /* Initialization of BGP interface. */
18768 static void bgp_vty_if_init(void)
18770 /* Install interface node. */
18771 if_cmd_init(config_write_interface
);
18773 /* "mpls bgp forwarding" commands. */
18774 install_element(INTERFACE_NODE
, &mpls_bgp_forwarding_cmd
);
18777 void bgp_vty_init(void)
18779 cmd_variable_handler_register(bgp_var_neighbor
);
18780 cmd_variable_handler_register(bgp_var_peergroup
);
18782 cmd_init_config_callbacks(bgp_config_start
, bgp_config_end
);
18784 /* Install bgp top node. */
18785 install_node(&bgp_node
);
18786 install_node(&bgp_ipv4_unicast_node
);
18787 install_node(&bgp_ipv4_multicast_node
);
18788 install_node(&bgp_ipv4_labeled_unicast_node
);
18789 install_node(&bgp_ipv6_unicast_node
);
18790 install_node(&bgp_ipv6_multicast_node
);
18791 install_node(&bgp_ipv6_labeled_unicast_node
);
18792 install_node(&bgp_vpnv4_node
);
18793 install_node(&bgp_vpnv6_node
);
18794 install_node(&bgp_evpn_node
);
18795 install_node(&bgp_evpn_vni_node
);
18796 install_node(&bgp_flowspecv4_node
);
18797 install_node(&bgp_flowspecv6_node
);
18798 install_node(&bgp_srv6_node
);
18800 /* Install default VTY commands to new nodes. */
18801 install_default(BGP_NODE
);
18802 install_default(BGP_IPV4_NODE
);
18803 install_default(BGP_IPV4M_NODE
);
18804 install_default(BGP_IPV4L_NODE
);
18805 install_default(BGP_IPV6_NODE
);
18806 install_default(BGP_IPV6M_NODE
);
18807 install_default(BGP_IPV6L_NODE
);
18808 install_default(BGP_VPNV4_NODE
);
18809 install_default(BGP_VPNV6_NODE
);
18810 install_default(BGP_FLOWSPECV4_NODE
);
18811 install_default(BGP_FLOWSPECV6_NODE
);
18812 install_default(BGP_EVPN_NODE
);
18813 install_default(BGP_EVPN_VNI_NODE
);
18814 install_default(BGP_SRV6_NODE
);
18816 /* "global bgp inq-limit command */
18817 install_element(CONFIG_NODE
, &bgp_inq_limit_cmd
);
18818 install_element(CONFIG_NODE
, &no_bgp_inq_limit_cmd
);
18819 install_element(CONFIG_NODE
, &bgp_outq_limit_cmd
);
18820 install_element(CONFIG_NODE
, &no_bgp_outq_limit_cmd
);
18822 /* "bgp local-mac" hidden commands. */
18823 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
18824 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
18826 /* "bgp suppress-fib-pending" global */
18827 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
18829 /* bgp route-map delay-timer commands. */
18830 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18831 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18833 install_element(BGP_NODE
, &bgp_allow_martian_cmd
);
18835 /* bgp fast-convergence command */
18836 install_element(BGP_NODE
, &bgp_fast_convergence_cmd
);
18837 install_element(BGP_NODE
, &no_bgp_fast_convergence_cmd
);
18839 /* global bgp update-delay command */
18840 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
18841 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
18843 /* global bgp graceful-shutdown command */
18844 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
18845 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
18847 /* Dummy commands (Currently not supported) */
18848 install_element(BGP_NODE
, &no_synchronization_cmd
);
18849 install_element(BGP_NODE
, &no_auto_summary_cmd
);
18851 /* "router bgp" commands. */
18852 install_element(CONFIG_NODE
, &router_bgp_cmd
);
18854 /* "no router bgp" commands. */
18855 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
18857 /* "bgp session-dscp command */
18858 install_element(CONFIG_NODE
, &bgp_session_dscp_cmd
);
18859 install_element(CONFIG_NODE
, &no_bgp_session_dscp_cmd
);
18861 /* "bgp router-id" commands. */
18862 install_element(BGP_NODE
, &bgp_router_id_cmd
);
18863 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
18865 /* "bgp suppress-fib-pending" command */
18866 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
18868 /* "bgp cluster-id" commands. */
18869 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
18870 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
18872 /* "bgp no-rib" commands. */
18873 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
18874 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
18876 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
18878 /* "bgp confederation" commands. */
18879 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
18880 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
18882 /* "bgp confederation peers" commands. */
18883 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
18884 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
18886 /* bgp max-med command */
18887 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
18888 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
18889 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
18890 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
18891 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
18893 /* "neighbor role" commands. */
18894 install_element(BGP_NODE
, &neighbor_role_cmd
);
18895 install_element(BGP_NODE
, &neighbor_role_strict_cmd
);
18896 install_element(BGP_NODE
, &no_neighbor_role_cmd
);
18898 /* "neighbor aigp" commands. */
18899 install_element(BGP_NODE
, &neighbor_aigp_cmd
);
18901 /* "neighbor graceful-shutdown" command */
18902 install_element(BGP_NODE
, &neighbor_graceful_shutdown_cmd
);
18904 /* bgp disable-ebgp-connected-nh-check */
18905 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
18906 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
18908 /* bgp update-delay command */
18909 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
18910 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
18912 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
18913 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
18915 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
18916 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
18918 /* "maximum-paths" commands. */
18919 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
18920 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
18921 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
18922 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
18923 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
18924 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
18925 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
18926 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
18927 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
18928 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
18929 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18930 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18931 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
18932 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18933 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18935 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
18936 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
18937 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18938 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18939 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18940 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
18941 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
18942 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18943 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18944 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18946 /* "timers bgp" commands. */
18947 install_element(BGP_NODE
, &bgp_timers_cmd
);
18948 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
18950 /* "minimum-holdtime" commands. */
18951 install_element(BGP_NODE
, &bgp_minimum_holdtime_cmd
);
18952 install_element(BGP_NODE
, &no_bgp_minimum_holdtime_cmd
);
18954 /* route-map delay-timer commands - per instance for backwards compat.
18956 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18957 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18959 /* "bgp client-to-client reflection" commands */
18960 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
18961 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
18963 /* "bgp always-compare-med" commands */
18964 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
18965 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
18967 /* bgp ebgp-requires-policy */
18968 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
18969 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
18971 /* bgp suppress-duplicates */
18972 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
18973 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
18975 /* bgp reject-as-sets */
18976 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
18977 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
18979 /* "bgp deterministic-med" commands */
18980 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
18981 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
18983 /* "bgp graceful-restart" command */
18984 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
18985 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
18987 /* "bgp graceful-restart-disable" command */
18988 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
18989 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
18991 /* "neighbor a:b:c:d graceful-restart" command */
18992 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
18993 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
18995 /* "neighbor a:b:c:d graceful-restart-disable" command */
18996 install_element(BGP_NODE
,
18997 &bgp_neighbor_graceful_restart_disable_set_cmd
);
18998 install_element(BGP_NODE
,
18999 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
19001 /* "neighbor a:b:c:d graceful-restart-helper" command */
19002 install_element(BGP_NODE
,
19003 &bgp_neighbor_graceful_restart_helper_set_cmd
);
19004 install_element(BGP_NODE
,
19005 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
19007 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
19008 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
19009 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
19010 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
19011 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
19012 install_element(BGP_NODE
,
19013 &no_bgp_graceful_restart_select_defer_time_cmd
);
19014 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
19015 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
19016 install_element(BGP_NODE
, &bgp_graceful_restart_notification_cmd
);
19018 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
19019 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
19020 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
19021 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
19023 /* "bgp graceful-shutdown" commands */
19024 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
19025 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
19027 /* "bgp hard-administrative-reset" commands */
19028 install_element(BGP_NODE
, &bgp_administrative_reset_cmd
);
19030 /* "bgp long-lived-graceful-restart" commands */
19031 install_element(BGP_NODE
, &bgp_llgr_stalepath_time_cmd
);
19032 install_element(BGP_NODE
, &no_bgp_llgr_stalepath_time_cmd
);
19034 /* "bgp fast-external-failover" commands */
19035 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
19036 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
19038 /* "bgp bestpath aigp" commands */
19039 install_element(BGP_NODE
, &bgp_bestpath_aigp_cmd
);
19041 /* "bgp bestpath compare-routerid" commands */
19042 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
19043 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
19045 /* "bgp bestpath as-path ignore" commands */
19046 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
19047 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
19049 /* "bgp bestpath as-path confed" commands */
19050 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
19051 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
19053 /* "bgp bestpath as-path multipath-relax" commands */
19054 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
19055 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
19057 /* "bgp bestpath peer-type multipath-relax" commands */
19058 install_element(BGP_NODE
, &bgp_bestpath_peer_type_multipath_relax_cmd
);
19059 install_element(BGP_NODE
,
19060 &no_bgp_bestpath_peer_type_multipath_relax_cmd
);
19062 /* "bgp log-neighbor-changes" commands */
19063 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
19064 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
19066 /* "bgp bestpath med" commands */
19067 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
19068 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
19070 /* "bgp bestpath bandwidth" commands */
19071 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
19072 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
19074 /* "no bgp default <afi>-<safi>" commands. */
19075 install_element(BGP_NODE
, &bgp_default_afi_safi_cmd
);
19077 /* "bgp network import-check" commands. */
19078 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
19079 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
19080 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
19082 /* "bgp default local-preference" commands. */
19083 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
19084 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
19086 /* bgp default show-hostname */
19087 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
19088 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
19090 /* bgp default show-nexthop-hostname */
19091 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
19092 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
19094 /* "bgp default subgroup-pkt-queue-max" commands. */
19095 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
19096 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
19098 /* bgp ibgp-allow-policy-mods command */
19099 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
19100 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
19102 /* "bgp listen limit" commands. */
19103 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
19104 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
19106 /* "bgp listen range" commands. */
19107 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
19108 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
19110 /* "bgp default shutdown" command */
19111 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
19113 /* "bgp shutdown" commands */
19114 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
19115 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
19116 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
19117 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
19119 /* "neighbor remote-as" commands. */
19120 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
19121 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
19122 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
19123 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
19124 install_element(BGP_NODE
,
19125 &neighbor_interface_v6only_config_remote_as_cmd
);
19126 install_element(BGP_NODE
, &no_neighbor_cmd
);
19127 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
19129 /* "neighbor peer-group" commands. */
19130 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
19131 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
19132 install_element(BGP_NODE
,
19133 &no_neighbor_interface_peer_group_remote_as_cmd
);
19135 /* "neighbor local-as" commands. */
19136 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
19137 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
19138 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
19139 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
19141 /* "neighbor solo" commands. */
19142 install_element(BGP_NODE
, &neighbor_solo_cmd
);
19143 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
19145 /* "neighbor password" commands. */
19146 install_element(BGP_NODE
, &neighbor_password_cmd
);
19147 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
19149 /* "neighbor activate" commands. */
19150 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
19151 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
19152 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
19153 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
19154 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
19155 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
19156 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
19157 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
19158 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
19159 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
19160 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
19161 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
19163 /* "no neighbor activate" commands. */
19164 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
19165 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
19166 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
19167 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
19168 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
19169 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
19170 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
19171 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
19172 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
19173 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
19174 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
19175 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
19177 /* "neighbor peer-group" set commands. */
19178 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
19179 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19180 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19181 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19182 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19183 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19184 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19185 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
19186 install_element(BGP_FLOWSPECV4_NODE
,
19187 &neighbor_set_peer_group_hidden_cmd
);
19188 install_element(BGP_FLOWSPECV6_NODE
,
19189 &neighbor_set_peer_group_hidden_cmd
);
19191 /* "no neighbor peer-group unset" commands. */
19192 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
19193 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19194 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19195 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19196 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19197 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19198 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19199 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
19200 install_element(BGP_FLOWSPECV4_NODE
,
19201 &no_neighbor_set_peer_group_hidden_cmd
);
19202 install_element(BGP_FLOWSPECV6_NODE
,
19203 &no_neighbor_set_peer_group_hidden_cmd
);
19205 /* "neighbor softreconfiguration inbound" commands.*/
19206 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
19207 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
19208 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
19209 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19210 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
19211 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19212 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
19213 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19214 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
19215 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19216 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
19217 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19218 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
19219 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19220 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
19221 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19222 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
19223 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19224 install_element(BGP_FLOWSPECV4_NODE
,
19225 &neighbor_soft_reconfiguration_cmd
);
19226 install_element(BGP_FLOWSPECV4_NODE
,
19227 &no_neighbor_soft_reconfiguration_cmd
);
19228 install_element(BGP_FLOWSPECV6_NODE
,
19229 &neighbor_soft_reconfiguration_cmd
);
19230 install_element(BGP_FLOWSPECV6_NODE
,
19231 &no_neighbor_soft_reconfiguration_cmd
);
19232 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
19233 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
19235 /* "neighbor attribute-unchanged" commands. */
19236 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
19237 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
19238 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
19239 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19240 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
19241 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
19242 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
19243 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
19244 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
19245 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19246 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
19247 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
19248 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
19249 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
19250 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
19251 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19252 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
19253 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19255 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
19256 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
19258 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
19259 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
19260 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
19261 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
19263 /* "nexthop-local unchanged" commands */
19264 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
19265 install_element(BGP_IPV6_NODE
,
19266 &no_neighbor_nexthop_local_unchanged_cmd
);
19268 /* "neighbor next-hop-self" commands. */
19269 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
19270 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
19271 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
19272 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
19273 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
19274 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
19275 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
19276 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
19277 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
19278 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
19279 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
19280 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
19281 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
19282 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
19283 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
19284 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
19285 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
19286 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
19287 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
19288 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
19290 /* "neighbor next-hop-self force" commands. */
19291 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
19292 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
19293 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19294 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
19295 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
19296 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19297 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19298 install_element(BGP_IPV4_NODE
,
19299 &no_neighbor_nexthop_self_all_hidden_cmd
);
19300 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
19301 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19302 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19303 install_element(BGP_IPV4M_NODE
,
19304 &no_neighbor_nexthop_self_all_hidden_cmd
);
19305 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
19306 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19307 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19308 install_element(BGP_IPV4L_NODE
,
19309 &no_neighbor_nexthop_self_all_hidden_cmd
);
19310 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
19311 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19312 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19313 install_element(BGP_IPV6_NODE
,
19314 &no_neighbor_nexthop_self_all_hidden_cmd
);
19315 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
19316 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19317 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19318 install_element(BGP_IPV6M_NODE
,
19319 &no_neighbor_nexthop_self_all_hidden_cmd
);
19320 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
19321 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19322 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19323 install_element(BGP_IPV6L_NODE
,
19324 &no_neighbor_nexthop_self_all_hidden_cmd
);
19325 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
19326 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19327 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19328 install_element(BGP_VPNV4_NODE
,
19329 &no_neighbor_nexthop_self_all_hidden_cmd
);
19330 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
19331 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19332 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
19333 install_element(BGP_VPNV6_NODE
,
19334 &no_neighbor_nexthop_self_all_hidden_cmd
);
19335 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
19336 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
19338 /* "neighbor as-override" commands. */
19339 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
19340 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
19341 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
19342 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
19343 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
19344 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
19345 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
19346 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
19347 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
19348 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
19349 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
19350 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
19351 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
19352 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
19353 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
19354 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
19355 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
19356 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
19358 /* "neighbor remove-private-AS" commands. */
19359 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
19360 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
19361 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
19362 install_element(BGP_NODE
,
19363 &no_neighbor_remove_private_as_all_hidden_cmd
);
19364 install_element(BGP_NODE
,
19365 &neighbor_remove_private_as_replace_as_hidden_cmd
);
19366 install_element(BGP_NODE
,
19367 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
19368 install_element(BGP_NODE
,
19369 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
19372 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
19373 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
19374 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
19375 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
19376 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19377 install_element(BGP_IPV4_NODE
,
19378 &neighbor_remove_private_as_replace_as_cmd
);
19379 install_element(BGP_IPV4_NODE
,
19380 &no_neighbor_remove_private_as_replace_as_cmd
);
19381 install_element(BGP_IPV4_NODE
,
19382 &neighbor_remove_private_as_all_replace_as_cmd
);
19383 install_element(BGP_IPV4_NODE
,
19384 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19385 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
19386 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
19387 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
19388 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19389 install_element(BGP_IPV4M_NODE
,
19390 &neighbor_remove_private_as_replace_as_cmd
);
19391 install_element(BGP_IPV4M_NODE
,
19392 &no_neighbor_remove_private_as_replace_as_cmd
);
19393 install_element(BGP_IPV4M_NODE
,
19394 &neighbor_remove_private_as_all_replace_as_cmd
);
19395 install_element(BGP_IPV4M_NODE
,
19396 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19397 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
19398 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
19399 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
19400 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19401 install_element(BGP_IPV4L_NODE
,
19402 &neighbor_remove_private_as_replace_as_cmd
);
19403 install_element(BGP_IPV4L_NODE
,
19404 &no_neighbor_remove_private_as_replace_as_cmd
);
19405 install_element(BGP_IPV4L_NODE
,
19406 &neighbor_remove_private_as_all_replace_as_cmd
);
19407 install_element(BGP_IPV4L_NODE
,
19408 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19409 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
19410 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19411 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19412 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19413 install_element(BGP_IPV6_NODE
,
19414 &neighbor_remove_private_as_replace_as_cmd
);
19415 install_element(BGP_IPV6_NODE
,
19416 &no_neighbor_remove_private_as_replace_as_cmd
);
19417 install_element(BGP_IPV6_NODE
,
19418 &neighbor_remove_private_as_all_replace_as_cmd
);
19419 install_element(BGP_IPV6_NODE
,
19420 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19421 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
19422 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
19423 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
19424 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19425 install_element(BGP_IPV6M_NODE
,
19426 &neighbor_remove_private_as_replace_as_cmd
);
19427 install_element(BGP_IPV6M_NODE
,
19428 &no_neighbor_remove_private_as_replace_as_cmd
);
19429 install_element(BGP_IPV6M_NODE
,
19430 &neighbor_remove_private_as_all_replace_as_cmd
);
19431 install_element(BGP_IPV6M_NODE
,
19432 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19433 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
19434 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
19435 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
19436 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19437 install_element(BGP_IPV6L_NODE
,
19438 &neighbor_remove_private_as_replace_as_cmd
);
19439 install_element(BGP_IPV6L_NODE
,
19440 &no_neighbor_remove_private_as_replace_as_cmd
);
19441 install_element(BGP_IPV6L_NODE
,
19442 &neighbor_remove_private_as_all_replace_as_cmd
);
19443 install_element(BGP_IPV6L_NODE
,
19444 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19445 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
19446 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
19447 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
19448 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19449 install_element(BGP_VPNV4_NODE
,
19450 &neighbor_remove_private_as_replace_as_cmd
);
19451 install_element(BGP_VPNV4_NODE
,
19452 &no_neighbor_remove_private_as_replace_as_cmd
);
19453 install_element(BGP_VPNV4_NODE
,
19454 &neighbor_remove_private_as_all_replace_as_cmd
);
19455 install_element(BGP_VPNV4_NODE
,
19456 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19457 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
19458 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
19459 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
19460 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
19461 install_element(BGP_VPNV6_NODE
,
19462 &neighbor_remove_private_as_replace_as_cmd
);
19463 install_element(BGP_VPNV6_NODE
,
19464 &no_neighbor_remove_private_as_replace_as_cmd
);
19465 install_element(BGP_VPNV6_NODE
,
19466 &neighbor_remove_private_as_all_replace_as_cmd
);
19467 install_element(BGP_VPNV6_NODE
,
19468 &no_neighbor_remove_private_as_all_replace_as_cmd
);
19470 /* "neighbor send-community" commands.*/
19471 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
19472 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
19473 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
19474 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
19475 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
19476 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
19477 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
19478 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
19479 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
19480 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
19481 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
19482 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
19483 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
19484 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
19485 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
19486 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
19487 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
19488 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
19489 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
19490 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
19491 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
19492 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
19493 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
19494 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
19495 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
19496 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
19497 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
19498 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
19499 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
19500 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
19501 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
19502 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
19503 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
19504 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
19505 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
19506 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
19508 /* "neighbor route-reflector" commands.*/
19509 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
19510 install_element(BGP_NODE
,
19511 &no_neighbor_route_reflector_client_hidden_cmd
);
19512 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
19513 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
19514 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
19515 install_element(BGP_IPV4M_NODE
,
19516 &no_neighbor_route_reflector_client_cmd
);
19517 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
19518 install_element(BGP_IPV4L_NODE
,
19519 &no_neighbor_route_reflector_client_cmd
);
19520 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
19521 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
19522 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
19523 install_element(BGP_IPV6M_NODE
,
19524 &no_neighbor_route_reflector_client_cmd
);
19525 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
19526 install_element(BGP_IPV6L_NODE
,
19527 &no_neighbor_route_reflector_client_cmd
);
19528 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
19529 install_element(BGP_VPNV4_NODE
,
19530 &no_neighbor_route_reflector_client_cmd
);
19531 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
19532 install_element(BGP_VPNV6_NODE
,
19533 &no_neighbor_route_reflector_client_cmd
);
19534 install_element(BGP_FLOWSPECV4_NODE
,
19535 &neighbor_route_reflector_client_cmd
);
19536 install_element(BGP_FLOWSPECV4_NODE
,
19537 &no_neighbor_route_reflector_client_cmd
);
19538 install_element(BGP_FLOWSPECV6_NODE
,
19539 &neighbor_route_reflector_client_cmd
);
19540 install_element(BGP_FLOWSPECV6_NODE
,
19541 &no_neighbor_route_reflector_client_cmd
);
19542 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
19543 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
19545 /* "neighbor route-server" commands.*/
19546 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
19547 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
19548 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
19549 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
19550 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
19551 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
19552 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
19553 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
19554 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
19555 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
19556 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
19557 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
19558 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
19559 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
19560 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
19561 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
19562 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
19563 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
19564 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
19565 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
19566 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
19567 install_element(BGP_FLOWSPECV4_NODE
,
19568 &no_neighbor_route_server_client_cmd
);
19569 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
19570 install_element(BGP_FLOWSPECV6_NODE
,
19571 &no_neighbor_route_server_client_cmd
);
19573 /* "neighbor disable-addpath-rx" commands. */
19574 install_element(BGP_IPV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19575 install_element(BGP_IPV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19576 install_element(BGP_IPV4M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19577 install_element(BGP_IPV4M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19578 install_element(BGP_IPV4L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19579 install_element(BGP_IPV4L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19580 install_element(BGP_IPV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19581 install_element(BGP_IPV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19582 install_element(BGP_IPV6M_NODE
, &neighbor_disable_addpath_rx_cmd
);
19583 install_element(BGP_IPV6M_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19584 install_element(BGP_IPV6L_NODE
, &neighbor_disable_addpath_rx_cmd
);
19585 install_element(BGP_IPV6L_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19586 install_element(BGP_VPNV4_NODE
, &neighbor_disable_addpath_rx_cmd
);
19587 install_element(BGP_VPNV4_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19588 install_element(BGP_VPNV6_NODE
, &neighbor_disable_addpath_rx_cmd
);
19589 install_element(BGP_VPNV6_NODE
, &no_neighbor_disable_addpath_rx_cmd
);
19591 /* "neighbor addpath-tx-all-paths" commands.*/
19592 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
19593 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
19594 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19595 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19596 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19597 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19598 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19599 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19600 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19601 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19602 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19603 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19604 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19605 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19606 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19607 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19608 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
19609 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
19611 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
19612 install_element(BGP_NODE
,
19613 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19614 install_element(BGP_NODE
,
19615 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
19616 install_element(BGP_IPV4_NODE
,
19617 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19618 install_element(BGP_IPV4_NODE
,
19619 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19620 install_element(BGP_IPV4M_NODE
,
19621 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19622 install_element(BGP_IPV4M_NODE
,
19623 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19624 install_element(BGP_IPV4L_NODE
,
19625 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19626 install_element(BGP_IPV4L_NODE
,
19627 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19628 install_element(BGP_IPV6_NODE
,
19629 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19630 install_element(BGP_IPV6_NODE
,
19631 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19632 install_element(BGP_IPV6M_NODE
,
19633 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19634 install_element(BGP_IPV6M_NODE
,
19635 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19636 install_element(BGP_IPV6L_NODE
,
19637 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19638 install_element(BGP_IPV6L_NODE
,
19639 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19640 install_element(BGP_VPNV4_NODE
,
19641 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19642 install_element(BGP_VPNV4_NODE
,
19643 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19644 install_element(BGP_VPNV6_NODE
,
19645 &neighbor_addpath_tx_bestpath_per_as_cmd
);
19646 install_element(BGP_VPNV6_NODE
,
19647 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
19649 /* "neighbor sender-as-path-loop-detection" commands. */
19650 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
19651 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
19653 /* "neighbor path-attribute discard" commands. */
19654 install_element(BGP_NODE
, &neighbor_path_attribute_discard_cmd
);
19655 install_element(BGP_NODE
, &no_neighbor_path_attribute_discard_cmd
);
19657 /* "neighbor path-attribute treat-as-withdraw" commands. */
19658 install_element(BGP_NODE
,
19659 &neighbor_path_attribute_treat_as_withdraw_cmd
);
19660 install_element(BGP_NODE
,
19661 &no_neighbor_path_attribute_treat_as_withdraw_cmd
);
19663 /* "neighbor passive" commands. */
19664 install_element(BGP_NODE
, &neighbor_passive_cmd
);
19665 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
19668 /* "neighbor shutdown" commands. */
19669 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
19670 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
19671 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
19672 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
19673 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
19674 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
19676 /* "neighbor capability extended-nexthop" commands.*/
19677 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
19678 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
19680 /* "neighbor capability orf prefix-list" commands.*/
19681 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
19682 install_element(BGP_NODE
,
19683 &no_neighbor_capability_orf_prefix_hidden_cmd
);
19684 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
19685 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19686 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19687 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19688 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19689 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19690 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
19691 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19692 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
19693 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19694 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
19695 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
19697 /* "neighbor capability dynamic" commands.*/
19698 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
19699 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
19701 /* "neighbor dont-capability-negotiate" commands. */
19702 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
19703 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
19705 /* "neighbor ebgp-multihop" commands. */
19706 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
19707 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
19708 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
19710 /* "neighbor disable-connected-check" commands. */
19711 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
19712 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
19714 /* "neighbor disable-link-bw-encoding-ieee" commands. */
19715 install_element(BGP_NODE
, &neighbor_disable_link_bw_encoding_ieee_cmd
);
19716 install_element(BGP_NODE
,
19717 &no_neighbor_disable_link_bw_encoding_ieee_cmd
);
19719 /* "neighbor extended-optional-parameters" commands. */
19720 install_element(BGP_NODE
, &neighbor_extended_optional_parameters_cmd
);
19721 install_element(BGP_NODE
,
19722 &no_neighbor_extended_optional_parameters_cmd
);
19724 /* "neighbor enforce-first-as" commands. */
19725 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
19726 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
19728 /* "neighbor description" commands. */
19729 install_element(BGP_NODE
, &neighbor_description_cmd
);
19730 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
19731 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
19733 /* "neighbor update-source" commands. "*/
19734 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
19735 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
19737 /* "neighbor default-originate" commands. */
19738 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
19739 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
19740 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
19741 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
19742 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
19743 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
19744 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
19745 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
19746 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
19747 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
19748 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
19749 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
19750 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
19751 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
19752 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
19753 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
19754 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
19755 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
19756 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
19757 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
19758 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
19760 /* "neighbor port" commands. */
19761 install_element(BGP_NODE
, &neighbor_port_cmd
);
19762 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
19764 /* "neighbor weight" commands. */
19765 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
19766 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
19768 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
19769 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
19770 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
19771 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
19772 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
19773 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
19774 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
19775 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
19776 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
19777 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
19778 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
19779 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
19780 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
19781 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
19782 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
19783 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
19785 /* "neighbor override-capability" commands. */
19786 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
19787 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
19789 /* "neighbor strict-capability-match" commands. */
19790 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
19791 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
19793 /* "neighbor timers" commands. */
19794 install_element(BGP_NODE
, &neighbor_timers_cmd
);
19795 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
19797 /* "neighbor timers connect" commands. */
19798 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
19799 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
19801 /* "neighbor timers delayopen" commands. */
19802 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
19803 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
19805 /* "neighbor advertisement-interval" commands. */
19806 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
19807 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
19809 /* "neighbor interface" commands. */
19810 install_element(BGP_NODE
, &neighbor_interface_cmd
);
19811 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
19813 /* "neighbor distribute" commands. */
19814 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
19815 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
19816 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
19817 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
19818 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
19819 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
19820 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
19821 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
19822 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
19823 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
19824 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
19825 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
19826 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
19827 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
19828 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
19829 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
19830 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
19831 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
19833 /* "neighbor prefix-list" commands. */
19834 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
19835 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
19836 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
19837 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
19838 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
19839 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
19840 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
19841 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
19842 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
19843 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
19844 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
19845 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
19846 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
19847 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
19848 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
19849 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
19850 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
19851 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
19852 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
19853 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
19854 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
19855 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
19857 /* "neighbor filter-list" commands. */
19858 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
19859 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
19860 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
19861 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
19862 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
19863 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
19864 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
19865 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
19866 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
19867 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
19868 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
19869 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
19870 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
19871 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
19872 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
19873 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
19874 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
19875 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
19876 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
19877 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
19878 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
19879 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
19881 /* "neighbor route-map" commands. */
19882 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
19883 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
19884 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
19885 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
19886 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
19887 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
19888 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
19889 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
19890 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
19891 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
19892 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
19893 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
19894 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
19895 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
19896 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
19897 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
19898 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
19899 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
19900 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
19901 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
19902 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
19903 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
19904 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
19905 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
19907 /* "neighbor unsuppress-map" commands. */
19908 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
19909 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
19910 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
19911 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19912 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
19913 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19914 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
19915 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19916 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
19917 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19918 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
19919 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
19920 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
19921 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
19922 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
19923 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
19924 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
19925 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
19927 /* "neighbor advertise-map" commands. */
19928 install_element(BGP_NODE
, &bgp_condadv_period_cmd
);
19929 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
19930 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
19931 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
19932 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
19933 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
19934 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
19935 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
19936 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
19937 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
19939 /* neighbor maximum-prefix-out commands. */
19940 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
19941 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19942 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19943 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19944 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19945 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19946 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19947 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19948 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19949 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19950 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
19951 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19952 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
19953 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19954 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
19955 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19956 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
19957 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
19959 /* "neighbor maximum-prefix" commands. */
19960 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
19961 install_element(BGP_NODE
,
19962 &neighbor_maximum_prefix_threshold_hidden_cmd
);
19963 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
19964 install_element(BGP_NODE
,
19965 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
19966 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
19967 install_element(BGP_NODE
,
19968 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
19969 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
19970 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
19971 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19972 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19973 install_element(BGP_IPV4_NODE
,
19974 &neighbor_maximum_prefix_threshold_warning_cmd
);
19975 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19976 install_element(BGP_IPV4_NODE
,
19977 &neighbor_maximum_prefix_threshold_restart_cmd
);
19978 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19979 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
19980 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19981 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19982 install_element(BGP_IPV4M_NODE
,
19983 &neighbor_maximum_prefix_threshold_warning_cmd
);
19984 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19985 install_element(BGP_IPV4M_NODE
,
19986 &neighbor_maximum_prefix_threshold_restart_cmd
);
19987 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19988 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
19989 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19990 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19991 install_element(BGP_IPV4L_NODE
,
19992 &neighbor_maximum_prefix_threshold_warning_cmd
);
19993 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19994 install_element(BGP_IPV4L_NODE
,
19995 &neighbor_maximum_prefix_threshold_restart_cmd
);
19996 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19997 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
19998 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19999 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20000 install_element(BGP_IPV6_NODE
,
20001 &neighbor_maximum_prefix_threshold_warning_cmd
);
20002 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20003 install_element(BGP_IPV6_NODE
,
20004 &neighbor_maximum_prefix_threshold_restart_cmd
);
20005 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
20006 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
20007 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
20008 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20009 install_element(BGP_IPV6M_NODE
,
20010 &neighbor_maximum_prefix_threshold_warning_cmd
);
20011 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20012 install_element(BGP_IPV6M_NODE
,
20013 &neighbor_maximum_prefix_threshold_restart_cmd
);
20014 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
20015 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
20016 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
20017 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20018 install_element(BGP_IPV6L_NODE
,
20019 &neighbor_maximum_prefix_threshold_warning_cmd
);
20020 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20021 install_element(BGP_IPV6L_NODE
,
20022 &neighbor_maximum_prefix_threshold_restart_cmd
);
20023 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
20024 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
20025 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
20026 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20027 install_element(BGP_VPNV4_NODE
,
20028 &neighbor_maximum_prefix_threshold_warning_cmd
);
20029 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20030 install_element(BGP_VPNV4_NODE
,
20031 &neighbor_maximum_prefix_threshold_restart_cmd
);
20032 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
20033 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
20034 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
20035 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
20036 install_element(BGP_VPNV6_NODE
,
20037 &neighbor_maximum_prefix_threshold_warning_cmd
);
20038 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
20039 install_element(BGP_VPNV6_NODE
,
20040 &neighbor_maximum_prefix_threshold_restart_cmd
);
20041 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
20043 /* "neighbor allowas-in" */
20044 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
20045 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
20046 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
20047 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
20048 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
20049 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
20050 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
20051 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
20052 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
20053 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
20054 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
20055 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
20056 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
20057 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
20058 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
20059 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
20060 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
20061 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
20062 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
20063 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
20065 /* neighbor accept-own */
20066 install_element(BGP_VPNV4_NODE
, &neighbor_accept_own_cmd
);
20067 install_element(BGP_VPNV6_NODE
, &neighbor_accept_own_cmd
);
20069 /* "neighbor soo" */
20070 install_element(BGP_IPV4_NODE
, &neighbor_soo_cmd
);
20071 install_element(BGP_IPV4_NODE
, &no_neighbor_soo_cmd
);
20072 install_element(BGP_IPV4M_NODE
, &neighbor_soo_cmd
);
20073 install_element(BGP_IPV4M_NODE
, &no_neighbor_soo_cmd
);
20074 install_element(BGP_IPV4L_NODE
, &neighbor_soo_cmd
);
20075 install_element(BGP_IPV4L_NODE
, &no_neighbor_soo_cmd
);
20076 install_element(BGP_IPV6_NODE
, &neighbor_soo_cmd
);
20077 install_element(BGP_IPV6_NODE
, &no_neighbor_soo_cmd
);
20078 install_element(BGP_IPV6M_NODE
, &neighbor_soo_cmd
);
20079 install_element(BGP_IPV6M_NODE
, &no_neighbor_soo_cmd
);
20080 install_element(BGP_IPV6L_NODE
, &neighbor_soo_cmd
);
20081 install_element(BGP_IPV6L_NODE
, &no_neighbor_soo_cmd
);
20082 install_element(BGP_VPNV4_NODE
, &neighbor_soo_cmd
);
20083 install_element(BGP_VPNV4_NODE
, &no_neighbor_soo_cmd
);
20084 install_element(BGP_VPNV6_NODE
, &neighbor_soo_cmd
);
20085 install_element(BGP_VPNV6_NODE
, &no_neighbor_soo_cmd
);
20086 install_element(BGP_EVPN_NODE
, &neighbor_soo_cmd
);
20087 install_element(BGP_EVPN_NODE
, &no_neighbor_soo_cmd
);
20089 /* address-family commands. */
20090 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
20091 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
20092 #ifdef KEEP_OLD_VPN_COMMANDS
20093 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
20094 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
20095 #endif /* KEEP_OLD_VPN_COMMANDS */
20097 install_element(BGP_NODE
, &address_family_evpn_cmd
);
20099 /* "exit-address-family" command. */
20100 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
20101 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
20102 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
20103 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
20104 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
20105 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
20106 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
20107 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
20108 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
20109 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
20110 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
20112 /* BGP retain all route-target */
20113 install_element(BGP_VPNV4_NODE
, &bgp_retain_route_target_cmd
);
20114 install_element(BGP_VPNV6_NODE
, &bgp_retain_route_target_cmd
);
20116 /* "clear ip bgp commands" */
20117 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
20119 /* clear ip bgp prefix */
20120 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
20121 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
20122 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
20124 /* "show [ip] bgp summary" commands. */
20125 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
20126 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
20127 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
20128 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
20129 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
20130 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
20131 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
20133 /* "show [ip] bgp neighbors" commands. */
20134 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
20136 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
20138 /* "show [ip] bgp peer-group" commands. */
20139 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
20141 /* "show [ip] bgp paths" commands. */
20142 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
20144 /* "show [ip] bgp community" commands. */
20145 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
20147 /* "show ip bgp large-community" commands. */
20148 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
20149 /* "show [ip] bgp attribute-info" commands. */
20150 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
20151 /* "show [ip] bgp route-leak" command */
20152 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
20154 /* "redistribute" commands. */
20155 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
20156 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
20157 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
20158 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
20159 install_element(BGP_NODE
,
20160 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
20161 install_element(BGP_NODE
,
20162 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
20163 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
20164 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
20165 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
20166 install_element(BGP_NODE
,
20167 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
20168 install_element(BGP_NODE
,
20169 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
20170 install_element(BGP_NODE
,
20171 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
20172 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
20173 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
20174 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
20175 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
20176 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
20177 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
20178 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
20179 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
20180 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
20181 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
20182 install_element(BGP_IPV4_NODE
,
20183 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
20184 install_element(BGP_IPV4_NODE
,
20185 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
20186 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
20187 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
20188 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
20189 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
20190 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
20191 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
20193 /* import|export vpn [route-map RMAP_NAME] */
20194 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
20195 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
20197 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
20198 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
20200 /* ttl_security commands */
20201 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
20202 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
20204 /* "bgp tcp-keepalive" commands */
20205 install_element(BGP_NODE
, &bgp_tcp_keepalive_cmd
);
20206 install_element(BGP_NODE
, &no_bgp_tcp_keepalive_cmd
);
20208 /* "show [ip] bgp memory" commands. */
20209 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
20211 /* "show bgp martian next-hop" */
20212 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
20214 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
20216 /* "show [ip] bgp views" commands. */
20217 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
20219 /* "show [ip] bgp vrfs" commands. */
20220 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
20222 /* Community-list. */
20223 community_list_vty();
20225 community_alias_vty();
20227 /* vpn-policy commands */
20228 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
20229 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
20230 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
20231 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
20232 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
20233 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
20234 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
20235 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
20236 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
20237 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
20238 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
20239 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
20241 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
20242 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
20244 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
20245 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
20246 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
20247 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
20248 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
20249 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
20250 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
20251 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
20252 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
20253 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
20255 /* tcp-mss command */
20256 install_element(BGP_NODE
, &neighbor_tcp_mss_cmd
);
20257 install_element(BGP_NODE
, &no_neighbor_tcp_mss_cmd
);
20259 /* srv6 commands */
20260 install_element(VIEW_NODE
, &show_bgp_srv6_cmd
);
20261 install_element(BGP_NODE
, &bgp_segment_routing_srv6_cmd
);
20262 install_element(BGP_NODE
, &no_bgp_segment_routing_srv6_cmd
);
20263 install_element(BGP_SRV6_NODE
, &bgp_srv6_locator_cmd
);
20264 install_element(BGP_SRV6_NODE
, &no_bgp_srv6_locator_cmd
);
20265 install_element(BGP_IPV4_NODE
, &af_sid_vpn_export_cmd
);
20266 install_element(BGP_IPV6_NODE
, &af_sid_vpn_export_cmd
);
20267 install_element(BGP_NODE
, &bgp_sid_vpn_export_cmd
);
20268 install_element(BGP_NODE
, &no_bgp_sid_vpn_export_cmd
);
20273 #include "memory.h"
20274 #include "bgp_regex.h"
20275 #include "bgp_clist.h"
20276 #include "bgp_ecommunity.h"
20278 /* VTY functions. */
20280 /* Direction value to string conversion. */
20281 static const char *community_direct_str(int direct
)
20284 case COMMUNITY_DENY
:
20286 case COMMUNITY_PERMIT
:
20293 /* Display error string. */
20294 static void community_list_perror(struct vty
*vty
, int ret
)
20297 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
20298 vty_out(vty
, "%% Can't find community-list\n");
20300 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
20301 vty_out(vty
, "%% Malformed community-list value\n");
20303 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
20305 "%% Community name conflict, previously defined as standard community\n");
20307 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
20309 "%% Community name conflict, previously defined as expanded community\n");
20314 /* "community-list" keyword help string. */
20315 #define COMMUNITY_LIST_STR "Add a community list entry\n"
20317 /*community-list standard */
20318 DEFUN (community_list_standard
,
20319 bgp_community_list_standard_cmd
,
20320 "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20323 "Community list number (standard)\n"
20324 "Add an standard community-list entry\n"
20325 "Community list name\n"
20326 "Sequence number of an entry\n"
20327 "Sequence number\n"
20328 "Specify community to reject\n"
20329 "Specify community to accept\n"
20332 char *cl_name_or_number
= NULL
;
20335 int style
= COMMUNITY_LIST_STANDARD
;
20338 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20339 seq
= argv
[idx
]->arg
;
20342 argv_find(argv
, argc
, "(1-99)", &idx
);
20343 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20344 cl_name_or_number
= argv
[idx
]->arg
;
20345 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20347 argv_find(argv
, argc
, "AA:NN", &idx
);
20348 char *str
= argv_concat(argv
, argc
, idx
);
20350 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
20353 XFREE(MTYPE_TMP
, str
);
20356 /* Display error string. */
20357 community_list_perror(vty
, ret
);
20358 return CMD_WARNING_CONFIG_FAILED
;
20361 return CMD_SUCCESS
;
20364 DEFUN (no_community_list_standard_all
,
20365 no_bgp_community_list_standard_all_cmd
,
20366 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20370 "Community list number (standard)\n"
20371 "Add an standard community-list entry\n"
20372 "Community list name\n"
20373 "Sequence number of an entry\n"
20374 "Sequence number\n"
20375 "Specify community to reject\n"
20376 "Specify community to accept\n"
20379 char *cl_name_or_number
= NULL
;
20382 int style
= COMMUNITY_LIST_STANDARD
;
20386 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20387 seq
= argv
[idx
]->arg
;
20390 argv_find(argv
, argc
, "permit", &idx
);
20391 argv_find(argv
, argc
, "deny", &idx
);
20394 direct
= argv_find(argv
, argc
, "permit", &idx
)
20399 argv_find(argv
, argc
, "AA:NN", &idx
);
20400 str
= argv_concat(argv
, argc
, idx
);
20404 argv_find(argv
, argc
, "(1-99)", &idx
);
20405 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20406 cl_name_or_number
= argv
[idx
]->arg
;
20408 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20411 XFREE(MTYPE_TMP
, str
);
20414 community_list_perror(vty
, ret
);
20415 return CMD_WARNING_CONFIG_FAILED
;
20418 return CMD_SUCCESS
;
20421 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
20422 "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>",
20423 NO_STR BGP_STR COMMUNITY_LIST_STR
20424 "Community list number (standard)\n"
20425 "Add an standard community-list entry\n"
20426 "Community list name\n")
20428 /*community-list expanded */
20429 DEFUN (community_list_expanded_all
,
20430 bgp_community_list_expanded_all_cmd
,
20431 "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20434 "Community list number (expanded)\n"
20435 "Add an expanded community-list entry\n"
20436 "Community list name\n"
20437 "Sequence number of an entry\n"
20438 "Sequence number\n"
20439 "Specify community to reject\n"
20440 "Specify community to accept\n"
20443 char *cl_name_or_number
= NULL
;
20446 int style
= COMMUNITY_LIST_EXPANDED
;
20449 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20450 seq
= argv
[idx
]->arg
;
20454 argv_find(argv
, argc
, "(100-500)", &idx
);
20455 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20456 cl_name_or_number
= argv
[idx
]->arg
;
20457 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20459 argv_find(argv
, argc
, "AA:NN", &idx
);
20460 char *str
= argv_concat(argv
, argc
, idx
);
20462 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
20465 XFREE(MTYPE_TMP
, str
);
20468 /* Display error string. */
20469 community_list_perror(vty
, ret
);
20470 return CMD_WARNING_CONFIG_FAILED
;
20473 return CMD_SUCCESS
;
20476 DEFUN (no_community_list_expanded_all
,
20477 no_bgp_community_list_expanded_all_cmd
,
20478 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
20482 "Community list number (expanded)\n"
20483 "Add an expanded community-list entry\n"
20484 "Community list name\n"
20485 "Sequence number of an entry\n"
20486 "Sequence number\n"
20487 "Specify community to reject\n"
20488 "Specify community to accept\n"
20491 char *cl_name_or_number
= NULL
;
20495 int style
= COMMUNITY_LIST_EXPANDED
;
20498 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20499 seq
= argv
[idx
]->arg
;
20502 argv_find(argv
, argc
, "permit", &idx
);
20503 argv_find(argv
, argc
, "deny", &idx
);
20506 direct
= argv_find(argv
, argc
, "permit", &idx
)
20511 argv_find(argv
, argc
, "AA:NN", &idx
);
20512 str
= argv_concat(argv
, argc
, idx
);
20516 argv_find(argv
, argc
, "(100-500)", &idx
);
20517 argv_find(argv
, argc
, "COMMUNITY_LIST_NAME", &idx
);
20518 cl_name_or_number
= argv
[idx
]->arg
;
20520 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
20523 XFREE(MTYPE_TMP
, str
);
20526 community_list_perror(vty
, ret
);
20527 return CMD_WARNING_CONFIG_FAILED
;
20530 return CMD_SUCCESS
;
20533 ALIAS(no_community_list_expanded_all
,
20534 no_bgp_community_list_expanded_all_list_cmd
,
20535 "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>",
20536 NO_STR BGP_STR COMMUNITY_LIST_STR
20537 "Community list number (expanded)\n"
20538 "Add an expanded community-list entry\n"
20539 "Community list name\n")
20541 /* Return configuration string of community-list entry. */
20542 static const char *community_list_config_str(struct community_entry
*entry
)
20549 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
20550 str
= community_str(entry
->u
.com
, false, false);
20551 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
20552 str
= lcommunity_str(entry
->u
.lcom
, false, false);
20554 str
= entry
->config
;
20559 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
20561 struct community_entry
*entry
;
20563 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20564 if (entry
== list
->head
) {
20565 if (all_digit(list
->name
))
20566 vty_out(vty
, "Community %s list %s\n",
20567 entry
->style
== COMMUNITY_LIST_STANDARD
20569 : "(expanded) access",
20572 vty_out(vty
, "Named Community %s list %s\n",
20573 entry
->style
== COMMUNITY_LIST_STANDARD
20579 vty_out(vty
, " %s\n",
20580 community_direct_str(entry
->direct
));
20582 vty_out(vty
, " %s %s\n",
20583 community_direct_str(entry
->direct
),
20584 community_list_config_str(entry
));
20588 DEFUN (show_community_list
,
20589 show_bgp_community_list_cmd
,
20590 "show bgp community-list",
20593 "List community-list\n")
20595 struct community_list
*list
;
20596 struct community_list_master
*cm
;
20598 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20600 return CMD_SUCCESS
;
20602 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20603 community_list_show(vty
, list
);
20605 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20606 community_list_show(vty
, list
);
20608 return CMD_SUCCESS
;
20611 DEFUN (show_community_list_arg
,
20612 show_bgp_community_list_arg_cmd
,
20613 "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail",
20616 "List community-list\n"
20617 "Community-list number\n"
20618 "Community-list name\n"
20619 "Detailed information on community-list\n")
20621 int idx_comm_list
= 3;
20622 struct community_list
*list
;
20624 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20625 COMMUNITY_LIST_MASTER
);
20627 vty_out(vty
, "%% Can't find community-list\n");
20628 return CMD_WARNING
;
20631 community_list_show(vty
, list
);
20633 return CMD_SUCCESS
;
20637 * Large Community code.
20639 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
20640 struct cmd_token
**argv
, int style
,
20641 int reject_all_digit_name
)
20650 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20651 seq
= argv
[idx
]->arg
;
20654 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20657 /* All digit name check. */
20659 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20660 argv_find(argv
, argc
, "(1-99)", &idx
);
20661 argv_find(argv
, argc
, "(100-500)", &idx
);
20662 cl_name
= argv
[idx
]->arg
;
20663 if (reject_all_digit_name
&& all_digit(cl_name
)) {
20664 vty_out(vty
, "%% Community name cannot have all digits\n");
20665 return CMD_WARNING_CONFIG_FAILED
;
20669 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
20670 argv_find(argv
, argc
, "LINE", &idx
);
20671 /* Concat community string argument. */
20673 str
= argv_concat(argv
, argc
, idx
);
20677 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
20679 /* Free temporary community list string allocated by
20681 XFREE(MTYPE_TMP
, str
);
20684 community_list_perror(vty
, ret
);
20685 return CMD_WARNING_CONFIG_FAILED
;
20687 return CMD_SUCCESS
;
20690 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
20691 struct cmd_token
**argv
, int style
)
20699 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20700 seq
= argv
[idx
]->arg
;
20703 argv_find(argv
, argc
, "permit", &idx
);
20704 argv_find(argv
, argc
, "deny", &idx
);
20707 /* Check the list direct. */
20708 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
20709 direct
= COMMUNITY_PERMIT
;
20711 direct
= COMMUNITY_DENY
;
20714 argv_find(argv
, argc
, "LINE", &idx
);
20715 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
20716 /* Concat community string argument. */
20717 str
= argv_concat(argv
, argc
, idx
);
20721 argv_find(argv
, argc
, "(1-99)", &idx
);
20722 argv_find(argv
, argc
, "(100-500)", &idx
);
20723 argv_find(argv
, argc
, "LCOMMUNITY_LIST_NAME", &idx
);
20725 /* Unset community list. */
20726 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
20729 /* Free temporary community list string allocated by
20731 XFREE(MTYPE_TMP
, str
);
20734 community_list_perror(vty
, ret
);
20735 return CMD_WARNING_CONFIG_FAILED
;
20738 return CMD_SUCCESS
;
20741 /* "large-community-list" keyword help string. */
20742 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
20743 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
20745 DEFUN (lcommunity_list_standard
,
20746 bgp_lcommunity_list_standard_cmd
,
20747 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20749 LCOMMUNITY_LIST_STR
20750 "Large Community list number (standard)\n"
20751 "Sequence number of an entry\n"
20752 "Sequence number\n"
20753 "Specify large community to reject\n"
20754 "Specify large community to accept\n"
20755 LCOMMUNITY_VAL_STR
)
20757 return lcommunity_list_set_vty(vty
, argc
, argv
,
20758 LARGE_COMMUNITY_LIST_STANDARD
, 0);
20761 DEFUN (lcommunity_list_expanded
,
20762 bgp_lcommunity_list_expanded_cmd
,
20763 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20765 LCOMMUNITY_LIST_STR
20766 "Large Community list number (expanded)\n"
20767 "Sequence number of an entry\n"
20768 "Sequence number\n"
20769 "Specify large community to reject\n"
20770 "Specify large community to accept\n"
20771 "An ordered list as a regular-expression\n")
20773 return lcommunity_list_set_vty(vty
, argc
, argv
,
20774 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
20777 DEFUN (lcommunity_list_name_standard
,
20778 bgp_lcommunity_list_name_standard_cmd
,
20779 "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
20781 LCOMMUNITY_LIST_STR
20782 "Specify standard large-community-list\n"
20783 "Large Community list name\n"
20784 "Sequence number of an entry\n"
20785 "Sequence number\n"
20786 "Specify large community to reject\n"
20787 "Specify large community to accept\n"
20788 LCOMMUNITY_VAL_STR
)
20790 return lcommunity_list_set_vty(vty
, argc
, argv
,
20791 LARGE_COMMUNITY_LIST_STANDARD
, 1);
20794 DEFUN (lcommunity_list_name_expanded
,
20795 bgp_lcommunity_list_name_expanded_cmd
,
20796 "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20798 LCOMMUNITY_LIST_STR
20799 "Specify expanded large-community-list\n"
20800 "Large Community list name\n"
20801 "Sequence number of an entry\n"
20802 "Sequence number\n"
20803 "Specify large community to reject\n"
20804 "Specify large community to accept\n"
20805 "An ordered list as a regular-expression\n")
20807 return lcommunity_list_set_vty(vty
, argc
, argv
,
20808 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
20811 DEFUN (no_lcommunity_list_all
,
20812 no_bgp_lcommunity_list_all_cmd
,
20813 "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>",
20816 LCOMMUNITY_LIST_STR
20817 "Large Community list number (standard)\n"
20818 "Large Community list number (expanded)\n"
20819 "Large Community list name\n")
20821 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20822 LARGE_COMMUNITY_LIST_STANDARD
);
20825 DEFUN (no_lcommunity_list_name_standard_all
,
20826 no_bgp_lcommunity_list_name_standard_all_cmd
,
20827 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME",
20830 LCOMMUNITY_LIST_STR
20831 "Specify standard large-community-list\n"
20832 "Large Community list name\n")
20834 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20835 LARGE_COMMUNITY_LIST_STANDARD
);
20838 DEFUN (no_lcommunity_list_name_expanded_all
,
20839 no_bgp_lcommunity_list_name_expanded_all_cmd
,
20840 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME",
20843 LCOMMUNITY_LIST_STR
20844 "Specify expanded large-community-list\n"
20845 "Large Community list name\n")
20847 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20848 LARGE_COMMUNITY_LIST_EXPANDED
);
20851 DEFUN (no_lcommunity_list_standard
,
20852 no_bgp_lcommunity_list_standard_cmd
,
20853 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20856 LCOMMUNITY_LIST_STR
20857 "Large Community list number (standard)\n"
20858 "Sequence number of an entry\n"
20859 "Sequence number\n"
20860 "Specify large community to reject\n"
20861 "Specify large community to accept\n"
20862 LCOMMUNITY_VAL_STR
)
20864 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20865 LARGE_COMMUNITY_LIST_STANDARD
);
20868 DEFUN (no_lcommunity_list_expanded
,
20869 no_bgp_lcommunity_list_expanded_cmd
,
20870 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
20873 LCOMMUNITY_LIST_STR
20874 "Large Community list number (expanded)\n"
20875 "Sequence number of an entry\n"
20876 "Sequence number\n"
20877 "Specify large community to reject\n"
20878 "Specify large community to accept\n"
20879 "An ordered list as a regular-expression\n")
20881 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20882 LARGE_COMMUNITY_LIST_EXPANDED
);
20885 DEFUN (no_lcommunity_list_name_standard
,
20886 no_bgp_lcommunity_list_name_standard_cmd
,
20887 "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
20890 LCOMMUNITY_LIST_STR
20891 "Specify standard large-community-list\n"
20892 "Large Community list name\n"
20893 "Sequence number of an entry\n"
20894 "Sequence number\n"
20895 "Specify large community to reject\n"
20896 "Specify large community to accept\n"
20897 LCOMMUNITY_VAL_STR
)
20899 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20900 LARGE_COMMUNITY_LIST_STANDARD
);
20903 DEFUN (no_lcommunity_list_name_expanded
,
20904 no_bgp_lcommunity_list_name_expanded_cmd
,
20905 "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...",
20908 LCOMMUNITY_LIST_STR
20909 "Specify expanded large-community-list\n"
20910 "Large community list name\n"
20911 "Sequence number of an entry\n"
20912 "Sequence number\n"
20913 "Specify large community to reject\n"
20914 "Specify large community to accept\n"
20915 "An ordered list as a regular-expression\n")
20917 return lcommunity_list_unset_vty(vty
, argc
, argv
,
20918 LARGE_COMMUNITY_LIST_EXPANDED
);
20921 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20923 struct community_entry
*entry
;
20925 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20926 if (entry
== list
->head
) {
20927 if (all_digit(list
->name
))
20928 vty_out(vty
, "Large community %s list %s\n",
20930 LARGE_COMMUNITY_LIST_STANDARD
20932 : "(expanded) access",
20936 "Named large community %s list %s\n",
20938 LARGE_COMMUNITY_LIST_STANDARD
20944 vty_out(vty
, " %s\n",
20945 community_direct_str(entry
->direct
));
20947 vty_out(vty
, " %s %s\n",
20948 community_direct_str(entry
->direct
),
20949 community_list_config_str(entry
));
20953 DEFUN (show_lcommunity_list
,
20954 show_bgp_lcommunity_list_cmd
,
20955 "show bgp large-community-list",
20958 "List large-community list\n")
20960 struct community_list
*list
;
20961 struct community_list_master
*cm
;
20963 cm
= community_list_master_lookup(bgp_clist
,
20964 LARGE_COMMUNITY_LIST_MASTER
);
20966 return CMD_SUCCESS
;
20968 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20969 lcommunity_list_show(vty
, list
);
20971 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20972 lcommunity_list_show(vty
, list
);
20974 return CMD_SUCCESS
;
20977 DEFUN (show_lcommunity_list_arg
,
20978 show_bgp_lcommunity_list_arg_cmd
,
20979 "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail",
20982 "List large-community list\n"
20983 "Large-community-list number\n"
20984 "Large-community-list name\n"
20985 "Detailed information on large-community-list\n")
20987 struct community_list
*list
;
20989 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
20990 LARGE_COMMUNITY_LIST_MASTER
);
20992 vty_out(vty
, "%% Can't find large-community-list\n");
20993 return CMD_WARNING
;
20996 lcommunity_list_show(vty
, list
);
20998 return CMD_SUCCESS
;
21001 /* "extcommunity-list" keyword help string. */
21002 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
21003 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
21005 DEFUN (extcommunity_list_standard
,
21006 bgp_extcommunity_list_standard_cmd
,
21007 "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
21009 EXTCOMMUNITY_LIST_STR
21010 "Extended Community list number (standard)\n"
21011 "Specify standard extcommunity-list\n"
21012 "Community list name\n"
21013 "Sequence number of an entry\n"
21014 "Sequence number\n"
21015 "Specify community to reject\n"
21016 "Specify community to accept\n"
21017 EXTCOMMUNITY_VAL_STR
)
21019 int style
= EXTCOMMUNITY_LIST_STANDARD
;
21021 char *cl_number_or_name
= NULL
;
21026 argv_find(argv
, argc
, "(1-99)", &idx
);
21027 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21028 cl_number_or_name
= argv
[idx
]->arg
;
21030 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21031 seq
= argv
[idx
]->arg
;
21033 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
21035 argv_find(argv
, argc
, "AA:NN", &idx
);
21036 char *str
= argv_concat(argv
, argc
, idx
);
21038 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
21041 XFREE(MTYPE_TMP
, str
);
21044 community_list_perror(vty
, ret
);
21045 return CMD_WARNING_CONFIG_FAILED
;
21048 return CMD_SUCCESS
;
21051 DEFUN (extcommunity_list_name_expanded
,
21052 bgp_extcommunity_list_name_expanded_cmd
,
21053 "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
21055 EXTCOMMUNITY_LIST_STR
21056 "Extended Community list number (expanded)\n"
21057 "Specify expanded extcommunity-list\n"
21058 "Extended Community list name\n"
21059 "Sequence number of an entry\n"
21060 "Sequence number\n"
21061 "Specify community to reject\n"
21062 "Specify community to accept\n"
21063 "An ordered list as a regular-expression\n")
21065 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
21067 char *cl_number_or_name
= NULL
;
21071 argv_find(argv
, argc
, "(100-500)", &idx
);
21072 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21073 cl_number_or_name
= argv
[idx
]->arg
;
21075 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21076 seq
= argv
[idx
]->arg
;
21078 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
21080 argv_find(argv
, argc
, "LINE", &idx
);
21081 char *str
= argv_concat(argv
, argc
, idx
);
21083 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
21086 XFREE(MTYPE_TMP
, str
);
21089 community_list_perror(vty
, ret
);
21090 return CMD_WARNING_CONFIG_FAILED
;
21093 return CMD_SUCCESS
;
21096 DEFUN (no_extcommunity_list_standard_all
,
21097 no_bgp_extcommunity_list_standard_all_cmd
,
21098 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...",
21101 EXTCOMMUNITY_LIST_STR
21102 "Extended Community list number (standard)\n"
21103 "Specify standard extcommunity-list\n"
21104 "Community list name\n"
21105 "Sequence number of an entry\n"
21106 "Sequence number\n"
21107 "Specify community to reject\n"
21108 "Specify community to accept\n"
21109 EXTCOMMUNITY_VAL_STR
)
21111 int style
= EXTCOMMUNITY_LIST_STANDARD
;
21113 char *cl_number_or_name
= NULL
;
21118 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21119 seq
= argv
[idx
]->arg
;
21122 argv_find(argv
, argc
, "permit", &idx
);
21123 argv_find(argv
, argc
, "deny", &idx
);
21125 direct
= argv_find(argv
, argc
, "permit", &idx
)
21130 argv_find(argv
, argc
, "AA:NN", &idx
);
21131 str
= argv_concat(argv
, argc
, idx
);
21135 argv_find(argv
, argc
, "(1-99)", &idx
);
21136 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21137 cl_number_or_name
= argv
[idx
]->arg
;
21139 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
21140 seq
, direct
, style
);
21142 XFREE(MTYPE_TMP
, str
);
21145 community_list_perror(vty
, ret
);
21146 return CMD_WARNING_CONFIG_FAILED
;
21149 return CMD_SUCCESS
;
21152 ALIAS(no_extcommunity_list_standard_all
,
21153 no_bgp_extcommunity_list_standard_all_list_cmd
,
21154 "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>",
21155 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
21156 "Extended Community list number (standard)\n"
21157 "Specify standard extcommunity-list\n"
21158 "Community list name\n")
21160 DEFUN (no_extcommunity_list_expanded_all
,
21161 no_bgp_extcommunity_list_expanded_all_cmd
,
21162 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...",
21165 EXTCOMMUNITY_LIST_STR
21166 "Extended Community list number (expanded)\n"
21167 "Specify expanded extcommunity-list\n"
21168 "Extended Community list name\n"
21169 "Sequence number of an entry\n"
21170 "Sequence number\n"
21171 "Specify community to reject\n"
21172 "Specify community to accept\n"
21173 "An ordered list as a regular-expression\n")
21175 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
21177 char *cl_number_or_name
= NULL
;
21182 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
21183 seq
= argv
[idx
]->arg
;
21186 argv_find(argv
, argc
, "permit", &idx
);
21187 argv_find(argv
, argc
, "deny", &idx
);
21190 direct
= argv_find(argv
, argc
, "permit", &idx
)
21195 argv_find(argv
, argc
, "LINE", &idx
);
21196 str
= argv_concat(argv
, argc
, idx
);
21200 argv_find(argv
, argc
, "(100-500)", &idx
);
21201 argv_find(argv
, argc
, "EXTCOMMUNITY_LIST_NAME", &idx
);
21202 cl_number_or_name
= argv
[idx
]->arg
;
21204 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
21205 seq
, direct
, style
);
21207 XFREE(MTYPE_TMP
, str
);
21210 community_list_perror(vty
, ret
);
21211 return CMD_WARNING_CONFIG_FAILED
;
21214 return CMD_SUCCESS
;
21217 ALIAS(no_extcommunity_list_expanded_all
,
21218 no_bgp_extcommunity_list_expanded_all_list_cmd
,
21219 "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>",
21220 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
21221 "Extended Community list number (expanded)\n"
21222 "Specify expanded extcommunity-list\n"
21223 "Extended Community list name\n")
21225 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
21227 struct community_entry
*entry
;
21229 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21230 if (entry
== list
->head
) {
21231 if (all_digit(list
->name
))
21232 vty_out(vty
, "Extended community %s list %s\n",
21233 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21235 : "(expanded) access",
21239 "Named extended community %s list %s\n",
21240 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21246 vty_out(vty
, " %s\n",
21247 community_direct_str(entry
->direct
));
21249 vty_out(vty
, " %s %s\n",
21250 community_direct_str(entry
->direct
),
21251 community_list_config_str(entry
));
21255 DEFUN (show_extcommunity_list
,
21256 show_bgp_extcommunity_list_cmd
,
21257 "show bgp extcommunity-list",
21260 "List extended-community list\n")
21262 struct community_list
*list
;
21263 struct community_list_master
*cm
;
21265 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
21267 return CMD_SUCCESS
;
21269 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21270 extcommunity_list_show(vty
, list
);
21272 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21273 extcommunity_list_show(vty
, list
);
21275 return CMD_SUCCESS
;
21278 DEFUN (show_extcommunity_list_arg
,
21279 show_bgp_extcommunity_list_arg_cmd
,
21280 "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail",
21283 "List extended-community list\n"
21284 "Extcommunity-list number\n"
21285 "Extcommunity-list name\n"
21286 "Detailed information on extcommunity-list\n")
21288 int idx_comm_list
= 3;
21289 struct community_list
*list
;
21291 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
21292 EXTCOMMUNITY_LIST_MASTER
);
21294 vty_out(vty
, "%% Can't find extcommunity-list\n");
21295 return CMD_WARNING
;
21298 extcommunity_list_show(vty
, list
);
21300 return CMD_SUCCESS
;
21303 /* Display community-list and extcommunity-list configuration. */
21304 static int community_list_config_write(struct vty
*vty
)
21306 struct community_list
*list
;
21307 struct community_entry
*entry
;
21308 struct community_list_master
*cm
;
21311 /* Community-list. */
21312 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
21314 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21315 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21317 "bgp community-list %s seq %" PRId64
" %s %s\n",
21318 list
->name
, entry
->seq
,
21319 community_direct_str(entry
->direct
),
21320 community_list_config_str(entry
));
21323 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21324 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21326 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
21327 entry
->style
== COMMUNITY_LIST_STANDARD
21330 list
->name
, entry
->seq
,
21331 community_direct_str(entry
->direct
),
21332 community_list_config_str(entry
));
21336 /* Extcommunity-list. */
21337 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
21339 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21340 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21342 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
21343 list
->name
, entry
->seq
,
21344 community_direct_str(entry
->direct
),
21345 community_list_config_str(entry
));
21348 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21349 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21351 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
21352 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
21355 list
->name
, entry
->seq
,
21356 community_direct_str(entry
->direct
),
21357 community_list_config_str(entry
));
21362 /* lcommunity-list. */
21363 cm
= community_list_master_lookup(bgp_clist
,
21364 LARGE_COMMUNITY_LIST_MASTER
);
21366 for (list
= cm
->num
.head
; list
; list
= list
->next
)
21367 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21369 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
21370 list
->name
, entry
->seq
,
21371 community_direct_str(entry
->direct
),
21372 community_list_config_str(entry
));
21375 for (list
= cm
->str
.head
; list
; list
= list
->next
)
21376 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
21378 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
21380 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
21383 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
21384 community_list_config_str(entry
));
21391 static int community_list_config_write(struct vty
*vty
);
21392 static struct cmd_node community_list_node
= {
21393 .name
= "community list",
21394 .node
= COMMUNITY_LIST_NODE
,
21396 .config_write
= community_list_config_write
,
21399 static void community_list_vty(void)
21401 install_node(&community_list_node
);
21403 /* Community-list. */
21404 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
21405 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
21406 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
21407 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
21408 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
21409 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
21410 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
21411 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
21413 /* Extcommunity-list. */
21414 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
21415 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
21416 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
21417 install_element(CONFIG_NODE
,
21418 &no_bgp_extcommunity_list_standard_all_list_cmd
);
21419 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
21420 install_element(CONFIG_NODE
,
21421 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
21422 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
21423 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
21425 /* Large Community List */
21426 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
21427 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
21428 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
21429 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
21430 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
21431 install_element(CONFIG_NODE
,
21432 &no_bgp_lcommunity_list_name_standard_all_cmd
);
21433 install_element(CONFIG_NODE
,
21434 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
21435 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
21436 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
21437 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
21438 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
21439 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
21440 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
21442 bgp_community_list_command_completion_setup();
21445 static struct cmd_node community_alias_node
= {
21446 .name
= "community alias",
21447 .node
= COMMUNITY_ALIAS_NODE
,
21449 .config_write
= bgp_community_alias_write
,
21452 void community_alias_vty(void)
21454 install_node(&community_alias_node
);
21456 /* Community-list. */
21457 install_element(CONFIG_NODE
, &bgp_community_alias_cmd
);
21459 bgp_community_alias_command_completion_setup();