]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP VTY interface. |
896014f4 DL |
2 | * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro |
3 | * | |
4 | * This file is part of GNU Zebra. | |
5 | * | |
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 | |
9 | * later version. | |
10 | * | |
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. | |
15 | * | |
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 | |
19 | */ | |
718e3744 | 20 | |
21 | #include <zebra.h> | |
22 | ||
23 | #include "command.h" | |
afec25d9 | 24 | #include "lib/json.h" |
4ab46701 | 25 | #include "lib/sockopt.h" |
5cb5f4d0 | 26 | #include "lib_errors.h" |
ec0ab544 | 27 | #include "lib/zclient.h" |
6f4eacf3 | 28 | #include "lib/printfrr.h" |
718e3744 | 29 | #include "prefix.h" |
30 | #include "plist.h" | |
31 | #include "buffer.h" | |
32 | #include "linklist.h" | |
33 | #include "stream.h" | |
34 | #include "thread.h" | |
35 | #include "log.h" | |
3b8b1855 | 36 | #include "memory.h" |
1c0d8808 | 37 | #include "lib_vty.h" |
4bf6a362 | 38 | #include "hash.h" |
3f9c7369 | 39 | #include "queue.h" |
039f3a34 | 40 | #include "filter.h" |
5d5ba018 | 41 | #include "frrstr.h" |
718e3744 | 42 | |
43 | #include "bgpd/bgpd.h" | |
48ecf8f5 | 44 | #include "bgpd/bgp_attr_evpn.h" |
4bf6a362 | 45 | #include "bgpd/bgp_advertise.h" |
718e3744 | 46 | #include "bgpd/bgp_attr.h" |
47 | #include "bgpd/bgp_aspath.h" | |
48 | #include "bgpd/bgp_community.h" | |
ed0e57e3 | 49 | #include "bgpd/bgp_community_alias.h" |
4bf6a362 | 50 | #include "bgpd/bgp_ecommunity.h" |
57d187bc | 51 | #include "bgpd/bgp_lcommunity.h" |
4bf6a362 | 52 | #include "bgpd/bgp_damp.h" |
718e3744 | 53 | #include "bgpd/bgp_debug.h" |
14454c9f | 54 | #include "bgpd/bgp_errors.h" |
e0701b79 | 55 | #include "bgpd/bgp_fsm.h" |
4cd690ae | 56 | #include "bgpd/bgp_nht.h" |
4bf6a362 | 57 | #include "bgpd/bgp_nexthop.h" |
4122b697 | 58 | #include "bgpd/bgp_network.h" |
718e3744 | 59 | #include "bgpd/bgp_open.h" |
4bf6a362 | 60 | #include "bgpd/bgp_regex.h" |
718e3744 | 61 | #include "bgpd/bgp_route.h" |
c016b6c7 | 62 | #include "bgpd/bgp_mplsvpn.h" |
718e3744 | 63 | #include "bgpd/bgp_zebra.h" |
fee0f4c6 | 64 | #include "bgpd/bgp_table.h" |
94f2b392 | 65 | #include "bgpd/bgp_vty.h" |
165b5fff | 66 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 67 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 68 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 69 | #include "bgpd/bgp_bfd.h" |
555e09d4 | 70 | #include "bgpd/bgp_io.h" |
94c2f693 | 71 | #include "bgpd/bgp_evpn.h" |
dd65f45e | 72 | #include "bgpd/bgp_evpn_vty.h" |
b5e140c8 | 73 | #include "bgpd/bgp_evpn_mh.h" |
dcc68b5e | 74 | #include "bgpd/bgp_addpath.h" |
48ecf8f5 | 75 | #include "bgpd/bgp_mac.h" |
dd65f45e | 76 | #include "bgpd/bgp_flowspec.h" |
389e4f92 | 77 | #include "bgpd/bgp_conditional_adv.h" |
49e5a4a0 | 78 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
79 | #include "bgpd/rfapi/bgp_rfapi_cfg.h" |
80 | #endif | |
70cd87ca MK |
81 | #include "bgpd/bgp_orr.h" |
82 | ||
dd65f45e | 83 | |
5d5393b9 | 84 | FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK, |
62282e83 DS |
85 | { |
86 | .val_bool = false, | |
87 | .match_profile = "traditional", | |
88 | .match_version = "< 7.4", | |
89 | }, | |
90 | { .val_bool = true }, | |
67b0f40c | 91 | ); |
5d5393b9 | 92 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME, |
4c1458b5 DL |
93 | { .val_bool = true, .match_profile = "datacenter", }, |
94 | { .val_bool = false }, | |
67b0f40c | 95 | ); |
aef999a2 DA |
96 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME, |
97 | { .val_bool = true, .match_profile = "datacenter", }, | |
98 | { .val_bool = false }, | |
67b0f40c | 99 | ); |
5d5393b9 | 100 | FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES, |
4c1458b5 DL |
101 | { .val_bool = true, .match_profile = "datacenter", }, |
102 | { .val_bool = false }, | |
67b0f40c | 103 | ); |
5d5393b9 | 104 | FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED, |
4c1458b5 DL |
105 | { .val_bool = true, .match_profile = "datacenter", }, |
106 | { .val_bool = false }, | |
67b0f40c | 107 | ); |
5d5393b9 DL |
108 | FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY, |
109 | { .val_ulong = 10, .match_profile = "datacenter", }, | |
110 | { .val_ulong = 120 }, | |
67b0f40c | 111 | ); |
5d5393b9 DL |
112 | FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME, |
113 | { .val_ulong = 9, .match_profile = "datacenter", }, | |
114 | { .val_ulong = 180 }, | |
67b0f40c | 115 | ); |
5d5393b9 DL |
116 | FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE, |
117 | { .val_ulong = 3, .match_profile = "datacenter", }, | |
118 | { .val_ulong = 60 }, | |
67b0f40c | 119 | ); |
1d3fdccf DA |
120 | FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY, |
121 | { .val_bool = false, .match_profile = "datacenter", }, | |
122 | { .val_bool = false, .match_version = "< 7.4", }, | |
123 | { .val_bool = true }, | |
67b0f40c | 124 | ); |
2adac256 DA |
125 | FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES, |
126 | { .val_bool = false, .match_version = "< 7.6", }, | |
127 | { .val_bool = true }, | |
67b0f40c | 128 | ); |
f2ca5c5b DA |
129 | FRR_CFG_DEFAULT_BOOL(BGP_GRACEFUL_NOTIFICATION, |
130 | { .val_bool = false, .match_version = "< 8.3", }, | |
131 | { .val_bool = true }, | |
132 | ); | |
1ae314be DA |
133 | FRR_CFG_DEFAULT_BOOL(BGP_HARD_ADMIN_RESET, |
134 | { .val_bool = false, .match_version = "< 8.3", }, | |
135 | { .val_bool = true }, | |
136 | ); | |
5d5393b9 | 137 | |
dd65f45e DL |
138 | DEFINE_HOOK(bgp_inst_config_write, |
139 | (struct bgp *bgp, struct vty *vty), | |
8451921b DL |
140 | (bgp, vty)); |
141 | DEFINE_HOOK(bgp_snmp_update_last_changed, (struct bgp *bgp), (bgp)); | |
1ca2fd11 | 142 | DEFINE_HOOK(bgp_snmp_init_stats, (struct bgp *bgp), (bgp)); |
718e3744 | 143 | |
d62a17ae | 144 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
145 | struct prefix *range, int exact); | |
146 | ||
055679e9 | 147 | /* Show BGP peer's information. */ |
148 | enum show_type { | |
149 | show_all, | |
150 | show_peer, | |
151 | show_ipv4_all, | |
152 | show_ipv6_all, | |
153 | show_ipv4_peer, | |
154 | show_ipv6_peer | |
155 | }; | |
156 | ||
36235319 QY |
157 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
158 | struct prefix *range, int exact); | |
2986cac2 | 159 | |
36235319 QY |
160 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, |
161 | struct bgp *bgp, | |
162 | bool use_json, | |
163 | json_object *json); | |
2986cac2 | 164 | |
36235319 QY |
165 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
166 | enum show_type type, | |
167 | const char *ip_str, | |
168 | afi_t afi, bool use_json); | |
2986cac2 | 169 | |
d62a17ae | 170 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) |
171 | { | |
172 | switch (afi) { | |
173 | case AFI_IP: | |
174 | switch (safi) { | |
175 | case SAFI_UNICAST: | |
176 | return BGP_IPV4_NODE; | |
d62a17ae | 177 | case SAFI_MULTICAST: |
178 | return BGP_IPV4M_NODE; | |
d62a17ae | 179 | case SAFI_LABELED_UNICAST: |
180 | return BGP_IPV4L_NODE; | |
d62a17ae | 181 | case SAFI_MPLS_VPN: |
182 | return BGP_VPNV4_NODE; | |
7c40bf39 | 183 | case SAFI_FLOWSPEC: |
184 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
185 | default: |
186 | /* not expected */ | |
187 | return BGP_IPV4_NODE; | |
d62a17ae | 188 | } |
d62a17ae | 189 | case AFI_IP6: |
190 | switch (safi) { | |
191 | case SAFI_UNICAST: | |
192 | return BGP_IPV6_NODE; | |
d62a17ae | 193 | case SAFI_MULTICAST: |
194 | return BGP_IPV6M_NODE; | |
d62a17ae | 195 | case SAFI_LABELED_UNICAST: |
196 | return BGP_IPV6L_NODE; | |
d62a17ae | 197 | case SAFI_MPLS_VPN: |
198 | return BGP_VPNV6_NODE; | |
7c40bf39 | 199 | case SAFI_FLOWSPEC: |
200 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
201 | default: |
202 | /* not expected */ | |
203 | return BGP_IPV4_NODE; | |
d62a17ae | 204 | } |
d62a17ae | 205 | case AFI_L2VPN: |
206 | return BGP_EVPN_NODE; | |
b26f891d | 207 | case AFI_UNSPEC: |
d62a17ae | 208 | case AFI_MAX: |
209 | // We should never be here but to clarify the switch statement.. | |
210 | return BGP_IPV4_NODE; | |
d62a17ae | 211 | } |
212 | ||
213 | // Impossible to happen | |
214 | return BGP_IPV4_NODE; | |
f51bae9c | 215 | } |
20eb8864 | 216 | |
5cb5f4d0 DD |
217 | static const char *get_afi_safi_vty_str(afi_t afi, safi_t safi) |
218 | { | |
7d0d37de DS |
219 | if (afi == AFI_IP) { |
220 | if (safi == SAFI_UNICAST) | |
221 | return "IPv4 Unicast"; | |
222 | if (safi == SAFI_MULTICAST) | |
223 | return "IPv4 Multicast"; | |
224 | if (safi == SAFI_LABELED_UNICAST) | |
225 | return "IPv4 Labeled Unicast"; | |
226 | if (safi == SAFI_MPLS_VPN) | |
227 | return "IPv4 VPN"; | |
228 | if (safi == SAFI_ENCAP) | |
229 | return "IPv4 Encap"; | |
230 | if (safi == SAFI_FLOWSPEC) | |
231 | return "IPv4 Flowspec"; | |
232 | } else if (afi == AFI_IP6) { | |
233 | if (safi == SAFI_UNICAST) | |
234 | return "IPv6 Unicast"; | |
235 | if (safi == SAFI_MULTICAST) | |
236 | return "IPv6 Multicast"; | |
237 | if (safi == SAFI_LABELED_UNICAST) | |
238 | return "IPv6 Labeled Unicast"; | |
239 | if (safi == SAFI_MPLS_VPN) | |
240 | return "IPv6 VPN"; | |
241 | if (safi == SAFI_ENCAP) | |
242 | return "IPv6 Encap"; | |
243 | if (safi == SAFI_FLOWSPEC) | |
244 | return "IPv6 Flowspec"; | |
245 | } else if (afi == AFI_L2VPN) { | |
246 | if (safi == SAFI_EVPN) | |
247 | return "L2VPN EVPN"; | |
248 | } | |
249 | ||
250 | return "Unknown"; | |
5cb5f4d0 DD |
251 | } |
252 | ||
253 | /* | |
254 | * Please note that we have intentionally camelCased | |
255 | * the return strings here. So if you want | |
256 | * to use this function, please ensure you | |
257 | * are doing this within json output | |
258 | */ | |
259 | static const char *get_afi_safi_json_str(afi_t afi, safi_t safi) | |
260 | { | |
7d0d37de DS |
261 | if (afi == AFI_IP) { |
262 | if (safi == SAFI_UNICAST) | |
263 | return "ipv4Unicast"; | |
264 | if (safi == SAFI_MULTICAST) | |
265 | return "ipv4Multicast"; | |
266 | if (safi == SAFI_LABELED_UNICAST) | |
267 | return "ipv4LabeledUnicast"; | |
268 | if (safi == SAFI_MPLS_VPN) | |
269 | return "ipv4Vpn"; | |
270 | if (safi == SAFI_ENCAP) | |
271 | return "ipv4Encap"; | |
272 | if (safi == SAFI_FLOWSPEC) | |
273 | return "ipv4Flowspec"; | |
274 | } else if (afi == AFI_IP6) { | |
275 | if (safi == SAFI_UNICAST) | |
276 | return "ipv6Unicast"; | |
277 | if (safi == SAFI_MULTICAST) | |
278 | return "ipv6Multicast"; | |
279 | if (safi == SAFI_LABELED_UNICAST) | |
280 | return "ipv6LabeledUnicast"; | |
281 | if (safi == SAFI_MPLS_VPN) | |
282 | return "ipv6Vpn"; | |
283 | if (safi == SAFI_ENCAP) | |
284 | return "ipv6Encap"; | |
285 | if (safi == SAFI_FLOWSPEC) | |
286 | return "ipv6Flowspec"; | |
287 | } else if (afi == AFI_L2VPN) { | |
288 | if (safi == SAFI_EVPN) | |
289 | return "l2VpnEvpn"; | |
290 | } | |
291 | ||
292 | return "Unknown"; | |
5cb5f4d0 DD |
293 | } |
294 | ||
0249b8b6 HS |
295 | /* unset srv6 locator */ |
296 | static int bgp_srv6_locator_unset(struct bgp *bgp) | |
297 | { | |
298 | int ret; | |
299 | struct listnode *node, *nnode; | |
efae8c26 | 300 | struct srv6_locator_chunk *chunk; |
0249b8b6 HS |
301 | struct bgp_srv6_function *func; |
302 | struct bgp *bgp_vrf; | |
0249b8b6 HS |
303 | |
304 | /* release chunk notification via ZAPI */ | |
305 | ret = bgp_zebra_srv6_manager_release_locator_chunk( | |
306 | bgp->srv6_locator_name); | |
307 | if (ret < 0) | |
308 | return -1; | |
309 | ||
310 | /* refresh chunks */ | |
03852f67 | 311 | for (ALL_LIST_ELEMENTS(bgp->srv6_locator_chunks, node, nnode, chunk)) { |
0249b8b6 | 312 | listnode_delete(bgp->srv6_locator_chunks, chunk); |
69467313 | 313 | srv6_locator_chunk_free(&chunk); |
03852f67 | 314 | } |
0249b8b6 HS |
315 | |
316 | /* refresh functions */ | |
bda15542 | 317 | for (ALL_LIST_ELEMENTS(bgp->srv6_functions, node, nnode, func)) { |
0249b8b6 | 318 | listnode_delete(bgp->srv6_functions, func); |
bda15542 CS |
319 | XFREE(MTYPE_BGP_SRV6_FUNCTION, func); |
320 | } | |
0249b8b6 HS |
321 | |
322 | /* refresh tovpn_sid */ | |
323 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp_vrf)) { | |
324 | if (bgp_vrf->inst_type != BGP_INSTANCE_TYPE_VRF) | |
325 | continue; | |
326 | ||
327 | /* refresh vpnv4 tovpn_sid */ | |
944909f4 CS |
328 | XFREE(MTYPE_BGP_SRV6_SID, |
329 | bgp_vrf->vpn_policy[AFI_IP].tovpn_sid); | |
0249b8b6 HS |
330 | |
331 | /* refresh vpnv6 tovpn_sid */ | |
944909f4 CS |
332 | XFREE(MTYPE_BGP_SRV6_SID, |
333 | bgp_vrf->vpn_policy[AFI_IP6].tovpn_sid); | |
527588aa CS |
334 | |
335 | /* refresh per-vrf tovpn_sid */ | |
336 | XFREE(MTYPE_BGP_SRV6_SID, bgp_vrf->tovpn_sid); | |
0249b8b6 HS |
337 | } |
338 | ||
339 | /* update vpn bgp processes */ | |
340 | vpn_leak_postchange_all(); | |
341 | ||
f8e9c702 CS |
342 | /* refresh tovpn_sid_locator */ |
343 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp_vrf)) { | |
344 | if (bgp_vrf->inst_type != BGP_INSTANCE_TYPE_VRF) | |
345 | continue; | |
346 | ||
347 | /* refresh vpnv4 tovpn_sid_locator */ | |
efae8c26 CS |
348 | srv6_locator_chunk_free( |
349 | &bgp_vrf->vpn_policy[AFI_IP].tovpn_sid_locator); | |
f8e9c702 CS |
350 | |
351 | /* refresh vpnv6 tovpn_sid_locator */ | |
efae8c26 CS |
352 | srv6_locator_chunk_free( |
353 | &bgp_vrf->vpn_policy[AFI_IP6].tovpn_sid_locator); | |
527588aa CS |
354 | |
355 | /* refresh per-vrf tovpn_sid_locator */ | |
69467313 | 356 | srv6_locator_chunk_free(&bgp_vrf->tovpn_sid_locator); |
f8e9c702 CS |
357 | } |
358 | ||
0249b8b6 HS |
359 | /* clear locator name */ |
360 | memset(bgp->srv6_locator_name, 0, sizeof(bgp->srv6_locator_name)); | |
361 | ||
362 | return 0; | |
363 | } | |
364 | ||
718e3744 | 365 | /* Utility function to get address family from current node. */ |
d62a17ae | 366 | afi_t bgp_node_afi(struct vty *vty) |
367 | { | |
368 | afi_t afi; | |
369 | switch (vty->node) { | |
370 | case BGP_IPV6_NODE: | |
371 | case BGP_IPV6M_NODE: | |
372 | case BGP_IPV6L_NODE: | |
373 | case BGP_VPNV6_NODE: | |
7c40bf39 | 374 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 375 | afi = AFI_IP6; |
376 | break; | |
377 | case BGP_EVPN_NODE: | |
378 | afi = AFI_L2VPN; | |
379 | break; | |
380 | default: | |
381 | afi = AFI_IP; | |
382 | break; | |
383 | } | |
384 | return afi; | |
718e3744 | 385 | } |
386 | ||
387 | /* Utility function to get subsequent address family from current | |
388 | node. */ | |
d62a17ae | 389 | safi_t bgp_node_safi(struct vty *vty) |
390 | { | |
391 | safi_t safi; | |
392 | switch (vty->node) { | |
393 | case BGP_VPNV4_NODE: | |
394 | case BGP_VPNV6_NODE: | |
395 | safi = SAFI_MPLS_VPN; | |
396 | break; | |
397 | case BGP_IPV4M_NODE: | |
398 | case BGP_IPV6M_NODE: | |
399 | safi = SAFI_MULTICAST; | |
400 | break; | |
401 | case BGP_EVPN_NODE: | |
402 | safi = SAFI_EVPN; | |
403 | break; | |
404 | case BGP_IPV4L_NODE: | |
405 | case BGP_IPV6L_NODE: | |
406 | safi = SAFI_LABELED_UNICAST; | |
407 | break; | |
7c40bf39 | 408 | case BGP_FLOWSPECV4_NODE: |
409 | case BGP_FLOWSPECV6_NODE: | |
410 | safi = SAFI_FLOWSPEC; | |
411 | break; | |
d62a17ae | 412 | default: |
413 | safi = SAFI_UNICAST; | |
414 | break; | |
415 | } | |
416 | return safi; | |
718e3744 | 417 | } |
418 | ||
55f91488 QY |
419 | /** |
420 | * Converts an AFI in string form to afi_t | |
421 | * | |
422 | * @param afi string, one of | |
423 | * - "ipv4" | |
424 | * - "ipv6" | |
81cf0de5 | 425 | * - "l2vpn" |
55f91488 QY |
426 | * @return the corresponding afi_t |
427 | */ | |
d62a17ae | 428 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
429 | { | |
430 | afi_t afi = AFI_MAX; /* unknown */ | |
431 | if (strmatch(afi_str, "ipv4")) | |
432 | afi = AFI_IP; | |
433 | else if (strmatch(afi_str, "ipv6")) | |
434 | afi = AFI_IP6; | |
81cf0de5 CS |
435 | else if (strmatch(afi_str, "l2vpn")) |
436 | afi = AFI_L2VPN; | |
d62a17ae | 437 | return afi; |
438 | } | |
439 | ||
440 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
441 | afi_t *afi) | |
442 | { | |
443 | int ret = 0; | |
444 | if (argv_find(argv, argc, "ipv4", index)) { | |
445 | ret = 1; | |
446 | if (afi) | |
447 | *afi = AFI_IP; | |
448 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
449 | ret = 1; | |
450 | if (afi) | |
451 | *afi = AFI_IP6; | |
8688b3e7 DS |
452 | } else if (argv_find(argv, argc, "l2vpn", index)) { |
453 | ret = 1; | |
454 | if (afi) | |
455 | *afi = AFI_L2VPN; | |
d62a17ae | 456 | } |
457 | return ret; | |
46f296b4 LB |
458 | } |
459 | ||
375a2e67 | 460 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 461 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
462 | { | |
463 | safi_t safi = SAFI_MAX; /* unknown */ | |
464 | if (strmatch(safi_str, "multicast")) | |
465 | safi = SAFI_MULTICAST; | |
466 | else if (strmatch(safi_str, "unicast")) | |
467 | safi = SAFI_UNICAST; | |
468 | else if (strmatch(safi_str, "vpn")) | |
469 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
470 | else if (strmatch(safi_str, "evpn")) |
471 | safi = SAFI_EVPN; | |
d62a17ae | 472 | else if (strmatch(safi_str, "labeled-unicast")) |
473 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 474 | else if (strmatch(safi_str, "flowspec")) |
475 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 476 | return safi; |
477 | } | |
478 | ||
479 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
480 | safi_t *safi) | |
481 | { | |
482 | int ret = 0; | |
483 | if (argv_find(argv, argc, "unicast", index)) { | |
484 | ret = 1; | |
485 | if (safi) | |
486 | *safi = SAFI_UNICAST; | |
487 | } else if (argv_find(argv, argc, "multicast", index)) { | |
488 | ret = 1; | |
489 | if (safi) | |
490 | *safi = SAFI_MULTICAST; | |
491 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
492 | ret = 1; | |
493 | if (safi) | |
494 | *safi = SAFI_LABELED_UNICAST; | |
495 | } else if (argv_find(argv, argc, "vpn", index)) { | |
496 | ret = 1; | |
497 | if (safi) | |
498 | *safi = SAFI_MPLS_VPN; | |
8688b3e7 DS |
499 | } else if (argv_find(argv, argc, "evpn", index)) { |
500 | ret = 1; | |
501 | if (safi) | |
502 | *safi = SAFI_EVPN; | |
7c40bf39 | 503 | } else if (argv_find(argv, argc, "flowspec", index)) { |
504 | ret = 1; | |
505 | if (safi) | |
506 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 507 | } |
508 | return ret; | |
46f296b4 LB |
509 | } |
510 | ||
b16bcbba TA |
511 | /* |
512 | * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag. | |
513 | * | |
514 | * afi | |
515 | * address-family identifier | |
516 | * | |
517 | * safi | |
518 | * subsequent address-family identifier | |
519 | * | |
520 | * Returns: | |
521 | * default_af string corresponding to the supplied afi/safi pair. | |
522 | * If afi/safi is invalid or if flag for afi/safi doesn't exist, | |
523 | * return -1. | |
524 | */ | |
525 | static const char *get_bgp_default_af_flag(afi_t afi, safi_t safi) | |
526 | { | |
527 | switch (afi) { | |
528 | case AFI_IP: | |
529 | switch (safi) { | |
530 | case SAFI_UNICAST: | |
531 | return "ipv4-unicast"; | |
532 | case SAFI_MULTICAST: | |
533 | return "ipv4-multicast"; | |
534 | case SAFI_MPLS_VPN: | |
535 | return "ipv4-vpn"; | |
536 | case SAFI_ENCAP: | |
537 | return "ipv4-encap"; | |
538 | case SAFI_LABELED_UNICAST: | |
539 | return "ipv4-labeled-unicast"; | |
540 | case SAFI_FLOWSPEC: | |
541 | return "ipv4-flowspec"; | |
542 | default: | |
543 | return "unknown-afi/safi"; | |
544 | } | |
545 | break; | |
546 | case AFI_IP6: | |
547 | switch (safi) { | |
548 | case SAFI_UNICAST: | |
549 | return "ipv6-unicast"; | |
550 | case SAFI_MULTICAST: | |
551 | return "ipv6-multicast"; | |
552 | case SAFI_MPLS_VPN: | |
553 | return "ipv6-vpn"; | |
554 | case SAFI_ENCAP: | |
555 | return "ipv6-encap"; | |
556 | case SAFI_LABELED_UNICAST: | |
557 | return "ipv6-labeled-unicast"; | |
558 | case SAFI_FLOWSPEC: | |
559 | return "ipv6-flowspec"; | |
560 | default: | |
561 | return "unknown-afi/safi"; | |
562 | } | |
563 | break; | |
564 | case AFI_L2VPN: | |
565 | switch (safi) { | |
566 | case SAFI_EVPN: | |
567 | return "l2vpn-evpn"; | |
568 | default: | |
569 | return "unknown-afi/safi"; | |
570 | } | |
571 | case AFI_UNSPEC: | |
572 | case AFI_MAX: | |
573 | return "unknown-afi/safi"; | |
574 | } | |
575 | /* all AFIs are accounted for above, so this shouldn't happen */ | |
576 | return "unknown-afi/safi"; | |
577 | } | |
578 | ||
5d5393b9 DL |
579 | int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name, |
580 | enum bgp_instance_type inst_type) | |
581 | { | |
582 | int ret = bgp_get(bgp, as, name, inst_type); | |
583 | ||
584 | if (ret == BGP_CREATED) { | |
585 | bgp_timers_set(*bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
d43114f3 | 586 | DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN); |
5d5393b9 DL |
587 | |
588 | if (DFLT_BGP_IMPORT_CHECK) | |
892fedb6 | 589 | SET_FLAG((*bgp)->flags, BGP_FLAG_IMPORT_CHECK); |
5d5393b9 | 590 | if (DFLT_BGP_SHOW_HOSTNAME) |
892fedb6 | 591 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_HOSTNAME); |
aef999a2 DA |
592 | if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME) |
593 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
5d5393b9 | 594 | if (DFLT_BGP_LOG_NEIGHBOR_CHANGES) |
892fedb6 | 595 | SET_FLAG((*bgp)->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
5d5393b9 | 596 | if (DFLT_BGP_DETERMINISTIC_MED) |
892fedb6 | 597 | SET_FLAG((*bgp)->flags, BGP_FLAG_DETERMINISTIC_MED); |
1d3fdccf DA |
598 | if (DFLT_BGP_EBGP_REQUIRES_POLICY) |
599 | SET_FLAG((*bgp)->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2adac256 DA |
600 | if (DFLT_BGP_SUPPRESS_DUPLICATES) |
601 | SET_FLAG((*bgp)->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
f2ca5c5b DA |
602 | if (DFLT_BGP_GRACEFUL_NOTIFICATION) |
603 | SET_FLAG((*bgp)->flags, BGP_FLAG_GRACEFUL_NOTIFICATION); | |
1ae314be DA |
604 | if (DFLT_BGP_HARD_ADMIN_RESET) |
605 | SET_FLAG((*bgp)->flags, BGP_FLAG_HARD_ADMIN_RESET); | |
5d5393b9 DL |
606 | |
607 | ret = BGP_SUCCESS; | |
608 | } | |
609 | return ret; | |
610 | } | |
611 | ||
7eeee51e | 612 | /* |
f212a857 | 613 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 614 | * |
f212a857 DS |
615 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
616 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
617 | * to appropriate values for the calling function. This is to allow the |
618 | * calling function to make decisions appropriate for the show command | |
619 | * that is being parsed. | |
620 | * | |
621 | * The show commands are generally of the form: | |
d62a17ae | 622 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
623 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
624 | * |
625 | * Since we use argv_find if the show command in particular doesn't have: | |
626 | * [ip] | |
18c57037 | 627 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 628 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
629 | * The command parsing should still be ok. |
630 | * | |
631 | * vty -> The vty for the command so we can output some useful data in | |
632 | * the event of a parse error in the vrf. | |
633 | * argv -> The command tokens | |
634 | * argc -> How many command tokens we have | |
d62a17ae | 635 | * idx -> The current place in the command, generally should be 0 for this |
636 | * function | |
7eeee51e DS |
637 | * afi -> The parsed afi if it was included in the show command, returned here |
638 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 639 | * bgp -> Pointer to the bgp data structure we need to fill in. |
52e5b8c4 | 640 | * use_json -> json is configured or not |
7eeee51e DS |
641 | * |
642 | * The function returns the correct location in the parse tree for the | |
643 | * last token found. | |
0e37c258 DS |
644 | * |
645 | * Returns 0 for failure to parse correctly, else the idx position of where | |
646 | * it found the last token. | |
7eeee51e | 647 | */ |
d62a17ae | 648 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
649 | struct cmd_token **argv, int argc, | |
650 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 651 | struct bgp **bgp, bool use_json) |
d62a17ae | 652 | { |
653 | char *vrf_name = NULL; | |
654 | ||
655 | assert(afi); | |
656 | assert(safi); | |
657 | assert(bgp); | |
658 | ||
659 | if (argv_find(argv, argc, "ip", idx)) | |
660 | *afi = AFI_IP; | |
661 | ||
9a8bdf1c | 662 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 663 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
664 | else if (argv_find(argv, argc, "vrf", idx)) { |
665 | vrf_name = argv[*idx + 1]->arg; | |
666 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
667 | vrf_name = NULL; | |
668 | } | |
669 | if (vrf_name) { | |
d62a17ae | 670 | if (strmatch(vrf_name, "all")) |
671 | *bgp = NULL; | |
672 | else { | |
673 | *bgp = bgp_lookup_by_name(vrf_name); | |
674 | if (!*bgp) { | |
52e5b8c4 SP |
675 | if (use_json) { |
676 | json_object *json = NULL; | |
677 | json = json_object_new_object(); | |
678 | json_object_string_add( | |
679 | json, "warning", | |
680 | "View/Vrf is unknown"); | |
75eeda93 | 681 | vty_json(vty, json); |
52e5b8c4 | 682 | } |
ca61fd25 DS |
683 | else |
684 | vty_out(vty, "View/Vrf %s is unknown\n", | |
685 | vrf_name); | |
d62a17ae | 686 | *idx = 0; |
687 | return 0; | |
688 | } | |
689 | } | |
690 | } else { | |
691 | *bgp = bgp_get_default(); | |
692 | if (!*bgp) { | |
52e5b8c4 SP |
693 | if (use_json) { |
694 | json_object *json = NULL; | |
695 | json = json_object_new_object(); | |
696 | json_object_string_add( | |
697 | json, "warning", | |
698 | "Default BGP instance not found"); | |
75eeda93 | 699 | vty_json(vty, json); |
52e5b8c4 | 700 | } |
ca61fd25 DS |
701 | else |
702 | vty_out(vty, | |
703 | "Default BGP instance not found\n"); | |
d62a17ae | 704 | *idx = 0; |
705 | return 0; | |
706 | } | |
707 | } | |
708 | ||
709 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
710 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
711 | ||
712 | *idx += 1; | |
713 | return *idx; | |
714 | } | |
715 | ||
28c6e247 | 716 | static bool peer_address_self_check(struct bgp *bgp, union sockunion *su) |
d62a17ae | 717 | { |
718 | struct interface *ifp = NULL; | |
4122b697 DA |
719 | struct listnode *node; |
720 | struct bgp_listener *listener; | |
721 | union sockunion all_su; | |
d62a17ae | 722 | |
4122b697 | 723 | if (su->sa.sa_family == AF_INET) { |
3d2a2725 | 724 | (void)str2sockunion("0.0.0.0", &all_su); |
d62a17ae | 725 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); |
4122b697 | 726 | } else if (su->sa.sa_family == AF_INET6) { |
3d2a2725 | 727 | (void)str2sockunion("::", &all_su); |
d62a17ae | 728 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, |
729 | su->sin6.sin6_scope_id, | |
730 | bgp->vrf_id); | |
4122b697 | 731 | } |
d62a17ae | 732 | |
4122b697 DA |
733 | if (ifp) { |
734 | for (ALL_LIST_ELEMENTS_RO(bm->listen_sockets, node, listener)) { | |
735 | if (sockunion_family(su) != | |
736 | sockunion_family(&listener->su)) | |
737 | continue; | |
738 | ||
739 | /* If 0.0.0.0/:: is a listener, then treat as self and | |
740 | * reject. | |
741 | */ | |
742 | if (!sockunion_cmp(&listener->su, su) || | |
743 | !sockunion_cmp(&listener->su, &all_su)) | |
744 | return true; | |
745 | } | |
746 | } | |
d62a17ae | 747 | |
3dc339cd | 748 | return false; |
718e3744 | 749 | } |
750 | ||
28c6e247 IR |
751 | /* Utility function for looking up peer from VTY. */ |
752 | /* This is used only for configuration, so disallow if attempted on | |
753 | * a dynamic neighbor. | |
754 | */ | |
755 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) | |
756 | { | |
757 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
758 | int ret; | |
759 | union sockunion su; | |
760 | struct peer *peer; | |
761 | ||
762 | if (!bgp) { | |
763 | return NULL; | |
764 | } | |
765 | ||
766 | ret = str2sockunion(ip_str, &su); | |
767 | if (ret < 0) { | |
768 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
769 | if (!peer) { | |
770 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
771 | == NULL) { | |
772 | vty_out(vty, | |
773 | "%% Malformed address or name: %s\n", | |
774 | ip_str); | |
775 | return NULL; | |
776 | } | |
777 | } | |
778 | } else { | |
779 | peer = peer_lookup(bgp, &su); | |
780 | if (!peer) { | |
781 | vty_out(vty, | |
782 | "%% Specify remote-as or peer-group commands first\n"); | |
783 | return NULL; | |
784 | } | |
785 | if (peer_dynamic_neighbor(peer)) { | |
786 | vty_out(vty, | |
787 | "%% Operation not allowed on a dynamic neighbor\n"); | |
788 | return NULL; | |
789 | } | |
790 | } | |
791 | return peer; | |
792 | } | |
793 | ||
718e3744 | 794 | /* Utility function for looking up peer or peer group. */ |
f14e6fdb DS |
795 | /* This is used only for configuration, so disallow if attempted on |
796 | * a dynamic neighbor. | |
797 | */ | |
d62a17ae | 798 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
799 | { | |
800 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
801 | int ret; | |
802 | union sockunion su; | |
803 | struct peer *peer = NULL; | |
804 | struct peer_group *group = NULL; | |
805 | ||
806 | if (!bgp) { | |
807 | return NULL; | |
808 | } | |
809 | ||
810 | ret = str2sockunion(peer_str, &su); | |
811 | if (ret == 0) { | |
812 | /* IP address, locate peer. */ | |
813 | peer = peer_lookup(bgp, &su); | |
814 | } else { | |
815 | /* Not IP, could match either peer configured on interface or a | |
816 | * group. */ | |
817 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
818 | if (!peer) | |
819 | group = peer_group_lookup(bgp, peer_str); | |
820 | } | |
821 | ||
822 | if (peer) { | |
823 | if (peer_dynamic_neighbor(peer)) { | |
824 | vty_out(vty, | |
825 | "%% Operation not allowed on a dynamic neighbor\n"); | |
826 | return NULL; | |
827 | } | |
828 | ||
829 | return peer; | |
830 | } | |
831 | ||
832 | if (group) | |
833 | return group->conf; | |
834 | ||
835 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
836 | ||
837 | return NULL; | |
838 | } | |
839 | ||
4b7e23e9 | 840 | int bgp_vty_return(struct vty *vty, enum bgp_create_error_code ret) |
d62a17ae | 841 | { |
842 | const char *str = NULL; | |
843 | ||
844 | switch (ret) { | |
4b7e23e9 DS |
845 | case BGP_SUCCESS: |
846 | case BGP_CREATED: | |
847 | case BGP_GR_NO_OPERATION: | |
848 | break; | |
d62a17ae | 849 | case BGP_ERR_INVALID_VALUE: |
850 | str = "Invalid value"; | |
851 | break; | |
852 | case BGP_ERR_INVALID_FLAG: | |
853 | str = "Invalid flag"; | |
854 | break; | |
855 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
856 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
857 | break; | |
858 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
859 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
860 | break; | |
861 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
862 | str = "Specify remote-as or peer-group remote AS first"; | |
863 | break; | |
864 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
865 | str = "Cannot change the peer-group. Deconfigure first"; | |
866 | break; | |
867 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
868 | str = "Peer is not a member of this peer-group"; | |
869 | break; | |
870 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
871 | str = "Prefix/distribute list can not co-exist"; | |
872 | break; | |
873 | case BGP_ERR_NOT_INTERNAL_PEER: | |
874 | str = "Invalid command. Not an internal neighbor"; | |
875 | break; | |
876 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
877 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
878 | break; | |
d62a17ae | 879 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: |
880 | str = "Cannot have local-as same as BGP AS number"; | |
881 | break; | |
882 | case BGP_ERR_TCPSIG_FAILED: | |
883 | str = "Error while applying TCP-Sig to session(s)"; | |
884 | break; | |
885 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
886 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
887 | break; | |
888 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
889 | str = "ttl-security only allowed for EBGP peers"; | |
890 | break; | |
891 | case BGP_ERR_AS_OVERRIDE: | |
892 | str = "as-override cannot be configured for IBGP peers"; | |
893 | break; | |
894 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
895 | str = "Invalid limit for number of dynamic neighbors"; | |
896 | break; | |
897 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
898 | str = "Dynamic neighbor listen range already exists"; | |
899 | break; | |
900 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
901 | str = "Operation not allowed on a dynamic neighbor"; | |
902 | break; | |
903 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
904 | str = "Operation not allowed on a directly connected neighbor"; | |
905 | break; | |
906 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
a59803d0 | 907 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; |
055679e9 | 908 | break; |
909 | case BGP_ERR_GR_INVALID_CMD: | |
910 | str = "The Graceful Restart command used is not valid at this moment."; | |
911 | break; | |
912 | case BGP_ERR_GR_OPERATION_FAILED: | |
913 | str = "The Graceful Restart Operation failed due to an err."; | |
914 | break; | |
6dcea6fe DS |
915 | case BGP_ERR_PEER_GROUP_MEMBER: |
916 | str = "Peer-group member cannot override remote-as of peer-group."; | |
917 | break; | |
918 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
919 | str = "Peer-group members must be all internal or all external."; | |
920 | break; | |
4b7e23e9 DS |
921 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND: |
922 | str = "Range specified cannot be deleted because it is not part of current config."; | |
923 | break; | |
924 | case BGP_ERR_INSTANCE_MISMATCH: | |
925 | str = "Instance specified does not match the current instance."; | |
926 | break; | |
927 | case BGP_ERR_NO_INTERFACE_CONFIG: | |
928 | str = "Interface specified is not being used for interface based peer."; | |
929 | break; | |
930 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
931 | str = "No configuration already specified for soft reconfiguration."; | |
932 | break; | |
933 | case BGP_ERR_AS_MISMATCH: | |
934 | str = "BGP is already running."; | |
935 | break; | |
936 | case BGP_ERR_AF_UNCONFIGURED: | |
937 | str = "AFI/SAFI specified is not currently configured."; | |
938 | break; | |
4b7e23e9 DS |
939 | case BGP_ERR_INVALID_AS: |
940 | str = "Confederation AS specified is the same AS as our AS."; | |
941 | break; | |
d864dd9e EB |
942 | case BGP_ERR_INVALID_ROLE_NAME: |
943 | str = "Invalid role name"; | |
944 | break; | |
945 | case BGP_ERR_INVALID_INTERNAL_ROLE: | |
8f2d6021 | 946 | str = "External roles can be set only on eBGP session"; |
d864dd9e | 947 | break; |
70cd87ca | 948 | case BGP_ERR_PEER_ORR_CONFIGURED: |
d6b27611 | 949 | str = "Deconfigure optimal-route-reflection on this peer first"; |
70cd87ca | 950 | break; |
d62a17ae | 951 | } |
952 | if (str) { | |
953 | vty_out(vty, "%% %s\n", str); | |
954 | return CMD_WARNING_CONFIG_FAILED; | |
955 | } | |
956 | return CMD_SUCCESS; | |
718e3744 | 957 | } |
958 | ||
7aafcaca | 959 | /* BGP clear sort. */ |
d62a17ae | 960 | enum clear_sort { |
961 | clear_all, | |
962 | clear_peer, | |
963 | clear_group, | |
964 | clear_external, | |
965 | clear_as | |
7aafcaca DS |
966 | }; |
967 | ||
1ca2fd11 IR |
968 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
969 | safi_t safi, int error) | |
d62a17ae | 970 | { |
971 | switch (error) { | |
972 | case BGP_ERR_AF_UNCONFIGURED: | |
a486300b PG |
973 | if (vty) |
974 | vty_out(vty, | |
975 | "%% BGP: Enable %s address family for the neighbor %s\n", | |
976 | get_afi_safi_str(afi, safi, false), peer->host); | |
977 | else | |
978 | zlog_warn( | |
1af6e82b | 979 | "%% BGP: Enable %s address family for the neighbor %s", |
a486300b | 980 | get_afi_safi_str(afi, safi, false), peer->host); |
d62a17ae | 981 | break; |
982 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
a486300b PG |
983 | if (vty) |
984 | vty_out(vty, | |
985 | "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
986 | peer->host); | |
987 | else | |
988 | zlog_warn( | |
1af6e82b | 989 | "%% BGP: Inbound soft reconfig for %s not possible as it has neither refresh capability, nor inbound soft reconfig", |
a486300b | 990 | peer->host); |
d62a17ae | 991 | break; |
992 | default: | |
993 | break; | |
994 | } | |
7aafcaca DS |
995 | } |
996 | ||
dc912615 | 997 | static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, |
c368171c | 998 | struct listnode **nnode, enum bgp_clear_type stype) |
dc912615 DS |
999 | { |
1000 | int ret = 0; | |
2adac256 | 1001 | struct peer_af *paf; |
dc912615 DS |
1002 | |
1003 | /* if afi/.safi not specified, spin thru all of them */ | |
1004 | if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) { | |
1005 | afi_t tmp_afi; | |
1006 | safi_t tmp_safi; | |
0e5cdd59 DS |
1007 | enum bgp_af_index index; |
1008 | ||
1009 | for (index = BGP_AF_START; index < BGP_AF_MAX; index++) { | |
1010 | paf = peer->peer_af_array[index]; | |
1011 | if (!paf) | |
1012 | continue; | |
dc912615 | 1013 | |
2adac256 DA |
1014 | if (paf && paf->subgroup) |
1015 | SET_FLAG(paf->subgroup->sflags, | |
1016 | SUBGRP_STATUS_FORCE_UPDATES); | |
1017 | ||
0e5cdd59 DS |
1018 | tmp_afi = paf->afi; |
1019 | tmp_safi = paf->safi; | |
dc912615 DS |
1020 | if (!peer->afc[tmp_afi][tmp_safi]) |
1021 | continue; | |
1022 | ||
1023 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 1024 | ret = peer_clear(peer, nnode); |
dc912615 DS |
1025 | else |
1026 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
1027 | stype); | |
1028 | } | |
1029 | /* if afi specified and safi not, spin thru safis on this afi */ | |
1030 | } else if (safi == SAFI_UNSPEC) { | |
1031 | safi_t tmp_safi; | |
1032 | ||
1033 | for (tmp_safi = SAFI_UNICAST; | |
1034 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
1035 | if (!peer->afc[afi][tmp_safi]) | |
1036 | continue; | |
1037 | ||
2adac256 DA |
1038 | paf = peer_af_find(peer, afi, tmp_safi); |
1039 | if (paf && paf->subgroup) | |
1040 | SET_FLAG(paf->subgroup->sflags, | |
1041 | SUBGRP_STATUS_FORCE_UPDATES); | |
1042 | ||
dc912615 | 1043 | if (stype == BGP_CLEAR_SOFT_NONE) |
c368171c | 1044 | ret = peer_clear(peer, nnode); |
dc912615 DS |
1045 | else |
1046 | ret = peer_clear_soft(peer, afi, | |
1047 | tmp_safi, stype); | |
1048 | } | |
1049 | /* both afi/safi specified, let the caller know if not defined */ | |
1050 | } else { | |
1051 | if (!peer->afc[afi][safi]) | |
1052 | return 1; | |
1053 | ||
2adac256 DA |
1054 | paf = peer_af_find(peer, afi, safi); |
1055 | if (paf && paf->subgroup) | |
1056 | SET_FLAG(paf->subgroup->sflags, | |
1057 | SUBGRP_STATUS_FORCE_UPDATES); | |
1058 | ||
dc912615 | 1059 | if (stype == BGP_CLEAR_SOFT_NONE) |
c368171c | 1060 | ret = peer_clear(peer, nnode); |
dc912615 DS |
1061 | else |
1062 | ret = peer_clear_soft(peer, afi, safi, stype); | |
1063 | } | |
1064 | ||
1065 | return ret; | |
1066 | } | |
1067 | ||
7aafcaca | 1068 | /* `clear ip bgp' functions. */ |
1ca2fd11 | 1069 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
d62a17ae | 1070 | enum clear_sort sort, enum bgp_clear_type stype, |
1ca2fd11 | 1071 | const char *arg) |
d62a17ae | 1072 | { |
dc912615 | 1073 | int ret = 0; |
3ae8bfa5 | 1074 | bool found = false; |
d62a17ae | 1075 | struct peer *peer; |
dc95985f | 1076 | |
1077 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
d62a17ae | 1078 | |
1079 | /* Clear all neighbors. */ | |
1080 | /* | |
1081 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
1082 | * nodes on the BGP instance as that may get freed if it is a |
1083 | * doppelganger | |
d62a17ae | 1084 | */ |
1085 | if (sort == clear_all) { | |
1086 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dc95985f | 1087 | |
1088 | bgp_peer_gr_flags_update(peer); | |
1089 | ||
36235319 | 1090 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
dc95985f | 1091 | gr_router_detected = true; |
1092 | ||
c368171c | 1093 | ret = bgp_peer_clear(peer, afi, safi, &nnode, |
dc912615 | 1094 | stype); |
d62a17ae | 1095 | |
1096 | if (ret < 0) | |
1ca2fd11 | 1097 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
dc95985f | 1098 | } |
1099 | ||
36235319 QY |
1100 | if (gr_router_detected |
1101 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1102 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1103 | } else if (!gr_router_detected |
1104 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1105 | bgp_zebra_send_capabilities(bgp, true); |
04b6bdc0 | 1106 | } |
d62a17ae | 1107 | |
1108 | /* This is to apply read-only mode on this clear. */ | |
1109 | if (stype == BGP_CLEAR_SOFT_NONE) | |
1110 | bgp->update_delay_over = 0; | |
1111 | ||
1112 | return CMD_SUCCESS; | |
7aafcaca DS |
1113 | } |
1114 | ||
3ae8bfa5 | 1115 | /* Clear specified neighbor. */ |
d62a17ae | 1116 | if (sort == clear_peer) { |
1117 | union sockunion su; | |
d62a17ae | 1118 | |
1119 | /* Make sockunion for lookup. */ | |
1120 | ret = str2sockunion(arg, &su); | |
1121 | if (ret < 0) { | |
1122 | peer = peer_lookup_by_conf_if(bgp, arg); | |
1123 | if (!peer) { | |
1124 | peer = peer_lookup_by_hostname(bgp, arg); | |
1125 | if (!peer) { | |
1ca2fd11 IR |
1126 | vty_out(vty, |
1127 | "Malformed address or name: %s\n", | |
d62a17ae | 1128 | arg); |
1129 | return CMD_WARNING; | |
1130 | } | |
1131 | } | |
1132 | } else { | |
1133 | peer = peer_lookup(bgp, &su); | |
1134 | if (!peer) { | |
1ca2fd11 | 1135 | vty_out(vty, |
664b6f18 | 1136 | "%% BGP: Unknown neighbor - \"%s\"\n", |
1ca2fd11 | 1137 | arg); |
d62a17ae | 1138 | return CMD_WARNING; |
1139 | } | |
1140 | } | |
7aafcaca | 1141 | |
dc95985f | 1142 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
1143 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
1144 | ||
dc912615 DS |
1145 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); |
1146 | ||
1147 | /* if afi/safi not defined for this peer, let caller know */ | |
1148 | if (ret == 1) | |
3ae8bfa5 | 1149 | ret = BGP_ERR_AF_UNCONFIGURED; |
7aafcaca | 1150 | |
d62a17ae | 1151 | if (ret < 0) |
1ca2fd11 | 1152 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
7aafcaca | 1153 | |
d62a17ae | 1154 | return CMD_SUCCESS; |
7aafcaca | 1155 | } |
7aafcaca | 1156 | |
3ae8bfa5 | 1157 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 1158 | if (sort == clear_group) { |
1159 | struct peer_group *group; | |
7aafcaca | 1160 | |
d62a17ae | 1161 | group = peer_group_lookup(bgp, arg); |
1162 | if (!group) { | |
664b6f18 | 1163 | vty_out(vty, "%% BGP: No such peer-group %s\n", arg); |
d62a17ae | 1164 | return CMD_WARNING; |
1165 | } | |
1166 | ||
1167 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
c368171c | 1168 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 1169 | |
d62a17ae | 1170 | if (ret < 0) |
1ca2fd11 | 1171 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
3ae8bfa5 PM |
1172 | else |
1173 | found = true; | |
d62a17ae | 1174 | } |
3ae8bfa5 PM |
1175 | |
1176 | if (!found) | |
1ca2fd11 | 1177 | vty_out(vty, |
664b6f18 | 1178 | "%% BGP: No %s peer belonging to peer-group %s is configured\n", |
5cb5f4d0 | 1179 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 1180 | |
d62a17ae | 1181 | return CMD_SUCCESS; |
7aafcaca | 1182 | } |
7aafcaca | 1183 | |
3ae8bfa5 | 1184 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 1185 | if (sort == clear_external) { |
1186 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1187 | if (peer->sort == BGP_PEER_IBGP) | |
1188 | continue; | |
7aafcaca | 1189 | |
dc95985f | 1190 | bgp_peer_gr_flags_update(peer); |
1191 | ||
36235319 | 1192 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 1193 | gr_router_detected = true; |
dc95985f | 1194 | |
c368171c | 1195 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 1196 | |
d62a17ae | 1197 | if (ret < 0) |
1ca2fd11 | 1198 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
3ae8bfa5 PM |
1199 | else |
1200 | found = true; | |
d62a17ae | 1201 | } |
3ae8bfa5 | 1202 | |
36235319 QY |
1203 | if (gr_router_detected |
1204 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1205 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1206 | } else if (!gr_router_detected |
1207 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1208 | bgp_zebra_send_capabilities(bgp, true); |
1209 | } | |
1210 | ||
3ae8bfa5 | 1211 | if (!found) |
1ca2fd11 | 1212 | vty_out(vty, |
664b6f18 | 1213 | "%% BGP: No external %s peer is configured\n", |
1ca2fd11 | 1214 | get_afi_safi_str(afi, safi, false)); |
3ae8bfa5 | 1215 | |
d62a17ae | 1216 | return CMD_SUCCESS; |
1217 | } | |
1218 | ||
3ae8bfa5 | 1219 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 1220 | if (sort == clear_as) { |
3ae8bfa5 | 1221 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 1222 | |
1223 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1224 | if (peer->as != as) | |
1225 | continue; | |
1226 | ||
dc95985f | 1227 | bgp_peer_gr_flags_update(peer); |
1228 | ||
36235319 | 1229 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 1230 | gr_router_detected = true; |
dc95985f | 1231 | |
c368171c | 1232 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
d62a17ae | 1233 | |
1234 | if (ret < 0) | |
1ca2fd11 | 1235 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
3ae8bfa5 PM |
1236 | else |
1237 | found = true; | |
d62a17ae | 1238 | } |
3ae8bfa5 | 1239 | |
36235319 QY |
1240 | if (gr_router_detected |
1241 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1242 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1243 | } else if (!gr_router_detected |
1244 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1245 | bgp_zebra_send_capabilities(bgp, true); |
1246 | } | |
1247 | ||
3ae8bfa5 | 1248 | if (!found) |
1ca2fd11 | 1249 | vty_out(vty, |
664b6f18 | 1250 | "%% BGP: No %s peer is configured with AS %s\n", |
1ca2fd11 | 1251 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 1252 | |
d62a17ae | 1253 | return CMD_SUCCESS; |
1254 | } | |
1255 | ||
1256 | return CMD_SUCCESS; | |
1257 | } | |
1258 | ||
1ca2fd11 IR |
1259 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, |
1260 | safi_t safi, enum clear_sort sort, | |
1261 | enum bgp_clear_type stype, const char *arg) | |
d62a17ae | 1262 | { |
1263 | struct bgp *bgp; | |
1264 | ||
1265 | /* BGP structure lookup. */ | |
1266 | if (name) { | |
1267 | bgp = bgp_lookup_by_name(name); | |
1268 | if (bgp == NULL) { | |
1ca2fd11 | 1269 | vty_out(vty, "Can't find BGP instance %s\n", name); |
d62a17ae | 1270 | return CMD_WARNING; |
1271 | } | |
1272 | } else { | |
1273 | bgp = bgp_get_default(); | |
1274 | if (bgp == NULL) { | |
1ca2fd11 | 1275 | vty_out(vty, "No BGP process is configured\n"); |
d62a17ae | 1276 | return CMD_WARNING; |
1277 | } | |
1278 | } | |
1279 | ||
1ca2fd11 | 1280 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); |
7aafcaca DS |
1281 | } |
1282 | ||
1283 | /* clear soft inbound */ | |
1ca2fd11 | 1284 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 1285 | { |
99b3ebd3 NS |
1286 | afi_t afi; |
1287 | safi_t safi; | |
1288 | ||
1ca2fd11 IR |
1289 | FOREACH_AFI_SAFI (afi, safi) |
1290 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1291 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
1292 | } |
1293 | ||
1294 | /* clear soft outbound */ | |
1ca2fd11 | 1295 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 1296 | { |
99b3ebd3 NS |
1297 | afi_t afi; |
1298 | safi_t safi; | |
1299 | ||
1ca2fd11 IR |
1300 | FOREACH_AFI_SAFI (afi, safi) |
1301 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1302 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
1303 | } |
1304 | ||
1305 | ||
a486300b PG |
1306 | void bgp_clear_soft_in(struct bgp *bgp, afi_t afi, safi_t safi) |
1307 | { | |
1308 | bgp_clear(NULL, bgp, afi, safi, clear_all, BGP_CLEAR_SOFT_IN, NULL); | |
1309 | } | |
1310 | ||
2e4c2296 | 1311 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 | 1312 | |
8029b216 AK |
1313 | DEFUN_HIDDEN (bgp_local_mac, |
1314 | bgp_local_mac_cmd, | |
093e3f23 | 1315 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
1316 | BGP_STR |
1317 | "Local MAC config\n" | |
1318 | "VxLAN Network Identifier\n" | |
1319 | "VNI number\n" | |
1320 | "local mac\n" | |
1321 | "mac address\n" | |
1322 | "mac-mobility sequence\n" | |
1323 | "seq number\n") | |
1324 | { | |
1325 | int rv; | |
1326 | vni_t vni; | |
1327 | struct ethaddr mac; | |
1328 | struct ipaddr ip; | |
1329 | uint32_t seq; | |
1330 | struct bgp *bgp; | |
1331 | ||
1332 | vni = strtoul(argv[3]->arg, NULL, 10); | |
1333 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
1334 | vty_out(vty, "%% Malformed MAC address\n"); | |
1335 | return CMD_WARNING; | |
1336 | } | |
1337 | memset(&ip, 0, sizeof(ip)); | |
1338 | seq = strtoul(argv[7]->arg, NULL, 10); | |
1339 | ||
1340 | bgp = bgp_get_default(); | |
1341 | if (!bgp) { | |
1342 | vty_out(vty, "Default BGP instance is not there\n"); | |
1343 | return CMD_WARNING; | |
1344 | } | |
1345 | ||
b5e140c8 AK |
1346 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq, |
1347 | zero_esi); | |
8029b216 AK |
1348 | if (rv < 0) { |
1349 | vty_out(vty, "Internal error\n"); | |
1350 | return CMD_WARNING; | |
1351 | } | |
1352 | ||
1353 | return CMD_SUCCESS; | |
1354 | } | |
1355 | ||
1356 | DEFUN_HIDDEN (no_bgp_local_mac, | |
1357 | no_bgp_local_mac_cmd, | |
093e3f23 | 1358 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
1359 | NO_STR |
1360 | BGP_STR | |
1361 | "Local MAC config\n" | |
1362 | "VxLAN Network Identifier\n" | |
1363 | "VNI number\n" | |
1364 | "local mac\n" | |
1365 | "mac address\n") | |
1366 | { | |
1367 | int rv; | |
1368 | vni_t vni; | |
1369 | struct ethaddr mac; | |
1370 | struct ipaddr ip; | |
1371 | struct bgp *bgp; | |
1372 | ||
1373 | vni = strtoul(argv[4]->arg, NULL, 10); | |
1374 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
1375 | vty_out(vty, "%% Malformed MAC address\n"); | |
1376 | return CMD_WARNING; | |
1377 | } | |
1378 | memset(&ip, 0, sizeof(ip)); | |
1379 | ||
1380 | bgp = bgp_get_default(); | |
1381 | if (!bgp) { | |
1382 | vty_out(vty, "Default BGP instance is not there\n"); | |
1383 | return CMD_WARNING; | |
1384 | } | |
1385 | ||
ec0ab544 | 1386 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
1387 | if (rv < 0) { |
1388 | vty_out(vty, "Internal error\n"); | |
1389 | return CMD_WARNING; | |
1390 | } | |
1391 | ||
1392 | return CMD_SUCCESS; | |
1393 | } | |
1394 | ||
718e3744 | 1395 | DEFUN (no_synchronization, |
1396 | no_synchronization_cmd, | |
1397 | "no synchronization", | |
1398 | NO_STR | |
1399 | "Perform IGP synchronization\n") | |
1400 | { | |
d62a17ae | 1401 | return CMD_SUCCESS; |
718e3744 | 1402 | } |
1403 | ||
1404 | DEFUN (no_auto_summary, | |
1405 | no_auto_summary_cmd, | |
1406 | "no auto-summary", | |
1407 | NO_STR | |
1408 | "Enable automatic network number summarization\n") | |
1409 | { | |
d62a17ae | 1410 | return CMD_SUCCESS; |
718e3744 | 1411 | } |
3d515fd9 | 1412 | |
718e3744 | 1413 | /* "router bgp" commands. */ |
1ca2fd11 IR |
1414 | DEFUN_NOSH (router_bgp, |
1415 | router_bgp_cmd, | |
1416 | "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1417 | ROUTER_STR | |
1418 | BGP_STR | |
1419 | AS_STR | |
1420 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1421 | { |
d62a17ae | 1422 | int idx_asn = 2; |
1423 | int idx_view_vrf = 3; | |
1424 | int idx_vrf = 4; | |
1ca2fd11 IR |
1425 | int is_new_bgp = 0; |
1426 | int ret; | |
d62a17ae | 1427 | as_t as; |
1428 | struct bgp *bgp; | |
1429 | const char *name = NULL; | |
1430 | enum bgp_instance_type inst_type; | |
1431 | ||
1432 | // "router bgp" without an ASN | |
1433 | if (argc == 2) { | |
1434 | // Pending: Make VRF option available for ASN less config | |
1abef40f | 1435 | bgp = bgp_get_default(); |
d62a17ae | 1436 | |
1abef40f | 1437 | if (bgp == NULL) { |
d62a17ae | 1438 | vty_out(vty, "%% No BGP process is configured\n"); |
1439 | return CMD_WARNING_CONFIG_FAILED; | |
1440 | } | |
1441 | ||
1442 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1443 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1444 | return CMD_WARNING_CONFIG_FAILED; |
1445 | } | |
1446 | } | |
1447 | ||
1448 | // "router bgp X" | |
1449 | else { | |
ff8a8a7a | 1450 | as = strtoul(argv[idx_asn]->arg, NULL, 10); |
1ca2fd11 | 1451 | |
cc413e2a DA |
1452 | if (as == BGP_PRIVATE_AS_MAX || as == BGP_AS4_MAX) |
1453 | vty_out(vty, "Reserved AS used (%u|%u); AS is %u\n", | |
1454 | BGP_PRIVATE_AS_MAX, BGP_AS4_MAX, as); | |
1455 | ||
d62a17ae | 1456 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; |
1457 | if (argc > 3) { | |
1458 | name = argv[idx_vrf]->arg; | |
1459 | ||
9a8bdf1c PG |
1460 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1461 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1462 | name = NULL; | |
1463 | else | |
1464 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
1ca2fd11 | 1465 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) |
d62a17ae | 1466 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
d62a17ae | 1467 | } |
1468 | ||
1ca2fd11 IR |
1469 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
1470 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
3bd70bf8 | 1471 | |
1ca2fd11 IR |
1472 | ret = bgp_get_vty(&bgp, &as, name, inst_type); |
1473 | switch (ret) { | |
1474 | case BGP_ERR_AS_MISMATCH: | |
1475 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
1476 | return CMD_WARNING_CONFIG_FAILED; | |
1477 | case BGP_ERR_INSTANCE_MISMATCH: | |
1478 | vty_out(vty, | |
1479 | "BGP instance name and AS number mismatch\n"); | |
1480 | vty_out(vty, | |
1481 | "BGP instance is already running; AS is %u\n", | |
1482 | as); | |
1483 | return CMD_WARNING_CONFIG_FAILED; | |
ff8a8a7a | 1484 | } |
1ca2fd11 IR |
1485 | |
1486 | /* | |
1487 | * If we just instantiated the default instance, complete | |
1488 | * any pending VRF-VPN leaking that was configured via | |
1489 | * earlier "router bgp X vrf FOO" blocks. | |
1490 | */ | |
1491 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
1492 | vpn_leak_postchange_all(); | |
1493 | ||
1494 | if (inst_type == BGP_INSTANCE_TYPE_VRF) | |
1495 | bgp_vpn_leak_export(bgp); | |
1496 | /* Pending: handle when user tries to change a view to vrf n vv. | |
1497 | */ | |
d62a17ae | 1498 | } |
1499 | ||
1ca2fd11 IR |
1500 | /* unset the auto created flag as the user config is now present */ |
1501 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
1502 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); | |
1503 | ||
1504 | return CMD_SUCCESS; | |
718e3744 | 1505 | } |
1506 | ||
718e3744 | 1507 | /* "no router bgp" commands. */ |
1ca2fd11 IR |
1508 | DEFUN (no_router_bgp, |
1509 | no_router_bgp_cmd, | |
1510 | "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1511 | NO_STR | |
1512 | ROUTER_STR | |
1513 | BGP_STR | |
1514 | AS_STR | |
1515 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1516 | { |
4fd9919e | 1517 | int idx_asn = 3; |
d62a17ae | 1518 | int idx_vrf = 5; |
1ca2fd11 | 1519 | as_t as; |
4fd9919e | 1520 | struct bgp *bgp; |
d62a17ae | 1521 | const char *name = NULL; |
718e3744 | 1522 | |
d62a17ae | 1523 | // "no router bgp" without an ASN |
1524 | if (argc == 3) { | |
1525 | // Pending: Make VRF option available for ASN less config | |
8382083a | 1526 | bgp = bgp_get_default(); |
718e3744 | 1527 | |
8382083a | 1528 | if (bgp == NULL) { |
d62a17ae | 1529 | vty_out(vty, "%% No BGP process is configured\n"); |
1530 | return CMD_WARNING_CONFIG_FAILED; | |
1531 | } | |
7fb21a9f | 1532 | |
d62a17ae | 1533 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1534 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1535 | return CMD_WARNING_CONFIG_FAILED; |
1536 | } | |
4fd9919e | 1537 | |
4fd9919e | 1538 | if (bgp->l3vni) { |
be125e6f | 1539 | vty_out(vty, "%% Please unconfigure l3vni %u\n", |
4fd9919e IR |
1540 | bgp->l3vni); |
1541 | return CMD_WARNING_CONFIG_FAILED; | |
1542 | } | |
d62a17ae | 1543 | } else { |
4fd9919e IR |
1544 | as = strtoul(argv[idx_asn]->arg, NULL, 10); |
1545 | ||
1ca42c8d | 1546 | if (argc > 4) { |
d62a17ae | 1547 | name = argv[idx_vrf]->arg; |
1ca42c8d IR |
1548 | if (strmatch(argv[idx_vrf - 1]->text, "vrf") |
1549 | && strmatch(name, VRF_DEFAULT_NAME)) | |
1550 | name = NULL; | |
1551 | } | |
7fb21a9f | 1552 | |
4fd9919e IR |
1553 | /* Lookup bgp structure. */ |
1554 | bgp = bgp_lookup(as, name); | |
1555 | if (!bgp) { | |
1556 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1557 | return CMD_WARNING_CONFIG_FAILED; | |
1558 | } | |
1559 | ||
1560 | if (bgp->l3vni) { | |
1561 | vty_out(vty, "%% Please unconfigure l3vni %u\n", | |
1562 | bgp->l3vni); | |
1563 | return CMD_WARNING_CONFIG_FAILED; | |
1564 | } | |
1565 | ||
1566 | /* Cannot delete default instance if vrf instances exist */ | |
1567 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1568 | struct listnode *node; | |
1569 | struct bgp *tmp_bgp; | |
1570 | ||
1571 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1572 | if (tmp_bgp->inst_type != BGP_INSTANCE_TYPE_VRF) | |
1573 | continue; | |
1574 | if (CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1575 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) || | |
1576 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1577 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) || | |
1578 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1579 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) || | |
1580 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1581 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) || | |
1582 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1583 | BGP_CONFIG_VRF_TO_VRF_EXPORT) || | |
1584 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1585 | BGP_CONFIG_VRF_TO_VRF_EXPORT) || | |
1586 | (bgp == bgp_get_evpn() && | |
1587 | (CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1588 | BGP_L2VPN_EVPN_ADV_IPV4_UNICAST) || | |
1589 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1590 | BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP) || | |
1591 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1592 | BGP_L2VPN_EVPN_ADV_IPV6_UNICAST) || | |
1593 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1594 | BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP))) || | |
f33bf7c0 | 1595 | (hashcount(tmp_bgp->vnihash))) { |
4fd9919e IR |
1596 | vty_out(vty, |
1597 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1598 | return CMD_WARNING_CONFIG_FAILED; | |
1599 | } | |
1600 | } | |
1601 | } | |
d62a17ae | 1602 | } |
718e3744 | 1603 | |
1ca2fd11 | 1604 | bgp_delete(bgp); |
718e3744 | 1605 | |
1ca2fd11 | 1606 | return CMD_SUCCESS; |
718e3744 | 1607 | } |
1608 | ||
425bd64b PS |
1609 | /* bgp session-dscp */ |
1610 | ||
1611 | DEFPY (bgp_session_dscp, | |
1612 | bgp_session_dscp_cmd, | |
1613 | "bgp session-dscp (0-63)$dscp", | |
1614 | BGP_STR | |
1615 | "Override default (C6) bgp TCP session DSCP value\n" | |
1616 | "Manually configured dscp parameter\n") | |
1617 | { | |
1618 | bm->tcp_dscp = dscp << 2; | |
1619 | ||
1620 | return CMD_SUCCESS; | |
1621 | } | |
1622 | ||
1623 | DEFPY (no_bgp_session_dscp, | |
1624 | no_bgp_session_dscp_cmd, | |
1625 | "no bgp session-dscp [(0-63)]", | |
1626 | NO_STR | |
1627 | BGP_STR | |
1628 | "Override default (C6) bgp TCP session DSCP value\n" | |
1629 | "Manually configured dscp parameter\n") | |
1630 | { | |
1631 | bm->tcp_dscp = IPTOS_PREC_INTERNETCONTROL; | |
1632 | ||
1633 | return CMD_SUCCESS; | |
1634 | } | |
718e3744 | 1635 | |
ff8a8a7a CS |
1636 | /* BGP router-id. */ |
1637 | ||
1ca2fd11 IR |
1638 | DEFPY (bgp_router_id, |
1639 | bgp_router_id_cmd, | |
1640 | "bgp router-id A.B.C.D", | |
1641 | BGP_STR | |
1642 | "Override configured router identifier\n" | |
1643 | "Manually configured router identifier\n") | |
718e3744 | 1644 | { |
1ca2fd11 IR |
1645 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1646 | bgp_router_id_static_set(bgp, router_id); | |
1647 | return CMD_SUCCESS; | |
ff8a8a7a | 1648 | } |
718e3744 | 1649 | |
1ca2fd11 IR |
1650 | DEFPY (no_bgp_router_id, |
1651 | no_bgp_router_id_cmd, | |
1652 | "no bgp router-id [A.B.C.D]", | |
1653 | NO_STR | |
1654 | BGP_STR | |
1655 | "Override configured router identifier\n" | |
1656 | "Manually configured router identifier\n") | |
ff8a8a7a | 1657 | { |
1ca2fd11 | 1658 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1659 | |
1ca2fd11 IR |
1660 | if (router_id_str) { |
1661 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1662 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1663 | return CMD_WARNING_CONFIG_FAILED; | |
1664 | } | |
1665 | } | |
718e3744 | 1666 | |
1ca2fd11 IR |
1667 | router_id.s_addr = 0; |
1668 | bgp_router_id_static_set(bgp, router_id); | |
1669 | ||
1670 | return CMD_SUCCESS; | |
ff8a8a7a | 1671 | } |
6b0655a2 | 1672 | |
ed0e57e3 | 1673 | DEFPY(bgp_community_alias, bgp_community_alias_cmd, |
b4ad2fae | 1674 | "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name", |
ed0e57e3 DA |
1675 | NO_STR BGP_STR |
1676 | "Add community specific parameters\n" | |
1677 | "Create an alias for a community\n" | |
1678 | "Community (AA:BB or AA:BB:CC)\n" | |
1679 | "Alias name\n") | |
1680 | { | |
8cfa1e78 | 1681 | struct community_alias ca = {}; |
ed0e57e3 DA |
1682 | struct community_alias *lookup_community; |
1683 | struct community_alias *lookup_alias; | |
d13d137a DA |
1684 | struct community *comm; |
1685 | struct lcommunity *lcomm; | |
1686 | uint8_t invalid = 0; | |
ed0e57e3 | 1687 | |
d13d137a DA |
1688 | comm = community_str2com(community); |
1689 | if (!comm) | |
1690 | invalid++; | |
1691 | community_free(&comm); | |
1692 | ||
1693 | lcomm = lcommunity_str2com(community); | |
1694 | if (!lcomm) | |
1695 | invalid++; | |
1696 | lcommunity_free(&lcomm); | |
1697 | ||
1698 | if (invalid > 1) { | |
ed0e57e3 DA |
1699 | vty_out(vty, "Invalid community format\n"); |
1700 | return CMD_WARNING; | |
1701 | } | |
1702 | ||
8cfa1e78 DA |
1703 | strlcpy(ca.community, community, sizeof(ca.community)); |
1704 | strlcpy(ca.alias, alias_name, sizeof(ca.alias)); | |
ed0e57e3 | 1705 | |
8cfa1e78 DA |
1706 | lookup_community = bgp_ca_community_lookup(&ca); |
1707 | lookup_alias = bgp_ca_alias_lookup(&ca); | |
ed0e57e3 DA |
1708 | |
1709 | if (no) { | |
8cfa1e78 DA |
1710 | bgp_ca_alias_delete(&ca); |
1711 | bgp_ca_community_delete(&ca); | |
ed0e57e3 DA |
1712 | } else { |
1713 | if (lookup_alias) { | |
1714 | /* Lookup if community hash table has an item | |
1715 | * with the same alias name. | |
1716 | */ | |
8cfa1e78 DA |
1717 | strlcpy(ca.community, lookup_alias->community, |
1718 | sizeof(ca.community)); | |
1719 | if (bgp_ca_community_lookup(&ca)) { | |
ed0e57e3 DA |
1720 | vty_out(vty, |
1721 | "community (%s) already has this alias (%s)\n", | |
1722 | lookup_alias->community, | |
1723 | lookup_alias->alias); | |
1724 | return CMD_WARNING; | |
1725 | } | |
8cfa1e78 | 1726 | bgp_ca_alias_delete(&ca); |
ed0e57e3 DA |
1727 | } |
1728 | ||
8cfa1e78 DA |
1729 | if (lookup_community) { |
1730 | /* Lookup if alias hash table has an item | |
1731 | * with the same community. | |
1732 | */ | |
1733 | strlcpy(ca.alias, lookup_community->alias, | |
1734 | sizeof(ca.alias)); | |
1735 | if (bgp_ca_alias_lookup(&ca)) { | |
1736 | vty_out(vty, | |
1737 | "alias (%s) already has this community (%s)\n", | |
1738 | lookup_community->alias, | |
1739 | lookup_community->community); | |
1740 | return CMD_WARNING; | |
1741 | } | |
1742 | bgp_ca_community_delete(&ca); | |
1743 | } | |
ed0e57e3 | 1744 | |
8cfa1e78 DA |
1745 | bgp_ca_alias_insert(&ca); |
1746 | bgp_ca_community_insert(&ca); | |
ed0e57e3 DA |
1747 | } |
1748 | ||
1749 | return CMD_SUCCESS; | |
1750 | } | |
1751 | ||
9acb67cb DS |
1752 | DEFPY (bgp_global_suppress_fib_pending, |
1753 | bgp_global_suppress_fib_pending_cmd, | |
1754 | "[no] bgp suppress-fib-pending", | |
1755 | NO_STR | |
1756 | BGP_STR | |
1757 | "Advertise only routes that are programmed in kernel to peers globally\n") | |
1758 | { | |
1759 | bm_wait_for_fib_set(!no); | |
1760 | ||
1761 | return CMD_SUCCESS; | |
1762 | } | |
1763 | ||
c208c586 S |
1764 | DEFPY (bgp_suppress_fib_pending, |
1765 | bgp_suppress_fib_pending_cmd, | |
1766 | "[no] bgp suppress-fib-pending", | |
1767 | NO_STR | |
1768 | BGP_STR | |
1769 | "Advertise only routes that are programmed in kernel to peers\n") | |
1770 | { | |
1771 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1772 | ||
1773 | bgp_suppress_fib_pending_set(bgp, !no); | |
1774 | return CMD_SUCCESS; | |
1775 | } | |
1776 | ||
1777 | ||
718e3744 | 1778 | /* BGP Cluster ID. */ |
1ca2fd11 IR |
1779 | DEFUN (bgp_cluster_id, |
1780 | bgp_cluster_id_cmd, | |
1781 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", | |
1782 | BGP_STR | |
1783 | "Configure Route-Reflector Cluster-id\n" | |
1784 | "Route-Reflector Cluster-id in IP address format\n" | |
1785 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1786 | { |
1ca2fd11 | 1787 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1788 | int idx_ipv4 = 2; |
1ca2fd11 IR |
1789 | int ret; |
1790 | struct in_addr cluster; | |
1791 | ||
1792 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); | |
1793 | if (!ret) { | |
1794 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1795 | return CMD_WARNING_CONFIG_FAILED; | |
1796 | } | |
718e3744 | 1797 | |
1ca2fd11 IR |
1798 | bgp_cluster_id_set(bgp, &cluster); |
1799 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1800 | |
1ca2fd11 | 1801 | return CMD_SUCCESS; |
718e3744 | 1802 | } |
1803 | ||
1ca2fd11 IR |
1804 | DEFUN (no_bgp_cluster_id, |
1805 | no_bgp_cluster_id_cmd, | |
1806 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", | |
1807 | NO_STR | |
1808 | BGP_STR | |
1809 | "Configure Route-Reflector Cluster-id\n" | |
1810 | "Route-Reflector Cluster-id in IP address format\n" | |
1811 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1812 | { |
1ca2fd11 IR |
1813 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1814 | bgp_cluster_id_unset(bgp); | |
1815 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1816 | |
1ca2fd11 | 1817 | return CMD_SUCCESS; |
718e3744 | 1818 | } |
1819 | ||
c163f297 DS |
1820 | DEFPY (bgp_norib, |
1821 | bgp_norib_cmd, | |
1822 | "bgp no-rib", | |
1823 | BGP_STR | |
1824 | "Disable BGP route installation to RIB (Zebra)\n") | |
1825 | { | |
1826 | if (bgp_option_check(BGP_OPT_NO_FIB)) { | |
1827 | vty_out(vty, | |
1828 | "%% No-RIB option is already set, nothing to do here.\n"); | |
1829 | return CMD_SUCCESS; | |
1830 | } | |
1831 | ||
1832 | bgp_option_norib_set_runtime(); | |
1833 | ||
1834 | return CMD_SUCCESS; | |
1835 | } | |
1836 | ||
1837 | DEFPY (no_bgp_norib, | |
1838 | no_bgp_norib_cmd, | |
1839 | "no bgp no-rib", | |
1840 | NO_STR | |
1841 | BGP_STR | |
1842 | "Disable BGP route installation to RIB (Zebra)\n") | |
1843 | { | |
1844 | if (!bgp_option_check(BGP_OPT_NO_FIB)) { | |
1845 | vty_out(vty, | |
1846 | "%% No-RIB option is not set, nothing to do here.\n"); | |
1847 | return CMD_SUCCESS; | |
1848 | } | |
1849 | ||
1850 | bgp_option_norib_unset_runtime(); | |
1851 | ||
1852 | return CMD_SUCCESS; | |
1853 | } | |
1854 | ||
e46723a5 DS |
1855 | DEFPY (no_bgp_send_extra_data, |
1856 | no_bgp_send_extra_data_cmd, | |
1857 | "[no] bgp send-extra-data zebra", | |
1858 | NO_STR | |
1859 | BGP_STR | |
1860 | "Extra data to Zebra for display/use\n" | |
1861 | "To zebra\n") | |
1862 | { | |
ec0acb80 DA |
1863 | if (no) |
1864 | UNSET_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA); | |
1865 | else | |
1866 | SET_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA); | |
e46723a5 DS |
1867 | |
1868 | return CMD_SUCCESS; | |
1869 | } | |
1870 | ||
1ca2fd11 IR |
1871 | DEFUN (bgp_confederation_identifier, |
1872 | bgp_confederation_identifier_cmd, | |
1873 | "bgp confederation identifier (1-4294967295)", | |
e9273987 | 1874 | BGP_STR |
1ca2fd11 IR |
1875 | "AS confederation parameters\n" |
1876 | "AS number\n" | |
1877 | "Set routing domain confederation AS\n") | |
718e3744 | 1878 | { |
1ca2fd11 | 1879 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1880 | int idx_number = 3; |
1ca2fd11 | 1881 | as_t as; |
718e3744 | 1882 | |
1ca2fd11 | 1883 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1884 | |
1ca2fd11 | 1885 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1886 | |
1ca2fd11 | 1887 | return CMD_SUCCESS; |
718e3744 | 1888 | } |
1889 | ||
1ca2fd11 IR |
1890 | DEFUN (no_bgp_confederation_identifier, |
1891 | no_bgp_confederation_identifier_cmd, | |
1892 | "no bgp confederation identifier [(1-4294967295)]", | |
1893 | NO_STR | |
e9273987 | 1894 | BGP_STR |
1ca2fd11 IR |
1895 | "AS confederation parameters\n" |
1896 | "AS number\n" | |
1897 | "Set routing domain confederation AS\n") | |
ff8a8a7a | 1898 | { |
1ca2fd11 IR |
1899 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1900 | bgp_confederation_id_unset(bgp); | |
1901 | ||
1902 | return CMD_SUCCESS; | |
ff8a8a7a CS |
1903 | } |
1904 | ||
1ca2fd11 IR |
1905 | DEFUN (bgp_confederation_peers, |
1906 | bgp_confederation_peers_cmd, | |
1907 | "bgp confederation peers (1-4294967295)...", | |
e9273987 | 1908 | BGP_STR |
1ca2fd11 IR |
1909 | "AS confederation parameters\n" |
1910 | "Peer ASs in BGP confederation\n" | |
1911 | AS_STR) | |
718e3744 | 1912 | { |
1ca2fd11 | 1913 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1914 | int idx_asn = 3; |
1ca2fd11 | 1915 | as_t as; |
d62a17ae | 1916 | int i; |
718e3744 | 1917 | |
1ca2fd11 IR |
1918 | for (i = idx_asn; i < argc; i++) { |
1919 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1920 | |
1ca2fd11 IR |
1921 | if (bgp->as == as) { |
1922 | vty_out(vty, | |
1923 | "%% Local member-AS not allowed in confed peer list\n"); | |
1924 | continue; | |
1925 | } | |
1926 | ||
1927 | bgp_confederation_peers_add(bgp, as); | |
1928 | } | |
1929 | return CMD_SUCCESS; | |
718e3744 | 1930 | } |
1931 | ||
1ca2fd11 IR |
1932 | DEFUN (no_bgp_confederation_peers, |
1933 | no_bgp_confederation_peers_cmd, | |
1934 | "no bgp confederation peers (1-4294967295)...", | |
1935 | NO_STR | |
e9273987 | 1936 | BGP_STR |
1ca2fd11 IR |
1937 | "AS confederation parameters\n" |
1938 | "Peer ASs in BGP confederation\n" | |
1939 | AS_STR) | |
718e3744 | 1940 | { |
1ca2fd11 | 1941 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1942 | int idx_asn = 4; |
1ca2fd11 | 1943 | as_t as; |
d62a17ae | 1944 | int i; |
718e3744 | 1945 | |
1ca2fd11 IR |
1946 | for (i = idx_asn; i < argc; i++) { |
1947 | as = strtoul(argv[i]->arg, NULL, 10); | |
ff8a8a7a | 1948 | |
1ca2fd11 IR |
1949 | bgp_confederation_peers_remove(bgp, as); |
1950 | } | |
1951 | return CMD_SUCCESS; | |
718e3744 | 1952 | } |
6b0655a2 | 1953 | |
5e242b0d DS |
1954 | /** |
1955 | * Central routine for maximum-paths configuration. | |
1956 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1957 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1958 | */ | |
585f1adc IR |
1959 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
1960 | const char *mpaths, uint16_t options, | |
1961 | int set) | |
d62a17ae | 1962 | { |
585f1adc IR |
1963 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1964 | uint16_t maxpaths = 0; | |
d62a17ae | 1965 | int ret; |
585f1adc IR |
1966 | afi_t afi; |
1967 | safi_t safi; | |
1968 | ||
1969 | afi = bgp_node_afi(vty); | |
1970 | safi = bgp_node_safi(vty); | |
d62a17ae | 1971 | |
1972 | if (set) { | |
585f1adc | 1973 | maxpaths = strtol(mpaths, NULL, 10); |
d62a17ae | 1974 | if (maxpaths > multipath_num) { |
585f1adc | 1975 | vty_out(vty, |
d62a17ae | 1976 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", |
1977 | maxpaths, multipath_num); | |
1978 | return CMD_WARNING_CONFIG_FAILED; | |
1979 | } | |
1980 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1981 | options); | |
1982 | } else | |
1983 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1984 | ||
1985 | if (ret < 0) { | |
585f1adc | 1986 | vty_out(vty, |
d62a17ae | 1987 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", |
1988 | (set == 1) ? "" : "un", | |
1989 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1990 | maxpaths, afi, safi); | |
1991 | return CMD_WARNING_CONFIG_FAILED; | |
1992 | } | |
1993 | ||
1994 | bgp_recalculate_all_bestpaths(bgp); | |
1995 | ||
1996 | return CMD_SUCCESS; | |
165b5fff JB |
1997 | } |
1998 | ||
1ca2fd11 IR |
1999 | DEFUN (bgp_maxmed_admin, |
2000 | bgp_maxmed_admin_cmd, | |
2001 | "bgp max-med administrative ", | |
2002 | BGP_STR | |
2003 | "Advertise routes with max-med\n" | |
2004 | "Administratively applied, for an indefinite period\n") | |
abc920f8 | 2005 | { |
1ca2fd11 | 2006 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 2007 | |
1ca2fd11 IR |
2008 | bgp->v_maxmed_admin = 1; |
2009 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
ff8a8a7a | 2010 | |
1ca2fd11 | 2011 | bgp_maxmed_update(bgp); |
abc920f8 | 2012 | |
1ca2fd11 | 2013 | return CMD_SUCCESS; |
ff8a8a7a CS |
2014 | } |
2015 | ||
1ca2fd11 IR |
2016 | DEFUN (bgp_maxmed_admin_medv, |
2017 | bgp_maxmed_admin_medv_cmd, | |
2018 | "bgp max-med administrative (0-4294967295)", | |
2019 | BGP_STR | |
2020 | "Advertise routes with max-med\n" | |
2021 | "Administratively applied, for an indefinite period\n" | |
2022 | "Max MED value to be used\n") | |
abc920f8 | 2023 | { |
1ca2fd11 | 2024 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 2025 | int idx_number = 3; |
abc920f8 | 2026 | |
1ca2fd11 IR |
2027 | bgp->v_maxmed_admin = 1; |
2028 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 2029 | |
1ca2fd11 | 2030 | bgp_maxmed_update(bgp); |
abc920f8 | 2031 | |
1ca2fd11 | 2032 | return CMD_SUCCESS; |
abc920f8 DS |
2033 | } |
2034 | ||
1ca2fd11 IR |
2035 | DEFUN (no_bgp_maxmed_admin, |
2036 | no_bgp_maxmed_admin_cmd, | |
2037 | "no bgp max-med administrative [(0-4294967295)]", | |
2038 | NO_STR | |
2039 | BGP_STR | |
2040 | "Advertise routes with max-med\n" | |
2041 | "Administratively applied, for an indefinite period\n" | |
2042 | "Max MED value to be used\n") | |
abc920f8 | 2043 | { |
1ca2fd11 IR |
2044 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2045 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
2046 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
2047 | bgp_maxmed_update(bgp); | |
ff8a8a7a | 2048 | |
1ca2fd11 | 2049 | return CMD_SUCCESS; |
abc920f8 DS |
2050 | } |
2051 | ||
1ca2fd11 IR |
2052 | DEFUN (bgp_maxmed_onstartup, |
2053 | bgp_maxmed_onstartup_cmd, | |
2054 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", | |
2055 | BGP_STR | |
2056 | "Advertise routes with max-med\n" | |
2057 | "Effective on a startup\n" | |
2058 | "Time (seconds) period for max-med\n" | |
2059 | "Max MED value to be used\n") | |
abc920f8 | 2060 | { |
1ca2fd11 | 2061 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 2062 | int idx = 0; |
4668a151 | 2063 | |
9b01d289 DA |
2064 | if (argv_find(argv, argc, "(5-86400)", &idx)) |
2065 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
d62a17ae | 2066 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
1ca2fd11 | 2067 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); |
d62a17ae | 2068 | else |
1ca2fd11 | 2069 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; |
abc920f8 | 2070 | |
1ca2fd11 IR |
2071 | bgp_maxmed_update(bgp); |
2072 | ||
2073 | return CMD_SUCCESS; | |
abc920f8 DS |
2074 | } |
2075 | ||
1ca2fd11 IR |
2076 | DEFUN (no_bgp_maxmed_onstartup, |
2077 | no_bgp_maxmed_onstartup_cmd, | |
2078 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", | |
2079 | NO_STR | |
2080 | BGP_STR | |
2081 | "Advertise routes with max-med\n" | |
2082 | "Effective on a startup\n" | |
2083 | "Time (seconds) period for max-med\n" | |
2084 | "Max MED value to be used\n") | |
abc920f8 | 2085 | { |
1ca2fd11 IR |
2086 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2087 | ||
2088 | /* Cancel max-med onstartup if its on */ | |
2089 | if (bgp->t_maxmed_onstartup) { | |
c3aaa89a | 2090 | THREAD_OFF(bgp->t_maxmed_onstartup); |
1ca2fd11 IR |
2091 | bgp->maxmed_onstartup_over = 1; |
2092 | } | |
abc920f8 | 2093 | |
1ca2fd11 IR |
2094 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
2095 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 2096 | |
1ca2fd11 IR |
2097 | bgp_maxmed_update(bgp); |
2098 | ||
2099 | return CMD_SUCCESS; | |
abc920f8 DS |
2100 | } |
2101 | ||
d70583f7 D |
2102 | static int bgp_global_update_delay_config_vty(struct vty *vty, |
2103 | uint16_t update_delay, | |
2104 | uint16_t establish_wait) | |
2105 | { | |
2106 | struct listnode *node, *nnode; | |
2107 | struct bgp *bgp; | |
2108 | bool vrf_cfg = false; | |
2109 | ||
2110 | /* | |
2111 | * See if update-delay is set per-vrf and warn user to delete it | |
2112 | * Note that we only need to check this if this is the first time | |
2113 | * setting the global config. | |
2114 | */ | |
2115 | if (bm->v_update_delay == BGP_UPDATE_DELAY_DEF) { | |
2116 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2117 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { | |
2118 | vty_out(vty, | |
2119 | "%% update-delay configuration found in vrf %s\n", | |
2120 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT | |
2121 | ? VRF_DEFAULT_NAME | |
2122 | : bgp->name); | |
2123 | vrf_cfg = true; | |
2124 | } | |
2125 | } | |
2126 | } | |
2127 | ||
2128 | if (vrf_cfg) { | |
2129 | vty_out(vty, | |
2130 | "%%Failed: global update-delay config not permitted\n"); | |
2131 | return CMD_WARNING; | |
2132 | } | |
2133 | ||
2134 | if (!establish_wait) { /* update-delay <delay> */ | |
2135 | bm->v_update_delay = update_delay; | |
2136 | bm->v_establish_wait = bm->v_update_delay; | |
2137 | } else { | |
2138 | /* update-delay <delay> <establish-wait> */ | |
2139 | if (update_delay < establish_wait) { | |
2140 | vty_out(vty, | |
2141 | "%%Failed: update-delay less than the establish-wait!\n"); | |
2142 | return CMD_WARNING_CONFIG_FAILED; | |
2143 | } | |
2144 | ||
2145 | bm->v_update_delay = update_delay; | |
2146 | bm->v_establish_wait = establish_wait; | |
2147 | } | |
2148 | ||
2149 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2150 | bgp->v_update_delay = bm->v_update_delay; | |
2151 | bgp->v_establish_wait = bm->v_establish_wait; | |
2152 | } | |
2153 | ||
2154 | return CMD_SUCCESS; | |
2155 | } | |
2156 | ||
2157 | static int bgp_global_update_delay_deconfig_vty(struct vty *vty) | |
2158 | { | |
2159 | struct listnode *node, *nnode; | |
2160 | struct bgp *bgp; | |
2161 | ||
2162 | bm->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
2163 | bm->v_establish_wait = bm->v_update_delay; | |
2164 | ||
2165 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2166 | bgp->v_update_delay = bm->v_update_delay; | |
2167 | bgp->v_establish_wait = bm->v_establish_wait; | |
2168 | } | |
2169 | ||
2170 | return CMD_SUCCESS; | |
2171 | } | |
2172 | ||
2173 | static int bgp_update_delay_config_vty(struct vty *vty, uint16_t update_delay, | |
2174 | uint16_t establish_wait) | |
f188f2c4 | 2175 | { |
d62a17ae | 2176 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 2177 | |
d70583f7 D |
2178 | /* if configured globally, per-instance config is not allowed */ |
2179 | if (bm->v_update_delay) { | |
2180 | vty_out(vty, | |
2181 | "%%Failed: per-vrf update-delay config not permitted with global update-delay\n"); | |
2182 | return CMD_WARNING_CONFIG_FAILED; | |
2183 | } | |
2184 | ||
f188f2c4 | 2185 | |
d70583f7 | 2186 | if (!establish_wait) /* update-delay <delay> */ |
d62a17ae | 2187 | { |
2188 | bgp->v_update_delay = update_delay; | |
2189 | bgp->v_establish_wait = bgp->v_update_delay; | |
2190 | return CMD_SUCCESS; | |
2191 | } | |
f188f2c4 | 2192 | |
d62a17ae | 2193 | /* update-delay <delay> <establish-wait> */ |
d62a17ae | 2194 | if (update_delay < establish_wait) { |
2195 | vty_out(vty, | |
2196 | "%%Failed: update-delay less than the establish-wait!\n"); | |
2197 | return CMD_WARNING_CONFIG_FAILED; | |
2198 | } | |
f188f2c4 | 2199 | |
d62a17ae | 2200 | bgp->v_update_delay = update_delay; |
2201 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 2202 | |
d62a17ae | 2203 | return CMD_SUCCESS; |
f188f2c4 DS |
2204 | } |
2205 | ||
d62a17ae | 2206 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 2207 | { |
d62a17ae | 2208 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 2209 | |
d70583f7 D |
2210 | /* If configured globally, cannot remove from one bgp instance */ |
2211 | if (bm->v_update_delay) { | |
2212 | vty_out(vty, | |
2213 | "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n"); | |
2214 | return CMD_WARNING_CONFIG_FAILED; | |
2215 | } | |
d62a17ae | 2216 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
2217 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 2218 | |
d62a17ae | 2219 | return CMD_SUCCESS; |
f188f2c4 DS |
2220 | } |
2221 | ||
2b791107 | 2222 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 2223 | { |
d70583f7 D |
2224 | /* If configured globally, no need to display per-instance value */ |
2225 | if (bgp->v_update_delay != bm->v_update_delay) { | |
d62a17ae | 2226 | vty_out(vty, " update-delay %d", bgp->v_update_delay); |
2227 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
2228 | vty_out(vty, " %d", bgp->v_establish_wait); | |
2229 | vty_out(vty, "\n"); | |
2230 | } | |
f188f2c4 DS |
2231 | } |
2232 | ||
d70583f7 D |
2233 | /* Global update-delay configuration */ |
2234 | DEFPY (bgp_global_update_delay, | |
2235 | bgp_global_update_delay_cmd, | |
2236 | "bgp update-delay (0-3600)$delay [(1-3600)$wait]", | |
2237 | BGP_STR | |
2238 | "Force initial delay for best-path and updates for all bgp instances\n" | |
2239 | "Max delay in seconds\n" | |
2240 | "Establish wait in seconds\n") | |
2241 | { | |
2242 | return bgp_global_update_delay_config_vty(vty, delay, wait); | |
2243 | } | |
f188f2c4 | 2244 | |
d70583f7 D |
2245 | /* Global update-delay deconfiguration */ |
2246 | DEFPY (no_bgp_global_update_delay, | |
2247 | no_bgp_global_update_delay_cmd, | |
2248 | "no bgp update-delay [(0-3600) [(1-3600)]]", | |
2249 | NO_STR | |
2250 | BGP_STR | |
f188f2c4 | 2251 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2252 | "Max delay in seconds\n" |
2253 | "Establish wait in seconds\n") | |
f188f2c4 | 2254 | { |
d70583f7 | 2255 | return bgp_global_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
2256 | } |
2257 | ||
d70583f7 D |
2258 | /* Update-delay configuration */ |
2259 | ||
2260 | DEFPY (bgp_update_delay, | |
2261 | bgp_update_delay_cmd, | |
2262 | "update-delay (0-3600)$delay [(1-3600)$wait]", | |
f188f2c4 | 2263 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2264 | "Max delay in seconds\n" |
2265 | "Establish wait in seconds\n") | |
f188f2c4 | 2266 | { |
d70583f7 | 2267 | return bgp_update_delay_config_vty(vty, delay, wait); |
f188f2c4 DS |
2268 | } |
2269 | ||
2270 | /* Update-delay deconfiguration */ | |
d70583f7 | 2271 | DEFPY (no_bgp_update_delay, |
f188f2c4 | 2272 | no_bgp_update_delay_cmd, |
838758ac DW |
2273 | "no update-delay [(0-3600) [(1-3600)]]", |
2274 | NO_STR | |
f188f2c4 | 2275 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2276 | "Max delay in seconds\n" |
2277 | "Establish wait in seconds\n") | |
f188f2c4 | 2278 | { |
d62a17ae | 2279 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
2280 | } |
2281 | ||
5e242b0d | 2282 | |
1ca2fd11 IR |
2283 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
2284 | bool set) | |
cb1faec9 | 2285 | { |
1ca2fd11 IR |
2286 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2287 | ||
8fa7732f QY |
2288 | quanta = set ? quanta : BGP_WRITE_PACKET_MAX; |
2289 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed); | |
555e09d4 QY |
2290 | |
2291 | return CMD_SUCCESS; | |
2292 | } | |
2293 | ||
1ca2fd11 IR |
2294 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
2295 | bool set) | |
555e09d4 | 2296 | { |
1ca2fd11 IR |
2297 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2298 | ||
8fa7732f QY |
2299 | quanta = set ? quanta : BGP_READ_PACKET_MAX; |
2300 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed); | |
cb1faec9 | 2301 | |
d62a17ae | 2302 | return CMD_SUCCESS; |
cb1faec9 DS |
2303 | } |
2304 | ||
2b791107 | 2305 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 2306 | { |
555e09d4 QY |
2307 | uint32_t quanta = |
2308 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
2309 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 2310 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
2311 | } |
2312 | ||
555e09d4 QY |
2313 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
2314 | { | |
2315 | uint32_t quanta = | |
2316 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
2317 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 2318 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 2319 | } |
cb1faec9 | 2320 | |
8fa7732f QY |
2321 | /* Packet quanta configuration |
2322 | * | |
2323 | * XXX: The value set here controls the size of a stack buffer in the IO | |
2324 | * thread. When changing these limits be careful to prevent stack overflow. | |
2325 | * | |
2326 | * Furthermore, the maximums used here should correspond to | |
2327 | * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX. | |
2328 | */ | |
1ca2fd11 IR |
2329 | DEFPY (bgp_wpkt_quanta, |
2330 | bgp_wpkt_quanta_cmd, | |
2331 | "[no] write-quanta (1-64)$quanta", | |
2332 | NO_STR | |
2333 | "How many packets to write to peer socket per run\n" | |
2334 | "Number of packets\n") | |
2335 | { | |
2336 | return bgp_wpkt_quanta_config_vty(vty, quanta, !no); | |
2337 | } | |
cb1faec9 | 2338 | |
1ca2fd11 IR |
2339 | DEFPY (bgp_rpkt_quanta, |
2340 | bgp_rpkt_quanta_cmd, | |
2341 | "[no] read-quanta (1-10)$quanta", | |
2342 | NO_STR | |
2343 | "How many packets to read from peer socket per I/O cycle\n" | |
2344 | "Number of packets\n") | |
2345 | { | |
2346 | return bgp_rpkt_quanta_config_vty(vty, quanta, !no); | |
555e09d4 QY |
2347 | } |
2348 | ||
2b791107 | 2349 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 2350 | { |
37a333fe | 2351 | if (!bgp->heuristic_coalesce) |
d62a17ae | 2352 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
2353 | } |
2354 | ||
d1adb448 PG |
2355 | /* BGP TCP keepalive */ |
2356 | static void bgp_config_tcp_keepalive(struct vty *vty, struct bgp *bgp) | |
2357 | { | |
2358 | if (bgp->tcp_keepalive_idle) { | |
2359 | vty_out(vty, " bgp tcp-keepalive %u %u %u\n", | |
2360 | bgp->tcp_keepalive_idle, bgp->tcp_keepalive_intvl, | |
2361 | bgp->tcp_keepalive_probes); | |
2362 | } | |
2363 | } | |
4668a151 | 2364 | |
1ca2fd11 IR |
2365 | DEFUN (bgp_coalesce_time, |
2366 | bgp_coalesce_time_cmd, | |
2367 | "coalesce-time (0-4294967295)", | |
2368 | "Subgroup coalesce timer\n" | |
2369 | "Subgroup coalesce timer value (in ms)\n") | |
ff8a8a7a | 2370 | { |
1ca2fd11 | 2371 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 2372 | |
1ca2fd11 | 2373 | int idx = 0; |
9b01d289 | 2374 | |
1ca2fd11 | 2375 | bgp->heuristic_coalesce = false; |
9b01d289 DA |
2376 | |
2377 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
2378 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); | |
2379 | ||
1ca2fd11 | 2380 | return CMD_SUCCESS; |
3f9c7369 DS |
2381 | } |
2382 | ||
1ca2fd11 IR |
2383 | DEFUN (no_bgp_coalesce_time, |
2384 | no_bgp_coalesce_time_cmd, | |
2385 | "no coalesce-time (0-4294967295)", | |
2386 | NO_STR | |
2387 | "Subgroup coalesce timer\n" | |
2388 | "Subgroup coalesce timer value (in ms)\n") | |
3f9c7369 | 2389 | { |
1ca2fd11 | 2390 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 2391 | |
1ca2fd11 IR |
2392 | bgp->heuristic_coalesce = true; |
2393 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; | |
2394 | return CMD_SUCCESS; | |
3f9c7369 DS |
2395 | } |
2396 | ||
5e242b0d | 2397 | /* Maximum-paths configuration */ |
585f1adc IR |
2398 | DEFUN (bgp_maxpaths, |
2399 | bgp_maxpaths_cmd, | |
2400 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2401 | "Forward packets over multiple paths\n" | |
2402 | "Number of paths\n") | |
5e242b0d | 2403 | { |
d62a17ae | 2404 | int idx_number = 1; |
585f1adc IR |
2405 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, |
2406 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
2407 | } |
2408 | ||
d62a17ae | 2409 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
2410 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2411 | "Forward packets over multiple paths\n" | |
2412 | "Number of paths\n") | |
596c17ba | 2413 | |
585f1adc IR |
2414 | DEFUN (bgp_maxpaths_ibgp, |
2415 | bgp_maxpaths_ibgp_cmd, | |
2416 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2417 | "Forward packets over multiple paths\n" | |
2418 | "iBGP-multipath\n" | |
2419 | "Number of paths\n") | |
165b5fff | 2420 | { |
d62a17ae | 2421 | int idx_number = 2; |
585f1adc IR |
2422 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, |
2423 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 2424 | } |
165b5fff | 2425 | |
d62a17ae | 2426 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
2427 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2428 | "Forward packets over multiple paths\n" | |
2429 | "iBGP-multipath\n" | |
2430 | "Number of paths\n") | |
596c17ba | 2431 | |
585f1adc IR |
2432 | DEFUN (bgp_maxpaths_ibgp_cluster, |
2433 | bgp_maxpaths_ibgp_cluster_cmd, | |
2434 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", | |
2435 | "Forward packets over multiple paths\n" | |
2436 | "iBGP-multipath\n" | |
2437 | "Number of paths\n" | |
2438 | "Match the cluster length\n") | |
5e242b0d | 2439 | { |
d62a17ae | 2440 | int idx_number = 2; |
aa53c036 DS |
2441 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, |
2442 | argv[idx_number]->arg, true, 1); | |
165b5fff JB |
2443 | } |
2444 | ||
d62a17ae | 2445 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
2446 | "maximum-paths ibgp " CMD_RANGE_STR( | |
2447 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
2448 | "Forward packets over multiple paths\n" | |
2449 | "iBGP-multipath\n" | |
2450 | "Number of paths\n" | |
2451 | "Match the cluster length\n") | |
596c17ba | 2452 | |
585f1adc IR |
2453 | DEFUN (no_bgp_maxpaths, |
2454 | no_bgp_maxpaths_cmd, | |
2455 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", | |
2456 | NO_STR | |
2457 | "Forward packets over multiple paths\n" | |
2458 | "Number of paths\n") | |
165b5fff | 2459 | { |
585f1adc | 2460 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
2461 | } |
2462 | ||
d62a17ae | 2463 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 2464 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 2465 | "Forward packets over multiple paths\n" |
2466 | "Number of paths\n") | |
596c17ba | 2467 | |
585f1adc IR |
2468 | DEFUN (no_bgp_maxpaths_ibgp, |
2469 | no_bgp_maxpaths_ibgp_cmd, | |
2470 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2471 | NO_STR | |
2472 | "Forward packets over multiple paths\n" | |
2473 | "iBGP-multipath\n" | |
2474 | "Number of paths\n" | |
2475 | "Match the cluster length\n") | |
165b5fff | 2476 | { |
585f1adc | 2477 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
2478 | } |
2479 | ||
d62a17ae | 2480 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
2481 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
2482 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2483 | NO_STR | |
2484 | "Forward packets over multiple paths\n" | |
2485 | "iBGP-multipath\n" | |
2486 | "Number of paths\n" | |
2487 | "Match the cluster length\n") | |
596c17ba | 2488 | |
dd65f45e DL |
2489 | static void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, |
2490 | afi_t afi, safi_t safi) | |
165b5fff | 2491 | { |
00908b7a | 2492 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != multipath_num) { |
d62a17ae | 2493 | vty_out(vty, " maximum-paths %d\n", |
2494 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
2495 | } | |
165b5fff | 2496 | |
00908b7a | 2497 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != multipath_num) { |
d62a17ae | 2498 | vty_out(vty, " maximum-paths ibgp %d", |
2499 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
aa53c036 | 2500 | if (bgp->maxpaths[afi][safi].same_clusterlen) |
d62a17ae | 2501 | vty_out(vty, " equal-cluster-length"); |
2502 | vty_out(vty, "\n"); | |
2503 | } | |
165b5fff | 2504 | } |
6b0655a2 | 2505 | |
718e3744 | 2506 | /* BGP timers. */ |
2507 | ||
1ca2fd11 IR |
2508 | DEFUN (bgp_timers, |
2509 | bgp_timers_cmd, | |
2510 | "timers bgp (0-65535) (0-65535)", | |
2511 | "Adjust routing timers\n" | |
2512 | "BGP timers\n" | |
2513 | "Keepalive interval\n" | |
2514 | "Holdtime\n") | |
718e3744 | 2515 | { |
1ca2fd11 | 2516 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 2517 | int idx_number = 2; |
2518 | int idx_number_2 = 3; | |
1ca2fd11 IR |
2519 | unsigned long keepalive = 0; |
2520 | unsigned long holdtime = 0; | |
718e3744 | 2521 | |
1ca2fd11 IR |
2522 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
2523 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 2524 | |
1ca2fd11 IR |
2525 | /* Holdtime value check. */ |
2526 | if (holdtime < 3 && holdtime != 0) { | |
2527 | vty_out(vty, | |
2528 | "%% hold time value must be either 0 or greater than 3\n"); | |
2529 | return CMD_WARNING_CONFIG_FAILED; | |
2530 | } | |
718e3744 | 2531 | |
1ca2fd11 IR |
2532 | bgp_timers_set(bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY, |
2533 | BGP_DEFAULT_DELAYOPEN); | |
718e3744 | 2534 | |
1ca2fd11 | 2535 | return CMD_SUCCESS; |
718e3744 | 2536 | } |
2537 | ||
1ca2fd11 IR |
2538 | DEFUN (no_bgp_timers, |
2539 | no_bgp_timers_cmd, | |
2540 | "no timers bgp [(0-65535) (0-65535)]", | |
2541 | NO_STR | |
2542 | "Adjust routing timers\n" | |
2543 | "BGP timers\n" | |
2544 | "Keepalive interval\n" | |
2545 | "Holdtime\n") | |
718e3744 | 2546 | { |
1ca2fd11 IR |
2547 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2548 | bgp_timers_set(bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
2549 | DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN); | |
ff8a8a7a | 2550 | |
1ca2fd11 | 2551 | return CMD_SUCCESS; |
718e3744 | 2552 | } |
2553 | ||
b042667a TI |
2554 | /* BGP minimum holdtime. */ |
2555 | ||
2556 | DEFUN(bgp_minimum_holdtime, bgp_minimum_holdtime_cmd, | |
2557 | "bgp minimum-holdtime (1-65535)", | |
2558 | "BGP specific commands\n" | |
2559 | "BGP minimum holdtime\n" | |
2560 | "Seconds\n") | |
2561 | { | |
2562 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2563 | int idx_number = 2; | |
2564 | unsigned long min_holdtime; | |
2565 | ||
2566 | min_holdtime = strtoul(argv[idx_number]->arg, NULL, 10); | |
2567 | ||
2568 | bgp->default_min_holdtime = min_holdtime; | |
2569 | ||
2570 | return CMD_SUCCESS; | |
2571 | } | |
2572 | ||
2573 | DEFUN(no_bgp_minimum_holdtime, no_bgp_minimum_holdtime_cmd, | |
2574 | "no bgp minimum-holdtime [(1-65535)]", | |
2575 | NO_STR | |
2576 | "BGP specific commands\n" | |
2577 | "BGP minimum holdtime\n" | |
2578 | "Seconds\n") | |
2579 | { | |
2580 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2581 | ||
2582 | bgp->default_min_holdtime = 0; | |
2583 | ||
2584 | return CMD_SUCCESS; | |
2585 | } | |
ff8a8a7a | 2586 | |
d1adb448 PG |
2587 | DEFPY(bgp_tcp_keepalive, bgp_tcp_keepalive_cmd, |
2588 | "bgp tcp-keepalive (1-65535)$idle (1-65535)$intvl (1-30)$probes", | |
2589 | BGP_STR | |
2590 | "TCP keepalive parameters\n" | |
2591 | "TCP keepalive idle time (seconds)\n" | |
2592 | "TCP keepalive interval (seconds)\n" | |
2593 | "TCP keepalive maximum probes\n") | |
2594 | { | |
2595 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2596 | ||
2597 | bgp_tcp_keepalive_set(bgp, (uint16_t)idle, (uint16_t)intvl, | |
2598 | (uint16_t)probes); | |
2599 | ||
2600 | return CMD_SUCCESS; | |
2601 | } | |
2602 | ||
2603 | DEFPY(no_bgp_tcp_keepalive, no_bgp_tcp_keepalive_cmd, | |
2604 | "no bgp tcp-keepalive [(1-65535) (1-65535) (1-30)]", | |
2605 | NO_STR | |
2606 | BGP_STR | |
2607 | "TCP keepalive parameters\n" | |
2608 | "TCP keepalive idle time (seconds)\n" | |
2609 | "TCP keepalive interval (seconds)\n" | |
2610 | "TCP keepalive maximum probes\n") | |
2611 | { | |
2612 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2613 | ||
2614 | bgp_tcp_keepalive_unset(bgp); | |
2615 | ||
2616 | return CMD_SUCCESS; | |
2617 | } | |
2618 | ||
1ca2fd11 IR |
2619 | DEFUN (bgp_client_to_client_reflection, |
2620 | bgp_client_to_client_reflection_cmd, | |
2621 | "bgp client-to-client reflection", | |
e9273987 | 2622 | BGP_STR |
1ca2fd11 IR |
2623 | "Configure client to client route reflection\n" |
2624 | "reflection of routes allowed\n") | |
718e3744 | 2625 | { |
1ca2fd11 IR |
2626 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2627 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
2628 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 2629 | |
1ca2fd11 | 2630 | return CMD_SUCCESS; |
718e3744 | 2631 | } |
2632 | ||
1ca2fd11 IR |
2633 | DEFUN (no_bgp_client_to_client_reflection, |
2634 | no_bgp_client_to_client_reflection_cmd, | |
2635 | "no bgp client-to-client reflection", | |
2636 | NO_STR | |
e9273987 | 2637 | BGP_STR |
1ca2fd11 IR |
2638 | "Configure client to client route reflection\n" |
2639 | "reflection of routes allowed\n") | |
718e3744 | 2640 | { |
1ca2fd11 IR |
2641 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2642 | SET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
2643 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 2644 | |
1ca2fd11 | 2645 | return CMD_SUCCESS; |
718e3744 | 2646 | } |
2647 | ||
2648 | /* "bgp always-compare-med" configuration. */ | |
1ca2fd11 IR |
2649 | DEFUN (bgp_always_compare_med, |
2650 | bgp_always_compare_med_cmd, | |
2651 | "bgp always-compare-med", | |
e9273987 | 2652 | BGP_STR |
1ca2fd11 | 2653 | "Allow comparing MED from different neighbors\n") |
718e3744 | 2654 | { |
1ca2fd11 IR |
2655 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2656 | SET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); | |
2657 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2658 | |
1ca2fd11 | 2659 | return CMD_SUCCESS; |
718e3744 | 2660 | } |
2661 | ||
1ca2fd11 IR |
2662 | DEFUN (no_bgp_always_compare_med, |
2663 | no_bgp_always_compare_med_cmd, | |
2664 | "no bgp always-compare-med", | |
2665 | NO_STR | |
e9273987 | 2666 | BGP_STR |
1ca2fd11 | 2667 | "Allow comparing MED from different neighbors\n") |
718e3744 | 2668 | { |
1ca2fd11 IR |
2669 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2670 | UNSET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); | |
2671 | bgp_recalculate_all_bestpaths(bgp); | |
6b0655a2 | 2672 | |
1ca2fd11 | 2673 | return CMD_SUCCESS; |
2adac256 DA |
2674 | } |
2675 | ||
2adac256 | 2676 | |
1ca2fd11 IR |
2677 | DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd, |
2678 | "bgp ebgp-requires-policy", | |
e9273987 | 2679 | BGP_STR |
1ca2fd11 | 2680 | "Require in and out policy for eBGP peers (RFC8212)\n") |
2adac256 | 2681 | { |
1ca2fd11 IR |
2682 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2683 | SET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2684 | return CMD_SUCCESS; | |
2adac256 DA |
2685 | } |
2686 | ||
1ca2fd11 IR |
2687 | DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd, |
2688 | "no bgp ebgp-requires-policy", | |
2689 | NO_STR | |
e9273987 | 2690 | BGP_STR |
1ca2fd11 | 2691 | "Require in and out policy for eBGP peers (RFC8212)\n") |
ff8a8a7a | 2692 | { |
1ca2fd11 IR |
2693 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2694 | UNSET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2695 | return CMD_SUCCESS; | |
ff8a8a7a | 2696 | } |
9dac9fc8 | 2697 | |
1ca2fd11 IR |
2698 | DEFUN(bgp_suppress_duplicates, bgp_suppress_duplicates_cmd, |
2699 | "bgp suppress-duplicates", | |
e9273987 | 2700 | BGP_STR |
1ca2fd11 | 2701 | "Suppress duplicate updates if the route actually not changed\n") |
9dac9fc8 | 2702 | { |
1ca2fd11 IR |
2703 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2704 | SET_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
2705 | return CMD_SUCCESS; | |
9dac9fc8 DA |
2706 | } |
2707 | ||
1ca2fd11 IR |
2708 | DEFUN(no_bgp_suppress_duplicates, no_bgp_suppress_duplicates_cmd, |
2709 | "no bgp suppress-duplicates", | |
2710 | NO_STR | |
e9273987 | 2711 | BGP_STR |
1ca2fd11 | 2712 | "Suppress duplicate updates if the route actually not changed\n") |
9dac9fc8 | 2713 | { |
1ca2fd11 IR |
2714 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2715 | UNSET_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
2716 | return CMD_SUCCESS; | |
9dac9fc8 DA |
2717 | } |
2718 | ||
fb29348a DA |
2719 | DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd, |
2720 | "bgp reject-as-sets", | |
e9273987 | 2721 | BGP_STR |
fb29348a DA |
2722 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") |
2723 | { | |
2724 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2725 | struct listnode *node, *nnode; | |
2726 | struct peer *peer; | |
2727 | ||
7f972cd8 | 2728 | bgp->reject_as_sets = true; |
fb29348a DA |
2729 | |
2730 | /* Reset existing BGP sessions to reject routes | |
2731 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2732 | */ | |
2733 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2734 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2735 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2736 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2737 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2738 | } | |
2739 | } | |
2740 | ||
2741 | return CMD_SUCCESS; | |
2742 | } | |
2743 | ||
2744 | DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd, | |
2745 | "no bgp reject-as-sets", | |
2746 | NO_STR | |
e9273987 | 2747 | BGP_STR |
fb29348a DA |
2748 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") |
2749 | { | |
2750 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2751 | struct listnode *node, *nnode; | |
2752 | struct peer *peer; | |
2753 | ||
7f972cd8 | 2754 | bgp->reject_as_sets = false; |
fb29348a DA |
2755 | |
2756 | /* Reset existing BGP sessions to reject routes | |
2757 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2758 | */ | |
2759 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2760 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2761 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2762 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2763 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2764 | } | |
2765 | } | |
2766 | ||
2767 | return CMD_SUCCESS; | |
2768 | } | |
9dac9fc8 | 2769 | |
718e3744 | 2770 | /* "bgp deterministic-med" configuration. */ |
1ca2fd11 | 2771 | DEFUN (bgp_deterministic_med, |
718e3744 | 2772 | bgp_deterministic_med_cmd, |
2773 | "bgp deterministic-med", | |
e9273987 | 2774 | BGP_STR |
718e3744 | 2775 | "Pick the best-MED path among paths advertised from the neighboring AS\n") |
2776 | { | |
1ca2fd11 IR |
2777 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2778 | ||
2779 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { | |
2780 | SET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); | |
2781 | bgp_recalculate_all_bestpaths(bgp); | |
2782 | } | |
7aafcaca | 2783 | |
1ca2fd11 | 2784 | return CMD_SUCCESS; |
718e3744 | 2785 | } |
2786 | ||
1ca2fd11 | 2787 | DEFUN (no_bgp_deterministic_med, |
718e3744 | 2788 | no_bgp_deterministic_med_cmd, |
2789 | "no bgp deterministic-med", | |
2790 | NO_STR | |
e9273987 | 2791 | BGP_STR |
718e3744 | 2792 | "Pick the best-MED path among paths advertised from the neighboring AS\n") |
2793 | { | |
1ca2fd11 IR |
2794 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2795 | int bestpath_per_as_used; | |
2796 | afi_t afi; | |
2797 | safi_t safi; | |
2798 | struct peer *peer; | |
2799 | struct listnode *node, *nnode; | |
2800 | ||
2801 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { | |
2802 | bestpath_per_as_used = 0; | |
2803 | ||
2804 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2805 | FOREACH_AFI_SAFI (afi, safi) | |
2806 | if (bgp_addpath_dmed_required( | |
2807 | peer->addpath_type[afi][safi])) { | |
2808 | bestpath_per_as_used = 1; | |
2809 | break; | |
2810 | } | |
2811 | ||
2812 | if (bestpath_per_as_used) | |
2813 | break; | |
2814 | } | |
2815 | ||
2816 | if (bestpath_per_as_used) { | |
2817 | vty_out(vty, | |
2818 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
2819 | return CMD_WARNING_CONFIG_FAILED; | |
2820 | } else { | |
2821 | UNSET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); | |
2822 | bgp_recalculate_all_bestpaths(bgp); | |
2823 | } | |
2824 | } | |
d62a17ae | 2825 | |
1ca2fd11 | 2826 | return CMD_SUCCESS; |
718e3744 | 2827 | } |
538621f2 | 2828 | |
055679e9 | 2829 | /* "bgp graceful-restart mode" configuration. */ |
538621f2 | 2830 | DEFUN (bgp_graceful_restart, |
2ba1fe69 | 2831 | bgp_graceful_restart_cmd, |
2832 | "bgp graceful-restart", | |
e9273987 | 2833 | BGP_STR |
2ba1fe69 | 2834 | GR_CMD |
055679e9 | 2835 | ) |
538621f2 | 2836 | { |
055679e9 | 2837 | int ret = BGP_GR_FAILURE; |
2838 | ||
2839 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2840 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START "); |
dc95985f | 2841 | |
d62a17ae | 2842 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2843 | |
2844 | ret = bgp_gr_update_all(bgp, GLOBAL_GR_CMD); | |
2845 | ||
36235319 QY |
2846 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2847 | ret); | |
5cce3f05 | 2848 | |
055679e9 | 2849 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2850 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END "); |
dc95985f | 2851 | vty_out(vty, |
2852 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2853 | return bgp_vty_return(vty, ret); |
538621f2 | 2854 | } |
2855 | ||
2856 | DEFUN (no_bgp_graceful_restart, | |
2ba1fe69 | 2857 | no_bgp_graceful_restart_cmd, |
2858 | "no bgp graceful-restart", | |
2859 | NO_STR | |
e9273987 | 2860 | BGP_STR |
2ba1fe69 | 2861 | NO_GR_CMD |
055679e9 | 2862 | ) |
538621f2 | 2863 | { |
d62a17ae | 2864 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2865 | |
2866 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2867 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START "); |
055679e9 | 2868 | |
2869 | int ret = BGP_GR_FAILURE; | |
2870 | ||
2871 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_GR_CMD); | |
2872 | ||
36235319 QY |
2873 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2874 | ret); | |
5cce3f05 | 2875 | |
055679e9 | 2876 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2877 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END "); |
dc95985f | 2878 | vty_out(vty, |
2879 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2880 | |
2881 | return bgp_vty_return(vty, ret); | |
538621f2 | 2882 | } |
2883 | ||
93406d87 | 2884 | DEFUN (bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2885 | bgp_graceful_restart_stalepath_time_cmd, |
2886 | "bgp graceful-restart stalepath-time (1-4095)", | |
e9273987 | 2887 | BGP_STR |
2ba1fe69 | 2888 | "Graceful restart capability parameters\n" |
2889 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2890 | "Delay value (seconds)\n") | |
93406d87 | 2891 | { |
d62a17ae | 2892 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2893 | int idx_number = 3; | |
d7c0a89a | 2894 | uint32_t stalepath; |
93406d87 | 2895 | |
d62a17ae | 2896 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
2897 | bgp->stalepath_time = stalepath; | |
2898 | return CMD_SUCCESS; | |
93406d87 | 2899 | } |
2900 | ||
eb6f1b41 | 2901 | DEFUN (bgp_graceful_restart_restart_time, |
2ba1fe69 | 2902 | bgp_graceful_restart_restart_time_cmd, |
dcbebfd3 | 2903 | "bgp graceful-restart restart-time (0-4095)", |
e9273987 | 2904 | BGP_STR |
2ba1fe69 | 2905 | "Graceful restart capability parameters\n" |
2906 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2907 | "Delay value (seconds)\n") | |
eb6f1b41 | 2908 | { |
d62a17ae | 2909 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2910 | int idx_number = 3; | |
d7c0a89a | 2911 | uint32_t restart; |
eb6f1b41 | 2912 | |
d62a17ae | 2913 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2914 | bgp->restart_time = restart; | |
2915 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2916 | } |
2917 | ||
cfd47646 | 2918 | DEFUN (bgp_graceful_restart_select_defer_time, |
2919 | bgp_graceful_restart_select_defer_time_cmd, | |
2920 | "bgp graceful-restart select-defer-time (0-3600)", | |
e9273987 | 2921 | BGP_STR |
cfd47646 | 2922 | "Graceful restart capability parameters\n" |
2923 | "Set the time to defer the BGP route selection after restart\n" | |
2924 | "Delay value (seconds, 0 - disable)\n") | |
2925 | { | |
2926 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2927 | int idx_number = 3; | |
2928 | uint32_t defer_time; | |
2929 | ||
2930 | defer_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2931 | bgp->select_defer_time = defer_time; | |
2932 | if (defer_time == 0) | |
892fedb6 | 2933 | SET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2934 | else |
892fedb6 | 2935 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2936 | |
2937 | return CMD_SUCCESS; | |
2938 | } | |
2939 | ||
93406d87 | 2940 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2941 | no_bgp_graceful_restart_stalepath_time_cmd, |
2942 | "no bgp graceful-restart stalepath-time [(1-4095)]", | |
2943 | NO_STR | |
e9273987 | 2944 | BGP_STR |
2ba1fe69 | 2945 | "Graceful restart capability parameters\n" |
2946 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2947 | "Delay value (seconds)\n") | |
93406d87 | 2948 | { |
d62a17ae | 2949 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2950 | |
d62a17ae | 2951 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2952 | return CMD_SUCCESS; | |
93406d87 | 2953 | } |
2954 | ||
eb6f1b41 | 2955 | DEFUN (no_bgp_graceful_restart_restart_time, |
2ba1fe69 | 2956 | no_bgp_graceful_restart_restart_time_cmd, |
dcbebfd3 | 2957 | "no bgp graceful-restart restart-time [(0-4095)]", |
2ba1fe69 | 2958 | NO_STR |
e9273987 | 2959 | BGP_STR |
2ba1fe69 | 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") | |
eb6f1b41 | 2963 | { |
d62a17ae | 2964 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2965 | |
d62a17ae | 2966 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2967 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2968 | } |
2969 | ||
cfd47646 | 2970 | DEFUN (no_bgp_graceful_restart_select_defer_time, |
2971 | no_bgp_graceful_restart_select_defer_time_cmd, | |
2972 | "no bgp graceful-restart select-defer-time [(0-3600)]", | |
2973 | NO_STR | |
e9273987 | 2974 | BGP_STR |
cfd47646 | 2975 | "Graceful restart capability parameters\n" |
2976 | "Set the time to defer the BGP route selection after restart\n" | |
2977 | "Delay value (seconds)\n") | |
2978 | { | |
2979 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2980 | ||
2981 | bgp->select_defer_time = BGP_DEFAULT_SELECT_DEFERRAL_TIME; | |
892fedb6 | 2982 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2983 | |
2984 | return CMD_SUCCESS; | |
2985 | } | |
2986 | ||
43fc21b3 | 2987 | DEFUN (bgp_graceful_restart_preserve_fw, |
2ba1fe69 | 2988 | bgp_graceful_restart_preserve_fw_cmd, |
2989 | "bgp graceful-restart preserve-fw-state", | |
e9273987 | 2990 | BGP_STR |
2ba1fe69 | 2991 | "Graceful restart capability parameters\n" |
2992 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2993 | { |
d62a17ae | 2994 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2995 | SET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2996 | return CMD_SUCCESS; |
43fc21b3 JC |
2997 | } |
2998 | ||
2999 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2ba1fe69 | 3000 | no_bgp_graceful_restart_preserve_fw_cmd, |
3001 | "no bgp graceful-restart preserve-fw-state", | |
3002 | NO_STR | |
e9273987 | 3003 | BGP_STR |
2ba1fe69 | 3004 | "Graceful restart capability parameters\n" |
3005 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 3006 | { |
d62a17ae | 3007 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3008 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 3009 | return CMD_SUCCESS; |
43fc21b3 JC |
3010 | } |
3011 | ||
f2ca5c5b DA |
3012 | DEFPY (bgp_graceful_restart_notification, |
3013 | bgp_graceful_restart_notification_cmd, | |
3014 | "[no$no] bgp graceful-restart notification", | |
3015 | NO_STR | |
3016 | BGP_STR | |
3017 | "Graceful restart capability parameters\n" | |
3018 | "Indicate Graceful Restart support for BGP NOTIFICATION messages\n") | |
3019 | { | |
3020 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3021 | ||
3022 | if (no) | |
3023 | UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION); | |
3024 | else | |
3025 | SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION); | |
3026 | ||
3027 | return CMD_SUCCESS; | |
3028 | } | |
3029 | ||
1ae314be DA |
3030 | DEFPY (bgp_administrative_reset, |
3031 | bgp_administrative_reset_cmd, | |
3032 | "[no$no] bgp hard-administrative-reset", | |
3033 | NO_STR | |
3034 | BGP_STR | |
3035 | "Send Hard Reset CEASE Notification for 'Administrative Reset'\n") | |
3036 | { | |
3037 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3038 | ||
3039 | if (no) | |
3040 | UNSET_FLAG(bgp->flags, BGP_FLAG_HARD_ADMIN_RESET); | |
3041 | else | |
3042 | SET_FLAG(bgp->flags, BGP_FLAG_HARD_ADMIN_RESET); | |
3043 | ||
3044 | return CMD_SUCCESS; | |
3045 | } | |
3046 | ||
055679e9 | 3047 | DEFUN (bgp_graceful_restart_disable, |
2ba1fe69 | 3048 | bgp_graceful_restart_disable_cmd, |
3049 | "bgp graceful-restart-disable", | |
e9273987 | 3050 | BGP_STR |
2ba1fe69 | 3051 | GR_DISABLE) |
055679e9 | 3052 | { |
3053 | int ret = BGP_GR_FAILURE; | |
3054 | ||
3055 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3056 | zlog_debug( | |
2ba1fe69 | 3057 | "[BGP_GR] bgp_graceful_restart_disable_cmd : START "); |
dc95985f | 3058 | |
055679e9 | 3059 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3060 | ||
3061 | ret = bgp_gr_update_all(bgp, GLOBAL_DISABLE_CMD); | |
3062 | ||
dc95985f | 3063 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, |
3064 | bgp->peer, ret); | |
5cce3f05 | 3065 | |
055679e9 | 3066 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3067 | zlog_debug( | |
2ba1fe69 | 3068 | "[BGP_GR] bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 3069 | vty_out(vty, |
3070 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
3071 | ||
055679e9 | 3072 | return bgp_vty_return(vty, ret); |
3073 | } | |
3074 | ||
3075 | DEFUN (no_bgp_graceful_restart_disable, | |
2ba1fe69 | 3076 | no_bgp_graceful_restart_disable_cmd, |
3077 | "no bgp graceful-restart-disable", | |
3078 | NO_STR | |
e9273987 | 3079 | BGP_STR |
2ba1fe69 | 3080 | NO_GR_DISABLE |
055679e9 | 3081 | ) |
3082 | { | |
3083 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3084 | ||
3085 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3086 | zlog_debug( | |
2ba1fe69 | 3087 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START "); |
055679e9 | 3088 | |
3089 | int ret = BGP_GR_FAILURE; | |
3090 | ||
3091 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_DISABLE_CMD); | |
3092 | ||
36235319 QY |
3093 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
3094 | ret); | |
5cce3f05 | 3095 | |
055679e9 | 3096 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3097 | zlog_debug( | |
2ba1fe69 | 3098 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 3099 | vty_out(vty, |
3100 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 3101 | |
3102 | return bgp_vty_return(vty, ret); | |
3103 | } | |
3104 | ||
3105 | DEFUN (bgp_neighbor_graceful_restart_set, | |
2ba1fe69 | 3106 | bgp_neighbor_graceful_restart_set_cmd, |
3107 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
3108 | NEIGHBOR_STR | |
3109 | NEIGHBOR_ADDR_STR2 | |
3110 | GR_NEIGHBOR_CMD | |
055679e9 | 3111 | ) |
3112 | { | |
3113 | int idx_peer = 1; | |
3114 | struct peer *peer; | |
3115 | int ret = BGP_GR_FAILURE; | |
3116 | ||
dc95985f | 3117 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3118 | ||
055679e9 | 3119 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3120 | zlog_debug( | |
2ba1fe69 | 3121 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START "); |
dc95985f | 3122 | |
055679e9 | 3123 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3124 | if (!peer) | |
3125 | return CMD_WARNING_CONFIG_FAILED; | |
3126 | ||
3127 | ret = bgp_neighbor_graceful_restart(peer, PEER_GR_CMD); | |
3128 | ||
dc95985f | 3129 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3130 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3131 | |
3132 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3133 | zlog_debug( | |
2ba1fe69 | 3134 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 3135 | vty_out(vty, |
3136 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3137 | |
3138 | return bgp_vty_return(vty, ret); | |
3139 | } | |
3140 | ||
3141 | DEFUN (no_bgp_neighbor_graceful_restart, | |
2ba1fe69 | 3142 | no_bgp_neighbor_graceful_restart_set_cmd, |
3143 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
3144 | NO_STR | |
3145 | NEIGHBOR_STR | |
3146 | NEIGHBOR_ADDR_STR2 | |
3147 | NO_GR_NEIGHBOR_CMD | |
055679e9 | 3148 | ) |
3149 | { | |
3150 | int idx_peer = 2; | |
3151 | int ret = BGP_GR_FAILURE; | |
3152 | struct peer *peer; | |
3153 | ||
dc95985f | 3154 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3155 | ||
055679e9 | 3156 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3157 | if (!peer) | |
3158 | return CMD_WARNING_CONFIG_FAILED; | |
3159 | ||
3160 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3161 | zlog_debug( | |
2ba1fe69 | 3162 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START "); |
055679e9 | 3163 | |
3164 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_GR_CMD); | |
3165 | ||
dc95985f | 3166 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3167 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3168 | |
3169 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3170 | zlog_debug( | |
2ba1fe69 | 3171 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 3172 | vty_out(vty, |
3173 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3174 | |
3175 | return bgp_vty_return(vty, ret); | |
3176 | } | |
3177 | ||
3178 | DEFUN (bgp_neighbor_graceful_restart_helper_set, | |
2ba1fe69 | 3179 | bgp_neighbor_graceful_restart_helper_set_cmd, |
3180 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
3181 | NEIGHBOR_STR | |
3182 | NEIGHBOR_ADDR_STR2 | |
3183 | GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 3184 | ) |
3185 | { | |
3186 | int idx_peer = 1; | |
3187 | struct peer *peer; | |
3188 | int ret = BGP_GR_FAILURE; | |
3189 | ||
dc95985f | 3190 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3191 | ||
055679e9 | 3192 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3193 | zlog_debug( | |
2ba1fe69 | 3194 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
dc95985f | 3195 | |
055679e9 | 3196 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3197 | ||
055679e9 | 3198 | if (!peer) |
3199 | return CMD_WARNING_CONFIG_FAILED; | |
3200 | ||
3201 | ||
3202 | ret = bgp_neighbor_graceful_restart(peer, PEER_HELPER_CMD); | |
5cce3f05 | 3203 | |
dc95985f | 3204 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3205 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
5cce3f05 | 3206 | |
055679e9 | 3207 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3208 | zlog_debug( | |
2ba1fe69 | 3209 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 3210 | vty_out(vty, |
3211 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3212 | |
3213 | return bgp_vty_return(vty, ret); | |
3214 | } | |
3215 | ||
3216 | DEFUN (no_bgp_neighbor_graceful_restart_helper, | |
2ba1fe69 | 3217 | no_bgp_neighbor_graceful_restart_helper_set_cmd, |
3218 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
3219 | NO_STR | |
3220 | NEIGHBOR_STR | |
3221 | NEIGHBOR_ADDR_STR2 | |
3222 | NO_GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 3223 | ) |
3224 | { | |
3225 | int idx_peer = 2; | |
3226 | int ret = BGP_GR_FAILURE; | |
3227 | struct peer *peer; | |
3228 | ||
dc95985f | 3229 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3230 | ||
055679e9 | 3231 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3232 | if (!peer) | |
3233 | return CMD_WARNING_CONFIG_FAILED; | |
3234 | ||
3235 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3236 | zlog_debug( | |
2ba1fe69 | 3237 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
055679e9 | 3238 | |
36235319 | 3239 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_HELPER_CMD); |
055679e9 | 3240 | |
dc95985f | 3241 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3242 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3243 | |
3244 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3245 | zlog_debug( | |
2ba1fe69 | 3246 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 3247 | vty_out(vty, |
3248 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3249 | |
3250 | return bgp_vty_return(vty, ret); | |
3251 | } | |
3252 | ||
3253 | DEFUN (bgp_neighbor_graceful_restart_disable_set, | |
2ba1fe69 | 3254 | bgp_neighbor_graceful_restart_disable_set_cmd, |
3255 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
3256 | NEIGHBOR_STR | |
3257 | NEIGHBOR_ADDR_STR2 | |
3258 | GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 3259 | ) |
3260 | { | |
3261 | int idx_peer = 1; | |
3262 | struct peer *peer; | |
3263 | int ret = BGP_GR_FAILURE; | |
3264 | ||
dc95985f | 3265 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3266 | ||
055679e9 | 3267 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3268 | zlog_debug( | |
2ba1fe69 | 3269 | "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 3270 | |
3271 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3272 | if (!peer) | |
3273 | return CMD_WARNING_CONFIG_FAILED; | |
3274 | ||
36235319 | 3275 | ret = bgp_neighbor_graceful_restart(peer, PEER_DISABLE_CMD); |
055679e9 | 3276 | |
3277 | if (peer->bgp->t_startup) | |
3278 | bgp_peer_gr_flags_update(peer); | |
3279 | ||
dc95985f | 3280 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3281 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
3282 | ||
055679e9 | 3283 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3284 | zlog_debug( | |
2ba1fe69 | 3285 | "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 3286 | vty_out(vty, |
3287 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3288 | |
3289 | return bgp_vty_return(vty, ret); | |
3290 | } | |
3291 | ||
3292 | DEFUN (no_bgp_neighbor_graceful_restart_disable, | |
2ba1fe69 | 3293 | no_bgp_neighbor_graceful_restart_disable_set_cmd, |
3294 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
3295 | NO_STR | |
3296 | NEIGHBOR_STR | |
3297 | NEIGHBOR_ADDR_STR2 | |
3298 | NO_GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 3299 | ) |
3300 | { | |
3301 | int idx_peer = 2; | |
3302 | int ret = BGP_GR_FAILURE; | |
3303 | struct peer *peer; | |
3304 | ||
dc95985f | 3305 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3306 | ||
055679e9 | 3307 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3308 | if (!peer) | |
3309 | return CMD_WARNING_CONFIG_FAILED; | |
3310 | ||
3311 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3312 | zlog_debug( | |
2ba1fe69 | 3313 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 3314 | |
3315 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_DISABLE_CMD); | |
3316 | ||
dc95985f | 3317 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3318 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3319 | |
3320 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3321 | zlog_debug( | |
2ba1fe69 | 3322 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 3323 | vty_out(vty, |
3324 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3325 | |
3326 | return bgp_vty_return(vty, ret); | |
3327 | } | |
3328 | ||
d6e3c15b | 3329 | DEFUN_HIDDEN (bgp_graceful_restart_disable_eor, |
3330 | bgp_graceful_restart_disable_eor_cmd, | |
3331 | "bgp graceful-restart disable-eor", | |
e9273987 | 3332 | BGP_STR |
d6e3c15b | 3333 | "Graceful restart configuration parameters\n" |
3334 | "Disable EOR Check\n") | |
3335 | { | |
3336 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 3337 | SET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 3338 | |
d6e3c15b | 3339 | return CMD_SUCCESS; |
3340 | } | |
3341 | ||
3342 | DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor, | |
3343 | no_bgp_graceful_restart_disable_eor_cmd, | |
3344 | "no bgp graceful-restart disable-eor", | |
3345 | NO_STR | |
e9273987 | 3346 | BGP_STR |
d6e3c15b | 3347 | "Graceful restart configuration parameters\n" |
3348 | "Disable EOR Check\n") | |
3349 | { | |
3350 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 3351 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 3352 | |
3353 | return CMD_SUCCESS; | |
3354 | } | |
3355 | ||
3356 | DEFUN (bgp_graceful_restart_rib_stale_time, | |
3357 | bgp_graceful_restart_rib_stale_time_cmd, | |
3358 | "bgp graceful-restart rib-stale-time (1-3600)", | |
e9273987 | 3359 | BGP_STR |
dc95985f | 3360 | "Graceful restart configuration parameters\n" |
3361 | "Specify the stale route removal timer in rib\n" | |
3362 | "Delay value (seconds)\n") | |
3363 | { | |
3364 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3365 | int idx_number = 3; | |
3366 | uint32_t stale_time; | |
3367 | ||
3368 | stale_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
3369 | bgp->rib_stale_time = stale_time; | |
3370 | /* Send the stale timer update message to RIB */ | |
3371 | if (bgp_zebra_stale_timer_update(bgp)) | |
3372 | return CMD_WARNING; | |
3373 | ||
3374 | return CMD_SUCCESS; | |
3375 | } | |
3376 | ||
3377 | DEFUN (no_bgp_graceful_restart_rib_stale_time, | |
3378 | no_bgp_graceful_restart_rib_stale_time_cmd, | |
3379 | "no bgp graceful-restart rib-stale-time [(1-3600)]", | |
3380 | NO_STR | |
e9273987 | 3381 | BGP_STR |
dc95985f | 3382 | "Graceful restart configuration parameters\n" |
3383 | "Specify the stale route removal timer in rib\n" | |
3384 | "Delay value (seconds)\n") | |
3385 | { | |
3386 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3387 | ||
3388 | bgp->rib_stale_time = BGP_DEFAULT_RIB_STALE_TIME; | |
3389 | /* Send the stale timer update message to RIB */ | |
3390 | if (bgp_zebra_stale_timer_update(bgp)) | |
3391 | return CMD_WARNING; | |
3392 | ||
d6e3c15b | 3393 | return CMD_SUCCESS; |
3394 | } | |
3395 | ||
8606be87 | 3396 | DEFUN(bgp_llgr_stalepath_time, bgp_llgr_stalepath_time_cmd, |
5970204c | 3397 | "bgp long-lived-graceful-restart stale-time (1-16777215)", |
7f8a9a24 | 3398 | BGP_STR |
8606be87 DA |
3399 | "Enable Long-lived Graceful Restart\n" |
3400 | "Specifies maximum time to wait before purging long-lived stale routes\n" | |
3401 | "Stale time value (seconds)\n") | |
3402 | { | |
3403 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3404 | ||
3405 | uint32_t llgr_stale_time; | |
3406 | ||
3407 | llgr_stale_time = strtoul(argv[3]->arg, NULL, 10); | |
3408 | bgp->llgr_stale_time = llgr_stale_time; | |
3409 | ||
3410 | return CMD_SUCCESS; | |
3411 | } | |
3412 | ||
3413 | DEFUN(no_bgp_llgr_stalepath_time, no_bgp_llgr_stalepath_time_cmd, | |
5970204c | 3414 | "no bgp long-lived-graceful-restart stale-time [(1-16777215)]", |
8606be87 DA |
3415 | NO_STR BGP_STR |
3416 | "Enable Long-lived Graceful Restart\n" | |
3417 | "Specifies maximum time to wait before purging long-lived stale routes\n" | |
3418 | "Stale time value (seconds)\n") | |
3419 | { | |
3420 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3421 | ||
3422 | bgp->llgr_stale_time = BGP_DEFAULT_LLGR_STALE_TIME; | |
3423 | ||
3424 | return CMD_SUCCESS; | |
3425 | } | |
3426 | ||
1ca2fd11 IR |
3427 | static inline void bgp_initiate_graceful_shut_unshut(struct vty *vty, |
3428 | struct bgp *bgp) | |
05bd726c | 3429 | { |
3430 | bgp_static_redo_import_check(bgp); | |
3431 | bgp_redistribute_redo(bgp); | |
1ca2fd11 IR |
3432 | bgp_clear_star_soft_out(vty, bgp->name); |
3433 | bgp_clear_star_soft_in(vty, bgp->name); | |
05bd726c | 3434 | } |
3435 | ||
3436 | static int bgp_global_graceful_shutdown_config_vty(struct vty *vty) | |
3437 | { | |
3438 | struct listnode *node, *nnode; | |
3439 | struct bgp *bgp; | |
3440 | bool vrf_cfg = false; | |
3441 | ||
3442 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3443 | return CMD_SUCCESS; | |
3444 | ||
3445 | /* See if graceful-shutdown is set per-vrf and warn user to delete */ | |
3446 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
3447 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
3448 | vty_out(vty, | |
3449 | "%% graceful-shutdown configuration found in vrf %s\n", | |
3450 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT ? | |
3451 | VRF_DEFAULT_NAME : bgp->name); | |
3452 | vrf_cfg = true; | |
3453 | } | |
3454 | } | |
3455 | ||
3456 | if (vrf_cfg) { | |
3457 | vty_out(vty, | |
3458 | "%%Failed: global graceful-shutdown not permitted\n"); | |
3459 | return CMD_WARNING; | |
3460 | } | |
3461 | ||
3462 | /* Set flag globally */ | |
3463 | SET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3464 | ||
3465 | /* Initiate processing for all BGP instances. */ | |
1ca2fd11 IR |
3466 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) |
3467 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
05bd726c | 3468 | |
3469 | return CMD_SUCCESS; | |
3470 | } | |
3471 | ||
3472 | static int bgp_global_graceful_shutdown_deconfig_vty(struct vty *vty) | |
3473 | { | |
3474 | struct listnode *node, *nnode; | |
3475 | struct bgp *bgp; | |
3476 | ||
3477 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3478 | return CMD_SUCCESS; | |
3479 | ||
3480 | /* Unset flag globally */ | |
3481 | UNSET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3482 | ||
3483 | /* Initiate processing for all BGP instances. */ | |
1ca2fd11 IR |
3484 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) |
3485 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
05bd726c | 3486 | |
3487 | return CMD_SUCCESS; | |
3488 | } | |
3489 | ||
7f323236 DW |
3490 | /* "bgp graceful-shutdown" configuration */ |
3491 | DEFUN (bgp_graceful_shutdown, | |
3492 | bgp_graceful_shutdown_cmd, | |
3493 | "bgp graceful-shutdown", | |
3494 | BGP_STR | |
3495 | "Graceful shutdown parameters\n") | |
3496 | { | |
05bd726c | 3497 | if (vty->node == CONFIG_NODE) |
3498 | return bgp_global_graceful_shutdown_config_vty(vty); | |
3499 | ||
1ca2fd11 | 3500 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
7f323236 | 3501 | |
1ca2fd11 IR |
3502 | /* if configured globally, per-instance config is not allowed */ |
3503 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) { | |
3504 | vty_out(vty, | |
3505 | "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n"); | |
3506 | return CMD_WARNING_CONFIG_FAILED; | |
3507 | } | |
3508 | ||
3509 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
3510 | SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
3511 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
3512 | } | |
3513 | ||
3514 | return CMD_SUCCESS; | |
7f323236 DW |
3515 | } |
3516 | ||
1ca2fd11 | 3517 | DEFUN (no_bgp_graceful_shutdown, |
7f323236 DW |
3518 | no_bgp_graceful_shutdown_cmd, |
3519 | "no bgp graceful-shutdown", | |
3520 | NO_STR | |
3521 | BGP_STR | |
3522 | "Graceful shutdown parameters\n") | |
3523 | { | |
05bd726c | 3524 | if (vty->node == CONFIG_NODE) |
3525 | return bgp_global_graceful_shutdown_deconfig_vty(vty); | |
3526 | ||
1ca2fd11 | 3527 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
05bd726c | 3528 | |
1ca2fd11 IR |
3529 | /* If configured globally, cannot remove from one bgp instance */ |
3530 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) { | |
3531 | vty_out(vty, | |
3532 | "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n"); | |
3533 | return CMD_WARNING_CONFIG_FAILED; | |
3534 | } | |
7f323236 | 3535 | |
1ca2fd11 IR |
3536 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { |
3537 | UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
3538 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
3539 | } | |
3540 | ||
3541 | return CMD_SUCCESS; | |
7f323236 DW |
3542 | } |
3543 | ||
718e3744 | 3544 | /* "bgp fast-external-failover" configuration. */ |
1ca2fd11 | 3545 | DEFUN (bgp_fast_external_failover, |
718e3744 | 3546 | bgp_fast_external_failover_cmd, |
3547 | "bgp fast-external-failover", | |
3548 | BGP_STR | |
3549 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3550 | { | |
1ca2fd11 IR |
3551 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3552 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
3553 | return CMD_SUCCESS; | |
718e3744 | 3554 | } |
3555 | ||
1ca2fd11 | 3556 | DEFUN (no_bgp_fast_external_failover, |
718e3744 | 3557 | no_bgp_fast_external_failover_cmd, |
3558 | "no bgp fast-external-failover", | |
3559 | NO_STR | |
3560 | BGP_STR | |
3561 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3562 | { | |
1ca2fd11 IR |
3563 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3564 | SET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
3565 | return CMD_SUCCESS; | |
718e3744 | 3566 | } |
6b0655a2 | 3567 | |
97a52c82 DA |
3568 | DEFPY (bgp_bestpath_aigp, |
3569 | bgp_bestpath_aigp_cmd, | |
3570 | "[no$no] bgp bestpath aigp", | |
3571 | NO_STR | |
3572 | BGP_STR | |
3573 | "Change the default bestpath selection\n" | |
3574 | "Evaluate the AIGP attribute during the best path selection process\n") | |
3575 | { | |
3576 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3577 | ||
3578 | if (no) | |
3579 | UNSET_FLAG(bgp->flags, BGP_FLAG_COMPARE_AIGP); | |
3580 | else | |
3581 | SET_FLAG(bgp->flags, BGP_FLAG_COMPARE_AIGP); | |
3582 | ||
3583 | bgp_recalculate_all_bestpaths(bgp); | |
3584 | ||
3585 | return CMD_SUCCESS; | |
3586 | } | |
3587 | ||
718e3744 | 3588 | /* "bgp bestpath compare-routerid" configuration. */ |
1ca2fd11 IR |
3589 | DEFUN (bgp_bestpath_compare_router_id, |
3590 | bgp_bestpath_compare_router_id_cmd, | |
3591 | "bgp bestpath compare-routerid", | |
e9273987 | 3592 | BGP_STR |
1ca2fd11 IR |
3593 | "Change the default bestpath selection\n" |
3594 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3595 | { |
1ca2fd11 IR |
3596 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3597 | SET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); | |
3598 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3599 | |
1ca2fd11 | 3600 | return CMD_SUCCESS; |
718e3744 | 3601 | } |
3602 | ||
1ca2fd11 IR |
3603 | DEFUN (no_bgp_bestpath_compare_router_id, |
3604 | no_bgp_bestpath_compare_router_id_cmd, | |
3605 | "no bgp bestpath compare-routerid", | |
3606 | NO_STR | |
e9273987 | 3607 | BGP_STR |
1ca2fd11 IR |
3608 | "Change the default bestpath selection\n" |
3609 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3610 | { |
1ca2fd11 IR |
3611 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3612 | UNSET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); | |
3613 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3614 | |
1ca2fd11 | 3615 | return CMD_SUCCESS; |
718e3744 | 3616 | } |
6b0655a2 | 3617 | |
718e3744 | 3618 | /* "bgp bestpath as-path ignore" configuration. */ |
1ca2fd11 IR |
3619 | DEFUN (bgp_bestpath_aspath_ignore, |
3620 | bgp_bestpath_aspath_ignore_cmd, | |
3621 | "bgp bestpath as-path ignore", | |
e9273987 | 3622 | BGP_STR |
1ca2fd11 IR |
3623 | "Change the default bestpath selection\n" |
3624 | "AS-path attribute\n" | |
3625 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3626 | { |
1ca2fd11 IR |
3627 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3628 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); | |
3629 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3630 | |
1ca2fd11 | 3631 | return CMD_SUCCESS; |
718e3744 | 3632 | } |
3633 | ||
1ca2fd11 IR |
3634 | DEFUN (no_bgp_bestpath_aspath_ignore, |
3635 | no_bgp_bestpath_aspath_ignore_cmd, | |
3636 | "no bgp bestpath as-path ignore", | |
3637 | NO_STR | |
e9273987 | 3638 | BGP_STR |
1ca2fd11 IR |
3639 | "Change the default bestpath selection\n" |
3640 | "AS-path attribute\n" | |
3641 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3642 | { |
1ca2fd11 IR |
3643 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3644 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); | |
3645 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3646 | |
1ca2fd11 | 3647 | return CMD_SUCCESS; |
718e3744 | 3648 | } |
6b0655a2 | 3649 | |
6811845b | 3650 | /* "bgp bestpath as-path confed" configuration. */ |
1ca2fd11 | 3651 | DEFUN (bgp_bestpath_aspath_confed, |
6811845b | 3652 | bgp_bestpath_aspath_confed_cmd, |
3653 | "bgp bestpath as-path confed", | |
e9273987 | 3654 | BGP_STR |
6811845b | 3655 | "Change the default bestpath selection\n" |
3656 | "AS-path attribute\n" | |
3657 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3658 | { | |
1ca2fd11 IR |
3659 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3660 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); | |
3661 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3662 | |
1ca2fd11 | 3663 | return CMD_SUCCESS; |
6811845b | 3664 | } |
3665 | ||
1ca2fd11 | 3666 | DEFUN (no_bgp_bestpath_aspath_confed, |
6811845b | 3667 | no_bgp_bestpath_aspath_confed_cmd, |
3668 | "no bgp bestpath as-path confed", | |
3669 | NO_STR | |
e9273987 | 3670 | BGP_STR |
6811845b | 3671 | "Change the default bestpath selection\n" |
3672 | "AS-path attribute\n" | |
3673 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3674 | { | |
1ca2fd11 IR |
3675 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3676 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); | |
3677 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3678 | |
1ca2fd11 | 3679 | return CMD_SUCCESS; |
6811845b | 3680 | } |
6b0655a2 | 3681 | |
2fdd455c | 3682 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
1ca2fd11 | 3683 | DEFUN (bgp_bestpath_aspath_multipath_relax, |
2fdd455c | 3684 | bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3685 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
e9273987 | 3686 | BGP_STR |
16fc1eec DS |
3687 | "Change the default bestpath selection\n" |
3688 | "AS-path attribute\n" | |
3689 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3690 | "Generate an AS_SET\n" |
16fc1eec DS |
3691 | "Do not generate an AS_SET\n") |
3692 | { | |
1ca2fd11 | 3693 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 3694 | int idx = 0; |
1ca2fd11 | 3695 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 | 3696 | |
1ca2fd11 IR |
3697 | /* no-as-set is now the default behavior so we can silently |
3698 | * ignore it */ | |
d62a17ae | 3699 | if (argv_find(argv, argc, "as-set", &idx)) |
1ca2fd11 | 3700 | SET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
d62a17ae | 3701 | else |
1ca2fd11 | 3702 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
7aafcaca | 3703 | |
1ca2fd11 IR |
3704 | bgp_recalculate_all_bestpaths(bgp); |
3705 | ||
3706 | return CMD_SUCCESS; | |
16fc1eec DS |
3707 | } |
3708 | ||
1ca2fd11 | 3709 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
219178b6 | 3710 | no_bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3711 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec | 3712 | NO_STR |
e9273987 | 3713 | BGP_STR |
16fc1eec DS |
3714 | "Change the default bestpath selection\n" |
3715 | "AS-path attribute\n" | |
3716 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3717 | "Generate an AS_SET\n" |
16fc1eec DS |
3718 | "Do not generate an AS_SET\n") |
3719 | { | |
1ca2fd11 IR |
3720 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3721 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
3722 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
3723 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3724 | |
1ca2fd11 | 3725 | return CMD_SUCCESS; |
2fdd455c | 3726 | } |
6b0655a2 | 3727 | |
ee88563a JM |
3728 | /* "bgp bestpath peer-type multipath-relax" configuration. */ |
3729 | DEFUN(bgp_bestpath_peer_type_multipath_relax, | |
3730 | bgp_bestpath_peer_type_multipath_relax_cmd, | |
3731 | "bgp bestpath peer-type multipath-relax", | |
3732 | BGP_STR | |
3733 | "Change the default bestpath selection\n" | |
3734 | "Peer type\n" | |
3735 | "Allow load sharing across routes learned from different peer types\n") | |
3736 | { | |
3737 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3738 | SET_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX); | |
3739 | bgp_recalculate_all_bestpaths(bgp); | |
3740 | ||
3741 | return CMD_SUCCESS; | |
3742 | } | |
3743 | ||
3744 | DEFUN(no_bgp_bestpath_peer_type_multipath_relax, | |
3745 | no_bgp_bestpath_peer_type_multipath_relax_cmd, | |
3746 | "no bgp bestpath peer-type multipath-relax", | |
3747 | NO_STR BGP_STR | |
3748 | "Change the default bestpath selection\n" | |
3749 | "Peer type\n" | |
3750 | "Allow load sharing across routes learned from different peer types\n") | |
3751 | { | |
3752 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3753 | UNSET_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX); | |
3754 | bgp_recalculate_all_bestpaths(bgp); | |
3755 | ||
3756 | return CMD_SUCCESS; | |
3757 | } | |
3758 | ||
848973c7 | 3759 | /* "bgp log-neighbor-changes" configuration. */ |
1ca2fd11 IR |
3760 | DEFUN (bgp_log_neighbor_changes, |
3761 | bgp_log_neighbor_changes_cmd, | |
3762 | "bgp log-neighbor-changes", | |
e9273987 | 3763 | BGP_STR |
1ca2fd11 | 3764 | "Log neighbor up/down and reset reason\n") |
848973c7 | 3765 | { |
1ca2fd11 IR |
3766 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3767 | SET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
3768 | return CMD_SUCCESS; | |
848973c7 | 3769 | } |
3770 | ||
1ca2fd11 IR |
3771 | DEFUN (no_bgp_log_neighbor_changes, |
3772 | no_bgp_log_neighbor_changes_cmd, | |
3773 | "no bgp log-neighbor-changes", | |
3774 | NO_STR | |
e9273987 | 3775 | BGP_STR |
1ca2fd11 | 3776 | "Log neighbor up/down and reset reason\n") |
848973c7 | 3777 | { |
1ca2fd11 IR |
3778 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3779 | UNSET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
3780 | return CMD_SUCCESS; | |
848973c7 | 3781 | } |
6b0655a2 | 3782 | |
718e3744 | 3783 | /* "bgp bestpath med" configuration. */ |
1ca2fd11 | 3784 | DEFUN (bgp_bestpath_med, |
718e3744 | 3785 | bgp_bestpath_med_cmd, |
2d8c1a4d | 3786 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
e9273987 | 3787 | BGP_STR |
718e3744 | 3788 | "Change the default bestpath selection\n" |
3789 | "MED attribute\n" | |
3790 | "Compare MED among confederation paths\n" | |
838758ac DW |
3791 | "Treat missing MED as the least preferred one\n" |
3792 | "Treat missing MED as the least preferred one\n" | |
3793 | "Compare MED among confederation paths\n") | |
718e3744 | 3794 | { |
1ca2fd11 | 3795 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3796 | |
1ca2fd11 | 3797 | int idx = 0; |
d62a17ae | 3798 | if (argv_find(argv, argc, "confed", &idx)) |
1ca2fd11 | 3799 | SET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 3800 | idx = 0; |
3801 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
1ca2fd11 | 3802 | SET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
e52702f2 | 3803 | |
1ca2fd11 | 3804 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 3805 | |
1ca2fd11 | 3806 | return CMD_SUCCESS; |
718e3744 | 3807 | } |
3808 | ||
1ca2fd11 | 3809 | DEFUN (no_bgp_bestpath_med, |
718e3744 | 3810 | no_bgp_bestpath_med_cmd, |
2d8c1a4d | 3811 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 3812 | NO_STR |
e9273987 | 3813 | BGP_STR |
718e3744 | 3814 | "Change the default bestpath selection\n" |
3815 | "MED attribute\n" | |
3816 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
3817 | "Treat missing MED as the least preferred one\n" |
3818 | "Treat missing MED as the least preferred one\n" | |
3819 | "Compare MED among confederation paths\n") | |
718e3744 | 3820 | { |
1ca2fd11 | 3821 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3822 | |
1ca2fd11 | 3823 | int idx = 0; |
d62a17ae | 3824 | if (argv_find(argv, argc, "confed", &idx)) |
1ca2fd11 | 3825 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 3826 | idx = 0; |
3827 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
1ca2fd11 IR |
3828 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
3829 | ||
3830 | bgp_recalculate_all_bestpaths(bgp); | |
718e3744 | 3831 | |
1ca2fd11 | 3832 | return CMD_SUCCESS; |
718e3744 | 3833 | } |
3834 | ||
f7e1c681 | 3835 | /* "bgp bestpath bandwidth" configuration. */ |
3836 | DEFPY (bgp_bestpath_bw, | |
3837 | bgp_bestpath_bw_cmd, | |
ad36d216 | 3838 | "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg", |
e9273987 | 3839 | BGP_STR |
f7e1c681 | 3840 | "Change the default bestpath selection\n" |
3841 | "Link Bandwidth attribute\n" | |
3842 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3843 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3844 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3845 | { | |
3846 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3847 | afi_t afi; | |
3848 | safi_t safi; | |
3849 | ||
ad36d216 DS |
3850 | if (!bw_cfg) { |
3851 | vty_out(vty, "%% Bandwidth configuration must be specified\n"); | |
3852 | return CMD_ERR_INCOMPLETE; | |
f7e1c681 | 3853 | } |
ad36d216 DS |
3854 | if (!strcmp(bw_cfg, "ignore")) |
3855 | bgp->lb_handling = BGP_LINK_BW_IGNORE_BW; | |
3856 | else if (!strcmp(bw_cfg, "skip-missing")) | |
3857 | bgp->lb_handling = BGP_LINK_BW_SKIP_MISSING; | |
3858 | else if (!strcmp(bw_cfg, "default-weight-for-missing")) | |
3859 | bgp->lb_handling = BGP_LINK_BW_DEFWT_4_MISSING; | |
3860 | else | |
3861 | return CMD_ERR_NO_MATCH; | |
f7e1c681 | 3862 | |
3863 | /* This config is used in route install, so redo that. */ | |
3864 | FOREACH_AFI_SAFI (afi, safi) { | |
3865 | if (!bgp_fibupd_safi(safi)) | |
3866 | continue; | |
3867 | bgp_zebra_announce_table(bgp, afi, safi); | |
3868 | } | |
3869 | ||
3870 | return CMD_SUCCESS; | |
3871 | } | |
3872 | ||
ad36d216 DS |
3873 | DEFPY (no_bgp_bestpath_bw, |
3874 | no_bgp_bestpath_bw_cmd, | |
3875 | "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]", | |
3876 | NO_STR | |
e9273987 | 3877 | BGP_STR |
ad36d216 DS |
3878 | "Change the default bestpath selection\n" |
3879 | "Link Bandwidth attribute\n" | |
3880 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3881 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3882 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3883 | { | |
3884 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3885 | afi_t afi; | |
3886 | safi_t safi; | |
3887 | ||
3888 | bgp->lb_handling = BGP_LINK_BW_ECMP; | |
3889 | ||
3890 | /* This config is used in route install, so redo that. */ | |
3891 | FOREACH_AFI_SAFI (afi, safi) { | |
3892 | if (!bgp_fibupd_safi(safi)) | |
3893 | continue; | |
3894 | bgp_zebra_announce_table(bgp, afi, safi); | |
3895 | } | |
3896 | return CMD_SUCCESS; | |
3897 | } | |
3898 | ||
b16bcbba | 3899 | DEFPY(bgp_default_afi_safi, bgp_default_afi_safi_cmd, |
38d11af5 TA |
3900 | "[no] bgp default <ipv4-unicast|" |
3901 | "ipv4-multicast|" | |
3902 | "ipv4-vpn|" | |
3903 | "ipv4-labeled-unicast|" | |
3904 | "ipv4-flowspec|" | |
3905 | "ipv6-unicast|" | |
3906 | "ipv6-multicast|" | |
3907 | "ipv6-vpn|" | |
3908 | "ipv6-labeled-unicast|" | |
3909 | "ipv6-flowspec|" | |
3910 | "l2vpn-evpn>$afi_safi", | |
b16bcbba | 3911 | NO_STR |
e9273987 | 3912 | BGP_STR |
e84c59af | 3913 | "Configure BGP defaults\n" |
b16bcbba | 3914 | "Activate ipv4-unicast for a peer by default\n" |
38d11af5 TA |
3915 | "Activate ipv4-multicast for a peer by default\n" |
3916 | "Activate ipv4-vpn for a peer by default\n" | |
3917 | "Activate ipv4-labeled-unicast for a peer by default\n" | |
3918 | "Activate ipv4-flowspec for a peer by default\n" | |
3919 | "Activate ipv6-unicast for a peer by default\n" | |
3920 | "Activate ipv6-multicast for a peer by default\n" | |
3921 | "Activate ipv6-vpn for a peer by default\n" | |
3922 | "Activate ipv6-labeled-unicast for a peer by default\n" | |
3923 | "Activate ipv6-flowspec for a peer by default\n" | |
3924 | "Activate l2vpn-evpn for a peer by default\n") | |
e84c59af DA |
3925 | { |
3926 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b16bcbba TA |
3927 | char afi_safi_str[strlen(afi_safi) + 1]; |
3928 | char *afi_safi_str_tok; | |
e84c59af | 3929 | |
b16bcbba TA |
3930 | strlcpy(afi_safi_str, afi_safi, sizeof(afi_safi_str)); |
3931 | char *afi_str = strtok_r(afi_safi_str, "-", &afi_safi_str_tok); | |
3932 | char *safi_str = strtok_r(NULL, "-", &afi_safi_str_tok); | |
3933 | afi_t afi = bgp_vty_afi_from_str(afi_str); | |
38d11af5 | 3934 | safi_t safi; |
e84c59af | 3935 | |
d880a643 DS |
3936 | /* |
3937 | * Impossible situation but making coverity happy | |
3938 | */ | |
3939 | assert(afi != AFI_MAX); | |
3940 | ||
38d11af5 TA |
3941 | if (strmatch(safi_str, "labeled")) |
3942 | safi = bgp_vty_safi_from_str("labeled-unicast"); | |
3943 | else | |
3944 | safi = bgp_vty_safi_from_str(safi_str); | |
b16bcbba | 3945 | |
f609bcd6 | 3946 | assert(safi != SAFI_MAX); |
b16bcbba TA |
3947 | if (no) |
3948 | bgp->default_af[afi][safi] = false; | |
38d11af5 TA |
3949 | else { |
3950 | if ((safi == SAFI_LABELED_UNICAST | |
3951 | && bgp->default_af[afi][SAFI_UNICAST]) | |
3952 | || (safi == SAFI_UNICAST | |
3953 | && bgp->default_af[afi][SAFI_LABELED_UNICAST])) | |
3954 | bgp_vty_return(vty, BGP_ERR_PEER_SAFI_CONFLICT); | |
3955 | else | |
3956 | bgp->default_af[afi][safi] = true; | |
3957 | } | |
718e3744 | 3958 | |
d62a17ae | 3959 | return CMD_SUCCESS; |
718e3744 | 3960 | } |
6b0655a2 | 3961 | |
04b6bdc0 | 3962 | /* Display hostname in certain command outputs */ |
1ca2fd11 | 3963 | DEFUN (bgp_default_show_hostname, |
04b6bdc0 DW |
3964 | bgp_default_show_hostname_cmd, |
3965 | "bgp default show-hostname", | |
e9273987 | 3966 | BGP_STR |
04b6bdc0 | 3967 | "Configure BGP defaults\n" |
0437e105 | 3968 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3969 | { |
1ca2fd11 IR |
3970 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3971 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); | |
3972 | return CMD_SUCCESS; | |
ff8a8a7a CS |
3973 | } |
3974 | ||
1ca2fd11 IR |
3975 | DEFUN (no_bgp_default_show_hostname, |
3976 | no_bgp_default_show_hostname_cmd, | |
3977 | "no bgp default show-hostname", | |
3978 | NO_STR | |
e9273987 | 3979 | BGP_STR |
1ca2fd11 IR |
3980 | "Configure BGP defaults\n" |
3981 | "Show hostname in certain command outputs\n") | |
ff8a8a7a | 3982 | { |
1ca2fd11 IR |
3983 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3984 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); | |
3985 | return CMD_SUCCESS; | |
04b6bdc0 DW |
3986 | } |
3987 | ||
aef999a2 | 3988 | /* Display hostname in certain command outputs */ |
1d80f243 IR |
3989 | DEFUN (bgp_default_show_nexthop_hostname, |
3990 | bgp_default_show_nexthop_hostname_cmd, | |
3991 | "bgp default show-nexthop-hostname", | |
e9273987 | 3992 | BGP_STR |
1d80f243 IR |
3993 | "Configure BGP defaults\n" |
3994 | "Show hostname for nexthop in certain command outputs\n") | |
aef999a2 | 3995 | { |
1ca2fd11 IR |
3996 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3997 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
3998 | return CMD_SUCCESS; | |
aef999a2 DA |
3999 | } |
4000 | ||
4001 | DEFUN (no_bgp_default_show_nexthop_hostname, | |
4002 | no_bgp_default_show_nexthop_hostname_cmd, | |
4003 | "no bgp default show-nexthop-hostname", | |
4004 | NO_STR | |
e9273987 | 4005 | BGP_STR |
aef999a2 DA |
4006 | "Configure BGP defaults\n" |
4007 | "Show hostname for nexthop in certain command outputs\n") | |
4008 | { | |
1ca2fd11 IR |
4009 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4010 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
4011 | return CMD_SUCCESS; | |
aef999a2 DA |
4012 | } |
4013 | ||
8233ef81 | 4014 | /* "bgp network import-check" configuration. */ |
1ca2fd11 IR |
4015 | DEFUN (bgp_network_import_check, |
4016 | bgp_network_import_check_cmd, | |
4017 | "bgp network import-check", | |
e9273987 | 4018 | BGP_STR |
1ca2fd11 IR |
4019 | "BGP network command\n" |
4020 | "Check BGP network route exists in IGP\n") | |
718e3744 | 4021 | { |
1ca2fd11 IR |
4022 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4023 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { | |
4024 | SET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
4025 | bgp_static_redo_import_check(bgp); | |
4026 | } | |
078430f6 | 4027 | |
1ca2fd11 | 4028 | return CMD_SUCCESS; |
718e3744 | 4029 | } |
4030 | ||
d62a17ae | 4031 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
4032 | "bgp network import-check exact", | |
e9273987 | 4033 | BGP_STR |
d62a17ae | 4034 | "BGP network command\n" |
4035 | "Check BGP network route exists in IGP\n" | |
4036 | "Match route precisely\n") | |
8233ef81 | 4037 | |
1ca2fd11 IR |
4038 | DEFUN (no_bgp_network_import_check, |
4039 | no_bgp_network_import_check_cmd, | |
4040 | "no bgp network import-check", | |
4041 | NO_STR | |
e9273987 | 4042 | BGP_STR |
1ca2fd11 IR |
4043 | "BGP network command\n" |
4044 | "Check BGP network route exists in IGP\n") | |
718e3744 | 4045 | { |
1ca2fd11 IR |
4046 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4047 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { | |
4048 | UNSET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
4049 | bgp_static_redo_import_check(bgp); | |
4050 | } | |
6b0655a2 | 4051 | |
1ca2fd11 | 4052 | return CMD_SUCCESS; |
ff8a8a7a | 4053 | } |
718e3744 | 4054 | |
1ca2fd11 IR |
4055 | DEFUN (bgp_default_local_preference, |
4056 | bgp_default_local_preference_cmd, | |
4057 | "bgp default local-preference (0-4294967295)", | |
e9273987 | 4058 | BGP_STR |
1ca2fd11 IR |
4059 | "Configure BGP defaults\n" |
4060 | "local preference (higher=more preferred)\n" | |
4061 | "Configure default local preference value\n") | |
ff8a8a7a | 4062 | { |
1ca2fd11 | 4063 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 4064 | int idx_number = 3; |
1ca2fd11 | 4065 | uint32_t local_pref; |
718e3744 | 4066 | |
1ca2fd11 | 4067 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 4068 | |
1ca2fd11 IR |
4069 | bgp_default_local_preference_set(bgp, local_pref); |
4070 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 4071 | |
1ca2fd11 | 4072 | return CMD_SUCCESS; |
718e3744 | 4073 | } |
4074 | ||
1ca2fd11 IR |
4075 | DEFUN (no_bgp_default_local_preference, |
4076 | no_bgp_default_local_preference_cmd, | |
4077 | "no bgp default local-preference [(0-4294967295)]", | |
4078 | NO_STR | |
e9273987 | 4079 | BGP_STR |
1ca2fd11 IR |
4080 | "Configure BGP defaults\n" |
4081 | "local preference (higher=more preferred)\n" | |
4082 | "Configure default local preference value\n") | |
ff8a8a7a | 4083 | { |
1ca2fd11 IR |
4084 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4085 | bgp_default_local_preference_unset(bgp); | |
4086 | bgp_clear_star_soft_in(vty, bgp->name); | |
4087 | ||
4088 | return CMD_SUCCESS; | |
ff8a8a7a | 4089 | } |
6b0655a2 | 4090 | |
ff8a8a7a | 4091 | |
1ca2fd11 IR |
4092 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
4093 | bgp_default_subgroup_pkt_queue_max_cmd, | |
4094 | "bgp default subgroup-pkt-queue-max (20-100)", | |
e9273987 | 4095 | BGP_STR |
1ca2fd11 IR |
4096 | "Configure BGP defaults\n" |
4097 | "subgroup-pkt-queue-max\n" | |
4098 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 4099 | { |
1ca2fd11 | 4100 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4101 | int idx_number = 3; |
1ca2fd11 | 4102 | uint32_t max_size; |
3f9c7369 | 4103 | |
1ca2fd11 | 4104 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 4105 | |
1ca2fd11 | 4106 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
ff8a8a7a | 4107 | |
1ca2fd11 | 4108 | return CMD_SUCCESS; |
8bd9d948 DS |
4109 | } |
4110 | ||
1ca2fd11 IR |
4111 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, |
4112 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
4113 | "no bgp default subgroup-pkt-queue-max [(20-100)]", | |
4114 | NO_STR | |
e9273987 | 4115 | BGP_STR |
1ca2fd11 IR |
4116 | "Configure BGP defaults\n" |
4117 | "subgroup-pkt-queue-max\n" | |
4118 | "Configure subgroup packet queue max\n") | |
ff8a8a7a | 4119 | { |
1ca2fd11 IR |
4120 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4121 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
4122 | return CMD_SUCCESS; | |
ff8a8a7a | 4123 | } |
813d4307 | 4124 | |
8bd9d948 | 4125 | |
1ca2fd11 IR |
4126 | DEFUN (bgp_rr_allow_outbound_policy, |
4127 | bgp_rr_allow_outbound_policy_cmd, | |
4128 | "bgp route-reflector allow-outbound-policy", | |
e9273987 | 4129 | BGP_STR |
1ca2fd11 IR |
4130 | "Allow modifications made by out route-map\n" |
4131 | "on ibgp neighbors\n") | |
ff8a8a7a | 4132 | { |
1ca2fd11 | 4133 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 4134 | |
1ca2fd11 IR |
4135 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
4136 | SET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
4137 | update_group_announce_rrclients(bgp); | |
4138 | bgp_clear_star_soft_out(vty, bgp->name); | |
4139 | } | |
8bd9d948 | 4140 | |
1ca2fd11 IR |
4141 | return CMD_SUCCESS; |
4142 | } | |
ff8a8a7a | 4143 | |
1ca2fd11 IR |
4144 | DEFUN (no_bgp_rr_allow_outbound_policy, |
4145 | no_bgp_rr_allow_outbound_policy_cmd, | |
4146 | "no bgp route-reflector allow-outbound-policy", | |
4147 | NO_STR | |
e9273987 | 4148 | BGP_STR |
1ca2fd11 IR |
4149 | "Allow modifications made by out route-map\n" |
4150 | "on ibgp neighbors\n") | |
8bd9d948 | 4151 | { |
1ca2fd11 | 4152 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 4153 | |
1ca2fd11 IR |
4154 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
4155 | UNSET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
4156 | update_group_announce_rrclients(bgp); | |
4157 | bgp_clear_star_soft_out(vty, bgp->name); | |
d62a17ae | 4158 | } |
8bd9d948 | 4159 | |
1ca2fd11 | 4160 | return CMD_SUCCESS; |
8bd9d948 DS |
4161 | } |
4162 | ||
1ca2fd11 IR |
4163 | DEFUN (bgp_listen_limit, |
4164 | bgp_listen_limit_cmd, | |
4165 | "bgp listen limit (1-65535)", | |
e9273987 | 4166 | BGP_STR |
1ca2fd11 IR |
4167 | "BGP Dynamic Neighbors listen commands\n" |
4168 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
4169 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 4170 | { |
1ca2fd11 | 4171 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4172 | int idx_number = 3; |
1ca2fd11 IR |
4173 | int listen_limit; |
4174 | ||
4175 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); | |
f14e6fdb | 4176 | |
1ca2fd11 | 4177 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 4178 | |
1ca2fd11 | 4179 | return CMD_SUCCESS; |
f14e6fdb DS |
4180 | } |
4181 | ||
1ca2fd11 IR |
4182 | DEFUN (no_bgp_listen_limit, |
4183 | no_bgp_listen_limit_cmd, | |
4184 | "no bgp listen limit [(1-65535)]", | |
4185 | NO_STR | |
e9273987 | 4186 | BGP_STR |
1ca2fd11 IR |
4187 | "BGP Dynamic Neighbors listen commands\n" |
4188 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
4189 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 4190 | { |
1ca2fd11 IR |
4191 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4192 | bgp_listen_limit_unset(bgp); | |
4193 | return CMD_SUCCESS; | |
f14e6fdb DS |
4194 | } |
4195 | ||
4196 | ||
20eb8864 | 4197 | /* |
4198 | * Check if this listen range is already configured. Check for exact | |
4199 | * match or overlap based on input. | |
4200 | */ | |
d62a17ae | 4201 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
4202 | struct prefix *range, int exact) | |
4203 | { | |
4204 | struct listnode *node, *nnode; | |
4205 | struct listnode *node1, *nnode1; | |
4206 | struct peer_group *group; | |
4207 | struct prefix *lr; | |
4208 | afi_t afi; | |
4209 | int match; | |
4210 | ||
4211 | afi = family2afi(range->family); | |
4212 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
4213 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
4214 | lr)) { | |
4215 | if (exact) | |
4216 | match = prefix_same(range, lr); | |
4217 | else | |
4218 | match = (prefix_match(range, lr) | |
4219 | || prefix_match(lr, range)); | |
4220 | if (match) | |
4221 | return group; | |
4222 | } | |
4223 | } | |
4224 | ||
4225 | return NULL; | |
20eb8864 | 4226 | } |
4227 | ||
f14e6fdb DS |
4228 | DEFUN (bgp_listen_range, |
4229 | bgp_listen_range_cmd, | |
d7b9898c | 4230 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
e9273987 | 4231 | BGP_STR |
d7fa34c1 QY |
4232 | "Configure BGP dynamic neighbors listen range\n" |
4233 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
4234 | NEIGHBOR_ADDR_STR |
4235 | "Member of the peer-group\n" | |
4236 | "Peer-group name\n") | |
f14e6fdb | 4237 | { |
d62a17ae | 4238 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4239 | struct prefix range; | |
4240 | struct peer_group *group, *existing_group; | |
4241 | afi_t afi; | |
4242 | int ret; | |
4243 | int idx = 0; | |
4244 | ||
4245 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
4246 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
4247 | char *prefix = argv[idx]->arg; | |
d7b9898c | 4248 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 4249 | char *peergroup = argv[idx]->arg; |
4250 | ||
4251 | /* Convert IP prefix string to struct prefix. */ | |
4252 | ret = str2prefix(prefix, &range); | |
4253 | if (!ret) { | |
4254 | vty_out(vty, "%% Malformed listen range\n"); | |
4255 | return CMD_WARNING_CONFIG_FAILED; | |
4256 | } | |
4257 | ||
4258 | afi = family2afi(range.family); | |
4259 | ||
4260 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
4261 | vty_out(vty, | |
4262 | "%% Malformed listen range (link-local address)\n"); | |
4263 | return CMD_WARNING_CONFIG_FAILED; | |
4264 | } | |
4265 | ||
4266 | apply_mask(&range); | |
4267 | ||
4268 | /* Check if same listen range is already configured. */ | |
4269 | existing_group = listen_range_exists(bgp, &range, 1); | |
4270 | if (existing_group) { | |
4271 | if (strcmp(existing_group->name, peergroup) == 0) | |
4272 | return CMD_SUCCESS; | |
4273 | else { | |
4274 | vty_out(vty, | |
4275 | "%% Same listen range is attached to peer-group %s\n", | |
4276 | existing_group->name); | |
4277 | return CMD_WARNING_CONFIG_FAILED; | |
4278 | } | |
4279 | } | |
4280 | ||
4281 | /* Check if an overlapping listen range exists. */ | |
4282 | if (listen_range_exists(bgp, &range, 0)) { | |
4283 | vty_out(vty, | |
4284 | "%% Listen range overlaps with existing listen range\n"); | |
4285 | return CMD_WARNING_CONFIG_FAILED; | |
4286 | } | |
4287 | ||
4288 | group = peer_group_lookup(bgp, peergroup); | |
4289 | if (!group) { | |
4290 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4291 | return CMD_WARNING_CONFIG_FAILED; | |
4292 | } | |
4293 | ||
4294 | ret = peer_group_listen_range_add(group, &range); | |
4295 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
4296 | } |
4297 | ||
4298 | DEFUN (no_bgp_listen_range, | |
4299 | no_bgp_listen_range_cmd, | |
d7b9898c | 4300 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 4301 | NO_STR |
e9273987 | 4302 | BGP_STR |
d7fa34c1 QY |
4303 | "Unconfigure BGP dynamic neighbors listen range\n" |
4304 | "Unconfigure BGP dynamic neighbors listen range\n" | |
4305 | NEIGHBOR_ADDR_STR | |
4306 | "Member of the peer-group\n" | |
4307 | "Peer-group name\n") | |
f14e6fdb | 4308 | { |
d62a17ae | 4309 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4310 | struct prefix range; | |
4311 | struct peer_group *group; | |
4312 | afi_t afi; | |
4313 | int ret; | |
4314 | int idx = 0; | |
4315 | ||
4316 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
4317 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
4318 | char *prefix = argv[idx]->arg; | |
21d88a71 | 4319 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 4320 | char *peergroup = argv[idx]->arg; |
4321 | ||
4322 | /* Convert IP prefix string to struct prefix. */ | |
4323 | ret = str2prefix(prefix, &range); | |
4324 | if (!ret) { | |
4325 | vty_out(vty, "%% Malformed listen range\n"); | |
4326 | return CMD_WARNING_CONFIG_FAILED; | |
4327 | } | |
4328 | ||
4329 | afi = family2afi(range.family); | |
4330 | ||
4331 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
4332 | vty_out(vty, | |
4333 | "%% Malformed listen range (link-local address)\n"); | |
4334 | return CMD_WARNING_CONFIG_FAILED; | |
4335 | } | |
4336 | ||
4337 | apply_mask(&range); | |
4338 | ||
4339 | group = peer_group_lookup(bgp, peergroup); | |
4340 | if (!group) { | |
4341 | vty_out(vty, "%% Peer-group does not exist\n"); | |
4342 | return CMD_WARNING_CONFIG_FAILED; | |
4343 | } | |
4344 | ||
4345 | ret = peer_group_listen_range_del(group, &range); | |
4346 | return bgp_vty_return(vty, ret); | |
4347 | } | |
4348 | ||
2b791107 | 4349 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 4350 | { |
4351 | struct peer_group *group; | |
4352 | struct listnode *node, *nnode, *rnode, *nrnode; | |
4353 | struct prefix *range; | |
4354 | afi_t afi; | |
d62a17ae | 4355 | |
4356 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
4357 | vty_out(vty, " bgp listen limit %d\n", | |
4358 | bgp->dynamic_neighbors_limit); | |
4359 | ||
4360 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
4361 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
4362 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
4363 | nrnode, range)) { | |
d62a17ae | 4364 | vty_out(vty, |
2dbe669b DA |
4365 | " bgp listen range %pFX peer-group %s\n", |
4366 | range, group->name); | |
d62a17ae | 4367 | } |
4368 | } | |
4369 | } | |
f14e6fdb DS |
4370 | } |
4371 | ||
4372 | ||
1ca2fd11 IR |
4373 | DEFUN (bgp_disable_connected_route_check, |
4374 | bgp_disable_connected_route_check_cmd, | |
4375 | "bgp disable-ebgp-connected-route-check", | |
e9273987 | 4376 | BGP_STR |
1ca2fd11 | 4377 | "Disable checking if nexthop is connected on ebgp sessions\n") |
907f92c8 | 4378 | { |
1ca2fd11 IR |
4379 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4380 | SET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
4381 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 4382 | |
1ca2fd11 | 4383 | return CMD_SUCCESS; |
907f92c8 DS |
4384 | } |
4385 | ||
1ca2fd11 IR |
4386 | DEFUN (no_bgp_disable_connected_route_check, |
4387 | no_bgp_disable_connected_route_check_cmd, | |
4388 | "no bgp disable-ebgp-connected-route-check", | |
4389 | NO_STR | |
e9273987 | 4390 | BGP_STR |
1ca2fd11 | 4391 | "Disable checking if nexthop is connected on ebgp sessions\n") |
907f92c8 | 4392 | { |
1ca2fd11 IR |
4393 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4394 | UNSET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
4395 | bgp_clear_star_soft_in(vty, bgp->name); | |
d62a17ae | 4396 | |
1ca2fd11 | 4397 | return CMD_SUCCESS; |
d62a17ae | 4398 | } |
4399 | ||
4400 | ||
28c6e247 IR |
4401 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, |
4402 | const char *as_str) | |
4403 | { | |
4404 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4405 | int ret; | |
4406 | as_t as; | |
4407 | int as_type = AS_SPECIFIED; | |
4408 | union sockunion su; | |
4409 | ||
4410 | if (as_str[0] == 'i') { | |
4411 | as = 0; | |
4412 | as_type = AS_INTERNAL; | |
4413 | } else if (as_str[0] == 'e') { | |
4414 | as = 0; | |
4415 | as_type = AS_EXTERNAL; | |
4416 | } else { | |
4417 | /* Get AS number. */ | |
4418 | as = strtoul(as_str, NULL, 10); | |
4419 | } | |
4420 | ||
4421 | /* If peer is peer group or interface peer, call proper function. */ | |
4422 | ret = str2sockunion(peer_str, &su); | |
4423 | if (ret < 0) { | |
4424 | struct peer *peer; | |
4425 | ||
4426 | /* Check if existing interface peer */ | |
4427 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
4428 | ||
4429 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type); | |
4430 | ||
4431 | /* if not interface peer, check peer-group settings */ | |
4432 | if (ret < 0 && !peer) { | |
4433 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); | |
4434 | if (ret < 0) { | |
4435 | vty_out(vty, | |
4436 | "%% Create the peer-group or interface first\n"); | |
4437 | return CMD_WARNING_CONFIG_FAILED; | |
4438 | } | |
4439 | return CMD_SUCCESS; | |
4440 | } | |
4441 | } else { | |
4442 | if (peer_address_self_check(bgp, &su)) { | |
4443 | vty_out(vty, | |
4444 | "%% Can not configure the local system as neighbor\n"); | |
4445 | return CMD_WARNING_CONFIG_FAILED; | |
4446 | } | |
4447 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type); | |
4448 | } | |
4449 | ||
28c6e247 IR |
4450 | return bgp_vty_return(vty, ret); |
4451 | } | |
4452 | ||
1ca2fd11 IR |
4453 | DEFUN (bgp_default_shutdown, |
4454 | bgp_default_shutdown_cmd, | |
4455 | "[no] bgp default shutdown", | |
4456 | NO_STR | |
4457 | BGP_STR | |
4458 | "Configure BGP defaults\n" | |
4459 | "Apply administrative shutdown to newly configured peers\n") | |
ff8a8a7a | 4460 | { |
1ca2fd11 IR |
4461 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4462 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
4463 | return CMD_SUCCESS; | |
f26845f9 QY |
4464 | } |
4465 | ||
736b68f3 DS |
4466 | DEFPY(bgp_shutdown_msg, bgp_shutdown_msg_cmd, "bgp shutdown message MSG...", |
4467 | BGP_STR | |
9ddf4b81 | 4468 | "Administrative shutdown of the BGP instance\n" |
736b68f3 DS |
4469 | "Add a shutdown message (RFC 8203)\n" |
4470 | "Shutdown message\n") | |
9cf59432 | 4471 | { |
736b68f3 | 4472 | char *msgstr = NULL; |
8389c83a | 4473 | |
9cf59432 DS |
4474 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4475 | ||
8389c83a | 4476 | if (argc > 3) |
f80e35b6 | 4477 | msgstr = argv_concat(argv, argc, 3); |
8389c83a | 4478 | |
b776f48c DA |
4479 | if (msgstr && strlen(msgstr) > BGP_ADMIN_SHUTDOWN_MSG_LEN) { |
4480 | vty_out(vty, "%% Shutdown message size exceeded %d\n", | |
4481 | BGP_ADMIN_SHUTDOWN_MSG_LEN); | |
4482 | return CMD_WARNING_CONFIG_FAILED; | |
4483 | } | |
4484 | ||
8389c83a DS |
4485 | bgp_shutdown_enable(bgp, msgstr); |
4486 | XFREE(MTYPE_TMP, msgstr); | |
9cf59432 DS |
4487 | |
4488 | return CMD_SUCCESS; | |
4489 | } | |
4490 | ||
736b68f3 | 4491 | DEFPY(bgp_shutdown, bgp_shutdown_cmd, "bgp shutdown", |
9ddf4b81 | 4492 | BGP_STR "Administrative shutdown of the BGP instance\n") |
1e12ebbc DS |
4493 | { |
4494 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4495 | ||
4496 | bgp_shutdown_enable(bgp, NULL); | |
4497 | ||
4498 | return CMD_SUCCESS; | |
4499 | } | |
8389c83a | 4500 | |
736b68f3 | 4501 | DEFPY(no_bgp_shutdown, no_bgp_shutdown_cmd, "no bgp shutdown", |
9ddf4b81 | 4502 | NO_STR BGP_STR "Administrative shutdown of the BGP instance\n") |
9cf59432 DS |
4503 | { |
4504 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4505 | ||
4506 | bgp_shutdown_disable(bgp); | |
4507 | ||
4508 | return CMD_SUCCESS; | |
4509 | } | |
4510 | ||
9ddf4b81 | 4511 | ALIAS(no_bgp_shutdown, no_bgp_shutdown_msg_cmd, |
1b6e7a88 | 4512 | "no bgp shutdown message MSG...", NO_STR BGP_STR |
9ddf4b81 | 4513 | "Administrative shutdown of the BGP instance\n" |
1b6e7a88 | 4514 | "Add a shutdown message (RFC 8203)\n" "Shutdown message\n") |
1b6e7a88 | 4515 | |
28c6e247 IR |
4516 | DEFUN (neighbor_remote_as, |
4517 | neighbor_remote_as_cmd, | |
4518 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", | |
4519 | NEIGHBOR_STR | |
4520 | NEIGHBOR_ADDR_STR2 | |
4521 | "Specify a BGP neighbor\n" | |
4522 | AS_STR | |
4523 | "Internal BGP peer\n" | |
4524 | "External BGP peer\n") | |
718e3744 | 4525 | { |
d62a17ae | 4526 | int idx_peer = 1; |
4527 | int idx_remote_as = 3; | |
28c6e247 IR |
4528 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, |
4529 | argv[idx_remote_as]->arg); | |
d62a17ae | 4530 | } |
8666265e DS |
4531 | |
4532 | DEFPY (bgp_allow_martian, | |
4533 | bgp_allow_martian_cmd, | |
4534 | "[no]$no bgp allow-martian-nexthop", | |
4535 | NO_STR | |
4536 | BGP_STR | |
4537 | "Allow Martian nexthops to be received in the NLRI from a peer\n") | |
4538 | { | |
4539 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4540 | ||
4541 | if (no) | |
4542 | bgp->allow_martian = false; | |
4543 | else | |
4544 | bgp->allow_martian = true; | |
4545 | ||
4546 | return CMD_SUCCESS; | |
4547 | } | |
4548 | ||
f852eb98 PG |
4549 | /* Enable fast convergence of bgp sessions. If this is enabled, bgp |
4550 | * sessions do not wait for hold timer expiry to bring down the sessions | |
4551 | * when nexthop becomes unreachable | |
4552 | */ | |
4553 | DEFUN(bgp_fast_convergence, bgp_fast_convergence_cmd, "bgp fast-convergence", | |
4554 | BGP_STR "Fast convergence for bgp sessions\n") | |
4555 | { | |
4556 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4557 | bgp->fast_convergence = true; | |
4558 | ||
4559 | return CMD_SUCCESS; | |
4560 | } | |
4561 | ||
4562 | DEFUN(no_bgp_fast_convergence, no_bgp_fast_convergence_cmd, | |
4563 | "no bgp fast-convergence", | |
4564 | NO_STR BGP_STR "Fast convergence for bgp sessions\n") | |
4565 | { | |
4566 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4567 | bgp->fast_convergence = false; | |
4568 | ||
4569 | return CMD_SUCCESS; | |
4570 | } | |
d62a17ae | 4571 | |
28c6e247 IR |
4572 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, |
4573 | int v6only, | |
4574 | const char *peer_group_name, | |
4575 | const char *as_str) | |
d62a17ae | 4576 | { |
28c6e247 IR |
4577 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4578 | as_t as = 0; | |
4579 | int as_type = AS_UNSPECIFIED; | |
d62a17ae | 4580 | struct peer *peer; |
4581 | struct peer_group *group; | |
4582 | int ret = 0; | |
d62a17ae | 4583 | |
4584 | group = peer_group_lookup(bgp, conf_if); | |
4585 | ||
4586 | if (group) { | |
28c6e247 IR |
4587 | vty_out(vty, "%% Name conflict with peer-group \n"); |
4588 | return CMD_WARNING_CONFIG_FAILED; | |
4589 | } | |
4590 | ||
4591 | if (as_str) { | |
4592 | if (as_str[0] == 'i') { | |
4593 | as_type = AS_INTERNAL; | |
4594 | } else if (as_str[0] == 'e') { | |
4595 | as_type = AS_EXTERNAL; | |
4596 | } else { | |
4597 | /* Get AS number. */ | |
4598 | as = strtoul(as_str, NULL, 10); | |
4599 | as_type = AS_SPECIFIED; | |
4600 | } | |
d62a17ae | 4601 | } |
4602 | ||
4603 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
4604 | if (peer) { | |
28c6e247 | 4605 | if (as_str) |
e84c59af | 4606 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type); |
d62a17ae | 4607 | } else { |
e84c59af DA |
4608 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, as_type, |
4609 | NULL); | |
d62a17ae | 4610 | |
4611 | if (!peer) { | |
28c6e247 IR |
4612 | vty_out(vty, "%% BGP failed to create peer\n"); |
4613 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4614 | } |
4615 | ||
4616 | if (v6only) | |
527de3dc | 4617 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4618 | |
4619 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
4620 | * this | |
4621 | * any unnumbered peer in order to not worry about run-time | |
4622 | * transitions | |
4623 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
4624 | * address | |
4625 | * gets deleted later etc.) | |
4626 | */ | |
4627 | if (peer->ifp) | |
4628 | bgp_zebra_initiate_radv(bgp, peer); | |
4629 | } | |
4630 | ||
4631 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
4632 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
4633 | if (v6only) | |
527de3dc | 4634 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4635 | else |
527de3dc | 4636 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4637 | |
4638 | /* v6only flag changed. Reset bgp seesion */ | |
4639 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
4640 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
4641 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
4642 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
4643 | } else | |
4644 | bgp_session_reset(peer); | |
4645 | } | |
4646 | ||
9fb964de PM |
4647 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
4648 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
4649 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 4650 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 4651 | } |
d62a17ae | 4652 | |
4653 | if (peer_group_name) { | |
4654 | group = peer_group_lookup(bgp, peer_group_name); | |
4655 | if (!group) { | |
28c6e247 IR |
4656 | vty_out(vty, "%% Configure the peer-group first\n"); |
4657 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4658 | } |
4659 | ||
8395c1f8 | 4660 | ret = peer_group_bind(bgp, NULL, peer, group, &as); |
d62a17ae | 4661 | } |
4662 | ||
28c6e247 | 4663 | return bgp_vty_return(vty, ret); |
a80beece DS |
4664 | } |
4665 | ||
28c6e247 IR |
4666 | DEFUN (neighbor_interface_config, |
4667 | neighbor_interface_config_cmd, | |
4668 | "neighbor WORD interface [peer-group PGNAME]", | |
4669 | NEIGHBOR_STR | |
4670 | "Interface name or neighbor tag\n" | |
4671 | "Enable BGP on interface\n" | |
4672 | "Member of the peer-group\n" | |
4673 | "Peer-group name\n") | |
4c48cf63 | 4674 | { |
d62a17ae | 4675 | int idx_word = 1; |
4676 | int idx_peer_group_word = 4; | |
f4b8ec07 | 4677 | |
d62a17ae | 4678 | if (argc > idx_peer_group_word) |
28c6e247 IR |
4679 | return peer_conf_interface_get( |
4680 | vty, argv[idx_word]->arg, 0, | |
4681 | argv[idx_peer_group_word]->arg, NULL); | |
4682 | else | |
4683 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 0, | |
4684 | NULL, NULL); | |
4c48cf63 DW |
4685 | } |
4686 | ||
28c6e247 IR |
4687 | DEFUN (neighbor_interface_config_v6only, |
4688 | neighbor_interface_config_v6only_cmd, | |
4689 | "neighbor WORD interface v6only [peer-group PGNAME]", | |
4690 | NEIGHBOR_STR | |
4691 | "Interface name or neighbor tag\n" | |
4692 | "Enable BGP on interface\n" | |
4693 | "Enable BGP with v6 link-local only\n" | |
4694 | "Member of the peer-group\n" | |
4695 | "Peer-group name\n") | |
4c48cf63 | 4696 | { |
d62a17ae | 4697 | int idx_word = 1; |
4698 | int idx_peer_group_word = 5; | |
31500417 | 4699 | |
d62a17ae | 4700 | if (argc > idx_peer_group_word) |
28c6e247 IR |
4701 | return peer_conf_interface_get( |
4702 | vty, argv[idx_word]->arg, 1, | |
4703 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 4704 | |
28c6e247 | 4705 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 1, NULL, NULL); |
4c48cf63 DW |
4706 | } |
4707 | ||
a80beece | 4708 | |
28c6e247 IR |
4709 | DEFUN (neighbor_interface_config_remote_as, |
4710 | neighbor_interface_config_remote_as_cmd, | |
4711 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", | |
4712 | NEIGHBOR_STR | |
4713 | "Interface name or neighbor tag\n" | |
4714 | "Enable BGP on interface\n" | |
4715 | "Specify a BGP neighbor\n" | |
4716 | AS_STR | |
4717 | "Internal BGP peer\n" | |
4718 | "External BGP peer\n") | |
b3a39dc5 | 4719 | { |
d62a17ae | 4720 | int idx_word = 1; |
4721 | int idx_remote_as = 4; | |
28c6e247 IR |
4722 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 0, NULL, |
4723 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
4724 | } |
4725 | ||
28c6e247 IR |
4726 | DEFUN (neighbor_interface_v6only_config_remote_as, |
4727 | neighbor_interface_v6only_config_remote_as_cmd, | |
4728 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", | |
4729 | NEIGHBOR_STR | |
4730 | "Interface name or neighbor tag\n" | |
4731 | "Enable BGP with v6 link-local only\n" | |
4732 | "Enable BGP on interface\n" | |
4733 | "Specify a BGP neighbor\n" | |
4734 | AS_STR | |
4735 | "Internal BGP peer\n" | |
4736 | "External BGP peer\n") | |
b3a39dc5 | 4737 | { |
d62a17ae | 4738 | int idx_word = 1; |
4739 | int idx_remote_as = 5; | |
28c6e247 IR |
4740 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 1, NULL, |
4741 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
4742 | } |
4743 | ||
28c6e247 IR |
4744 | DEFUN (neighbor_peer_group, |
4745 | neighbor_peer_group_cmd, | |
4746 | "neighbor WORD peer-group", | |
4747 | NEIGHBOR_STR | |
4748 | "Interface name or neighbor tag\n" | |
4749 | "Configure peer-group\n") | |
718e3744 | 4750 | { |
28c6e247 | 4751 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4752 | int idx_word = 1; |
28c6e247 IR |
4753 | struct peer *peer; |
4754 | struct peer_group *group; | |
718e3744 | 4755 | |
28c6e247 IR |
4756 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
4757 | if (peer) { | |
4758 | vty_out(vty, "%% Name conflict with interface: \n"); | |
4759 | return CMD_WARNING_CONFIG_FAILED; | |
4760 | } | |
718e3744 | 4761 | |
28c6e247 IR |
4762 | group = peer_group_get(bgp, argv[idx_word]->arg); |
4763 | if (!group) { | |
4764 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
4765 | return CMD_WARNING_CONFIG_FAILED; | |
4766 | } | |
718e3744 | 4767 | |
28c6e247 | 4768 | return CMD_SUCCESS; |
718e3744 | 4769 | } |
4770 | ||
1d80f243 IR |
4771 | DEFUN (no_neighbor, |
4772 | no_neighbor_cmd, | |
4773 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", | |
4774 | NO_STR | |
4775 | NEIGHBOR_STR | |
4776 | NEIGHBOR_ADDR_STR2 | |
4777 | "Specify a BGP neighbor\n" | |
4778 | AS_STR | |
4779 | "Internal BGP peer\n" | |
4780 | "External BGP peer\n") | |
718e3744 | 4781 | { |
28c6e247 | 4782 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4783 | int idx_peer = 2; |
28c6e247 | 4784 | int ret; |
d62a17ae | 4785 | union sockunion su; |
28c6e247 IR |
4786 | struct peer_group *group; |
4787 | struct peer *peer; | |
4788 | struct peer *other; | |
d62a17ae | 4789 | |
28c6e247 IR |
4790 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
4791 | if (ret < 0) { | |
4792 | /* look up for neighbor by interface name config. */ | |
4793 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4794 | if (peer) { | |
4795 | /* Request zebra to terminate IPv6 RAs on this | |
4796 | * interface. */ | |
4797 | if (peer->ifp) | |
4798 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4799 | peer_notify_unconfig(peer); | |
4800 | peer_delete(peer); | |
4801 | return CMD_SUCCESS; | |
d62a17ae | 4802 | } |
28c6e247 IR |
4803 | |
4804 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); | |
4805 | if (group) { | |
4806 | peer_group_notify_unconfig(group); | |
4807 | peer_group_delete(group); | |
4e2786df | 4808 | } else { |
28c6e247 | 4809 | vty_out(vty, "%% Create the peer-group first\n"); |
d62a17ae | 4810 | return CMD_WARNING_CONFIG_FAILED; |
4811 | } | |
28c6e247 IR |
4812 | } else { |
4813 | peer = peer_lookup(bgp, &su); | |
4814 | if (peer) { | |
4815 | if (peer_dynamic_neighbor(peer)) { | |
4816 | vty_out(vty, | |
4817 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4818 | return CMD_WARNING_CONFIG_FAILED; | |
4819 | } | |
d62a17ae | 4820 | |
28c6e247 | 4821 | other = peer->doppelganger; |
f4b8ec07 | 4822 | |
28c6e247 IR |
4823 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) |
4824 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
f4b8ec07 | 4825 | |
28c6e247 IR |
4826 | peer_notify_unconfig(peer); |
4827 | peer_delete(peer); | |
4828 | if (other && other->status != Deleted) { | |
4829 | peer_notify_unconfig(other); | |
4830 | peer_delete(other); | |
4831 | } | |
4832 | } | |
4833 | } | |
4834 | ||
4835 | return CMD_SUCCESS; | |
a80beece DS |
4836 | } |
4837 | ||
28c6e247 IR |
4838 | DEFUN (no_neighbor_interface_config, |
4839 | no_neighbor_interface_config_cmd, | |
4840 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", | |
4841 | NO_STR | |
4842 | NEIGHBOR_STR | |
4843 | "Interface name\n" | |
4844 | "Configure BGP on interface\n" | |
4845 | "Enable BGP with v6 link-local only\n" | |
4846 | "Member of the peer-group\n" | |
4847 | "Peer-group name\n" | |
4848 | "Specify a BGP neighbor\n" | |
4849 | AS_STR | |
4850 | "Internal BGP peer\n" | |
4851 | "External BGP peer\n") | |
718e3744 | 4852 | { |
28c6e247 | 4853 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4854 | int idx_word = 2; |
28c6e247 | 4855 | struct peer *peer; |
718e3744 | 4856 | |
28c6e247 IR |
4857 | /* look up for neighbor by interface name config. */ |
4858 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
4859 | if (peer) { | |
4860 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
4861 | if (peer->ifp) | |
4862 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4863 | peer_notify_unconfig(peer); | |
4864 | peer_delete(peer); | |
4865 | } else { | |
4866 | vty_out(vty, "%% Create the bgp interface first\n"); | |
4867 | return CMD_WARNING_CONFIG_FAILED; | |
4868 | } | |
4869 | return CMD_SUCCESS; | |
718e3744 | 4870 | } |
4871 | ||
28c6e247 IR |
4872 | DEFUN (no_neighbor_peer_group, |
4873 | no_neighbor_peer_group_cmd, | |
4874 | "no neighbor WORD peer-group", | |
4875 | NO_STR | |
4876 | NEIGHBOR_STR | |
4877 | "Neighbor tag\n" | |
4878 | "Configure peer-group\n") | |
718e3744 | 4879 | { |
28c6e247 IR |
4880 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4881 | int idx_word = 2; | |
4882 | struct peer_group *group; | |
f4b8ec07 | 4883 | |
28c6e247 IR |
4884 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4885 | if (group) { | |
4886 | peer_group_notify_unconfig(group); | |
4887 | peer_group_delete(group); | |
f4b8ec07 | 4888 | } else { |
28c6e247 | 4889 | vty_out(vty, "%% Create the peer-group first\n"); |
d62a17ae | 4890 | return CMD_WARNING_CONFIG_FAILED; |
4891 | } | |
28c6e247 IR |
4892 | return CMD_SUCCESS; |
4893 | } | |
f4b8ec07 | 4894 | |
28c6e247 IR |
4895 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
4896 | no_neighbor_interface_peer_group_remote_as_cmd, | |
4897 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", | |
4898 | NO_STR | |
4899 | NEIGHBOR_STR | |
4900 | "Interface name or neighbor tag\n" | |
4901 | "Specify a BGP neighbor\n" | |
4902 | AS_STR | |
4903 | "Internal BGP peer\n" | |
4904 | "External BGP peer\n") | |
4905 | { | |
4906 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4907 | int idx_word = 2; | |
4908 | struct peer_group *group; | |
4909 | struct peer *peer; | |
f4b8ec07 | 4910 | |
28c6e247 IR |
4911 | /* look up for neighbor by interface name config. */ |
4912 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
4913 | if (peer) { | |
4914 | peer_as_change(peer, 0, AS_UNSPECIFIED); | |
4915 | return CMD_SUCCESS; | |
4916 | } | |
f4b8ec07 | 4917 | |
28c6e247 IR |
4918 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4919 | if (group) | |
4920 | peer_group_remote_as_delete(group); | |
4921 | else { | |
4922 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
4923 | return CMD_WARNING_CONFIG_FAILED; | |
4924 | } | |
4925 | return CMD_SUCCESS; | |
718e3744 | 4926 | } |
6b0655a2 | 4927 | |
28c6e247 IR |
4928 | DEFUN (neighbor_local_as, |
4929 | neighbor_local_as_cmd, | |
4930 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", | |
4931 | NEIGHBOR_STR | |
4932 | NEIGHBOR_ADDR_STR2 | |
4933 | "Specify a local-as number\n" | |
4934 | "AS number used as local AS\n") | |
718e3744 | 4935 | { |
d62a17ae | 4936 | int idx_peer = 1; |
4937 | int idx_number = 3; | |
28c6e247 IR |
4938 | struct peer *peer; |
4939 | int ret; | |
4940 | as_t as; | |
718e3744 | 4941 | |
28c6e247 IR |
4942 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4943 | if (!peer) | |
d62a17ae | 4944 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4945 | |
28c6e247 IR |
4946 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4947 | ret = peer_local_as_set(peer, as, 0, 0); | |
4948 | return bgp_vty_return(vty, ret); | |
718e3744 | 4949 | } |
4950 | ||
28c6e247 IR |
4951 | DEFUN (neighbor_local_as_no_prepend, |
4952 | neighbor_local_as_no_prepend_cmd, | |
4953 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", | |
4954 | NEIGHBOR_STR | |
4955 | NEIGHBOR_ADDR_STR2 | |
4956 | "Specify a local-as number\n" | |
4957 | "AS number used as local AS\n" | |
4958 | "Do not prepend local-as to updates from ebgp peers\n") | |
718e3744 | 4959 | { |
d62a17ae | 4960 | int idx_peer = 1; |
4961 | int idx_number = 3; | |
28c6e247 IR |
4962 | struct peer *peer; |
4963 | int ret; | |
4964 | as_t as; | |
718e3744 | 4965 | |
28c6e247 IR |
4966 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4967 | if (!peer) | |
d62a17ae | 4968 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4969 | |
28c6e247 IR |
4970 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4971 | ret = peer_local_as_set(peer, as, 1, 0); | |
4972 | return bgp_vty_return(vty, ret); | |
718e3744 | 4973 | } |
4974 | ||
28c6e247 IR |
4975 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
4976 | neighbor_local_as_no_prepend_replace_as_cmd, | |
4977 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", | |
4978 | NEIGHBOR_STR | |
4979 | NEIGHBOR_ADDR_STR2 | |
4980 | "Specify a local-as number\n" | |
4981 | "AS number used as local AS\n" | |
4982 | "Do not prepend local-as to updates from ebgp peers\n" | |
4983 | "Do not prepend local-as to updates from ibgp peers\n") | |
9d3f9705 | 4984 | { |
d62a17ae | 4985 | int idx_peer = 1; |
4986 | int idx_number = 3; | |
28c6e247 IR |
4987 | struct peer *peer; |
4988 | int ret; | |
4989 | as_t as; | |
9d3f9705 | 4990 | |
28c6e247 IR |
4991 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4992 | if (!peer) | |
d62a17ae | 4993 | return CMD_WARNING_CONFIG_FAILED; |
9d3f9705 | 4994 | |
28c6e247 IR |
4995 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4996 | ret = peer_local_as_set(peer, as, 1, 1); | |
4997 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
4998 | } |
4999 | ||
28c6e247 IR |
5000 | DEFUN (no_neighbor_local_as, |
5001 | no_neighbor_local_as_cmd, | |
5002 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", | |
5003 | NO_STR | |
5004 | NEIGHBOR_STR | |
5005 | NEIGHBOR_ADDR_STR2 | |
5006 | "Specify a local-as number\n" | |
5007 | "AS number used as local AS\n" | |
5008 | "Do not prepend local-as to updates from ebgp peers\n" | |
5009 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 5010 | { |
d62a17ae | 5011 | int idx_peer = 2; |
28c6e247 IR |
5012 | struct peer *peer; |
5013 | int ret; | |
718e3744 | 5014 | |
28c6e247 IR |
5015 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5016 | if (!peer) | |
d62a17ae | 5017 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 5018 | |
28c6e247 IR |
5019 | ret = peer_local_as_unset(peer); |
5020 | return bgp_vty_return(vty, ret); | |
718e3744 | 5021 | } |
5022 | ||
718e3744 | 5023 | |
3f9c7369 DS |
5024 | DEFUN (neighbor_solo, |
5025 | neighbor_solo_cmd, | |
9ccf14f7 | 5026 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
5027 | NEIGHBOR_STR |
5028 | NEIGHBOR_ADDR_STR2 | |
5029 | "Solo peer - part of its own update group\n") | |
5030 | { | |
d62a17ae | 5031 | int idx_peer = 1; |
5032 | struct peer *peer; | |
5033 | int ret; | |
3f9c7369 | 5034 | |
d62a17ae | 5035 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5036 | if (!peer) | |
5037 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 5038 | |
d62a17ae | 5039 | ret = update_group_adjust_soloness(peer, 1); |
5040 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
5041 | } |
5042 | ||
5043 | DEFUN (no_neighbor_solo, | |
5044 | no_neighbor_solo_cmd, | |
9ccf14f7 | 5045 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
5046 | NO_STR |
5047 | NEIGHBOR_STR | |
5048 | NEIGHBOR_ADDR_STR2 | |
5049 | "Solo peer - part of its own update group\n") | |
5050 | { | |
d62a17ae | 5051 | int idx_peer = 2; |
5052 | struct peer *peer; | |
5053 | int ret; | |
3f9c7369 | 5054 | |
d62a17ae | 5055 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5056 | if (!peer) | |
5057 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 5058 | |
d62a17ae | 5059 | ret = update_group_adjust_soloness(peer, 0); |
5060 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
5061 | } |
5062 | ||
28c6e247 IR |
5063 | DEFUN (neighbor_password, |
5064 | neighbor_password_cmd, | |
5065 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", | |
5066 | NEIGHBOR_STR | |
5067 | NEIGHBOR_ADDR_STR2 | |
5068 | "Set a password\n" | |
5069 | "The password\n") | |
0df7c91f | 5070 | { |
d62a17ae | 5071 | int idx_peer = 1; |
5072 | int idx_line = 3; | |
28c6e247 IR |
5073 | struct peer *peer; |
5074 | int ret; | |
0df7c91f | 5075 | |
28c6e247 IR |
5076 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5077 | if (!peer) | |
d62a17ae | 5078 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 5079 | |
28c6e247 IR |
5080 | ret = peer_password_set(peer, argv[idx_line]->arg); |
5081 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
5082 | } |
5083 | ||
28c6e247 IR |
5084 | DEFUN (no_neighbor_password, |
5085 | no_neighbor_password_cmd, | |
5086 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", | |
5087 | NO_STR | |
5088 | NEIGHBOR_STR | |
5089 | NEIGHBOR_ADDR_STR2 | |
5090 | "Set a password\n" | |
5091 | "The password\n") | |
0df7c91f | 5092 | { |
d62a17ae | 5093 | int idx_peer = 2; |
28c6e247 IR |
5094 | struct peer *peer; |
5095 | int ret; | |
0df7c91f | 5096 | |
28c6e247 IR |
5097 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5098 | if (!peer) | |
d62a17ae | 5099 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 5100 | |
28c6e247 IR |
5101 | ret = peer_password_unset(peer); |
5102 | return bgp_vty_return(vty, ret); | |
0df7c91f | 5103 | } |
6b0655a2 | 5104 | |
28c6e247 IR |
5105 | DEFUN (neighbor_activate, |
5106 | neighbor_activate_cmd, | |
5107 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
5108 | NEIGHBOR_STR | |
5109 | NEIGHBOR_ADDR_STR2 | |
5110 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 5111 | { |
d62a17ae | 5112 | int idx_peer = 1; |
28c6e247 IR |
5113 | int ret; |
5114 | struct peer *peer; | |
56ceae84 | 5115 | |
28c6e247 IR |
5116 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5117 | if (!peer) | |
d62a17ae | 5118 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 5119 | |
28c6e247 IR |
5120 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
5121 | return bgp_vty_return(vty, ret); | |
718e3744 | 5122 | } |
5123 | ||
d62a17ae | 5124 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
5125 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
5126 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5127 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 5128 | |
28c6e247 IR |
5129 | DEFUN (no_neighbor_activate, |
5130 | no_neighbor_activate_cmd, | |
5131 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
5132 | NO_STR | |
5133 | NEIGHBOR_STR | |
5134 | NEIGHBOR_ADDR_STR2 | |
5135 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 5136 | { |
d62a17ae | 5137 | int idx_peer = 2; |
28c6e247 IR |
5138 | int ret; |
5139 | struct peer *peer; | |
f4b8ec07 | 5140 | |
28c6e247 IR |
5141 | /* Lookup peer. */ |
5142 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5143 | if (!peer) | |
d62a17ae | 5144 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 5145 | |
28c6e247 IR |
5146 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
5147 | return bgp_vty_return(vty, ret); | |
718e3744 | 5148 | } |
6b0655a2 | 5149 | |
d62a17ae | 5150 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
5151 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
5152 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5153 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 5154 | |
28c6e247 IR |
5155 | DEFUN (neighbor_set_peer_group, |
5156 | neighbor_set_peer_group_cmd, | |
5157 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
5158 | NEIGHBOR_STR | |
5159 | NEIGHBOR_ADDR_STR2 | |
5160 | "Member of the peer-group\n" | |
5161 | "Peer-group name\n") | |
718e3744 | 5162 | { |
28c6e247 | 5163 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 5164 | int idx_peer = 1; |
5165 | int idx_word = 3; | |
28c6e247 IR |
5166 | int ret; |
5167 | as_t as; | |
5168 | union sockunion su; | |
5169 | struct peer *peer; | |
5170 | struct peer_group *group; | |
5171 | ||
5172 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
5173 | if (ret < 0) { | |
5174 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
5175 | if (!peer) { | |
5176 | vty_out(vty, "%% Malformed address or name: %s\n", | |
5177 | argv[idx_peer]->arg); | |
5178 | return CMD_WARNING_CONFIG_FAILED; | |
5179 | } | |
5180 | } else { | |
5181 | if (peer_address_self_check(bgp, &su)) { | |
5182 | vty_out(vty, | |
5183 | "%% Can not configure the local system as neighbor\n"); | |
5184 | return CMD_WARNING_CONFIG_FAILED; | |
5185 | } | |
2a059a54 | 5186 | |
28c6e247 IR |
5187 | /* Disallow for dynamic neighbor. */ |
5188 | peer = peer_lookup(bgp, &su); | |
5189 | if (peer && peer_dynamic_neighbor(peer)) { | |
5190 | vty_out(vty, | |
5191 | "%% Operation not allowed on a dynamic neighbor\n"); | |
5192 | return CMD_WARNING_CONFIG_FAILED; | |
5193 | } | |
5194 | } | |
5195 | ||
5196 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
5197 | if (!group) { | |
5198 | vty_out(vty, "%% Configure the peer-group first\n"); | |
d62a17ae | 5199 | return CMD_WARNING_CONFIG_FAILED; |
28c6e247 | 5200 | } |
d62a17ae | 5201 | |
28c6e247 | 5202 | ret = peer_group_bind(bgp, &su, peer, group, &as); |
2a059a54 | 5203 | |
28c6e247 | 5204 | return bgp_vty_return(vty, ret); |
d62a17ae | 5205 | } |
5206 | ||
5207 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 5208 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 5209 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
5210 | "Member of the peer-group\n" | |
5211 | "Peer-group name\n") | |
596c17ba | 5212 | |
28c6e247 IR |
5213 | DEFUN (no_neighbor_set_peer_group, |
5214 | no_neighbor_set_peer_group_cmd, | |
5215 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
5216 | NO_STR | |
5217 | NEIGHBOR_STR | |
5218 | NEIGHBOR_ADDR_STR2 | |
5219 | "Member of the peer-group\n" | |
5220 | "Peer-group name\n") | |
718e3744 | 5221 | { |
28c6e247 | 5222 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 5223 | int idx_peer = 2; |
28c6e247 IR |
5224 | int idx_word = 4; |
5225 | int ret; | |
5226 | struct peer *peer; | |
5227 | struct peer_group *group; | |
d62a17ae | 5228 | |
28c6e247 IR |
5229 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); |
5230 | if (!peer) | |
d62a17ae | 5231 | return CMD_WARNING_CONFIG_FAILED; |
b3a3290e | 5232 | |
28c6e247 IR |
5233 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
5234 | if (!group) { | |
5235 | vty_out(vty, "%% Configure the peer-group first\n"); | |
5236 | return CMD_WARNING_CONFIG_FAILED; | |
5237 | } | |
718e3744 | 5238 | |
28c6e247 IR |
5239 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) |
5240 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
5241 | ||
5242 | peer_notify_unconfig(peer); | |
5243 | ret = peer_delete(peer); | |
5244 | ||
5245 | return bgp_vty_return(vty, ret); | |
718e3744 | 5246 | } |
6b0655a2 | 5247 | |
d62a17ae | 5248 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
71cc0c88 | 5249 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 5250 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
5251 | "Member of the peer-group\n" | |
5252 | "Peer-group name\n") | |
596c17ba | 5253 | |
d62a17ae | 5254 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
83194f39 | 5255 | uint64_t flag, int set) |
718e3744 | 5256 | { |
d62a17ae | 5257 | int ret; |
5258 | struct peer *peer; | |
718e3744 | 5259 | |
d62a17ae | 5260 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5261 | if (!peer) | |
5262 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5263 | |
7ebe625c QY |
5264 | /* |
5265 | * If 'neighbor <interface>', then this is for directly connected peers, | |
5266 | * we should not accept disable-connected-check. | |
5267 | */ | |
5268 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
5269 | vty_out(vty, | |
3efd0893 | 5270 | "%s is directly connected peer, cannot accept disable-connected-check\n", |
7ebe625c QY |
5271 | ip_str); |
5272 | return CMD_WARNING_CONFIG_FAILED; | |
5273 | } | |
5274 | ||
d62a17ae | 5275 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
5276 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 5277 | |
d62a17ae | 5278 | if (set) |
5279 | ret = peer_flag_set(peer, flag); | |
5280 | else | |
5281 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 5282 | |
d62a17ae | 5283 | return bgp_vty_return(vty, ret); |
718e3744 | 5284 | } |
5285 | ||
83194f39 | 5286 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint64_t flag) |
718e3744 | 5287 | { |
d62a17ae | 5288 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 5289 | } |
5290 | ||
d62a17ae | 5291 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
83194f39 | 5292 | uint64_t flag) |
718e3744 | 5293 | { |
d62a17ae | 5294 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 5295 | } |
5296 | ||
5297 | /* neighbor passive. */ | |
28c6e247 IR |
5298 | DEFUN (neighbor_passive, |
5299 | neighbor_passive_cmd, | |
5300 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
5301 | NEIGHBOR_STR | |
5302 | NEIGHBOR_ADDR_STR2 | |
5303 | "Don't send open messages to this neighbor\n") | |
718e3744 | 5304 | { |
d62a17ae | 5305 | int idx_peer = 1; |
28c6e247 | 5306 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); |
718e3744 | 5307 | } |
5308 | ||
28c6e247 IR |
5309 | DEFUN (no_neighbor_passive, |
5310 | no_neighbor_passive_cmd, | |
5311 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
5312 | NO_STR | |
5313 | NEIGHBOR_STR | |
5314 | NEIGHBOR_ADDR_STR2 | |
5315 | "Don't send open messages to this neighbor\n") | |
718e3744 | 5316 | { |
d62a17ae | 5317 | int idx_peer = 2; |
28c6e247 | 5318 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); |
718e3744 | 5319 | } |
6b0655a2 | 5320 | |
718e3744 | 5321 | /* neighbor shutdown. */ |
28c6e247 IR |
5322 | DEFUN (neighbor_shutdown_msg, |
5323 | neighbor_shutdown_msg_cmd, | |
5324 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5325 | NEIGHBOR_STR | |
5326 | NEIGHBOR_ADDR_STR2 | |
5327 | "Administratively shut down this neighbor\n" | |
5328 | "Add a shutdown message (RFC 8203)\n" | |
5329 | "Shutdown message\n") | |
718e3744 | 5330 | { |
d62a17ae | 5331 | int idx_peer = 1; |
73d70fa6 | 5332 | |
d62a17ae | 5333 | if (argc >= 5) { |
28c6e247 IR |
5334 | struct peer *peer = |
5335 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
d62a17ae | 5336 | char *message; |
73d70fa6 | 5337 | |
28c6e247 IR |
5338 | if (!peer) |
5339 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5340 | message = argv_concat(argv, argc, 4); |
28c6e247 IR |
5341 | peer_tx_shutdown_message_set(peer, message); |
5342 | XFREE(MTYPE_TMP, message); | |
d62a17ae | 5343 | } |
73d70fa6 | 5344 | |
28c6e247 | 5345 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 5346 | } |
5347 | ||
1d80f243 | 5348 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
d62a17ae | 5349 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
5350 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5351 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5352 | |
28c6e247 IR |
5353 | DEFUN (no_neighbor_shutdown_msg, |
5354 | no_neighbor_shutdown_msg_cmd, | |
5355 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5356 | NO_STR | |
5357 | NEIGHBOR_STR | |
5358 | NEIGHBOR_ADDR_STR2 | |
5359 | "Administratively shut down this neighbor\n" | |
5360 | "Remove a shutdown message (RFC 8203)\n" | |
5361 | "Shutdown message\n") | |
718e3744 | 5362 | { |
d62a17ae | 5363 | int idx_peer = 2; |
73d70fa6 | 5364 | |
28c6e247 IR |
5365 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
5366 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 5367 | } |
6b0655a2 | 5368 | |
1d80f243 | 5369 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
d62a17ae | 5370 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
5371 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5372 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5373 | |
8336c896 DA |
5374 | DEFUN(neighbor_shutdown_rtt, |
5375 | neighbor_shutdown_rtt_cmd, | |
5376 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]", | |
5377 | NEIGHBOR_STR | |
5378 | NEIGHBOR_ADDR_STR2 | |
5379 | "Administratively shut down this neighbor\n" | |
5380 | "Shutdown if round-trip-time is higher than expected\n" | |
5381 | "Round-trip-time in milliseconds\n" | |
5382 | "Specify the number of keepalives before shutdown\n" | |
5383 | "The number of keepalives with higher RTT to shutdown\n") | |
5384 | { | |
5385 | int idx_peer = 1; | |
5386 | int idx_rtt = 4; | |
5387 | int idx_count = 0; | |
5388 | struct peer *peer; | |
5389 | ||
5390 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5391 | ||
5392 | if (!peer) | |
5393 | return CMD_WARNING_CONFIG_FAILED; | |
5394 | ||
5395 | peer->rtt_expected = strtol(argv[idx_rtt]->arg, NULL, 10); | |
5396 | ||
5397 | if (argv_find(argv, argc, "count", &idx_count)) | |
5398 | peer->rtt_keepalive_conf = | |
5399 | strtol(argv[idx_count + 1]->arg, NULL, 10); | |
5400 | ||
5401 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5402 | PEER_FLAG_RTT_SHUTDOWN); | |
5403 | } | |
5404 | ||
5405 | DEFUN(no_neighbor_shutdown_rtt, | |
5406 | no_neighbor_shutdown_rtt_cmd, | |
5407 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]", | |
5408 | NO_STR | |
5409 | NEIGHBOR_STR | |
5410 | NEIGHBOR_ADDR_STR2 | |
5411 | "Administratively shut down this neighbor\n" | |
5412 | "Shutdown if round-trip-time is higher than expected\n" | |
5413 | "Round-trip-time in milliseconds\n" | |
5414 | "Specify the number of keepalives before shutdown\n" | |
5415 | "The number of keepalives with higher RTT to shutdown\n") | |
5416 | { | |
5417 | int idx_peer = 2; | |
5418 | struct peer *peer; | |
5419 | ||
5420 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5421 | ||
5422 | if (!peer) | |
5423 | return CMD_WARNING_CONFIG_FAILED; | |
5424 | ||
5425 | peer->rtt_expected = 0; | |
5426 | peer->rtt_keepalive_conf = 1; | |
5427 | ||
5428 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5429 | PEER_FLAG_RTT_SHUTDOWN); | |
5430 | } | |
5431 | ||
718e3744 | 5432 | /* neighbor capability dynamic. */ |
28c6e247 IR |
5433 | DEFUN (neighbor_capability_dynamic, |
5434 | neighbor_capability_dynamic_cmd, | |
5435 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5436 | NEIGHBOR_STR | |
5437 | NEIGHBOR_ADDR_STR2 | |
5438 | "Advertise capability to the peer\n" | |
5439 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5440 | { |
d62a17ae | 5441 | int idx_peer = 1; |
28c6e247 IR |
5442 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
5443 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 5444 | } |
5445 | ||
28c6e247 IR |
5446 | DEFUN (no_neighbor_capability_dynamic, |
5447 | no_neighbor_capability_dynamic_cmd, | |
5448 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5449 | NO_STR | |
5450 | NEIGHBOR_STR | |
5451 | NEIGHBOR_ADDR_STR2 | |
5452 | "Advertise capability to the peer\n" | |
5453 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5454 | { |
d62a17ae | 5455 | int idx_peer = 2; |
28c6e247 IR |
5456 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
5457 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 5458 | } |
6b0655a2 | 5459 | |
718e3744 | 5460 | /* neighbor dont-capability-negotiate */ |
5461 | DEFUN (neighbor_dont_capability_negotiate, | |
5462 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5463 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5464 | NEIGHBOR_STR |
5465 | NEIGHBOR_ADDR_STR2 | |
5466 | "Do not perform capability negotiation\n") | |
5467 | { | |
d62a17ae | 5468 | int idx_peer = 1; |
5469 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5470 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 5471 | } |
5472 | ||
5473 | DEFUN (no_neighbor_dont_capability_negotiate, | |
5474 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5475 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5476 | NO_STR |
5477 | NEIGHBOR_STR | |
5478 | NEIGHBOR_ADDR_STR2 | |
5479 | "Do not perform capability negotiation\n") | |
5480 | { | |
28c6e247 IR |
5481 | int idx_peer = 2; |
5482 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5483 | PEER_FLAG_DONT_CAPABILITY); | |
f4b8ec07 CS |
5484 | } |
5485 | ||
28c6e247 IR |
5486 | /* neighbor capability extended next hop encoding */ |
5487 | DEFUN (neighbor_capability_enhe, | |
5488 | neighbor_capability_enhe_cmd, | |
5489 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5490 | NEIGHBOR_STR | |
5491 | NEIGHBOR_ADDR_STR2 | |
5492 | "Advertise capability to the peer\n" | |
5493 | "Advertise extended next-hop capability to the peer\n") | |
f4b8ec07 | 5494 | { |
28c6e247 | 5495 | int idx_peer = 1; |
c4786405 DS |
5496 | struct peer *peer; |
5497 | ||
5498 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5499 | if (peer && peer->conf_if) | |
5500 | return CMD_SUCCESS; | |
5501 | ||
28c6e247 IR |
5502 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
5503 | PEER_FLAG_CAPABILITY_ENHE); | |
5504 | } | |
f4b8ec07 | 5505 | |
28c6e247 IR |
5506 | DEFUN (no_neighbor_capability_enhe, |
5507 | no_neighbor_capability_enhe_cmd, | |
5508 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5509 | NO_STR | |
5510 | NEIGHBOR_STR | |
5511 | NEIGHBOR_ADDR_STR2 | |
5512 | "Advertise capability to the peer\n" | |
5513 | "Advertise extended next-hop capability to the peer\n") | |
5514 | { | |
5515 | int idx_peer = 2; | |
c4786405 DS |
5516 | struct peer *peer; |
5517 | ||
5518 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5519 | if (peer && peer->conf_if) { | |
5520 | vty_out(vty, | |
5521 | "Peer %s cannot have capability extended-nexthop turned off\n", | |
5522 | argv[idx_peer]->arg); | |
5523 | return CMD_WARNING_CONFIG_FAILED; | |
5524 | } | |
5525 | ||
28c6e247 IR |
5526 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
5527 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
5528 | } |
5529 | ||
d62a17ae | 5530 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5531 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 5532 | int set) |
718e3744 | 5533 | { |
d62a17ae | 5534 | int ret; |
5535 | struct peer *peer; | |
718e3744 | 5536 | |
d62a17ae | 5537 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5538 | if (!peer) | |
5539 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5540 | |
d62a17ae | 5541 | if (set) |
5542 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
5543 | else | |
5544 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 5545 | |
d62a17ae | 5546 | return bgp_vty_return(vty, ret); |
718e3744 | 5547 | } |
5548 | ||
d62a17ae | 5549 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5550 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5551 | { |
d62a17ae | 5552 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 5553 | } |
5554 | ||
d62a17ae | 5555 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5556 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5557 | { |
d62a17ae | 5558 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 5559 | } |
6b0655a2 | 5560 | |
718e3744 | 5561 | /* neighbor capability orf prefix-list. */ |
5562 | DEFUN (neighbor_capability_orf_prefix, | |
5563 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5564 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5565 | NEIGHBOR_STR |
5566 | NEIGHBOR_ADDR_STR2 | |
5567 | "Advertise capability to the peer\n" | |
5568 | "Advertise ORF capability to the peer\n" | |
5569 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5570 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5571 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5572 | "Capability to SEND the ORF to this neighbor\n") | |
5573 | { | |
d62a17ae | 5574 | int idx_send_recv = 5; |
db45f64d DS |
5575 | char *peer_str = argv[1]->arg; |
5576 | struct peer *peer; | |
5577 | afi_t afi = bgp_node_afi(vty); | |
5578 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5579 | |
db45f64d DS |
5580 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5581 | if (!peer) | |
d62a17ae | 5582 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5583 | |
db45f64d DS |
5584 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5585 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5586 | PEER_FLAG_ORF_PREFIX_SM); | |
5587 | ||
5588 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5589 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5590 | PEER_FLAG_ORF_PREFIX_RM); | |
5591 | ||
5592 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5593 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5594 | PEER_FLAG_ORF_PREFIX_SM) | |
5595 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5596 | PEER_FLAG_ORF_PREFIX_RM); | |
5597 | ||
5598 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5599 | } |
5600 | ||
5601 | ALIAS_HIDDEN( | |
5602 | neighbor_capability_orf_prefix, | |
5603 | neighbor_capability_orf_prefix_hidden_cmd, | |
5604 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5605 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5606 | "Advertise capability to the peer\n" | |
5607 | "Advertise ORF capability to the peer\n" | |
5608 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5609 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5610 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5611 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5612 | |
718e3744 | 5613 | DEFUN (no_neighbor_capability_orf_prefix, |
5614 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5615 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5616 | NO_STR |
5617 | NEIGHBOR_STR | |
5618 | NEIGHBOR_ADDR_STR2 | |
5619 | "Advertise capability to the peer\n" | |
5620 | "Advertise ORF capability to the peer\n" | |
5621 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5622 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5623 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5624 | "Capability to SEND the ORF to this neighbor\n") | |
5625 | { | |
d62a17ae | 5626 | int idx_send_recv = 6; |
db45f64d DS |
5627 | char *peer_str = argv[2]->arg; |
5628 | struct peer *peer; | |
5629 | afi_t afi = bgp_node_afi(vty); | |
5630 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5631 | |
db45f64d DS |
5632 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5633 | if (!peer) | |
d62a17ae | 5634 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5635 | |
db45f64d DS |
5636 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5637 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5638 | PEER_FLAG_ORF_PREFIX_SM); | |
5639 | ||
5640 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5641 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5642 | PEER_FLAG_ORF_PREFIX_RM); | |
5643 | ||
5644 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5645 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5646 | PEER_FLAG_ORF_PREFIX_SM) | |
5647 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5648 | PEER_FLAG_ORF_PREFIX_RM); | |
5649 | ||
5650 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5651 | } |
5652 | ||
5653 | ALIAS_HIDDEN( | |
5654 | no_neighbor_capability_orf_prefix, | |
5655 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
5656 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5657 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5658 | "Advertise capability to the peer\n" | |
5659 | "Advertise ORF capability to the peer\n" | |
5660 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5661 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5662 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5663 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5664 | |
718e3744 | 5665 | /* neighbor next-hop-self. */ |
28c6e247 IR |
5666 | DEFUN (neighbor_nexthop_self, |
5667 | neighbor_nexthop_self_cmd, | |
5668 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5669 | NEIGHBOR_STR | |
5670 | NEIGHBOR_ADDR_STR2 | |
5671 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5672 | { |
d62a17ae | 5673 | int idx_peer = 1; |
28c6e247 IR |
5674 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5675 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 5676 | } |
9e7a53c1 | 5677 | |
d62a17ae | 5678 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
5679 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5680 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5681 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5682 | |
f4b8ec07 | 5683 | /* neighbor next-hop-self. */ |
28c6e247 IR |
5684 | DEFUN (neighbor_nexthop_self_force, |
5685 | neighbor_nexthop_self_force_cmd, | |
5686 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5687 | NEIGHBOR_STR | |
5688 | NEIGHBOR_ADDR_STR2 | |
5689 | "Disable the next hop calculation for this neighbor\n" | |
5690 | "Set the next hop to self for reflected routes\n") | |
f4b8ec07 CS |
5691 | { |
5692 | int idx_peer = 1; | |
28c6e247 IR |
5693 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5694 | bgp_node_safi(vty), | |
5695 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 5696 | } |
5697 | ||
d62a17ae | 5698 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5699 | neighbor_nexthop_self_force_hidden_cmd, | |
5700 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5701 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5702 | "Disable the next hop calculation for this neighbor\n" | |
5703 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5704 | |
1bc4e531 DA |
5705 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5706 | neighbor_nexthop_self_all_hidden_cmd, | |
5707 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5708 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5709 | "Disable the next hop calculation for this neighbor\n" | |
5710 | "Set the next hop to self for reflected routes\n") | |
5711 | ||
28c6e247 IR |
5712 | DEFUN (no_neighbor_nexthop_self, |
5713 | no_neighbor_nexthop_self_cmd, | |
5714 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5715 | NO_STR | |
5716 | NEIGHBOR_STR | |
5717 | NEIGHBOR_ADDR_STR2 | |
5718 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5719 | { |
d62a17ae | 5720 | int idx_peer = 2; |
28c6e247 IR |
5721 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5722 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5723 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 5724 | } |
6b0655a2 | 5725 | |
d62a17ae | 5726 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
5727 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5728 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5729 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5730 | |
28c6e247 IR |
5731 | DEFUN (no_neighbor_nexthop_self_force, |
5732 | no_neighbor_nexthop_self_force_cmd, | |
5733 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5734 | NO_STR | |
5735 | NEIGHBOR_STR | |
5736 | NEIGHBOR_ADDR_STR2 | |
5737 | "Disable the next hop calculation for this neighbor\n" | |
5738 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 5739 | { |
d62a17ae | 5740 | int idx_peer = 2; |
28c6e247 IR |
5741 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5742 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5743 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 5744 | } |
a538debe | 5745 | |
d62a17ae | 5746 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5747 | no_neighbor_nexthop_self_force_hidden_cmd, | |
5748 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5749 | NO_STR 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") | |
596c17ba | 5752 | |
1bc4e531 DA |
5753 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5754 | no_neighbor_nexthop_self_all_hidden_cmd, | |
5755 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5756 | NO_STR 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") | |
5759 | ||
c7122e14 | 5760 | /* neighbor as-override */ |
28c6e247 IR |
5761 | DEFUN (neighbor_as_override, |
5762 | neighbor_as_override_cmd, | |
5763 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5764 | NEIGHBOR_STR | |
5765 | NEIGHBOR_ADDR_STR2 | |
5766 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5767 | { |
d62a17ae | 5768 | int idx_peer = 1; |
28c6e247 IR |
5769 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5770 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
5771 | } |
5772 | ||
d62a17ae | 5773 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
5774 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5775 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5776 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5777 | |
28c6e247 IR |
5778 | DEFUN (no_neighbor_as_override, |
5779 | no_neighbor_as_override_cmd, | |
5780 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5781 | NO_STR | |
5782 | NEIGHBOR_STR | |
5783 | NEIGHBOR_ADDR_STR2 | |
5784 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5785 | { |
d62a17ae | 5786 | int idx_peer = 2; |
28c6e247 IR |
5787 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5788 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5789 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
5790 | } |
5791 | ||
d62a17ae | 5792 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
5793 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5794 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5795 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5796 | |
718e3744 | 5797 | /* neighbor remove-private-AS. */ |
28c6e247 IR |
5798 | DEFUN (neighbor_remove_private_as, |
5799 | neighbor_remove_private_as_cmd, | |
5800 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5801 | NEIGHBOR_STR | |
5802 | NEIGHBOR_ADDR_STR2 | |
5803 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 5804 | { |
d62a17ae | 5805 | int idx_peer = 1; |
28c6e247 IR |
5806 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5807 | bgp_node_safi(vty), | |
5808 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 5809 | } |
5810 | ||
d62a17ae | 5811 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
5812 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5813 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5814 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5815 | |
28c6e247 IR |
5816 | DEFUN (neighbor_remove_private_as_all, |
5817 | neighbor_remove_private_as_all_cmd, | |
5818 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5819 | NEIGHBOR_STR | |
5820 | NEIGHBOR_ADDR_STR2 | |
5821 | "Remove private ASNs in outbound updates\n" | |
5822 | "Apply to all AS numbers\n") | |
5000f21c | 5823 | { |
d62a17ae | 5824 | int idx_peer = 1; |
28c6e247 IR |
5825 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5826 | bgp_node_safi(vty), | |
5827 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
5828 | } |
5829 | ||
d62a17ae | 5830 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
5831 | neighbor_remove_private_as_all_hidden_cmd, | |
5832 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5833 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5834 | "Remove private ASNs in outbound updates\n" | |
a0dfca37 | 5835 | "Apply to all AS numbers\n") |
596c17ba | 5836 | |
28c6e247 IR |
5837 | DEFUN (neighbor_remove_private_as_replace_as, |
5838 | neighbor_remove_private_as_replace_as_cmd, | |
5839 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5840 | NEIGHBOR_STR | |
5841 | NEIGHBOR_ADDR_STR2 | |
5842 | "Remove private ASNs in outbound updates\n" | |
5843 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 5844 | { |
d62a17ae | 5845 | int idx_peer = 1; |
28c6e247 IR |
5846 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5847 | bgp_node_safi(vty), | |
5848 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
5849 | } |
5850 | ||
d62a17ae | 5851 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
5852 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
5853 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5854 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5855 | "Remove private ASNs in outbound updates\n" | |
5856 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5857 | |
28c6e247 IR |
5858 | DEFUN (neighbor_remove_private_as_all_replace_as, |
5859 | neighbor_remove_private_as_all_replace_as_cmd, | |
5860 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5861 | NEIGHBOR_STR | |
5862 | NEIGHBOR_ADDR_STR2 | |
5863 | "Remove private ASNs in outbound updates\n" | |
5864 | "Apply to all AS numbers\n" | |
5865 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 5866 | { |
d62a17ae | 5867 | int idx_peer = 1; |
28c6e247 IR |
5868 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5869 | bgp_node_safi(vty), | |
5870 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
5871 | } |
5872 | ||
d62a17ae | 5873 | ALIAS_HIDDEN( |
5874 | neighbor_remove_private_as_all_replace_as, | |
5875 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5876 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5877 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5878 | "Remove private ASNs in outbound updates\n" | |
5879 | "Apply to all AS numbers\n" | |
5880 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5881 | |
28c6e247 IR |
5882 | DEFUN (no_neighbor_remove_private_as, |
5883 | no_neighbor_remove_private_as_cmd, | |
5884 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5885 | NO_STR | |
5886 | NEIGHBOR_STR | |
5887 | NEIGHBOR_ADDR_STR2 | |
5888 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 5889 | { |
d62a17ae | 5890 | int idx_peer = 2; |
28c6e247 IR |
5891 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5892 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5893 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 5894 | } |
6b0655a2 | 5895 | |
d62a17ae | 5896 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
5897 | no_neighbor_remove_private_as_hidden_cmd, | |
5898 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5899 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5900 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5901 | |
28c6e247 IR |
5902 | DEFUN (no_neighbor_remove_private_as_all, |
5903 | no_neighbor_remove_private_as_all_cmd, | |
5904 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5905 | NO_STR | |
5906 | NEIGHBOR_STR | |
5907 | NEIGHBOR_ADDR_STR2 | |
5908 | "Remove private ASNs in outbound updates\n" | |
5909 | "Apply to all AS numbers\n") | |
88b8ed8d | 5910 | { |
d62a17ae | 5911 | int idx_peer = 2; |
28c6e247 IR |
5912 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5913 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5914 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 5915 | } |
5000f21c | 5916 | |
d62a17ae | 5917 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
5918 | no_neighbor_remove_private_as_all_hidden_cmd, | |
5919 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5920 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5921 | "Remove private ASNs in outbound updates\n" | |
5922 | "Apply to all AS numbers\n") | |
596c17ba | 5923 | |
28c6e247 IR |
5924 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5925 | no_neighbor_remove_private_as_replace_as_cmd, | |
5926 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5927 | NO_STR | |
5928 | NEIGHBOR_STR | |
5929 | NEIGHBOR_ADDR_STR2 | |
5930 | "Remove private ASNs in outbound updates\n" | |
5931 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 5932 | { |
d62a17ae | 5933 | int idx_peer = 2; |
28c6e247 IR |
5934 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5935 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5936 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 5937 | } |
5000f21c | 5938 | |
d62a17ae | 5939 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
5940 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
5941 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5942 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5943 | "Remove private ASNs in outbound updates\n" | |
5944 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5945 | |
28c6e247 IR |
5946 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5947 | no_neighbor_remove_private_as_all_replace_as_cmd, | |
5948 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5949 | NO_STR | |
5950 | NEIGHBOR_STR | |
5951 | NEIGHBOR_ADDR_STR2 | |
5952 | "Remove private ASNs in outbound updates\n" | |
5953 | "Apply to all AS numbers\n" | |
5954 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 5955 | { |
d62a17ae | 5956 | int idx_peer = 2; |
28c6e247 IR |
5957 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5958 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5959 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 5960 | } |
5000f21c | 5961 | |
d62a17ae | 5962 | ALIAS_HIDDEN( |
5963 | no_neighbor_remove_private_as_all_replace_as, | |
5964 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5965 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5966 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5967 | "Remove private ASNs in outbound updates\n" | |
5968 | "Apply to all AS numbers\n" | |
5969 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5970 | |
5000f21c | 5971 | |
718e3744 | 5972 | /* neighbor send-community. */ |
28c6e247 IR |
5973 | DEFUN (neighbor_send_community, |
5974 | neighbor_send_community_cmd, | |
5975 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5976 | NEIGHBOR_STR | |
5977 | NEIGHBOR_ADDR_STR2 | |
5978 | "Send Community attribute to this neighbor\n") | |
718e3744 | 5979 | { |
d62a17ae | 5980 | int idx_peer = 1; |
27c05d4d | 5981 | |
f63d4054 IR |
5982 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5983 | bgp_node_safi(vty), | |
5984 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 5985 | } |
5986 | ||
d62a17ae | 5987 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
5988 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5989 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5990 | "Send Community attribute to this neighbor\n") | |
596c17ba | 5991 | |
28c6e247 IR |
5992 | DEFUN (no_neighbor_send_community, |
5993 | no_neighbor_send_community_cmd, | |
5994 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5995 | NO_STR | |
5996 | NEIGHBOR_STR | |
5997 | NEIGHBOR_ADDR_STR2 | |
5998 | "Send Community attribute to this neighbor\n") | |
718e3744 | 5999 | { |
d62a17ae | 6000 | int idx_peer = 2; |
27c05d4d | 6001 | |
f63d4054 IR |
6002 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
6003 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6004 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 6005 | } |
6b0655a2 | 6006 | |
d62a17ae | 6007 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
6008 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6009 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6010 | "Send Community attribute to this neighbor\n") | |
596c17ba | 6011 | |
718e3744 | 6012 | /* neighbor send-community extended. */ |
28c6e247 IR |
6013 | DEFUN (neighbor_send_community_type, |
6014 | neighbor_send_community_type_cmd, | |
6015 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6016 | NEIGHBOR_STR | |
6017 | NEIGHBOR_ADDR_STR2 | |
6018 | "Send Community attribute to this neighbor\n" | |
6019 | "Send Standard and Extended Community attributes\n" | |
6020 | "Send Standard, Large and Extended Community attributes\n" | |
6021 | "Send Extended Community attributes\n" | |
6022 | "Send Standard Community attributes\n" | |
6023 | "Send Large Community attributes\n") | |
718e3744 | 6024 | { |
27c05d4d | 6025 | const char *type = argv[argc - 1]->text; |
db45f64d | 6026 | char *peer_str = argv[1]->arg; |
28c6e247 | 6027 | struct peer *peer; |
db45f64d | 6028 | afi_t afi = bgp_node_afi(vty); |
28c6e247 | 6029 | safi_t safi = bgp_node_safi(vty); |
f4b8ec07 | 6030 | |
28c6e247 IR |
6031 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6032 | if (!peer) | |
6033 | return CMD_WARNING_CONFIG_FAILED; | |
f4b8ec07 | 6034 | |
28c6e247 IR |
6035 | if (strmatch(type, "standard")) |
6036 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6037 | PEER_FLAG_SEND_COMMUNITY); | |
f4b8ec07 | 6038 | |
28c6e247 IR |
6039 | if (strmatch(type, "extended")) |
6040 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6041 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 6042 | |
28c6e247 IR |
6043 | if (strmatch(type, "large")) |
6044 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6045 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
f4b8ec07 | 6046 | |
28c6e247 IR |
6047 | if (strmatch(type, "both")) { |
6048 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6049 | PEER_FLAG_SEND_COMMUNITY) | |
6050 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6051 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 6052 | } |
28c6e247 IR |
6053 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, |
6054 | PEER_FLAG_SEND_COMMUNITY) | |
6055 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6056 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
6057 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6058 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 6059 | } |
6060 | ||
6061 | ALIAS_HIDDEN( | |
6062 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
6063 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6064 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6065 | "Send Community attribute to this neighbor\n" | |
6066 | "Send Standard and Extended Community attributes\n" | |
6067 | "Send Standard, Large and Extended Community attributes\n" | |
6068 | "Send Extended Community attributes\n" | |
6069 | "Send Standard Community attributes\n" | |
6070 | "Send Large Community attributes\n") | |
596c17ba | 6071 | |
28c6e247 IR |
6072 | DEFUN (no_neighbor_send_community_type, |
6073 | no_neighbor_send_community_type_cmd, | |
6074 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6075 | NO_STR | |
6076 | NEIGHBOR_STR | |
6077 | NEIGHBOR_ADDR_STR2 | |
6078 | "Send Community attribute to this neighbor\n" | |
6079 | "Send Standard and Extended Community attributes\n" | |
6080 | "Send Standard, Large and Extended Community attributes\n" | |
6081 | "Send Extended Community attributes\n" | |
6082 | "Send Standard Community attributes\n" | |
6083 | "Send Large Community attributes\n") | |
718e3744 | 6084 | { |
d62a17ae | 6085 | const char *type = argv[argc - 1]->text; |
db45f64d | 6086 | char *peer_str = argv[2]->arg; |
28c6e247 | 6087 | struct peer *peer; |
db45f64d DS |
6088 | afi_t afi = bgp_node_afi(vty); |
6089 | safi_t safi = bgp_node_safi(vty); | |
6090 | ||
28c6e247 IR |
6091 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6092 | if (!peer) | |
f4b8ec07 CS |
6093 | return CMD_WARNING_CONFIG_FAILED; |
6094 | ||
28c6e247 IR |
6095 | if (strmatch(type, "standard")) |
6096 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6097 | PEER_FLAG_SEND_COMMUNITY); | |
f4b8ec07 | 6098 | |
28c6e247 IR |
6099 | if (strmatch(type, "extended")) |
6100 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6101 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 6102 | |
28c6e247 IR |
6103 | if (strmatch(type, "large")) |
6104 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6105 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
f4b8ec07 CS |
6106 | |
6107 | if (strmatch(type, "both")) { | |
db45f64d | 6108 | |
28c6e247 IR |
6109 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6110 | PEER_FLAG_SEND_COMMUNITY) | |
6111 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6112 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d PM |
6113 | } |
6114 | ||
28c6e247 IR |
6115 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6116 | PEER_FLAG_SEND_COMMUNITY) | |
6117 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6118 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
6119 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6120 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 6121 | } |
6122 | ||
6123 | ALIAS_HIDDEN( | |
6124 | no_neighbor_send_community_type, | |
6125 | no_neighbor_send_community_type_hidden_cmd, | |
6126 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6127 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6128 | "Send Community attribute to this neighbor\n" | |
6129 | "Send Standard and Extended Community attributes\n" | |
6130 | "Send Standard, Large and Extended Community attributes\n" | |
6131 | "Send Extended Community attributes\n" | |
6132 | "Send Standard Community attributes\n" | |
6133 | "Send Large Community attributes\n") | |
596c17ba | 6134 | |
718e3744 | 6135 | /* neighbor soft-reconfig. */ |
28c6e247 IR |
6136 | DEFUN (neighbor_soft_reconfiguration, |
6137 | neighbor_soft_reconfiguration_cmd, | |
6138 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6139 | NEIGHBOR_STR | |
6140 | NEIGHBOR_ADDR_STR2 | |
6141 | "Per neighbor soft reconfiguration\n" | |
6142 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 6143 | { |
d62a17ae | 6144 | int idx_peer = 1; |
28c6e247 IR |
6145 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6146 | bgp_node_safi(vty), | |
6147 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 6148 | } |
6149 | ||
d62a17ae | 6150 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
6151 | neighbor_soft_reconfiguration_hidden_cmd, | |
6152 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6153 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6154 | "Per neighbor soft reconfiguration\n" | |
6155 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 6156 | |
28c6e247 IR |
6157 | DEFUN (no_neighbor_soft_reconfiguration, |
6158 | no_neighbor_soft_reconfiguration_cmd, | |
6159 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6160 | NO_STR | |
6161 | NEIGHBOR_STR | |
6162 | NEIGHBOR_ADDR_STR2 | |
6163 | "Per neighbor soft reconfiguration\n" | |
6164 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 6165 | { |
d62a17ae | 6166 | int idx_peer = 2; |
28c6e247 IR |
6167 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
6168 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6169 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 6170 | } |
6b0655a2 | 6171 | |
d62a17ae | 6172 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
6173 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
6174 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6175 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6176 | "Per neighbor soft reconfiguration\n" | |
6177 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 6178 | |
28c6e247 IR |
6179 | DEFUN (neighbor_route_reflector_client, |
6180 | neighbor_route_reflector_client_cmd, | |
6181 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6182 | NEIGHBOR_STR | |
6183 | NEIGHBOR_ADDR_STR2 | |
6184 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 6185 | { |
d62a17ae | 6186 | int idx_peer = 1; |
28c6e247 | 6187 | struct peer *peer; |
718e3744 | 6188 | |
6189 | ||
28c6e247 IR |
6190 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6191 | if (!peer) | |
d62a17ae | 6192 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6193 | |
28c6e247 IR |
6194 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6195 | bgp_node_safi(vty), | |
6196 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 6197 | } |
6198 | ||
d62a17ae | 6199 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
6200 | neighbor_route_reflector_client_hidden_cmd, | |
6201 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6202 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6203 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 6204 | |
28c6e247 IR |
6205 | DEFUN (no_neighbor_route_reflector_client, |
6206 | no_neighbor_route_reflector_client_cmd, | |
6207 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6208 | NO_STR | |
6209 | NEIGHBOR_STR | |
6210 | NEIGHBOR_ADDR_STR2 | |
6211 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 6212 | { |
d62a17ae | 6213 | int idx_peer = 2; |
28c6e247 IR |
6214 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
6215 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6216 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 6217 | } |
6b0655a2 | 6218 | |
d62a17ae | 6219 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
6220 | no_neighbor_route_reflector_client_hidden_cmd, | |
6221 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6222 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6223 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 6224 | |
70cd87ca MK |
6225 | /* optimal-route-reflection Root Routers configuration */ |
6226 | DEFPY (optimal_route_reflection, | |
6227 | optimal_route_reflection_cmd, | |
6228 | "[no$no] optimal-route-reflection WORD$orr_group [<A.B.C.D|X:X::X:X>$primary [<A.B.C.D|X:X::X:X>$secondary [<A.B.C.D|X:X::X:X>$tertiary]]]", | |
6229 | NO_STR | |
6230 | "Create ORR group and assign root router(s)\n" | |
6231 | "ORR Group name\n" | |
6232 | "Primary Root address\n" | |
6233 | "Primary Root IPv6 address\n" | |
6234 | "Secondary Root address\n" | |
6235 | "Secondary Root IPv6 address\n" | |
6236 | "Tertiary Root address\n" | |
6237 | "Tertiary Root IPv6 address\n") | |
6238 | { | |
6239 | if (!no && !primary) { | |
6240 | vty_out(vty, "%% Specify Primary Root address\n"); | |
6241 | return CMD_WARNING_CONFIG_FAILED; | |
6242 | } | |
6243 | return bgp_afi_safi_orr_group_set_vty( | |
6244 | vty, bgp_node_afi(vty), bgp_node_safi(vty), orr_group, | |
80f6ea8b | 6245 | primary_str, secondary_str, tertiary_str, !!no); |
70cd87ca MK |
6246 | } |
6247 | ||
6248 | /* neighbor optimal-route-reflection group*/ | |
6249 | DEFPY (neighbor_optimal_route_reflection, | |
6250 | neighbor_optimal_route_reflection_cmd, | |
6251 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor optimal-route-reflection WORD$orr_group", | |
6252 | NO_STR | |
6253 | NEIGHBOR_STR | |
6254 | NEIGHBOR_ADDR_STR2 | |
6255 | "Apply ORR group configuration to the neighbor\n" | |
6256 | "ORR group name\n") | |
6257 | { | |
6258 | return peer_orr_group_set_vty(vty, neighbor, bgp_node_afi(vty), | |
80f6ea8b | 6259 | bgp_node_safi(vty), orr_group, !!no); |
70cd87ca MK |
6260 | } |
6261 | ||
718e3744 | 6262 | /* neighbor route-server-client. */ |
28c6e247 IR |
6263 | DEFUN (neighbor_route_server_client, |
6264 | neighbor_route_server_client_cmd, | |
6265 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6266 | NEIGHBOR_STR | |
6267 | NEIGHBOR_ADDR_STR2 | |
6268 | "Configure a neighbor as Route Server client\n") | |
718e3744 | 6269 | { |
d62a17ae | 6270 | int idx_peer = 1; |
28c6e247 | 6271 | struct peer *peer; |
f4b8ec07 | 6272 | |
28c6e247 IR |
6273 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6274 | if (!peer) | |
d62a17ae | 6275 | return CMD_WARNING_CONFIG_FAILED; |
28c6e247 IR |
6276 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6277 | bgp_node_safi(vty), | |
6278 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 6279 | } |
6280 | ||
d62a17ae | 6281 | ALIAS_HIDDEN(neighbor_route_server_client, |
6282 | neighbor_route_server_client_hidden_cmd, | |
6283 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6284 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6285 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 6286 | |
28c6e247 IR |
6287 | DEFUN (no_neighbor_route_server_client, |
6288 | no_neighbor_route_server_client_cmd, | |
6289 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6290 | NO_STR | |
6291 | NEIGHBOR_STR | |
6292 | NEIGHBOR_ADDR_STR2 | |
6293 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 6294 | { |
d62a17ae | 6295 | int idx_peer = 2; |
28c6e247 IR |
6296 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
6297 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6298 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 6299 | } |
6b0655a2 | 6300 | |
d62a17ae | 6301 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
6302 | no_neighbor_route_server_client_hidden_cmd, | |
6303 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6304 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6305 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 6306 | |
fee0f4c6 | 6307 | DEFUN (neighbor_nexthop_local_unchanged, |
6308 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 6309 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 6310 | NEIGHBOR_STR |
6311 | NEIGHBOR_ADDR_STR2 | |
6312 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
6313 | "Leave link-local nexthop unchanged for this peer\n") | |
6314 | { | |
d62a17ae | 6315 | int idx_peer = 1; |
6316 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6317 | bgp_node_safi(vty), | |
6318 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 6319 | } |
6b0655a2 | 6320 | |
fee0f4c6 | 6321 | DEFUN (no_neighbor_nexthop_local_unchanged, |
6322 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 6323 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 6324 | NO_STR |
6325 | NEIGHBOR_STR | |
6326 | NEIGHBOR_ADDR_STR2 | |
6327 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
6328 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 6329 | { |
d62a17ae | 6330 | int idx_peer = 2; |
6331 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6332 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6333 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 6334 | } |
6b0655a2 | 6335 | |
28c6e247 IR |
6336 | DEFUN (neighbor_attr_unchanged, |
6337 | neighbor_attr_unchanged_cmd, | |
6338 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6339 | NEIGHBOR_STR | |
6340 | NEIGHBOR_ADDR_STR2 | |
6341 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6342 | "As-path attribute\n" | |
6343 | "Nexthop attribute\n" | |
6344 | "Med attribute\n") | |
718e3744 | 6345 | { |
d62a17ae | 6346 | int idx = 0; |
8eeb0335 | 6347 | char *peer_str = argv[1]->arg; |
28c6e247 | 6348 | struct peer *peer; |
db45f64d DS |
6349 | bool aspath = false; |
6350 | bool nexthop = false; | |
6351 | bool med = false; | |
8eeb0335 DW |
6352 | afi_t afi = bgp_node_afi(vty); |
6353 | safi_t safi = bgp_node_safi(vty); | |
28c6e247 | 6354 | int ret = 0; |
f4b8ec07 | 6355 | |
28c6e247 IR |
6356 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6357 | if (!peer) | |
8eeb0335 | 6358 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6359 | |
6360 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6361 | aspath = true; |
6362 | ||
d62a17ae | 6363 | idx = 0; |
6364 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6365 | nexthop = true; |
6366 | ||
d62a17ae | 6367 | idx = 0; |
6368 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6369 | med = true; |
d62a17ae | 6370 | |
8eeb0335 | 6371 | /* no flags means all of them! */ |
db45f64d | 6372 | if (!aspath && !nexthop && !med) { |
28c6e247 IR |
6373 | ret = peer_af_flag_set_vty(vty, peer_str, afi, safi, |
6374 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6375 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6376 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6377 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6378 | PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 6379 | } else { |
28c6e247 IR |
6380 | if (!aspath) { |
6381 | if (peer_af_flag_check(peer, afi, safi, | |
6382 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
6383 | ret |= peer_af_flag_unset_vty( | |
6384 | vty, peer_str, afi, safi, | |
6385 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6386 | } | |
6387 | } else | |
6388 | ret |= peer_af_flag_set_vty( | |
6389 | vty, peer_str, afi, safi, | |
6390 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6391 | ||
6392 | if (!nexthop) { | |
6393 | if (peer_af_flag_check(peer, afi, safi, | |
6394 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
6395 | ret |= peer_af_flag_unset_vty( | |
6396 | vty, peer_str, afi, safi, | |
6397 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6398 | } | |
6399 | } else | |
6400 | ret |= peer_af_flag_set_vty( | |
6401 | vty, peer_str, afi, safi, | |
6402 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6403 | ||
6404 | if (!med) { | |
6405 | if (peer_af_flag_check(peer, afi, safi, | |
6406 | PEER_FLAG_MED_UNCHANGED)) { | |
6407 | ret |= peer_af_flag_unset_vty( | |
6408 | vty, peer_str, afi, safi, | |
6409 | PEER_FLAG_MED_UNCHANGED); | |
6410 | } | |
6411 | } else | |
6412 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6413 | PEER_FLAG_MED_UNCHANGED); | |
d62a17ae | 6414 | } |
6415 | ||
28c6e247 | 6416 | return ret; |
d62a17ae | 6417 | } |
6418 | ||
6419 | ALIAS_HIDDEN( | |
6420 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
6421 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6422 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6423 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6424 | "As-path attribute\n" | |
6425 | "Nexthop attribute\n" | |
6426 | "Med attribute\n") | |
596c17ba | 6427 | |
28c6e247 IR |
6428 | DEFUN (no_neighbor_attr_unchanged, |
6429 | no_neighbor_attr_unchanged_cmd, | |
6430 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6431 | NO_STR | |
6432 | NEIGHBOR_STR | |
6433 | NEIGHBOR_ADDR_STR2 | |
6434 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6435 | "As-path attribute\n" | |
6436 | "Nexthop attribute\n" | |
6437 | "Med attribute\n") | |
718e3744 | 6438 | { |
d62a17ae | 6439 | int idx = 0; |
db45f64d | 6440 | char *peer_str = argv[2]->arg; |
28c6e247 | 6441 | struct peer *peer; |
db45f64d DS |
6442 | bool aspath = false; |
6443 | bool nexthop = false; | |
6444 | bool med = false; | |
6445 | afi_t afi = bgp_node_afi(vty); | |
6446 | safi_t safi = bgp_node_safi(vty); | |
28c6e247 | 6447 | int ret = 0; |
f4b8ec07 | 6448 | |
28c6e247 IR |
6449 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6450 | if (!peer) | |
db45f64d | 6451 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6452 | |
6453 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6454 | aspath = true; |
6455 | ||
d62a17ae | 6456 | idx = 0; |
6457 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6458 | nexthop = true; |
6459 | ||
d62a17ae | 6460 | idx = 0; |
6461 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6462 | med = true; |
d62a17ae | 6463 | |
28c6e247 IR |
6464 | if (!aspath && !nexthop && !med) // no flags means all of them! |
6465 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6466 | PEER_FLAG_AS_PATH_UNCHANGED) | |
6467 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6468 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
6469 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6470 | PEER_FLAG_MED_UNCHANGED); | |
db45f64d DS |
6471 | |
6472 | if (aspath) | |
28c6e247 IR |
6473 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6474 | PEER_FLAG_AS_PATH_UNCHANGED); | |
db45f64d DS |
6475 | |
6476 | if (nexthop) | |
28c6e247 IR |
6477 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6478 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
d62a17ae | 6479 | |
db45f64d | 6480 | if (med) |
28c6e247 IR |
6481 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6482 | PEER_FLAG_MED_UNCHANGED); | |
db45f64d | 6483 | |
28c6e247 | 6484 | return ret; |
d62a17ae | 6485 | } |
6486 | ||
6487 | ALIAS_HIDDEN( | |
6488 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
6489 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6490 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6491 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6492 | "As-path attribute\n" | |
6493 | "Nexthop attribute\n" | |
6494 | "Med attribute\n") | |
718e3744 | 6495 | |
28c6e247 IR |
6496 | /* EBGP multihop configuration. */ |
6497 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, | |
6498 | const char *ttl_str) | |
718e3744 | 6499 | { |
28c6e247 IR |
6500 | struct peer *peer; |
6501 | unsigned int ttl; | |
718e3744 | 6502 | |
28c6e247 IR |
6503 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6504 | if (!peer) | |
d62a17ae | 6505 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6506 | |
28c6e247 IR |
6507 | if (peer->conf_if) |
6508 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
6509 | ||
6510 | if (!ttl_str) | |
6511 | ttl = MAXTTL; | |
6512 | else | |
6513 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 6514 | |
28c6e247 | 6515 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 6516 | } |
6517 | ||
28c6e247 | 6518 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6519 | { |
28c6e247 | 6520 | struct peer *peer; |
718e3744 | 6521 | |
28c6e247 IR |
6522 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6523 | if (!peer) | |
d62a17ae | 6524 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6525 | |
28c6e247 | 6526 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 6527 | } |
6528 | ||
28c6e247 IR |
6529 | /* neighbor ebgp-multihop. */ |
6530 | DEFUN (neighbor_ebgp_multihop, | |
6531 | neighbor_ebgp_multihop_cmd, | |
6532 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", | |
6533 | NEIGHBOR_STR | |
6534 | NEIGHBOR_ADDR_STR2 | |
6535 | "Allow EBGP neighbors not on directly connected networks\n") | |
718e3744 | 6536 | { |
28c6e247 IR |
6537 | int idx_peer = 1; |
6538 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
6539 | } | |
f4b8ec07 | 6540 | |
28c6e247 IR |
6541 | DEFUN (neighbor_ebgp_multihop_ttl, |
6542 | neighbor_ebgp_multihop_ttl_cmd, | |
6543 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", | |
6544 | NEIGHBOR_STR | |
6545 | NEIGHBOR_ADDR_STR2 | |
6546 | "Allow EBGP neighbors not on directly connected networks\n" | |
6547 | "maximum hop count\n") | |
6548 | { | |
6549 | int idx_peer = 1; | |
6550 | int idx_number = 3; | |
6551 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
6552 | argv[idx_number]->arg); | |
6553 | } | |
f4b8ec07 | 6554 | |
28c6e247 IR |
6555 | DEFUN (no_neighbor_ebgp_multihop, |
6556 | no_neighbor_ebgp_multihop_cmd, | |
6557 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", | |
6558 | NO_STR | |
6559 | NEIGHBOR_STR | |
6560 | NEIGHBOR_ADDR_STR2 | |
6561 | "Allow EBGP neighbors not on directly connected networks\n" | |
6562 | "maximum hop count\n") | |
6563 | { | |
6564 | int idx_peer = 2; | |
6565 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6566 | } |
6567 | ||
97a52c82 DA |
6568 | DEFPY (neighbor_aigp, |
6569 | neighbor_aigp_cmd, | |
6570 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor aigp", | |
6571 | NO_STR | |
6572 | NEIGHBOR_STR | |
6573 | NEIGHBOR_ADDR_STR2 | |
6574 | "Enable send and receive of the AIGP attribute per neighbor\n") | |
6575 | { | |
6576 | struct peer *peer; | |
6577 | ||
6578 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
6579 | if (!peer) | |
6580 | return CMD_WARNING_CONFIG_FAILED; | |
6581 | ||
6582 | if (no) | |
6583 | return peer_flag_unset_vty(vty, neighbor, PEER_FLAG_AIGP); | |
6584 | else | |
6585 | return peer_flag_set_vty(vty, neighbor, PEER_FLAG_AIGP); | |
6586 | } | |
6587 | ||
d864dd9e EB |
6588 | static uint8_t get_role_by_name(const char *role_str) |
6589 | { | |
6590 | if (strncmp(role_str, "peer", 2) == 0) | |
6591 | return ROLE_PEER; | |
6592 | if (strncmp(role_str, "provider", 2) == 0) | |
6593 | return ROLE_PROVIDER; | |
6594 | if (strncmp(role_str, "customer", 2) == 0) | |
6595 | return ROLE_CUSTOMER; | |
6596 | if (strncmp(role_str, "rs-server", 4) == 0) | |
6597 | return ROLE_RS_SERVER; | |
6598 | if (strncmp(role_str, "rs-client", 4) == 0) | |
6599 | return ROLE_RS_CLIENT; | |
8f2d6021 | 6600 | return ROLE_UNDEFINED; |
d864dd9e EB |
6601 | } |
6602 | ||
6603 | static int peer_role_set_vty(struct vty *vty, const char *ip_str, | |
8f2d6021 | 6604 | const char *role_str, bool strict_mode) |
d864dd9e EB |
6605 | { |
6606 | struct peer *peer; | |
6607 | ||
7dddd1f7 | 6608 | peer = peer_and_group_lookup_vty(vty, ip_str); |
d864dd9e EB |
6609 | if (!peer) |
6610 | return CMD_WARNING_CONFIG_FAILED; | |
6611 | uint8_t role = get_role_by_name(role_str); | |
6612 | ||
8f2d6021 | 6613 | if (role == ROLE_UNDEFINED) |
d864dd9e EB |
6614 | return bgp_vty_return(vty, BGP_ERR_INVALID_ROLE_NAME); |
6615 | return bgp_vty_return(vty, peer_role_set(peer, role, strict_mode)); | |
6616 | } | |
6617 | ||
6618 | static int peer_role_unset_vty(struct vty *vty, const char *ip_str) | |
6619 | { | |
6620 | struct peer *peer; | |
6621 | ||
7dddd1f7 | 6622 | peer = peer_and_group_lookup_vty(vty, ip_str); |
d864dd9e EB |
6623 | if (!peer) |
6624 | return CMD_WARNING_CONFIG_FAILED; | |
6625 | return bgp_vty_return(vty, peer_role_unset(peer)); | |
6626 | } | |
6627 | ||
8f2d6021 | 6628 | DEFPY(neighbor_role, |
d864dd9e EB |
6629 | neighbor_role_cmd, |
6630 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer>", | |
6631 | NEIGHBOR_STR | |
6632 | NEIGHBOR_ADDR_STR2 | |
6633 | "Set session role\n" | |
6634 | ROLE_STR) | |
6635 | { | |
6636 | int idx_peer = 1; | |
6637 | int idx_role = 3; | |
6638 | ||
6639 | return peer_role_set_vty(vty, argv[idx_peer]->arg, argv[idx_role]->arg, | |
8f2d6021 | 6640 | false); |
d864dd9e EB |
6641 | } |
6642 | ||
8f2d6021 | 6643 | DEFPY(neighbor_role_strict, |
d864dd9e EB |
6644 | neighbor_role_strict_cmd, |
6645 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> strict-mode", | |
6646 | NEIGHBOR_STR | |
6647 | NEIGHBOR_ADDR_STR2 | |
6648 | "Set session role\n" | |
6649 | ROLE_STR | |
6650 | "Use additional restriction on peer\n") | |
6651 | { | |
6652 | int idx_peer = 1; | |
6653 | int idx_role = 3; | |
6654 | ||
6655 | return peer_role_set_vty(vty, argv[idx_peer]->arg, argv[idx_role]->arg, | |
8f2d6021 | 6656 | true); |
d864dd9e EB |
6657 | } |
6658 | ||
8f2d6021 | 6659 | DEFPY(no_neighbor_role, |
d864dd9e EB |
6660 | no_neighbor_role_cmd, |
6661 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]", | |
6662 | NO_STR | |
6663 | NEIGHBOR_STR | |
6664 | NEIGHBOR_ADDR_STR2 | |
8f2d6021 | 6665 | "Set session role\n" |
d864dd9e | 6666 | ROLE_STR |
8f2d6021 | 6667 | "Use additional restriction on peer\n") |
d864dd9e EB |
6668 | { |
6669 | int idx_peer = 2; | |
6670 | ||
6671 | return peer_role_unset_vty(vty, argv[idx_peer]->arg); | |
6672 | } | |
6b0655a2 | 6673 | |
6ffd2079 | 6674 | /* disable-connected-check */ |
28c6e247 IR |
6675 | DEFUN (neighbor_disable_connected_check, |
6676 | neighbor_disable_connected_check_cmd, | |
6677 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6678 | NEIGHBOR_STR | |
6679 | NEIGHBOR_ADDR_STR2 | |
6680 | "one-hop away EBGP peer using loopback address\n" | |
6681 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6682 | { |
d62a17ae | 6683 | int idx_peer = 1; |
28c6e247 IR |
6684 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6685 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 6686 | } |
6687 | ||
28c6e247 IR |
6688 | DEFUN (no_neighbor_disable_connected_check, |
6689 | no_neighbor_disable_connected_check_cmd, | |
6690 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6691 | NO_STR | |
6692 | NEIGHBOR_STR | |
6693 | NEIGHBOR_ADDR_STR2 | |
6694 | "one-hop away EBGP peer using loopback address\n" | |
6695 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6696 | { |
d62a17ae | 6697 | int idx_peer = 2; |
28c6e247 IR |
6698 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6699 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 6700 | } |
6701 | ||
7ab294ea DA |
6702 | /* disable-link-bw-encoding-ieee */ |
6703 | DEFUN(neighbor_disable_link_bw_encoding_ieee, | |
6704 | neighbor_disable_link_bw_encoding_ieee_cmd, | |
27aa23a4 DA |
6705 | "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee", |
6706 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7ab294ea | 6707 | "Disable IEEE floating-point encoding for extended community bandwidth\n") |
27aa23a4 DA |
6708 | { |
6709 | int idx_peer = 1; | |
6710 | ||
6711 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6712 | PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE); | |
6713 | } | |
6714 | ||
7ab294ea DA |
6715 | DEFUN(no_neighbor_disable_link_bw_encoding_ieee, |
6716 | no_neighbor_disable_link_bw_encoding_ieee_cmd, | |
27aa23a4 DA |
6717 | "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee", |
6718 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7ab294ea | 6719 | "Disable IEEE floating-point encoding for extended community bandwidth\n") |
27aa23a4 DA |
6720 | { |
6721 | int idx_peer = 2; | |
6722 | ||
6723 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6724 | PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE); | |
6725 | } | |
6726 | ||
d08c0c80 DA |
6727 | /* extended-optional-parameters */ |
6728 | DEFUN(neighbor_extended_optional_parameters, | |
6729 | neighbor_extended_optional_parameters_cmd, | |
6730 | "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters", | |
6731 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6732 | "Force the extended optional parameters format for OPEN messages\n") | |
6733 | { | |
6734 | int idx_peer = 1; | |
6735 | ||
6736 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6737 | PEER_FLAG_EXTENDED_OPT_PARAMS); | |
6738 | } | |
6739 | ||
6740 | DEFUN(no_neighbor_extended_optional_parameters, | |
6741 | no_neighbor_extended_optional_parameters_cmd, | |
6742 | "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters", | |
6743 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6744 | "Force the extended optional parameters format for OPEN messages\n") | |
6745 | { | |
6746 | int idx_peer = 2; | |
6747 | ||
6748 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6749 | PEER_FLAG_EXTENDED_OPT_PARAMS); | |
6750 | } | |
47cbc09b PM |
6751 | |
6752 | /* enforce-first-as */ | |
28c6e247 IR |
6753 | DEFUN (neighbor_enforce_first_as, |
6754 | neighbor_enforce_first_as_cmd, | |
6755 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6756 | NEIGHBOR_STR | |
6757 | NEIGHBOR_ADDR_STR2 | |
6758 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6759 | { |
6760 | int idx_peer = 1; | |
f4b8ec07 | 6761 | |
28c6e247 IR |
6762 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6763 | PEER_FLAG_ENFORCE_FIRST_AS); | |
47cbc09b PM |
6764 | } |
6765 | ||
28c6e247 IR |
6766 | DEFUN (no_neighbor_enforce_first_as, |
6767 | no_neighbor_enforce_first_as_cmd, | |
6768 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6769 | NO_STR | |
6770 | NEIGHBOR_STR | |
6771 | NEIGHBOR_ADDR_STR2 | |
6772 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6773 | { |
6774 | int idx_peer = 2; | |
f4b8ec07 | 6775 | |
28c6e247 IR |
6776 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6777 | PEER_FLAG_ENFORCE_FIRST_AS); | |
47cbc09b PM |
6778 | } |
6779 | ||
6780 | ||
28c6e247 IR |
6781 | DEFUN (neighbor_description, |
6782 | neighbor_description_cmd, | |
6783 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
6784 | NEIGHBOR_STR | |
6785 | NEIGHBOR_ADDR_STR2 | |
6786 | "Neighbor specific description\n" | |
6787 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 6788 | { |
d62a17ae | 6789 | int idx_peer = 1; |
6790 | int idx_line = 3; | |
28c6e247 | 6791 | struct peer *peer; |
d62a17ae | 6792 | char *str; |
718e3744 | 6793 | |
28c6e247 IR |
6794 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6795 | if (!peer) | |
d62a17ae | 6796 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6797 | |
d62a17ae | 6798 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 6799 | |
28c6e247 | 6800 | peer_description_set(peer, str); |
718e3744 | 6801 | |
d62a17ae | 6802 | XFREE(MTYPE_TMP, str); |
718e3744 | 6803 | |
28c6e247 | 6804 | return CMD_SUCCESS; |
718e3744 | 6805 | } |
6806 | ||
28c6e247 IR |
6807 | DEFUN (no_neighbor_description, |
6808 | no_neighbor_description_cmd, | |
6809 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", | |
6810 | NO_STR | |
6811 | NEIGHBOR_STR | |
6812 | NEIGHBOR_ADDR_STR2 | |
6813 | "Neighbor specific description\n") | |
718e3744 | 6814 | { |
d62a17ae | 6815 | int idx_peer = 2; |
28c6e247 | 6816 | struct peer *peer; |
f4b8ec07 | 6817 | |
28c6e247 IR |
6818 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6819 | if (!peer) | |
d62a17ae | 6820 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6821 | |
28c6e247 | 6822 | peer_description_unset(peer); |
718e3744 | 6823 | |
28c6e247 | 6824 | return CMD_SUCCESS; |
718e3744 | 6825 | } |
6826 | ||
1d80f243 | 6827 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
a14810f4 PM |
6828 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
6829 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6830 | "Neighbor specific description\n" | |
6831 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 6832 | |
28c6e247 IR |
6833 | /* Neighbor update-source. */ |
6834 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, | |
6835 | const char *source_str) | |
6836 | { | |
6837 | struct peer *peer; | |
6838 | struct prefix p; | |
6839 | union sockunion su; | |
6840 | ||
6841 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
6842 | if (!peer) | |
6843 | return CMD_WARNING_CONFIG_FAILED; | |
6844 | ||
6845 | if (peer->conf_if) | |
6846 | return CMD_WARNING; | |
6847 | ||
6848 | if (source_str) { | |
6849 | if (str2sockunion(source_str, &su) == 0) | |
6850 | peer_update_source_addr_set(peer, &su); | |
6851 | else { | |
6852 | if (str2prefix(source_str, &p)) { | |
6853 | vty_out(vty, | |
6854 | "%% Invalid update-source, remove prefix length \n"); | |
6855 | return CMD_WARNING_CONFIG_FAILED; | |
6856 | } else | |
6857 | peer_update_source_if_set(peer, source_str); | |
6858 | } | |
6859 | } else | |
6860 | peer_update_source_unset(peer); | |
6861 | ||
6862 | return CMD_SUCCESS; | |
6863 | } | |
6864 | ||
d62a17ae | 6865 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
6866 | "IPv4 address\n" \ | |
6867 | "IPv6 address\n" \ | |
6868 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 6869 | |
28c6e247 IR |
6870 | DEFUN (neighbor_update_source, |
6871 | neighbor_update_source_cmd, | |
6872 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", | |
6873 | NEIGHBOR_STR | |
6874 | NEIGHBOR_ADDR_STR2 | |
6875 | "Source of routing updates\n" | |
6876 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6877 | { |
d62a17ae | 6878 | int idx_peer = 1; |
6879 | int idx_peer_2 = 3; | |
28c6e247 | 6880 | return peer_update_source_vty(vty, argv[idx_peer]->arg, |
d62a17ae | 6881 | argv[idx_peer_2]->arg); |
718e3744 | 6882 | } |
6883 | ||
28c6e247 IR |
6884 | DEFUN (no_neighbor_update_source, |
6885 | no_neighbor_update_source_cmd, | |
6886 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", | |
6887 | NO_STR | |
6888 | NEIGHBOR_STR | |
6889 | NEIGHBOR_ADDR_STR2 | |
6890 | "Source of routing updates\n" | |
6891 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6892 | { |
d62a17ae | 6893 | int idx_peer = 2; |
28c6e247 | 6894 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); |
718e3744 | 6895 | } |
6b0655a2 | 6896 | |
d62a17ae | 6897 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
6898 | afi_t afi, safi_t safi, | |
6899 | const char *rmap, int set) | |
718e3744 | 6900 | { |
d62a17ae | 6901 | int ret; |
6902 | struct peer *peer; | |
80912664 | 6903 | struct route_map *route_map = NULL; |
718e3744 | 6904 | |
d62a17ae | 6905 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6906 | if (!peer) | |
6907 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6908 | |
1de27621 | 6909 | if (set) { |
80912664 DS |
6910 | if (rmap) |
6911 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
6912 | ret = peer_default_originate_set(peer, afi, safi, |
6913 | rmap, route_map); | |
6914 | } else | |
d62a17ae | 6915 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 6916 | |
d62a17ae | 6917 | return bgp_vty_return(vty, ret); |
718e3744 | 6918 | } |
6919 | ||
6920 | /* neighbor default-originate. */ | |
6921 | DEFUN (neighbor_default_originate, | |
6922 | neighbor_default_originate_cmd, | |
9ccf14f7 | 6923 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 6924 | NEIGHBOR_STR |
6925 | NEIGHBOR_ADDR_STR2 | |
6926 | "Originate default route to this neighbor\n") | |
6927 | { | |
d62a17ae | 6928 | int idx_peer = 1; |
6929 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
6930 | bgp_node_afi(vty), | |
6931 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 6932 | } |
6933 | ||
d62a17ae | 6934 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
6935 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
6936 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6937 | "Originate default route to this neighbor\n") | |
596c17ba | 6938 | |
718e3744 | 6939 | DEFUN (neighbor_default_originate_rmap, |
6940 | neighbor_default_originate_rmap_cmd, | |
70dd370f | 6941 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME", |
718e3744 | 6942 | NEIGHBOR_STR |
6943 | NEIGHBOR_ADDR_STR2 | |
6944 | "Originate default route to this neighbor\n" | |
6945 | "Route-map to specify criteria to originate default\n" | |
6946 | "route-map name\n") | |
6947 | { | |
d62a17ae | 6948 | int idx_peer = 1; |
6949 | int idx_word = 4; | |
6950 | return peer_default_originate_set_vty( | |
6951 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6952 | argv[idx_word]->arg, 1); | |
718e3744 | 6953 | } |
6954 | ||
d62a17ae | 6955 | ALIAS_HIDDEN( |
6956 | neighbor_default_originate_rmap, | |
6957 | neighbor_default_originate_rmap_hidden_cmd, | |
70dd370f | 6958 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME", |
d62a17ae | 6959 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
6960 | "Originate default route to this neighbor\n" | |
6961 | "Route-map to specify criteria to originate default\n" | |
6962 | "route-map name\n") | |
596c17ba | 6963 | |
718e3744 | 6964 | DEFUN (no_neighbor_default_originate, |
6965 | no_neighbor_default_originate_cmd, | |
70dd370f | 6966 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]", |
718e3744 | 6967 | NO_STR |
6968 | NEIGHBOR_STR | |
6969 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
6970 | "Originate default route to this neighbor\n" |
6971 | "Route-map to specify criteria to originate default\n" | |
6972 | "route-map name\n") | |
718e3744 | 6973 | { |
d62a17ae | 6974 | int idx_peer = 2; |
6975 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
6976 | bgp_node_afi(vty), | |
6977 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 6978 | } |
6979 | ||
d62a17ae | 6980 | ALIAS_HIDDEN( |
6981 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
70dd370f | 6982 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]", |
d62a17ae | 6983 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
6984 | "Originate default route to this neighbor\n" | |
6985 | "Route-map to specify criteria to originate default\n" | |
6986 | "route-map name\n") | |
596c17ba | 6987 | |
6b0655a2 | 6988 | |
28c6e247 IR |
6989 | /* Set neighbor's BGP port. */ |
6990 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, | |
6991 | const char *port_str) | |
718e3744 | 6992 | { |
28c6e247 IR |
6993 | struct peer *peer; |
6994 | uint16_t port; | |
6995 | struct servent *sp; | |
6996 | ||
a3aecc99 | 6997 | peer = peer_and_group_lookup_vty(vty, ip_str); |
28c6e247 IR |
6998 | if (!peer) |
6999 | return CMD_WARNING_CONFIG_FAILED; | |
7000 | ||
7001 | if (!port_str) { | |
7002 | sp = getservbyname("bgp", "tcp"); | |
7003 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
7004 | } else { | |
7005 | port = strtoul(port_str, NULL, 10); | |
7006 | } | |
718e3744 | 7007 | |
28c6e247 | 7008 | peer_port_set(peer, port); |
718e3744 | 7009 | |
28c6e247 IR |
7010 | return CMD_SUCCESS; |
7011 | } | |
f4b8ec07 | 7012 | |
28c6e247 IR |
7013 | /* Set specified peer's BGP port. */ |
7014 | DEFUN (neighbor_port, | |
7015 | neighbor_port_cmd, | |
a3aecc99 | 7016 | "neighbor <A.B.C.D|X:X::X:X|WORD> port (0-65535)", |
28c6e247 | 7017 | NEIGHBOR_STR |
a3aecc99 | 7018 | NEIGHBOR_ADDR_STR2 |
28c6e247 IR |
7019 | "Neighbor's BGP port\n" |
7020 | "TCP port number\n") | |
7021 | { | |
7022 | int idx_ip = 1; | |
7023 | int idx_number = 3; | |
7024 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
7025 | argv[idx_number]->arg); | |
f4b8ec07 | 7026 | } |
6b0655a2 | 7027 | |
28c6e247 IR |
7028 | DEFUN (no_neighbor_port, |
7029 | no_neighbor_port_cmd, | |
a3aecc99 | 7030 | "no neighbor <A.B.C.D|X:X::X:X|WORD> port [(0-65535)]", |
28c6e247 IR |
7031 | NO_STR |
7032 | NEIGHBOR_STR | |
a3aecc99 | 7033 | NEIGHBOR_ADDR_STR2 |
28c6e247 IR |
7034 | "Neighbor's BGP port\n" |
7035 | "TCP port number\n") | |
718e3744 | 7036 | { |
f4b8ec07 | 7037 | int idx_ip = 2; |
28c6e247 IR |
7038 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); |
7039 | } | |
7040 | ||
7041 | ||
7042 | /* neighbor weight. */ | |
7043 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, | |
7044 | safi_t safi, const char *weight_str) | |
7045 | { | |
7046 | int ret; | |
7047 | struct peer *peer; | |
7048 | unsigned long weight; | |
718e3744 | 7049 | |
28c6e247 IR |
7050 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7051 | if (!peer) | |
7052 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7053 | |
28c6e247 | 7054 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 7055 | |
28c6e247 IR |
7056 | ret = peer_weight_set(peer, afi, safi, weight); |
7057 | return bgp_vty_return(vty, ret); | |
718e3744 | 7058 | } |
7059 | ||
28c6e247 IR |
7060 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7061 | safi_t safi) | |
718e3744 | 7062 | { |
28c6e247 IR |
7063 | int ret; |
7064 | struct peer *peer; | |
f4b8ec07 | 7065 | |
28c6e247 IR |
7066 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7067 | if (!peer) | |
d62a17ae | 7068 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7069 | |
28c6e247 IR |
7070 | ret = peer_weight_unset(peer, afi, safi); |
7071 | return bgp_vty_return(vty, ret); | |
7072 | } | |
f4b8ec07 | 7073 | |
28c6e247 IR |
7074 | DEFUN (neighbor_weight, |
7075 | neighbor_weight_cmd, | |
7076 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
7077 | NEIGHBOR_STR | |
7078 | NEIGHBOR_ADDR_STR2 | |
7079 | "Set default weight for routes from this neighbor\n" | |
7080 | "default weight\n") | |
7081 | { | |
7082 | int idx_peer = 1; | |
7083 | int idx_number = 3; | |
7084 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
7085 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 7086 | } |
7087 | ||
d62a17ae | 7088 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
7089 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
7090 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7091 | "Set default weight for routes from this neighbor\n" | |
7092 | "default weight\n") | |
596c17ba | 7093 | |
28c6e247 IR |
7094 | DEFUN (no_neighbor_weight, |
7095 | no_neighbor_weight_cmd, | |
7096 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
7097 | NO_STR | |
7098 | NEIGHBOR_STR | |
7099 | NEIGHBOR_ADDR_STR2 | |
7100 | "Set default weight for routes from this neighbor\n" | |
7101 | "default weight\n") | |
718e3744 | 7102 | { |
d62a17ae | 7103 | int idx_peer = 2; |
28c6e247 IR |
7104 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, |
7105 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 7106 | } |
7107 | ||
d62a17ae | 7108 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
7109 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
7110 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7111 | "Set default weight for routes from this neighbor\n" | |
7112 | "default weight\n") | |
596c17ba | 7113 | |
6b0655a2 | 7114 | |
718e3744 | 7115 | /* Override capability negotiation. */ |
c36bc05f IR |
7116 | DEFUN (neighbor_override_capability, |
7117 | neighbor_override_capability_cmd, | |
7118 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
7119 | NEIGHBOR_STR | |
7120 | NEIGHBOR_ADDR_STR2 | |
7121 | "Override capability negotiation result\n") | |
718e3744 | 7122 | { |
d62a17ae | 7123 | int idx_peer = 1; |
c36bc05f IR |
7124 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
7125 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 7126 | } |
7127 | ||
c36bc05f IR |
7128 | DEFUN (no_neighbor_override_capability, |
7129 | no_neighbor_override_capability_cmd, | |
7130 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
7131 | NO_STR | |
7132 | NEIGHBOR_STR | |
7133 | NEIGHBOR_ADDR_STR2 | |
7134 | "Override capability negotiation result\n") | |
718e3744 | 7135 | { |
d62a17ae | 7136 | int idx_peer = 2; |
c36bc05f IR |
7137 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
7138 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 7139 | } |
6b0655a2 | 7140 | |
c36bc05f IR |
7141 | DEFUN (neighbor_strict_capability, |
7142 | neighbor_strict_capability_cmd, | |
7143 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
7144 | NEIGHBOR_STR | |
7145 | NEIGHBOR_ADDR_STR2 | |
7146 | "Strict capability negotiation match\n") | |
718e3744 | 7147 | { |
9fb964de PM |
7148 | int idx_peer = 1; |
7149 | ||
c36bc05f IR |
7150 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
7151 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 7152 | } |
7153 | ||
c36bc05f IR |
7154 | DEFUN (no_neighbor_strict_capability, |
7155 | no_neighbor_strict_capability_cmd, | |
7156 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
7157 | NO_STR | |
7158 | NEIGHBOR_STR | |
7159 | NEIGHBOR_ADDR_STR2 | |
7160 | "Strict capability negotiation match\n") | |
718e3744 | 7161 | { |
9fb964de | 7162 | int idx_peer = 2; |
8611c7f3 | 7163 | |
c36bc05f IR |
7164 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
7165 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 7166 | } |
6b0655a2 | 7167 | |
28c6e247 IR |
7168 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
7169 | const char *keep_str, const char *hold_str) | |
718e3744 | 7170 | { |
28c6e247 IR |
7171 | int ret; |
7172 | struct peer *peer; | |
7173 | uint32_t keepalive; | |
7174 | uint32_t holdtime; | |
718e3744 | 7175 | |
28c6e247 IR |
7176 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7177 | if (!peer) | |
d62a17ae | 7178 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7179 | |
28c6e247 IR |
7180 | keepalive = strtoul(keep_str, NULL, 10); |
7181 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 7182 | |
28c6e247 | 7183 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 7184 | |
28c6e247 | 7185 | return bgp_vty_return(vty, ret); |
718e3744 | 7186 | } |
6b0655a2 | 7187 | |
28c6e247 | 7188 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 7189 | { |
28c6e247 IR |
7190 | int ret; |
7191 | struct peer *peer; | |
718e3744 | 7192 | |
28c6e247 IR |
7193 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7194 | if (!peer) | |
d62a17ae | 7195 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7196 | |
28c6e247 | 7197 | ret = peer_timers_unset(peer); |
718e3744 | 7198 | |
28c6e247 | 7199 | return bgp_vty_return(vty, ret); |
718e3744 | 7200 | } |
6b0655a2 | 7201 | |
28c6e247 IR |
7202 | DEFUN (neighbor_timers, |
7203 | neighbor_timers_cmd, | |
7204 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", | |
7205 | NEIGHBOR_STR | |
7206 | NEIGHBOR_ADDR_STR2 | |
7207 | "BGP per neighbor timers\n" | |
7208 | "Keepalive interval\n" | |
7209 | "Holdtime\n") | |
718e3744 | 7210 | { |
f4b8ec07 | 7211 | int idx_peer = 1; |
28c6e247 IR |
7212 | int idx_number = 3; |
7213 | int idx_number_2 = 4; | |
7214 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
7215 | argv[idx_number]->arg, | |
7216 | argv[idx_number_2]->arg); | |
7217 | } | |
7218 | ||
7219 | DEFUN (no_neighbor_timers, | |
7220 | no_neighbor_timers_cmd, | |
7221 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", | |
7222 | NO_STR | |
7223 | NEIGHBOR_STR | |
7224 | NEIGHBOR_ADDR_STR2 | |
7225 | "BGP per neighbor timers\n" | |
7226 | "Keepalive interval\n" | |
7227 | "Holdtime\n") | |
7228 | { | |
7229 | int idx_peer = 2; | |
7230 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
7231 | } | |
7232 | ||
7233 | ||
7234 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, | |
7235 | const char *time_str) | |
7236 | { | |
7237 | int ret; | |
7238 | struct peer *peer; | |
7239 | uint32_t connect; | |
718e3744 | 7240 | |
28c6e247 IR |
7241 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7242 | if (!peer) | |
d62a17ae | 7243 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7244 | |
28c6e247 IR |
7245 | connect = strtoul(time_str, NULL, 10); |
7246 | ||
7247 | ret = peer_timers_connect_set(peer, connect); | |
718e3744 | 7248 | |
28c6e247 | 7249 | return bgp_vty_return(vty, ret); |
718e3744 | 7250 | } |
7251 | ||
28c6e247 | 7252 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 7253 | { |
28c6e247 IR |
7254 | int ret; |
7255 | struct peer *peer; | |
718e3744 | 7256 | |
28c6e247 IR |
7257 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7258 | if (!peer) | |
d62a17ae | 7259 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7260 | |
28c6e247 IR |
7261 | ret = peer_timers_connect_unset(peer); |
7262 | ||
7263 | return bgp_vty_return(vty, ret); | |
7264 | } | |
7265 | ||
7266 | DEFUN (neighbor_timers_connect, | |
7267 | neighbor_timers_connect_cmd, | |
7268 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", | |
7269 | NEIGHBOR_STR | |
7270 | NEIGHBOR_ADDR_STR2 | |
7271 | "BGP per neighbor timers\n" | |
7272 | "BGP connect timer\n" | |
7273 | "Connect timer\n") | |
7274 | { | |
7275 | int idx_peer = 1; | |
7276 | int idx_number = 4; | |
7277 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
7278 | argv[idx_number]->arg); | |
7279 | } | |
718e3744 | 7280 | |
28c6e247 IR |
7281 | DEFUN (no_neighbor_timers_connect, |
7282 | no_neighbor_timers_connect_cmd, | |
7283 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", | |
7284 | NO_STR | |
7285 | NEIGHBOR_STR | |
7286 | NEIGHBOR_ADDR_STR2 | |
7287 | "BGP per neighbor timers\n" | |
7288 | "BGP connect timer\n" | |
7289 | "Connect timer\n") | |
7290 | { | |
7291 | int idx_peer = 2; | |
7292 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 7293 | } |
7294 | ||
d43114f3 DS |
7295 | DEFPY (neighbor_timers_delayopen, |
7296 | neighbor_timers_delayopen_cmd, | |
7297 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval", | |
7298 | NEIGHBOR_STR | |
7299 | NEIGHBOR_ADDR_STR2 | |
7300 | "BGP per neighbor timers\n" | |
7301 | "RFC 4271 DelayOpenTimer\n" | |
7302 | "DelayOpenTime timer interval\n") | |
7303 | { | |
7304 | struct peer *peer; | |
7305 | ||
7306 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7307 | if (!peer) | |
7308 | return CMD_WARNING_CONFIG_FAILED; | |
7309 | ||
7310 | if (!interval) { | |
7311 | if (peer_timers_delayopen_unset(peer)) | |
7312 | return CMD_WARNING_CONFIG_FAILED; | |
7313 | } else { | |
7314 | if (peer_timers_delayopen_set(peer, interval)) | |
7315 | return CMD_WARNING_CONFIG_FAILED; | |
7316 | } | |
7317 | ||
7318 | return CMD_SUCCESS; | |
7319 | } | |
7320 | ||
7321 | DEFPY (no_neighbor_timers_delayopen, | |
7322 | no_neighbor_timers_delayopen_cmd, | |
7323 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]", | |
7324 | NO_STR | |
7325 | NEIGHBOR_STR | |
7326 | NEIGHBOR_ADDR_STR2 | |
7327 | "BGP per neighbor timers\n" | |
7328 | "RFC 4271 DelayOpenTimer\n" | |
7329 | "DelayOpenTime timer interval\n") | |
7330 | { | |
7331 | struct peer *peer; | |
7332 | ||
7333 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7334 | if (!peer) | |
7335 | return CMD_WARNING_CONFIG_FAILED; | |
7336 | ||
7337 | if (peer_timers_delayopen_unset(peer)) | |
7338 | return CMD_WARNING_CONFIG_FAILED; | |
7339 | ||
7340 | return CMD_SUCCESS; | |
7341 | } | |
7342 | ||
28c6e247 IR |
7343 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
7344 | const char *time_str, int set) | |
718e3744 | 7345 | { |
28c6e247 IR |
7346 | int ret; |
7347 | struct peer *peer; | |
7348 | uint32_t routeadv = 0; | |
718e3744 | 7349 | |
28c6e247 IR |
7350 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7351 | if (!peer) | |
d62a17ae | 7352 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7353 | |
28c6e247 IR |
7354 | if (time_str) |
7355 | routeadv = strtoul(time_str, NULL, 10); | |
7356 | ||
7357 | if (set) | |
7358 | ret = peer_advertise_interval_set(peer, routeadv); | |
7359 | else | |
7360 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 7361 | |
28c6e247 | 7362 | return bgp_vty_return(vty, ret); |
718e3744 | 7363 | } |
7364 | ||
28c6e247 IR |
7365 | DEFUN (neighbor_advertise_interval, |
7366 | neighbor_advertise_interval_cmd, | |
7367 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", | |
7368 | NEIGHBOR_STR | |
7369 | NEIGHBOR_ADDR_STR2 | |
7370 | "Minimum interval between sending BGP routing updates\n" | |
7371 | "time in seconds\n") | |
718e3744 | 7372 | { |
28c6e247 IR |
7373 | int idx_peer = 1; |
7374 | int idx_number = 3; | |
7375 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
7376 | argv[idx_number]->arg, 1); | |
7377 | } | |
f4b8ec07 | 7378 | |
28c6e247 IR |
7379 | DEFUN (no_neighbor_advertise_interval, |
7380 | no_neighbor_advertise_interval_cmd, | |
7381 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", | |
7382 | NO_STR | |
7383 | NEIGHBOR_STR | |
7384 | NEIGHBOR_ADDR_STR2 | |
7385 | "Minimum interval between sending BGP routing updates\n" | |
7386 | "time in seconds\n") | |
7387 | { | |
7388 | int idx_peer = 2; | |
7389 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 7390 | } |
7391 | ||
6b0655a2 | 7392 | |
518f0eb1 DS |
7393 | /* Time to wait before processing route-map updates */ |
7394 | DEFUN (bgp_set_route_map_delay_timer, | |
7395 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 7396 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
7397 | SET_STR |
7398 | "BGP route-map delay timer\n" | |
7399 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 7400 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 7401 | { |
d62a17ae | 7402 | int idx_number = 3; |
d7c0a89a | 7403 | uint32_t rmap_delay_timer; |
d62a17ae | 7404 | |
7405 | if (argv[idx_number]->arg) { | |
7406 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
7407 | bm->rmap_update_timer = rmap_delay_timer; | |
7408 | ||
7409 | /* if the dynamic update handling is being disabled, and a timer | |
7410 | * is | |
7411 | * running, stop the timer and act as if the timer has already | |
7412 | * fired. | |
7413 | */ | |
7414 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
fa5806c3 | 7415 | THREAD_OFF(bm->t_rmap_update); |
d62a17ae | 7416 | thread_execute(bm->master, bgp_route_map_update_timer, |
7417 | NULL, 0); | |
7418 | } | |
7419 | return CMD_SUCCESS; | |
7420 | } else { | |
7421 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
7422 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 7423 | } |
518f0eb1 DS |
7424 | } |
7425 | ||
7426 | DEFUN (no_bgp_set_route_map_delay_timer, | |
7427 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 7428 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 7429 | NO_STR |
3a2d747c | 7430 | BGP_STR |
518f0eb1 | 7431 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
7432 | "Reset to default time to wait for processing route-map changes\n" |
7433 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 7434 | { |
518f0eb1 | 7435 | |
d62a17ae | 7436 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 7437 | |
d62a17ae | 7438 | return CMD_SUCCESS; |
518f0eb1 DS |
7439 | } |
7440 | ||
28c6e247 IR |
7441 | /* neighbor interface */ |
7442 | static int peer_interface_vty(struct vty *vty, const char *ip_str, | |
7443 | const char *str) | |
718e3744 | 7444 | { |
28c6e247 | 7445 | struct peer *peer; |
718e3744 | 7446 | |
28c6e247 IR |
7447 | peer = peer_lookup_vty(vty, ip_str); |
7448 | if (!peer || peer->conf_if) { | |
7449 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
7450 | return CMD_WARNING_CONFIG_FAILED; | |
7451 | } | |
718e3744 | 7452 | |
28c6e247 IR |
7453 | if (str) |
7454 | peer_interface_set(peer, str); | |
7455 | else | |
7456 | peer_interface_unset(peer); | |
718e3744 | 7457 | |
28c6e247 | 7458 | return CMD_SUCCESS; |
718e3744 | 7459 | } |
7460 | ||
28c6e247 IR |
7461 | DEFUN (neighbor_interface, |
7462 | neighbor_interface_cmd, | |
7463 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", | |
7464 | NEIGHBOR_STR | |
7465 | NEIGHBOR_ADDR_STR | |
7466 | "Interface\n" | |
7467 | "Interface name\n") | |
718e3744 | 7468 | { |
28c6e247 IR |
7469 | int idx_ip = 1; |
7470 | int idx_word = 3; | |
294d8425 | 7471 | |
28c6e247 IR |
7472 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); |
7473 | } | |
f4b8ec07 | 7474 | |
28c6e247 IR |
7475 | DEFUN (no_neighbor_interface, |
7476 | no_neighbor_interface_cmd, | |
294d8425 | 7477 | "no neighbor <A.B.C.D|X:X::X:X> interface WORD", |
28c6e247 IR |
7478 | NO_STR |
7479 | NEIGHBOR_STR | |
294d8425 | 7480 | NEIGHBOR_ADDR_STR |
28c6e247 IR |
7481 | "Interface\n" |
7482 | "Interface name\n") | |
7483 | { | |
7484 | int idx_peer = 2; | |
294d8425 | 7485 | |
28c6e247 | 7486 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); |
718e3744 | 7487 | } |
6b0655a2 | 7488 | |
718e3744 | 7489 | DEFUN (neighbor_distribute_list, |
7490 | neighbor_distribute_list_cmd, | |
c60dec36 | 7491 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
718e3744 | 7492 | NEIGHBOR_STR |
7493 | NEIGHBOR_ADDR_STR2 | |
7494 | "Filter updates to/from this neighbor\n" | |
718e3744 | 7495 | "IP Access-list name\n" |
7496 | "Filter incoming updates\n" | |
7497 | "Filter outgoing updates\n") | |
7498 | { | |
d62a17ae | 7499 | int idx_peer = 1; |
7500 | int idx_acl = 3; | |
7501 | int direct, ret; | |
7502 | struct peer *peer; | |
a8206004 | 7503 | |
d62a17ae | 7504 | const char *pstr = argv[idx_peer]->arg; |
7505 | const char *acl = argv[idx_acl]->arg; | |
7506 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7507 | |
d62a17ae | 7508 | peer = peer_and_group_lookup_vty(vty, pstr); |
7509 | if (!peer) | |
7510 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7511 | |
d62a17ae | 7512 | /* Check filter direction. */ |
7513 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7514 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7515 | direct, acl); | |
a8206004 | 7516 | |
d62a17ae | 7517 | return bgp_vty_return(vty, ret); |
718e3744 | 7518 | } |
7519 | ||
d62a17ae | 7520 | ALIAS_HIDDEN( |
7521 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
c60dec36 | 7522 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
d62a17ae | 7523 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7524 | "Filter updates to/from this neighbor\n" | |
d62a17ae | 7525 | "IP Access-list name\n" |
7526 | "Filter incoming updates\n" | |
7527 | "Filter outgoing updates\n") | |
596c17ba | 7528 | |
718e3744 | 7529 | DEFUN (no_neighbor_distribute_list, |
7530 | no_neighbor_distribute_list_cmd, | |
c60dec36 | 7531 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
718e3744 | 7532 | NO_STR |
7533 | NEIGHBOR_STR | |
7534 | NEIGHBOR_ADDR_STR2 | |
7535 | "Filter updates to/from this neighbor\n" | |
718e3744 | 7536 | "IP Access-list name\n" |
7537 | "Filter incoming updates\n" | |
7538 | "Filter outgoing updates\n") | |
7539 | { | |
d62a17ae | 7540 | int idx_peer = 2; |
7541 | int direct, ret; | |
7542 | struct peer *peer; | |
a8206004 | 7543 | |
d62a17ae | 7544 | const char *pstr = argv[idx_peer]->arg; |
7545 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7546 | |
d62a17ae | 7547 | peer = peer_and_group_lookup_vty(vty, pstr); |
7548 | if (!peer) | |
7549 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7550 | |
d62a17ae | 7551 | /* Check filter direction. */ |
7552 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7553 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7554 | direct); | |
a8206004 | 7555 | |
d62a17ae | 7556 | return bgp_vty_return(vty, ret); |
718e3744 | 7557 | } |
6b0655a2 | 7558 | |
d62a17ae | 7559 | ALIAS_HIDDEN( |
7560 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
c60dec36 | 7561 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
d62a17ae | 7562 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7563 | "Filter updates to/from this neighbor\n" | |
d62a17ae | 7564 | "IP Access-list name\n" |
7565 | "Filter incoming updates\n" | |
7566 | "Filter outgoing updates\n") | |
596c17ba | 7567 | |
718e3744 | 7568 | /* Set prefix list to the peer. */ |
642ef664 IR |
7569 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
7570 | afi_t afi, safi_t safi, | |
7571 | const char *name_str, | |
7572 | const char *direct_str) | |
718e3744 | 7573 | { |
642ef664 IR |
7574 | int ret; |
7575 | int direct = FILTER_IN; | |
7576 | struct peer *peer; | |
718e3744 | 7577 | |
642ef664 IR |
7578 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7579 | if (!peer) | |
d62a17ae | 7580 | return CMD_WARNING_CONFIG_FAILED; |
e52702f2 | 7581 | |
642ef664 IR |
7582 | /* Check filter direction. */ |
7583 | if (strncmp(direct_str, "i", 1) == 0) | |
7584 | direct = FILTER_IN; | |
7585 | else if (strncmp(direct_str, "o", 1) == 0) | |
7586 | direct = FILTER_OUT; | |
718e3744 | 7587 | |
642ef664 | 7588 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 7589 | |
642ef664 IR |
7590 | return bgp_vty_return(vty, ret); |
7591 | } | |
7592 | ||
7593 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, | |
7594 | afi_t afi, safi_t safi, | |
7595 | const char *direct_str) | |
7596 | { | |
7597 | int ret; | |
7598 | struct peer *peer; | |
7599 | int direct = FILTER_IN; | |
7600 | ||
7601 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7602 | if (!peer) | |
7603 | return CMD_WARNING_CONFIG_FAILED; | |
7604 | ||
7605 | /* Check filter direction. */ | |
7606 | if (strncmp(direct_str, "i", 1) == 0) | |
7607 | direct = FILTER_IN; | |
7608 | else if (strncmp(direct_str, "o", 1) == 0) | |
7609 | direct = FILTER_OUT; | |
7610 | ||
7611 | ret = peer_prefix_list_unset(peer, afi, safi, direct); | |
7612 | ||
7613 | return bgp_vty_return(vty, ret); | |
7614 | } | |
7615 | ||
7616 | DEFUN (neighbor_prefix_list, | |
7617 | neighbor_prefix_list_cmd, | |
7618 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7619 | NEIGHBOR_STR | |
7620 | NEIGHBOR_ADDR_STR2 | |
7621 | "Filter updates to/from this neighbor\n" | |
7622 | "Name of a prefix list\n" | |
7623 | "Filter incoming updates\n" | |
7624 | "Filter outgoing updates\n") | |
7625 | { | |
7626 | int idx_peer = 1; | |
7627 | int idx_word = 3; | |
7628 | int idx_in_out = 4; | |
7629 | return peer_prefix_list_set_vty( | |
7630 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7631 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7632 | } |
7633 | ||
d62a17ae | 7634 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
7635 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7636 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7637 | "Filter updates to/from this neighbor\n" | |
7638 | "Name of a prefix list\n" | |
7639 | "Filter incoming updates\n" | |
7640 | "Filter outgoing updates\n") | |
596c17ba | 7641 | |
642ef664 IR |
7642 | DEFUN (no_neighbor_prefix_list, |
7643 | no_neighbor_prefix_list_cmd, | |
7644 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7645 | NO_STR | |
7646 | NEIGHBOR_STR | |
7647 | 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") | |
7652 | { | |
7653 | int idx_peer = 2; | |
7654 | int idx_in_out = 5; | |
7655 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
7656 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7657 | argv[idx_in_out]->arg); | |
7658 | } | |
7659 | ||
7660 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, | |
7661 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7662 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7663 | "Filter updates to/from this neighbor\n" | |
7664 | "Name of a prefix list\n" | |
7665 | "Filter incoming updates\n" | |
7666 | "Filter outgoing updates\n") | |
7667 | ||
d62a17ae | 7668 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7669 | safi_t safi, const char *name_str, | |
7670 | const char *direct_str) | |
718e3744 | 7671 | { |
d62a17ae | 7672 | int ret; |
7673 | struct peer *peer; | |
7674 | int direct = FILTER_IN; | |
718e3744 | 7675 | |
d62a17ae | 7676 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7677 | if (!peer) | |
7678 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7679 | |
d62a17ae | 7680 | /* Check filter direction. */ |
7681 | if (strncmp(direct_str, "i", 1) == 0) | |
7682 | direct = FILTER_IN; | |
7683 | else if (strncmp(direct_str, "o", 1) == 0) | |
7684 | direct = FILTER_OUT; | |
718e3744 | 7685 | |
d62a17ae | 7686 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 7687 | |
d62a17ae | 7688 | return bgp_vty_return(vty, ret); |
718e3744 | 7689 | } |
7690 | ||
d62a17ae | 7691 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7692 | safi_t safi, const char *direct_str) | |
718e3744 | 7693 | { |
d62a17ae | 7694 | int ret; |
7695 | struct peer *peer; | |
7696 | int direct = FILTER_IN; | |
718e3744 | 7697 | |
d62a17ae | 7698 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7699 | if (!peer) | |
7700 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7701 | |
d62a17ae | 7702 | /* Check filter direction. */ |
7703 | if (strncmp(direct_str, "i", 1) == 0) | |
7704 | direct = FILTER_IN; | |
7705 | else if (strncmp(direct_str, "o", 1) == 0) | |
7706 | direct = FILTER_OUT; | |
718e3744 | 7707 | |
d62a17ae | 7708 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 7709 | |
d62a17ae | 7710 | return bgp_vty_return(vty, ret); |
718e3744 | 7711 | } |
7712 | ||
7713 | DEFUN (neighbor_filter_list, | |
7714 | neighbor_filter_list_cmd, | |
de71d43e | 7715 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
718e3744 | 7716 | NEIGHBOR_STR |
7717 | NEIGHBOR_ADDR_STR2 | |
7718 | "Establish BGP filters\n" | |
7719 | "AS path access-list name\n" | |
7720 | "Filter incoming routes\n" | |
7721 | "Filter outgoing routes\n") | |
7722 | { | |
d62a17ae | 7723 | int idx_peer = 1; |
7724 | int idx_word = 3; | |
7725 | int idx_in_out = 4; | |
7726 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
7727 | bgp_node_safi(vty), argv[idx_word]->arg, | |
7728 | argv[idx_in_out]->arg); | |
718e3744 | 7729 | } |
7730 | ||
d62a17ae | 7731 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
de71d43e | 7732 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
d62a17ae | 7733 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7734 | "Establish BGP filters\n" | |
7735 | "AS path access-list name\n" | |
7736 | "Filter incoming routes\n" | |
7737 | "Filter outgoing routes\n") | |
596c17ba | 7738 | |
718e3744 | 7739 | DEFUN (no_neighbor_filter_list, |
7740 | no_neighbor_filter_list_cmd, | |
de71d43e | 7741 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
718e3744 | 7742 | NO_STR |
7743 | NEIGHBOR_STR | |
7744 | 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") | |
7749 | { | |
d62a17ae | 7750 | int idx_peer = 2; |
7751 | int idx_in_out = 5; | |
7752 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
7753 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7754 | argv[idx_in_out]->arg); | |
718e3744 | 7755 | } |
6b0655a2 | 7756 | |
d62a17ae | 7757 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
de71d43e | 7758 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
d62a17ae | 7759 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7760 | "Establish BGP filters\n" | |
7761 | "AS path access-list name\n" | |
7762 | "Filter incoming routes\n" | |
7763 | "Filter outgoing routes\n") | |
596c17ba | 7764 | |
7f7940e6 MK |
7765 | /* Set advertise-map to the peer. */ |
7766 | static int peer_advertise_map_set_vty(struct vty *vty, const char *ip_str, | |
7767 | afi_t afi, safi_t safi, | |
cf2ad4d8 MK |
7768 | const char *advertise_str, |
7769 | const char *condition_str, bool condition, | |
7770 | bool set) | |
7f7940e6 MK |
7771 | { |
7772 | int ret = CMD_WARNING_CONFIG_FAILED; | |
7773 | struct peer *peer; | |
7774 | struct route_map *advertise_map; | |
7775 | struct route_map *condition_map; | |
7776 | ||
7777 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7778 | if (!peer) | |
7779 | return ret; | |
7780 | ||
7781 | condition_map = route_map_lookup_warn_noexist(vty, condition_str); | |
7782 | advertise_map = route_map_lookup_warn_noexist(vty, advertise_str); | |
7783 | ||
cf2ad4d8 MK |
7784 | if (set) |
7785 | ret = peer_advertise_map_set(peer, afi, safi, advertise_str, | |
7786 | advertise_map, condition_str, | |
7787 | condition_map, condition); | |
7788 | else | |
7789 | ret = peer_advertise_map_unset(peer, afi, safi, advertise_str, | |
7790 | advertise_map, condition_str, | |
7791 | condition_map, condition); | |
7f7940e6 MK |
7792 | |
7793 | return bgp_vty_return(vty, ret); | |
7794 | } | |
7795 | ||
389e4f92 QY |
7796 | DEFPY (bgp_condadv_period, |
7797 | bgp_condadv_period_cmd, | |
7798 | "[no$no] bgp conditional-advertisement timer (5-240)$period", | |
7799 | NO_STR | |
7800 | BGP_STR | |
7801 | "Conditional advertisement settings\n" | |
7802 | "Set period to rescan BGP table to check if condition is met\n" | |
7803 | "Period between BGP table scans, in seconds; default 60\n") | |
7804 | { | |
7805 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7806 | ||
7807 | bgp->condition_check_period = | |
7808 | no ? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME : period; | |
7809 | ||
7810 | return CMD_SUCCESS; | |
7811 | } | |
7812 | ||
cf2ad4d8 | 7813 | DEFPY (neighbor_advertise_map, |
7f7940e6 | 7814 | neighbor_advertise_map_cmd, |
3ccddc25 | 7815 | "[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", |
cf2ad4d8 | 7816 | NO_STR |
7f7940e6 MK |
7817 | NEIGHBOR_STR |
7818 | NEIGHBOR_ADDR_STR2 | |
7819 | "Route-map to conditionally advertise routes\n" | |
7820 | "Name of advertise map\n" | |
7821 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7822 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7823 | "Name of the exist or non exist map\n") |
7f7940e6 | 7824 | { |
7f7940e6 MK |
7825 | bool condition = CONDITION_EXIST; |
7826 | ||
52b84062 | 7827 | if (!strcmp(exist, "non-exist-map")) |
7f7940e6 MK |
7828 | condition = CONDITION_NON_EXIST; |
7829 | ||
52b84062 MK |
7830 | return peer_advertise_map_set_vty(vty, neighbor, bgp_node_afi(vty), |
7831 | bgp_node_safi(vty), advertise_str, | |
7832 | condition_str, condition, !no); | |
7f7940e6 MK |
7833 | } |
7834 | ||
7835 | ALIAS_HIDDEN(neighbor_advertise_map, neighbor_advertise_map_hidden_cmd, | |
3ccddc25 | 7836 | "[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", |
7f7940e6 MK |
7837 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7838 | "Route-map to conditionally advertise routes\n" | |
7839 | "Name of advertise map\n" | |
7840 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7841 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7842 | "Name of the exist or non exist map\n") |
7f7940e6 | 7843 | |
718e3744 | 7844 | /* Set route-map to the peer. */ |
0ea8d871 IR |
7845 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
7846 | afi_t afi, safi_t safi, const char *name_str, | |
7847 | const char *direct_str) | |
718e3744 | 7848 | { |
0ea8d871 IR |
7849 | int ret; |
7850 | struct peer *peer; | |
7851 | int direct = RMAP_IN; | |
7852 | struct route_map *route_map; | |
718e3744 | 7853 | |
0ea8d871 IR |
7854 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7855 | if (!peer) | |
d62a17ae | 7856 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7857 | |
0ea8d871 IR |
7858 | /* Check filter direction. */ |
7859 | if (strncmp(direct_str, "in", 2) == 0) | |
7860 | direct = RMAP_IN; | |
7861 | else if (strncmp(direct_str, "o", 1) == 0) | |
7862 | direct = RMAP_OUT; | |
718e3744 | 7863 | |
0ea8d871 IR |
7864 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7865 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 7866 | |
0ea8d871 IR |
7867 | return bgp_vty_return(vty, ret); |
7868 | } | |
7869 | ||
7870 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, | |
7871 | afi_t afi, safi_t safi, | |
7872 | const char *direct_str) | |
7873 | { | |
7874 | int ret; | |
7875 | struct peer *peer; | |
7876 | int direct = RMAP_IN; | |
7877 | ||
7878 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7879 | if (!peer) | |
7880 | return CMD_WARNING_CONFIG_FAILED; | |
7881 | ||
7882 | /* Check filter direction. */ | |
7883 | if (strncmp(direct_str, "in", 2) == 0) | |
7884 | direct = RMAP_IN; | |
7885 | else if (strncmp(direct_str, "o", 1) == 0) | |
7886 | direct = RMAP_OUT; | |
7887 | ||
7888 | ret = peer_route_map_unset(peer, afi, safi, direct); | |
7889 | ||
7890 | return bgp_vty_return(vty, ret); | |
7891 | } | |
7892 | ||
7893 | DEFUN (neighbor_route_map, | |
7894 | neighbor_route_map_cmd, | |
70dd370f | 7895 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", |
0ea8d871 IR |
7896 | NEIGHBOR_STR |
7897 | NEIGHBOR_ADDR_STR2 | |
7898 | "Apply route map to neighbor\n" | |
7899 | "Name of route map\n" | |
7900 | "Apply map to incoming routes\n" | |
7901 | "Apply map to outbound routes\n") | |
7902 | { | |
7903 | int idx_peer = 1; | |
7904 | int idx_word = 3; | |
7905 | int idx_in_out = 4; | |
7906 | return peer_route_map_set_vty( | |
7907 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7908 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7909 | } |
7910 | ||
d6d7ed37 | 7911 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
70dd370f | 7912 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", |
d6d7ed37 IR |
7913 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7914 | "Apply route map to neighbor\n" | |
7915 | "Name of route map\n" | |
7916 | "Apply map to incoming routes\n" | |
7917 | "Apply map to outbound routes\n") | |
7918 | ||
0ea8d871 IR |
7919 | DEFUN (no_neighbor_route_map, |
7920 | no_neighbor_route_map_cmd, | |
70dd370f | 7921 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", |
0ea8d871 IR |
7922 | NO_STR |
7923 | NEIGHBOR_STR | |
7924 | 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") | |
7929 | { | |
7930 | int idx_peer = 2; | |
7931 | int idx_in_out = 5; | |
7932 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
7933 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7934 | argv[idx_in_out]->arg); | |
7935 | } | |
7936 | ||
7937 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, | |
70dd370f | 7938 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", |
d6d7ed37 IR |
7939 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7940 | "Apply route map to neighbor\n" | |
7941 | "Name of route map\n" | |
7942 | "Apply map to incoming routes\n" | |
7943 | "Apply map to outbound routes\n") | |
7944 | ||
718e3744 | 7945 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 7946 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
7947 | afi_t afi, safi_t safi, | |
7948 | const char *name_str) | |
718e3744 | 7949 | { |
d62a17ae | 7950 | int ret; |
7951 | struct peer *peer; | |
1de27621 | 7952 | struct route_map *route_map; |
718e3744 | 7953 | |
d62a17ae | 7954 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7955 | if (!peer) | |
7956 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7957 | |
1de27621 DA |
7958 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7959 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 7960 | |
d62a17ae | 7961 | return bgp_vty_return(vty, ret); |
718e3744 | 7962 | } |
7963 | ||
7964 | /* Unset route-map from the peer. */ | |
d62a17ae | 7965 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
7966 | afi_t afi, safi_t safi) | |
718e3744 | 7967 | { |
d62a17ae | 7968 | int ret; |
7969 | struct peer *peer; | |
718e3744 | 7970 | |
d62a17ae | 7971 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7972 | if (!peer) | |
7973 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7974 | |
d62a17ae | 7975 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 7976 | |
d62a17ae | 7977 | return bgp_vty_return(vty, ret); |
718e3744 | 7978 | } |
7979 | ||
7980 | DEFUN (neighbor_unsuppress_map, | |
7981 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 7982 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 7983 | NEIGHBOR_STR |
7984 | NEIGHBOR_ADDR_STR2 | |
7985 | "Route-map to selectively unsuppress suppressed routes\n" | |
7986 | "Name of route map\n") | |
7987 | { | |
d62a17ae | 7988 | int idx_peer = 1; |
7989 | int idx_word = 3; | |
7990 | return peer_unsuppress_map_set_vty( | |
7991 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7992 | argv[idx_word]->arg); | |
718e3744 | 7993 | } |
7994 | ||
d62a17ae | 7995 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
7996 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
7997 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7998 | "Route-map to selectively unsuppress suppressed routes\n" | |
7999 | "Name of route map\n") | |
596c17ba | 8000 | |
718e3744 | 8001 | DEFUN (no_neighbor_unsuppress_map, |
8002 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 8003 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 8004 | NO_STR |
8005 | NEIGHBOR_STR | |
8006 | NEIGHBOR_ADDR_STR2 | |
8007 | "Route-map to selectively unsuppress suppressed routes\n" | |
8008 | "Name of route map\n") | |
8009 | { | |
d62a17ae | 8010 | int idx_peer = 2; |
8011 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
8012 | bgp_node_afi(vty), | |
8013 | bgp_node_safi(vty)); | |
718e3744 | 8014 | } |
6b0655a2 | 8015 | |
d62a17ae | 8016 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
8017 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
8018 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8019 | "Route-map to selectively unsuppress suppressed routes\n" | |
8020 | "Name of route map\n") | |
596c17ba | 8021 | |
7e62b792 IR |
8022 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
8023 | afi_t afi, safi_t safi, | |
8024 | const char *num_str, | |
8025 | const char *threshold_str, int warning, | |
8026 | const char *restart_str, | |
8027 | const char *force_str) | |
8028 | { | |
8029 | int ret; | |
8030 | struct peer *peer; | |
8031 | uint32_t max; | |
8032 | uint8_t threshold; | |
8033 | uint16_t restart; | |
8034 | ||
8035 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
8036 | if (!peer) | |
8037 | return CMD_WARNING_CONFIG_FAILED; | |
8038 | ||
8039 | max = strtoul(num_str, NULL, 10); | |
8040 | if (threshold_str) | |
8041 | threshold = atoi(threshold_str); | |
8042 | else | |
8043 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
8044 | ||
8045 | if (restart_str) | |
8046 | restart = atoi(restart_str); | |
8047 | else | |
8048 | restart = 0; | |
8049 | ||
8050 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, | |
8051 | restart, force_str ? true : false); | |
8052 | ||
8053 | return bgp_vty_return(vty, ret); | |
8054 | } | |
8055 | ||
8056 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, | |
8057 | afi_t afi, safi_t safi) | |
8058 | { | |
8059 | int ret; | |
8060 | struct peer *peer; | |
8061 | ||
8062 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
8063 | if (!peer) | |
8064 | return CMD_WARNING_CONFIG_FAILED; | |
8065 | ||
8066 | ret = peer_maximum_prefix_unset(peer, afi, safi); | |
8067 | ||
8068 | return bgp_vty_return(vty, ret); | |
8069 | } | |
8070 | ||
fde246e8 | 8071 | /* Maximum number of prefix to be sent to the neighbor. */ |
1d80f243 IR |
8072 | DEFUN(neighbor_maximum_prefix_out, |
8073 | neighbor_maximum_prefix_out_cmd, | |
8074 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
8075 | NEIGHBOR_STR | |
8076 | NEIGHBOR_ADDR_STR2 | |
8077 | "Maximum number of prefixes to be sent to this peer\n" | |
8078 | "Maximum no. of prefix limit\n") | |
fde246e8 | 8079 | { |
80444d30 | 8080 | int ret; |
fde246e8 DA |
8081 | int idx_peer = 1; |
8082 | int idx_number = 3; | |
7e62b792 IR |
8083 | struct peer *peer; |
8084 | uint32_t max; | |
fde246e8 DA |
8085 | afi_t afi = bgp_node_afi(vty); |
8086 | safi_t safi = bgp_node_safi(vty); | |
8087 | ||
7e62b792 IR |
8088 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8089 | if (!peer) | |
fde246e8 DA |
8090 | return CMD_WARNING_CONFIG_FAILED; |
8091 | ||
7e62b792 | 8092 | max = strtoul(argv[idx_number]->arg, NULL, 10); |
fde246e8 | 8093 | |
80444d30 | 8094 | ret = peer_maximum_prefix_out_set(peer, afi, safi, max); |
fde246e8 | 8095 | |
80444d30 | 8096 | return bgp_vty_return(vty, ret); |
fde246e8 DA |
8097 | } |
8098 | ||
1d80f243 IR |
8099 | DEFUN(no_neighbor_maximum_prefix_out, |
8100 | no_neighbor_maximum_prefix_out_cmd, | |
bc03c622 | 8101 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]", |
1d80f243 IR |
8102 | NO_STR |
8103 | NEIGHBOR_STR | |
8104 | NEIGHBOR_ADDR_STR2 | |
bc03c622 LS |
8105 | "Maximum number of prefixes to be sent to this peer\n" |
8106 | "Maximum no. of prefix limit\n") | |
fde246e8 | 8107 | { |
80444d30 | 8108 | int ret; |
fde246e8 | 8109 | int idx_peer = 2; |
7e62b792 | 8110 | struct peer *peer; |
fde246e8 DA |
8111 | afi_t afi = bgp_node_afi(vty); |
8112 | safi_t safi = bgp_node_safi(vty); | |
8113 | ||
7e62b792 IR |
8114 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8115 | if (!peer) | |
fde246e8 DA |
8116 | return CMD_WARNING_CONFIG_FAILED; |
8117 | ||
80444d30 | 8118 | ret = peer_maximum_prefix_out_unset(peer, afi, safi); |
fde246e8 | 8119 | |
80444d30 | 8120 | return bgp_vty_return(vty, ret); |
fde246e8 DA |
8121 | } |
8122 | ||
9cbd06e0 DA |
8123 | /* Maximum number of prefix configuration. Prefix count is different |
8124 | for each peer configuration. So this configuration can be set for | |
718e3744 | 8125 | each peer configuration. */ |
1d80f243 IR |
8126 | DEFUN (neighbor_maximum_prefix, |
8127 | neighbor_maximum_prefix_cmd, | |
8128 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", | |
8129 | NEIGHBOR_STR | |
8130 | NEIGHBOR_ADDR_STR2 | |
8131 | "Maximum number of prefix accept from this peer\n" | |
8132 | "maximum no. of prefix limit\n" | |
8133 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8134 | { |
d62a17ae | 8135 | int idx_peer = 1; |
8136 | int idx_number = 3; | |
9cbd06e0 | 8137 | int idx_force = 0; |
7e62b792 | 8138 | char *force = NULL; |
9cbd06e0 DA |
8139 | |
8140 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8141 | force = argv[idx_force]->arg; |
9cbd06e0 | 8142 | |
7e62b792 IR |
8143 | return peer_maximum_prefix_set_vty( |
8144 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8145 | argv[idx_number]->arg, NULL, 0, NULL, force); | |
718e3744 | 8146 | } |
8147 | ||
d62a17ae | 8148 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
9cbd06e0 | 8149 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", |
d62a17ae | 8150 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8151 | "Maximum number of prefix accept from this peer\n" | |
9cbd06e0 DA |
8152 | "maximum no. of prefix limit\n" |
8153 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8154 | |
1d80f243 IR |
8155 | DEFUN (neighbor_maximum_prefix_threshold, |
8156 | neighbor_maximum_prefix_threshold_cmd, | |
8157 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", | |
8158 | NEIGHBOR_STR | |
8159 | NEIGHBOR_ADDR_STR2 | |
8160 | "Maximum number of prefix accept from this peer\n" | |
8161 | "maximum no. of prefix limit\n" | |
8162 | "Threshold value (%) at which to generate a warning msg\n" | |
8163 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 8164 | { |
d62a17ae | 8165 | int idx_peer = 1; |
8166 | int idx_number = 3; | |
8167 | int idx_number_2 = 4; | |
9cbd06e0 | 8168 | int idx_force = 0; |
7e62b792 | 8169 | char *force = NULL; |
9cbd06e0 DA |
8170 | |
8171 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8172 | force = argv[idx_force]->arg; |
9cbd06e0 | 8173 | |
7e62b792 IR |
8174 | return peer_maximum_prefix_set_vty( |
8175 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8176 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL, force); | |
0a486e5f | 8177 | } |
e0701b79 | 8178 | |
d62a17ae | 8179 | ALIAS_HIDDEN( |
8180 | neighbor_maximum_prefix_threshold, | |
8181 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
9cbd06e0 | 8182 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", |
d62a17ae | 8183 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8184 | "Maximum number of prefix accept from this peer\n" | |
8185 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
8186 | "Threshold value (%) at which to generate a warning msg\n" |
8187 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8188 | |
1d80f243 IR |
8189 | DEFUN (neighbor_maximum_prefix_warning, |
8190 | neighbor_maximum_prefix_warning_cmd, | |
8191 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", | |
8192 | NEIGHBOR_STR | |
8193 | NEIGHBOR_ADDR_STR2 | |
8194 | "Maximum number of prefix accept from this peer\n" | |
8195 | "maximum no. of prefix limit\n" | |
8196 | "Only give warning message when limit is exceeded\n" | |
8197 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8198 | { |
d62a17ae | 8199 | int idx_peer = 1; |
8200 | int idx_number = 3; | |
9cbd06e0 | 8201 | int idx_force = 0; |
7e62b792 | 8202 | char *force = NULL; |
9cbd06e0 DA |
8203 | |
8204 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8205 | force = argv[idx_force]->arg; |
9cbd06e0 | 8206 | |
7e62b792 IR |
8207 | return peer_maximum_prefix_set_vty( |
8208 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8209 | argv[idx_number]->arg, NULL, 1, NULL, force); | |
718e3744 | 8210 | } |
8211 | ||
d62a17ae | 8212 | ALIAS_HIDDEN( |
8213 | neighbor_maximum_prefix_warning, | |
8214 | neighbor_maximum_prefix_warning_hidden_cmd, | |
9cbd06e0 | 8215 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", |
d62a17ae | 8216 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8217 | "Maximum number of prefix accept from this peer\n" | |
8218 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
8219 | "Only give warning message when limit is exceeded\n" |
8220 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8221 | |
1d80f243 IR |
8222 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
8223 | neighbor_maximum_prefix_threshold_warning_cmd, | |
8224 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", | |
8225 | NEIGHBOR_STR | |
8226 | NEIGHBOR_ADDR_STR2 | |
8227 | "Maximum number of prefix accept from this peer\n" | |
8228 | "maximum no. of prefix limit\n" | |
8229 | "Threshold value (%) at which to generate a warning msg\n" | |
8230 | "Only give warning message when limit is exceeded\n" | |
8231 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 8232 | { |
d62a17ae | 8233 | int idx_peer = 1; |
8234 | int idx_number = 3; | |
8235 | int idx_number_2 = 4; | |
9cbd06e0 | 8236 | int idx_force = 0; |
7e62b792 | 8237 | char *force = NULL; |
9cbd06e0 DA |
8238 | |
8239 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8240 | force = argv[idx_force]->arg; |
9cbd06e0 | 8241 | |
7e62b792 IR |
8242 | return peer_maximum_prefix_set_vty( |
8243 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8244 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL, force); | |
0a486e5f | 8245 | } |
8246 | ||
d62a17ae | 8247 | ALIAS_HIDDEN( |
8248 | neighbor_maximum_prefix_threshold_warning, | |
8249 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
9cbd06e0 | 8250 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", |
d62a17ae | 8251 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8252 | "Maximum number of prefix accept from this peer\n" | |
8253 | "maximum no. of prefix limit\n" | |
8254 | "Threshold value (%) at which to generate a warning msg\n" | |
9cbd06e0 DA |
8255 | "Only give warning message when limit is exceeded\n" |
8256 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8257 | |
1d80f243 IR |
8258 | DEFUN (neighbor_maximum_prefix_restart, |
8259 | neighbor_maximum_prefix_restart_cmd, | |
8260 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", | |
8261 | NEIGHBOR_STR | |
8262 | NEIGHBOR_ADDR_STR2 | |
8263 | "Maximum number of prefix accept from this peer\n" | |
8264 | "maximum no. of prefix limit\n" | |
8265 | "Restart bgp connection after limit is exceeded\n" | |
8266 | "Restart interval in minutes\n" | |
8267 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 8268 | { |
d62a17ae | 8269 | int idx_peer = 1; |
8270 | int idx_number = 3; | |
8271 | int idx_number_2 = 5; | |
9cbd06e0 | 8272 | int idx_force = 0; |
7e62b792 | 8273 | char *force = NULL; |
9cbd06e0 DA |
8274 | |
8275 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8276 | force = argv[idx_force]->arg; |
9cbd06e0 | 8277 | |
7e62b792 IR |
8278 | return peer_maximum_prefix_set_vty( |
8279 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8280 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg, force); | |
0a486e5f | 8281 | } |
8282 | ||
d62a17ae | 8283 | ALIAS_HIDDEN( |
8284 | neighbor_maximum_prefix_restart, | |
8285 | neighbor_maximum_prefix_restart_hidden_cmd, | |
9cbd06e0 | 8286 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", |
d62a17ae | 8287 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8288 | "Maximum number of prefix accept from this peer\n" | |
8289 | "maximum no. of prefix limit\n" | |
8290 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
8291 | "Restart interval in minutes\n" |
8292 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8293 | |
1d80f243 IR |
8294 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
8295 | neighbor_maximum_prefix_threshold_restart_cmd, | |
8296 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", | |
8297 | NEIGHBOR_STR | |
8298 | NEIGHBOR_ADDR_STR2 | |
8299 | "Maximum number of prefixes to accept from this peer\n" | |
8300 | "maximum no. of prefix limit\n" | |
8301 | "Threshold value (%) at which to generate a warning msg\n" | |
8302 | "Restart bgp connection after limit is exceeded\n" | |
8303 | "Restart interval in minutes\n" | |
8304 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 8305 | { |
d62a17ae | 8306 | int idx_peer = 1; |
8307 | int idx_number = 3; | |
8308 | int idx_number_2 = 4; | |
8309 | int idx_number_3 = 6; | |
9cbd06e0 | 8310 | int idx_force = 0; |
7e62b792 | 8311 | char *force = NULL; |
9cbd06e0 DA |
8312 | |
8313 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8314 | force = argv[idx_force]->arg; |
9cbd06e0 | 8315 | |
7e62b792 IR |
8316 | return peer_maximum_prefix_set_vty( |
8317 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8318 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
8319 | argv[idx_number_3]->arg, force); | |
d62a17ae | 8320 | } |
8321 | ||
8322 | ALIAS_HIDDEN( | |
8323 | neighbor_maximum_prefix_threshold_restart, | |
8324 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
9cbd06e0 | 8325 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", |
d62a17ae | 8326 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8327 | "Maximum number of prefixes to accept from this peer\n" | |
8328 | "maximum no. of prefix limit\n" | |
8329 | "Threshold value (%) at which to generate a warning msg\n" | |
8330 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
8331 | "Restart interval in minutes\n" |
8332 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8333 | |
1d80f243 IR |
8334 | DEFUN (no_neighbor_maximum_prefix, |
8335 | no_neighbor_maximum_prefix_cmd, | |
8336 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", | |
8337 | NO_STR | |
8338 | NEIGHBOR_STR | |
8339 | NEIGHBOR_ADDR_STR2 | |
8340 | "Maximum number of prefixes to accept from this peer\n" | |
8341 | "maximum no. of prefix limit\n" | |
8342 | "Threshold value (%) at which to generate a warning msg\n" | |
8343 | "Restart bgp connection after limit is exceeded\n" | |
8344 | "Restart interval in minutes\n" | |
8345 | "Only give warning message when limit is exceeded\n" | |
8346 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8347 | { |
d62a17ae | 8348 | int idx_peer = 2; |
7e62b792 IR |
8349 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, |
8350 | bgp_node_afi(vty), | |
8351 | bgp_node_safi(vty)); | |
718e3744 | 8352 | } |
e52702f2 | 8353 | |
d62a17ae | 8354 | ALIAS_HIDDEN( |
8355 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
9cbd06e0 | 8356 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", |
d62a17ae | 8357 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8358 | "Maximum number of prefixes to accept from this peer\n" | |
8359 | "maximum no. of prefix limit\n" | |
8360 | "Threshold value (%) at which to generate a warning msg\n" | |
8361 | "Restart bgp connection after limit is exceeded\n" | |
8362 | "Restart interval in minutes\n" | |
9cbd06e0 DA |
8363 | "Only give warning message when limit is exceeded\n" |
8364 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8365 | |
46dbf9d0 DA |
8366 | /* "neighbor accept-own" */ |
8367 | DEFPY (neighbor_accept_own, | |
8368 | neighbor_accept_own_cmd, | |
8369 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor accept-own", | |
8370 | NO_STR | |
8371 | NEIGHBOR_STR | |
8372 | NEIGHBOR_ADDR_STR2 | |
8373 | "Enable handling of self-originated VPN routes containing ACCEPT_OWN community\n") | |
8374 | { | |
8375 | struct peer *peer; | |
8376 | afi_t afi = bgp_node_afi(vty); | |
8377 | safi_t safi = bgp_node_safi(vty); | |
8378 | int ret; | |
8379 | ||
8380 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8381 | if (!peer) | |
8382 | return CMD_WARNING_CONFIG_FAILED; | |
8383 | ||
8384 | if (no) | |
8385 | ret = peer_af_flag_unset(peer, afi, safi, PEER_FLAG_ACCEPT_OWN); | |
8386 | else | |
8387 | ret = peer_af_flag_set(peer, afi, safi, PEER_FLAG_ACCEPT_OWN); | |
8388 | ||
8389 | return bgp_vty_return(vty, ret); | |
8390 | } | |
8391 | ||
01da2d26 DA |
8392 | /* "neighbor soo" */ |
8393 | DEFPY (neighbor_soo, | |
8394 | neighbor_soo_cmd, | |
8395 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo ASN:NN_OR_IP-ADDRESS:NN$soo", | |
8396 | NEIGHBOR_STR | |
8397 | NEIGHBOR_ADDR_STR2 | |
8398 | "Set the Site-of-Origin (SoO) extended community\n" | |
8399 | "VPN extended community\n") | |
8400 | { | |
8401 | struct peer *peer; | |
8402 | afi_t afi = bgp_node_afi(vty); | |
8403 | safi_t safi = bgp_node_safi(vty); | |
8404 | struct ecommunity *ecomm_soo; | |
8405 | ||
8406 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8407 | if (!peer) | |
8408 | return CMD_WARNING_CONFIG_FAILED; | |
8409 | ||
8410 | ecomm_soo = ecommunity_str2com(soo, ECOMMUNITY_SITE_ORIGIN, 0); | |
8411 | if (!ecomm_soo) { | |
8412 | vty_out(vty, "%% Malformed SoO extended community\n"); | |
8413 | return CMD_WARNING; | |
8414 | } | |
8415 | ecommunity_str(ecomm_soo); | |
8416 | ||
8417 | if (!ecommunity_match(peer->soo[afi][safi], ecomm_soo)) { | |
8418 | ecommunity_free(&peer->soo[afi][safi]); | |
8419 | peer->soo[afi][safi] = ecomm_soo; | |
8420 | peer_af_flag_unset(peer, afi, safi, PEER_FLAG_SOO); | |
8421 | } | |
8422 | ||
8423 | return bgp_vty_return(vty, | |
8424 | peer_af_flag_set(peer, afi, safi, PEER_FLAG_SOO)); | |
8425 | } | |
8426 | ||
8427 | DEFPY (no_neighbor_soo, | |
8428 | no_neighbor_soo_cmd, | |
8429 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo [ASN:NN_OR_IP-ADDRESS:NN$soo]", | |
8430 | NO_STR | |
8431 | NEIGHBOR_STR | |
8432 | NEIGHBOR_ADDR_STR2 | |
8433 | "Set the Site-of-Origin (SoO) extended community\n" | |
8434 | "VPN extended community\n") | |
8435 | { | |
8436 | struct peer *peer; | |
8437 | afi_t afi = bgp_node_afi(vty); | |
8438 | safi_t safi = bgp_node_safi(vty); | |
8439 | ||
8440 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8441 | if (!peer) | |
8442 | return CMD_WARNING_CONFIG_FAILED; | |
8443 | ||
8444 | ecommunity_free(&peer->soo[afi][safi]); | |
8445 | ||
8446 | return bgp_vty_return( | |
8447 | vty, peer_af_flag_unset(peer, afi, safi, PEER_FLAG_SOO)); | |
8448 | } | |
718e3744 | 8449 | |
718e3744 | 8450 | /* "neighbor allowas-in" */ |
8451 | DEFUN (neighbor_allowas_in, | |
8452 | neighbor_allowas_in_cmd, | |
fd8503f5 | 8453 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 8454 | NEIGHBOR_STR |
8455 | NEIGHBOR_ADDR_STR2 | |
31500417 | 8456 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 8457 | "Number of occurrences of AS number\n" |
fd8503f5 | 8458 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 8459 | { |
d62a17ae | 8460 | int idx_peer = 1; |
8461 | int idx_number_origin = 3; | |
8462 | int ret; | |
8463 | int origin = 0; | |
8464 | struct peer *peer; | |
8465 | int allow_num = 0; | |
8466 | ||
8467 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8468 | if (!peer) | |
8469 | return CMD_WARNING_CONFIG_FAILED; | |
8470 | ||
8471 | if (argc <= idx_number_origin) | |
8472 | allow_num = 3; | |
8473 | else { | |
8474 | if (argv[idx_number_origin]->type == WORD_TKN) | |
8475 | origin = 1; | |
8476 | else | |
8477 | allow_num = atoi(argv[idx_number_origin]->arg); | |
8478 | } | |
8479 | ||
8480 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8481 | allow_num, origin); | |
8482 | ||
8483 | return bgp_vty_return(vty, ret); | |
8484 | } | |
8485 | ||
8486 | ALIAS_HIDDEN( | |
8487 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
8488 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
8489 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8490 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 8491 | "Number of occurrences of AS number\n" |
d62a17ae | 8492 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 8493 | |
718e3744 | 8494 | DEFUN (no_neighbor_allowas_in, |
8495 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 8496 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 8497 | NO_STR |
8498 | NEIGHBOR_STR | |
8499 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 8500 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 8501 | "Number of occurrences of AS number\n" |
fd8503f5 | 8502 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 8503 | { |
d62a17ae | 8504 | int idx_peer = 2; |
8505 | int ret; | |
8506 | struct peer *peer; | |
718e3744 | 8507 | |
d62a17ae | 8508 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8509 | if (!peer) | |
8510 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8511 | |
d62a17ae | 8512 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
8513 | bgp_node_safi(vty)); | |
718e3744 | 8514 | |
d62a17ae | 8515 | return bgp_vty_return(vty, ret); |
718e3744 | 8516 | } |
6b0655a2 | 8517 | |
d62a17ae | 8518 | ALIAS_HIDDEN( |
8519 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
8520 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
8521 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8522 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 8523 | "Number of occurrences of AS number\n" |
d62a17ae | 8524 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 8525 | |
28c6e247 IR |
8526 | DEFUN (neighbor_ttl_security, |
8527 | neighbor_ttl_security_cmd, | |
8528 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8529 | NEIGHBOR_STR | |
8530 | NEIGHBOR_ADDR_STR2 | |
8531 | "BGP ttl-security parameters\n" | |
8532 | "Specify the maximum number of hops to the BGP peer\n" | |
8533 | "Number of hops to BGP peer\n") | |
fa411a21 | 8534 | { |
d62a17ae | 8535 | int idx_peer = 1; |
8536 | int idx_number = 4; | |
28c6e247 IR |
8537 | struct peer *peer; |
8538 | int gtsm_hops; | |
d62a17ae | 8539 | |
28c6e247 IR |
8540 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8541 | if (!peer) | |
d62a17ae | 8542 | return CMD_WARNING_CONFIG_FAILED; |
8543 | ||
28c6e247 IR |
8544 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); |
8545 | ||
8546 | /* | |
8547 | * If 'neighbor swpX', then this is for directly connected peers, | |
8548 | * we should not accept a ttl-security hops value greater than 1. | |
8549 | */ | |
8550 | if (peer->conf_if && (gtsm_hops > BGP_GTSM_HOPS_CONNECTED)) { | |
8551 | vty_out(vty, | |
8552 | "%s is directly connected peer, hops cannot exceed 1\n", | |
8553 | argv[idx_peer]->arg); | |
8554 | return CMD_WARNING_CONFIG_FAILED; | |
8555 | } | |
7ebe625c | 8556 | |
28c6e247 | 8557 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
8558 | } |
8559 | ||
1d80f243 IR |
8560 | DEFUN (no_neighbor_ttl_security, |
8561 | no_neighbor_ttl_security_cmd, | |
8562 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8563 | NO_STR | |
8564 | NEIGHBOR_STR | |
8565 | NEIGHBOR_ADDR_STR2 | |
8566 | "BGP ttl-security parameters\n" | |
8567 | "Specify the maximum number of hops to the BGP peer\n" | |
8568 | "Number of hops to BGP peer\n") | |
fa411a21 | 8569 | { |
d62a17ae | 8570 | int idx_peer = 2; |
28c6e247 | 8571 | struct peer *peer; |
fa411a21 | 8572 | |
28c6e247 IR |
8573 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8574 | if (!peer) | |
d62a17ae | 8575 | return CMD_WARNING_CONFIG_FAILED; |
fa411a21 | 8576 | |
28c6e247 | 8577 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 8578 | } |
6b0655a2 | 8579 | |
7c0e4312 DA |
8580 | /* disable-addpath-rx */ |
8581 | DEFUN(neighbor_disable_addpath_rx, | |
8582 | neighbor_disable_addpath_rx_cmd, | |
8583 | "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx", | |
8584 | NEIGHBOR_STR | |
8585 | NEIGHBOR_ADDR_STR2 | |
8586 | "Do not accept additional paths\n") | |
8587 | { | |
8588 | char *peer_str = argv[1]->arg; | |
8589 | struct peer *peer; | |
8590 | afi_t afi = bgp_node_afi(vty); | |
8591 | safi_t safi = bgp_node_safi(vty); | |
8592 | ||
8593 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
8594 | if (!peer) | |
8595 | return CMD_WARNING_CONFIG_FAILED; | |
8596 | ||
8597 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
8598 | PEER_FLAG_DISABLE_ADDPATH_RX); | |
8599 | } | |
8600 | ||
8601 | DEFUN(no_neighbor_disable_addpath_rx, | |
8602 | no_neighbor_disable_addpath_rx_cmd, | |
8603 | "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx", | |
8604 | NO_STR | |
8605 | NEIGHBOR_STR | |
8606 | NEIGHBOR_ADDR_STR2 | |
8607 | "Do not accept additional paths\n") | |
8608 | { | |
8609 | char *peer_str = argv[2]->arg; | |
8610 | struct peer *peer; | |
8611 | afi_t afi = bgp_node_afi(vty); | |
8612 | safi_t safi = bgp_node_safi(vty); | |
8613 | ||
8614 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
8615 | if (!peer) | |
8616 | return CMD_WARNING_CONFIG_FAILED; | |
8617 | ||
8618 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
8619 | PEER_FLAG_DISABLE_ADDPATH_RX); | |
8620 | } | |
8621 | ||
adbac85e DW |
8622 | DEFUN (neighbor_addpath_tx_all_paths, |
8623 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8624 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8625 | NEIGHBOR_STR |
8626 | NEIGHBOR_ADDR_STR2 | |
8627 | "Use addpath to advertise all paths to a neighbor\n") | |
8628 | { | |
d62a17ae | 8629 | int idx_peer = 1; |
8630 | struct peer *peer; | |
adbac85e | 8631 | |
d62a17ae | 8632 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8633 | if (!peer) | |
8634 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 8635 | |
dcc68b5e MS |
8636 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8637 | BGP_ADDPATH_ALL); | |
8638 | return CMD_SUCCESS; | |
adbac85e DW |
8639 | } |
8640 | ||
d62a17ae | 8641 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
8642 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
8643 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8644 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8645 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8646 | |
adbac85e DW |
8647 | DEFUN (no_neighbor_addpath_tx_all_paths, |
8648 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8649 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8650 | NO_STR |
8651 | NEIGHBOR_STR | |
8652 | NEIGHBOR_ADDR_STR2 | |
8653 | "Use addpath to advertise all paths to a neighbor\n") | |
8654 | { | |
d62a17ae | 8655 | int idx_peer = 2; |
dcc68b5e MS |
8656 | struct peer *peer; |
8657 | ||
8658 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8659 | if (!peer) | |
8660 | return CMD_WARNING_CONFIG_FAILED; | |
8661 | ||
8662 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8663 | != BGP_ADDPATH_ALL) { | |
8664 | vty_out(vty, | |
8665 | "%% Peer not currently configured to transmit all paths."); | |
8666 | return CMD_WARNING_CONFIG_FAILED; | |
8667 | } | |
8668 | ||
8669 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8670 | BGP_ADDPATH_NONE); | |
8671 | ||
8672 | return CMD_SUCCESS; | |
adbac85e DW |
8673 | } |
8674 | ||
d62a17ae | 8675 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
8676 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
8677 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8678 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8679 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8680 | |
06370dac DW |
8681 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
8682 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8683 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8684 | NEIGHBOR_STR |
8685 | NEIGHBOR_ADDR_STR2 | |
8686 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8687 | { | |
d62a17ae | 8688 | int idx_peer = 1; |
8689 | struct peer *peer; | |
06370dac | 8690 | |
d62a17ae | 8691 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8692 | if (!peer) | |
8693 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 8694 | |
dcc68b5e MS |
8695 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8696 | BGP_ADDPATH_BEST_PER_AS); | |
8697 | ||
8698 | return CMD_SUCCESS; | |
06370dac DW |
8699 | } |
8700 | ||
d62a17ae | 8701 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
8702 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8703 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8704 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8705 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8706 | |
06370dac DW |
8707 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
8708 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8709 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8710 | NO_STR |
8711 | NEIGHBOR_STR | |
8712 | NEIGHBOR_ADDR_STR2 | |
8713 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8714 | { | |
d62a17ae | 8715 | int idx_peer = 2; |
dcc68b5e MS |
8716 | struct peer *peer; |
8717 | ||
8718 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8719 | if (!peer) | |
8720 | return CMD_WARNING_CONFIG_FAILED; | |
8721 | ||
8722 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8723 | != BGP_ADDPATH_BEST_PER_AS) { | |
8724 | vty_out(vty, | |
8725 | "%% Peer not currently configured to transmit all best path per as."); | |
8726 | return CMD_WARNING_CONFIG_FAILED; | |
8727 | } | |
8728 | ||
8729 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8730 | BGP_ADDPATH_NONE); | |
8731 | ||
8732 | return CMD_SUCCESS; | |
06370dac DW |
8733 | } |
8734 | ||
d62a17ae | 8735 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
8736 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8737 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8738 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8739 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8740 | |
2b31007c RZ |
8741 | DEFPY( |
8742 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
8743 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8744 | NEIGHBOR_STR | |
8745 | NEIGHBOR_ADDR_STR2 | |
8746 | "Detect AS loops before sending to neighbor\n") | |
8747 | { | |
8748 | struct peer *peer; | |
8749 | ||
8750 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8751 | if (!peer) | |
8752 | return CMD_WARNING_CONFIG_FAILED; | |
8753 | ||
8754 | peer->as_path_loop_detection = true; | |
8755 | ||
8756 | return CMD_SUCCESS; | |
8757 | } | |
8758 | ||
8759 | DEFPY( | |
8760 | no_neighbor_aspath_loop_detection, | |
8761 | no_neighbor_aspath_loop_detection_cmd, | |
8762 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8763 | NO_STR | |
8764 | NEIGHBOR_STR | |
8765 | NEIGHBOR_ADDR_STR2 | |
8766 | "Detect AS loops before sending to neighbor\n") | |
8767 | { | |
8768 | struct peer *peer; | |
8769 | ||
8770 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8771 | if (!peer) | |
8772 | return CMD_WARNING_CONFIG_FAILED; | |
8773 | ||
8774 | peer->as_path_loop_detection = false; | |
8775 | ||
8776 | return CMD_SUCCESS; | |
8777 | } | |
8778 | ||
b9c7bc5a | 8779 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
c6423c31 | 8780 | struct ecommunity **list, bool is_rt6) |
ddb5b488 | 8781 | { |
b9c7bc5a PZ |
8782 | struct ecommunity *ecom = NULL; |
8783 | struct ecommunity *ecomadd; | |
ddb5b488 | 8784 | |
b9c7bc5a | 8785 | for (; argc; --argc, ++argv) { |
9a659715 PG |
8786 | if (is_rt6) |
8787 | ecomadd = ecommunity_str2com_ipv6(argv[0]->arg, | |
8788 | ECOMMUNITY_ROUTE_TARGET, | |
8789 | 0); | |
8790 | else | |
8791 | ecomadd = ecommunity_str2com(argv[0]->arg, | |
8792 | ECOMMUNITY_ROUTE_TARGET, | |
8793 | 0); | |
b9c7bc5a PZ |
8794 | if (!ecomadd) { |
8795 | vty_out(vty, "Malformed community-list value\n"); | |
8796 | if (ecom) | |
8797 | ecommunity_free(&ecom); | |
8798 | return CMD_WARNING_CONFIG_FAILED; | |
8799 | } | |
ddb5b488 | 8800 | |
b9c7bc5a PZ |
8801 | if (ecom) { |
8802 | ecommunity_merge(ecom, ecomadd); | |
8803 | ecommunity_free(&ecomadd); | |
8804 | } else { | |
8805 | ecom = ecomadd; | |
8806 | } | |
8807 | } | |
8808 | ||
8809 | if (*list) { | |
8810 | ecommunity_free(&*list); | |
ddb5b488 | 8811 | } |
b9c7bc5a PZ |
8812 | *list = ecom; |
8813 | ||
8814 | return CMD_SUCCESS; | |
ddb5b488 PZ |
8815 | } |
8816 | ||
0ca70ba5 DS |
8817 | /* |
8818 | * v2vimport is true if we are handling a `import vrf ...` command | |
8819 | */ | |
8820 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 8821 | { |
0ca70ba5 DS |
8822 | afi_t afi; |
8823 | ||
ddb5b488 | 8824 | switch (vty->node) { |
b9c7bc5a | 8825 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
8826 | afi = AFI_IP; |
8827 | break; | |
b9c7bc5a | 8828 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
8829 | afi = AFI_IP6; |
8830 | break; | |
ddb5b488 PZ |
8831 | default: |
8832 | vty_out(vty, | |
b9c7bc5a | 8833 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 8834 | return AFI_MAX; |
ddb5b488 | 8835 | } |
69b07479 | 8836 | |
0ca70ba5 DS |
8837 | if (!v2vimport) { |
8838 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8839 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
8840 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8841 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
8842 | vty_out(vty, | |
8843 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
8844 | return AFI_MAX; | |
8845 | } | |
8846 | } else { | |
8847 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8848 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
8849 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8850 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
8851 | vty_out(vty, | |
8852 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
8853 | return AFI_MAX; | |
8854 | } | |
8855 | } | |
8856 | return afi; | |
ddb5b488 PZ |
8857 | } |
8858 | ||
585f1adc IR |
8859 | DEFPY (af_rd_vpn_export, |
8860 | af_rd_vpn_export_cmd, | |
8861 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
8862 | NO_STR | |
8863 | "Specify route distinguisher\n" | |
8864 | "Between current address-family and vpn\n" | |
8865 | "For routes leaked from current address-family to vpn\n" | |
8866 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") | |
ddb5b488 | 8867 | { |
585f1adc IR |
8868 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8869 | struct prefix_rd prd; | |
8870 | int ret; | |
ddb5b488 | 8871 | afi_t afi; |
b9c7bc5a | 8872 | int idx = 0; |
585f1adc | 8873 | bool yes = true; |
b9c7bc5a | 8874 | |
585f1adc IR |
8875 | if (argv_find(argv, argc, "no", &idx)) |
8876 | yes = false; | |
ddb5b488 | 8877 | |
585f1adc IR |
8878 | if (yes) { |
8879 | ret = str2prefix_rd(rd_str, &prd); | |
8880 | if (!ret) { | |
8881 | vty_out(vty, "%% Malformed rd\n"); | |
8882 | return CMD_WARNING_CONFIG_FAILED; | |
8883 | } | |
8884 | } | |
ddb5b488 | 8885 | |
585f1adc IR |
8886 | afi = vpn_policy_getafi(vty, bgp, false); |
8887 | if (afi == AFI_MAX) | |
8888 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8889 | |
585f1adc IR |
8890 | /* |
8891 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8892 | */ | |
8893 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8894 | bgp_get_default(), bgp); | |
ddb5b488 | 8895 | |
585f1adc IR |
8896 | if (yes) { |
8897 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
8898 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8899 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
8900 | } else { | |
8901 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
8902 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
8903 | } | |
69b07479 | 8904 | |
585f1adc IR |
8905 | /* post-change: re-export vpn routes */ |
8906 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8907 | bgp_get_default(), bgp); | |
8908 | ||
8909 | return CMD_SUCCESS; | |
ddb5b488 PZ |
8910 | } |
8911 | ||
b9c7bc5a PZ |
8912 | ALIAS (af_rd_vpn_export, |
8913 | af_no_rd_vpn_export_cmd, | |
8914 | "no rd vpn export", | |
ddb5b488 | 8915 | NO_STR |
b9c7bc5a PZ |
8916 | "Specify route distinguisher\n" |
8917 | "Between current address-family and vpn\n" | |
8918 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 8919 | |
b9c7bc5a PZ |
8920 | DEFPY (af_label_vpn_export, |
8921 | af_label_vpn_export_cmd, | |
e70e9f8e | 8922 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 8923 | NO_STR |
ddb5b488 | 8924 | "label value for VRF\n" |
b9c7bc5a PZ |
8925 | "Between current address-family and vpn\n" |
8926 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
8927 | "Label Value <0-1048575>\n" |
8928 | "Automatically assign a label\n") | |
ddb5b488 PZ |
8929 | { |
8930 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 8931 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 8932 | afi_t afi; |
b9c7bc5a | 8933 | int idx = 0; |
c6423c31 | 8934 | bool yes = true; |
b9c7bc5a PZ |
8935 | |
8936 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 8937 | yes = false; |
ddb5b488 | 8938 | |
21a16cc2 PZ |
8939 | /* If "no ...", squash trailing parameter */ |
8940 | if (!yes) | |
8941 | label_auto = NULL; | |
8942 | ||
e70e9f8e PZ |
8943 | if (yes) { |
8944 | if (!label_auto) | |
8945 | label = label_val; /* parser should force unsigned */ | |
8946 | } | |
ddb5b488 | 8947 | |
0ca70ba5 | 8948 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8949 | if (afi == AFI_MAX) |
8950 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 8951 | |
e70e9f8e | 8952 | |
69b07479 DS |
8953 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
8954 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
8955 | /* no change */ | |
8956 | return CMD_SUCCESS; | |
e70e9f8e | 8957 | |
69b07479 DS |
8958 | /* |
8959 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8960 | */ | |
8961 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8962 | bgp_get_default(), bgp); | |
8963 | ||
8964 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8965 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
8966 | ||
8967 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
8968 | ||
8969 | /* | |
8970 | * label has previously been automatically | |
8971 | * assigned by labelpool: release it | |
8972 | * | |
8973 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
8974 | * means the automatic assignment is in flight | |
8975 | * and therefore the labelpool callback must | |
8976 | * detect that the auto label is not needed. | |
8977 | */ | |
8978 | ||
8979 | bgp_lp_release(LP_TYPE_VRF, | |
8980 | &bgp->vpn_policy[afi], | |
8981 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 8982 | } |
69b07479 DS |
8983 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
8984 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
8985 | } | |
ddb5b488 | 8986 | |
69b07479 DS |
8987 | bgp->vpn_policy[afi].tovpn_label = label; |
8988 | if (label_auto) { | |
8989 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8990 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
8991 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
8992 | vpn_leak_label_callback); | |
ddb5b488 PZ |
8993 | } |
8994 | ||
69b07479 DS |
8995 | /* post-change: re-export vpn routes */ |
8996 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8997 | bgp_get_default(), bgp); | |
8998 | ||
0d020cd6 | 8999 | hook_call(bgp_snmp_update_last_changed, bgp); |
ddb5b488 PZ |
9000 | return CMD_SUCCESS; |
9001 | } | |
9002 | ||
b72c9e14 HS |
9003 | DEFPY (af_sid_vpn_export, |
9004 | af_sid_vpn_export_cmd, | |
46279a11 | 9005 | "[no] sid vpn export <(1-1048575)$sid_idx|auto$sid_auto>", |
b72c9e14 HS |
9006 | NO_STR |
9007 | "sid value for VRF\n" | |
9008 | "Between current address-family and vpn\n" | |
9009 | "For routes leaked from current address-family to vpn\n" | |
9010 | "Sid allocation index\n" | |
9011 | "Automatically assign a label\n") | |
9012 | { | |
9013 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9014 | afi_t afi; | |
9015 | int debug = 0; | |
9016 | int idx = 0; | |
9017 | bool yes = true; | |
9018 | ||
9019 | if (argv_find(argv, argc, "no", &idx)) | |
9020 | yes = false; | |
9021 | debug = (BGP_DEBUG(vpn, VPN_LEAK_TO_VRF) | | |
9022 | BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF)); | |
9023 | ||
9024 | afi = vpn_policy_getafi(vty, bgp, false); | |
9025 | if (afi == AFI_MAX) | |
9026 | return CMD_WARNING_CONFIG_FAILED; | |
9027 | ||
9028 | if (!yes) { | |
9029 | /* implement me */ | |
4d4c404b | 9030 | vty_out(vty, "It's not implemented\n"); |
b72c9e14 HS |
9031 | return CMD_WARNING_CONFIG_FAILED; |
9032 | } | |
9033 | ||
527588aa CS |
9034 | if (bgp->tovpn_sid_index != 0 || |
9035 | CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO)) { | |
9036 | vty_out(vty, | |
9037 | "per-vrf sid and per-af sid are mutually exclusive\n" | |
9038 | "Failed: per-vrf sid is configured. Remove per-vrf sid before configuring per-af sid\n"); | |
9039 | return CMD_WARNING_CONFIG_FAILED; | |
9040 | } | |
9041 | ||
b72c9e14 HS |
9042 | /* skip when it's already configured */ |
9043 | if ((sid_idx != 0 && bgp->vpn_policy[afi].tovpn_sid_index != 0) | |
9044 | || (sid_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
9045 | BGP_VPN_POLICY_TOVPN_SID_AUTO))) | |
9046 | return CMD_SUCCESS; | |
9047 | ||
7de4c885 HS |
9048 | /* |
9049 | * mode change between sid_idx and sid_auto isn't supported. | |
9050 | * user must negate sid vpn export when they want to change the mode | |
9051 | */ | |
b72c9e14 HS |
9052 | if ((sid_auto && bgp->vpn_policy[afi].tovpn_sid_index != 0) |
9053 | || (sid_idx != 0 && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
9054 | BGP_VPN_POLICY_TOVPN_SID_AUTO))) { | |
9055 | vty_out(vty, "it's already configured as %s.\n", | |
9056 | sid_auto ? "auto-mode" : "idx-mode"); | |
9057 | return CMD_WARNING_CONFIG_FAILED; | |
9058 | } | |
9059 | ||
9060 | /* pre-change */ | |
9061 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9062 | bgp_get_default(), bgp); | |
9063 | ||
9064 | if (sid_auto) { | |
9065 | /* SID allocation auto-mode */ | |
9066 | if (debug) | |
9067 | zlog_debug("%s: auto sid alloc.", __func__); | |
9068 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
9069 | BGP_VPN_POLICY_TOVPN_SID_AUTO); | |
9070 | } else { | |
9071 | /* SID allocation index-mode */ | |
9072 | if (debug) | |
9073 | zlog_debug("%s: idx %ld sid alloc.", __func__, sid_idx); | |
9074 | bgp->vpn_policy[afi].tovpn_sid_index = sid_idx; | |
9075 | } | |
9076 | ||
9077 | /* post-change */ | |
9078 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9079 | bgp_get_default(), bgp); | |
9080 | return CMD_SUCCESS; | |
9081 | } | |
9082 | ||
527588aa CS |
9083 | DEFPY (bgp_sid_vpn_export, |
9084 | bgp_sid_vpn_export_cmd, | |
9085 | "[no] sid vpn per-vrf export <(1-255)$sid_idx|auto$sid_auto>", | |
9086 | NO_STR | |
9087 | "sid value for VRF\n" | |
9088 | "Between current vrf and vpn\n" | |
9089 | "sid per-VRF (both IPv4 and IPv6 address families)\n" | |
9090 | "For routes leaked from current vrf to vpn\n" | |
9091 | "Sid allocation index\n" | |
9092 | "Automatically assign a label\n") | |
9093 | { | |
9094 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9095 | int debug; | |
9096 | ||
9097 | debug = (BGP_DEBUG(vpn, VPN_LEAK_TO_VRF) | | |
9098 | BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF)); | |
9099 | ||
9100 | if (no) { | |
e606d8ec CS |
9101 | /* when per-VRF SID is not set, do nothing */ |
9102 | if (bgp->tovpn_sid_index == 0 && | |
9103 | !CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO)) | |
9104 | return CMD_SUCCESS; | |
9105 | ||
9106 | sid_idx = 0; | |
9107 | sid_auto = false; | |
9108 | bgp->tovpn_sid_index = 0; | |
9109 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO); | |
527588aa CS |
9110 | } |
9111 | ||
9112 | if (bgp->vpn_policy[AFI_IP].tovpn_sid_index != 0 || | |
9113 | CHECK_FLAG(bgp->vpn_policy[AFI_IP].flags, | |
9114 | BGP_VPN_POLICY_TOVPN_SID_AUTO) || | |
9115 | bgp->vpn_policy[AFI_IP6].tovpn_sid_index != 0 || | |
9116 | CHECK_FLAG(bgp->vpn_policy[AFI_IP6].flags, | |
9117 | BGP_VPN_POLICY_TOVPN_SID_AUTO)) { | |
9118 | vty_out(vty, | |
9119 | "per-vrf sid and per-af sid are mutually exclusive\n" | |
9120 | "Failed: per-af sid is configured. Remove per-af sid before configuring per-vrf sid\n"); | |
9121 | return CMD_WARNING_CONFIG_FAILED; | |
9122 | } | |
9123 | ||
9124 | /* skip when it's already configured */ | |
9125 | if ((sid_idx != 0 && bgp->tovpn_sid_index != 0) || | |
9126 | (sid_auto && CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO))) | |
9127 | return CMD_SUCCESS; | |
9128 | ||
9129 | /* | |
9130 | * mode change between sid_idx and sid_auto isn't supported. | |
9131 | * user must negate sid vpn export when they want to change the mode | |
9132 | */ | |
9133 | if ((sid_auto && bgp->tovpn_sid_index != 0) || | |
9134 | (sid_idx != 0 && | |
9135 | CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO))) { | |
9136 | vty_out(vty, "it's already configured as %s.\n", | |
9137 | sid_auto ? "auto-mode" : "idx-mode"); | |
9138 | return CMD_WARNING_CONFIG_FAILED; | |
9139 | } | |
9140 | ||
9141 | /* pre-change */ | |
9142 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP, bgp_get_default(), | |
9143 | bgp); | |
9144 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP6, bgp_get_default(), | |
9145 | bgp); | |
9146 | ||
9147 | if (sid_auto) { | |
9148 | /* SID allocation auto-mode */ | |
9149 | if (debug) | |
9150 | zlog_debug("%s: auto per-vrf sid alloc.", __func__); | |
9151 | SET_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO); | |
e606d8ec | 9152 | } else if (sid_idx != 0) { |
527588aa CS |
9153 | /* SID allocation index-mode */ |
9154 | if (debug) | |
9155 | zlog_debug("%s: idx %ld per-vrf sid alloc.", __func__, | |
9156 | sid_idx); | |
9157 | bgp->tovpn_sid_index = sid_idx; | |
9158 | } | |
9159 | ||
9160 | /* post-change */ | |
9161 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP, bgp_get_default(), | |
9162 | bgp); | |
9163 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP6, | |
9164 | bgp_get_default(), bgp); | |
9165 | ||
9166 | return CMD_SUCCESS; | |
9167 | } | |
9168 | ||
b9c7bc5a PZ |
9169 | ALIAS (af_label_vpn_export, |
9170 | af_no_label_vpn_export_cmd, | |
9171 | "no label vpn export", | |
9172 | NO_STR | |
9173 | "label value for VRF\n" | |
9174 | "Between current address-family and vpn\n" | |
9175 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 9176 | |
e606d8ec CS |
9177 | ALIAS (bgp_sid_vpn_export, |
9178 | no_bgp_sid_vpn_export_cmd, | |
9179 | "no$no sid vpn per-vrf export", | |
9180 | NO_STR | |
9181 | "sid value for VRF\n" | |
9182 | "Between current vrf and vpn\n" | |
9183 | "sid per-VRF (both IPv4 and IPv6 address families)\n" | |
9184 | "For routes leaked from current vrf to vpn\n") | |
9185 | ||
585f1adc | 9186 | DEFPY (af_nexthop_vpn_export, |
b9c7bc5a | 9187 | af_nexthop_vpn_export_cmd, |
8c85ca28 | 9188 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", |
b9c7bc5a | 9189 | NO_STR |
ddb5b488 | 9190 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
9191 | "Between current address-family and vpn\n" |
9192 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
9193 | "IPv4 prefix\n" |
9194 | "IPv6 prefix\n") | |
9195 | { | |
585f1adc | 9196 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ddb5b488 | 9197 | afi_t afi; |
ddb5b488 PZ |
9198 | struct prefix p; |
9199 | ||
8c85ca28 QY |
9200 | if (!no) { |
9201 | if (!nexthop_su) { | |
9202 | vty_out(vty, "%% Nexthop required\n"); | |
9203 | return CMD_WARNING_CONFIG_FAILED; | |
9204 | } | |
8c85ca28 | 9205 | if (!sockunion2hostprefix(nexthop_su, &p)) |
b9c7bc5a PZ |
9206 | return CMD_WARNING_CONFIG_FAILED; |
9207 | } | |
ddb5b488 | 9208 | |
585f1adc IR |
9209 | afi = vpn_policy_getafi(vty, bgp, false); |
9210 | if (afi == AFI_MAX) | |
9211 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9212 | |
585f1adc IR |
9213 | /* |
9214 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
9215 | */ | |
9216 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9217 | bgp_get_default(), bgp); | |
ddb5b488 | 9218 | |
585f1adc IR |
9219 | if (!no) { |
9220 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
9221 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
9222 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
9223 | } else { | |
9224 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
9225 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
9226 | } | |
69b07479 | 9227 | |
585f1adc IR |
9228 | /* post-change: re-export vpn routes */ |
9229 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9230 | bgp_get_default(), bgp); | |
37a87b8f | 9231 | |
585f1adc | 9232 | return CMD_SUCCESS; |
ddb5b488 PZ |
9233 | } |
9234 | ||
b9c7bc5a | 9235 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 9236 | { |
b9c7bc5a PZ |
9237 | if (!strcmp(dstr, "import")) { |
9238 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
9239 | } else if (!strcmp(dstr, "export")) { | |
9240 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
9241 | } else if (!strcmp(dstr, "both")) { | |
9242 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
9243 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
9244 | } else { | |
9245 | vty_out(vty, "%% direction parse error\n"); | |
9246 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9247 | } |
ddb5b488 PZ |
9248 | return CMD_SUCCESS; |
9249 | } | |
9250 | ||
b9c7bc5a PZ |
9251 | DEFPY (af_rt_vpn_imexport, |
9252 | af_rt_vpn_imexport_cmd, | |
9253 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
9254 | NO_STR | |
9255 | "Specify route target list\n" | |
ddb5b488 | 9256 | "Specify route target list\n" |
b9c7bc5a PZ |
9257 | "Between current address-family and vpn\n" |
9258 | "For routes leaked from vpn to current address-family: match any\n" | |
9259 | "For routes leaked from current address-family to vpn: set\n" | |
9260 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
9261 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
9262 | { | |
9263 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9264 | int ret; | |
9265 | struct ecommunity *ecom = NULL; | |
9266 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
9c2fd3fe | 9267 | enum vpn_policy_direction dir; |
ddb5b488 PZ |
9268 | afi_t afi; |
9269 | int idx = 0; | |
c6423c31 | 9270 | bool yes = true; |
ddb5b488 | 9271 | |
b9c7bc5a | 9272 | if (argv_find(argv, argc, "no", &idx)) |
c6423c31 | 9273 | yes = false; |
b9c7bc5a | 9274 | |
0ca70ba5 | 9275 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9276 | if (afi == AFI_MAX) |
9277 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9278 | |
b9c7bc5a | 9279 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
9280 | if (ret != CMD_SUCCESS) |
9281 | return ret; | |
9282 | ||
b9c7bc5a PZ |
9283 | if (yes) { |
9284 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
9285 | vty_out(vty, "%% Missing RTLIST\n"); | |
9286 | return CMD_WARNING_CONFIG_FAILED; | |
9287 | } | |
c6423c31 | 9288 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, false); |
b9c7bc5a PZ |
9289 | if (ret != CMD_SUCCESS) { |
9290 | return ret; | |
9291 | } | |
ddb5b488 PZ |
9292 | } |
9293 | ||
69b07479 DS |
9294 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
9295 | if (!dodir[dir]) | |
ddb5b488 | 9296 | continue; |
ddb5b488 | 9297 | |
69b07479 | 9298 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 9299 | |
69b07479 DS |
9300 | if (yes) { |
9301 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
9302 | ecommunity_free( | |
9303 | &bgp->vpn_policy[afi].rtlist[dir]); | |
9304 | bgp->vpn_policy[afi].rtlist[dir] = | |
9305 | ecommunity_dup(ecom); | |
9306 | } else { | |
9307 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
9308 | ecommunity_free( | |
9309 | &bgp->vpn_policy[afi].rtlist[dir]); | |
9310 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 9311 | } |
69b07479 DS |
9312 | |
9313 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 9314 | } |
69b07479 | 9315 | |
d555f3e9 PZ |
9316 | if (ecom) |
9317 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
9318 | |
9319 | return CMD_SUCCESS; | |
9320 | } | |
9321 | ||
b9c7bc5a PZ |
9322 | ALIAS (af_rt_vpn_imexport, |
9323 | af_no_rt_vpn_imexport_cmd, | |
9324 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
9325 | NO_STR |
9326 | "Specify route target list\n" | |
b9c7bc5a PZ |
9327 | "Specify route target list\n" |
9328 | "Between current address-family and vpn\n" | |
9329 | "For routes leaked from vpn to current address-family\n" | |
9330 | "For routes leaked from current address-family to vpn\n" | |
9331 | "both import and export\n") | |
9332 | ||
585f1adc | 9333 | DEFPY (af_route_map_vpn_imexport, |
b9c7bc5a PZ |
9334 | af_route_map_vpn_imexport_cmd, |
9335 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
9336 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
9337 | NO_STR | |
ddb5b488 | 9338 | "Specify route map\n" |
b9c7bc5a PZ |
9339 | "Between current address-family and vpn\n" |
9340 | "For routes leaked from vpn to current address-family\n" | |
9341 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
9342 | "name of route-map\n") |
9343 | { | |
585f1adc IR |
9344 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9345 | int ret; | |
9346 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
9c2fd3fe | 9347 | enum vpn_policy_direction dir; |
ddb5b488 | 9348 | afi_t afi; |
ddb5b488 | 9349 | int idx = 0; |
585f1adc | 9350 | bool yes = true; |
ddb5b488 | 9351 | |
585f1adc IR |
9352 | if (argv_find(argv, argc, "no", &idx)) |
9353 | yes = false; | |
ddb5b488 | 9354 | |
585f1adc IR |
9355 | afi = vpn_policy_getafi(vty, bgp, false); |
9356 | if (afi == AFI_MAX) | |
9357 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9358 | |
585f1adc IR |
9359 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
9360 | if (ret != CMD_SUCCESS) | |
9361 | return ret; | |
ddb5b488 | 9362 | |
585f1adc IR |
9363 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
9364 | if (!dodir[dir]) | |
9365 | continue; | |
69b07479 | 9366 | |
585f1adc IR |
9367 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
9368 | ||
9369 | if (yes) { | |
9370 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
9371 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9372 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9373 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
9374 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
9375 | bgp->vpn_policy[afi].rmap[dir] = | |
9376 | route_map_lookup_warn_noexist(vty, rmap_str); | |
9377 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
9378 | return CMD_SUCCESS; | |
9379 | } else { | |
9380 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
9381 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9382 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9383 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
9384 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
9385 | } | |
9386 | ||
9387 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
9388 | } | |
ddb5b488 | 9389 | |
585f1adc | 9390 | return CMD_SUCCESS; |
ddb5b488 PZ |
9391 | } |
9392 | ||
b9c7bc5a PZ |
9393 | ALIAS (af_route_map_vpn_imexport, |
9394 | af_no_route_map_vpn_imexport_cmd, | |
9395 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
9396 | NO_STR |
9397 | "Specify route map\n" | |
b9c7bc5a PZ |
9398 | "Between current address-family and vpn\n" |
9399 | "For routes leaked from vpn to current address-family\n" | |
9400 | "For routes leaked from current address-family to vpn\n") | |
9401 | ||
bb4f6190 | 9402 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
ae6a6fb4 | 9403 | "import vrf route-map RMAP$rmap_str", |
bb4f6190 DS |
9404 | "Import routes from another VRF\n" |
9405 | "Vrf routes being filtered\n" | |
9406 | "Specify route map\n" | |
9407 | "name of route-map\n") | |
9408 | { | |
9409 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9c2fd3fe | 9410 | enum vpn_policy_direction dir = BGP_VPN_POLICY_DIR_FROMVPN; |
bb4f6190 | 9411 | afi_t afi; |
bb4f6190 DS |
9412 | struct bgp *bgp_default; |
9413 | ||
0ca70ba5 | 9414 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
9415 | if (afi == AFI_MAX) |
9416 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
9417 | |
9418 | bgp_default = bgp_get_default(); | |
9419 | if (!bgp_default) { | |
9420 | int32_t ret; | |
9421 | as_t as = bgp->as; | |
9422 | ||
9423 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
9424 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
9425 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
9426 | |
9427 | if (ret) { | |
9428 | vty_out(vty, | |
9429 | "VRF default is not configured as a bgp instance\n"); | |
9430 | return CMD_WARNING; | |
9431 | } | |
9432 | } | |
9433 | ||
69b07479 | 9434 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 9435 | |
ae6a6fb4 DS |
9436 | if (bgp->vpn_policy[afi].rmap_name[dir]) |
9437 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9438 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9439 | bgp->vpn_policy[afi].rmap_name[dir] = | |
9440 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
9441 | bgp->vpn_policy[afi].rmap[dir] = | |
9442 | route_map_lookup_warn_noexist(vty, rmap_str); | |
9443 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
9444 | return CMD_SUCCESS; | |
9445 | ||
9446 | SET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9447 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
bb4f6190 | 9448 | |
69b07479 DS |
9449 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
9450 | ||
bb4f6190 DS |
9451 | return CMD_SUCCESS; |
9452 | } | |
9453 | ||
ae6a6fb4 DS |
9454 | DEFPY(af_no_import_vrf_route_map, af_no_import_vrf_route_map_cmd, |
9455 | "no import vrf route-map [RMAP$rmap_str]", | |
bb4f6190 DS |
9456 | NO_STR |
9457 | "Import routes from another VRF\n" | |
9458 | "Vrf routes being filtered\n" | |
ae6a6fb4 DS |
9459 | "Specify route map\n" |
9460 | "name of route-map\n") | |
9461 | { | |
9462 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9c2fd3fe | 9463 | enum vpn_policy_direction dir = BGP_VPN_POLICY_DIR_FROMVPN; |
ae6a6fb4 DS |
9464 | afi_t afi; |
9465 | ||
9466 | afi = vpn_policy_getafi(vty, bgp, true); | |
9467 | if (afi == AFI_MAX) | |
9468 | return CMD_WARNING_CONFIG_FAILED; | |
9469 | ||
9470 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
9471 | ||
9472 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
9473 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9474 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9475 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
9476 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
9477 | ||
9478 | if (bgp->vpn_policy[afi].import_vrf->count == 0) | |
9479 | UNSET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9480 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
9481 | ||
9482 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
9483 | ||
9484 | return CMD_SUCCESS; | |
9485 | } | |
bb4f6190 | 9486 | |
585f1adc IR |
9487 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
9488 | "[no] import vrf VIEWVRFNAME$import_name", | |
9489 | NO_STR | |
9490 | "Import routes from another VRF\n" | |
9491 | "VRF to import from\n" | |
9492 | "The name of the VRF\n") | |
12a844a5 | 9493 | { |
585f1adc IR |
9494 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9495 | struct listnode *node; | |
9496 | struct bgp *vrf_bgp, *bgp_default; | |
9497 | int32_t ret = 0; | |
9498 | as_t as = bgp->as; | |
9499 | bool remove = false; | |
9500 | int32_t idx = 0; | |
9501 | char *vname; | |
9502 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; | |
12a844a5 DS |
9503 | safi_t safi; |
9504 | afi_t afi; | |
9505 | ||
867f0cca | 9506 | if (import_name == NULL) { |
9507 | vty_out(vty, "%% Missing import name\n"); | |
9508 | return CMD_WARNING; | |
9509 | } | |
9510 | ||
ae6a6fb4 DS |
9511 | if (strcmp(import_name, "route-map") == 0) { |
9512 | vty_out(vty, "%% Must include route-map name\n"); | |
9513 | return CMD_WARNING; | |
9514 | } | |
9515 | ||
585f1adc IR |
9516 | if (argv_find(argv, argc, "no", &idx)) |
9517 | remove = true; | |
9518 | ||
9519 | afi = vpn_policy_getafi(vty, bgp, true); | |
9520 | if (afi == AFI_MAX) | |
9521 | return CMD_WARNING_CONFIG_FAILED; | |
9522 | ||
12a844a5 DS |
9523 | safi = bgp_node_safi(vty); |
9524 | ||
585f1adc IR |
9525 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
9526 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) | |
9527 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { | |
9528 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
9529 | remove ? "unimport" : "import", import_name); | |
9530 | return CMD_WARNING; | |
9531 | } | |
25679caa | 9532 | |
585f1adc IR |
9533 | bgp_default = bgp_get_default(); |
9534 | if (!bgp_default) { | |
9535 | /* Auto-create assuming the same AS */ | |
9536 | ret = bgp_get_vty(&bgp_default, &as, NULL, | |
9537 | BGP_INSTANCE_TYPE_DEFAULT); | |
12a844a5 | 9538 | |
585f1adc IR |
9539 | if (ret) { |
9540 | vty_out(vty, | |
9541 | "VRF default is not configured as a bgp instance\n"); | |
9542 | return CMD_WARNING; | |
9543 | } | |
9544 | } | |
12a844a5 | 9545 | |
585f1adc IR |
9546 | vrf_bgp = bgp_lookup_by_name(import_name); |
9547 | if (!vrf_bgp) { | |
9548 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) | |
9549 | vrf_bgp = bgp_default; | |
9550 | else | |
9551 | /* Auto-create assuming the same AS */ | |
9552 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type); | |
9553 | ||
9554 | if (ret) { | |
9555 | vty_out(vty, | |
9556 | "VRF %s is not configured as a bgp instance\n", | |
9557 | import_name); | |
9558 | return CMD_WARNING; | |
9559 | } | |
9560 | } | |
9561 | ||
9562 | if (remove) { | |
9563 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); | |
9564 | } else { | |
9565 | /* Already importing from "import_vrf"? */ | |
9566 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, | |
9567 | vname)) { | |
9568 | if (strcmp(vname, import_name) == 0) | |
9569 | return CMD_WARNING; | |
9570 | } | |
9571 | ||
9572 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); | |
9573 | } | |
9574 | ||
9575 | return CMD_SUCCESS; | |
12a844a5 DS |
9576 | } |
9577 | ||
b9c7bc5a | 9578 | /* This command is valid only in a bgp vrf instance or the default instance */ |
585f1adc | 9579 | DEFPY (bgp_imexport_vpn, |
b9c7bc5a PZ |
9580 | bgp_imexport_vpn_cmd, |
9581 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
9582 | NO_STR |
9583 | "Import routes to this address-family\n" | |
9584 | "Export routes from this address-family\n" | |
9585 | "to/from default instance VPN RIB\n") | |
ddb5b488 | 9586 | { |
585f1adc IR |
9587 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9588 | int previous_state; | |
37a87b8f | 9589 | afi_t afi; |
585f1adc IR |
9590 | safi_t safi; |
9591 | int idx = 0; | |
9592 | bool yes = true; | |
9593 | int flag; | |
9c2fd3fe | 9594 | enum vpn_policy_direction dir; |
585f1adc IR |
9595 | |
9596 | if (argv_find(argv, argc, "no", &idx)) | |
9597 | yes = false; | |
9598 | ||
9599 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && | |
9600 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
9601 | ||
9602 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); | |
9603 | return CMD_WARNING_CONFIG_FAILED; | |
9604 | } | |
ddb5b488 | 9605 | |
b9c7bc5a PZ |
9606 | afi = bgp_node_afi(vty); |
9607 | safi = bgp_node_safi(vty); | |
585f1adc IR |
9608 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { |
9609 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
9610 | return CMD_WARNING_CONFIG_FAILED; | |
9611 | } | |
ddb5b488 | 9612 | |
b9c7bc5a | 9613 | if (!strcmp(direction_str, "import")) { |
585f1adc IR |
9614 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; |
9615 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b9c7bc5a | 9616 | } else if (!strcmp(direction_str, "export")) { |
585f1adc IR |
9617 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; |
9618 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b9c7bc5a PZ |
9619 | } else { |
9620 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
9621 | return CMD_WARNING_CONFIG_FAILED; | |
9622 | } | |
9623 | ||
585f1adc | 9624 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); |
ddb5b488 | 9625 | |
585f1adc IR |
9626 | if (yes) { |
9627 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
9628 | if (!previous_state) { | |
9629 | /* trigger export current vrf */ | |
9630 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
9631 | } | |
9632 | } else { | |
9633 | if (previous_state) { | |
9634 | /* trigger un-export current vrf */ | |
9635 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
9636 | } | |
9637 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
9638 | } | |
37a87b8f | 9639 | |
1ca2fd11 IR |
9640 | hook_call(bgp_snmp_init_stats, bgp); |
9641 | ||
585f1adc | 9642 | return CMD_SUCCESS; |
ddb5b488 PZ |
9643 | } |
9644 | ||
301ad80a PG |
9645 | DEFPY (af_routetarget_import, |
9646 | af_routetarget_import_cmd, | |
9a659715 | 9647 | "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...", |
301ad80a PG |
9648 | NO_STR |
9649 | "Specify route target list\n" | |
9650 | "Specify route target list\n" | |
9a659715 PG |
9651 | "Specify route target list\n" |
9652 | "Specify route target list\n" | |
301ad80a PG |
9653 | "Flow-spec redirect type route target\n" |
9654 | "Import routes to this address-family\n" | |
9a659715 | 9655 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n") |
301ad80a PG |
9656 | { |
9657 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9658 | int ret; | |
9659 | struct ecommunity *ecom = NULL; | |
301ad80a | 9660 | afi_t afi; |
9a659715 | 9661 | int idx = 0, idx_unused = 0; |
c6423c31 PG |
9662 | bool yes = true; |
9663 | bool rt6 = false; | |
301ad80a PG |
9664 | |
9665 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 9666 | yes = false; |
301ad80a | 9667 | |
9a659715 PG |
9668 | if (argv_find(argv, argc, "rt6", &idx_unused) || |
9669 | argv_find(argv, argc, "route-target6", &idx_unused)) | |
c6423c31 | 9670 | rt6 = true; |
301ad80a | 9671 | |
0ca70ba5 | 9672 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9673 | if (afi == AFI_MAX) |
9674 | return CMD_WARNING_CONFIG_FAILED; | |
9675 | ||
9a659715 PG |
9676 | if (rt6 && afi != AFI_IP6) |
9677 | return CMD_WARNING_CONFIG_FAILED; | |
9678 | ||
301ad80a PG |
9679 | if (yes) { |
9680 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
9681 | vty_out(vty, "%% Missing RTLIST\n"); | |
9682 | return CMD_WARNING_CONFIG_FAILED; | |
9683 | } | |
9a659715 | 9684 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, rt6); |
301ad80a PG |
9685 | if (ret != CMD_SUCCESS) |
9686 | return ret; | |
9687 | } | |
69b07479 DS |
9688 | |
9689 | if (yes) { | |
9690 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9691 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9692 | .import_redirect_rtlist); |
69b07479 DS |
9693 | bgp->vpn_policy[afi].import_redirect_rtlist = |
9694 | ecommunity_dup(ecom); | |
9695 | } else { | |
9696 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9697 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9698 | .import_redirect_rtlist); |
69b07479 | 9699 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 9700 | } |
69b07479 | 9701 | |
301ad80a PG |
9702 | if (ecom) |
9703 | ecommunity_free(&ecom); | |
9704 | ||
9705 | return CMD_SUCCESS; | |
9706 | } | |
9707 | ||
505e5056 | 9708 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 9709 | address_family_ipv4_safi_cmd, |
9710 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9711 | "Enter Address Family command mode\n" | |
00e6edb9 | 9712 | BGP_AF_STR |
7c40bf39 | 9713 | BGP_SAFI_WITH_LABEL_HELP_STR) |
718e3744 | 9714 | { |
f51bae9c | 9715 | |
d62a17ae | 9716 | if (argc == 3) { |
585f1adc IR |
9717 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9718 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
9719 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT | |
a4d82a8a | 9720 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9721 | && safi != SAFI_EVPN) { |
31947174 MK |
9722 | vty_out(vty, |
9723 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9724 | return CMD_WARNING_CONFIG_FAILED; |
9725 | } | |
585f1adc IR |
9726 | vty->node = bgp_node_type(AFI_IP, safi); |
9727 | } else | |
9728 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 9729 | |
d62a17ae | 9730 | return CMD_SUCCESS; |
718e3744 | 9731 | } |
9732 | ||
505e5056 | 9733 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 9734 | address_family_ipv6_safi_cmd, |
9735 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9736 | "Enter Address Family command mode\n" | |
00e6edb9 | 9737 | BGP_AF_STR |
7c40bf39 | 9738 | BGP_SAFI_WITH_LABEL_HELP_STR) |
25ffbdc1 | 9739 | { |
d62a17ae | 9740 | if (argc == 3) { |
585f1adc IR |
9741 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9742 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
9743 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT | |
a4d82a8a | 9744 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9745 | && safi != SAFI_EVPN) { |
31947174 MK |
9746 | vty_out(vty, |
9747 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9748 | return CMD_WARNING_CONFIG_FAILED; |
9749 | } | |
585f1adc IR |
9750 | vty->node = bgp_node_type(AFI_IP6, safi); |
9751 | } else | |
9752 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 9753 | |
d62a17ae | 9754 | return CMD_SUCCESS; |
25ffbdc1 | 9755 | } |
718e3744 | 9756 | |
d6902373 | 9757 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 9758 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 9759 | address_family_vpnv4_cmd, |
8334fd5a | 9760 | "address-family vpnv4 [unicast]", |
718e3744 | 9761 | "Enter Address Family command mode\n" |
00e6edb9 DA |
9762 | BGP_AF_STR |
9763 | BGP_AF_MODIFIER_STR) | |
718e3744 | 9764 | { |
d62a17ae | 9765 | vty->node = BGP_VPNV4_NODE; |
9766 | return CMD_SUCCESS; | |
718e3744 | 9767 | } |
9768 | ||
505e5056 | 9769 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 9770 | address_family_vpnv6_cmd, |
8334fd5a | 9771 | "address-family vpnv6 [unicast]", |
8ecd3266 | 9772 | "Enter Address Family command mode\n" |
00e6edb9 DA |
9773 | BGP_AF_STR |
9774 | BGP_AF_MODIFIER_STR) | |
8ecd3266 | 9775 | { |
d62a17ae | 9776 | vty->node = BGP_VPNV6_NODE; |
9777 | return CMD_SUCCESS; | |
8ecd3266 | 9778 | } |
64e4a6c5 | 9779 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 9780 | |
505e5056 | 9781 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 9782 | address_family_evpn_cmd, |
7111c1a0 | 9783 | "address-family l2vpn evpn", |
4e0b7b6d | 9784 | "Enter Address Family command mode\n" |
00e6edb9 DA |
9785 | BGP_AF_STR |
9786 | BGP_AF_MODIFIER_STR) | |
4e0b7b6d | 9787 | { |
2131d5cf | 9788 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 9789 | vty->node = BGP_EVPN_NODE; |
9790 | return CMD_SUCCESS; | |
4e0b7b6d PG |
9791 | } |
9792 | ||
bfaab44d HS |
9793 | DEFUN_NOSH (bgp_segment_routing_srv6, |
9794 | bgp_segment_routing_srv6_cmd, | |
9795 | "segment-routing srv6", | |
9796 | "Segment-Routing configuration\n" | |
9797 | "Segment-Routing SRv6 configuration\n") | |
9798 | { | |
9799 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
92a9e6f2 | 9800 | bgp->srv6_enabled = true; |
bfaab44d HS |
9801 | vty->node = BGP_SRV6_NODE; |
9802 | return CMD_SUCCESS; | |
9803 | } | |
9804 | ||
0249b8b6 HS |
9805 | DEFUN (no_bgp_segment_routing_srv6, |
9806 | no_bgp_segment_routing_srv6_cmd, | |
9807 | "no segment-routing srv6", | |
9808 | NO_STR | |
9809 | "Segment-Routing configuration\n" | |
9810 | "Segment-Routing SRv6 configuration\n") | |
9811 | { | |
9812 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9813 | ||
9814 | if (strlen(bgp->srv6_locator_name) > 0) | |
9815 | if (bgp_srv6_locator_unset(bgp) < 0) | |
9816 | return CMD_WARNING_CONFIG_FAILED; | |
9817 | ||
9818 | bgp->srv6_enabled = false; | |
9819 | return CMD_SUCCESS; | |
9820 | } | |
9821 | ||
a0281b2e HS |
9822 | DEFPY (bgp_srv6_locator, |
9823 | bgp_srv6_locator_cmd, | |
9824 | "locator NAME$name", | |
9825 | "Specify SRv6 locator\n" | |
9826 | "Specify SRv6 locator\n") | |
9827 | { | |
9828 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7de4c885 | 9829 | int ret; |
a0281b2e HS |
9830 | |
9831 | if (strlen(bgp->srv6_locator_name) > 0 | |
9832 | && strcmp(name, bgp->srv6_locator_name) != 0) { | |
9833 | vty_out(vty, "srv6 locator is already configured\n"); | |
9834 | return CMD_WARNING_CONFIG_FAILED; | |
7de4c885 HS |
9835 | } |
9836 | ||
9837 | snprintf(bgp->srv6_locator_name, | |
9838 | sizeof(bgp->srv6_locator_name), "%s", name); | |
a0281b2e | 9839 | |
7de4c885 | 9840 | ret = bgp_zebra_srv6_manager_get_locator_chunk(name); |
a0281b2e HS |
9841 | if (ret < 0) |
9842 | return CMD_WARNING_CONFIG_FAILED; | |
9843 | ||
9844 | return CMD_SUCCESS; | |
9845 | } | |
9846 | ||
0249b8b6 HS |
9847 | DEFPY (no_bgp_srv6_locator, |
9848 | no_bgp_srv6_locator_cmd, | |
9849 | "no locator NAME$name", | |
9850 | NO_STR | |
9851 | "Specify SRv6 locator\n" | |
9852 | "Specify SRv6 locator\n") | |
9853 | { | |
9854 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9855 | ||
9856 | /* when locator isn't configured, do nothing */ | |
9857 | if (strlen(bgp->srv6_locator_name) < 1) | |
9858 | return CMD_SUCCESS; | |
9859 | ||
9860 | /* name validation */ | |
9861 | if (strcmp(name, bgp->srv6_locator_name) != 0) { | |
9862 | vty_out(vty, "%% No srv6 locator is configured\n"); | |
9863 | return CMD_WARNING_CONFIG_FAILED; | |
9864 | } | |
9865 | ||
9866 | /* unset locator */ | |
9867 | if (bgp_srv6_locator_unset(bgp) < 0) | |
9868 | return CMD_WARNING_CONFIG_FAILED; | |
9869 | ||
9870 | return CMD_SUCCESS; | |
9871 | } | |
9872 | ||
ea372e81 HS |
9873 | DEFPY (show_bgp_srv6, |
9874 | show_bgp_srv6_cmd, | |
9875 | "show bgp segment-routing srv6", | |
9876 | SHOW_STR | |
9877 | BGP_STR | |
9878 | "BGP Segment Routing\n" | |
9879 | "BGP Segment Routing SRv6\n") | |
9880 | { | |
9881 | struct bgp *bgp; | |
9882 | struct listnode *node; | |
1c21a234 | 9883 | struct srv6_locator_chunk *chunk; |
ea372e81 | 9884 | struct bgp_srv6_function *func; |
ea372e81 | 9885 | char buf[256]; |
ea372e81 HS |
9886 | |
9887 | bgp = bgp_get_default(); | |
96db4340 | 9888 | if (!bgp) |
ea372e81 HS |
9889 | return CMD_SUCCESS; |
9890 | ||
9891 | vty_out(vty, "locator_name: %s\n", bgp->srv6_locator_name); | |
9892 | vty_out(vty, "locator_chunks:\n"); | |
dccef127 | 9893 | for (ALL_LIST_ELEMENTS_RO(bgp->srv6_locator_chunks, node, chunk)) { |
511211bf | 9894 | vty_out(vty, "- %pFX\n", &chunk->prefix); |
dccef127 CS |
9895 | vty_out(vty, " block-length: %d\n", chunk->block_bits_length); |
9896 | vty_out(vty, " node-length: %d\n", chunk->node_bits_length); | |
9897 | vty_out(vty, " func-length: %d\n", | |
9898 | chunk->function_bits_length); | |
9899 | vty_out(vty, " arg-length: %d\n", chunk->argument_bits_length); | |
9900 | } | |
ea372e81 HS |
9901 | |
9902 | vty_out(vty, "functions:\n"); | |
9903 | for (ALL_LIST_ELEMENTS_RO(bgp->srv6_functions, node, func)) { | |
9904 | inet_ntop(AF_INET6, &func->sid, buf, sizeof(buf)); | |
9905 | vty_out(vty, "- sid: %s\n", buf); | |
9906 | vty_out(vty, " locator: %s\n", func->locator_name); | |
9907 | } | |
9908 | ||
9909 | vty_out(vty, "bgps:\n"); | |
9910 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) { | |
9911 | vty_out(vty, "- name: %s\n", | |
9912 | bgp->name ? bgp->name : "default"); | |
9913 | ||
1830895a CS |
9914 | vty_out(vty, " vpn_policy[AFI_IP].tovpn_sid: %pI6\n", |
9915 | bgp->vpn_policy[AFI_IP].tovpn_sid); | |
9916 | vty_out(vty, " vpn_policy[AFI_IP6].tovpn_sid: %pI6\n", | |
9917 | bgp->vpn_policy[AFI_IP6].tovpn_sid); | |
9f5d4430 | 9918 | vty_out(vty, " per-vrf tovpn_sid: %pI6\n", bgp->tovpn_sid); |
ea372e81 HS |
9919 | } |
9920 | ||
9921 | return CMD_SUCCESS; | |
9922 | } | |
9923 | ||
505e5056 | 9924 | DEFUN_NOSH (exit_address_family, |
718e3744 | 9925 | exit_address_family_cmd, |
9926 | "exit-address-family", | |
9927 | "Exit from Address Family configuration mode\n") | |
9928 | { | |
d62a17ae | 9929 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
9930 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
9931 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
9932 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
9933 | || vty->node == BGP_EVPN_NODE |
9934 | || vty->node == BGP_FLOWSPECV4_NODE | |
9935 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 9936 | vty->node = BGP_NODE; |
9937 | return CMD_SUCCESS; | |
718e3744 | 9938 | } |
6b0655a2 | 9939 | |
8ad7271d | 9940 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 9941 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
9942 | const char *ip_str, afi_t afi, safi_t safi, | |
9943 | struct prefix_rd *prd) | |
9944 | { | |
9945 | int ret; | |
9946 | struct prefix match; | |
9bcb3eef DS |
9947 | struct bgp_dest *dest; |
9948 | struct bgp_dest *rm; | |
d62a17ae | 9949 | struct bgp *bgp; |
9950 | struct bgp_table *table; | |
9951 | struct bgp_table *rib; | |
9952 | ||
9953 | /* BGP structure lookup. */ | |
9954 | if (view_name) { | |
9955 | bgp = bgp_lookup_by_name(view_name); | |
9956 | if (bgp == NULL) { | |
9957 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
9958 | view_name); | |
9959 | return CMD_WARNING; | |
9960 | } | |
9961 | } else { | |
9962 | bgp = bgp_get_default(); | |
9963 | if (bgp == NULL) { | |
9964 | vty_out(vty, "%% No BGP process is configured\n"); | |
9965 | return CMD_WARNING; | |
9966 | } | |
9967 | } | |
9968 | ||
9969 | /* Check IP address argument. */ | |
9970 | ret = str2prefix(ip_str, &match); | |
9971 | if (!ret) { | |
9972 | vty_out(vty, "%% address is malformed\n"); | |
9973 | return CMD_WARNING; | |
9974 | } | |
9975 | ||
9976 | match.family = afi2family(afi); | |
9977 | rib = bgp->rib[afi][safi]; | |
9978 | ||
9979 | if (safi == SAFI_MPLS_VPN) { | |
9bcb3eef DS |
9980 | for (dest = bgp_table_top(rib); dest; |
9981 | dest = bgp_route_next(dest)) { | |
9982 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 9983 | |
9bcb3eef | 9984 | if (prd && memcmp(dest_p->u.val, prd->val, 8) != 0) |
d62a17ae | 9985 | continue; |
9986 | ||
9bcb3eef | 9987 | table = bgp_dest_get_bgp_table_info(dest); |
b54892e0 DS |
9988 | if (table == NULL) |
9989 | continue; | |
9990 | ||
4953391b DA |
9991 | rm = bgp_node_match(table, &match); |
9992 | if (rm != NULL) { | |
b54892e0 | 9993 | const struct prefix *rm_p = |
9bcb3eef | 9994 | bgp_dest_get_prefix(rm); |
b54892e0 DS |
9995 | |
9996 | if (rm_p->prefixlen == match.prefixlen) { | |
9997 | SET_FLAG(rm->flags, | |
9998 | BGP_NODE_USER_CLEAR); | |
9999 | bgp_process(bgp, rm, afi, safi); | |
d62a17ae | 10000 | } |
9bcb3eef | 10001 | bgp_dest_unlock_node(rm); |
d62a17ae | 10002 | } |
10003 | } | |
10004 | } else { | |
4953391b DA |
10005 | dest = bgp_node_match(rib, &match); |
10006 | if (dest != NULL) { | |
9bcb3eef | 10007 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); |
b54892e0 | 10008 | |
9bcb3eef DS |
10009 | if (dest_p->prefixlen == match.prefixlen) { |
10010 | SET_FLAG(dest->flags, BGP_NODE_USER_CLEAR); | |
10011 | bgp_process(bgp, dest, afi, safi); | |
d62a17ae | 10012 | } |
9bcb3eef | 10013 | bgp_dest_unlock_node(dest); |
d62a17ae | 10014 | } |
10015 | } | |
10016 | ||
10017 | return CMD_SUCCESS; | |
8ad7271d DS |
10018 | } |
10019 | ||
b09b5ae0 | 10020 | /* one clear bgp command to rule them all */ |
718e3744 | 10021 | DEFUN (clear_ip_bgp_all, |
10022 | clear_ip_bgp_all_cmd, | |
3cb14f26 | 10023 | "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>]", |
718e3744 | 10024 | CLEAR_STR |
10025 | IP_STR | |
10026 | BGP_STR | |
838758ac | 10027 | BGP_INSTANCE_HELP_STR |
510afcd6 | 10028 | BGP_AFI_HELP_STR |
00e6edb9 | 10029 | BGP_AF_STR |
510afcd6 | 10030 | BGP_SAFI_WITH_LABEL_HELP_STR |
00e6edb9 | 10031 | BGP_AF_MODIFIER_STR |
b09b5ae0 | 10032 | "Clear all peers\n" |
453c92f6 | 10033 | "BGP IPv4 neighbor to clear\n" |
a80beece | 10034 | "BGP IPv6 neighbor to clear\n" |
838758ac | 10035 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
10036 | "Clear peers with the AS number\n" |
10037 | "Clear all external peers\n" | |
718e3744 | 10038 | "Clear all members of peer-group\n" |
b09b5ae0 | 10039 | "BGP peer-group name\n" |
b09b5ae0 DW |
10040 | BGP_SOFT_STR |
10041 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
10042 | BGP_SOFT_OUT_STR |
10043 | BGP_SOFT_IN_STR | |
10044 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
3cb14f26 DS |
10045 | BGP_SOFT_OUT_STR |
10046 | "Reset message statistics\n") | |
718e3744 | 10047 | { |
d62a17ae | 10048 | char *vrf = NULL; |
10049 | ||
dc912615 DS |
10050 | afi_t afi = AFI_UNSPEC; |
10051 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 10052 | enum clear_sort clr_sort = clear_peer; |
10053 | enum bgp_clear_type clr_type; | |
10054 | char *clr_arg = NULL; | |
10055 | ||
10056 | int idx = 0; | |
10057 | ||
10058 | /* clear [ip] bgp */ | |
10059 | if (argv_find(argv, argc, "ip", &idx)) | |
10060 | afi = AFI_IP; | |
10061 | ||
9a8bdf1c PG |
10062 | /* [<vrf> VIEWVRFNAME] */ |
10063 | if (argv_find(argv, argc, "vrf", &idx)) { | |
10064 | vrf = argv[idx + 1]->arg; | |
10065 | idx += 2; | |
10066 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
10067 | vrf = NULL; | |
10068 | } else if (argv_find(argv, argc, "view", &idx)) { | |
10069 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 10070 | vrf = argv[idx + 1]->arg; |
10071 | idx += 2; | |
10072 | } | |
d62a17ae | 10073 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
10074 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
10075 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
10076 | ||
d7b9898c | 10077 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 10078 | if (argv_find(argv, argc, "*", &idx)) { |
10079 | clr_sort = clear_all; | |
10080 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
10081 | clr_sort = clear_peer; | |
10082 | clr_arg = argv[idx]->arg; | |
10083 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
10084 | clr_sort = clear_peer; | |
10085 | clr_arg = argv[idx]->arg; | |
10086 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
10087 | clr_sort = clear_group; | |
10088 | idx++; | |
10089 | clr_arg = argv[idx]->arg; | |
d7b9898c | 10090 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 10091 | clr_sort = clear_peer; |
10092 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
10093 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
10094 | clr_sort = clear_peer; | |
10095 | clr_arg = argv[idx]->arg; | |
d62a17ae | 10096 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
10097 | clr_sort = clear_as; | |
10098 | clr_arg = argv[idx]->arg; | |
10099 | } else if (argv_find(argv, argc, "external", &idx)) { | |
10100 | clr_sort = clear_external; | |
10101 | } | |
10102 | ||
3cb14f26 | 10103 | /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */ |
d62a17ae | 10104 | if (argv_find(argv, argc, "soft", &idx)) { |
10105 | if (argv_find(argv, argc, "in", &idx) | |
10106 | || argv_find(argv, argc, "out", &idx)) | |
10107 | clr_type = strmatch(argv[idx]->text, "in") | |
10108 | ? BGP_CLEAR_SOFT_IN | |
10109 | : BGP_CLEAR_SOFT_OUT; | |
10110 | else | |
10111 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
10112 | } else if (argv_find(argv, argc, "in", &idx)) { | |
10113 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
10114 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
10115 | : BGP_CLEAR_SOFT_IN; | |
10116 | } else if (argv_find(argv, argc, "out", &idx)) { | |
10117 | clr_type = BGP_CLEAR_SOFT_OUT; | |
3cb14f26 DS |
10118 | } else if (argv_find(argv, argc, "message-stats", &idx)) { |
10119 | clr_type = BGP_CLEAR_MESSAGE_STATS; | |
d62a17ae | 10120 | } else |
10121 | clr_type = BGP_CLEAR_SOFT_NONE; | |
10122 | ||
1ca2fd11 | 10123 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); |
838758ac | 10124 | } |
01080f7c | 10125 | |
8ad7271d DS |
10126 | DEFUN (clear_ip_bgp_prefix, |
10127 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 10128 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
10129 | CLEAR_STR |
10130 | IP_STR | |
10131 | BGP_STR | |
838758ac | 10132 | BGP_INSTANCE_HELP_STR |
8ad7271d | 10133 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 10134 | "IPv4 prefix\n") |
8ad7271d | 10135 | { |
d62a17ae | 10136 | char *vrf = NULL; |
10137 | char *prefix = NULL; | |
8ad7271d | 10138 | |
d62a17ae | 10139 | int idx = 0; |
01080f7c | 10140 | |
d62a17ae | 10141 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
10142 | if (argv_find(argv, argc, "vrf", &idx)) { |
10143 | vrf = argv[idx + 1]->arg; | |
10144 | idx += 2; | |
10145 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
10146 | vrf = NULL; | |
10147 | } else if (argv_find(argv, argc, "view", &idx)) { | |
10148 | /* [<view> VIEWVRFNAME] */ | |
10149 | vrf = argv[idx + 1]->arg; | |
10150 | idx += 2; | |
10151 | } | |
0c7b1b01 | 10152 | |
d62a17ae | 10153 | prefix = argv[argc - 1]->arg; |
8ad7271d | 10154 | |
d62a17ae | 10155 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 10156 | } |
8ad7271d | 10157 | |
b09b5ae0 DW |
10158 | DEFUN (clear_bgp_ipv6_safi_prefix, |
10159 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 10160 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 10161 | CLEAR_STR |
3a2d747c | 10162 | IP_STR |
718e3744 | 10163 | BGP_STR |
00e6edb9 | 10164 | BGP_AF_STR |
46f296b4 | 10165 | BGP_SAFI_HELP_STR |
b09b5ae0 | 10166 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 10167 | "IPv6 prefix\n") |
718e3744 | 10168 | { |
9b475e76 PG |
10169 | int idx_safi = 0; |
10170 | int idx_ipv6_prefix = 0; | |
10171 | safi_t safi = SAFI_UNICAST; | |
10172 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
10173 | argv[idx_ipv6_prefix]->arg : NULL; | |
10174 | ||
10175 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 10176 | return bgp_clear_prefix( |
9b475e76 PG |
10177 | vty, NULL, prefix, AFI_IP6, |
10178 | safi, NULL); | |
838758ac | 10179 | } |
01080f7c | 10180 | |
b09b5ae0 DW |
10181 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
10182 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 10183 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 10184 | CLEAR_STR |
3a2d747c | 10185 | IP_STR |
718e3744 | 10186 | BGP_STR |
838758ac | 10187 | BGP_INSTANCE_HELP_STR |
00e6edb9 | 10188 | BGP_AF_STR |
46f296b4 | 10189 | BGP_SAFI_HELP_STR |
b09b5ae0 | 10190 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 10191 | "IPv6 prefix\n") |
718e3744 | 10192 | { |
9b475e76 | 10193 | int idx_safi = 0; |
9a8bdf1c | 10194 | int idx_vrfview = 0; |
9b475e76 PG |
10195 | int idx_ipv6_prefix = 0; |
10196 | safi_t safi = SAFI_UNICAST; | |
10197 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
10198 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 10199 | char *vrfview = NULL; |
9b475e76 | 10200 | |
9a8bdf1c PG |
10201 | /* [<view|vrf> VIEWVRFNAME] */ |
10202 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
10203 | vrfview = argv[idx_vrfview + 1]->arg; | |
10204 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
10205 | vrfview = NULL; | |
10206 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
10207 | /* [<view> VIEWVRFNAME] */ | |
10208 | vrfview = argv[idx_vrfview + 1]->arg; | |
10209 | } | |
9b475e76 PG |
10210 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
10211 | ||
d62a17ae | 10212 | return bgp_clear_prefix( |
9b475e76 PG |
10213 | vty, vrfview, prefix, |
10214 | AFI_IP6, safi, NULL); | |
718e3744 | 10215 | } |
10216 | ||
b09b5ae0 DW |
10217 | DEFUN (show_bgp_views, |
10218 | show_bgp_views_cmd, | |
d6e3c605 | 10219 | "show [ip] bgp views", |
b09b5ae0 | 10220 | SHOW_STR |
d6e3c605 | 10221 | IP_STR |
01080f7c | 10222 | BGP_STR |
b09b5ae0 | 10223 | "Show the defined BGP views\n") |
01080f7c | 10224 | { |
d62a17ae | 10225 | struct list *inst = bm->bgp; |
10226 | struct listnode *node; | |
10227 | struct bgp *bgp; | |
01080f7c | 10228 | |
d62a17ae | 10229 | vty_out(vty, "Defined BGP views:\n"); |
10230 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
10231 | /* Skip VRFs. */ | |
10232 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
10233 | continue; | |
10234 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
10235 | bgp->as); | |
10236 | } | |
e52702f2 | 10237 | |
d62a17ae | 10238 | return CMD_SUCCESS; |
e0081f70 ML |
10239 | } |
10240 | ||
8386ac43 | 10241 | DEFUN (show_bgp_vrfs, |
10242 | show_bgp_vrfs_cmd, | |
d6e3c605 | 10243 | "show [ip] bgp vrfs [json]", |
8386ac43 | 10244 | SHOW_STR |
d6e3c605 | 10245 | IP_STR |
8386ac43 | 10246 | BGP_STR |
10247 | "Show BGP VRFs\n" | |
9973d184 | 10248 | JSON_STR) |
8386ac43 | 10249 | { |
fe1dc5a3 | 10250 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 10251 | struct list *inst = bm->bgp; |
10252 | struct listnode *node; | |
10253 | struct bgp *bgp; | |
9f049418 | 10254 | bool uj = use_json(argc, argv); |
d62a17ae | 10255 | json_object *json = NULL; |
10256 | json_object *json_vrfs = NULL; | |
10257 | int count = 0; | |
d62a17ae | 10258 | |
d62a17ae | 10259 | if (uj) { |
10260 | json = json_object_new_object(); | |
10261 | json_vrfs = json_object_new_object(); | |
10262 | } | |
10263 | ||
10264 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
10265 | const char *name, *type; | |
10266 | struct peer *peer; | |
7fe96307 | 10267 | struct listnode *node2, *nnode2; |
d62a17ae | 10268 | int peers_cfg, peers_estb; |
10269 | json_object *json_vrf = NULL; | |
d62a17ae | 10270 | |
10271 | /* Skip Views. */ | |
10272 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
10273 | continue; | |
10274 | ||
10275 | count++; | |
efb4077a | 10276 | if (!uj && count == 1) { |
fe1dc5a3 | 10277 | vty_out(vty, |
efb4077a | 10278 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 10279 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
10280 | "#PeersEstb", "Name"); |
10281 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
10282 | "L3-VNI", "RouterMAC", "Interface"); | |
10283 | } | |
d62a17ae | 10284 | |
10285 | peers_cfg = peers_estb = 0; | |
10286 | if (uj) | |
10287 | json_vrf = json_object_new_object(); | |
10288 | ||
10289 | ||
7fe96307 | 10290 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 10291 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
10292 | continue; | |
10293 | peers_cfg++; | |
feb17238 | 10294 | if (peer_established(peer)) |
d62a17ae | 10295 | peers_estb++; |
10296 | } | |
10297 | ||
10298 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 10299 | name = VRF_DEFAULT_NAME; |
d62a17ae | 10300 | type = "DFLT"; |
10301 | } else { | |
10302 | name = bgp->name; | |
10303 | type = "VRF"; | |
10304 | } | |
10305 | ||
a8bf7d9c | 10306 | |
d62a17ae | 10307 | if (uj) { |
a4d82a8a PZ |
10308 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
10309 | ? -1 | |
10310 | : (int64_t)bgp->vrf_id; | |
23d0a753 DA |
10311 | char buf[BUFSIZ] = {0}; |
10312 | ||
d62a17ae | 10313 | json_object_string_add(json_vrf, "type", type); |
10314 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
c949c771 DA |
10315 | json_object_string_addf(json_vrf, "routerId", "%pI4", |
10316 | &bgp->router_id); | |
d62a17ae | 10317 | json_object_int_add(json_vrf, "numConfiguredPeers", |
10318 | peers_cfg); | |
10319 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
10320 | peers_estb); | |
10321 | ||
fe1dc5a3 | 10322 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
10323 | json_object_string_add( |
10324 | json_vrf, "rmac", | |
10325 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
10326 | json_object_string_add(json_vrf, "interface", |
10327 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
10328 | bgp->vrf_id)); | |
d62a17ae | 10329 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 10330 | } else { |
23d0a753 | 10331 | vty_out(vty, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n", |
a4d82a8a PZ |
10332 | type, |
10333 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
10334 | : (int)bgp->vrf_id, | |
23d0a753 | 10335 | &bgp->router_id, peers_cfg, peers_estb, name); |
efb4077a CS |
10336 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", |
10337 | bgp->l3vni, | |
10338 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
10339 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
10340 | bgp->vrf_id)); | |
10341 | } | |
d62a17ae | 10342 | } |
10343 | ||
10344 | if (uj) { | |
10345 | json_object_object_add(json, "vrfs", json_vrfs); | |
10346 | ||
10347 | json_object_int_add(json, "totalVrfs", count); | |
10348 | ||
75eeda93 | 10349 | vty_json(vty, json); |
d62a17ae | 10350 | } else { |
10351 | if (count) | |
10352 | vty_out(vty, | |
10353 | "\nTotal number of VRFs (including default): %d\n", | |
10354 | count); | |
10355 | } | |
10356 | ||
10357 | return CMD_SUCCESS; | |
8386ac43 | 10358 | } |
10359 | ||
48ecf8f5 DS |
10360 | DEFUN (show_bgp_mac_hash, |
10361 | show_bgp_mac_hash_cmd, | |
10362 | "show bgp mac hash", | |
10363 | SHOW_STR | |
10364 | BGP_STR | |
10365 | "Mac Address\n" | |
10366 | "Mac Address database\n") | |
10367 | { | |
10368 | bgp_mac_dump_table(vty); | |
10369 | ||
10370 | return CMD_SUCCESS; | |
10371 | } | |
acf71666 | 10372 | |
e3b78da8 | 10373 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 10374 | { |
0291c246 | 10375 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 10376 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 10377 | |
23d0a753 | 10378 | vty_out(vty, "addr: %pI4, count: %d\n", &tip->addr, tip->refcnt); |
acf71666 MK |
10379 | } |
10380 | ||
10381 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
10382 | { | |
10383 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 10384 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
10385 | |
10386 | vty_out(vty, "Tunnel-ip database:\n"); | |
10387 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 10388 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
10389 | vty); |
10390 | } | |
10391 | ||
15c81ca4 DS |
10392 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
10393 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
10394 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
10395 | "martian next-hops\n" |
10396 | "martian next-hop database\n") | |
acf71666 | 10397 | { |
0291c246 | 10398 | struct bgp *bgp = NULL; |
15c81ca4 | 10399 | int idx = 0; |
9a8bdf1c PG |
10400 | char *name = NULL; |
10401 | ||
10402 | /* [<vrf> VIEWVRFNAME] */ | |
10403 | if (argv_find(argv, argc, "vrf", &idx)) { | |
10404 | name = argv[idx + 1]->arg; | |
10405 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
10406 | name = NULL; | |
10407 | } else if (argv_find(argv, argc, "view", &idx)) | |
10408 | /* [<view> VIEWVRFNAME] */ | |
10409 | name = argv[idx + 1]->arg; | |
10410 | if (name) | |
10411 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
10412 | else |
10413 | bgp = bgp_get_default(); | |
acf71666 | 10414 | |
acf71666 MK |
10415 | if (!bgp) { |
10416 | vty_out(vty, "%% No BGP process is configured\n"); | |
10417 | return CMD_WARNING; | |
10418 | } | |
10419 | bgp_show_martian_nexthops(vty, bgp); | |
10420 | ||
10421 | return CMD_SUCCESS; | |
10422 | } | |
10423 | ||
f412b39a | 10424 | DEFUN (show_bgp_memory, |
4bf6a362 | 10425 | show_bgp_memory_cmd, |
7fa12b13 | 10426 | "show [ip] bgp memory", |
4bf6a362 | 10427 | SHOW_STR |
3a2d747c | 10428 | IP_STR |
4bf6a362 PJ |
10429 | BGP_STR |
10430 | "Global BGP memory statistics\n") | |
10431 | { | |
d62a17ae | 10432 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
10433 | unsigned long count; | |
10434 | ||
10435 | /* RIB related usage stats */ | |
10436 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
10437 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
10438 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9bcb3eef | 10439 | count * sizeof(struct bgp_dest))); |
d62a17ae | 10440 | |
10441 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
10442 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
10443 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 10444 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 10445 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
10446 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
10447 | count, | |
4b7e6066 DS |
10448 | mtype_memstr( |
10449 | memstrbuf, sizeof(memstrbuf), | |
10450 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 10451 | |
10452 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
10453 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
10454 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10455 | count * sizeof(struct bgp_static))); | |
10456 | ||
10457 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
10458 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
10459 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10460 | count * sizeof(struct bpacket))); | |
10461 | ||
10462 | /* Adj-In/Out */ | |
10463 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
10464 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
10465 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10466 | count * sizeof(struct bgp_adj_in))); | |
10467 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
10468 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
10469 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10470 | count * sizeof(struct bgp_adj_out))); | |
10471 | ||
10472 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
10473 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
10474 | count, | |
10475 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10476 | count * sizeof(struct bgp_nexthop_cache))); | |
10477 | ||
10478 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
10479 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
10480 | count, | |
10481 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10482 | count * sizeof(struct bgp_damp_info))); | |
10483 | ||
10484 | /* Attributes */ | |
10485 | count = attr_count(); | |
10486 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
10487 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10488 | count * sizeof(struct attr))); | |
10489 | ||
10490 | if ((count = attr_unknown_count())) | |
10491 | vty_out(vty, "%ld unknown attributes\n", count); | |
10492 | ||
10493 | /* AS_PATH attributes */ | |
10494 | count = aspath_count(); | |
10495 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
10496 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10497 | count * sizeof(struct aspath))); | |
10498 | ||
10499 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
10500 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
10501 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10502 | count * sizeof(struct assegment))); | |
10503 | ||
10504 | /* Other attributes */ | |
10505 | if ((count = community_count())) | |
10506 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
10507 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10508 | count * sizeof(struct community))); | |
d62a17ae | 10509 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
145f7619 DA |
10510 | vty_out(vty, |
10511 | "%ld BGP ext-community entries, using %s of memory\n", | |
10512 | count, | |
10513 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10514 | count * sizeof(struct ecommunity))); | |
d62a17ae | 10515 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
10516 | vty_out(vty, | |
10517 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
10518 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10519 | count * sizeof(struct lcommunity))); | |
d62a17ae | 10520 | |
10521 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
10522 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
10523 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10524 | count * sizeof(struct cluster_list))); | |
10525 | ||
10526 | /* Peer related usage */ | |
10527 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
10528 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
10529 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10530 | count * sizeof(struct peer))); | |
10531 | ||
10532 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
10533 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
10534 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10535 | count * sizeof(struct peer_group))); | |
10536 | ||
10537 | /* Other */ | |
d62a17ae | 10538 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
10539 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
10540 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10541 | count * sizeof(regex_t))); | |
d62a17ae | 10542 | return CMD_SUCCESS; |
4bf6a362 | 10543 | } |
fee0f4c6 | 10544 | |
57a9c8a8 DS |
10545 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
10546 | { | |
10547 | json_object *bestpath = json_object_new_object(); | |
10548 | ||
892fedb6 | 10549 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
57a9c8a8 DS |
10550 | json_object_string_add(bestpath, "asPath", "ignore"); |
10551 | ||
892fedb6 | 10552 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
57a9c8a8 DS |
10553 | json_object_string_add(bestpath, "asPath", "confed"); |
10554 | ||
892fedb6 DA |
10555 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
10556 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
a4d82a8a | 10557 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
10558 | "as-set"); |
10559 | else | |
a4d82a8a | 10560 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
10561 | "true"); |
10562 | } else | |
a4d82a8a | 10563 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 | 10564 | |
ee88563a JM |
10565 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX)) |
10566 | json_object_boolean_true_add(bestpath, "peerTypeRelax"); | |
10567 | ||
892fedb6 | 10568 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
57a9c8a8 | 10569 | json_object_string_add(bestpath, "compareRouterId", "true"); |
892fedb6 DA |
10570 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
10571 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
10572 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 10573 | json_object_string_add(bestpath, "med", "confed"); |
892fedb6 | 10574 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) |
57a9c8a8 DS |
10575 | json_object_string_add(bestpath, "med", |
10576 | "missing-as-worst"); | |
10577 | else | |
10578 | json_object_string_add(bestpath, "med", "true"); | |
10579 | } | |
10580 | ||
10581 | json_object_object_add(json, "bestPath", bestpath); | |
10582 | } | |
10583 | ||
3577f1c5 DD |
10584 | /* Print the error code/subcode for why the peer is down */ |
10585 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
10586 | json_object *json_peer, bool use_json) | |
10587 | { | |
10588 | const char *code_str; | |
10589 | const char *subcode_str; | |
10590 | ||
10591 | if (use_json) { | |
10592 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10593 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10594 | char errorcodesubcode_hexstr[5]; | |
10595 | char errorcodesubcode_str[256]; | |
10596 | ||
10597 | code_str = bgp_notify_code_str(peer->notify.code); | |
10598 | subcode_str = bgp_notify_subcode_str( | |
10599 | peer->notify.code, | |
10600 | peer->notify.subcode); | |
10601 | ||
772270f3 QY |
10602 | snprintf(errorcodesubcode_hexstr, |
10603 | sizeof(errorcodesubcode_hexstr), "%02X%02X", | |
10604 | peer->notify.code, peer->notify.subcode); | |
3577f1c5 DD |
10605 | json_object_string_add(json_peer, |
10606 | "lastErrorCodeSubcode", | |
10607 | errorcodesubcode_hexstr); | |
10608 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
10609 | code_str, subcode_str); | |
10610 | json_object_string_add(json_peer, | |
10611 | "lastNotificationReason", | |
10612 | errorcodesubcode_str); | |
eea685b6 DA |
10613 | json_object_boolean_add(json_peer, |
10614 | "lastNotificationHardReset", | |
10615 | peer->notify.hard_reset); | |
3577f1c5 DD |
10616 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED |
10617 | && peer->notify.code == BGP_NOTIFY_CEASE | |
10618 | && (peer->notify.subcode | |
10619 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10620 | || peer->notify.subcode | |
10621 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10622 | && peer->notify.length) { | |
10623 | char msgbuf[1024]; | |
10624 | const char *msg_str; | |
10625 | ||
10626 | msg_str = bgp_notify_admin_message( | |
10627 | msgbuf, sizeof(msgbuf), | |
10628 | (uint8_t *)peer->notify.data, | |
10629 | peer->notify.length); | |
10630 | if (msg_str) | |
10631 | json_object_string_add( | |
10632 | json_peer, | |
10633 | "lastShutdownDescription", | |
10634 | msg_str); | |
10635 | } | |
10636 | ||
c258527b | 10637 | } |
3577f1c5 DD |
10638 | json_object_string_add(json_peer, "lastResetDueTo", |
10639 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
10640 | json_object_int_add(json_peer, "lastResetCode", |
10641 | peer->last_reset); | |
3577f1c5 DD |
10642 | } else { |
10643 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10644 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10645 | code_str = bgp_notify_code_str(peer->notify.code); | |
10646 | subcode_str = | |
10647 | bgp_notify_subcode_str(peer->notify.code, | |
10648 | peer->notify.subcode); | |
eea685b6 | 10649 | vty_out(vty, " Notification %s (%s%s%s)\n", |
3577f1c5 | 10650 | peer->last_reset == PEER_DOWN_NOTIFY_SEND |
eea685b6 DA |
10651 | ? "sent" |
10652 | : "received", | |
10653 | code_str, subcode_str, | |
10654 | peer->notify.hard_reset | |
10655 | ? bgp_notify_subcode_str( | |
10656 | BGP_NOTIFY_CEASE, | |
10657 | BGP_NOTIFY_CEASE_HARD_RESET) | |
10658 | : ""); | |
3577f1c5 | 10659 | } else { |
e91c24c8 | 10660 | vty_out(vty, " %s\n", |
3577f1c5 DD |
10661 | peer_down_str[(int)peer->last_reset]); |
10662 | } | |
10663 | } | |
10664 | } | |
10665 | ||
10666 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
10667 | safi_t safi) | |
10668 | { | |
feb17238 | 10669 | return ((!peer_established(peer)) || !peer->afc_recv[afi][safi]); |
3577f1c5 DD |
10670 | } |
10671 | ||
10672 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
10673 | struct peer *peer, json_object *json_peer, | |
10674 | int max_neighbor_width, bool use_json) | |
10675 | { | |
10676 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10677 | int len; | |
10678 | ||
10679 | if (use_json) { | |
10680 | if (peer_dynamic_neighbor(peer)) | |
10681 | json_object_boolean_true_add(json_peer, | |
10682 | "dynamicPeer"); | |
10683 | if (peer->hostname) | |
10684 | json_object_string_add(json_peer, "hostname", | |
10685 | peer->hostname); | |
10686 | ||
10687 | if (peer->domainname) | |
10688 | json_object_string_add(json_peer, "domainname", | |
10689 | peer->domainname); | |
10690 | json_object_int_add(json_peer, "connectionsEstablished", | |
10691 | peer->established); | |
10692 | json_object_int_add(json_peer, "connectionsDropped", | |
10693 | peer->dropped); | |
10694 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
10695 | use_json, json_peer); | |
feb17238 | 10696 | if (peer_established(peer)) |
3577f1c5 DD |
10697 | json_object_string_add(json_peer, "lastResetDueTo", |
10698 | "AFI/SAFI Not Negotiated"); | |
10699 | else | |
10700 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
10701 | } else { | |
10702 | dn_flag[1] = '\0'; | |
10703 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
10704 | if (peer->hostname | |
892fedb6 | 10705 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) |
3577f1c5 DD |
10706 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
10707 | peer->hostname, peer->host); | |
10708 | else | |
10709 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
10710 | ||
10711 | /* pad the neighbor column with spaces */ | |
10712 | if (len < max_neighbor_width) | |
10713 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10714 | " "); | |
e91c24c8 | 10715 | vty_out(vty, "%7d %7d %9s", peer->established, |
3577f1c5 DD |
10716 | peer->dropped, |
10717 | peer_uptime(peer->uptime, timebuf, | |
10718 | BGP_UPTIME_LEN, 0, NULL)); | |
feb17238 | 10719 | if (peer_established(peer)) |
3577f1c5 DD |
10720 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); |
10721 | else | |
10722 | bgp_show_peer_reset(vty, peer, NULL, | |
10723 | false); | |
10724 | } | |
10725 | } | |
c258527b | 10726 | |
565e9ddd | 10727 | /* Strip peer's description to the given size. */ |
cb75bb31 DA |
10728 | static char *bgp_peer_description_stripped(char *desc, uint32_t size) |
10729 | { | |
10730 | static char stripped[BUFSIZ]; | |
64541ffa FD |
10731 | uint32_t i = 0; |
10732 | uint32_t last_space = 0; | |
cb75bb31 | 10733 | |
64541ffa FD |
10734 | while (i < size) { |
10735 | if (*(desc + i) == 0) { | |
10736 | stripped[i] = '\0'; | |
10737 | return stripped; | |
10738 | } | |
10739 | if (i != 0 && *(desc + i) == ' ' && last_space != i - 1) | |
10740 | last_space = i; | |
10741 | stripped[i] = *(desc + i); | |
10742 | i++; | |
10743 | } | |
10744 | ||
10745 | if (last_space > size) | |
10746 | stripped[size + 1] = '\0'; | |
10747 | else | |
10748 | stripped[last_space] = '\0'; | |
cb75bb31 DA |
10749 | |
10750 | return stripped; | |
10751 | } | |
3577f1c5 | 10752 | |
8c1d4cd5 LS |
10753 | /* Determine whether var peer should be filtered out of the summary. */ |
10754 | static bool bgp_show_summary_is_peer_filtered(struct peer *peer, | |
10755 | struct peer *fpeer, int as_type, | |
10756 | as_t as) | |
10757 | { | |
10758 | ||
10759 | /* filter neighbor XXXX */ | |
10760 | if (fpeer && fpeer != peer) | |
10761 | return true; | |
10762 | ||
10763 | /* filter remote-as (internal|external) */ | |
10764 | if (as_type != AS_UNSPECIFIED) { | |
10765 | if (peer->as_type == AS_SPECIFIED) { | |
10766 | if (as_type == AS_INTERNAL) { | |
10767 | if (peer->as != peer->local_as) | |
10768 | return true; | |
10769 | } else if (peer->as == peer->local_as) | |
10770 | return true; | |
10771 | } else if (as_type != peer->as_type) | |
10772 | return true; | |
10773 | } else if (as && as != peer->as) /* filter remote-as XXX */ | |
10774 | return true; | |
10775 | ||
10776 | return false; | |
10777 | } | |
10778 | ||
565e9ddd DA |
10779 | /* Show BGP peer's summary information. |
10780 | * | |
10781 | * Peer's description is stripped according to if `wide` option is given | |
10782 | * or not. | |
10783 | * | |
10784 | * When adding new columns to `show bgp summary` output, please make | |
10785 | * sure `Desc` is the lastest column to show because it can contain | |
10786 | * whitespaces and the whole output will be tricky. | |
10787 | */ | |
d62a17ae | 10788 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
8c1d4cd5 | 10789 | struct peer *fpeer, int as_type, as_t as, |
96c81f66 | 10790 | uint16_t show_flags) |
d62a17ae | 10791 | { |
10792 | struct peer *peer; | |
10793 | struct listnode *node, *nnode; | |
10794 | unsigned int count = 0, dn_count = 0; | |
10795 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10796 | char neighbor_buf[VTY_BUFSIZ]; | |
10797 | int neighbor_col_default_width = 16; | |
3577f1c5 | 10798 | int len, failed_count = 0; |
ce1944f0 | 10799 | unsigned int filtered_count = 0; |
d62a17ae | 10800 | int max_neighbor_width = 0; |
10801 | int pfx_rcd_safi; | |
3c13337d | 10802 | json_object *json = NULL; |
d62a17ae | 10803 | json_object *json_peer = NULL; |
10804 | json_object *json_peers = NULL; | |
50e05855 | 10805 | struct peer_af *paf; |
d3ada366 | 10806 | struct bgp_filter *filter; |
85eeb029 DA |
10807 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
10808 | bool show_failed = CHECK_FLAG(show_flags, BGP_SHOW_OPT_FAILED); | |
10809 | bool show_established = | |
10810 | CHECK_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); | |
10811 | bool show_wide = CHECK_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
96c81f66 | 10812 | bool show_terse = CHECK_FLAG(show_flags, BGP_SHOW_OPT_TERSE); |
d62a17ae | 10813 | |
10814 | /* labeled-unicast routes are installed in the unicast table so in order | |
10815 | * to | |
10816 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
10817 | */ | |
3577f1c5 | 10818 | |
d62a17ae | 10819 | if (safi == SAFI_LABELED_UNICAST) |
10820 | pfx_rcd_safi = SAFI_UNICAST; | |
10821 | else | |
10822 | pfx_rcd_safi = safi; | |
10823 | ||
10824 | if (use_json) { | |
3c13337d | 10825 | json = json_object_new_object(); |
d62a17ae | 10826 | json_peers = json_object_new_object(); |
3577f1c5 | 10827 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8c1d4cd5 LS |
10828 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
10829 | as_type, as)) { | |
ce1944f0 | 10830 | filtered_count++; |
8c1d4cd5 LS |
10831 | count++; |
10832 | continue; | |
10833 | } | |
10834 | ||
3577f1c5 DD |
10835 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
10836 | continue; | |
10837 | ||
10838 | if (peer->afc[afi][safi]) { | |
10839 | /* See if we have at least a single failed peer */ | |
10840 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10841 | failed_count++; | |
10842 | count++; | |
10843 | } | |
10844 | if (peer_dynamic_neighbor(peer)) | |
10845 | dn_count++; | |
10846 | } | |
c258527b | 10847 | |
d62a17ae | 10848 | } else { |
10849 | /* Loop over all neighbors that will be displayed to determine | |
10850 | * how many | |
10851 | * characters are needed for the Neighbor column | |
10852 | */ | |
10853 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
8c1d4cd5 LS |
10854 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
10855 | as_type, as)) { | |
ce1944f0 | 10856 | filtered_count++; |
8c1d4cd5 LS |
10857 | count++; |
10858 | continue; | |
10859 | } | |
10860 | ||
d62a17ae | 10861 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
10862 | continue; | |
10863 | ||
10864 | if (peer->afc[afi][safi]) { | |
10865 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10866 | if (peer_dynamic_neighbor(peer)) | |
10867 | dn_flag[0] = '*'; | |
10868 | ||
10869 | if (peer->hostname | |
892fedb6 DA |
10870 | && CHECK_FLAG(bgp->flags, |
10871 | BGP_FLAG_SHOW_HOSTNAME)) | |
772270f3 QY |
10872 | snprintf(neighbor_buf, |
10873 | sizeof(neighbor_buf), | |
10874 | "%s%s(%s) ", dn_flag, | |
10875 | peer->hostname, peer->host); | |
d62a17ae | 10876 | else |
772270f3 QY |
10877 | snprintf(neighbor_buf, |
10878 | sizeof(neighbor_buf), "%s%s ", | |
10879 | dn_flag, peer->host); | |
d62a17ae | 10880 | |
10881 | len = strlen(neighbor_buf); | |
10882 | ||
10883 | if (len > max_neighbor_width) | |
10884 | max_neighbor_width = len; | |
c258527b | 10885 | |
3577f1c5 DD |
10886 | /* See if we have at least a single failed peer */ |
10887 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10888 | failed_count++; | |
10889 | count++; | |
d62a17ae | 10890 | } |
10891 | } | |
f933309e | 10892 | |
d62a17ae | 10893 | /* Originally we displayed the Neighbor column as 16 |
10894 | * characters wide so make that the default | |
10895 | */ | |
10896 | if (max_neighbor_width < neighbor_col_default_width) | |
10897 | max_neighbor_width = neighbor_col_default_width; | |
10898 | } | |
f933309e | 10899 | |
3577f1c5 DD |
10900 | if (show_failed && !failed_count) { |
10901 | if (use_json) { | |
10902 | json_object_int_add(json, "failedPeersCount", 0); | |
10903 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 10904 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 | 10905 | |
75eeda93 | 10906 | vty_json(vty, json); |
3577f1c5 DD |
10907 | } else { |
10908 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
3577f1c5 DD |
10909 | } |
10910 | return CMD_SUCCESS; | |
10911 | } | |
c258527b | 10912 | |
3577f1c5 | 10913 | count = 0; /* Reset the value as its used again */ |
ce1944f0 | 10914 | filtered_count = 0; |
800867d8 | 10915 | dn_count = 0; |
d62a17ae | 10916 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
10917 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10918 | continue; | |
10919 | ||
ea47320b DL |
10920 | if (!peer->afc[afi][safi]) |
10921 | continue; | |
d62a17ae | 10922 | |
ea47320b DL |
10923 | if (!count) { |
10924 | unsigned long ents; | |
10925 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 10926 | int64_t vrf_id_ui; |
d62a17ae | 10927 | |
a4d82a8a PZ |
10928 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
10929 | ? -1 | |
10930 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
10931 | |
10932 | /* Usage summary and header */ | |
10933 | if (use_json) { | |
c949c771 DA |
10934 | json_object_string_addf(json, "routerId", |
10935 | "%pI4", | |
10936 | &bgp->router_id); | |
60466a63 QY |
10937 | json_object_int_add(json, "as", bgp->as); |
10938 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
10939 | json_object_string_add( |
10940 | json, "vrfName", | |
10941 | (bgp->inst_type | |
10942 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10943 | ? VRF_DEFAULT_NAME |
ea47320b DL |
10944 | : bgp->name); |
10945 | } else { | |
10946 | vty_out(vty, | |
23d0a753 DA |
10947 | "BGP router identifier %pI4, local AS number %u vrf-id %d", |
10948 | &bgp->router_id, bgp->as, | |
a4d82a8a PZ |
10949 | bgp->vrf_id == VRF_UNKNOWN |
10950 | ? -1 | |
10951 | : (int)bgp->vrf_id); | |
ea47320b DL |
10952 | vty_out(vty, "\n"); |
10953 | } | |
d62a17ae | 10954 | |
ea47320b | 10955 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 10956 | if (use_json) { |
ea47320b | 10957 | json_object_int_add( |
60466a63 | 10958 | json, "updateDelayLimit", |
ea47320b | 10959 | bgp->v_update_delay); |
d62a17ae | 10960 | |
ea47320b DL |
10961 | if (bgp->v_update_delay |
10962 | != bgp->v_establish_wait) | |
d62a17ae | 10963 | json_object_int_add( |
10964 | json, | |
ea47320b DL |
10965 | "updateDelayEstablishWait", |
10966 | bgp->v_establish_wait); | |
d62a17ae | 10967 | |
60466a63 | 10968 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
10969 | json_object_string_add( |
10970 | json, | |
10971 | "updateDelayFirstNeighbor", | |
10972 | bgp->update_delay_begin_time); | |
10973 | json_object_boolean_true_add( | |
10974 | json, | |
10975 | "updateDelayInProgress"); | |
10976 | } else { | |
10977 | if (bgp->update_delay_over) { | |
d62a17ae | 10978 | json_object_string_add( |
10979 | json, | |
10980 | "updateDelayFirstNeighbor", | |
10981 | bgp->update_delay_begin_time); | |
ea47320b | 10982 | json_object_string_add( |
d62a17ae | 10983 | json, |
ea47320b DL |
10984 | "updateDelayBestpathResumed", |
10985 | bgp->update_delay_end_time); | |
10986 | json_object_string_add( | |
d62a17ae | 10987 | json, |
ea47320b DL |
10988 | "updateDelayZebraUpdateResume", |
10989 | bgp->update_delay_zebra_resume_time); | |
10990 | json_object_string_add( | |
10991 | json, | |
10992 | "updateDelayPeerUpdateResume", | |
10993 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 10994 | } |
ea47320b DL |
10995 | } |
10996 | } else { | |
10997 | vty_out(vty, | |
10998 | "Read-only mode update-delay limit: %d seconds\n", | |
10999 | bgp->v_update_delay); | |
11000 | if (bgp->v_update_delay | |
11001 | != bgp->v_establish_wait) | |
d62a17ae | 11002 | vty_out(vty, |
ea47320b DL |
11003 | " Establish wait: %d seconds\n", |
11004 | bgp->v_establish_wait); | |
d62a17ae | 11005 | |
60466a63 | 11006 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
11007 | vty_out(vty, |
11008 | " First neighbor established: %s\n", | |
11009 | bgp->update_delay_begin_time); | |
11010 | vty_out(vty, | |
11011 | " Delay in progress\n"); | |
11012 | } else { | |
11013 | if (bgp->update_delay_over) { | |
d62a17ae | 11014 | vty_out(vty, |
11015 | " First neighbor established: %s\n", | |
11016 | bgp->update_delay_begin_time); | |
11017 | vty_out(vty, | |
ea47320b DL |
11018 | " Best-paths resumed: %s\n", |
11019 | bgp->update_delay_end_time); | |
11020 | vty_out(vty, | |
11021 | " zebra update resumed: %s\n", | |
11022 | bgp->update_delay_zebra_resume_time); | |
11023 | vty_out(vty, | |
11024 | " peers update resumed: %s\n", | |
11025 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 11026 | } |
11027 | } | |
11028 | } | |
ea47320b | 11029 | } |
d62a17ae | 11030 | |
ea47320b DL |
11031 | if (use_json) { |
11032 | if (bgp_maxmed_onstartup_configured(bgp) | |
11033 | && bgp->maxmed_active) | |
11034 | json_object_boolean_true_add( | |
60466a63 | 11035 | json, "maxMedOnStartup"); |
ea47320b DL |
11036 | if (bgp->v_maxmed_admin) |
11037 | json_object_boolean_true_add( | |
60466a63 | 11038 | json, "maxMedAdministrative"); |
d62a17ae | 11039 | |
ea47320b DL |
11040 | json_object_int_add( |
11041 | json, "tableVersion", | |
60466a63 | 11042 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 11043 | |
60466a63 QY |
11044 | ents = bgp_table_count(bgp->rib[afi][safi]); |
11045 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
11046 | json_object_int_add( |
11047 | json, "ribMemory", | |
9bcb3eef | 11048 | ents * sizeof(struct bgp_dest)); |
d62a17ae | 11049 | |
210ec2a0 | 11050 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
11051 | json_object_int_add(json, "peerCount", ents); |
11052 | json_object_int_add(json, "peerMemory", | |
11053 | ents * sizeof(struct peer)); | |
d62a17ae | 11054 | |
ea47320b DL |
11055 | if ((ents = listcount(bgp->group))) { |
11056 | json_object_int_add( | |
60466a63 | 11057 | json, "peerGroupCount", ents); |
ea47320b DL |
11058 | json_object_int_add( |
11059 | json, "peerGroupMemory", | |
996c9314 LB |
11060 | ents * sizeof(struct |
11061 | peer_group)); | |
ea47320b | 11062 | } |
d62a17ae | 11063 | |
ea47320b DL |
11064 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
11065 | BGP_CONFIG_DAMPENING)) | |
11066 | json_object_boolean_true_add( | |
60466a63 | 11067 | json, "dampeningEnabled"); |
ea47320b | 11068 | } else { |
96c81f66 LS |
11069 | if (!show_terse) { |
11070 | if (bgp_maxmed_onstartup_configured(bgp) | |
11071 | && bgp->maxmed_active) | |
11072 | vty_out(vty, | |
11073 | "Max-med on-startup active\n"); | |
11074 | if (bgp->v_maxmed_admin) | |
11075 | vty_out(vty, | |
11076 | "Max-med administrative active\n"); | |
d62a17ae | 11077 | |
96c81f66 LS |
11078 | vty_out(vty, |
11079 | "BGP table version %" PRIu64 | |
11080 | "\n", | |
11081 | bgp_table_version( | |
11082 | bgp->rib[afi][safi])); | |
ea47320b | 11083 | |
96c81f66 LS |
11084 | ents = bgp_table_count( |
11085 | bgp->rib[afi][safi]); | |
d62a17ae | 11086 | vty_out(vty, |
96c81f66 | 11087 | "RIB entries %ld, using %s of memory\n", |
d62a17ae | 11088 | ents, |
11089 | mtype_memstr( | |
11090 | memstrbuf, | |
11091 | sizeof(memstrbuf), | |
96c81f66 LS |
11092 | ents |
11093 | * sizeof( | |
11094 | struct | |
11095 | bgp_dest))); | |
d62a17ae | 11096 | |
96c81f66 LS |
11097 | /* Peer related usage */ |
11098 | ents = bgp->af_peer_count[afi][safi]; | |
11099 | vty_out(vty, | |
11100 | "Peers %ld, using %s of memory\n", | |
11101 | ents, | |
11102 | mtype_memstr( | |
11103 | memstrbuf, | |
11104 | sizeof(memstrbuf), | |
11105 | ents | |
11106 | * sizeof( | |
11107 | struct | |
11108 | peer))); | |
d62a17ae | 11109 | |
96c81f66 LS |
11110 | if ((ents = listcount(bgp->group))) |
11111 | vty_out(vty, | |
11112 | "Peer groups %ld, using %s of memory\n", | |
11113 | ents, | |
11114 | mtype_memstr( | |
11115 | memstrbuf, | |
11116 | sizeof(memstrbuf), | |
11117 | ents | |
11118 | * sizeof( | |
11119 | struct | |
11120 | peer_group))); | |
11121 | ||
11122 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
11123 | BGP_CONFIG_DAMPENING)) | |
11124 | vty_out(vty, | |
11125 | "Dampening enabled.\n"); | |
11126 | } | |
11127 | if (show_failed) { | |
11128 | vty_out(vty, "\n"); | |
11129 | ||
11130 | /* Subtract 8 here because 'Neighbor' is | |
11131 | * 8 characters */ | |
11132 | vty_out(vty, "Neighbor"); | |
11133 | vty_out(vty, "%*s", | |
11134 | max_neighbor_width - 8, " "); | |
85eeb029 DA |
11135 | vty_out(vty, |
11136 | BGP_SHOW_SUMMARY_HEADER_FAILED); | |
96c81f66 | 11137 | } |
d62a17ae | 11138 | } |
ea47320b | 11139 | } |
d62a17ae | 11140 | |
d55811cc | 11141 | paf = peer_af_find(peer, afi, safi); |
d3ada366 | 11142 | filter = &peer->filter[afi][safi]; |
db92d226 | 11143 | |
ea47320b | 11144 | count++; |
3577f1c5 DD |
11145 | /* Works for both failed & successful cases */ |
11146 | if (peer_dynamic_neighbor(peer)) | |
11147 | dn_count++; | |
d62a17ae | 11148 | |
ea47320b | 11149 | if (use_json) { |
3577f1c5 | 11150 | json_peer = NULL; |
8c1d4cd5 | 11151 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
ce1944f0 LS |
11152 | as_type, as)) { |
11153 | filtered_count++; | |
8c1d4cd5 | 11154 | continue; |
ce1944f0 | 11155 | } |
3577f1c5 DD |
11156 | if (show_failed && |
11157 | bgp_has_peer_failed(peer, afi, safi)) { | |
11158 | json_peer = json_object_new_object(); | |
11159 | bgp_show_failed_summary(vty, bgp, peer, | |
11160 | json_peer, 0, use_json); | |
11161 | } else if (!show_failed) { | |
10b49f14 | 11162 | if (show_established |
ce1944f0 LS |
11163 | && bgp_has_peer_failed(peer, afi, safi)) { |
11164 | filtered_count++; | |
10b49f14 | 11165 | continue; |
ce1944f0 | 11166 | } |
10b49f14 | 11167 | |
3577f1c5 DD |
11168 | json_peer = json_object_new_object(); |
11169 | if (peer_dynamic_neighbor(peer)) { | |
11170 | json_object_boolean_true_add(json_peer, | |
11171 | "dynamicPeer"); | |
11172 | } | |
d62a17ae | 11173 | |
3577f1c5 DD |
11174 | if (peer->hostname) |
11175 | json_object_string_add(json_peer, "hostname", | |
11176 | peer->hostname); | |
11177 | ||
11178 | if (peer->domainname) | |
11179 | json_object_string_add(json_peer, "domainname", | |
11180 | peer->domainname); | |
11181 | ||
11182 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
c854765f DA |
11183 | json_object_int_add( |
11184 | json_peer, "localAs", | |
11185 | peer->change_local_as | |
11186 | ? peer->change_local_as | |
11187 | : peer->local_as); | |
3577f1c5 DD |
11188 | json_object_int_add(json_peer, "version", 4); |
11189 | json_object_int_add(json_peer, "msgRcvd", | |
11190 | PEER_TOTAL_RX(peer)); | |
11191 | json_object_int_add(json_peer, "msgSent", | |
11192 | PEER_TOTAL_TX(peer)); | |
11193 | ||
43aa5965 QY |
11194 | atomic_size_t outq_count, inq_count; |
11195 | outq_count = atomic_load_explicit( | |
11196 | &peer->obuf->count, | |
11197 | memory_order_relaxed); | |
11198 | inq_count = atomic_load_explicit( | |
11199 | &peer->ibuf->count, | |
11200 | memory_order_relaxed); | |
11201 | ||
3577f1c5 DD |
11202 | json_object_int_add(json_peer, "tableVersion", |
11203 | peer->version[afi][safi]); | |
11204 | json_object_int_add(json_peer, "outq", | |
43aa5965 QY |
11205 | outq_count); |
11206 | json_object_int_add(json_peer, "inq", | |
11207 | inq_count); | |
3577f1c5 DD |
11208 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
11209 | use_json, json_peer); | |
11210 | ||
3577f1c5 DD |
11211 | json_object_int_add(json_peer, "pfxRcd", |
11212 | peer->pcount[afi][pfx_rcd_safi]); | |
11213 | ||
3577f1c5 | 11214 | if (paf && PAF_SUBGRP(paf)) |
a616dd1f DA |
11215 | json_object_int_add( |
11216 | json_peer, "pfxSnt", | |
11217 | (PAF_SUBGRP(paf))->scount); | |
11218 | else | |
11219 | json_object_int_add(json_peer, "pfxSnt", | |
11220 | 0); | |
0e1f8ab5 DA |
11221 | |
11222 | /* BGP FSM state */ | |
cb9196e7 | 11223 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
736b68f3 DS |
11224 | || CHECK_FLAG(peer->bgp->flags, |
11225 | BGP_FLAG_SHUTDOWN)) | |
0e1f8ab5 DA |
11226 | json_object_string_add(json_peer, |
11227 | "state", | |
3577f1c5 DD |
11228 | "Idle (Admin)"); |
11229 | else if (peer->afc_recv[afi][safi]) | |
11230 | json_object_string_add( | |
0e1f8ab5 DA |
11231 | json_peer, "state", |
11232 | lookup_msg(bgp_status_msg, | |
11233 | peer->status, NULL)); | |
11234 | else if (CHECK_FLAG( | |
11235 | peer->sflags, | |
11236 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11237 | json_object_string_add(json_peer, | |
11238 | "state", | |
3577f1c5 DD |
11239 | "Idle (PfxCt)"); |
11240 | else | |
11241 | json_object_string_add( | |
0e1f8ab5 DA |
11242 | json_peer, "state", |
11243 | lookup_msg(bgp_status_msg, | |
11244 | peer->status, NULL)); | |
11245 | ||
11246 | /* BGP peer state */ | |
11247 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) | |
11248 | || CHECK_FLAG(peer->bgp->flags, | |
11249 | BGP_FLAG_SHUTDOWN)) | |
11250 | json_object_string_add(json_peer, | |
11251 | "peerState", | |
11252 | "Admin"); | |
11253 | else if (CHECK_FLAG( | |
11254 | peer->sflags, | |
11255 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11256 | json_object_string_add(json_peer, | |
11257 | "peerState", | |
11258 | "PfxCt"); | |
11259 | else if (CHECK_FLAG(peer->flags, | |
11260 | PEER_FLAG_PASSIVE)) | |
11261 | json_object_string_add(json_peer, | |
11262 | "peerState", | |
11263 | "Passive"); | |
11264 | else if (CHECK_FLAG(peer->sflags, | |
11265 | PEER_STATUS_NSF_WAIT)) | |
11266 | json_object_string_add(json_peer, | |
11267 | "peerState", | |
11268 | "NSF passive"); | |
11269 | else if (CHECK_FLAG( | |
11270 | peer->bgp->flags, | |
11271 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
11272 | && (!bgp_inbound_policy_exists(peer, | |
11273 | filter) | |
11274 | || !bgp_outbound_policy_exists( | |
11275 | peer, filter))) | |
11276 | json_object_string_add(json_peer, | |
11277 | "peerState", | |
11278 | "Policy"); | |
11279 | else | |
11280 | json_object_string_add( | |
11281 | json_peer, "peerState", "OK"); | |
11282 | ||
200116db DD |
11283 | json_object_int_add(json_peer, "connectionsEstablished", |
11284 | peer->established); | |
11285 | json_object_int_add(json_peer, "connectionsDropped", | |
11286 | peer->dropped); | |
aa72bd7e PG |
11287 | if (peer->desc) |
11288 | json_object_string_add( | |
11289 | json_peer, "desc", peer->desc); | |
b4e9dcba | 11290 | } |
3577f1c5 DD |
11291 | /* Avoid creating empty peer dicts in JSON */ |
11292 | if (json_peer == NULL) | |
11293 | continue; | |
ea47320b DL |
11294 | |
11295 | if (peer->conf_if) | |
60466a63 | 11296 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
11297 | "interface"); |
11298 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
11299 | json_object_string_add(json_peer, "idType", |
11300 | "ipv4"); | |
ea47320b | 11301 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
11302 | json_object_string_add(json_peer, "idType", |
11303 | "ipv6"); | |
ea47320b DL |
11304 | json_object_object_add(json_peers, peer->host, |
11305 | json_peer); | |
11306 | } else { | |
8c1d4cd5 | 11307 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
ce1944f0 LS |
11308 | as_type, as)) { |
11309 | filtered_count++; | |
8c1d4cd5 | 11310 | continue; |
ce1944f0 | 11311 | } |
3577f1c5 DD |
11312 | if (show_failed && |
11313 | bgp_has_peer_failed(peer, afi, safi)) { | |
11314 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
11315 | max_neighbor_width, | |
11316 | use_json); | |
11317 | } else if (!show_failed) { | |
10b49f14 | 11318 | if (show_established |
ce1944f0 LS |
11319 | && bgp_has_peer_failed(peer, afi, safi)) { |
11320 | filtered_count++; | |
10b49f14 | 11321 | continue; |
ce1944f0 | 11322 | } |
96c81f66 LS |
11323 | |
11324 | if ((count - filtered_count) == 1) { | |
11325 | /* display headline before the first | |
11326 | * neighbor line */ | |
11327 | vty_out(vty, "\n"); | |
11328 | ||
11329 | /* Subtract 8 here because 'Neighbor' is | |
11330 | * 8 characters */ | |
11331 | vty_out(vty, "Neighbor"); | |
11332 | vty_out(vty, "%*s", | |
11333 | max_neighbor_width - 8, " "); | |
11334 | vty_out(vty, | |
11335 | show_wide | |
11336 | ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE | |
11337 | : BGP_SHOW_SUMMARY_HEADER_ALL); | |
11338 | } | |
11339 | ||
3577f1c5 DD |
11340 | memset(dn_flag, '\0', sizeof(dn_flag)); |
11341 | if (peer_dynamic_neighbor(peer)) { | |
11342 | dn_flag[0] = '*'; | |
11343 | } | |
d62a17ae | 11344 | |
3577f1c5 | 11345 | if (peer->hostname |
892fedb6 DA |
11346 | && CHECK_FLAG(bgp->flags, |
11347 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 11348 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
11349 | peer->hostname, |
11350 | peer->host); | |
d62a17ae | 11351 | else |
3577f1c5 DD |
11352 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
11353 | ||
11354 | /* pad the neighbor column with spaces */ | |
11355 | if (len < max_neighbor_width) | |
11356 | vty_out(vty, "%*s", max_neighbor_width - len, | |
11357 | " "); | |
11358 | ||
43aa5965 QY |
11359 | atomic_size_t outq_count, inq_count; |
11360 | outq_count = atomic_load_explicit( | |
11361 | &peer->obuf->count, | |
11362 | memory_order_relaxed); | |
11363 | inq_count = atomic_load_explicit( | |
11364 | &peer->ibuf->count, | |
11365 | memory_order_relaxed); | |
11366 | ||
85eeb029 DA |
11367 | if (show_wide) |
11368 | vty_out(vty, | |
11369 | "4 %10u %10u %9u %9u %8" PRIu64 | |
11370 | " %4zu %4zu %8s", | |
11371 | peer->as, | |
11372 | peer->change_local_as | |
11373 | ? peer->change_local_as | |
11374 | : peer->local_as, | |
11375 | PEER_TOTAL_RX(peer), | |
11376 | PEER_TOTAL_TX(peer), | |
11377 | peer->version[afi][safi], | |
11378 | inq_count, outq_count, | |
11379 | peer_uptime(peer->uptime, | |
11380 | timebuf, | |
11381 | BGP_UPTIME_LEN, 0, | |
11382 | NULL)); | |
11383 | else | |
11384 | vty_out(vty, "4 %10u %9u %9u %8" PRIu64 | |
11385 | " %4zu %4zu %8s", | |
11386 | peer->as, PEER_TOTAL_RX(peer), | |
11387 | PEER_TOTAL_TX(peer), | |
11388 | peer->version[afi][safi], | |
11389 | inq_count, outq_count, | |
11390 | peer_uptime(peer->uptime, | |
11391 | timebuf, | |
11392 | BGP_UPTIME_LEN, 0, | |
11393 | NULL)); | |
3577f1c5 | 11394 | |
feb17238 | 11395 | if (peer_established(peer)) { |
d3ada366 DA |
11396 | if (peer->afc_recv[afi][safi]) { |
11397 | if (CHECK_FLAG( | |
11398 | bgp->flags, | |
11399 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
11400 | && !bgp_inbound_policy_exists( | |
11401 | peer, filter)) | |
11402 | vty_out(vty, " %12s", | |
11403 | "(Policy)"); | |
11404 | else | |
11405 | vty_out(vty, | |
6cde4b45 | 11406 | " %12u", |
d3ada366 DA |
11407 | peer->pcount |
11408 | [afi] | |
11409 | [pfx_rcd_safi]); | |
11410 | } else { | |
749d0f27 | 11411 | vty_out(vty, " NoNeg"); |
d3ada366 | 11412 | } |
db92d226 | 11413 | |
d3ada366 DA |
11414 | if (paf && PAF_SUBGRP(paf)) { |
11415 | if (CHECK_FLAG( | |
11416 | bgp->flags, | |
11417 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
11418 | && !bgp_outbound_policy_exists( | |
11419 | peer, filter)) | |
11420 | vty_out(vty, " %8s", | |
11421 | "(Policy)"); | |
11422 | else | |
11423 | vty_out(vty, | |
6cde4b45 | 11424 | " %8u", |
d3ada366 DA |
11425 | (PAF_SUBGRP( |
11426 | paf)) | |
11427 | ->scount); | |
749d0f27 DA |
11428 | } else { |
11429 | vty_out(vty, " NoNeg"); | |
d3ada366 | 11430 | } |
db92d226 | 11431 | } else { |
736b68f3 DS |
11432 | if (CHECK_FLAG(peer->flags, |
11433 | PEER_FLAG_SHUTDOWN) | |
11434 | || CHECK_FLAG(peer->bgp->flags, | |
11435 | BGP_FLAG_SHUTDOWN)) | |
3577f1c5 DD |
11436 | vty_out(vty, " Idle (Admin)"); |
11437 | else if (CHECK_FLAG( | |
11438 | peer->sflags, | |
11439 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11440 | vty_out(vty, " Idle (PfxCt)"); | |
11441 | else | |
11442 | vty_out(vty, " %12s", | |
11443 | lookup_msg(bgp_status_msg, | |
11444 | peer->status, NULL)); | |
db92d226 | 11445 | |
6cde4b45 | 11446 | vty_out(vty, " %8u", 0); |
3577f1c5 | 11447 | } |
565e9ddd DA |
11448 | /* Make sure `Desc` column is the lastest in |
11449 | * the output. | |
11450 | */ | |
aa72bd7e | 11451 | if (peer->desc) |
cb75bb31 DA |
11452 | vty_out(vty, " %s", |
11453 | bgp_peer_description_stripped( | |
85eeb029 DA |
11454 | peer->desc, |
11455 | show_wide ? 64 : 20)); | |
aa72bd7e PG |
11456 | else |
11457 | vty_out(vty, " N/A"); | |
3577f1c5 | 11458 | vty_out(vty, "\n"); |
d62a17ae | 11459 | } |
3577f1c5 | 11460 | |
d62a17ae | 11461 | } |
11462 | } | |
f933309e | 11463 | |
d62a17ae | 11464 | if (use_json) { |
11465 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 11466 | json_object_int_add(json, "failedPeers", failed_count); |
ce1944f0 LS |
11467 | json_object_int_add(json, "displayedPeers", |
11468 | count - filtered_count); | |
d62a17ae | 11469 | json_object_int_add(json, "totalPeers", count); |
11470 | json_object_int_add(json, "dynamicPeers", dn_count); | |
11471 | ||
3577f1c5 DD |
11472 | if (!show_failed) |
11473 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 11474 | |
75eeda93 | 11475 | vty_json(vty, json); |
d62a17ae | 11476 | } else { |
ce1944f0 | 11477 | if (count) { |
96c81f66 LS |
11478 | if (filtered_count == count) |
11479 | vty_out(vty, "\n%% No matching neighbor\n"); | |
11480 | else { | |
11481 | if (show_failed) | |
11482 | vty_out(vty, "\nDisplayed neighbors %d", | |
11483 | failed_count); | |
11484 | else if (as_type != AS_UNSPECIFIED || as | |
11485 | || fpeer || show_established) | |
ce1944f0 LS |
11486 | vty_out(vty, "\nDisplayed neighbors %d", |
11487 | count - filtered_count); | |
96c81f66 LS |
11488 | |
11489 | vty_out(vty, "\nTotal number of neighbors %d\n", | |
11490 | count); | |
ce1944f0 | 11491 | } |
ce1944f0 | 11492 | } else { |
d6ceaca3 | 11493 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 11494 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 11495 | } |
b05a1c8b | 11496 | |
d6ceaca3 | 11497 | if (dn_count) { |
d62a17ae | 11498 | vty_out(vty, "* - dynamic neighbor\n"); |
11499 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
11500 | dn_count, bgp->dynamic_neighbors_limit); | |
11501 | } | |
11502 | } | |
1ff9a340 | 11503 | |
d62a17ae | 11504 | return CMD_SUCCESS; |
718e3744 | 11505 | } |
11506 | ||
d62a17ae | 11507 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
8c1d4cd5 | 11508 | int safi, struct peer *fpeer, int as_type, |
96c81f66 | 11509 | as_t as, uint16_t show_flags) |
d62a17ae | 11510 | { |
11511 | int is_first = 1; | |
11512 | int afi_wildcard = (afi == AFI_MAX); | |
11513 | int safi_wildcard = (safi == SAFI_MAX); | |
11514 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 11515 | bool nbr_output = false; |
85eeb029 | 11516 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 11517 | |
11518 | if (use_json && is_wildcard) | |
11519 | vty_out(vty, "{\n"); | |
11520 | if (afi_wildcard) | |
11521 | afi = 1; /* AFI_IP */ | |
11522 | while (afi < AFI_MAX) { | |
11523 | if (safi_wildcard) | |
11524 | safi = 1; /* SAFI_UNICAST */ | |
11525 | while (safi < SAFI_MAX) { | |
318cac96 | 11526 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 11527 | nbr_output = true; |
f86897b9 | 11528 | |
d62a17ae | 11529 | if (is_wildcard) { |
11530 | /* | |
11531 | * So limit output to those afi/safi | |
11532 | * pairs that | |
11533 | * actualy have something interesting in | |
11534 | * them | |
11535 | */ | |
11536 | if (use_json) { | |
d62a17ae | 11537 | if (!is_first) |
11538 | vty_out(vty, ",\n"); | |
11539 | else | |
11540 | is_first = 0; | |
11541 | ||
11542 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
11543 | get_afi_safi_str(afi, |
11544 | safi, | |
11545 | true)); | |
d62a17ae | 11546 | } else { |
6cac2fcc LS |
11547 | vty_out(vty, |
11548 | "\n%s Summary (%s):\n", | |
5cb5f4d0 DD |
11549 | get_afi_safi_str(afi, |
11550 | safi, | |
6cac2fcc LS |
11551 | false), |
11552 | bgp->name_pretty); | |
d62a17ae | 11553 | } |
11554 | } | |
8c1d4cd5 LS |
11555 | bgp_show_summary(vty, bgp, afi, safi, fpeer, |
11556 | as_type, as, show_flags); | |
d62a17ae | 11557 | } |
11558 | safi++; | |
d62a17ae | 11559 | if (!safi_wildcard) |
11560 | safi = SAFI_MAX; | |
11561 | } | |
11562 | afi++; | |
ee851c8c | 11563 | if (!afi_wildcard) |
d62a17ae | 11564 | afi = AFI_MAX; |
11565 | } | |
11566 | ||
11567 | if (use_json && is_wildcard) | |
11568 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
11569 | else if (!nbr_output) { |
11570 | if (use_json) | |
11571 | vty_out(vty, "{}\n"); | |
11572 | else | |
6cac2fcc LS |
11573 | vty_out(vty, "%% No BGP neighbors found in %s\n", |
11574 | bgp->name_pretty); | |
ca61fd25 | 11575 | } |
d62a17ae | 11576 | } |
11577 | ||
11578 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
8c1d4cd5 LS |
11579 | safi_t safi, |
11580 | const char *neighbor, | |
11581 | int as_type, as_t as, | |
96c81f66 | 11582 | uint16_t show_flags) |
d62a17ae | 11583 | { |
11584 | struct listnode *node, *nnode; | |
11585 | struct bgp *bgp; | |
8c1d4cd5 | 11586 | struct peer *fpeer = NULL; |
d62a17ae | 11587 | int is_first = 1; |
9f049418 | 11588 | bool nbr_output = false; |
85eeb029 | 11589 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 11590 | |
11591 | if (use_json) | |
11592 | vty_out(vty, "{\n"); | |
11593 | ||
11594 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 11595 | nbr_output = true; |
d62a17ae | 11596 | if (use_json) { |
d62a17ae | 11597 | if (!is_first) |
11598 | vty_out(vty, ",\n"); | |
11599 | else | |
11600 | is_first = 0; | |
11601 | ||
11602 | vty_out(vty, "\"%s\":", | |
11603 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11604 | ? VRF_DEFAULT_NAME |
d62a17ae | 11605 | : bgp->name); |
d62a17ae | 11606 | } |
8c1d4cd5 LS |
11607 | if (neighbor) { |
11608 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11609 | use_json); | |
11610 | if (!fpeer) | |
11611 | continue; | |
11612 | } | |
11613 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, as_type, | |
11614 | as, show_flags); | |
d62a17ae | 11615 | } |
11616 | ||
11617 | if (use_json) | |
11618 | vty_out(vty, "}\n"); | |
9f049418 DS |
11619 | else if (!nbr_output) |
11620 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11621 | } |
11622 | ||
11623 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
8c1d4cd5 | 11624 | safi_t safi, const char *neighbor, int as_type, |
96c81f66 | 11625 | as_t as, uint16_t show_flags) |
d62a17ae | 11626 | { |
11627 | struct bgp *bgp; | |
85eeb029 | 11628 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
8c1d4cd5 | 11629 | struct peer *fpeer = NULL; |
d62a17ae | 11630 | |
11631 | if (name) { | |
11632 | if (strmatch(name, "all")) { | |
85eeb029 | 11633 | bgp_show_all_instances_summary_vty(vty, afi, safi, |
8c1d4cd5 LS |
11634 | neighbor, as_type, |
11635 | as, show_flags); | |
d62a17ae | 11636 | return CMD_SUCCESS; |
11637 | } else { | |
11638 | bgp = bgp_lookup_by_name(name); | |
11639 | ||
11640 | if (!bgp) { | |
11641 | if (use_json) | |
11642 | vty_out(vty, "{}\n"); | |
11643 | else | |
11644 | vty_out(vty, | |
ca61fd25 | 11645 | "%% BGP instance not found\n"); |
d62a17ae | 11646 | return CMD_WARNING; |
11647 | } | |
11648 | ||
8c1d4cd5 LS |
11649 | if (neighbor) { |
11650 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11651 | use_json); | |
11652 | if (!fpeer) | |
11653 | return CMD_WARNING; | |
11654 | } | |
11655 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, | |
11656 | as_type, as, show_flags); | |
d62a17ae | 11657 | return CMD_SUCCESS; |
11658 | } | |
11659 | } | |
11660 | ||
11661 | bgp = bgp_get_default(); | |
11662 | ||
8c1d4cd5 LS |
11663 | if (bgp) { |
11664 | if (neighbor) { | |
11665 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11666 | use_json); | |
11667 | if (!fpeer) | |
11668 | return CMD_WARNING; | |
11669 | } | |
11670 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, as_type, | |
11671 | as, show_flags); | |
11672 | } else { | |
ca61fd25 DS |
11673 | if (use_json) |
11674 | vty_out(vty, "{}\n"); | |
11675 | else | |
11676 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
11677 | return CMD_WARNING; |
11678 | } | |
d62a17ae | 11679 | |
11680 | return CMD_SUCCESS; | |
4fb25c53 DW |
11681 | } |
11682 | ||
716b2d8a | 11683 | /* `show [ip] bgp summary' commands. */ |
8c1d4cd5 LS |
11684 | DEFPY(show_ip_bgp_summary, show_ip_bgp_summary_cmd, |
11685 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR | |
11686 | " [" BGP_SAFI_WITH_LABEL_CMD_STR | |
96c81f66 | 11687 | "]] [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]", |
8c1d4cd5 LS |
11688 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR |
11689 | BGP_SAFI_WITH_LABEL_HELP_STR | |
11690 | "Display the entries for all address families\n" | |
11691 | "Summary of BGP neighbor status\n" | |
11692 | "Show only sessions in Established state\n" | |
11693 | "Show only sessions not in Established state\n" | |
11694 | "Show only the specified neighbor session\n" | |
11695 | "Neighbor to display information about\n" | |
11696 | "Neighbor to display information about\n" | |
11697 | "Neighbor on BGP configured interface\n" | |
11698 | "Show only the specified remote AS sessions\n" | |
11699 | "AS number\n" | |
11700 | "Internal (iBGP) AS sessions\n" | |
11701 | "External (eBGP) AS sessions\n" | |
96c81f66 | 11702 | "Shorten the information on BGP instances\n" |
8c1d4cd5 | 11703 | "Increase table width for longer output\n" JSON_STR) |
718e3744 | 11704 | { |
d62a17ae | 11705 | char *vrf = NULL; |
11706 | afi_t afi = AFI_MAX; | |
11707 | safi_t safi = SAFI_MAX; | |
8c1d4cd5 LS |
11708 | as_t as = 0; /* 0 means AS filter not set */ |
11709 | int as_type = AS_UNSPECIFIED; | |
96c81f66 | 11710 | uint16_t show_flags = 0; |
d62a17ae | 11711 | |
11712 | int idx = 0; | |
11713 | ||
11714 | /* show [ip] bgp */ | |
96f3485c | 11715 | if (!all && argv_find(argv, argc, "ip", &idx)) |
d62a17ae | 11716 | afi = AFI_IP; |
9a8bdf1c PG |
11717 | /* [<vrf> VIEWVRFNAME] */ |
11718 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11719 | vrf = argv[idx + 1]->arg; | |
11720 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11721 | vrf = NULL; | |
11722 | } else if (argv_find(argv, argc, "view", &idx)) | |
11723 | /* [<view> VIEWVRFNAME] */ | |
11724 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 11725 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11726 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11727 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11728 | } | |
11729 | ||
3577f1c5 | 11730 | if (argv_find(argv, argc, "failed", &idx)) |
85eeb029 DA |
11731 | SET_FLAG(show_flags, BGP_SHOW_OPT_FAILED); |
11732 | ||
10b49f14 | 11733 | if (argv_find(argv, argc, "established", &idx)) |
85eeb029 DA |
11734 | SET_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); |
11735 | ||
8c1d4cd5 LS |
11736 | if (argv_find(argv, argc, "remote-as", &idx)) { |
11737 | if (argv[idx + 1]->arg[0] == 'i') | |
11738 | as_type = AS_INTERNAL; | |
11739 | else if (argv[idx + 1]->arg[0] == 'e') | |
11740 | as_type = AS_EXTERNAL; | |
11741 | else | |
11742 | as = (as_t)atoi(argv[idx + 1]->arg); | |
11743 | } | |
11744 | ||
96c81f66 LS |
11745 | if (argv_find(argv, argc, "terse", &idx)) |
11746 | SET_FLAG(show_flags, BGP_SHOW_OPT_TERSE); | |
11747 | ||
85eeb029 DA |
11748 | if (argv_find(argv, argc, "wide", &idx)) |
11749 | SET_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
11750 | ||
11751 | if (argv_find(argv, argc, "json", &idx)) | |
11752 | SET_FLAG(show_flags, BGP_SHOW_OPT_JSON); | |
3577f1c5 | 11753 | |
8c1d4cd5 LS |
11754 | return bgp_show_summary_vty(vty, vrf, afi, safi, neighbor, as_type, as, |
11755 | show_flags); | |
d62a17ae | 11756 | } |
11757 | ||
5cb5f4d0 | 11758 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 11759 | { |
5cb5f4d0 DD |
11760 | if (for_json) |
11761 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 11762 | else |
5cb5f4d0 | 11763 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
11764 | } |
11765 | ||
d62a17ae | 11766 | |
11767 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
11768 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
11769 | uint16_t adv_smcap, uint16_t adv_rmcap, |
11770 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 11771 | bool use_json, json_object *json_pref) |
d62a17ae | 11772 | { |
11773 | /* Send-Mode */ | |
11774 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11775 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
11776 | if (use_json) { | |
11777 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11778 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11779 | json_object_string_add(json_pref, "sendMode", | |
11780 | "advertisedAndReceived"); | |
11781 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11782 | json_object_string_add(json_pref, "sendMode", | |
11783 | "advertised"); | |
11784 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11785 | json_object_string_add(json_pref, "sendMode", | |
11786 | "received"); | |
11787 | } else { | |
11788 | vty_out(vty, " Send-mode: "); | |
11789 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11790 | vty_out(vty, "advertised"); | |
11791 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11792 | vty_out(vty, "%sreceived", | |
11793 | CHECK_FLAG(p->af_cap[afi][safi], | |
11794 | adv_smcap) | |
11795 | ? ", " | |
11796 | : ""); | |
11797 | vty_out(vty, "\n"); | |
11798 | } | |
11799 | } | |
11800 | ||
11801 | /* Receive-Mode */ | |
11802 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11803 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
11804 | if (use_json) { | |
11805 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11806 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11807 | json_object_string_add(json_pref, "recvMode", | |
11808 | "advertisedAndReceived"); | |
11809 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11810 | json_object_string_add(json_pref, "recvMode", | |
11811 | "advertised"); | |
11812 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11813 | json_object_string_add(json_pref, "recvMode", | |
11814 | "received"); | |
11815 | } else { | |
11816 | vty_out(vty, " Receive-mode: "); | |
11817 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11818 | vty_out(vty, "advertised"); | |
11819 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11820 | vty_out(vty, "%sreceived", | |
11821 | CHECK_FLAG(p->af_cap[afi][safi], | |
11822 | adv_rmcap) | |
11823 | ? ", " | |
11824 | : ""); | |
11825 | vty_out(vty, "\n"); | |
11826 | } | |
11827 | } | |
11828 | } | |
11829 | ||
eea685b6 DA |
11830 | static void bgp_show_neighnor_graceful_restart_flags(struct vty *vty, |
11831 | struct peer *p, | |
11832 | bool use_json, | |
11833 | json_object *json) | |
2986cac2 | 11834 | { |
eea685b6 DA |
11835 | bool rbit = false; |
11836 | bool nbit = false; | |
2986cac2 | 11837 | |
13909c4f DS |
11838 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
11839 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
feb17238 | 11840 | && (peer_established(p))) { |
eea685b6 DA |
11841 | rbit = CHECK_FLAG(p->cap, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV); |
11842 | nbit = CHECK_FLAG(p->cap, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV); | |
2986cac2 | 11843 | } |
11844 | ||
eea685b6 DA |
11845 | if (use_json) { |
11846 | json_object_boolean_add(json, "rBit", rbit); | |
11847 | json_object_boolean_add(json, "nBit", nbit); | |
2986cac2 | 11848 | } else { |
eea685b6 DA |
11849 | vty_out(vty, "\n R bit: %s", rbit ? "True" : "False"); |
11850 | vty_out(vty, "\n N bit: %s\n", nbit ? "True" : "False"); | |
2986cac2 | 11851 | } |
11852 | } | |
11853 | ||
13909c4f DS |
11854 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
11855 | struct peer *peer, | |
11856 | bool use_json, | |
11857 | json_object *json) | |
2986cac2 | 11858 | { |
2bb5d39b | 11859 | const char *mode = "NotApplicable"; |
2986cac2 | 11860 | |
11861 | if (!use_json) | |
a53ca37b | 11862 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 11863 | |
13909c4f | 11864 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
feb17238 | 11865 | && (peer_established(peer))) { |
2986cac2 | 11866 | |
13909c4f DS |
11867 | if ((peer->nsf_af_count == 0) |
11868 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11869 | |
2986cac2 | 11870 | mode = "Disable"; |
11871 | ||
13909c4f DS |
11872 | } else if (peer->nsf_af_count == 0 |
11873 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11874 | |
2986cac2 | 11875 | mode = "Helper"; |
11876 | ||
13909c4f DS |
11877 | } else if (peer->nsf_af_count != 0 |
11878 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11879 | |
2986cac2 | 11880 | mode = "Restart"; |
2986cac2 | 11881 | } |
11882 | } | |
11883 | ||
11884 | if (use_json) { | |
13909c4f | 11885 | json_object_string_add(json, "remoteGrMode", mode); |
2986cac2 | 11886 | } else |
11887 | vty_out(vty, mode, "\n"); | |
11888 | } | |
11889 | ||
13909c4f DS |
11890 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
11891 | struct peer *p, | |
11892 | bool use_json, | |
11893 | json_object *json) | |
2986cac2 | 11894 | { |
11895 | const char *mode = "Invalid"; | |
11896 | ||
11897 | if (!use_json) | |
a53ca37b | 11898 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 11899 | |
11900 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
11901 | mode = "Helper"; | |
11902 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
11903 | mode = "Restart"; | |
11904 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
11905 | mode = "Disable"; | |
2ba1fe69 | 11906 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 11907 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
11908 | mode = "Helper*"; | |
11909 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
11910 | mode = "Restart*"; | |
11911 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
11912 | mode = "Disable*"; | |
11913 | else | |
11914 | mode = "Invalid*"; | |
2ba1fe69 | 11915 | } |
2986cac2 | 11916 | |
11917 | if (use_json) { | |
13909c4f | 11918 | json_object_string_add(json, "localGrMode", mode); |
2986cac2 | 11919 | } else { |
11920 | vty_out(vty, mode, "\n"); | |
11921 | } | |
11922 | } | |
11923 | ||
13909c4f DS |
11924 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
11925 | struct vty *vty, struct peer *peer, bool use_json, json_object *json) | |
2986cac2 | 11926 | { |
2ba1fe69 | 11927 | afi_t afi; |
11928 | safi_t safi; | |
2986cac2 | 11929 | json_object *json_afi_safi = NULL; |
11930 | json_object *json_timer = NULL; | |
11931 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 11932 | bool eor_flag = false; |
2986cac2 | 11933 | |
df8d723c DA |
11934 | FOREACH_AFI_SAFI_NSF (afi, safi) { |
11935 | if (!peer->afc[afi][safi]) | |
11936 | continue; | |
2986cac2 | 11937 | |
df8d723c DA |
11938 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) || |
11939 | !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
11940 | continue; | |
9e3b51a7 | 11941 | |
df8d723c DA |
11942 | if (use_json) { |
11943 | json_afi_safi = json_object_new_object(); | |
11944 | json_endofrib_status = json_object_new_object(); | |
11945 | json_timer = json_object_new_object(); | |
11946 | } | |
2986cac2 | 11947 | |
df8d723c DA |
11948 | if (peer->eor_stime[afi][safi] >= peer->pkt_stime[afi][safi]) |
11949 | eor_flag = true; | |
11950 | else | |
11951 | eor_flag = false; | |
2986cac2 | 11952 | |
df8d723c DA |
11953 | if (!use_json) { |
11954 | vty_out(vty, " %s:\n", | |
11955 | get_afi_safi_str(afi, safi, false)); | |
2986cac2 | 11956 | |
df8d723c DA |
11957 | vty_out(vty, " F bit: "); |
11958 | } | |
2986cac2 | 11959 | |
df8d723c DA |
11960 | if (peer->nsf[afi][safi] && |
11961 | CHECK_FLAG(peer->af_cap[afi][safi], | |
11962 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 11963 | |
df8d723c DA |
11964 | if (use_json) { |
11965 | json_object_boolean_true_add(json_afi_safi, | |
11966 | "fBit"); | |
11967 | } else | |
11968 | vty_out(vty, "True\n"); | |
11969 | } else { | |
11970 | if (use_json) | |
11971 | json_object_boolean_false_add(json_afi_safi, | |
11972 | "fBit"); | |
11973 | else | |
11974 | vty_out(vty, "False\n"); | |
11975 | } | |
2986cac2 | 11976 | |
df8d723c DA |
11977 | if (!use_json) |
11978 | vty_out(vty, " End-of-RIB sent: "); | |
2986cac2 | 11979 | |
df8d723c DA |
11980 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
11981 | PEER_STATUS_EOR_SEND)) { | |
11982 | if (use_json) { | |
11983 | json_object_boolean_true_add( | |
11984 | json_endofrib_status, "endOfRibSend"); | |
9e3b51a7 | 11985 | |
df8d723c DA |
11986 | PRINT_EOR_JSON(eor_flag); |
11987 | } else { | |
11988 | vty_out(vty, "Yes\n"); | |
11989 | vty_out(vty, | |
11990 | " End-of-RIB sent after update: "); | |
2986cac2 | 11991 | |
df8d723c DA |
11992 | PRINT_EOR(eor_flag); |
11993 | } | |
11994 | } else { | |
11995 | if (use_json) { | |
11996 | json_object_boolean_false_add( | |
11997 | json_endofrib_status, "endOfRibSend"); | |
11998 | json_object_boolean_false_add( | |
11999 | json_endofrib_status, | |
12000 | "endOfRibSentAfterUpdate"); | |
13909c4f | 12001 | } else { |
df8d723c DA |
12002 | vty_out(vty, "No\n"); |
12003 | vty_out(vty, | |
12004 | " End-of-RIB sent after update: "); | |
12005 | vty_out(vty, "No\n"); | |
13909c4f | 12006 | } |
df8d723c | 12007 | } |
2986cac2 | 12008 | |
df8d723c DA |
12009 | if (!use_json) |
12010 | vty_out(vty, " End-of-RIB received: "); | |
a53ca37b | 12011 | |
df8d723c DA |
12012 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
12013 | PEER_STATUS_EOR_RECEIVED)) { | |
12014 | if (use_json) | |
12015 | json_object_boolean_true_add( | |
12016 | json_endofrib_status, "endOfRibRecv"); | |
12017 | else | |
12018 | vty_out(vty, "Yes\n"); | |
12019 | } else { | |
12020 | if (use_json) | |
12021 | json_object_boolean_false_add( | |
12022 | json_endofrib_status, "endOfRibRecv"); | |
12023 | else | |
12024 | vty_out(vty, "No\n"); | |
12025 | } | |
12026 | ||
12027 | if (use_json) { | |
12028 | json_object_int_add(json_timer, "stalePathTimer", | |
12029 | peer->bgp->stalepath_time); | |
12030 | ||
12031 | if (peer->t_gr_stale != NULL) { | |
12032 | json_object_int_add(json_timer, | |
12033 | "stalePathTimerRemaining", | |
12034 | thread_timer_remain_second( | |
12035 | peer->t_gr_stale)); | |
a53ca37b DA |
12036 | } |
12037 | ||
df8d723c DA |
12038 | /* Display Configured Selection |
12039 | * Deferral only when when | |
12040 | * Gr mode is enabled. | |
12041 | */ | |
12042 | if (CHECK_FLAG(peer->flags, | |
12043 | PEER_FLAG_GRACEFUL_RESTART)) { | |
13909c4f | 12044 | json_object_int_add(json_timer, |
df8d723c | 12045 | "selectionDeferralTimer", |
13909c4f | 12046 | peer->bgp->stalepath_time); |
df8d723c | 12047 | } |
2986cac2 | 12048 | |
df8d723c DA |
12049 | if (peer->bgp->gr_info[afi][safi].t_select_deferral != |
12050 | NULL) { | |
2986cac2 | 12051 | |
df8d723c DA |
12052 | json_object_int_add( |
12053 | json_timer, | |
12054 | "selectionDeferralTimerRemaining", | |
12055 | thread_timer_remain_second( | |
12056 | peer->bgp->gr_info[afi][safi] | |
12057 | .t_select_deferral)); | |
12058 | } | |
12059 | } else { | |
12060 | vty_out(vty, " Timers:\n"); | |
12061 | vty_out(vty, | |
12062 | " Configured Stale Path Time(sec): %u\n", | |
12063 | peer->bgp->stalepath_time); | |
2986cac2 | 12064 | |
df8d723c | 12065 | if (peer->t_gr_stale != NULL) |
13909c4f | 12066 | vty_out(vty, |
df8d723c DA |
12067 | " Stale Path Remaining(sec): %ld\n", |
12068 | thread_timer_remain_second( | |
12069 | peer->t_gr_stale)); | |
12070 | /* Display Configured Selection | |
12071 | * Deferral only when when | |
12072 | * Gr mode is enabled. | |
12073 | */ | |
12074 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) | |
12075 | vty_out(vty, | |
12076 | " Configured Selection Deferral Time(sec): %u\n", | |
12077 | peer->bgp->select_defer_time); | |
2986cac2 | 12078 | |
df8d723c DA |
12079 | if (peer->bgp->gr_info[afi][safi].t_select_deferral != |
12080 | NULL) | |
12081 | vty_out(vty, | |
12082 | " Selection Deferral Time Remaining(sec): %ld\n", | |
12083 | thread_timer_remain_second( | |
12084 | peer->bgp->gr_info[afi][safi] | |
12085 | .t_select_deferral)); | |
12086 | } | |
12087 | if (use_json) { | |
12088 | json_object_object_add(json_afi_safi, "endOfRibStatus", | |
12089 | json_endofrib_status); | |
12090 | json_object_object_add(json_afi_safi, "timers", | |
12091 | json_timer); | |
12092 | json_object_object_add( | |
12093 | json, get_afi_safi_str(afi, safi, true), | |
12094 | json_afi_safi); | |
2986cac2 | 12095 | } |
12096 | } | |
12097 | } | |
12098 | ||
36235319 QY |
12099 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
12100 | struct peer *p, | |
12101 | bool use_json, | |
12102 | json_object *json) | |
2986cac2 | 12103 | { |
12104 | if (use_json) { | |
12105 | json_object *json_timer = NULL; | |
12106 | ||
12107 | json_timer = json_object_new_object(); | |
12108 | ||
13909c4f DS |
12109 | json_object_int_add(json_timer, "configuredRestartTimer", |
12110 | p->bgp->restart_time); | |
2986cac2 | 12111 | |
13909c4f DS |
12112 | json_object_int_add(json_timer, "receivedRestartTimer", |
12113 | p->v_gr_restart); | |
2986cac2 | 12114 | |
13909c4f DS |
12115 | if (p->t_gr_restart != NULL) |
12116 | json_object_int_add( | |
12117 | json_timer, "restartTimerRemaining", | |
12118 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 12119 | |
12120 | json_object_object_add(json, "timers", json_timer); | |
12121 | } else { | |
12122 | ||
a53ca37b DA |
12123 | vty_out(vty, " Timers:\n"); |
12124 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 12125 | p->bgp->restart_time); |
2986cac2 | 12126 | |
a53ca37b | 12127 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
12128 | p->v_gr_restart); |
12129 | if (p->t_gr_restart != NULL) | |
a53ca37b | 12130 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 12131 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 12132 | if (p->t_gr_restart != NULL) { |
a53ca37b | 12133 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
12134 | thread_timer_remain_second(p->t_gr_restart)); |
12135 | } | |
2986cac2 | 12136 | } |
12137 | } | |
12138 | ||
12139 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
36235319 | 12140 | bool use_json, json_object *json) |
2986cac2 | 12141 | { |
2986cac2 | 12142 | char dn_flag[2] = {0}; |
2b7165e7 QY |
12143 | /* '*' + v6 address of neighbor */ |
12144 | char neighborAddr[INET6_ADDRSTRLEN + 1] = {0}; | |
2986cac2 | 12145 | |
2986cac2 | 12146 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
12147 | dn_flag[0] = '*'; | |
12148 | ||
12149 | if (p->conf_if) { | |
12150 | if (use_json) | |
47e12884 DA |
12151 | json_object_string_addf(json, "neighborAddr", "%pSU", |
12152 | &p->su); | |
2986cac2 | 12153 | else |
47e12884 DA |
12154 | vty_out(vty, "BGP neighbor on %s: %pSU\n", p->conf_if, |
12155 | &p->su); | |
2986cac2 | 12156 | } else { |
772270f3 QY |
12157 | snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag, |
12158 | p->host); | |
2986cac2 | 12159 | |
12160 | if (use_json) | |
36235319 QY |
12161 | json_object_string_add(json, "neighborAddr", |
12162 | neighborAddr); | |
2986cac2 | 12163 | else |
36235319 | 12164 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 12165 | } |
12166 | ||
12167 | /* more gr info in new format */ | |
12168 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
12169 | } | |
12170 | ||
d62a17ae | 12171 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 12172 | safi_t safi, bool use_json, |
d62a17ae | 12173 | json_object *json_neigh) |
12174 | { | |
0291c246 MK |
12175 | struct bgp_filter *filter; |
12176 | struct peer_af *paf; | |
12177 | char orf_pfx_name[BUFSIZ]; | |
12178 | int orf_pfx_count; | |
12179 | json_object *json_af = NULL; | |
12180 | json_object *json_prefA = NULL; | |
12181 | json_object *json_prefB = NULL; | |
12182 | json_object *json_addr = NULL; | |
fa36596c | 12183 | json_object *json_advmap = NULL; |
d62a17ae | 12184 | |
12185 | if (use_json) { | |
12186 | json_addr = json_object_new_object(); | |
12187 | json_af = json_object_new_object(); | |
12188 | filter = &p->filter[afi][safi]; | |
12189 | ||
12190 | if (peer_group_active(p)) | |
12191 | json_object_string_add(json_addr, "peerGroupMember", | |
12192 | p->group->name); | |
12193 | ||
12194 | paf = peer_af_find(p, afi, safi); | |
12195 | if (paf && PAF_SUBGRP(paf)) { | |
12196 | json_object_int_add(json_addr, "updateGroupId", | |
12197 | PAF_UPDGRP(paf)->id); | |
12198 | json_object_int_add(json_addr, "subGroupId", | |
12199 | PAF_SUBGRP(paf)->id); | |
12200 | json_object_int_add(json_addr, "packetQueueLength", | |
12201 | bpacket_queue_virtual_length(paf)); | |
12202 | } | |
12203 | ||
12204 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12205 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12206 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12207 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12208 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12209 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12210 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
12211 | json_object_int_add(json_af, "orfType", | |
12212 | ORF_TYPE_PREFIX); | |
12213 | json_prefA = json_object_new_object(); | |
12214 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
12215 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
12216 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12217 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
12218 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
12219 | use_json, json_prefA); | |
12220 | json_object_object_add(json_af, "orfPrefixList", | |
12221 | json_prefA); | |
12222 | } | |
12223 | ||
12224 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12225 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12226 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12227 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12228 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12229 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12230 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
12231 | json_object_int_add(json_af, "orfOldType", | |
12232 | ORF_TYPE_PREFIX_OLD); | |
12233 | json_prefB = json_object_new_object(); | |
12234 | bgp_show_peer_afi_orf_cap( | |
12235 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12236 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12237 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
12238 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
12239 | json_prefB); | |
12240 | json_object_object_add(json_af, "orfOldPrefixList", | |
12241 | json_prefB); | |
12242 | } | |
12243 | ||
12244 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12245 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12246 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12247 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12248 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12249 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12250 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12251 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12252 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
12253 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12254 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
12255 | json_object_object_add(json_addr, "afDependentCap", | |
12256 | json_af); | |
12257 | else | |
12258 | json_object_free(json_af); | |
12259 | ||
772270f3 QY |
12260 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
12261 | p->host, afi, safi); | |
d62a17ae | 12262 | orf_pfx_count = prefix_bgp_show_prefix_list( |
12263 | NULL, afi, orf_pfx_name, use_json); | |
12264 | ||
12265 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12266 | PEER_STATUS_ORF_PREFIX_SEND) | |
12267 | || orf_pfx_count) { | |
12268 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12269 | PEER_STATUS_ORF_PREFIX_SEND)) | |
12270 | json_object_boolean_true_add(json_neigh, | |
12271 | "orfSent"); | |
12272 | if (orf_pfx_count) | |
12273 | json_object_int_add(json_addr, "orfRecvCounter", | |
12274 | orf_pfx_count); | |
12275 | } | |
12276 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12277 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
12278 | json_object_string_add( | |
12279 | json_addr, "orfFirstUpdate", | |
12280 | "deferredUntilORFOrRouteRefreshRecvd"); | |
12281 | ||
12282 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12283 | PEER_FLAG_REFLECTOR_CLIENT)) | |
12284 | json_object_boolean_true_add(json_addr, | |
12285 | "routeReflectorClient"); | |
12286 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12287 | PEER_FLAG_RSERVER_CLIENT)) | |
12288 | json_object_boolean_true_add(json_addr, | |
12289 | "routeServerClient"); | |
12290 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
12291 | json_object_boolean_true_add(json_addr, | |
12292 | "inboundSoftConfigPermit"); | |
12293 | ||
12294 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12295 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
12296 | json_object_boolean_true_add( | |
12297 | json_addr, | |
12298 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
12299 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12300 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
12301 | json_object_boolean_true_add( | |
12302 | json_addr, | |
12303 | "privateAsNumsReplacedInUpdatesToNbr"); | |
12304 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12305 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
12306 | json_object_boolean_true_add( | |
12307 | json_addr, | |
12308 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
12309 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12310 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
12311 | json_object_boolean_true_add( | |
12312 | json_addr, | |
12313 | "privateAsNumsRemovedInUpdatesToNbr"); | |
12314 | ||
b2ac1d0d MS |
12315 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN)) { |
12316 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12317 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) | |
12318 | json_object_boolean_true_add(json_addr, | |
12319 | "allowAsInOrigin"); | |
12320 | else | |
12321 | json_object_int_add(json_addr, "allowAsInCount", | |
12322 | p->allowas_in[afi][safi]); | |
12323 | } | |
12324 | ||
dcc68b5e MS |
12325 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
12326 | json_object_boolean_true_add( | |
12327 | json_addr, | |
12328 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
12329 | ->type_json_name); | |
d62a17ae | 12330 | |
12331 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
12332 | json_object_string_add(json_addr, | |
12333 | "overrideASNsInOutboundUpdates", | |
12334 | "ifAspathEqualRemoteAs"); | |
12335 | ||
12336 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
12337 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12338 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
12339 | json_object_boolean_true_add(json_addr, | |
12340 | "routerAlwaysNextHop"); | |
12341 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12342 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
12343 | json_object_boolean_true_add( | |
12344 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
12345 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12346 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
12347 | json_object_boolean_true_add( | |
12348 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
12349 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
12350 | json_object_boolean_true_add( | |
12351 | json_addr, "unchangedMedPropogatedToNbr"); | |
12352 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
12353 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12354 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
12355 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12356 | PEER_FLAG_SEND_COMMUNITY) | |
12357 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12358 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12359 | json_object_string_add(json_addr, | |
12360 | "commAttriSentToNbr", | |
12361 | "extendedAndStandard"); | |
12362 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12363 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12364 | json_object_string_add(json_addr, | |
12365 | "commAttriSentToNbr", | |
12366 | "extended"); | |
12367 | else | |
12368 | json_object_string_add(json_addr, | |
12369 | "commAttriSentToNbr", | |
12370 | "standard"); | |
12371 | } | |
12372 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12373 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
12374 | if (p->default_rmap[afi][safi].name) | |
12375 | json_object_string_add( | |
12376 | json_addr, "defaultRouteMap", | |
12377 | p->default_rmap[afi][safi].name); | |
12378 | ||
12379 | if (paf && PAF_SUBGRP(paf) | |
12380 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
12381 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
12382 | json_object_boolean_true_add(json_addr, | |
12383 | "defaultSent"); | |
12384 | else | |
12385 | json_object_boolean_true_add(json_addr, | |
12386 | "defaultNotSent"); | |
12387 | } | |
12388 | ||
dff8f48d | 12389 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 12390 | if (is_evpn_enabled()) |
60466a63 QY |
12391 | json_object_boolean_true_add( |
12392 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
12393 | } |
12394 | ||
d62a17ae | 12395 | if (filter->plist[FILTER_IN].name |
12396 | || filter->dlist[FILTER_IN].name | |
12397 | || filter->aslist[FILTER_IN].name | |
12398 | || filter->map[RMAP_IN].name) | |
12399 | json_object_boolean_true_add(json_addr, | |
12400 | "inboundPathPolicyConfig"); | |
12401 | if (filter->plist[FILTER_OUT].name | |
12402 | || filter->dlist[FILTER_OUT].name | |
12403 | || filter->aslist[FILTER_OUT].name | |
12404 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
12405 | json_object_boolean_true_add( | |
12406 | json_addr, "outboundPathPolicyConfig"); | |
12407 | ||
12408 | /* prefix-list */ | |
12409 | if (filter->plist[FILTER_IN].name) | |
12410 | json_object_string_add(json_addr, | |
12411 | "incomingUpdatePrefixFilterList", | |
12412 | filter->plist[FILTER_IN].name); | |
12413 | if (filter->plist[FILTER_OUT].name) | |
12414 | json_object_string_add(json_addr, | |
12415 | "outgoingUpdatePrefixFilterList", | |
12416 | filter->plist[FILTER_OUT].name); | |
12417 | ||
12418 | /* distribute-list */ | |
12419 | if (filter->dlist[FILTER_IN].name) | |
12420 | json_object_string_add( | |
12421 | json_addr, "incomingUpdateNetworkFilterList", | |
12422 | filter->dlist[FILTER_IN].name); | |
12423 | if (filter->dlist[FILTER_OUT].name) | |
12424 | json_object_string_add( | |
12425 | json_addr, "outgoingUpdateNetworkFilterList", | |
12426 | filter->dlist[FILTER_OUT].name); | |
12427 | ||
12428 | /* filter-list. */ | |
12429 | if (filter->aslist[FILTER_IN].name) | |
12430 | json_object_string_add(json_addr, | |
12431 | "incomingUpdateAsPathFilterList", | |
12432 | filter->aslist[FILTER_IN].name); | |
12433 | if (filter->aslist[FILTER_OUT].name) | |
12434 | json_object_string_add(json_addr, | |
12435 | "outgoingUpdateAsPathFilterList", | |
12436 | filter->aslist[FILTER_OUT].name); | |
12437 | ||
12438 | /* route-map. */ | |
12439 | if (filter->map[RMAP_IN].name) | |
12440 | json_object_string_add( | |
12441 | json_addr, "routeMapForIncomingAdvertisements", | |
12442 | filter->map[RMAP_IN].name); | |
12443 | if (filter->map[RMAP_OUT].name) | |
12444 | json_object_string_add( | |
12445 | json_addr, "routeMapForOutgoingAdvertisements", | |
12446 | filter->map[RMAP_OUT].name); | |
12447 | ||
9dac9fc8 | 12448 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 12449 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12450 | && !bgp_inbound_policy_exists(p, filter)) |
12451 | json_object_string_add( | |
12452 | json_addr, "inboundEbgpRequiresPolicy", | |
12453 | "Inbound updates discarded due to missing policy"); | |
12454 | ||
12455 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 12456 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12457 | && (!bgp_outbound_policy_exists(p, filter))) |
12458 | json_object_string_add( | |
12459 | json_addr, "outboundEbgpRequiresPolicy", | |
12460 | "Outbound updates discarded due to missing policy"); | |
12461 | ||
d62a17ae | 12462 | /* unsuppress-map */ |
12463 | if (filter->usmap.name) | |
12464 | json_object_string_add(json_addr, | |
12465 | "selectiveUnsuppressRouteMap", | |
12466 | filter->usmap.name); | |
12467 | ||
fa36596c MK |
12468 | /* advertise-map */ |
12469 | if (filter->advmap.aname) { | |
12470 | json_advmap = json_object_new_object(); | |
12471 | json_object_string_add(json_advmap, "condition", | |
12472 | filter->advmap.condition | |
12473 | ? "EXIST" | |
12474 | : "NON_EXIST"); | |
12475 | json_object_string_add(json_advmap, "conditionMap", | |
12476 | filter->advmap.cname); | |
12477 | json_object_string_add(json_advmap, "advertiseMap", | |
12478 | filter->advmap.aname); | |
ecf2b628 QY |
12479 | json_object_string_add( |
12480 | json_advmap, "advertiseStatus", | |
12481 | filter->advmap.update_type == | |
12482 | UPDATE_TYPE_ADVERTISE | |
12483 | ? "Advertise" | |
12484 | : "Withdraw"); | |
fa36596c MK |
12485 | json_object_object_add(json_addr, "advertiseMap", |
12486 | json_advmap); | |
12487 | } | |
12488 | ||
d62a17ae | 12489 | /* Receive prefix count */ |
12490 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
12491 | p->pcount[afi][safi]); | |
50e05855 AD |
12492 | if (paf && PAF_SUBGRP(paf)) |
12493 | json_object_int_add(json_addr, "sentPrefixCounter", | |
12494 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 12495 | |
fde246e8 DA |
12496 | /* Maximum prefix */ |
12497 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
12498 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
12499 | p->pmax_out[afi][safi]); | |
12500 | ||
d62a17ae | 12501 | /* Maximum prefix */ |
12502 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
12503 | json_object_int_add(json_addr, "prefixAllowedMax", | |
12504 | p->pmax[afi][safi]); | |
12505 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12506 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
12507 | json_object_boolean_true_add( | |
12508 | json_addr, "prefixAllowedMaxWarning"); | |
12509 | json_object_int_add(json_addr, | |
12510 | "prefixAllowedWarningThresh", | |
12511 | p->pmax_threshold[afi][safi]); | |
12512 | if (p->pmax_restart[afi][safi]) | |
12513 | json_object_int_add( | |
12514 | json_addr, | |
12515 | "prefixAllowedRestartIntervalMsecs", | |
12516 | p->pmax_restart[afi][safi] * 60000); | |
12517 | } | |
2986cac2 | 12518 | json_object_object_add(json_neigh, |
36235319 | 12519 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 12520 | json_addr); |
12521 | ||
12522 | } else { | |
12523 | filter = &p->filter[afi][safi]; | |
12524 | ||
12525 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 12526 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 12527 | |
12528 | if (peer_group_active(p)) | |
12529 | vty_out(vty, " %s peer-group member\n", | |
12530 | p->group->name); | |
12531 | ||
12532 | paf = peer_af_find(p, afi, safi); | |
12533 | if (paf && PAF_SUBGRP(paf)) { | |
6cde4b45 | 12534 | vty_out(vty, " Update group %" PRIu64", subgroup %" PRIu64 "\n", |
d62a17ae | 12535 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
12536 | vty_out(vty, " Packet Queue length %d\n", | |
12537 | bpacket_queue_virtual_length(paf)); | |
12538 | } else { | |
12539 | vty_out(vty, " Not part of any update group\n"); | |
12540 | } | |
12541 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12542 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12543 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12544 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12545 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12546 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12547 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12548 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12549 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
12550 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12551 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
12552 | vty_out(vty, " AF-dependant capabilities:\n"); | |
12553 | ||
12554 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12555 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12556 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12557 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12558 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12559 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12560 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
12561 | vty_out(vty, | |
12562 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
12563 | ORF_TYPE_PREFIX); | |
12564 | bgp_show_peer_afi_orf_cap( | |
12565 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12566 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12567 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
12568 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
12569 | } | |
12570 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12571 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12572 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12573 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12574 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12575 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12576 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
12577 | vty_out(vty, | |
12578 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
12579 | ORF_TYPE_PREFIX_OLD); | |
12580 | bgp_show_peer_afi_orf_cap( | |
12581 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12582 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12583 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
12584 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
12585 | } | |
12586 | ||
772270f3 QY |
12587 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
12588 | p->host, afi, safi); | |
d62a17ae | 12589 | orf_pfx_count = prefix_bgp_show_prefix_list( |
12590 | NULL, afi, orf_pfx_name, use_json); | |
12591 | ||
12592 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12593 | PEER_STATUS_ORF_PREFIX_SEND) | |
12594 | || orf_pfx_count) { | |
12595 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
12596 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12597 | PEER_STATUS_ORF_PREFIX_SEND)) | |
12598 | vty_out(vty, " sent;"); | |
12599 | if (orf_pfx_count) | |
12600 | vty_out(vty, " received (%d entries)", | |
12601 | orf_pfx_count); | |
12602 | vty_out(vty, "\n"); | |
12603 | } | |
12604 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12605 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
12606 | vty_out(vty, | |
12607 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
12608 | ||
12609 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12610 | PEER_FLAG_REFLECTOR_CLIENT)) | |
12611 | vty_out(vty, " Route-Reflector Client\n"); | |
12612 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12613 | PEER_FLAG_RSERVER_CLIENT)) | |
12614 | vty_out(vty, " Route-Server Client\n"); | |
70cd87ca MK |
12615 | |
12616 | if (peer_af_flag_check(p, afi, safi, PEER_FLAG_ORR_GROUP)) | |
12617 | vty_out(vty, " ORR group (configured) : %s\n", | |
12618 | p->orr_group_name[afi][safi]); | |
12619 | ||
d62a17ae | 12620 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
12621 | vty_out(vty, | |
12622 | " Inbound soft reconfiguration allowed\n"); | |
12623 | ||
12624 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12625 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
12626 | vty_out(vty, | |
12627 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
12628 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12629 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
12630 | vty_out(vty, | |
12631 | " Private AS numbers replaced in updates to this neighbor\n"); | |
12632 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12633 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
12634 | vty_out(vty, | |
12635 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
12636 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12637 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
12638 | vty_out(vty, | |
12639 | " Private AS numbers removed in updates to this neighbor\n"); | |
12640 | ||
b2ac1d0d MS |
12641 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN)) { |
12642 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12643 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) | |
12644 | vty_out(vty, | |
12645 | " Local AS allowed as path origin\n"); | |
12646 | else | |
12647 | vty_out(vty, | |
12648 | " Local AS allowed in path, %d occurrences\n", | |
12649 | p->allowas_in[afi][safi]); | |
12650 | } | |
12651 | ||
dcc68b5e MS |
12652 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
12653 | vty_out(vty, " %s\n", | |
12654 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
12655 | ->human_description); | |
d62a17ae | 12656 | |
12657 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
12658 | vty_out(vty, | |
12659 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
12660 | ||
12661 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
12662 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12663 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
12664 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
12665 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12666 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
12667 | vty_out(vty, | |
12668 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
12669 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12670 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
12671 | vty_out(vty, | |
12672 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
12673 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
12674 | vty_out(vty, | |
12675 | " MED is propagated unchanged to this neighbor\n"); | |
12676 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
12677 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12678 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12679 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12680 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
12681 | vty_out(vty, | |
12682 | " Community attribute sent to this neighbor"); | |
12683 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12684 | PEER_FLAG_SEND_COMMUNITY) | |
12685 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12686 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12687 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12688 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12689 | vty_out(vty, "(all)\n"); | |
12690 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12691 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12692 | vty_out(vty, "(large)\n"); | |
12693 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12694 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12695 | vty_out(vty, "(extended)\n"); | |
12696 | else | |
12697 | vty_out(vty, "(standard)\n"); | |
12698 | } | |
12699 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12700 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
12701 | vty_out(vty, " Default information originate,"); | |
12702 | ||
12703 | if (p->default_rmap[afi][safi].name) | |
12704 | vty_out(vty, " default route-map %s%s,", | |
12705 | p->default_rmap[afi][safi].map ? "*" | |
12706 | : "", | |
12707 | p->default_rmap[afi][safi].name); | |
12708 | if (paf && PAF_SUBGRP(paf) | |
12709 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
12710 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
12711 | vty_out(vty, " default sent\n"); | |
12712 | else | |
12713 | vty_out(vty, " default not sent\n"); | |
12714 | } | |
12715 | ||
dff8f48d MK |
12716 | /* advertise-vni-all */ |
12717 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 12718 | if (is_evpn_enabled()) |
dff8f48d MK |
12719 | vty_out(vty, " advertise-all-vni\n"); |
12720 | } | |
12721 | ||
d62a17ae | 12722 | if (filter->plist[FILTER_IN].name |
12723 | || filter->dlist[FILTER_IN].name | |
12724 | || filter->aslist[FILTER_IN].name | |
12725 | || filter->map[RMAP_IN].name) | |
12726 | vty_out(vty, " Inbound path policy configured\n"); | |
12727 | if (filter->plist[FILTER_OUT].name | |
12728 | || filter->dlist[FILTER_OUT].name | |
12729 | || filter->aslist[FILTER_OUT].name | |
12730 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
12731 | vty_out(vty, " Outbound path policy configured\n"); | |
12732 | ||
12733 | /* prefix-list */ | |
12734 | if (filter->plist[FILTER_IN].name) | |
12735 | vty_out(vty, | |
12736 | " Incoming update prefix filter list is %s%s\n", | |
12737 | filter->plist[FILTER_IN].plist ? "*" : "", | |
12738 | filter->plist[FILTER_IN].name); | |
12739 | if (filter->plist[FILTER_OUT].name) | |
12740 | vty_out(vty, | |
12741 | " Outgoing update prefix filter list is %s%s\n", | |
12742 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
12743 | filter->plist[FILTER_OUT].name); | |
12744 | ||
12745 | /* distribute-list */ | |
12746 | if (filter->dlist[FILTER_IN].name) | |
12747 | vty_out(vty, | |
12748 | " Incoming update network filter list is %s%s\n", | |
12749 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
12750 | filter->dlist[FILTER_IN].name); | |
12751 | if (filter->dlist[FILTER_OUT].name) | |
12752 | vty_out(vty, | |
12753 | " Outgoing update network filter list is %s%s\n", | |
12754 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
12755 | filter->dlist[FILTER_OUT].name); | |
12756 | ||
12757 | /* filter-list. */ | |
12758 | if (filter->aslist[FILTER_IN].name) | |
12759 | vty_out(vty, | |
12760 | " Incoming update AS path filter list is %s%s\n", | |
12761 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
12762 | filter->aslist[FILTER_IN].name); | |
12763 | if (filter->aslist[FILTER_OUT].name) | |
12764 | vty_out(vty, | |
12765 | " Outgoing update AS path filter list is %s%s\n", | |
12766 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
12767 | filter->aslist[FILTER_OUT].name); | |
12768 | ||
12769 | /* route-map. */ | |
12770 | if (filter->map[RMAP_IN].name) | |
12771 | vty_out(vty, | |
12772 | " Route map for incoming advertisements is %s%s\n", | |
12773 | filter->map[RMAP_IN].map ? "*" : "", | |
12774 | filter->map[RMAP_IN].name); | |
12775 | if (filter->map[RMAP_OUT].name) | |
12776 | vty_out(vty, | |
12777 | " Route map for outgoing advertisements is %s%s\n", | |
12778 | filter->map[RMAP_OUT].map ? "*" : "", | |
12779 | filter->map[RMAP_OUT].name); | |
12780 | ||
9dac9fc8 | 12781 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 12782 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12783 | && !bgp_inbound_policy_exists(p, filter)) |
12784 | vty_out(vty, | |
12785 | " Inbound updates discarded due to missing policy\n"); | |
12786 | ||
12787 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 12788 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12789 | && !bgp_outbound_policy_exists(p, filter)) |
12790 | vty_out(vty, | |
12791 | " Outbound updates discarded due to missing policy\n"); | |
12792 | ||
d62a17ae | 12793 | /* unsuppress-map */ |
12794 | if (filter->usmap.name) | |
12795 | vty_out(vty, | |
12796 | " Route map for selective unsuppress is %s%s\n", | |
12797 | filter->usmap.map ? "*" : "", | |
12798 | filter->usmap.name); | |
12799 | ||
7f7940e6 MK |
12800 | /* advertise-map */ |
12801 | if (filter->advmap.aname && filter->advmap.cname) | |
12802 | vty_out(vty, | |
12803 | " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n", | |
12804 | filter->advmap.condition ? "EXIST" | |
12805 | : "NON_EXIST", | |
12806 | filter->advmap.cmap ? "*" : "", | |
12807 | filter->advmap.cname, | |
12808 | filter->advmap.amap ? "*" : "", | |
12809 | filter->advmap.aname, | |
ecf2b628 QY |
12810 | filter->advmap.update_type == |
12811 | UPDATE_TYPE_ADVERTISE | |
c385f82a MK |
12812 | ? "Advertise" |
12813 | : "Withdraw"); | |
7f7940e6 | 12814 | |
d62a17ae | 12815 | /* Receive prefix count */ |
6cde4b45 | 12816 | vty_out(vty, " %u accepted prefixes\n", |
a0a87037 | 12817 | p->pcount[afi][safi]); |
d62a17ae | 12818 | |
fde246e8 DA |
12819 | /* maximum-prefix-out */ |
12820 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12821 | PEER_FLAG_MAX_PREFIX_OUT)) | |
12822 | vty_out(vty, | |
6cde4b45 | 12823 | " Maximum allowed prefixes sent %u\n", |
fde246e8 DA |
12824 | p->pmax_out[afi][safi]); |
12825 | ||
d62a17ae | 12826 | /* Maximum prefix */ |
12827 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 | 12828 | vty_out(vty, |
6cde4b45 | 12829 | " Maximum prefixes allowed %u%s\n", |
d62a17ae | 12830 | p->pmax[afi][safi], |
12831 | CHECK_FLAG(p->af_flags[afi][safi], | |
12832 | PEER_FLAG_MAX_PREFIX_WARNING) | |
12833 | ? " (warning-only)" | |
12834 | : ""); | |
12835 | vty_out(vty, " Threshold for warning message %d%%", | |
12836 | p->pmax_threshold[afi][safi]); | |
12837 | if (p->pmax_restart[afi][safi]) | |
12838 | vty_out(vty, ", restart interval %d min", | |
12839 | p->pmax_restart[afi][safi]); | |
12840 | vty_out(vty, "\n"); | |
12841 | } | |
12842 | ||
12843 | vty_out(vty, "\n"); | |
12844 | } | |
12845 | } | |
12846 | ||
9f049418 | 12847 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 12848 | json_object *json) |
718e3744 | 12849 | { |
d62a17ae | 12850 | struct bgp *bgp; |
47e12884 | 12851 | char buf1[PREFIX2STR_BUFFER]; |
d62a17ae | 12852 | char timebuf[BGP_UPTIME_LEN]; |
12853 | char dn_flag[2]; | |
d62a17ae | 12854 | afi_t afi; |
12855 | safi_t safi; | |
d7c0a89a QY |
12856 | uint16_t i; |
12857 | uint8_t *msg; | |
d62a17ae | 12858 | json_object *json_neigh = NULL; |
12859 | time_t epoch_tbuf; | |
4ab46701 | 12860 | uint32_t sync_tcp_mss; |
718e3744 | 12861 | |
d62a17ae | 12862 | bgp = p->bgp; |
12863 | ||
12864 | if (use_json) | |
12865 | json_neigh = json_object_new_object(); | |
12866 | ||
12867 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
12868 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
12869 | dn_flag[0] = '*'; | |
12870 | ||
12871 | if (!use_json) { | |
12872 | if (p->conf_if) /* Configured interface name. */ | |
47e12884 DA |
12873 | vty_out(vty, "BGP neighbor on %s: %pSU, ", p->conf_if, |
12874 | &p->su); | |
d62a17ae | 12875 | else /* Configured IP address. */ |
12876 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
12877 | p->host); | |
12878 | } | |
12879 | ||
12880 | if (use_json) { | |
12881 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
12882 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
12883 | "none"); | |
12884 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
47e12884 DA |
12885 | json_object_string_addf(json_neigh, "bgpNeighborAddr", |
12886 | "%pSU", &p->su); | |
d62a17ae | 12887 | |
12888 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
12889 | ||
12890 | if (p->change_local_as) | |
12891 | json_object_int_add(json_neigh, "localAs", | |
12892 | p->change_local_as); | |
12893 | else | |
12894 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
12895 | ||
12896 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
12897 | json_object_boolean_true_add(json_neigh, | |
12898 | "localAsNoPrepend"); | |
12899 | ||
12900 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
12901 | json_object_boolean_true_add(json_neigh, | |
12902 | "localAsReplaceAs"); | |
12903 | } else { | |
12904 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
12905 | || (p->as_type == AS_INTERNAL)) | |
12906 | vty_out(vty, "remote AS %u, ", p->as); | |
12907 | else | |
12908 | vty_out(vty, "remote AS Unspecified, "); | |
12909 | vty_out(vty, "local AS %u%s%s, ", | |
12910 | p->change_local_as ? p->change_local_as : p->local_as, | |
12911 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
12912 | ? " no-prepend" | |
12913 | : "", | |
12914 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
12915 | ? " replace-as" | |
12916 | : ""); | |
12917 | } | |
faa16034 DS |
12918 | /* peer type internal or confed-internal */ |
12919 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 12920 | if (use_json) { |
12921 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12922 | json_object_boolean_true_add( | |
12923 | json_neigh, "nbrConfedInternalLink"); | |
12924 | else | |
12925 | json_object_boolean_true_add(json_neigh, | |
12926 | "nbrInternalLink"); | |
12927 | } else { | |
12928 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12929 | vty_out(vty, "confed-internal link\n"); | |
12930 | else | |
12931 | vty_out(vty, "internal link\n"); | |
12932 | } | |
faa16034 DS |
12933 | /* peer type external or confed-external */ |
12934 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 12935 | if (use_json) { |
12936 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12937 | json_object_boolean_true_add( | |
12938 | json_neigh, "nbrConfedExternalLink"); | |
12939 | else | |
12940 | json_object_boolean_true_add(json_neigh, | |
12941 | "nbrExternalLink"); | |
12942 | } else { | |
12943 | if (bgp_confederation_peers_check(bgp, p->as)) | |
12944 | vty_out(vty, "confed-external link\n"); | |
12945 | else | |
12946 | vty_out(vty, "external link\n"); | |
12947 | } | |
faa16034 DS |
12948 | } else { |
12949 | if (use_json) | |
12950 | json_object_boolean_true_add(json_neigh, | |
12951 | "nbrUnspecifiedLink"); | |
12952 | else | |
12953 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 12954 | } |
12955 | ||
d864dd9e EB |
12956 | /* Roles */ |
12957 | if (use_json) { | |
12958 | json_object_string_add(json_neigh, "localRole", | |
8f2d6021 EB |
12959 | bgp_get_name_by_role(p->local_role)); |
12960 | json_object_string_add(json_neigh, "remoteRole", | |
12961 | bgp_get_name_by_role(p->remote_role)); | |
d864dd9e EB |
12962 | } else { |
12963 | vty_out(vty, " Local Role: %s\n", | |
8f2d6021 EB |
12964 | bgp_get_name_by_role(p->local_role)); |
12965 | vty_out(vty, " Remote Role: %s\n", | |
12966 | bgp_get_name_by_role(p->remote_role)); | |
d864dd9e EB |
12967 | } |
12968 | ||
12969 | ||
d62a17ae | 12970 | /* Description. */ |
12971 | if (p->desc) { | |
12972 | if (use_json) | |
12973 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
12974 | else | |
12975 | vty_out(vty, " Description: %s\n", p->desc); | |
12976 | } | |
12977 | ||
12978 | if (p->hostname) { | |
12979 | if (use_json) { | |
12980 | if (p->hostname) | |
12981 | json_object_string_add(json_neigh, "hostname", | |
12982 | p->hostname); | |
12983 | ||
12984 | if (p->domainname) | |
12985 | json_object_string_add(json_neigh, "domainname", | |
12986 | p->domainname); | |
12987 | } else { | |
12988 | if (p->domainname && (p->domainname[0] != '\0')) | |
12989 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
12990 | p->domainname); | |
12991 | else | |
12992 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
12993 | } | |
12994 | } | |
12995 | ||
12996 | /* Peer-group */ | |
12997 | if (p->group) { | |
12998 | if (use_json) { | |
12999 | json_object_string_add(json_neigh, "peerGroup", | |
13000 | p->group->name); | |
13001 | ||
13002 | if (dn_flag[0]) { | |
13003 | struct prefix prefix, *range = NULL; | |
13004 | ||
0154d8ce DS |
13005 | if (sockunion2hostprefix(&(p->su), &prefix)) |
13006 | range = peer_group_lookup_dynamic_neighbor_range( | |
13007 | p->group, &prefix); | |
d62a17ae | 13008 | |
13009 | if (range) { | |
67d7e256 | 13010 | json_object_string_addf( |
d62a17ae | 13011 | json_neigh, |
67d7e256 DA |
13012 | "peerSubnetRangeGroup", "%pFX", |
13013 | range); | |
d62a17ae | 13014 | } |
13015 | } | |
13016 | } else { | |
13017 | vty_out(vty, | |
13018 | " Member of peer-group %s for session parameters\n", | |
13019 | p->group->name); | |
13020 | ||
13021 | if (dn_flag[0]) { | |
13022 | struct prefix prefix, *range = NULL; | |
13023 | ||
0154d8ce DS |
13024 | if (sockunion2hostprefix(&(p->su), &prefix)) |
13025 | range = peer_group_lookup_dynamic_neighbor_range( | |
13026 | p->group, &prefix); | |
d62a17ae | 13027 | |
13028 | if (range) { | |
d62a17ae | 13029 | vty_out(vty, |
1b78780b DL |
13030 | " Belongs to the subnet range group: %pFX\n", |
13031 | range); | |
d62a17ae | 13032 | } |
13033 | } | |
13034 | } | |
13035 | } | |
13036 | ||
13037 | if (use_json) { | |
13038 | /* Administrative shutdown. */ | |
cb9196e7 DS |
13039 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
13040 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 13041 | json_object_boolean_true_add(json_neigh, |
13042 | "adminShutDown"); | |
13043 | ||
13044 | /* BGP Version. */ | |
13045 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
c949c771 DA |
13046 | json_object_string_addf(json_neigh, "remoteRouterId", "%pI4", |
13047 | &p->remote_id); | |
13048 | json_object_string_addf(json_neigh, "localRouterId", "%pI4", | |
13049 | &bgp->router_id); | |
d62a17ae | 13050 | |
13051 | /* Confederation */ | |
13052 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
13053 | && bgp_confederation_peers_check(bgp, p->as)) | |
13054 | json_object_boolean_true_add(json_neigh, | |
13055 | "nbrCommonAdmin"); | |
13056 | ||
13057 | /* Status. */ | |
13058 | json_object_string_add( | |
13059 | json_neigh, "bgpState", | |
13060 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
13061 | ||
feb17238 | 13062 | if (peer_established(p)) { |
d62a17ae | 13063 | time_t uptime; |
d62a17ae | 13064 | |
083ec940 | 13065 | uptime = monotime(NULL); |
d62a17ae | 13066 | uptime -= p->uptime; |
d62a17ae | 13067 | epoch_tbuf = time(NULL) - uptime; |
13068 | ||
d3c7efed DS |
13069 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
13070 | uptime * 1000); | |
d62a17ae | 13071 | json_object_string_add(json_neigh, "bgpTimerUpString", |
13072 | peer_uptime(p->uptime, timebuf, | |
13073 | BGP_UPTIME_LEN, 0, | |
13074 | NULL)); | |
13075 | json_object_int_add(json_neigh, | |
13076 | "bgpTimerUpEstablishedEpoch", | |
13077 | epoch_tbuf); | |
13078 | } | |
13079 | ||
13080 | else if (p->status == Active) { | |
13081 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
13082 | json_object_string_add(json_neigh, "bgpStateIs", | |
13083 | "passive"); | |
13084 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
13085 | json_object_string_add(json_neigh, "bgpStateIs", | |
13086 | "passiveNSF"); | |
13087 | } | |
13088 | ||
13089 | /* read timer */ | |
13090 | time_t uptime; | |
a2700b50 | 13091 | struct tm tm; |
d62a17ae | 13092 | |
083ec940 | 13093 | uptime = monotime(NULL); |
d62a17ae | 13094 | uptime -= p->readtime; |
a2700b50 MS |
13095 | gmtime_r(&uptime, &tm); |
13096 | ||
d62a17ae | 13097 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
13098 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
13099 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 13100 | |
083ec940 | 13101 | uptime = monotime(NULL); |
d62a17ae | 13102 | uptime -= p->last_write; |
a2700b50 MS |
13103 | gmtime_r(&uptime, &tm); |
13104 | ||
d62a17ae | 13105 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
13106 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
13107 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 13108 | |
083ec940 | 13109 | uptime = monotime(NULL); |
d62a17ae | 13110 | uptime -= p->update_time; |
a2700b50 MS |
13111 | gmtime_r(&uptime, &tm); |
13112 | ||
d62a17ae | 13113 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
13114 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
13115 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 13116 | |
13117 | /* Configured timer values. */ | |
9b1b9623 TA |
13118 | json_object_int_add(json_neigh, |
13119 | "bgpTimerConfiguredHoldTimeMsecs", | |
e93d5c29 TA |
13120 | CHECK_FLAG(p->flags, PEER_FLAG_TIMER) |
13121 | ? p->holdtime * 1000 | |
13122 | : bgp->default_holdtime * 1000); | |
13123 | json_object_int_add(json_neigh, | |
13124 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
13125 | CHECK_FLAG(p->flags, PEER_FLAG_TIMER) | |
13126 | ? p->keepalive * 1000 | |
13127 | : bgp->default_keepalive * 1000); | |
d62a17ae | 13128 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", |
13129 | p->v_holdtime * 1000); | |
13130 | json_object_int_add(json_neigh, | |
13131 | "bgpTimerKeepAliveIntervalMsecs", | |
13132 | p->v_keepalive * 1000); | |
d43114f3 DS |
13133 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) { |
13134 | json_object_int_add(json_neigh, | |
13135 | "bgpTimerDelayOpenTimeMsecs", | |
13136 | p->v_delayopen * 1000); | |
13137 | } | |
13138 | ||
4ab46701 AR |
13139 | /* Configured and Synced tcp-mss value for peer */ |
13140 | if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { | |
13141 | sync_tcp_mss = sockopt_tcp_mss_get(p->fd); | |
13142 | json_object_int_add(json_neigh, "bgpTcpMssConfigured", | |
13143 | p->tcp_mss); | |
13144 | json_object_int_add(json_neigh, "bgpTcpMssSynced", | |
13145 | sync_tcp_mss); | |
13146 | } | |
13147 | ||
d08c0c80 DA |
13148 | /* Extended Optional Parameters Length for BGP OPEN Message */ |
13149 | if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p)) | |
13150 | json_object_boolean_true_add( | |
13151 | json_neigh, "extendedOptionalParametersLength"); | |
13152 | else | |
13153 | json_object_boolean_false_add( | |
13154 | json_neigh, "extendedOptionalParametersLength"); | |
6e37924b DA |
13155 | |
13156 | /* Conditional advertisements */ | |
13157 | json_object_int_add( | |
13158 | json_neigh, | |
13159 | "bgpTimerConfiguredConditionalAdvertisementsSec", | |
13160 | bgp->condition_check_period); | |
13161 | if (thread_is_scheduled(bgp->t_condition_check)) | |
13162 | json_object_int_add( | |
13163 | json_neigh, | |
13164 | "bgpTimerUntilConditionalAdvertisementsSec", | |
13165 | thread_timer_remain_second( | |
13166 | bgp->t_condition_check)); | |
d62a17ae | 13167 | } else { |
13168 | /* Administrative shutdown. */ | |
cb9196e7 DS |
13169 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
13170 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 13171 | vty_out(vty, " Administratively shut down\n"); |
13172 | ||
13173 | /* BGP Version. */ | |
13174 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 13175 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 13176 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
13177 | vty_out(vty, ", local router ID %s\n", |
13178 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
13179 | sizeof(buf1))); | |
d62a17ae | 13180 | |
13181 | /* Confederation */ | |
13182 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
13183 | && bgp_confederation_peers_check(bgp, p->as)) | |
13184 | vty_out(vty, | |
13185 | " Neighbor under common administration\n"); | |
13186 | ||
13187 | /* Status. */ | |
13188 | vty_out(vty, " BGP state = %s", | |
13189 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
13190 | ||
feb17238 | 13191 | if (peer_established(p)) |
d62a17ae | 13192 | vty_out(vty, ", up for %8s", |
13193 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
13194 | 0, NULL)); | |
13195 | ||
13196 | else if (p->status == Active) { | |
13197 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
13198 | vty_out(vty, " (passive)"); | |
13199 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
13200 | vty_out(vty, " (NSF passive)"); | |
13201 | } | |
13202 | vty_out(vty, "\n"); | |
13203 | ||
13204 | /* read timer */ | |
13205 | vty_out(vty, " Last read %s", | |
13206 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
13207 | NULL)); | |
13208 | vty_out(vty, ", Last write %s\n", | |
13209 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
13210 | NULL)); | |
13211 | ||
13212 | /* Configured timer values. */ | |
13213 | vty_out(vty, | |
e93d5c29 | 13214 | " Hold time is %d seconds, keepalive interval is %d seconds\n", |
d62a17ae | 13215 | p->v_holdtime, p->v_keepalive); |
e93d5c29 TA |
13216 | vty_out(vty, " Configured hold time is %d seconds", |
13217 | CHECK_FLAG(p->flags, PEER_FLAG_TIMER) | |
13218 | ? p->holdtime | |
13219 | : bgp->default_holdtime); | |
9b1b9623 | 13220 | vty_out(vty, ", keepalive interval is %d seconds\n", |
e93d5c29 TA |
13221 | CHECK_FLAG(p->flags, PEER_FLAG_TIMER) |
13222 | ? p->keepalive | |
13223 | : bgp->default_keepalive); | |
d43114f3 DS |
13224 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) |
13225 | vty_out(vty, | |
13226 | " Configured DelayOpenTime is %d seconds\n", | |
13227 | p->delayopen); | |
4ab46701 AR |
13228 | |
13229 | /* Configured and synced tcp-mss value for peer */ | |
13230 | if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { | |
13231 | sync_tcp_mss = sockopt_tcp_mss_get(p->fd); | |
13232 | vty_out(vty, " Configured tcp-mss is %d", p->tcp_mss); | |
13233 | vty_out(vty, ", synced tcp-mss is %d\n", sync_tcp_mss); | |
13234 | } | |
d08c0c80 DA |
13235 | |
13236 | /* Extended Optional Parameters Length for BGP OPEN Message */ | |
13237 | if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p)) | |
13238 | vty_out(vty, | |
13239 | " Extended Optional Parameters Length is enabled\n"); | |
6e37924b DA |
13240 | |
13241 | /* Conditional advertisements */ | |
13242 | vty_out(vty, | |
13243 | " Configured conditional advertisements interval is %d seconds\n", | |
13244 | bgp->condition_check_period); | |
13245 | if (thread_is_scheduled(bgp->t_condition_check)) | |
13246 | vty_out(vty, | |
13247 | " Time until conditional advertisements begin is %lu seconds\n", | |
13248 | thread_timer_remain_second( | |
13249 | bgp->t_condition_check)); | |
d62a17ae | 13250 | } |
13251 | /* Capability. */ | |
10711563 DA |
13252 | if (peer_established(p) && |
13253 | (p->cap || peer_afc_advertised(p) || peer_afc_received(p))) { | |
13254 | if (use_json) { | |
13255 | json_object *json_cap = NULL; | |
d62a17ae | 13256 | |
10711563 | 13257 | json_cap = json_object_new_object(); |
d62a17ae | 13258 | |
10711563 DA |
13259 | /* AS4 */ |
13260 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) || | |
13261 | CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
13262 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) && | |
13263 | CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV)) | |
ef56aee4 | 13264 | json_object_string_add( |
10711563 | 13265 | json_cap, "4byteAs", |
ef56aee4 | 13266 | "advertisedAndReceived"); |
10711563 DA |
13267 | else if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) |
13268 | json_object_string_add(json_cap, | |
13269 | "4byteAs", | |
13270 | "advertised"); | |
13271 | else if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV)) | |
13272 | json_object_string_add(json_cap, | |
13273 | "4byteAs", | |
13274 | "received"); | |
13275 | } | |
ef56aee4 | 13276 | |
10711563 DA |
13277 | /* Extended Message Support */ |
13278 | if (CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_ADV) && | |
13279 | CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
13280 | json_object_string_add(json_cap, | |
13281 | "extendedMessage", | |
13282 | "advertisedAndReceived"); | |
13283 | else if (CHECK_FLAG(p->cap, | |
13284 | PEER_CAP_EXTENDED_MESSAGE_ADV)) | |
13285 | json_object_string_add(json_cap, | |
13286 | "extendedMessage", | |
13287 | "advertised"); | |
13288 | else if (CHECK_FLAG(p->cap, | |
13289 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
13290 | json_object_string_add(json_cap, | |
13291 | "extendedMessage", | |
13292 | "received"); | |
ef56aee4 | 13293 | |
10711563 DA |
13294 | /* AddPath */ |
13295 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) || | |
13296 | CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_ADV)) { | |
13297 | json_object *json_add = NULL; | |
13298 | const char *print_store; | |
d62a17ae | 13299 | |
10711563 | 13300 | json_add = json_object_new_object(); |
d62a17ae | 13301 | |
10711563 DA |
13302 | FOREACH_AFI_SAFI (afi, safi) { |
13303 | json_object *json_sub = NULL; | |
13304 | json_sub = json_object_new_object(); | |
13305 | print_store = get_afi_safi_str( | |
13306 | afi, safi, true); | |
d62a17ae | 13307 | |
10711563 DA |
13308 | if (CHECK_FLAG( |
13309 | p->af_cap[afi][safi], | |
13310 | PEER_CAP_ADDPATH_AF_TX_ADV) || | |
13311 | CHECK_FLAG( | |
13312 | p->af_cap[afi][safi], | |
13313 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
05c7a1cc QY |
13314 | if (CHECK_FLAG( |
13315 | p->af_cap[afi] | |
13316 | [safi], | |
10711563 DA |
13317 | PEER_CAP_ADDPATH_AF_TX_ADV) && |
13318 | CHECK_FLAG( | |
05c7a1cc QY |
13319 | p->af_cap[afi] |
13320 | [safi], | |
10711563 DA |
13321 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
13322 | json_object_boolean_true_add( | |
13323 | json_sub, | |
13324 | "txAdvertisedAndReceived"); | |
13325 | else if ( | |
13326 | CHECK_FLAG( | |
13327 | p->af_cap[afi] | |
13328 | [safi], | |
13329 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
13330 | json_object_boolean_true_add( | |
13331 | json_sub, | |
13332 | "txAdvertised"); | |
13333 | else if ( | |
13334 | CHECK_FLAG( | |
13335 | p->af_cap[afi] | |
13336 | [safi], | |
13337 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
13338 | json_object_boolean_true_add( | |
13339 | json_sub, | |
13340 | "txReceived"); | |
13341 | } | |
d62a17ae | 13342 | |
10711563 DA |
13343 | if (CHECK_FLAG( |
13344 | p->af_cap[afi][safi], | |
13345 | PEER_CAP_ADDPATH_AF_RX_ADV) || | |
13346 | CHECK_FLAG( | |
13347 | p->af_cap[afi][safi], | |
13348 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
05c7a1cc QY |
13349 | if (CHECK_FLAG( |
13350 | p->af_cap[afi] | |
13351 | [safi], | |
10711563 DA |
13352 | PEER_CAP_ADDPATH_AF_RX_ADV) && |
13353 | CHECK_FLAG( | |
13354 | p->af_cap[afi] | |
13355 | [safi], | |
13356 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
13357 | json_object_boolean_true_add( | |
13358 | json_sub, | |
13359 | "rxAdvertisedAndReceived"); | |
13360 | else if ( | |
13361 | CHECK_FLAG( | |
13362 | p->af_cap[afi] | |
13363 | [safi], | |
13364 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
13365 | json_object_boolean_true_add( | |
13366 | json_sub, | |
13367 | "rxAdvertised"); | |
13368 | else if ( | |
13369 | CHECK_FLAG( | |
13370 | p->af_cap[afi] | |
13371 | [safi], | |
13372 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
13373 | json_object_boolean_true_add( | |
13374 | json_sub, | |
13375 | "rxReceived"); | |
05c7a1cc QY |
13376 | } |
13377 | ||
10711563 DA |
13378 | if (CHECK_FLAG( |
13379 | p->af_cap[afi][safi], | |
13380 | PEER_CAP_ADDPATH_AF_TX_ADV) || | |
13381 | CHECK_FLAG( | |
13382 | p->af_cap[afi][safi], | |
13383 | PEER_CAP_ADDPATH_AF_TX_RCV) || | |
13384 | CHECK_FLAG( | |
13385 | p->af_cap[afi][safi], | |
13386 | PEER_CAP_ADDPATH_AF_RX_ADV) || | |
13387 | CHECK_FLAG( | |
13388 | p->af_cap[afi][safi], | |
13389 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
13390 | json_object_object_add( | |
13391 | json_add, print_store, | |
13392 | json_sub); | |
13393 | else | |
13394 | json_object_free(json_sub); | |
d62a17ae | 13395 | } |
13396 | ||
10711563 DA |
13397 | json_object_object_add(json_cap, "addPath", |
13398 | json_add); | |
13399 | } | |
d62a17ae | 13400 | |
10711563 DA |
13401 | /* Dynamic */ |
13402 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) || | |
13403 | CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV)) { | |
13404 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV) && | |
13405 | CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV)) | |
13406 | json_object_string_add( | |
13407 | json_cap, "dynamic", | |
13408 | "advertisedAndReceived"); | |
13409 | else if (CHECK_FLAG(p->cap, | |
13410 | PEER_CAP_DYNAMIC_ADV)) | |
13411 | json_object_string_add(json_cap, | |
13412 | "dynamic", | |
13413 | "advertised"); | |
13414 | else if (CHECK_FLAG(p->cap, | |
13415 | PEER_CAP_DYNAMIC_RCV)) | |
13416 | json_object_string_add(json_cap, | |
13417 | "dynamic", | |
13418 | "received"); | |
13419 | } | |
d62a17ae | 13420 | |
d864dd9e EB |
13421 | /* Role */ |
13422 | if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_RCV) || | |
13423 | CHECK_FLAG(p->cap, PEER_CAP_ROLE_ADV)) { | |
13424 | if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_ADV) && | |
13425 | CHECK_FLAG(p->cap, PEER_CAP_ROLE_RCV)) | |
13426 | json_object_string_add( | |
13427 | json_cap, "role", | |
13428 | "advertisedAndReceived"); | |
13429 | else if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_ADV)) | |
13430 | json_object_string_add(json_cap, "role", | |
13431 | "advertised"); | |
13432 | else if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_RCV)) | |
13433 | json_object_string_add(json_cap, "role", | |
13434 | "received"); | |
13435 | } | |
13436 | ||
10711563 DA |
13437 | /* Extended nexthop */ |
13438 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) || | |
13439 | CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
13440 | json_object *json_nxt = NULL; | |
13441 | const char *print_store; | |
d62a17ae | 13442 | |
d62a17ae | 13443 | |
10711563 DA |
13444 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV) && |
13445 | CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) | |
13446 | json_object_string_add( | |
13447 | json_cap, "extendedNexthop", | |
13448 | "advertisedAndReceived"); | |
13449 | else if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) | |
13450 | json_object_string_add( | |
13451 | json_cap, "extendedNexthop", | |
13452 | "advertised"); | |
13453 | else if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) | |
13454 | json_object_string_add( | |
13455 | json_cap, "extendedNexthop", | |
13456 | "received"); | |
d62a17ae | 13457 | |
10711563 DA |
13458 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) { |
13459 | json_nxt = json_object_new_object(); | |
d62a17ae | 13460 | |
10711563 DA |
13461 | for (safi = SAFI_UNICAST; |
13462 | safi < SAFI_MAX; safi++) { | |
13463 | if (CHECK_FLAG( | |
13464 | p->af_cap[AFI_IP] | |
13465 | [safi], | |
13466 | PEER_CAP_ENHE_AF_RCV)) { | |
13467 | print_store = | |
13468 | get_afi_safi_str( | |
d62a17ae | 13469 | AFI_IP, |
10711563 DA |
13470 | safi, |
13471 | true); | |
13472 | json_object_string_add( | |
13473 | json_nxt, | |
13474 | print_store, | |
13475 | "recieved"); /* misspelled for compatibility */ | |
d62a17ae | 13476 | } |
d62a17ae | 13477 | } |
10711563 DA |
13478 | json_object_object_add( |
13479 | json_cap, | |
13480 | "extendedNexthopFamililesByPeer", | |
13481 | json_nxt); | |
d62a17ae | 13482 | } |
10711563 | 13483 | } |
d62a17ae | 13484 | |
10711563 DA |
13485 | /* Long-lived Graceful Restart */ |
13486 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV) || | |
13487 | CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) { | |
13488 | json_object *json_llgr = NULL; | |
13489 | const char *afi_safi_str; | |
8606be87 | 13490 | |
10711563 DA |
13491 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV) && |
13492 | CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) | |
13493 | json_object_string_add( | |
13494 | json_cap, | |
13495 | "longLivedGracefulRestart", | |
13496 | "advertisedAndReceived"); | |
13497 | else if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) | |
13498 | json_object_string_add( | |
13499 | json_cap, | |
13500 | "longLivedGracefulRestart", | |
13501 | "advertised"); | |
13502 | else if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) | |
13503 | json_object_string_add( | |
13504 | json_cap, | |
13505 | "longLivedGracefulRestart", | |
13506 | "received"); | |
8606be87 | 13507 | |
10711563 DA |
13508 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) { |
13509 | json_llgr = json_object_new_object(); | |
8606be87 | 13510 | |
10711563 DA |
13511 | FOREACH_AFI_SAFI (afi, safi) { |
13512 | if (CHECK_FLAG( | |
13513 | p->af_cap[afi] | |
13514 | [safi], | |
13515 | PEER_CAP_ENHE_AF_RCV)) { | |
13516 | afi_safi_str = | |
13517 | get_afi_safi_str( | |
8606be87 DA |
13518 | afi, |
13519 | safi, | |
13520 | true); | |
10711563 DA |
13521 | json_object_string_add( |
13522 | json_llgr, | |
13523 | afi_safi_str, | |
13524 | "received"); | |
8606be87 | 13525 | } |
8606be87 | 13526 | } |
10711563 DA |
13527 | json_object_object_add( |
13528 | json_cap, | |
13529 | "longLivedGracefulRestartByPeer", | |
13530 | json_llgr); | |
8606be87 | 13531 | } |
10711563 | 13532 | } |
8606be87 | 13533 | |
10711563 DA |
13534 | /* Route Refresh */ |
13535 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) || | |
13536 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_NEW_RCV) || | |
13537 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_OLD_RCV)) { | |
13538 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) && | |
13539 | (CHECK_FLAG(p->cap, | |
13540 | PEER_CAP_REFRESH_NEW_RCV) || | |
13541 | CHECK_FLAG(p->cap, | |
13542 | PEER_CAP_REFRESH_OLD_RCV))) { | |
13543 | if (CHECK_FLAG( | |
13544 | p->cap, | |
13545 | PEER_CAP_REFRESH_OLD_RCV) && | |
13546 | CHECK_FLAG( | |
13547 | p->cap, | |
13548 | PEER_CAP_REFRESH_NEW_RCV)) | |
13549 | json_object_string_add( | |
13550 | json_cap, | |
13551 | "routeRefresh", | |
13552 | "advertisedAndReceivedOldNew"); | |
13553 | else { | |
d62a17ae | 13554 | if (CHECK_FLAG( |
13555 | p->cap, | |
10711563 | 13556 | PEER_CAP_REFRESH_OLD_RCV)) |
d62a17ae | 13557 | json_object_string_add( |
13558 | json_cap, | |
13559 | "routeRefresh", | |
10711563 DA |
13560 | "advertisedAndReceivedOld"); |
13561 | else | |
13562 | json_object_string_add( | |
13563 | json_cap, | |
13564 | "routeRefresh", | |
13565 | "advertisedAndReceivedNew"); | |
d62a17ae | 13566 | } |
10711563 DA |
13567 | } else if (CHECK_FLAG(p->cap, |
13568 | PEER_CAP_REFRESH_ADV)) | |
13569 | json_object_string_add(json_cap, | |
13570 | "routeRefresh", | |
13571 | "advertised"); | |
13572 | else if (CHECK_FLAG(p->cap, | |
13573 | PEER_CAP_REFRESH_NEW_RCV) || | |
13574 | CHECK_FLAG(p->cap, | |
13575 | PEER_CAP_REFRESH_OLD_RCV)) | |
13576 | json_object_string_add(json_cap, | |
13577 | "routeRefresh", | |
13578 | "received"); | |
13579 | } | |
d62a17ae | 13580 | |
10711563 DA |
13581 | /* Enhanced Route Refresh */ |
13582 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) || | |
13583 | CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_RCV)) { | |
13584 | if (CHECK_FLAG(p->cap, | |
13585 | PEER_CAP_ENHANCED_RR_ADV) && | |
13586 | CHECK_FLAG(p->cap, | |
13587 | PEER_CAP_ENHANCED_RR_RCV)) | |
d77114b7 | 13588 | json_object_string_add( |
10711563 DA |
13589 | json_cap, |
13590 | "enhancedRouteRefresh", | |
13591 | "advertisedAndReceived"); | |
13592 | else if (CHECK_FLAG(p->cap, | |
13593 | PEER_CAP_ENHANCED_RR_ADV)) | |
d77114b7 | 13594 | json_object_string_add( |
10711563 DA |
13595 | json_cap, |
13596 | "enhancedRouteRefresh", | |
13597 | "advertised"); | |
13598 | else if (CHECK_FLAG(p->cap, | |
9af52ccf | 13599 | PEER_CAP_ENHANCED_RR_RCV)) |
10711563 DA |
13600 | json_object_string_add( |
13601 | json_cap, | |
13602 | "enhancedRouteRefresh", | |
13603 | "received"); | |
13604 | } | |
d77114b7 | 13605 | |
10711563 DA |
13606 | /* Multiprotocol Extensions */ |
13607 | json_object *json_multi = NULL; | |
d77114b7 | 13608 | |
10711563 | 13609 | json_multi = json_object_new_object(); |
d77114b7 | 13610 | |
10711563 DA |
13611 | FOREACH_AFI_SAFI (afi, safi) { |
13612 | if (p->afc_adv[afi][safi] || | |
13613 | p->afc_recv[afi][safi]) { | |
13614 | json_object *json_exten = NULL; | |
13615 | json_exten = json_object_new_object(); | |
13616 | ||
13617 | if (p->afc_adv[afi][safi] && | |
13618 | p->afc_recv[afi][safi]) | |
13619 | json_object_boolean_true_add( | |
13620 | json_exten, | |
9af52ccf | 13621 | "advertisedAndReceived"); |
10711563 DA |
13622 | else if (p->afc_adv[afi][safi]) |
13623 | json_object_boolean_true_add( | |
13624 | json_exten, | |
9af52ccf | 13625 | "advertised"); |
10711563 DA |
13626 | else if (p->afc_recv[afi][safi]) |
13627 | json_object_boolean_true_add( | |
13628 | json_exten, "received"); | |
9af52ccf | 13629 | |
10711563 DA |
13630 | json_object_object_add( |
13631 | json_multi, | |
13632 | get_afi_safi_str(afi, safi, | |
13633 | true), | |
13634 | json_exten); | |
13635 | } | |
13636 | } | |
13637 | json_object_object_add(json_cap, | |
13638 | "multiprotocolExtensions", | |
13639 | json_multi); | |
d62a17ae | 13640 | |
10711563 DA |
13641 | /* Hostname capabilities */ |
13642 | json_object *json_hname = NULL; | |
d62a17ae | 13643 | |
10711563 | 13644 | json_hname = json_object_new_object(); |
d62a17ae | 13645 | |
10711563 DA |
13646 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { |
13647 | json_object_string_add( | |
13648 | json_hname, "advHostName", | |
13649 | bgp->peer_self->hostname | |
13650 | ? bgp->peer_self->hostname | |
13651 | : "n/a"); | |
13652 | json_object_string_add( | |
13653 | json_hname, "advDomainName", | |
13654 | bgp->peer_self->domainname | |
13655 | ? bgp->peer_self->domainname | |
13656 | : "n/a"); | |
13657 | } | |
d77114b7 | 13658 | |
d77114b7 | 13659 | |
10711563 DA |
13660 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
13661 | json_object_string_add( | |
13662 | json_hname, "rcvHostName", | |
13663 | p->hostname ? p->hostname : "n/a"); | |
13664 | json_object_string_add( | |
13665 | json_hname, "rcvDomainName", | |
13666 | p->domainname ? p->domainname : "n/a"); | |
13667 | } | |
d77114b7 | 13668 | |
10711563 DA |
13669 | json_object_object_add(json_cap, "hostName", |
13670 | json_hname); | |
d77114b7 | 13671 | |
17be83bf | 13672 | /* Graceful Restart */ |
10711563 DA |
13673 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || |
13674 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)) { | |
13675 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) && | |
13676 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
d77114b7 | 13677 | json_object_string_add( |
10711563 DA |
13678 | json_cap, "gracefulRestart", |
13679 | "advertisedAndReceived"); | |
13680 | else if (CHECK_FLAG(p->cap, | |
13681 | PEER_CAP_RESTART_ADV)) | |
d77114b7 | 13682 | json_object_string_add( |
10711563 DA |
13683 | json_cap, |
13684 | "gracefulRestartCapability", | |
13685 | "advertised"); | |
13686 | else if (CHECK_FLAG(p->cap, | |
13687 | PEER_CAP_RESTART_RCV)) | |
13688 | json_object_string_add( | |
13689 | json_cap, | |
13690 | "gracefulRestartCapability", | |
13691 | "received"); | |
d77114b7 | 13692 | |
10711563 DA |
13693 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { |
13694 | int restart_af_count = 0; | |
13695 | json_object *json_restart = NULL; | |
13696 | json_restart = json_object_new_object(); | |
d62a17ae | 13697 | |
10711563 DA |
13698 | json_object_int_add( |
13699 | json_cap, | |
13700 | "gracefulRestartRemoteTimerMsecs", | |
13701 | p->v_gr_restart * 1000); | |
d62a17ae | 13702 | |
10711563 | 13703 | FOREACH_AFI_SAFI (afi, safi) { |
05c7a1cc QY |
13704 | if (CHECK_FLAG( |
13705 | p->af_cap[afi] | |
13706 | [safi], | |
10711563 DA |
13707 | PEER_CAP_RESTART_AF_RCV)) { |
13708 | json_object *json_sub = | |
13709 | NULL; | |
13710 | json_sub = | |
13711 | json_object_new_object(); | |
d62a17ae | 13712 | |
05c7a1cc QY |
13713 | if (CHECK_FLAG( |
13714 | p->af_cap | |
13715 | [afi] | |
13716 | [safi], | |
10711563 DA |
13717 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
13718 | json_object_boolean_true_add( | |
13719 | json_sub, | |
13720 | "preserved"); | |
13721 | restart_af_count++; | |
d62a17ae | 13722 | json_object_object_add( |
10711563 DA |
13723 | json_restart, |
13724 | get_afi_safi_str( | |
13725 | afi, | |
13726 | safi, | |
13727 | true), | |
13728 | json_sub); | |
d62a17ae | 13729 | } |
d62a17ae | 13730 | } |
10711563 DA |
13731 | if (!restart_af_count) { |
13732 | json_object_string_add( | |
13733 | json_cap, | |
13734 | "addressFamiliesByPeer", | |
13735 | "none"); | |
13736 | json_object_free(json_restart); | |
13737 | } else | |
13738 | json_object_object_add( | |
13739 | json_cap, | |
13740 | "addressFamiliesByPeer", | |
13741 | json_restart); | |
d62a17ae | 13742 | } |
10711563 DA |
13743 | } |
13744 | json_object_object_add( | |
13745 | json_neigh, "neighborCapabilities", json_cap); | |
13746 | } else { | |
13747 | vty_out(vty, " Neighbor capabilities:\n"); | |
13748 | ||
13749 | /* AS4 */ | |
13750 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) || | |
13751 | CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
13752 | vty_out(vty, " 4 Byte AS:"); | |
13753 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) | |
13754 | vty_out(vty, " advertised"); | |
13755 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV)) | |
13756 | vty_out(vty, " %sreceived", | |
13757 | CHECK_FLAG(p->cap, | |
13758 | PEER_CAP_AS4_ADV) | |
13759 | ? "and " | |
13760 | : ""); | |
13761 | vty_out(vty, "\n"); | |
13762 | } | |
d62a17ae | 13763 | |
10711563 DA |
13764 | /* Extended Message Support */ |
13765 | if (CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_RCV) || | |
13766 | CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_ADV)) { | |
13767 | vty_out(vty, " Extended Message:"); | |
ef56aee4 | 13768 | if (CHECK_FLAG(p->cap, |
10711563 DA |
13769 | PEER_CAP_EXTENDED_MESSAGE_ADV)) |
13770 | vty_out(vty, " advertised"); | |
13771 | if (CHECK_FLAG(p->cap, | |
13772 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
13773 | vty_out(vty, " %sreceived", | |
13774 | CHECK_FLAG( | |
13775 | p->cap, | |
13776 | PEER_CAP_EXTENDED_MESSAGE_ADV) | |
13777 | ? "and " | |
13778 | : ""); | |
13779 | vty_out(vty, "\n"); | |
13780 | } | |
d62a17ae | 13781 | |
10711563 DA |
13782 | /* AddPath */ |
13783 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) || | |
13784 | CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_ADV)) { | |
13785 | vty_out(vty, " AddPath:\n"); | |
d62a17ae | 13786 | |
10711563 | 13787 | FOREACH_AFI_SAFI (afi, safi) { |
ef56aee4 | 13788 | if (CHECK_FLAG( |
10711563 DA |
13789 | p->af_cap[afi][safi], |
13790 | PEER_CAP_ADDPATH_AF_TX_ADV) || | |
13791 | CHECK_FLAG( | |
13792 | p->af_cap[afi][safi], | |
13793 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
13794 | vty_out(vty, " %s: TX ", | |
13795 | get_afi_safi_str( | |
13796 | afi, safi, | |
13797 | false)); | |
ef56aee4 | 13798 | |
10711563 DA |
13799 | if (CHECK_FLAG( |
13800 | p->af_cap[afi] | |
13801 | [safi], | |
13802 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
13803 | vty_out(vty, | |
13804 | "advertised"); | |
d62a17ae | 13805 | |
05c7a1cc QY |
13806 | if (CHECK_FLAG( |
13807 | p->af_cap[afi] | |
13808 | [safi], | |
10711563 | 13809 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
05c7a1cc | 13810 | vty_out(vty, |
10711563 DA |
13811 | "%sreceived", |
13812 | CHECK_FLAG( | |
13813 | p->af_cap | |
13814 | [afi] | |
13815 | [safi], | |
13816 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13817 | ? " and " | |
13818 | : ""); | |
05c7a1cc | 13819 | |
10711563 DA |
13820 | vty_out(vty, "\n"); |
13821 | } | |
d62a17ae | 13822 | |
9af52ccf | 13823 | if (CHECK_FLAG( |
10711563 DA |
13824 | p->af_cap[afi][safi], |
13825 | PEER_CAP_ADDPATH_AF_RX_ADV) || | |
13826 | CHECK_FLAG( | |
13827 | p->af_cap[afi][safi], | |
13828 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
13829 | vty_out(vty, " %s: RX ", | |
5cb5f4d0 | 13830 | get_afi_safi_str( |
10711563 DA |
13831 | afi, safi, |
13832 | false)); | |
d62a17ae | 13833 | |
05c7a1cc QY |
13834 | if (CHECK_FLAG( |
13835 | p->af_cap[afi] | |
13836 | [safi], | |
10711563 | 13837 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
05c7a1cc | 13838 | vty_out(vty, |
10711563 | 13839 | "advertised"); |
d62a17ae | 13840 | |
10711563 DA |
13841 | if (CHECK_FLAG( |
13842 | p->af_cap[afi] | |
13843 | [safi], | |
13844 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc | 13845 | vty_out(vty, |
10711563 DA |
13846 | "%sreceived", |
13847 | CHECK_FLAG( | |
13848 | p->af_cap | |
13849 | [afi] | |
13850 | [safi], | |
13851 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13852 | ? " and " | |
05c7a1cc | 13853 | : ""); |
d62a17ae | 13854 | |
05c7a1cc | 13855 | vty_out(vty, "\n"); |
05c7a1cc | 13856 | } |
d62a17ae | 13857 | } |
10711563 | 13858 | } |
d62a17ae | 13859 | |
10711563 DA |
13860 | /* Dynamic */ |
13861 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) || | |
13862 | CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV)) { | |
13863 | vty_out(vty, " Dynamic:"); | |
13864 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV)) | |
13865 | vty_out(vty, " advertised"); | |
13866 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV)) | |
13867 | vty_out(vty, " %sreceived", | |
13868 | CHECK_FLAG(p->cap, | |
13869 | PEER_CAP_DYNAMIC_ADV) | |
13870 | ? "and " | |
13871 | : ""); | |
13872 | vty_out(vty, "\n"); | |
13873 | } | |
d62a17ae | 13874 | |
d864dd9e EB |
13875 | /* Role */ |
13876 | if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_RCV) || | |
13877 | CHECK_FLAG(p->cap, PEER_CAP_ROLE_ADV)) { | |
13878 | vty_out(vty, " Role:"); | |
13879 | if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_ADV)) | |
13880 | vty_out(vty, " advertised"); | |
13881 | if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_RCV)) | |
13882 | vty_out(vty, " %sreceived", | |
13883 | CHECK_FLAG(p->cap, | |
13884 | PEER_CAP_ROLE_ADV) | |
13885 | ? "and " | |
13886 | : ""); | |
13887 | vty_out(vty, "\n"); | |
13888 | } | |
13889 | ||
10711563 DA |
13890 | /* Extended nexthop */ |
13891 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) || | |
13892 | CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
13893 | vty_out(vty, " Extended nexthop:"); | |
13894 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) | |
13895 | vty_out(vty, " advertised"); | |
13896 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) | |
13897 | vty_out(vty, " %sreceived", | |
13898 | CHECK_FLAG(p->cap, | |
13899 | PEER_CAP_ENHE_ADV) | |
13900 | ? "and " | |
13901 | : ""); | |
13902 | vty_out(vty, "\n"); | |
d62a17ae | 13903 | |
10711563 | 13904 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) { |
57f7feb6 | 13905 | vty_out(vty, |
10711563 DA |
13906 | " Address families by peer:\n "); |
13907 | for (safi = SAFI_UNICAST; | |
13908 | safi < SAFI_MAX; safi++) | |
13909 | if (CHECK_FLAG( | |
13910 | p->af_cap[AFI_IP] | |
13911 | [safi], | |
13912 | PEER_CAP_ENHE_AF_RCV)) | |
13913 | vty_out(vty, | |
13914 | " %s\n", | |
13915 | get_afi_safi_str( | |
13916 | AFI_IP, | |
13917 | safi, | |
13918 | false)); | |
d62a17ae | 13919 | } |
10711563 | 13920 | } |
d62a17ae | 13921 | |
10711563 DA |
13922 | /* Long-lived Graceful Restart */ |
13923 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV) || | |
13924 | CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) { | |
13925 | vty_out(vty, | |
13926 | " Long-lived Graceful Restart:"); | |
13927 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) | |
13928 | vty_out(vty, " advertised"); | |
13929 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) | |
13930 | vty_out(vty, " %sreceived", | |
13931 | CHECK_FLAG(p->cap, | |
13932 | PEER_CAP_LLGR_ADV) | |
13933 | ? "and " | |
13934 | : ""); | |
13935 | vty_out(vty, "\n"); | |
8606be87 | 13936 | |
10711563 | 13937 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) { |
57f7feb6 | 13938 | vty_out(vty, |
10711563 DA |
13939 | " Address families by peer:\n"); |
13940 | FOREACH_AFI_SAFI (afi, safi) | |
13941 | if (CHECK_FLAG( | |
13942 | p->af_cap[afi] | |
13943 | [safi], | |
13944 | PEER_CAP_LLGR_AF_RCV)) | |
13945 | vty_out(vty, | |
13946 | " %s\n", | |
13947 | get_afi_safi_str( | |
13948 | afi, | |
13949 | safi, | |
13950 | false)); | |
8606be87 | 13951 | } |
10711563 | 13952 | } |
8606be87 | 13953 | |
10711563 DA |
13954 | /* Route Refresh */ |
13955 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) || | |
13956 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_NEW_RCV) || | |
13957 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_OLD_RCV)) { | |
13958 | vty_out(vty, " Route refresh:"); | |
13959 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV)) | |
13960 | vty_out(vty, " advertised"); | |
13961 | if (CHECK_FLAG(p->cap, | |
13962 | PEER_CAP_REFRESH_NEW_RCV) || | |
13963 | CHECK_FLAG(p->cap, | |
13964 | PEER_CAP_REFRESH_OLD_RCV)) | |
13965 | vty_out(vty, " %sreceived(%s)", | |
13966 | CHECK_FLAG(p->cap, | |
13967 | PEER_CAP_REFRESH_ADV) | |
13968 | ? "and " | |
13969 | : "", | |
13970 | (CHECK_FLAG( | |
13971 | p->cap, | |
13972 | PEER_CAP_REFRESH_OLD_RCV) && | |
13973 | CHECK_FLAG( | |
13974 | p->cap, | |
13975 | PEER_CAP_REFRESH_NEW_RCV)) | |
13976 | ? "old & new" | |
13977 | : CHECK_FLAG( | |
13978 | p->cap, | |
13979 | PEER_CAP_REFRESH_OLD_RCV) | |
13980 | ? "old" | |
13981 | : "new"); | |
d62a17ae | 13982 | |
d77114b7 | 13983 | vty_out(vty, "\n"); |
10711563 | 13984 | } |
d62a17ae | 13985 | |
10711563 DA |
13986 | /* Enhanced Route Refresh */ |
13987 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) || | |
13988 | CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_RCV)) { | |
13989 | vty_out(vty, " Enhanced Route Refresh:"); | |
13990 | if (CHECK_FLAG(p->cap, | |
13991 | PEER_CAP_ENHANCED_RR_ADV)) | |
13992 | vty_out(vty, " advertised"); | |
13993 | if (CHECK_FLAG(p->cap, | |
13994 | PEER_CAP_ENHANCED_RR_RCV)) | |
13995 | vty_out(vty, " %sreceived", | |
13996 | CHECK_FLAG(p->cap, | |
13997 | PEER_CAP_REFRESH_ADV) | |
13998 | ? "and " | |
13999 | : ""); | |
14000 | vty_out(vty, "\n"); | |
14001 | } | |
14002 | ||
14003 | /* Multiprotocol Extensions */ | |
14004 | FOREACH_AFI_SAFI (afi, safi) | |
14005 | if (p->afc_adv[afi][safi] || | |
14006 | p->afc_recv[afi][safi]) { | |
14007 | vty_out(vty, " Address Family %s:", | |
14008 | get_afi_safi_str(afi, safi, | |
14009 | false)); | |
14010 | if (p->afc_adv[afi][safi]) | |
9af52ccf | 14011 | vty_out(vty, " advertised"); |
10711563 | 14012 | if (p->afc_recv[afi][safi]) |
9af52ccf | 14013 | vty_out(vty, " %sreceived", |
10711563 | 14014 | p->afc_adv[afi][safi] |
9af52ccf DA |
14015 | ? "and " |
14016 | : ""); | |
14017 | vty_out(vty, "\n"); | |
14018 | } | |
14019 | ||
10711563 DA |
14020 | /* Hostname capability */ |
14021 | vty_out(vty, " Hostname Capability:"); | |
d62a17ae | 14022 | |
10711563 DA |
14023 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { |
14024 | vty_out(vty, | |
14025 | " advertised (name: %s,domain name: %s)", | |
14026 | bgp->peer_self->hostname | |
14027 | ? bgp->peer_self->hostname | |
14028 | : "n/a", | |
14029 | bgp->peer_self->domainname | |
14030 | ? bgp->peer_self->domainname | |
14031 | : "n/a"); | |
14032 | } else { | |
14033 | vty_out(vty, " not advertised"); | |
14034 | } | |
d77114b7 | 14035 | |
10711563 DA |
14036 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
14037 | vty_out(vty, | |
14038 | " received (name: %s,domain name: %s)", | |
14039 | p->hostname ? p->hostname : "n/a", | |
14040 | p->domainname ? p->domainname : "n/a"); | |
14041 | } else { | |
14042 | vty_out(vty, " not received"); | |
d62a17ae | 14043 | } |
d62a17ae | 14044 | |
10711563 | 14045 | vty_out(vty, "\n"); |
d77114b7 | 14046 | |
10711563 DA |
14047 | /* Graceful Restart */ |
14048 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || | |
14049 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)) { | |
14050 | vty_out(vty, | |
14051 | " Graceful Restart Capability:"); | |
14052 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)) | |
14053 | vty_out(vty, " advertised"); | |
14054 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
14055 | vty_out(vty, " %sreceived", | |
14056 | CHECK_FLAG(p->cap, | |
14057 | PEER_CAP_RESTART_ADV) | |
14058 | ? "and " | |
14059 | : ""); | |
d77114b7 MK |
14060 | vty_out(vty, "\n"); |
14061 | ||
10711563 DA |
14062 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { |
14063 | int restart_af_count = 0; | |
d62a17ae | 14064 | |
10711563 DA |
14065 | vty_out(vty, |
14066 | " Remote Restart timer is %d seconds\n", | |
14067 | p->v_gr_restart); | |
14068 | vty_out(vty, | |
14069 | " Address families by peer:\n "); | |
d62a17ae | 14070 | |
10711563 DA |
14071 | FOREACH_AFI_SAFI (afi, safi) |
14072 | if (CHECK_FLAG( | |
14073 | p->af_cap[afi] | |
14074 | [safi], | |
14075 | PEER_CAP_RESTART_AF_RCV)) { | |
14076 | vty_out(vty, "%s%s(%s)", | |
14077 | restart_af_count | |
14078 | ? ", " | |
14079 | : "", | |
14080 | get_afi_safi_str( | |
14081 | afi, | |
14082 | safi, | |
14083 | false), | |
14084 | CHECK_FLAG( | |
14085 | p->af_cap | |
14086 | [afi] | |
14087 | [safi], | |
14088 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
14089 | ? "preserved" | |
14090 | : "not preserved"); | |
14091 | restart_af_count++; | |
14092 | } | |
14093 | if (!restart_af_count) | |
14094 | vty_out(vty, "none"); | |
14095 | vty_out(vty, "\n"); | |
14096 | } | |
17be83bf | 14097 | } /* Graceful Restart */ |
d62a17ae | 14098 | } |
14099 | } | |
14100 | ||
14101 | /* graceful restart information */ | |
10711563 DA |
14102 | json_object *json_grace = NULL; |
14103 | json_object *json_grace_send = NULL; | |
14104 | json_object *json_grace_recv = NULL; | |
14105 | int eor_send_af_count = 0; | |
14106 | int eor_receive_af_count = 0; | |
d62a17ae | 14107 | |
10711563 DA |
14108 | if (use_json) { |
14109 | json_grace = json_object_new_object(); | |
14110 | json_grace_send = json_object_new_object(); | |
14111 | json_grace_recv = json_object_new_object(); | |
14112 | ||
14113 | if ((peer_established(p)) && | |
14114 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
14115 | FOREACH_AFI_SAFI (afi, safi) { | |
14116 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
14117 | PEER_STATUS_EOR_SEND)) { | |
14118 | json_object_boolean_true_add( | |
14119 | json_grace_send, | |
14120 | get_afi_safi_str(afi, safi, | |
14121 | true)); | |
14122 | eor_send_af_count++; | |
d62a17ae | 14123 | } |
10711563 DA |
14124 | } |
14125 | FOREACH_AFI_SAFI (afi, safi) { | |
14126 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
14127 | PEER_STATUS_EOR_RECEIVED)) { | |
14128 | json_object_boolean_true_add( | |
14129 | json_grace_recv, | |
14130 | get_afi_safi_str(afi, safi, | |
14131 | true)); | |
14132 | eor_receive_af_count++; | |
d62a17ae | 14133 | } |
14134 | } | |
10711563 DA |
14135 | } |
14136 | json_object_object_add(json_grace, "endOfRibSend", | |
14137 | json_grace_send); | |
14138 | json_object_object_add(json_grace, "endOfRibRecv", | |
14139 | json_grace_recv); | |
d62a17ae | 14140 | |
d62a17ae | 14141 | |
10711563 DA |
14142 | if (p->t_gr_restart) |
14143 | json_object_int_add( | |
14144 | json_grace, "gracefulRestartTimerMsecs", | |
14145 | thread_timer_remain_second(p->t_gr_restart) * | |
14146 | 1000); | |
2986cac2 | 14147 | |
10711563 DA |
14148 | if (p->t_gr_stale) |
14149 | json_object_int_add( | |
14150 | json_grace, "gracefulStalepathTimerMsecs", | |
14151 | thread_timer_remain_second(p->t_gr_stale) * | |
14152 | 1000); | |
14153 | /* more gr info in new format */ | |
14154 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json_grace); | |
14155 | json_object_object_add(json_neigh, "gracefulRestartInfo", | |
14156 | json_grace); | |
14157 | } else { | |
14158 | vty_out(vty, " Graceful restart information:\n"); | |
14159 | if ((peer_established(p)) && | |
14160 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
14161 | ||
14162 | vty_out(vty, " End-of-RIB send: "); | |
14163 | FOREACH_AFI_SAFI (afi, safi) { | |
14164 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
14165 | PEER_STATUS_EOR_SEND)) { | |
14166 | vty_out(vty, "%s%s", | |
14167 | eor_send_af_count ? ", " : "", | |
14168 | get_afi_safi_str(afi, safi, | |
14169 | false)); | |
14170 | eor_send_af_count++; | |
d62a17ae | 14171 | } |
10711563 DA |
14172 | } |
14173 | vty_out(vty, "\n"); | |
14174 | vty_out(vty, " End-of-RIB received: "); | |
14175 | FOREACH_AFI_SAFI (afi, safi) { | |
14176 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
14177 | PEER_STATUS_EOR_RECEIVED)) { | |
14178 | vty_out(vty, "%s%s", | |
14179 | eor_receive_af_count ? ", " | |
14180 | : "", | |
14181 | get_afi_safi_str(afi, safi, | |
14182 | false)); | |
14183 | eor_receive_af_count++; | |
d62a17ae | 14184 | } |
d62a17ae | 14185 | } |
10711563 DA |
14186 | vty_out(vty, "\n"); |
14187 | } | |
d62a17ae | 14188 | |
10711563 DA |
14189 | if (p->t_gr_restart) |
14190 | vty_out(vty, | |
14191 | " The remaining time of restart timer is %ld\n", | |
14192 | thread_timer_remain_second(p->t_gr_restart)); | |
d62a17ae | 14193 | |
10711563 DA |
14194 | if (p->t_gr_stale) |
14195 | vty_out(vty, | |
14196 | " The remaining time of stalepath timer is %ld\n", | |
14197 | thread_timer_remain_second(p->t_gr_stale)); | |
2986cac2 | 14198 | |
10711563 DA |
14199 | /* more gr info in new format */ |
14200 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
14201 | } | |
2986cac2 | 14202 | |
d62a17ae | 14203 | if (use_json) { |
14204 | json_object *json_stat = NULL; | |
14205 | json_stat = json_object_new_object(); | |
14206 | /* Packet counts. */ | |
43aa5965 QY |
14207 | |
14208 | atomic_size_t outq_count, inq_count; | |
14209 | outq_count = atomic_load_explicit(&p->obuf->count, | |
14210 | memory_order_relaxed); | |
14211 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
14212 | memory_order_relaxed); | |
14213 | ||
14214 | json_object_int_add(json_stat, "depthInq", | |
14215 | (unsigned long)inq_count); | |
d62a17ae | 14216 | json_object_int_add(json_stat, "depthOutq", |
43aa5965 | 14217 | (unsigned long)outq_count); |
0112e9e0 QY |
14218 | json_object_int_add(json_stat, "opensSent", |
14219 | atomic_load_explicit(&p->open_out, | |
14220 | memory_order_relaxed)); | |
14221 | json_object_int_add(json_stat, "opensRecv", | |
14222 | atomic_load_explicit(&p->open_in, | |
14223 | memory_order_relaxed)); | |
d62a17ae | 14224 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
14225 | atomic_load_explicit(&p->notify_out, |
14226 | memory_order_relaxed)); | |
d62a17ae | 14227 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
14228 | atomic_load_explicit(&p->notify_in, |
14229 | memory_order_relaxed)); | |
14230 | json_object_int_add(json_stat, "updatesSent", | |
14231 | atomic_load_explicit(&p->update_out, | |
14232 | memory_order_relaxed)); | |
14233 | json_object_int_add(json_stat, "updatesRecv", | |
14234 | atomic_load_explicit(&p->update_in, | |
14235 | memory_order_relaxed)); | |
d62a17ae | 14236 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
14237 | atomic_load_explicit(&p->keepalive_out, |
14238 | memory_order_relaxed)); | |
d62a17ae | 14239 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
14240 | atomic_load_explicit(&p->keepalive_in, |
14241 | memory_order_relaxed)); | |
d62a17ae | 14242 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
14243 | atomic_load_explicit(&p->refresh_out, |
14244 | memory_order_relaxed)); | |
d62a17ae | 14245 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
14246 | atomic_load_explicit(&p->refresh_in, |
14247 | memory_order_relaxed)); | |
d62a17ae | 14248 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
14249 | atomic_load_explicit(&p->dynamic_cap_out, |
14250 | memory_order_relaxed)); | |
d62a17ae | 14251 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
14252 | atomic_load_explicit(&p->dynamic_cap_in, |
14253 | memory_order_relaxed)); | |
14254 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
14255 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 14256 | json_object_object_add(json_neigh, "messageStats", json_stat); |
14257 | } else { | |
cb93e0a2 IS |
14258 | atomic_size_t outq_count, inq_count, open_out, open_in, |
14259 | notify_out, notify_in, update_out, update_in, | |
14260 | keepalive_out, keepalive_in, refresh_out, refresh_in, | |
14261 | dynamic_cap_out, dynamic_cap_in; | |
43aa5965 QY |
14262 | outq_count = atomic_load_explicit(&p->obuf->count, |
14263 | memory_order_relaxed); | |
14264 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
14265 | memory_order_relaxed); | |
cb93e0a2 IS |
14266 | open_out = atomic_load_explicit(&p->open_out, |
14267 | memory_order_relaxed); | |
14268 | open_in = | |
14269 | atomic_load_explicit(&p->open_in, memory_order_relaxed); | |
14270 | notify_out = atomic_load_explicit(&p->notify_out, | |
14271 | memory_order_relaxed); | |
14272 | notify_in = atomic_load_explicit(&p->notify_in, | |
14273 | memory_order_relaxed); | |
14274 | update_out = atomic_load_explicit(&p->update_out, | |
14275 | memory_order_relaxed); | |
14276 | update_in = atomic_load_explicit(&p->update_in, | |
14277 | memory_order_relaxed); | |
14278 | keepalive_out = atomic_load_explicit(&p->keepalive_out, | |
14279 | memory_order_relaxed); | |
14280 | keepalive_in = atomic_load_explicit(&p->keepalive_in, | |
14281 | memory_order_relaxed); | |
14282 | refresh_out = atomic_load_explicit(&p->refresh_out, | |
14283 | memory_order_relaxed); | |
14284 | refresh_in = atomic_load_explicit(&p->refresh_in, | |
14285 | memory_order_relaxed); | |
14286 | dynamic_cap_out = atomic_load_explicit(&p->dynamic_cap_out, | |
14287 | memory_order_relaxed); | |
14288 | dynamic_cap_in = atomic_load_explicit(&p->dynamic_cap_in, | |
14289 | memory_order_relaxed); | |
43aa5965 | 14290 | |
d62a17ae | 14291 | /* Packet counts. */ |
14292 | vty_out(vty, " Message statistics:\n"); | |
43aa5965 QY |
14293 | vty_out(vty, " Inq depth is %zu\n", inq_count); |
14294 | vty_out(vty, " Outq depth is %zu\n", outq_count); | |
d62a17ae | 14295 | vty_out(vty, " Sent Rcvd\n"); |
cb93e0a2 IS |
14296 | vty_out(vty, " Opens: %10zu %10zu\n", open_out, |
14297 | open_in); | |
14298 | vty_out(vty, " Notifications: %10zu %10zu\n", notify_out, | |
14299 | notify_in); | |
14300 | vty_out(vty, " Updates: %10zu %10zu\n", update_out, | |
14301 | update_in); | |
14302 | vty_out(vty, " Keepalives: %10zu %10zu\n", keepalive_out, | |
14303 | keepalive_in); | |
14304 | vty_out(vty, " Route Refresh: %10zu %10zu\n", refresh_out, | |
14305 | refresh_in); | |
14306 | vty_out(vty, " Capability: %10zu %10zu\n", | |
14307 | dynamic_cap_out, dynamic_cap_in); | |
14308 | vty_out(vty, " Total: %10u %10u\n", | |
14309 | (uint32_t)PEER_TOTAL_TX(p), (uint32_t)PEER_TOTAL_RX(p)); | |
d62a17ae | 14310 | } |
14311 | ||
14312 | if (use_json) { | |
14313 | /* advertisement-interval */ | |
14314 | json_object_int_add(json_neigh, | |
14315 | "minBtwnAdvertisementRunsTimerMsecs", | |
14316 | p->v_routeadv * 1000); | |
14317 | ||
14318 | /* Update-source. */ | |
14319 | if (p->update_if || p->update_source) { | |
14320 | if (p->update_if) | |
14321 | json_object_string_add(json_neigh, | |
14322 | "updateSource", | |
14323 | p->update_if); | |
14324 | else if (p->update_source) | |
47e12884 DA |
14325 | json_object_string_addf(json_neigh, |
14326 | "updateSource", "%pSU", | |
14327 | p->update_source); | |
d62a17ae | 14328 | } |
14329 | } else { | |
14330 | /* advertisement-interval */ | |
14331 | vty_out(vty, | |
14332 | " Minimum time between advertisement runs is %d seconds\n", | |
14333 | p->v_routeadv); | |
14334 | ||
14335 | /* Update-source. */ | |
14336 | if (p->update_if || p->update_source) { | |
14337 | vty_out(vty, " Update source is "); | |
14338 | if (p->update_if) | |
14339 | vty_out(vty, "%s", p->update_if); | |
14340 | else if (p->update_source) | |
47e12884 | 14341 | vty_out(vty, "%pSU", p->update_source); |
d62a17ae | 14342 | vty_out(vty, "\n"); |
14343 | } | |
14344 | ||
14345 | vty_out(vty, "\n"); | |
14346 | } | |
14347 | ||
14348 | /* Address Family Information */ | |
14349 | json_object *json_hold = NULL; | |
14350 | ||
14351 | if (use_json) | |
14352 | json_hold = json_object_new_object(); | |
14353 | ||
05c7a1cc QY |
14354 | FOREACH_AFI_SAFI (afi, safi) |
14355 | if (p->afc[afi][safi]) | |
14356 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
14357 | json_hold); | |
d62a17ae | 14358 | |
14359 | if (use_json) { | |
14360 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
14361 | json_hold); | |
14362 | json_object_int_add(json_neigh, "connectionsEstablished", | |
14363 | p->established); | |
14364 | json_object_int_add(json_neigh, "connectionsDropped", | |
14365 | p->dropped); | |
14366 | } else | |
14367 | vty_out(vty, " Connections established %d; dropped %d\n", | |
14368 | p->established, p->dropped); | |
14369 | ||
14370 | if (!p->last_reset) { | |
14371 | if (use_json) | |
14372 | json_object_string_add(json_neigh, "lastReset", | |
14373 | "never"); | |
14374 | else | |
14375 | vty_out(vty, " Last reset never\n"); | |
14376 | } else { | |
14377 | if (use_json) { | |
14378 | time_t uptime; | |
a2700b50 | 14379 | struct tm tm; |
d62a17ae | 14380 | |
083ec940 | 14381 | uptime = monotime(NULL); |
d62a17ae | 14382 | uptime -= p->resettime; |
a2700b50 MS |
14383 | gmtime_r(&uptime, &tm); |
14384 | ||
d62a17ae | 14385 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
14386 | (tm.tm_sec * 1000) |
14387 | + (tm.tm_min * 60000) | |
14388 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 14389 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 14390 | } else { |
14391 | vty_out(vty, " Last reset %s, ", | |
14392 | peer_uptime(p->resettime, timebuf, | |
14393 | BGP_UPTIME_LEN, 0, NULL)); | |
14394 | ||
3577f1c5 | 14395 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 14396 | if (p->last_reset_cause_size) { |
14397 | msg = p->last_reset_cause; | |
14398 | vty_out(vty, | |
14399 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
14400 | for (i = 1; i <= p->last_reset_cause_size; | |
14401 | i++) { | |
14402 | vty_out(vty, "%02X", *msg++); | |
14403 | ||
14404 | if (i != p->last_reset_cause_size) { | |
14405 | if (i % 16 == 0) { | |
14406 | vty_out(vty, "\n "); | |
14407 | } else if (i % 4 == 0) { | |
14408 | vty_out(vty, " "); | |
14409 | } | |
14410 | } | |
14411 | } | |
14412 | vty_out(vty, "\n"); | |
14413 | } | |
14414 | } | |
14415 | } | |
14416 | ||
14417 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
14418 | if (use_json) | |
14419 | json_object_boolean_true_add(json_neigh, | |
14420 | "prefixesConfigExceedMax"); | |
14421 | else | |
14422 | vty_out(vty, | |
14423 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
14424 | ||
14425 | if (p->t_pmax_restart) { | |
14426 | if (use_json) { | |
14427 | json_object_boolean_true_add( | |
14428 | json_neigh, "reducePrefixNumFrom"); | |
14429 | json_object_int_add(json_neigh, | |
14430 | "restartInTimerMsec", | |
14431 | thread_timer_remain_second( | |
14432 | p->t_pmax_restart) | |
14433 | * 1000); | |
14434 | } else | |
14435 | vty_out(vty, | |
14436 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
14437 | p->host, thread_timer_remain_second( |
14438 | p->t_pmax_restart)); | |
d62a17ae | 14439 | } else { |
14440 | if (use_json) | |
14441 | json_object_boolean_true_add( | |
14442 | json_neigh, | |
14443 | "reducePrefixNumAndClearIpBgp"); | |
14444 | else | |
14445 | vty_out(vty, | |
14446 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
14447 | p->host); | |
14448 | } | |
14449 | } | |
14450 | ||
14451 | /* EBGP Multihop and GTSM */ | |
14452 | if (p->sort != BGP_PEER_IBGP) { | |
14453 | if (use_json) { | |
e2521429 | 14454 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 14455 | json_object_int_add(json_neigh, |
14456 | "externalBgpNbrMaxHopsAway", | |
14457 | p->gtsm_hops); | |
be8d1733 | 14458 | else |
d62a17ae | 14459 | json_object_int_add(json_neigh, |
14460 | "externalBgpNbrMaxHopsAway", | |
14461 | p->ttl); | |
14462 | } else { | |
e2521429 | 14463 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 14464 | vty_out(vty, |
14465 | " External BGP neighbor may be up to %d hops away.\n", | |
14466 | p->gtsm_hops); | |
be8d1733 | 14467 | else |
d62a17ae | 14468 | vty_out(vty, |
14469 | " External BGP neighbor may be up to %d hops away.\n", | |
14470 | p->ttl); | |
14471 | } | |
14472 | } else { | |
be8d1733 DA |
14473 | if (use_json) { |
14474 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) | |
d62a17ae | 14475 | json_object_int_add(json_neigh, |
14476 | "internalBgpNbrMaxHopsAway", | |
14477 | p->gtsm_hops); | |
14478 | else | |
be8d1733 DA |
14479 | json_object_int_add(json_neigh, |
14480 | "internalBgpNbrMaxHopsAway", | |
14481 | p->ttl); | |
14482 | } else { | |
14483 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) | |
d62a17ae | 14484 | vty_out(vty, |
14485 | " Internal BGP neighbor may be up to %d hops away.\n", | |
14486 | p->gtsm_hops); | |
be8d1733 DA |
14487 | else |
14488 | vty_out(vty, | |
14489 | " Internal BGP neighbor may be up to %d hops away.\n", | |
14490 | p->ttl); | |
d62a17ae | 14491 | } |
14492 | } | |
14493 | ||
14494 | /* Local address. */ | |
14495 | if (p->su_local) { | |
14496 | if (use_json) { | |
47e12884 DA |
14497 | json_object_string_addf(json_neigh, "hostLocal", "%pSU", |
14498 | p->su_local); | |
d62a17ae | 14499 | json_object_int_add(json_neigh, "portLocal", |
14500 | ntohs(p->su_local->sin.sin_port)); | |
14501 | } else | |
47e12884 DA |
14502 | vty_out(vty, "Local host: %pSU, Local port: %d\n", |
14503 | p->su_local, ntohs(p->su_local->sin.sin_port)); | |
1e592331 DS |
14504 | } else { |
14505 | if (use_json) { | |
14506 | json_object_string_add(json_neigh, "hostLocal", | |
14507 | "Unknown"); | |
14508 | json_object_int_add(json_neigh, "portLocal", -1); | |
14509 | } | |
d62a17ae | 14510 | } |
14511 | ||
14512 | /* Remote address. */ | |
14513 | if (p->su_remote) { | |
14514 | if (use_json) { | |
47e12884 DA |
14515 | json_object_string_addf(json_neigh, "hostForeign", |
14516 | "%pSU", p->su_remote); | |
d62a17ae | 14517 | json_object_int_add(json_neigh, "portForeign", |
14518 | ntohs(p->su_remote->sin.sin_port)); | |
14519 | } else | |
47e12884 DA |
14520 | vty_out(vty, "Foreign host: %pSU, Foreign port: %d\n", |
14521 | p->su_remote, | |
d62a17ae | 14522 | ntohs(p->su_remote->sin.sin_port)); |
1e592331 DS |
14523 | } else { |
14524 | if (use_json) { | |
14525 | json_object_string_add(json_neigh, "hostForeign", | |
14526 | "Unknown"); | |
14527 | json_object_int_add(json_neigh, "portForeign", -1); | |
14528 | } | |
d62a17ae | 14529 | } |
14530 | ||
14531 | /* Nexthop display. */ | |
14532 | if (p->su_local) { | |
14533 | if (use_json) { | |
c949c771 DA |
14534 | json_object_string_addf(json_neigh, "nexthop", "%pI4", |
14535 | &p->nexthop.v4); | |
14536 | json_object_string_addf(json_neigh, "nexthopGlobal", | |
14537 | "%pI6", &p->nexthop.v6_global); | |
14538 | json_object_string_addf(json_neigh, "nexthopLocal", | |
14539 | "%pI6", &p->nexthop.v6_local); | |
d62a17ae | 14540 | if (p->shared_network) |
14541 | json_object_string_add(json_neigh, | |
14542 | "bgpConnection", | |
14543 | "sharedNetwork"); | |
14544 | else | |
14545 | json_object_string_add(json_neigh, | |
14546 | "bgpConnection", | |
14547 | "nonSharedNetwork"); | |
14548 | } else { | |
14549 | vty_out(vty, "Nexthop: %s\n", | |
14550 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
14551 | sizeof(buf1))); | |
14552 | vty_out(vty, "Nexthop global: %s\n", | |
14553 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
14554 | sizeof(buf1))); | |
14555 | vty_out(vty, "Nexthop local: %s\n", | |
14556 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
14557 | sizeof(buf1))); | |
14558 | vty_out(vty, "BGP connection: %s\n", | |
14559 | p->shared_network ? "shared network" | |
14560 | : "non shared network"); | |
14561 | } | |
14562 | } | |
14563 | ||
14564 | /* Timer information. */ | |
14565 | if (use_json) { | |
14566 | json_object_int_add(json_neigh, "connectRetryTimer", | |
14567 | p->v_connect); | |
feb17238 | 14568 | if (peer_established(p) && p->rtt) |
d62a17ae | 14569 | json_object_int_add(json_neigh, "estimatedRttInMsecs", |
14570 | p->rtt); | |
14571 | if (p->t_start) | |
14572 | json_object_int_add( | |
14573 | json_neigh, "nextStartTimerDueInMsecs", | |
14574 | thread_timer_remain_second(p->t_start) * 1000); | |
14575 | if (p->t_connect) | |
14576 | json_object_int_add( | |
14577 | json_neigh, "nextConnectTimerDueInMsecs", | |
14578 | thread_timer_remain_second(p->t_connect) | |
14579 | * 1000); | |
14580 | if (p->t_routeadv) { | |
14581 | json_object_int_add(json_neigh, "mraiInterval", | |
14582 | p->v_routeadv); | |
14583 | json_object_int_add( | |
14584 | json_neigh, "mraiTimerExpireInMsecs", | |
14585 | thread_timer_remain_second(p->t_routeadv) | |
14586 | * 1000); | |
14587 | } | |
14588 | if (p->password) | |
14589 | json_object_int_add(json_neigh, "authenticationEnabled", | |
14590 | 1); | |
14591 | ||
14592 | if (p->t_read) | |
14593 | json_object_string_add(json_neigh, "readThread", "on"); | |
14594 | else | |
14595 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
14596 | |
14597 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 14598 | json_object_string_add(json_neigh, "writeThread", "on"); |
14599 | else | |
14600 | json_object_string_add(json_neigh, "writeThread", | |
14601 | "off"); | |
14602 | } else { | |
14603 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
14604 | p->v_connect); | |
feb17238 | 14605 | if (peer_established(p) && p->rtt) |
d62a17ae | 14606 | vty_out(vty, "Estimated round trip time: %d ms\n", |
14607 | p->rtt); | |
14608 | if (p->t_start) | |
14609 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
14610 | thread_timer_remain_second(p->t_start)); | |
14611 | if (p->t_connect) | |
14612 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
14613 | thread_timer_remain_second(p->t_connect)); | |
14614 | if (p->t_routeadv) | |
14615 | vty_out(vty, | |
14616 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
14617 | p->v_routeadv, | |
14618 | thread_timer_remain_second(p->t_routeadv)); | |
14619 | if (p->password) | |
14620 | vty_out(vty, "Peer Authentication Enabled\n"); | |
14621 | ||
cac9e917 | 14622 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
14623 | p->t_read ? "on" : "off", |
14624 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
14625 | ? "on" | |
cac9e917 | 14626 | : "off", p->fd); |
d62a17ae | 14627 | } |
14628 | ||
14629 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
14630 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
14631 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
14632 | ||
14633 | if (!use_json) | |
14634 | vty_out(vty, "\n"); | |
14635 | ||
14636 | /* BFD information. */ | |
21bfce98 RZ |
14637 | if (p->bfd_config) |
14638 | bgp_bfd_show_info(vty, p, json_neigh); | |
d62a17ae | 14639 | |
14640 | if (use_json) { | |
14641 | if (p->conf_if) /* Configured interface name. */ | |
14642 | json_object_object_add(json, p->conf_if, json_neigh); | |
14643 | else /* Configured IP address. */ | |
14644 | json_object_object_add(json, p->host, json_neigh); | |
14645 | } | |
14646 | } | |
14647 | ||
36235319 QY |
14648 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
14649 | enum show_type type, | |
14650 | union sockunion *su, | |
14651 | const char *conf_if, afi_t afi, | |
74a630b6 | 14652 | bool use_json) |
2986cac2 | 14653 | { |
14654 | struct listnode *node, *nnode; | |
14655 | struct peer *peer; | |
14656 | int find = 0; | |
14657 | safi_t safi = SAFI_UNICAST; | |
74a630b6 | 14658 | json_object *json = NULL; |
2986cac2 | 14659 | json_object *json_neighbor = NULL; |
14660 | ||
74a630b6 NT |
14661 | if (use_json) { |
14662 | json = json_object_new_object(); | |
14663 | json_neighbor = json_object_new_object(); | |
14664 | } | |
14665 | ||
2986cac2 | 14666 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
14667 | ||
14668 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14669 | continue; | |
14670 | ||
14671 | if ((peer->afc[afi][safi]) == 0) | |
14672 | continue; | |
14673 | ||
2ba1fe69 | 14674 | if (type == show_all) { |
2986cac2 | 14675 | bgp_show_peer_gr_status(vty, peer, use_json, |
13909c4f | 14676 | json_neighbor); |
2986cac2 | 14677 | |
74a630b6 | 14678 | if (use_json) { |
13909c4f DS |
14679 | json_object_object_add(json, peer->host, |
14680 | json_neighbor); | |
74a630b6 NT |
14681 | json_neighbor = NULL; |
14682 | } | |
2986cac2 | 14683 | |
2ba1fe69 | 14684 | } else if (type == show_peer) { |
2986cac2 | 14685 | if (conf_if) { |
14686 | if ((peer->conf_if | |
13909c4f DS |
14687 | && !strcmp(peer->conf_if, conf_if)) |
14688 | || (peer->hostname | |
2986cac2 | 14689 | && !strcmp(peer->hostname, conf_if))) { |
14690 | find = 1; | |
13909c4f DS |
14691 | bgp_show_peer_gr_status(vty, peer, |
14692 | use_json, | |
14693 | json_neighbor); | |
2986cac2 | 14694 | } |
14695 | } else { | |
14696 | if (sockunion_same(&peer->su, su)) { | |
14697 | find = 1; | |
13909c4f DS |
14698 | bgp_show_peer_gr_status(vty, peer, |
14699 | use_json, | |
14700 | json_neighbor); | |
2986cac2 | 14701 | } |
14702 | } | |
13909c4f DS |
14703 | if (use_json && find) |
14704 | json_object_object_add(json, peer->host, | |
14705 | json_neighbor); | |
2986cac2 | 14706 | } |
14707 | ||
74a630b6 NT |
14708 | if (find) { |
14709 | json_neighbor = NULL; | |
2986cac2 | 14710 | break; |
74a630b6 | 14711 | } |
2986cac2 | 14712 | } |
14713 | ||
14714 | if (type == show_peer && !find) { | |
14715 | if (use_json) | |
13909c4f | 14716 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 14717 | else |
14718 | vty_out(vty, "%% No such neighbor\n"); | |
14719 | } | |
14720 | if (use_json) { | |
74a630b6 NT |
14721 | if (json_neighbor) |
14722 | json_object_free(json_neighbor); | |
75eeda93 | 14723 | vty_json(vty, json); |
2986cac2 | 14724 | } else { |
14725 | vty_out(vty, "\n"); | |
14726 | } | |
14727 | ||
14728 | return CMD_SUCCESS; | |
14729 | } | |
14730 | ||
d62a17ae | 14731 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
14732 | enum show_type type, union sockunion *su, | |
9f049418 | 14733 | const char *conf_if, bool use_json, |
d62a17ae | 14734 | json_object *json) |
14735 | { | |
14736 | struct listnode *node, *nnode; | |
14737 | struct peer *peer; | |
14738 | int find = 0; | |
9f049418 | 14739 | bool nbr_output = false; |
d1927ebe AS |
14740 | afi_t afi = AFI_MAX; |
14741 | safi_t safi = SAFI_MAX; | |
14742 | ||
14743 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
14744 | afi = AFI_IP; | |
14745 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
14746 | afi = AFI_IP6; | |
14747 | } | |
d62a17ae | 14748 | |
14749 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14750 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14751 | continue; | |
14752 | ||
14753 | switch (type) { | |
14754 | case show_all: | |
14755 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 14756 | nbr_output = true; |
d62a17ae | 14757 | break; |
14758 | case show_peer: | |
14759 | if (conf_if) { | |
14760 | if ((peer->conf_if | |
14761 | && !strcmp(peer->conf_if, conf_if)) | |
14762 | || (peer->hostname | |
14763 | && !strcmp(peer->hostname, conf_if))) { | |
14764 | find = 1; | |
14765 | bgp_show_peer(vty, peer, use_json, | |
14766 | json); | |
14767 | } | |
14768 | } else { | |
14769 | if (sockunion_same(&peer->su, su)) { | |
14770 | find = 1; | |
14771 | bgp_show_peer(vty, peer, use_json, | |
14772 | json); | |
14773 | } | |
14774 | } | |
14775 | break; | |
d1927ebe AS |
14776 | case show_ipv4_peer: |
14777 | case show_ipv6_peer: | |
14778 | FOREACH_SAFI (safi) { | |
14779 | if (peer->afc[afi][safi]) { | |
14780 | if (conf_if) { | |
14781 | if ((peer->conf_if | |
14782 | && !strcmp(peer->conf_if, conf_if)) | |
14783 | || (peer->hostname | |
14784 | && !strcmp(peer->hostname, conf_if))) { | |
14785 | find = 1; | |
14786 | bgp_show_peer(vty, peer, use_json, | |
14787 | json); | |
14788 | break; | |
14789 | } | |
14790 | } else { | |
14791 | if (sockunion_same(&peer->su, su)) { | |
14792 | find = 1; | |
14793 | bgp_show_peer(vty, peer, use_json, | |
14794 | json); | |
14795 | break; | |
14796 | } | |
14797 | } | |
14798 | } | |
14799 | } | |
14800 | break; | |
14801 | case show_ipv4_all: | |
14802 | case show_ipv6_all: | |
14803 | FOREACH_SAFI (safi) { | |
14804 | if (peer->afc[afi][safi]) { | |
14805 | bgp_show_peer(vty, peer, use_json, json); | |
14806 | nbr_output = true; | |
14807 | break; | |
14808 | } | |
14809 | } | |
14810 | break; | |
d62a17ae | 14811 | } |
14812 | } | |
14813 | ||
d1927ebe AS |
14814 | if ((type == show_peer || type == show_ipv4_peer || |
14815 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 14816 | if (use_json) |
14817 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
14818 | else | |
88b7d255 | 14819 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 14820 | } |
14821 | ||
d1927ebe AS |
14822 | if (type != show_peer && type != show_ipv4_peer && |
14823 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 14824 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 14825 | |
d62a17ae | 14826 | if (use_json) { |
996c9314 LB |
14827 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
14828 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 14829 | } else { |
14830 | vty_out(vty, "\n"); | |
14831 | } | |
14832 | ||
14833 | return CMD_SUCCESS; | |
14834 | } | |
14835 | ||
36235319 QY |
14836 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
14837 | enum show_type type, | |
14838 | const char *ip_str, | |
14839 | afi_t afi, bool use_json) | |
2986cac2 | 14840 | { |
14841 | ||
14842 | int ret; | |
14843 | struct bgp *bgp; | |
14844 | union sockunion su; | |
2986cac2 | 14845 | |
14846 | bgp = bgp_get_default(); | |
14847 | ||
13909c4f DS |
14848 | if (!bgp) |
14849 | return; | |
2986cac2 | 14850 | |
13909c4f DS |
14851 | if (!use_json) |
14852 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json, | |
14853 | NULL); | |
2986cac2 | 14854 | |
13909c4f DS |
14855 | if (ip_str) { |
14856 | ret = str2sockunion(ip_str, &su); | |
14857 | if (ret < 0) | |
13909c4f | 14858 | bgp_show_neighbor_graceful_restart( |
74a630b6 NT |
14859 | vty, bgp, type, NULL, ip_str, afi, use_json); |
14860 | else | |
14861 | bgp_show_neighbor_graceful_restart(vty, bgp, type, &su, | |
14862 | NULL, afi, use_json); | |
13909c4f DS |
14863 | } else |
14864 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
74a630b6 | 14865 | afi, use_json); |
2986cac2 | 14866 | } |
14867 | ||
d62a17ae | 14868 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
14869 | enum show_type type, |
14870 | const char *ip_str, | |
9f049418 | 14871 | bool use_json) |
d62a17ae | 14872 | { |
0291c246 MK |
14873 | struct listnode *node, *nnode; |
14874 | struct bgp *bgp; | |
71aedaa3 | 14875 | union sockunion su; |
0291c246 | 14876 | json_object *json = NULL; |
71aedaa3 | 14877 | int ret, is_first = 1; |
9f049418 | 14878 | bool nbr_output = false; |
d62a17ae | 14879 | |
14880 | if (use_json) | |
14881 | vty_out(vty, "{\n"); | |
14882 | ||
14883 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 14884 | nbr_output = true; |
d62a17ae | 14885 | if (use_json) { |
14886 | if (!(json = json_object_new_object())) { | |
af4c2728 | 14887 | flog_err( |
e50f7cfd | 14888 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 14889 | "Unable to allocate memory for JSON object"); |
14890 | vty_out(vty, | |
14891 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
14892 | return; | |
14893 | } | |
14894 | ||
14895 | json_object_int_add(json, "vrfId", | |
14896 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
14897 | ? -1 |
14898 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 14899 | json_object_string_add( |
14900 | json, "vrfName", | |
14901 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14902 | ? VRF_DEFAULT_NAME |
d62a17ae | 14903 | : bgp->name); |
14904 | ||
14905 | if (!is_first) | |
14906 | vty_out(vty, ",\n"); | |
14907 | else | |
14908 | is_first = 0; | |
14909 | ||
14910 | vty_out(vty, "\"%s\":", | |
14911 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14912 | ? VRF_DEFAULT_NAME |
d62a17ae | 14913 | : bgp->name); |
14914 | } else { | |
14915 | vty_out(vty, "\nInstance %s:\n", | |
14916 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14917 | ? VRF_DEFAULT_NAME |
d62a17ae | 14918 | : bgp->name); |
14919 | } | |
71aedaa3 | 14920 | |
d1927ebe AS |
14921 | if (type == show_peer || type == show_ipv4_peer || |
14922 | type == show_ipv6_peer) { | |
71aedaa3 DS |
14923 | ret = str2sockunion(ip_str, &su); |
14924 | if (ret < 0) | |
14925 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14926 | use_json, json); | |
14927 | else | |
14928 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14929 | use_json, json); | |
14930 | } else { | |
d1927ebe | 14931 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
14932 | use_json, json); |
14933 | } | |
b77004d6 | 14934 | json_object_free(json); |
121067e9 | 14935 | json = NULL; |
d62a17ae | 14936 | } |
14937 | ||
3e78a6ce | 14938 | if (use_json) |
d62a17ae | 14939 | vty_out(vty, "}\n"); |
9f049418 DS |
14940 | else if (!nbr_output) |
14941 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 14942 | } |
14943 | ||
14944 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
14945 | enum show_type type, const char *ip_str, | |
9f049418 | 14946 | bool use_json) |
d62a17ae | 14947 | { |
14948 | int ret; | |
14949 | struct bgp *bgp; | |
14950 | union sockunion su; | |
14951 | json_object *json = NULL; | |
14952 | ||
14953 | if (name) { | |
14954 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
14955 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
14956 | use_json); | |
d62a17ae | 14957 | return CMD_SUCCESS; |
14958 | } else { | |
14959 | bgp = bgp_lookup_by_name(name); | |
14960 | if (!bgp) { | |
14961 | if (use_json) { | |
14962 | json = json_object_new_object(); | |
75eeda93 | 14963 | vty_json(vty, json); |
d62a17ae | 14964 | } else |
14965 | vty_out(vty, | |
9f049418 | 14966 | "%% BGP instance not found\n"); |
d62a17ae | 14967 | |
14968 | return CMD_WARNING; | |
14969 | } | |
14970 | } | |
14971 | } else { | |
14972 | bgp = bgp_get_default(); | |
14973 | } | |
14974 | ||
14975 | if (bgp) { | |
14976 | json = json_object_new_object(); | |
14977 | if (ip_str) { | |
14978 | ret = str2sockunion(ip_str, &su); | |
14979 | if (ret < 0) | |
14980 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14981 | use_json, json); | |
14982 | else | |
14983 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14984 | use_json, json); | |
14985 | } else { | |
14986 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
14987 | json); | |
14988 | } | |
14989 | json_object_free(json); | |
ca61fd25 DS |
14990 | } else { |
14991 | if (use_json) | |
14992 | vty_out(vty, "{}\n"); | |
14993 | else | |
14994 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 14995 | } |
14996 | ||
14997 | return CMD_SUCCESS; | |
4fb25c53 DW |
14998 | } |
14999 | ||
2986cac2 | 15000 | |
15001 | ||
15002 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
dcab9012 | 15003 | DEFUN (show_ip_bgp_neighbors_graceful_restart, |
2986cac2 | 15004 | show_ip_bgp_neighbors_graceful_restart_cmd, |
15005 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
15006 | SHOW_STR | |
15007 | BGP_STR | |
15008 | IP_STR | |
15009 | IPV6_STR | |
15010 | NEIGHBOR_STR | |
15011 | "Neighbor to display information about\n" | |
15012 | "Neighbor to display information about\n" | |
15013 | "Neighbor on BGP configured interface\n" | |
15014 | GR_SHOW | |
15015 | JSON_STR) | |
15016 | { | |
15017 | char *sh_arg = NULL; | |
15018 | enum show_type sh_type; | |
15019 | int idx = 0; | |
15020 | afi_t afi = AFI_MAX; | |
2986cac2 | 15021 | bool uj = use_json(argc, argv); |
15022 | ||
36235319 | 15023 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 15024 | afi = AFI_MAX; |
15025 | ||
15026 | idx++; | |
15027 | ||
15028 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
15029 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
15030 | || argv_find(argv, argc, "WORD", &idx)) { | |
15031 | sh_type = show_peer; | |
15032 | sh_arg = argv[idx]->arg; | |
15033 | } else | |
15034 | sh_type = show_all; | |
15035 | ||
15036 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
15037 | return CMD_SUCCESS; | |
15038 | ||
15039 | ||
36235319 QY |
15040 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
15041 | afi, uj); | |
2986cac2 | 15042 | } |
15043 | ||
716b2d8a | 15044 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 15045 | DEFUN (show_ip_bgp_neighbors, |
15046 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 15047 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 15048 | SHOW_STR |
15049 | IP_STR | |
15050 | BGP_STR | |
f2a8972b | 15051 | BGP_INSTANCE_HELP_STR |
00e6edb9 DA |
15052 | BGP_AF_STR |
15053 | BGP_AF_STR | |
718e3744 | 15054 | "Detailed information on TCP and BGP neighbor connections\n" |
15055 | "Neighbor to display information about\n" | |
a80beece | 15056 | "Neighbor to display information about\n" |
91d37724 | 15057 | "Neighbor on BGP configured interface\n" |
9973d184 | 15058 | JSON_STR) |
718e3744 | 15059 | { |
d62a17ae | 15060 | char *vrf = NULL; |
15061 | char *sh_arg = NULL; | |
15062 | enum show_type sh_type; | |
d1927ebe | 15063 | afi_t afi = AFI_MAX; |
718e3744 | 15064 | |
9f049418 | 15065 | bool uj = use_json(argc, argv); |
718e3744 | 15066 | |
d62a17ae | 15067 | int idx = 0; |
718e3744 | 15068 | |
9a8bdf1c PG |
15069 | /* [<vrf> VIEWVRFNAME] */ |
15070 | if (argv_find(argv, argc, "vrf", &idx)) { | |
15071 | vrf = argv[idx + 1]->arg; | |
15072 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
15073 | vrf = NULL; | |
15074 | } else if (argv_find(argv, argc, "view", &idx)) | |
15075 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 15076 | vrf = argv[idx + 1]->arg; |
718e3744 | 15077 | |
d62a17ae | 15078 | idx++; |
d1927ebe AS |
15079 | |
15080 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
15081 | sh_type = show_ipv4_all; | |
15082 | afi = AFI_IP; | |
15083 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
15084 | sh_type = show_ipv6_all; | |
15085 | afi = AFI_IP6; | |
15086 | } else { | |
15087 | sh_type = show_all; | |
15088 | } | |
15089 | ||
d62a17ae | 15090 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
15091 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
15092 | || argv_find(argv, argc, "WORD", &idx)) { | |
15093 | sh_type = show_peer; | |
15094 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
15095 | } |
15096 | ||
15097 | if (sh_type == show_peer && afi == AFI_IP) { | |
15098 | sh_type = show_ipv4_peer; | |
15099 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
15100 | sh_type = show_ipv6_peer; | |
15101 | } | |
856ca177 | 15102 | |
d62a17ae | 15103 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 15104 | } |
15105 | ||
716b2d8a | 15106 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 15107 | paths' and `show ip mbgp paths'. Those functions results are the |
15108 | same.*/ | |
f412b39a | 15109 | DEFUN (show_ip_bgp_paths, |
718e3744 | 15110 | show_ip_bgp_paths_cmd, |
46f296b4 | 15111 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 15112 | SHOW_STR |
15113 | IP_STR | |
15114 | BGP_STR | |
46f296b4 | 15115 | BGP_SAFI_HELP_STR |
718e3744 | 15116 | "Path information\n") |
15117 | { | |
d62a17ae | 15118 | vty_out(vty, "Address Refcnt Path\n"); |
15119 | aspath_print_all_vty(vty); | |
15120 | return CMD_SUCCESS; | |
718e3744 | 15121 | } |
15122 | ||
718e3744 | 15123 | #include "hash.h" |
15124 | ||
e3b78da8 | 15125 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 15126 | struct vty *vty) |
718e3744 | 15127 | { |
d62a17ae | 15128 | struct community *com; |
718e3744 | 15129 | |
e3b78da8 | 15130 | com = (struct community *)bucket->data; |
3f65c5b1 | 15131 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
c0945b78 | 15132 | community_str(com, false, false)); |
718e3744 | 15133 | } |
15134 | ||
15135 | /* Show BGP's community internal data. */ | |
f412b39a | 15136 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 15137 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 15138 | "show [ip] bgp community-info", |
718e3744 | 15139 | SHOW_STR |
15140 | IP_STR | |
15141 | BGP_STR | |
15142 | "List all bgp community information\n") | |
15143 | { | |
d62a17ae | 15144 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 15145 | |
d62a17ae | 15146 | hash_iterate(community_hash(), |
e3b78da8 | 15147 | (void (*)(struct hash_bucket *, |
d62a17ae | 15148 | void *))community_show_all_iterator, |
15149 | vty); | |
718e3744 | 15150 | |
d62a17ae | 15151 | return CMD_SUCCESS; |
718e3744 | 15152 | } |
15153 | ||
e3b78da8 | 15154 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 15155 | struct vty *vty) |
57d187bc | 15156 | { |
d62a17ae | 15157 | struct lcommunity *lcom; |
57d187bc | 15158 | |
e3b78da8 | 15159 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 15160 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
c0945b78 | 15161 | lcommunity_str(lcom, false, false)); |
57d187bc JS |
15162 | } |
15163 | ||
15164 | /* Show BGP's community internal data. */ | |
15165 | DEFUN (show_ip_bgp_lcommunity_info, | |
15166 | show_ip_bgp_lcommunity_info_cmd, | |
15167 | "show ip bgp large-community-info", | |
15168 | SHOW_STR | |
15169 | IP_STR | |
15170 | BGP_STR | |
15171 | "List all bgp large-community information\n") | |
15172 | { | |
d62a17ae | 15173 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 15174 | |
d62a17ae | 15175 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 15176 | (void (*)(struct hash_bucket *, |
d62a17ae | 15177 | void *))lcommunity_show_all_iterator, |
15178 | vty); | |
57d187bc | 15179 | |
d62a17ae | 15180 | return CMD_SUCCESS; |
57d187bc | 15181 | } |
2986cac2 | 15182 | /* Graceful Restart */ |
15183 | ||
15184 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
36235319 QY |
15185 | struct bgp *bgp, |
15186 | bool use_json, | |
15187 | json_object *json) | |
2986cac2 | 15188 | { |
57d187bc JS |
15189 | |
15190 | ||
2986cac2 | 15191 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
15192 | ||
7318ae88 | 15193 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 15194 | |
15195 | switch (bgp_global_gr_mode) { | |
15196 | ||
15197 | case GLOBAL_HELPER: | |
13909c4f | 15198 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 15199 | break; |
15200 | ||
15201 | case GLOBAL_GR: | |
13909c4f | 15202 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 15203 | break; |
15204 | ||
15205 | case GLOBAL_DISABLE: | |
13909c4f | 15206 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 15207 | break; |
15208 | ||
15209 | case GLOBAL_INVALID: | |
2986cac2 | 15210 | vty_out(vty, |
2ba1fe69 | 15211 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 15212 | break; |
15213 | } | |
15214 | vty_out(vty, "\n"); | |
15215 | } | |
15216 | ||
36235319 QY |
15217 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
15218 | enum show_type type, | |
15219 | const char *ip_str, | |
15220 | afi_t afi, bool use_json) | |
2986cac2 | 15221 | { |
15222 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
15223 | afi = AFI_IP; | |
15224 | ||
15225 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
15226 | ||
36235319 QY |
15227 | bgp_show_neighbor_graceful_restart_vty( |
15228 | vty, type, ip_str, afi, use_json); | |
2986cac2 | 15229 | afi++; |
15230 | } | |
15231 | } else if (afi != AFI_MAX) { | |
36235319 QY |
15232 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
15233 | use_json); | |
2986cac2 | 15234 | } else { |
15235 | return CMD_ERR_INCOMPLETE; | |
15236 | } | |
15237 | ||
15238 | return CMD_SUCCESS; | |
15239 | } | |
15240 | /* Graceful Restart */ | |
15241 | ||
f412b39a | 15242 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 15243 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 15244 | "show [ip] bgp attribute-info", |
718e3744 | 15245 | SHOW_STR |
15246 | IP_STR | |
15247 | BGP_STR | |
15248 | "List all bgp attribute information\n") | |
15249 | { | |
d62a17ae | 15250 | attr_show_all(vty); |
15251 | return CMD_SUCCESS; | |
718e3744 | 15252 | } |
6b0655a2 | 15253 | |
03915806 CS |
15254 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
15255 | afi_t afi, safi_t safi, | |
15256 | bool use_json, json_object *json) | |
53089bec | 15257 | { |
15258 | struct bgp *bgp; | |
15259 | struct listnode *node; | |
15260 | char *vname; | |
53089bec | 15261 | char *ecom_str; |
9c2fd3fe | 15262 | enum vpn_policy_direction dir; |
53089bec | 15263 | |
03915806 | 15264 | if (json) { |
b46dfd20 DS |
15265 | json_object *json_import_vrfs = NULL; |
15266 | json_object *json_export_vrfs = NULL; | |
15267 | ||
b46dfd20 DS |
15268 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
15269 | ||
53089bec | 15270 | if (!bgp) { |
75eeda93 | 15271 | vty_json(vty, json); |
b46dfd20 | 15272 | |
53089bec | 15273 | return CMD_WARNING; |
15274 | } | |
b46dfd20 | 15275 | |
94d4c685 DS |
15276 | /* Provide context for the block */ |
15277 | json_object_string_add(json, "vrf", name ? name : "default"); | |
15278 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 15279 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 15280 | |
b46dfd20 DS |
15281 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
15282 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
15283 | json_object_string_add(json, "importFromVrfs", "none"); | |
15284 | json_object_string_add(json, "importRts", "none"); | |
15285 | } else { | |
6ce24e52 DS |
15286 | json_import_vrfs = json_object_new_array(); |
15287 | ||
b46dfd20 DS |
15288 | for (ALL_LIST_ELEMENTS_RO( |
15289 | bgp->vpn_policy[afi].import_vrf, | |
15290 | node, vname)) | |
15291 | json_object_array_add(json_import_vrfs, | |
15292 | json_object_new_string(vname)); | |
15293 | ||
b20875ea CS |
15294 | json_object_object_add(json, "importFromVrfs", |
15295 | json_import_vrfs); | |
b46dfd20 | 15296 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
15297 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
15298 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15299 | bgp->vpn_policy[afi].rtlist[dir], |
15300 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
15301 | json_object_string_add(json, "importRts", |
15302 | ecom_str); | |
15303 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
15304 | } else | |
15305 | json_object_string_add(json, "importRts", | |
15306 | "none"); | |
b46dfd20 DS |
15307 | } |
15308 | ||
15309 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
15310 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
15311 | json_object_string_add(json, "exportToVrfs", "none"); | |
15312 | json_object_string_add(json, "routeDistinguisher", | |
15313 | "none"); | |
15314 | json_object_string_add(json, "exportRts", "none"); | |
15315 | } else { | |
6ce24e52 DS |
15316 | json_export_vrfs = json_object_new_array(); |
15317 | ||
b46dfd20 DS |
15318 | for (ALL_LIST_ELEMENTS_RO( |
15319 | bgp->vpn_policy[afi].export_vrf, | |
15320 | node, vname)) | |
15321 | json_object_array_add(json_export_vrfs, | |
15322 | json_object_new_string(vname)); | |
15323 | json_object_object_add(json, "exportToVrfs", | |
15324 | json_export_vrfs); | |
c4f64ea9 DA |
15325 | json_object_string_addf(json, "routeDistinguisher", |
15326 | "%pRD", | |
15327 | &bgp->vpn_policy[afi].tovpn_rd); | |
b46dfd20 DS |
15328 | |
15329 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
15330 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
15331 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15332 | bgp->vpn_policy[afi].rtlist[dir], |
15333 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
15334 | json_object_string_add(json, "exportRts", |
15335 | ecom_str); | |
15336 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
15337 | } else | |
15338 | json_object_string_add(json, "exportRts", | |
15339 | "none"); | |
b46dfd20 DS |
15340 | } |
15341 | ||
03915806 | 15342 | if (use_json) { |
75eeda93 | 15343 | vty_json(vty, json); |
03915806 | 15344 | } |
53089bec | 15345 | } else { |
b46dfd20 DS |
15346 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
15347 | ||
53089bec | 15348 | if (!bgp) { |
b46dfd20 | 15349 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 15350 | return CMD_WARNING; |
15351 | } | |
53089bec | 15352 | |
b46dfd20 DS |
15353 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
15354 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
15355 | vty_out(vty, | |
15356 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 15357 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15358 | else { |
15359 | vty_out(vty, | |
15360 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 15361 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15362 | |
15363 | for (ALL_LIST_ELEMENTS_RO( | |
15364 | bgp->vpn_policy[afi].import_vrf, | |
15365 | node, vname)) | |
15366 | vty_out(vty, " %s\n", vname); | |
15367 | ||
15368 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
15369 | ecom_str = NULL; |
15370 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
15371 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15372 | bgp->vpn_policy[afi].rtlist[dir], |
15373 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 15374 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 15375 | |
b20875ea CS |
15376 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
15377 | } else | |
15378 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 15379 | } |
53089bec | 15380 | |
b46dfd20 DS |
15381 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
15382 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
15383 | vty_out(vty, | |
15384 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 15385 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15386 | else { |
15387 | vty_out(vty, | |
04c9077f | 15388 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 15389 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15390 | |
15391 | for (ALL_LIST_ELEMENTS_RO( | |
15392 | bgp->vpn_policy[afi].export_vrf, | |
15393 | node, vname)) | |
15394 | vty_out(vty, " %s\n", vname); | |
15395 | ||
c4f64ea9 DA |
15396 | vty_out(vty, "RD: %pRD\n", |
15397 | &bgp->vpn_policy[afi].tovpn_rd); | |
b46dfd20 DS |
15398 | |
15399 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
15400 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
15401 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15402 | bgp->vpn_policy[afi].rtlist[dir], |
15403 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
15404 | vty_out(vty, "Export RT: %s\n", ecom_str); |
15405 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
15406 | } else | |
15407 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 15408 | } |
53089bec | 15409 | } |
15410 | ||
15411 | return CMD_SUCCESS; | |
15412 | } | |
15413 | ||
03915806 CS |
15414 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
15415 | safi_t safi, bool use_json) | |
15416 | { | |
15417 | struct listnode *node, *nnode; | |
15418 | struct bgp *bgp; | |
15419 | char *vrf_name = NULL; | |
15420 | json_object *json = NULL; | |
15421 | json_object *json_vrf = NULL; | |
15422 | json_object *json_vrfs = NULL; | |
15423 | ||
15424 | if (use_json) { | |
15425 | json = json_object_new_object(); | |
15426 | json_vrfs = json_object_new_object(); | |
15427 | } | |
15428 | ||
15429 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
15430 | ||
15431 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
15432 | vrf_name = bgp->name; | |
15433 | ||
15434 | if (use_json) { | |
15435 | json_vrf = json_object_new_object(); | |
15436 | } else { | |
15437 | vty_out(vty, "\nInstance %s:\n", | |
15438 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
15439 | ? VRF_DEFAULT_NAME : bgp->name); | |
15440 | } | |
15441 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
15442 | if (use_json) { | |
15443 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
15444 | json_object_object_add(json_vrfs, | |
15445 | VRF_DEFAULT_NAME, json_vrf); | |
15446 | else | |
15447 | json_object_object_add(json_vrfs, vrf_name, | |
15448 | json_vrf); | |
15449 | } | |
15450 | } | |
15451 | ||
15452 | if (use_json) { | |
15453 | json_object_object_add(json, "vrfs", json_vrfs); | |
75eeda93 | 15454 | vty_json(vty, json); |
03915806 CS |
15455 | } |
15456 | ||
15457 | return CMD_SUCCESS; | |
15458 | } | |
15459 | ||
53089bec | 15460 | /* "show [ip] bgp route-leak" command. */ |
15461 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
15462 | show_ip_bgp_route_leak_cmd, |
15463 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
15464 | SHOW_STR |
15465 | IP_STR | |
15466 | BGP_STR | |
15467 | BGP_INSTANCE_HELP_STR | |
15468 | BGP_AFI_HELP_STR | |
15469 | BGP_SAFI_HELP_STR | |
15470 | "Route leaking information\n" | |
15471 | JSON_STR) | |
53089bec | 15472 | { |
15473 | char *vrf = NULL; | |
15474 | afi_t afi = AFI_MAX; | |
15475 | safi_t safi = SAFI_MAX; | |
15476 | ||
9f049418 | 15477 | bool uj = use_json(argc, argv); |
53089bec | 15478 | int idx = 0; |
03915806 | 15479 | json_object *json = NULL; |
53089bec | 15480 | |
15481 | /* show [ip] bgp */ | |
15482 | if (argv_find(argv, argc, "ip", &idx)) { | |
15483 | afi = AFI_IP; | |
15484 | safi = SAFI_UNICAST; | |
15485 | } | |
15486 | /* [vrf VIEWVRFNAME] */ | |
15487 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
15488 | vty_out(vty, |
15489 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 15490 | return CMD_WARNING; |
15491 | } | |
15492 | ||
9a8bdf1c PG |
15493 | if (argv_find(argv, argc, "vrf", &idx)) { |
15494 | vrf = argv[idx + 1]->arg; | |
15495 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
15496 | vrf = NULL; | |
15497 | } | |
53089bec | 15498 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
c48349e3 | 15499 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
53089bec | 15500 | argv_find_and_parse_safi(argv, argc, &idx, &safi); |
53089bec | 15501 | |
15502 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
15503 | vty_out(vty, |
15504 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 15505 | return CMD_WARNING; |
15506 | } | |
15507 | ||
03915806 CS |
15508 | if (vrf && strmatch(vrf, "all")) |
15509 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
15510 | ||
15511 | if (uj) | |
15512 | json = json_object_new_object(); | |
15513 | ||
15514 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 15515 | } |
15516 | ||
d62a17ae | 15517 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
15518 | safi_t safi) | |
f186de26 | 15519 | { |
d62a17ae | 15520 | struct listnode *node, *nnode; |
15521 | struct bgp *bgp; | |
f186de26 | 15522 | |
d62a17ae | 15523 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
15524 | vty_out(vty, "\nInstance %s:\n", | |
15525 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 15526 | ? VRF_DEFAULT_NAME |
d62a17ae | 15527 | : bgp->name); |
15528 | update_group_show(bgp, afi, safi, vty, 0); | |
15529 | } | |
f186de26 | 15530 | } |
15531 | ||
d62a17ae | 15532 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
15533 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 15534 | { |
d62a17ae | 15535 | struct bgp *bgp; |
4fb25c53 | 15536 | |
d62a17ae | 15537 | if (name) { |
15538 | if (strmatch(name, "all")) { | |
15539 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
15540 | return CMD_SUCCESS; | |
15541 | } else { | |
15542 | bgp = bgp_lookup_by_name(name); | |
15543 | } | |
15544 | } else { | |
15545 | bgp = bgp_get_default(); | |
15546 | } | |
4fb25c53 | 15547 | |
d62a17ae | 15548 | if (bgp) |
15549 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
15550 | return CMD_SUCCESS; | |
4fb25c53 DW |
15551 | } |
15552 | ||
8fe8a7f6 DS |
15553 | DEFUN (show_ip_bgp_updgrps, |
15554 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 15555 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 15556 | SHOW_STR |
15557 | IP_STR | |
15558 | BGP_STR | |
15559 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 15560 | BGP_AFI_HELP_STR |
9bedbb1e | 15561 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
15562 | "Detailed info about dynamic update groups\n" |
15563 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 15564 | { |
d62a17ae | 15565 | char *vrf = NULL; |
15566 | afi_t afi = AFI_IP6; | |
15567 | safi_t safi = SAFI_UNICAST; | |
15568 | uint64_t subgrp_id = 0; | |
15569 | ||
15570 | int idx = 0; | |
15571 | ||
15572 | /* show [ip] bgp */ | |
15573 | if (argv_find(argv, argc, "ip", &idx)) | |
15574 | afi = AFI_IP; | |
9a8bdf1c PG |
15575 | /* [<vrf> VIEWVRFNAME] */ |
15576 | if (argv_find(argv, argc, "vrf", &idx)) { | |
15577 | vrf = argv[idx + 1]->arg; | |
15578 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
15579 | vrf = NULL; | |
15580 | } else if (argv_find(argv, argc, "view", &idx)) | |
15581 | /* [<view> VIEWVRFNAME] */ | |
15582 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 15583 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
15584 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
15585 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
15586 | } | |
5bf15956 | 15587 | |
d62a17ae | 15588 | /* get subgroup id, if provided */ |
15589 | idx = argc - 1; | |
15590 | if (argv[idx]->type == VARIABLE_TKN) | |
15591 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 15592 | |
d62a17ae | 15593 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
15594 | } |
15595 | ||
f186de26 | 15596 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
15597 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 15598 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 15599 | SHOW_STR |
716b2d8a | 15600 | IP_STR |
f186de26 | 15601 | BGP_STR |
15602 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 15603 | "Detailed info about dynamic update groups\n") |
f186de26 | 15604 | { |
d62a17ae | 15605 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
15606 | return CMD_SUCCESS; | |
f186de26 | 15607 | } |
15608 | ||
43d3f4fc DS |
15609 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
15610 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
15611 | "show [ip] bgp l2vpn evpn update-groups", | |
15612 | SHOW_STR | |
15613 | IP_STR | |
15614 | BGP_STR | |
15615 | "l2vpn address family\n" | |
15616 | "evpn sub-address family\n" | |
15617 | "Detailed info about dynamic update groups\n") | |
15618 | { | |
15619 | char *vrf = NULL; | |
15620 | uint64_t subgrp_id = 0; | |
15621 | ||
15622 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
15623 | return CMD_SUCCESS; | |
15624 | } | |
15625 | ||
5bf15956 DW |
15626 | DEFUN (show_bgp_updgrps_stats, |
15627 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 15628 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 15629 | SHOW_STR |
716b2d8a | 15630 | IP_STR |
3f9c7369 | 15631 | BGP_STR |
0c7b1b01 | 15632 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
15633 | "Statistics\n") |
15634 | { | |
d62a17ae | 15635 | struct bgp *bgp; |
3f9c7369 | 15636 | |
d62a17ae | 15637 | bgp = bgp_get_default(); |
15638 | if (bgp) | |
15639 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 15640 | |
d62a17ae | 15641 | return CMD_SUCCESS; |
3f9c7369 DS |
15642 | } |
15643 | ||
8386ac43 | 15644 | DEFUN (show_bgp_instance_updgrps_stats, |
15645 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 15646 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 15647 | SHOW_STR |
716b2d8a | 15648 | IP_STR |
8386ac43 | 15649 | BGP_STR |
15650 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 15651 | "Detailed info about dynamic update groups\n" |
8386ac43 | 15652 | "Statistics\n") |
15653 | { | |
d62a17ae | 15654 | int idx_word = 3; |
15655 | struct bgp *bgp; | |
8386ac43 | 15656 | |
d62a17ae | 15657 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
15658 | if (bgp) | |
15659 | update_group_show_stats(bgp, vty); | |
8386ac43 | 15660 | |
d62a17ae | 15661 | return CMD_SUCCESS; |
8386ac43 | 15662 | } |
15663 | ||
d62a17ae | 15664 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
15665 | afi_t afi, safi_t safi, | |
15666 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 15667 | { |
d62a17ae | 15668 | struct bgp *bgp; |
8386ac43 | 15669 | |
d62a17ae | 15670 | if (name) |
15671 | bgp = bgp_lookup_by_name(name); | |
15672 | else | |
15673 | bgp = bgp_get_default(); | |
8386ac43 | 15674 | |
d62a17ae | 15675 | if (bgp) { |
15676 | if (!strcmp(what, "advertise-queue")) | |
15677 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
15678 | subgrp_id); | |
15679 | else if (!strcmp(what, "advertised-routes")) | |
15680 | update_group_show_advertised(bgp, afi, safi, vty, | |
15681 | subgrp_id); | |
15682 | else if (!strcmp(what, "packet-queue")) | |
15683 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
15684 | subgrp_id); | |
15685 | } | |
3f9c7369 DS |
15686 | } |
15687 | ||
dc64bdec QY |
15688 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
15689 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
15690 | "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", | |
15691 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
15692 | BGP_SAFI_HELP_STR | |
15693 | "Detailed info about dynamic update groups\n" | |
15694 | "Specific subgroup to display info for\n" | |
15695 | "Advertisement queue\n" | |
15696 | "Announced routes\n" | |
15697 | "Packet queue\n") | |
3f9c7369 | 15698 | { |
dc64bdec QY |
15699 | uint64_t subgrp_id = 0; |
15700 | afi_t afiz; | |
15701 | safi_t safiz; | |
15702 | if (sgid) | |
15703 | subgrp_id = strtoull(sgid, NULL, 10); | |
15704 | ||
15705 | if (!ip && !afi) | |
15706 | afiz = AFI_IP6; | |
15707 | if (!ip && afi) | |
15708 | afiz = bgp_vty_afi_from_str(afi); | |
15709 | if (ip && !afi) | |
15710 | afiz = AFI_IP; | |
15711 | if (ip && afi) { | |
15712 | afiz = bgp_vty_afi_from_str(afi); | |
15713 | if (afiz != AFI_IP) | |
15714 | vty_out(vty, | |
15715 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
15716 | return CMD_WARNING; | |
15717 | } | |
d62a17ae | 15718 | |
dc64bdec | 15719 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 15720 | |
dc64bdec | 15721 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 15722 | return CMD_SUCCESS; |
15723 | } | |
15724 | ||
6f4eacf3 DA |
15725 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group, |
15726 | json_object *json) | |
d62a17ae | 15727 | { |
15728 | struct listnode *node, *nnode; | |
15729 | struct prefix *range; | |
15730 | struct peer *conf; | |
15731 | struct peer *peer; | |
d62a17ae | 15732 | afi_t afi; |
15733 | safi_t safi; | |
15734 | const char *peer_status; | |
d62a17ae | 15735 | int lr_count; |
15736 | int dynamic; | |
6f4eacf3 DA |
15737 | bool af_cfgd; |
15738 | json_object *json_peer_group = NULL; | |
15739 | json_object *json_peer_group_afc = NULL; | |
15740 | json_object *json_peer_group_members = NULL; | |
15741 | json_object *json_peer_group_dynamic = NULL; | |
15742 | json_object *json_peer_group_dynamic_af = NULL; | |
15743 | json_object *json_peer_group_ranges = NULL; | |
d62a17ae | 15744 | |
15745 | conf = group->conf; | |
15746 | ||
6f4eacf3 DA |
15747 | if (json) { |
15748 | json_peer_group = json_object_new_object(); | |
15749 | json_peer_group_afc = json_object_new_array(); | |
15750 | } | |
15751 | ||
d62a17ae | 15752 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { |
6f4eacf3 DA |
15753 | if (json) |
15754 | json_object_int_add(json_peer_group, "remoteAs", | |
15755 | conf->as); | |
15756 | else | |
15757 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", | |
15758 | group->name, conf->as); | |
d62a17ae | 15759 | } else if (conf->as_type == AS_INTERNAL) { |
6f4eacf3 DA |
15760 | if (json) |
15761 | json_object_int_add(json_peer_group, "remoteAs", | |
15762 | group->bgp->as); | |
15763 | else | |
15764 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", | |
15765 | group->name, group->bgp->as); | |
d62a17ae | 15766 | } else { |
6f4eacf3 DA |
15767 | if (!json) |
15768 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
d62a17ae | 15769 | } |
f14e6fdb | 15770 | |
6f4eacf3 DA |
15771 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) { |
15772 | if (json) | |
15773 | json_object_string_add(json_peer_group, "type", | |
15774 | "internal"); | |
15775 | else | |
15776 | vty_out(vty, " Peer-group type is internal\n"); | |
15777 | } else { | |
15778 | if (json) | |
15779 | json_object_string_add(json_peer_group, "type", | |
15780 | "external"); | |
15781 | else | |
15782 | vty_out(vty, " Peer-group type is external\n"); | |
15783 | } | |
d62a17ae | 15784 | |
15785 | /* Display AFs configured. */ | |
6f4eacf3 DA |
15786 | if (!json) |
15787 | vty_out(vty, " Configured address-families:"); | |
15788 | ||
05c7a1cc QY |
15789 | FOREACH_AFI_SAFI (afi, safi) { |
15790 | if (conf->afc[afi][safi]) { | |
6f4eacf3 DA |
15791 | af_cfgd = true; |
15792 | if (json) | |
15793 | json_object_array_add( | |
15794 | json_peer_group_afc, | |
15795 | json_object_new_string(get_afi_safi_str( | |
15796 | afi, safi, false))); | |
15797 | else | |
15798 | vty_out(vty, " %s;", | |
15799 | get_afi_safi_str(afi, safi, false)); | |
d62a17ae | 15800 | } |
05c7a1cc | 15801 | } |
6f4eacf3 DA |
15802 | |
15803 | if (json) { | |
15804 | json_object_object_add(json_peer_group, | |
15805 | "addressFamiliesConfigured", | |
15806 | json_peer_group_afc); | |
15807 | } else { | |
15808 | if (!af_cfgd) | |
15809 | vty_out(vty, " none\n"); | |
15810 | else | |
15811 | vty_out(vty, "\n"); | |
15812 | } | |
d62a17ae | 15813 | |
15814 | /* Display listen ranges (for dynamic neighbors), if any */ | |
15815 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
d62a17ae | 15816 | lr_count = listcount(group->listen_range[afi]); |
15817 | if (lr_count) { | |
6f4eacf3 DA |
15818 | if (json) { |
15819 | if (!json_peer_group_dynamic) | |
15820 | json_peer_group_dynamic = | |
15821 | json_object_new_object(); | |
15822 | ||
15823 | json_peer_group_dynamic_af = | |
15824 | json_object_new_object(); | |
15825 | json_peer_group_ranges = | |
15826 | json_object_new_array(); | |
15827 | json_object_int_add(json_peer_group_dynamic_af, | |
15828 | "count", lr_count); | |
15829 | } else { | |
15830 | vty_out(vty, " %d %s listen range(s)\n", | |
15831 | lr_count, afi2str(afi)); | |
15832 | } | |
d62a17ae | 15833 | |
15834 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
6f4eacf3 DA |
15835 | nnode, range)) { |
15836 | if (json) { | |
15837 | char buf[BUFSIZ]; | |
15838 | ||
15839 | snprintfrr(buf, sizeof(buf), "%pFX", | |
15840 | range); | |
15841 | ||
15842 | json_object_array_add( | |
15843 | json_peer_group_ranges, | |
15844 | json_object_new_string(buf)); | |
15845 | } else { | |
15846 | vty_out(vty, " %pFX\n", range); | |
15847 | } | |
15848 | } | |
15849 | ||
15850 | if (json) { | |
15851 | json_object_object_add( | |
15852 | json_peer_group_dynamic_af, "ranges", | |
15853 | json_peer_group_ranges); | |
15854 | ||
15855 | json_object_object_add( | |
15856 | json_peer_group_dynamic, afi2str(afi), | |
15857 | json_peer_group_dynamic_af); | |
15858 | } | |
d62a17ae | 15859 | } |
15860 | } | |
f14e6fdb | 15861 | |
6f4eacf3 DA |
15862 | if (json_peer_group_dynamic) |
15863 | json_object_object_add(json_peer_group, "dynamicRanges", | |
15864 | json_peer_group_dynamic); | |
15865 | ||
d62a17ae | 15866 | /* Display group members and their status */ |
15867 | if (listcount(group->peer)) { | |
6f4eacf3 DA |
15868 | if (json) |
15869 | json_peer_group_members = json_object_new_object(); | |
15870 | else | |
15871 | vty_out(vty, " Peer-group members:\n"); | |
d62a17ae | 15872 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { |
cb9196e7 DS |
15873 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
15874 | || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 15875 | peer_status = "Idle (Admin)"; |
15876 | else if (CHECK_FLAG(peer->sflags, | |
15877 | PEER_STATUS_PREFIX_OVERFLOW)) | |
15878 | peer_status = "Idle (PfxCt)"; | |
15879 | else | |
15880 | peer_status = lookup_msg(bgp_status_msg, | |
15881 | peer->status, NULL); | |
15882 | ||
15883 | dynamic = peer_dynamic_neighbor(peer); | |
6f4eacf3 DA |
15884 | |
15885 | if (json) { | |
15886 | json_object *json_peer_group_member = | |
15887 | json_object_new_object(); | |
15888 | ||
15889 | json_object_string_add(json_peer_group_member, | |
15890 | "status", peer_status); | |
15891 | ||
15892 | if (dynamic) | |
15893 | json_object_boolean_true_add( | |
15894 | json_peer_group_member, | |
15895 | "dynamic"); | |
15896 | ||
15897 | json_object_object_add(json_peer_group_members, | |
15898 | peer->host, | |
15899 | json_peer_group_member); | |
15900 | } else { | |
15901 | vty_out(vty, " %s %s %s \n", peer->host, | |
15902 | dynamic ? "(dynamic)" : "", | |
15903 | peer_status); | |
15904 | } | |
d62a17ae | 15905 | } |
6f4eacf3 DA |
15906 | if (json) |
15907 | json_object_object_add(json_peer_group, "members", | |
15908 | json_peer_group_members); | |
d62a17ae | 15909 | } |
f14e6fdb | 15910 | |
6f4eacf3 DA |
15911 | if (json) |
15912 | json_object_object_add(json, group->name, json_peer_group); | |
15913 | ||
d62a17ae | 15914 | return CMD_SUCCESS; |
15915 | } | |
15916 | ||
ff9959b0 | 15917 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
6f4eacf3 | 15918 | const char *group_name, bool uj) |
d62a17ae | 15919 | { |
ff9959b0 | 15920 | struct bgp *bgp; |
d62a17ae | 15921 | struct listnode *node, *nnode; |
15922 | struct peer_group *group; | |
ff9959b0 | 15923 | bool found = false; |
6f4eacf3 DA |
15924 | json_object *json = NULL; |
15925 | ||
15926 | if (uj) | |
15927 | json = json_object_new_object(); | |
ff9959b0 QY |
15928 | |
15929 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
15930 | ||
15931 | if (!bgp) { | |
c48349e3 | 15932 | if (uj) |
75eeda93 | 15933 | vty_json(vty, json); |
c48349e3 | 15934 | else |
6f4eacf3 | 15935 | vty_out(vty, "%% BGP instance not found\n"); |
6f4eacf3 | 15936 | |
ff9959b0 QY |
15937 | return CMD_WARNING; |
15938 | } | |
d62a17ae | 15939 | |
15940 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
15941 | if (group_name) { |
15942 | if (strmatch(group->name, group_name)) { | |
6f4eacf3 | 15943 | bgp_show_one_peer_group(vty, group, json); |
ff9959b0 QY |
15944 | found = true; |
15945 | break; | |
d62a17ae | 15946 | } |
ff9959b0 | 15947 | } else { |
6f4eacf3 | 15948 | bgp_show_one_peer_group(vty, group, json); |
d62a17ae | 15949 | } |
f14e6fdb | 15950 | } |
f14e6fdb | 15951 | |
6f4eacf3 | 15952 | if (group_name && !found && !uj) |
d62a17ae | 15953 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 15954 | |
c48349e3 | 15955 | if (uj) |
75eeda93 | 15956 | vty_json(vty, json); |
6f4eacf3 | 15957 | |
d62a17ae | 15958 | return CMD_SUCCESS; |
f14e6fdb DS |
15959 | } |
15960 | ||
6f4eacf3 DA |
15961 | DEFUN(show_ip_bgp_peer_groups, show_ip_bgp_peer_groups_cmd, |
15962 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]", | |
15963 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR | |
15964 | "Detailed information on BGP peer groups\n" | |
15965 | "Peer group name\n" JSON_STR) | |
f14e6fdb | 15966 | { |
d62a17ae | 15967 | char *vrf, *pg; |
d62a17ae | 15968 | int idx = 0; |
6f4eacf3 | 15969 | bool uj = use_json(argc, argv); |
f14e6fdb | 15970 | |
a4d82a8a PZ |
15971 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
15972 | : NULL; | |
d62a17ae | 15973 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 15974 | |
6f4eacf3 | 15975 | return bgp_show_peer_group_vty(vty, vrf, pg, uj); |
f14e6fdb | 15976 | } |
3f9c7369 | 15977 | |
d6e3c605 | 15978 | |
718e3744 | 15979 | /* Redistribute VTY commands. */ |
15980 | ||
585f1adc IR |
15981 | DEFUN (bgp_redistribute_ipv4, |
15982 | bgp_redistribute_ipv4_cmd, | |
15983 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
15984 | "Redistribute information from another routing protocol\n" | |
15985 | FRR_IP_REDIST_HELP_STR_BGPD) | |
718e3744 | 15986 | { |
585f1adc | 15987 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15988 | int idx_protocol = 1; |
585f1adc | 15989 | int type; |
37a87b8f | 15990 | |
585f1adc IR |
15991 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
15992 | if (type < 0) { | |
15993 | vty_out(vty, "%% Invalid route type\n"); | |
15994 | return CMD_WARNING_CONFIG_FAILED; | |
15995 | } | |
7f323236 | 15996 | |
585f1adc IR |
15997 | bgp_redist_add(bgp, AFI_IP, type, 0); |
15998 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); | |
718e3744 | 15999 | } |
16000 | ||
d62a17ae | 16001 | ALIAS_HIDDEN( |
16002 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
16003 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
16004 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 16005 | |
585f1adc IR |
16006 | DEFUN (bgp_redistribute_ipv4_rmap, |
16007 | bgp_redistribute_ipv4_rmap_cmd, | |
70dd370f | 16008 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map RMAP_NAME", |
585f1adc IR |
16009 | "Redistribute information from another routing protocol\n" |
16010 | FRR_IP_REDIST_HELP_STR_BGPD | |
16011 | "Route map reference\n" | |
16012 | "Pointer to route-map entries\n") | |
718e3744 | 16013 | { |
585f1adc | 16014 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16015 | int idx_protocol = 1; |
16016 | int idx_word = 3; | |
585f1adc IR |
16017 | int type; |
16018 | struct bgp_redist *red; | |
16019 | bool changed; | |
16020 | struct route_map *route_map = route_map_lookup_warn_noexist( | |
16021 | vty, argv[idx_word]->arg); | |
16022 | ||
16023 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
16024 | if (type < 0) { | |
16025 | vty_out(vty, "%% Invalid route type\n"); | |
16026 | return CMD_WARNING_CONFIG_FAILED; | |
16027 | } | |
37a87b8f | 16028 | |
585f1adc IR |
16029 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
16030 | changed = | |
16031 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16032 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
718e3744 | 16033 | } |
16034 | ||
d62a17ae | 16035 | ALIAS_HIDDEN( |
16036 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
70dd370f | 16037 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map RMAP_NAME", |
d62a17ae | 16038 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD |
16039 | "Route map reference\n" | |
16040 | "Pointer to route-map entries\n") | |
596c17ba | 16041 | |
585f1adc IR |
16042 | DEFUN (bgp_redistribute_ipv4_metric, |
16043 | bgp_redistribute_ipv4_metric_cmd, | |
16044 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
16045 | "Redistribute information from another routing protocol\n" | |
16046 | FRR_IP_REDIST_HELP_STR_BGPD | |
16047 | "Metric for redistributed routes\n" | |
16048 | "Default metric\n") | |
718e3744 | 16049 | { |
585f1adc | 16050 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16051 | int idx_protocol = 1; |
16052 | int idx_number = 3; | |
585f1adc IR |
16053 | int type; |
16054 | uint32_t metric; | |
16055 | struct bgp_redist *red; | |
16056 | bool changed; | |
16057 | ||
16058 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
16059 | if (type < 0) { | |
16060 | vty_out(vty, "%% Invalid route type\n"); | |
16061 | return CMD_WARNING_CONFIG_FAILED; | |
16062 | } | |
16063 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 16064 | |
585f1adc IR |
16065 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
16066 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
16067 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 16068 | } |
16069 | ||
16070 | ALIAS_HIDDEN( | |
16071 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
16072 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
16073 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
16074 | "Metric for redistributed routes\n" | |
16075 | "Default metric\n") | |
596c17ba | 16076 | |
585f1adc IR |
16077 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
16078 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
70dd370f | 16079 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map RMAP_NAME metric (0-4294967295)", |
585f1adc IR |
16080 | "Redistribute information from another routing protocol\n" |
16081 | FRR_IP_REDIST_HELP_STR_BGPD | |
16082 | "Route map reference\n" | |
16083 | "Pointer to route-map entries\n" | |
16084 | "Metric for redistributed routes\n" | |
16085 | "Default metric\n") | |
718e3744 | 16086 | { |
585f1adc | 16087 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16088 | int idx_protocol = 1; |
16089 | int idx_word = 3; | |
16090 | int idx_number = 5; | |
585f1adc IR |
16091 | int type; |
16092 | uint32_t metric; | |
16093 | struct bgp_redist *red; | |
16094 | bool changed; | |
16095 | struct route_map *route_map = | |
16096 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16097 | ||
16098 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
16099 | if (type < 0) { | |
16100 | vty_out(vty, "%% Invalid route type\n"); | |
16101 | return CMD_WARNING_CONFIG_FAILED; | |
16102 | } | |
16103 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
d62a17ae | 16104 | |
585f1adc IR |
16105 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
16106 | changed = | |
16107 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16108 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
16109 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 16110 | } |
16111 | ||
16112 | ALIAS_HIDDEN( | |
16113 | bgp_redistribute_ipv4_rmap_metric, | |
16114 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
16115 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
70dd370f | 16116 | " route-map RMAP_NAME metric (0-4294967295)", |
d62a17ae | 16117 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD |
16118 | "Route map reference\n" | |
16119 | "Pointer to route-map entries\n" | |
16120 | "Metric for redistributed routes\n" | |
16121 | "Default metric\n") | |
596c17ba | 16122 | |
585f1adc IR |
16123 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
16124 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
70dd370f | 16125 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map RMAP_NAME", |
585f1adc IR |
16126 | "Redistribute information from another routing protocol\n" |
16127 | FRR_IP_REDIST_HELP_STR_BGPD | |
16128 | "Metric for redistributed routes\n" | |
16129 | "Default metric\n" | |
16130 | "Route map reference\n" | |
16131 | "Pointer to route-map entries\n") | |
718e3744 | 16132 | { |
585f1adc | 16133 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16134 | int idx_protocol = 1; |
37a87b8f | 16135 | int idx_number = 3; |
585f1adc IR |
16136 | int idx_word = 5; |
16137 | int type; | |
16138 | uint32_t metric; | |
16139 | struct bgp_redist *red; | |
16140 | bool changed; | |
16141 | struct route_map *route_map = | |
16142 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16143 | ||
16144 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
16145 | if (type < 0) { | |
16146 | vty_out(vty, "%% Invalid route type\n"); | |
16147 | return CMD_WARNING_CONFIG_FAILED; | |
16148 | } | |
16149 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
d62a17ae | 16150 | |
585f1adc IR |
16151 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
16152 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
16153 | changed |= | |
16154 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16155 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 16156 | } |
16157 | ||
16158 | ALIAS_HIDDEN( | |
16159 | bgp_redistribute_ipv4_metric_rmap, | |
16160 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
16161 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
70dd370f | 16162 | " metric (0-4294967295) route-map RMAP_NAME", |
d62a17ae | 16163 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD |
16164 | "Metric for redistributed routes\n" | |
16165 | "Default metric\n" | |
16166 | "Route map reference\n" | |
16167 | "Pointer to route-map entries\n") | |
596c17ba | 16168 | |
585f1adc IR |
16169 | DEFUN (bgp_redistribute_ipv4_ospf, |
16170 | bgp_redistribute_ipv4_ospf_cmd, | |
16171 | "redistribute <ospf|table> (1-65535)", | |
16172 | "Redistribute information from another routing protocol\n" | |
16173 | "Open Shortest Path First (OSPFv2)\n" | |
16174 | "Non-main Kernel Routing Table\n" | |
16175 | "Instance ID/Table ID\n") | |
7c8ff89e | 16176 | { |
585f1adc IR |
16177 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16178 | int idx_ospf_table = 1; | |
d62a17ae | 16179 | int idx_number = 2; |
585f1adc IR |
16180 | unsigned short instance; |
16181 | unsigned short protocol; | |
7c8ff89e | 16182 | |
585f1adc | 16183 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 16184 | |
585f1adc IR |
16185 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
16186 | protocol = ZEBRA_ROUTE_OSPF; | |
16187 | else | |
16188 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 16189 | |
585f1adc IR |
16190 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
16191 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); | |
7c8ff89e DS |
16192 | } |
16193 | ||
d62a17ae | 16194 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
16195 | "redistribute <ospf|table> (1-65535)", | |
16196 | "Redistribute information from another routing protocol\n" | |
16197 | "Open Shortest Path First (OSPFv2)\n" | |
16198 | "Non-main Kernel Routing Table\n" | |
16199 | "Instance ID/Table ID\n") | |
596c17ba | 16200 | |
585f1adc IR |
16201 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
16202 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
70dd370f | 16203 | "redistribute <ospf|table> (1-65535) route-map RMAP_NAME", |
585f1adc IR |
16204 | "Redistribute information from another routing protocol\n" |
16205 | "Open Shortest Path First (OSPFv2)\n" | |
16206 | "Non-main Kernel Routing Table\n" | |
16207 | "Instance ID/Table ID\n" | |
16208 | "Route map reference\n" | |
16209 | "Pointer to route-map entries\n") | |
7c8ff89e | 16210 | { |
585f1adc IR |
16211 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16212 | int idx_ospf_table = 1; | |
d62a17ae | 16213 | int idx_number = 2; |
16214 | int idx_word = 4; | |
585f1adc IR |
16215 | struct bgp_redist *red; |
16216 | unsigned short instance; | |
16217 | int protocol; | |
16218 | bool changed; | |
16219 | struct route_map *route_map = | |
16220 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16221 | ||
16222 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
16223 | protocol = ZEBRA_ROUTE_OSPF; | |
16224 | else | |
16225 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 16226 | |
585f1adc IR |
16227 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
16228 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
16229 | changed = | |
16230 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16231 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 16232 | } |
16233 | ||
16234 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
16235 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
70dd370f | 16236 | "redistribute <ospf|table> (1-65535) route-map RMAP_NAME", |
d62a17ae | 16237 | "Redistribute information from another routing protocol\n" |
16238 | "Open Shortest Path First (OSPFv2)\n" | |
16239 | "Non-main Kernel Routing Table\n" | |
16240 | "Instance ID/Table ID\n" | |
16241 | "Route map reference\n" | |
16242 | "Pointer to route-map entries\n") | |
596c17ba | 16243 | |
585f1adc IR |
16244 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
16245 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
16246 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
16247 | "Redistribute information from another routing protocol\n" | |
16248 | "Open Shortest Path First (OSPFv2)\n" | |
16249 | "Non-main Kernel Routing Table\n" | |
16250 | "Instance ID/Table ID\n" | |
16251 | "Metric for redistributed routes\n" | |
16252 | "Default metric\n") | |
7c8ff89e | 16253 | { |
585f1adc IR |
16254 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16255 | int idx_ospf_table = 1; | |
d62a17ae | 16256 | int idx_number = 2; |
16257 | int idx_number_2 = 4; | |
585f1adc IR |
16258 | uint32_t metric; |
16259 | struct bgp_redist *red; | |
16260 | unsigned short instance; | |
16261 | int protocol; | |
16262 | bool changed; | |
16263 | ||
16264 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
16265 | protocol = ZEBRA_ROUTE_OSPF; | |
16266 | else | |
16267 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 16268 | |
585f1adc IR |
16269 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
16270 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 16271 | |
585f1adc IR |
16272 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
16273 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
16274 | metric); | |
16275 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 16276 | } |
16277 | ||
16278 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
16279 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
16280 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
16281 | "Redistribute information from another routing protocol\n" | |
16282 | "Open Shortest Path First (OSPFv2)\n" | |
16283 | "Non-main Kernel Routing Table\n" | |
16284 | "Instance ID/Table ID\n" | |
16285 | "Metric for redistributed routes\n" | |
16286 | "Default metric\n") | |
596c17ba | 16287 | |
585f1adc IR |
16288 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
16289 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
70dd370f | 16290 | "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)", |
585f1adc IR |
16291 | "Redistribute information from another routing protocol\n" |
16292 | "Open Shortest Path First (OSPFv2)\n" | |
16293 | "Non-main Kernel Routing Table\n" | |
16294 | "Instance ID/Table ID\n" | |
16295 | "Route map reference\n" | |
16296 | "Pointer to route-map entries\n" | |
16297 | "Metric for redistributed routes\n" | |
16298 | "Default metric\n") | |
7c8ff89e | 16299 | { |
585f1adc IR |
16300 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16301 | int idx_ospf_table = 1; | |
d62a17ae | 16302 | int idx_number = 2; |
16303 | int idx_word = 4; | |
16304 | int idx_number_2 = 6; | |
585f1adc IR |
16305 | uint32_t metric; |
16306 | struct bgp_redist *red; | |
16307 | unsigned short instance; | |
16308 | int protocol; | |
16309 | bool changed; | |
16310 | struct route_map *route_map = | |
16311 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16312 | ||
16313 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
16314 | protocol = ZEBRA_ROUTE_OSPF; | |
16315 | else | |
16316 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 16317 | |
585f1adc IR |
16318 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
16319 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 16320 | |
585f1adc IR |
16321 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
16322 | changed = | |
16323 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16324 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
16325 | metric); | |
16326 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 16327 | } |
16328 | ||
16329 | ALIAS_HIDDEN( | |
16330 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
16331 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
70dd370f | 16332 | "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)", |
d62a17ae | 16333 | "Redistribute information from another routing protocol\n" |
16334 | "Open Shortest Path First (OSPFv2)\n" | |
16335 | "Non-main Kernel Routing Table\n" | |
16336 | "Instance ID/Table ID\n" | |
16337 | "Route map reference\n" | |
16338 | "Pointer to route-map entries\n" | |
16339 | "Metric for redistributed routes\n" | |
16340 | "Default metric\n") | |
596c17ba | 16341 | |
585f1adc IR |
16342 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
16343 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
70dd370f | 16344 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME", |
585f1adc IR |
16345 | "Redistribute information from another routing protocol\n" |
16346 | "Open Shortest Path First (OSPFv2)\n" | |
16347 | "Non-main Kernel Routing Table\n" | |
16348 | "Instance ID/Table ID\n" | |
16349 | "Metric for redistributed routes\n" | |
16350 | "Default metric\n" | |
16351 | "Route map reference\n" | |
16352 | "Pointer to route-map entries\n") | |
7c8ff89e | 16353 | { |
585f1adc IR |
16354 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16355 | int idx_ospf_table = 1; | |
d62a17ae | 16356 | int idx_number = 2; |
16357 | int idx_number_2 = 4; | |
16358 | int idx_word = 6; | |
585f1adc IR |
16359 | uint32_t metric; |
16360 | struct bgp_redist *red; | |
16361 | unsigned short instance; | |
16362 | int protocol; | |
16363 | bool changed; | |
16364 | struct route_map *route_map = | |
16365 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16366 | ||
16367 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
16368 | protocol = ZEBRA_ROUTE_OSPF; | |
16369 | else | |
16370 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 16371 | |
585f1adc IR |
16372 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
16373 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 16374 | |
585f1adc IR |
16375 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
16376 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
16377 | metric); | |
16378 | changed |= | |
16379 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16380 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 16381 | } |
16382 | ||
16383 | ALIAS_HIDDEN( | |
16384 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
16385 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
70dd370f | 16386 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME", |
d62a17ae | 16387 | "Redistribute information from another routing protocol\n" |
16388 | "Open Shortest Path First (OSPFv2)\n" | |
16389 | "Non-main Kernel Routing Table\n" | |
16390 | "Instance ID/Table ID\n" | |
16391 | "Metric for redistributed routes\n" | |
16392 | "Default metric\n" | |
16393 | "Route map reference\n" | |
16394 | "Pointer to route-map entries\n") | |
596c17ba | 16395 | |
585f1adc IR |
16396 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
16397 | no_bgp_redistribute_ipv4_ospf_cmd, | |
70dd370f | 16398 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]", |
585f1adc IR |
16399 | NO_STR |
16400 | "Redistribute information from another routing protocol\n" | |
16401 | "Open Shortest Path First (OSPFv2)\n" | |
16402 | "Non-main Kernel Routing Table\n" | |
16403 | "Instance ID/Table ID\n" | |
16404 | "Metric for redistributed routes\n" | |
16405 | "Default metric\n" | |
16406 | "Route map reference\n" | |
16407 | "Pointer to route-map entries\n") | |
7c8ff89e | 16408 | { |
585f1adc IR |
16409 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16410 | int idx_ospf_table = 2; | |
d62a17ae | 16411 | int idx_number = 3; |
585f1adc IR |
16412 | unsigned short instance; |
16413 | int protocol; | |
37a87b8f | 16414 | |
585f1adc IR |
16415 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
16416 | protocol = ZEBRA_ROUTE_OSPF; | |
16417 | else | |
16418 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 16419 | |
585f1adc IR |
16420 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
16421 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
d62a17ae | 16422 | } |
16423 | ||
16424 | ALIAS_HIDDEN( | |
16425 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
70dd370f | 16426 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]", |
d62a17ae | 16427 | NO_STR |
16428 | "Redistribute information from another routing protocol\n" | |
16429 | "Open Shortest Path First (OSPFv2)\n" | |
16430 | "Non-main Kernel Routing Table\n" | |
16431 | "Instance ID/Table ID\n" | |
16432 | "Metric for redistributed routes\n" | |
16433 | "Default metric\n" | |
16434 | "Route map reference\n" | |
16435 | "Pointer to route-map entries\n") | |
596c17ba | 16436 | |
585f1adc IR |
16437 | DEFUN (no_bgp_redistribute_ipv4, |
16438 | no_bgp_redistribute_ipv4_cmd, | |
70dd370f | 16439 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map RMAP_NAME}]", |
585f1adc IR |
16440 | NO_STR |
16441 | "Redistribute information from another routing protocol\n" | |
16442 | FRR_IP_REDIST_HELP_STR_BGPD | |
16443 | "Metric for redistributed routes\n" | |
16444 | "Default metric\n" | |
16445 | "Route map reference\n" | |
16446 | "Pointer to route-map entries\n") | |
718e3744 | 16447 | { |
585f1adc | 16448 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16449 | int idx_protocol = 2; |
585f1adc | 16450 | int type; |
d62a17ae | 16451 | |
585f1adc IR |
16452 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
16453 | if (type < 0) { | |
16454 | vty_out(vty, "%% Invalid route type\n"); | |
16455 | return CMD_WARNING_CONFIG_FAILED; | |
16456 | } | |
16457 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
d62a17ae | 16458 | } |
16459 | ||
16460 | ALIAS_HIDDEN( | |
16461 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
16462 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
70dd370f | 16463 | " [{metric (0-4294967295)|route-map RMAP_NAME}]", |
d62a17ae | 16464 | NO_STR |
16465 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
16466 | "Metric for redistributed routes\n" | |
16467 | "Default metric\n" | |
16468 | "Route map reference\n" | |
16469 | "Pointer to route-map entries\n") | |
596c17ba | 16470 | |
585f1adc IR |
16471 | DEFUN (bgp_redistribute_ipv6, |
16472 | bgp_redistribute_ipv6_cmd, | |
16473 | "redistribute " FRR_IP6_REDIST_STR_BGPD, | |
16474 | "Redistribute information from another routing protocol\n" | |
16475 | FRR_IP6_REDIST_HELP_STR_BGPD) | |
718e3744 | 16476 | { |
585f1adc | 16477 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16478 | int idx_protocol = 1; |
585f1adc | 16479 | int type; |
718e3744 | 16480 | |
585f1adc IR |
16481 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
16482 | if (type < 0) { | |
16483 | vty_out(vty, "%% Invalid route type\n"); | |
16484 | return CMD_WARNING_CONFIG_FAILED; | |
16485 | } | |
718e3744 | 16486 | |
585f1adc IR |
16487 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
16488 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); | |
718e3744 | 16489 | } |
16490 | ||
585f1adc IR |
16491 | DEFUN (bgp_redistribute_ipv6_rmap, |
16492 | bgp_redistribute_ipv6_rmap_cmd, | |
70dd370f | 16493 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map RMAP_NAME", |
585f1adc IR |
16494 | "Redistribute information from another routing protocol\n" |
16495 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16496 | "Route map reference\n" | |
16497 | "Pointer to route-map entries\n") | |
718e3744 | 16498 | { |
585f1adc | 16499 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16500 | int idx_protocol = 1; |
16501 | int idx_word = 3; | |
585f1adc IR |
16502 | int type; |
16503 | struct bgp_redist *red; | |
16504 | bool changed; | |
16505 | struct route_map *route_map = | |
16506 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16507 | ||
16508 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
16509 | if (type < 0) { | |
16510 | vty_out(vty, "%% Invalid route type\n"); | |
16511 | return CMD_WARNING_CONFIG_FAILED; | |
16512 | } | |
37a87b8f | 16513 | |
585f1adc IR |
16514 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16515 | changed = | |
16516 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16517 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16518 | } |
16519 | ||
585f1adc | 16520 | DEFUN (bgp_redistribute_ipv6_metric, |
718e3744 | 16521 | bgp_redistribute_ipv6_metric_cmd, |
40d1cbfb | 16522 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 16523 | "Redistribute information from another routing protocol\n" |
ab0181ee | 16524 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 16525 | "Metric for redistributed routes\n" |
16526 | "Default metric\n") | |
16527 | { | |
585f1adc | 16528 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16529 | int idx_protocol = 1; |
16530 | int idx_number = 3; | |
585f1adc IR |
16531 | int type; |
16532 | uint32_t metric; | |
16533 | struct bgp_redist *red; | |
16534 | bool changed; | |
16535 | ||
16536 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
16537 | if (type < 0) { | |
16538 | vty_out(vty, "%% Invalid route type\n"); | |
16539 | return CMD_WARNING_CONFIG_FAILED; | |
16540 | } | |
16541 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 16542 | |
585f1adc IR |
16543 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16544 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
16545 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16546 | } |
16547 | ||
585f1adc IR |
16548 | DEFUN (bgp_redistribute_ipv6_rmap_metric, |
16549 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
70dd370f | 16550 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map RMAP_NAME metric (0-4294967295)", |
585f1adc IR |
16551 | "Redistribute information from another routing protocol\n" |
16552 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16553 | "Route map reference\n" | |
16554 | "Pointer to route-map entries\n" | |
16555 | "Metric for redistributed routes\n" | |
16556 | "Default metric\n") | |
718e3744 | 16557 | { |
585f1adc | 16558 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16559 | int idx_protocol = 1; |
16560 | int idx_word = 3; | |
16561 | int idx_number = 5; | |
585f1adc IR |
16562 | int type; |
16563 | uint32_t metric; | |
16564 | struct bgp_redist *red; | |
16565 | bool changed; | |
16566 | struct route_map *route_map = | |
16567 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16568 | ||
16569 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
16570 | if (type < 0) { | |
16571 | vty_out(vty, "%% Invalid route type\n"); | |
16572 | return CMD_WARNING_CONFIG_FAILED; | |
16573 | } | |
16574 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 16575 | |
585f1adc IR |
16576 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16577 | changed = | |
16578 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16579 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, | |
16580 | metric); | |
16581 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16582 | } |
16583 | ||
585f1adc IR |
16584 | DEFUN (bgp_redistribute_ipv6_metric_rmap, |
16585 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
70dd370f | 16586 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map RMAP_NAME", |
585f1adc IR |
16587 | "Redistribute information from another routing protocol\n" |
16588 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16589 | "Metric for redistributed routes\n" | |
16590 | "Default metric\n" | |
16591 | "Route map reference\n" | |
16592 | "Pointer to route-map entries\n") | |
718e3744 | 16593 | { |
585f1adc | 16594 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16595 | int idx_protocol = 1; |
37a87b8f | 16596 | int idx_number = 3; |
585f1adc IR |
16597 | int idx_word = 5; |
16598 | int type; | |
16599 | uint32_t metric; | |
16600 | struct bgp_redist *red; | |
16601 | bool changed; | |
16602 | struct route_map *route_map = | |
16603 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16604 | ||
16605 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
16606 | if (type < 0) { | |
16607 | vty_out(vty, "%% Invalid route type\n"); | |
16608 | return CMD_WARNING_CONFIG_FAILED; | |
16609 | } | |
16610 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 16611 | |
585f1adc IR |
16612 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16613 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, | |
16614 | metric); | |
16615 | changed |= | |
16616 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16617 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16618 | } |
16619 | ||
585f1adc IR |
16620 | DEFUN (no_bgp_redistribute_ipv6, |
16621 | no_bgp_redistribute_ipv6_cmd, | |
70dd370f | 16622 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map RMAP_NAME}]", |
585f1adc IR |
16623 | NO_STR |
16624 | "Redistribute information from another routing protocol\n" | |
16625 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16626 | "Metric for redistributed routes\n" | |
16627 | "Default metric\n" | |
16628 | "Route map reference\n" | |
16629 | "Pointer to route-map entries\n") | |
718e3744 | 16630 | { |
585f1adc | 16631 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16632 | int idx_protocol = 2; |
585f1adc | 16633 | int type; |
37a87b8f | 16634 | |
585f1adc IR |
16635 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
16636 | if (type < 0) { | |
16637 | vty_out(vty, "%% Invalid route type\n"); | |
16638 | return CMD_WARNING_CONFIG_FAILED; | |
16639 | } | |
718e3744 | 16640 | |
585f1adc | 16641 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
d62a17ae | 16642 | } |
16643 | ||
4ab46701 AR |
16644 | /* Neighbor update tcp-mss. */ |
16645 | static int peer_tcp_mss_vty(struct vty *vty, const char *peer_str, | |
16646 | const char *tcp_mss_str) | |
16647 | { | |
16648 | struct peer *peer; | |
16649 | uint32_t tcp_mss_val = 0; | |
16650 | ||
16651 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
16652 | if (!peer) | |
16653 | return CMD_WARNING_CONFIG_FAILED; | |
16654 | ||
16655 | if (tcp_mss_str) { | |
16656 | tcp_mss_val = strtoul(tcp_mss_str, NULL, 10); | |
16657 | peer_tcp_mss_set(peer, tcp_mss_val); | |
16658 | } else { | |
16659 | peer_tcp_mss_unset(peer); | |
16660 | } | |
16661 | ||
16662 | return CMD_SUCCESS; | |
16663 | } | |
16664 | ||
16665 | DEFUN(neighbor_tcp_mss, neighbor_tcp_mss_cmd, | |
16666 | "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)", | |
16667 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
16668 | "TCP max segment size\n" | |
16669 | "TCP MSS value\n") | |
16670 | { | |
16671 | int peer_index = 1; | |
16672 | int mss_index = 3; | |
16673 | ||
16674 | vty_out(vty, | |
16675 | " Warning: Reset BGP session for tcp-mss value to take effect\n"); | |
16676 | return peer_tcp_mss_vty(vty, argv[peer_index]->arg, | |
16677 | argv[mss_index]->arg); | |
16678 | } | |
16679 | ||
16680 | DEFUN(no_neighbor_tcp_mss, no_neighbor_tcp_mss_cmd, | |
16681 | "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]", | |
16682 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
16683 | "TCP max segment size\n" | |
16684 | "TCP MSS value\n") | |
16685 | { | |
16686 | int peer_index = 2; | |
16687 | ||
16688 | vty_out(vty, | |
16689 | " Warning: Reset BGP session for tcp-mss value to take effect\n"); | |
16690 | return peer_tcp_mss_vty(vty, argv[peer_index]->arg, NULL); | |
16691 | } | |
16692 | ||
a486300b PG |
16693 | DEFPY(bgp_retain_route_target, bgp_retain_route_target_cmd, |
16694 | "[no$no] bgp retain route-target all", | |
16695 | NO_STR BGP_STR | |
16696 | "Retain BGP updates\n" | |
16697 | "Retain BGP updates based on route-target values\n" | |
16698 | "Retain all BGP updates\n") | |
16699 | { | |
16700 | bool check; | |
16701 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
16702 | ||
16703 | check = CHECK_FLAG(bgp->af_flags[bgp_node_afi(vty)][bgp_node_safi(vty)], | |
16704 | BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL); | |
16705 | if (check != !no) { | |
16706 | if (!no) | |
16707 | SET_FLAG(bgp->af_flags[bgp_node_afi(vty)] | |
16708 | [bgp_node_safi(vty)], | |
16709 | BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL); | |
16710 | else | |
16711 | UNSET_FLAG(bgp->af_flags[bgp_node_afi(vty)] | |
16712 | [bgp_node_safi(vty)], | |
16713 | BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL); | |
16714 | /* trigger a flush to re-sync with ADJ-RIB-in */ | |
16715 | bgp_clear(vty, bgp, bgp_node_afi(vty), bgp_node_safi(vty), | |
16716 | clear_all, BGP_CLEAR_SOFT_IN, NULL); | |
16717 | } | |
16718 | return CMD_SUCCESS; | |
16719 | } | |
16720 | ||
dd65f45e DL |
16721 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
16722 | afi_t afi, safi_t safi) | |
d62a17ae | 16723 | { |
16724 | int i; | |
16725 | ||
16726 | /* Unicast redistribution only. */ | |
16727 | if (safi != SAFI_UNICAST) | |
2b791107 | 16728 | return; |
d62a17ae | 16729 | |
16730 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
16731 | /* Redistribute BGP does not make sense. */ | |
16732 | if (i != ZEBRA_ROUTE_BGP) { | |
16733 | struct list *red_list; | |
16734 | struct listnode *node; | |
16735 | struct bgp_redist *red; | |
16736 | ||
16737 | red_list = bgp->redist[afi][i]; | |
16738 | if (!red_list) | |
16739 | continue; | |
16740 | ||
16741 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 16742 | /* "redistribute" configuration. */ |
16743 | vty_out(vty, " redistribute %s", | |
16744 | zebra_route_string(i)); | |
16745 | if (red->instance) | |
16746 | vty_out(vty, " %d", red->instance); | |
16747 | if (red->redist_metric_flag) | |
16748 | vty_out(vty, " metric %u", | |
16749 | red->redist_metric); | |
16750 | if (red->rmap.name) | |
16751 | vty_out(vty, " route-map %s", | |
16752 | red->rmap.name); | |
16753 | vty_out(vty, "\n"); | |
16754 | } | |
16755 | } | |
16756 | } | |
718e3744 | 16757 | } |
6b0655a2 | 16758 | |
dd65f45e DL |
16759 | /* peer-group helpers for config-write */ |
16760 | ||
83194f39 | 16761 | static bool peergroup_flag_check(struct peer *peer, uint64_t flag) |
dd65f45e DL |
16762 | { |
16763 | if (!peer_group_active(peer)) { | |
16764 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
16765 | return !CHECK_FLAG(peer->flags, flag); | |
16766 | else | |
16767 | return !!CHECK_FLAG(peer->flags, flag); | |
16768 | } | |
16769 | ||
16770 | return !!CHECK_FLAG(peer->flags_override, flag); | |
16771 | } | |
16772 | ||
16773 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
da5e1a58 | 16774 | uint64_t flag) |
dd65f45e DL |
16775 | { |
16776 | if (!peer_group_active(peer)) { | |
16777 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
16778 | return !peer_af_flag_check(peer, afi, safi, flag); | |
16779 | else | |
16780 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
16781 | } | |
16782 | ||
16783 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
16784 | } | |
16785 | ||
16786 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
16787 | uint8_t type, int direct) | |
16788 | { | |
16789 | struct bgp_filter *filter; | |
16790 | ||
16791 | if (peer_group_active(peer)) | |
16792 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
16793 | type); | |
16794 | ||
16795 | filter = &peer->filter[afi][safi]; | |
16796 | switch (type) { | |
16797 | case PEER_FT_DISTRIBUTE_LIST: | |
16798 | return !!(filter->dlist[direct].name); | |
16799 | case PEER_FT_FILTER_LIST: | |
16800 | return !!(filter->aslist[direct].name); | |
16801 | case PEER_FT_PREFIX_LIST: | |
16802 | return !!(filter->plist[direct].name); | |
16803 | case PEER_FT_ROUTE_MAP: | |
16804 | return !!(filter->map[direct].name); | |
16805 | case PEER_FT_UNSUPPRESS_MAP: | |
16806 | return !!(filter->usmap.name); | |
7f7940e6 MK |
16807 | case PEER_FT_ADVERTISE_MAP: |
16808 | return !!(filter->advmap.aname | |
16809 | && ((filter->advmap.condition == direct) | |
16810 | && filter->advmap.cname)); | |
dd65f45e DL |
16811 | default: |
16812 | return false; | |
16813 | } | |
16814 | } | |
16815 | ||
16816 | /* Return true if the addpath type is set for peer and different from | |
16817 | * peer-group. | |
16818 | */ | |
3dc339cd DA |
16819 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, |
16820 | safi_t safi) | |
dd65f45e DL |
16821 | { |
16822 | enum bgp_addpath_strat type, g_type; | |
16823 | ||
16824 | type = peer->addpath_type[afi][safi]; | |
16825 | ||
16826 | if (type != BGP_ADDPATH_NONE) { | |
16827 | if (peer_group_active(peer)) { | |
16828 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
16829 | ||
16830 | if (type != g_type) | |
3dc339cd | 16831 | return true; |
dd65f45e | 16832 | else |
3dc339cd | 16833 | return false; |
dd65f45e DL |
16834 | } |
16835 | ||
3dc339cd | 16836 | return true; |
dd65f45e DL |
16837 | } |
16838 | ||
3dc339cd | 16839 | return false; |
dd65f45e DL |
16840 | } |
16841 | ||
b9c7bc5a | 16842 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 16843 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
16844 | afi_t afi) |
16845 | { | |
b9c7bc5a | 16846 | int indent = 2; |
53970de3 | 16847 | uint32_t tovpn_sid_index = 0; |
ddb5b488 | 16848 | |
8a066a70 | 16849 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
ae6a6fb4 DS |
16850 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
16851 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
8a066a70 PG |
16852 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", |
16853 | bgp->vpn_policy[afi] | |
bb4f6190 | 16854 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
16855 | else |
16856 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
16857 | bgp->vpn_policy[afi] | |
16858 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
16859 | } | |
12a844a5 DS |
16860 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
16861 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
16862 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
16863 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
16864 | return; | |
16865 | ||
e70e9f8e PZ |
16866 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
16867 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
16868 | ||
16869 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
16870 | ||
16871 | } else { | |
16872 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
16873 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
16874 | bgp->vpn_policy[afi].tovpn_label); | |
16875 | } | |
ddb5b488 | 16876 | } |
53970de3 RS |
16877 | |
16878 | tovpn_sid_index = bgp->vpn_policy[afi].tovpn_sid_index; | |
16879 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16880 | BGP_VPN_POLICY_TOVPN_SID_AUTO)) { | |
16881 | vty_out(vty, "%*ssid vpn export %s\n", indent, "", "auto"); | |
16882 | } else if (tovpn_sid_index != 0) { | |
16883 | vty_out(vty, "%*ssid vpn export %d\n", indent, "", | |
16884 | tovpn_sid_index); | |
16885 | } | |
16886 | ||
c4f64ea9 DA |
16887 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, BGP_VPN_POLICY_TOVPN_RD_SET)) |
16888 | vty_out(vty, "%*srd vpn export %pRD\n", indent, "", | |
16889 | &bgp->vpn_policy[afi].tovpn_rd); | |
16890 | ||
ddb5b488 PZ |
16891 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
16892 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
16893 | ||
16894 | char buf[PREFIX_STRLEN]; | |
16895 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
16896 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
16897 | sizeof(buf))) { | |
16898 | ||
b9c7bc5a PZ |
16899 | vty_out(vty, "%*snexthop vpn export %s\n", |
16900 | indent, "", buf); | |
ddb5b488 PZ |
16901 | } |
16902 | } | |
16903 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
16904 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
16905 | && ecommunity_cmp( | |
16906 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16907 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
16908 | ||
16909 | char *b = ecommunity_ecom2str( | |
16910 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16911 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16912 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
16913 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16914 | } else { | |
16915 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
16916 | char *b = ecommunity_ecom2str( | |
16917 | bgp->vpn_policy[afi] | |
16918 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16919 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16920 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16921 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
16922 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16923 | } | |
16924 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
16925 | char *b = ecommunity_ecom2str( | |
16926 | bgp->vpn_policy[afi] | |
16927 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16928 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16929 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16930 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
16931 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16932 | } | |
16933 | } | |
bb4f6190 DS |
16934 | |
16935 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 16936 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
16937 | bgp->vpn_policy[afi] |
16938 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 16939 | |
301ad80a PG |
16940 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
16941 | char *b = ecommunity_ecom2str( | |
16942 | bgp->vpn_policy[afi] | |
16943 | .import_redirect_rtlist, | |
16944 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16945 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 16946 | |
9a659715 PG |
16947 | if (bgp->vpn_policy[afi].import_redirect_rtlist->unit_size |
16948 | != ECOMMUNITY_SIZE) | |
c6423c31 | 16949 | vty_out(vty, "%*srt6 redirect import %s\n", |
9a659715 PG |
16950 | indent, "", b); |
16951 | else | |
16952 | vty_out(vty, "%*srt redirect import %s\n", | |
16953 | indent, "", b); | |
301ad80a PG |
16954 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16955 | } | |
ddb5b488 PZ |
16956 | } |
16957 | ||
dd65f45e DL |
16958 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
16959 | afi_t afi, safi_t safi) | |
16960 | { | |
16961 | struct bgp_filter *filter; | |
16962 | char *addr; | |
16963 | ||
16964 | addr = peer->host; | |
16965 | filter = &peer->filter[afi][safi]; | |
16966 | ||
16967 | /* distribute-list. */ | |
16968 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
16969 | FILTER_IN)) | |
16970 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
16971 | filter->dlist[FILTER_IN].name); | |
16972 | ||
16973 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
16974 | FILTER_OUT)) | |
16975 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
16976 | filter->dlist[FILTER_OUT].name); | |
16977 | ||
16978 | /* prefix-list. */ | |
16979 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
16980 | FILTER_IN)) | |
16981 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
16982 | filter->plist[FILTER_IN].name); | |
16983 | ||
16984 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
16985 | FILTER_OUT)) | |
16986 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
16987 | filter->plist[FILTER_OUT].name); | |
16988 | ||
16989 | /* route-map. */ | |
16990 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
16991 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
16992 | filter->map[RMAP_IN].name); | |
16993 | ||
16994 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
16995 | RMAP_OUT)) | |
16996 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
16997 | filter->map[RMAP_OUT].name); | |
16998 | ||
16999 | /* unsuppress-map */ | |
17000 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
17001 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
17002 | filter->usmap.name); | |
17003 | ||
7f7940e6 MK |
17004 | /* advertise-map : always applied in OUT direction*/ |
17005 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
17006 | CONDITION_NON_EXIST)) | |
17007 | vty_out(vty, | |
17008 | " neighbor %s advertise-map %s non-exist-map %s\n", | |
17009 | addr, filter->advmap.aname, filter->advmap.cname); | |
17010 | ||
17011 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
17012 | CONDITION_EXIST)) | |
17013 | vty_out(vty, " neighbor %s advertise-map %s exist-map %s\n", | |
17014 | addr, filter->advmap.aname, filter->advmap.cname); | |
17015 | ||
dd65f45e DL |
17016 | /* filter-list. */ |
17017 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
17018 | FILTER_IN)) | |
17019 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
17020 | filter->aslist[FILTER_IN].name); | |
17021 | ||
17022 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
17023 | FILTER_OUT)) | |
17024 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
17025 | filter->aslist[FILTER_OUT].name); | |
17026 | } | |
17027 | ||
17028 | /* BGP peer configuration display function. */ | |
17029 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
17030 | struct peer *peer) | |
17031 | { | |
17032 | struct peer *g_peer = NULL; | |
dd65f45e DL |
17033 | char *addr; |
17034 | int if_pg_printed = false; | |
17035 | int if_ras_printed = false; | |
17036 | ||
17037 | /* Skip dynamic neighbors. */ | |
17038 | if (peer_dynamic_neighbor(peer)) | |
17039 | return; | |
17040 | ||
17041 | if (peer->conf_if) | |
17042 | addr = peer->conf_if; | |
17043 | else | |
17044 | addr = peer->host; | |
17045 | ||
17046 | /************************************ | |
17047 | ****** Global to the neighbor ****** | |
17048 | ************************************/ | |
17049 | if (peer->conf_if) { | |
17050 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
17051 | vty_out(vty, " neighbor %s interface v6only", addr); | |
17052 | else | |
17053 | vty_out(vty, " neighbor %s interface", addr); | |
17054 | ||
17055 | if (peer_group_active(peer)) { | |
17056 | vty_out(vty, " peer-group %s", peer->group->name); | |
17057 | if_pg_printed = true; | |
17058 | } else if (peer->as_type == AS_SPECIFIED) { | |
17059 | vty_out(vty, " remote-as %u", peer->as); | |
17060 | if_ras_printed = true; | |
17061 | } else if (peer->as_type == AS_INTERNAL) { | |
17062 | vty_out(vty, " remote-as internal"); | |
17063 | if_ras_printed = true; | |
17064 | } else if (peer->as_type == AS_EXTERNAL) { | |
17065 | vty_out(vty, " remote-as external"); | |
17066 | if_ras_printed = true; | |
17067 | } | |
17068 | ||
17069 | vty_out(vty, "\n"); | |
17070 | } | |
17071 | ||
17072 | /* remote-as and peer-group */ | |
17073 | /* peer is a member of a peer-group */ | |
17074 | if (peer_group_active(peer)) { | |
17075 | g_peer = peer->group->conf; | |
17076 | ||
17077 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
17078 | if (peer->as_type == AS_SPECIFIED) { | |
17079 | vty_out(vty, " neighbor %s remote-as %u\n", | |
17080 | addr, peer->as); | |
17081 | } else if (peer->as_type == AS_INTERNAL) { | |
17082 | vty_out(vty, | |
17083 | " neighbor %s remote-as internal\n", | |
17084 | addr); | |
17085 | } else if (peer->as_type == AS_EXTERNAL) { | |
17086 | vty_out(vty, | |
17087 | " neighbor %s remote-as external\n", | |
17088 | addr); | |
17089 | } | |
17090 | } | |
17091 | ||
17092 | /* For swpX peers we displayed the peer-group | |
17093 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
17094 | if (!if_pg_printed) | |
17095 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
17096 | peer->group->name); | |
17097 | } | |
17098 | ||
17099 | /* peer is NOT a member of a peer-group */ | |
17100 | else { | |
17101 | /* peer is a peer-group, declare the peer-group */ | |
17102 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
17103 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
17104 | } | |
17105 | ||
17106 | if (!if_ras_printed) { | |
17107 | if (peer->as_type == AS_SPECIFIED) { | |
17108 | vty_out(vty, " neighbor %s remote-as %u\n", | |
17109 | addr, peer->as); | |
17110 | } else if (peer->as_type == AS_INTERNAL) { | |
17111 | vty_out(vty, | |
17112 | " neighbor %s remote-as internal\n", | |
17113 | addr); | |
17114 | } else if (peer->as_type == AS_EXTERNAL) { | |
17115 | vty_out(vty, | |
17116 | " neighbor %s remote-as external\n", | |
17117 | addr); | |
17118 | } | |
17119 | } | |
17120 | } | |
17121 | ||
17122 | /* local-as */ | |
17123 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
17124 | vty_out(vty, " neighbor %s local-as %u", addr, | |
17125 | peer->change_local_as); | |
17126 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
17127 | vty_out(vty, " no-prepend"); | |
17128 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
17129 | vty_out(vty, " replace-as"); | |
17130 | vty_out(vty, "\n"); | |
17131 | } | |
17132 | ||
17133 | /* description */ | |
17134 | if (peer->desc) { | |
17135 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
17136 | } | |
17137 | ||
17138 | /* shutdown */ | |
17139 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
17140 | if (peer->tx_shutdown_message) | |
17141 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
17142 | peer->tx_shutdown_message); | |
17143 | else | |
17144 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
17145 | } | |
17146 | ||
8336c896 DA |
17147 | if (peergroup_flag_check(peer, PEER_FLAG_RTT_SHUTDOWN)) |
17148 | vty_out(vty, " neighbor %s shutdown rtt %u count %u\n", addr, | |
17149 | peer->rtt_expected, peer->rtt_keepalive_conf); | |
17150 | ||
dd65f45e | 17151 | /* bfd */ |
21bfce98 RZ |
17152 | if (peer->bfd_config) |
17153 | bgp_bfd_peer_config_write(vty, peer, addr); | |
dd65f45e DL |
17154 | |
17155 | /* password */ | |
17156 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
17157 | vty_out(vty, " neighbor %s password %s\n", addr, | |
17158 | peer->password); | |
17159 | ||
17160 | /* neighbor solo */ | |
17161 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
17162 | if (!peer_group_active(peer)) { | |
17163 | vty_out(vty, " neighbor %s solo\n", addr); | |
17164 | } | |
17165 | } | |
17166 | ||
17167 | /* BGP port */ | |
17168 | if (peer->port != BGP_PORT_DEFAULT) { | |
17169 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
17170 | } | |
17171 | ||
17172 | /* Local interface name */ | |
17173 | if (peer->ifname) { | |
17174 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
17175 | } | |
17176 | ||
4ab46701 AR |
17177 | /* TCP max segment size */ |
17178 | if (CHECK_FLAG(peer->flags, PEER_FLAG_TCP_MSS)) | |
17179 | vty_out(vty, " neighbor %s tcp-mss %d\n", addr, peer->tcp_mss); | |
17180 | ||
dd65f45e DL |
17181 | /* passive */ |
17182 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
17183 | vty_out(vty, " neighbor %s passive\n", addr); | |
17184 | ||
17185 | /* ebgp-multihop */ | |
17186 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
17187 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
17188 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
17189 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
17190 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
17191 | peer->ttl); | |
17192 | } | |
17193 | } | |
17194 | ||
97a52c82 DA |
17195 | /* aigp */ |
17196 | if (peergroup_flag_check(peer, PEER_FLAG_AIGP)) | |
17197 | vty_out(vty, " neighbor %s aigp\n", addr); | |
17198 | ||
d864dd9e | 17199 | /* role */ |
7dddd1f7 DA |
17200 | if (peergroup_flag_check(peer, PEER_FLAG_ROLE) && |
17201 | peer->local_role != ROLE_UNDEFINED) | |
d864dd9e | 17202 | vty_out(vty, " neighbor %s local-role %s%s\n", addr, |
8f2d6021 | 17203 | bgp_get_name_by_role(peer->local_role), |
7dddd1f7 | 17204 | CHECK_FLAG(peer->flags, PEER_FLAG_ROLE_STRICT_MODE) |
d864dd9e EB |
17205 | ? " strict-mode" |
17206 | : ""); | |
d864dd9e | 17207 | |
dd65f45e | 17208 | /* ttl-security hops */ |
e2521429 | 17209 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
17210 | if (!peer_group_active(peer) |
17211 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
17212 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
17213 | addr, peer->gtsm_hops); | |
17214 | } | |
17215 | } | |
17216 | ||
17217 | /* disable-connected-check */ | |
17218 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
17219 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
17220 | ||
27aa23a4 DA |
17221 | /* link-bw-encoding-ieee */ |
17222 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE)) | |
17223 | vty_out(vty, " neighbor %s disable-link-bw-encoding-ieee\n", | |
17224 | addr); | |
17225 | ||
d08c0c80 DA |
17226 | /* extended-optional-parameters */ |
17227 | if (peergroup_flag_check(peer, PEER_FLAG_EXTENDED_OPT_PARAMS)) | |
17228 | vty_out(vty, " neighbor %s extended-optional-parameters\n", | |
17229 | addr); | |
17230 | ||
dd65f45e DL |
17231 | /* enforce-first-as */ |
17232 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
17233 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
17234 | ||
17235 | /* update-source */ | |
17236 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
17237 | if (peer->update_source) | |
47e12884 DA |
17238 | vty_out(vty, " neighbor %s update-source %pSU\n", addr, |
17239 | peer->update_source); | |
dd65f45e DL |
17240 | else if (peer->update_if) |
17241 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
17242 | peer->update_if); | |
17243 | } | |
17244 | ||
17245 | /* advertisement-interval */ | |
17246 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
17247 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
17248 | peer->routeadv); | |
17249 | ||
17250 | /* timers */ | |
17251 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
17252 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
17253 | peer->keepalive, peer->holdtime); | |
17254 | ||
17255 | /* timers connect */ | |
17256 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
17257 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
17258 | peer->connect); | |
5d5393b9 DL |
17259 | /* need special-case handling for changed default values due to |
17260 | * config profile / version (because there is no "timers bgp connect" | |
17261 | * command, we need to save this per-peer :/) | |
17262 | */ | |
17263 | else if (!peer_group_active(peer) && !peer->connect && | |
17264 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
17265 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
17266 | peer->bgp->default_connect_retry); | |
dd65f45e | 17267 | |
d43114f3 DS |
17268 | /* timers delayopen */ |
17269 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_DELAYOPEN)) | |
17270 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
17271 | peer->delayopen); | |
17272 | /* Save config even though flag is not set if default values have been | |
17273 | * changed | |
17274 | */ | |
17275 | else if (!peer_group_active(peer) && !peer->delayopen | |
17276 | && peer->bgp->default_delayopen != BGP_DEFAULT_DELAYOPEN) | |
17277 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
17278 | peer->bgp->default_delayopen); | |
17279 | ||
dd65f45e DL |
17280 | /* capability dynamic */ |
17281 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
17282 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
17283 | ||
17284 | /* capability extended-nexthop */ | |
17285 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
8e89adc1 DS |
17286 | if (CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE) && |
17287 | !peer->conf_if) | |
843770f6 DA |
17288 | vty_out(vty, |
17289 | " no neighbor %s capability extended-nexthop\n", | |
17290 | addr); | |
17291 | else if (!peer->conf_if) | |
17292 | vty_out(vty, | |
17293 | " neighbor %s capability extended-nexthop\n", | |
17294 | addr); | |
dd65f45e DL |
17295 | } |
17296 | ||
17297 | /* dont-capability-negotiation */ | |
17298 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
17299 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
17300 | ||
17301 | /* override-capability */ | |
17302 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
17303 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
17304 | ||
17305 | /* strict-capability-match */ | |
17306 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
17307 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
17308 | ||
17309 | /* Sender side AS path loop detection. */ | |
17310 | if (peer->as_path_loop_detection) | |
17311 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
17312 | addr); | |
cfd47646 | 17313 | |
17314 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 17315 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 17316 | |
17317 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 17318 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 17319 | vty_out(vty, |
17320 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
17321 | } else if (CHECK_FLAG( |
17322 | peer->peer_gr_new_status_flag, | |
17323 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 17324 | vty_out(vty, |
17325 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
17326 | } else if ( |
17327 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
17328 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
17329 | && !(CHECK_FLAG( | |
17330 | peer->peer_gr_new_status_flag, | |
17331 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
17332 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
17333 | addr); | |
cfd47646 | 17334 | } |
17335 | } | |
dd65f45e DL |
17336 | } |
17337 | ||
17338 | /* BGP peer configuration display function. */ | |
17339 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
17340 | struct peer *peer, afi_t afi, safi_t safi) | |
17341 | { | |
17342 | struct peer *g_peer = NULL; | |
17343 | char *addr; | |
17344 | bool flag_scomm, flag_secomm, flag_slcomm; | |
17345 | ||
17346 | /* Skip dynamic neighbors. */ | |
17347 | if (peer_dynamic_neighbor(peer)) | |
17348 | return; | |
17349 | ||
17350 | if (peer->conf_if) | |
17351 | addr = peer->conf_if; | |
17352 | else | |
17353 | addr = peer->host; | |
17354 | ||
17355 | /************************************ | |
17356 | ****** Per AF to the neighbor ****** | |
17357 | ************************************/ | |
17358 | if (peer_group_active(peer)) { | |
17359 | g_peer = peer->group->conf; | |
17360 | ||
17361 | /* If the peer-group is active but peer is not, print a 'no | |
17362 | * activate' */ | |
17363 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
17364 | vty_out(vty, " no neighbor %s activate\n", addr); | |
17365 | } | |
17366 | ||
17367 | /* If the peer-group is not active but peer is, print an | |
17368 | 'activate' */ | |
17369 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
17370 | vty_out(vty, " neighbor %s activate\n", addr); | |
17371 | } | |
17372 | } else { | |
17373 | if (peer->afc[afi][safi]) { | |
38d11af5 TA |
17374 | if (safi == SAFI_ENCAP) |
17375 | vty_out(vty, " neighbor %s activate\n", addr); | |
17376 | else if (!bgp->default_af[afi][safi]) | |
dd65f45e DL |
17377 | vty_out(vty, " neighbor %s activate\n", addr); |
17378 | } else { | |
38d11af5 TA |
17379 | if (bgp->default_af[afi][safi]) |
17380 | vty_out(vty, " no neighbor %s activate\n", | |
17381 | addr); | |
dd65f45e DL |
17382 | } |
17383 | } | |
17384 | ||
17385 | /* addpath TX knobs */ | |
17386 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
17387 | switch (peer->addpath_type[afi][safi]) { | |
17388 | case BGP_ADDPATH_ALL: | |
17389 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
17390 | addr); | |
17391 | break; | |
17392 | case BGP_ADDPATH_BEST_PER_AS: | |
17393 | vty_out(vty, | |
17394 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
17395 | addr); | |
17396 | break; | |
17397 | case BGP_ADDPATH_MAX: | |
17398 | case BGP_ADDPATH_NONE: | |
17399 | break; | |
17400 | } | |
17401 | } | |
17402 | ||
7c0e4312 DA |
17403 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_DISABLE_ADDPATH_RX)) |
17404 | vty_out(vty, " neighbor %s disable-addpath-rx\n", addr); | |
17405 | ||
dd65f45e DL |
17406 | /* ORF capability. */ |
17407 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
17408 | || peergroup_af_flag_check(peer, afi, safi, | |
17409 | PEER_FLAG_ORF_PREFIX_RM)) { | |
17410 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
17411 | ||
17412 | if (peergroup_af_flag_check(peer, afi, safi, | |
17413 | PEER_FLAG_ORF_PREFIX_SM) | |
17414 | && peergroup_af_flag_check(peer, afi, safi, | |
17415 | PEER_FLAG_ORF_PREFIX_RM)) | |
17416 | vty_out(vty, " both"); | |
17417 | else if (peergroup_af_flag_check(peer, afi, safi, | |
17418 | PEER_FLAG_ORF_PREFIX_SM)) | |
17419 | vty_out(vty, " send"); | |
17420 | else | |
17421 | vty_out(vty, " receive"); | |
17422 | vty_out(vty, "\n"); | |
17423 | } | |
17424 | ||
dd65f45e DL |
17425 | /* Route reflector client. */ |
17426 | if (peergroup_af_flag_check(peer, afi, safi, | |
17427 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
17428 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
17429 | } | |
17430 | ||
17431 | /* next-hop-self force */ | |
17432 | if (peergroup_af_flag_check(peer, afi, safi, | |
17433 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
17434 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
17435 | } | |
17436 | ||
17437 | /* next-hop-self */ | |
17438 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
17439 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
17440 | } | |
17441 | ||
17442 | /* remove-private-AS */ | |
17443 | if (peergroup_af_flag_check(peer, afi, safi, | |
17444 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
17445 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
17446 | addr); | |
17447 | } | |
17448 | ||
17449 | else if (peergroup_af_flag_check(peer, afi, safi, | |
17450 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
17451 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
17452 | addr); | |
17453 | } | |
17454 | ||
17455 | else if (peergroup_af_flag_check(peer, afi, safi, | |
17456 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
17457 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
17458 | } | |
17459 | ||
17460 | else if (peergroup_af_flag_check(peer, afi, safi, | |
17461 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
17462 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
17463 | } | |
17464 | ||
17465 | /* as-override */ | |
17466 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
17467 | vty_out(vty, " neighbor %s as-override\n", addr); | |
17468 | } | |
17469 | ||
17470 | /* send-community print. */ | |
17471 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
17472 | PEER_FLAG_SEND_COMMUNITY); | |
17473 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
17474 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
17475 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
17476 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
17477 | ||
17478 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
17479 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
17480 | } else { | |
17481 | if (flag_scomm) | |
17482 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
17483 | if (flag_secomm) | |
17484 | vty_out(vty, | |
17485 | " no neighbor %s send-community extended\n", | |
17486 | addr); | |
17487 | ||
17488 | if (flag_slcomm) | |
17489 | vty_out(vty, " no neighbor %s send-community large\n", | |
17490 | addr); | |
17491 | } | |
17492 | ||
17493 | /* Default information */ | |
17494 | if (peergroup_af_flag_check(peer, afi, safi, | |
17495 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
17496 | vty_out(vty, " neighbor %s default-originate", addr); | |
17497 | ||
17498 | if (peer->default_rmap[afi][safi].name) | |
17499 | vty_out(vty, " route-map %s", | |
17500 | peer->default_rmap[afi][safi].name); | |
17501 | ||
17502 | vty_out(vty, "\n"); | |
17503 | } | |
17504 | ||
17505 | /* Soft reconfiguration inbound. */ | |
17506 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
17507 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
17508 | addr); | |
17509 | } | |
17510 | ||
17511 | /* maximum-prefix. */ | |
17512 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
6cde4b45 | 17513 | vty_out(vty, " neighbor %s maximum-prefix %u", addr, |
dd65f45e DL |
17514 | peer->pmax[afi][safi]); |
17515 | ||
17516 | if (peer->pmax_threshold[afi][safi] | |
17517 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
17518 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
17519 | if (peer_af_flag_check(peer, afi, safi, | |
17520 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
17521 | vty_out(vty, " warning-only"); | |
17522 | if (peer->pmax_restart[afi][safi]) | |
17523 | vty_out(vty, " restart %u", | |
17524 | peer->pmax_restart[afi][safi]); | |
9cbd06e0 DA |
17525 | if (peer_af_flag_check(peer, afi, safi, |
17526 | PEER_FLAG_MAX_PREFIX_FORCE)) | |
17527 | vty_out(vty, " force"); | |
dd65f45e DL |
17528 | |
17529 | vty_out(vty, "\n"); | |
17530 | } | |
17531 | ||
fde246e8 DA |
17532 | /* maximum-prefix-out */ |
17533 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
6cde4b45 | 17534 | vty_out(vty, " neighbor %s maximum-prefix-out %u\n", |
fde246e8 DA |
17535 | addr, peer->pmax_out[afi][safi]); |
17536 | ||
dd65f45e DL |
17537 | /* Route server client. */ |
17538 | if (peergroup_af_flag_check(peer, afi, safi, | |
17539 | PEER_FLAG_RSERVER_CLIENT)) { | |
17540 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
17541 | } | |
17542 | ||
17543 | /* Nexthop-local unchanged. */ | |
17544 | if (peergroup_af_flag_check(peer, afi, safi, | |
17545 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
17546 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
17547 | } | |
17548 | ||
17549 | /* allowas-in <1-10> */ | |
17550 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
17551 | if (peer_af_flag_check(peer, afi, safi, | |
17552 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
17553 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
17554 | } else if (peer->allowas_in[afi][safi] == 3) { | |
17555 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
17556 | } else { | |
17557 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
17558 | peer->allowas_in[afi][safi]); | |
17559 | } | |
17560 | } | |
17561 | ||
46dbf9d0 DA |
17562 | /* accept-own */ |
17563 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ACCEPT_OWN)) | |
17564 | vty_out(vty, " neighbor %s accept-own\n", addr); | |
17565 | ||
01da2d26 DA |
17566 | /* soo */ |
17567 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOO)) { | |
17568 | char *soo_str = ecommunity_ecom2str( | |
17569 | peer->soo[afi][safi], ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
17570 | ||
17571 | vty_out(vty, " neighbor %s soo %s\n", addr, soo_str); | |
17572 | XFREE(MTYPE_ECOMMUNITY_STR, soo_str); | |
17573 | } | |
17574 | ||
dd65f45e DL |
17575 | /* weight */ |
17576 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
17577 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
17578 | peer->weight[afi][safi]); | |
17579 | ||
17580 | /* Filter. */ | |
17581 | bgp_config_write_filter(vty, peer, afi, safi); | |
17582 | ||
17583 | /* atribute-unchanged. */ | |
17584 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
17585 | || (safi != SAFI_EVPN | |
17586 | && peer_af_flag_check(peer, afi, safi, | |
17587 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
17588 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
17589 | ||
17590 | if (!peer_group_active(peer) | |
17591 | || peergroup_af_flag_check(peer, afi, safi, | |
17592 | PEER_FLAG_AS_PATH_UNCHANGED) | |
17593 | || peergroup_af_flag_check(peer, afi, safi, | |
17594 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
17595 | || peergroup_af_flag_check(peer, afi, safi, | |
17596 | PEER_FLAG_MED_UNCHANGED)) { | |
17597 | ||
17598 | vty_out(vty, | |
17599 | " neighbor %s attribute-unchanged%s%s%s\n", | |
17600 | addr, | |
17601 | peer_af_flag_check(peer, afi, safi, | |
17602 | PEER_FLAG_AS_PATH_UNCHANGED) | |
17603 | ? " as-path" | |
17604 | : "", | |
17605 | peer_af_flag_check(peer, afi, safi, | |
17606 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
17607 | ? " next-hop" | |
17608 | : "", | |
17609 | peer_af_flag_check(peer, afi, safi, | |
17610 | PEER_FLAG_MED_UNCHANGED) | |
17611 | ? " med" | |
17612 | : ""); | |
17613 | } | |
17614 | } | |
70cd87ca MK |
17615 | |
17616 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_ORR_GROUP)) | |
17617 | vty_out(vty, " neighbor %s optimal-route-reflection %s\n", | |
5fcf01c9 | 17618 | addr, peer->orr_group_name[afi][safi]); |
dd65f45e DL |
17619 | } |
17620 | ||
a486300b PG |
17621 | static void bgp_vpn_config_write(struct vty *vty, struct bgp *bgp, afi_t afi, |
17622 | safi_t safi) | |
17623 | { | |
17624 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
17625 | BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL)) | |
17626 | vty_out(vty, " no bgp retain route-target all\n"); | |
17627 | } | |
17628 | ||
dd65f45e DL |
17629 | /* Address family based peer configuration display. */ |
17630 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
17631 | safi_t safi) | |
17632 | { | |
17633 | struct peer *peer; | |
17634 | struct peer_group *group; | |
17635 | struct listnode *node, *nnode; | |
17636 | ||
17637 | ||
17638 | vty_frame(vty, " !\n address-family "); | |
17639 | if (afi == AFI_IP) { | |
17640 | if (safi == SAFI_UNICAST) | |
17641 | vty_frame(vty, "ipv4 unicast"); | |
17642 | else if (safi == SAFI_LABELED_UNICAST) | |
17643 | vty_frame(vty, "ipv4 labeled-unicast"); | |
17644 | else if (safi == SAFI_MULTICAST) | |
17645 | vty_frame(vty, "ipv4 multicast"); | |
17646 | else if (safi == SAFI_MPLS_VPN) | |
17647 | vty_frame(vty, "ipv4 vpn"); | |
17648 | else if (safi == SAFI_ENCAP) | |
17649 | vty_frame(vty, "ipv4 encap"); | |
17650 | else if (safi == SAFI_FLOWSPEC) | |
17651 | vty_frame(vty, "ipv4 flowspec"); | |
17652 | } else if (afi == AFI_IP6) { | |
17653 | if (safi == SAFI_UNICAST) | |
17654 | vty_frame(vty, "ipv6 unicast"); | |
17655 | else if (safi == SAFI_LABELED_UNICAST) | |
17656 | vty_frame(vty, "ipv6 labeled-unicast"); | |
17657 | else if (safi == SAFI_MULTICAST) | |
17658 | vty_frame(vty, "ipv6 multicast"); | |
17659 | else if (safi == SAFI_MPLS_VPN) | |
17660 | vty_frame(vty, "ipv6 vpn"); | |
17661 | else if (safi == SAFI_ENCAP) | |
17662 | vty_frame(vty, "ipv6 encap"); | |
17663 | else if (safi == SAFI_FLOWSPEC) | |
17664 | vty_frame(vty, "ipv6 flowspec"); | |
17665 | } else if (afi == AFI_L2VPN) { | |
17666 | if (safi == SAFI_EVPN) | |
17667 | vty_frame(vty, "l2vpn evpn"); | |
17668 | } | |
17669 | vty_frame(vty, "\n"); | |
17670 | ||
17671 | bgp_config_write_distance(vty, bgp, afi, safi); | |
17672 | ||
17673 | bgp_config_write_network(vty, bgp, afi, safi); | |
17674 | ||
17675 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
17676 | ||
8a4e7fe6 DA |
17677 | /* BGP flag dampening. */ |
17678 | if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
6c75f4b3 | 17679 | bgp_config_write_damp(vty, afi, safi); |
8a4e7fe6 | 17680 | |
dd65f45e DL |
17681 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) |
17682 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
17683 | ||
17684 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dd65f45e DL |
17685 | /* Do not display doppelganger peers */ |
17686 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
17687 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
17688 | } | |
17689 | ||
17690 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
17691 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
17692 | ||
17693 | if (safi == SAFI_EVPN) | |
17694 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
17695 | ||
17696 | if (safi == SAFI_FLOWSPEC) | |
17697 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
17698 | ||
a486300b PG |
17699 | if (safi == SAFI_MPLS_VPN) |
17700 | bgp_vpn_config_write(vty, bgp, afi, safi); | |
17701 | ||
dd65f45e DL |
17702 | if (safi == SAFI_UNICAST) { |
17703 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
17704 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17705 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
17706 | ||
17707 | vty_out(vty, " export vpn\n"); | |
17708 | } | |
17709 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17710 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
17711 | ||
17712 | vty_out(vty, " import vpn\n"); | |
17713 | } | |
17714 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17715 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
17716 | char *name; | |
17717 | ||
17718 | for (ALL_LIST_ELEMENTS_RO( | |
17719 | bgp->vpn_policy[afi].import_vrf, node, | |
17720 | name)) | |
17721 | vty_out(vty, " import vrf %s\n", name); | |
17722 | } | |
17723 | } | |
17724 | ||
70cd87ca MK |
17725 | /* Optimal Route Reflection */ |
17726 | bgp_config_write_orr(vty, bgp, afi, safi); | |
17727 | ||
dd65f45e DL |
17728 | vty_endframe(vty, " exit-address-family\n"); |
17729 | } | |
17730 | ||
17731 | int bgp_config_write(struct vty *vty) | |
17732 | { | |
17733 | struct bgp *bgp; | |
17734 | struct peer_group *group; | |
17735 | struct peer *peer; | |
17736 | struct listnode *node, *nnode; | |
17737 | struct listnode *mnode, *mnnode; | |
b16bcbba TA |
17738 | afi_t afi; |
17739 | safi_t safi; | |
efc9b57d | 17740 | uint32_t tovpn_sid_index = 0; |
dd65f45e DL |
17741 | |
17742 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
17743 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
17744 | bm->rmap_update_timer); | |
17745 | ||
d70583f7 D |
17746 | if (bm->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
17747 | vty_out(vty, "bgp update-delay %d", bm->v_update_delay); | |
17748 | if (bm->v_update_delay != bm->v_establish_wait) | |
17749 | vty_out(vty, " %d", bm->v_establish_wait); | |
17750 | vty_out(vty, "\n"); | |
17751 | } | |
17752 | ||
9acb67cb DS |
17753 | if (bm->wait_for_fib) |
17754 | vty_out(vty, "bgp suppress-fib-pending\n"); | |
17755 | ||
05bd726c | 17756 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) |
17757 | vty_out(vty, "bgp graceful-shutdown\n"); | |
17758 | ||
c163f297 DS |
17759 | /* No-RIB (Zebra) option flag configuration */ |
17760 | if (bgp_option_check(BGP_OPT_NO_FIB)) | |
17761 | vty_out(vty, "bgp no-rib\n"); | |
17762 | ||
870791a3 IR |
17763 | if (CHECK_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA)) |
17764 | vty_out(vty, "bgp send-extra-data zebra\n"); | |
e46723a5 | 17765 | |
425bd64b PS |
17766 | /* BGP session DSCP value */ |
17767 | if (bm->tcp_dscp != IPTOS_PREC_INTERNETCONTROL) | |
17768 | vty_out(vty, "bgp session-dscp %u\n", bm->tcp_dscp >> 2); | |
17769 | ||
a0b937de SW |
17770 | /* BGP InQ limit */ |
17771 | if (bm->inq_limit != BM_DEFAULT_INQ_LIMIT) | |
17772 | vty_out(vty, "bgp input-queue-limit %u\n", bm->inq_limit); | |
17773 | ||
dd65f45e DL |
17774 | /* BGP configuration. */ |
17775 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
17776 | ||
17777 | /* skip all auto created vrf as they dont have user config */ | |
17778 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
17779 | continue; | |
17780 | ||
17781 | /* Router bgp ASN */ | |
17782 | vty_out(vty, "router bgp %u", bgp->as); | |
17783 | ||
17784 | if (bgp->name) | |
17785 | vty_out(vty, " %s %s", | |
17786 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
17787 | ? "view" : "vrf", bgp->name); | |
17788 | vty_out(vty, "\n"); | |
17789 | ||
17790 | /* BGP fast-external-failover. */ | |
17791 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
17792 | vty_out(vty, " no bgp fast-external-failover\n"); | |
17793 | ||
17794 | /* BGP router ID. */ | |
3a6290bd | 17795 | if (bgp->router_id_static.s_addr != INADDR_ANY) |
23d0a753 DA |
17796 | vty_out(vty, " bgp router-id %pI4\n", |
17797 | &bgp->router_id_static); | |
dd65f45e | 17798 | |
c208c586 S |
17799 | /* Suppress fib pending */ |
17800 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_FIB_PENDING)) | |
17801 | vty_out(vty, " bgp suppress-fib-pending\n"); | |
17802 | ||
dd65f45e | 17803 | /* BGP log-neighbor-changes. */ |
892fedb6 | 17804 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 17805 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 17806 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
17807 | CHECK_FLAG(bgp->flags, |
17808 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
17809 | ? "" |
17810 | : "no "); | |
17811 | ||
17812 | /* BGP configuration. */ | |
892fedb6 | 17813 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
17814 | vty_out(vty, " bgp always-compare-med\n"); |
17815 | ||
17816 | /* RFC8212 default eBGP policy. */ | |
1d3fdccf DA |
17817 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
17818 | != SAVE_BGP_EBGP_REQUIRES_POLICY) | |
17819 | vty_out(vty, " %sbgp ebgp-requires-policy\n", | |
17820 | CHECK_FLAG(bgp->flags, | |
17821 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
17822 | ? "" | |
17823 | : "no "); | |
dd65f45e DL |
17824 | |
17825 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
7f972cd8 | 17826 | if (bgp->reject_as_sets) |
dd65f45e DL |
17827 | vty_out(vty, " bgp reject-as-sets\n"); |
17828 | ||
2adac256 DA |
17829 | /* Suppress duplicate updates if the route actually not changed |
17830 | */ | |
17831 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES) | |
17832 | != SAVE_BGP_SUPPRESS_DUPLICATES) | |
17833 | vty_out(vty, " %sbgp suppress-duplicates\n", | |
17834 | CHECK_FLAG(bgp->flags, | |
17835 | BGP_FLAG_SUPPRESS_DUPLICATES) | |
17836 | ? "" | |
17837 | : "no "); | |
17838 | ||
1ae314be DA |
17839 | /* Send Hard Reset CEASE Notification for 'Administrative Reset' |
17840 | */ | |
17841 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_HARD_ADMIN_RESET) != | |
17842 | SAVE_BGP_HARD_ADMIN_RESET) | |
17843 | vty_out(vty, " %sbgp hard-administrative-reset\n", | |
17844 | CHECK_FLAG(bgp->flags, | |
17845 | BGP_FLAG_HARD_ADMIN_RESET) | |
17846 | ? "" | |
17847 | : "no "); | |
17848 | ||
b16bcbba TA |
17849 | /* BGP default <afi>-<safi> */ |
17850 | FOREACH_AFI_SAFI (afi, safi) { | |
17851 | if (afi == AFI_IP && safi == SAFI_UNICAST) { | |
17852 | if (!bgp->default_af[afi][safi]) | |
17853 | vty_out(vty, " no bgp default %s\n", | |
17854 | get_bgp_default_af_flag(afi, | |
17855 | safi)); | |
17856 | } else if (bgp->default_af[afi][safi]) | |
17857 | vty_out(vty, " bgp default %s\n", | |
17858 | get_bgp_default_af_flag(afi, safi)); | |
17859 | } | |
e84c59af | 17860 | |
dd65f45e DL |
17861 | /* BGP default local-preference. */ |
17862 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
17863 | vty_out(vty, " bgp default local-preference %u\n", | |
17864 | bgp->default_local_pref); | |
17865 | ||
17866 | /* BGP default show-hostname */ | |
892fedb6 | 17867 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 17868 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 17869 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 17870 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
17871 | ? "" |
17872 | : "no "); | |
17873 | ||
aef999a2 DA |
17874 | /* BGP default show-nexthop-hostname */ |
17875 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
17876 | != SAVE_BGP_SHOW_HOSTNAME) | |
17877 | vty_out(vty, " %sbgp default show-nexthop-hostname\n", | |
17878 | CHECK_FLAG(bgp->flags, | |
17879 | BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
17880 | ? "" | |
17881 | : "no "); | |
17882 | ||
dd65f45e DL |
17883 | /* BGP default subgroup-pkt-queue-max. */ |
17884 | if (bgp->default_subgroup_pkt_queue_max | |
17885 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
17886 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
17887 | bgp->default_subgroup_pkt_queue_max); | |
17888 | ||
17889 | /* BGP client-to-client reflection. */ | |
892fedb6 | 17890 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
17891 | vty_out(vty, " no bgp client-to-client reflection\n"); |
17892 | ||
17893 | /* BGP cluster ID. */ | |
17894 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
23d0a753 DA |
17895 | vty_out(vty, " bgp cluster-id %pI4\n", |
17896 | &bgp->cluster_id); | |
dd65f45e DL |
17897 | |
17898 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 17899 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
17900 | vty_out(vty, |
17901 | " bgp disable-ebgp-connected-route-check\n"); | |
17902 | ||
17903 | /* Confederation identifier*/ | |
17904 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
17905 | vty_out(vty, " bgp confederation identifier %u\n", | |
17906 | bgp->confed_id); | |
17907 | ||
17908 | /* Confederation peer */ | |
17909 | if (bgp->confed_peers_cnt > 0) { | |
17910 | int i; | |
17911 | ||
17912 | vty_out(vty, " bgp confederation peers"); | |
17913 | ||
17914 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
17915 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
17916 | ||
17917 | vty_out(vty, "\n"); | |
17918 | } | |
17919 | ||
17920 | /* BGP deterministic-med. */ | |
892fedb6 | 17921 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 17922 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 17923 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
17924 | CHECK_FLAG(bgp->flags, |
17925 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
17926 | ? "" |
17927 | : "no "); | |
17928 | ||
17929 | /* BGP update-delay. */ | |
17930 | bgp_config_write_update_delay(vty, bgp); | |
17931 | ||
17932 | if (bgp->v_maxmed_onstartup | |
17933 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
17934 | vty_out(vty, " bgp max-med on-startup %u", | |
17935 | bgp->v_maxmed_onstartup); | |
17936 | if (bgp->maxmed_onstartup_value | |
17937 | != BGP_MAXMED_VALUE_DEFAULT) | |
17938 | vty_out(vty, " %u", | |
17939 | bgp->maxmed_onstartup_value); | |
17940 | vty_out(vty, "\n"); | |
17941 | } | |
17942 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
17943 | vty_out(vty, " bgp max-med administrative"); | |
17944 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
17945 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
17946 | vty_out(vty, "\n"); | |
17947 | } | |
17948 | ||
17949 | /* write quanta */ | |
17950 | bgp_config_write_wpkt_quanta(vty, bgp); | |
17951 | /* read quanta */ | |
17952 | bgp_config_write_rpkt_quanta(vty, bgp); | |
17953 | ||
17954 | /* coalesce time */ | |
17955 | bgp_config_write_coalesce_time(vty, bgp); | |
17956 | ||
05bd726c | 17957 | /* BGP per-instance graceful-shutdown */ |
17958 | /* BGP-wide settings and per-instance settings are mutually | |
17959 | * exclusive. | |
17960 | */ | |
17961 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
17962 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) | |
17963 | vty_out(vty, " bgp graceful-shutdown\n"); | |
17964 | ||
8606be87 DA |
17965 | /* Long-lived Graceful Restart */ |
17966 | if (bgp->llgr_stale_time != BGP_DEFAULT_LLGR_STALE_TIME) | |
17967 | vty_out(vty, | |
17968 | " bgp long-lived-graceful-restart stale-time %u\n", | |
17969 | bgp->llgr_stale_time); | |
17970 | ||
dd65f45e DL |
17971 | /* BGP graceful-restart. */ |
17972 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
17973 | vty_out(vty, | |
17974 | " bgp graceful-restart stalepath-time %u\n", | |
17975 | bgp->stalepath_time); | |
cfd47646 | 17976 | |
dd65f45e DL |
17977 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
17978 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
17979 | bgp->restart_time); | |
cfd47646 | 17980 | |
f2ca5c5b DA |
17981 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION) != |
17982 | SAVE_BGP_GRACEFUL_NOTIFICATION) | |
17983 | vty_out(vty, " %sbgp graceful-restart notification\n", | |
17984 | CHECK_FLAG(bgp->flags, | |
17985 | BGP_FLAG_GRACEFUL_NOTIFICATION) | |
17986 | ? "" | |
17987 | : "no "); | |
17988 | ||
cfd47646 | 17989 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) |
17990 | vty_out(vty, | |
17991 | " bgp graceful-restart select-defer-time %u\n", | |
17992 | bgp->select_defer_time); | |
17993 | ||
17994 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
17995 | vty_out(vty, " bgp graceful-restart\n"); |
17996 | ||
cfd47646 | 17997 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
17998 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
17999 | ||
dd65f45e | 18000 | /* BGP graceful-restart Preserve State F bit. */ |
892fedb6 | 18001 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
18002 | vty_out(vty, |
18003 | " bgp graceful-restart preserve-fw-state\n"); | |
18004 | ||
d1adb448 PG |
18005 | /* BGP TCP keepalive */ |
18006 | bgp_config_tcp_keepalive(vty, bgp); | |
18007 | ||
dc95985f | 18008 | /* Stale timer for RIB */ |
18009 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
18010 | vty_out(vty, | |
18011 | " bgp graceful-restart rib-stale-time %u\n", | |
18012 | bgp->rib_stale_time); | |
18013 | ||
dd65f45e | 18014 | /* BGP bestpath method. */ |
892fedb6 | 18015 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 18016 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 18017 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
18018 | vty_out(vty, " bgp bestpath as-path confed\n"); |
18019 | ||
892fedb6 DA |
18020 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
18021 | if (CHECK_FLAG(bgp->flags, | |
18022 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
18023 | vty_out(vty, |
18024 | " bgp bestpath as-path multipath-relax as-set\n"); | |
18025 | } else { | |
18026 | vty_out(vty, | |
18027 | " bgp bestpath as-path multipath-relax\n"); | |
18028 | } | |
18029 | } | |
18030 | ||
892fedb6 | 18031 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
18032 | vty_out(vty, |
18033 | " bgp route-reflector allow-outbound-policy\n"); | |
18034 | } | |
892fedb6 | 18035 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 18036 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
97a52c82 DA |
18037 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_AIGP)) |
18038 | vty_out(vty, " bgp bestpath aigp\n"); | |
892fedb6 DA |
18039 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
18040 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 18041 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 18042 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 18043 | vty_out(vty, " confed"); |
892fedb6 DA |
18044 | if (CHECK_FLAG(bgp->flags, |
18045 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
18046 | vty_out(vty, " missing-as-worst"); |
18047 | vty_out(vty, "\n"); | |
18048 | } | |
18049 | ||
ee88563a JM |
18050 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX)) |
18051 | vty_out(vty, | |
18052 | " bgp bestpath peer-type multipath-relax\n"); | |
18053 | ||
f7e1c681 | 18054 | /* Link bandwidth handling. */ |
18055 | if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW) | |
18056 | vty_out(vty, " bgp bestpath bandwidth ignore\n"); | |
18057 | else if (bgp->lb_handling == BGP_LINK_BW_SKIP_MISSING) | |
18058 | vty_out(vty, " bgp bestpath bandwidth skip-missing\n"); | |
18059 | else if (bgp->lb_handling == BGP_LINK_BW_DEFWT_4_MISSING) | |
18060 | vty_out(vty, " bgp bestpath bandwidth default-weight-for-missing\n"); | |
18061 | ||
dd65f45e | 18062 | /* BGP network import check. */ |
892fedb6 | 18063 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 18064 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 18065 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 18066 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
18067 | ? "" |
18068 | : "no "); | |
18069 | ||
18070 | /* BGP timers configuration. */ | |
5d5393b9 | 18071 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
9800cfff | 18072 | || bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
dd65f45e DL |
18073 | vty_out(vty, " timers bgp %u %u\n", |
18074 | bgp->default_keepalive, bgp->default_holdtime); | |
18075 | ||
b042667a TI |
18076 | /* BGP minimum holdtime configuration. */ |
18077 | if (bgp->default_min_holdtime != SAVE_BGP_HOLDTIME | |
18078 | && bgp->default_min_holdtime != 0) | |
18079 | vty_out(vty, " bgp minimum-holdtime %u\n", | |
18080 | bgp->default_min_holdtime); | |
18081 | ||
389e4f92 QY |
18082 | /* Conditional advertisement timer configuration */ |
18083 | if (bgp->condition_check_period | |
18084 | != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME) | |
18085 | vty_out(vty, | |
18086 | " bgp conditional-advertisement timer %u\n", | |
18087 | bgp->condition_check_period); | |
18088 | ||
dd65f45e DL |
18089 | /* peer-group */ |
18090 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
18091 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
18092 | } | |
18093 | ||
18094 | /* Normal neighbor configuration. */ | |
18095 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
18096 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
18097 | bgp_config_write_peer_global(vty, bgp, peer); | |
18098 | } | |
18099 | ||
18100 | /* listen range and limit for dynamic BGP neighbors */ | |
18101 | bgp_config_write_listen(vty, bgp); | |
18102 | ||
18103 | /* | |
18104 | * BGP default autoshutdown neighbors | |
18105 | * | |
18106 | * This must be placed after any peer and peer-group | |
18107 | * configuration, to avoid setting all peers to shutdown after | |
18108 | * a daemon restart, which is undesired behavior. (see #2286) | |
18109 | */ | |
18110 | if (bgp->autoshutdown) | |
18111 | vty_out(vty, " bgp default shutdown\n"); | |
18112 | ||
9cf59432 DS |
18113 | /* BGP instance administrative shutdown */ |
18114 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN)) | |
18115 | vty_out(vty, " bgp shutdown\n"); | |
18116 | ||
8666265e DS |
18117 | if (bgp->allow_martian) |
18118 | vty_out(vty, " bgp allow-martian-nexthop\n"); | |
18119 | ||
f852eb98 PG |
18120 | if (bgp->fast_convergence) |
18121 | vty_out(vty, " bgp fast-convergence\n"); | |
18122 | ||
a0281b2e HS |
18123 | if (bgp->srv6_enabled) { |
18124 | vty_frame(vty, " !\n segment-routing srv6\n"); | |
96db4340 | 18125 | if (strlen(bgp->srv6_locator_name)) |
a0281b2e HS |
18126 | vty_out(vty, " locator %s\n", |
18127 | bgp->srv6_locator_name); | |
ff7c3ee1 | 18128 | vty_endframe(vty, " exit\n"); |
a0281b2e HS |
18129 | } |
18130 | ||
efc9b57d CS |
18131 | tovpn_sid_index = bgp->tovpn_sid_index; |
18132 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO)) { | |
18133 | vty_out(vty, " sid vpn per-vrf export auto\n"); | |
18134 | } else if (tovpn_sid_index != 0) { | |
18135 | vty_out(vty, " sid vpn per-vrf export %d\n", | |
18136 | tovpn_sid_index); | |
18137 | } | |
a0281b2e | 18138 | |
dd65f45e DL |
18139 | /* IPv4 unicast configuration. */ |
18140 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
18141 | ||
18142 | /* IPv4 multicast configuration. */ | |
18143 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
18144 | ||
18145 | /* IPv4 labeled-unicast configuration. */ | |
18146 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
18147 | ||
18148 | /* IPv4 VPN configuration. */ | |
18149 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
18150 | ||
18151 | /* ENCAPv4 configuration. */ | |
18152 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
18153 | ||
18154 | /* FLOWSPEC v4 configuration. */ | |
18155 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
18156 | ||
18157 | /* IPv6 unicast configuration. */ | |
18158 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
18159 | ||
18160 | /* IPv6 multicast configuration. */ | |
18161 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
18162 | ||
18163 | /* IPv6 labeled-unicast configuration. */ | |
18164 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
18165 | SAFI_LABELED_UNICAST); | |
18166 | ||
18167 | /* IPv6 VPN configuration. */ | |
18168 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
18169 | ||
18170 | /* ENCAPv6 configuration. */ | |
18171 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
18172 | ||
18173 | /* FLOWSPEC v6 configuration. */ | |
18174 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
18175 | ||
18176 | /* EVPN configuration. */ | |
18177 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
18178 | ||
18179 | hook_call(bgp_inst_config_write, bgp, vty); | |
18180 | ||
49e5a4a0 | 18181 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
18182 | bgp_rfapi_cfg_write(vty, bgp); |
18183 | #endif | |
18184 | ||
07679ad9 | 18185 | vty_out(vty, "exit\n"); |
dd65f45e DL |
18186 | vty_out(vty, "!\n"); |
18187 | } | |
18188 | return 0; | |
18189 | } | |
18190 | ||
ddb5b488 | 18191 | |
718e3744 | 18192 | /* BGP node structure. */ |
d62a17ae | 18193 | static struct cmd_node bgp_node = { |
f4b8291f | 18194 | .name = "bgp", |
62b346ee | 18195 | .node = BGP_NODE, |
24389580 | 18196 | .parent_node = CONFIG_NODE, |
62b346ee | 18197 | .prompt = "%s(config-router)# ", |
612c2c15 | 18198 | .config_write = bgp_config_write, |
718e3744 | 18199 | }; |
18200 | ||
d62a17ae | 18201 | static struct cmd_node bgp_ipv4_unicast_node = { |
f4b8291f | 18202 | .name = "bgp ipv4 unicast", |
62b346ee | 18203 | .node = BGP_IPV4_NODE, |
24389580 | 18204 | .parent_node = BGP_NODE, |
62b346ee | 18205 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18206 | .no_xpath = true, |
718e3744 | 18207 | }; |
18208 | ||
d62a17ae | 18209 | static struct cmd_node bgp_ipv4_multicast_node = { |
f4b8291f | 18210 | .name = "bgp ipv4 multicast", |
62b346ee | 18211 | .node = BGP_IPV4M_NODE, |
24389580 | 18212 | .parent_node = BGP_NODE, |
62b346ee | 18213 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18214 | .no_xpath = true, |
718e3744 | 18215 | }; |
18216 | ||
d62a17ae | 18217 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
f4b8291f | 18218 | .name = "bgp ipv4 labeled unicast", |
62b346ee | 18219 | .node = BGP_IPV4L_NODE, |
24389580 | 18220 | .parent_node = BGP_NODE, |
62b346ee | 18221 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18222 | .no_xpath = true, |
f51bae9c DS |
18223 | }; |
18224 | ||
d62a17ae | 18225 | static struct cmd_node bgp_ipv6_unicast_node = { |
a17cfb3f | 18226 | .name = "bgp ipv6 unicast", |
62b346ee | 18227 | .node = BGP_IPV6_NODE, |
24389580 | 18228 | .parent_node = BGP_NODE, |
62b346ee | 18229 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18230 | .no_xpath = true, |
718e3744 | 18231 | }; |
18232 | ||
d62a17ae | 18233 | static struct cmd_node bgp_ipv6_multicast_node = { |
f4b8291f | 18234 | .name = "bgp ipv6 multicast", |
62b346ee | 18235 | .node = BGP_IPV6M_NODE, |
24389580 | 18236 | .parent_node = BGP_NODE, |
62b346ee | 18237 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18238 | .no_xpath = true, |
25ffbdc1 | 18239 | }; |
18240 | ||
d62a17ae | 18241 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
f4b8291f | 18242 | .name = "bgp ipv6 labeled unicast", |
62b346ee | 18243 | .node = BGP_IPV6L_NODE, |
24389580 | 18244 | .parent_node = BGP_NODE, |
62b346ee | 18245 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18246 | .no_xpath = true, |
f51bae9c DS |
18247 | }; |
18248 | ||
62b346ee | 18249 | static struct cmd_node bgp_vpnv4_node = { |
f4b8291f | 18250 | .name = "bgp vpnv4", |
62b346ee | 18251 | .node = BGP_VPNV4_NODE, |
24389580 | 18252 | .parent_node = BGP_NODE, |
62b346ee | 18253 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18254 | .no_xpath = true, |
62b346ee | 18255 | }; |
6b0655a2 | 18256 | |
62b346ee | 18257 | static struct cmd_node bgp_vpnv6_node = { |
f4b8291f | 18258 | .name = "bgp vpnv6", |
62b346ee | 18259 | .node = BGP_VPNV6_NODE, |
24389580 | 18260 | .parent_node = BGP_NODE, |
62b346ee | 18261 | .prompt = "%s(config-router-af-vpnv6)# ", |
dd2c81b8 | 18262 | .no_xpath = true, |
62b346ee | 18263 | }; |
8ecd3266 | 18264 | |
62b346ee | 18265 | static struct cmd_node bgp_evpn_node = { |
f4b8291f | 18266 | .name = "bgp evpn", |
62b346ee | 18267 | .node = BGP_EVPN_NODE, |
24389580 | 18268 | .parent_node = BGP_NODE, |
62b346ee | 18269 | .prompt = "%s(config-router-evpn)# ", |
dd2c81b8 | 18270 | .no_xpath = true, |
62b346ee | 18271 | }; |
4e0b7b6d | 18272 | |
62b346ee | 18273 | static struct cmd_node bgp_evpn_vni_node = { |
f4b8291f | 18274 | .name = "bgp evpn vni", |
62b346ee | 18275 | .node = BGP_EVPN_VNI_NODE, |
24389580 | 18276 | .parent_node = BGP_EVPN_NODE, |
62b346ee | 18277 | .prompt = "%s(config-router-af-vni)# ", |
62b346ee | 18278 | }; |
90e60aa7 | 18279 | |
62b346ee | 18280 | static struct cmd_node bgp_flowspecv4_node = { |
f4b8291f | 18281 | .name = "bgp ipv4 flowspec", |
62b346ee | 18282 | .node = BGP_FLOWSPECV4_NODE, |
24389580 | 18283 | .parent_node = BGP_NODE, |
62b346ee | 18284 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18285 | .no_xpath = true, |
62b346ee | 18286 | }; |
7c40bf39 | 18287 | |
62b346ee | 18288 | static struct cmd_node bgp_flowspecv6_node = { |
f4b8291f | 18289 | .name = "bgp ipv6 flowspec", |
62b346ee | 18290 | .node = BGP_FLOWSPECV6_NODE, |
24389580 | 18291 | .parent_node = BGP_NODE, |
62b346ee | 18292 | .prompt = "%s(config-router-af-vpnv6)# ", |
dd2c81b8 | 18293 | .no_xpath = true, |
62b346ee | 18294 | }; |
7c40bf39 | 18295 | |
bfaab44d HS |
18296 | static struct cmd_node bgp_srv6_node = { |
18297 | .name = "bgp srv6", | |
18298 | .node = BGP_SRV6_NODE, | |
18299 | .parent_node = BGP_NODE, | |
18300 | .prompt = "%s(config-router-srv6)# ", | |
18301 | }; | |
18302 | ||
d62a17ae | 18303 | static void community_list_vty(void); |
1f8ae70b | 18304 | |
8c20061f DA |
18305 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
18306 | { | |
18307 | struct bgp *bgp; | |
18308 | struct peer_group *group; | |
18309 | struct listnode *lnbgp, *lnpeer; | |
18310 | ||
18311 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
18312 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
18313 | vector_set(comps, | |
18314 | XSTRDUP(MTYPE_COMPLETION, group->name)); | |
18315 | } | |
18316 | } | |
18317 | ||
18318 | static void bgp_ac_peer(vector comps, struct cmd_token *token) | |
b8a815e5 | 18319 | { |
d62a17ae | 18320 | struct bgp *bgp; |
18321 | struct peer *peer; | |
d62a17ae | 18322 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 18323 | |
d62a17ae | 18324 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
18325 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
18326 | /* only provide suggestions on the appropriate input | |
18327 | * token type, | |
18328 | * they'll otherwise show up multiple times */ | |
18329 | enum cmd_token_type match_type; | |
18330 | char *name = peer->host; | |
d48ed3e0 | 18331 | |
d62a17ae | 18332 | if (peer->conf_if) { |
18333 | match_type = VARIABLE_TKN; | |
18334 | name = peer->conf_if; | |
18335 | } else if (strchr(peer->host, ':')) | |
18336 | match_type = IPV6_TKN; | |
18337 | else | |
18338 | match_type = IPV4_TKN; | |
d48ed3e0 | 18339 | |
d62a17ae | 18340 | if (token->type != match_type) |
18341 | continue; | |
d48ed3e0 | 18342 | |
d62a17ae | 18343 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
18344 | } | |
d62a17ae | 18345 | } |
b8a815e5 DL |
18346 | } |
18347 | ||
8c20061f DA |
18348 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
18349 | { | |
18350 | bgp_ac_peer(comps, token); | |
84de1483 DA |
18351 | |
18352 | if (token->type == VARIABLE_TKN) | |
18353 | bgp_ac_peergroup(comps, token); | |
8c20061f DA |
18354 | } |
18355 | ||
b8a815e5 | 18356 | static const struct cmd_variable_handler bgp_var_neighbor[] = { |
d62a17ae | 18357 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
18358 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 18359 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 18360 | {.completions = NULL}}; |
18361 | ||
47a306a0 DS |
18362 | static const struct cmd_variable_handler bgp_var_peergroup[] = { |
18363 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
18364 | {.completions = NULL} }; | |
18365 | ||
aa24a36a DA |
18366 | DEFINE_HOOK(bgp_config_end, (struct bgp *bgp), (bgp)); |
18367 | ||
18368 | static struct thread *t_bgp_cfg; | |
18369 | ||
18370 | bool bgp_config_inprocess(void) | |
18371 | { | |
18372 | return thread_is_scheduled(t_bgp_cfg); | |
18373 | } | |
18374 | ||
18375 | static void bgp_config_finish(struct thread *t) | |
18376 | { | |
18377 | struct listnode *node; | |
18378 | struct bgp *bgp; | |
18379 | ||
18380 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) | |
18381 | hook_call(bgp_config_end, bgp); | |
18382 | } | |
18383 | ||
18384 | static void bgp_config_start(void) | |
18385 | { | |
18386 | #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600 | |
18387 | THREAD_OFF(t_bgp_cfg); | |
18388 | thread_add_timer(bm->master, bgp_config_finish, NULL, | |
18389 | BGP_PRE_CONFIG_MAX_WAIT_SECONDS, &t_bgp_cfg); | |
18390 | } | |
18391 | ||
18392 | /* When we receive a hook the configuration is read, | |
18393 | * we start a timer to make sure we postpone sending | |
18394 | * EoR before route-maps are processed. | |
18395 | * This is especially valid if using `bgp route-map delay-timer`. | |
18396 | */ | |
18397 | static void bgp_config_end(void) | |
18398 | { | |
18399 | #define BGP_POST_CONFIG_DELAY_SECONDS 1 | |
18400 | uint32_t bgp_post_config_delay = | |
18401 | thread_is_scheduled(bm->t_rmap_update) | |
18402 | ? thread_timer_remain_second(bm->t_rmap_update) | |
18403 | : BGP_POST_CONFIG_DELAY_SECONDS; | |
18404 | ||
18405 | /* If BGP config processing thread isn't running, then | |
18406 | * we can return and rely it's properly handled. | |
18407 | */ | |
18408 | if (!bgp_config_inprocess()) | |
18409 | return; | |
18410 | ||
18411 | THREAD_OFF(t_bgp_cfg); | |
18412 | ||
18413 | /* Start a new timer to make sure we don't send EoR | |
18414 | * before route-maps are processed. | |
18415 | */ | |
18416 | thread_add_timer(bm->master, bgp_config_finish, NULL, | |
18417 | bgp_post_config_delay, &t_bgp_cfg); | |
18418 | } | |
18419 | ||
4cd690ae PG |
18420 | static int config_write_interface_one(struct vty *vty, struct vrf *vrf) |
18421 | { | |
18422 | int write = 0; | |
18423 | struct interface *ifp; | |
18424 | struct bgp_interface *iifp; | |
18425 | ||
18426 | FOR_ALL_INTERFACES (vrf, ifp) { | |
18427 | iifp = ifp->info; | |
18428 | if (!iifp) | |
18429 | continue; | |
18430 | ||
18431 | if_vty_config_start(vty, ifp); | |
18432 | ||
18433 | if (CHECK_FLAG(iifp->flags, | |
18434 | BGP_INTERFACE_MPLS_BGP_FORWARDING)) { | |
18435 | vty_out(vty, " mpls bgp forwarding\n"); | |
18436 | write++; | |
18437 | } | |
18438 | ||
18439 | if_vty_config_end(vty); | |
18440 | } | |
18441 | ||
18442 | return write; | |
18443 | } | |
18444 | ||
18445 | /* Configuration write function for bgpd. */ | |
18446 | static int config_write_interface(struct vty *vty) | |
18447 | { | |
18448 | int write = 0; | |
18449 | struct vrf *vrf = NULL; | |
18450 | ||
18451 | /* Display all VRF aware OSPF interface configuration */ | |
18452 | RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { | |
18453 | write += config_write_interface_one(vty, vrf); | |
18454 | } | |
18455 | ||
18456 | return write; | |
18457 | } | |
18458 | ||
18459 | DEFPY(mpls_bgp_forwarding, mpls_bgp_forwarding_cmd, | |
18460 | "[no$no] mpls bgp forwarding", | |
18461 | NO_STR MPLS_STR BGP_STR | |
18462 | "Enable MPLS forwarding for eBGP directly connected peers\n") | |
18463 | { | |
18464 | bool check; | |
18465 | struct bgp_interface *iifp; | |
18466 | ||
18467 | VTY_DECLVAR_CONTEXT(interface, ifp); | |
18468 | iifp = ifp->info; | |
18469 | if (!iifp) { | |
18470 | vty_out(vty, "Interface %s not available\n", ifp->name); | |
18471 | return CMD_WARNING_CONFIG_FAILED; | |
18472 | } | |
18473 | check = CHECK_FLAG(iifp->flags, BGP_INTERFACE_MPLS_BGP_FORWARDING); | |
18474 | if (check != !no) { | |
18475 | if (no) | |
18476 | UNSET_FLAG(iifp->flags, | |
18477 | BGP_INTERFACE_MPLS_BGP_FORWARDING); | |
18478 | else | |
18479 | SET_FLAG(iifp->flags, | |
18480 | BGP_INTERFACE_MPLS_BGP_FORWARDING); | |
18481 | /* trigger a nht update on eBGP sessions */ | |
18482 | if (if_is_operative(ifp)) | |
18483 | bgp_nht_ifp_up(ifp); | |
18484 | } | |
18485 | return CMD_SUCCESS; | |
18486 | } | |
18487 | ||
a0b937de SW |
18488 | DEFPY (bgp_inq_limit, |
18489 | bgp_inq_limit_cmd, | |
18490 | "bgp input-queue-limit (1-4294967295)$limit", | |
18491 | BGP_STR | |
18492 | "Set the BGP Input Queue limit for all peers when message parsing\n" | |
18493 | "Input-Queue limit\n") | |
18494 | { | |
18495 | bm->inq_limit = limit; | |
18496 | ||
18497 | return CMD_SUCCESS; | |
18498 | } | |
18499 | ||
18500 | DEFPY (no_bgp_inq_limit, | |
18501 | no_bgp_inq_limit_cmd, | |
18502 | "no bgp input-queue-limit [(1-4294967295)$limit]", | |
18503 | NO_STR | |
18504 | BGP_STR | |
18505 | "Set the BGP Input Queue limit for all peers when message parsing\n" | |
18506 | "Input-Queue limit\n") | |
18507 | { | |
18508 | bm->inq_limit = BM_DEFAULT_INQ_LIMIT; | |
18509 | ||
18510 | return CMD_SUCCESS; | |
18511 | } | |
18512 | ||
4cd690ae PG |
18513 | /* Initialization of BGP interface. */ |
18514 | static void bgp_vty_if_init(void) | |
18515 | { | |
18516 | /* Install interface node. */ | |
18517 | if_cmd_init(config_write_interface); | |
18518 | ||
18519 | /* "mpls bgp forwarding" commands. */ | |
18520 | install_element(INTERFACE_NODE, &mpls_bgp_forwarding_cmd); | |
18521 | } | |
18522 | ||
d62a17ae | 18523 | void bgp_vty_init(void) |
18524 | { | |
18525 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 18526 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 18527 | |
aa24a36a DA |
18528 | cmd_init_config_callbacks(bgp_config_start, bgp_config_end); |
18529 | ||
d62a17ae | 18530 | /* Install bgp top node. */ |
612c2c15 DL |
18531 | install_node(&bgp_node); |
18532 | install_node(&bgp_ipv4_unicast_node); | |
18533 | install_node(&bgp_ipv4_multicast_node); | |
18534 | install_node(&bgp_ipv4_labeled_unicast_node); | |
18535 | install_node(&bgp_ipv6_unicast_node); | |
18536 | install_node(&bgp_ipv6_multicast_node); | |
18537 | install_node(&bgp_ipv6_labeled_unicast_node); | |
18538 | install_node(&bgp_vpnv4_node); | |
18539 | install_node(&bgp_vpnv6_node); | |
18540 | install_node(&bgp_evpn_node); | |
18541 | install_node(&bgp_evpn_vni_node); | |
18542 | install_node(&bgp_flowspecv4_node); | |
18543 | install_node(&bgp_flowspecv6_node); | |
bfaab44d | 18544 | install_node(&bgp_srv6_node); |
d62a17ae | 18545 | |
18546 | /* Install default VTY commands to new nodes. */ | |
18547 | install_default(BGP_NODE); | |
18548 | install_default(BGP_IPV4_NODE); | |
18549 | install_default(BGP_IPV4M_NODE); | |
18550 | install_default(BGP_IPV4L_NODE); | |
18551 | install_default(BGP_IPV6_NODE); | |
18552 | install_default(BGP_IPV6M_NODE); | |
18553 | install_default(BGP_IPV6L_NODE); | |
18554 | install_default(BGP_VPNV4_NODE); | |
18555 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 18556 | install_default(BGP_FLOWSPECV4_NODE); |
18557 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 18558 | install_default(BGP_EVPN_NODE); |
18559 | install_default(BGP_EVPN_VNI_NODE); | |
bfaab44d | 18560 | install_default(BGP_SRV6_NODE); |
d62a17ae | 18561 | |
a0b937de SW |
18562 | /* "global bgp inq-limit command */ |
18563 | install_element(CONFIG_NODE, &bgp_inq_limit_cmd); | |
18564 | install_element(CONFIG_NODE, &no_bgp_inq_limit_cmd); | |
18565 | ||
8029b216 AK |
18566 | /* "bgp local-mac" hidden commands. */ |
18567 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
18568 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
18569 | ||
9acb67cb DS |
18570 | /* "bgp suppress-fib-pending" global */ |
18571 | install_element(CONFIG_NODE, &bgp_global_suppress_fib_pending_cmd); | |
18572 | ||
d62a17ae | 18573 | /* bgp route-map delay-timer commands. */ |
18574 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
18575 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
18576 | ||
8666265e DS |
18577 | install_element(BGP_NODE, &bgp_allow_martian_cmd); |
18578 | ||
f852eb98 PG |
18579 | /* bgp fast-convergence command */ |
18580 | install_element(BGP_NODE, &bgp_fast_convergence_cmd); | |
18581 | install_element(BGP_NODE, &no_bgp_fast_convergence_cmd); | |
18582 | ||
d70583f7 D |
18583 | /* global bgp update-delay command */ |
18584 | install_element(CONFIG_NODE, &bgp_global_update_delay_cmd); | |
18585 | install_element(CONFIG_NODE, &no_bgp_global_update_delay_cmd); | |
18586 | ||
05bd726c | 18587 | /* global bgp graceful-shutdown command */ |
18588 | install_element(CONFIG_NODE, &bgp_graceful_shutdown_cmd); | |
18589 | install_element(CONFIG_NODE, &no_bgp_graceful_shutdown_cmd); | |
18590 | ||
d62a17ae | 18591 | /* Dummy commands (Currently not supported) */ |
18592 | install_element(BGP_NODE, &no_synchronization_cmd); | |
18593 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
18594 | ||
18595 | /* "router bgp" commands. */ | |
18596 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
18597 | ||
18598 | /* "no router bgp" commands. */ | |
18599 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
18600 | ||
425bd64b PS |
18601 | /* "bgp session-dscp command */ |
18602 | install_element(CONFIG_NODE, &bgp_session_dscp_cmd); | |
18603 | install_element(CONFIG_NODE, &no_bgp_session_dscp_cmd); | |
18604 | ||
d62a17ae | 18605 | /* "bgp router-id" commands. */ |
18606 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
18607 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
18608 | ||
c208c586 S |
18609 | /* "bgp suppress-fib-pending" command */ |
18610 | install_element(BGP_NODE, &bgp_suppress_fib_pending_cmd); | |
18611 | ||
d62a17ae | 18612 | /* "bgp cluster-id" commands. */ |
18613 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
18614 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
18615 | ||
c163f297 DS |
18616 | /* "bgp no-rib" commands. */ |
18617 | install_element(CONFIG_NODE, &bgp_norib_cmd); | |
18618 | install_element(CONFIG_NODE, &no_bgp_norib_cmd); | |
18619 | ||
e46723a5 DS |
18620 | install_element(CONFIG_NODE, &no_bgp_send_extra_data_cmd); |
18621 | ||
d62a17ae | 18622 | /* "bgp confederation" commands. */ |
18623 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
18624 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
18625 | ||
18626 | /* "bgp confederation peers" commands. */ | |
18627 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
18628 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
18629 | ||
18630 | /* bgp max-med command */ | |
18631 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
18632 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
18633 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
18634 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
18635 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
18636 | ||
d864dd9e EB |
18637 | /* "neighbor role" commands. */ |
18638 | install_element(BGP_NODE, &neighbor_role_cmd); | |
18639 | install_element(BGP_NODE, &neighbor_role_strict_cmd); | |
18640 | install_element(BGP_NODE, &no_neighbor_role_cmd); | |
18641 | ||
97a52c82 DA |
18642 | /* "neighbor aigp" commands. */ |
18643 | install_element(BGP_NODE, &neighbor_aigp_cmd); | |
18644 | ||
d62a17ae | 18645 | /* bgp disable-ebgp-connected-nh-check */ |
18646 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
18647 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
18648 | ||
18649 | /* bgp update-delay command */ | |
18650 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
18651 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
d62a17ae | 18652 | |
18653 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 18654 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 18655 | |
18656 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
18657 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
18658 | ||
18659 | /* "maximum-paths" commands. */ | |
18660 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
18661 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
18662 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
18663 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
18664 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
18665 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
18666 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
18667 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
18668 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
18669 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
18670 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
18671 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
18672 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
18673 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
18674 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
18675 | ||
39edabac PG |
18676 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
18677 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
18678 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
18679 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
18680 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
d62a17ae | 18681 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); |
18682 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
18683 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
18684 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
18685 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
18686 | ||
18687 | /* "timers bgp" commands. */ | |
18688 | install_element(BGP_NODE, &bgp_timers_cmd); | |
18689 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
18690 | ||
b042667a TI |
18691 | /* "minimum-holdtime" commands. */ |
18692 | install_element(BGP_NODE, &bgp_minimum_holdtime_cmd); | |
18693 | install_element(BGP_NODE, &no_bgp_minimum_holdtime_cmd); | |
18694 | ||
d62a17ae | 18695 | /* route-map delay-timer commands - per instance for backwards compat. |
18696 | */ | |
18697 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
18698 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
18699 | ||
18700 | /* "bgp client-to-client reflection" commands */ | |
18701 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
18702 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
18703 | ||
18704 | /* "bgp always-compare-med" commands */ | |
18705 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
18706 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
18707 | ||
9dac9fc8 DA |
18708 | /* bgp ebgp-requires-policy */ |
18709 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
18710 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
18711 | ||
2adac256 DA |
18712 | /* bgp suppress-duplicates */ |
18713 | install_element(BGP_NODE, &bgp_suppress_duplicates_cmd); | |
18714 | install_element(BGP_NODE, &no_bgp_suppress_duplicates_cmd); | |
18715 | ||
fb29348a DA |
18716 | /* bgp reject-as-sets */ |
18717 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
18718 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
18719 | ||
d62a17ae | 18720 | /* "bgp deterministic-med" commands */ |
18721 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
18722 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
18723 | ||
055679e9 | 18724 | /* "bgp graceful-restart" command */ |
36235319 QY |
18725 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
18726 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 18727 | |
18728 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
18729 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
18730 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 18731 | |
18732 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
18733 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
18734 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 18735 | |
18736 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
18737 | install_element(BGP_NODE, | |
18738 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
18739 | install_element(BGP_NODE, | |
18740 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
18741 | ||
18742 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
18743 | install_element(BGP_NODE, | |
18744 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
18745 | install_element(BGP_NODE, | |
18746 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
18747 | ||
d62a17ae | 18748 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
18749 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
18750 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
18751 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 18752 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 18753 | install_element(BGP_NODE, |
18754 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 18755 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
18756 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
f2ca5c5b | 18757 | install_element(BGP_NODE, &bgp_graceful_restart_notification_cmd); |
d62a17ae | 18758 | |
d6e3c15b | 18759 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
18760 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 18761 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
18762 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 18763 | |
a0b937de SW |
18764 | /* "bgp inq-limit command */ |
18765 | install_element(BGP_NODE, &bgp_inq_limit_cmd); | |
18766 | install_element(BGP_NODE, &no_bgp_inq_limit_cmd); | |
18767 | ||
7f323236 DW |
18768 | /* "bgp graceful-shutdown" commands */ |
18769 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
18770 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
18771 | ||
1ae314be DA |
18772 | /* "bgp hard-administrative-reset" commands */ |
18773 | install_element(BGP_NODE, &bgp_administrative_reset_cmd); | |
18774 | ||
8606be87 DA |
18775 | /* "bgp long-lived-graceful-restart" commands */ |
18776 | install_element(BGP_NODE, &bgp_llgr_stalepath_time_cmd); | |
18777 | install_element(BGP_NODE, &no_bgp_llgr_stalepath_time_cmd); | |
18778 | ||
d62a17ae | 18779 | /* "bgp fast-external-failover" commands */ |
18780 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
18781 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
18782 | ||
97a52c82 DA |
18783 | /* "bgp bestpath aigp" commands */ |
18784 | install_element(BGP_NODE, &bgp_bestpath_aigp_cmd); | |
18785 | ||
d62a17ae | 18786 | /* "bgp bestpath compare-routerid" commands */ |
18787 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
18788 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
18789 | ||
18790 | /* "bgp bestpath as-path ignore" commands */ | |
18791 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
18792 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
18793 | ||
18794 | /* "bgp bestpath as-path confed" commands */ | |
18795 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
18796 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
18797 | ||
18798 | /* "bgp bestpath as-path multipath-relax" commands */ | |
18799 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
18800 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
18801 | ||
ee88563a JM |
18802 | /* "bgp bestpath peer-type multipath-relax" commands */ |
18803 | install_element(BGP_NODE, &bgp_bestpath_peer_type_multipath_relax_cmd); | |
18804 | install_element(BGP_NODE, | |
18805 | &no_bgp_bestpath_peer_type_multipath_relax_cmd); | |
18806 | ||
d62a17ae | 18807 | /* "bgp log-neighbor-changes" commands */ |
18808 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
18809 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
18810 | ||
18811 | /* "bgp bestpath med" commands */ | |
18812 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
18813 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
18814 | ||
f7e1c681 | 18815 | /* "bgp bestpath bandwidth" commands */ |
18816 | install_element(BGP_NODE, &bgp_bestpath_bw_cmd); | |
ad36d216 | 18817 | install_element(BGP_NODE, &no_bgp_bestpath_bw_cmd); |
f7e1c681 | 18818 | |
b16bcbba TA |
18819 | /* "no bgp default <afi>-<safi>" commands. */ |
18820 | install_element(BGP_NODE, &bgp_default_afi_safi_cmd); | |
e84c59af | 18821 | |
d62a17ae | 18822 | /* "bgp network import-check" commands. */ |
18823 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
18824 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
18825 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
18826 | ||
18827 | /* "bgp default local-preference" commands. */ | |
18828 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
18829 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
18830 | ||
18831 | /* bgp default show-hostname */ | |
18832 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
18833 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
18834 | ||
aef999a2 DA |
18835 | /* bgp default show-nexthop-hostname */ |
18836 | install_element(BGP_NODE, &bgp_default_show_nexthop_hostname_cmd); | |
18837 | install_element(BGP_NODE, &no_bgp_default_show_nexthop_hostname_cmd); | |
18838 | ||
d62a17ae | 18839 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
18840 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
18841 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
18842 | ||
18843 | /* bgp ibgp-allow-policy-mods command */ | |
18844 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
18845 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
18846 | ||
18847 | /* "bgp listen limit" commands. */ | |
18848 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
18849 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
18850 | ||
18851 | /* "bgp listen range" commands. */ | |
18852 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
18853 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
18854 | ||
8175f54a | 18855 | /* "bgp default shutdown" command */ |
f26845f9 | 18856 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
9cf59432 DS |
18857 | |
18858 | /* "bgp shutdown" commands */ | |
18859 | install_element(BGP_NODE, &bgp_shutdown_cmd); | |
8389c83a | 18860 | install_element(BGP_NODE, &bgp_shutdown_msg_cmd); |
9cf59432 | 18861 | install_element(BGP_NODE, &no_bgp_shutdown_cmd); |
1b6e7a88 | 18862 | install_element(BGP_NODE, &no_bgp_shutdown_msg_cmd); |
f26845f9 | 18863 | |
d62a17ae | 18864 | /* "neighbor remote-as" commands. */ |
18865 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
18866 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
18867 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
18868 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
18869 | install_element(BGP_NODE, | |
18870 | &neighbor_interface_v6only_config_remote_as_cmd); | |
18871 | install_element(BGP_NODE, &no_neighbor_cmd); | |
18872 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
18873 | ||
18874 | /* "neighbor peer-group" commands. */ | |
18875 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
18876 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
18877 | install_element(BGP_NODE, | |
18878 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
18879 | ||
18880 | /* "neighbor local-as" commands. */ | |
18881 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
18882 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
18883 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
18884 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
18885 | ||
18886 | /* "neighbor solo" commands. */ | |
18887 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
18888 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
18889 | ||
18890 | /* "neighbor password" commands. */ | |
18891 | install_element(BGP_NODE, &neighbor_password_cmd); | |
18892 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
18893 | ||
18894 | /* "neighbor activate" commands. */ | |
18895 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
18896 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
18897 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
18898 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
18899 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
18900 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
18901 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
18902 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
18903 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 18904 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
18905 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 18906 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
18907 | ||
18908 | /* "no neighbor activate" commands. */ | |
18909 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
18910 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
18911 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
18912 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
18913 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
18914 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
18915 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
18916 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
18917 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 18918 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
18919 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 18920 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
18921 | ||
18922 | /* "neighbor peer-group" set commands. */ | |
18923 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
18924 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18925 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18926 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18927 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18928 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18929 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18930 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 18931 | install_element(BGP_FLOWSPECV4_NODE, |
18932 | &neighbor_set_peer_group_hidden_cmd); | |
18933 | install_element(BGP_FLOWSPECV6_NODE, | |
18934 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 18935 | |
18936 | /* "no neighbor peer-group unset" commands. */ | |
18937 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
18938 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18939 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18940 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18941 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18942 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18943 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18944 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 18945 | install_element(BGP_FLOWSPECV4_NODE, |
18946 | &no_neighbor_set_peer_group_hidden_cmd); | |
18947 | install_element(BGP_FLOWSPECV6_NODE, | |
18948 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 18949 | |
18950 | /* "neighbor softreconfiguration inbound" commands.*/ | |
18951 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
18952 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
18953 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
18954 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18955 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
18956 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18957 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
18958 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18959 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
18960 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18961 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
18962 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18963 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
18964 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18965 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
18966 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18967 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
18968 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 18969 | install_element(BGP_FLOWSPECV4_NODE, |
18970 | &neighbor_soft_reconfiguration_cmd); | |
18971 | install_element(BGP_FLOWSPECV4_NODE, | |
18972 | &no_neighbor_soft_reconfiguration_cmd); | |
18973 | install_element(BGP_FLOWSPECV6_NODE, | |
18974 | &neighbor_soft_reconfiguration_cmd); | |
18975 | install_element(BGP_FLOWSPECV6_NODE, | |
18976 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
18977 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
18978 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 18979 | |
18980 | /* "neighbor attribute-unchanged" commands. */ | |
18981 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
18982 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
18983 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
18984 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
18985 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
18986 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
18987 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
18988 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
18989 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
18990 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
18991 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
18992 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
18993 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
18994 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
18995 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
18996 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
18997 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
18998 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
18999 | ||
19000 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
19001 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
19002 | ||
b8ad84d2 PG |
19003 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_attr_unchanged_cmd); |
19004 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
19005 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_attr_unchanged_cmd); | |
19006 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
19007 | ||
d62a17ae | 19008 | /* "nexthop-local unchanged" commands */ |
19009 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
19010 | install_element(BGP_IPV6_NODE, | |
19011 | &no_neighbor_nexthop_local_unchanged_cmd); | |
19012 | ||
19013 | /* "neighbor next-hop-self" commands. */ | |
19014 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
19015 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
19016 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
19017 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
19018 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
19019 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
19020 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
19021 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
19022 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
19023 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
19024 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
19025 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
19026 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
19027 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
19028 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
19029 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
19030 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
19031 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
19032 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
19033 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 19034 | |
19035 | /* "neighbor next-hop-self force" commands. */ | |
19036 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
19037 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
19038 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19039 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19040 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
19041 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19042 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19043 | install_element(BGP_IPV4_NODE, | |
19044 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19045 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
19046 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19047 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19048 | install_element(BGP_IPV4M_NODE, | |
19049 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19050 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
19051 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19052 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19053 | install_element(BGP_IPV4L_NODE, | |
19054 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19055 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
19056 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19057 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19058 | install_element(BGP_IPV6_NODE, | |
19059 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19060 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
19061 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19062 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19063 | install_element(BGP_IPV6M_NODE, | |
19064 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19065 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
19066 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19067 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19068 | install_element(BGP_IPV6L_NODE, | |
19069 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19070 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
19071 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19072 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19073 | install_element(BGP_VPNV4_NODE, | |
19074 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19075 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
19076 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19077 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19078 | install_element(BGP_VPNV6_NODE, | |
19079 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
be7e1fa3 MS |
19080 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_force_cmd); |
19081 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_force_cmd); | |
d62a17ae | 19082 | |
19083 | /* "neighbor as-override" commands. */ | |
19084 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
19085 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
19086 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
19087 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
19088 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
19089 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
19090 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
19091 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
19092 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
19093 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
19094 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
19095 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
19096 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
19097 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
19098 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
19099 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
19100 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
19101 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
19102 | ||
19103 | /* "neighbor remove-private-AS" commands. */ | |
19104 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
19105 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
19106 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
19107 | install_element(BGP_NODE, | |
19108 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
19109 | install_element(BGP_NODE, | |
19110 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
19111 | install_element(BGP_NODE, | |
19112 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
19113 | install_element(BGP_NODE, | |
19114 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
19115 | install_element( | |
19116 | BGP_NODE, | |
19117 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
19118 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
19119 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
19120 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
19121 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19122 | install_element(BGP_IPV4_NODE, | |
19123 | &neighbor_remove_private_as_replace_as_cmd); | |
19124 | install_element(BGP_IPV4_NODE, | |
19125 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19126 | install_element(BGP_IPV4_NODE, | |
19127 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19128 | install_element(BGP_IPV4_NODE, | |
19129 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19130 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
19131 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
19132 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
19133 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19134 | install_element(BGP_IPV4M_NODE, | |
19135 | &neighbor_remove_private_as_replace_as_cmd); | |
19136 | install_element(BGP_IPV4M_NODE, | |
19137 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19138 | install_element(BGP_IPV4M_NODE, | |
19139 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19140 | install_element(BGP_IPV4M_NODE, | |
19141 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19142 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
19143 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
19144 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
19145 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19146 | install_element(BGP_IPV4L_NODE, | |
19147 | &neighbor_remove_private_as_replace_as_cmd); | |
19148 | install_element(BGP_IPV4L_NODE, | |
19149 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19150 | install_element(BGP_IPV4L_NODE, | |
19151 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19152 | install_element(BGP_IPV4L_NODE, | |
19153 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19154 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
19155 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
19156 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
19157 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19158 | install_element(BGP_IPV6_NODE, | |
19159 | &neighbor_remove_private_as_replace_as_cmd); | |
19160 | install_element(BGP_IPV6_NODE, | |
19161 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19162 | install_element(BGP_IPV6_NODE, | |
19163 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19164 | install_element(BGP_IPV6_NODE, | |
19165 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19166 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
19167 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
19168 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
19169 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19170 | install_element(BGP_IPV6M_NODE, | |
19171 | &neighbor_remove_private_as_replace_as_cmd); | |
19172 | install_element(BGP_IPV6M_NODE, | |
19173 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19174 | install_element(BGP_IPV6M_NODE, | |
19175 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19176 | install_element(BGP_IPV6M_NODE, | |
19177 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19178 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
19179 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
19180 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
19181 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19182 | install_element(BGP_IPV6L_NODE, | |
19183 | &neighbor_remove_private_as_replace_as_cmd); | |
19184 | install_element(BGP_IPV6L_NODE, | |
19185 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19186 | install_element(BGP_IPV6L_NODE, | |
19187 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19188 | install_element(BGP_IPV6L_NODE, | |
19189 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19190 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
19191 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
19192 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
19193 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19194 | install_element(BGP_VPNV4_NODE, | |
19195 | &neighbor_remove_private_as_replace_as_cmd); | |
19196 | install_element(BGP_VPNV4_NODE, | |
19197 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19198 | install_element(BGP_VPNV4_NODE, | |
19199 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19200 | install_element(BGP_VPNV4_NODE, | |
19201 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19202 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
19203 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
19204 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
19205 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19206 | install_element(BGP_VPNV6_NODE, | |
19207 | &neighbor_remove_private_as_replace_as_cmd); | |
19208 | install_element(BGP_VPNV6_NODE, | |
19209 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19210 | install_element(BGP_VPNV6_NODE, | |
19211 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19212 | install_element(BGP_VPNV6_NODE, | |
19213 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19214 | ||
19215 | /* "neighbor send-community" commands.*/ | |
19216 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
19217 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
19218 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
19219 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
19220 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
19221 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
19222 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
19223 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
19224 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
19225 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
19226 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
19227 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
19228 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
19229 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
19230 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
19231 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
19232 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
19233 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
19234 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
19235 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
19236 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
19237 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
19238 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
19239 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
19240 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
19241 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
19242 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
19243 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
19244 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
19245 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
19246 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
19247 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
19248 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
19249 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
19250 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
19251 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
19252 | ||
19253 | /* "neighbor route-reflector" commands.*/ | |
19254 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
19255 | install_element(BGP_NODE, | |
19256 | &no_neighbor_route_reflector_client_hidden_cmd); | |
19257 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
19258 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
19259 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
19260 | install_element(BGP_IPV4M_NODE, | |
19261 | &no_neighbor_route_reflector_client_cmd); | |
19262 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
19263 | install_element(BGP_IPV4L_NODE, | |
19264 | &no_neighbor_route_reflector_client_cmd); | |
19265 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
19266 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
19267 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
19268 | install_element(BGP_IPV6M_NODE, | |
19269 | &no_neighbor_route_reflector_client_cmd); | |
19270 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
19271 | install_element(BGP_IPV6L_NODE, | |
19272 | &no_neighbor_route_reflector_client_cmd); | |
19273 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
19274 | install_element(BGP_VPNV4_NODE, | |
19275 | &no_neighbor_route_reflector_client_cmd); | |
19276 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
19277 | install_element(BGP_VPNV6_NODE, | |
19278 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 19279 | install_element(BGP_FLOWSPECV4_NODE, |
19280 | &neighbor_route_reflector_client_cmd); | |
19281 | install_element(BGP_FLOWSPECV4_NODE, | |
19282 | &no_neighbor_route_reflector_client_cmd); | |
19283 | install_element(BGP_FLOWSPECV6_NODE, | |
19284 | &neighbor_route_reflector_client_cmd); | |
19285 | install_element(BGP_FLOWSPECV6_NODE, | |
19286 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 19287 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
19288 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
19289 | ||
70cd87ca MK |
19290 | /* "optimal-route-reflection" commands */ |
19291 | install_element(BGP_IPV4_NODE, &optimal_route_reflection_cmd); | |
19292 | install_element(BGP_IPV4M_NODE, &optimal_route_reflection_cmd); | |
19293 | install_element(BGP_IPV4L_NODE, &optimal_route_reflection_cmd); | |
19294 | install_element(BGP_IPV6_NODE, &optimal_route_reflection_cmd); | |
19295 | install_element(BGP_IPV6M_NODE, &optimal_route_reflection_cmd); | |
19296 | install_element(BGP_IPV6L_NODE, &optimal_route_reflection_cmd); | |
19297 | install_element(BGP_VPNV4_NODE, &optimal_route_reflection_cmd); | |
19298 | install_element(BGP_VPNV6_NODE, &optimal_route_reflection_cmd); | |
19299 | install_element(BGP_FLOWSPECV4_NODE, &optimal_route_reflection_cmd); | |
19300 | install_element(BGP_FLOWSPECV6_NODE, &optimal_route_reflection_cmd); | |
19301 | install_element(BGP_EVPN_NODE, &optimal_route_reflection_cmd); | |
19302 | ||
19303 | /* "neighbor optimal-route-reflection" commands */ | |
19304 | install_element(BGP_IPV4_NODE, &neighbor_optimal_route_reflection_cmd); | |
19305 | install_element(BGP_IPV4M_NODE, &neighbor_optimal_route_reflection_cmd); | |
19306 | install_element(BGP_IPV4L_NODE, &neighbor_optimal_route_reflection_cmd); | |
19307 | install_element(BGP_IPV6_NODE, &neighbor_optimal_route_reflection_cmd); | |
19308 | install_element(BGP_IPV6M_NODE, &neighbor_optimal_route_reflection_cmd); | |
19309 | install_element(BGP_IPV6L_NODE, &neighbor_optimal_route_reflection_cmd); | |
19310 | install_element(BGP_VPNV4_NODE, &neighbor_optimal_route_reflection_cmd); | |
19311 | install_element(BGP_VPNV6_NODE, &neighbor_optimal_route_reflection_cmd); | |
19312 | install_element(BGP_FLOWSPECV4_NODE, | |
19313 | &neighbor_optimal_route_reflection_cmd); | |
19314 | install_element(BGP_FLOWSPECV6_NODE, | |
19315 | &neighbor_optimal_route_reflection_cmd); | |
19316 | install_element(BGP_EVPN_NODE, &neighbor_optimal_route_reflection_cmd); | |
19317 | ||
d62a17ae | 19318 | /* "neighbor route-server" commands.*/ |
19319 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
19320 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
19321 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
19322 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
19323 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
19324 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
19325 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
19326 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
19327 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
19328 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
19329 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
19330 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
19331 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
19332 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
19333 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
19334 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
19335 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
19336 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
19337 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
19338 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 19339 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
19340 | install_element(BGP_FLOWSPECV4_NODE, | |
19341 | &no_neighbor_route_server_client_cmd); | |
19342 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
19343 | install_element(BGP_FLOWSPECV6_NODE, | |
19344 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 19345 | |
7c0e4312 DA |
19346 | /* "neighbor disable-addpath-rx" commands. */ |
19347 | install_element(BGP_IPV4_NODE, &neighbor_disable_addpath_rx_cmd); | |
19348 | install_element(BGP_IPV4_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19349 | install_element(BGP_IPV4M_NODE, &neighbor_disable_addpath_rx_cmd); | |
19350 | install_element(BGP_IPV4M_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19351 | install_element(BGP_IPV4L_NODE, &neighbor_disable_addpath_rx_cmd); | |
19352 | install_element(BGP_IPV4L_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19353 | install_element(BGP_IPV6_NODE, &neighbor_disable_addpath_rx_cmd); | |
19354 | install_element(BGP_IPV6_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19355 | install_element(BGP_IPV6M_NODE, &neighbor_disable_addpath_rx_cmd); | |
19356 | install_element(BGP_IPV6M_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19357 | install_element(BGP_IPV6L_NODE, &neighbor_disable_addpath_rx_cmd); | |
19358 | install_element(BGP_IPV6L_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19359 | install_element(BGP_VPNV4_NODE, &neighbor_disable_addpath_rx_cmd); | |
19360 | install_element(BGP_VPNV4_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19361 | install_element(BGP_VPNV6_NODE, &neighbor_disable_addpath_rx_cmd); | |
19362 | install_element(BGP_VPNV6_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19363 | ||
d62a17ae | 19364 | /* "neighbor addpath-tx-all-paths" commands.*/ |
19365 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
19366 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
19367 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19368 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19369 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19370 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19371 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19372 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19373 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19374 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19375 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19376 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19377 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19378 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19379 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19380 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19381 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19382 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19383 | ||
19384 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
19385 | install_element(BGP_NODE, | |
19386 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
19387 | install_element(BGP_NODE, | |
19388 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
19389 | install_element(BGP_IPV4_NODE, | |
19390 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19391 | install_element(BGP_IPV4_NODE, | |
19392 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19393 | install_element(BGP_IPV4M_NODE, | |
19394 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19395 | install_element(BGP_IPV4M_NODE, | |
19396 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19397 | install_element(BGP_IPV4L_NODE, | |
19398 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19399 | install_element(BGP_IPV4L_NODE, | |
19400 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19401 | install_element(BGP_IPV6_NODE, | |
19402 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19403 | install_element(BGP_IPV6_NODE, | |
19404 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19405 | install_element(BGP_IPV6M_NODE, | |
19406 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19407 | install_element(BGP_IPV6M_NODE, | |
19408 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19409 | install_element(BGP_IPV6L_NODE, | |
19410 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19411 | install_element(BGP_IPV6L_NODE, | |
19412 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19413 | install_element(BGP_VPNV4_NODE, | |
19414 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19415 | install_element(BGP_VPNV4_NODE, | |
19416 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19417 | install_element(BGP_VPNV6_NODE, | |
19418 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19419 | install_element(BGP_VPNV6_NODE, | |
19420 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19421 | ||
2b31007c RZ |
19422 | /* "neighbor sender-as-path-loop-detection" commands. */ |
19423 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
19424 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
19425 | ||
d62a17ae | 19426 | /* "neighbor passive" commands. */ |
19427 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
19428 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
19429 | ||
19430 | ||
19431 | /* "neighbor shutdown" commands. */ | |
19432 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
19433 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
19434 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
19435 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
8336c896 DA |
19436 | install_element(BGP_NODE, &neighbor_shutdown_rtt_cmd); |
19437 | install_element(BGP_NODE, &no_neighbor_shutdown_rtt_cmd); | |
d62a17ae | 19438 | |
19439 | /* "neighbor capability extended-nexthop" commands.*/ | |
19440 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
19441 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
19442 | ||
19443 | /* "neighbor capability orf prefix-list" commands.*/ | |
19444 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
19445 | install_element(BGP_NODE, | |
19446 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
19447 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
19448 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19449 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
19450 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19451 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
19452 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19453 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
19454 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19455 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
19456 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19457 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
19458 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19459 | ||
19460 | /* "neighbor capability dynamic" commands.*/ | |
19461 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
19462 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
19463 | ||
19464 | /* "neighbor dont-capability-negotiate" commands. */ | |
19465 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
19466 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
19467 | ||
19468 | /* "neighbor ebgp-multihop" commands. */ | |
19469 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
19470 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
19471 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
19472 | ||
19473 | /* "neighbor disable-connected-check" commands. */ | |
19474 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
19475 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
19476 | ||
7ab294ea DA |
19477 | /* "neighbor disable-link-bw-encoding-ieee" commands. */ |
19478 | install_element(BGP_NODE, &neighbor_disable_link_bw_encoding_ieee_cmd); | |
19479 | install_element(BGP_NODE, | |
19480 | &no_neighbor_disable_link_bw_encoding_ieee_cmd); | |
27aa23a4 | 19481 | |
d08c0c80 DA |
19482 | /* "neighbor extended-optional-parameters" commands. */ |
19483 | install_element(BGP_NODE, &neighbor_extended_optional_parameters_cmd); | |
19484 | install_element(BGP_NODE, | |
19485 | &no_neighbor_extended_optional_parameters_cmd); | |
19486 | ||
47cbc09b PM |
19487 | /* "neighbor enforce-first-as" commands. */ |
19488 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
19489 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
19490 | ||
d62a17ae | 19491 | /* "neighbor description" commands. */ |
19492 | install_element(BGP_NODE, &neighbor_description_cmd); | |
19493 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 19494 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 19495 | |
19496 | /* "neighbor update-source" commands. "*/ | |
19497 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
19498 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
19499 | ||
19500 | /* "neighbor default-originate" commands. */ | |
19501 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
19502 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
19503 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
19504 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
19505 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
19506 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
19507 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
19508 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
19509 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
19510 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
19511 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
19512 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
19513 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
19514 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
19515 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
19516 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
19517 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
19518 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
19519 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
19520 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
19521 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
19522 | ||
19523 | /* "neighbor port" commands. */ | |
19524 | install_element(BGP_NODE, &neighbor_port_cmd); | |
19525 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
19526 | ||
19527 | /* "neighbor weight" commands. */ | |
19528 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
19529 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
19530 | ||
19531 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
19532 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
19533 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
19534 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
19535 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
19536 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
19537 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
19538 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
19539 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
19540 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
19541 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
19542 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
19543 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
19544 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
19545 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
19546 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
19547 | ||
19548 | /* "neighbor override-capability" commands. */ | |
19549 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
19550 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
19551 | ||
19552 | /* "neighbor strict-capability-match" commands. */ | |
19553 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
19554 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
19555 | ||
19556 | /* "neighbor timers" commands. */ | |
19557 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
19558 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
19559 | ||
19560 | /* "neighbor timers connect" commands. */ | |
19561 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
19562 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
19563 | ||
d43114f3 DS |
19564 | /* "neighbor timers delayopen" commands. */ |
19565 | install_element(BGP_NODE, &neighbor_timers_delayopen_cmd); | |
19566 | install_element(BGP_NODE, &no_neighbor_timers_delayopen_cmd); | |
19567 | ||
d62a17ae | 19568 | /* "neighbor advertisement-interval" commands. */ |
19569 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
19570 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
19571 | ||
19572 | /* "neighbor interface" commands. */ | |
19573 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
19574 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
19575 | ||
19576 | /* "neighbor distribute" commands. */ | |
19577 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
19578 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
19579 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
19580 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
19581 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
19582 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
19583 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
19584 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
19585 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
19586 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
19587 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
19588 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
19589 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
19590 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
19591 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
19592 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
19593 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
19594 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
19595 | ||
19596 | /* "neighbor prefix-list" commands. */ | |
19597 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
642ef664 | 19598 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); |
d62a17ae | 19599 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19600 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19601 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19602 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19603 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19604 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19605 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19606 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19607 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19608 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19609 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19610 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19611 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19612 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19613 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19614 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); |
7c40bf39 | 19615 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19616 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); |
7c40bf39 | 19617 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19618 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19619 | |
19620 | /* "neighbor filter-list" commands. */ | |
19621 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
19622 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
19623 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
19624 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
19625 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
19626 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
19627 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
19628 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
19629 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
19630 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
19631 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
19632 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
19633 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
19634 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
19635 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
19636 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
19637 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
19638 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 19639 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
19640 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
19641 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
19642 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 19643 | |
19644 | /* "neighbor route-map" commands. */ | |
d6d7ed37 IR |
19645 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); |
19646 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
d62a17ae | 19647 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19648 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19649 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19650 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19651 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19652 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19653 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19654 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19655 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19656 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19657 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19658 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19659 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19660 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19661 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19662 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); |
7c40bf39 | 19663 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19664 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); |
7c40bf39 | 19665 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19666 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); |
d37ba549 | 19667 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19668 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19669 | |
19670 | /* "neighbor unsuppress-map" commands. */ | |
19671 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
19672 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
19673 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
19674 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
19675 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
19676 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
19677 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
19678 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
19679 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
19680 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
19681 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
19682 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
19683 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
19684 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
19685 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
19686 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
19687 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
19688 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
19689 | ||
7f7940e6 | 19690 | /* "neighbor advertise-map" commands. */ |
389e4f92 | 19691 | install_element(BGP_NODE, &bgp_condadv_period_cmd); |
7f7940e6 | 19692 | install_element(BGP_NODE, &neighbor_advertise_map_hidden_cmd); |
7f7940e6 | 19693 | install_element(BGP_IPV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19694 | install_element(BGP_IPV4M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19695 | install_element(BGP_IPV4L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19696 | install_element(BGP_IPV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19697 | install_element(BGP_IPV6M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19698 | install_element(BGP_IPV6L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19699 | install_element(BGP_VPNV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19700 | install_element(BGP_VPNV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19701 | |
fde246e8 DA |
19702 | /* neighbor maximum-prefix-out commands. */ |
19703 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
19704 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19705 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
19706 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19707 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
19708 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19709 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
19710 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19711 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
19712 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19713 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
19714 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19715 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
19716 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19717 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
19718 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19719 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
19720 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19721 | ||
d62a17ae | 19722 | /* "neighbor maximum-prefix" commands. */ |
19723 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
19724 | install_element(BGP_NODE, | |
19725 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
19726 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
19727 | install_element(BGP_NODE, | |
19728 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
19729 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
19730 | install_element(BGP_NODE, | |
19731 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
19732 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
19733 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
19734 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19735 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19736 | install_element(BGP_IPV4_NODE, | |
19737 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19738 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19739 | install_element(BGP_IPV4_NODE, | |
19740 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19741 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
19742 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
19743 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19744 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19745 | install_element(BGP_IPV4M_NODE, | |
19746 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19747 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19748 | install_element(BGP_IPV4M_NODE, | |
19749 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19750 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
19751 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
19752 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19753 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19754 | install_element(BGP_IPV4L_NODE, | |
19755 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19756 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19757 | install_element(BGP_IPV4L_NODE, | |
19758 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19759 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
19760 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
19761 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19762 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19763 | install_element(BGP_IPV6_NODE, | |
19764 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19765 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19766 | install_element(BGP_IPV6_NODE, | |
19767 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19768 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
19769 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
19770 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19771 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19772 | install_element(BGP_IPV6M_NODE, | |
19773 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19774 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19775 | install_element(BGP_IPV6M_NODE, | |
19776 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19777 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
19778 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
19779 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19780 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19781 | install_element(BGP_IPV6L_NODE, | |
19782 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19783 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19784 | install_element(BGP_IPV6L_NODE, | |
19785 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19786 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
19787 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
19788 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19789 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19790 | install_element(BGP_VPNV4_NODE, | |
19791 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19792 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19793 | install_element(BGP_VPNV4_NODE, | |
19794 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19795 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
19796 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
19797 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19798 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19799 | install_element(BGP_VPNV6_NODE, | |
19800 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19801 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19802 | install_element(BGP_VPNV6_NODE, | |
19803 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19804 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
19805 | ||
19806 | /* "neighbor allowas-in" */ | |
19807 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
19808 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
19809 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
19810 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
19811 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
19812 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
19813 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
19814 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
19815 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
19816 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
19817 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
19818 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
19819 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
19820 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
19821 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
19822 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
19823 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
19824 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
19825 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
19826 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
19827 | ||
46dbf9d0 DA |
19828 | /* neighbor accept-own */ |
19829 | install_element(BGP_VPNV4_NODE, &neighbor_accept_own_cmd); | |
19830 | install_element(BGP_VPNV6_NODE, &neighbor_accept_own_cmd); | |
19831 | ||
01da2d26 DA |
19832 | /* "neighbor soo" */ |
19833 | install_element(BGP_IPV4_NODE, &neighbor_soo_cmd); | |
19834 | install_element(BGP_IPV4_NODE, &no_neighbor_soo_cmd); | |
19835 | install_element(BGP_IPV4M_NODE, &neighbor_soo_cmd); | |
19836 | install_element(BGP_IPV4M_NODE, &no_neighbor_soo_cmd); | |
19837 | install_element(BGP_IPV4L_NODE, &neighbor_soo_cmd); | |
19838 | install_element(BGP_IPV4L_NODE, &no_neighbor_soo_cmd); | |
19839 | install_element(BGP_IPV6_NODE, &neighbor_soo_cmd); | |
19840 | install_element(BGP_IPV6_NODE, &no_neighbor_soo_cmd); | |
19841 | install_element(BGP_IPV6M_NODE, &neighbor_soo_cmd); | |
19842 | install_element(BGP_IPV6M_NODE, &no_neighbor_soo_cmd); | |
19843 | install_element(BGP_IPV6L_NODE, &neighbor_soo_cmd); | |
19844 | install_element(BGP_IPV6L_NODE, &no_neighbor_soo_cmd); | |
19845 | install_element(BGP_VPNV4_NODE, &neighbor_soo_cmd); | |
19846 | install_element(BGP_VPNV4_NODE, &no_neighbor_soo_cmd); | |
19847 | install_element(BGP_VPNV6_NODE, &neighbor_soo_cmd); | |
19848 | install_element(BGP_VPNV6_NODE, &no_neighbor_soo_cmd); | |
19849 | install_element(BGP_EVPN_NODE, &neighbor_soo_cmd); | |
19850 | install_element(BGP_EVPN_NODE, &no_neighbor_soo_cmd); | |
19851 | ||
d62a17ae | 19852 | /* address-family commands. */ |
19853 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
19854 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 19855 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 19856 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
19857 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 19858 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 19859 | |
d62a17ae | 19860 | install_element(BGP_NODE, &address_family_evpn_cmd); |
19861 | ||
19862 | /* "exit-address-family" command. */ | |
19863 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
19864 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
19865 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
19866 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
19867 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
19868 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
19869 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
19870 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 19871 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
19872 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 19873 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
19874 | ||
a486300b PG |
19875 | /* BGP retain all route-target */ |
19876 | install_element(BGP_VPNV4_NODE, &bgp_retain_route_target_cmd); | |
19877 | install_element(BGP_VPNV6_NODE, &bgp_retain_route_target_cmd); | |
19878 | ||
d62a17ae | 19879 | /* "clear ip bgp commands" */ |
19880 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
19881 | ||
19882 | /* clear ip bgp prefix */ | |
19883 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
19884 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
19885 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
19886 | ||
19887 | /* "show [ip] bgp summary" commands. */ | |
19888 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 19889 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 19890 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 19891 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 19892 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
19893 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 19894 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
19895 | ||
19896 | /* "show [ip] bgp neighbors" commands. */ | |
19897 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
19898 | ||
36235319 | 19899 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 19900 | |
d62a17ae | 19901 | /* "show [ip] bgp peer-group" commands. */ |
19902 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
19903 | ||
19904 | /* "show [ip] bgp paths" commands. */ | |
19905 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
19906 | ||
19907 | /* "show [ip] bgp community" commands. */ | |
19908 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
19909 | ||
19910 | /* "show ip bgp large-community" commands. */ | |
19911 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
19912 | /* "show [ip] bgp attribute-info" commands. */ | |
19913 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 19914 | /* "show [ip] bgp route-leak" command */ |
19915 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 19916 | |
19917 | /* "redistribute" commands. */ | |
19918 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
19919 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
19920 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
19921 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
19922 | install_element(BGP_NODE, | |
19923 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
19924 | install_element(BGP_NODE, | |
19925 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
19926 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
19927 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
19928 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
19929 | install_element(BGP_NODE, | |
19930 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
19931 | install_element(BGP_NODE, | |
19932 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
19933 | install_element(BGP_NODE, | |
19934 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
19935 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
19936 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
19937 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
19938 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
19939 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
19940 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
19941 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
19942 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
19943 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
19944 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
19945 | install_element(BGP_IPV4_NODE, | |
19946 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
19947 | install_element(BGP_IPV4_NODE, | |
19948 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
19949 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
19950 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
19951 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
19952 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
19953 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
19954 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
19955 | ||
70dd370f | 19956 | /* import|export vpn [route-map RMAP_NAME] */ |
b9c7bc5a PZ |
19957 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); |
19958 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 19959 | |
12a844a5 DS |
19960 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
19961 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
19962 | ||
d62a17ae | 19963 | /* ttl_security commands */ |
19964 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
19965 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
19966 | ||
d1adb448 PG |
19967 | /* "bgp tcp-keepalive" commands */ |
19968 | install_element(BGP_NODE, &bgp_tcp_keepalive_cmd); | |
19969 | install_element(BGP_NODE, &no_bgp_tcp_keepalive_cmd); | |
19970 | ||
d62a17ae | 19971 | /* "show [ip] bgp memory" commands. */ |
19972 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
19973 | ||
acf71666 MK |
19974 | /* "show bgp martian next-hop" */ |
19975 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
19976 | ||
48ecf8f5 DS |
19977 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
19978 | ||
d62a17ae | 19979 | /* "show [ip] bgp views" commands. */ |
19980 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
19981 | ||
19982 | /* "show [ip] bgp vrfs" commands. */ | |
19983 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
19984 | ||
19985 | /* Community-list. */ | |
19986 | community_list_vty(); | |
ddb5b488 | 19987 | |
ed0e57e3 DA |
19988 | community_alias_vty(); |
19989 | ||
ddb5b488 | 19990 | /* vpn-policy commands */ |
b9c7bc5a PZ |
19991 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
19992 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
19993 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
19994 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
19995 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
19996 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
19997 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
19998 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
19999 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
20000 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
20001 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
20002 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 20003 | |
301ad80a PG |
20004 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
20005 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
20006 | ||
b9c7bc5a PZ |
20007 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
20008 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
20009 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
20010 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
20011 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
20012 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
20013 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
20014 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
20015 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
20016 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
4ab46701 AR |
20017 | |
20018 | /* tcp-mss command */ | |
20019 | install_element(BGP_NODE, &neighbor_tcp_mss_cmd); | |
20020 | install_element(BGP_NODE, &no_neighbor_tcp_mss_cmd); | |
bfaab44d HS |
20021 | |
20022 | /* srv6 commands */ | |
ea372e81 | 20023 | install_element(VIEW_NODE, &show_bgp_srv6_cmd); |
bfaab44d | 20024 | install_element(BGP_NODE, &bgp_segment_routing_srv6_cmd); |
0249b8b6 | 20025 | install_element(BGP_NODE, &no_bgp_segment_routing_srv6_cmd); |
a0281b2e | 20026 | install_element(BGP_SRV6_NODE, &bgp_srv6_locator_cmd); |
0249b8b6 | 20027 | install_element(BGP_SRV6_NODE, &no_bgp_srv6_locator_cmd); |
b72c9e14 HS |
20028 | install_element(BGP_IPV4_NODE, &af_sid_vpn_export_cmd); |
20029 | install_element(BGP_IPV6_NODE, &af_sid_vpn_export_cmd); | |
527588aa | 20030 | install_element(BGP_NODE, &bgp_sid_vpn_export_cmd); |
e606d8ec | 20031 | install_element(BGP_NODE, &no_bgp_sid_vpn_export_cmd); |
4cd690ae PG |
20032 | |
20033 | bgp_vty_if_init(); | |
718e3744 | 20034 | } |
6b0655a2 | 20035 | |
718e3744 | 20036 | #include "memory.h" |
20037 | #include "bgp_regex.h" | |
20038 | #include "bgp_clist.h" | |
20039 | #include "bgp_ecommunity.h" | |
20040 | ||
20041 | /* VTY functions. */ | |
20042 | ||
20043 | /* Direction value to string conversion. */ | |
d62a17ae | 20044 | static const char *community_direct_str(int direct) |
20045 | { | |
20046 | switch (direct) { | |
20047 | case COMMUNITY_DENY: | |
20048 | return "deny"; | |
20049 | case COMMUNITY_PERMIT: | |
20050 | return "permit"; | |
20051 | default: | |
20052 | return "unknown"; | |
20053 | } | |
718e3744 | 20054 | } |
20055 | ||
20056 | /* Display error string. */ | |
d62a17ae | 20057 | static void community_list_perror(struct vty *vty, int ret) |
20058 | { | |
20059 | switch (ret) { | |
20060 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
20061 | vty_out(vty, "%% Can't find community-list\n"); | |
20062 | break; | |
20063 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
20064 | vty_out(vty, "%% Malformed community-list value\n"); | |
20065 | break; | |
20066 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
20067 | vty_out(vty, | |
20068 | "%% Community name conflict, previously defined as standard community\n"); | |
20069 | break; | |
20070 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
20071 | vty_out(vty, | |
20072 | "%% Community name conflict, previously defined as expanded community\n"); | |
20073 | break; | |
20074 | } | |
718e3744 | 20075 | } |
20076 | ||
5bf15956 DW |
20077 | /* "community-list" keyword help string. */ |
20078 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
20079 | ||
7336e101 SP |
20080 | /*community-list standard */ |
20081 | DEFUN (community_list_standard, | |
20082 | bgp_community_list_standard_cmd, | |
a2099c1d | 20083 | "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 20084 | BGP_STR |
718e3744 | 20085 | COMMUNITY_LIST_STR |
20086 | "Community list number (standard)\n" | |
5bf15956 | 20087 | "Add an standard community-list entry\n" |
718e3744 | 20088 | "Community list name\n" |
2f8cc0e5 DA |
20089 | "Sequence number of an entry\n" |
20090 | "Sequence number\n" | |
718e3744 | 20091 | "Specify community to reject\n" |
20092 | "Specify community to accept\n" | |
20093 | COMMUNITY_VAL_STR) | |
20094 | { | |
d62a17ae | 20095 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 20096 | char *seq = NULL; |
d62a17ae | 20097 | int direct = 0; |
20098 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 20099 | int idx = 0; |
7336e101 | 20100 | |
e34627f9 | 20101 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20102 | seq = argv[idx]->arg; |
20103 | ||
20104 | idx = 0; | |
d62a17ae | 20105 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 20106 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20107 | cl_name_or_number = argv[idx]->arg; |
20108 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
20109 | : COMMUNITY_DENY; | |
20110 | argv_find(argv, argc, "AA:NN", &idx); | |
20111 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 20112 | |
2f8cc0e5 DA |
20113 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
20114 | direct, style); | |
42f914d4 | 20115 | |
d62a17ae | 20116 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20117 | |
d62a17ae | 20118 | if (ret < 0) { |
20119 | /* Display error string. */ | |
20120 | community_list_perror(vty, ret); | |
20121 | return CMD_WARNING_CONFIG_FAILED; | |
20122 | } | |
42f914d4 | 20123 | |
d62a17ae | 20124 | return CMD_SUCCESS; |
718e3744 | 20125 | } |
20126 | ||
7336e101 SP |
20127 | DEFUN (no_community_list_standard_all, |
20128 | no_bgp_community_list_standard_all_cmd, | |
a2099c1d | 20129 | "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
20130 | NO_STR |
20131 | BGP_STR | |
20132 | COMMUNITY_LIST_STR | |
20133 | "Community list number (standard)\n" | |
20134 | "Add an standard community-list entry\n" | |
20135 | "Community list name\n" | |
2f8cc0e5 DA |
20136 | "Sequence number of an entry\n" |
20137 | "Sequence number\n" | |
7336e101 SP |
20138 | "Specify community to reject\n" |
20139 | "Specify community to accept\n" | |
20140 | COMMUNITY_VAL_STR) | |
718e3744 | 20141 | { |
d62a17ae | 20142 | char *cl_name_or_number = NULL; |
174b5cb9 | 20143 | char *str = NULL; |
d62a17ae | 20144 | int direct = 0; |
20145 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 20146 | char *seq = NULL; |
d62a17ae | 20147 | int idx = 0; |
7336e101 | 20148 | |
e34627f9 | 20149 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20150 | seq = argv[idx]->arg; |
20151 | ||
20152 | idx = 0; | |
174b5cb9 DA |
20153 | argv_find(argv, argc, "permit", &idx); |
20154 | argv_find(argv, argc, "deny", &idx); | |
20155 | ||
20156 | if (idx) { | |
20157 | direct = argv_find(argv, argc, "permit", &idx) | |
20158 | ? COMMUNITY_PERMIT | |
20159 | : COMMUNITY_DENY; | |
20160 | ||
20161 | idx = 0; | |
20162 | argv_find(argv, argc, "AA:NN", &idx); | |
20163 | str = argv_concat(argv, argc, idx); | |
20164 | } | |
20165 | ||
20166 | idx = 0; | |
d62a17ae | 20167 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 20168 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20169 | cl_name_or_number = argv[idx]->arg; |
42f914d4 | 20170 | |
2f8cc0e5 | 20171 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 20172 | direct, style); |
42f914d4 | 20173 | |
d62a17ae | 20174 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 20175 | |
d62a17ae | 20176 | if (ret < 0) { |
20177 | community_list_perror(vty, ret); | |
20178 | return CMD_WARNING_CONFIG_FAILED; | |
20179 | } | |
42f914d4 | 20180 | |
d62a17ae | 20181 | return CMD_SUCCESS; |
718e3744 | 20182 | } |
7336e101 | 20183 | |
174b5cb9 | 20184 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
a2099c1d | 20185 | "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>", |
174b5cb9 DA |
20186 | NO_STR BGP_STR COMMUNITY_LIST_STR |
20187 | "Community list number (standard)\n" | |
20188 | "Add an standard community-list entry\n" | |
20189 | "Community list name\n") | |
20190 | ||
7336e101 SP |
20191 | /*community-list expanded */ |
20192 | DEFUN (community_list_expanded_all, | |
20193 | bgp_community_list_expanded_all_cmd, | |
a2099c1d | 20194 | "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
20195 | BGP_STR |
20196 | COMMUNITY_LIST_STR | |
718e3744 | 20197 | "Community list number (expanded)\n" |
5bf15956 | 20198 | "Add an expanded community-list entry\n" |
718e3744 | 20199 | "Community list name\n" |
2f8cc0e5 DA |
20200 | "Sequence number of an entry\n" |
20201 | "Sequence number\n" | |
718e3744 | 20202 | "Specify community to reject\n" |
20203 | "Specify community to accept\n" | |
20204 | COMMUNITY_VAL_STR) | |
20205 | { | |
d62a17ae | 20206 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 20207 | char *seq = NULL; |
d62a17ae | 20208 | int direct = 0; |
20209 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 20210 | int idx = 0; |
7b9a4750 | 20211 | |
e34627f9 | 20212 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20213 | seq = argv[idx]->arg; |
20214 | ||
20215 | idx = 0; | |
20216 | ||
d62a17ae | 20217 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 20218 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20219 | cl_name_or_number = argv[idx]->arg; |
20220 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
20221 | : COMMUNITY_DENY; | |
20222 | argv_find(argv, argc, "AA:NN", &idx); | |
20223 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 20224 | |
2f8cc0e5 DA |
20225 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
20226 | direct, style); | |
42f914d4 | 20227 | |
d62a17ae | 20228 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20229 | |
d62a17ae | 20230 | if (ret < 0) { |
20231 | /* Display error string. */ | |
20232 | community_list_perror(vty, ret); | |
20233 | return CMD_WARNING_CONFIG_FAILED; | |
20234 | } | |
42f914d4 | 20235 | |
d62a17ae | 20236 | return CMD_SUCCESS; |
718e3744 | 20237 | } |
20238 | ||
7336e101 SP |
20239 | DEFUN (no_community_list_expanded_all, |
20240 | no_bgp_community_list_expanded_all_cmd, | |
a2099c1d | 20241 | "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
20242 | NO_STR |
20243 | BGP_STR | |
20244 | COMMUNITY_LIST_STR | |
20245 | "Community list number (expanded)\n" | |
20246 | "Add an expanded community-list entry\n" | |
20247 | "Community list name\n" | |
2f8cc0e5 DA |
20248 | "Sequence number of an entry\n" |
20249 | "Sequence number\n" | |
7336e101 SP |
20250 | "Specify community to reject\n" |
20251 | "Specify community to accept\n" | |
20252 | COMMUNITY_VAL_STR) | |
718e3744 | 20253 | { |
d62a17ae | 20254 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 20255 | char *seq = NULL; |
174b5cb9 | 20256 | char *str = NULL; |
d62a17ae | 20257 | int direct = 0; |
20258 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 20259 | int idx = 0; |
174b5cb9 | 20260 | |
e34627f9 | 20261 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20262 | seq = argv[idx]->arg; |
20263 | ||
20264 | idx = 0; | |
174b5cb9 DA |
20265 | argv_find(argv, argc, "permit", &idx); |
20266 | argv_find(argv, argc, "deny", &idx); | |
20267 | ||
20268 | if (idx) { | |
20269 | direct = argv_find(argv, argc, "permit", &idx) | |
20270 | ? COMMUNITY_PERMIT | |
20271 | : COMMUNITY_DENY; | |
20272 | ||
20273 | idx = 0; | |
20274 | argv_find(argv, argc, "AA:NN", &idx); | |
20275 | str = argv_concat(argv, argc, idx); | |
7336e101 | 20276 | } |
174b5cb9 DA |
20277 | |
20278 | idx = 0; | |
d62a17ae | 20279 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 20280 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20281 | cl_name_or_number = argv[idx]->arg; |
42f914d4 | 20282 | |
2f8cc0e5 | 20283 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 20284 | direct, style); |
42f914d4 | 20285 | |
d62a17ae | 20286 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 20287 | |
d62a17ae | 20288 | if (ret < 0) { |
20289 | community_list_perror(vty, ret); | |
20290 | return CMD_WARNING_CONFIG_FAILED; | |
20291 | } | |
42f914d4 | 20292 | |
d62a17ae | 20293 | return CMD_SUCCESS; |
718e3744 | 20294 | } |
20295 | ||
36d4bb44 EB |
20296 | ALIAS(no_community_list_expanded_all, |
20297 | no_bgp_community_list_expanded_all_list_cmd, | |
a2099c1d | 20298 | "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>", |
36d4bb44 | 20299 | NO_STR BGP_STR COMMUNITY_LIST_STR |
174b5cb9 DA |
20300 | "Community list number (expanded)\n" |
20301 | "Add an expanded community-list entry\n" | |
20302 | "Community list name\n") | |
20303 | ||
8d9b8ed9 PM |
20304 | /* Return configuration string of community-list entry. */ |
20305 | static const char *community_list_config_str(struct community_entry *entry) | |
20306 | { | |
20307 | const char *str; | |
20308 | ||
20309 | if (entry->any) | |
20310 | str = ""; | |
20311 | else { | |
20312 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
c0945b78 | 20313 | str = community_str(entry->u.com, false, false); |
8d9b8ed9 | 20314 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) |
c0945b78 | 20315 | str = lcommunity_str(entry->u.lcom, false, false); |
8d9b8ed9 PM |
20316 | else |
20317 | str = entry->config; | |
20318 | } | |
20319 | return str; | |
20320 | } | |
20321 | ||
d62a17ae | 20322 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 20323 | { |
d62a17ae | 20324 | struct community_entry *entry; |
718e3744 | 20325 | |
d62a17ae | 20326 | for (entry = list->head; entry; entry = entry->next) { |
20327 | if (entry == list->head) { | |
20328 | if (all_digit(list->name)) | |
20329 | vty_out(vty, "Community %s list %s\n", | |
20330 | entry->style == COMMUNITY_LIST_STANDARD | |
20331 | ? "standard" | |
20332 | : "(expanded) access", | |
20333 | list->name); | |
20334 | else | |
20335 | vty_out(vty, "Named Community %s list %s\n", | |
20336 | entry->style == COMMUNITY_LIST_STANDARD | |
20337 | ? "standard" | |
20338 | : "expanded", | |
20339 | list->name); | |
20340 | } | |
20341 | if (entry->any) | |
20342 | vty_out(vty, " %s\n", | |
20343 | community_direct_str(entry->direct)); | |
20344 | else | |
20345 | vty_out(vty, " %s %s\n", | |
20346 | community_direct_str(entry->direct), | |
8d9b8ed9 | 20347 | community_list_config_str(entry)); |
d62a17ae | 20348 | } |
718e3744 | 20349 | } |
20350 | ||
7336e101 SP |
20351 | DEFUN (show_community_list, |
20352 | show_bgp_community_list_cmd, | |
20353 | "show bgp community-list", | |
718e3744 | 20354 | SHOW_STR |
7336e101 | 20355 | BGP_STR |
718e3744 | 20356 | "List community-list\n") |
20357 | { | |
d62a17ae | 20358 | struct community_list *list; |
20359 | struct community_list_master *cm; | |
718e3744 | 20360 | |
d62a17ae | 20361 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
20362 | if (!cm) | |
20363 | return CMD_SUCCESS; | |
718e3744 | 20364 | |
d62a17ae | 20365 | for (list = cm->num.head; list; list = list->next) |
20366 | community_list_show(vty, list); | |
718e3744 | 20367 | |
d62a17ae | 20368 | for (list = cm->str.head; list; list = list->next) |
20369 | community_list_show(vty, list); | |
718e3744 | 20370 | |
d62a17ae | 20371 | return CMD_SUCCESS; |
718e3744 | 20372 | } |
20373 | ||
7336e101 SP |
20374 | DEFUN (show_community_list_arg, |
20375 | show_bgp_community_list_arg_cmd, | |
a2099c1d | 20376 | "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail", |
7336e101 SP |
20377 | SHOW_STR |
20378 | BGP_STR | |
718e3744 | 20379 | "List community-list\n" |
20380 | "Community-list number\n" | |
960b69b9 | 20381 | "Community-list name\n" |
20382 | "Detailed information on community-list\n") | |
718e3744 | 20383 | { |
d62a17ae | 20384 | int idx_comm_list = 3; |
20385 | struct community_list *list; | |
718e3744 | 20386 | |
e237b0d2 | 20387 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 20388 | COMMUNITY_LIST_MASTER); |
20389 | if (!list) { | |
20390 | vty_out(vty, "%% Can't find community-list\n"); | |
20391 | return CMD_WARNING; | |
20392 | } | |
718e3744 | 20393 | |
d62a17ae | 20394 | community_list_show(vty, list); |
718e3744 | 20395 | |
d62a17ae | 20396 | return CMD_SUCCESS; |
718e3744 | 20397 | } |
6b0655a2 | 20398 | |
57d187bc JS |
20399 | /* |
20400 | * Large Community code. | |
20401 | */ | |
d62a17ae | 20402 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
20403 | struct cmd_token **argv, int style, | |
20404 | int reject_all_digit_name) | |
20405 | { | |
20406 | int ret; | |
20407 | int direct; | |
20408 | char *str; | |
20409 | int idx = 0; | |
20410 | char *cl_name; | |
2f8cc0e5 DA |
20411 | char *seq = NULL; |
20412 | ||
a08032fe | 20413 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 | 20414 | seq = argv[idx]->arg; |
d62a17ae | 20415 | |
2f8cc0e5 | 20416 | idx = 0; |
d62a17ae | 20417 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
20418 | : COMMUNITY_DENY; | |
20419 | ||
20420 | /* All digit name check. */ | |
20421 | idx = 0; | |
a2099c1d | 20422 | argv_find(argv, argc, "LCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20423 | argv_find(argv, argc, "(1-99)", &idx); |
20424 | argv_find(argv, argc, "(100-500)", &idx); | |
20425 | cl_name = argv[idx]->arg; | |
20426 | if (reject_all_digit_name && all_digit(cl_name)) { | |
20427 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
20428 | return CMD_WARNING_CONFIG_FAILED; | |
20429 | } | |
20430 | ||
20431 | idx = 0; | |
20432 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
20433 | argv_find(argv, argc, "LINE", &idx); | |
20434 | /* Concat community string argument. */ | |
20435 | if (idx) | |
20436 | str = argv_concat(argv, argc, idx); | |
20437 | else | |
20438 | str = NULL; | |
20439 | ||
2f8cc0e5 | 20440 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 20441 | |
20442 | /* Free temporary community list string allocated by | |
20443 | argv_concat(). */ | |
0a22ddfb | 20444 | XFREE(MTYPE_TMP, str); |
d62a17ae | 20445 | |
20446 | if (ret < 0) { | |
20447 | community_list_perror(vty, ret); | |
20448 | return CMD_WARNING_CONFIG_FAILED; | |
20449 | } | |
20450 | return CMD_SUCCESS; | |
20451 | } | |
20452 | ||
20453 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
20454 | struct cmd_token **argv, int style) | |
20455 | { | |
20456 | int ret; | |
20457 | int direct = 0; | |
20458 | char *str = NULL; | |
20459 | int idx = 0; | |
2f8cc0e5 | 20460 | char *seq = NULL; |
d62a17ae | 20461 | |
a08032fe | 20462 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 | 20463 | seq = argv[idx]->arg; |
d62a17ae | 20464 | |
2f8cc0e5 | 20465 | idx = 0; |
d62a17ae | 20466 | argv_find(argv, argc, "permit", &idx); |
20467 | argv_find(argv, argc, "deny", &idx); | |
20468 | ||
20469 | if (idx) { | |
20470 | /* Check the list direct. */ | |
20471 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
20472 | direct = COMMUNITY_PERMIT; | |
20473 | else | |
20474 | direct = COMMUNITY_DENY; | |
20475 | ||
20476 | idx = 0; | |
20477 | argv_find(argv, argc, "LINE", &idx); | |
20478 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
20479 | /* Concat community string argument. */ | |
20480 | str = argv_concat(argv, argc, idx); | |
20481 | } | |
20482 | ||
20483 | idx = 0; | |
20484 | argv_find(argv, argc, "(1-99)", &idx); | |
20485 | argv_find(argv, argc, "(100-500)", &idx); | |
a2099c1d | 20486 | argv_find(argv, argc, "LCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20487 | |
20488 | /* Unset community list. */ | |
2f8cc0e5 | 20489 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 20490 | style); |
20491 | ||
20492 | /* Free temporary community list string allocated by | |
20493 | argv_concat(). */ | |
0a22ddfb | 20494 | XFREE(MTYPE_TMP, str); |
d62a17ae | 20495 | |
20496 | if (ret < 0) { | |
20497 | community_list_perror(vty, ret); | |
20498 | return CMD_WARNING_CONFIG_FAILED; | |
20499 | } | |
20500 | ||
20501 | return CMD_SUCCESS; | |
57d187bc JS |
20502 | } |
20503 | ||
20504 | /* "large-community-list" keyword help string. */ | |
20505 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
20506 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
20507 | ||
7336e101 SP |
20508 | DEFUN (lcommunity_list_standard, |
20509 | bgp_lcommunity_list_standard_cmd, | |
a08032fe | 20510 | "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
20511 | BGP_STR |
20512 | LCOMMUNITY_LIST_STR | |
20513 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
20514 | "Sequence number of an entry\n" |
20515 | "Sequence number\n" | |
7336e101 SP |
20516 | "Specify large community to reject\n" |
20517 | "Specify large community to accept\n" | |
20518 | LCOMMUNITY_VAL_STR) | |
52951b63 | 20519 | { |
d62a17ae | 20520 | return lcommunity_list_set_vty(vty, argc, argv, |
20521 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
20522 | } |
20523 | ||
7336e101 SP |
20524 | DEFUN (lcommunity_list_expanded, |
20525 | bgp_lcommunity_list_expanded_cmd, | |
a08032fe | 20526 | "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20527 | BGP_STR |
20528 | LCOMMUNITY_LIST_STR | |
20529 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
20530 | "Sequence number of an entry\n" |
20531 | "Sequence number\n" | |
7336e101 SP |
20532 | "Specify large community to reject\n" |
20533 | "Specify large community to accept\n" | |
20534 | "An ordered list as a regular-expression\n") | |
57d187bc | 20535 | { |
d62a17ae | 20536 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 20537 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
20538 | } |
20539 | ||
7336e101 SP |
20540 | DEFUN (lcommunity_list_name_standard, |
20541 | bgp_lcommunity_list_name_standard_cmd, | |
a2099c1d | 20542 | "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
20543 | BGP_STR |
20544 | LCOMMUNITY_LIST_STR | |
20545 | "Specify standard large-community-list\n" | |
20546 | "Large Community list name\n" | |
2f8cc0e5 DA |
20547 | "Sequence number of an entry\n" |
20548 | "Sequence number\n" | |
7336e101 SP |
20549 | "Specify large community to reject\n" |
20550 | "Specify large community to accept\n" | |
20551 | LCOMMUNITY_VAL_STR) | |
52951b63 | 20552 | { |
d62a17ae | 20553 | return lcommunity_list_set_vty(vty, argc, argv, |
20554 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
20555 | } |
20556 | ||
7336e101 SP |
20557 | DEFUN (lcommunity_list_name_expanded, |
20558 | bgp_lcommunity_list_name_expanded_cmd, | |
a2099c1d | 20559 | "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20560 | BGP_STR |
20561 | LCOMMUNITY_LIST_STR | |
20562 | "Specify expanded large-community-list\n" | |
20563 | "Large Community list name\n" | |
2f8cc0e5 DA |
20564 | "Sequence number of an entry\n" |
20565 | "Sequence number\n" | |
7336e101 SP |
20566 | "Specify large community to reject\n" |
20567 | "Specify large community to accept\n" | |
20568 | "An ordered list as a regular-expression\n") | |
57d187bc | 20569 | { |
d62a17ae | 20570 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 20571 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
20572 | } |
20573 | ||
4378f57c DA |
20574 | DEFUN (no_lcommunity_list_all, |
20575 | no_bgp_lcommunity_list_all_cmd, | |
a2099c1d | 20576 | "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>", |
7336e101 SP |
20577 | NO_STR |
20578 | BGP_STR | |
20579 | LCOMMUNITY_LIST_STR | |
20580 | "Large Community list number (standard)\n" | |
20581 | "Large Community list number (expanded)\n" | |
20582 | "Large Community list name\n") | |
57d187bc | 20583 | { |
7336e101 SP |
20584 | return lcommunity_list_unset_vty(vty, argc, argv, |
20585 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
20586 | } |
20587 | ||
4378f57c DA |
20588 | DEFUN (no_lcommunity_list_name_standard_all, |
20589 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
a2099c1d | 20590 | "no bgp large-community-list standard LCOMMUNITY_LIST_NAME", |
4378f57c DA |
20591 | NO_STR |
20592 | BGP_STR | |
20593 | LCOMMUNITY_LIST_STR | |
20594 | "Specify standard large-community-list\n" | |
20595 | "Large Community list name\n") | |
20596 | { | |
20597 | return lcommunity_list_unset_vty(vty, argc, argv, | |
20598 | LARGE_COMMUNITY_LIST_STANDARD); | |
20599 | } | |
20600 | ||
7336e101 SP |
20601 | DEFUN (no_lcommunity_list_name_expanded_all, |
20602 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
a2099c1d | 20603 | "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME", |
7336e101 SP |
20604 | NO_STR |
20605 | BGP_STR | |
20606 | LCOMMUNITY_LIST_STR | |
20607 | "Specify expanded large-community-list\n" | |
20608 | "Large Community list name\n") | |
57d187bc | 20609 | { |
d62a17ae | 20610 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20611 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
20612 | } |
20613 | ||
7336e101 SP |
20614 | DEFUN (no_lcommunity_list_standard, |
20615 | no_bgp_lcommunity_list_standard_cmd, | |
a08032fe | 20616 | "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
20617 | NO_STR |
20618 | BGP_STR | |
20619 | LCOMMUNITY_LIST_STR | |
20620 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
20621 | "Sequence number of an entry\n" |
20622 | "Sequence number\n" | |
7336e101 SP |
20623 | "Specify large community to reject\n" |
20624 | "Specify large community to accept\n" | |
20625 | LCOMMUNITY_VAL_STR) | |
57d187bc | 20626 | { |
d62a17ae | 20627 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20628 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
20629 | } |
20630 | ||
7336e101 SP |
20631 | DEFUN (no_lcommunity_list_expanded, |
20632 | no_bgp_lcommunity_list_expanded_cmd, | |
a08032fe | 20633 | "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20634 | NO_STR |
20635 | BGP_STR | |
20636 | LCOMMUNITY_LIST_STR | |
20637 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
20638 | "Sequence number of an entry\n" |
20639 | "Sequence number\n" | |
7336e101 SP |
20640 | "Specify large community to reject\n" |
20641 | "Specify large community to accept\n" | |
20642 | "An ordered list as a regular-expression\n") | |
57d187bc | 20643 | { |
d62a17ae | 20644 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20645 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
20646 | } |
20647 | ||
7336e101 SP |
20648 | DEFUN (no_lcommunity_list_name_standard, |
20649 | no_bgp_lcommunity_list_name_standard_cmd, | |
a2099c1d | 20650 | "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
20651 | NO_STR |
20652 | BGP_STR | |
20653 | LCOMMUNITY_LIST_STR | |
20654 | "Specify standard large-community-list\n" | |
20655 | "Large Community list name\n" | |
2f8cc0e5 DA |
20656 | "Sequence number of an entry\n" |
20657 | "Sequence number\n" | |
7336e101 SP |
20658 | "Specify large community to reject\n" |
20659 | "Specify large community to accept\n" | |
20660 | LCOMMUNITY_VAL_STR) | |
57d187bc | 20661 | { |
d62a17ae | 20662 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20663 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
20664 | } |
20665 | ||
7336e101 SP |
20666 | DEFUN (no_lcommunity_list_name_expanded, |
20667 | no_bgp_lcommunity_list_name_expanded_cmd, | |
a2099c1d | 20668 | "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20669 | NO_STR |
20670 | BGP_STR | |
20671 | LCOMMUNITY_LIST_STR | |
20672 | "Specify expanded large-community-list\n" | |
20673 | "Large community list name\n" | |
2f8cc0e5 DA |
20674 | "Sequence number of an entry\n" |
20675 | "Sequence number\n" | |
7336e101 SP |
20676 | "Specify large community to reject\n" |
20677 | "Specify large community to accept\n" | |
20678 | "An ordered list as a regular-expression\n") | |
57d187bc | 20679 | { |
d62a17ae | 20680 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20681 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
20682 | } |
20683 | ||
d62a17ae | 20684 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
20685 | { | |
20686 | struct community_entry *entry; | |
20687 | ||
20688 | for (entry = list->head; entry; entry = entry->next) { | |
20689 | if (entry == list->head) { | |
20690 | if (all_digit(list->name)) | |
20691 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 20692 | entry->style == |
20693 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 20694 | ? "standard" |
20695 | : "(expanded) access", | |
20696 | list->name); | |
20697 | else | |
20698 | vty_out(vty, | |
20699 | "Named large community %s list %s\n", | |
169b72c8 | 20700 | entry->style == |
20701 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 20702 | ? "standard" |
20703 | : "expanded", | |
20704 | list->name); | |
20705 | } | |
20706 | if (entry->any) | |
20707 | vty_out(vty, " %s\n", | |
20708 | community_direct_str(entry->direct)); | |
20709 | else | |
20710 | vty_out(vty, " %s %s\n", | |
20711 | community_direct_str(entry->direct), | |
8d9b8ed9 | 20712 | community_list_config_str(entry)); |
d62a17ae | 20713 | } |
57d187bc JS |
20714 | } |
20715 | ||
7336e101 SP |
20716 | DEFUN (show_lcommunity_list, |
20717 | show_bgp_lcommunity_list_cmd, | |
20718 | "show bgp large-community-list", | |
57d187bc | 20719 | SHOW_STR |
7336e101 | 20720 | BGP_STR |
57d187bc JS |
20721 | "List large-community list\n") |
20722 | { | |
d62a17ae | 20723 | struct community_list *list; |
20724 | struct community_list_master *cm; | |
57d187bc | 20725 | |
d62a17ae | 20726 | cm = community_list_master_lookup(bgp_clist, |
20727 | LARGE_COMMUNITY_LIST_MASTER); | |
20728 | if (!cm) | |
20729 | return CMD_SUCCESS; | |
57d187bc | 20730 | |
d62a17ae | 20731 | for (list = cm->num.head; list; list = list->next) |
20732 | lcommunity_list_show(vty, list); | |
57d187bc | 20733 | |
d62a17ae | 20734 | for (list = cm->str.head; list; list = list->next) |
20735 | lcommunity_list_show(vty, list); | |
57d187bc | 20736 | |
d62a17ae | 20737 | return CMD_SUCCESS; |
57d187bc JS |
20738 | } |
20739 | ||
7336e101 SP |
20740 | DEFUN (show_lcommunity_list_arg, |
20741 | show_bgp_lcommunity_list_arg_cmd, | |
a2099c1d | 20742 | "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail", |
7336e101 SP |
20743 | SHOW_STR |
20744 | BGP_STR | |
57d187bc | 20745 | "List large-community list\n" |
960b69b9 | 20746 | "Large-community-list number\n" |
20747 | "Large-community-list name\n" | |
20748 | "Detailed information on large-community-list\n") | |
57d187bc | 20749 | { |
d62a17ae | 20750 | struct community_list *list; |
57d187bc | 20751 | |
e237b0d2 | 20752 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 20753 | LARGE_COMMUNITY_LIST_MASTER); |
20754 | if (!list) { | |
960b69b9 | 20755 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 20756 | return CMD_WARNING; |
20757 | } | |
57d187bc | 20758 | |
d62a17ae | 20759 | lcommunity_list_show(vty, list); |
57d187bc | 20760 | |
d62a17ae | 20761 | return CMD_SUCCESS; |
57d187bc JS |
20762 | } |
20763 | ||
718e3744 | 20764 | /* "extcommunity-list" keyword help string. */ |
20765 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
20766 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
20767 | ||
7336e101 SP |
20768 | DEFUN (extcommunity_list_standard, |
20769 | bgp_extcommunity_list_standard_cmd, | |
a2099c1d | 20770 | "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 20771 | BGP_STR |
718e3744 | 20772 | EXTCOMMUNITY_LIST_STR |
20773 | "Extended Community list number (standard)\n" | |
718e3744 | 20774 | "Specify standard extcommunity-list\n" |
5bf15956 | 20775 | "Community list name\n" |
2f8cc0e5 DA |
20776 | "Sequence number of an entry\n" |
20777 | "Sequence number\n" | |
718e3744 | 20778 | "Specify community to reject\n" |
20779 | "Specify community to accept\n" | |
20780 | EXTCOMMUNITY_VAL_STR) | |
20781 | { | |
d62a17ae | 20782 | int style = EXTCOMMUNITY_LIST_STANDARD; |
20783 | int direct = 0; | |
20784 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 20785 | char *seq = NULL; |
42f914d4 | 20786 | |
d62a17ae | 20787 | int idx = 0; |
7b9a4750 | 20788 | |
d62a17ae | 20789 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 20790 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20791 | cl_number_or_name = argv[idx]->arg; |
2f8cc0e5 | 20792 | |
a08032fe | 20793 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20794 | seq = argv[idx]->arg; |
20795 | ||
d62a17ae | 20796 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
20797 | : COMMUNITY_DENY; | |
20798 | argv_find(argv, argc, "AA:NN", &idx); | |
20799 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 20800 | |
2f8cc0e5 | 20801 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 20802 | direct, style); |
42f914d4 | 20803 | |
d62a17ae | 20804 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20805 | |
d62a17ae | 20806 | if (ret < 0) { |
20807 | community_list_perror(vty, ret); | |
20808 | return CMD_WARNING_CONFIG_FAILED; | |
20809 | } | |
42f914d4 | 20810 | |
d62a17ae | 20811 | return CMD_SUCCESS; |
718e3744 | 20812 | } |
20813 | ||
7336e101 SP |
20814 | DEFUN (extcommunity_list_name_expanded, |
20815 | bgp_extcommunity_list_name_expanded_cmd, | |
a2099c1d | 20816 | "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20817 | BGP_STR |
20818 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 20819 | "Extended Community list number (expanded)\n" |
718e3744 | 20820 | "Specify expanded extcommunity-list\n" |
20821 | "Extended Community list name\n" | |
2f8cc0e5 DA |
20822 | "Sequence number of an entry\n" |
20823 | "Sequence number\n" | |
718e3744 | 20824 | "Specify community to reject\n" |
20825 | "Specify community to accept\n" | |
20826 | "An ordered list as a regular-expression\n") | |
20827 | { | |
d62a17ae | 20828 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
20829 | int direct = 0; | |
20830 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 20831 | char *seq = NULL; |
d62a17ae | 20832 | int idx = 0; |
7336e101 | 20833 | |
d62a17ae | 20834 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 20835 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20836 | cl_number_or_name = argv[idx]->arg; |
2f8cc0e5 | 20837 | |
a08032fe | 20838 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20839 | seq = argv[idx]->arg; |
20840 | ||
d62a17ae | 20841 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
20842 | : COMMUNITY_DENY; | |
20843 | argv_find(argv, argc, "LINE", &idx); | |
20844 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 20845 | |
2f8cc0e5 | 20846 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 20847 | direct, style); |
42f914d4 | 20848 | |
d62a17ae | 20849 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20850 | |
d62a17ae | 20851 | if (ret < 0) { |
20852 | community_list_perror(vty, ret); | |
20853 | return CMD_WARNING_CONFIG_FAILED; | |
20854 | } | |
42f914d4 | 20855 | |
d62a17ae | 20856 | return CMD_SUCCESS; |
718e3744 | 20857 | } |
20858 | ||
7336e101 SP |
20859 | DEFUN (no_extcommunity_list_standard_all, |
20860 | no_bgp_extcommunity_list_standard_all_cmd, | |
a2099c1d | 20861 | "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
20862 | NO_STR |
20863 | BGP_STR | |
20864 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 20865 | "Extended Community list number (standard)\n" |
718e3744 | 20866 | "Specify standard extcommunity-list\n" |
5bf15956 | 20867 | "Community list name\n" |
2f8cc0e5 DA |
20868 | "Sequence number of an entry\n" |
20869 | "Sequence number\n" | |
718e3744 | 20870 | "Specify community to reject\n" |
20871 | "Specify community to accept\n" | |
20872 | EXTCOMMUNITY_VAL_STR) | |
20873 | { | |
d62a17ae | 20874 | int style = EXTCOMMUNITY_LIST_STANDARD; |
20875 | int direct = 0; | |
20876 | char *cl_number_or_name = NULL; | |
d4455c89 | 20877 | char *str = NULL; |
2f8cc0e5 | 20878 | char *seq = NULL; |
d62a17ae | 20879 | int idx = 0; |
d4455c89 | 20880 | |
a08032fe | 20881 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20882 | seq = argv[idx]->arg; |
20883 | ||
20884 | idx = 0; | |
d4455c89 DA |
20885 | argv_find(argv, argc, "permit", &idx); |
20886 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
20887 | if (idx) { |
20888 | direct = argv_find(argv, argc, "permit", &idx) | |
20889 | ? COMMUNITY_PERMIT | |
20890 | : COMMUNITY_DENY; | |
20891 | ||
20892 | idx = 0; | |
20893 | argv_find(argv, argc, "AA:NN", &idx); | |
20894 | str = argv_concat(argv, argc, idx); | |
20895 | } | |
20896 | ||
20897 | idx = 0; | |
d62a17ae | 20898 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 20899 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20900 | cl_number_or_name = argv[idx]->arg; |
42f914d4 | 20901 | |
d62a17ae | 20902 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 20903 | seq, direct, style); |
42f914d4 | 20904 | |
d62a17ae | 20905 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20906 | |
d62a17ae | 20907 | if (ret < 0) { |
20908 | community_list_perror(vty, ret); | |
20909 | return CMD_WARNING_CONFIG_FAILED; | |
20910 | } | |
42f914d4 | 20911 | |
d62a17ae | 20912 | return CMD_SUCCESS; |
718e3744 | 20913 | } |
20914 | ||
d4455c89 DA |
20915 | ALIAS(no_extcommunity_list_standard_all, |
20916 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
a2099c1d | 20917 | "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>", |
36d4bb44 | 20918 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
20919 | "Extended Community list number (standard)\n" |
20920 | "Specify standard extcommunity-list\n" | |
20921 | "Community list name\n") | |
20922 | ||
7336e101 SP |
20923 | DEFUN (no_extcommunity_list_expanded_all, |
20924 | no_bgp_extcommunity_list_expanded_all_cmd, | |
a2099c1d | 20925 | "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20926 | NO_STR |
20927 | BGP_STR | |
20928 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 20929 | "Extended Community list number (expanded)\n" |
718e3744 | 20930 | "Specify expanded extcommunity-list\n" |
5bf15956 | 20931 | "Extended Community list name\n" |
2f8cc0e5 DA |
20932 | "Sequence number of an entry\n" |
20933 | "Sequence number\n" | |
718e3744 | 20934 | "Specify community to reject\n" |
20935 | "Specify community to accept\n" | |
20936 | "An ordered list as a regular-expression\n") | |
20937 | { | |
d62a17ae | 20938 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
20939 | int direct = 0; | |
20940 | char *cl_number_or_name = NULL; | |
d4455c89 | 20941 | char *str = NULL; |
2f8cc0e5 | 20942 | char *seq = NULL; |
d62a17ae | 20943 | int idx = 0; |
d4455c89 | 20944 | |
a08032fe | 20945 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20946 | seq = argv[idx]->arg; |
20947 | ||
20948 | idx = 0; | |
d4455c89 DA |
20949 | argv_find(argv, argc, "permit", &idx); |
20950 | argv_find(argv, argc, "deny", &idx); | |
20951 | ||
20952 | if (idx) { | |
20953 | direct = argv_find(argv, argc, "permit", &idx) | |
20954 | ? COMMUNITY_PERMIT | |
20955 | : COMMUNITY_DENY; | |
20956 | ||
20957 | idx = 0; | |
20958 | argv_find(argv, argc, "LINE", &idx); | |
20959 | str = argv_concat(argv, argc, idx); | |
20960 | } | |
20961 | ||
20962 | idx = 0; | |
d62a17ae | 20963 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 20964 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20965 | cl_number_or_name = argv[idx]->arg; |
42f914d4 | 20966 | |
d62a17ae | 20967 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 20968 | seq, direct, style); |
42f914d4 | 20969 | |
d62a17ae | 20970 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20971 | |
d62a17ae | 20972 | if (ret < 0) { |
20973 | community_list_perror(vty, ret); | |
20974 | return CMD_WARNING_CONFIG_FAILED; | |
20975 | } | |
42f914d4 | 20976 | |
d62a17ae | 20977 | return CMD_SUCCESS; |
718e3744 | 20978 | } |
20979 | ||
d4455c89 DA |
20980 | ALIAS(no_extcommunity_list_expanded_all, |
20981 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
a2099c1d | 20982 | "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>", |
36d4bb44 | 20983 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
20984 | "Extended Community list number (expanded)\n" |
20985 | "Specify expanded extcommunity-list\n" | |
20986 | "Extended Community list name\n") | |
20987 | ||
d62a17ae | 20988 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 20989 | { |
d62a17ae | 20990 | struct community_entry *entry; |
718e3744 | 20991 | |
d62a17ae | 20992 | for (entry = list->head; entry; entry = entry->next) { |
20993 | if (entry == list->head) { | |
20994 | if (all_digit(list->name)) | |
20995 | vty_out(vty, "Extended community %s list %s\n", | |
20996 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
20997 | ? "standard" | |
20998 | : "(expanded) access", | |
20999 | list->name); | |
21000 | else | |
21001 | vty_out(vty, | |
21002 | "Named extended community %s list %s\n", | |
21003 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
21004 | ? "standard" | |
21005 | : "expanded", | |
21006 | list->name); | |
21007 | } | |
21008 | if (entry->any) | |
21009 | vty_out(vty, " %s\n", | |
21010 | community_direct_str(entry->direct)); | |
21011 | else | |
21012 | vty_out(vty, " %s %s\n", | |
21013 | community_direct_str(entry->direct), | |
8d9b8ed9 | 21014 | community_list_config_str(entry)); |
d62a17ae | 21015 | } |
718e3744 | 21016 | } |
21017 | ||
7336e101 SP |
21018 | DEFUN (show_extcommunity_list, |
21019 | show_bgp_extcommunity_list_cmd, | |
21020 | "show bgp extcommunity-list", | |
718e3744 | 21021 | SHOW_STR |
7336e101 | 21022 | BGP_STR |
718e3744 | 21023 | "List extended-community list\n") |
21024 | { | |
d62a17ae | 21025 | struct community_list *list; |
21026 | struct community_list_master *cm; | |
718e3744 | 21027 | |
d62a17ae | 21028 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
21029 | if (!cm) | |
21030 | return CMD_SUCCESS; | |
718e3744 | 21031 | |
d62a17ae | 21032 | for (list = cm->num.head; list; list = list->next) |
21033 | extcommunity_list_show(vty, list); | |
718e3744 | 21034 | |
d62a17ae | 21035 | for (list = cm->str.head; list; list = list->next) |
21036 | extcommunity_list_show(vty, list); | |
718e3744 | 21037 | |
d62a17ae | 21038 | return CMD_SUCCESS; |
718e3744 | 21039 | } |
21040 | ||
7336e101 SP |
21041 | DEFUN (show_extcommunity_list_arg, |
21042 | show_bgp_extcommunity_list_arg_cmd, | |
a2099c1d | 21043 | "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail", |
7336e101 SP |
21044 | SHOW_STR |
21045 | BGP_STR | |
718e3744 | 21046 | "List extended-community list\n" |
21047 | "Extcommunity-list number\n" | |
960b69b9 | 21048 | "Extcommunity-list name\n" |
21049 | "Detailed information on extcommunity-list\n") | |
718e3744 | 21050 | { |
d62a17ae | 21051 | int idx_comm_list = 3; |
21052 | struct community_list *list; | |
718e3744 | 21053 | |
e237b0d2 | 21054 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 21055 | EXTCOMMUNITY_LIST_MASTER); |
21056 | if (!list) { | |
21057 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
21058 | return CMD_WARNING; | |
21059 | } | |
718e3744 | 21060 | |
d62a17ae | 21061 | extcommunity_list_show(vty, list); |
718e3744 | 21062 | |
d62a17ae | 21063 | return CMD_SUCCESS; |
718e3744 | 21064 | } |
6b0655a2 | 21065 | |
718e3744 | 21066 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 21067 | static int community_list_config_write(struct vty *vty) |
21068 | { | |
21069 | struct community_list *list; | |
21070 | struct community_entry *entry; | |
21071 | struct community_list_master *cm; | |
21072 | int write = 0; | |
21073 | ||
21074 | /* Community-list. */ | |
21075 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
21076 | ||
21077 | for (list = cm->num.head; list; list = list->next) | |
21078 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
21079 | vty_out(vty, |
21080 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
21081 | list->name, entry->seq, | |
d62a17ae | 21082 | community_direct_str(entry->direct), |
21083 | community_list_config_str(entry)); | |
21084 | write++; | |
21085 | } | |
21086 | for (list = cm->str.head; list; list = list->next) | |
21087 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
21088 | vty_out(vty, |
21089 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 21090 | entry->style == COMMUNITY_LIST_STANDARD |
21091 | ? "standard" | |
21092 | : "expanded", | |
2f8cc0e5 DA |
21093 | list->name, entry->seq, |
21094 | community_direct_str(entry->direct), | |
d62a17ae | 21095 | community_list_config_str(entry)); |
21096 | write++; | |
21097 | } | |
21098 | ||
21099 | /* Extcommunity-list. */ | |
21100 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
21101 | ||
21102 | for (list = cm->num.head; list; list = list->next) | |
21103 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
21104 | vty_out(vty, |
21105 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
21106 | list->name, entry->seq, | |
21107 | community_direct_str(entry->direct), | |
d62a17ae | 21108 | community_list_config_str(entry)); |
21109 | write++; | |
21110 | } | |
21111 | for (list = cm->str.head; list; list = list->next) | |
21112 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 21113 | vty_out(vty, |
6cde4b45 | 21114 | "bgp extcommunity-list %s %s seq %" PRId64" %s %s\n", |
d62a17ae | 21115 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
21116 | ? "standard" | |
21117 | : "expanded", | |
2f8cc0e5 DA |
21118 | list->name, entry->seq, |
21119 | community_direct_str(entry->direct), | |
d62a17ae | 21120 | community_list_config_str(entry)); |
21121 | write++; | |
21122 | } | |
21123 | ||
21124 | ||
21125 | /* lcommunity-list. */ | |
21126 | cm = community_list_master_lookup(bgp_clist, | |
21127 | LARGE_COMMUNITY_LIST_MASTER); | |
21128 | ||
21129 | for (list = cm->num.head; list; list = list->next) | |
21130 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 21131 | vty_out(vty, |
6cde4b45 | 21132 | "bgp large-community-list %s seq %" PRId64" %s %s\n", |
2f8cc0e5 DA |
21133 | list->name, entry->seq, |
21134 | community_direct_str(entry->direct), | |
d62a17ae | 21135 | community_list_config_str(entry)); |
21136 | write++; | |
21137 | } | |
21138 | for (list = cm->str.head; list; list = list->next) | |
21139 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 21140 | vty_out(vty, |
6cde4b45 | 21141 | "bgp large-community-list %s %s seq %" PRId64" %s %s\n", |
2f8cc0e5 | 21142 | |
d62a17ae | 21143 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
21144 | ? "standard" | |
21145 | : "expanded", | |
2f8cc0e5 | 21146 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 21147 | community_list_config_str(entry)); |
21148 | write++; | |
21149 | } | |
21150 | ||
21151 | return write; | |
21152 | } | |
21153 | ||
612c2c15 | 21154 | static int community_list_config_write(struct vty *vty); |
d62a17ae | 21155 | static struct cmd_node community_list_node = { |
f4b8291f | 21156 | .name = "community list", |
62b346ee DL |
21157 | .node = COMMUNITY_LIST_NODE, |
21158 | .prompt = "", | |
612c2c15 | 21159 | .config_write = community_list_config_write, |
718e3744 | 21160 | }; |
21161 | ||
d62a17ae | 21162 | static void community_list_vty(void) |
21163 | { | |
612c2c15 | 21164 | install_node(&community_list_node); |
d62a17ae | 21165 | |
21166 | /* Community-list. */ | |
7336e101 SP |
21167 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
21168 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
21169 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 21170 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 21171 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 21172 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
21173 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
21174 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 21175 | |
21176 | /* Extcommunity-list. */ | |
7336e101 SP |
21177 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
21178 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
21179 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
21180 | install_element(CONFIG_NODE, |
21181 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 21182 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
21183 | install_element(CONFIG_NODE, |
21184 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
21185 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
21186 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 21187 | |
21188 | /* Large Community List */ | |
7336e101 | 21189 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
21190 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
21191 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 21192 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
21193 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
21194 | install_element(CONFIG_NODE, | |
21195 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
21196 | install_element(CONFIG_NODE, |
21197 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
21198 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
21199 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
21200 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
21201 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
21202 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
21203 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
225096bc DA |
21204 | |
21205 | bgp_community_list_command_completion_setup(); | |
5bf15956 | 21206 | } |
ed0e57e3 DA |
21207 | |
21208 | static struct cmd_node community_alias_node = { | |
21209 | .name = "community alias", | |
21210 | .node = COMMUNITY_ALIAS_NODE, | |
21211 | .prompt = "", | |
21212 | .config_write = bgp_community_alias_write, | |
21213 | }; | |
21214 | ||
21215 | void community_alias_vty(void) | |
21216 | { | |
21217 | install_node(&community_alias_node); | |
21218 | ||
21219 | /* Community-list. */ | |
21220 | install_element(CONFIG_NODE, &bgp_community_alias_cmd); | |
b4ad2fae DS |
21221 | |
21222 | bgp_community_alias_command_completion_setup(); | |
ed0e57e3 | 21223 | } |